线体产品维护

master
zhaoxiaolin 8 months ago
parent 52c9c41a6d
commit cb33c605cf

@ -1,9 +1,15 @@
package com.op.mes.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.ExcelCol;
import com.op.common.core.utils.poi.ExcelMapUtil;
import com.op.mes.domain.MesLineProduct;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
@ -23,6 +29,7 @@ import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 线Controller
@ -120,5 +127,52 @@ public class MesLineController extends BaseController {
List<MesLineProduct> list = mesLineService.getProductListBom(mesLineProduct);
return getDataTable(list);
}
@PostMapping("/importTemplate")
@Log(title = "生成订单模板", businessType = BusinessType.EXPORT)
public void importTemplate(HttpServletResponse response) throws IOException {
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("线体编码", "lineCode", 20));
excelCols.add(new ExcelCol("产品编码", "productCode", 20));
excelCols.add(new ExcelCol("产品名称", "productName", 20));
excelCols.add(new ExcelCol("标准用人", "useMan", 20));
excelCols.add(new ExcelCol("标准效率", "efficiency", 20));
excelCols.add(new ExcelCol("标准工时", "attr1", 20));
String titleName = "线体产品信息导入";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + titleName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(titleName, null, excelCols, null);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
/**
*
*
* @param file
* @return
* @throws Exception
*/
@Log(title = "导入线体产品信息", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file) throws Exception {
// 创建接收对象
ExcelUtil<MesLine> util = new ExcelUtil<>(MesLine.class);
// 接收表格信息
List<MesLine> orderList = util.importExcel(file.getInputStream());
return mesLineService.importOrder(orderList);
}
}

@ -27,11 +27,13 @@ public class MesLine extends BaseEntity {
*/
@Excel(name = "线体编码")
private String lineCode;
@Excel(name = "产品编码")
private String productCode;
@Excel(name = "产品名称")
private String productName;
/**
* 线
*/
@Excel(name = "线体名称")
private String lineName;
/**
@ -49,31 +51,27 @@ public class MesLine extends BaseEntity {
/**
*
*/
@Excel(name = "检验工具")
@Excel(name = "标准工时")
private String attr1;
/**
* $column.columnComment
*/
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String attr2;
/**
* $column.columnComment
*/
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String attr3;
/**
* 1
*/
@Excel(name = "预留字段1")
private String attr4;
/**
*
*/
@Excel(name = "工厂编码")
private String factoryCode;
/**
@ -85,6 +83,22 @@ public class MesLine extends BaseEntity {
private BigDecimal standarXl;//标准效率
private BigDecimal actXl;//实际效率
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;
}
private List<MesLineProduct> productList;
public BigDecimal getStandarMan() {

@ -69,4 +69,10 @@ public interface MesLineMapper {
public MesLine validate(MesLine mesLine);
public List<MesLineProduct> getProductListBom(MesLineProduct mesLineProduct);
MesLine selectInfoByLineProduct(MesLine mesLine);
void insertLineProduct(MesLine mesLine);
void updateLineProduct(MesLine mesLine);
}

@ -2,6 +2,7 @@ package com.op.mes.service;
import java.util.List;
import com.op.common.core.web.domain.AjaxResult;
import com.op.mes.domain.MesLine;
import com.op.mes.domain.MesLineProduct;
@ -68,4 +69,6 @@ public interface IMesLineService {
public MesLine validate(MesLine mesLine);
public List<MesLineProduct> getProductListBom(MesLineProduct productDto);
AjaxResult importOrder(List<MesLine> orderList);
}

@ -1,12 +1,16 @@
package com.op.mes.service.impl;
import java.math.BigDecimal;
import java.util.Date;
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.common.core.utils.ServletUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.MesLineProcess;
import com.op.mes.domain.MesLineProduct;
@ -25,6 +29,9 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success;
/**
* 线Service
*
@ -231,4 +238,98 @@ public class MesLineServiceImpl implements IMesLineService {
public List<MesLineProduct> getProductListBom(MesLineProduct mesLineProduct) {
return mesLineMapper.getProductListBom(mesLineProduct);
}
@Override
@DS("#header.poolName")
@Transactional
public AjaxResult importOrder(List<MesLine> mesLineList) {
for(MesLine mesLineProduct:mesLineList){
String factoryCode = ServletUtils.getRequest().getHeader("PoolName").replace("ds_","");
mesLineProduct.setFactoryCode(factoryCode);
mesLineProduct.setCreateBy(SecurityUtils.getUsername());
mesLineProduct.setCreateTime(DateUtils.getNowDate());
}
// 数据校验
AjaxResult checkResult = checkImportOrder(mesLineList);
// 如果数据校验成功
if (checkResult.isSuccess()) {
String info = syncImportFunc(mesLineList);
return success("信息导入完成。其中导入失败订单:"+info);
}else{
return checkResult;
}
}
/**
*
*
* @param orderList
*/
public AjaxResult checkImportOrder(List<MesLine> orderList) {
// 传入对象不能为空
if (orderList.size() == 0 || StringUtils.isNull(orderList)) {
return error(500, "导入的订单信息不能为空!信息导入失败!");
}
// 循环遍历校验数据是否为空
for (MesLine mesLine : orderList) {
// 订单号
if (mesLine.getLineCode().isEmpty() || mesLine.getLineCode() == null) {
return error(500, "线体不能为空!信息导入失败!");
}
// 物料号
if (mesLine.getProductCode().isEmpty() || mesLine.getProductCode() == null) {
return error(500, "产品编码不能为空!信息导入失败!");
}
// 物料名称
if (mesLine.getProductName().isEmpty() || mesLine.getProductName() == null) {
return error(500, "产品名称不能为空!信息导入失败!");
}
// 订单数量
if (mesLine.getUseMan() == 0 || mesLine.getUseMan() == null) {
return error(500, "标准用人不能为0或空信息导入失败");
}
// 单位
if (mesLine.getEfficiency() == null) {
return error(500, "标准效率不能为空!信息导入失败!");
}
// 订单拆分状态
if (mesLine.getAttr1().isEmpty() || mesLine.getAttr1() == null) {
return error(500, "标准工时不能为空!信息导入失败!");
}
}
return success();
}
public String syncImportFunc(List<MesLine> mesLineList){
String failOrder = "";
for (MesLine mesLine:mesLineList) {
String msg = syncFunc(mesLine);
if(StringUtils.isNotBlank(msg)){
failOrder += msg+",";
}
}
return failOrder;
}
@Transactional(rollbackFor = Exception.class)
public String syncFunc(MesLine mesLine){
String failOrder = "";
//pro_order_workorder
Date nowDate = DateUtils.getNowDate();
MesLine orderExit = mesLineMapper.selectInfoByLineProduct(mesLine);
if (orderExit==null) {//不存在就插入
mesLine.setId(IdUtils.fastSimpleUUID());
mesLine.setCreateTime(nowDate);
mesLineMapper.insertLineProduct(mesLine);
} else {//存在,如果没活动更新,否则不允许更新,关闭订单
mesLine.setId(IdUtils.fastSimpleUUID());
mesLine.setUpdateTime(nowDate);
mesLine.setUpdateBy(SecurityUtils.getUsername());
mesLineMapper.updateLineProduct(mesLine);
}
return failOrder;
}
}

