线体管理

master
shaoyong 9 months ago
parent a6d9884ce2
commit 6869af8869

@ -1,10 +1,9 @@
package com.op.mes.controller;
import java.util.List;
import java.util.Optional;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.nacos.shaded.com.google.protobuf.Internal;
import com.op.mes.domain.MesLineProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
@ -76,13 +75,14 @@ public class MesLineController extends BaseController {
@Log(title = "线体管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MesLine mesLine) {
MesLine vali = mesLineService.validate(mesLine.getLineCode());
if (ObjectUtils.isEmpty(vali)){
MesLine vali = mesLineService.validate(mesLine);
if (ObjectUtils.isEmpty(vali)) {
return toAjax(mesLineService.insertMesLine(mesLine));
}else {
return error("线体已存在不能重复添加");
return error("此标准已存在,请检查已有标准");
}
}
/**
@ -113,5 +113,12 @@ public class MesLineController extends BaseController {
List<MesLine> list = mesLineService.selectLineBody(mesLine);
return getDataTable(list);
}
@GetMapping("/getProductListBom")
public TableDataInfo getProductListBom(MesLineProduct mesLineProduct) {
startPage();
List<MesLineProduct> list = mesLineService.getProductListBom(mesLineProduct);
return getDataTable(list);
}
}

@ -85,6 +85,8 @@ public class MesLine extends BaseEntity {
private BigDecimal standarXl;//标准效率
private BigDecimal actXl;//实际效率
private List<MesLineProduct> productList;
public BigDecimal getStandarMan() {
return standarMan;
}
@ -225,6 +227,14 @@ public class MesLine extends BaseEntity {
this.qualityList = qualityList;
}
public List<MesLineProduct> getProductList() {
return productList;
}
public void setProductList(List<MesLineProduct> productList) {
this.productList = productList;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,87 @@
package com.op.mes.domain;
import com.op.common.core.web.domain.BaseEntity;
public class MesLineProduct extends BaseEntity {
private static final long serialVersionUID = 1L;
private String id;
private String productCode;
private String productName;
private String belongTo;
private String factoryCode;
private String delFlag;
private String attr1;
private String attr2;
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getBelongTo() {
return belongTo;
}
public void setBelongTo(String belongTo) {
this.belongTo = belongTo;
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getFactoryCode() {
return factoryCode;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
}

@ -3,6 +3,7 @@ package com.op.mes.mapper;
import java.util.List;
import com.op.mes.domain.MesLine;
import com.op.mes.domain.MesLineProduct;
import org.apache.ibatis.annotations.Mapper;
/**
@ -65,5 +66,7 @@ public interface MesLineMapper {
*/
public List<MesLine> selectLineBody(MesLine mesLine);
public MesLine validate(String lineCode);
public MesLine validate(MesLine mesLine);
public List<MesLineProduct> getProductListBom(MesLineProduct mesLineProduct);
}

@ -0,0 +1,71 @@
package com.op.mes.mapper;
import java.util.List;
import com.op.mes.domain.MesLineProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 线Mapper
*
* @author Open Platform
* @date 2024-06-06
*/
@Mapper
public interface MesLineProductMapper {
/**
* 线
*
* @param id 线
* @return 线
*/
public MesLineProduct selectMesLineProductById(String id);
/**
* 线
*
* @param mesLineProduct 线
* @return 线
*/
public List<MesLineProduct> selectMesLineProductList(MesLineProduct mesLineProduct);
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
public int insertMesLineProduct(MesLineProduct mesLineProduct);
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
public int updateMesLineProduct(MesLineProduct mesLineProduct);
/**
* 线
*
* @param id 线
* @return
*/
public int deleteMesLineProductById(String id);
/**
* 线
*
* @param ids
* @return
*/
public int deleteMesLineProductByIds(String[] ids);
public int batchInsertMesLineProduct(@Param("list") List<MesLineProduct> mesLineProductList);
int deleteProductByBelongTo(@Param("belongTo") String belongTo);
List<MesLineProduct> selectProductByBelongTo(@Param("belongTo") String belongTo);
}

@ -0,0 +1,67 @@
package com.op.mes.service;
import java.util.List;
import com.op.mes.domain.MesLineProduct;
/**
* 线Service
*
* @author Open Platform
* @date 2024-06-06
*/
public interface IMesLineProductService {
/**
* 线
*
* @param id 线
* @return 线
*/
public MesLineProduct selectMesLineProductById(String id);
/**
* 线
*
* @param mesLineProduct 线
* @return 线
*/
public List<MesLineProduct> selectMesLineProductList(MesLineProduct mesLineProduct);
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
public int insertMesLineProduct(MesLineProduct mesLineProduct);
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
public int updateMesLineProduct(MesLineProduct mesLineProduct);
/**
* 线
*
* @param ids 线
* @return
*/
public int deleteMesLineProductByIds(String[] ids);
/**
* 线
*
* @param id 线
* @return
*/
public int deleteMesLineProductById(String id);
public int batchInsertMesLineProduct(List<MesLineProduct> mesLineProductList);
public int deleteProductByBelongTo(String belongTo);
List<MesLineProduct> selectProductByBelongTo(String belongTo);
}

@ -3,6 +3,7 @@ package com.op.mes.service;
import java.util.List;
import com.op.mes.domain.MesLine;
import com.op.mes.domain.MesLineProduct;
/**
* 线Service
@ -64,5 +65,7 @@ public interface IMesLineService {
*/
public List<MesLine> selectLineBody(MesLine mesLine);
public MesLine validate(String lineCode);
public MesLine validate(MesLine mesLine);
public List<MesLineProduct> getProductListBom(MesLineProduct productDto);
}

