From 4715a6a8fbd53ee75f0cec728dc27eefc5f20e60 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Wed, 23 Oct 2024 16:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM=20?= =?UTF-8?q?=E2=88=9A1=E3=80=81=E6=9F=A5=E8=AF=A2=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BF=87=E6=BB=A4=E7=88=B6=E7=BA=A7=E5=86=BB?= =?UTF-8?q?=E7=BB=93=E7=89=A9=E6=96=99=EF=BC=9B=20=E2=88=9A2=E3=80=81SAP?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=A4=B1=E8=B4=A5=EF=BC=8C=E5=8F=82=E7=85=A7?= =?UTF-8?q?EBOM=20PBOM=E7=BB=99=E6=8C=89=E9=92=AE=E6=9F=A5=E8=AF=A2SAP?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=87=8D=E6=96=B0=E7=82=B9=E2=80=9C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0BOM=E5=B9=B6=E5=AF=BC=E5=85=A5SAP=E2=80=9D=EF=BC=9B=20?= =?UTF-8?q?=E2=88=9A3=E3=80=81=E5=AF=BC=E5=85=A5=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=90=8E=E5=BC=B9=E5=87=BA=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=EF=BC=8C=E6=88=90=E5=8A=9F=E5=A4=9A=E5=B0=91=E6=9D=A1=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=A4=9A=E5=B0=91=E6=9D=A1=EF=BC=9B=20=E2=88=9A4?= =?UTF-8?q?=E3=80=81=E8=A1=A8=E6=A0=BC=E9=AB=98=E5=BA=A6=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E7=BB=9F=E8=AE=A1=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=92=8C=E9=80=89=E4=B8=AD=E6=95=B0=E9=87=8F?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 24 ++++---- .../bomnew/service/BatchBomService.java | 59 ++++++++++++------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java index e89cf39d..dbfca896 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java @@ -6,10 +6,7 @@ import cn.hutool.core.util.ObjectUtil; import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.bomnew.pojo.query.BatchBomQuery; import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery; -import com.nflg.product.bomnew.pojo.vo.BaseBomVO; -import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; -import com.nflg.product.bomnew.pojo.vo.BomPageVO; -import com.nflg.product.bomnew.pojo.vo.BomTbHeaderVO; +import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.service.BatchBomService; import com.nflg.product.bomnew.service.BomNewEbomExportToSAP; import com.nflg.product.bomnew.service.BomNewPbomParentService; @@ -25,10 +22,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.io.IOException; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 批量替代BOM @@ -68,32 +62,34 @@ public class BatchBomApi extends BaseApi { @PostMapping("updateEBom") @ApiOperation("更新EBOM并导入SAP") - public ResultVO> updateEBom(@RequestBody List baseBomVOList) { + public ResultVO> updateEBom(@RequestBody List baseBomVOList) { List addRowIds = batchBomService.updateEBom(baseBomVOList); + List errorMsgVOS = new ArrayList<>(); // 导入SAP if (CollUtil.isNotEmpty(addRowIds)) { addRowIds.forEach(rootRowId -> { BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); - exportToSAP.export(rootRowId); + errorMsgVOS.addAll(exportToSAP.export(rootRowId)); }); } - return ResultVO.success(); + return ResultVO.success(errorMsgVOS); } @PostMapping("updatePBom") @ApiOperation("更新PBOM并导入SAP") - public ResultVO> updatePBom(@RequestBody List baseBomVOList) { + public ResultVO> updatePBom(@RequestBody List baseBomVOList) { List addRowIds = batchBomService.updatePBom(baseBomVOList); + List errorMsgVOS = new ArrayList<>(); // 导入SAP if (CollUtil.isNotEmpty(addRowIds)) { addRowIds.forEach(rootRowId -> { PbomImportToSAPQuery query = new PbomImportToSAPQuery(); query.setRootBomRowId(rootRowId); query.setIsForSale(false); - bomNewPbomParentService.importToSAP2(query); + errorMsgVOS.addAll(bomNewPbomParentService.importToSAP2(query)); }); } - return ResultVO.success(); + return ResultVO.success(errorMsgVOS); } @PostMapping("exportExcel") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java index fdbe865d..aab67811 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java @@ -96,7 +96,6 @@ public class BatchBomService { .orderByDesc(BomNewEbomParentEntity::getCreatedTime) .list(); if (CollectionUtil.isNotEmpty(ebomParentEntities)) { - long counter = 0; for (BomNewEbomParentEntity parent : ebomParentEntities) { // 按创建时间过滤 if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { @@ -112,7 +111,6 @@ public class BatchBomService { } } BaseBomVO baseBomVO = new BaseBomVO(); - baseBomVO.setOrderNum(++counter); baseBomVO.setParentRowId(parent.getRowId()); baseBomVO.setParentMaterialNo(parent.getMaterialNo()); baseBomVO.setParentVersion(parent.getCurrentVersion()); @@ -153,7 +151,6 @@ public class BatchBomService { .orderByDesc(BomNewPbomParentEntity::getCreatedTime) .list(); if (CollectionUtil.isNotEmpty(pbomParentEntities)) { - long counter = 0; for (BomNewPbomParentEntity parent : pbomParentEntities) { // 按创建时间过滤 if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { @@ -169,7 +166,6 @@ public class BatchBomService { } } BaseBomVO baseBomVO = new BaseBomVO(); - baseBomVO.setOrderNum(++counter); baseBomVO.setParentRowId(parent.getRowId()); baseBomVO.setParentMaterialNo(parent.getMaterialNo()); baseBomVO.setParentVersion(parent.getCurrentVersion()); @@ -198,22 +194,14 @@ public class BatchBomService { if (CollectionUtil.isEmpty(resultList)) { return null; } - // 实时查询物料的物料描述,物料类别等字段 - List tempList = new ArrayList<>(); - resultList.forEach(result -> { - BaseMaterialVO parent = new BaseMaterialVO(); - parent.setMaterialNo(result.getParentMaterialNo()); - tempList.add(parent); - }); - materialMainService.intiMaterialInfo(tempList); - Map materialMp = ListCommonUtil.listToMap(tempList, BaseMaterialVO::getMaterialNo); - resultList.forEach(result -> { - result.setParentMaterialRowId(materialMp.get(result.getParentMaterialNo()).getMaterialRowId()); - result.setParentMaterialDesc(materialMp.get(result.getParentMaterialNo()).getMaterialDesc()); - result.setCategoryCode(materialMp.get(result.getParentMaterialNo()).getMaterialCategoryCode()); - result.setRelCategoryCode(materialMp.get(result.getParentMaterialNo()).getRelCategoryCode()); - result.setCategoryName(materialMp.get(result.getParentMaterialNo()).getCategoryName()); - }); + initMaterialInfoAndFilter(resultList); + if (CollectionUtil.isNotEmpty(resultList)) { + long counter = 0; + for (BaseBomVO result : resultList) { + result.setOrderNum(++counter); + } + } + BomPageVO, BomTbHeaderVO> pageVO = new BomPageVO<>(); List> records = new ArrayList<>(resultList.size()); resultList.forEach(result -> records.add(BeanUtil.beanToMap(result))); @@ -226,6 +214,37 @@ public class BatchBomService { return pageVO; } + /** + * 初始化物料信息,并过滤掉冻结物料 + */ + private void initMaterialInfoAndFilter(List resultList) { + // 实时查询物料的物料描述,物料类别等字段 + List tempList = new ArrayList<>(); + resultList.forEach(result -> { + BaseMaterialVO parent = new BaseMaterialVO(); + parent.setMaterialNo(result.getParentMaterialNo()); + tempList.add(parent); + }); + materialMainService.intiMaterialInfo(tempList); + Map materialMp = ListCommonUtil.listToMap(tempList, BaseMaterialVO::getMaterialNo); + ListIterator listIterator = resultList.listIterator(); + while (listIterator.hasNext()) { + BaseBomVO result = listIterator.next(); + // 过滤掉冻结物料 + if (ObjectUtil.isNotEmpty(materialMp.get(result.getParentMaterialNo())) + && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(materialMp.get(result.getParentMaterialNo()).getMaterialState()) + || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(materialMp.get(result.getParentMaterialNo()).getMaterialState()))) { + listIterator.remove(); + continue; + } + result.setParentMaterialRowId(materialMp.get(result.getParentMaterialNo()).getMaterialRowId()); + result.setParentMaterialDesc(materialMp.get(result.getParentMaterialNo()).getMaterialDesc()); + result.setCategoryCode(materialMp.get(result.getParentMaterialNo()).getMaterialCategoryCode()); + result.setRelCategoryCode(materialMp.get(result.getParentMaterialNo()).getRelCategoryCode()); + result.setCategoryName(materialMp.get(result.getParentMaterialNo()).getCategoryName()); + } + } + private List getTbHeaders() { List headerVOS = new ArrayList<>(); headerVOS.add(new BomTbHeaderVO("序号", "orderNum"));