1.分工厂

This commit is contained in:
大米 2024-01-03 19:32:02 +08:00
parent 017646bd95
commit 00a19a8851
16 changed files with 759 additions and 110 deletions

View File

@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.constant.PBomEditStatusEnum;
import com.nflg.product.bomnew.pojo.dto.CopyPBomParam;
import com.nflg.product.bomnew.pojo.dto.EditPBomDelDTO;
import com.nflg.product.bomnew.pojo.dto.EditPBomParamDTO;
import com.nflg.product.bomnew.pojo.dto.TechnologyPackageParam;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
@ -149,6 +146,30 @@ public class PBomApi extends BaseApi {
}
@PostMapping("getAllocationFactoryBom")
@ApiOperation("分工厂-获取BOM树")
public ResultVO<List<BomNewPbomParentVO> > getAllocationFactoryBom(@Valid @RequestBody AllocationFactoryBomQuery param ) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewPbomParentService.getAllocationFactoryBom(param));
}
@PostMapping("saveAllocationFactory")
@ApiOperation("分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody List<SaveAllocationFactoryDTO> params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
}
@PostMapping("allocationFactoryForRel")
@ApiOperation("分工厂-规则匹配")
public ResultVO<Boolean> allocationFactoryForRel(@Valid @RequestBody AllocationFactoryForRelDTO params) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewPbomParentService.allocationFactoryForRel(params));
}

View File

@ -0,0 +1,18 @@
package com.nflg.product.bomnew.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum ProductionFactoryCodeInputTypeEnum implements ValueEnum<Integer> {
// 0-默认 1-规则匹配 2-手工
DEFAULT(0, "默认"),
RULE_MATCH(1, "规则匹配"),
MANUAL(2, "手工");
private final Integer value;
private final String description;
}

View File

@ -0,0 +1,15 @@
package com.nflg.product.bomnew.mapper.master;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.product.bomnew.pojo.entity.BomFactorySplitRuleEntity;
/**
* t_bom_factory_split_rule 表数据库访问层
* PBOM工厂拆分规则
*
* @author makejava
* @since 2024-01-03 18:43:03
*/
public interface BomFactorySplitRuleMapper extends BaseMapper<BomFactorySplitRuleEntity> {
}

View File

@ -21,4 +21,6 @@ public interface BomNewPbomChildMapper extends BaseMapper<BomNewPbomChildEntity>
void setVirtualPart(@Param("rowIds") List<Long> rowIds);
void delByParentRowId(@Param("parentRowId") Long parentRowId);
void setProductionFactoryCode(@Param("productionFactoryCode")String productionFactoryCode, @Param("rowIds") List<Long> rowIds);
}

View File

@ -0,0 +1,32 @@
package com.nflg.product.bomnew.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.logging.Level;
/**
* 分工厂-获取BOM明细
*
*/
@Data
public class AllocationFactoryBomQuery {
@ApiModelProperty("bom版本行ID")
@NotNull(message = "bom版本行ID不能为空")
private Long bomRowId;
@ApiModelProperty("物料编码")
private String materialNo;
@ApiModelProperty("图号")
private String drawingNo;
@ApiModelProperty("层级")
private Integer levelNum;
}

View File

@ -0,0 +1,23 @@
package com.nflg.product.bomnew.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 分工厂-规则匹配参数
*/
@Data
public class AllocationFactoryForRelDTO {
@ApiModelProperty("bom版本行ID")
@NotNull(message = "bom版本行ID不能为空")
private Long bomRowId;
@ApiModelProperty("规则分组代码")
@NotNull(message = "规则分组代码不能为空")
private String ruleGroupCode;
}

View File

@ -0,0 +1,21 @@
package com.nflg.product.bomnew.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 保存分工厂参数
*/
@Data
public class SaveAllocationFactoryDTO {
@ApiModelProperty("bom明细行ID")
@NotNull(message = "bom明细行ID不能为空")
private Long rowId;
@ApiModelProperty("生产工厂")
@NotNull(message = "生产工厂不能为空")
private String productionFactoryCode;
}

View File

