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 2e950dec..8ab71adb 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 @@ -68,6 +68,9 @@ public class EbomApi extends BaseApi { @Resource private BomNewEbomUpgradeChangeService upgradeChangeService; + @Resource + private BomNewPbomParentService bomNewPbomParentService; + @PostMapping("workDetailsListByPage") @ApiOperation("Ebom-工作明细列表") @@ -143,6 +146,8 @@ public class EbomApi extends BaseApi { VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); bomNewEbomParentService.convertToPBom(paramDto); + //更新PBomUse 数据 + bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse(); return ResultVO.success(true); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomMaterialUseMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomMaterialUseMapper.java new file mode 100644 index 00000000..a49a7690 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomMaterialUseMapper.java @@ -0,0 +1,13 @@ +package com.nflg.product.bomnew.mapper.master; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomMaterialUseEntity; + +/** + * t_bom_new_pbom_material_use 表数据库访问层 + * + * @author makejava + * @since 2024-01-09 16:17:50 + */ +public interface BomNewPbomMaterialUseMapper extends BaseMapper { +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomParentMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomParentMapper.java index 8071a628..6e76f722 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomParentMapper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomParentMapper.java @@ -33,4 +33,10 @@ public interface BomNewPbomParentMapper extends BaseMapper rowIds ); + void updatePBomMaterialUse(); + + List getParentForMaterialNoSeach(@Param("userFac") String userFac,@Param("materialNoList") List materialNoList); + + List getChildForMaterialNoSeach(@Param("userFac") String userFac,@Param("materialNoList") List materialNoList,@Param("materialNo")String materialNo); + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomMaterialUseEntity.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomMaterialUseEntity.java new file mode 100644 index 00000000..33df43df --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomMaterialUseEntity.java @@ -0,0 +1,50 @@ +package com.nflg.product.bomnew.pojo.entity; + +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_material_use + * + * @author makejava + * @since 2024-01-09 16:17:50 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewPbomMaterialUseEntity") +@TableName(value = "t_bom_new_pbom_material_use") +public class BomNewPbomMaterialUseEntity implements Serializable { + + /** + * 主键-雪花 + */ + @TableId(value = "row_id", type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键-雪花") + private Long rowId; + + /** + * 物料编码 + */ + @TableField(value = "material_no") + @ApiModelProperty(value = "物料编码") + private String materialNo; + + /** + * 父级物料编码,多个用逗号隔开 + */ + @TableField(value = "parent_material_no") + @ApiModelProperty(value = "父级物料编码,多个用逗号隔开") + private String parentMaterialNo; + + private static final long serialVersionUID = -73503794405112500L; + +} 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 242a7673..ca20a83d 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 @@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.vo; import java.math.BigDecimal; import java.time.LocalDateTime; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.LocalDateTimeUtil; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -210,8 +211,8 @@ 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"); + public LocalDateTime getExpireEndTime() { + return expireEndTime==null? LocalDateTime.of(9999,12,31,23,59,59):expireEndTime; } /** diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomMaterialUseService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomMaterialUseService.java new file mode 100644 index 00000000..8d4dd099 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomMaterialUseService.java @@ -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.BomNewPbomMaterialUseMapper; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomMaterialUseEntity; +import org.springframework.stereotype.Service; + + +/** + * t_bom_new_pbom_material_use 表服务实现类 + * + * + * @author makejava + * @since 2024-01-09 16:17:50 + */ +@Service +public class BomNewPbomMaterialUseService extends ServiceImpl { + +} 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 e16c5343..4fb227eb 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 @@ -85,6 +85,10 @@ public class BomNewPbomParentService extends ServiceImpl workDetailsListByPage(BomNewPbomParentQuery query) { //物料编码搜索或图号搜索 -// if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) { -// String materialNo = query.getMaterialNo(); -// if (StrUtil.isBlank(materialNo)) { -// List materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); -// if (CollUtil.isNotEmpty(materialList)) { -// materialNo = materialList.get(0).getMaterialNo(); -// } -// } -// if (StrUtil.isNotBlank(materialNo)) { -// List parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician()).stream().collect(Collectors.toList()); -// if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { -// List parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo); -// List childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo); -// List data = new ArrayList<>(); -// data.addAll(parents); -// data.addAll(childs); -// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); -// returnResult = handSeachToTree(parents, childs); -// } -// } -// return null; -// } -// else { + if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) { + String materialNo = query.getMaterialNo(); + if (StrUtil.isBlank(materialNo)) { + List materialList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); + if (CollUtil.isNotEmpty(materialList)) { + materialNo = materialList.get(0).getMaterialNo(); + } + } + if (StrUtil.isNotBlank(materialNo)) { + List parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList()); + if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { + List parents = this.getBaseMapper().getParentForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo ); + List childs = this.getBaseMapper().getChildForMaterialNoSeach(userRoleService.getUserFactory(),parentMaterialByMaterialNo, materialNo); + List data = new ArrayList<>(); + data.addAll(parents); + data.addAll(childs); + materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + return handSeachToTree(parents, childs); + } + } + return null; + } else { Page result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory()); materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); return result; -// } + } + } + + private Page handSeachToTree(List parents, List childs) { + Page resutlData = new Page<>(); + Set parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + Set childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + Set difference = Sets.difference(parentSet, childSet); + List resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList()); + resutlData.setTotal(difference.size()); + resutlData.setSize(difference.size()); + resutlData.setPages(1); + resutlData.setCurrent(1L); + List all = new ArrayList<>(); + // all.addAll(resultParents); + all.addAll(childs); + List result = new ArrayList<>(); + for (BomNewPbomParentVO vo : resultParents) { + //vo.setParentRowId(0L); + List da = new ArrayList<>(); + da.addAll(childs); + da.add(vo); + result.addAll(CTreePBomUtils.toTree(0L, da, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId)); + } + resutlData.setRecords(result); + return resutlData; } /** * 获取物料所有子级 * @param materialNo - * @param selfIs + * @param * @return */ -// public Set getParentMaterialByMaterialNo(String materialNo, Boolean selfIs) { -// BomNewEbomMaterialUseEntity materialBom = bomNewEbomMaterialUseService.lambdaQuery().eq(BomNewEbomMaterialUseEntity::getMaterialNo, materialNo).one(); -// Set result = new HashSet<>(); -// if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { -// Set relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); -// if (selfIs && CollUtil.isNotEmpty(relSkuNo)) { -// relSkuNo = getSelfMaterialNo(relSkuNo); -// } -// while (CollUtil.isNotEmpty(relSkuNo)) { -// result.addAll(relSkuNo); -// List relSkuList = bomNewEbomMaterialUseService.lambdaQuery().in(BomNewEbomMaterialUseEntity::getMaterialNo, relSkuNo).list(); -// relSkuNo.clear(); -// Set finalRelSkuNo = relSkuNo; -// relSkuList.forEach(k -> { -// if (StrUtil.isNotBlank(k.getParentMaterialNo())) { -// finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); -// } -// }); -// relSkuNo = finalRelSkuNo; -// if (CollUtil.isNotEmpty(relSkuNo) && selfIs) { -// relSkuNo = getSelfMaterialNo(relSkuNo); -// } -// } -// } -// return result; -// } + public Set getParentMaterialByMaterialNo(String materialNo) { + BomNewPbomMaterialUseEntity materialBom = pbomMaterialUseService.lambdaQuery().eq(BomNewPbomMaterialUseEntity::getMaterialNo, materialNo).one(); + Set result = new HashSet<>(); + if (Objects.nonNull(materialBom) && StrUtil.isNotBlank(materialBom.getParentMaterialNo())) { + Set relSkuNo = Sets.newHashSet(StrUtil.split(materialBom.getParentMaterialNo(), ",")); + + while (CollUtil.isNotEmpty(relSkuNo)) { + result.addAll(relSkuNo); + List relSkuList = pbomMaterialUseService.lambdaQuery().in(BomNewPbomMaterialUseEntity::getMaterialNo, relSkuNo).list(); + relSkuNo.clear(); + Set finalRelSkuNo = relSkuNo; + relSkuList.forEach(k -> { + if (StrUtil.isNotBlank(k.getParentMaterialNo())) { + finalRelSkuNo.addAll(Sets.newHashSet(StrUtil.split(k.getParentMaterialNo(), ","))); + } + }); + relSkuNo = finalRelSkuNo; + } + } + return result; + } + + /** * 已 + * * @param query * @return */ @@ -166,16 +192,17 @@ public class BomNewPbomParentService extends ServiceImpl() { + new Workbook().addSheet(new ListSheet() { Long n = 1L; + @Override protected List more() { query.setPage(n); n++; - List result=workDetailsListByPage(query).getRecords(); - return CollUtil.isNotEmpty(result)?result:null; + List result = workDetailsListByPage(query).getRecords(); + return CollUtil.isNotEmpty(result) ? result : null; } }).writeTo(response.getOutputStream()); } @@ -322,7 +349,6 @@ public class BomNewPbomParentService extends ServiceImpl copyBomCheck(Long sourceBomRowId, String targetFacCode) throws ExecutionException, InterruptedException { - checkCopyBomParam(sourceBomRowId,targetFacCode); - BomCopy bomCopy=new BomCopy(sourceBomRowId,targetFacCode,getAllBom(sourceBomRowId,0)); + checkCopyBomParam(sourceBomRowId, targetFacCode); + BomCopy bomCopy = new BomCopy(sourceBomRowId, targetFacCode, getAllBom(sourceBomRowId, 0)); bomCopy.check(); - return Convert.toList(BomCopyCheckResultVO.class,bomCopy.getCheckList() ) ; + return Convert.toList(BomCopyCheckResultVO.class, bomCopy.getCheckList()); } @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(),0)); + checkCopyBomParam(param.getSourceBomRowId(), param.getTargetFacCode()); + BomCopy bomCopy = new BomCopy(param.getSourceBomRowId(), param.getTargetFacCode(), getAllBom(param.getSourceBomRowId(), 0)); bomCopy.copy(param.getCheckResult()); - if(CollUtil.isNotEmpty(bomCopy.getParentResult())){ + if (CollUtil.isNotEmpty(bomCopy.getParentResult())) { this.saveOrUpdateBatch(bomCopy.getParentResult()); } - if(CollUtil.isNotEmpty(bomCopy.getChildResult())){ + if (CollUtil.isNotEmpty(bomCopy.getChildResult())) { pbomChildService.saveBatch(bomCopy.getChildResult()); } @@ -422,8 +449,9 @@ public class BomNewPbomParentService extends ServiceImpl getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException { List bomDetail = this.getBaseMapper().getParentChild(rowId); AtomicInteger levelNum = new AtomicInteger(1); - PBomDetailTask detailTask = new PBomDetailTask(bomDetail,countLevelNum,levelNum); + PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum); ForkJoinTask> submit = bomDetailPool.submit(detailTask); List result = submit.join(); @@ -439,29 +467,29 @@ public class BomNewPbomParentService extends ServiceImpl getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException { + public List getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException { List 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 getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException { + public List getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException { List 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); + return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId); } @Transactional(rollbackFor = Exception.class) - public Boolean saveAllocationFactory(List params){ + public Boolean saveAllocationFactory(List params) { VUtils.isTure(CollUtil.isEmpty(params)).throwMessage("分配工厂数据为空"); //按分配的工厂分组 Map> stringListMap = ListCommonUtil.listGroupMap(params, SaveAllocationFactoryDTO::getProductionFactoryCode); for (Map.Entry> entry : stringListMap.entrySet()) { List saveList = entry.getValue(); List rowIds = saveList.stream().map(u -> u.getRowId()).collect(Collectors.toList()); - pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(),rowIds); + pbomChildService.getBaseMapper().setProductionFactoryCode(entry.getKey(), rowIds); } return true; } @@ -470,43 +498,43 @@ public class BomNewPbomParentService extends ServiceImpl childrenVO = getAllBom(params.getBomRowId() ,0); + List childrenVO = getAllBom(params.getBomRowId(), 0); materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); List relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); - StringBuilder relPattern=new StringBuilder(); - List result=new ArrayList<>(); - Boolean match=true; - for (BomNewPbomParentVO child : childrenVO) { - if(StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType()) ){ + StringBuilder relPattern = new StringBuilder(); + List result = new ArrayList<>(); + 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.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.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.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.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.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.getMaterialTexture())) { + match = match & (StrUtil.isNotBlank(child.getMaterialTexture()) && child.getMaterialName().equals(role.getMaterialTexture())); } - if(StrUtil.isNotBlank(role.getNextMaterialCategoryCode())){ - List childSubNodes=childrenVO.stream().filter(u->u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList()); + if (StrUtil.isNotBlank(role.getNextMaterialCategoryCode())) { + List childSubNodes = childrenVO.stream().filter(u -> u.getParentRowId().equals(child.getBomRowId())).collect(Collectors.toList()); List relChild = childSubNodes.stream().filter(u -> u.getMaterialCategoryCode().equals(role.getNextMaterialCategoryCode())).collect(Collectors.toList()); - match=match & (relChild.size()>0); + match = match & (relChild.size() > 0); } - if(match){ + if (match) { BomNewPbomChildEntity ent = new BomNewPbomChildEntity(); ent.setRowId(child.getRowId()); ent.setFacCode(role.getFactoryCode()); @@ -517,51 +545,49 @@ public class BomNewPbomParentService extends ServiceImpl backRowId){ + public void reConvertToMBom(Long bomRowId, List backRowId) { - UpdateWrapper updateWrapper=new UpdateWrapper<>(); - updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode,backRowId); - updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId,backRowId); - + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.lambda().set(BomNewPbomChildEntity::getProductionFactoryCode, backRowId); + updateWrapper.lambda().in(BomNewPbomChildEntity::getRowId, backRowId); } - /** * 发布MBOM */ @Transactional(rollbackFor = Exception.class) - public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException { + public Boolean convertToMBom(Long bomRowId) throws ExecutionException, InterruptedException { BomNewPbomParentEntity rootParent = this.getById(bomRowId); List allChild = getAllBom(bomRowId, 0); - if(StrUtil.isBlank(rootParent.getOrderNo())){ + if (StrUtil.isBlank(rootParent.getOrderNo())) { String orderNo = crmService.getOrderNo(rootParent.getMaterialNo()); rootParent.setOrderNo(orderNo); } VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号"); List noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList)+"物料暂未分工厂,请分完工厂再进行发布"); - ConvertToMBom convertToMBom=new ConvertToMBom(rootParent ,allChild); + VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布"); + ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild); convertToMBom.convertToMBom(); - if(CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())){ + if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) { mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); } - if(CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())){ + if (CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())) { mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult()); } //将PBOM改为已发布 @@ -569,25 +595,24 @@ public class BomNewPbomParentService extends ServiceImpl allBom = getAllBom(bomRowId, 0); List bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList()); - Integer state= parent.getMaterialNo().startsWith("31")?PBomStatusEnum.WAIT_FACTORY.getValue():PBomStatusEnum.PUBLISH.getValue(); + Integer state = parent.getMaterialNo().startsWith("31") ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue(); bomRowIds.add(bomRowId); - this.getBaseMapper().bomRelease(state,SessionUtil.getUserName(),bomRowIds); + this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds); //保存订单号 this.updateById(parent); + } catch (Exception ex) { + throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage()); } - catch (Exception ex){ - throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:"+ex.getMessage()); - } - return true; + return true; } /** * 获取CRM 订单号 + * * @param materialNo * @return */ - public String getCrmOrderNo(String materialNo){ + public String getCrmOrderNo(String materialNo) { return crmService.getOrderNo(materialNo); } 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 f9a5c0e0..4749d35b 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 @@ -76,9 +76,9 @@ public class UserRoleService { public List getUserOfFactory(){ Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId()); if(userMultiplantFacRoleCount>0){ - return ImmutableList.of("1010","1020"); + return ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010,EBomConstant.XIAN_TAO_FACTORY_CODE_1020); }else { - return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of("1020") : ImmutableList.of("1010") ; + return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of(EBomConstant.XIAN_TAO_FACTORY_CODE_1020) : ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010) ; } } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomMaterialUseMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomMaterialUseMapper.xml new file mode 100644 index 00000000..dfcfe02c --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomMaterialUseMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + row_id, material_no, parent_material_no + + 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 c7a3bdbe..daf3e9e1 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 @@ -124,6 +124,48 @@ + + SET @@global.group_concat_max_len=804800; + truncate table t_bom_new_pbom_material_use; + INSERT INTO `t_bom_new_pbom_material_use` (`row_id`, `material_no`, `parent_material_no`) + + select min(b.row_id) rowId, b.material_no, GROUP_CONCAt( distinct a.material_no) as value_list + from t_bom_new_pbom_parent a + join t_bom_new_pbom_child b on a.row_id=b.parent_row_id and a.last_version_is=1 + group by b.material_no ; + + + + + + + +