| | |
| | | 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; |
| | |
| | | // 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"; |
| | | |
| | | 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<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, |
| | | String reportTime, |
| | | CrossProcessBreakingDTO crossProcessBreakingDTO) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | // 默认时间范围:过去 15 天 |
| | | String startDate = to080000(LocalDate.now().minusDays(15).toString()); |
| | | String endDate = to080000(LocalDate.now().toString()); |
| | | // 默认时间范围:过去 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 = to080000(selectDate.get(0)); |
| | | startDate = toReportTime(selectDate.get(0), reportTime); |
| | | } |
| | | if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { |
| | | endDate = to080000(selectDate.get(1)); |
| | | endDate = toReportTime(selectDate.get(1), reportTime); |
| | | } |
| | | } |
| | | |
| | |
| | | // 使用异步线程池 |
| | | String finalEndDate = endDate; |
| | | String finalStartDate = startDate; |
| | | System.out.println(finalEndDate+"==="+finalStartDate); |
| | | CompletableFuture<List<CrossProcessBreakingDTO>> dataFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.getProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO)); |
| | | |
| | |
| | | //非跨工序次破 |
| | | public Map<String, Object> notCrossProcessBreakingSv(Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, |
| | | String reportTime, |
| | | CrossProcessBreakingDTO crossProcessBreakingDTO) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | // 默认时间范围:过去 15 天 |
| | | String startDate = to080000(LocalDate.now().minusDays(15).toString()); |
| | | String endDate = to080000(LocalDate.now().toString()); |
| | | // 默认时间范围:过去 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 = to080000(selectDate.get(0)); |
| | | startDate = toReportTime(selectDate.get(0), reportTime); |
| | | } |
| | | if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { |
| | | endDate = to080000(selectDate.get(1)); |
| | | endDate = toReportTime(selectDate.get(1), reportTime); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, |
| | | List<String> selectDate, |
| | | String reportTime, |
| | | DamageReportDTO damageReportDTO) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | // 默认时间范围:过去 15 天 |
| | | String startDate = to080000(LocalDate.now().minusDays(15).toString()); |
| | | String endDate = to080000(LocalDate.now().toString()); |
| | | |
| | | 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 = to080000(selectDate.get(0)); |
| | | startDate = toReportTime(selectDate.get(0), reportTime); |
| | | } |
| | | if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) { |
| | | endDate = to080000(selectDate.get(1)); |
| | | endDate = toReportTime(selectDate.get(1), reportTime); |
| | | } |
| | | } |
| | | Map<String, Object> result = new HashMap<>(); |
| | | String finalEndDate = endDate; |
| | | String finalStartDate = startDate; |
| | | // 异步任务定义 |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | String finalStartDate = startDate; |
| | | String finalEndDate = endDate; |
| | | |
| | | // 异步任务定义 |
| | | CompletableFuture<List<DamageReportDTO>> dataFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.selectDamageReportMp(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO)); |
| | | |
| | |
| | | CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() -> |
| | | reportMapper.damageReportFootSum(finalStartDate, finalEndDate, damageReportDTO)); |
| | | |
| | | //等待全部任务完成 |
| | | // 等待全部任务完成 |
| | | CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join(); |
| | | |
| | | try { |
| | |
| | | result.put("footSum", footSumFuture.get()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询异常:" + e.getMessage(), e); |
| | | throw new RuntimeException("次破总表并行查询异常:" + e.getMessage(), e); |
| | | } |
| | | |
| | | // 回传前端的时间(现在是带时分秒的) |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> splittingDetailsOutsideSv(String orderId, Report report) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | } |
| | | String inputVal= (String) dates.get("inputVal"); |
| | | String project= (String) dates.get("project"); |
| | | String terminationVals= (String) dates.get("terminationVals"); |
| | | if ("null".equals(inputVal)) { |
| | | String terminationVals= dates.get("terminationVals").toString();; |
| | | if (inputVal==null) { |
| | | inputVal = ""; |
| | | } |
| | | if ("null".equals(project)) { |
| | | if (project==null) { |
| | | project = ""; |
| | | } |
| | | if ("null".equals(terminationVals)) { |
| | | if (terminationVals==null) { |
| | | terminationVals = ""; |
| | | } |
| | | List<WorkInProgressDTO> dataList1 =reportMapper.exportWorkInProgressMp(process,inputVal,project,terminationVals); |
| | |
| | | } |
| | | String inputVal= (String) dates.get("inputVal"); |
| | | String project= (String) dates.get("project"); |
| | | String terminationVals= (String) dates.get("terminationVals"); |
| | | if ("null".equals(inputVal)) { |
| | | String terminationVals= dates.get("terminationVals").toString();; |
| | | if (inputVal==null) { |
| | | inputVal = ""; |
| | | } |
| | | if ("null".equals(project)) { |
| | | if (project==null) { |
| | | project = ""; |
| | | } |
| | | if ("null".equals(terminationVals)) { |
| | | if (terminationVals==null) { |
| | | terminationVals = ""; |
| | | } |
| | | |