@ -0,0 +1,191 @@
package com.nflg.product.bomnew.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* t_bom_factory_split_rule
* PBOM工厂拆分规则
*
* @author makejava
* @since 2024-01-03 18:43:03
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-factory-entity-BomFactorySplitRuleEntity")
@TableName(value = "t_bom_factory_split_rule")
public class BomFactorySplitRuleEntity implements Serializable {
/**
*
*/
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "")
private Long rowId;
/**
* 排序
*/
@TableField(value = "rule_group_depth")
@ApiModelProperty(value = "排序")
private Integer ruleGroupDepth;
/**
* 规则分组代码
*/
@TableField(value = "rule_group_code")
@ApiModelProperty(value = "规则分组代码")
private String ruleGroupCode;
/**
* 规则分组名称
*/
@TableField(value = "rule_group_name")
@ApiModelProperty(value = "规则分组名称")
private String ruleGroupName;
/**
* 规则名称
*/
@TableField(value = "rule_name")
@ApiModelProperty(value = "规则名称")
private String ruleName;
/**
* 物料分类编码
*/
@TableField(value = "material_category_code")
@ApiModelProperty(value = "物料分类编码")
private String materialCategoryCode;
/**
* 物料分类名称
*/
@TableField(value = "material_category_name")
@ApiModelProperty(value = "物料分类名称")
private String materialCategoryName;
/**
* 图号前缀
*/
@TableField(value = "drawing_prefix")
@ApiModelProperty(value = "图号前缀")
private String drawingPrefix;
/**
* 图号包含
*/
@TableField(value = "drawing_contain")
@ApiModelProperty(value = "图号包含")
private String drawingContain;
/**
* 图号后缀
*/
@TableField(value = "drawing_suffix")
@ApiModelProperty(value = "图号后缀")
private String drawingSuffix;
/**
* 名称包含指的是物料名称
*/
@TableField(value = "material_name_contain")
@ApiModelProperty(value = "名称包含(指的是物料名称)")
private String materialNameContain;
/**
* 材质
*/
@TableField(value = "material_texture")
@ApiModelProperty(value = "材质")
private String materialTexture;
/**
* 部门ID
*/
@TableField(value = "dept_row_id")
@ApiModelProperty(value = "部门ID")
private Long deptRowId;
/**
* 部门名称
*/
@TableField(value = "dept_name")
@ApiModelProperty(value = "部门名称")
private String deptName;
/**
* 下级BOM行包含物料分类代码
*/
@TableField(value = "next_material_category_code")
@ApiModelProperty(value = "下级BOM行包含物料分类代码")
private String nextMaterialCategoryCode;
/**
* 下级BOM行包含物料分类名称
*/
@TableField(value = "next_material_category_name")
@ApiModelProperty(value = "下级BOM行包含物料分类名称")
private String nextMaterialCategoryName;
/**
* 目标工厂编码
*/
@TableField(value = "factory_code")
@ApiModelProperty(value = "目标工厂编码")
private String factoryCode;
/**
* 规则状态1=生效2=作废
*/
@TableField(value = "status")
@ApiModelProperty(value = "规则状态1=生效、2=作废")
private Integer status;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
/**
* 创建人
*/
@TableField(value = "created_by")
@ApiModelProperty(value = "创建人")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_time")
@ApiModelProperty(value = "创建时间")
private LocalDateTime createdTime;
/**
* 更新人
*/
@TableField(value = "updated_by")
@ApiModelProperty(value = "更新人")
private String updatedBy;
/**
* 更新时间
*/
@TableField(value = "updated_time")
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatedTime;
private static final long serialVersionUID = -87704764754587418L;
}

View File

