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 47b71bdf..b45990c7 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 @@ -616,7 +616,7 @@ public class EbomApi extends BaseApi { @ApiOperation("BOM删除") @LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除") public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, - @RequestParam("childBomRowId") Long childBomRowId) { + @RequestParam(value = "childBomRowId",required = false) Long childBomRowId) { return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId)); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index c5193134..b8cd7686 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -366,7 +366,7 @@ public class PBomApi extends BaseApi { @ApiOperation("BOM删除") @LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除") public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, - @RequestParam("childBomRowId") Long childBomRowId) { + @RequestParam(value = "childBomRowId",required = false) Long childBomRowId) { bomNewPbomParentService.bomDelete(bomRowId,childBomRowId); return ResultVO.success(true); } 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 fd6e6127..1f950737 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 @@ -56,6 +56,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ExecutionException; @@ -1495,6 +1496,15 @@ public class BomNewEbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() + .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) + .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + if(CollUtil.isNotEmpty(mList)){ + VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + } + //检查是否存在发布前的版本,有则不能发起 BOM删除 List existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()) .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); @@ -1523,8 +1533,6 @@ public class BomNewEbomParentService extends ServiceImpl childEntityList = Lists.newArrayList(); - BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId); - BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity(); - BeanUtil.copyProperties(oldBomChild, newBomChild); - newBomChild.setRowId(IdWorker.getId()); - newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId()); - newBomChild.setBomVersionRowId(newParent.getRowId()); - newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); - childEntityList.add(newBomChild); + if(childBomRowId != null){ + BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId); + if(oldBomChild != null){ + BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId()); + newBomChild.setBomVersionRowId(newParent.getRowId()); + newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + childEntityList.add(newBomChild); + } + } + //2、子表增加一行项目类别为K,标识删除 BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); @@ -1595,8 +1612,9 @@ public class BomNewEbomParentService extends ServiceImpl addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId()); List delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 88d380ef..405f4258 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -284,14 +284,14 @@ public class BomNewPbomParentService extends ServiceImpl(query.getPage(), query.getPageSize()), query); } //添加仓库地点 by 10002327 0830 - if(!result.getRecords().isEmpty()){ - List> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()), - result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList())); - Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> { - return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")); - },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); - result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode()))); - } +// if(!result.getRecords().isEmpty()){ +// List> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()), +// result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList())); +// Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> { +// return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")); +// },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); +// result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode()))); +// } materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); return result; } @@ -1447,6 +1447,14 @@ public class BomNewPbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() + .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) + .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + if(CollUtil.isNotEmpty(mList)){ + VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + } VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能删除"); //检查当前用户是否有该工厂权限 if(!userRoleService.getUserOfFactory().contains(parent.getFacCode())){ @@ -1484,9 +1492,7 @@ public class BomNewPbomParentService extends ServiceImpl newChildEntityList = Lists.newArrayList(); - BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId); - BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity(); - BeanUtil.copyProperties(oldBomChild, newBomChild); - newBomChild.setRowId(IdWorker.getId()); - newBomChild.setBomVersionRowId(pbomParent.getRowId()); - newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue()); - newChildEntityList.add(newBomChild); + if(childBomRowId != null){ + BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId); + if(oldBomChild!= null){ + BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setBomVersionRowId(pbomParent.getRowId()); + newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue()); + newChildEntityList.add(newBomChild); + } + } //2、子表新增一行项目类别为K的标识行 @@ -1555,8 +1567,9 @@ public class BomNewPbomParentService extends ServiceImpl exceptRowIds = Lists.newArrayList(pbomParent.getRowId()); List parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo()); //历史版本转移到formal正式工作表