2024-08-29 MES-自检互检报表+首件报表

master
A0010407 6 months ago
parent 0e249df6f3
commit 84a774f61e

@ -0,0 +1,51 @@
package com.op.mes.controller;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.mes.domain.MesInspectionReport;
import com.op.mes.service.IMesInspectionReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/inspectionReport")
public class MesInspectionReportController extends BaseController {
@Autowired
private IMesInspectionReportService iMesInspectionReportService;
//自检互检记录 报表 主体 查询
@GetMapping("/selfMutualInspectionList")
public List<MesInspectionReport> selfMutualInspectionList(MesInspectionReport mesInspectionReport) {
return iMesInspectionReportService.selectSelfMutualInspectionList(mesInspectionReport);
}
//自检互检记录报表 产品名称 检查人 生产产线 检查日期 异常处理 备注
@GetMapping("/selfMutualInspectionData")
public MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport) {
return iMesInspectionReportService.selfMutualInspectionData(mesInspectionReport);
}
//查询产线
@GetMapping("/getLineCodeList")
public List<MesInspectionReport> getLineCodeList() {
List<MesInspectionReport> list = iMesInspectionReportService.getLineCodeList();
return list;
}
//首检记录 左侧报表 主体 查询
@GetMapping("/listFirstInspectionLeft")
public List<MesInspectionReport> firstInspectionLeftList(MesInspectionReport mesInspectionReport) {
return iMesInspectionReportService.selectFirstInspectionLeftList(mesInspectionReport);
}
//首检记录 右侧报表 主体 查询
@GetMapping("/listFirstInspectionRight")
public List<MesInspectionReport> firstInspectionRightList(MesInspectionReport mesInspectionReport) {
return iMesInspectionReportService.selectFirstInspectionRightList(mesInspectionReport);
}
}

@ -0,0 +1,135 @@
package com.op.mes.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import java.util.HashMap;
import java.util.Map;
//MES自检互检
public class MesInspectionReport extends BaseEntity {
private static final long serialVersionUID = 1L;
//子表
private String id;
@Excel(name = "主表id")
private String belongTo;
@Excel(name = "异常处理")
private String bz;
@Excel(name = "删除标志")
private String delFlag;
@Excel(name = "检查开始时间")
private String checkTimeS;
@Excel(name = "检查结束时间")
private String checkTimeE;
@Excel(name = "检验结果")
private String checkResult;
@Excel(name = "检验内容编码")
private String infoCode;
@Excel(name = "检验内容名称")
private String infoName;
@Excel(name = "同一列的一致")
private Integer tableLine;
//主表
@Excel(name = "产线编码")
private String lineCode;
@Excel(name = "生产日期")
private String productDate;
@Excel(name = "检查日期")
private String checkDate;
@Excel(name = "产品编码")
private String productCode;
@Excel(name = "产品名称")
private String productName;
@Excel(name = "报表名称")
private String reportName;
//虚拟字段
private String timeArray;
//设备编码
private String equipmentCode;
//设备名称
private String equipmentName;
//动态增加字段
// private Map<String,String> dynamicTime;
//
// public void setDynamicTime(String dynamicTimeName, String value) { dynamicTime.put(dynamicTimeName,value); }
// public String getDynamicTime(String dynamicTimeName) { return dynamicTime.get(dynamicTimeName); }
public void setId(String id) { this.id = id; }
public String getId() { return id; }
public void setBelongTo(String belongTo) { this.belongTo = belongTo; }
public String getBelongTo() { return belongTo; }
public void setBz(String bz) { this.bz = bz; }
public String getBz() { return bz; }
public String getDelFlag() { return delFlag; }
public void setDelFlag(String delFlag) { this.delFlag = delFlag; }
public void setCheckTimeS(String checkTimeS) { this.checkTimeS = checkTimeS; }
public String getCheckTimeS() { return checkTimeS; }
public void setCheckTimeE(String checkTimeE) { this.checkTimeE = checkTimeE; }
public String getCheckTimeE() { return checkTimeE; }
public void setCheckResult(String checkResult) { this.checkResult = checkResult; }
public String getCheckResult() { return checkResult; }
public void setInfoCode(String infoCode) { this.infoCode = infoCode; }
public String getInfoCode() { return infoCode; }
public void setInfoName(String infoName) { this.infoName = infoName; }
public String getInfoName() { return infoName; }
public void setTableLine(Integer tableLine) { this.tableLine = tableLine; }
public Integer getTableLine() { return tableLine; }
public void setLineCode(String lineCode) { this.lineCode = lineCode; }
public String getLineCode() { return lineCode; }
public void setProductDate(String productDate) { this.productDate = productDate; }
public String getProductDate() { return productDate; }
public void setCheckDate(String checkDate) { this.checkDate = checkDate; }
public String getCheckDate() { return checkDate; }
public void setProductCode(String productCode) { this.productCode = productCode; }
public String getProductCode() { return productCode; }
public void setProductName(String productName) { this.productName = productName; }
public String getProductName() { return productName; }
public void setReportName(String reportName) { this.reportName = reportName; }
public String getReportName() { return reportName; }
public void setTimeArray(String timeArray) { this.timeArray = timeArray; }
public String getTimeArray() { return timeArray; }
public void setEquipmentCode(String equipmentCode) { this.equipmentCode = equipmentCode; }
public String getEquipmentCode() { return equipmentCode; }
public void setEquipmentName(String equipmentName) { this.equipmentName = equipmentName; }
public String getEquipmentName() { return equipmentName; }
}