@ -2,210 +2,220 @@ 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_child
*
* t_bom_new_pbom_child
*
* @author makejava
* @since 2024-01-01 10:39:51
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewPbomChildEntity")
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewPbomChildEntity")
@TableName(value = "t_bom_new_pbom_child")
public class BomNewPbomChildEntity implements Serializable {
/**
* 主键-雪花
*/
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键-雪花")
private Long rowId;
/**
* 父行ID
*/
@TableField(value = "parent_row_id")
@ApiModelProperty(value = "父行ID")
@TableField(value = "parent_row_id")
@ApiModelProperty(value = "父行ID")
private Long parentRowId;
/**
* 父级id_子级ID(原父节点ID)
*/
@TableField(value = "identity_no")
@ApiModelProperty(value = "父级id_子级ID(原父节点ID)")
@TableField(value = "identity_no")
@ApiModelProperty(value = "父级id_子级ID(原父节点ID)")
private String identityNo;
/**
* 工厂编码
*/
@TableField(value = "fac_code")
@ApiModelProperty(value = "工厂编码")
@TableField(value = "fac_code")
@ApiModelProperty(value = "工厂编码")
private String facCode;
/**
* 排序号
*/
@TableField(value = "order_number")
@ApiModelProperty(value = "排序号")
@TableField(value = "order_number")
@ApiModelProperty(value = "排序号")
private String orderNumber;
/**
* 图号
*/
@TableField(value = "drawing_no")
@ApiModelProperty(value = "图号")
@TableField(value = "drawing_no")
@ApiModelProperty(value = "图号")
private String drawingNo;
/**
* 物料编码
*/
@TableField(value = "material_no")
@ApiModelProperty(value = "物料编码")
@TableField(value = "material_no")
@ApiModelProperty(value = "物料编码")
private String materialNo;
/**
* 物料名称
*/
@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 = "material_category_code")
@ApiModelProperty(value = "物料分类编码")
@TableField(value = "material_category_code")
@ApiModelProperty(value = "物料分类编码")
private String materialCategoryCode;
/**
* 单重
*/
@TableField(value = "unit_weight")
@ApiModelProperty(value = "单重")
@TableField(value = "unit_weight")
@ApiModelProperty(value = "单重")
private BigDecimal unitWeight;
/**
* 数量
*/
@TableField(value = "num")
@ApiModelProperty(value = "数量")
@TableField(value = "num")
@ApiModelProperty(value = "数量")
private BigDecimal num;
/**
* 总重
*/
@TableField(value = "total_weight")
@ApiModelProperty(value = "总重")
@TableField(value = "total_weight")
@ApiModelProperty(value = "总重")
private BigDecimal totalWeight;
/**
* 项目类别
*/
@TableField(value = "project_type")
@ApiModelProperty(value = "项目类别")
@TableField(value = "project_type")
@ApiModelProperty(value = "项目类别")
private String projectType;
/**
* 生产工厂
*/
@TableField(value = "production_factory_code")
@ApiModelProperty(value = "生产工厂")
@TableField(value = "production_factory_code")
@ApiModelProperty(value = "生产工厂")
private String productionFactoryCode;
/**
* 生产工厂设置方式 0-默认 1-规则匹配 2-手工
*/
@TableField(value = "production_factory_code_input_type")
@ApiModelProperty("生产工厂设置方式 0-默认 1-规则匹配 2-手工")
private Integer productionFactoryCodeInputType;
/**
* 设置生产工厂时间
*/
@TableField(value = "set_production_factory_time")
@ApiModelProperty(value = "设置生产工厂时间")
@TableField(value = "set_production_factory_time")
@ApiModelProperty(value = "设置生产工厂时间")
private LocalDateTime setProductionFactoryTime;
/**
* 是否超级物料
*/
@TableField(value = "super_material_status")
@ApiModelProperty(value = "是否超级物料")
@TableField(value = "super_material_status")
@ApiModelProperty(value = "是否超级物料")
private Integer superMaterialStatus;
/**
* 是否虚拟件 0- 1-
*/
@TableField(value = "virtual_part_is")
@ApiModelProperty(value = "是否虚拟件 0-否 1-是")
@TableField(value = "virtual_part_is")
@ApiModelProperty(value = "是否虚拟件 0-否 1-是")
private Integer virtualPartIs;
/**
* 创建人工号
*/
@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;
/**
* 更新时间
*/
@TableField(value = "modify_time")
@ApiModelProperty(value = "更新时间")
@TableField(value = "modify_time")
@ApiModelProperty(value = "更新时间")
private LocalDateTime modifyTime;
/**
* 来源行-父项物BOM行ID(作废)
*/
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行-父项物BOM行ID(作废)")
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行-父项物BOM行ID(作废)")
private Long sourceRowId;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
/**
* 来源行-父项物料编码
*/
@TableField(value = "source_parent_material_no")
@ApiModelProperty(value = "来源行-父项物料编码")
@TableField(value = "source_parent_material_no")
@ApiModelProperty(value = "来源行-父项物料编码")
private String sourceParentMaterialNo;
private static final long serialVersionUID = -76633783850936076L;
}

View File

