From b87a02f892e54fdb5d6adaf31bce038284000a84 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Wed, 30 Oct 2024 17:04:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3BOM=E3=80=91=E5=AF=BC=E5=85=A5SAP=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=8F=AA=E5=AF=BC=E5=85=A5=E5=8D=95=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 4 ++-- .../nflg/product/bomnew/api/user/EbomApi.java | 4 ++-- .../nflg/product/bomnew/api/user/PBomApi.java | 4 ++-- .../bomnew/service/BomNewEbomExportToSAP.java | 14 +++++++++++++- .../service/BomNewPbomExportToSAPImpl.java | 16 ++++++++++++++-- .../bomnew/service/BomNewPbomParentService.java | 4 ++-- .../bomnew/service/IBomNewPbomExportToSAP.java | 2 +- 7 files changed, 36 insertions(+), 12 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 dbfca896..d8a9dcac 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 @@ -69,7 +69,7 @@ public class BatchBomApi extends BaseApi { if (CollUtil.isNotEmpty(addRowIds)) { addRowIds.forEach(rootRowId -> { BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); - errorMsgVOS.addAll(exportToSAP.export(rootRowId)); + errorMsgVOS.addAll(exportToSAP.export(rootRowId, true)); }); } return ResultVO.success(errorMsgVOS); @@ -86,7 +86,7 @@ public class BatchBomApi extends BaseApi { PbomImportToSAPQuery query = new PbomImportToSAPQuery(); query.setRootBomRowId(rootRowId); query.setIsForSale(false); - errorMsgVOS.addAll(bomNewPbomParentService.importToSAP2(query)); + errorMsgVOS.addAll(bomNewPbomParentService.importToSAP2(query, true)); }); } return ResultVO.success(errorMsgVOS); 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 0841bdf5..15d275e2 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 @@ -180,7 +180,7 @@ public class EbomApi extends BaseApi { errorMsgVOS.addAll(bomNewEbomParentService.convertToPBom(paramDto)); paramDto.getBomRowIds().forEach(rootRowId -> { BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); - errorMsgVOS.addAll(exportToSAP.export(rootRowId)); + errorMsgVOS.addAll(exportToSAP.export(rootRowId, false)); }); return ResultVO.success(errorMsgVOS); @@ -469,7 +469,7 @@ public class EbomApi extends BaseApi { VUtils.isTure(rootBomRowIds.size() > 1).throwMessage("每次只能导入1条"); // return ResultVO.success(bomNewEbomParentService.importToSAP(rootBomRowIds.get(0))); BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); - return ResultVO.success(exportToSAP.export(rootBomRowIds.get(0))); + return ResultVO.success(exportToSAP.export(rootBomRowIds.get(0), false)); } /** 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 89ed62e8..d4b1490e 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 @@ -336,7 +336,7 @@ public class PBomApi extends BaseApi { .last(" order by current_version desc limit 1").one(); query.setRootBomRowId(parentEnt.getRowId()); } - return ResultVO.success(bomNewPbomParentService.importToSAP2(query)); + return ResultVO.success(bomNewPbomParentService.importToSAP2(query, false)); } @@ -389,7 +389,7 @@ public class PBomApi extends BaseApi { @PostMapping("importToSAP") @ApiOperation("导入到SAP") public ResultVO> importToSAP(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) { - return ResultVO.success(bomNewPbomParentService.importToSAP2(query)); + return ResultVO.success(bomNewPbomParentService.importToSAP2(query, false)); } /** diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java index cd7c39c9..4180ec84 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java @@ -50,7 +50,7 @@ public class BomNewEbomExportToSAP { private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class); private final SapErrorMsgUtil sapErrorMsgUtil = SpringUtil.getBean(SapErrorMsgUtil.class); - public List export(Long rootBomRowId) { + public List export(Long rootBomRowId, boolean singleLevel) { BomNewEbomParentEntity root = bomNewEbomParentService.getById(rootBomRowId); // VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在"); if (Objects.isNull(root)) return Collections.emptyList(); @@ -78,6 +78,9 @@ public class BomNewEbomExportToSAP { sapDto.setI_STLAN("2"); sapDto.setI_EMPNO(root.getCreatedBy()); sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList()))); + if (singleLevel) { + filterSingleLevelData(root.getMaterialNo(), sapDto); + } liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null); if (CollUtil.isEmpty(liErrMsg)) { state = SapStatusEnum.PUB_SUCCESS; @@ -102,6 +105,15 @@ public class BomNewEbomExportToSAP { return liErrMsg; } + /** + * 单层导入,过滤出指定父级物料号的子级即可 + * @param materialNo 父级物料号 + */ + private void filterSingleLevelData(String materialNo, ImportSapParamDTO sapDto) { + List t1 = sapDto.getT1(); + sapDto.setT1(t1.stream().filter(item -> item.getMATNR().equals(materialNo)).collect(Collectors.toList())); + } + /** * 构建child数据发包编号 * @param p 上级节点的parent diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java index d4e8d7c5..cad3d9b1 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java @@ -62,7 +62,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { } @Override - public List export(Long rootBomRowId) { + public List export(Long rootBomRowId, boolean singleLevel) { BomNewPbomParentEntity root = bomNewPbomParentService.getById(rootBomRowId); is21 = root.getMaterialNo().startsWith("21"); is31 = root.getMaterialNo().startsWith("31"); @@ -114,6 +114,9 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { sapDto.setI_STLAN("1"); sapDto.setI_EMPNO(root.getCreatedBy()); sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList()))); + if (singleLevel) { + filterSingleLevelData(root.getMaterialNo(), sapDto); + } liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null); LOGGER.debug("本次导入到sap数量共{}个,其中{}个有错误", sapDto.getT1().size(), liErrMsg.size()); if (CollUtil.isEmpty(liErrMsg)) { @@ -139,6 +142,15 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { return liErrMsg; } + /** + * 单层导入,过滤出指定父级物料号的子级即可 + * @param materialNo 父级物料号 + */ + private void filterSingleLevelData(String materialNo, ImportSapParamDTO sapDto) { + List t1 = sapDto.getT1(); + sapDto.setT1(t1.stream().filter(item -> item.getMATNR().equals(materialNo)).collect(Collectors.toList())); + } + private Long getZFBBomRowId(List children) { Long ddpRowId = null; //电控系统的无须增加 直发包parent记录 by 10002327 240918 @@ -378,7 +390,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { .one(); VUtils.isTure(Objects.isNull(pfhb)).throwMessage("没有需要导入的数据"); - List errorMsgVOS = export(pfhb.getRowId()); + List errorMsgVOS = export(pfhb.getRowId(), false); if (CollUtil.isNotEmpty(errorMsgVOS)) { //如果导入SAP出错了,得将该bom提升为用户根节点,以便用户手动尝试导入到SAP去 pfhb.setUserRootIs(1); 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 143d715c..efde0e27 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 @@ -1433,13 +1433,13 @@ public class BomNewPbomParentService extends ServiceImpl importToSAP2(PbomImportToSAPQuery query) { + public List importToSAP2(PbomImportToSAPQuery query, boolean singleLevel) { BomNewPbomParentEntity root = getById(query.getRootBomRowId()); VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在"); // VUtils.isTure(root.getUserRootIs() != 1 && root.getRootIs() != 1).throwMessage("请选择根节点"); IBomNewPbomExportToSAP service = new BomNewPbomExportToSAPImpl(query.getIsForSale()); - return service.export(root.getRowId()); + return service.export(root.getRowId(), singleLevel); } /** diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/IBomNewPbomExportToSAP.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/IBomNewPbomExportToSAP.java index e2d0ee00..d3a8b247 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/IBomNewPbomExportToSAP.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/IBomNewPbomExportToSAP.java @@ -21,7 +21,7 @@ public interface IBomNewPbomExportToSAP { // // String dateYMD = DateUtil.format(new Date(), "yyyyMMdd"); - List export(Long rootBomRowId); + List export(Long rootBomRowId, boolean singleLevel); /** * 根据直发包编号导入上级物料到SAP From afe518a65eca251e3c0a94cc84f0094e1531ae9a Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Thu, 31 Oct 2024 15:36:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3BOM=E3=80=91=E5=B7=A5=E5=8E=82=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/BatchBomApi.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 d8a9dcac..30044fa4 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 @@ -3,7 +3,10 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.nflg.product.base.core.api.BaseApi; +import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.pojo.query.BatchBomQuery; import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery; import com.nflg.product.bomnew.pojo.vo.*; @@ -98,4 +101,14 @@ public class BatchBomApi extends BaseApi { EecExcelUtil.setResponseExcelHeader(response, "批量替代" + query.getMaterialNo() + "_" + new Date().getTime()); batchBomService.getExportExcelWork(query).writeTo(response.getOutputStream()); } + + @GetMapping("getUserFactory") + @ApiOperation("获取登录用户所在工厂") + public ResultVO getUserFactory() { + String dptCde = materialMainService.getBaseMapper().getUserDepartmentDptCode(SessionUtil.getDepartRowId()); + if (StrUtil.isNotBlank(dptCde) && dptCde.contains("仙桃公司")) { + return ResultVO.success(EBomConstant.XIAN_TAO_FACTORY_CODE_1020); + } + return ResultVO.success(EBomConstant.MAIN_FACTORY_CODE_1010); + } }