@ -0,0 +1,109 @@
package com.op.mes.service.impl;
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;
import com.op.mes.mapper.MesLineProductMapper;
import com.op.mes.domain.MesLineProduct;
import com.op.mes.service.IMesLineProductService;
/**
* 线Service
*
* @author Open Platform
* @date 2024-06-06
*/
@Service
public class MesLineProductServiceImpl implements IMesLineProductService {
@Autowired
private MesLineProductMapper mesLineProductMapper;
/**
* 线
*
* @param id 线
* @return 线
*/
@Override
public MesLineProduct selectMesLineProductById(String id) {
return mesLineProductMapper.selectMesLineProductById(id);
}
/**
* 线
*
* @param mesLineProduct 线
* @return 线
*/
@Override
public List<MesLineProduct> selectMesLineProductList(MesLineProduct mesLineProduct) {
return mesLineProductMapper.selectMesLineProductList(mesLineProduct);
}
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
@Override
public int insertMesLineProduct(MesLineProduct mesLineProduct) {
mesLineProduct.setCreateTime(DateUtils.getNowDate());
return mesLineProductMapper.insertMesLineProduct(mesLineProduct);
}
/**
* 线
*
* @param mesLineProduct 线
* @return
*/
@Override
public int updateMesLineProduct(MesLineProduct mesLineProduct) {
mesLineProduct.setUpdateTime(DateUtils.getNowDate());
return mesLineProductMapper.updateMesLineProduct(mesLineProduct);
}
/**
* 线
*
* @param ids 线
* @return
*/
@Override
public int deleteMesLineProductByIds(String[] ids) {
return mesLineProductMapper.deleteMesLineProductByIds(ids);
}
/**
* 线
*
* @param id 线
* @return
*/
@Override
public int deleteMesLineProductById(String id) {
return mesLineProductMapper.deleteMesLineProductById(id);
}
@Override
@DS("#header.poolName")
public int batchInsertMesLineProduct(List<MesLineProduct> mesLineProductList) {
return mesLineProductMapper.batchInsertMesLineProduct(mesLineProductList);
}
@Override
@DS("#header.poolName")
public int deleteProductByBelongTo(String belongTo) {
return mesLineProductMapper.deleteProductByBelongTo(belongTo);
}
@Override
@DS("#header.poolName")
public List<MesLineProduct> selectProductByBelongTo(String belongTo) {
return mesLineProductMapper.selectProductByBelongTo(belongTo);
}
}