@ -9,6 +9,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.List;
/**
* t_bom_new_pbom_parent
@ -239,9 +240,15 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty("生产工厂")
private String productionFactoryCode;
@ApiModelProperty("生产工厂设置方式 0-默认 1-规则匹配 2-手工")
private Integer productionFactoryCodeInputType;
@ApiModelProperty("是否虚拟件 0-否 1-是")
private Integer virtualPartIs;
@ApiModelProperty("子级")
List<BomNewPbomParentVO> childNodes;
private static final long serialVersionUID = 1L;

View File

@ -0,0 +1,19 @@
package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.mapper.master.BomFactorySplitRuleMapper;
import com.nflg.product.bomnew.pojo.entity.BomFactorySplitRuleEntity;
import org.springframework.stereotype.Service;
/**
* t_bom_factory_split_rule 表服务实现类
* PBOM工厂拆分规则
*
* @author makejava
* @since 2024-01-03 18:43:03
*/
@Service
public class BomFactorySplitRuleService extends ServiceImpl<BomFactorySplitRuleMapper, BomFactorySplitRuleEntity> {
}

View File

@ -9,27 +9,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.constant.PBomEditStatusEnum;
import com.nflg.product.bomnew.constant.PBomStatusEnum;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.CopyPBomParam;
import com.nflg.product.bomnew.pojo.dto.EditPBomDelDTO;
import com.nflg.product.bomnew.pojo.dto.EditPBomParamDTO;
import com.nflg.product.bomnew.pojo.dto.TechnologyPackageParam;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.PBom.BomCopy;
import com.nflg.product.bomnew.service.domain.PBom.PBomDetailTask;
import com.nflg.product.bomnew.service.domain.PBom.TechnologyPackageParamBuilder;
import com.nflg.product.bomnew.util.EecExcelUtil;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.*;
import nflg.product.common.constant.STATE;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@ -39,6 +28,7 @@ import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -73,6 +63,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource
MaterialService materialService;
@Resource
BomFactorySplitRuleService bomFactorySplitRuleService;
@Resource
@Qualifier(value = "getPBomDetailPool")
private ForkJoinPool bomDetailPool;
@ -87,7 +80,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
materialMainService.intiMaterialInfo(result.getRecords(), "material", "materialTexture", "projectType");
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return result;
}
@ -96,7 +89,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
BomNewPbomParentEntity parent = this.getById(rowId);
if (CollUtil.isNotEmpty(parentChild)) {
materialMainService.intiMaterialInfo(parentChild, "material", "materialTexture", "projectType");
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<String> materialNos = parentChild.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewPbomParentEntity> list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos).eq(BomNewPbomParentEntity::getLastVersionIs, 1).list();
@ -306,7 +299,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
*/
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException {
checkCopyBomParam(sourceBomRowId,targetFacCode);
BomCopy bomCopy=new BomCopy(sourceBomRowId,targetFacCode,getAllBom(sourceBomRowId));
BomCopy bomCopy=new BomCopy(sourceBomRowId,targetFacCode,getAllBom(sourceBomRowId,0));
bomCopy.check();
return Convert.toList(BomCopyCheckResultVO.class,bomCopy.getCheckList() ) ;
@ -315,7 +308,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public void copyFrom(CopyPBomParam param) throws ExecutionException, InterruptedException {
checkCopyBomParam(param.getSourceBomRowId(),param.getTargetFacCode());
BomCopy bomCopy=new BomCopy(param.getSourceBomRowId(),param.getTargetFacCode(),getAllBom(param.getSourceBomRowId()));
BomCopy bomCopy=new BomCopy(param.getSourceBomRowId(),param.getTargetFacCode(),getAllBom(param.getSourceBomRowId(),0));
bomCopy.copy(param.getCheckResult());
if(CollUtil.isNotEmpty(bomCopy.getParentResult())){
@ -329,14 +322,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
/**
* 获取整颗树的BOM明细
* @param rowId
* @param
* @param countLevelNum 是否标记层级 0- 1-
* @return
* @throws ExecutionException
* @throws InterruptedException
*/
public List<BomNewPbomParentVO> getAllBom(Long rowId) throws ExecutionException, InterruptedException {
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail,countLevelNum);
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewPbomParentVO> result = submit.join();
@ -344,5 +339,87 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
}
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
}
@Transactional(rollbackFor = Exception.class)
public Boolean saveAllocationFactory(List<SaveAllocationFactoryDTO> params){
VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空");
//按分配的工厂分组
Map<String, List<SaveAllocationFactoryDTO>> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode);
for (Map.Entry<String, List<SaveAllocationFactoryDTO>> entry : stringListMap.entrySet()) {
List<SaveAllocationFactoryDTO> saveList = entry.getValue();
List<Long> rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList());
pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(),rowIds);
}
return true;
}
public Boolean allocationFactoryForRel(AllocationFactoryForRelDTO params) throws ExecutionException, InterruptedException {
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId() ,0);
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
StringBuilder relPattern=new StringBuilder();
Map<Long ,String> result=new HashMap<>();
Boolean match=true;
for (BomNewPbomParentVO child : childrenVO) {
if(StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType()) ){
continue;
}
for (BomFactorySplitRuleEntity role : relList) {
if(StrUtil.isNotBlank(role.getMaterialCategoryCode())){
match=match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode()));
}
if(StrUtil.isNotBlank(role.getDrawingPrefix())){
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().startsWith(role.getDrawingPrefix()));
}
if(StrUtil.isNotBlank(role.getDrawingContain())){
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().contains(role.getDrawingPrefix()));
}
if(StrUtil.isNotBlank(role.getDrawingSuffix())){
match=match & (StrUtil.isNotBlank(child.getDrawingNo()) && child.getDrawingNo().endsWith(role.getDrawingSuffix()));
}
if(StrUtil.isNotBlank(role.getMaterialNameContain())){
match=match & (StrUtil.isNotBlank(child.getMaterialName()) && child.getMaterialName().contains(role.getMaterialNameContain()));
}
if(StrUtil.isNotBlank(role.getMaterialTexture())){
match=match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture()));
}
if(StrUtil.isNotBlank(role.getNextMaterialCategoryCode())){
List<BomNewPbomParentVO> childSubNodes=childrenVO.stream().filter(u->u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList());
List<BomNewPbomParentVO> relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList());
match=match & (relChild.size()>0);
}
if(match){
result.put(child.getRowId(), role.getFactoryCode());
break;
}
}
}
if(CollUtil.isNotEmpty(result)){
}
return true;
}
}

