diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 7bc40ffd..a5789ecc 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -185,7 +185,7 @@ public class EbomApi extends BaseApi { // } @PostMapping("createBomImport") @ApiOperation("创建EBOM-导入") - public ResultVO createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException { + public ResultVO createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException, ExecutionException, InterruptedException { if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) { return ResultVO.error("请上传Excel文件"); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 14407c31..ea6df6e6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -274,6 +274,12 @@ public class BomNewEbomParentService extends ServiceImpl getChildBatch(List rowIds) { List result = new ArrayList<>(); for (Long bomRowId : rowIds) { @@ -283,6 +289,12 @@ public class BomNewEbomParentService extends ServiceImpl result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); List datas = Convert.convert(new TypeReference>() { }, result); + + List materialNos = datas.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + //检查物料编码是否在主数据中存在 + List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); + List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + Set difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); + VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在"); + + + materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue()); - BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO(); bomNewEBomParentEditDTO.setParent(dto.getParent()); bomNewEBomParentEditDTO.setDatas(datas); eBomEdit.temporary(bomNewEBomParentEditDTO); + + + if(dto.getParent().getBomRowId()>0 && (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) + || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))){ + + deleteBom(dto.getParent().getBomRowId()); + + } + if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { this.saveOrUpdateBatch(eBomEdit.parentEntities); } @@ -620,6 +653,9 @@ public class BomNewEbomParentService extends ServiceImpl0 说明有bom,更新只到parent这层,无bom不需要更新 @@ -947,7 +984,7 @@ public class BomNewEbomParentService extends ServiceImpl u.getBomRowId() > 0 && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) - || EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))) + ||u.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) .collect(Collectors.toList()); //借用件不能删除,原始bom转换只能自己 @@ -1001,7 +1038,9 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus = CollectionUtil.toList(new Integer[]{ @@ -1049,6 +1089,7 @@ public class BomNewEbomParentService extends ServiceImpl delList) { + if(CollectionUtil.isEmpty(delList)){ + return; + } List delTagList = new ArrayList<>(); //原始bom不正常 List s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java index 91f8551d..490a0ee0 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java @@ -182,11 +182,17 @@ public class BomNewOriginalParentService extends ServiceImpl(); //添加数据 if (dto.getParent() == null) { + CheckEBomException eBomException=new CheckEBomException( dto.getDatas() ); + eBomException.checkException(); for (BomNewEbomParentVO vo : dto.getDatas()) { parentEntities.add(createParentBomInfo (vo)); } } else { BomNewEbomParentEntity parent; + + List exceptList=new ArrayList<>(); + exceptList.addAll(dto.getDatas()); + + + + //缺bom if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { + dto.getParent().setBomRowId(dto.getParent().getRowId()); + exceptList.add(dto.getParent()); + CheckEBomException eBomException=new CheckEBomException( exceptList ); + eBomException.checkException(); parent = createParentBomInfo(dto.getParent()); parentEntities.add(parent); }else { + exceptList.add(dto.getParent()); + CheckEBomException eBomException=new CheckEBomException( exceptList ); + eBomException.checkException(); parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); + parent.setEditStatus(dto.getOpType()); + parentEntities.add(parent); } - SpringUtil.getBean(BomNewEbomParentService.class).initBomException(dto.getDatas()); + childEntities=Convert.convert(new TypeReference>() { }, dto.getDatas()); @@ -130,7 +148,7 @@ public class EBomEdit { //child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); - + List roleList= SpringUtil.getBean(UserRoleService.class).getUserPost(); //新增数据 if(child.getRowId()==null || child.getRowId().longValue()==0){ child.setRowId(IdWorker.getId()); @@ -141,14 +159,21 @@ public class EBomEdit { child.setCreatedTime(LocalDateTime.now()); child.setCreatedBy(SessionUtil.getUserCode()); child.setSourceRowId(0l); + child.setParentRowId(parent.getRowId()); + child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); - parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); + + //工艺人员 + if(roleList.contains(EBomConstant.TECHNICIAN)){ + parent.setStatus(EBomStatusEnum.CHECKED.getValue()); + } } + child.setEditStatus(dto.getOpType()); + parent.setCreatedJob(roleList.contains(EBomConstant.TECHNICIAN)?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); - child.setParentRowId(parent.getRowId()); if(StrUtil.isEmpty(child.getProjectType())){ child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); } @@ -170,8 +195,4 @@ public class EBomEdit { } - - - - }