基础信息BOM

highway
A0010407 1 year ago
parent 297748addc
commit 3c337dbf43

@ -1,7 +1,9 @@
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;
@ -40,8 +42,10 @@ public class BaseBomController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(BaseBom baseBom) {
startPage();
List<BaseBom> list = baseBomService.selectBaseBomList(baseBom);
return getDataTable(list);
BaseBomComponent baseBomComponent = new BaseBomComponent();
List<BaseBomComponent> list = new ArrayList<>();
List<BaseBomComponent> baseBoms = baseBomService.selectBaseBomComponentList(baseBomComponent);
return getDataTable(baseBoms);
}
/**

@ -1,6 +1,8 @@
package com.op.wms.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -17,7 +19,7 @@ public class BaseBomComponent extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
private String handle;
/** BOM单号 */
@Excel(name = "BOM单号")
@ -56,9 +58,8 @@ public class BaseBomComponent extends BaseEntity {
private Long lossRate;
/** 损耗额 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "损耗额", width = 30, dateFormat = "yyyy-MM-dd")
private Date lossAmount;
@Excel(name = "损耗额")
private Long lossAmount;
/** 含损耗用量 */
@Excel(name = "含损耗用量")
@ -92,12 +93,22 @@ public class BaseBomComponent extends BaseEntity {
@Excel(name = "预留字段3")
private String attr3;
public void setId(Long id) {
this.id = id;
private List<BaseBomComponent> children;
public List<BaseBomComponent> getChildren() {
return children;
}
public void setChildren(List<BaseBomComponent> children) {
this.children = children;
}
public void setHandle(String handle) {
this.handle = handle;
}
public Long getId() {
return id;
public String getHandle() {
return handle;
}
public void setBomCode(String bomCode) {
this.bomCode = bomCode;
@ -162,11 +173,11 @@ public class BaseBomComponent extends BaseEntity {
public Long getLossRate() {
return lossRate;
}
public void setLossAmount(Date lossAmount) {
public void setLossAmount(Long lossAmount) {
this.lossAmount = lossAmount;
}
public Date getLossAmount() {
public Long getLossAmount() {
return lossAmount;
}
public void setCilosses(Long cilosses) {
@ -229,7 +240,7 @@ public class BaseBomComponent extends BaseEntity {
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("handle", getHandle())
.append("bomCode", getBomCode())
.append("site", getSite())
.append("productCode", getProductCode())

@ -58,4 +58,9 @@ public interface BaseBomComponentMapper {
* @return
*/
public int deleteBaseBomComponentByIds(Long[] ids);
//查询Bom表中的BomCodeList
List<String> selectBomCodeList(BaseBomComponent baseBomComponent);
//查询BaseBomComponent表中的product_code
List<String> selectProductCodeList(BaseBomComponent baseBomComponent);
}

@ -2,6 +2,7 @@ package com.op.wms.service;
import java.util.List;
import com.op.wms.domain.BaseBom;
import com.op.wms.domain.BaseBomComponent;
/**
* BOMService
@ -25,6 +26,8 @@ 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,9 +1,14 @@
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.wms.mapper.BaseBomComponentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.wms.mapper.BaseBomMapper;
@ -20,6 +25,8 @@ import com.op.wms.service.IBaseBomService;
public class BaseBomServiceImpl implements IBaseBomService {
@Autowired
private BaseBomMapper baseBomMapper;
@Autowired
private BaseBomComponentMapper baseBomComponentMapper;
/**
* BOM
@ -94,4 +101,91 @@ public class BaseBomServiceImpl implements IBaseBomService {
public int deleteBaseBomByFactoryCode(String factoryCode) {
return baseBomMapper.deleteBaseBomByFactoryCode(factoryCode);
}
// @Override
// public List<BaseBomComponent> findByTree(BaseBomComponent baseBomComponent) {
// //父 Cumc 子Component
// //查询出所有物料BOM数据
// List<BaseBomComponent> bomList = baseBomComponentMapper.selectBaseBomComponentList(baseBomComponent);
// List<BaseBomComponent> conversionList = bomList.stream().map((baseBomComponent1) -> {
// BaseBomComponent vo = new BaseBomComponent();
// vo.setComponent(baseBomComponent1.getComponent());//子表
// vo.setHandle(baseBomComponent1.getHandle());//主键
// vo.setCumc(baseBomComponent1.getCumc());//父表
// return vo;
// }).collect(Collectors.toList());
// //使用filter去进行拦截进行判断
// List<BaseBomComponent> baseBomComponentVos = conversionList.stream().filter(baseBomComponentVo -> 0 == BaseBomComponent.getCumc())
// .peek(organizationVo -> organizationVo.setChildren(createChildList(organizationVo, conversionList)))
// .sorted(Comparator.comparing(BaseBomComponent::getComponent))
// .collect(Collectors.toList());
////
//// return organizationVos;
// return conversionList;
// }
/**
* @param organizationVo
* @param organizationVoList list
* @return
*/
// private static List<BaseBomComponent> createChildList(BaseBomComponent organizationVo, List<BaseBomComponent> organizationVoList) {
// return organizationVoList.stream().filter(model -> organizationVo.getHandle().equals(model.getCumc()))
// .peek(model -> model.setChildren(createChildList(model, organizationVoList)))
// .sorted((Comparator.comparing(BaseBomComponent::getComponent))).collect(Collectors.toList());
// }
// public List<BaseBomComponent> findByTree(BaseBomComponent baseBomComponent) {
// List<BaseBomComponent> node = findByTree(treeList);
// System.out.println(node);
// return node;
// }
/**
*
* @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) {
// 调用递归方法填充子节点列表
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;
}
}

@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.op.wms.mapper.BaseBomComponentMapper">
<resultMap type="BaseBomComponent" id="BaseBomComponentResult">
<result property="id" column="id" />
<result property="handle" column="handle" />
<result property="bomCode" column="bom_code" />
<result property="site" column="site" />
<result property="productCode" column="product_code" />
@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBaseBomComponentVo">
select id, bom_code, site, product_code, cumc, component, bom_hierarchy, project_no, standard_dosage, loss_rate, loss_amount, cilosses, component_unit, component_pro_flag, msi, sanka, attr1, attr2, attr3, create_by, create_time, update_by, update_time, remark from base_bom_component
select handle, bom_code, site, product_code, cumc, component, bom_hierarchy, project_no, standard_dosage, loss_rate, loss_amount, cilosses, component_unit, component_pro_flag, msi, sanka, attr1, attr2, attr3, create_by, create_time, update_by, update_time, remark from base_bom_component
</sql>
<select id="selectBaseBomComponentList" parameterType="BaseBomComponent" resultMap="BaseBomComponentResult">
@ -61,13 +61,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBaseBomComponentById" parameterType="Long" resultMap="BaseBomComponentResult">
<include refid="selectBaseBomComponentVo"/>
where id = #{id}
where handle = #{handle}
</select>
<insert id="insertBaseBomComponent" parameterType="BaseBomComponent">
insert into base_bom_component
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="handle != null">handle,</if>
<if test="bomCode != null and bomCode != ''">bom_code,</if>
<if test="site != null">site,</if>
<if test="productCode != null">product_code,</if>
@ -93,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="handle != null">#{handle},</if>
<if test="bomCode != null and bomCode != ''">#{bomCode},</if>
<if test="site != null">#{site},</if>
<if test="productCode != null">#{productCode},</if>
@ -157,7 +157,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteBaseBomComponentByIds" parameterType="String">
delete from base_bom_component where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
#{handle}
</foreach>
</delete>
<select id="selectBomCodeList" parameterType="BaseBomComponent" resultType="java.lang.String">
select bom_code
from base_bom
</select>
<select id="selectProductCodeList" parameterType="BaseBomComponent" resultType="java.lang.String">
select product_code
from base_bom_component
order by product_code
</select>
</mapper>
Loading…
Cancel
Save