View File

@ -34,11 +34,17 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
List<BomNewPbomParentVO> result = new ArrayList<>();
public static Integer levelNum=1;
//是否统计层级数
private Integer countLevelState;
public PBomDetailTask(List<BomNewPbomParentVO> inBomDetail) {
public PBomDetailTask(List<BomNewPbomParentVO> inBomDetail ,Integer inCountLevelState) {
bomDetail = inBomDetail;
countLevelState=inCountLevelState;
}
@ -59,6 +65,32 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
detailVO.setBomRowId(ebomParentEntity.getRowId());
detailVO.setSourceRowId(ebomParentEntity.getSourceRowId());
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
detailVO.setStatus(ebomParentEntity.getStatus());
detailVO.setEditStatus(ebomParentEntity.getEditStatus());
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
detailVO.setCreatedTime(ebomParentEntity.getCreatedTime());
detailVO.setLevelNum(ebomParentEntity.getLevelNum());
detailVO.setDeptName(ebomParentEntity.getDeptName());
detailVO.setChangeDesc(ebomParentEntity.getChangeDesc());
detailVO.setOrderNo(ebomParentEntity.getOrderNo());
detailVO.setBomExist(ebomParentEntity.getBomExist());
detailVO.setShouldBomExist(ebomParentEntity.getShouldBomExist());
detailVO.setVirtualPackageIs(ebomParentEntity.getVirtualPackageIs());
}
else {
BomNewPbomParentEntity parent= SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, detailVO.getParentRowId()).one();
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
detailVO.setDeviseName(parent.getDeviseName());
detailVO.setDeptName(parent.getDeptName());
detailVO.setStatus(parent.getStatus());
detailVO.setEditStatus(parent.getEditStatus());
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs()) ;
}
}
@ -80,6 +112,12 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
// 最新 BOM 版本
result.addAll(bomDetail);
//标记层级
if(countLevelState.equals(1)){
bomDetail.forEach(k->k.setLevelNum(levelNum));
levelNumAdd();
}
if (CollUtil.isNotEmpty(bomDetail)) {
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getBomRowId() > 0).map(u->u.getBomRowId()).collect(Collectors.toList());
@ -87,7 +125,7 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
List<BomNewPbomChildEntity> children = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().in(BomNewPbomChildEntity::getParentRowId, childBowIds).list();
List<BomNewPbomParentVO> bom = Convert.toList(BomNewPbomParentVO.class,children);
PBomDetailTask task = new PBomDetailTask(bom);
PBomDetailTask task = new PBomDetailTask(bom,countLevelState);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;
@ -95,8 +133,11 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
}
return result;
}
public synchronized void levelNumAdd(){
levelNum++;
}

