diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesInspectionReportController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesInspectionReportController.java new file mode 100644 index 00000000..4f5a0d44 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesInspectionReportController.java @@ -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 selfMutualInspectionList(MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.selectSelfMutualInspectionList(mesInspectionReport); + } + + //自检互检记录报表 产品名称 检查人 生产产线 检查日期 异常处理 备注 + @GetMapping("/selfMutualInspectionData") + public MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.selfMutualInspectionData(mesInspectionReport); + } + + //查询产线 + @GetMapping("/getLineCodeList") + public List getLineCodeList() { + List list = iMesInspectionReportService.getLineCodeList(); + return list; + } + + //首检记录 左侧报表 主体 查询 + @GetMapping("/listFirstInspectionLeft") + public List firstInspectionLeftList(MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.selectFirstInspectionLeftList(mesInspectionReport); + } + + //首检记录 右侧报表 主体 查询 + @GetMapping("/listFirstInspectionRight") + public List firstInspectionRightList(MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.selectFirstInspectionRightList(mesInspectionReport); + } + +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesInspectionReport.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesInspectionReport.java new file mode 100644 index 00000000..b29a4aea --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesInspectionReport.java @@ -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 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; } + +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesInspectionReportMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesInspectionReportMapper.java new file mode 100644 index 00000000..134b64af --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesInspectionReportMapper.java @@ -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 selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport);//查询自检互检列表 + List selectProjectName(String param);//自检互检左侧项目 + List selectTimeArray(MesInspectionReport mesInspectionReport);//查询所有时间 + MesInspectionReport selectSelfMutualInspectionData(MesInspectionReport mesInspectionReport); + List getLineCodeList(); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesInspectionReportService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesInspectionReportService.java new file mode 100644 index 00000000..a27bec23 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesInspectionReportService.java @@ -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 selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport); + + MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport); + + List getLineCodeList(); + + List selectFirstInspectionRightList(MesInspectionReport mesInspectionReport);//首检右报表 + + List selectFirstInspectionLeftList(MesInspectionReport mesInspectionReport);//首检左报表 +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesInspectionReportServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesInspectionReportServiceImpl.java new file mode 100644 index 00000000..c087ae8e --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesInspectionReportServiceImpl.java @@ -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 list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); + //1.查询左侧边 列 存入 + String param = "self_mutual_inspection"; + List projectNames = mesInspectionReportMapper.selectProjectName(param); + List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + List listDTO = new ArrayList<>(); + + for(String projectName : projectNames){ + Map dynamicTime = new LinkedHashMap<>(); + dynamicTime.put("开始-结束",projectName); + if(CollectionUtils.isEmpty(timeArray)){ + dynamicTime.put("", ""); + dynamicTime.put(" ", ""); + dynamicTime.put(" ", ""); + }else{ + for(String time : timeArray){ + List 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 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 getLineCodeList() { + List 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 list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); + //2..查询左侧边 列 存入 + String param = "first_inspection_left"; + List projectNames = mesInspectionReportMapper.selectProjectName(param); + + List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + List listDTO = new ArrayList<>(); + + for(String projectName : projectNames){ + Map dynamicTime = new LinkedHashMap<>(); + dynamicTime.put("开始-结束",projectName); + if(CollectionUtils.isEmpty(timeArray)){ + dynamicTime.put("", ""); + dynamicTime.put(" ", ""); + dynamicTime.put(" ", ""); + }else{ + for(String time : timeArray){ + List 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 list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); + //2..查询左侧边 列 存入 + String param = "first_inspection_right"; + List projectNames = mesInspectionReportMapper.selectProjectName(param); + + List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + List listDTO = new ArrayList<>(); + + for(String projectName : projectNames){ + Map dynamicTime = new LinkedHashMap<>(); + dynamicTime.put("开始-结束",projectName); + if(CollectionUtils.isEmpty(timeArray)){ + dynamicTime.put("", ""); + dynamicTime.put(" ", ""); + dynamicTime.put(" ", ""); + }else{ + for(String time : timeArray){ + List 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; + } + +} diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesInspectionReportMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesInspectionReportMapper.xml new file mode 100644 index 00000000..d12c334d --- /dev/null +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesInspectionReportMapper.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +