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 ea6df6e6..3a6c1e9d 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 @@ -12,6 +12,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -320,6 +321,7 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus = CollectionUtil.toList(new Integer[]{ EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index d9dba33e..4ea81c75 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -39,14 +39,14 @@ public class CheckEBomException { public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException { -// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); -// BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); -// BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); -// convert.setBomRowId(convert.getRowId()); -// convert.setParentRowId(0L); -// allBomDetail.add(convert); + allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); + BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); + BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); + convert.setBomRowId(convert.getRowId()); + convert.setParentRowId(0L); + allBomDetail.add(convert); - allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); + // allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index c5b1bfe2..82743c8a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -86,14 +86,82 @@ public class EBomEdit { - - - - - public void temporary(BomNewEBomParentEditDTO dto) { + parentEntities = new ArrayList<>(); + childEntities = new ArrayList<>(); + //添加数据 + if (dto.getParent() == null) { + + for (BomNewEbomParentVO vo : dto.getDatas()) { + parentEntities.add(createParentBomInfo (vo)); + } + + } else { + BomNewEbomParentEntity parent; + + //缺bom + if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { + dto.getParent().setBomRowId(dto.getParent().getRowId()); + + parent = createParentBomInfo(dto.getParent()); + parent.setEditStatus(dto.getOpType()); + parentEntities.add(parent); + }else { + + parent = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); + parent.setEditStatus(dto.getOpType()); + parentEntities.add(parent); + } + + + childEntities=Convert.convert(new TypeReference>() { + }, dto.getDatas()); + + for (BomNewEbomChildEntity child : + childEntities) { + + 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()); + child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId())); + + child.setSource(source); + child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + 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()); + + //工艺人员 + 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())); + + + } + } + + + + } + + + + + public void submit(BomNewEBomParentEditDTO dto) { + + List materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); //检查物料编码是否在主数据中存在 List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); @@ -118,16 +186,14 @@ public class EBomEdit { 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()); + parent = createParentBomInfo(dto.getParent()); + parent.setEditStatus(dto.getOpType()); parentEntities.add(parent); }else { exceptList.add(dto.getParent());