|
|
@ -134,6 +134,60 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 发布物料BOM信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param bo 物料BOM信息
|
|
|
|
|
|
|
|
* @return 是否修改成功
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public Boolean publishByBo(ProdMaterialBomBo bo) {
|
|
|
|
|
|
|
|
String materialBomVersion = bo.getMaterialBomVersion();
|
|
|
|
|
|
|
|
bo.setDeleteFlag(HwMomMesConstants.DELETE_FLAG_NO);
|
|
|
|
|
|
|
|
bo.setMaterialBomVersion(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//先获取parentid所有的物料bom信息
|
|
|
|
|
|
|
|
List<ProdMaterialBomVo> allVosByParentId = this.queryList(bo);
|
|
|
|
|
|
|
|
if (allVosByParentId == null || allVosByParentId.isEmpty()) {
|
|
|
|
|
|
|
|
throw new ServiceException("数据已删除");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//再过滤出当前要发布的版本信息
|
|
|
|
|
|
|
|
List<ProdMaterialBomVo> toPublishVos = allVosByParentId.stream().
|
|
|
|
|
|
|
|
filter(e -> e.getMaterialBomVersion().equals(materialBomVersion) &&
|
|
|
|
|
|
|
|
!e.getActiveFlag().equals(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_ACTIVE))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (toPublishVos == null && toPublishVos.isEmpty()) {
|
|
|
|
|
|
|
|
throw new ServiceException("无可发布数据,或已发布");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//再过滤出其他激活版本,需要改为历史版本的数据
|
|
|
|
|
|
|
|
List<ProdMaterialBomVo> toHistoryVos = allVosByParentId.stream().
|
|
|
|
|
|
|
|
filter(e -> !e.getMaterialBomVersion().equals(materialBomVersion) &&
|
|
|
|
|
|
|
|
e.getActiveFlag().equals(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_ACTIVE))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发布
|
|
|
|
|
|
|
|
for (ProdMaterialBomVo toPublishVo : toPublishVos) {
|
|
|
|
|
|
|
|
ProdMaterialBom toPublishMaterialBom = MapstructUtils.convert(toPublishVo, ProdMaterialBom.class);
|
|
|
|
|
|
|
|
toPublishMaterialBom.setActiveFlag(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_ACTIVE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baseMapper.updateById(toPublishMaterialBom);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//改为历史版本
|
|
|
|
|
|
|
|
if (toHistoryVos != null && !toHistoryVos.isEmpty()) {
|
|
|
|
|
|
|
|
for (ProdMaterialBomVo toHistoryVo : toHistoryVos) {
|
|
|
|
|
|
|
|
ProdMaterialBom toHistoryMaterialBom = MapstructUtils.convert(toHistoryVo, ProdMaterialBom.class);
|
|
|
|
|
|
|
|
toHistoryMaterialBom.setActiveFlag(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_HISTORY);
|
|
|
|
|
|
|
|
baseMapper.updateById(toHistoryMaterialBom);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 校验并批量删除物料BOM信息信息
|
|
|
|
* 校验并批量删除物料BOM信息信息
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -163,7 +217,7 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
* @description 校验并批量删除物料BOM信息信息
|
|
|
|
* @description 校验并批量删除物料BOM信息信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional (rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public Boolean deleteMaterialBoms(List<ProdMaterialBomBo> materialBomBos) {
|
|
|
|
public Boolean deleteMaterialBoms(List<ProdMaterialBomBo> materialBomBos) {
|
|
|
|
Collection<Long> ids = new ArrayList<>();
|
|
|
|
Collection<Long> ids = new ArrayList<>();
|
|
|
|
materialBomBos.forEach(materialBomBo -> {
|
|
|
|
materialBomBos.forEach(materialBomBo -> {
|
|
|
@ -181,51 +235,65 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
* 更新前的数据校验
|
|
|
|
* 更新前的数据校验
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void validEntityUsed(@NotNull ProdMaterialBomBo entity) {
|
|
|
|
private void validEntityUsed(@NotNull ProdMaterialBomBo entity) {
|
|
|
|
Long semiFinishedId = mesProperties.getSemiFinishedId();
|
|
|
|
|
|
|
|
Long modelingId = mesProperties.getModelingId();
|
|
|
|
|
|
|
|
Long vulcanizingId = mesProperties.getVulcanizingId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String semiFinishedTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + semiFinishedId;
|
|
|
|
if(entity.getActiveFlag().equals(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_ACTIVE)){
|
|
|
|
String modelingTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + modelingId;
|
|
|
|
throw new ServiceException("此物料bom已经发布,不能修改");
|
|
|
|
String vulcanizingTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + vulcanizingId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProdPlanInfoBo queryBo = new ProdPlanInfoBo();
|
|
|
|
|
|
|
|
queryBo.setMaterialId(entity.getParentId());
|
|
|
|
|
|
|
|
queryBo.setMaterialBomVersion(entity.getMaterialBomVersion());
|
|
|
|
|
|
|
|
MPJLambdaWrapper<ProdPlanInfo> lqw = buildPlanQueryWrapper(queryBo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询半制品计划、成型计划、硫化计划中有没有使用此bom
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
List<ProdPlanInfoVo> semiFinishedPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(semiFinishedTableName, lqw);
|
|
|
|
|
|
|
|
if (semiFinishedPlanInfoVos != null && !semiFinishedPlanInfoVos.isEmpty()) {
|
|
|
|
|
|
|
|
List<String> planCodes = semiFinishedPlanInfoVos.stream()
|
|
|
|
|
|
|
|
.map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ServiceException("半制品计划中计划编号[" + planCodes.toString() + "]已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ProdPlanInfoVo> modelingPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(modelingTableName, lqw);
|
|
|
|
if(entity.getActiveFlag().equals(HwMomMesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_HISTORY)){
|
|
|
|
if (modelingPlanInfoVos != null && !modelingPlanInfoVos.isEmpty()) {
|
|
|
|
throw new ServiceException("此物料bom为历史版本,不能修改");
|
|
|
|
List<String> planCodes = modelingPlanInfoVos.stream()
|
|
|
|
|
|
|
|
.map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ServiceException("成型计划中计划编号[" + planCodes.toString() + "]已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProdPlanInfoVo> vulcanizingPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(vulcanizingTableName, lqw);
|
|
|
|
|
|
|
|
if (vulcanizingPlanInfoVos != null && !vulcanizingPlanInfoVos.isEmpty()) {
|
|
|
|
|
|
|
|
List<String> planCodes = vulcanizingPlanInfoVos.stream()
|
|
|
|
|
|
|
|
.map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ServiceException("硫化计划中计划编号已经使用[" + planCodes.toString() + "已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
|
|
// * 更新前的数据校验
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// private void validEntityUsed(@NotNull ProdMaterialBomBo entity) {
|
|
|
|
|
|
|
|
// Long semiFinishedId = mesProperties.getSemiFinishedId();
|
|
|
|
|
|
|
|
// Long modelingId = mesProperties.getModelingId();
|
|
|
|
|
|
|
|
// Long vulcanizingId = mesProperties.getVulcanizingId();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// String semiFinishedTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + semiFinishedId;
|
|
|
|
|
|
|
|
// String modelingTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + modelingId;
|
|
|
|
|
|
|
|
// String vulcanizingTableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + vulcanizingId;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// ProdPlanInfoBo queryBo = new ProdPlanInfoBo();
|
|
|
|
|
|
|
|
// queryBo.setMaterialId(entity.getParentId());
|
|
|
|
|
|
|
|
// queryBo.setMaterialBomVersion(entity.getMaterialBomVersion());
|
|
|
|
|
|
|
|
// MPJLambdaWrapper<ProdPlanInfo> lqw = buildPlanQueryWrapper(queryBo);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
|
|
// * 查询半制品计划、成型计划、硫化计划中有没有使用此bom
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// List<ProdPlanInfoVo> semiFinishedPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(semiFinishedTableName, lqw);
|
|
|
|
|
|
|
|
// if (semiFinishedPlanInfoVos != null && !semiFinishedPlanInfoVos.isEmpty()) {
|
|
|
|
|
|
|
|
// List<String> planCodes = semiFinishedPlanInfoVos.stream()
|
|
|
|
|
|
|
|
// .map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
// .toList();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// throw new ServiceException("半制品计划中计划编号[" + planCodes.toString() + "]已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// List<ProdPlanInfoVo> modelingPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(modelingTableName, lqw);
|
|
|
|
|
|
|
|
// if (modelingPlanInfoVos != null && !modelingPlanInfoVos.isEmpty()) {
|
|
|
|
|
|
|
|
// List<String> planCodes = modelingPlanInfoVos.stream()
|
|
|
|
|
|
|
|
// .map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
// .toList();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// throw new ServiceException("成型计划中计划编号[" + planCodes.toString() + "]已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// List<ProdPlanInfoVo> vulcanizingPlanInfoVos = prodPlanInfoMapper.selectProdPlanInfoList(vulcanizingTableName, lqw);
|
|
|
|
|
|
|
|
// if (vulcanizingPlanInfoVos != null && !vulcanizingPlanInfoVos.isEmpty()) {
|
|
|
|
|
|
|
|
// List<String> planCodes = vulcanizingPlanInfoVos.stream()
|
|
|
|
|
|
|
|
// .map(ProdPlanInfoVo::getPlanCode)
|
|
|
|
|
|
|
|
// .toList();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// throw new ServiceException("硫化计划中计划编号已经使用[" + planCodes.toString() + "已经使用此bom,不能修改");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -244,6 +312,20 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 根据父级物料ID获取下一个版本号
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param parentId
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String selectNextMaterialBomVersion(Long parentId) {
|
|
|
|
|
|
|
|
String nextMaterialBomVersion = baseMapper.selectNextMaterialBomVersion(parentId);
|
|
|
|
|
|
|
|
System.out.println("nnn:" + nextMaterialBomVersion);
|
|
|
|
|
|
|
|
return nextMaterialBomVersion;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据结构BOM批量插入物料清单BOM。
|
|
|
|
* 根据结构BOM批量插入物料清单BOM。
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -257,6 +339,9 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// long materialBomId = baseMapper.getNextMaterialBomIdSequence();
|
|
|
|
|
|
|
|
// System.out.println("matbomid:"+materialBomId);
|
|
|
|
|
|
|
|
|
|
|
|
//判断在新建子级时,是否存在在此颗树的父级节点存在此子级节点,根据bom版本找(可以先不加此判断,主要原因是物料类型已经限制了)
|
|
|
|
//判断在新建子级时,是否存在在此颗树的父级节点存在此子级节点,根据bom版本找(可以先不加此判断,主要原因是物料类型已经限制了)
|
|
|
|
//获取materialbomid不为空的更新,获取materialbomid为空materialid不为空的保存
|
|
|
|
//获取materialbomid不为空的更新,获取materialbomid为空materialid不为空的保存
|
|
|
|
for (ProdMaterialBomBo prodMaterialBomBo : boList) {
|
|
|
|
for (ProdMaterialBomBo prodMaterialBomBo : boList) {
|
|
|
@ -311,17 +396,295 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<TreeSelect> selectMaterialBomTreeList(ProdMaterialBomBo bo) {
|
|
|
|
public List<TreeSelect> selectMaterialBomTreeList(ProdMaterialBomBo bo) {
|
|
|
|
List<ProdMaterialBomVo> prodMaterialBomVos = baseMapper.selectMaterialBomJoinList(bo);
|
|
|
|
List<ProdMaterialBomVo> prodMaterialBomVos = baseMapper.selectMaterialBomJoinList(bo);
|
|
|
|
return buildMaterialBomTreeSelect(prodMaterialBomVos);
|
|
|
|
return buildMaterialBomTree(prodMaterialBomVos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 构建前端所需要树结构
|
|
|
|
* 构建前端所需要树结构
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param bomList 生产bom结构树列表
|
|
|
|
|
|
|
|
* @return 下拉树结构列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private List<TreeSelect> buildMaterialBomTree(List<ProdMaterialBomVo> bomList) {
|
|
|
|
|
|
|
|
// 1. 建立索引
|
|
|
|
|
|
|
|
Map<String, List<ProdMaterialBomVo>> parentVersionGroup = new HashMap<>();
|
|
|
|
|
|
|
|
Map<Long, Set<String>> materialVersions = new HashMap<>();
|
|
|
|
|
|
|
|
Map<Long, String> materialNameMap = new HashMap<>();
|
|
|
|
|
|
|
|
Map<Long, Long> materialTypeIdMap = new HashMap<>();
|
|
|
|
|
|
|
|
Map<Long, String> materialTypeNameMap = new HashMap<>();
|
|
|
|
|
|
|
|
Map<String, String> versionActiveFlagMap = new HashMap<>(); // 新增:存储版本状态
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ProdMaterialBomVo item : bomList) {
|
|
|
|
|
|
|
|
// 按parentId+version分组
|
|
|
|
|
|
|
|
String parentKey = item.getParentId() + "_" + item.getMaterialBomVersion();
|
|
|
|
|
|
|
|
parentVersionGroup.computeIfAbsent(parentKey, k -> new ArrayList<>()).add(item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录每个material的所有版本
|
|
|
|
|
|
|
|
materialVersions.computeIfAbsent(item.getMaterialId(), k -> new HashSet<>())
|
|
|
|
|
|
|
|
.add(item.getMaterialBomVersion());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录物料名称
|
|
|
|
|
|
|
|
if (item.getMaterialName() != null) {
|
|
|
|
|
|
|
|
materialNameMap.putIfAbsent(item.getMaterialId(), item.getMaterialName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.getParentMaterialName() != null) {
|
|
|
|
|
|
|
|
materialNameMap.putIfAbsent(item.getParentId(), item.getParentMaterialName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录物料类型ID和物料类型名称
|
|
|
|
|
|
|
|
if (item.getMaterialTypeId() != null) {
|
|
|
|
|
|
|
|
materialTypeIdMap.putIfAbsent(item.getMaterialId(), item.getMaterialTypeId());
|
|
|
|
|
|
|
|
materialTypeNameMap.putIfAbsent(item.getMaterialId(), item.getMaterialTypeName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.getParentMaterialTypeId() != null) {
|
|
|
|
|
|
|
|
materialTypeIdMap.putIfAbsent(item.getParentId(), item.getParentMaterialTypeId());
|
|
|
|
|
|
|
|
materialTypeNameMap.putIfAbsent(item.getParentId(), item.getParentMaterialTypeName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 记录版本状态(新增)
|
|
|
|
|
|
|
|
String versionKey = item.getParentId() + "_" + item.getMaterialBomVersion();
|
|
|
|
|
|
|
|
versionActiveFlagMap.putIfAbsent(versionKey, item.getActiveFlag()); // 假设activeFlag是boolean类型
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 找出顶级节点
|
|
|
|
|
|
|
|
Set<Long> topLevelParentIds = bomList.stream()
|
|
|
|
|
|
|
|
.map(ProdMaterialBomVo::getParentId)
|
|
|
|
|
|
|
|
.filter(parentId -> !materialVersions.containsKey(parentId))
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 构建树结构
|
|
|
|
|
|
|
|
List<TreeSelect> tree = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Long topParentId : topLevelParentIds) {
|
|
|
|
|
|
|
|
// 获取该顶级节点的所有版本
|
|
|
|
|
|
|
|
Set<String> parentVersions = bomList.stream()
|
|
|
|
|
|
|
|
.filter(item -> item.getParentId().equals(topParentId))
|
|
|
|
|
|
|
|
.map(ProdMaterialBomVo::getMaterialBomVersion)
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String version : parentVersions) {
|
|
|
|
|
|
|
|
String versionKey = topParentId + "_" + version;
|
|
|
|
|
|
|
|
String activeFlag = versionActiveFlagMap.get(versionKey);
|
|
|
|
|
|
|
|
TreeSelect versionNode = new TreeSelect();
|
|
|
|
|
|
|
|
versionNode.setTreeKey(versionKey);
|
|
|
|
|
|
|
|
versionNode.setLabel(buildLabel(topParentId, version, materialNameMap,materialTypeNameMap));
|
|
|
|
|
|
|
|
versionNode.setMaterialBomVersion(version);
|
|
|
|
|
|
|
|
versionNode.setMaterialId(topParentId);
|
|
|
|
|
|
|
|
versionNode.setMaterialTypeId(materialTypeIdMap.getOrDefault(topParentId, 0L));
|
|
|
|
|
|
|
|
versionNode.setMaterialTypeName(materialTypeNameMap.getOrDefault(topParentId, ""));
|
|
|
|
|
|
|
|
versionNode.setActiveFlag(activeFlag);
|
|
|
|
|
|
|
|
versionNode.setChildren(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String parentKey = topParentId + "_" + version;
|
|
|
|
|
|
|
|
if (parentVersionGroup.containsKey(parentKey)) {
|
|
|
|
|
|
|
|
// 获取该父节点下的所有materialId
|
|
|
|
|
|
|
|
Set<Long> childMaterialIds = parentVersionGroup.get(parentKey).stream()
|
|
|
|
|
|
|
|
.map(ProdMaterialBomVo::getMaterialId)
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Long materialId : childMaterialIds) {
|
|
|
|
|
|
|
|
// 添加无版本号的基础节点
|
|
|
|
|
|
|
|
versionNode.getChildren().add(createBasicNode(materialId,materialNameMap,materialTypeIdMap,materialTypeNameMap));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 动态添加该material的有子节点的版本
|
|
|
|
|
|
|
|
if (materialVersions.containsKey(materialId)) {
|
|
|
|
|
|
|
|
for (String childVersion : materialVersions.get(materialId)) {
|
|
|
|
|
|
|
|
TreeSelect versionedNode = createVersionNodeIfHasChildren(
|
|
|
|
|
|
|
|
materialId, childVersion, activeFlag,parentVersionGroup,materialNameMap,materialTypeIdMap,materialTypeNameMap);
|
|
|
|
|
|
|
|
if (versionedNode != null) {
|
|
|
|
|
|
|
|
versionNode.getChildren().add(versionedNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只有当有子节点时才添加父节点
|
|
|
|
|
|
|
|
if (!versionNode.getChildren().isEmpty()) {
|
|
|
|
|
|
|
|
tree.add(versionNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
|
|
|
// return topLevelNodes;
|
|
|
|
|
|
|
|
// return rootNodes.stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String buildLabel(Long materialId, String version, Map<Long, String> materialNameMap, Map<Long, String> materialTypeNameMap) {
|
|
|
|
|
|
|
|
String materialName = materialNameMap.getOrDefault(materialId, "");
|
|
|
|
|
|
|
|
String materialTypeName = materialTypeNameMap.getOrDefault(materialId, "");
|
|
|
|
|
|
|
|
return String.format("[%s][%s]%s",
|
|
|
|
|
|
|
|
version,
|
|
|
|
|
|
|
|
materialTypeName.isEmpty() ? "" : materialTypeName,
|
|
|
|
|
|
|
|
materialName.isEmpty() ? "" : materialName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static TreeSelect createBasicNode(Long materialId,
|
|
|
|
|
|
|
|
Map<Long, String> materialNameMap,Map<Long, Long> materialTypeIdMap,Map<Long, String> materialTypeNameMap) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.parentId = prodMaterialBomVo.getParentId();
|
|
|
|
|
|
|
|
TreeSelect node = new TreeSelect();
|
|
|
|
|
|
|
|
node.setTreeKey(materialId.toString());
|
|
|
|
|
|
|
|
String materialName = materialNameMap.getOrDefault(materialId, "");
|
|
|
|
|
|
|
|
String materialTypeName = materialTypeNameMap.getOrDefault(materialId, "");
|
|
|
|
|
|
|
|
String label = String.format("[%s]%s",
|
|
|
|
|
|
|
|
materialTypeName.isEmpty() ? "" : materialTypeName,
|
|
|
|
|
|
|
|
materialName.isEmpty() ? "" : materialName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node.setLabel(label);
|
|
|
|
|
|
|
|
node.setMaterialId(materialId);
|
|
|
|
|
|
|
|
node.setMaterialTypeId(materialTypeIdMap.getOrDefault(materialId, 0L));
|
|
|
|
|
|
|
|
node.setMaterialTypeName(materialTypeNameMap.getOrDefault(materialId, ""));
|
|
|
|
|
|
|
|
node.setMaterialBomVersion(null);
|
|
|
|
|
|
|
|
node.setActiveFlag(null);
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static TreeSelect createVersionNodeIfHasChildren(Long materialId, String version,String activeFlag,
|
|
|
|
|
|
|
|
Map<String, List<ProdMaterialBomVo>> parentVersionGroup,
|
|
|
|
|
|
|
|
Map<Long, String> materialNameMap,Map<Long, Long> materialTypeIdMap,Map<Long, String> materialTypeNameMap) {
|
|
|
|
|
|
|
|
String key = materialId + "_" + version;
|
|
|
|
|
|
|
|
// 只有当该版本有子节点时才创建
|
|
|
|
|
|
|
|
if (parentVersionGroup.containsKey(key)) {
|
|
|
|
|
|
|
|
TreeSelect node = new TreeSelect();
|
|
|
|
|
|
|
|
node.setTreeKey(key);
|
|
|
|
|
|
|
|
node.setLabel(buildLabel(materialId, version, materialNameMap,materialTypeNameMap));
|
|
|
|
|
|
|
|
node.setMaterialBomVersion(version);
|
|
|
|
|
|
|
|
node.setMaterialBomVersion(version);
|
|
|
|
|
|
|
|
node.setMaterialId(materialId);
|
|
|
|
|
|
|
|
node.setMaterialTypeId(materialTypeIdMap.getOrDefault(materialId, 0L));
|
|
|
|
|
|
|
|
node.setMaterialTypeName(materialTypeNameMap.getOrDefault(materialId, ""));
|
|
|
|
|
|
|
|
node.setActiveFlag(activeFlag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node.setChildren(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加子节点
|
|
|
|
|
|
|
|
Set<Long> childIds = parentVersionGroup.get(key).stream()
|
|
|
|
|
|
|
|
.map(ProdMaterialBomVo::getMaterialId)
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Long childId : childIds) {
|
|
|
|
|
|
|
|
node.getChildren().add(createBasicNode(childId,materialNameMap,materialTypeIdMap,materialTypeNameMap));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<TreeSelect> buildChildren(Long currentParentId,List<ProdMaterialBomVo> items,
|
|
|
|
|
|
|
|
Map<Long, Map<String, List<ProdMaterialBomVo>>> parentVersionMap) {
|
|
|
|
|
|
|
|
List<TreeSelect> children = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (ProdMaterialBomVo item : items) {
|
|
|
|
|
|
|
|
// 确保当前item的parentId匹配currentParentId
|
|
|
|
|
|
|
|
if (!item.getParentId().equals(currentParentId)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TreeSelect childNode = new TreeSelect();
|
|
|
|
|
|
|
|
childNode.setTreeKey(item.getMaterialId().toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有子节点
|
|
|
|
|
|
|
|
if (parentVersionMap.containsKey(item.getMaterialId())) {
|
|
|
|
|
|
|
|
// 有子节点,需要处理每个版本
|
|
|
|
|
|
|
|
Map<String, List<ProdMaterialBomVo>> versionMap = parentVersionMap.get(item.getMaterialId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (versionMap.size() == 1) {
|
|
|
|
|
|
|
|
// 只有一个版本
|
|
|
|
|
|
|
|
String version = versionMap.keySet().iterator().next();
|
|
|
|
|
|
|
|
childNode.setLabel(item.getMaterialId() + " (v" + version + ")");
|
|
|
|
|
|
|
|
childNode.setMaterialBomVersion(version);
|
|
|
|
|
|
|
|
childNode.setChildren(buildChildren(item.getMaterialId(), versionMap.get(version), parentVersionMap));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 多个版本,需要创建中间节点
|
|
|
|
|
|
|
|
childNode.setLabel(item.getMaterialId().toString());
|
|
|
|
|
|
|
|
childNode.setChildren(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<ProdMaterialBomVo>> versionEntry : versionMap.entrySet()) {
|
|
|
|
|
|
|
|
String version = versionEntry.getKey();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TreeSelect versionNode = new TreeSelect();
|
|
|
|
|
|
|
|
versionNode.setTreeKey(item.getMaterialId() + "_" + version);
|
|
|
|
|
|
|
|
versionNode.setLabel(item.getMaterialId() + " (v" + version + ")");
|
|
|
|
|
|
|
|
versionNode.setMaterialBomVersion(version);
|
|
|
|
|
|
|
|
versionNode.setChildren(buildChildren(item.getMaterialId(), versionEntry.getValue(), parentVersionMap));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childNode.getChildren().add(versionNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 没有子节点,直接创建
|
|
|
|
|
|
|
|
childNode.setLabel(item.getMaterialId().toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children.add(childNode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return children;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private static void printTree(List<ProdMaterialBomVo> nodes, int indent) {
|
|
|
|
|
|
|
|
// for (ProdMaterialBomVo node : nodes) {
|
|
|
|
|
|
|
|
// System.out.println(" ".repeat(indent) + node.getParentMaterialName()+"["+node.getMaterialBomVersion()+"]"+node.getMaterialName());
|
|
|
|
|
|
|
|
// printTree(node.getChildren(), indent + 1);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private List<TreeSelect> buildMaterialBomTree(List<ProdMaterialBomVo> prodMaterialBomVos) {
|
|
|
|
|
|
|
|
// // 用于存储所有节点
|
|
|
|
|
|
|
|
// Map<String, TreeSelect> nodeMap = new HashMap<>();
|
|
|
|
|
|
|
|
// // 用于存储根节点
|
|
|
|
|
|
|
|
// List<TreeSelect> rootNodes = new ArrayList<>();
|
|
|
|
|
|
|
|
// // 用于识别哪些materialId是父节点
|
|
|
|
|
|
|
|
// Map<String, Boolean> isParentMap = new HashMap<>();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // 第一次遍历:创建所有节点并识别父节点
|
|
|
|
|
|
|
|
// for (ProdMaterialBomVo bom : prodMaterialBomVos) {
|
|
|
|
|
|
|
|
// // 创建节点
|
|
|
|
|
|
|
|
// TreeSelect node = new TreeSelect(bom);
|
|
|
|
|
|
|
|
// String nodeKey = bom.getMaterialId() + "|" + bom.getMaterialBomVersion();
|
|
|
|
|
|
|
|
// nodeMap.put(nodeKey, node);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // 标记此materialId是某个节点的parentId
|
|
|
|
|
|
|
|
// isParentMap.put(bom.getParentId(), true);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// // 第二次遍历:建立父子关系
|
|
|
|
|
|
|
|
// for (ProdMaterialBomVo bom : prodMaterialBomVos) {
|
|
|
|
|
|
|
|
// String nodeKey = bom.getMaterialId() + "|" + bom.getMaterialBomVersion();
|
|
|
|
|
|
|
|
// String parentKey = bom.getParentId() + "|" + bom.getMaterialBomVersion();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// TreeSelect currentNode = nodeMap.get(nodeKey);
|
|
|
|
|
|
|
|
// TreeSelect parentNode = nodeMap.get(parentKey);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (parentNode != null) {
|
|
|
|
|
|
|
|
// // 添加到父节点的子列表
|
|
|
|
|
|
|
|
// parentNode.addChild(currentNode);
|
|
|
|
|
|
|
|
// } else if (!isParentMap.containsKey(bom.getMaterialId())) {
|
|
|
|
|
|
|
|
// // 如果当前节点的materialId从未作为parentId出现过,则是根节点
|
|
|
|
|
|
|
|
// rootNodes.add(currentNode);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return rootNodes;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 构建前端所需要树结构(废弃)
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param prodMaterialBomVos 部门列表
|
|
|
|
* @param prodMaterialBomVos 部门列表
|
|
|
|
* @return 树结构列表
|
|
|
|
* @return 树结构列表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private List<ProdMaterialBomVo> buildMaterialBomTree(List<ProdMaterialBomVo> prodMaterialBomVos) {
|
|
|
|
private List<ProdMaterialBomVo> buildMaterialBomTreeNodesDiscard(List<ProdMaterialBomVo> prodMaterialBomVos) {
|
|
|
|
List<ProdMaterialBomVo> returnList = new ArrayList<ProdMaterialBomVo>();
|
|
|
|
List<ProdMaterialBomVo> returnList = new ArrayList<ProdMaterialBomVo>();
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 由于顶级节点的parent没有父级对象,需要虚拟新增一个
|
|
|
|
* 由于顶级节点的parent没有父级对象,需要虚拟新增一个
|
|
|
@ -334,10 +697,10 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2、过滤出parentId相同的
|
|
|
|
//2、过滤出parentId-materialBomVersion相同的
|
|
|
|
List<ProdMaterialBomVo> distinctParentIdVoList = topMaterialBomVos.stream()
|
|
|
|
List<ProdMaterialBomVo> distinctParentIdVoList = topMaterialBomVos.stream()
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
ProdMaterialBomVo::getParentId, // 以parentId作为key
|
|
|
|
ProdMaterialBomVo::getKey, // 以parentId-materialBomVersion作为key
|
|
|
|
Function.identity(), // 以对象本身作为value
|
|
|
|
Function.identity(), // 以对象本身作为value
|
|
|
|
(existing, replacement) -> existing // 如果遇到重复的key,保留已有的对象
|
|
|
|
(existing, replacement) -> existing // 如果遇到重复的key,保留已有的对象
|
|
|
|
))
|
|
|
|
))
|
|
|
@ -355,6 +718,7 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
topProdMaterialBomVo.setMaterialTypeName(prodMaterialBomVo.getParentMaterialTypeName());//设置parent的物料类型名称
|
|
|
|
topProdMaterialBomVo.setMaterialTypeName(prodMaterialBomVo.getParentMaterialTypeName());//设置parent的物料类型名称
|
|
|
|
topProdMaterialBomVo.setMaterialName(prodMaterialBomVo.getParentMaterialName());//设置parent的物料名称
|
|
|
|
topProdMaterialBomVo.setMaterialName(prodMaterialBomVo.getParentMaterialName());//设置parent的物料名称
|
|
|
|
topProdMaterialBomVo.setMaterialBomVersion(prodMaterialBomVo.getMaterialBomVersion());
|
|
|
|
topProdMaterialBomVo.setMaterialBomVersion(prodMaterialBomVo.getMaterialBomVersion());
|
|
|
|
|
|
|
|
topProdMaterialBomVo.setActiveFlag(prodMaterialBomVo.getActiveFlag());
|
|
|
|
prodMaterialBomVos.add(topProdMaterialBomVo);
|
|
|
|
prodMaterialBomVos.add(topProdMaterialBomVo);
|
|
|
|
|
|
|
|
|
|
|
|
recursionFn(prodMaterialBomVos, topProdMaterialBomVo);
|
|
|
|
recursionFn(prodMaterialBomVos, topProdMaterialBomVo);
|
|
|
@ -379,30 +743,10 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
returnList = prodMaterialBomVos;
|
|
|
|
returnList = prodMaterialBomVos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return returnList;
|
|
|
|
return returnList;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 构建前端所需要下拉树结构
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param prodMaterialBomVos 生产bom结构树列表
|
|
|
|
|
|
|
|
* @return 下拉树结构列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private List<TreeSelect> buildMaterialBomTreeSelect(List<ProdMaterialBomVo> prodMaterialBomVos) {
|
|
|
|
|
|
|
|
// 根据物料bom版本号group,不能的版本是不同的树。使用 groupingBy 将 List 转换为 Map<String, List<ProdMaterialBomVo>>
|
|
|
|
|
|
|
|
Map<String, List<ProdMaterialBomVo>> prodMaterialBomVoMap = prodMaterialBomVos.stream()
|
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(ProdMaterialBomVo::getMaterialBomVersion));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProdMaterialBomVo> allMaterialBomTrees = new ArrayList<>();
|
|
|
|
|
|
|
|
// 根据物料版本号build树
|
|
|
|
|
|
|
|
prodMaterialBomVoMap.forEach((materialBomVersion, vos) -> {
|
|
|
|
|
|
|
|
List<ProdMaterialBomVo> materialBomTrees = buildMaterialBomTree(vos);
|
|
|
|
|
|
|
|
allMaterialBomTrees.addAll(materialBomTrees);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return allMaterialBomTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 递归列表
|
|
|
|
* 递归列表
|
|
|
@ -410,14 +754,21 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
private void recursionFn(List<ProdMaterialBomVo> list, ProdMaterialBomVo parent) {
|
|
|
|
private void recursionFn(List<ProdMaterialBomVo> list, ProdMaterialBomVo parent) {
|
|
|
|
// 获取子节点
|
|
|
|
// 获取子节点
|
|
|
|
List<ProdMaterialBomVo> childList = getChildList(list, parent);
|
|
|
|
List<ProdMaterialBomVo> childList = getChildList(list, parent);
|
|
|
|
|
|
|
|
if(childList == null || childList.isEmpty()){
|
|
|
|
|
|
|
|
System.out.println(parent.getMaterialBomId()+"----");
|
|
|
|
|
|
|
|
// parent.setMaterialBomVersion("");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
System.out.println(parent.getMaterialBomId()+"****"+childList.get(0).getMaterialBomVersion());
|
|
|
|
|
|
|
|
// parent.setMaterialBomVersion(childList.get(0).getMaterialBomVersion());
|
|
|
|
|
|
|
|
}
|
|
|
|
parent.setChildren(childList);
|
|
|
|
parent.setChildren(childList);
|
|
|
|
|
|
|
|
|
|
|
|
// 递归处理子节点
|
|
|
|
// 递归处理子节点
|
|
|
|
for (ProdMaterialBomVo child : childList) {
|
|
|
|
for (ProdMaterialBomVo child : childList) {
|
|
|
|
// 确保子节点继承 BOM 版本信息
|
|
|
|
// 父节点显示bom版本信息(一个父子记录的信息的bom版本),确保子节点继承 BOM 版本信息
|
|
|
|
if (StringUtils.isBlank(child.getMaterialBomVersion()) && StringUtils.isNotBlank(parent.getMaterialBomVersion())) {
|
|
|
|
// if (StringUtils.isNotBlank(child.getMaterialBomVersion())) {
|
|
|
|
child.setMaterialBomVersion(parent.getMaterialBomVersion());
|
|
|
|
// parent.setMaterialBomVersion(child.getMaterialBomVersion());
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
recursionFn(list, child);
|
|
|
|
recursionFn(list, child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|