Просмотр исходного кода

feat: 抽问抽答完成趋势、错题分析接口参数改为 dateRangeQueryType/year/quarter/month 形式

simonlll недель назад: 3
Родитель
Сommit
c91bb6365c

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

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

+ 31 - 38
airport-admin/src/main/java/com/sundot/airport/web/controller/exam/DailyExamWrongAnalysisController.java

@@ -5,6 +5,8 @@ import com.sundot.airport.common.core.domain.entity.SysDept;
5
 import com.sundot.airport.common.core.domain.entity.SysRole;
5
 import com.sundot.airport.common.core.domain.entity.SysRole;
6
 import com.sundot.airport.common.core.domain.model.LoginUser;
6
 import com.sundot.airport.common.core.domain.model.LoginUser;
7
 import com.sundot.airport.common.enums.RoleTypeEnum;
7
 import com.sundot.airport.common.enums.RoleTypeEnum;
8
+import com.sundot.airport.common.core.domain.SysAnalysisReportParamDto;
9
+import com.sundot.airport.common.utils.DateRangeQueryUtils;
8
 import com.sundot.airport.common.utils.SecurityUtils;
10
 import com.sundot.airport.common.utils.SecurityUtils;
9
 import com.sundot.airport.exam.common.HttpResult;
11
 import com.sundot.airport.exam.common.HttpResult;
10
 import com.sundot.airport.exam.common.service.QuesCatService;
12
 import com.sundot.airport.exam.common.service.QuesCatService;
