Browse Source

测试申请页面材料中添加BOM导入功能,将料号对应的BOM信息导入当前测试单

1、bom导入时需要选择对应版本进行导入
            1.1  如果是正式料号,那么需要调用接口获取成本信息
master
han\hanst 1 month ago
parent
commit
25f17b8d75
  1. 11
      src/main/java/com/spring/modules/test/controller/TestSoBomController.java
  2. 1
      src/main/java/com/spring/modules/test/service/TestSoBomService.java
  3. 39
      src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java

11
src/main/java/com/spring/modules/test/controller/TestSoBomController.java

@ -70,4 +70,15 @@ public class TestSoBomController {
testSoBomService.removeBatchTestSoBom(testSoBomList); testSoBomService.removeBatchTestSoBom(testSoBomList);
return R.ok("操作成功"); return R.ok("操作成功");
} }
/**
* BOM导入 - 批量新增测试产品结构
* @param testSoBomList 从BOM导入的物料列表
* @return
*/
@PostMapping("/saveBatch")
public R saveBatchTestSoBom(@RequestBody List<TestSoBom> testSoBomList){
testSoBomService.saveBatchTestSoBom(testSoBomList);
return R.ok("导入成功");
}
} }

1
src/main/java/com/spring/modules/test/service/TestSoBomService.java

@ -16,5 +16,6 @@ public interface TestSoBomService extends IService<TestSoBom> {
void removeBatchTestSoBom(List<TestSoBom> testSoBomList); void removeBatchTestSoBom(List<TestSoBom> testSoBomList);
void saveTestSoBom(TestSoBom testSoBom); void saveTestSoBom(TestSoBom testSoBom);
void updateTestSoBom(TestSoBom testSoBom); void updateTestSoBom(TestSoBom testSoBom);
void saveBatchTestSoBom(List<TestSoBom> testSoBomList);
} }

39
src/main/java/com/spring/modules/test/service/impl/TestSoBomServiceImpl.java

@ -146,6 +146,45 @@ public class TestSoBomServiceImpl extends ServiceImpl<TestSoBomMapper, TestSoBom
return wrapper; return wrapper;
} }
/**
* 批量导入BOM子物料到测试产品结构
* @param testSoBomList 待保存的TestSoBom列表
*/
@Override
@Transactional
public void saveBatchTestSoBom(List<TestSoBom> testSoBomList) {
if (testSoBomList == null || testSoBomList.isEmpty()) {
return;
}
String site = testSoBomList.get(0).getSite();
String testNo = testSoBomList.get(0).getTestNo();
checkoutTestSoBomKey(testSoBomList.get(0));
TestInformationEntity testInfo = testInformationService.lambdaQuery()
.eq(TestInformationEntity::getTestNo, testNo)
.eq(TestInformationEntity::getSite, site)
.one();
if (Objects.isNull(testInfo)) {
throw new RuntimeException("测试单号" + testNo + "不存在");
}
BigDecimal nextItemNo = baseMapper.selectTestSoBomItemNo(site, testNo);
if (nextItemNo == null) {
nextItemNo = BigDecimal.ONE;
}
for (TestSoBom testSoBom : testSoBomList) {
if (testInfo.getTestPartNo().equals(testSoBom.getComponentPartNo())) {
throw new RuntimeException("不可将自身物料[" + testSoBom.getComponentPartNo() + "]作为产品结构");
}
testSoBom.setSite(site);
testSoBom.setTestNo(testNo);
testSoBom.setItemNo(nextItemNo);
nextItemNo = nextItemNo.add(BigDecimal.ONE);
baseMapper.insert(testSoBom);
}
}
/** /**
* 检查测试产品结构Key * 检查测试产品结构Key
* @param testSoBom * @param testSoBom

Loading…
Cancel
Save