From 16a71b3af332313d9024a13695993af55dcd7654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Mon, 6 May 2024 11:43:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81=E8=BF=87=E6=B8=A1=E7=89=88?= =?UTF-8?q?=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/EbomTempApi.java | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomTempApi.java diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomTempApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomTempApi.java deleted file mode 100644 index 4b0e983e..00000000 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomTempApi.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.nflg.product.bomnew.api.user; - -import cn.hutool.core.collection.CollUtil; -import com.mzt.logapi.starter.annotation.LogRecord; -import com.nflg.product.base.core.api.BaseApi; -import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto; -import com.nflg.product.bomnew.service.*; -import com.nflg.product.bomnew.util.VUtils; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import nflg.product.common.vo.ResultVO; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.io.IOException; - - -/** - * ebom-临时过渡接口 - * - */ -@Api(tags = "EBom临时接口") -@RestController -@RequestMapping("bom/new/ebom/temp") -public class EbomTempApi extends BaseApi { - - /** - * 服务对象 - */ - @Resource - private BomNewEbomParentService bomNewEbomParentService; - - @PostMapping("generateVirtualPackage") - @ApiOperation("生成虚拟包") - @LogRecord(success = "生成虚拟包:物料编码:{{#gvbom.materialNo}} 版本:{{#gvbom.currentVersion}},操作结果:{{#_ret}}", - bizNo = "{{#paramDto.bomRowId}}", type = "生成虚拟包") - public ResultVO generateVirtualPackage(@RequestBody VirtualPackageParamDto paramDto) throws IOException { - VUtils.isTure(CollUtil.isEmpty(paramDto.getVirtualPackageValue())).throwMessage("请选择要生成的虚拟包"); - - //检查-是否已 - bomNewEbomParentService.generateVirtualPackage(paramDto); - return ResultVO.success(true); - } -} From 362f6c7ce0ca1e2fd2233c6ee417e422bd1ad06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Mon, 6 May 2024 13:44:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E7=94=9F=E6=88=90=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E5=8C=85=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E4=B8=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE-=E7=BC=A9=E7=9F=AD=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=8C=85=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/EBom/VirtualPackageBase.java | 140 +++++++++++------- 1 file changed, 90 insertions(+), 50 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java index 2b9d05dc..d92ce572 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java @@ -17,10 +17,12 @@ import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.MaterialService; import com.nflg.product.bomnew.util.VersionUtil; import lombok.Getter; +import org.ttzero.excel.reader.Col; import java.io.IOException; import java.math.BigDecimal; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -30,10 +32,10 @@ public abstract class VirtualPackageBase { @Getter - protected List parentResult=new ArrayList<>(); + protected List parentResult = new ArrayList<>(); @Getter - protected List childResult=new ArrayList<>(); + protected List childResult = new ArrayList<>(); protected Long bomRowId; @@ -46,41 +48,57 @@ public abstract class VirtualPackageBase { protected List virtualPackageValue; //虚拟包编码 - protected Map vMNos=new HashMap<>(); - + protected Map vMNos = new HashMap<>(); /** * 申请虚拟包 + * * @param child * @param virtualPackageTypeEnums * @return */ protected void generateVMNoFor31(String parentDrawingNo, List child, VirtualPackageTypeEnum... virtualPackageTypeEnums) { - List params=new ArrayList<>(); + List params = new ArrayList<>(); + Set vDrawingNoSet = new HashSet<>(); for (BomNewEbomChildEntity ch : child) { for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) { - String vDrawingNo = String.join("","(",parentDrawingNo,")","(",ch.getMaterialName(),")","(",vpy.getConMaterialName(),")" ); - params.add(buildAddMaterialParamDo(StrUtil.join("",ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy)); + String vDrawingNo = String.join("", "(", parentDrawingNo, ")", "(", ch.getMaterialName(), ")", "(", vpy.getConMaterialName(), ")"); + vDrawingNoSet.add(vDrawingNo); } } - List addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(addM)) { - Map vMNosResult = SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM); - vMNos.putAll(vMNosResult); + if (CollUtil.isNotEmpty(vDrawingNoSet)) { + + List oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().in(MaterialMainEntity::getDrawingNo, vDrawingNoSet).list(); + Map oldMaterialMap = oldMaterialList.stream().collect(Collectors.toMap(MaterialMainEntity::getDrawingNo, Function.identity(), (k1, k2) -> k1)); + + for (BomNewEbomChildEntity ch : child) { + for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) { + String vDrawingNo = String.join("", "(", parentDrawingNo, ")", "(", ch.getMaterialName(), ")", "(", vpy.getConMaterialName(), ")"); + params.add(buildAddMaterialParamDo(StrUtil.join("", ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy, oldMaterialMap)); + } + } + List addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(addM)) { + Map vMNosResult = SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM); + vMNos.putAll(vMNosResult); + } } } /** * 申请虚拟包 + * * @param child * @param virtualPackageTypeEnums * @return */ - protected void generateVMNoF21(String parentDrawingNo, List child,VirtualPackageTypeEnum ... virtualPackageTypeEnums){ - List params=new ArrayList<>(); - for ( BomNewEbomParentVO ch: child ) { + protected void generateVMNoF21(String parentDrawingNo, List child, VirtualPackageTypeEnum... virtualPackageTypeEnums) { + List params = new ArrayList<>(); + + Set vDrawingNoSet = new HashSet<>(); + for (BomNewEbomParentVO ch : child) { for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) { String vDrawingNo; if (vpy == VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE) { @@ -88,65 +106,84 @@ public abstract class VirtualPackageBase { } else { vDrawingNo = String.join("", "(", parentDrawingNo, ch.getMaterialName(), ")", "(", vpy.getConMaterialName(), ")"); } - params.add(buildAddMaterialParamDo(StrUtil.join("",ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy)); + vDrawingNoSet.add(vDrawingNo); } } - List addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); - vMNos= SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM); + if (CollUtil.isNotEmpty(vDrawingNoSet)) { + + List oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().in(MaterialMainEntity::getDrawingNo, vDrawingNoSet).list(); + Map oldMaterialMap = oldMaterialList.stream().collect(Collectors.toMap(MaterialMainEntity::getDrawingNo, Function.identity(), (k1, k2) -> k1)); + + + for (BomNewEbomParentVO ch : child) { + for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) { + String vDrawingNo; + if (vpy == VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE) { + vDrawingNo = String.join("", parentDrawingNo, ".FHQ", "(", ch.getMaterialName(), ")", "(", vpy.getConMaterialName(), ")"); + } else { + vDrawingNo = String.join("", "(", parentDrawingNo, ch.getMaterialName(), ")", "(", vpy.getConMaterialName(), ")"); + } + params.add(buildAddMaterialParamDo(StrUtil.join("", ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy, oldMaterialMap)); + } + } + List addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); + vMNos = SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM); + } } - //申请物料编码 - private AddVirtrualMaterialDTO buildAddMaterialParamDo(String key, String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType){ - List oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getDrawingNo, drawingNo) - .list(); - AddVirtrualMaterialDTO ent=new AddVirtrualMaterialDTO(); - if(CollUtil.isNotEmpty(oldMaterialList)){ + //申请物料编码 + private AddVirtrualMaterialDTO buildAddMaterialParamDo(String key, String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType, Map oldMaterialMap) { + +// List oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getDrawingNo, drawingNo) +// .list(); + MaterialMainEntity oldMaterial = oldMaterialMap.get(drawingNo); + AddVirtrualMaterialDTO ent = new AddVirtrualMaterialDTO(); + if (Objects.nonNull(oldMaterial)) { ent.setKey(key); ent.setDrawingNo(drawingNo); - ent.setMaterialNo(oldMaterialList.get(0).getMaterialNo()); - ent.setMaterialName(oldMaterialList.get(0).getMaterialName()); - ent.setMaterialDesc(oldMaterialList.get(0).getMaterialDesc()); - ent.setMaterialCategoryCode(oldMaterialList.get(0).getMaterialCategoryCode()); - vMNos.put(ent.getKey(),ent); - } - else { + ent.setMaterialNo(oldMaterial.getMaterialNo()); + ent.setMaterialName(oldMaterial.getMaterialName()); + ent.setMaterialDesc(oldMaterial.getMaterialDesc()); + ent.setMaterialCategoryCode(oldMaterial.getMaterialCategoryCode()); + vMNos.put(ent.getKey(), ent); + } else { ent.setKey(key); ent.setDrawingNo(drawingNo); ent.setMaterialName(materialName); ent.setMaterialDesc(materialName); ent.setMaterialCategoryCode(virtualPackageType.getMaterialCategoryCode()); } - return ent; + return ent; } protected BomNewEbomParentEntity buildParentVirtualPackage(Long rowId, VirtualPackageTypeEnum virtualPackageTypeEnum, String orderNum, BomNewEbomParentEntity p) { - AddVirtrualMaterialDTO addM = vMNos.get(StrUtil.join("",rowId,virtualPackageTypeEnum.getConMaterialName())); - BomNewEbomParentEntity oldParent= SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery() + AddVirtrualMaterialDTO addM = vMNos.get(StrUtil.join("", rowId, virtualPackageTypeEnum.getConMaterialName())); + BomNewEbomParentEntity oldParent = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery() .eq(BomNewEbomParentEntity::getMaterialNo, addM.getMaterialNo()) - .eq(BomNewEbomParentEntity::getLastVersionIs,1) + .eq(BomNewEbomParentEntity::getLastVersionIs, 1) //.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) .one(); - if(Objects.nonNull(oldParent) && !EBomStatusEnum.PUBLISHED.equalsValue(oldParent.getStatus()) ){ + if (Objects.nonNull(oldParent) && !EBomStatusEnum.PUBLISHED.equalsValue(oldParent.getStatus())) { return oldParent; } - if(Objects.nonNull(oldParent)){ + if (Objects.nonNull(oldParent)) { oldParent.setLastVersionIs(0); this.parentResult.add(oldParent); } // String materialNo = SpringUtil.getBean(MaterialService.class).addMaterial(drawingNo, vMaterialName,materialDesc, virtualPackageType.getMaterialCategoryCode()); - BomNewEbomParentEntity parent =new BomNewEbomParentEntity(); + BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); parent.setRowId(IdWorker.getId()); - parent.setOrderNumber(StrUtil.isNotBlank(orderNum) ? StrUtil.padPre(orderNum,3,"0"):"001"); - parent.setDrawingNo(addM.getDrawingNo() ); + parent.setOrderNumber(StrUtil.isNotBlank(orderNum) ? StrUtil.padPre(orderNum, 3, "0") : "001"); + parent.setDrawingNo(addM.getDrawingNo()); parent.setMaterialNo(addM.getMaterialNo()); parent.setMaterialName(addM.getMaterialName()); parent.setMaterialDesc(addM.getMaterialDesc()); - parent.setCurrentVersion(VersionUtil.getNextVersion(Objects.nonNull(oldParent)?oldParent.getCurrentVersion():"")); + parent.setCurrentVersion(VersionUtil.getNextVersion(Objects.nonNull(oldParent) ? oldParent.getCurrentVersion() : "")); parent.setVirtualPackageIs(1); // parent.setProjectType("L"); // parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue()); @@ -170,11 +207,12 @@ public abstract class VirtualPackageBase { /** * 构建子级 + * * @return */ - protected BomNewEbomChildEntity buildChild(BomNewEbomParentEntity parent, Long parentRowId, String orderNo,VirtualPackageTypeEnum virtualPackageTypeEnum,String rootMaterialNo){ - BomNewEbomChildEntity childEntity =new BomNewEbomChildEntity(); - BeanUtil.copyProperties(parent,childEntity); + protected BomNewEbomChildEntity buildChild(BomNewEbomParentEntity parent, Long parentRowId, String orderNo, VirtualPackageTypeEnum virtualPackageTypeEnum, String rootMaterialNo) { + BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(parent, childEntity); childEntity.setRowId(IdWorker.getId()); childEntity.setParentRowId(parentRowId); childEntity.setIdentityNo(parent.getRowId().toString()); @@ -188,21 +226,22 @@ public abstract class VirtualPackageBase { childEntity.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue()); childEntity.setVirtualPartRootMaterialNo(rootMaterialNo); this.childResult.add(childEntity); - return childEntity; + return childEntity; } /** * 获取子级 + * * @return */ - protected List getChild(){ + protected List getChild() { return SpringUtil.getBean(BomNewEbomParentService.class).getChildForVirtualPackage(bomRowId); } - protected BomNewEbomParentEntity getParentZhiZuo(String inDrawingNo){ + protected BomNewEbomParentEntity getParentZhiZuo(String inDrawingNo) { - return SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getDrawingNo,StrUtil.join("","(", inDrawingNo,VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName(),")")) - .eq(BomNewEbomParentEntity::getLastVersionIs,1).one(); + return SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getDrawingNo, StrUtil.join("", "(", inDrawingNo, VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName(), ")")) + .eq(BomNewEbomParentEntity::getLastVersionIs, 1).one(); // List list = SpringUtil.getBean(BomNewEbomChildService.class).lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, inBomRowId).list(); // List zhiZuo = list.stream().filter(u -> u.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())).collect(Collectors.toList()); @@ -216,10 +255,11 @@ public abstract class VirtualPackageBase { /** * 获取父节点 + * * @return */ - protected BomNewEbomParentEntity getParentByRowId(Long rowId){ - return SpringUtil.getBean(BomNewEbomParentService.class).getById(rowId); + protected BomNewEbomParentEntity getParentByRowId(Long rowId) { + return SpringUtil.getBean(BomNewEbomParentService.class).getById(rowId); } /** From ca66acc0a3998fa7724adb4ba93f2bee9fe72deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 7 May 2024 11:08:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20ebom=E7=BC=96=E8=BE=91=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=B9=9F=E9=9C=80=E8=A6=81=E8=B7=9F=E7=94=B5=E6=B0=94?= =?UTF-8?q?=E4=B8=93=E7=94=A8bom=E7=9A=84=E7=BC=96=E8=BE=91=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=B8=80=E6=A0=B7=E6=9C=89=E7=88=B6=E7=BA=A7=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 19 +++++++--- .../service/BomNewEbomParentService.java | 35 ++++++++++++++++--- .../domain/EBom/CheckEBomException.java | 3 +- 3 files changed, 46 insertions(+), 11 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 51517b7a..7eb6d4f3 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 @@ -10,12 +10,10 @@ import com.mzt.logapi.starter.annotation.LogRecord; import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.pojo.dto.*; +import com.nflg.product.bomnew.pojo.query.BomExceptionQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; -import com.nflg.product.bomnew.pojo.vo.BomNewEbomEditDetailVO; -import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; -import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO; -import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; +import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.service.*; import com.nflg.product.bomnew.util.EecExcelUtil; import com.nflg.product.bomnew.util.VUtils; @@ -411,7 +409,7 @@ public class EbomApi extends BaseApi { @PostMapping("intiException") @ApiOperation("初始化错误类型") @LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}", type = "Ebom-初始化错误类型") - public ResultVO intiException(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { + public ResultVO intiException(@RequestBody List bomRowIds) { bomNewEbomParentService.batchCheckAndSaveEBomException(bomRowIds); return ResultVO.success(true); @@ -464,4 +462,15 @@ public class EbomApi extends BaseApi { VUtils.isTure(rootBomRowIds.size() > 1).throwMessage("每次只能导入1条"); return bomNewEbomParentService.importToSAP(rootBomRowIds.get(0)); } + + /** + * 获取节点异常状态 + * @param query query + * @return 节点异常状态 + */ + @PostMapping("getBomException") + @ApiOperation("获取节点异常状态") + public ResultVO> getBomException(@Valid @RequestBody @NotEmpty List query) { + return ResultVO.success(bomNewEbomParentService.getBomException(query)); + } } 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 8e912e98..522c931a 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 @@ -24,6 +24,7 @@ import com.nflg.product.bomnew.pojo.dto.*; import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO; import com.nflg.product.bomnew.pojo.entity.*; +import com.nflg.product.bomnew.pojo.query.BomExceptionQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.vo.*; @@ -527,10 +528,8 @@ public class BomNewEbomParentService extends ServiceImpl getBomTree(Long rowId, Boolean generateLevelNumberFlag) throws ExecutionException, InterruptedException { + public List getBomTree(Long rowId, Boolean generateLevelNumberFlag) { List bomDetail = this.getBaseMapper().getParentChild(rowId); // EBomDetailTask detailTask = new EBomDetailTask(bomDetail); @@ -719,7 +718,7 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds) throws ExecutionException, InterruptedException { + public void batchCheckAndSaveEBomException(List bomRowIds) { for (Long bomRowId : bomRowIds) { CheckEBomException checkEBomException = new CheckEBomException(bomRowId); checkEBomException.initException(); @@ -2258,4 +2257,32 @@ public class BomNewEbomParentService extends ServiceImpl getBomException(List query) { + List datas = new ArrayList<>(); + for (int index = 0, count = query.size(); index < count; index++) { + BomExceptionQuery bom = query.get(index); + BomExceptionVO vo = new BomExceptionVO(); + if (index == 0) { + batchCheckAndSaveEBomException(Collections.singletonList(bom.getBomRowId())); + + BomNewEbomParentEntity parent = getById(bom.getBomRowId()); + vo.setMaterialNo(parent.getMaterialNo()); + vo.setExceptionStatus(parent.getExceptionStatus()); + } else { + BomNewEbomChildEntity child = ebomChildService.getById(bom.getRowId()); + vo.setMaterialNo(child.getMaterialNo()); + if (Objects.equals(child.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) { + BomNewEbomParentEntity parent = getById(bom.getBomRowId()); + vo.setExceptionStatus(parent.getExceptionStatus()); + } else { + vo.setExceptionStatus(child.getExceptionStatus()); + } + } + vo.setBomRowId(bom.getBomRowId()); + vo.setRowId(bom.getRowId()); + datas.add(vo); + } + return datas; + } } 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 95f69909..b7ee4e03 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 @@ -21,7 +21,6 @@ import nflg.product.common.constant.STATE; import java.math.BigDecimal; import java.util.*; -import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; /** @@ -53,7 +52,7 @@ public class CheckEBomException { } - public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException { + public CheckEBomException(Long bomRowId) { allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId, true); //只检查待复核和自己的 From 8f1fb6c330697c1c9656a82a445a00139c335b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 7 May 2024 11:10:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E5=88=B0excel?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=95=B0=E6=8D=AE=E7=94=B1?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E4=BC=A0=E8=BF=87=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/DQBomApi.java | 12 ++++++++++ .../nflg/product/bomnew/api/user/TestApi.java | 22 +++++++++++++++++++ .../pojo/vo/OperationErrorMsgBaseVO.java | 2 ++ .../bomnew/pojo/vo/OperationErrorMsgVO.java | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/DQBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/DQBomApi.java index 0cf761ef..956a9e67 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/DQBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/DQBomApi.java @@ -239,4 +239,16 @@ public class DQBomApi extends BaseApi { public ResultVO> getBomException(@Valid @RequestBody @NotEmpty List query) { return ResultVO.success(dQBomService.getBomException(query)); } + + /** + * 导出错误信息到excel + * @param messages 错误信息 + * @return + */ + @PostMapping("exportErrorToExcel") + @ApiOperation("导出错误信息到excel") + public void exportErrorToExcel(@Valid @RequestBody @NotNull List messages + , HttpServletResponse response) throws IOException { + EecExcelUtil.export(response, messages, OperationErrorMsgVO.class, "错误信息"); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/TestApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/TestApi.java index 88575698..f08ab8aa 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/TestApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/TestApi.java @@ -11,9 +11,12 @@ import io.swagger.annotations.ApiOperation; import nflg.product.common.vo.ResultVO; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -30,6 +33,10 @@ public class TestApi { @Resource SapOpUtilService sapOpUtilService; + /** + * sap接口测试 + * @return + */ @GetMapping("sap") @ApiOperation("sap接口测试") public ResultVO> workDetailsListByPage() { @@ -52,4 +59,19 @@ public class TestApi { sapDto.setT1(t1s); return ResultVO.success(sapOpUtilService.importToSapV2(sapDto, null)); } + + /** + * 获取异常信息 + * @param num 数量 + * @return + */ + @GetMapping("getErrors") + @ApiOperation("获取异常信息") + public ResultVO> getErrors(@Valid @RequestParam("num") @NotNull Integer num) { + List msgs = new ArrayList<>(); + for (int i = 0; i < num; i++) { + msgs.add(OperationErrorMsgVO.create("主键数据:" + i, "错误描述:" + i)); + } + return ResultVO.success(msgs); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgBaseVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgBaseVO.java index 0cc71b1b..63689139 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgBaseVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgBaseVO.java @@ -1,6 +1,7 @@ package com.nflg.product.bomnew.pojo.vo; import io.swagger.annotations.ApiModelProperty; +import org.ttzero.excel.annotation.ExcelColumn; import java.io.Serializable; @@ -11,6 +12,7 @@ import java.io.Serializable; public class OperationErrorMsgBaseVO implements Serializable { @ApiModelProperty("错误描述") + @ExcelColumn("异常信息") public String msg; public OperationErrorMsgBaseVO() { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgVO.java index 23e02cb5..052affbf 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/OperationErrorMsgVO.java @@ -1,6 +1,8 @@ package com.nflg.product.bomnew.pojo.vo; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.ttzero.excel.annotation.ExcelColumn; import java.io.Serializable; @@ -8,9 +10,11 @@ import java.io.Serializable; * @author 曹鹏飞 * @date 2024-03-21 14:49:05 */ +@Data public class OperationErrorMsgVO extends OperationErrorMsgBaseVO implements Serializable { @ApiModelProperty("主键数据") + @ExcelColumn("所在行") public String primaryKey; public OperationErrorMsgVO() {