From 2cdae7a0fa2e9d0e6b6a91ed4eadc48f81b66805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E6=B0=94=E6=BB=A1=E6=BB=A1=28jgy=29?= Date: Tue, 7 Jan 2025 15:17:26 +0800 Subject: [PATCH 1/5] =?UTF-8?q?2025-1-7=20MES-=E4=BA=A7=E5=93=81=E9=A6=96?= =?UTF-8?q?=E6=A3=80=E8=AE=B0=E5=BD=95=E8=A1=A8=E3=80=81=E8=87=AA=E6=A3=80?= =?UTF-8?q?=E4=BA=92=E6=A3=80=E8=AE=B0=E5=BD=95=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MesInspectionReportController.java | 25 ++ .../op/mes/domain/MesInspectionReport.java | 130 +++++++++- .../mes/mapper/MesInspectionReportMapper.java | 18 +- .../service/IMesInspectionReportService.java | 8 + .../impl/MesInspectionReportServiceImpl.java | 226 ++++++++++++++---- .../mapper/mes/MesInspectionReportMapper.xml | 153 ++++++++---- 6 files changed, 461 insertions(+), 99 deletions(-) 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 index b7078cb72..9907e72cd 100644 --- 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 @@ -1,7 +1,12 @@ 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.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; import com.op.mes.domain.MesInspectionReport; +import com.op.mes.domain.ProOrderWorkorder; import com.op.mes.service.IMesInspectionReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -27,6 +32,12 @@ public class MesInspectionReportController extends BaseController { return iMesInspectionReportService.selfMutualInspectionData(mesInspectionReport); } + //修改表头表位内容 + @PutMapping("/updateTable") + public AjaxResult updateTable(@RequestBody MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.updateTable(mesInspectionReport); + } + //查询产线 @GetMapping("/getLineCodeList") public List getLineCodeList() { @@ -34,6 +45,20 @@ public class MesInspectionReportController extends BaseController { return list; } + //查询产品列表 + @GetMapping("/getProductList") + public List getProductList(MesInspectionReport mesInspectionReport) { + List list = iMesInspectionReportService.getProductList(mesInspectionReport); + return list; + } + + //通过查询工单列表查询日期码 + @GetMapping("/getWorkList") + public List getWorkList(MesInspectionReport mesInspectionReport) { + List list = iMesInspectionReportService.getWorkList(mesInspectionReport); + return list; + } + //首检记录 左侧报表 主体 查询 @GetMapping("/listFirstInspectionLeft") public List firstInspectionLeftList(MesInspectionReport 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 index 2cc552980..5dcccac9a 100644 --- 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 @@ -3,6 +3,11 @@ package com.op.mes.domain; import com.op.common.core.annotation.Excel; import com.op.common.core.web.domain.BaseEntity; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; + //MES自检互检 public class MesInspectionReport extends BaseEntity { private static final long serialVersionUID = 1L; @@ -45,7 +50,7 @@ public class MesInspectionReport extends BaseEntity { private String productDate; @Excel(name = "检查日期") - private String checkDate; + private Date checkDate; @Excel(name = "产品编码") private String productCode; @@ -67,6 +72,8 @@ public class MesInspectionReport extends BaseEntity { //项目名 private String projectName; + //项目名 + private String projectCode; //线体名 private String lineName; @@ -78,12 +85,6 @@ public class MesInspectionReport extends BaseEntity { //班组 private String team; - //动态增加字段 -// 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; } @@ -121,8 +122,8 @@ public class MesInspectionReport extends BaseEntity { 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 setCheckDate(Date checkDate) { this.checkDate = checkDate; } + public Date getCheckDate() { return checkDate; } public void setProductCode(String productCode) { this.productCode = productCode; } public String getProductCode() { return productCode; } @@ -145,6 +146,9 @@ public class MesInspectionReport extends BaseEntity { public void setProjectName(String projectName) { this.projectName = projectName; } public String getProjectName() { return projectName; } + public void setProjectCode(String projectCode) { this.projectCode = projectCode; } + public String getProjectCode() { return projectCode; } + public void setOpenLine(String openLine) { this.openLine = openLine; } public String getOpenLine() { return openLine; } @@ -156,4 +160,112 @@ public class MesInspectionReport extends BaseEntity { public void setLineName(String lineName) { this.lineName = lineName; } public String getLineName() { return lineName; } + + private Integer row;//行 + private Integer col;//列 + private String type;//项目名、日期、对错号码 + private String data; + private Date time; + + // row的set和get方法 + public void setRow(Integer row) { + this.row = row; + } + + public Integer getRow() { + return row; + } + + // col的set和get方法 + public void setCol(Integer col) { + this.col = col; + } + + public Integer getCol() { + return col; + } + + // type的set和get方法 + public void setType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + // data的set和get方法 + public void setData(String data) { + this.data = data; + } + + public String getData() { + return data; + } + + // time的set和get方法 + public void setTime(Date time) { + this.time = time; + } + + public Date getTime() { + return time; + } + + //产线列表 + public List productList; + //日期码列表 + public List dateCodeList; + + // productList的get方法 + public List getProductList() { + return productList; + } + + // productList的set方法 + public void setProductList(List productList) { + this.productList = productList; + } + + // dateCodeList的get方法 + public List getDateCodeList() { + return dateCodeList; + } + + // dateCodeList的set方法 + public void setDateCodeList(List dateCodeList) { + this.dateCodeList = dateCodeList; + } + + private String workorderId;//工单号 + // get方法,用于获取工单号的值 + public String getWorkorderId() { + return workorderId; + } + + // set方法,用于设置工单号的值 + public void setWorkorderId(String workorderId) { + this.workorderId = workorderId; + } + + private ArrayList>> tableData; + + public ArrayList>> getTableData() { + return tableData; + } + + public void setTableData(ArrayList>> tableData) { + this.tableData = tableData; + } + + private String factoryCode; + + // row的set和get方法 + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } } 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 index c2cb67c85..3d50bd83c 100644 --- 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 @@ -1,13 +1,15 @@ package com.op.mes.mapper; import com.op.mes.domain.MesInspectionReport; +import com.op.mes.domain.ProOrderWorkorder; +import org.apache.ibatis.annotations.Param; import java.util.List; public interface MesInspectionReportMapper { List selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport);//查询自检互检列表 - List selectProjectName(String param);//自检互检左侧项目 - List selectTimeArray(MesInspectionReport mesInspectionReport);//查询所有时间 + List selectProjectName(String param);//自检互检左侧项目 + List selectTimeArray(MesInspectionReport mesInspectionReport);//查询所有时间 MesInspectionReport selectSelfMutualInspectionData(MesInspectionReport mesInspectionReport); List getLineCodeList(); @@ -15,4 +17,16 @@ public interface MesInspectionReportMapper { List selectTeamArray(MesInspectionReport mesInspectionReport);//班组 List selectCheckBoxList(MesInspectionReport mesInspectionReport); + List getProductList(MesInspectionReport mesInspectionReport);//查询产品列表 + List getDataCodeList(MesInspectionReport data); + + void updateHeaderFooter(MesInspectionReport mesInspectionReport); + + void updateTableBody(MesInspectionReport mesInspectionReport); + + void updateBatch(@Param("list")List updateList); + + void addBatch(@Param("list")List updateList); + + List getWorkList(MesInspectionReport mesInspectionReport); } 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 index 0f2942181..7f055178b 100644 --- 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 @@ -1,6 +1,8 @@ package com.op.mes.service; +import com.op.common.core.web.domain.AjaxResult; import com.op.mes.domain.MesInspectionReport; +import com.op.mes.domain.ProOrderWorkorder; import java.util.List; @@ -18,4 +20,10 @@ public interface IMesInspectionReportService { List selectPointInspectionList(MesInspectionReport mesInspectionReport);//产品转换/完产清线点检表 List selectCheckBoxList(MesInspectionReport mesInspectionReport);//点检上方备选框 + + List getProductList(MesInspectionReport mesInspectionReport);//查询产线 + + AjaxResult updateTable(MesInspectionReport mesInspectionReport);//修改表头 表尾部 表主体 + + List getWorkList(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 index e72c0ee92..be04086a9 100644 --- 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 @@ -3,8 +3,13 @@ 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.context.SecurityContextHolder; +import com.op.common.core.utils.DateUtils; 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.domain.ProOrderWorkorder; import com.op.mes.mapper.MesInspectionReportMapper; import com.op.mes.service.IMesInspectionReportService; import org.slf4j.Logger; @@ -26,35 +31,82 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi @Override @DS("#header.poolName") public List selectSelfMutualInspectionList(MesInspectionReport mesInspectionReport) { - mesInspectionReport.setReportName("ConversionReport"); + //mesInspectionReport.setReportName("ConversionReport"); List list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); //1.查询左侧边 列 存入 - String param = "self_mutual_inspection"; - List projectNames = mesInspectionReportMapper.selectProjectName(param); - List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + String param = ""; + if(mesInspectionReport.getReportName().equals("ConversionReport")){ + param = "self_mutual_inspection"; + }else if(mesInspectionReport.getReportName().equals("ConversionReportLeft")){ + param = "first_inspection_left"; + } + + MesInspectionReport buildDTO = new MesInspectionReport(); + buildDTO.setCheckTimeS(""); + buildDTO.setCheckTimeE(""); + + 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); + for(MesInspectionReport project : projectNames){ + Map dynamicTime = new LinkedHashMap<>(); + MesInspectionReport dto = new MesInspectionReport(); + dto.setData(project.getProjectName()); + dto.setType("projectName"); + dto.setProjectName(project.getProjectName());//项目名 + dto.setProjectCode(project.getProjectCode());//项目编码 + dynamicTime.put("开始-结束",dto); + if(CollectionUtils.isEmpty(timeArray)){ - dynamicTime.put("", ""); - dynamicTime.put(" ", ""); - dynamicTime.put(" ", ""); + dynamicTime.put("", new MesInspectionReport()); + dynamicTime.put(" ", new MesInspectionReport()); + dynamicTime.put(" ", new MesInspectionReport()); }else{ - for(String time : timeArray){ + for(MesInspectionReport time : timeArray){ List result = list.stream() - .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1:符合开始时间结束时间 - .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2:符合当前项目名 + .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time.getTimeArray())) // 条件1:符合开始时间结束时间 + .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(project.getProjectName())) // 条件2:符合当前项目名 .collect(Collectors.toList()); // 收集结果 + if(!CollectionUtils.isEmpty(result)){ if(StringUtils.isNotBlank(result.get(0).getCheckResult())){ - dynamicTime.put(time, result.get(0).getCheckResult()); + if(project.getProjectName().equals("日期码") || project.getProjectName().equals("生产批号")){ + result.get(0).setType("dataCode"); + }else if(project.getProjectName().equals("灌装量/净含量/喷药量")){ + result.get(0).setType("sprayAmount"); + }else{ + result.get(0).setType("rightWrong"); + } + result.get(0).setData(result.get(0).getCheckResult()); + dynamicTime.put(time.getTimeArray(), result.get(0)); }else{ - dynamicTime.put(time, ""); + MesInspectionReport result0 = new MesInspectionReport(); + if(project.getProjectName().equals("日期码")|| project.getProjectName().equals("生产批号")){ + result0.setType("dataCode"); + }else if(project.getProjectName().equals("灌装量/净含量/喷药量")){ + result0.setType("sprayAmount"); + }else{ + result0.setType("rightWrong"); + } + result0.setCheckTimeS(time.getCheckTimeS()); + result0.setCheckTimeE(time.getCheckTimeE()); + result0.setTableLine(time.getTableLine()); + dynamicTime.put(time.getTimeArray(), result0); } }else{ - dynamicTime.put(time, ""); + MesInspectionReport result0 = new MesInspectionReport(); + if(project.getProjectName().equals("日期码")|| project.getProjectName().equals("生产批号")){ + result0.setType("dataCode"); + }else if(project.getProjectName().equals("灌装量/净含量/喷药量")){ + result0.setType("sprayAmount"); + }else{ + result0.setType("rightWrong"); + } + result0.setCheckTimeS(time.getCheckTimeS()); + result0.setCheckTimeE(time.getCheckTimeE()); + result0.setTableLine(time.getTableLine()); + dynamicTime.put(time.getTimeArray(), result0); } } } @@ -65,17 +117,14 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi if(timeArray.size() < 3){ for(int i = 0 ; i < 3-(timeArray.size()) ; i++){ if(i == 0){ - dynamicTime.put(string1, ""); + dynamicTime.put(string1,new MesInspectionReport()); }else if(i == 1){ - dynamicTime.put(string2, ""); + dynamicTime.put(string2,new MesInspectionReport()); } } } - 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); @@ -84,11 +133,88 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi return listDTO; } + @Override + @DS("#header.poolName") + //修改表头部和表尾部 + public AjaxResult updateTable(MesInspectionReport mesInspectionReport) { + mesInspectionReport.setUpdateBy(SecurityContextHolder.getUserName()); + mesInspectionReport.setUpdateTime(DateUtils.getNowDate()); + //更新表头和表尾 也就是数据库的主表内容 + mesInspectionReport.setCreateBy(StringUtils.isBlank(mesInspectionReport.getCreateBy())? + SecurityContextHolder.getUserName() : mesInspectionReport.getCreateBy()); + mesInspectionReportMapper.updateHeaderFooter(mesInspectionReport); + + //需要新增的 + List addList = new ArrayList<>(); + //需要修改的 + List updateList = new ArrayList<>(); + + ArrayList>> tableData = mesInspectionReport.getTableData(); + if (tableData!= null) { + for (LinkedHashMap> item : tableData) { + //提取出来开始结束那一行数据的 项目名字 + String projectName = (String) item.get("开始-结束").get("projectName"); + String projectCode = (String) item.get("开始-结束").get("projectCode"); + + for (Map.Entry> entry : item.entrySet()) { + if(!entry.getKey().equals("开始-结束")){ + LinkedHashMap innerMap = entry.getValue(); + String dataValue = (String) innerMap.get("data"); + String idValue = (String) innerMap.get("id"); + String checkTimeS = (String) innerMap.get("checkTimeS"); + String checkTimeE = (String) innerMap.get("checkTimeE"); + Integer tableLine = (Integer) innerMap.get("tableLine"); //实际上是列的意思 + + //如果是新的需要插入的值 ,那么说明没有id + if(StringUtils.isBlank(idValue) && StringUtils.isNotBlank(dataValue)){ + MesInspectionReport addDto = new MesInspectionReport(); + addDto.setId(IdUtils.fastSimpleUUID());//自动生成id + addDto.setBelongTo(mesInspectionReport.getId());//主表id + addDto.setInfoCode(projectCode); + addDto.setInfoName(projectName); + addDto.setCreateTime(DateUtils.getNowDate()); + addDto.setCreateBy(SecurityContextHolder.getUserName()); + addDto.setCheckResult(dataValue); + addDto.setCheckTimeS(checkTimeS); + addDto.setCheckTimeE(StringUtils.isBlank(checkTimeE)? "" : checkTimeE); + addDto.setTableLine(tableLine); + addDto.setDelFlag("0"); + addList.add(addDto); + }else if(StringUtils.isNotBlank(idValue) && StringUtils.isNotBlank(dataValue)){ + MesInspectionReport updateDto = new MesInspectionReport(); + updateDto.setId(idValue); + updateDto.setUpdateBy(SecurityContextHolder.getUserName()); + updateDto.setUpdateTime(DateUtils.getNowDate()); + updateDto.setCheckResult(dataValue); + updateDto.setCheckTimeS(checkTimeS); + updateDto.setCheckTimeE(StringUtils.isBlank(checkTimeE)? "" : checkTimeE); + updateList.add(updateDto); + } + } + } + } + } + + //更新表的主体部分 也就是数据库的子表 + if(updateList.size() > 0 ){ + mesInspectionReportMapper.updateBatch(updateList); + } + + if(addList.size() >0){ + mesInspectionReportMapper.addBatch(addList); + } + + return AjaxResult.success(); + } + @Override @DS("#header.poolName") public MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport) { - //'ConversionReport' MesInspectionReport data = mesInspectionReportMapper.selectSelfMutualInspectionData(mesInspectionReport); + if(mesInspectionReport.getWorkorderId() != null){ + List dateCodeList = mesInspectionReportMapper.getDataCodeList(mesInspectionReport); + data.setDateCodeList(dateCodeList); + } return data; } @@ -99,6 +225,22 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi return list; } + @Override + @DS("#header.poolName") + public List getProductList(MesInspectionReport mesInspectionReport) { + List productList = mesInspectionReportMapper.getProductList(mesInspectionReport); + return productList; + } + + @Override + @DS("#header.poolName") + public List getWorkList(MesInspectionReport mesInspectionReport) { + List workList = mesInspectionReportMapper.getWorkList(mesInspectionReport); + return workList; + } + + + ////////左右报表都不需要 //首检左报表 @Override @DS("#header.poolName") @@ -117,32 +259,32 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi List list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); //2..查询左侧边 列 存入 String param = "first_inspection_left"; - List projectNames = mesInspectionReportMapper.selectProjectName(param); + List projectNames = mesInspectionReportMapper.selectProjectName(param); - List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); List listDTO = new ArrayList<>(); - for(String projectName : projectNames){ + for(MesInspectionReport project : projectNames){ Map dynamicTime = new LinkedHashMap<>(); - dynamicTime.put("开始-结束",projectName); + dynamicTime.put("开始-结束",project.getProjectName()); if(CollectionUtils.isEmpty(timeArray)){ dynamicTime.put("", ""); dynamicTime.put(" ", ""); dynamicTime.put(" ", ""); }else{ - for(String time : timeArray){ + for(MesInspectionReport time : timeArray){ List result = list.stream() - .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1:符合开始时间结束时间 - .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2:符合当前项目名 + .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time.getTimeArray())) // 条件1:符合开始时间结束时间 + .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(project.getProjectName())) // 条件2:符合当前项目名 .collect(Collectors.toList()); // 收集结果 if(!CollectionUtils.isEmpty(result)){ if(StringUtils.isNotBlank(result.get(0).getCheckResult())){ - dynamicTime.put(time, result.get(0).getCheckResult()); + dynamicTime.put(time.getTimeArray(), result.get(0).getCheckResult()); }else{ - dynamicTime.put(time, ""); + dynamicTime.put(time.getTimeArray(), ""); } }else{ - dynamicTime.put(time, ""); + dynamicTime.put(time.getTimeArray(), ""); } } } @@ -176,32 +318,32 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi List list = mesInspectionReportMapper.selectSelfMutualInspectionList(mesInspectionReport); //2..查询左侧边 列 存入 String param = "first_inspection_right"; - List projectNames = mesInspectionReportMapper.selectProjectName(param); + List projectNames = mesInspectionReportMapper.selectProjectName(param); - List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); + List timeArray = mesInspectionReportMapper.selectTimeArray(mesInspectionReport); List listDTO = new ArrayList<>(); - for(String projectName : projectNames){ + for(MesInspectionReport project : projectNames){ Map dynamicTime = new LinkedHashMap<>(); - dynamicTime.put("开始-结束",projectName); + dynamicTime.put("开始-结束",project.getProjectName()); if(CollectionUtils.isEmpty(timeArray)){ dynamicTime.put("", ""); dynamicTime.put(" ", ""); dynamicTime.put(" ", ""); }else{ - for(String time : timeArray){ + for(MesInspectionReport time : timeArray){ List result = list.stream() - .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time)) // 条件1:符合开始时间结束时间 - .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(projectName)) // 条件2:符合当前项目名 + .filter(MesInspectionReport -> MesInspectionReport.getTimeArray().equals(time.getTimeArray())) // 条件1:符合开始时间结束时间 + .filter(MesInspectionReport-> MesInspectionReport.getInfoName().equals(project.getProjectName())) // 条件2:符合当前项目名 .collect(Collectors.toList()); // 收集结果 if(!CollectionUtils.isEmpty(result)){ if(StringUtils.isNotBlank(result.get(0).getCheckResult())){ - dynamicTime.put(time, result.get(0).getCheckResult()); + dynamicTime.put(time.getTimeArray(), result.get(0).getCheckResult()); }else{ - dynamicTime.put(time, ""); + dynamicTime.put(time.getTimeArray(), ""); } }else{ - dynamicTime.put(time, ""); + dynamicTime.put(time.getTimeArray(), ""); } } } 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 index b560f3ab2..78c7d3c67 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesInspectionReportMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesInspectionReportMapper.xml @@ -35,7 +35,7 @@ - + - + select dict_label as projectName , dict_code as projectCode ,dict_sort as tableLine from base_dict_data where dict_type = #{param} order by dict_sort asc @@ -88,24 +78,23 @@ order by dict_sort asc - select - mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray + mtsd.check_time_s as checkTimeS, + mtsd.check_time_e as checkTimeE, + mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray, + mtsd.table_line as tableLine from mes_table_self mts left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to and mts.del_flag = '0' and mtsd.del_flag = '0' - - and CONVERT(date, mts.check_date) = dateadd(day, -1, CONVERT(date,#{checkDate})) - - - and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate}) - + and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate}) and mts.line_code = #{lineCode} and mts.report_name = #{reportName} + and mtsd.table_line is not null - group by mtsd.check_time_s,mtsd.check_time_e + group by mtsd.check_time_s , mtsd.check_time_e , mtsd.table_line order by mtsd.check_time_s @@ -125,29 +114,18 @@ + + + + + + update mes_table_self + + remark = #{remark}, + create_by = #{createBy}, + bz = #{bz}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + + + update mes_table_self_detial + + check_time_s = #{item.checkTimeS}, + check_time_e = #{item.checkTimeE}, + check_result = #{item.checkResult}, + update_by = #{item.updateBy}, + update_time = #{item.updateTime}, + + where id = #{item.id} + + + + + insert into mes_table_self_detial( + id, belong_to, + remark, bz, + create_by, create_time, + update_by, update_time, + factory_code, del_flag, + check_time_s, check_time_e, + check_result, info_code, + info_name, table_line + ) values + + ( + #{item.id}, #{item.belongTo}, + #{item.remark}, #{item.bz}, + #{item.createBy}, #{item.createTime}, + #{item.updateBy}, #{item.updateTime}, + #{item.factoryCode}, #{item.delFlag}, + #{item.checkTimeS}, #{item.checkTimeE}, + #{item.checkResult}, #{item.infoCode}, + #{item.infoName}, #{item.tableLine} + ) + + + From 1ab70516726a588a75ca4ce29b20307ae54fe0bc Mon Sep 17 00:00:00 2001 From: Yangwl <1726150332@qq.com> Date: Tue, 7 Jan 2025 16:38:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9C=88=E5=BA=A6=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/op/mes/controller/MesReportWorkController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java index da240a0c0..d8bccd09e 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java @@ -662,7 +662,7 @@ public class MesReportWorkController extends BaseController { /** * 黑蚊香车间月度汇总表 */ - @RequiresPermissions("mes:monthProductionSut:list") + @GetMapping("/getmonthProductionSut") public AjaxResult getmonthProductionSut(MesMonthReportVo mesMonthReportVo) { SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); From 501ca0b094f8e803e118c843c90e172f1e9838a3 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Tue, 7 Jan 2025 17:33:10 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=83=98=E6=88=BF=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8+=E4=BA=A7=E5=93=81=E8=BF=BD=E6=BA=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/quality/QcCheckTaskDTO.java | 18 ++++ .../mes/controller/MesPrepareController.java | 22 +++++ .../controller/MesReportWorksController.java | 53 ++++++++++++ .../java/com/op/mes/domain/HFProduction.java | 83 +++++++++++++++++++ .../java/com/op/mes/domain/MesPrepare.java | 27 ++++++ .../com/op/mes/mapper/MesPrepareMapper.java | 5 ++ .../op/mes/mapper/MesReportWorkMapper.java | 5 ++ .../op/mes/service/IMesPrepareService.java | 5 ++ .../mes/service/IMesReportWorksService.java | 7 ++ .../service/impl/MesPrepareServiceImpl.java | 12 +++ .../impl/MesReportWorksServiceImpl.java | 82 +++++++++++++++++- .../resources/mapper/mes/MesPrepareMapper.xml | 52 ++++++++++++ .../mapper/mes/MesReportWorkMapper.xml | 30 +++++++ .../resources/mapper/system/SysUserMapper.xml | 2 +- 14 files changed, 399 insertions(+), 4 deletions(-) create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/domain/HFProduction.java diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/quality/QcCheckTaskDTO.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/quality/QcCheckTaskDTO.java index 47eb82b42..387772e11 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/quality/QcCheckTaskDTO.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/quality/QcCheckTaskDTO.java @@ -135,6 +135,24 @@ public class QcCheckTaskDTO extends BaseEntity { private BigDecimal aNoOkquality; private BigDecimal bNoOkquality; private BigDecimal cNoOkquality; + private String className; + private String reason; + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } public BigDecimal getSampleQuality() { return sampleQuality; diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesPrepareController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesPrepareController.java index 99b5f3d4a..191866738 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesPrepareController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesPrepareController.java @@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse; import com.op.common.core.domain.R; import com.op.common.core.utils.uuid.IdUtils; +import com.op.system.api.domain.quality.QcCheckTaskDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties; import org.springframework.web.bind.annotation.GetMapping; @@ -113,4 +114,25 @@ public class MesPrepareController extends BaseController { public R reportWorkTask() { return mesPrepareService.reportWorkTask(); } + + /** + * 查询备料单列表 + */ + @GetMapping("/getBomTraceList") + @Log(title = "产品主键追溯备料单查询", businessType = BusinessType.QUERY) + public TableDataInfo getBomTraceList(MesPrepare mesPrepare) { + startPage(); + List list = mesPrepareService.getBomTraceList(mesPrepare); + return getDataTable(list); + } + /** + * 查询备料单列表 + */ + @GetMapping("/getCheckTaskTraceList") + @Log(title = "产品主键追溯检验任务查询", businessType = BusinessType.QUERY) + public TableDataInfo getCheckTaskTraceList(QcCheckTaskDTO dto) { + startPage(); + List list = mesPrepareService.getCheckTaskTraceList(dto); + return getDataTable(list); + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorksController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorksController.java index c789aff98..148940d0b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorksController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorksController.java @@ -1,23 +1,30 @@ package com.op.mes.controller; +import com.op.common.core.domain.ExcelCol; import com.op.common.core.domain.R; import com.op.common.core.utils.bean.BeanUtils; +import com.op.common.core.utils.poi.ExcelMapUtil; import com.op.common.core.utils.poi.ExcelUtil; import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.page.TableDataInfo; import com.op.common.security.annotation.RequiresPermissions; import com.op.mes.domain.*; +import com.op.mes.domain.vo.DynamicColumnVo; import com.op.mes.service.IMesReportWorksService; import com.op.common.core.utils.bean.BeanUtils; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import static com.op.common.core.utils.PageUtils.startPage; @@ -80,4 +87,50 @@ public class MesReportWorksController extends BaseController { } } + /**烘房产量统计**/ + @GetMapping("/getHFProductionList") + public List> getHFProductionList(HFProduction dto) { + List equNames = this.getHFProductionTitle(dto); + dto.setEquNames(equNames); + List> list = mesReportWorksService.getHFProductionList(dto); + return list; + } + @GetMapping("/getHFProductionTitle") + public List getHFProductionTitle(HFProduction dto) { + List list = mesReportWorksService.getHFProductionTitle(dto); + return list; + } + @PostMapping("/getHFProductionExport") + public void getHFProductionExport(HttpServletResponse response,HFProduction dto) { + List equNames = this.getHFProductionTitle(dto); + dto.setEquNames(equNames); + List> list = mesReportWorksService.getHFProductionList(dto); + + ArrayList excelCols = new ArrayList<>(); + excelCols.add(new ExcelCol("日期","ymd",20)); + for (DynamicColumnVo column : equNames) { + excelCols.add(new ExcelCol(column.getLabel(), column.getCode(), 20)); + } + excelCols.add(new ExcelCol("总产量","totalQuantity",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, list); + workbook.write(outputStream); + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (workbook!=null){ + workbook.dispose(); + } + } + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/HFProduction.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/HFProduction.java new file mode 100644 index 000000000..790121799 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/HFProduction.java @@ -0,0 +1,83 @@ +package com.op.mes.domain; + +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; +import com.op.mes.domain.vo.DynamicColumnVo; + +import java.util.List; + +/** + * + * @author Open Platform + * @date 2024-12-12 + */ +public class HFProduction extends BaseEntity { + private static final long serialVersionUID = 1L; + @Excel(name = "日期") + private String ymd; + @Excel(name = "烘房编码") + private String equCode; + @Excel(name = "烘房名称") + private String equName; + @Excel(name = "产量") + private String quality; + private String ymArrayStart; + private String ymArrayEnd; + private List equNames; + + public List getEquNames() { + return equNames; + } + + public void setEquNames(List equNames) { + this.equNames = equNames; + } + + public String getYmd() { + return ymd; + } + + public void setYmd(String ymd) { + this.ymd = ymd; + } + + public String getEquCode() { + return equCode; + } + + public void setEquCode(String equCode) { + this.equCode = equCode; + } + + public String getEquName() { + return equName; + } + + public void setEquName(String equName) { + this.equName = equName; + } + + public String getQuality() { + return quality; + } + + public void setQuality(String quality) { + this.quality = quality; + } + + public String getYmArrayStart() { + return ymArrayStart; + } + + public void setYmArrayStart(String ymArrayStart) { + this.ymArrayStart = ymArrayStart; + } + + public String getYmArrayEnd() { + return ymArrayEnd; + } + + public void setYmArrayEnd(String ymArrayEnd) { + this.ymArrayEnd = ymArrayEnd; + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java index d64aaf866..374fd508e 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesPrepare.java @@ -175,6 +175,33 @@ public class MesPrepare extends BaseEntity { private String factoryCode; private String prodLineCode; private String dayStr; + private String recoil; + private String ymArrayStart; + private String ymArrayEnd; + + public String getYmArrayStart() { + return ymArrayStart; + } + + public void setYmArrayStart(String ymArrayStart) { + this.ymArrayStart = ymArrayStart; + } + + public String getYmArrayEnd() { + return ymArrayEnd; + } + + public void setYmArrayEnd(String ymArrayEnd) { + this.ymArrayEnd = ymArrayEnd; + } + + public String getRecoil() { + return recoil; + } + + public void setRecoil(String recoil) { + this.recoil = recoil; + } public String getProdLineCode() { return prodLineCode; diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java index 0be20db32..6f8d32a57 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesPrepareMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.mes.domain.MesPrepare; +import com.op.system.api.domain.quality.QcCheckTaskDTO; import org.apache.ibatis.annotations.Mapper; /** @@ -71,4 +72,8 @@ public interface MesPrepareMapper { * @return */ MesPrepare selectMesPrepareByCode(String workorderCode); + + List getBomTraceList(MesPrepare mesPrepare); + + List getCheckTaskTraceList(QcCheckTaskDTO dto); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java index dd97e2370..1b4dcda8b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java @@ -8,6 +8,7 @@ import com.op.mes.domain.*; import com.op.mes.domain.dto.LineChartSeriesDto; import com.op.mes.domain.dto.QuantityDto; import com.op.mes.domain.dto.SysFactoryDto; +import com.op.mes.domain.vo.DynamicColumnVo; import com.op.mes.domain.vo.MesDailyReportVo; import com.op.mes.domain.vo.MesMonthReportVo; import com.op.system.api.domain.SysNoticeGroup; @@ -214,4 +215,8 @@ public interface MesReportWorkMapper { List getWorkList(MesProductTrace qo); List getWaList(MesProductTrace qo); + + List getHFProductionList(HFProduction dto); + + List getHFProductionTitle(HFProduction dto); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java index 0319e10b6..979667118 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java @@ -4,6 +4,7 @@ import java.util.List; import com.op.common.core.domain.R; import com.op.mes.domain.MesPrepare; +import com.op.system.api.domain.quality.QcCheckTaskDTO; /** * 备料单Service接口 @@ -66,4 +67,8 @@ public interface IMesPrepareService { public R getMesPrepare(); public R reportWorkTask(); + + public List getBomTraceList(MesPrepare mesPrepare); + + public List getCheckTaskTraceList(QcCheckTaskDTO dto); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorksService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorksService.java index 32f98d6e3..46645ec72 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorksService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorksService.java @@ -1,10 +1,13 @@ package com.op.mes.service; import com.op.common.core.domain.R; +import com.op.mes.domain.HFProduction; import com.op.mes.domain.MesProductTrace; import com.op.mes.domain.MesReportWork; +import com.op.mes.domain.vo.DynamicColumnVo; import java.util.List; +import java.util.Map; public interface IMesReportWorksService { @@ -13,4 +16,8 @@ public interface IMesReportWorksService { R mesProTask(); List getProductTrace(MesProductTrace dto); + + List> getHFProductionList(HFProduction dto); + + List getHFProductionTitle(HFProduction dto); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java index 087ab1a51..f50832027 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java @@ -20,6 +20,7 @@ import com.op.mes.mapper.MesReportWorkMapper; import com.op.system.api.RemoteSapService; import com.op.system.api.RemoteUserService; import com.op.system.api.domain.SysUser; +import com.op.system.api.domain.quality.QcCheckTaskDTO; import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.domain.sap.SapRFW; import org.slf4j.Logger; @@ -303,4 +304,15 @@ public class MesPrepareServiceImpl implements IMesPrepareService { Set orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); System.out.println(JSON.toJSONString(orderCodes)); } + + @Override + @DS("#header.poolName") + public List getBomTraceList(MesPrepare mesPrepare) { + return mesPrepareMapper.getBomTraceList(mesPrepare); + } + @Override + @DS("#header.poolName") + public List getCheckTaskTraceList(QcCheckTaskDTO dto) { + return mesPrepareMapper.getCheckTaskTraceList(dto); + } } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorksServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorksServiceImpl.java index ef803cc6f..9d324a7fb 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorksServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorksServiceImpl.java @@ -2,6 +2,7 @@ package com.op.mes.service.impl; import com.alibaba.fastjson2.JSONObject; +import com.alibaba.nacos.shaded.com.google.common.collect.Lists; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.domain.R; @@ -9,9 +10,8 @@ import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.bean.BeanUtils; import com.op.common.core.web.domain.AjaxResult; -import com.op.mes.domain.MesProductTrace; -import com.op.mes.domain.MesReportWork; -import com.op.mes.domain.ProOrderWorkorder; +import com.op.mes.domain.*; +import com.op.mes.domain.vo.DynamicColumnVo; import com.op.mes.mapper.MesReportWorkMapper; import com.op.mes.mapper.MesReportWorksMapper; import com.op.mes.service.IMesReportWorksService; @@ -27,6 +27,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -147,6 +149,7 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService { } return dtos; } + public void setMesProInfoFunc(String poolName){ DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key //工厂名称 @@ -199,4 +202,77 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService { //发企业微信--------------------结束 } } + + @Override + @DS("#header.poolName") + public List> getHFProductionList(HFProduction dto) { + //return mesReportWorkMapper.getHFProductionList(dto); + // 开始日期 + String start = dto.getYmArrayStart(); + String end = dto.getYmArrayEnd(); + // 查询出来时间区间 + List listDate = getDateInterval(start,end); + List allEquNames = dto.getEquNames(); + + List dbMProductList = mesReportWorkMapper.getHFProductionList(dto); + + List> results = listDate.stream() + .map(date -> { + Map row = new HashMap<>(); + row.put("ymd", date); + + //对于每个日期,收集该日期下所有产品的产量数据 + Map dailyProductQuantities = dbMProductList.stream() + .filter(HFProduction -> HFProduction.getYmd().equals(date)) + .collect(Collectors.toMap( + HFProduction::getEquCode, + HFProduction::getQuality + )); + + // 遍历所有产品,如果dailyProduct不存在此产品,添加产品,产量设为空 + for (DynamicColumnVo equ : allEquNames) { + String equCode = equ.getCode(); + dailyProductQuantities.putIfAbsent(equCode, "0"); + } + + row.putAll(dailyProductQuantities); + + // 计算并添加当日总产量 + int totalQuantity = dailyProductQuantities.values().stream() + .mapToInt(Integer::parseInt) + .sum(); + row.put("totalQuantity", totalQuantity); + + return row; + }).collect(Collectors.toList()); + + return results; + } + + @Override + @DS("#header.poolName") + public List getHFProductionTitle(HFProduction dto) { + //查询sql数据 + List data = mesReportWorkMapper.getHFProductionTitle(dto); + return data; + } + private List getDateInterval(String start, String end) { + start = start.substring(0,10); + end = end.substring(0,10); + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + List dateList = Lists.newArrayList(); + + LocalDate localStart = LocalDate.parse(start,fmt); + LocalDate localEnd = LocalDate.parse(end,fmt); + + LocalDate nextDate = localStart; + + do { + String nextDateStr = nextDate.format(fmt); + dateList.add(nextDateStr); + nextDate = nextDate.plusDays(1); + }while (nextDate.compareTo(localEnd) <= 0); + return dateList; + + } } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesPrepareMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesPrepareMapper.xml index 172258faa..b9f0a6476 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesPrepareMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesPrepareMapper.xml @@ -92,6 +92,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from mes_prepare where workorder_code = #{workorderCode} and del_flag = '0' + + insert into mes_prepare diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml index b74c437b8..9ed7a0ad9 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml @@ -1187,6 +1187,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and #{ymArrayEnd} >=CONVERT(varchar(10),qct.income_time,120) order by ba.area_desc asc,qct.income_time desc + + insert into mes_report_work diff --git a/op-modules/op-system/src/main/resources/mapper/system/SysUserMapper.xml b/op-modules/op-system/src/main/resources/mapper/system/SysUserMapper.xml index 8b1fd304c..f702196a5 100644 --- a/op-modules/op-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/op-modules/op-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -285,7 +285,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select max(create_time) from sys_user where create_by = 'job' and del_flag = '0' @@ -125,7 +126,16 @@ mts.remark, mts.create_by from mes_table_self mts - where id = #{id} + where 1=1 + + and report_name = #{reportName} + and line_code = #{lineCode} + and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate}) + + + and id = #{id} + + and del_flag = '0' - -