From 1f7113fc991231e4fc0c9da44553bb8263abbaf8 Mon Sep 17 00:00:00 2001 From: A0010407 Date: Wed, 30 Aug 2023 21:13:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF-BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/wms/controller/BaseBomController.java | 4 +- .../op/wms/mapper/BaseBomComponentMapper.java | 2 + .../com/op/wms/service/IBaseBomService.java | 2 +- .../impl/BaseBomComponentServiceImpl.java | 61 +++++++++++++++---- .../wms/service/impl/BaseBomServiceImpl.java | 45 -------------- .../op-wms/src/main/resources/bootstrap.yml | 4 +- .../mapper/wms/BaseBomComponentMapper.xml | 2 +- 7 files changed, 57 insertions(+), 63 deletions(-) diff --git a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseBomController.java b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseBomController.java index 4f7e3574..97c24e0d 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseBomController.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/controller/BaseBomController.java @@ -42,9 +42,7 @@ public class BaseBomController extends BaseController { @GetMapping("/list") public TableDataInfo list(BaseBom baseBom) { startPage(); - BaseBomComponent baseBomComponent = new BaseBomComponent(); - List list = new ArrayList<>(); - List baseBoms = baseBomService.selectBaseBomComponentList(baseBomComponent); + List baseBoms = baseBomService.selectBaseBomList(baseBom); return getDataTable(baseBoms); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomComponentMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomComponentMapper.java index 1709d771..1741f608 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomComponentMapper.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomComponentMapper.java @@ -63,4 +63,6 @@ public interface BaseBomComponentMapper { List selectBomCodeList(BaseBomComponent baseBomComponent); //查询BaseBomComponent表中的product_code List selectProductCodeList(BaseBomComponent baseBomComponent); + //查询全部 + List selectAllBaseBomComponentList(BaseBomComponent baseBomComponent); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseBomService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseBomService.java index 3c075240..b0134bab 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseBomService.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IBaseBomService.java @@ -27,7 +27,7 @@ public interface IBaseBomService { */ public List selectBaseBomList(BaseBom baseBom); //public List selectBaseBomList(BaseBom baseBom, BaseBomComponent baseBomComponent, List list); - public List selectBaseBomComponentList(BaseBomComponent baseBomComponent); +// public List selectBaseBomComponentList(BaseBomComponent baseBomComponent); /** * 新增BOM物料管理 diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomComponentServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomComponentServiceImpl.java index b9c704e2..cc2387ae 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomComponentServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomComponentServiceImpl.java @@ -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 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 selectBaseBomComponentList(BaseBomComponent baseBomComponent){ + List trees = new ArrayList<>();//新创建 + List baseBomComponentList = baseBomComponentMapper.selectBaseBomComponentList(baseBomComponent);//查询baseBomComponent + List filterBaseBomComponentList = baseBomComponentMapper.selectBomCodeList(baseBomComponent);//查询BomCodeList + List 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 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; + } } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomServiceImpl.java index 2e736a7d..9c7ae615 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/BaseBomServiceImpl.java @@ -143,49 +143,4 @@ public class BaseBomServiceImpl implements IBaseBomService { // return node; // } - /** - * 递归方法转换成树形结构 - * @param baseBomComponent - * @return - */ - @Override - @DS("#header.poolName") - public List selectBaseBomComponentList(BaseBomComponent baseBomComponent){ - List trees = new ArrayList<>();//新创建 - List baseBomComponentList = baseBomComponentMapper.selectBaseBomComponentList(baseBomComponent);//查询baseBomComponent - List filterBaseBomComponentList = baseBomComponentMapper.selectBomCodeList(baseBomComponent);//查询BomCodeList - List 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) { - // 调用递归方法填充子节点列表 - trees.add(findChildren(tree,baseBomComponentList));//找到孩子节点 - } - } - return trees; - } - - /** - * 递归方法 - * @param baseBomComponent 父节点对象 - * @param baseBomComponentList 所有的List - * @return - */ - - public BaseBomComponent findChildren(BaseBomComponent baseBomComponent, List 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; - } } diff --git a/op-modules/op-wms/src/main/resources/bootstrap.yml b/op-modules/op-wms/src/main/resources/bootstrap.yml index 01b12e10..7eaee74c 100644 --- a/op-modules/op-wms/src/main/resources/bootstrap.yml +++ b/op-modules/op-wms/src/main/resources/bootstrap.yml @@ -14,12 +14,12 @@ spring: nacos: discovery: namespace: lanju-op - group: zxl + group: jgy # 服务注册地址 server-addr: 140.249.53.142:8848 config: namespace: lanju-op - group: zxl + group: jgy #命名空间 #group: local # 配置中心地址 diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomComponentMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomComponentMapper.xml index ed58c6ac..bd4ba419 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomComponentMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomComponentMapper.xml @@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and attr3 = #{attr3} - +