异常调整

This commit is contained in:
jing's 2024-01-04 23:25:08 +08:00
parent 9757db017d
commit 4893ccaba7
4 changed files with 71 additions and 35 deletions

View File

@ -264,10 +264,14 @@ public class EbomApi extends BaseApi {
@GetMapping("editDetail")
@ApiOperation("编辑物料列表")
public ResultVO<BomNewEbomEditDetailVO> editDetail(@RequestParam("bomRowId") Long bomRowId) {
public ResultVO<BomNewEbomEditDetailVO> editDetail(@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) {
if(Objects.isNull(bomRowId)){
VUtils.isTure(true ).throwMessage("bomRowId不能为空");
}
ResultVO resultVO = new ResultVO();
resultVO.setData(bomNewEbomParentService.editDetail(bomRowId));
resultVO.setData(bomNewEbomParentService.editDetail(bomRowId,projectType));
return resultVO;
}

View File

@ -499,6 +499,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void checkAndSaveEBomException(List<BomNewEbomParentVO> list) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.initException();
//保存异常
saveException(checkEBomException);
}
/**
* 生成虚拟包
@ -984,7 +995,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO > childList=getBomTree(bomRowId);
CheckEBomException checkEBomException = new CheckEBomException(childList);
// System.out.println(JSON.toJSONString(checkEBomException.getAllBomDetail()));
checkEBomException.initException("projectType");
checkEBomException.initException();
//错误状态包含在checkStatus内有异常抛出
checkEBomException.checkContainExcept(checkStatus);
//筛选bomRowId()>0 说明有bom更新只到parent这层无bom不需要更新
@ -1074,12 +1085,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return true;
}
public BomNewEbomEditDetailVO editDetail(Long bomRowId) {
public BomNewEbomEditDetailVO editDetail(Long bomRowId,String projectType) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getById(bomRowId);
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
parentVO.setBomRowId(parentVO.getRowId());
parentVO.setParentRowId(0l);
parentVO.setProjectType(projectType);
// materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
@ -1197,6 +1209,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
dto.setOpType(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
@ -1205,18 +1220,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
//ebomChildService.getBaseMapper().updateEBomMaterialUse();
}
if (dto.getParent() != null) {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
}
List<BomNewEbomParentVO> childList=dto.getDatas();
checkAndSaveEBomException(dto.getParent().getBomRowId());
if( dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) {
childList.add(dto.getParent());
}
checkAndSaveEBomException(childList);
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
return true;
}
@ -1242,6 +1259,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()
});
if (dto.getParent() != null) {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
}
if(CollectionUtil.isNotEmpty(eBomEdit.childEntities)){
@ -1249,12 +1271,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> allBom = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, eBomEdit.childEntities);
BomNewEbomParentVO parent = Convert.convert( BomNewEbomParentVO .class
, eBomEdit.parentEntities.get(0));
if(dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) {
allBom.add(parent);
}
CheckEBomException checkEBomException = new CheckEBomException(allBom);
checkEBomException.initException("material", "materialTexture", "projectType");
checkEBomException.checkContainExcept(checkStatus);
}
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
@ -1267,12 +1292,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
if (dto.getParent() != null) {
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
deleteBomChild(dto.getDelDatas());
}
// checkAndSaveEBomException(dto.getParent().getBomRowId());
List<BomNewEbomParentVO> childList= dto.getDatas();
if(dto.getParent().getRootIs()==null || dto.getParent().getRootIs()==0) {
childList.add(dto.getParent());
}
checkAndSaveEBomException(dto.getParent().getBomRowId());
checkAndSaveEBomException(childList);
// ebomChildService.getBaseMapper().updateEBomMaterialUse();
ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
return true;
@ -1292,8 +1323,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return;
}
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
CheckEBomException checkEBomException = new CheckEBomException(delList);
checkEBomException.initException("material", "materialTexture", "projectType");
// CheckEBomException checkEBomException = new CheckEBomException(delList);
// checkEBomException.initException();
//原始bom不正常
List<BomNewEbomParentVO> s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&& !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
@ -1326,10 +1357,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
*/
public List<BomNewEbomParentVO> changeMaterial(BomNewEBomChangeDTO dto) {
CheckEBomException.checkMaterialNoInMain(dto.getDatas());
List<BomNewEbomParentVO> checkBom = new ArrayList<>();
List<BomNewEbomParentVO> tmp1=dto.getDatas().stream().filter(item->Objects.nonNull(item.getRowId()) && item.getRowId()>0).collect(Collectors.toList());
@ -1350,6 +1379,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
checkBom.addAll(tmp1);
checkBom.addAll(tmp2);
if(dto.getParent().getRootIs()==null ||dto.getParent().getRootIs()==0 ) {
checkBom.add(dto.getParent());
}
// CheckEBomException checkEBomException = new CheckEBomException(checkBom);
// checkEBomException.checkException();
// this.initBomException(checkBom);

View File

@ -220,7 +220,7 @@ public class CheckEBomException {
if(CollUtil.isNotEmpty(list)){
throw new NflgBusinessException(STATE.BusinessError, EBomExceptionStatusEnum.code2description(list.get(0)));
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编码{} 异常情况 {}",item.getMaterialNo(),EBomExceptionStatusEnum.code2description(list.get(0)) ));
}

View File

@ -241,19 +241,19 @@ public class EBomEdit {
// parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
if(StrUtil.isEmpty(child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
if(StrUtil.isNotEmpty(dto.getParent().getProjectType()) && StrUtil.containsAny(dto.getParent().getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
}
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
}
}
// if(StrUtil.isEmpty(child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
// }
//
// if(StrUtil.isNotEmpty(dto.getParent().getProjectType()) && StrUtil.containsAny(dto.getParent().getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
// }
//
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
// }
// }
// VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");