2024-1-12 基础信息-bom数据改结构 第一版

master
A0010407 1 year ago
parent 61996ec9b9
commit f3dbd81cab

@ -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;

@ -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;
}

@ -25,7 +25,9 @@ public interface BaseBomMapper {
* @param baseBom BOM
* @return BOM
*/
public List<BaseBom> selectBaseBomList(BaseBom baseBom);
public List<BaseBom> selectBaseBomList0(BaseBom baseBom);
public List<BaseBom> selectBaseBomList1(BaseBom baseBom);
public List<BaseBom> selectBaseBomList2(BaseBom baseBom);
/**
* BOM
@ -58,4 +60,11 @@ public interface BaseBomMapper {
* @return
*/
public int deleteBaseBomByFactoryCodes(String[] factoryCodes);
//查询层级
String selectLevels();
//查询子节点多少个
Integer selectChildNodes(BaseBom baseBom);
}

@ -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;
/**
* BOMService
@ -26,8 +25,6 @@ public interface IBaseBomService {
* @return BOM
*/
public List<BaseBom> selectBaseBomList(BaseBom baseBom);
//public List<BaseBom> selectBaseBomList(BaseBom baseBom, BaseBomComponent baseBomComponent, List<BaseBomComponent> list);
// public List<BaseBomComponent> selectBaseBomComponentList(BaseBomComponent baseBomComponent);
/**
* BOM

@ -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<BaseBom> selectBaseBomList(BaseBom baseBom) {
return baseBomMapper.selectBaseBomList(baseBom);
//bom表
//主表 第0层
if(baseBom.getBomHierarchy().equals("0")){
List<BaseBom> 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<BaseBom> 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<BaseBom> 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;
}
}
/**

@ -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
</sql>
<select id="selectBaseBomList" parameterType="BaseBom" resultType="com.op.wms.domain.BaseBom">
<select id="selectBaseBomList0" parameterType="BaseBom" resultType="com.op.wms.domain.BaseBom">
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
<where>
<if test="bomCode != null and bomCode != ''"> and bbc.bom_code like concat('%', #{bomCode}, '%')</if>
</where>
GROUP BY bbc.bom_code,bb.bom_bo,b1.product_desc_zh,bbc.product_code
order by bbc.bom_code desc
</select>
<!--第一层-->
<select id="selectBaseBomList1" parameterType="BaseBom" resultType="com.op.wms.domain.BaseBom">
select
bbc.handle as handle,
bb.factory_code as factoryCode,
bb.production_version as productionVersion,
bb.bom_code as bomCode,
@ -72,13 +92,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bbc.loss_rate as lossRate,
bbc.loss_amount as lossAmount,
bbc.cilosses as cilosses
from base_bom bb
left join base_bom_component bbc on bb.bom_code = bbc.bom_code
from base_bom_component bbc
left join base_product b1 on right(b1.product_code,11) = bbc.product_code
left join base_product bp on right(bp.product_code,11) = bbc.component
left join base_bom bb on bbc.bom_code = bb.bom_code
<where>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="bomCode != null and bomCode != ''"> and bb.bom_code like concat('%', #{bomCode}, '%')</if>
<if test="bomCode != null and bomCode != ''"> and bbc.bom_code like concat('%', #{bomCode}, '%')</if>
<if test="bomHierarchy != null and bomHierarchy != ''"> and bbc.bom_hierarchy = #{bomHierarchy}</if>
</where>
</select>
<!--第二层以及以上-->
<select id="selectBaseBomList2" parameterType="BaseBom" resultType="com.op.wms.domain.BaseBom">
select
bbc.handle as handle,
bb.factory_code as factoryCode,
bb.production_version as productionVersion,
bb.bom_code as bomCode,
bb.optional_bom as optionalBom,
bb.optional_bom_text as optionalBomText,
bb.pvvd as pvvd,
bb.pved as pved,
bb.bom_calculate_number as bomCalculateNumber,
bb.bom_calculate_unit as bomCalculateUnit,
bb.bom_base_number as bomBaseNumber,
bb.bom_base_unit as bomBaseUnit,
bb.component_unit as componentUnit,
bb.component_pro_flag as componentProFlag,
bb.msi as msi,
bb.sanka as sanka,
bb.attr1 as attr1,
bb.attr2 as attr2,
bb.attr3 as attr3,
bb.create_by as createBy,
bb.create_time as createTime,
bb.update_by as updateBy,
bb.update_time,
bb.remark as remark,
bb.current_version as currentVersion,
bbc.product_code as productCode,
b1.product_desc_zh as productDescZh,
bp.product_desc_zh as componentDescZh,
bbc.cumc as cumc,
bbc.component as component,
bbc.bom_hierarchy as bomHierarchy,
bbc.project_no as projectNo,
bbc.standard_dosage as standardDosage,
bbc.loss_rate as lossRate,
bbc.loss_amount as lossAmount,
bbc.cilosses as cilosses
from base_bom_component bbc
left join base_product b1 on right(b1.product_code,11) = bbc.product_code
left join base_product bp on right(bp.product_code,11) = bbc.component
left join base_bom bb on bbc.bom_code = bb.bom_code
<where>
<if test="bomCode != null and bomCode != ''"> and bbc.bom_code like concat('%', #{bomCode}, '%')</if>
and bbc.cumc = #{component}
<if test="handle != null and handle != ''"> and bbc.handle = #{handle}</if>
<if test="bomHierarchy != null and bomHierarchy != ''"> and bbc.bom_hierarchy = #{bomHierarchy}</if>
</where>
</select>
@ -183,4 +254,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{factoryCode}
</foreach>
</delete>
<select id="selectLevels" parameterType="String" resultType="String">
select max( bom_hierarchy ) AS levels
from base_bom_component
</select>
<select id="selectChildNodes" parameterType="com.op.wms.domain.BaseBom" resultType="Integer">
select count(*) as number
from base_bom_component
where cumc = #{component}
and bom_code = #{bomCode}
</select>
</mapper>
Loading…
Cancel
Save