@@ -73,19 +75,14 @@ public class DailyExamWrongAnalysisController {
73
      * 总体问题分布(按大类统计错题数)
75
      * 总体问题分布(按大类统计错题数)
74
      * 站长/管理员/质检科:全站;大队长:本大队;主管:本主管室;班组长:本班组
76
      * 站长/管理员/质检科:全站;大队长:本大队;主管:本主管室;班组长:本班组
75
      *
77
      *
76
-     * @param timeType  year/month/custom,默认 month
77
-     * @param startDate 自定义开始日期 yyyy-MM-dd
78
-     * @param endDate   自定义结束日期 yyyy-MM-dd
78
+     * @param param dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
79
      */
79
      */
80
     @GetMapping("/overview")
80
     @GetMapping("/overview")
81
-    public HttpResult<Map<String, Object>> getOverview(
82
-            @RequestParam(required = false, defaultValue = "month") String timeType,
83
-            @RequestParam(required = false) String startDate,
84
-            @RequestParam(required = false) String endDate) {
81
+    public HttpResult<Map<String, Object>> getOverview(SysAnalysisReportParamDto param) {
85
 
82
 
86
         try {
83
         try {
87
             RoleInfo role = getRoleInfo();
84
             RoleInfo role = getRoleInfo();
88
-            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
85
+            LocalDate[] range = resolveDateRange(param);
89
 
86
 
90
             List<DailyTaskDetail> errorDetails = getErrorDetails(role, range[0], range[1]);
87
             List<DailyTaskDetail> errorDetails = getErrorDetails(role, range[0], range[1]);
91
 
88
 
@@ -131,15 +128,10 @@ public class DailyExamWrongAnalysisController {
131
     /**
128
     /**
132
      * 问题分布对比雷达图(仅站长可见,各大队在各大类的错题数对比)
129
      * 问题分布对比雷达图(仅站长可见,各大队在各大类的错题数对比)
133
      *
130
      *
134
-     * @param timeType  year/month/custom,默认 month
135
-     * @param startDate 自定义开始日期
136
-     * @param endDate   自定义结束日期
131
+     * @param param dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
137
      */
132
      */
138
     @GetMapping("/radar")
133
     @GetMapping("/radar")
139
-    public HttpResult<Map<String, Object>> getRadar(
140
-            @RequestParam(required = false, defaultValue = "month") String timeType,
141
-            @RequestParam(required = false) String startDate,
142
-            @RequestParam(required = false) String endDate) {
134
+    public HttpResult<Map<String, Object>> getRadar(SysAnalysisReportParamDto param) {
143
 
135
 
144
         try {
136
         try {
145
             RoleInfo role = getRoleInfo();
137
             RoleInfo role = getRoleInfo();
@@ -149,7 +141,7 @@ public class DailyExamWrongAnalysisController {
149
                 return HttpResult.success(noShow);
141
                 return HttpResult.success(noShow);
150
             }
142
             }
151
 
143
 
152
-            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
144
+            LocalDate[] range = resolveDateRange(param);
153
 
145
 
154
             // 查询所有大类,作为雷达图的维度
146
             // 查询所有大类,作为雷达图的维度
155
             BaseCheckCategory level1Query = new BaseCheckCategory();
147
             BaseCheckCategory level1Query = new BaseCheckCategory();
@@ -220,16 +212,12 @@ public class DailyExamWrongAnalysisController {
220
      * 班组长及以下:show=false
212
      * 班组长及以下:show=false
221
      *
213
      *
222
      * @param categoryId 大类ID(base_check_category.id,level=1)
214
      * @param categoryId 大类ID(base_check_category.id,level=1)
223
-     * @param timeType   year/month/custom,默认 month
224
-     * @param startDate  自定义开始日期
225
-     * @param endDate    自定义结束日期
215
+     * @param param      dateRangeQueryType=YEAR|QUARTER|MONTH,year,quarter,month
226
      */
216
      */
227
     @GetMapping("/category-detail")
217
     @GetMapping("/category-detail")
228
     public HttpResult<Map<String, Object>> getCategoryDetail(
218
     public HttpResult<Map<String, Object>> getCategoryDetail(
229
             @RequestParam Long categoryId,
219
             @RequestParam Long categoryId,
230
-            @RequestParam(required = false, defaultValue = "month") String timeType,
231
-            @RequestParam(required = false) String startDate,
232
-            @RequestParam(required = false) String endDate) {
220
+            SysAnalysisReportParamDto param) {
233
 
221
 
234
         try {
222
         try {
235
             RoleInfo role = getRoleInfo();
223
             RoleInfo role = getRoleInfo();
@@ -240,7 +228,7 @@ public class DailyExamWrongAnalysisController {
240
                 return HttpResult.success(noShow);
228
                 return HttpResult.success(noShow);
241
             }
229
             }
242
 
230
 
243
-            LocalDate[] range = resolveDateRange(timeType, startDate, endDate);
231
+            LocalDate[] range = resolveDateRange(param);
244
 
232
 
245
             BaseCheckCategory level1Cat = baseCheckCategoryService.selectBaseCheckCategoryById(categoryId);
233
             BaseCheckCategory level1Cat = baseCheckCategoryService.selectBaseCheckCategoryById(categoryId);
246
             if (level1Cat == null) {
234
             if (level1Cat == null) {
@@ -264,7 +252,7 @@ public class DailyExamWrongAnalysisController {
264
             result.put("categoryId", categoryId);
252
             result.put("categoryId", categoryId);
265
             result.put("categoryName", level1Cat.getName());
253
             result.put("categoryName", level1Cat.getName());
266
 
254
 
267
-            boolean byMonth = "year".equals(timeType);
255
+            boolean byMonth = "YEAR".equals(param != null ? param.getDateRangeQueryType() : null);
268
             List<String> xAxis = buildXAxis(range[0], range[1], byMonth);
256
             List<String> xAxis = buildXAxis(range[0], range[1], byMonth);
269
             SimpleDateFormat sdf = new SimpleDateFormat(byMonth ? "yyyy-MM" : "yyyy-MM-dd");
257
             SimpleDateFormat sdf = new SimpleDateFormat(byMonth ? "yyyy-MM" : "yyyy-MM-dd");
270
 
258
 
@@ -669,26 +657,31 @@ public class DailyExamWrongAnalysisController {
669
     }
657
     }
670
 
658
 
671
     /**
659
     /**
672
-     * 根据时间类型计算起止日期
660
+     * 根据 SysAnalysisReportParamDto 计算起止日期
661
+     * YEAR → 全年;QUARTER → 指定季度;MONTH → 指定月份;默认 → 当月
673
      */
662
      */
674
-    private LocalDate[] resolveDateRange(String timeType, String startDate, String endDate) {
663
+    private LocalDate[] resolveDateRange(SysAnalysisReportParamDto param) {
675
         LocalDate today = LocalDate.now();
664
         LocalDate today = LocalDate.now();
676
-        LocalDate start;
677
-        LocalDate end = today;
678
-        switch (timeType == null ? "month" : timeType) {
679
-            case "year":
680
-                start = today.withDayOfYear(1);
681
-                end = today.withMonth(12).withDayOfMonth(31);
665
+        int year = (param != null && param.getYear() != null) ? param.getYear() : today.getYear();
666
+        String type = (param != null && param.getDateRangeQueryType() != null) ? param.getDateRangeQueryType() : "MONTH";
667
+        com.sundot.airport.common.core.domain.SysAnalysisReportDateRangeDto range;
668
+        switch (type) {
669
+            case "YEAR":
670
+                range = DateRangeQueryUtils.getYearRange(year, null);
682
                 break;
671
                 break;
683
-            case "custom":
684
-                start = (startDate != null) ? LocalDate.parse(startDate) : today.withDayOfMonth(1);
685
-                end = (endDate != null) ? LocalDate.parse(endDate) : today;
672
+            case "QUARTER":
673
+                int quarter = (param.getQuarter() != null) ? param.getQuarter() : 1;
674
+                range = DateRangeQueryUtils.getQuarterRange(year, quarter, null);
686
                 break;
675
                 break;
687
-            default: // month
688
-                start = today.withDayOfMonth(1);
676
+            default: // MONTH
677
+                int month = (param != null && param.getMonth() != null) ? param.getMonth() : today.getMonthValue();
678
+                range = DateRangeQueryUtils.getMonthRange(year, month, null);
689
                 break;
679
                 break;
690
         }
680
         }
691
-        return new LocalDate[]{start, end};
681
+        return new LocalDate[]{
682
+                ((java.sql.Date) range.getStartDate()).toLocalDate(),
683
+                ((java.sql.Date) range.getEndDate()).toLocalDate()
684
+        };
692
     }
685
     }
693
 
686
 
694
     /**
687
     /**