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 97c24e0d..9a3c25e6 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 @@ -3,7 +3,6 @@ package com.op.wms.controller; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; -import com.op.wms.domain.BaseBomComponent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; diff --git a/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseBom.java b/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseBom.java index 747eda37..0293572c 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseBom.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/domain/BaseBom.java @@ -139,6 +139,40 @@ public class BaseBom extends BaseEntity { @Excel(name = "含损耗用量") private Long cilosses; + //虚拟字段 + private Boolean hasChildren; + private String handle; + private String bomBo; + private Integer number; + + public void setNumber(Integer number) { + this.number = number; + } + public Integer getNumber() { + return number; + } + + public void setBomBo(String bomBo) { + this.bomBo = bomBo; + } + public String getBomBo() { + return bomBo; + } + + public void setHasChildren(Boolean hasChildren) { + this.hasChildren = hasChildren; + } + public Boolean getHasChildren() { + return hasChildren; + } + + public void setHandle(String handle) { + this.handle = handle; + } + public String getHandle() { + return handle; + } + public void setFactoryCode(String factoryCode) { this.factoryCode = factoryCode; } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomMapper.java index 20ef3b5e..49bdd034 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomMapper.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/BaseBomMapper.java @@ -25,7 +25,9 @@ public interface BaseBomMapper { * @param baseBom BOM物料管理 * @return BOM物料管理集合 */ - public List selectBaseBomList(BaseBom baseBom); + public List selectBaseBomList0(BaseBom baseBom); + public List selectBaseBomList1(BaseBom baseBom); + public List selectBaseBomList2(BaseBom baseBom); /** * 新增BOM物料管理 @@ -58,4 +60,11 @@ public interface BaseBomMapper { * @return 结果 */ public int deleteBaseBomByFactoryCodes(String[] factoryCodes); + + //查询层级 + String selectLevels(); + + //查询子节点多少个 + Integer selectChildNodes(BaseBom baseBom); + } 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 b0134bab..adb0c4ac 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 @@ -2,7 +2,6 @@ package com.op.wms.service; import java.util.List; import com.op.wms.domain.BaseBom; -import com.op.wms.domain.BaseBomComponent; /** * BOM物料管理Service接口 @@ -26,8 +25,6 @@ public interface IBaseBomService { * @return BOM物料管理集合 */ public List selectBaseBomList(BaseBom baseBom); - //public List selectBaseBomList(BaseBom baseBom, BaseBomComponent baseBomComponent, List list); -// public List selectBaseBomComponentList(BaseBomComponent baseBomComponent); /** * 新增BOM物料管理 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 9c7ae615..671f5078 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 @@ -1,13 +1,9 @@ package com.op.wms.service.impl; - -import java.util.ArrayList; -import java.util.Comparator; import java.util.List; -import java.util.stream.Collectors; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.utils.DateUtils; -import com.op.wms.domain.BaseBomComponent; +import com.op.common.core.utils.uuid.IdUtils; import com.op.wms.mapper.BaseBomComponentMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -49,7 +45,49 @@ public class BaseBomServiceImpl implements IBaseBomService { @Override @DS("#header.poolName") public List selectBaseBomList(BaseBom baseBom) { - return baseBomMapper.selectBaseBomList(baseBom); + //bom表 + //主表 第0层 + if(baseBom.getBomHierarchy().equals("0")){ + List list = baseBomMapper.selectBaseBomList0(baseBom); + //判断 是否有HasChildren + for(BaseBom baseBom1 : list){ + if(baseBom1.getNumber() > 1){ + baseBom1.setHasChildren(Boolean.TRUE); + }else{ + baseBom1.setHasChildren(Boolean.FALSE); + } + } + return list; + }else if(baseBom.getBomHierarchy().equals("1")){ + List list = baseBomMapper.selectBaseBomList1(baseBom); + for(BaseBom baseBom1 : list){ + if(baseBom1.getHandle() == null){ + baseBom1.setHandle(IdUtils.fastSimpleUUID()); + } + Integer childNodes = baseBomMapper.selectChildNodes(baseBom1); + if(childNodes > 0){ + baseBom1.setHasChildren(Boolean.TRUE); + }else{ + baseBom1.setHasChildren(Boolean.FALSE); + } + } + return list; + }else{ + //2层以及以上 多条list + List list = baseBomMapper.selectBaseBomList2(baseBom); + for(BaseBom baseBom1 : list){ + if(baseBom1.getHandle() == null){ + baseBom1.setHandle(IdUtils.fastSimpleUUID()); + } + Integer childNodes = baseBomMapper.selectChildNodes(baseBom1); + if(childNodes > 0){ + baseBom1.setHasChildren(Boolean.TRUE); + }else{ + baseBom1.setHasChildren(Boolean.FALSE); + } + } + return list; + } } /** diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomMapper.xml index 74595933..acb44733 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/BaseBomMapper.xml @@ -35,8 +35,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select factory_code, production_version, bom_code, optional_bom, optional_bom_text, pvvd, pved, bom_calculate_number, bom_calculate_unit, bom_base_number, bom_base_unit, component_unit, component_pro_flag, msi, sanka, attr1, attr2, attr3, create_by, create_time, update_by, update_time, remark, current_version from base_bom - select + count(bb.bom_bo) AS number, + bbc.bom_code as bomCode, + bb.bom_bo as handle, + b1.product_desc_zh as productDescZh, + bbc.product_code as productCode + from base_bom_component bbc + left join base_product b1 on right(b1.product_code,11) = bbc.product_code + left join base_bom bb on bb.bom_code = bbc.bom_code + left join base_product bp on right(bp.product_code,11) = bbc.component + + and bbc.bom_code like concat('%', #{bomCode}, '%') + + GROUP BY bbc.bom_code,bb.bom_bo,b1.product_desc_zh,bbc.product_code + order by bbc.bom_code desc + + + + + + + @@ -183,4 +254,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{factoryCode} + + + + + \ No newline at end of file