package com.example.erp.service.pp; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.baomidou.dynamic.datasource.annotation.DS; import com.example.erp.common.AsyncQueryExecutor; import com.example.erp.entity.sd.*; import com.example.erp.tools.AreaComputed.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.example.erp.dto.pp.*; import com.example.erp.entity.pp.DamageDetails; import com.example.erp.entity.pp.Report; import com.example.erp.mapper.pp.*; import com.example.erp.mapper.sd.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import javax.annotation.PreDestroy; import javax.annotation.Resource; import java.lang.reflect.Field; import java.math.BigDecimal; import java.sql.Date; import java.sql.SQLOutput; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.*; import java.util.function.Function; import java.util.stream.Collectors; import static cn.hutool.core.convert.Convert.toDouble; import static com.example.erp.tools.AreaComputed.computeArea; @Service @DS("pp") public class ReportService { private final ReportMapper reportMapper; private final OrderProcessDetailMapper orderProcessDetailMapper; private final ProductionSchedulingMapper productionSchedulingMapper; private final OrderGlassDetailMapper orderGlassDetailMapper; private final BasicDataMapper basicDataMapper; private final ProductDetailMapper productDetailMapper; private final OrderDetailMapper orderDetailMapper; private final DamageDetailsMapper damageDetailsMapper; FlowCardMapper flowCardMapper; private ReportingWorkMapper reportingWorkMapper; private final OrderMapper orderMapper; @Resource private AsyncQueryExecutor asyncExecutor; //上工序报工班组 private void mergeTeamsGroupsName( List dataList1,List dataList2) { for (WorkInProgressDTO dto1 : dataList1) { //根据当前工序获取 是否为单片、夹胶、或者全部 BasicData basicData = basicDataMapper. selectOne(new QueryWrapper() .eq("basic_name", dto1.getThisProcess()) .last("limit 1") ); OrderDetail orderDetail = orderDetailMapper .selectOne( new QueryWrapper() .eq("order_id", dto1.getOrderId()) .eq("order_number", dto1.getOrderNumber()) ); //如果为单片,则根据产品名称和工艺编号获取玻璃名称 if(basicData.getNickname()==null || basicData.getNickname().isEmpty()){ ProductDetail productDetail = productDetailMapper. selectOne(new QueryWrapper() .eq("prod_id", orderDetail.getProductId()) .eq("glass_sort",dto1.getTechnologyNumber()) ); if(productDetail!=null){ dto1.setGlassName(productDetail.getDetail()); } //basicData.getNickname().equals("stepC") }else if(basicData.getNickname().equals("stepC")){ OrderGlassDetail orderGlassDetailGroup = orderGlassDetailMapper .selectOne(new QueryWrapper() .eq("order_id", dto1.getOrderId()) .eq("order_number", dto1.getOrderNumber()) .eq("technology_number",dto1.getTechnologyNumber()) ); String glassName = productDetailMapper.getGlassNameByGroup( orderDetail.getProductId(), orderGlassDetailMapper.getMinTechnologyNumberByGroup(dto1.getOrderId(),dto1.getOrderNumber(), String.valueOf(orderGlassDetailGroup.getGroup())), orderGlassDetailMapper.getMaxTechnologyNumberByGroup(dto1.getOrderId(),dto1.getOrderNumber(), String.valueOf(orderGlassDetailGroup.getGroup())) ); dto1.setGlassName(glassName); }else{ dto1.setGlassName(dto1.getProductName()); } } Function keyFn = dto -> dto.getProcessId() + "|" + dto.getOrderNumber() + "|" + dto.getTechnologyNumber(); Map map2 = dataList2.stream() .collect(Collectors.toMap( keyFn, Function.identity(), (existing, replacement) -> existing )); for (WorkInProgressDTO dto1 : dataList1) { WorkInProgressDTO dto2 = map2.get(keyFn.apply(dto1)); if (dto2 != null) { String tgn = dto2.getTeamsGroupsName(); if (StringUtils.hasText(tgn)) { dto1.setTeamsGroupsName(tgn); } } } } public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper, ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper, ReportingWorkMapper reportingWorkMapper, DamageDetailsMapper damageDetailsMapper, OrderMapper orderMapper) { this.reportMapper = reportMapper; this.orderProcessDetailMapper = orderProcessDetailMapper; this.productionSchedulingMapper = productionSchedulingMapper; this.flowCardMapper = flowCardMapper; this.orderGlassDetailMapper = orderGlassDetailMapper; this.basicDataMapper = basicDataMapper; this.productDetailMapper = productDetailMapper; this.orderDetailMapper = orderDetailMapper; this.reportingWorkMapper = reportingWorkMapper; this.damageDetailsMapper = damageDetailsMapper; this.orderMapper = orderMapper; } //流程卡进度方法 public Map processCardProgressSv(String orderId, List columns) { Map map = new HashMap<>(); //获取表格内容数据 List> dataList = reportMapper.processCardProgressMp(orderId); //获取表头工序筛选数据 List> uniqueList = orderProcessDetailMapper.filterOrderProcess(orderId); map.put("title", uniqueList); Map clos = new HashMap<>(); HashMap>> rowCount = new HashMap>>(); for (int i=0;i() .eq("basic_category","process") .eq("basic_name",uniqueList.get(i).get("process")) .last("limit 1") ); //判断夹胶和夹胶后工序 //Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC") if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){ clos.put(uniqueList.get(i).get("process"), 14+i); } //判断中空和中空后工序 //Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD") if(Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")){ columns.add("reportWorkQuantity."+uniqueList.get(i).get("process")); } } List> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); HashMap> getRowCountMap = new HashMap<>(); getRowCount.forEach(col -> { Integer getRowCountOrderNumber = ((Number) col.get("order_number")).intValue(); getRowCountMap.put(getRowCountOrderNumber, col); }); //循环结果 for (int i=0;i { if(rowCount.get(col) == null){ rowCount.put(col, new HashMap>()); } if(getRowCountMap.get(orderNumber) != null){ Map row = getRowCountMap.get(orderNumber); Map getRow = new HashMap<>(); //判断当前此次 是否为第一行 并且相同序号 if(technologyNumber==1){ getRow.put("rowspan", ((Number) row.get("rowCount")).intValue()); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); } rowCount.get(col).put(finalI1+"_"+col, getRow); } }); Map data = JSON.parseObject(dataList.get(i).get("reportWorkQuantity"), new TypeReference>() { }); Map dataShow = JSON.parseObject(dataList.get(i).get("reportWorkQuantityShow"), new TypeReference>() { }); //判断后工序此流程卡号是否有次破 List hasBreak = damageDetailsMapper .getNotReview(dataList.get(i).get("processId"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("technology_number")) ); if(!hasBreak.isEmpty()){ int finalI = i; data.forEach((thisProcess, index)->{ String behindProcess = orderProcessDetailMapper.getBehindProcess( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), thisProcess, orderId ); if(behindProcess!=null &&!behindProcess.isEmpty()){ Integer behindDamageSum = damageDetailsMapper.getBehindDamageSum( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), behindProcess,1 ); if(behindDamageSum>0){ data.put(thisProcess, String.valueOf(Integer.parseInt(data.get(thisProcess) )- behindDamageSum)); dataShow.put(thisProcess, String.valueOf(Integer.parseInt(dataShow.get(thisProcess) )- behindDamageSum)); } } }); } //夹胶工序判断合并行数 if(!clos.isEmpty()){ Integer max = orderGlassDetailMapper .getMaxTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); Integer min = orderGlassDetailMapper .getMinTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); for (String key : clos.keySet()) { if(data.get(key) != null){ if (rowCount.get("reportWorkQuantity."+key)==null){ rowCount.put("reportWorkQuantity."+key, new HashMap>()); } Map getRow = new HashMap<>(); if(min == Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) ){ // { row: 0, col: 1, rowspan: 3, colspan: 0}, //getRow.put("row", i ); getRow.put("rowspan", max-min+1); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); data.put(key,"0"); } rowCount.get("reportWorkQuantity."+key).put(i+"_reportWorkQuantity."+key, getRow); } } } dataList.get(i).put("reportWorkQuantity",JSON.toJSONString(data)); dataList.get(i).put("reportWorkQuantityShow",JSON.toJSONString(dataShow)); } map.put("data",dataList ); map.put("mergeCells", rowCount); return map; } // public Map crossProcessBreakingSv(Integer pageNum, Integer pageSize, List selectDate, CrossProcessBreakingDTO crossProcessBreakingDTO) { // Integer offset = (pageNum - 1) * pageSize; // String endDate = LocalDate.now().toString(); // String startDate = LocalDate.now().minusDays(15).toString(); // if (selectDate != null && selectDate.size() == 2) { // if (!selectDate.get(0).isEmpty()) { // startDate = selectDate.get(0); // } // if (!selectDate.get(1).isEmpty()) { // endDate = selectDate.get(1); // } // } // Map map = new HashMap<>(); // map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); // map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, crossProcessBreakingDTO)); // List list = new ArrayList<>(); // list.add(startDate); // list.add(endDate); // map.put("selectDate", list); // return map; // } private static final DateTimeFormatter DATE_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private String toReportTime(String dateStr, String reportTime) { if (dateStr == null || dateStr.isEmpty()) { return null; } // 只保留 yyyy-MM-dd,防止前端传完整时间导致 parse 异常 String onlyDate = dateStr.length() > 10 ? dateStr.substring(0, 10) : dateStr; String[] parts = reportTime.split(":"); int hour = Integer.parseInt(parts[0]); int minute = parts.length > 1 ? Integer.parseInt(parts[1]) : 0; int second = parts.length > 2 ? Integer.parseInt(parts[2]) : 0; LocalDate date = LocalDate.parse(onlyDate); LocalTime time = LocalTime.of(hour, minute, second); return LocalDateTime.of(date, time).format(DATE_TIME_FMT); } //跨工序次破 public Map crossProcessBreakingSv(Integer pageNum, Integer pageSize, List selectDate, String reportTime, CrossProcessBreakingDTO crossProcessBreakingDTO) { Integer offset = (pageNum - 1) * pageSize; // 默认时间范围:过去 15 天(日期 + reportTime) String startDate = toReportTime(LocalDate.now().minusDays(15).toString(), reportTime); String endDate = toReportTime(LocalDate.now().toString(), reportTime); // 如果前端传了时间,就用前端日期 + reportTime if (selectDate != null && selectDate.size() == 2) { if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) { startDate = toReportTime(selectDate.get(0), reportTime); } if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { endDate = toReportTime(selectDate.get(1), reportTime); } } Map result = new HashMap<>(); // 使用异步线程池 String finalEndDate = endDate; String finalStartDate = startDate; CompletableFuture> dataFuture = asyncExecutor.runAsync(() -> reportMapper.getProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); CompletableFuture> totalFuture = asyncExecutor.runAsync(() -> reportMapper.getProcessBreakingTotal(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); // 等待两个任务执行完毕 CompletableFuture.allOf(dataFuture, totalFuture).join(); try { result.put("data", dataFuture.get()); result.put("total", totalFuture.get()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("并行查询异常:" + e.getMessage(), e); } List list = new ArrayList<>(); list.add(startDate); list.add(endDate); result.put("selectDate", list); return result; } //非跨工序次破 public Map notCrossProcessBreakingSv(Integer pageNum, Integer pageSize, List selectDate, String reportTime, CrossProcessBreakingDTO crossProcessBreakingDTO) { Integer offset = (pageNum - 1) * pageSize; // 默认时间范围:过去 15 天(日期 + reportTime) String startDate = toReportTime(LocalDate.now().minusDays(15).toString(), reportTime); String endDate = toReportTime(LocalDate.now().toString(), reportTime); // 如果前端传了时间,就用前端日期 + reportTime if (selectDate != null && selectDate.size() == 2) { if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) { startDate = toReportTime(selectDate.get(0), reportTime); } if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { endDate = toReportTime(selectDate.get(1), reportTime); } } Map result = new HashMap<>(); // 使用异步线程池 String finalEndDate = endDate; String finalStartDate = startDate; CompletableFuture> dataFuture = asyncExecutor.runAsync(() -> reportMapper.getNotProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); CompletableFuture> totalFuture = asyncExecutor.runAsync(() -> reportMapper.getNotProcessBreakingTotal(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); // 等待两个任务执行完毕 CompletableFuture.allOf(dataFuture, totalFuture).join(); try { result.put("data", dataFuture.get()); result.put("total", totalFuture.get()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("并行查询异常:" + e.getMessage(), e); } List list = new ArrayList<>(); list.add(startDate); list.add(endDate); result.put("selectDate", list); return result; } // public Map workInProgressSv(Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) { // Integer offset = (pageNum - 1) * pageSize; // if ("null".equals(orderId)) { // orderId = ""; // } // if ("null".equals(inputProject)) { // inputProject = ""; // } // if ("null".equals(optionVal)) { // optionVal = (""); // } // if (selectProcesses.equals("all")){ // selectProcesses=""; // } // String laminating = reportMapper.getLaminating(selectProcesses); // Map map = new HashMap<>(); // List dataList2 =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); // if (optionVal.equals("1")){ // /* 根据销售单号汇总*/ // List dataList1 =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); // mergeTeamsGroupsName(dataList1, dataList2); // map.put("data",dataList1); // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); // }else if(optionVal.equals("2")){ // /* 根据流程卡号汇总*/ // List dataList1 =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO); // mergeTeamsGroupsName(dataList1, dataList2); // map.put("data",dataList1); // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); // // } else if (optionVal.equals("3")) { // // } else { // //没有选择分组 // List dataList1 =reportMapper.workInProgressMpdataList1(offset, pageSize, orderId, inputProject, selectProcesses,laminating, workInProgressDTO); // mergeTeamsGroupsName(dataList1, dataList2); // map.put("data",dataList1); // map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO)); // // } // map.put("process", productionSchedulingMapper.selectProcess()); // return map; // } public Map workInProgressSv( Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal,String terminationVals, WorkInProgressDTO workInProgressDTO) { Integer offset = (pageNum - 1) * pageSize; if ("null".equals(orderId)) orderId = ""; if ("null".equals(inputProject)) inputProject = ""; if ("null".equals(optionVal)) optionVal = ""; if ("null".equals(terminationVals)) terminationVals = ""; if ("all".equals(selectProcesses)) selectProcesses = ""; String laminating = reportMapper.getLaminating(selectProcesses); Map result = new HashMap<>(); try { // dataList2 是所有分组下的基础数据,独立执行 String finalOrderId = orderId; String finalInputProject = inputProject; String finalSelectProcesses = selectProcesses; String finalTerminationVals = terminationVals; CompletableFuture> dataList2Future = asyncExecutor.runAsync(() -> reportMapper.workInProgressMpdataList2( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); CompletableFuture> dataList1Future; CompletableFuture> totalFuture; // 根据 optionVal 决定查询类型 if ("1".equals(optionVal)) { // 销售单号汇总 dataList1Future = asyncExecutor.runAsync(() -> reportMapper.workInProgressOrderMpList1( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); totalFuture = asyncExecutor.runAsync(() -> reportMapper.workInProgressOrderFootSum( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses,finalTerminationVals, workInProgressDTO)); } else if ("2".equals(optionVal)) { // 流程卡号汇总 dataList1Future = asyncExecutor.runAsync(() -> reportMapper.workInProgressProcessMpList1( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, workInProgressDTO)); totalFuture = asyncExecutor.runAsync(() -> reportMapper.workInProgressOrderFootSum( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses,finalTerminationVals, workInProgressDTO)); } else if ("3".equals(optionVal)) { dataList1Future = asyncExecutor.runAsync(() -> reportMapper.workInProgressMpdataList1( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, laminating,finalTerminationVals, workInProgressDTO)); totalFuture = asyncExecutor.runAsync(() -> reportMapper.workInProgressOrderFootSum( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses,finalTerminationVals, workInProgressDTO)); } else { // 不分组 dataList1Future = asyncExecutor.runAsync(() -> reportMapper.workInProgressMpdataList1( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses, laminating,finalTerminationVals, workInProgressDTO)); totalFuture = asyncExecutor.runAsync(() -> reportMapper.workInProgressOrderFootSum( offset, pageSize, finalOrderId, finalInputProject, finalSelectProcesses,finalTerminationVals, workInProgressDTO)); } // 等待全部任务完成 CompletableFuture.allOf(dataList1Future, dataList2Future, totalFuture).join(); List dataList1 = dataList1Future.get(); List dataList2 = dataList2Future.get(); mergeTeamsGroupsName(dataList1, dataList2); result.put("data", dataList1); result.put("total", totalFuture.get()); // 并行查询工序信息 List> process = productionSchedulingMapper.selectProcess(); result.put("process", process); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("并行查询在制品信息异常:" + e.getMessage(), e); } return result; } public Map selectProcessToBeCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) { if ("null".equals(orderId)) { orderId = ""; } if ("null".equals(inputProject)) { inputProject = ""; } Map map = new HashMap<>(); map.put("data", reportMapper.processToBeCompletedMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report)); map.put("process", productionSchedulingMapper.selectProcess()); map.put("footSum" ,reportMapper.processToBeCompletedFootSum(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report)); return map; } // public Map selectDamageReportSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, DamageReportDTO damageReportDTO) { // Integer offset = (pageNum - 1) * pageSize; // Map map = new HashMap<>(); // map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); // map.put("total", reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); // map.put("footSum" ,reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO)); // return map; // } public Map selectDamageReportSv(Integer pageNum, Integer pageSize, List selectDate, String reportTime, DamageReportDTO damageReportDTO) { Integer offset = (pageNum - 1) * pageSize; // 默认时间范围:过去 15 天(日期 + reportTime) String startDate = toReportTime(LocalDate.now().minusDays(15).toString(), reportTime); String endDate = toReportTime(LocalDate.now().toString(), reportTime); // 如果前端传了时间,就用前端日期 + reportTime if (selectDate != null && selectDate.size() == 2) { if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) { startDate = toReportTime(selectDate.get(0), reportTime); } if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { endDate = toReportTime(selectDate.get(1), reportTime); } } Map result = new HashMap<>(); String finalStartDate = startDate; String finalEndDate = endDate; // 异步任务定义 CompletableFuture> dataFuture = asyncExecutor.runAsync(() -> reportMapper.selectDamageReportMp(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO)); CompletableFuture> totalFuture = asyncExecutor.runAsync(() -> reportMapper.getDamageReportPageTotal(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO)); CompletableFuture> footSumFuture = asyncExecutor.runAsync(() -> reportMapper.damageReportFootSum(finalStartDate, finalEndDate, damageReportDTO)); // 等待全部任务完成 CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join(); try { result.put("data", dataFuture.get()); result.put("total", totalFuture.get()); result.put("footSum", footSumFuture.get()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("次破总表并行查询异常:" + e.getMessage(), e); } // 回传前端的时间(现在是带时分秒的) List list = new ArrayList<>(); list.add(startDate); list.add(endDate); result.put("selectDate", list); return result; } public Map splittingDetailsOutsideSv(String orderId, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.splittingDetailsOutsideMp(orderId, report)); map.put("orderOtherMoney", flowCardMapper.selectorderOtherMoney()); return map; } public Map qualityReportSv(Date selectTime1, Date selectTime2, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.qualityReportMp(selectTime1, selectTime2, report)); return map; } public Map yieldSv(String selectTime1, String selectTime2, String selectProcesses, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.yieldMp(selectTime1, selectTime2, selectProcesses, report)); map.put("process", productionSchedulingMapper.selectProcess()); return map; } public Map productionScheduleSv(String orderId, List columns) { Map map = new HashMap<>(); //获取表格内容数据 List> dataList = reportMapper.productionScheduleMp(orderId); //获取表头工序筛选数据 List> uniqueList = orderProcessDetailMapper.filterOrderProcess(orderId); map.put("title", uniqueList); Map clos = new HashMap<>(); HashMap>> rowCount = new HashMap>>(); for (int i=0;i() .eq("basic_category","process") .eq("basic_name",uniqueList.get(i).get("process")) .last("limit 1") ); //判断夹胶和夹胶后工序 //Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC") if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){ clos.put(uniqueList.get(i).get("process"), 14+i); } //判断中空和中空后工序 //Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD") if(Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")){ columns.add("reportWorkQuantity."+uniqueList.get(i).get("process")); } } List> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); HashMap> getRowCountMap = new HashMap<>(); getRowCount.forEach(col -> { Integer getRowCountOrderNumber = ((Number) col.get("order_number")).intValue(); getRowCountMap.put(getRowCountOrderNumber, col); }); //循环结果 for (int i=0;i { if(rowCount.get(col) == null){ rowCount.put(col, new HashMap>()); } if(getRowCountMap.get(orderNumber) != null){ Map row = getRowCountMap.get(orderNumber); Map getRow = new HashMap<>(); //判断当前此次 是否为第一行 并且相同序号 if(technologyNumber==1){ getRow.put("rowspan", ((Number) row.get("rowCount")).intValue()); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); } rowCount.get(col).put(finalI1+"_"+col, getRow); } }); Map data = JSON.parseObject(dataList.get(i).get("reportWorkQuantity"), new TypeReference>() { }); Map dataShow = JSON.parseObject(dataList.get(i).get("reportWorkQuantityShow"), new TypeReference>() { }); //判断后工序此流程卡号是否有次破 List hasBreak = damageDetailsMapper .getNotReview(dataList.get(i).get("processId"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("technology_number")) ); if(!hasBreak.isEmpty()){ int finalI = i; data.forEach((thisProcess, index)->{ String behindProcess = orderProcessDetailMapper.getBehindProcess( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), thisProcess, orderId ); if(behindProcess!=null &&!behindProcess.isEmpty()){ Integer behindDamageSum = damageDetailsMapper.getBehindDamageSum( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), behindProcess,1 ); if(behindDamageSum>0){ data.put(thisProcess, String.valueOf(Integer.parseInt(data.get(thisProcess) )- behindDamageSum)); dataShow.put(thisProcess, String.valueOf(Integer.parseInt(dataShow.get(thisProcess) )- behindDamageSum)); } } }); } //夹胶工序判断合并行数 if(!clos.isEmpty()){ Integer max = orderGlassDetailMapper .getMaxTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); Integer min = orderGlassDetailMapper .getMinTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); for (String key : clos.keySet()) { if(data.get(key) != null){ if (rowCount.get("reportWorkQuantity."+key)==null){ rowCount.put("reportWorkQuantity."+key, new HashMap>()); } Map getRow = new HashMap<>(); if(min == Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) ){ // { row: 0, col: 1, rowspan: 3, colspan: 0}, //getRow.put("row", i ); getRow.put("rowspan", max-min+1); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); data.put(key,"0"); } rowCount.get("reportWorkQuantity."+key).put(i+"_reportWorkQuantity."+key, getRow); } } } dataList.get(i).put("reportWorkQuantity",JSON.toJSONString(data)); dataList.get(i).put("reportWorkQuantityShow",JSON.toJSONString(dataShow)); } map.put("data",dataList ); map.put("mergeCells", rowCount); return map; } public Map taskCompletionStatusSv(Date selectTime1, Date selectTime2, String orderId, List columns) { if ("null".equals(orderId)) { orderId = ""; } Map map = new HashMap<>(); //获取表格内容数据 map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2,orderId)); //获取表头工序筛选数据 List> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2,orderId); List> processList = processFilterList; List filterList = new ArrayList<>(); //循环遍历数组,判断此序号当前的工序 for (int i = 1; i < processFilterList.size(); i++) { filterList.add(processFilterList.get(i).get("process")); List> lastProcessList = orderProcessDetailMapper.filterLastProcess( String.valueOf(processFilterList.get(i).get("order_id")), String.valueOf(processFilterList.get(i).get("order_number")), String.valueOf(processFilterList.get(i).get("technology_number")), String.valueOf(processFilterList.get(i).get("id")) ); if (!lastProcessList.isEmpty()) { int finalI = i; lastProcessList.forEach(lastProcess -> { if (filterList.contains(lastProcess.get("process"))) { processList.add(lastProcess); } }); } } // 使用HashSet来记录已经遇到的value值 Set seenValues = new HashSet<>(); // 创建一个新的List来存储结果 List> uniqueList = new ArrayList<>(); // 反向遍历原始List for (int i = processList.size() - 1; i >= 0; i--) { Map maps = processList.get(i); String value = maps.values().iterator().next(); // 假设每个Map只有一个value // 如果value还没有被看到过,就添加到结果List和HashSet中 if (!seenValues.contains(value)) { uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序 seenValues.add(value); } } map.put("title", uniqueList); List> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2,orderId); List> rowCount = new ArrayList<>(); columns.forEach(col -> { getRowCount.forEach(row -> { Map getRow = new HashMap<>(); // { row: 0, col: 1, rowspan: 3, colspan: 0}, Object rowNumObj = row.get("RowNum"); if (rowNumObj instanceof Double) { getRow.put("row", ((Double) rowNumObj).intValue()); } else if (rowNumObj instanceof Integer) { getRow.put("row", (Integer) rowNumObj); } getRow.put("col", col); getRow.put("rowspan", row.get("rowCount")); getRow.put("colspan", 0); rowCount.add(getRow); }); }); map.put("mergeCells", rowCount); return map; } public Map orderPlanDecompositionSv(Date selectTime1, Date selectTime2, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.orderPlanDecompositionMp(selectTime1, selectTime2, report)); return map; } public Map orderReportingWorks(Date selectTime1, Date selectTime2, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.orderReportingWorks(selectTime1, selectTime2, report)); return map; } public Map rawMaterialRequisitionSv(Date selectTime1, Date selectTime2, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.rawMaterialRequisitionMp(selectTime1, selectTime2, report)); return map; } public List exportCrossProcessBreakingSv(List dates) { return reportMapper.exportCrossProcessBreakingMp(dates); } public List exportNotCrossProcessBreakingSv(List dates) { return reportMapper.exportNotCrossProcessBreakingMp(dates); } // public List exportTeamOutputSv(Map dates) { // List date= (List) dates.get("date"); // String process= (String) dates.get("processes"); // if (process.equals("全部")){ // process=""; // } // String laminating = reportMapper.getLaminating(process); // return reportMapper.exportTeamOutputMp(date,process,laminating); // } public List exportDamageReportSv(Map dates) { List date= (List) dates.get("date"); return reportMapper.exportDamageReportMp(date); } public List exportOrderPlanDecompositionSv(List dates) { return reportMapper.exportOrderPlanDecompositionMp(dates); } public List exportProcessToBeCompletedSv(Map dates) { List date= (List) dates.get("date"); String process= (String) dates.get("processes"); String inputVal= (String) dates.get("inputVal"); String project= (String) dates.get("project"); if ("null".equals(inputVal)) { inputVal = ""; } if ("null".equals(project)) { project = ""; } return reportMapper.exportProcessToBeCompletedMp(date,process,inputVal,project); } public List exportWorkInProgressSv(Map dates) { String process= (String) dates.get("processes"); if (process.equals("all")){ process=""; } String inputVal= (String) dates.get("inputVal"); String project= (String) dates.get("project"); String terminationVals= dates.get("terminationVals").toString();; if (inputVal==null) { inputVal = ""; } if (project==null) { project = ""; } if (terminationVals==null) { terminationVals = ""; } List dataList1 =reportMapper.exportWorkInProgressMp(process,inputVal,project,terminationVals); List dataList2 =reportMapper.exportWorkInProgressMpdataList2(process); mergeTeamsGroupsName(dataList1, dataList2); return dataList1; } public List exportTaskCompletionStatusSv(Map dates) { return reportMapper.exportTaskCompletionStatusMp(dates); } public List exportRawMaterialRequisitionSv(List dates) { return reportMapper.exportRawMaterialRequisitionMp(dates); } public List exportQualityReportSv(List dates) { return reportMapper.exportQualityReportSv(dates); } public List exportYieldSv(Map dates) { List date= (List) dates.get("date"); String process= (String) dates.get("processes"); return reportMapper.exportYieldMp(date,process); } // public Map teamOutputSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) { // if (selectProcesses.equals("all")){ // selectProcesses=""; // } // Integer offset = (pageNum - 1) * pageSize; // Map map = new HashMap<>(); // String laminating = reportMapper.getLaminating(selectProcesses); // // map.put("data", reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO)); // map.put("process", productionSchedulingMapper.selectProcess()); // map.put("total", reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO)); // map.put("footSum" ,reportMapper.teamOutputFootSum(selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO)); // return map; // } public Map teamOutputSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) { if ("all".equals(selectProcesses)) { selectProcesses = ""; } Integer offset = (pageNum - 1) * pageSize; Map result = new HashMap<>(); String laminating = reportMapper.getLaminating(selectProcesses); String finalSelectProcesses = selectProcesses; CompletableFuture> dataFuture = asyncExecutor.runAsync(() -> reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); CompletableFuture>> processFuture = asyncExecutor.runAsync(() -> productionSchedulingMapper.selectProcess()); CompletableFuture> totalFuture = asyncExecutor.runAsync(() -> reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); CompletableFuture> footSumFuture = asyncExecutor.runAsync(() -> reportMapper.teamOutputFootSum(selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO)); // 等待所有任务完成 CompletableFuture.allOf(dataFuture, processFuture, totalFuture, footSumFuture).join(); try { result.put("data", dataFuture.get()); result.put("process", processFuture.get()); result.put("total", totalFuture.get()); result.put("footSum", footSumFuture.get()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("并行查询异常:" + e.getMessage(), e); } return result; } public Map scheduleProductionScheduleSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String processes, ScheduleProductionScheduleDTO scheduleProductionScheduleDTO) { Integer offset = (pageNum - 1) * pageSize; Map map = new HashMap<>(); map.put("data", reportMapper.scheduleProductionScheduleMp(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO)); map.put("total", reportMapper.getScheduleProductionScheduleTotal(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO)); map.put("process", productionSchedulingMapper.selectProcess()); return map; } public List exportScheduleReportSv(Map dates) { List date= (List) dates.get("date1"); String process= (String) dates.get("processes"); return reportMapper.exportScheduleReportMp(date,process); } public List exportTeamOutputSv(Map dates) { List date= (List) dates.get("date"); String process= (String) dates.get("processes"); if (process.equals("all")){ process=""; } String laminating = reportMapper.getLaminating(process); List list = reportMapper.exportTeamOutputMp(date, process, laminating); // 清洗每个 TeamOutputDTO 实例的 String 字段(去除前后空格) for (TeamOutputDTO dto : list) { for (Field field : dto.getClass().getDeclaredFields()) { field.setAccessible(true); try { Object value = field.get(dto); if (value instanceof String) { String trimmed = ((String) value).trim(); field.set(dto, trimmed); } } catch (IllegalAccessException e) { e.printStackTrace(); } } } return list; } public Map workInProgressCombinationProcessSv( Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) { Integer offset = (pageNum - 1) * pageSize; if ("null".equals(orderId)) { orderId = ""; } if ("null".equals(inputProject)) { inputProject = ""; } if ("null".equals(optionVal)) { optionVal = ""; } if ("all".equals(selectProcesses)) { selectProcesses = ""; } String laminating = ""; Map map = new HashMap<>(); Map totalSumMap = new HashMap<>(); double totalStockNum = 0; double totalStockArea = 0; map.put("process", productionSchedulingMapper.selectProcess()); return map; } public Map workInProgressCombinationSv( Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal,String terminationVal, WorkInProgressDTO workInProgressDTO) { Integer offset = (pageNum - 1) * pageSize; if ("null".equals(orderId)) { orderId = ""; } if ("null".equals(inputProject)) { inputProject = ""; } if ("null".equals(optionVal)) { optionVal = ""; } if ("null".equals(terminationVal)) { terminationVal = ""; } if ("all".equals(selectProcesses)) { selectProcesses = ""; } String laminating = ""; Map map = new HashMap<>(); Map totalSumMap = new HashMap<>(); double totalStockNum = 0; double totalStockArea = 0; // 获取所有工序 List processList = reportMapper.selectProcess(); // 最终数据集合 List> resultList = new ArrayList<>(); if (!"".equals(selectProcesses)) { laminating = reportingWorkMapper.getProcessLaminating(selectProcesses); List> singleResult = reportMapper.getWorkInProgressCombination(selectProcesses, laminating, optionVal,terminationVal); if (singleResult != null && !singleResult.isEmpty()) { resultList.addAll(singleResult); } Map total = reportMapper.getWorkInProgressCombinationFootSum(selectProcesses, laminating, optionVal,terminationVal); if (total != null) { BigDecimal stockNum = (BigDecimal) total.get("stockNum"); BigDecimal stockArea = (BigDecimal) total.get("stockArea"); if (stockNum != null) { totalStockNum += stockNum.doubleValue(); } if (stockArea != null) { totalStockArea += stockArea.doubleValue(); } } } else { for (String process : processList) { laminating = reportingWorkMapper.getProcessLaminating(process); List> singleResult = reportMapper.getWorkInProgressCombination(process, laminating, optionVal,terminationVal); if (singleResult != null && !singleResult.isEmpty()) { resultList.addAll(singleResult); } Map total = reportMapper.getWorkInProgressCombinationFootSum(process, laminating, optionVal,terminationVal); if (total != null) { BigDecimal stockNum = (BigDecimal) total.get("stockNum"); BigDecimal stockArea = (BigDecimal) total.get("stockArea"); if (stockNum != null) { totalStockNum += stockNum.doubleValue(); } if (stockArea != null) { totalStockArea += stockArea.doubleValue(); } } } } totalSumMap.put("stockNum", totalStockNum); totalSumMap.put("stockArea", totalStockArea); map.put("data", resultList); map.put("total", totalSumMap); map.put("process", productionSchedulingMapper.selectProcess()); return map; } public List exportWorkInProgressCombinationSv(Map dates) { String process= (String) dates.get("processes"); if (process.equals("all")){ process=""; } String inputVal= (String) dates.get("inputVal"); String project= (String) dates.get("project"); String terminationVals= dates.get("terminationVals").toString();; if (inputVal==null) { inputVal = ""; } if (project==null) { project = ""; } if (terminationVals==null) { terminationVals = ""; } String laminating = ""; // 获取所有工序 List processList = reportMapper.selectProcess(); // 最终数据集合 List resultList = new ArrayList<>(); if (!"".equals(process)) { laminating = reportingWorkMapper.getProcessLaminating(process); List singleResult = reportMapper.exportWorkInProgressCombination(process, laminating, inputVal,terminationVals); if (singleResult != null && !singleResult.isEmpty()) { resultList.addAll((Collection) singleResult); } } else { for (String processVal : processList) { laminating = reportingWorkMapper.getProcessLaminating(processVal); List singleResult = reportMapper.exportWorkInProgressCombination(processVal, laminating, inputVal,terminationVals); if (singleResult != null && !singleResult.isEmpty()) { resultList.addAll((Collection) singleResult); } } } return resultList; } public Object processCardProgressCollectSv(String orderId, List columns) { Map map = new HashMap<>(); //获取表格内容数据 List> dataList = reportMapper.processCardProgressCollectMp(orderId); //获取表头工序筛选数据 List> uniqueList = orderProcessDetailMapper.filterOrderProcess(orderId); map.put("title", uniqueList); Map> clos = new HashMap<>(); for (int i=0;i() .eq("basic_category","process") .eq("basic_name",uniqueList.get(i).get("process")) .last("limit 1") ); Map getCol = new HashMap<>(); //判断夹胶和夹胶后工序 //Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC") if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){ getCol.put("col", 11+i); getCol.put("step","stepA"); clos.put(uniqueList.get(i).get("process"), getCol); } //判断中空和中空后工序 //Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD") if(Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")){ columns.add("reportWorkQuantity."+uniqueList.get(i).get("process")); getCol.put("col", 11+i); getCol.put("step","stepB"); clos.put(uniqueList.get(i).get("process"), getCol); } } List> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); HashMap> getRowCountMap = new HashMap<>(); getRowCount.forEach(col -> { String getRowCountProcessId = String.valueOf(col.get("process_id")); getRowCountMap.put(getRowCountProcessId, col); }); HashMap>> rowCount = new HashMap>>(); //循环结果 for (int i=0;i { if(rowCount.get(col) == null){ rowCount.put(col, new HashMap>()); } if(getRowCountMap.get(processId) != null){ Map row = getRowCountMap.get(processId); Map getRow = new HashMap<>(); //判断当前此次 是否为第一行 并且相同序号 if(technologyNumber==1){ getRow.put("rowspan", ((Number) row.get("rowCount")).intValue()); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); } rowCount.get(col).put(finalI1+"_"+col, getRow); } }); dataList.get(i).put("reportWorkQuantityShow",dataList.get(i).get("reportWorkQuantity")); Map data = JSON.parseObject(dataList.get(i).get("reportWorkQuantity"), new TypeReference>() { }); Map dataShow = JSON.parseObject(dataList.get(i).get("reportWorkQuantityShow"), new TypeReference>() { }); //判断后工序此流程卡号是否有次破 List hasBreak = damageDetailsMapper .getNotReview(dataList.get(i).get("process_id"), null, String.valueOf(dataList.get(i).get("technology_number")) ); if(!hasBreak.isEmpty()){ int finalI = i; data.forEach((thisProcess, index)->{ String behindProcess = orderProcessDetailMapper.getBehindProcess( dataList.get(finalI).get("process_id"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), thisProcess, orderId ); if(behindProcess!=null &&!behindProcess.isEmpty()){ Integer behindDamageSum = damageDetailsMapper.getBehindDamageSum( dataList.get(finalI).get("process_id"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), behindProcess, null ); if(behindDamageSum>0){ data.put(thisProcess, String.valueOf(Integer.parseInt(data.get(thisProcess) )- behindDamageSum)); dataShow.put(thisProcess, String.valueOf(Integer.parseInt(dataShow.get(thisProcess) )- behindDamageSum)); } } }); } if(!clos.isEmpty()){ Integer max = orderGlassDetailMapper .getMaxTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); Integer min = orderGlassDetailMapper .getMinTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); for (String key : clos.keySet()) { if(data.get(key) != null){ //判断是夹胶工序 if( clos.get(key).get("step")=="stepA"){ if (rowCount.get("reportWorkQuantity."+key)==null){ rowCount.put("reportWorkQuantity."+key, new HashMap>()); } Map getRow = new HashMap<>(); if(min == Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) ){ getRow.put("rowspan", max-min+1); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); data.put(key,"0"); } rowCount.get("reportWorkQuantity."+key).put(i+"_reportWorkQuantity."+key, getRow); }else{//中空,中空后工序 //小片序号不是1 的时候赋值0 if(Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) !=1){ data.put(key,"0"); } } } } } dataList.get(i).put("reportWorkQuantity",JSON.toJSONString(data)); dataList.get(i).put("reportWorkQuantityShow",JSON.toJSONString(dataShow)); } Order order = orderMapper.selectOrderId(orderId); map.put("mergeCells", rowCount); map.put("data",dataList); map.put("order",order); return map; } public Map processCardProgressReportSv(String orderId, List columns) { Map map = new HashMap<>(); //获取表格内容数据 List> dataList = reportMapper.processCardProgressReportMp(orderId); //获取表头工序筛选数据 List> uniqueList = orderProcessDetailMapper.filterOrderProcess(orderId); map.put("title", uniqueList); Map clos = new HashMap<>(); HashMap>> rowCount = new HashMap>>(); for (int i=0;i() .eq("basic_category","process") .eq("basic_name",uniqueList.get(i).get("process")) .last("limit 1") ); //判断夹胶和夹胶后工序 //Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC") if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){ clos.put(uniqueList.get(i).get("process"), 14+i); } //判断中空和中空后工序 //Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD") if(Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")){ columns.add("reportWorkQuantity."+uniqueList.get(i).get("process")); } } List> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); HashMap> getRowCountMap = new HashMap<>(); getRowCount.forEach(col -> { Integer getRowCountOrderNumber = ((Number) col.get("order_number")).intValue(); getRowCountMap.put(getRowCountOrderNumber, col); }); //循环结果 for (int i=0;i { if(rowCount.get(col) == null){ rowCount.put(col, new HashMap>()); } if(getRowCountMap.get(orderNumber) != null){ Map row = getRowCountMap.get(orderNumber); Map getRow = new HashMap<>(); //判断当前此次 是否为第一行 并且相同序号 if(technologyNumber==1){ getRow.put("rowspan", ((Number) row.get("rowCount")).intValue()); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); } rowCount.get(col).put(finalI1+"_"+col, getRow); } }); Map data = JSON.parseObject(dataList.get(i).get("reportWorkQuantity"), new TypeReference>() { }); Map dataShow = JSON.parseObject(dataList.get(i).get("reportWorkQuantityShow"), new TypeReference>() { }); //判断后工序此流程卡号是否有次破 List hasBreak = damageDetailsMapper .getNotReview(dataList.get(i).get("processId"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("technology_number")) ); if(!hasBreak.isEmpty()){ int finalI = i; data.forEach((thisProcess, index)->{ String behindProcess = orderProcessDetailMapper.getBehindProcess( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), thisProcess, orderId ); if(behindProcess!=null &&!behindProcess.isEmpty()){ Integer behindDamageSum = damageDetailsMapper.getBehindDamageSum( dataList.get(finalI).get("processId"), String.valueOf(dataList.get(finalI).get("order_number")), String.valueOf(dataList.get(finalI).get("technology_number")), behindProcess,1 ); if(behindDamageSum>0){ data.put(thisProcess, String.valueOf(Integer.parseInt(data.get(thisProcess) )- behindDamageSum)); dataShow.put(thisProcess, String.valueOf(Integer.parseInt(dataShow.get(thisProcess) )- behindDamageSum)); } } }); } //夹胶工序判断合并行数 if(!clos.isEmpty()){ Integer max = orderGlassDetailMapper .getMaxTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); Integer min = orderGlassDetailMapper .getMinTechnologyNumberByGroup(dataList.get(i).get("order_id"), String.valueOf(dataList.get(i).get("order_number")), String.valueOf(dataList.get(i).get("group")) ); for (String key : clos.keySet()) { if(data.get(key) != null){ if (rowCount.get("reportWorkQuantity."+key)==null){ rowCount.put("reportWorkQuantity."+key, new HashMap>()); } Map getRow = new HashMap<>(); if(min == Integer.parseInt(String.valueOf(dataList.get(i).get("technology_number"))) ){ // { row: 0, col: 1, rowspan: 3, colspan: 0}, //getRow.put("row", i ); getRow.put("rowspan", max-min+1); getRow.put("colspan", 1); }else{ getRow.put("rowspan", 0); getRow.put("colspan", 0); data.put(key,"0"); } rowCount.get("reportWorkQuantity."+key).put(i+"_reportWorkQuantity."+key, getRow); } } } dataList.get(i).put("reportWorkQuantity",JSON.toJSONString(data)); dataList.get(i).put("reportWorkQuantityShow",JSON.toJSONString(dataShow)); } map.put("data",dataList ); map.put("mergeCells", rowCount); return map; } public Map yieldProcessSv(String selectTime1, String selectTime2, Report report) { Map map = new HashMap<>(); map.put("data", reportMapper.yieldProcessMp(selectTime1, selectTime2, report)); map.put("process", productionSchedulingMapper.selectProcess()); return map; } public Map selectProcessCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) { if ("null".equals(orderId)) { orderId = ""; } if ("null".equals(inputProject)) { inputProject = ""; } Map map = new HashMap<>(); String laminating = reportMapper.getLaminating(selectProcesses); map.put("data", reportMapper.selectProcessCompletedMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses,laminating, report)); map.put("process", productionSchedulingMapper.selectProcess()); map.put("footSum" ,reportMapper.processToBeCompletedFootSum(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report)); return map; } }