@ -20,47 +20,40 @@
<result property="updateTime" column="update_time"/>
<result property="factoryCode" column="factory_code"/>
<result property="delFlag" column="del_flag"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<collection property="productList" ofType="com.op.mes.domain.MesLineProduct"
select="com.op.mes.mapper.MesLineProductMapper.selectProductByBelongTo" column="id"/>
</resultMap>
<sql id="selectMesLineVo">
select id, line_code, line_name, use_man, efficiency, attr1, attr2, attr3, attr4, create_by,
create_time, update_by, update_time, factory_code, del_flag from mes_line
select id, line_code, product_code,product_name,use_man, efficiency, attr1, attr2, attr3, attr4, create_by,
create_time, update_by, update_time, factory_code, del_flag from mes_line_product
</sql>
<select id="selectMesLineList" parameterType="MesLine" resultMap="MesLineResult">
<include refid="selectMesLineVo"/>
select mlp.id, mlp.line_code, mlp.product_code,mlp.product_name,mlp.use_man, mlp.efficiency, mlp.attr1,
mlp.attr2, mlp.attr3, mlp.attr4, mlp.create_by,
mlp.create_time, mlp.update_by, mlp.update_time, mlp.factory_code, mlp.del_flag,
be.equipment_name line_name
from mes_line_product mlp
left join base_equipment be on be.equipment_code = mlp.line_code
<where>
<if test="lineCode != null and lineCode != ''">
and line_code = #{lineCode}
and mlp.line_code like concat('%', #{lineName}, '%')
</if>
<if test="lineName != null and lineName != ''">
and line_name like concat('%', #{lineName}, '%')
and be.equipment_name like concat('%', #{lineName}, '%')
</if>
<if test="useMan != null ">
and use_man = #{useMan}
<if test="productCode != null and productCode != ''">
and mlp.product_code like concat('%', #{productCode}, '%')
</if>
<if test="efficiency != null ">
and efficiency = #{efficiency}
<if test="productName != null and productName != ''">
and mlp.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>
and del_flag = '0' order by create_time
and mlp.del_flag = '0' order by mlp.line_code
</where>
</select>
<select id="selectMesLineById" parameterType="String"
@ -70,11 +63,11 @@
</select>
<insert id="insertMesLine" parameterType="MesLine">
insert into mes_line
insert into mes_line_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="lineCode != null">line_code,</if>
<if test="lineName != null">line_name,</if>
<if test="useMan != null">use_man,</if>
<if test="efficiency != null">efficiency,</if>
<if test="attr1 != null">attr1,</if>
@ -91,7 +84,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="lineCode != null">#{lineCode},</if>
<if test="lineName != null">#{lineName},</if>
<if test="useMan != null">#{useMan},</if>
<if test="efficiency != null">#{efficiency},</if>
<if test="attr1 != null">#{attr1},</if>
@ -106,12 +99,51 @@
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<insert id="insertLineProduct">
insert into mes_line_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="lineCode != null">line_code,</if>
<if test="productCode != null">product_code,</if>
<if test="productName != null">product_name,</if>
<if test="useMan != null">use_man,</if>
<if test="efficiency != null">efficiency,</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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="lineCode != null">#{lineCode},</if>
<if test="productCode != null">#{productCode},</if>
<if test="productName != null">#{productName},</if>
<if test="useMan != null">#{useMan},</if>
<if test="efficiency != null">#{efficiency},</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>
</trim>
</insert>
<update id="updateMesLine" parameterType="MesLine">
update mes_line
update mes_line_product
<trim prefix="SET" suffixOverrides=",">
<if test="lineCode != null">line_code = #{lineCode},</if>
<if test="lineName != null">line_name = #{lineName},</if>
<if test="useMan != null">use_man = #{useMan},</if>
<if test="efficiency != null">efficiency = #{efficiency},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
@ -127,13 +159,31 @@
</trim>
where id = #{id}
</update>
<update id="updateLineProduct">
update mes_line_product
<trim prefix="SET" suffixOverrides=",">
<if test="useMan != null">use_man = #{useMan},</if>
<if test="efficiency != null">efficiency = #{efficiency},</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>
</trim>
where line_code = #{lineCode} and product_code= #{productCode}
</update>
<delete id="deleteMesLineById" parameterType="String">
update mes_line set del_flag = '1' where id = #{id}
update mes_line_product set del_flag = '1' where id = #{id}
</delete>
<delete id="deleteMesLineByIds" parameterType="String">
update mes_line set del_flag = '1' where id in
update mes_line_product set del_flag = '1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
@ -151,8 +201,8 @@
</if>
</select>
<select id="validate" parameterType="MesLine" resultMap="MesLineResult">
select id, line_code, line_name, use_man, efficiency
from mes_line
select id, line_code, use_man, efficiency
from mes_line_product
where del_flag = '0' and line_code = #{lineCode}
and use_man = #{useMan} and efficiency = #{efficiency}
</select>
@ -166,5 +216,11 @@
'%')
</if>
</select>
<select id="selectInfoByLineProduct" resultType="com.op.mes.domain.MesLine">
select id, line_code,use_man, efficiency
from mes_line_product
where del_flag = '0' and line_code = #{lineCode}
and product_code = #{productCode}
</select>
</mapper>

@ -668,28 +668,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getDailyReportUp" resultType="com.op.mes.domain.vo.MesDailyReportVo">
select be.workshop_code workshopCode,
be.workshop_name workshopName,
pow.product_date productDate,
be.sap_code sapCode,
be.sap_name sapName,
be.equipment_code equipmentCode,
be.equipment_name equipmentName,
be.unit_working_hours unitWorkingHours,
pow.workorder_code_sap workorderCodeSap,
pow.product_code productCode,
pow.product_name productName,
pow.unit unit,
pow.quantity_split quantitySplit,
ml.use_man useMan,
ml.efficiency efficiency,
pow.workorder_code workorderCode,
pow.workorder_name workorderName
be.workshop_name workshopName,
pow.product_date productDate,
be.sap_code sapCode,
be.sap_name sapName,
be.equipment_code equipmentCode,
be.equipment_name equipmentName,
pow.workorder_code_sap workorderCodeSap,
pow.product_code productCode,
pow.product_name productName,
pow.unit unit,
pow.quantity_split quantitySplit,
mlp.use_man useMan,
mlp.efficiency efficiency,
mlp.attr1 unitWorkingHours,
pow.workorder_code workorderCode,
pow.workorder_name workorderName
from base_equipment be
left join pro_order_workorder pow on be.equipment_code = pow.workorder_name
left join mes_line ml on be.equipment_code = ml.line_code
left join mes_line_product mlp on mlp.belong_to = ml.id and pow.product_code = mlp.product_code
left join mes_line_product mlp on pow.workorder_name = mlp.line_code and pow.product_code = mlp.product_code
where be.del_flag = '0' and be.sap_code is not null and pow.status = 'w3' and mlp.del_flag='0'
and pow.parent_order = '0' and pow.del_flag='0' and ml.del_flag='0'
and pow.parent_order = '0' and pow.del_flag='0'
<if test="sapName != null and sapName != ''">and be.sap_name like concat('%', #{sapName}, '%')</if>
<if test="workCenter != null and workCenter != ''">and be.workshop_code = #{workCenter}</if>
<if test="equipmentTypeCode != null and equipmentTypeCode != ''">and be.equipment_type_code = #{equipmentTypeCode}</if>

Loading…
Cancel
Save