Pārlūkot izejas kodu

回滚抽问抽答接口参数形式:completion-trend和错题分析overview/radar改回timeType/startDate/endDate参数

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
simonlll 2 nedēļas atpakaļ
vecāks
revīzija
312ceb902f

+ 24 - 23
airport-admin/src/main/java/com/sundot/airport/web/controller/exam/DailyExamController.java

@@ -298,10 +298,15 @@ public class DailyExamController {
298 298
      * 主管:本主管室完成趋势(单条折线)
299 299
      * 班组长/安检员:show=false
300 300
      *
301
-     * @param param dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
301
+     * @param timeType  时间类型:year/month/custom,默认 month
302
+     * @param startDate 自定义开始日期(yyyy-MM-dd),timeType=custom 时有效
303
+     * @param endDate   自定义结束日期(yyyy-MM-dd),timeType=custom 时有效
302 304
      */
303 305
     @GetMapping("/completion-trend")
304
-    public HttpResult<Map<String, Object>> getCompletionTrend(SysAnalysisReportParamDto param) {
306
+    public HttpResult<Map<String, Object>> getCompletionTrend(
307
+            @RequestParam(required = false, defaultValue = "month") String timeType,
308
+            @RequestParam(required = false) String startDate,
309
+            @RequestParam(required = false) String endDate) {
305 310
 
306 311
         try {
307 312
             LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -325,10 +330,10 @@ public class DailyExamController {
325 330
                 return HttpResult.success(noShow);
326 331
             }
327 332
 
328
-            LocalDate[] range = resolveDateRange(param);
333
+            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
329 334
             LocalDate start = range[0];
330 335
             LocalDate end = range[1];
331
-            boolean byMonth = "YEAR".equals(param != null ? param.getDateRangeQueryType() : null);
336
+            boolean byMonth = "year".equals(timeType);
332 337
             List<String> xAxis = buildXAxis(start, end, byMonth);
333 338
             List<Map<String, Object>> series = new ArrayList<>();
334 339
 
@@ -419,31 +424,27 @@ public class DailyExamController {
419 424
     }
420 425
 
421 426
     /**
422
-     * 根据 SysAnalysisReportParamDto 计算起止日期
423
-     * YEAR → 全年;QUARTER → 指定季度;MONTH → 指定月份;默认 → 当月
427
+     * 根据 timeType 计算起止日期
428
+     * year: 当年全年;month: 当月;custom: 自定义范围
424 429
      */
425
-    private LocalDate[] resolveDateRange(SysAnalysisReportParamDto param) {
430
+    private LocalDate[] resolveDateRange(String timeType, String startDate, String endDate) {
426 431
         LocalDate today = LocalDate.now();
427
-        int year = (param != null && param.getYear() != null) ? param.getYear() : today.getYear();
428
-        String type = (param != null && param.getDateRangeQueryType() != null) ? param.getDateRangeQueryType() : "MONTH";
429
-        com.sundot.airport.common.core.domain.SysAnalysisReportDateRangeDto range;
430
-        switch (type) {
431
-            case "YEAR":
432
-                range = DateRangeQueryUtils.getYearRange(year, null);
432
+        LocalDate start;
433
+        LocalDate end = today;
434
+        switch (timeType == null ? "month" : timeType) {
435
+            case "year":
436
+                start = today.withDayOfYear(1);
437
+                end = today.withMonth(12).withDayOfMonth(31);
433 438
                 break;
434
-            case "QUARTER":
435
-                int quarter = (param.getQuarter() != null) ? param.getQuarter() : 1;
436
-                range = DateRangeQueryUtils.getQuarterRange(year, quarter, null);
439
+            case "custom":
440
+                start = (startDate != null) ? LocalDate.parse(startDate) : today.withDayOfMonth(1);
441
+                end = (endDate != null) ? LocalDate.parse(endDate) : today;
437 442
                 break;
438
-            default: // MONTH
439
-                int month = (param != null && param.getMonth() != null) ? param.getMonth() : today.getMonthValue();
440
-                range = DateRangeQueryUtils.getMonthRange(year, month, null);
443
+            default: // month
444
+                start = today.withDayOfMonth(1);
441 445
                 break;
442 446
         }
443
-        return new LocalDate[]{
444
-                ((java.sql.Date) range.getStartDate()).toLocalDate(),
445
-                ((java.sql.Date) range.getEndDate()).toLocalDate()
446
-        };
447
+        return new LocalDate[]{start, end};
447 448
     }
448 449
 
449 450
     /**

+ 40 - 7
airport-admin/src/main/java/com/sundot/airport/web/controller/exam/DailyExamWrongAnalysisController.java

@@ -75,14 +75,19 @@ public class DailyExamWrongAnalysisController {
75 75
      * 总体问题分布(按大类统计错题数)
76 76
      * 站长/管理员/质检科:全站;大队长:本大队;主管:本主管室;班组长:本班组
77 77
      *
78
-     * @param param dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
78
+     * @param timeType  year/month/custom,默认 month
79
+     * @param startDate 自定义开始日期 yyyy-MM-dd
80
+     * @param endDate   自定义结束日期 yyyy-MM-dd
79 81
      */
80 82
     @GetMapping("/overview")
81
-    public HttpResult<Map<String, Object>> getOverview(SysAnalysisReportParamDto param) {
83
+    public HttpResult<Map<String, Object>> getOverview(
84
+            @RequestParam(required = false, defaultValue = "month") String timeType,
85
+            @RequestParam(required = false) String startDate,
86
+            @RequestParam(required = false) String endDate) {
82 87
 
83 88
         try {
84 89
             RoleInfo role = getRoleInfo();
85
-            LocalDate[] range = resolveDateRange(param);
90
+            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
86 91
 
87 92
             List<DailyTaskDetail> errorDetails = getErrorDetails(role, range[0], range[1]);
88 93
 
@@ -128,10 +133,15 @@ public class DailyExamWrongAnalysisController {
128 133
     /**
129 134
      * 问题分布对比雷达图(仅站长可见,各大队在各大类的错题数对比)
130 135
      *
131
-     * @param param dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
136
+     * @param timeType  year/month/custom,默认 month
137
+     * @param startDate 自定义开始日期
138
+     * @param endDate   自定义结束日期
132 139
      */
133 140
     @GetMapping("/radar")
134
-    public HttpResult<Map<String, Object>> getRadar(SysAnalysisReportParamDto param) {
141
+    public HttpResult<Map<String, Object>> getRadar(
142
+            @RequestParam(required = false, defaultValue = "month") String timeType,
143
+            @RequestParam(required = false) String startDate,
144
+            @RequestParam(required = false) String endDate) {
135 145
 
136 146
         try {
137 147
             RoleInfo role = getRoleInfo();
@@ -141,7 +151,7 @@ public class DailyExamWrongAnalysisController {
141 151
                 return HttpResult.success(noShow);
142 152
             }
143 153
 
144
-            LocalDate[] range = resolveDateRange(param);
154
+            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
145 155
 
146 156
             // 查询所有大类,作为雷达图的维度
147 157
             BaseCheckCategory level1Query = new BaseCheckCategory();
@@ -657,7 +667,30 @@ public class DailyExamWrongAnalysisController {
657 667
     }
658 668
 
659 669
     /**
660
-     * 根据 SysAnalysisReportParamDto 计算起止日期
670
+     * 根据 timeType 计算起止日期(供 overview/radar 使用)
671
+     */
672
+    private LocalDate[] resolveDateRange(String timeType, String startDate, String endDate) {
673
+        LocalDate today = LocalDate.now();
674
+        LocalDate start;
675
+        LocalDate end = today;
676
+        switch (timeType == null ? "month" : timeType) {
677
+            case "year":
678
+                start = today.withDayOfYear(1);
679
+                end = today.withMonth(12).withDayOfMonth(31);
680
+                break;
681
+            case "custom":
682
+                start = (startDate != null) ? LocalDate.parse(startDate) : today.withDayOfMonth(1);
683
+                end = (endDate != null) ? LocalDate.parse(endDate) : today;
684
+                break;
685
+            default: // month
686
+                start = today.withDayOfMonth(1);
687
+                break;
688
+        }
689
+        return new LocalDate[]{start, end};
690
+    }
691
+
692
+    /**
693
+     * 根据 SysAnalysisReportParamDto 计算起止日期(供 category-detail 使用)
661 694
      * YEAR → 全年;QUARTER → 指定季度;MONTH → 指定月份;默认 → 当月
662 695
      */
663 696
     private LocalDate[] resolveDateRange(SysAnalysisReportParamDto param) {