廖井涛
2025-10-28 fcc929fa2888c6b06a168f1ca84344e3bf9fdce5
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
@@ -332,6 +332,7 @@
//        return map;
//    }
    //跨工序次破
    public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize,
                                                      List<String> selectDate,
                                                      CrossProcessBreakingDTO crossProcessBreakingDTO) {
@@ -360,6 +361,55 @@
        CompletableFuture<Map<String, Integer>> 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<String> list = new ArrayList<>();
        list.add(startDate);
        list.add(endDate);
        result.put("selectDate", list);
        return result;
    }
    //非跨工序次破
    public Map<String, Object> notCrossProcessBreakingSv(Integer pageNum, Integer pageSize,
                                                      List<String> selectDate,
                                                      CrossProcessBreakingDTO crossProcessBreakingDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        // 默认时间范围:过去 15 天
        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> result = new HashMap<>();
        // 使用异步线程池
        String finalEndDate = endDate;
        String finalStartDate = startDate;
        CompletableFuture<List<CrossProcessBreakingDTO>> dataFuture = asyncExecutor.runAsync(() ->
                reportMapper.getNotProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO));
        CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() ->
                reportMapper.getNotProcessBreakingTotal(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO));
        // 等待两个任务执行完毕
        CompletableFuture.allOf(dataFuture, totalFuture).join();
@@ -756,6 +806,10 @@
        return reportMapper.exportCrossProcessBreakingMp(dates);
    }
    public List exportNotCrossProcessBreakingSv(List<LocalDate> dates) {
        return reportMapper.exportNotCrossProcessBreakingMp(dates);
    }
    //    public List exportTeamOutputSv(Map<String, Object> dates) {
//        List<LocalDate> date= (List<LocalDate>) dates.get("date");
//        String process= (String) dates.get("processes");