From f6cb5cf3262045b4a0ce1245e69f8d84993e614b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Tue, 9 Jan 2024 12:19:24 +0800 Subject: [PATCH] =?UTF-8?q?EBOM=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 11 + .../nflg/product/bomnew/api/user/PBomApi.java | 12 + .../pojo/entity/BomNewPbomParentEntity.java | 264 ++++++++++-------- .../bomnew/pojo/vo/BomNewEbomParentVO.java | 4 + .../bomnew/pojo/vo/BomNewPbomParentVO.java | 21 +- .../service/BomNewEbomParentService.java | 53 +++- .../service/BomNewPbomParentService.java | 6 +- .../bomnew/service/UserRoleService.java | 16 ++ .../domain/EBom/CheckEBomException.java | 109 ++++---- .../service/domain/EBom/EBomToPBom.java | 29 +- .../domain/EBom/VirtualPackageBase.java | 10 +- .../product/bomnew/util/sap/LevelNumUtil.java | 31 ++ .../mapper/master/BomNewPbomParentMapper.xml | 4 +- 13 files changed, 372 insertions(+), 198 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/sap/LevelNumUtil.java diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index bfda9a44..2e950dec 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -15,6 +15,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.service.*; +import com.nflg.product.bomnew.service.cache.MaterialMateCache; import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase; import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31; import com.nflg.product.bomnew.util.EecExcelUtil; @@ -353,6 +354,16 @@ public class EbomApi extends BaseApi { + @GetMapping("getrel") + @ApiOperation("模糊匹配物料") + public ResultVO getRelMaterial(@RequestParam(value = "materialName", required = false) String materialName ,@RequestParam(value = "materialTexture" ,required = false) String materialTexture ){ + MaterialMateCache mateCache = new MaterialMateCache(); + MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(materialName,materialTexture); + return ResultVO.success(materialMate) ; + } + + + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 9ba9f859..03b35a4b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -16,6 +16,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; import com.nflg.product.bomnew.pojo.vo.BomNewTechnologyPackageTypeVO; import com.nflg.product.bomnew.service.BomNewPbomParentService; import com.nflg.product.bomnew.service.BomNewTechnologyPackageTypeService; +import com.nflg.product.bomnew.service.UserRoleService; import com.nflg.product.bomnew.util.VUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -52,6 +53,9 @@ public class PBomApi extends BaseApi { @Resource private BomNewTechnologyPackageTypeService technologyPackageTypeService; + @Resource + private UserRoleService userRoleService; + @PostMapping("workDetailsListByPage") @ApiOperation("PBom工作列表") @@ -199,6 +203,14 @@ public class PBomApi extends BaseApi { } + @GetMapping("getUserFacCode") + @ApiOperation("获取当前用户所在工厂") + public ResultVO> getUserFacCode(@RequestParam("bomRowId") Long bomRowId) { + + return ResultVO.success(userRoleService.getUserOfFactory()); + } + + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomParentEntity.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomParentEntity.java index d1f29cc4..c7ed189c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomParentEntity.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomParentEntity.java @@ -2,308 +2,326 @@ package com.nflg.product.bomnew.pojo.entity; import java.math.BigDecimal; import java.time.LocalDateTime; + import com.baomidou.mybatisplus.annotation.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; + import lombok.Data; import lombok.experimental.Accessors; + import java.time.LocalDateTime; import java.time.LocalDate; /** - * t_bom_new_pbom_parent - * + * t_bom_new_pbom_parent * * @author makejava * @since 2024-01-01 10:39:58 */ @Data @Accessors(chain = true) -@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewPbomParentEntity") +@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewPbomParentEntity") @TableName(value = "t_bom_new_pbom_parent") public class BomNewPbomParentEntity implements Serializable { - + /** * 主键行ID-雪花 */ @TableId(value = "row_id", type = IdType.ASSIGN_ID) @ApiModelProperty(value = "主键行ID-雪花") private Long rowId; - + /** * 批号-来自plm-临时 */ - @TableField(value = "batch_no") - @ApiModelProperty(value = "批号-来自plm-临时") + @TableField(value = "batch_no") + @ApiModelProperty(value = "批号-来自plm-临时") private String batchNo; - + /** * 图号 */ - @TableField(value = "drawing_no") - @ApiModelProperty(value = "图号") + @TableField(value = "drawing_no") + @ApiModelProperty(value = "图号") private String drawingNo; - + /** * 工厂编码 */ - @TableField(value = "fac_code") - @ApiModelProperty(value = "工厂编码") + @TableField(value = "fac_code") + @ApiModelProperty(value = "工厂编码") private String facCode; - + /** * 物料编码 */ - @TableField(value = "material_no") - @ApiModelProperty(value = "物料编码") + @TableField(value = "material_no") + @ApiModelProperty(value = "物料编码") private String materialNo; - + /** * 排序号 */ - @TableField(value = "order_number") - @ApiModelProperty(value = "排序号") + @TableField(value = "order_number") + @ApiModelProperty(value = "排序号") private String orderNumber; - + /** * 物料名称 */ - @TableField(value = "material_name") - @ApiModelProperty(value = "物料名称") + @TableField(value = "material_name") + @ApiModelProperty(value = "物料名称") private String materialName; - + /** * 物料描述 */ - @TableField(value = "material_desc") - @ApiModelProperty(value = "物料描述") + @TableField(value = "material_desc") + @ApiModelProperty(value = "物料描述") private String materialDesc; - + /** * 材质,材料 */ - @TableField(value = "material_texture") - @ApiModelProperty(value = "材质,材料") + @TableField(value = "material_texture") + @ApiModelProperty(value = "材质,材料") private String materialTexture; - + /** * 单位 */ - @TableField(value = "material_unit") - @ApiModelProperty(value = "单位") + @TableField(value = "material_unit") + @ApiModelProperty(value = "单位") private String materialUnit; - + /** * 单重 */ - @TableField(value = "unit_weight") - @ApiModelProperty(value = "单重") + @TableField(value = "unit_weight") + @ApiModelProperty(value = "单重") private BigDecimal unitWeight; - + /** * 总重 */ - @TableField(value = "total_weight") - @ApiModelProperty(value = "总重") + @TableField(value = "total_weight") + @ApiModelProperty(value = "总重") private BigDecimal totalWeight; - + /** * 版本号 */ - @TableField(value = "current_version") - @ApiModelProperty(value = "版本号") + @TableField(value = "current_version") + @ApiModelProperty(value = "版本号") private String currentVersion; - + /** * 数量 */ - @TableField(value = "num") - @ApiModelProperty(value = "数量") + @TableField(value = "num") + @ApiModelProperty(value = "数量") private BigDecimal num; - + /** * 项目类别 */ - @TableField(value = "project_type") - @ApiModelProperty(value = "项目类别") + @TableField(value = "project_type") + @ApiModelProperty(value = "项目类别") private String projectType; - + /** * 是否跟节点 0-否 1-是 */ - @TableField(value = "root_is") - @ApiModelProperty(value = "是否跟节点 0-否 1-是") + @TableField(value = "root_is") + @ApiModelProperty(value = "是否跟节点 0-否 1-是") private Integer rootIs; - + /** * 是否应该有BOM 0-否 1-是 */ - @TableField(value = "should_bom_exist") - @ApiModelProperty(value = "是否应该有BOM 0-否 1-是") + @TableField(value = "should_bom_exist") + @ApiModelProperty(value = "是否应该有BOM 0-否 1-是") private Integer shouldBomExist; - + /** * 超级物料 0-否 1-是 */ - @TableField(value = "super_material_status") - @ApiModelProperty(value = "超级物料 0-否 1-是") + @TableField(value = "super_material_status") + @ApiModelProperty(value = "超级物料 0-否 1-是") private Integer superMaterialStatus; - + /** * 是否有BOM: 0-否 1-是 */ - @TableField(value = "bom_exist") - @ApiModelProperty(value = "是否有BOM: 0-否 1-是") + @TableField(value = "bom_exist") + @ApiModelProperty(value = "是否有BOM: 0-否 1-是") private Integer bomExist; - + /** * 是否最新版:0-否 1-是 */ - @TableField(value = "last_version_is") - @ApiModelProperty(value = "是否最新版:0-否 1-是") + @TableField(value = "last_version_is") + @ApiModelProperty(value = "是否最新版:0-否 1-是") private Integer lastVersionIs; - + /** * 1=待处理、2=暂存 3=已处理 */ - @TableField(value = "edit_status") - @ApiModelProperty(value = "1=待处理、2=暂存 3=已处理") + @TableField(value = "edit_status") + @ApiModelProperty(value = "1=待处理、2=暂存 3=已处理") private Integer editStatus; - + /** * BOM状态:1=待发布 2=待分配工厂 3=已分配工厂 4=已发布 */ - @TableField(value = "status") - @ApiModelProperty(value = "BOM状态:1=待发布 4=已发布 8=待分配工厂 16=已分配工厂") + @TableField(value = "status") + @ApiModelProperty(value = "BOM状态:1=待发布 4=已发布 8=待分配工厂 16=已分配工厂") private Integer status; - + /** * 是否用户跟节点 0-否 1-是 */ - @TableField(value = "user_root_is") - @ApiModelProperty(value = "是否用户跟节点 0-否 1-是") + @TableField(value = "user_root_is") + @ApiModelProperty(value = "是否用户跟节点 0-否 1-是") private Integer userRootIs; - + /** * 是否虚拟包 0-否 1-是 */ - @TableField(value = "virtual_package_is") - @ApiModelProperty(value = "是否虚拟包 0-否 1-是") + @TableField(value = "virtual_package_is") + @ApiModelProperty(value = "是否虚拟包 0-否 1-是") private Integer virtualPackageIs; - + /** * 来源行ID(EBOM中的行ID) */ - @TableField(value = "source_row_id") - @ApiModelProperty(value = "来源行ID(EBOM中的行ID)") + @TableField(value = "source_row_id") + @ApiModelProperty(value = "来源行ID(EBOM中的行ID)") private Long sourceRowId; - + /** * 设计人员编码 */ - @TableField(value = "devise_user_code") - @ApiModelProperty(value = "设计人员编码") + @TableField(value = "devise_user_code") + @ApiModelProperty(value = "设计人员编码") private String deviseUserCode; - + /** * 设计人员名称 */ - @TableField(value = "devise_name") - @ApiModelProperty(value = "设计人员名称") + @TableField(value = "devise_name") + @ApiModelProperty(value = "设计人员名称") private String deviseName; - + + /** + * 工艺人员编码 + */ + @TableField(value = "technology_user_code") + @ApiModelProperty(value = "工艺人员编码") + private String technologyUserCode; + + + /** + * 工艺人员名称 + */ + @TableField(value = "technology_user_name") + @ApiModelProperty(value = "工艺人员名称") + private String technologyUserName; + /** * 创建人编码 */ - @TableField(value = "created_by") - @ApiModelProperty(value = "创建人编码") + @TableField(value = "created_by") + @ApiModelProperty(value = "创建人编码") private String createdBy; - + /** * 创建时间 */ - @TableField(value = "created_time") - @ApiModelProperty(value = "创建时间") + @TableField(value = "created_time") + @ApiModelProperty(value = "创建时间") private LocalDateTime createdTime; - + /** * 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他 */ - @TableField(value = "created_job") - @ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他") + @TableField(value = "created_job") + @ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他") private Integer createdJob; - + /** * 发布时间 */ - @TableField(value = "release_time") - @ApiModelProperty(value = "发布时间") + @TableField(value = "release_time") + @ApiModelProperty(value = "发布时间") private LocalDateTime releaseTime; - + /** * 发布人 */ - @TableField(value = "release_user_name") - @ApiModelProperty(value = "发布人") + @TableField(value = "release_user_name") + @ApiModelProperty(value = "发布人") private String releaseUserName; - + /** * 版本过期时间=下个版本的创建时间 */ - @TableField(value = "expire_end_time") - @ApiModelProperty(value = "版本过期时间=下个版本的创建时间") + @TableField(value = "expire_end_time") + @ApiModelProperty(value = "版本过期时间=下个版本的创建时间") private LocalDateTime expireEndTime; - + /** * 备注 */ - @TableField(value = "remark") - @ApiModelProperty(value = "备注") + @TableField(value = "remark") + @ApiModelProperty(value = "备注") private String remark; - + /** * 设计维护部门名称 */ - @TableField(value = "dept_name") - @ApiModelProperty(value = "设计维护部门名称") + @TableField(value = "dept_name") + @ApiModelProperty(value = "设计维护部门名称") private String deptName; - + /** * bom树的高度 */ - @TableField(value = "level_num") - @ApiModelProperty(value = "bom树的高度") + @TableField(value = "level_num") + @ApiModelProperty(value = "bom树的高度") private Integer levelNum; - + /** * 升版说明 */ - @TableField(value = "change_desc") - @ApiModelProperty(value = "升版说明") + @TableField(value = "change_desc") + @ApiModelProperty(value = "升版说明") private String changeDesc; - + /** * 通知单号 */ - @TableField(value = "notice_nums") - @ApiModelProperty(value = "通知单号") + @TableField(value = "notice_nums") + @ApiModelProperty(value = "通知单号") private String noticeNums; - + /** * 订单号 */ - @TableField(value = "order_no") - @ApiModelProperty(value = "订单号") + @TableField(value = "order_no") + @ApiModelProperty(value = "订单号") private String orderNo; - + /** * 修改时间 */ - @TableField(value = "modify_time") - @ApiModelProperty(value = "修改时间") + @TableField(value = "modify_time") + @ApiModelProperty(value = "修改时间") private LocalDateTime modifyTime; - + private static final long serialVersionUID = -31999878274445137L; - + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java index d64f5a13..bab644b7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java @@ -1,5 +1,6 @@ package com.nflg.product.bomnew.pojo.vo; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -178,6 +179,9 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable { @ApiModelProperty(value = "设计人员名称") private String deviseName; + + + /** * 创建人编码 */ diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java index 47548791..242a7673 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java @@ -2,6 +2,8 @@ package com.nflg.product.bomnew.pojo.vo; import java.math.BigDecimal; import java.time.LocalDateTime; + +import cn.hutool.core.date.LocalDateTimeUtil; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; @@ -158,6 +160,19 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable { */ @ApiModelProperty(value = "设计人员名称") private String deviseName; + + /** + * 工艺人员编码 + */ + @ApiModelProperty(value = "工艺人员编码") + private String technologyUserCode; + + + /** + * 工艺人员名称 + */ + @ApiModelProperty(value = "工艺人员名称") + private String technologyUserName; /** * 创建人编码 @@ -194,7 +209,11 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable { */ @ApiModelProperty(value = "版本过期时间=下个版本的创建时间") private LocalDateTime expireEndTime; - + + public String getExpireEndTime() { + return expireEndTime==null? LocalDateTimeUtil.format(LocalDateTime.MAX,"yy-MM-dd HH:mm:ss"):LocalDateTimeUtil.format(expireEndTime,"yyyy-MM-dd HH:mm:ss"); + } + /** * 备注 */ diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 9fb8e933..f7603226 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -133,7 +133,7 @@ public class BomNewEbomParentService extends ServiceImpl all = new ArrayList<>(); - // all.addAll(resultParents); + // all.addAll(resultParents); all.addAll(childs); List result = new ArrayList<>(); for (BomNewEbomParentVO vo : resultParents) { //vo.setParentRowId(0L); - List da=new ArrayList<>(); + List da = new ArrayList<>(); da.addAll(childs); da.add(vo); result.addAll(CTreeUtils.toTree(0L, da, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId)); @@ -272,13 +272,13 @@ public class BomNewEbomParentService extends ServiceImpl parentChild = this.getBaseMapper().getParentChild(rowId); //排除项目类别的赋值 - materialMainService.intiMaterialInfoInPattern(parentChild,"^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + materialMainService.intiMaterialInfoInPattern(parentChild, "^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); if (CollUtil.isNotEmpty(parentChild)) { List materialNos = parentChild.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); if (CollUtil.isNotEmpty(materialNos)) { List list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos) .eq(BomNewEbomParentEntity::getLastVersionIs, 1) - .eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()),BomNewEbomParentEntity::getStatus,EBomStatusEnum.PUBLISHED.getValue() ).list(); + .eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); Map bomListMap = ListCommonUtil.listToMap(list, BomNewEbomParentEntity::getMaterialNo); for (BomNewEbomParentVO child : parentChild) { if (bomListMap.containsKey(child.getMaterialNo())) { @@ -340,7 +340,6 @@ public class BomNewEbomParentService extends ServiceImpl> submit = bomDetailPool.submit(detailTask); List result = submit.join(); + + EBomToPBom eBomToPBom = new EBomToPBom(); + eBomToPBom.generateDrawingNo(bomDetail, rowId, ""); + return result; } + + /** + * 获取整个BOM树 + * + * @param rowId + * @return + * @throws ExecutionException + * @throws InterruptedException + */ + public List getBomTree(Long rowId, Boolean generateLevelNumberFlag) throws ExecutionException, InterruptedException { + List bomDetail = this.getBaseMapper().getParentChild(rowId); + EBomDetailTask detailTask = new EBomDetailTask(bomDetail); + ForkJoinTask> submit = bomDetailPool.submit(detailTask); + + List result = submit.join(); + if (generateLevelNumberFlag) { + EBomToPBom eBomToPBom = new EBomToPBom(); + eBomToPBom.generateDrawingNo(bomDetail, rowId, ""); + } + return result; + + } + + public List buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException { List list = getBomTree(rowId); @@ -538,10 +565,10 @@ public class BomNewEbomParentService extends ServiceImpl= 0) { + if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) { vo.setUnitWeight(vo.getMaterialWeight()); } vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); + } } } - } return dto.getDatas(); -} + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 4121613e..17cab06c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -208,6 +208,8 @@ public class BomNewPbomParentService extends ServiceImpl noDelList = childListVO.stream().filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021")).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料,以下物料为非辅助物料:" + StrUtil.join(",", noDelList)); + VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料"); pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList()); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java index 33a26ea3..f9a5c0e0 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/UserRoleService.java @@ -1,6 +1,7 @@ package com.nflg.product.bomnew.service; +import com.google.common.collect.ImmutableList; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.UserJobEnum; @@ -65,4 +66,19 @@ public class UserRoleService { return SessionUtil.getFullDeptName().contains("仙桃公司")?"1020":"1010"; } } + + + /** + * 获取用户工厂 + * 多工厂权限时返回空 + * @return + */ + public List getUserOfFactory(){ + Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId()); + if(userMultiplantFacRoleCount>0){ + return ImmutableList.of("1010","1020"); + }else { + return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of("1020") : ImmutableList.of("1010") ; + } + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index b463a090..7a0abab8 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -36,13 +36,13 @@ import java.util.stream.Collectors; public class CheckEBomException { @Getter - List allBomDetail ; -@Setter + List allBomDetail; + @Setter List unCheckExcept; - public static void checkMaterialNoInMain1(List materialNos){ - // List materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + public static void checkMaterialNoInMain1(List materialNos) { + // List materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); //检查物料编码是否在主数据中存在 List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); @@ -50,28 +50,28 @@ public class CheckEBomException { VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在"); } - public static void checkMaterialNoInMain(List list){ - List materialNos = list.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + public static void checkMaterialNoInMain(List list) { + List materialNos = list.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); checkMaterialNoInMain1(materialNos); - } + } public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException { - allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); + allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId, true); BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); convert.setBomRowId(convert.getRowId()); convert.setParentRowId(0L); + convert.setLevelNumber(BigDecimal.ZERO); allBomDetail.add(convert); - // allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); + // allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); } /** - * - * @param allBom 整颗BOM树(包含跟节点) + * @param allBom 整颗BOM树(包含跟节点) */ public CheckEBomException(List allBom) { allBomDetail = allBom; @@ -88,26 +88,25 @@ public class CheckEBomException { } - public void initException( String ... ignorePropertyList) { + public void initException(String... ignorePropertyList) { - SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail,ignorePropertyList); + SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, ignorePropertyList); checkException(); } - - public void checkException(){ + public void checkException() { for (BomNewEbomParentVO vo : allBomDetail) { - // if(Objects.isNull(vo.getExceptionStatus())) { + // if(Objects.isNull(vo.getExceptionStatus())) { //忽略不检查的如14 - if(CollectionUtil.isNotEmpty(unCheckExcept) - && vo.getExceptionStatus()!=null - &&unCheckExcept.contains(vo.getExceptionStatus())){ - continue; + if (CollectionUtil.isNotEmpty(unCheckExcept) + && vo.getExceptionStatus() != null + && unCheckExcept.contains(vo.getExceptionStatus())) { + continue; } - vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); - // } + vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); + // } if (StrUtil.isNotBlank(vo.getMaterialNo()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) { @@ -119,10 +118,9 @@ public class CheckEBomException { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue()); } else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue()); - } else if (StrUtil.isBlank(vo.getProjectType()) && (vo.getRootIs()==null || vo.getRootIs()==0)) { + } else if (StrUtil.isBlank(vo.getProjectType()) && (vo.getRootIs() == null || vo.getRootIs() == 0)) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); - } - else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())){ + } else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())) { vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); } @@ -131,15 +129,13 @@ public class CheckEBomException { } - - /** * 检查 EXCEPT_NO_3 EXCEPT_NO_6, EXCEPT_NO_9, EXCEPT_NO_10 * * @param */ private void checkOther() { - // List checkEBomExceptionDTOS=new ArrayList<>(); + // List checkEBomExceptionDTOS=new ArrayList<>(); List parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); for (BomNewEbomParentVO parent : parents) { List child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList()); @@ -184,20 +180,30 @@ public class CheckEBomException { } /** - * 黄色警号异常 + * 黄色警号异常 + * * @param list */ - public void initExceptionYellowWarn( List list ){ + public void initExceptionYellowWarn(List list) { List exceptionList = allBomDetail.stream().filter(u -> u.getExceptionStatus() > 1).collect(Collectors.toList()); - List exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); - if(CollUtil.isEmpty(exceptionMaterialNos)){ + // List exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + if (CollUtil.isEmpty(exceptionList)) { return; } - List allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos); - List warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); - warnList.forEach(k->{ - k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); - }); + for (BomNewEbomParentVO exItem : list) { + List warnList = allBomDetail.stream().filter(u -> exItem.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); + warnList.forEach(k -> { + k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); + }); + + } + + +// List allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos); +// List warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); +// warnList.forEach(k->{ +// k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); +// }); } @@ -205,10 +211,10 @@ public class CheckEBomException { * 检查循环依赖 */ private void checkCircularDependency(List list) { - List result = TreeUtils.checkParentChildRelationship(list, CheckEBomExceptionDTO::getParentMaterialNo, CheckEBomExceptionDTO::getChildMaterialNo, CheckEBomExceptionDTO::getRowId); - if(CollUtil.isNotEmpty(result)){ + List result = TreeUtils.checkParentChildRelationship(list, CheckEBomExceptionDTO::getParentMaterialNo, CheckEBomExceptionDTO::getChildMaterialNo, CheckEBomExceptionDTO::getRowId); + if (CollUtil.isNotEmpty(result)) { List collect = allBomDetail.stream().filter(u -> result.contains(u.getRowId())).collect(Collectors.toList()); - collect.forEach(u->{ + collect.forEach(u -> { u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue()); }); @@ -216,31 +222,26 @@ public class CheckEBomException { } + public void checkContainExcept(List codeList) throws NflgBusinessException { - public void checkContainExcept(List codeList) throws NflgBusinessException { + if (CollUtil.isEmpty(codeList)) return; - if(CollUtil.isEmpty(codeList))return; - - for (BomNewEbomParentVO item: - allBomDetail) { + for (BomNewEbomParentVO item : + allBomDetail) { //并集 寻找相同 - List list=CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());; + List list = CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList()); + ; - if(CollUtil.isNotEmpty(list)){ + if (CollUtil.isNotEmpty(list)) { - throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编码{} 异常情况 {}",item.getMaterialNo(),EBomExceptionStatusEnum.code2description(list.get(0)) )); + throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编码{} 异常情况 {}", item.getMaterialNo(), EBomExceptionStatusEnum.code2description(list.get(0)))); - } + } } - } - - - - } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPBom.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPBom.java index a8c63995..f1e98d35 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPBom.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPBom.java @@ -24,6 +24,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VersionUtil; import lombok.Getter; +import lombok.NoArgsConstructor; import org.bouncycastle.crypto.engines.EthereumIESEngine; import java.math.BigDecimal; @@ -34,6 +35,7 @@ import java.util.stream.Collectors; /** * Ebom 转Pbom */ +@NoArgsConstructor public class EBomToPBom { private BomNewEbomParentVO parent; @@ -93,7 +95,9 @@ public class EBomToPBom { //子级 List child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(child)) { - for (BomNewEbomParentVO eb : child) { + //合并子级 + List mergeChild = mergeChild(child); + for (BomNewEbomParentVO eb : mergeChild) { BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity(); BeanUtil.copyProperties(eb, childEnt); childEnt.setRowId(IdWorker.getId()); @@ -102,10 +106,28 @@ public class EBomToPBom { childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo())); this.pBomChildResult.add(childEnt); } + + } } } } + //合并子级 + public List mergeChild (List child){ + + List result=child.stream().filter(u->StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); + + Map> listMp = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo); + + for ( String key: listMp.keySet()) { + List voList = listMp.get(key); + BomNewEbomParentVO ent = voList.get(0); + ent.setNum(voList.stream().map(aa -> aa.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add)); + result.add(ent); + } + return result; + } + /** * 数据效验 @@ -142,6 +164,9 @@ public class EBomToPBom { pBomParent.setRowId(IdWorker.getId()); pBomParent.setLastVersionIs(1); pBomParent.setFacCode(facCode); + pBomParent.setTechnologyUserCode(SessionUtil.getUserCode()); + pBomParent.setTechnologyUserName(SessionUtil.getRealName()); + this.pBomParentResult.add(pBomParent); return pBomParent; } @@ -331,7 +356,7 @@ public class EBomToPBom { * @param bomRowID * @param parentDrawingNo */ - private void generateDrawingNo(List saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) { + public void generateDrawingNo(List saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) { List firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList()); parentDrawingNo = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : ""; Integer gNo = 1; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java index e5e00b38..ab00a99a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/VirtualPackageBase.java @@ -52,9 +52,9 @@ public abstract class VirtualPackageBase { protected BomNewEbomParentEntity buildParentVirtualPackage(String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType) throws IOException { //申请物料 - String vDrawingNo = String.join("",drawingNo,"(",virtualPackageType.getConMaterialName(),")" ); - String vMaterialName = StrUtil.join("",materialName,"(",virtualPackageType.getConMaterialName(),")"); - String vMaterialDesc = StrUtil.join("", drawingNo ," ", materialName,"(",virtualPackageType.getConMaterialName(),")"); + String vDrawingNo = String.join("","(",drawingNo,")","(",virtualPackageType.getConMaterialName(),")" ); + String vMaterialName = StrUtil.join("","(",materialName,")","(",virtualPackageType.getConMaterialName(),")"); + String vMaterialDesc = StrUtil.join("", "(",drawingNo,")" ,"(", materialName,")","(",virtualPackageType.getConMaterialName(),")"); BomNewEbomParentEntity oldParent=null; List oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getMaterialName, vMaterialName) .eq(MaterialMainEntity::getMaterialDesc, vMaterialDesc).list(); @@ -87,6 +87,7 @@ public abstract class VirtualPackageBase { // parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue()); parent.setShouldBomExist(1); parent.setBomExist(1); + parent.setMaterialUnit("PC"); parent.setSourceRowId(0L); parent.setLastVersionIs(1); parent.setNum(new BigDecimal(1)); @@ -115,6 +116,9 @@ public abstract class VirtualPackageBase { childEntity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); childEntity.setSource(EBomSourceEnum.FROM_MDM.getValue()); childEntity.setVirtualPartType(virtualPackageTypeEnum.getValue()); + childEntity.setProjectType("L"); + childEntity.setMaterialUnit("PC"); + childEntity.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue()); this.childResult.add(childEntity); return childEntity; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/sap/LevelNumUtil.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/sap/LevelNumUtil.java new file mode 100644 index 00000000..803bb5b4 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/sap/LevelNumUtil.java @@ -0,0 +1,31 @@ +package com.nflg.product.bomnew.util.sap; + +import cn.hutool.core.util.StrUtil; + +import java.math.BigDecimal; + +/** + * 大米 + */ +public class LevelNumUtil { + + public static BigDecimal levelToNum(String strLevel) { + if (StrUtil.isEmpty(strLevel)) { + return null; + } + if (strLevel.indexOf('-') == -1) { + return new BigDecimal(strLevel); + } + String[] fromArray = strLevel.split("-"); + String reuslt = ""; + for (int i = 0; i < fromArray.length; i++) { + if (i == 0) { + reuslt = fromArray[i] + '.'; + } else { + reuslt += StrUtil.padPre(fromArray[i], 2, '0'); + } + + } + return new BigDecimal(reuslt); + } +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml index cfb69436..c7a3bdbe 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml @@ -31,6 +31,8 @@ + + @@ -51,7 +53,7 @@ row_id, batch_no, drawing_no, fac_code, material_no, order_number, material_name, material_desc, material_texture, material_unit, unit_weight, total_weight, current_version, num, project_type, root_is, should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is, - virtual_package_is, source_row_id, devise_user_code, devise_name, created_by, created_time, created_job, + virtual_package_is, source_row_id, devise_user_code, devise_name,technology_user_code,technology_user_name, created_by, created_time, created_job, release_time, release_user_name, expire_end_time, remark, dept_name, level_num, change_desc, notice_nums, order_no, modify_time