@ -0,0 +1,14 @@
package com.op.mes.mapper;
import com.op.common.core.web.domain.AjaxResult;
import com.op.mes.domain.MesInspectionReport;
import java.util.List;
public interface MesInspectionReportMapper {
List<MesInspectionReport> selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport);//查询自检互检列表
List<String> selectProjectName(String param);//自检互检左侧项目
List<String> selectTimeArray(MesInspectionReport mesInspectionReport);//查询所有时间
MesInspectionReport selectSelfMutualInspectionData(MesInspectionReport mesInspectionReport);
List<MesInspectionReport> getLineCodeList();
}

@ -0,0 +1,18 @@
package com.op.mes.service;
import com.op.common.core.web.domain.AjaxResult;
import com.op.mes.domain.MesInspectionReport;
import java.util.List;
public interface IMesInspectionReportService {
List<MesInspectionReport> selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport);
MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport);
List<MesInspectionReport> getLineCodeList();
List<MesInspectionReport> selectFirstInspectionRightList(MesInspectionReport mesInspectionReport);//首检右报表
List<MesInspectionReport> selectFirstInspectionLeftList(MesInspectionReport mesInspectionReport);//首检左报表
}

@ -0,0 +1,235 @@
package com.op.mes.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.baomidou.dynamic.datasource.annotation.DS;
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.mes.domain.MesInspectionReport;
import com.op.mes.mapper.MesInspectionReportMapper;
import com.op.mes.service.IMesInspectionReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import sun.reflect.misc.ReflectUtil;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MesInspectionReportServiceImpl implements IMesInspectionReportService {
private static final Logger log = LoggerFactory.getLogger(MesInspectionReportServiceImpl.class);
@Autowired
private MesInspectionReportMapper mesInspectionReportMapper;
@Override
@DS("#header.poolName")
public List selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport) {
mesInspectionReport.setReportName("ConversionReport");
List<MesInspectionReport> list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport);
//1.查询左侧边 列 存入
String param = "self_mutual_inspection";
List<String> projectNames = mesInspectionReportMapper.selectProjectName(param);
List<String> timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport);
List<Object> listDTO = new ArrayList<>();
for(String projectName : projectNames){
Map<String,String> dynamicTime = new LinkedHashMap<>();
dynamicTime.put("开始-结束",projectName);
if(CollectionUtils.isEmpty(timeArray)){
dynamicTime.put("", "");
dynamicTime.put(" ", "");
dynamicTime.put(" ", "");
}else{
for(String time : timeArray){
List<MesInspectionReport> result = list.stream()
.filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1符合开始时间结束时间
.filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2符合当前项目名
.collect(Collectors.toList()); // 收集结果
if(!CollectionUtils.isEmpty(result)){
if(StringUtils.isNotBlank(result.get(0).getCheckResult())){
dynamicTime.put(time, result.get(0).getCheckResult());
}else{
dynamicTime.put(time, "");
}
}else{
dynamicTime.put(time, "");
}
}
}
String string1 = "";
String string2 = " ";
String string3 = " ";
if(timeArray.size() < 3){
for(int i = 0 ; i < 3-(timeArray.size()) ; i++){
if(i == 0){
dynamicTime.put(string1, "");
}else if(i == 1){
dynamicTime.put(string2, "");
}
}
}
String s = JSON.toJSONString(dynamicTime);
// Object object = JSON.parseObject(s, Object.class);
// LinkedHashMap<String, Object> linkedMap = JSON.parseObject(s, LinkedHashMap.class);
JSONObject object = JSONObject.parseObject(s, Feature.OrderedField);
log.info("动态添加属性: = {}",object);
listDTO.add(object);
}
log.info("动态添加属性: = {}", JSON.toJSONString(listDTO));
return listDTO;
}
@Override
@DS("#header.poolName")
public MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport) {
//'ConversionReport'
MesInspectionReport data = mesInspectionReportMapper.selectSelfMutualInspectionData(mesInspectionReport);
return data;
}
@Override
@DS("#header.poolName")
public List<MesInspectionReport> getLineCodeList() {
List<MesInspectionReport> list = mesInspectionReportMapper.getLineCodeList();
return list;
}
//首检左报表
@Override
@DS("#header.poolName")
public List selectFirstInspectionLeftList(MesInspectionReport mesInspectionReport) {
//0.时间处理
// if(mesInspectionReport.getCheckDate() != null){
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//设置格式
// Calendar calendar = Calendar.getInstance();
// calendar.add(Integer.valueOf(mesInspectionReport.getCheckDate()), -1); //当前时间减去一天,即一天前的时间
// String checkDate = simpleDateFormat.format(calendar.getTime());
// mesInspectionReport.setCheckDate(checkDate);
// }
// 1.报表名
mesInspectionReport.setReportName("ConversionReportLeft");
List<MesInspectionReport> list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport);
//2..查询左侧边 列 存入
String param = "first_inspection_left";
List<String> projectNames = mesInspectionReportMapper.selectProjectName(param);
List<String> timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport);
List<Object> listDTO = new ArrayList<>();
for(String projectName : projectNames){
Map<String,String> dynamicTime = new LinkedHashMap<>();
dynamicTime.put("开始-结束",projectName);
if(CollectionUtils.isEmpty(timeArray)){
dynamicTime.put("", "");
dynamicTime.put(" ", "");
dynamicTime.put(" ", "");
}else{
for(String time : timeArray){
List<MesInspectionReport> result = list.stream()
.filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1符合开始时间结束时间
.filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2符合当前项目名
.collect(Collectors.toList()); // 收集结果
if(!CollectionUtils.isEmpty(result)){
if(StringUtils.isNotBlank(result.get(0).getCheckResult())){
dynamicTime.put(time, result.get(0).getCheckResult());
}else{
dynamicTime.put(time, "");
}
}else{
dynamicTime.put(time, "");
}
}
}
String string1 = "";
String string2 = " ";
if(timeArray.size() < 3){
for(int i = 0 ; i < 3-(timeArray.size()) ; i++){
if(i == 0){
dynamicTime.put(string1, "");
}else if(i == 1){
dynamicTime.put(string2, "");
}
}
}
String s = JSON.toJSONString(dynamicTime);
JSONObject object = JSONObject.parseObject(s, Feature.OrderedField);
log.info("左侧动态添加属性: = {}",object);
listDTO.add(object);
}
log.info("左侧动态添加属性: = {}", JSON.toJSONString(listDTO));
return listDTO;
}
@Override
@DS("#header.poolName")
public List selectFirstInspectionRightList(MesInspectionReport mesInspectionReport) {
//1.报表名
mesInspectionReport.setReportName("ConversionReportRight");
List<MesInspectionReport> list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport);
//2..查询左侧边 列 存入
String param = "first_inspection_right";
List<String> projectNames = mesInspectionReportMapper.selectProjectName(param);
List<String> timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport);
List<Object> listDTO = new ArrayList<>();
for(String projectName : projectNames){
Map<String,String> dynamicTime = new LinkedHashMap<>();
dynamicTime.put("开始-结束",projectName);
if(CollectionUtils.isEmpty(timeArray)){
dynamicTime.put("", "");
dynamicTime.put(" ", "");
dynamicTime.put(" ", "");
}else{
for(String time : timeArray){
List<MesInspectionReport> result = list.stream()
.filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1符合开始时间结束时间
.filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2符合当前项目名
.collect(Collectors.toList()); // 收集结果
if(!CollectionUtils.isEmpty(result)){
if(StringUtils.isNotBlank(result.get(0).getCheckResult())){
dynamicTime.put(time, result.get(0).getCheckResult());
}else{
dynamicTime.put(time, "");
}
}else{
dynamicTime.put(time, "");
}
}
}
String string1 = "";
String string2 = " ";
if(timeArray.size() < 3){
for(int i = 0 ; i < 3-(timeArray.size()) ; i++){
if(i == 0){
dynamicTime.put(string1, "");
}else if(i == 1){
dynamicTime.put(string2, "");
}
}
}
String s = JSON.toJSONString(dynamicTime);
JSONObject object = JSONObject.parseObject(s, Feature.OrderedField);
log.info("右侧动态添加属性: = {}",object);
listDTO.add(object);
}
log.info("右侧动态添加属性: = {}", JSON.toJSONString(listDTO));
return listDTO;
}
}