View File

@ -0,0 +1,126 @@
package com.nflg.product.bomnew.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
*
* @author 大米
* @date 2023/11/18 16:19
*/
public class CTreePBomUtils {
/**
*
*
* @param dataList 数据
* @param keyFun id
* @param parentKeyFun 父级id
* @param rootKey 顶层的 id 比如部门树的顶层id是0
*/
public static <T, K> List<BomNewPbomParentVO> toTree(K rootKey,
Collection<T> dataList,
@NotNull Function<T, K> parentKeyFun,
@NotNull Function<T, K> keyFun) {
return toFilterTree(rootKey, dataList, parentKeyFun, keyFun, null);
}
/**
*
*
* @param rootKey 顶层的 id 比如部门树的顶层id是0
* @param dataList 数据列
* @param parentKeyFun 取父级id的方法引用
* @param keyFun 取子级id的方法引用
* @param filterNoDataFun 存在这种场景选人的时候某个子部门以及父部门下没有下挂任何人员那么这两个部门直接隐藏避免对用户造成干扰
* 这个参数表示部门实体类人员字段的方法引用
*/
public static <T, K, D> List<BomNewPbomParentVO> toFilterTree(K rootKey,
Collection<T> dataList,
@NotNull Function<T, K> parentKeyFun,
@NotNull Function<T, K> keyFun,
Function<T, D> filterNoDataFun) {
if (CollUtil.isEmpty(dataList)) {
return Collections.emptyList();
}
// 根据父节点对列表进行分组
Map<K, List<T>> groupParentKeyMap = dataList.stream().filter(t -> parentKeyFun.apply(t) != null).collect(Collectors.groupingBy(parentKeyFun));
List<T> rootNodes;
if (rootKey == null) {
rootNodes = dataList.stream().filter(t -> parentKeyFun.apply(t) == null).collect(Collectors.toList());
} else {
rootNodes = groupParentKeyMap.getOrDefault(rootKey, Collections.emptyList());
}
return handlerChildTree(rootNodes, groupParentKeyMap, keyFun, filterNoDataFun);
}
/**
* 列表转树
*/
private static <T, K, D> List<BomNewPbomParentVO> handlerChildTree(Collection<T> rootNodes, Map<K, List<T>> groupParentKeyMap,
Function<T, K> keyFun, Function<T, D> filterNoDataFun) {
if (CollUtil.isEmpty(rootNodes)) {
return Collections.emptyList();
}
List<BomNewPbomParentVO> nodes = new ArrayList<>();
for (T t : rootNodes) {
List<T> childNodesData = groupParentKeyMap.getOrDefault(keyFun.apply(t), Collections.emptyList());
BomNewPbomParentVO node =new BomNewPbomParentVO();
BeanUtil.copyProperties(t,node);
List<BomNewPbomParentVO> treeNodes = handlerChildTree(childNodesData, groupParentKeyMap, keyFun, filterNoDataFun);
if (filterNoDataFun != null && CollUtil.isEmpty(treeNodes)) {
if (skipNoDataNode(filterNoDataFun, t)) {
continue;
}
}
nodes.add(node);
node.setChildNodes(treeNodes);
}
return nodes;
}
/**
* 判断是否为空数据如果没有数据则隐藏
*/
@SuppressWarnings("rawtypes")
private static <T, D> boolean skipNoDataNode(Function<T, D> filterNoDataFun, T t) {
D filterData = filterNoDataFun.apply(t);
if (filterData == null) {
return true;
}
if (filterData instanceof Collection) {
Collection filterDataList = (Collection) filterData;
return CollUtil.isEmpty(filterDataList);
}
return false;
}
/**
* 树转list
*/
public static <T> List<T> toList(List<TreeNode<T>> treeNodeList) {
List<T> resultList = new ArrayList<>();
for (TreeNode<T> treeNode : treeNodeList) {
if (treeNode == null || treeNode.getData() == null) {
continue;
}
resultList.add(treeNode.getData());
if (CollUtil.isNotEmpty(treeNode.getChildNodes())) {
resultList.addAll(toList(treeNode.getChildNodes()));
}
}
return resultList;
}
}

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomFactorySplitRuleMapper">
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomFactorySplitRuleEntity">
<!--@mbg.generated-->
<!--@Table t_bom_factory_split_rule -->
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
<result column="rule_group_depth" property="ruleGroupDepth" jdbcType="INTEGER"/>
<result column="rule_group_code" property="ruleGroupCode" jdbcType="VARCHAR"/>
<result column="rule_group_name" property="ruleGroupName" jdbcType="VARCHAR"/>
<result column="rule_name" property="ruleName" jdbcType="VARCHAR"/>
<result column="material_category_code" property="materialCategoryCode" jdbcType="VARCHAR"/>
<result column="material_category_name" property="materialCategoryName" jdbcType="VARCHAR"/>
<result column="drawing_prefix" property="drawingPrefix" jdbcType="VARCHAR"/>
<result column="drawing_contain" property="drawingContain" jdbcType="VARCHAR"/>
<result column="drawing_suffix" property="drawingSuffix" jdbcType="VARCHAR"/>
<result column="material_name_contain" property="materialNameContain" jdbcType="VARCHAR"/>
<result column="material_texture" property="materialTexture" jdbcType="VARCHAR"/>
<result column="dept_row_id" property="deptRowId" jdbcType="BIGINT"/>
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
<result column="next_material_category_code" property="nextMaterialCategoryCode" jdbcType="VARCHAR"/>
<result column="next_material_category_name" property="nextMaterialCategoryName" jdbcType="VARCHAR"/>
<result column="factory_code" property="factoryCode" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
row_id, rule_group_depth, rule_group_code, rule_group_name, rule_name, material_category_code, material_category_name, drawing_prefix, drawing_contain, drawing_suffix, material_name_contain, material_texture, dept_row_id, dept_name, next_material_category_code, next_material_category_name, factory_code, status, remark, created_by, created_time, updated_by, updated_time </sql>
</mapper>

