From bad832b9dcf4e84c970fbea2abc41d036a2a0af3 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Wed, 9 Oct 2024 23:31:11 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3BOM=E3=80=91=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java 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 new file mode 100644 index 00000000..4e582e82 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java @@ -0,0 +1,47 @@ +package com.nflg.product.bomnew.api.user; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.nflg.product.base.core.api.BaseApi; +import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.service.MaterialMainService; +import io.swagger.annotations.Api; +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 java.util.Collections; +import java.util.List; + +/** + * 批量替代BOM + * + * @author makejava + * @since 2023-11-17 16:55:08 + */ +@Api(tags = "批量替代BOM接口") +@RestController +@RequestMapping("bom/new/batchBom") +public class BatchBomApi extends BaseApi { + + @Resource + private MaterialMainService materialMainService; + + @GetMapping("getMaterialInfo") + @ApiOperation("查询物料信息") + public ResultVO getMaterialInfo(@RequestParam String materialNo) { + if (ObjectUtil.isEmpty(materialNo)) { + return ResultVO.error("物料编码不能为空"); + } + List materialBaseInfo = materialMainService.getMaterialBaseInfo(Collections.singletonList(materialNo)); + if (CollectionUtil.isEmpty(materialBaseInfo)) { + return ResultVO.error("物料编码不存在"); + } + return ResultVO.success(materialBaseInfo.get(0)); + } + +} From a40c73a9eef2de2adb26d32195226ccc2ca34243 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Thu, 10 Oct 2024 17:09:26 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3BOM=E3=80=91=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 19 ++- .../bomnew/pojo/query/BatchBomQuery.java | 43 +++++++ .../product/bomnew/pojo/vo/BaseBomVO.java | 90 ++++++++++++++ .../bomnew/service/BatchBomService.java | 114 ++++++++++++++++++ 4 files changed, 261 insertions(+), 5 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java 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 4e582e82..8b7a3ade 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,17 +3,19 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollectionUtil; 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.vo.BaseBomVO; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.service.BatchBomService; import com.nflg.product.bomnew.service.MaterialMainService; import io.swagger.annotations.Api; 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 org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.util.Collections; import java.util.List; @@ -21,7 +23,6 @@ import java.util.List; * 批量替代BOM * * @author makejava - * @since 2023-11-17 16:55:08 */ @Api(tags = "批量替代BOM接口") @RestController @@ -30,6 +31,8 @@ public class BatchBomApi extends BaseApi { @Resource private MaterialMainService materialMainService; + @Resource + private BatchBomService batchBomService; @GetMapping("getMaterialInfo") @ApiOperation("查询物料信息") @@ -44,4 +47,10 @@ public class BatchBomApi extends BaseApi { return ResultVO.success(materialBaseInfo.get(0)); } + @PostMapping("getParentBomList") + @ApiOperation("获取指定物料号的所有父级BOM列表") + public ResultVO> getParentBomList(@Valid @RequestBody @NotNull BatchBomQuery batchBomQuery) { + return ResultVO.success(batchBomService.getParentBomList(batchBomQuery)); + } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java new file mode 100644 index 00000000..f4f4fc41 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java @@ -0,0 +1,43 @@ +package com.nflg.product.bomnew.pojo.query; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class BatchBomQuery implements Serializable { + + @ApiModelProperty(value = "原物料号") + @NotNull + private String materialNo; + + @ApiModelProperty(value = "新物料号") + @NotNull + private String newMaterialNo; + + @ApiModelProperty(value = "原物料单位") + @NotNull + private String materialUnit; + + @ApiModelProperty(value = "新物料单位") + @NotNull + private String newMaterialUnit; + + @ApiModelProperty(value = "换算前") + @NotNull + private BigDecimal replaceTimes; + + @ApiModelProperty(value = "换算后") + @NotNull + private BigDecimal newReplaceTimes; + + @ApiModelProperty(value = "BOM类型") + @NotNull + private String bomType; + + @ApiModelProperty(value = "工厂") + private String factory; +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java new file mode 100644 index 00000000..4ab2c7dc --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java @@ -0,0 +1,90 @@ +package com.nflg.product.bomnew.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class BaseBomVO { + + @ApiModelProperty("序号") + private Long orderNum; + + @ApiModelProperty("父级BOM ID") + private Long parentRowId; + + @ApiModelProperty("父级物料主数据行ID") + private Long parentMaterialRowId; + + @ApiModelProperty("父级物料编码") + private String parentMaterialNo; + + @ApiModelProperty("父级物料描述") + private String parentMaterialDesc; + + @ApiModelProperty("物料大类别") + private String relCategoryCode; + + @ApiModelProperty("物料类别代码") + private String categoryCode; + + @ApiModelProperty("物料类别") + private String categoryName; + + @ApiModelProperty("父级BOM版本号") + private String parentVersion; + + @ApiModelProperty("原物料编码") + private String materialNo; + + @ApiModelProperty("原数量") + private BigDecimal num; + + @ApiModelProperty("原单位") + private String unit; + + @ApiModelProperty("新物料编码") + private String newMaterialNo; + + @ApiModelProperty("新数量") + private BigDecimal newNum; + + @ApiModelProperty("新单位") + private String newUnit; + + @ApiModelProperty("新版本号") + private String newVersion; + + /** + * 设计人员编码 + */ + @ApiModelProperty(value = "设计人员编码") + private String deviseUserCode; + + /** + * 设计人员名称 + */ + @ApiModelProperty(value = "设计人员名称") + private String deviseName; + + /** + * 创建人编码 + */ + @ApiModelProperty(value = "创建人编码") + private String createdBy; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private LocalDateTime createdTime; + + /** + * 版本过期时间 + */ + @ApiModelProperty(value = "版本过期时间") + private LocalDateTime expireEndTime; + +} 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 new file mode 100644 index 00000000..4a6e253c --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java @@ -0,0 +1,114 @@ +package com.nflg.product.bomnew.service; + +import cn.hutool.core.collection.CollectionUtil; +import com.nflg.product.base.core.exception.NflgBusinessException; +import com.nflg.product.bomnew.constant.EBomStatusEnum; +import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; +import com.nflg.product.bomnew.pojo.query.BatchBomQuery; +import com.nflg.product.bomnew.pojo.vo.BaseBomVO; +import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.util.ListCommonUtil; +import com.nflg.product.bomnew.util.VersionUtil; +import lombok.extern.slf4j.Slf4j; +import nflg.product.common.constant.STATE; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class BatchBomService { + + @Resource + private BomNewEbomParentService bomNewEbomParentService; + @Resource + private BomNewEbomChildService bomNewEbomChildService; + @Resource + private BomNewPbomParentService bomNewPbomParentService; + @Resource + private BomNewPbomChildService bomNewPbomChildService; + @Resource + private MaterialMainService materialMainService; + + public List getParentBomList(BatchBomQuery batchBomQuery) { + if (batchBomQuery.getReplaceTimes().compareTo(BigDecimal.ZERO) == 0 || batchBomQuery.getNewReplaceTimes().compareTo(BigDecimal.ZERO) == 0) { + throw new NflgBusinessException(STATE.ParamErr, "参数错误,换算关系不能为0"); + } + List resultList = new ArrayList<>(); + String bomType = batchBomQuery.getBomType(); + if ("ebom".equals(bomType)) { + String materialNo = batchBomQuery.getMaterialNo(); + // 查询出子级 + List ebomChildEntities = bomNewEbomChildService.lambdaQuery() + .eq(BomNewEbomChildEntity::getMaterialNo, materialNo) + .list(); + if (CollectionUtil.isNotEmpty(ebomChildEntities)) { + // 根据子级的parentRowId查询父级(状态是已发布PBOM,即正式表数据) + List parentRowIds = ebomChildEntities.stream().map(BomNewEbomChildEntity::getParentRowId).collect(Collectors.toList()); + List ebomParentEntities = bomNewEbomParentService.lambdaQuery() + .in(BomNewEbomParentEntity::getRowId, parentRowIds) + .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) + .orderByDesc(BomNewEbomParentEntity::getCreatedTime) + .list(); + if (CollectionUtil.isNotEmpty(ebomParentEntities)) { + long counter = 0; + for (BomNewEbomParentEntity parent : ebomParentEntities) { + BaseBomVO baseBomVO = new BaseBomVO(); + baseBomVO.setOrderNum(++counter); + baseBomVO.setParentRowId(parent.getRowId()); + baseBomVO.setParentMaterialNo(parent.getMaterialNo()); + baseBomVO.setParentVersion(parent.getCurrentVersion()); + baseBomVO.setCreatedBy(parent.getCreatedBy()); + baseBomVO.setCreatedTime(parent.getCreatedTime()); + baseBomVO.setExpireEndTime(parent.getExpireEndTime()); + baseBomVO.setDeviseUserCode(parent.getDeviseUserCode()); + baseBomVO.setDeviseName(parent.getDeviseName()); + Optional first = ebomChildEntities.stream().filter(item -> item.getParentRowId().equals(parent.getRowId())).findFirst(); + if (first.isPresent()) { + BomNewEbomChildEntity ebomChild = first.get(); + baseBomVO.setMaterialNo(ebomChild.getMaterialNo()); + baseBomVO.setNum(ebomChild.getNum()); + baseBomVO.setUnit(ebomChild.getMaterialUnit()); + } + baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); + baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), 3, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); + baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); + resultList.add(baseBomVO); + } + } + } + } else if ("pbom".equals(bomType)) { + + } + 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()); + }); + return resultList; + } + +} From 04503f8c26c955c18a31efae2bb6d3bd533e39a2 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Sat, 12 Oct 2024 17:39:02 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 35 +++ .../product/bomnew/pojo/vo/BaseBomVO.java | 3 + .../bomnew/service/BatchBomService.java | 283 +++++++++++++++++- 3 files changed, 316 insertions(+), 5 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 8b7a3ade..a5515ede 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 @@ -1,12 +1,16 @@ 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 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.service.BatchBomService; +import com.nflg.product.bomnew.service.BomNewEbomExportToSAP; +import com.nflg.product.bomnew.service.BomNewPbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -33,6 +37,8 @@ public class BatchBomApi extends BaseApi { private MaterialMainService materialMainService; @Resource private BatchBomService batchBomService; + @Resource + private BomNewPbomParentService bomNewPbomParentService; @GetMapping("getMaterialInfo") @ApiOperation("查询物料信息") @@ -53,4 +59,33 @@ public class BatchBomApi extends BaseApi { return ResultVO.success(batchBomService.getParentBomList(batchBomQuery)); } + @PostMapping("updateEBom") + @ApiOperation("更新EBOM并导入SAP") + public ResultVO> updateEBom(@RequestBody List baseBomVOList) { + List addRowIds = batchBomService.updateEBom(baseBomVOList); + // 导入SAP + if (CollUtil.isNotEmpty(addRowIds)) { + addRowIds.forEach(rootRowId -> { + BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); + exportToSAP.export(rootRowId); + }); + } + return ResultVO.success(); + } + + @PostMapping("updatePBom") + @ApiOperation("更新PBOM并导入SAP") + public ResultVO> updatePBom(@RequestBody List baseBomVOList) { + List addRowIds = batchBomService.updatePBom(baseBomVOList); + // 导入SAP + if (CollUtil.isNotEmpty(addRowIds)) { + addRowIds.forEach(rootRowId -> { + PbomImportToSAPQuery query = new PbomImportToSAPQuery(); + query.setRootBomRowId(rootRowId); + query.setIsForSale(false); + bomNewPbomParentService.importToSAP2(query); + }); + } + return ResultVO.success(); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java index 4ab2c7dc..84fcc9d6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java @@ -36,6 +36,9 @@ public class BaseBomVO { @ApiModelProperty("父级BOM版本号") private String parentVersion; + @ApiModelProperty("子级BOM ID") + private Long childRowId; + @ApiModelProperty("原物料编码") private String materialNo; 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 4a6e253c..7ff62470 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 @@ -1,10 +1,22 @@ package com.nflg.product.bomnew.service; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.EBomStatusEnum; +import com.nflg.product.bomnew.constant.PBomStatusEnum; +import com.nflg.product.bomnew.constant.SapStatusEnum; +import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper; +import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper; +import com.nflg.product.bomnew.mapper.master.BomNewPbomChildMapper; +import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.query.BatchBomQuery; import com.nflg.product.bomnew.pojo.vo.BaseBomVO; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; @@ -13,14 +25,13 @@ import com.nflg.product.bomnew.util.VersionUtil; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.time.LocalDateTime; +import java.util.*; import java.util.stream.Collectors; @Service @@ -32,10 +43,18 @@ public class BatchBomService { @Resource private BomNewEbomChildService bomNewEbomChildService; @Resource + private BomNewEbomParentMapper bomNewEbomParentMapper; + @Resource + private BomNewEbomChildMapper bomNewEbomChildMapper; + @Resource private BomNewPbomParentService bomNewPbomParentService; @Resource private BomNewPbomChildService bomNewPbomChildService; @Resource + private BomNewPbomParentMapper bomNewPbomParentMapper; + @Resource + private BomNewPbomChildMapper bomNewPbomChildMapper; + @Resource private MaterialMainService materialMainService; public List getParentBomList(BatchBomQuery batchBomQuery) { @@ -74,6 +93,7 @@ public class BatchBomService { Optional first = ebomChildEntities.stream().filter(item -> item.getParentRowId().equals(parent.getRowId())).findFirst(); if (first.isPresent()) { BomNewEbomChildEntity ebomChild = first.get(); + baseBomVO.setChildRowId(ebomChild.getRowId()); baseBomVO.setMaterialNo(ebomChild.getMaterialNo()); baseBomVO.setNum(ebomChild.getNum()); baseBomVO.setUnit(ebomChild.getMaterialUnit()); @@ -87,7 +107,49 @@ public class BatchBomService { } } } else if ("pbom".equals(bomType)) { - + String materialNo = batchBomQuery.getMaterialNo(); + // 查询出子级 + List pbomChildEntities = bomNewPbomChildService.lambdaQuery() + .eq(BomNewPbomChildEntity::getMaterialNo, materialNo) + .eq(BomNewPbomChildEntity::getFacCode, batchBomQuery.getFactory()) // 工厂查询 + .list(); + if (CollectionUtil.isNotEmpty(pbomChildEntities)) { + // 根据子级的parentRowId查询父级(状态是>=已发布,即正式表数据) + List parentRowIds = pbomChildEntities.stream().map(BomNewPbomChildEntity::getParentRowId).collect(Collectors.toList()); + List pbomParentEntities = bomNewPbomParentService.lambdaQuery() + .in(BomNewPbomParentEntity::getRowId, parentRowIds) + .ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) + .orderByDesc(BomNewPbomParentEntity::getCreatedTime) + .list(); + if (CollectionUtil.isNotEmpty(pbomParentEntities)) { + long counter = 0; + for (BomNewPbomParentEntity parent : pbomParentEntities) { + BaseBomVO baseBomVO = new BaseBomVO(); + baseBomVO.setOrderNum(++counter); + baseBomVO.setParentRowId(parent.getRowId()); + baseBomVO.setParentMaterialNo(parent.getMaterialNo()); + baseBomVO.setParentVersion(parent.getCurrentVersion()); + baseBomVO.setCreatedBy(parent.getCreatedBy()); + baseBomVO.setCreatedTime(parent.getCreatedTime()); + baseBomVO.setExpireEndTime(parent.getExpireEndTime()); + baseBomVO.setDeviseUserCode(parent.getDeviseUserCode()); + baseBomVO.setDeviseName(parent.getDeviseName()); + Optional first = pbomChildEntities.stream().filter(item -> item.getParentRowId().equals(parent.getRowId())).findFirst(); + if (first.isPresent()) { + BomNewPbomChildEntity pbomChild = first.get(); + baseBomVO.setChildRowId(pbomChild.getRowId()); + baseBomVO.setMaterialNo(pbomChild.getMaterialNo()); + baseBomVO.setNum(pbomChild.getNum()); + baseBomVO.setUnit(pbomChild.getMaterialUnit()); + } + baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); + baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), 3, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); + baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); + resultList.add(baseBomVO); + } + } + } } if (CollectionUtil.isEmpty(resultList)) { return null; @@ -111,4 +173,215 @@ public class BatchBomService { return resultList; } + /** + * 更新BOM并导入SAP(但是EBOM的话,不生成PBOM工作表) + * @param baseBomVOList + */ + @Transactional(rollbackFor = Exception.class) + public List updateEBom(List baseBomVOList) { + if (CollectionUtil.isEmpty(baseBomVOList)) { + return null; + } + List materialBaseInfo = materialMainService.getMaterialBaseInfo(Collections.singletonList(baseBomVOList.get(0).getNewMaterialNo())); + if (CollectionUtil.isEmpty(materialBaseInfo)) { + throw new NflgBusinessException(STATE.ParamErr, "新物料编码不存在"); + } + BaseMaterialVO newMaterialInfo= materialBaseInfo.get(0); + List addRowIds = new ArrayList<>(baseBomVOList.size()); // 需要加入历史表的父级BOM ID + List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID + for (BaseBomVO baseBomVO: baseBomVOList) { + // 找到父级 + BomNewEbomParentEntity ebomParentEntity = bomNewEbomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); + if (ObjectUtil.isNotEmpty(ebomParentEntity)) { + LocalDateTime now = LocalDateTime.now(); + // 找到该父级的所有子级列表 + List ebomChildEntities = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); + // 在子级列表中找到要被替换的那条子级 + List collect = ebomChildEntities.stream().filter(item -> item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList()); + BomNewEbomChildEntity replaceChild = collect.get(0); + // 其他子级 + List otherChildren = ebomChildEntities.stream().filter(item -> !item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList()); + // 构建新版的父级规则:大版本号+1(如果该BOM还有编辑中的草稿版本,则草稿版本号也+1) + BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); + BeanUtil.copyProperties(ebomParentEntity, newParent); + newParent.setRowId(IdWorker.getId()); + newParent.setCurrentVersion(baseBomVO.getNewVersion()); // 新版本号 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newParent.setCreatedTime(now); + newParent.setModifyTime(now); + newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); + newParent.setSapTime(null); + // 构建新版的子级规则:其他子级复制一份,被替换的子级改物料编码,数量,单位等 + List newChildList = new ArrayList<>(ebomChildEntities.size()); + otherChildren.forEach(item -> { + BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(item, newChild); + newChild.setRowId(IdWorker.getId()); + newChild.setParentRowId(newParent.getRowId()); + newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId()); + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newChild.setCreatedTime(now); + newChild.setModifyTime(now); + newChildList.add(newChild); + }); + BomNewEbomChildEntity newReplaceChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(replaceChild, newReplaceChild); + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setParentRowId(newParent.getRowId()); + newReplaceChild.setIdentityNo(newParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newChildList.add(newReplaceChild); + bomNewEbomParentService.save(newParent); + bomNewEbomChildService.saveBatch(newChildList); + addRowIds.add(newParent.getRowId()); + } + delRowIds.add(ebomParentEntity.getRowId()); + } + // 转入历史表 + if (CollUtil.isNotEmpty(addRowIds)) { + bomNewEbomParentMapper.insertEBomFormalParent(addRowIds); + bomNewEbomParentMapper.insertEBomFormalChild(addRowIds); + } + if (CollUtil.isNotEmpty(delRowIds)){ + // 转移后删除 + bomNewEbomParentService.delEBomHistory(delRowIds); + } + // TODO 如果有草稿中数据,草稿版本+1 + for (BaseBomVO baseBomVO: baseBomVOList) { + BomNewEbomParentEntity draftParent = bomNewEbomParentService.lambdaQuery() + .eq(BomNewEbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) + .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) + .one(); + if (ObjectUtil.isNotEmpty(draftParent)) { + // 草稿版本 A01 -> A02,A01.1 -> A02.1 + String[] currentVersionArr = draftParent.getCurrentVersion().split("."); + String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]); + if (currentVersionArr.length > 1) { + newVersion += "." + currentVersionArr[1]; + } + draftParent.setCurrentVersion(newVersion); + draftParent.setModifyTime(LocalDateTime.now()); + bomNewEbomParentService.updateById(draftParent); + } + } + return addRowIds; + } + + /** + * 更新BOM并导入SAP + * @param baseBomVOList + */ + @Transactional(rollbackFor = Exception.class) + public List updatePBom(List baseBomVOList) { + if (CollectionUtil.isEmpty(baseBomVOList)) { + return null; + } + List materialBaseInfo = materialMainService.getMaterialBaseInfo(Collections.singletonList(baseBomVOList.get(0).getNewMaterialNo())); + if (CollectionUtil.isEmpty(materialBaseInfo)) { + throw new NflgBusinessException(STATE.ParamErr, "新物料编码不存在"); + } + BaseMaterialVO newMaterialInfo= materialBaseInfo.get(0); + List addRowIds = new ArrayList<>(baseBomVOList.size()); // 需要加入历史表的父级BOM ID + List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID + for (BaseBomVO baseBomVO: baseBomVOList) { + // 找到父级 + BomNewPbomParentEntity pbomParentEntity = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); + if (ObjectUtil.isNotEmpty(pbomParentEntity)) { + LocalDateTime now = LocalDateTime.now(); + // 找到该父级的所有子级列表 + List pbomChildEntities = bomNewPbomChildService.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); + // 在子级列表中找到要被替换的那条子级 + List collect = pbomChildEntities.stream().filter(item -> item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList()); + BomNewPbomChildEntity replaceChild = collect.get(0); + // 其他子级 + List otherChildren = pbomChildEntities.stream().filter(item -> !item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList()); + // 构建新版的父级规则:大版本号+1(如果该BOM还有编辑中的草稿版本,则草稿版本号也+1) + BomNewPbomParentEntity newParent = new BomNewPbomParentEntity(); + BeanUtil.copyProperties(pbomParentEntity, newParent); + newParent.setRowId(IdWorker.getId()); + newParent.setCurrentVersion(baseBomVO.getNewVersion()); // 新版本号 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newParent.setCreatedTime(now); + newParent.setModifyTime(now); + newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); + newParent.setSapTime(null); + // 构建新版的子级规则:其他子级复制一份,被替换的子级改物料编码,数量,单位等 + List newChildList = new ArrayList<>(pbomChildEntities.size()); + otherChildren.forEach(item -> { + BomNewPbomChildEntity newChild = new BomNewPbomChildEntity(); + BeanUtil.copyProperties(item, newChild); + newChild.setRowId(IdWorker.getId()); + newChild.setParentRowId(newParent.getRowId()); + newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId()); + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newChild.setCreatedTime(now); + newChild.setModifyTime(now); + newChildList.add(newChild); + }); + BomNewPbomChildEntity newReplaceChild = new BomNewPbomChildEntity(); + BeanUtil.copyProperties(replaceChild, newReplaceChild); + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setParentRowId(newParent.getRowId()); + newReplaceChild.setIdentityNo(newParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newChildList.add(newReplaceChild); + bomNewPbomParentService.save(newParent); + bomNewPbomChildService.saveBatch(newChildList); + addRowIds.add(newParent.getRowId()); + } + delRowIds.add(pbomParentEntity.getRowId()); + } + // 转入历史表 + if (CollUtil.isNotEmpty(addRowIds)) { + bomNewPbomParentMapper.insertPBomParentToFormal(addRowIds); + bomNewPbomParentMapper.insertPBomChildToFormal(addRowIds); + } + if (CollUtil.isNotEmpty(delRowIds)){ + // 转移后删除 + bomNewPbomParentService.delPBom(delRowIds); + } + // TODO 如果有草稿中数据,草稿版本+1 + for (BaseBomVO baseBomVO: baseBomVOList) { + BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery() + .eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) + .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) + .one(); + if (ObjectUtil.isNotEmpty(draftParent)) { + // 草稿版本 A01 -> A02,A01.1 -> A02.1 + String[] currentVersionArr = draftParent.getCurrentVersion().split("."); + String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]); + if (currentVersionArr.length > 1) { + newVersion += "." + currentVersionArr[1]; + } + draftParent.setCurrentVersion(newVersion); + draftParent.setModifyTime(LocalDateTime.now()); + bomNewPbomParentService.updateById(draftParent); + } + } + return addRowIds; + } } From 38428173456b0dc6de90f1047f1786e7fa564a9b Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Wed, 16 Oct 2024 16:31:07 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E3=80=90=E7=89=A9=E6=96=99=E4=B8=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E3=80=91=E6=89=B9=E9=87=8F=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=EF=BC=8C=E5=9B=BE=E5=8F=B7=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/material/service/MaterialUpdateBillService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/material/src/main/java/com/nflg/product/material/service/MaterialUpdateBillService.java b/nflg_project_dev/material/src/main/java/com/nflg/product/material/service/MaterialUpdateBillService.java index d8b1b9ca..edb51f67 100644 --- a/nflg_project_dev/material/src/main/java/com/nflg/product/material/service/MaterialUpdateBillService.java +++ b/nflg_project_dev/material/src/main/java/com/nflg/product/material/service/MaterialUpdateBillService.java @@ -700,9 +700,9 @@ public class MaterialUpdateBillService extends ServiceImpl drawingNoList = excelContext.stream().map(TwentyMaterialTemplateExcelDTO::getDrawingNo).collect(Collectors.toList()); List entityList = this.materialMainService.lambdaQuery().in(MaterialMainEntity::getDrawingNo, drawingNoList).list(); if (entityList != null && entityList.size() > 0) { - List drawingNos = entityList.stream().map(MaterialMainEntity::getDrawingNo).collect(Collectors.toList()); List others = entityList.stream().filter(item -> !upMaterialNos.contains(item.getMaterialNo())).collect(Collectors.toList()); if (others.size() > 0) { + List drawingNos = others.stream().map(MaterialMainEntity::getDrawingNo).collect(Collectors.toList()); throw new NflgBusinessException(STATE.ParamErr, StrUtil.join(",", drawingNos).concat("的图号在正式物料中已存在")); } } From 52530bee3b1e6acee61015a63ac97d3a58f5854d Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Thu, 17 Oct 2024 15:34:53 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/constant/DateTypeEnum.java | 23 + .../bomnew/pojo/query/BatchBomQuery.java | 13 + .../bomnew/service/BatchBomService.java | 76 +- .../nflg/product/bomnew/util/DateUtils.java | 650 ++++++++++++++++++ 4 files changed, 759 insertions(+), 3 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/DateTypeEnum.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/DateUtils.java diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/DateTypeEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/DateTypeEnum.java new file mode 100644 index 00000000..a5abd2ed --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/DateTypeEnum.java @@ -0,0 +1,23 @@ +package com.nflg.product.bomnew.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 物料创建时间,1=7天,2=30天,3=90天,4=一段时间 + * @decription + * @Author LYK + * @Date 2022/9/2 10:15 + **/ +@Getter +@AllArgsConstructor +public enum DateTypeEnum { + ZERO(0,"全部"), + SEVEN(1,"7天"), + THIRTY(2,"30天"), + NINETY(3,"90天"), + LONGDATE(4,"一段时间"); + + private final Integer code; + private final String msg; +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java index f4f4fc41..39df6f52 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java @@ -34,10 +34,23 @@ public class BatchBomQuery implements Serializable { @NotNull private BigDecimal newReplaceTimes; + @ApiModelProperty(value = "新数量小数位") + @NotNull + private Integer decimalScale; + @ApiModelProperty(value = "BOM类型") @NotNull private String bomType; @ApiModelProperty(value = "工厂") private String factory; + + @ApiModelProperty(value = "日期类型") + private Integer dateType; + + @ApiModelProperty("统计开始时间") + private String startDate; + + @ApiModelProperty("统计结束时间") + private String endDate; } 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 7ff62470..1ac9ba68 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 @@ -3,9 +3,12 @@ package com.nflg.product.bomnew.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.nflg.product.base.core.exception.NflgBusinessException; +import com.nflg.product.bomnew.constant.DateTypeEnum; import com.nflg.product.bomnew.constant.EBomStatusEnum; import com.nflg.product.bomnew.constant.PBomStatusEnum; import com.nflg.product.bomnew.constant.SapStatusEnum; @@ -20,6 +23,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.query.BatchBomQuery; import com.nflg.product.bomnew.pojo.vo.BaseBomVO; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.util.DateUtils; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VersionUtil; import lombok.extern.slf4j.Slf4j; @@ -31,6 +35,8 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -58,11 +64,14 @@ public class BatchBomService { private MaterialMainService materialMainService; public List getParentBomList(BatchBomQuery batchBomQuery) { - if (batchBomQuery.getReplaceTimes().compareTo(BigDecimal.ZERO) == 0 || batchBomQuery.getNewReplaceTimes().compareTo(BigDecimal.ZERO) == 0) { + if (!(batchBomQuery.getMaterialUnit().equals(batchBomQuery.getNewMaterialUnit())) + && (batchBomQuery.getReplaceTimes().compareTo(BigDecimal.ZERO) == 0 || batchBomQuery.getNewReplaceTimes().compareTo(BigDecimal.ZERO) == 0)) { throw new NflgBusinessException(STATE.ParamErr, "参数错误,换算关系不能为0"); } List resultList = new ArrayList<>(); String bomType = batchBomQuery.getBomType(); + Integer decimalScale = batchBomQuery.getDecimalScale(); + buildQueryCondition(batchBomQuery); if ("ebom".equals(bomType)) { String materialNo = batchBomQuery.getMaterialNo(); // 查询出子级 @@ -80,6 +89,19 @@ public class BatchBomService { if (CollectionUtil.isNotEmpty(ebomParentEntities)) { long counter = 0; for (BomNewEbomParentEntity parent : ebomParentEntities) { + // 按创建时间过滤 + if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { + LocalDateTime startTime = LocalDateTime.parse(batchBomQuery.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + if (parent.getCreatedTime().isBefore(startTime)) { + continue; + } + } + if (ObjectUtil.isNotEmpty(batchBomQuery.getEndDate())) { + LocalDateTime endTime = LocalDateTime.parse(batchBomQuery.getEndDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + if (parent.getCreatedTime().isAfter(endTime)) { + continue; + } + } BaseBomVO baseBomVO = new BaseBomVO(); baseBomVO.setOrderNum(++counter); baseBomVO.setParentRowId(parent.getRowId()); @@ -99,7 +121,7 @@ public class BatchBomService { baseBomVO.setUnit(ebomChild.getMaterialUnit()); } baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); - baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), 3, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); resultList.add(baseBomVO); @@ -124,6 +146,19 @@ public class BatchBomService { if (CollectionUtil.isNotEmpty(pbomParentEntities)) { long counter = 0; for (BomNewPbomParentEntity parent : pbomParentEntities) { + // 按创建时间过滤 + if (ObjectUtil.isNotEmpty(batchBomQuery.getStartDate())) { + LocalDateTime startTime = LocalDateTimeUtil.parse(batchBomQuery.getStartDate(), DatePattern.NORM_DATE_PATTERN); + if (parent.getCreatedTime().isBefore(startTime)) { + continue; + } + } + if (ObjectUtil.isNotEmpty(batchBomQuery.getEndDate())) { + LocalDateTime endTime = LocalDateTimeUtil.parse(batchBomQuery.getEndDate(), DatePattern.NORM_DATE_PATTERN); + if (parent.getCreatedTime().isAfter(endTime)) { + continue; + } + } BaseBomVO baseBomVO = new BaseBomVO(); baseBomVO.setOrderNum(++counter); baseBomVO.setParentRowId(parent.getRowId()); @@ -143,7 +178,7 @@ public class BatchBomService { baseBomVO.setUnit(pbomChild.getMaterialUnit()); } baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); - baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), 3, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); resultList.add(baseBomVO); @@ -173,6 +208,41 @@ public class BatchBomService { return resultList; } + private void buildQueryCondition(BatchBomQuery query) { + if (query.getDateType() != null) { + if (query.getDateType().compareTo(DateTypeEnum.ZERO.getCode()) == 0) { + query.setStartDate(null); + query.setEndDate(null); + } else { + if (query.getDateType().compareTo(DateTypeEnum.SEVEN.getCode()) == 0) { + String endDate = DateUtils.date2Str(DateUtils.datetimeFormat.get()); + query.setEndDate(endDate); + ZonedDateTime zonedDateTime = ZonedDateTime.now().minusDays(6).withHour(0).withMinute(0).withSecond(0).withNano(0); + String startDate = zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + query.setStartDate(startDate); + } + if (query.getDateType().compareTo(DateTypeEnum.THIRTY.getCode()) == 0) { + String endDate = DateUtils.date2Str(DateUtils.datetimeFormat.get()); + query.setEndDate(endDate); + ZonedDateTime zonedDateTime = ZonedDateTime.now().minusDays(29).withHour(0).withMinute(0).withSecond(0).withNano(0); + String startDate = zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + query.setStartDate(startDate); + } + if (query.getDateType().compareTo(DateTypeEnum.NINETY.getCode()) == 0) { + String endDate = DateUtils.date2Str(DateUtils.datetimeFormat.get()); + query.setEndDate(endDate); + ZonedDateTime zonedDateTime = ZonedDateTime.now().minusDays(89).withHour(0).withMinute(0).withSecond(0).withNano(0); + String startDate = zonedDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + query.setStartDate(startDate); + } + if (query.getDateType().compareTo(DateTypeEnum.LONGDATE.getCode()) == 0 && ObjectUtil.isNotEmpty(query.getStartDate()) && ObjectUtil.isNotEmpty(query.getEndDate())) { + query.setEndDate(query.getEndDate() + " 00:00:00"); + query.setStartDate(query.getStartDate() + " 00:00:00"); + } + } + } + } + /** * 更新BOM并导入SAP(但是EBOM的话,不生成PBOM工作表) * @param baseBomVOList diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/DateUtils.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/DateUtils.java new file mode 100644 index 00000000..c4eae47c --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/DateUtils.java @@ -0,0 +1,650 @@ +package com.nflg.product.bomnew.util; + +import org.springframework.util.StringUtils; + +import java.beans.PropertyEditorSupport; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * @Author 大米 + * @Date 2022-03-11 + */ +public class DateUtils extends PropertyEditorSupport { + + public static ThreadLocal date_sdf = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + public static ThreadLocal yyyyMMdd = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyyMMdd"); + } + }; + public static ThreadLocal date_sdf_wz = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy年MM月dd日"); + } + }; + public static ThreadLocal time_sdf = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm"); + } + }; + public static ThreadLocal yyyymmddhhmmss = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyyMMddHHmmss"); + } + }; + public static ThreadLocal short_time_sdf = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("HH:mm"); + } + }; + public static ThreadLocal datetimeFormat = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + } + }; + + // 以毫秒表示的时间 + private static final long DAY_IN_MILLIS = 24 * 3600 * 1000; + private static final long HOUR_IN_MILLIS = 3600 * 1000; + private static final long MINUTE_IN_MILLIS = 60 * 1000; + private static final long SECOND_IN_MILLIS = 1000; + + // 指定模式的时间格式 + private static SimpleDateFormat getSDFormat(String pattern) { + return new SimpleDateFormat(pattern); + } + + /** + * 当前日历,这里用中国时间表示 + * + * @return 以当地时区表示的系统当前日历 + */ + public static Calendar getCalendar() { + return Calendar.getInstance(); + } + + /** + * 指定毫秒数表示的日历 + * + * @param millis 毫秒数 + * @return 指定毫秒数表示的日历 + */ + public static Calendar getCalendar(long millis) { + Calendar cal = Calendar.getInstance(); + // --------------------cal.setTimeInMillis(millis); + cal.setTime(new Date(millis)); + return cal; + } + + // //////////////////////////////////////////////////////////////////////////// + // getDate + // 各种方式获取的Date + // //////////////////////////////////////////////////////////////////////////// + + /** + * 当前日期 + * + * @return 系统当前时间 + */ + public static Date getDate() { + return new Date(); + } + + /** + * 指定毫秒数表示的日期 + * + * @param millis 毫秒数 + * @return 指定毫秒数表示的日期 + */ + public static Date getDate(long millis) { + return new Date(millis); + } + + /** + * 时间戳转换为字符串 + * + * @param time + * @return + */ + public static String timestamptoStr(Timestamp time) { + Date date = null; + if (null != time) { + date = new Date(time.getTime()); + } + return date2Str(date_sdf.get()); + } + + /** + * 字符串转换时间戳 + * + * @param str + * @return + */ + public static Timestamp str2Timestamp(String str) { + Date date = str2Date(str, date_sdf.get()); + return new Timestamp(date.getTime()); + } + + /** + * 字符串转换成日期 + * + * @param str + * @param sdf + * @return + */ + public static Date str2Date(String str, SimpleDateFormat sdf) { + if (null == str || "".equals(str)) { + return null; + } + Date date = null; + try { + date = sdf.parse(str); + return date; + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + /** + * 日期转换为字符串 + * + * @param date_sdf 日期格式 + * @return 字符串 + */ + public static String date2Str(SimpleDateFormat date_sdf) { + Date date = getDate(); + if (null == date) { + return null; + } + return date_sdf.format(date); + } + + /** + * 格式化时间 + * + * @param date + * @param format + * @return + */ + public static String dateformat(String date, String format) { + SimpleDateFormat sformat = new SimpleDateFormat(format); + Date _date = null; + try { + _date = sformat.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return sformat.format(_date); + } + + /** + * 日期转换为字符串 + * + * @param date 日期 + * @param date_sdf 日期格式 + * @return 字符串 + */ + public static String date2Str(Date date, SimpleDateFormat date_sdf) { + if (null == date) { + return null; + } + return date_sdf.format(date); + } + + /** + * 日期转换为字符串 + * + * @param format 日期格式 + * @return 字符串 + */ + public static String getDate(String format) { + Date date = new Date(); + if (null == date) { + return null; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + /** + * 指定毫秒数的时间戳 + * + * @param millis 毫秒数 + * @return 指定毫秒数的时间戳 + */ + public static Timestamp getTimestamp(long millis) { + return new Timestamp(millis); + } + + /** + * 以字符形式表示的时间戳 + * + * @param time 毫秒数 + * @return 以字符形式表示的时间戳 + */ + public static Timestamp getTimestamp(String time) { + return new Timestamp(Long.parseLong(time)); + } + + /** + * 系统当前的时间戳 + * + * @return 系统当前的时间戳 + */ + public static Timestamp getTimestamp() { + return new Timestamp(System.currentTimeMillis()); + } + + /** + * 当前时间,格式 yyyy-MM-dd HH:mm:ss + * + * @return 当前时间的标准形式字符串 + */ + public static String now() { + return datetimeFormat.get().format(getCalendar().getTime()); + } + + /** + * 指定日期的时间戳 + * + * @param date 指定日期 + * @return 指定日期的时间戳 + */ + public static Timestamp getTimestamp(Date date) { + return new Timestamp(date.getTime()); + } + + /** + * 指定日历的时间戳 + * + * @param cal 指定日历 + * @return 指定日历的时间戳 + */ + public static Timestamp getCalendarTimestamp(Calendar cal) { + // ---------------------return new Timestamp(cal.getTimeInMillis()); + return new Timestamp(cal.getTime().getTime()); + } + + public static Timestamp gettimestamp() { + Date dt = new Date(); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowTime = df.format(dt); + Timestamp buydate = Timestamp.valueOf(nowTime); + return buydate; + } + + // //////////////////////////////////////////////////////////////////////////// + // getMillis + // 各种方式获取的Millis + // //////////////////////////////////////////////////////////////////////////// + + /** + * 系统时间的毫秒数 + * + * @return 系统时间的毫秒数 + */ + public static long getMillis() { + return System.currentTimeMillis(); + } + + /** + * 指定日历的毫秒数 + * + * @param cal 指定日历 + * @return 指定日历的毫秒数 + */ + public static long getMillis(Calendar cal) { + // --------------------return cal.getTimeInMillis(); + return cal.getTime().getTime(); + } + + /** + * 指定日期的毫秒数 + * + * @param date 指定日期 + * @return 指定日期的毫秒数 + */ + public static long getMillis(Date date) { + return date.getTime(); + } + + /** + * 指定时间戳的毫秒数 + * + * @param ts 指定时间戳 + * @return 指定时间戳的毫秒数 + */ + public static long getMillis(Timestamp ts) { + return ts.getTime(); + } + + // //////////////////////////////////////////////////////////////////////////// + // formatDate + // 将日期按照一定的格式转化为字符串 + // //////////////////////////////////////////////////////////////////////////// + + /** + * 默认方式表示的系统当前日期,具体格式:年-月-日 + * + * @return 默认日期按“年-月-日“格式显示 + */ + public static String formatDate() { + return date_sdf.get().format(getCalendar().getTime()); + } + + /** + * 默认方式表示的系统当前日期,具体格式:yyyy-MM-dd HH:mm:ss + * + * @return 默认日期按“yyyy-MM-dd HH:mm:ss“格式显示 + */ + public static String formatDateTime() { + return datetimeFormat.get().format(getCalendar().getTime()); + } + + /** + * 获取时间字符串 + */ + public static String getDataString(SimpleDateFormat formatstr) { + return formatstr.format(getCalendar().getTime()); + } + + /** + * 指定日期的默认显示,具体格式:年-月-日 + * + * @param cal 指定的日期 + * @return 指定日期按“年-月-日“格式显示 + */ + public static String formatDate(Calendar cal) { + return date_sdf.get().format(cal.getTime()); + } + + /** + * 指定日期的默认显示,具体格式:年-月-日 + * + * @param date 指定的日期 + * @return 指定日期按“年-月-日“格式显示 + */ + public static String formatDate(Date date) { + return date_sdf.get().format(date); + } + + /** + * 指定毫秒数表示日期的默认显示,具体格式:年-月-日 + * + * @param millis 指定的毫秒数 + * @return 指定毫秒数表示日期按“年-月-日“格式显示 + */ + public static String formatDate(long millis) { + return date_sdf.get().format(new Date(millis)); + } + + /** + * 默认日期按指定格式显示 + * + * @param pattern 指定的格式 + * @return 默认日期按指定格式显示 + */ + public static String formatDate(String pattern) { + return getSDFormat(pattern).format(getCalendar().getTime()); + } + + /** + * 指定日期按指定格式显示 + * + * @param cal 指定的日期 + * @param pattern 指定的格式 + * @return 指定日期按指定格式显示 + */ + public static String formatDate(Calendar cal, String pattern) { + return getSDFormat(pattern).format(cal.getTime()); + } + + /** + * 指定日期按指定格式显示 + * + * @param date 指定的日期 + * @param pattern 指定的格式 + * @return 指定日期按指定格式显示 + */ + public static String formatDate(Date date, String pattern) { + return getSDFormat(pattern).format(date); + } + + // //////////////////////////////////////////////////////////////////////////// + // formatTime + // 将日期按照一定的格式转化为字符串 + // //////////////////////////////////////////////////////////////////////////// + + /** + * 默认方式表示的系统当前日期,具体格式:年-月-日 时:分 + * + * @return 默认日期按“年-月-日 时:分“格式显示 + */ + public static String formatTime() { + return time_sdf.get().format(getCalendar().getTime()); + } + + /** + * 指定毫秒数表示日期的默认显示,具体格式:年-月-日 时:分 + * + * @param millis 指定的毫秒数 + * @return 指定毫秒数表示日期按“年-月-日 时:分“格式显示 + */ + public static String formatTime(long millis) { + return time_sdf.get().format(new Date(millis)); + } + + /** + * 指定日期的默认显示,具体格式:年-月-日 时:分 + * + * @param cal 指定的日期 + * @return 指定日期按“年-月-日 时:分“格式显示 + */ + public static String formatTime(Calendar cal) { + return time_sdf.get().format(cal.getTime()); + } + + /** + * 指定日期的默认显示,具体格式:年-月-日 时:分 + * + * @param date 指定的日期 + * @return 指定日期按“年-月-日 时:分“格式显示 + */ + public static String formatTime(Date date) { + return time_sdf.get().format(date); + } + + // //////////////////////////////////////////////////////////////////////////// + // formatShortTime + // 将日期按照一定的格式转化为字符串 + // //////////////////////////////////////////////////////////////////////////// + + /** + * 默认方式表示的系统当前日期,具体格式:时:分 + * + * @return 默认日期按“时:分“格式显示 + */ + public static String formatShortTime() { + return short_time_sdf.get().format(getCalendar().getTime()); + } + + /** + * 指定毫秒数表示日期的默认显示,具体格式:时:分 + * + * @param millis 指定的毫秒数 + * @return 指定毫秒数表示日期按“时:分“格式显示 + */ + public static String formatShortTime(long millis) { + return short_time_sdf.get().format(new Date(millis)); + } + + /** + * 指定日期的默认显示,具体格式:时:分 + * + * @param cal 指定的日期 + * @return 指定日期按“时:分“格式显示 + */ + public static String formatShortTime(Calendar cal) { + return short_time_sdf.get().format(cal.getTime()); + } + + /** + * 指定日期的默认显示,具体格式:时:分 + * + * @param date 指定的日期 + * @return 指定日期按“时:分“格式显示 + */ + public static String formatShortTime(Date date) { + return short_time_sdf.get().format(date); + } + + // //////////////////////////////////////////////////////////////////////////// + // parseDate + // parseCalendar + // parseTimestamp + // 将字符串按照一定的格式转化为日期或时间 + // //////////////////////////////////////////////////////////////////////////// + + /** + * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间 + * + * @param src 将要转换的原始字符窜 + * @param pattern 转换的匹配格式 + * @return 如果转换成功则返回转换后的日期 + * @throws ParseException + */ + public static Date parseDate(String src, String pattern) throws ParseException { + return getSDFormat(pattern).parse(src); + + } + + /** + * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间 + * + * @param src 将要转换的原始字符窜 + * @param pattern 转换的匹配格式 + * @return 如果转换成功则返回转换后的日期 + * @throws ParseException + */ + public static Calendar parseCalendar(String src, String pattern) throws ParseException { + + Date date = parseDate(src, pattern); + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + return cal; + } + + public static String formatAddDate(String src, String pattern, int amount) throws ParseException { + Calendar cal; + cal = parseCalendar(src, pattern); + cal.add(Calendar.DATE, amount); + return formatDate(cal); + } + + /** + * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间 + * + * @param src 将要转换的原始字符窜 + * @param pattern 转换的匹配格式 + * @return 如果转换成功则返回转换后的时间戳 + * @throws ParseException + */ + public static Timestamp parseTimestamp(String src, String pattern) throws ParseException { + Date date = parseDate(src, pattern); + return new Timestamp(date.getTime()); + } + + // //////////////////////////////////////////////////////////////////////////// + // dateDiff + // 计算两个日期之间的差值 + // //////////////////////////////////////////////////////////////////////////// + + /** + * 计算两个时间之间的差值,根据标志的不同而不同 + * + * @param flag 计算标志,表示按照年/月/日/时/分/秒等计算 + * @param calSrc 减数 + * @param calDes 被减数 + * @return 两个日期之间的差值 + */ + public static int dateDiff(char flag, Calendar calSrc, Calendar calDes) { + + long millisDiff = getMillis(calSrc) - getMillis(calDes); + + if (flag == 'y') { + return (calSrc.get(Calendar.YEAR) - calDes.get(Calendar.YEAR)); + } + + if (flag == 'd') { + return (int) (millisDiff / DAY_IN_MILLIS); + } + + if (flag == 'h') { + return (int) (millisDiff / HOUR_IN_MILLIS); + } + + if (flag == 'm') { + return (int) (millisDiff / MINUTE_IN_MILLIS); + } + + if (flag == 's') { + return (int) (millisDiff / SECOND_IN_MILLIS); + } + + return 0; + } + + public static Long getCurrentTimestamp() { + return Long.valueOf(DateUtils.yyyymmddhhmmss.get().format(new Date())); + } + + /** + * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd + * HH:mm:ss“ * @param text String类型的时间值 + */ + @Override + public void setAsText(String text) throws IllegalArgumentException { + if (StringUtils.hasText(text)) { + try { + if (text.indexOf(":") == -1 && text.length() == 10) { + setValue(DateUtils.date_sdf.get().parse(text)); + } else if (text.indexOf(":") > 0 && text.length() == 19) { + setValue(DateUtils.datetimeFormat.get().parse(text)); + } else { + throw new IllegalArgumentException("Could not parse date, date format is error "); + } + } catch (ParseException ex) { + IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage()); + iae.initCause(ex); + throw iae; + } + } else { + setValue(null); + } + } + + public static int getYear() { + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(getDate()); + return calendar.get(Calendar.YEAR); + } + +} \ No newline at end of file From 7f15b9b35a5c50547268c50b2174fcc4405a2ed5 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Fri, 18 Oct 2024 15:15:43 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 5 +- .../bomnew/pojo/query/BatchBomQuery.java | 6 +- .../product/bomnew/pojo/vo/BomPageVO.java | 69 +++++++++++++++++++ .../product/bomnew/pojo/vo/BomTbHeaderVO.java | 23 +++++++ .../bomnew/service/BatchBomService.java | 44 ++++++++++-- 5 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomPageVO.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomTbHeaderVO.java 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 a5515ede..158550e3 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 @@ -8,6 +8,8 @@ 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.service.BatchBomService; import com.nflg.product.bomnew.service.BomNewEbomExportToSAP; import com.nflg.product.bomnew.service.BomNewPbomParentService; @@ -22,6 +24,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.util.Collections; import java.util.List; +import java.util.Map; /** * 批量替代BOM @@ -55,7 +58,7 @@ public class BatchBomApi extends BaseApi { @PostMapping("getParentBomList") @ApiOperation("获取指定物料号的所有父级BOM列表") - public ResultVO> getParentBomList(@Valid @RequestBody @NotNull BatchBomQuery batchBomQuery) { + public ResultVO, BomTbHeaderVO>> getParentBomList(@Valid @RequestBody @NotNull BatchBomQuery batchBomQuery) { return ResultVO.success(batchBomService.getParentBomList(batchBomQuery)); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java index 39df6f52..e58b38f3 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java @@ -27,15 +27,15 @@ public class BatchBomQuery implements Serializable { private String newMaterialUnit; @ApiModelProperty(value = "换算前") - @NotNull +// @NotNull private BigDecimal replaceTimes; @ApiModelProperty(value = "换算后") - @NotNull +// @NotNull private BigDecimal newReplaceTimes; @ApiModelProperty(value = "新数量小数位") - @NotNull +// @NotNull private Integer decimalScale; @ApiModelProperty(value = "BOM类型") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomPageVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomPageVO.java new file mode 100644 index 00000000..397bb161 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomPageVO.java @@ -0,0 +1,69 @@ +package com.nflg.product.bomnew.pojo.vo; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.nflg.product.base.core.vo.PageVO; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 分页带状态统计 + * + * @author + * @Date 2021/6/16 10:02 + */ +public class BomPageVO extends PageVO { + + @Getter + @Setter + private List tbHeaders; + + public BomPageVO() { + super(); + } + + public BomPageVO(long page, long pageSize) { + super(page, pageSize); + } + + public BomPageVO(long page, long pageSize, long total) { + super(page, pageSize, total); + } + + public BomPageVO(long current, long size, boolean isSearchCount) { + super(current, size, isSearchCount); + } + + public BomPageVO(long current, long size, long total, boolean isSearchCount) { + super(current, size, total, isSearchCount); + } + + /** + * 将 IPage 转换为 CountPageVO + * + * @param page 要转换的 IPage + * @param 数据类型 + * @return 转换后的 CountPageVO + */ + public static BomPageVO valueOf(IPage page) { + return BomPageVO.valueOf(page, page.getRecords()); + } + + /** + * 将 IPage 转换为 CountPageVO,并且切换新的数据集合 + * 应该保证原有的分页信息可以正确的应用在新的数据集合之中 + * + * @param page 要转换的 IPage + * @param records 数据集合 + * @param 数据类型 + * @return 转换后的 CountPageVO + */ + public static BomPageVO valueOf(IPage page, List records) { + BomPageVO pageVO = new BomPageVO<>(page.getCurrent(), page.getSize(), page.getTotal(), page.searchCount()); + pageVO.setRecords(records); // 应该保证原有的分页信息可以正确的应用在新的数据集中 + return pageVO; + } + + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomTbHeaderVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomTbHeaderVO.java new file mode 100644 index 00000000..13f772fa --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomTbHeaderVO.java @@ -0,0 +1,23 @@ +package com.nflg.product.bomnew.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * @decription + * @Author 大米 + * @Date 2022/9/25 9:25 + **/ +@Data +@AllArgsConstructor +public class BomTbHeaderVO { + @ApiModelProperty("表头显示名称") + private String displayHeaderName; + @ApiModelProperty("对应数据字段名称") + private String valueHeaderName; + +// @ApiModelProperty("是否显示 0:不显示 1:显示") +// private Integer displayState; + +} 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 1ac9ba68..83ef10e2 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 @@ -3,6 +3,7 @@ package com.nflg.product.bomnew.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjectUtil; @@ -23,6 +24,8 @@ import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.query.BatchBomQuery; 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.util.DateUtils; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VersionUtil; @@ -63,14 +66,16 @@ public class BatchBomService { @Resource private MaterialMainService materialMainService; - public List getParentBomList(BatchBomQuery batchBomQuery) { + public BomPageVO, BomTbHeaderVO> getParentBomList(BatchBomQuery batchBomQuery) { if (!(batchBomQuery.getMaterialUnit().equals(batchBomQuery.getNewMaterialUnit())) && (batchBomQuery.getReplaceTimes().compareTo(BigDecimal.ZERO) == 0 || batchBomQuery.getNewReplaceTimes().compareTo(BigDecimal.ZERO) == 0)) { throw new NflgBusinessException(STATE.ParamErr, "参数错误,换算关系不能为0"); } List resultList = new ArrayList<>(); String bomType = batchBomQuery.getBomType(); - Integer decimalScale = batchBomQuery.getDecimalScale(); + int decimalScale = ObjectUtil.isNotEmpty(batchBomQuery.getDecimalScale()) ? batchBomQuery.getDecimalScale() : 3; + BigDecimal replaceTimes = ObjectUtil.isNotEmpty(batchBomQuery.getReplaceTimes()) ? batchBomQuery.getReplaceTimes() : BigDecimal.ONE; + BigDecimal newReplaceTimes = ObjectUtil.isNotEmpty(batchBomQuery.getNewReplaceTimes()) ? batchBomQuery.getNewReplaceTimes() : BigDecimal.ONE; buildQueryCondition(batchBomQuery); if ("ebom".equals(bomType)) { String materialNo = batchBomQuery.getMaterialNo(); @@ -121,7 +126,7 @@ public class BatchBomService { baseBomVO.setUnit(ebomChild.getMaterialUnit()); } baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); - baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewNum(newReplaceTimes.divide(replaceTimes, decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); resultList.add(baseBomVO); @@ -178,7 +183,7 @@ public class BatchBomService { baseBomVO.setUnit(pbomChild.getMaterialUnit()); } baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); - baseBomVO.setNewNum(batchBomQuery.getNewReplaceTimes().divide(batchBomQuery.getReplaceTimes(), decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); + baseBomVO.setNewNum(newReplaceTimes.divide(replaceTimes, decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); resultList.add(baseBomVO); @@ -205,7 +210,36 @@ public class BatchBomService { result.setRelCategoryCode(materialMp.get(result.getParentMaterialNo()).getRelCategoryCode()); result.setCategoryName(materialMp.get(result.getParentMaterialNo()).getCategoryName()); }); - return resultList; + BomPageVO, BomTbHeaderVO> pageVO = new BomPageVO<>(); + List> records = new ArrayList<>(resultList.size()); + resultList.forEach(result -> records.add(BeanUtil.beanToMap(result))); + pageVO.setRecords(records); + pageVO.setPages(records.size()); + pageVO.setCurrent(1L); + pageVO.setPageSize(Long.MAX_VALUE); + pageVO.setTotal(records.size()); + pageVO.setTbHeaders(getTbHeaders()); + return pageVO; + } + + private List getTbHeaders() { + List headerVOS = new ArrayList<>(); + headerVOS.add(new BomTbHeaderVO("序号", "orderNum")); + headerVOS.add(new BomTbHeaderVO("父级物料编码", "parentMaterialNo")); + headerVOS.add(new BomTbHeaderVO("父级物料描述", "parentMaterialDesc")); + headerVOS.add(new BomTbHeaderVO("物料类别", "categoryName")); + headerVOS.add(new BomTbHeaderVO("父级BOM版本号", "parentVersion")); + headerVOS.add(new BomTbHeaderVO("原物料编码", "materialNo")); + headerVOS.add(new BomTbHeaderVO("原数量", "num")); + headerVOS.add(new BomTbHeaderVO("原单位", "unit")); + headerVOS.add(new BomTbHeaderVO("新物料编码", "newMaterialNo")); + headerVOS.add(new BomTbHeaderVO("新数量", "newNum")); + headerVOS.add(new BomTbHeaderVO("新单位", "newUnit")); + headerVOS.add(new BomTbHeaderVO("新版本号", "newVersion")); + headerVOS.add(new BomTbHeaderVO("创建时间", "createdTime")); + headerVOS.add(new BomTbHeaderVO("版本过期时间", "expireEndTime")); + headerVOS.add(new BomTbHeaderVO("设计人员", "deviseName")); + return headerVOS; } private void buildQueryCondition(BatchBomQuery query) { From 6db6bc3bef9ed688b97ac35e1f5340cffc26aa94 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Mon, 21 Oct 2024 10:25:37 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BatchBomApi.java | 11 ++ .../bomnew/pojo/query/BatchBomQuery.java | 6 + .../bomnew/service/BatchBomService.java | 118 ++++++++++++++++-- 3 files changed, 126 insertions(+), 9 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 158550e3..e89cf39d 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 @@ -14,15 +14,19 @@ import com.nflg.product.bomnew.service.BatchBomService; import com.nflg.product.bomnew.service.BomNewEbomExportToSAP; import com.nflg.product.bomnew.service.BomNewPbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; +import com.nflg.product.bomnew.util.EecExcelUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import nflg.product.common.vo.ResultVO; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +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; @@ -91,4 +95,11 @@ public class BatchBomApi extends BaseApi { } return ResultVO.success(); } + + @PostMapping("exportExcel") + @ApiOperation("数据导出") + public void exportExcel(@RequestBody BatchBomQuery query, HttpServletResponse response) throws IOException { + EecExcelUtil.setResponseExcelHeader(response, "批量替代" + query.getMaterialNo() + "_" + new Date().getTime()); + batchBomService.getExportExcelWork(query).writeTo(response.getOutputStream()); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java index e58b38f3..b1344768 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/query/BatchBomQuery.java @@ -53,4 +53,10 @@ public class BatchBomQuery implements Serializable { @ApiModelProperty("统计结束时间") private String endDate; + + @ApiModelProperty(value = "设置每页显示条数") + private Long pageSize = 20L; + + @ApiModelProperty(value = "当前页") + private Long page = 1L; } 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 83ef10e2..f373db40 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 @@ -6,13 +6,12 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.exception.NflgBusinessException; -import com.nflg.product.bomnew.constant.DateTypeEnum; -import com.nflg.product.bomnew.constant.EBomStatusEnum; -import com.nflg.product.bomnew.constant.PBomStatusEnum; -import com.nflg.product.bomnew.constant.SapStatusEnum; +import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper; import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper; import com.nflg.product.bomnew.mapper.master.BomNewPbomChildMapper; @@ -33,6 +32,9 @@ import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.ttzero.excel.entity.Column; +import org.ttzero.excel.entity.ListMapSheet; +import org.ttzero.excel.entity.Workbook; import javax.annotation.Resource; import java.math.BigDecimal; @@ -65,6 +67,8 @@ public class BatchBomService { private BomNewPbomChildMapper bomNewPbomChildMapper; @Resource private MaterialMainService materialMainService; + @Resource + private UserRoleService userRoleService; public BomPageVO, BomTbHeaderVO> getParentBomList(BatchBomQuery batchBomQuery) { if (!(batchBomQuery.getMaterialUnit().equals(batchBomQuery.getNewMaterialUnit())) @@ -214,7 +218,7 @@ public class BatchBomService { List> records = new ArrayList<>(resultList.size()); resultList.forEach(result -> records.add(BeanUtil.beanToMap(result))); pageVO.setRecords(records); - pageVO.setPages(records.size()); + pageVO.setPages(1L); pageVO.setCurrent(1L); pageVO.setPageSize(Long.MAX_VALUE); pageVO.setTotal(records.size()); @@ -293,11 +297,12 @@ public class BatchBomService { BaseMaterialVO newMaterialInfo= materialBaseInfo.get(0); List addRowIds = new ArrayList<>(baseBomVOList.size()); // 需要加入历史表的父级BOM ID List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID + LocalDateTime now = LocalDateTime.now(); + int createdJob = userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue(); for (BaseBomVO baseBomVO: baseBomVOList) { // 找到父级 BomNewEbomParentEntity ebomParentEntity = bomNewEbomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); if (ObjectUtil.isNotEmpty(ebomParentEntity)) { - LocalDateTime now = LocalDateTime.now(); // 找到该父级的所有子级列表 List ebomChildEntities = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); // 在子级列表中找到要被替换的那条子级 @@ -315,6 +320,12 @@ public class BatchBomService { newParent.setModifyTime(now); newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); newParent.setSapTime(null); + newParent.setDeptRowId(SessionUtil.getDepartRowId()); + newParent.setDeptName(SessionUtil.getDepartName()); + newParent.setDeviseName(SessionUtil.getRealName()); + newParent.setDeviseUserCode(SessionUtil.getUserCode()); + newParent.setCreatedBy(SessionUtil.getUserCode()); + newParent.setCreatedJob(createdJob); // 构建新版的子级规则:其他子级复制一份,被替换的子级改物料编码,数量,单位等 List newChildList = new ArrayList<>(ebomChildEntities.size()); otherChildren.forEach(item -> { @@ -326,6 +337,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newChild.setCreatedTime(now); newChild.setModifyTime(now); + newChild.setCreatedBy(SessionUtil.getUserCode()); newChildList.add(newChild); }); BomNewEbomChildEntity newReplaceChild = new BomNewEbomChildEntity(); @@ -345,6 +357,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newReplaceChild.setCreatedTime(now); newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); newChildList.add(newReplaceChild); bomNewEbomParentService.save(newParent); @@ -370,7 +383,7 @@ public class BatchBomService { .one(); if (ObjectUtil.isNotEmpty(draftParent)) { // 草稿版本 A01 -> A02,A01.1 -> A02.1 - String[] currentVersionArr = draftParent.getCurrentVersion().split("."); + String[] currentVersionArr = draftParent.getCurrentVersion().split("\\."); String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]); if (currentVersionArr.length > 1) { newVersion += "." + currentVersionArr[1]; @@ -378,6 +391,32 @@ public class BatchBomService { draftParent.setCurrentVersion(newVersion); draftParent.setModifyTime(LocalDateTime.now()); bomNewEbomParentService.updateById(draftParent); + // 子级有原物料号,也要替代成新物料号 + List draftChildren = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); + if (CollectionUtil.isNotEmpty(draftChildren)) { + List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(replaceChildren)) { + for (BomNewEbomChildEntity newReplaceChild: replaceChildren) { + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + } + bomNewEbomChildService.updateBatchById(replaceChildren); + } + } } } return addRowIds; @@ -399,11 +438,12 @@ public class BatchBomService { BaseMaterialVO newMaterialInfo= materialBaseInfo.get(0); List addRowIds = new ArrayList<>(baseBomVOList.size()); // 需要加入历史表的父级BOM ID List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID + LocalDateTime now = LocalDateTime.now(); + int createdJob = userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue(); for (BaseBomVO baseBomVO: baseBomVOList) { // 找到父级 BomNewPbomParentEntity pbomParentEntity = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); if (ObjectUtil.isNotEmpty(pbomParentEntity)) { - LocalDateTime now = LocalDateTime.now(); // 找到该父级的所有子级列表 List pbomChildEntities = bomNewPbomChildService.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); // 在子级列表中找到要被替换的那条子级 @@ -421,6 +461,12 @@ public class BatchBomService { newParent.setModifyTime(now); newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); newParent.setSapTime(null); + newParent.setDeptRowId(SessionUtil.getDepartRowId()); + newParent.setDeptName(SessionUtil.getDepartName()); + newParent.setDeviseName(SessionUtil.getRealName()); + newParent.setDeviseUserCode(SessionUtil.getUserCode()); + newParent.setCreatedBy(SessionUtil.getUserCode()); + newParent.setCreatedJob(createdJob); // 构建新版的子级规则:其他子级复制一份,被替换的子级改物料编码,数量,单位等 List newChildList = new ArrayList<>(pbomChildEntities.size()); otherChildren.forEach(item -> { @@ -432,6 +478,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newChild.setCreatedTime(now); newChild.setModifyTime(now); + newChild.setCreatedBy(SessionUtil.getUserCode()); newChildList.add(newChild); }); BomNewPbomChildEntity newReplaceChild = new BomNewPbomChildEntity(); @@ -451,6 +498,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newReplaceChild.setCreatedTime(now); newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); newChildList.add(newReplaceChild); bomNewPbomParentService.save(newParent); @@ -476,7 +524,7 @@ public class BatchBomService { .one(); if (ObjectUtil.isNotEmpty(draftParent)) { // 草稿版本 A01 -> A02,A01.1 -> A02.1 - String[] currentVersionArr = draftParent.getCurrentVersion().split("."); + String[] currentVersionArr = draftParent.getCurrentVersion().split("\\."); String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]); if (currentVersionArr.length > 1) { newVersion += "." + currentVersionArr[1]; @@ -484,8 +532,60 @@ public class BatchBomService { draftParent.setCurrentVersion(newVersion); draftParent.setModifyTime(LocalDateTime.now()); bomNewPbomParentService.updateById(draftParent); + // 子级有原物料号,也要替代成新物料号 + List draftChildren = bomNewPbomChildService.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); + if (CollectionUtil.isNotEmpty(draftChildren)) { + List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(replaceChildren)) { + for (BomNewPbomChildEntity newReplaceChild: replaceChildren) { + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + } + bomNewPbomChildService.updateBatchById(replaceChildren); + } + } } } return addRowIds; } + + public Workbook getExportExcelWork(BatchBomQuery query) { + BomPageVO list = this.getParentBomList(query); + long pages = list.getPages(); + List voList = list.getRecords(); + Integer pageCount = Math.toIntExact(pages + 1); + return new Workbook().addSheet(new ListMapSheet("bom", getExcelColumns(getTbHeaders())) { + Long n = 1L; + + @Override + protected List> more() { + query.setPage(n); + return n++ < pageCount ? Convert.convert(new TypeReference>>() { + }, voList) : null; + } + }); + } + + public Column[] getExcelColumns(List headers) { + Column[] excelColumns = new Column[headers.size()]; + for (int i = 0; i < headers.size(); i++) { + BomTbHeaderVO h = headers.get(i); + excelColumns[i] = new Column(h.getDisplayHeaderName(), h.getValueHeaderName(), String.class); + } + return excelColumns; + } } From 8f4fb88d4a156d1c1ad45c4b851694821ac84b9d Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Tue, 22 Oct 2024 15:33:25 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nflg/product/bomnew/service/BatchBomService.java | 3 +++ 1 file changed, 3 insertions(+) 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 f373db40..fdbe865d 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 @@ -565,6 +565,9 @@ public class BatchBomService { public Workbook getExportExcelWork(BatchBomQuery query) { BomPageVO list = this.getParentBomList(query); + if (ObjectUtil.isEmpty(list)) { + return new Workbook().addSheet(new ListMapSheet("bom")); + } long pages = list.getPages(); List voList = list.getRecords(); Integer pageCount = Math.toIntExact(pages + 1); 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 09/11] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3BOM?= =?UTF-8?q?=20=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")); From d7bd61f7f47fa0b25d89549c8686ee399991dd42 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Tue, 29 Oct 2024 15:24:53 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3BOM=E3=80=91PBOM=E5=88=97=E8=A1=A8=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java | 5 +++++ .../com/nflg/product/bomnew/service/BatchBomService.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java index 84fcc9d6..8e4442f4 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseBomVO.java @@ -90,4 +90,9 @@ public class BaseBomVO { @ApiModelProperty(value = "版本过期时间") private LocalDateTime expireEndTime; + /** + * 工厂 + */ + @ApiModelProperty(value = "工厂") + private String factory; } 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 aab67811..de62556d 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 @@ -174,6 +174,7 @@ public class BatchBomService { baseBomVO.setExpireEndTime(parent.getExpireEndTime()); baseBomVO.setDeviseUserCode(parent.getDeviseUserCode()); baseBomVO.setDeviseName(parent.getDeviseName()); + baseBomVO.setFactory(parent.getFacCode()); Optional first = pbomChildEntities.stream().filter(item -> item.getParentRowId().equals(parent.getRowId())).findFirst(); if (first.isPresent()) { BomNewPbomChildEntity pbomChild = first.get(); @@ -539,6 +540,7 @@ public class BatchBomService { for (BaseBomVO baseBomVO: baseBomVOList) { BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery() .eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) + .eq(BomNewPbomParentEntity::getFacCode, baseBomVO.getFactory()) .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) .one(); if (ObjectUtil.isNotEmpty(draftParent)) { From 2d1dc935213693e5c01616cc23ffbd00622205c9 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Wed, 30 Oct 2024 11:09:41 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E3=80=90EBOM=E3=80=91=E4=BB=8EEXCEL?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=EF=BC=8C=E5=AD=90=E7=BA=A7=E8=A1=A8=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E5=8D=95=E4=BD=8D=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nflg/product/bomnew/service/EBomImportService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/EBomImportService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/EBomImportService.java index dee2ed6c..5fc49142 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/EBomImportService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/EBomImportService.java @@ -402,6 +402,7 @@ public class EBomImportService { child.setDrawingNo(vo.getDrawingNo()); child.setUnitWeight(vo.getMaterialWeight()); child.setMaterialUnit(vo.getMaterialUnit()); + child.setMaterialOriginalUnit(vo.getMaterialUnit()); child.setMaterialTexture(vo.getMaterialTexture()); if (StrUtil.isBlank(child.getMaterialDesc())) { child.setMaterialDesc(vo.getMaterialDesc());