@ -9,7 +9,9 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.MesLineProcess;
import com.op.mes.domain.MesLineProduct;
import com.op.mes.service.IMesLineProcessService;
import com.op.mes.service.IMesLineProductService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -36,6 +38,8 @@ public class MesLineServiceImpl implements IMesLineService {
@Autowired
private IMesLineProcessService mesLineProcessService;
@Autowired
private IMesLineProductService mesLineProductService;
/**
* 线
@ -52,10 +56,17 @@ public class MesLineServiceImpl implements IMesLineService {
List<BigDecimal> qualityList = mesList.stream().map(MesLineProcess::getQuality).collect(Collectors.toList());
MesLine mesLine = mesLineMapper.selectMesLineById(id);
//设置线体数据
if (!CollectionUtils.isEmpty(processList)) {
if (CollectionUtils.isNotEmpty(processList)) {
mesLine.setProcessList(processList);
mesLine.setQualityList(qualityList);
}
// 绑定线体产品
List<MesLineProduct> productList = mesLineProductService.selectProductByBelongTo(id);
if (CollectionUtils.isNotEmpty(productList)) {
mesLine.setProductList(productList);
}
return mesLine;
}
@ -79,15 +90,48 @@ public class MesLineServiceImpl implements IMesLineService {
*/
@Override
@DS("#header.poolName")
@Transactional(propagation = Propagation.REQUIRED)
public int insertMesLine(MesLine mesLine) {
mesLine.setCreateTime(DateUtils.getNowDate());
mesLine.setCreateBy(SecurityUtils.getUsername());
mesLine.setId(IdUtils.fastSimpleUUID());
String belongTo = mesLine.getId();
// 获取工厂编码
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
mesLine.setFactoryCode(factoryCode);
// 绑定工艺
List<String> processList = mesLine.getProcessList();
List<BigDecimal> qualityList = mesLine.getQualityList();
if (!CollectionUtils.isEmpty(processList)) {
String lineCode = mesLine.getLineCode();
String lineName = mesLine.getLineName();
for (int i = 0; i < processList.size(); i++) {
MesLineProcess mesLineProcess = new MesLineProcess();
mesLineProcess.setBelongTo(belongTo);
mesLineProcess.setProcessName(processList.get(i));
mesLineProcess.setQuality(qualityList.get(i));
mesLineProcess.setLineCode(lineCode);
mesLineProcess.setLineName(lineName);
mesLineProcess.setFactoryCode(factoryCode);
mesLineProcessService.insertMesLineProcess(mesLineProcess);
}
}
// 绑定产品
List<MesLineProduct> productList = mesLine.getProductList();
if (CollectionUtils.isNotEmpty(productList)) {
for (MesLineProduct item : productList) {
item.setId(IdUtils.fastSimpleUUID());
item.setBelongTo(belongTo);
item.setFactoryCode(factoryCode);
item.setCreateBy(SecurityUtils.getUsername());
item.setCreateTime(DateUtils.getNowDate());
}
mesLineProductService.batchInsertMesLineProduct(productList);
}
return mesLineMapper.insertMesLine(mesLine);
}
@ -103,20 +147,20 @@ public class MesLineServiceImpl implements IMesLineService {
public int updateMesLine(MesLine mesLine) {
mesLine.setUpdateTime(DateUtils.getNowDate());
mesLine.setUpdateBy(SecurityUtils.getUsername());
String belongTo = mesLine.getId();
// 获取工厂编码
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
// 绑定工艺
List<String> processList = mesLine.getProcessList();
List<BigDecimal> qualityList = mesLine.getQualityList();
mesLineProcessService.deleteMesLineProcessByBelongTo(belongTo);
if (!CollectionUtils.isEmpty(processList)) {
//删除旧的工艺项
mesLineProcessService.deleteMesLineProcessByBelongTo(mesLine.getId());
String belongTo = mesLine.getId();
String lineCode = mesLine.getLineCode();
String lineName = mesLine.getLineName();
// 获取工厂编码
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String factoryCode = request.getHeader(key.substring(8)).replace("ds_", "");
for (int i = 0; i < processList.size(); i++) {
MesLineProcess mesLineProcess = new MesLineProcess();
mesLineProcess.setBelongTo(belongTo);
@ -128,6 +172,20 @@ public class MesLineServiceImpl implements IMesLineService {
mesLineProcessService.insertMesLineProcess(mesLineProcess);
}
}
// 绑定产品
List<MesLineProduct> productList = mesLine.getProductList();
mesLineProductService.deleteProductByBelongTo(belongTo);
if (CollectionUtils.isNotEmpty(productList)) {
for (MesLineProduct item : productList) {
item.setId(IdUtils.fastSimpleUUID());
item.setBelongTo(belongTo);
item.setFactoryCode(factoryCode);
item.setCreateBy(SecurityUtils.getUsername());
item.setCreateTime(DateUtils.getNowDate());
}
mesLineProductService.batchInsertMesLineProduct(productList);
}
return mesLineMapper.updateMesLine(mesLine);
@ -164,7 +222,13 @@ public class MesLineServiceImpl implements IMesLineService {
@Override
@DS("#header.poolName")
public MesLine validate(String lineCode) {
return mesLineMapper.validate(lineCode);
public MesLine validate(MesLine mesLine) {
return mesLineMapper.validate(mesLine);
}
@Override
@DS("#header.poolName")
public List<MesLineProduct> getProductListBom(MesLineProduct mesLineProduct) {
return mesLineMapper.getProductListBom(mesLineProduct);
}
}

@ -140,7 +140,7 @@
select equipment_code line_code,
equipment_name line_name
from base_equipment
where del_flag = '0'
where del_flag = '0' and equipment_type_code = 'equ_type_bzx'
<if test="lineCode != null and lineCode != ''">
and equipment_code = #{lineCode}
</if>
@ -151,6 +151,18 @@
<select id="validate" parameterType="MesLine" resultMap="MesLineResult">
select id, line_code, line_name, use_man, efficiency
from mes_line
where line_code = #{lineCode} and del_flag = '0'
where del_flag = '0' and line_code = #{lineCode}
and use_man = #{useMan} and efficiency = #{efficiency}
</select>
<select id="getProductListBom" resultType="com.op.mes.domain.MesLineProduct">
select product_code productCode,product_desc_zh productName
from base_product
where del_flag = '0'
<if test="productCode != null and productCode != ''">and product_code like concat('%', #{productCode}, '%')</if>
<if test="productName != null and productName != ''">and product_desc_zh like concat('%', #{productName},
'%')
</if>
</select>
</mapper>

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.mes.mapper.MesLineProductMapper">
<resultMap type="MesLineProduct" id="MesLineProductResult">
<result property="id" column="id"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="attr4" column="attr4"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="factoryCode" column="factory_code"/>
<result property="delFlag" column="del_flag"/>
<result property="belongTo" column="belong_to"/>
</resultMap>
<sql id="selectMesLineProductVo">
select id,
product_code,
product_name,
attr1,
attr2,
attr3,
attr4,
create_by,
create_time,
update_by,
update_time,
factory_code,
del_flag,
belong_to
from mes_line_product
</sql>
<select id="selectMesLineProductList" parameterType="MesLineProduct" resultMap="MesLineProductResult">
<include refid="selectMesLineProductVo"/>
<where>
<if test="productCode != null and productCode != ''">
and product_code = #{productCode}
</if>
<if test="productName != null and productName != ''">
and product_name like concat('%', #{productName}, '%')
</if>
<if test="attr1 != null and attr1 != ''">
and attr1 = #{attr1}
</if>
<if test="attr2 != null and attr2 != ''">
and attr2 = #{attr2}
</if>
<if test="attr3 != null and attr3 != ''">
and attr3 = #{attr3}
</if>
<if test="attr4 != null and attr4 != ''">
and attr4 = #{attr4}
</if>
<if test="factoryCode != null and factoryCode != ''">
and factory_code = #{factoryCode}
</if>
<if test="belongTo != null and belongTo != ''">
and belong_to = #{belongTo}
</if>
</where>
</select>
<select id="selectMesLineProductById" parameterType="String"
resultMap="MesLineProductResult">
<include refid="selectMesLineProductVo"/>
where id = #{id}
</select>
<insert id="insertMesLineProduct" parameterType="MesLineProduct">
insert into mes_line_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,
</if>
<if test="productCode != null">product_code,
</if>
<if test="productName != null">product_name,
</if>
<if test="attr1 != null">attr1,
</if>
<if test="attr2 != null">attr2,
</if>
<if test="attr3 != null">attr3,
</if>
<if test="attr4 != null">attr4,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="factoryCode != null">factory_code,
</if>
<if test="delFlag != null">del_flag,
</if>
<if test="belongTo != null">belong_to,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},
</if>
<if test="productCode != null">#{productCode},
</if>
<if test="productName != null">#{productName},
</if>
<if test="attr1 != null">#{attr1},
</if>
<if test="attr2 != null">#{attr2},
</if>
<if test="attr3 != null">#{attr3},
</if>
<if test="attr4 != null">#{attr4},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="factoryCode != null">#{factoryCode},
</if>
<if test="delFlag != null">#{delFlag},
</if>
<if test="belongTo != null">#{belongTo},
</if>
</trim>
</insert>
<update id="updateMesLineProduct" parameterType="MesLineProduct">
update mes_line_product
<trim prefix="SET" suffixOverrides=",">
<if test="productCode != null">product_code =
#{productCode},
</if>
<if test="productName != null">product_name =
#{productName},
</if>
<if test="attr1 != null">attr1 =
#{attr1},
</if>
<if test="attr2 != null">attr2 =
#{attr2},
</if>
<if test="attr3 != null">attr3 =
#{attr3},
</if>
<if test="attr4 != null">attr4 =
#{attr4},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="factoryCode != null">factory_code =
#{factoryCode},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</if>
<if test="belongTo != null">belong_to =
#{belongTo},
</if>
</trim>
where id = #{id}
</update>
<insert id="batchInsertMesLineProduct" parameterType="java.util.List">
INSERT INTO mes_line_product (
id,
product_code,
product_name,
attr1,
create_by,
create_time,
update_by,
update_time,
factory_code,
belong_to
)
VALUES
<foreach collection="list" item="element" separator=",">
(
#{element.id},
#{element.productCode},
#{element.productName},
#{element.attr1},
#{element.createBy},
#{element.createTime},
#{element.updateBy},
#{element.updateTime},
#{element.factoryCode},
#{element.belongTo}
)
</foreach>
</insert>
<delete id="deleteMesLineProductById" parameterType="String">
delete
from mes_line_product
where id = #{id}
</delete>
<delete id="deleteMesLineProductByIds" parameterType="String">
delete from mes_line_product where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteProductByBelongTo" parameterType="String">
delete from mes_line_product where belong_to = #{belongTo}
</delete>
<select id="selectProductByBelongTo" parameterType="String"
resultMap="MesLineProductResult">
<include refid="selectMesLineProductVo"/>
where belong_to = #{belongTo} order by create_time ASC
</select>
</mapper>
Loading…
Cancel
Save