View File

@ -22,6 +22,7 @@
<result column="total_weight" property="totalWeight" jdbcType="DECIMAL"/>
<result column="project_type" property="projectType" jdbcType="VARCHAR"/>
<result column="production_factory_code" property="productionFactoryCode" jdbcType="VARCHAR"/>
<result column="production_factory_code_input_type" property="productionFactoryCodeInputType" jdbcType="INTEGER"/>
<result column="set_production_factory_time" property="setProductionFactoryTime" jdbcType="TIMESTAMP"/>
<result column="super_material_status" property="superMaterialStatus" jdbcType="INTEGER"/>
<result column="virtual_part_is" property="virtualPartIs" jdbcType="INTEGER"/>
@ -35,7 +36,7 @@
<sql id="Base_Column_List">
<!--@mbg.generated-->
row_id, parent_row_id, identity_no, fac_code, order_number, drawing_no, material_no, material_name, material_desc, material_texture, material_unit, material_category_code, unit_weight, num, total_weight, project_type, production_factory_code, set_production_factory_time, super_material_status, virtual_part_is, created_by, created_time, modify_time, source_row_id, remark, source_parent_material_no </sql>
row_id, parent_row_id, identity_no, fac_code, order_number, drawing_no, material_no, material_name, material_desc, material_texture, material_unit, material_category_code, unit_weight, num, total_weight, project_type, production_factory_code,production_factory_code_input_type, set_production_factory_time, super_material_status, virtual_part_is, created_by, created_time, modify_time, source_row_id, remark, source_parent_material_no </sql>
<delete id="delByRowId">
@ -56,4 +57,12 @@
delete from t_bom_new_pbom_child where parent_row_id =#{parentRowId}
</delete>
<update id="setProductionFactoryCode">
update t_bom_new_pbom_child set production_factory_code=#{productionFactoryCode}, set_production_factory_time=now() , production_factory_code_input_type=2
where row_id in
<foreach collection="rowIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>