@ -0,0 +1,130 @@
<?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.MesInspectionReportMapper">
<resultMap type="MesInspectionReport" id="MesInspectionReportResult">
<!-- 子表-->
<result property="id" column="id"/>
<result property="belongTo" column="belong_to"/>
<result property="bz" column="bz"/>
<result property="checkTimeS" column="check_time_s"/>
<result property="checkTimeE" column="check_time_e"/>
<result property="checkResult" column="check_result"/>
<result property="infoCode" column="info_code"/>
<result property="infoName" column="info_name"/>
<result property="tableLine" column="table_line"/>
<result property="delFlag" column="del_flag"/>
<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="remark" column="remark"/>
<!-- 主表-->
<result property="lineCode" column="line_code"/>
<result property="productDate" column="product_date"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="checkDate" column="check_date"/>
<result property="bz" column="bz"/>
<result property="timeArray" column="timeArray"/>
<!-- 主表-->
<result property="equipmentCode" column="equipment_code"/>
<result property="equipmentName" column="equipment_name"/>
</resultMap>
<select id="selectSelfMutualInspectionList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select
mts.line_code,
mts.product_date,
mts.product_code,
mts.product_name,
mts.bz,
mtsd.id,
mtsd.belong_to,
mtsd.check_time_s,
mtsd.check_time_e,
mtsd.check_result,
mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray,
mtsd.info_code,
mtsd.info_name,
mtsd.table_line
from mes_table_self mts
left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to
<where>
<if test="reportName == 'ConversionReportLeft'">
and CONVERT(date, mts.check_date) = dateadd(day, -1, CONVERT(date,#{checkDate}))
</if>
<if test = "reportName == 'ConversionReportRight' or reportName == 'ConversionReport'">
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
</if>
and mts.line_code = #{lineCode}
and mts.del_flag = '0'
and mtsd.del_flag = '0'
and mts.report_name = #{reportName}
</where>
</select>
<select id="selectProjectName" resultType="java.lang.String" parameterType="java.lang.String">
select dict_label
from base_dict_data
where dict_type = #{param}
order by dict_sort asc
</select>
<select id="selectTimeArray" resultType="java.lang.String" parameterType="MesInspectionReport">
select
mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray
from mes_table_self mts
left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to
<where>
and mts.del_flag = '0'
and mtsd.del_flag = '0'
<if test="reportName == 'ConversionReportLeft'">
and CONVERT(date, mts.check_date) = dateadd(day, -1, CONVERT(date,#{checkDate}))
</if>
<if test = "reportName == 'ConversionReportRight' or reportName == 'ConversionReport'">
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
</if>
and mts.line_code = #{lineCode}
and mts.report_name = #{reportName}
</where>
group by mtsd.check_time_s,mtsd.check_time_e
order by mtsd.check_time_s
</select>
<select id="selectSelfMutualInspectionData" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select top 1
mts.line_code,
mts.product_date,
mts.product_code,
mts.product_name,
mts.check_date,
mts.bz,
mts.remark,
mts.create_by
from mes_table_self mts
<where>
and mts.report_name = #{reportName}
and mts.del_flag = '0'
and mts.line_code = #{lineCode}
<if test="reportName == 'ConversionReportLeft'">
and CONVERT(date, mts.check_date) = dateadd(day, -1, CONVERT(date,#{checkDate}))
</if>
<if test = "reportName == 'ConversionReportRight' or reportName == 'ConversionReport'">
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
</if>
</where>
</select>
<select id="getLineCodeList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select equipment_code, equipment_name
from base_equipment
where del_flag = '0'
and equipment_category = '1'
</select>
</mapper>
Loading…
Cancel
Save