|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.op.wms.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -30,17 +33,6 @@ public class BaseBomComponentServiceImpl implements IBaseBomComponentService {
|
|
|
|
|
return baseBomComponentMapper.selectBaseBomComponentById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询物料BOM子表列表
|
|
|
|
|
*
|
|
|
|
|
* @param baseBomComponent 物料BOM子表
|
|
|
|
|
* @return 物料BOM子表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseBomComponent> selectBaseBomComponentList(BaseBomComponent baseBomComponent) {
|
|
|
|
|
return baseBomComponentMapper.selectBaseBomComponentList(baseBomComponent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增物料BOM子表
|
|
|
|
|
*
|
|
|
|
@ -86,4 +78,51 @@ public class BaseBomComponentServiceImpl implements IBaseBomComponentService {
|
|
|
|
|
public int deleteBaseBomComponentById(Long id) {
|
|
|
|
|
return baseBomComponentMapper.deleteBaseBomComponentById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归方法转换成树形结构
|
|
|
|
|
* @param baseBomComponent
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<BaseBomComponent> selectBaseBomComponentList(BaseBomComponent baseBomComponent){
|
|
|
|
|
List<BaseBomComponent> trees = new ArrayList<>();//新创建
|
|
|
|
|
List<BaseBomComponent> baseBomComponentList = baseBomComponentMapper.selectBaseBomComponentList(baseBomComponent);//查询baseBomComponent
|
|
|
|
|
List<String> filterBaseBomComponentList = baseBomComponentMapper.selectBomCodeList(baseBomComponent);//查询BomCodeList
|
|
|
|
|
List<String> filterCumcList = baseBomComponentMapper.selectProductCodeList(baseBomComponent);//查询BomCodeList
|
|
|
|
|
//查询cumc 是否存在于product_code
|
|
|
|
|
for (BaseBomComponent tree : baseBomComponentList) {
|
|
|
|
|
//找出父节点
|
|
|
|
|
boolean bool1 = filterBaseBomComponentList.contains(tree.getBomCode());//查询父节点是否在bom表中
|
|
|
|
|
boolean bool2 = filterCumcList.contains(tree.getCumc());//查询节点是否是父节点
|
|
|
|
|
// if (bool1 && bool2) {
|
|
|
|
|
if (bool1) {
|
|
|
|
|
// 调用递归方法填充子节点列表
|
|
|
|
|
trees.add(findChildren(tree,baseBomComponentList));//找到孩子节点
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return trees;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归方法
|
|
|
|
|
* @param baseBomComponent 父节点对象
|
|
|
|
|
* @param baseBomComponentList 所有的List
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public BaseBomComponent findChildren(BaseBomComponent baseBomComponent, List<BaseBomComponent> baseBomComponentList) {
|
|
|
|
|
//父 Cumc 子Component
|
|
|
|
|
for (BaseBomComponent node : baseBomComponentList) {
|
|
|
|
|
if (baseBomComponent.getComponent().equals(node.getCumc())) {
|
|
|
|
|
if (baseBomComponent.getChildren() == null) {
|
|
|
|
|
baseBomComponent.setChildren(new ArrayList<>());
|
|
|
|
|
}
|
|
|
|
|
// 递归调用自身
|
|
|
|
|
baseBomComponent.getChildren().add(findChildren(node, baseBomComponentList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return baseBomComponent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|