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 9907e72c..3c143fe4 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 @@ -2,9 +2,6 @@ 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; @@ -26,18 +23,24 @@ public class MesInspectionReportController extends BaseController { return iMesInspectionReportService.selectSelfMutualInspectionList(mesInspectionReport); } - //自检互检记录报表 产品名称 检查人 生产产线 检查日期 异常处理 备注 + //查询表头表尾内容 @GetMapping("/selfMutualInspectionData") public MesInspectionReport selfMutualInspectionData(MesInspectionReport mesInspectionReport) { return iMesInspectionReportService.selfMutualInspectionData(mesInspectionReport); } - //修改表头表位内容 + //修改整个表 @PutMapping("/updateTable") public AjaxResult updateTable(@RequestBody MesInspectionReport mesInspectionReport) { return iMesInspectionReportService.updateTable(mesInspectionReport); } + //修改点检表 + @PutMapping("/updatePointInspectionTable") + public AjaxResult updatePointInspectionTable(@RequestBody MesInspectionReport mesInspectionReport) { + return iMesInspectionReportService.updatePointInspectionTable(mesInspectionReport); + } + //查询产线 @GetMapping("/getLineCodeList") public List getLineCodeList() { @@ -59,13 +62,13 @@ public class MesInspectionReportController extends BaseController { return list; } - //首检记录 左侧报表 主体 查询 + //这个不用了 @GetMapping("/listFirstInspectionLeft") public List firstInspectionLeftList(MesInspectionReport mesInspectionReport) { return iMesInspectionReportService.selectFirstInspectionLeftList(mesInspectionReport); } - //首检记录 右侧报表 主体 查询 + //这个也不用了 @GetMapping("/listFirstInspectionRight") public List firstInspectionRightList(MesInspectionReport mesInspectionReport) { return iMesInspectionReportService.selectFirstInspectionRightList(mesInspectionReport); @@ -76,10 +79,4 @@ public class MesInspectionReportController extends BaseController { public List listPointInspection(MesInspectionReport mesInspectionReport) { return iMesInspectionReportService.selectPointInspectionList(mesInspectionReport); } - - //点检记录 - @GetMapping("/listCheckBox") - public List listCheckBox(MesInspectionReport mesInspectionReport) { - return iMesInspectionReportService.selectCheckBoxList(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 5dcccac9..9cad0db8 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 @@ -268,4 +268,21 @@ public class MesInspectionReport extends BaseEntity { public String getFactoryCode() { return factoryCode; } + + private Boolean whetherOpenLine;//是开线还是清换线 开线是1 清换线是0 + public void setWhetherOpenLine(Boolean whetherOpenLine) { + this.whetherOpenLine = whetherOpenLine; + } + public Boolean getWhetherOpenLine() { + return whetherOpenLine; + } + + //点检 + private ArrayList> pointTableData; + public ArrayList> getPointTableData() { + return pointTableData; + } + public void setPointTableData(ArrayList> pointTableData) { + this.pointTableData = pointTableData; + } } 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 3d50bd83..7e121000 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 @@ -15,8 +15,6 @@ public interface MesInspectionReportMapper { List selectPointInspectionProjectList(String param);//点检项目 List selectTeamArray(MesInspectionReport mesInspectionReport);//班组 - - List selectCheckBoxList(MesInspectionReport mesInspectionReport); List getProductList(MesInspectionReport mesInspectionReport);//查询产品列表 List getDataCodeList(MesInspectionReport data); 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 7f055178..2d8ac257 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 @@ -19,11 +19,11 @@ public interface IMesInspectionReportService { List selectPointInspectionList(MesInspectionReport mesInspectionReport);//产品转换/完产清线点检表 - List selectCheckBoxList(MesInspectionReport mesInspectionReport);//点检上方备选框 - List getProductList(MesInspectionReport mesInspectionReport);//查询产线 AjaxResult updateTable(MesInspectionReport mesInspectionReport);//修改表头 表尾部 表主体 List getWorkList(MesInspectionReport mesInspectionReport); + + AjaxResult updatePointInspectionTable(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 be04086a..ac4dc4b9 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 @@ -245,15 +245,6 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi @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); @@ -381,19 +372,42 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi List teamArray = mesInspectionReportMapper.selectTeamArray(mesInspectionReport); List listDTO = new ArrayList<>(); + MesInspectionReport buildDTO = new MesInspectionReport(); + buildDTO.setId(""); + buildDTO.setRemark(""); + buildDTO.setCheckResult(""); + buildDTO.setBelongTo(mesInspectionReport.getId()); + buildDTO.setWhetherOpenLine(null); for(MesInspectionReport project : projectList){ - Map dynamicRow = new LinkedHashMap<>(); - dynamicRow.put("序号",project.getTableLine() + ""); - dynamicRow.put("点检项目",project.getProjectName()); - dynamicRow.put("点检内容",project.getInfoName()); + Map dynamicRow = new LinkedHashMap<>(); + + MesInspectionReport buildDTO1 = new MesInspectionReport(); + buildDTO1.setData(project.getTableLine() + ""); + dynamicRow.put("序号",buildDTO1); + + MesInspectionReport buildDTO2 = new MesInspectionReport(); + buildDTO2.setData(project.getProjectName()); + dynamicRow.put("点检项目",buildDTO2); + + MesInspectionReport buildDTO3 = new MesInspectionReport(); + buildDTO3.setData(project.getInfoName()); + dynamicRow.put("点检内容",buildDTO3); + if(CollectionUtils.isEmpty(teamArray)){ - dynamicRow.put("", ""); - dynamicRow.put(" ", ""); - dynamicRow.put(" ", ""); - dynamicRow.put(" ", ""); - dynamicRow.put(" ", ""); - dynamicRow.put(" ", ""); + buildDTO.setTableLine(1); + dynamicRow.put("第1列", buildDTO); + buildDTO.setTableLine(2); + dynamicRow.put("第2列", buildDTO); + buildDTO.setTableLine(3); + dynamicRow.put("第3列", buildDTO); + buildDTO.setTableLine(4); + dynamicRow.put("第4列", buildDTO); + buildDTO.setTableLine(5); + dynamicRow.put("第5列", buildDTO); + buildDTO.setTableLine(6); + dynamicRow.put("第6列", buildDTO); + }else{ for(String team : teamArray){ List result = list.stream() @@ -402,32 +416,40 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi .collect(Collectors.toList()); // 收集结果 if(!CollectionUtils.isEmpty(result)){ if(StringUtils.isNotBlank(result.get(0).getCheckResult())){ - dynamicRow.put(team, result.get(0).getCheckResult()); + result.get(0).setWhetherOpenLine( result.get(0).getBz().equals("1") ? true : false); + dynamicRow.put(team, result.get(0)); }else{ - dynamicRow.put(team, ""); + result.get(0).setWhetherOpenLine( result.get(0).getBz().equals("1") ? true : false); + dynamicRow.put(team, result.get(0)); } }else{ - dynamicRow.put(team, ""); + dynamicRow.put(team, buildDTO); } } } if(teamArray.size() < 6){ - for(int i = 0 ; i < 6-(teamArray.size()) ; i++){ + for(int i = 0 ; i < 6 - (teamArray.size()) ; i++){ + if(i == 0){ - dynamicRow.put("", ""); + buildDTO.setTableLine(teamArray.size() + 1); + dynamicRow.put("第"+ (teamArray.size()+1)+"列", buildDTO); }else if(i == 1){ - dynamicRow.put(" ", ""); + buildDTO.setTableLine(teamArray.size() + 2); + dynamicRow.put("第"+(teamArray.size()+2)+"列", buildDTO); }else if(i == 2){ - dynamicRow.put(" ", ""); + buildDTO.setTableLine(teamArray.size() + 3); + dynamicRow.put("第"+(teamArray.size()+3)+"列", buildDTO); }else if(i == 3){ - dynamicRow.put(" ", ""); + buildDTO.setTableLine(teamArray.size() + 4); + dynamicRow.put("第"+(teamArray.size()+4)+"列", buildDTO); }else if(i == 4){ - dynamicRow.put(" ", ""); + buildDTO.setTableLine(teamArray.size() + 5); + dynamicRow.put("第"+(teamArray.size()+5)+"列", buildDTO); }else if(i == 5){ - dynamicRow.put(" ", ""); + buildDTO.setTableLine(teamArray.size() + 6); + dynamicRow.put("第"+(teamArray.size() + 6)+"列", buildDTO); } - } } @@ -440,101 +462,74 @@ public class MesInspectionReportServiceImpl implements IMesInspectionReportServi return listDTO; } - //点检上半部分数据 @Override @DS("#header.poolName") - public List selectCheckBoxList(MesInspectionReport mesInspectionReport) { - List listDTO = new ArrayList<>(); - //1.报表名 - mesInspectionReport.setReportName("CheckReport"); - List lists = mesInspectionReportMapper.selectCheckBoxList(mesInspectionReport); - - Map> dynamicRow1 = new LinkedHashMap<>(); - Map dynamicRow2 = new LinkedHashMap<>(); - String str = "str"; - int i = 0; - for(MesInspectionReport list :lists){ - Map dynamicRow10 = new LinkedHashMap<>(); - if(list.getBz().equals("1")){ - dynamicRow10.put("openLine",Boolean.TRUE); - dynamicRow10.put("clearLine",Boolean.FALSE); - dynamicRow1.put(str + i + "",dynamicRow10); - }else{ - dynamicRow10.put("clearLine",Boolean.TRUE); - dynamicRow10.put("openLine",Boolean.FALSE); - dynamicRow1.put(str + i + "",dynamicRow10); - } + //修改表头部和表尾部 + public AjaxResult updatePointInspectionTable(MesInspectionReport mesInspectionReport) { + mesInspectionReport.setUpdateBy(SecurityContextHolder.getUserName()); + mesInspectionReport.setUpdateTime(DateUtils.getNowDate()); + mesInspectionReportMapper.updateHeaderFooter(mesInspectionReport);//修改主表 - dynamicRow2.put(str + i + "","班次:" + list.getRemark()); - i++; - } - if(lists == null){ - Map dynamicRow10 = new LinkedHashMap<>(); - dynamicRow10.put("openLine",Boolean.FALSE); - dynamicRow10.put("clearLine",Boolean.FALSE); - dynamicRow1.put(str + 0 + "", dynamicRow10); - dynamicRow1.put(str + 1 + "", dynamicRow10); - dynamicRow1.put(str + 2 + "", dynamicRow10); - dynamicRow1.put(str + 3 + "", dynamicRow10); - dynamicRow1.put(str + 4 + "", dynamicRow10); - dynamicRow1.put(str + 5 + "", dynamicRow10); - - dynamicRow2.put(str + 0 + "", "班次:"); - dynamicRow2.put(str + 1 + "", "班次:"); - dynamicRow2.put(str + 2 + "", "班次:"); - dynamicRow2.put(str + 3 + "", "班次:"); - dynamicRow2.put(str + 4 + "", "班次:"); - dynamicRow2.put(str + 5 + "", "班次:"); - } + //需要新增的 + List addList = new ArrayList<>(); + //需要修改的 + List updateList = new ArrayList<>(); + ArrayList>> tableData = mesInspectionReport.getTableData(); + if (tableData!= null) { + for (LinkedHashMap> item : tableData) { + //提取出来开始结束那一行数据的 项目名字 + String infoName = (String) item.get("点检内容").get("data"); - if(dynamicRow1.size() < 6){ - for(int j = 0 ; j < 6-(lists.size()) ; j++){ - Map dynamicRow10 = new LinkedHashMap<>(); - dynamicRow10.put("openLine",Boolean.FALSE); - dynamicRow10.put("clearLine",Boolean.FALSE); - if(j == 0){ - dynamicRow1.put(str + 5 +"", dynamicRow10); - }else if(j == 1){ - dynamicRow1.put(str + 4 +"", dynamicRow10); - }else if(j == 2){ - dynamicRow1.put(str + 3 +"", dynamicRow10); - }else if(j == 3){ - dynamicRow1.put(str + 2 +"", dynamicRow10); - }else if(j == 4){ - dynamicRow1.put(str + 1 +"", dynamicRow10); - }else if(j == 5){ - dynamicRow1.put(str + 0 +"", dynamicRow10); + for (Map.Entry> entry : item.entrySet()) { + if(!entry.getKey().equals("序号") && !entry.getKey().equals("点检内容") && !entry.getKey().equals("点检项目")){ + LinkedHashMap innerMap = entry.getValue(); + + String id = (String) innerMap.get("id"); + String checkResult = (String) innerMap.get("checkResult"); + Boolean whetherOpenLine = (Boolean) innerMap.get("whetherOpenLine"); + String remark = (String) innerMap.get("remark"); + String belongTo = (String) innerMap.get("belongTo"); + Integer tableLine = (Integer) innerMap.get("tableLine"); + + if(StringUtils.isNotBlank(id) && StringUtils.isNotBlank(checkResult)){ + MesInspectionReport updateDto = new MesInspectionReport(); + updateDto.setId(id); + updateDto.setUpdateBy(SecurityContextHolder.getUserName()); + updateDto.setUpdateTime(DateUtils.getNowDate()); + updateDto.setCheckResult(checkResult); + updateDto.setBz(whetherOpenLine == true ? "1": "0"); + updateDto.setRemark(remark); + updateList.add(updateDto); + }else if(StringUtils.isBlank(id) && StringUtils.isNotBlank(checkResult)){ + MesInspectionReport addDto = new MesInspectionReport(); + addDto.setId(IdUtils.fastSimpleUUID()); + addDto.setBelongTo(StringUtils.isNotBlank(belongTo)? belongTo: mesInspectionReport.getId()); + addDto.setCreateBy(SecurityContextHolder.getUserName()); + addDto.setCreateTime(DateUtils.getNowDate()); + addDto.setUpdateBy(SecurityContextHolder.getUserName()); + addDto.setUpdateTime(DateUtils.getNowDate()); + addDto.setCheckResult(checkResult); + addDto.setBz(whetherOpenLine == true ? "1": "0"); + addDto.setDelFlag("0"); + addDto.setRemark(remark); + addDto.setInfoName(infoName); + addDto.setTableLine(tableLine); + addList.add(addDto); + } } } } + } - if(dynamicRow2.size() < 6){ - for(int j = 0 ; j < 6-(lists.size()) ; j++){ - if(j == 0){ - dynamicRow2.put(str + 5 +"", "班次:"); - }else if(j == 1){ - dynamicRow2.put(str + 4 +"", "班次:"); - }else if(j == 2){ - dynamicRow2.put(str + 3 +"", "班次:"); - }else if(j == 3){ - dynamicRow2.put(str + 2 +"", "班次:"); - }else if(j == 4){ - dynamicRow2.put(str + 1 +"", "班次:"); - }else if(j == 5){ - dynamicRow2.put(str + 0 +"", "班次:"); - } - } + //更新表的主体部分 也就是数据库的子表 + if(updateList.size() > 0 ){ + mesInspectionReportMapper.updateBatch(updateList); } - String s1 = JSON.toJSONString(dynamicRow1); - String s2 = JSON.toJSONString(dynamicRow2); - JSONObject object1 = JSONObject.parseObject(s1, Feature.OrderedField); - JSONObject object2 = JSONObject.parseObject(s2, Feature.OrderedField); - log.info("点检动态添加属性: = {}",object1); - log.info("点检动态添加属性: = {}",object2); - listDTO.add(object1); - listDTO.add(object2); - log.info("点检动态添加属性: = {}", JSON.toJSONString(listDTO)); - return listDTO; + if(addList.size() >0){ + mesInspectionReportMapper.addBatch(addList); + } + + return AjaxResult.success(); } } 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 78c7d3c6..59f86ccc 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 @@ -57,7 +57,8 @@ mtsd.remark from mes_table_self mts left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to - where mts.id = #{id} + where 1 = 1 + and mts.id = #{id} and mtsd.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' - -