From 2f640b1038fa331954f78ed1f4317212cf5bb34d Mon Sep 17 00:00:00 2001 From: chenlu <1320612696@qq.com> Date: 星期五, 07 六月 2024 16:56:06 +0800 Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override --- north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java | 384 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 363 insertions(+), 21 deletions(-) diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java index 0bcecbb..6d65e9c 100644 --- a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java +++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java @@ -1,21 +1,20 @@ package com.example.erp.service.pp; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; -import com.example.erp.entity.pp.FlowCard; +import com.example.erp.dto.pp.DamageReportDTO; +import com.example.erp.dto.pp.TeamOutputDTO; +import com.example.erp.entity.pp.DamageDetails; +import com.example.erp.entity.pp.Report; +import com.example.erp.mapper.pp.ProductionSchedulingMapper; import com.example.erp.mapper.pp.ReportMapper; import com.example.erp.mapper.sd.OrderProcessDetailMapper; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.sql.Date; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.time.LocalDate; +import java.util.*; @Service @DS("pp") @@ -23,34 +22,377 @@ private final ReportMapper reportMapper; private final OrderProcessDetailMapper orderProcessDetailMapper; + private final ProductionSchedulingMapper productionSchedulingMapper; - public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper) { + + public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, ProductionSchedulingMapper productionSchedulingMapper) { this.reportMapper = reportMapper; this.orderProcessDetailMapper = orderProcessDetailMapper; + this.productionSchedulingMapper = productionSchedulingMapper; } - + //娴佺▼鍗¤繘搴︽柟娉� public Map<String, Object> processCardProgressSv(String orderId, List<Integer> columns) { Map<String, Object> map = new HashMap<>(); + //鑾峰彇琛ㄦ牸鍐呭鏁版嵁 map.put("data", reportMapper.processCardProgressMp(orderId)); - map.put("title", orderProcessDetailMapper.filterOrderProcess(orderId)); - List<Map<String,Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); - List<Map<String,Integer>> rowCount = new ArrayList<>(); - columns.forEach(col ->{ - getRowCount.forEach(row ->{ - Map<String,Integer> getRow = new HashMap<>(); + + //鑾峰彇琛ㄥご宸ュ簭绛涢�夋暟鎹� + List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId); + List<Map<String, String>> processList = processFilterList; + + List<String> filterList = new ArrayList<>(); + //寰幆閬嶅巻鏁扮粍锛屽垽鏂搴忓彿褰撳墠鐨勫伐搴� + for (int i = 1; i < processFilterList.size(); i++) { + filterList.add(processFilterList.get(i).get("process")); + List<Map<String, String>> lastProcessList = + orderProcessDetailMapper.filterLastProcess( + orderId, + 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<String> seenValues = new HashSet<>(); + // 鍒涘缓涓�涓柊鐨凩ist鏉ュ瓨鍌ㄧ粨鏋� + List<Map<String, String>> uniqueList = new ArrayList<>(); + + // 鍙嶅悜閬嶅巻鍘熷List + for (int i = processList.size() - 1; i >= 0; i--) { + Map<String, String> maps = processList.get(i); + String value = maps.values().iterator().next(); // 鍋囪姣忎釜Map鍙湁涓�涓獀alue + + // 濡傛灉value杩樻病鏈夎鐪嬪埌杩囷紝灏辨坊鍔犲埌缁撴灉List鍜孒ashSet涓� + if (!seenValues.contains(value)) { + uniqueList.add(0, maps); // 娣诲姞鍒扮粨鏋淟ist鐨勫紑澶达紝浠ヤ繚鎸佸師椤哄簭 + seenValues.add(value); + } + } + map.put("title", uniqueList); + + + List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); + List<Map<String, Integer>> rowCount = new ArrayList<>(); + columns.forEach(col -> { + getRowCount.forEach(row -> { + Map<String, Integer> getRow = new HashMap<>(); // { row: 0, col: 1, rowspan: 3, colspan: 0}, - getRow.put("row",row.get("RowNum")); - getRow.put("col",col); - getRow.put("rowspan",row.get("rowCount")); - getRow.put("colspan",0); + getRow.put("row", row.get("RowNum")); + getRow.put("col", col); + getRow.put("rowspan", row.get("rowCount")); + getRow.put("colspan", 0); rowCount.add(getRow); }); }); - map.put("mergeCells",rowCount); + map.put("mergeCells", rowCount); return map; } + + public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, List<String> selectDate, DamageDetails damageDetails) { + 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<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, damageDetails)); + map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, damageDetails)); + List<String> list = new ArrayList<>(); + list.add(startDate); + list.add(endDate); + map.put("selectDate", list); +// map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail)); + return map; + } + + public Map<String, Object> workInProgressSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) { + + if ("null".equals(orderId)) { + orderId = ""; + } + if ("null".equals(inputProject)) { + inputProject = ""; + } + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.workInProgressMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report)); + map.put("process", productionSchedulingMapper.selectProcess()); + return map; + } + + public Map<String, Object> selectProcessToBeCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) { + if ("null".equals(orderId)) { + orderId = ""; + } + if ("null".equals(inputProject)) { + inputProject = ""; + } + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.processToBeCompletedMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report)); + map.put("process", productionSchedulingMapper.selectProcess()); + return map; + } + + public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, DamageReportDTO damageReportDTO) { + Integer offset = (pageNum - 1) * pageSize; + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); + map.put("total", reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO)); + return map; + } + + public Map<String, Object> splittingDetailsOutsideSv(String orderId, Report report) { + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.splittingDetailsOutsideMp(orderId, report)); + return map; + } + + public Map<String, Object> qualityReportSv(Date selectTime1, Date selectTime2, Report report) { + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.qualityReportMp(selectTime1, selectTime2, report)); + return map; + } + + public Map<String, Object> yieldSv(Date selectTime1, Date selectTime2, String selectProcesses, Report report) { + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.yieldMp(selectTime1, selectTime2, selectProcesses, report)); + map.put("process", productionSchedulingMapper.selectProcess()); + return map; + } + + public Map<String, Object> productionScheduleSv(String orderId, List<Integer> columns) { + Map<String, Object> map = new HashMap<>(); + //鑾峰彇琛ㄦ牸鍐呭鏁版嵁 + map.put("data", reportMapper.productionScheduleMp(orderId)); + + //鑾峰彇琛ㄥご宸ュ簭绛涢�夋暟鎹� + List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId); + List<Map<String, String>> processList = processFilterList; + + List<String> filterList = new ArrayList<>(); + //寰幆閬嶅巻鏁扮粍锛屽垽鏂搴忓彿褰撳墠鐨勫伐搴� + for (int i = 1; i < processFilterList.size(); i++) { + filterList.add(processFilterList.get(i).get("process")); + List<Map<String, String>> lastProcessList = + orderProcessDetailMapper.filterLastProcess( + orderId, + 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<String> seenValues = new HashSet<>(); + // 鍒涘缓涓�涓柊鐨凩ist鏉ュ瓨鍌ㄧ粨鏋� + List<Map<String, String>> uniqueList = new ArrayList<>(); + + // 鍙嶅悜閬嶅巻鍘熷List + for (int i = processList.size() - 1; i >= 0; i--) { + Map<String, String> maps = processList.get(i); + String value = maps.values().iterator().next(); // 鍋囪姣忎釜Map鍙湁涓�涓獀alue + + // 濡傛灉value杩樻病鏈夎鐪嬪埌杩囷紝灏辨坊鍔犲埌缁撴灉List鍜孒ashSet涓� + if (!seenValues.contains(value)) { + uniqueList.add(0, maps); // 娣诲姞鍒扮粨鏋淟ist鐨勫紑澶达紝浠ヤ繚鎸佸師椤哄簭 + seenValues.add(value); + } + } + map.put("title", uniqueList); + + + List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId); + List<Map<String, Integer>> rowCount = new ArrayList<>(); + columns.forEach(col -> { + getRowCount.forEach(row -> { + Map<String, Integer> getRow = new HashMap<>(); + // { row: 0, col: 1, rowspan: 3, colspan: 0}, + getRow.put("row", row.get("RowNum")); + 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<String, Object> taskCompletionStatusSv(Date selectTime1, Date selectTime2, List<Integer> columns) { + Map<String, Object> map = new HashMap<>(); + //鑾峰彇琛ㄦ牸鍐呭鏁版嵁 + map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2)); + + //鑾峰彇琛ㄥご宸ュ簭绛涢�夋暟鎹� + List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2); + List<Map<String, String>> processList = processFilterList; + + List<String> filterList = new ArrayList<>(); + //寰幆閬嶅巻鏁扮粍锛屽垽鏂搴忓彿褰撳墠鐨勫伐搴� + for (int i = 1; i < processFilterList.size(); i++) { + filterList.add(processFilterList.get(i).get("process")); + List<Map<String, String>> 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<String> seenValues = new HashSet<>(); + // 鍒涘缓涓�涓柊鐨凩ist鏉ュ瓨鍌ㄧ粨鏋� + List<Map<String, String>> uniqueList = new ArrayList<>(); + + // 鍙嶅悜閬嶅巻鍘熷List + for (int i = processList.size() - 1; i >= 0; i--) { + Map<String, String> maps = processList.get(i); + String value = maps.values().iterator().next(); // 鍋囪姣忎釜Map鍙湁涓�涓獀alue + + // 濡傛灉value杩樻病鏈夎鐪嬪埌杩囷紝灏辨坊鍔犲埌缁撴灉List鍜孒ashSet涓� + if (!seenValues.contains(value)) { + uniqueList.add(0, maps); // 娣诲姞鍒扮粨鏋淟ist鐨勫紑澶达紝浠ヤ繚鎸佸師椤哄簭 + seenValues.add(value); + } + } + map.put("title", uniqueList); + + + List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2); + List<Map<String, Integer>> rowCount = new ArrayList<>(); + columns.forEach(col -> { + getRowCount.forEach(row -> { + Map<String, Integer> getRow = new HashMap<>(); + // { row: 0, col: 1, rowspan: 3, colspan: 0}, + getRow.put("row", row.get("RowNum")); + 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<String, Object> orderPlanDecompositionSv(Date selectTime1, Date selectTime2, Report report) { + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.orderPlanDecompositionMp(selectTime1, selectTime2, report)); + return map; + } + + public Map<String, Object> rawMaterialRequisitionSv(Date selectTime1, Date selectTime2, Report report) { + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.rawMaterialRequisitionMp(selectTime1, selectTime2, report)); + return map; + } + + public List exportCrossProcessBreakingSv(List<LocalDate> dates) { + return reportMapper.exportCrossProcessBreakingMp(dates); + } + + public List exportDamageReportSv(List<LocalDate> dates) { + + return reportMapper.exportDamageReportMp(dates); + } + + public List exportOrderPlanDecompositionSv(List<LocalDate> dates) { + return reportMapper.exportOrderPlanDecompositionMp(dates); + } + + public List exportProcessToBeCompletedSv(Map<String, Object> dates) { + List<LocalDate> date= (List<LocalDate>) 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<String, Object> dates) { + List<LocalDate> date= (List<LocalDate>) 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.exportWorkInProgressMp(date,process,inputVal,project); + } + + public List exportTaskCompletionStatusSv(Map<String, Object> dates) { + return reportMapper.exportTaskCompletionStatusMp(dates); + } + + public List exportRawMaterialRequisitionSv(List<LocalDate> dates) { + return reportMapper.exportRawMaterialRequisitionMp(dates); + } + + public List exportQualityReportSv(List<LocalDate> dates) { + return reportMapper.exportQualityReportSv(dates); + } + + public List exportYieldSv(Map<String, Object> dates) { + List<LocalDate> date= (List<LocalDate>) dates.get("date"); + String process= (String) dates.get("processes"); + return reportMapper.exportYieldMp(date,process); + } + + public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) { + Integer offset = (pageNum - 1) * pageSize; + Map<String, Object> map = new HashMap<>(); + map.put("data", reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2,selectProcesses, teamOutputDTO)); + map.put("process", productionSchedulingMapper.selectProcess()); + map.put("total", reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2,selectProcesses, teamOutputDTO)); + return map; + } } -- Gitblit v1.8.0