From 592d61ab7483216ab9cab3420176c34ddf560b73 Mon Sep 17 00:00:00 2001 From: jing's Date: Mon, 18 Dec 2023 21:14:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A4=8D=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/constant/MaterialGetEnum.java | 26 +++ .../service/BomNewEbomParentService.java | 211 +++++++++++++----- .../bomnew/service/MaterialMainService.java | 24 ++ 3 files changed, 207 insertions(+), 54 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/MaterialGetEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/MaterialGetEnum.java index 1c18cca4..9eb55218 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/MaterialGetEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/MaterialGetEnum.java @@ -17,4 +17,30 @@ public enum MaterialGetEnum implements ValueEnum { private final Integer value; private final String description; + + + + + + + + + @AllArgsConstructor + @Getter + public enum MaterialStateEnum implements ValueEnum { + //物料状态 1:正常 2:禁止采购 3:售后专用 4:冻结 5:完全弃用 + OK(1, "正常"), + STATE_NO_2(2, "禁止采购"), + STATE_NO_3(3, "售后专用"), + STATE_NO_4(4, "冻结"), + STATE_NO_5(5, "完全弃用") + ; + + + private final Integer value; + private final String description; + + + } + } 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 44d099b9..48fdeb06 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 @@ -3,6 +3,9 @@ package com.nflg.product.bomnew.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; @@ -81,28 +84,28 @@ public class BomNewEbomParentService extends ServiceImpl workDetailsListByPage(BomNewEbomParentQuery query) { - PagereturnResult = new Page<>(); + Page returnResult = new Page<>(); //物料编码搜索或图号搜索 - if(StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) { - String materialNo=query.getMaterialNo(); - if(StrUtil.isBlank(materialNo)){ + if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) { + String materialNo = query.getMaterialNo(); + if (StrUtil.isBlank(materialNo)) { List materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); - if(CollUtil.isNotEmpty(materialList)){ - materialNo=materialList.get(0).getMaterialNo(); + if (CollUtil.isNotEmpty(materialList)) { + materialNo = materialList.get(0).getMaterialNo(); } } - if(StrUtil.isNotBlank(materialNo)){ + if (StrUtil.isNotBlank(materialNo)) { List parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()); - if(CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { + if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { List parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo); List childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo); returnResult = handSeachToTree(parents, childs); } } - }else { + } else { Page result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode()); - returnResult=result; + returnResult = result; // materialMainService.intiMaterialInfo(result.getRecords()); // Page> resutlData = new Page<>(); // BeanUtil.copyProperties(result, resutlData); @@ -111,7 +114,8 @@ public class BomNewEbomParentService extends ServiceImpl handSeachToTree(List parents, List childs){ + + private Page handSeachToTree(List parents, List childs) { Page resutlData = new Page<>(); Set parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); Set childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); @@ -121,16 +125,16 @@ public class BomNewEbomParentService extends ServiceImpl all=new ArrayList<>(); + List all = new ArrayList<>(); all.addAll(parents); all.addAll(childs); - List result=new ArrayList<>(); + List result = new ArrayList<>(); for (BomNewEbomParentVO vo : resultParents) { vo.setParentRowId(0L); - result.addAll( CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId)); + result.addAll(CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId)); } resutlData.setRecords(result); - return resutlData; + return resutlData; } // private List handNodeToTree(List list){ @@ -146,16 +150,17 @@ public class BomNewEbomParentService extends ServiceImpl getParentMaterialByMaterialNo(String materialNo , Boolean selfIs) { + private List getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) { BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one(); List result = new ArrayList<>(); if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { Set relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); - if(selfIs && CollUtil.isNotEmpty(relSkuNo)){ - relSkuNo=getSelfMaterialNo(relSkuNo); + if (selfIs && CollUtil.isNotEmpty(relSkuNo)) { + relSkuNo = getSelfMaterialNo(relSkuNo); } while (CollUtil.isNotEmpty(relSkuNo)) { result.addAll(relSkuNo); @@ -164,19 +169,19 @@ public class BomNewEbomParentService extends ServiceImpl finalRelSkuNo = relSkuNo; relSkuList.forEach(k -> { if (StrUtil.isNotBlank(k.getParentMaterialNo())) { - finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ",")) ); + finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); } }); - relSkuNo=finalRelSkuNo; - if(CollUtil.isNotEmpty(relSkuNo) && selfIs){ - relSkuNo=getSelfMaterialNo(relSkuNo); + relSkuNo = finalRelSkuNo; + if (CollUtil.isNotEmpty(relSkuNo) && selfIs) { + relSkuNo = getSelfMaterialNo(relSkuNo); } } } return result; } - private Set getSelfMaterialNo(Set relSkuNo){ + private Set getSelfMaterialNo(Set relSkuNo) { Set selfParentMaterialNo = this.getBaseMapper().getSelfParentMaterialNo(SessionUtil.getUserCode(), relSkuNo); return selfParentMaterialNo; } @@ -184,6 +189,7 @@ public class BomNewEbomParentService extends ServiceImpl buildBomTree(Long rowId) throws Exception{ - return getBomTree(rowId); + public List buildBomTree(Long rowId) throws Exception { + return getBomTree(rowId); } - /** * 初始化-项目类别 */ @@ -478,19 +481,18 @@ public class BomNewEbomParentService extends ServiceImpl updateList=new ArrayList<>(); - bomNewEbomParentEntityList.forEach(item->{ - BomNewEbomParentEntity entity=new BomNewEbomParentEntity(); + List updateList = new ArrayList<>(); + bomNewEbomParentEntityList.forEach(item -> { + BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); entity.setRowId(item.getRowId()); - entity .setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); entity.setRevertTime(LocalDateTime.now()); entity.setRevertUserName(dto.getRevertUserName()); updateList.add(entity); }); - - if (! this.updateBatchById(updateList)) { + if (!this.updateBatchById(updateList)) { throw new NflgBusinessException(STATE.Error, "退回设计失败"); } @@ -498,15 +500,15 @@ public class BomNewEbomParentService extends ServiceImpl designReview(BomNewEBomRevertDTO dto){ + // @Transactional(rollbackFor = Exception.class) + public ResultVO designReview(BomNewEBomRevertDTO dto) { List rowIds = dto.getRowIdList(); @@ -521,32 +523,133 @@ public class BomNewEbomParentService extends ServiceImpl updateReviewIdList=new ArrayList<>(); + //子bom检查 + for (BomNewEbomParentEntity item : + bomNewEbomParentEntityList) { + + List childBomList; + try { + childBomList = buildBomTree(item.getRowId()); + } catch (Exception e) { + return ResultVO.error("获取Bom数据失败"); + } + + + if (CollUtil.isNotEmpty(childBomList)) { + + for (BomNewEbomParentVO childBomItem : + childBomList) { + + + if (childBomItem.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) { + return ResultVO.error("请调整数据后进行复核"); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_2.getDescription())); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_3.getDescription())); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription())); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_6.getDescription())); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription())); + } + + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription())); + } + + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_8.getDescription())); + } + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_9.getDescription())); + + } + if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())) { + return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_10.getDescription())); + + } - if(StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum()==null||item.getNum().floatValue()==0) ){ - return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription()); - } + } } + updateReviewIdList.addAll( childBomList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); + + } + //改变复核状态 + List updateReviewList=new ArrayList<>(); + for(Long id:updateReviewIdList){ + BomNewEbomParentEntity entity=new BomNewEbomParentEntity(); + entity.setRowId(id); + entity.setAuditTime(LocalDateTime.now()); + entity.setAuditUserName(dto.getRevertUserName()); + updateReviewList.add(entity); + } + if (!this.updateBatchById(updateReviewList)) { + throw new NflgBusinessException(STATE.Error, "复核失败"); + } return ResultVO.success(true); } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java index 20d8ec74..655f2b2c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java @@ -2,6 +2,8 @@ package com.nflg.product.bomnew.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -50,6 +52,9 @@ public class MaterialMainService extends ServiceImpl getExceptStatList(List materialNos,List states) { + if (CollUtil.isNotEmpty(materialNos)) { + return null; + } + List list= this.lambdaQuery().in(MaterialMainEntity::getMaterialState, states) + .in(MaterialMainEntity::getMaterialNo, materialNos).list(); + return Convert.convert(new TypeReference >(){ + + },list); + + + } + + + + + } From 43186e2433dee5b9a33fcbbe3406356118ea5b13 Mon Sep 17 00:00:00 2001 From: jing's Date: Mon, 18 Dec 2023 21:32:49 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/nflg/product/bomnew/api/user/EbomApi.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 d0797059..c9156e30 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,9 +185,8 @@ public class EbomApi extends BaseApi { return ResultVO.error(STATE.ParamErr, "请选择要复核的数据"); } dto.setRevertUserName(SessionUtil.getUserName()); - bomNewEbomParentService.designReview(dto); + return bomNewEbomParentService.designReview(dto); - return ResultVO.success(true); } From e64f7409856380e34ef62f8c4d08cf61a9222713 Mon Sep 17 00:00:00 2001 From: jing's Date: Mon, 18 Dec 2023 21:42:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nflg/product/bomnew/excel/ExportDeviceHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/excel/ExportDeviceHelper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/excel/ExportDeviceHelper.java index f061699e..f3207e9e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/excel/ExportDeviceHelper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/excel/ExportDeviceHelper.java @@ -363,12 +363,12 @@ public class ExportDeviceHelper { if(StrUtil.isEmpty(item3.getDrawingNo())) { excelField.setCellSecond(StrUtil.format("{}", item3.getMaterialName())); }else { - excelField.setCellSecond(StrUtil.format ("{}:{}", item3.getDrawingNo(), item3.getMaterialName())); + excelField.setCellSecond(StrUtil.format ("{} {}", item3.getDrawingNo(), item3.getMaterialName())); } excelField.setCellThird(StrUtil.format("{}",item3.getChooseStatus() == 1 ? "标配" : "可选")) ; - excelField.setCellFourth(item3.getRemak()); ; + excelField.setCellFourth(item3.getRemak()); items.add(excelField); } From c19d7348f04a8185c29b80849a458d49fba1a931 Mon Sep 17 00:00:00 2001 From: luoliming Date: Mon, 18 Dec 2023 22:07:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg-bom-new/src/main/resources/bootstrap.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/bootstrap.properties b/nflg_project_dev/nflg-bom-new/src/main/resources/bootstrap.properties index 18b0b86f..00bb014f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/bootstrap.properties +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/bootstrap.properties @@ -3,10 +3,10 @@ spring.profiles.active=sit spring.jackson.date-format=yyyy-MM-dd HH:mm:ss -spring.cloud.nacos.config.namespace=nflg_dev -spring.cloud.nacos.discovery.namespace=nflg_dev +spring.cloud.nacos.config.namespace=nflg +spring.cloud.nacos.discovery.namespace=nflg spring.cloud.nacos.config.file-extension=properties -nacos.plugin.namespace=nflg_dev +nacos.plugin.namespace=nflg #configuration spring.cloud.nacos.config.server-addr=${nacos.server-addr}