廖井涛
2025-11-03 f692a364cdb559ddadc4f6dac86c25848a1d4f34
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
@@ -332,6 +332,13 @@
//        return map;
//    }
    private static String to080000(String s) {
        if (s == null || s.isEmpty()) return null;
        String v = s.trim();
        // 只保留日期部分(前10位 yyyy-MM-dd)
        String datePart = v.length() >= 10 ? v.substring(0, 10) : v;
        return datePart + " 08:00:00";
    }
    //跨工序次破
    public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize,
                                                      List<String> selectDate,
@@ -339,15 +346,15 @@
        Integer offset = (pageNum - 1) * pageSize;
        // 默认时间范围:过去 15 天
        String endDate = LocalDate.now().toString();
        String startDate = LocalDate.now().minusDays(15).toString();
        String startDate = to080000(LocalDate.now().minusDays(15).toString());
        String endDate   = to080000(LocalDate.now().toString());
        if (selectDate != null && selectDate.size() == 2) {
            if (!selectDate.get(0).isEmpty()) {
                startDate = selectDate.get(0);
            if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
                startDate = to080000(selectDate.get(0));
            }
            if (!selectDate.get(1).isEmpty()) {
                endDate = selectDate.get(1);
            if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
                endDate = to080000(selectDate.get(1));
            }
        }
@@ -356,6 +363,7 @@
        // 使用异步线程池
        String finalEndDate = endDate;
        String finalStartDate = startDate;
        System.out.println(finalEndDate+"==="+finalStartDate);
        CompletableFuture<List<CrossProcessBreakingDTO>> dataFuture = asyncExecutor.runAsync(() ->
                reportMapper.getProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO));
@@ -388,15 +396,15 @@
        Integer offset = (pageNum - 1) * pageSize;
        // 默认时间范围:过去 15 天
        String endDate = LocalDate.now().toString();
        String startDate = LocalDate.now().minusDays(15).toString();
        String startDate = to080000(LocalDate.now().minusDays(15).toString());
        String endDate   = to080000(LocalDate.now().toString());
        if (selectDate != null && selectDate.size() == 2) {
            if (!selectDate.get(0).isEmpty()) {
                startDate = selectDate.get(0);
            if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
                startDate = to080000(selectDate.get(0));
            }
            if (!selectDate.get(1).isEmpty()) {
                endDate = selectDate.get(1);
            if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
                endDate = to080000(selectDate.get(1));
            }
        }
@@ -590,21 +598,34 @@
//    }
    public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize,
                                                    String selectTime1, String selectTime2,
                                                    List<String> selectDate,
                                                    DamageReportDTO damageReportDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        Map<String, Object> result = new HashMap<>();
        // 默认时间范围:过去 15 天
        String startDate = to080000(LocalDate.now().minusDays(15).toString());
        String endDate   = to080000(LocalDate.now().toString());
        if (selectDate != null && selectDate.size() == 2) {
            if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
                startDate = to080000(selectDate.get(0));
            }
            if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
                endDate = to080000(selectDate.get(1));
            }
        }
        Map<String, Object> result = new HashMap<>();
        String finalEndDate = endDate;
        String finalStartDate = startDate;
        // 异步任务定义
        CompletableFuture<List<DamageReportDTO>> dataFuture = asyncExecutor.runAsync(() ->
                reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
                reportMapper.selectDamageReportMp(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO));
        CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() ->
                reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
                reportMapper.getDamageReportPageTotal(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO));
        CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() ->
                reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO));
                reportMapper.damageReportFootSum(finalStartDate, finalEndDate, damageReportDTO));
        //等待全部任务完成
        CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join();
@@ -617,6 +638,10 @@
            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;
    }