浏览代码

抽问抽答首页集成

simonlll 2 月之前
父节点
当前提交
a648bfb0ac

+ 22 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/system/SysHomePageController.java

@@ -20,6 +20,7 @@ import com.sundot.airport.common.enums.HomePageQueryEnum;
20 20
 import com.sundot.airport.common.enums.SourceTypeEnum;
21 21
 import com.sundot.airport.common.exception.ServiceException;
22 22
 import com.sundot.airport.common.utils.DateUtils;
23
+import com.sundot.airport.exam.service.IAccuracyStatisticsService;
23 24
 import com.sundot.airport.item.mapper.SeizureReportMapper;
24 25
 import com.sundot.airport.system.service.ISysDeptService;
25 26
 import com.sundot.airport.system.service.ISysLearningGrowthService;
@@ -68,6 +69,9 @@ public class SysHomePageController extends BaseController {
68 69
     @Autowired
69 70
     private IAttendancePostRecordService attendancePostRecordService;
70 71
 
72
+    @Autowired
73
+    private IAccuracyStatisticsService accuracyStatisticsService;
74
+
71 75
     /**
72 76
      * 首页-排名
73 77
      */
@@ -75,6 +79,7 @@ public class SysHomePageController extends BaseController {
75 79
     public AjaxResult homePageRanking(BaseLargeScreenQueryParamDto dto) {
76 80
         SysHomePageRankingDto result = new SysHomePageRankingDto();
77 81
         result.setCheckLargeScreenHomePageRankingDto(checkLargeScreenService.checkRanking(dto));
82
+        result.setDailyTaskAccuracyRankingDto(accuracyStatisticsService.getAccuracyRanking(dto));
78 83
         return success(result);
79 84
     }
80 85
 
@@ -277,12 +282,29 @@ public class SysHomePageController extends BaseController {
277 282
             resultItem.setCheckPassRateGraph(resultItem.getCheckPassRate());
278 283
             resultItem.setSeizureCount(getSeizureCount(item));
279 284
             resultItem.setSeizureCountGraph(getSeizureCountGraph(item));
285
+            // 抽问抽答正确率
286
+            resultItem.setAnswersAccuracy(getAnswersAccuracy(item));
287
+            resultItem.setAnswersAccuracyGraph(resultItem.getAnswersAccuracy());
280 288
             result.add(resultItem);
281 289
         }
282 290
         return result;
283 291
     }
284 292
 
285 293
     /**
294
+     * 获取抽问抽答正确率
295
+     */
296
+    private BigDecimal getAnswersAccuracy(SysHomePageDetailQueryParamDto item) {
297
+        Long userId = null;
298
+        Long deptId = null;
299
+        if (StrUtil.equals(HomePageQueryEnum.USER.getCode(), item.getType())) {
300
+            userId = item.getId();
301
+        } else {
302
+            deptId = item.getId();
303
+        }
304
+        return accuracyStatisticsService.getAccuracyRate(userId, deptId, item.getStartDate(), item.getEndDate());
305
+    }
306
+
307
+    /**
286 308
      * 获取巡检合格率
287 309
      */
288 310
     private BigDecimal getCheckPassRate(SysHomePageDetailQueryParamDto item) {

+ 56 - 0
airport-common/src/main/java/com/sundot/airport/common/core/domain/DailyTaskAccuracyRankingDto.java

@@ -0,0 +1,56 @@
1
+package com.sundot.airport.common.core.domain;
2
+
3
+import lombok.Data;
4
+
5
+import java.math.BigDecimal;
6
+import java.util.List;
7
+
8
+/**
9
+ * 抽问抽答正确率排名DTO
10
+ *
11
+ * @author Simon Lin
12
+ * @date 2026-01-29
13
+ */
14
+@Data
15
+public class DailyTaskAccuracyRankingDto {
16
+
17
+    /**
18
+     * ID(用户ID或部门ID)
19
+     */
20
+    private Long id;
21
+
22
+    /**
23
+     * 名称(用户姓名或部门名称)
24
+     */
25
+    private String name;
26
+
27
+    /**
28
+     * 排名
29
+     */
30
+    private Integer rank;
31
+
32
+    /**
33
+     * 总数
34
+     */
35
+    private Integer total;
36
+
37
+    /**
38
+     * 奖牌类型(1-金牌,2-银牌,3-铜牌,4-哭脸红,5-哭脸橙,6-哭脸黄)
39
+     */
40
+    private Integer medalType;
41
+
42
+    /**
43
+     * 奖牌类型描述
44
+     */
45
+    private String medalTypeDesc;
46
+
47
+    /**
48
+     * 正确率
49
+     */
50
+    private BigDecimal accuracyRate;
51
+
52
+    /**
53
+     * 排行列表
54
+     */
55
+    private List<DailyTaskAccuracyRankingItemDto> rankingList;
56
+}

+ 35 - 0
airport-common/src/main/java/com/sundot/airport/common/core/domain/DailyTaskAccuracyRankingItemDto.java

@@ -0,0 +1,35 @@
1
+package com.sundot.airport.common.core.domain;
2
+
3
+import lombok.Data;
4
+
5
+import java.math.BigDecimal;
6
+
7
+/**
8
+ * 抽问抽答正确率排名项DTO
9
+ *
10
+ * @author Simon Lin
11
+ * @date 2026-01-29
12
+ */
13
+@Data
14
+public class DailyTaskAccuracyRankingItemDto {
15
+
16
+    /**
17
+     * 主键(用户ID或部门ID)
18
+     */
19
+    private Long id;
20
+
21
+    /**
22
+     * 名称(用户姓名或部门名称)
23
+     */
24
+    private String name;
25
+
26
+    /**
27
+     * 正确率
28
+     */
29
+    private BigDecimal accuracyRate;
30
+
31
+    /**
32
+     * 名次
33
+     */
34
+    private Integer rank;
35
+}

+ 5 - 0
airport-common/src/main/java/com/sundot/airport/common/core/domain/SysHomePageRankingDto.java

@@ -16,4 +16,9 @@ public class SysHomePageRankingDto {
16 16
      */
17 17
     private CheckLargeScreenHomePageRankingDto checkLargeScreenHomePageRankingDto;
18 18
 
19
+    /**
20
+     * 抽问抽答正确率排名
21
+     */
22
+    private DailyTaskAccuracyRankingDto dailyTaskAccuracyRankingDto;
23
+
19 24
 }

+ 32 - 0
airport-common/src/main/java/com/sundot/airport/common/enums/TimeRangeEnum.java

@@ -0,0 +1,32 @@
1
+package com.sundot.airport.common.enums;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Getter;
5
+
6
+/**
7
+ * 时间范围枚举
8
+ *
9
+ * @author Simon Lin
10
+ * @date 2026-01-29
11
+ */
12
+@Getter
13
+@AllArgsConstructor
14
+public enum TimeRangeEnum {
15
+
16
+    TODAY("TODAY", "今日"),
17
+    WEEK("WEEK", "本周"),
18
+    MONTH("MONTH", "本月"),
19
+    YEAR("YEAR", "本年");
20
+
21
+    private final String code;
22
+    private final String desc;
23
+
24
+    public static TimeRangeEnum getByCode(String code) {
25
+        for (TimeRangeEnum item : TimeRangeEnum.values()) {
26
+            if (item.getCode().equals(code)) {
27
+                return item;
28
+            }
29
+        }
30
+        return null;
31
+    }
32
+}

+ 83 - 0
airport-exam/src/main/java/com/sundot/airport/exam/controller/AccuracyStatisticsController.java

@@ -0,0 +1,83 @@
1
+package com.sundot.airport.exam.controller;
2
+
3
+import com.sundot.airport.common.core.controller.BaseController;
4
+import com.sundot.airport.common.core.domain.AjaxResult;
5
+import com.sundot.airport.common.core.domain.BaseLargeScreenQueryParamDto;
6
+import com.sundot.airport.exam.dto.AccuracyAggregateStatisticsDTO;
7
+import com.sundot.airport.exam.dto.AccuracyStatisticsDTO;
8
+import com.sundot.airport.exam.dto.AccuracyStatisticsQueryDTO;
9
+import com.sundot.airport.exam.service.IAccuracyStatisticsService;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.security.access.prepost.PreAuthorize;
12
+import org.springframework.web.bind.annotation.*;
13
+
14
+/**
15
+ * <b>功能名:</b>AccuracyStatisticsController<br>
16
+ * <b>说明:</b> 抽问抽答正确率统计Controller <br>
17
+ * <b>著作权:</b> Copyright (C) 2026 SUNDOT CORPORATION<br>
18
+ *
19
+ * @author Simon Lin
20
+ */
21
+@RestController
22
+@RequestMapping("/exam/daily/accuracy-statistics")
23
+public class AccuracyStatisticsController extends BaseController {
24
+
25
+    @Autowired
26
+    private IAccuracyStatisticsService accuracyStatisticsService;
27
+
28
+    /**
29
+     * 获取当前用户或指定部门的正确率统计
30
+     */
31
+    @GetMapping
32
+    public AjaxResult getAccuracyStatistics(AccuracyStatisticsQueryDTO query) {
33
+        try {
34
+            AccuracyStatisticsDTO statistics = accuracyStatisticsService.getAccuracyStatistics(query);
35
+            return AjaxResult.success(statistics);
36
+        } catch (Exception e) {
37
+            logger.error("查询正确率统计失败", e);
38
+            return error("查询正确率统计失败:" + e.getMessage());
39
+        }
40
+    }
41
+
42
+    /**
43
+     * 获取指定用户的正确率统计
44
+     */
45
+    @GetMapping("/user/{userId}")
46
+    public AjaxResult getUserAccuracyStatistics(@PathVariable Long userId, AccuracyStatisticsQueryDTO query) {
47
+        try {
48
+            AccuracyStatisticsDTO statistics = accuracyStatisticsService.getUserAccuracyStatistics(userId, query);
49
+            return AjaxResult.success(statistics);
50
+        } catch (Exception e) {
51
+            logger.error("查询用户正确率统计失败 - userId: {}", userId, e);
52
+            return error("查询用户正确率统计失败:" + e.getMessage());
53
+        }
54
+    }
55
+
56
+    /**
57
+     * 获取聚合统计数据(管理员视角)
58
+     */
59
+    @PreAuthorize("@ss.hasPermi('exam:daily:statistics:admin') or @ss.hasRole('test') or @ss.hasRole('zhijianke')")
60
+    @GetMapping("/aggregate")
61
+    public AjaxResult getAggregateStatistics(AccuracyStatisticsQueryDTO query) {
62
+        try {
63
+            AccuracyAggregateStatisticsDTO statistics = accuracyStatisticsService.getAggregateStatistics(query);
64
+            return AjaxResult.success(statistics);
65
+        } catch (Exception e) {
66
+            logger.error("查询聚合统计数据失败", e);
67
+            return error("查询聚合统计数据失败:" + e.getMessage());
68
+        }
69
+    }
70
+
71
+    /**
72
+     * 获取首页正确率排名
73
+     */
74
+    @GetMapping("/ranking")
75
+    public AjaxResult getAccuracyRanking(BaseLargeScreenQueryParamDto dto) {
76
+        try {
77
+            return AjaxResult.success(accuracyStatisticsService.getAccuracyRanking(dto));
78
+        } catch (Exception e) {
79
+            logger.error("查询正确率排名失败", e);
80
+            return error("查询正确率排名失败:" + e.getMessage());
81
+        }
82
+    }
83
+}

+ 70 - 0
airport-exam/src/main/java/com/sundot/airport/exam/dto/AccuracyAggregateStatisticsDTO.java

@@ -0,0 +1,70 @@
1
+package com.sundot.airport.exam.dto;
2
+
3
+import lombok.Data;
4
+
5
+import java.io.Serializable;
6
+import java.math.BigDecimal;
7
+import java.util.List;
8
+
9
+/**
10
+ * <b>功能名:</b>AccuracyAggregateStatisticsDTO<br>
11
+ * <b>说明:</b> 正确率聚合统计DTO <br>
12
+ * <b>著作权:</b> Copyright (C) 2026 SUNDOT CORPORATION<br>
13
+ *
14
+ * @author Simon Lin
15
+ */
16
+@Data
17
+public class AccuracyAggregateStatisticsDTO implements Serializable {
18
+
19
+    private static final long serialVersionUID = 1L;
20
+
21
+    /**
22
+     * 总答题人数
23
+     */
24
+    private Integer totalUsers;
25
+
26
+    /**
27
+     * 总答题数
28
+     */
29
+    private Long totalAnswers;
30
+
31
+    /**
32
+     * 总正确数
33
+     */
34
+    private Long totalCorrect;
35
+
36
+    /**
37
+     * 整体正确率
38
+     */
39
+    private BigDecimal overallAccuracyRate;
40
+
41
+    /**
42
+     * 今日答题人数
43
+     */
44
+    private Integer todayUsers;
45
+
46
+    /**
47
+     * 今日答题数
48
+     */
49
+    private Long todayAnswers;
50
+
51
+    /**
52
+     * 今日正确数
53
+     */
54
+    private Long todayCorrect;
55
+
56
+    /**
57
+     * 今日正确率
58
+     */
59
+    private BigDecimal todayAccuracyRate;
60
+
61
+    /**
62
+     * 部门统计列表
63
+     */
64
+    private List<AccuracyStatisticsDTO> deptStatistics;
65
+
66
+    /**
67
+     * 用户排名列表(Top N)
68
+     */
69
+    private List<AccuracyStatisticsDTO> userRanking;
70
+}

+ 180 - 0
airport-exam/src/main/java/com/sundot/airport/exam/dto/AccuracyStatisticsDTO.java

@@ -0,0 +1,180 @@
1
+package com.sundot.airport.exam.dto;
2
+
3
+import lombok.Data;
4
+
5
+import java.io.Serializable;
6
+import java.math.BigDecimal;
7
+
8
+/**
9
+ * <b>功能名:</b>AccuracyStatisticsDTO<br>
10
+ * <b>说明:</b> 正确率统计结果DTO(匹配成都接口格式) <br>
11
+ * <b>著作权:</b> Copyright (C) 2026 SUNDOT CORPORATION<br>
12
+ *
13
+ * @author Simon Lin
14
+ */
15
+@Data
16
+public class AccuracyStatisticsDTO implements Serializable {
17
+
18
+    private static final long serialVersionUID = 1L;
19
+
20
+    /**
21
+     * 用户角色
22
+     */
23
+    private String userRole;
24
+
25
+    /**
26
+     * 时间范围描述
27
+     */
28
+    private String timePeriod;
29
+
30
+    /**
31
+     * 是否有待完成任务
32
+     */
33
+    private Boolean hasPendingTask;
34
+
35
+    /**
36
+     * 待完成任务ID
37
+     */
38
+    private String pendingTaskId;
39
+
40
+    /**
41
+     * 今日任务完成情况
42
+     */
43
+    private String todayTaskCompletion;
44
+
45
+    /**
46
+     * 个人正确率(百分比)
47
+     */
48
+    private BigDecimal personalAccuracy;
49
+
50
+    /**
51
+     * 个人正确数
52
+     */
53
+    private Long personalCorrectCount;
54
+
55
+    /**
56
+     * 个人总答题数
57
+     */
58
+    private Long personalTotalCount;
59
+
60
+    /**
61
+     * 班组平均正确率
62
+     */
63
+    private BigDecimal teamAvgAccuracy;
64
+
65
+    /**
66
+     * 主管平均正确率(成都为科室deptAvgAccuracy)
67
+     */
68
+    private BigDecimal deptAvgAccuracy;
69
+
70
+    /**
71
+     * 大队平均正确率(美兰特有)
72
+     */
73
+    private BigDecimal brigadeAvgAccuracy;
74
+
75
+    /**
76
+     * 站级平均正确率
77
+     */
78
+    private BigDecimal siteAvgAccuracy;
79
+
80
+    /**
81
+     * 个人在班组中的排名
82
+     */
83
+    private RankingInfo teamRanking;
84
+
85
+    /**
86
+     * 个人在主管中的排名(成都为科室deptRanking)
87
+     */
88
+    private RankingInfo deptRanking;
89
+
90
+    /**
91
+     * 个人在大队中的排名(美兰特有)
92
+     */
93
+    private RankingInfo brigadeRanking;
94
+
95
+    /**
96
+     * 个人在站级中的排名
97
+     */
98
+    private RankingInfo siteRanking;
99
+
100
+    /**
101
+     * 班组在主管中的排名
102
+     */
103
+    private RankingInfo teamInDeptRanking;
104
+
105
+    /**
106
+     * 班组在站级中的排名
107
+     */
108
+    private RankingInfo teamInSiteRanking;
109
+
110
+    /**
111
+     * 主管内Top班组
112
+     */
113
+    private java.util.List<RankingItem> topTeamsInDept;
114
+
115
+    /**
116
+     * 主管在站级中的排名
117
+     */
118
+    private RankingInfo deptInSiteRanking;
119
+
120
+    /**
121
+     * Top主管(科室)
122
+     */
123
+    private java.util.List<RankingItem> topDepts;
124
+
125
+    /**
126
+     * 站级内Top班组
127
+     */
128
+    private java.util.List<RankingItem> topTeamsInSite;
129
+
130
+    /**
131
+     * 站级内Bottom班组
132
+     */
133
+    private java.util.List<RankingItem> bottomTeamsInSite;
134
+
135
+    /**
136
+     * 排名信息
137
+     */
138
+    @Data
139
+    public static class RankingInfo implements Serializable {
140
+        private static final long serialVersionUID = 1L;
141
+
142
+        /**
143
+         * 排名
144
+         */
145
+        private Integer rank;
146
+
147
+        /**
148
+         * 总数
149
+         */
150
+        private Integer total;
151
+    }
152
+
153
+    /**
154
+     * 排名项
155
+     */
156
+    @Data
157
+    public static class RankingItem implements Serializable {
158
+        private static final long serialVersionUID = 1L;
159
+
160
+        /**
161
+         * ID
162
+         */
163
+        private Long id;
164
+
165
+        /**
166
+         * 名称
167
+         */
168
+        private String name;
169
+
170
+        /**
171
+         * 正确率
172
+         */
173
+        private BigDecimal accuracy;
174
+
175
+        /**
176
+         * 排名
177
+         */
178
+        private Integer rank;
179
+    }
180
+}

+ 57 - 0
airport-exam/src/main/java/com/sundot/airport/exam/dto/AccuracyStatisticsQueryDTO.java

@@ -0,0 +1,57 @@
1
+package com.sundot.airport.exam.dto;
2
+
3
+import com.fasterxml.jackson.annotation.JsonFormat;
4
+import lombok.Data;
5
+
6
+import java.io.Serializable;
7
+import java.util.Date;
8
+
9
+/**
10
+ * <b>功能名:</b>AccuracyStatisticsQueryDTO<br>
11
+ * <b>说明:</b> 正确率统计查询参数DTO <br>
12
+ * <b>著作权:</b> Copyright (C) 2026 SUNDOT CORPORATION<br>
13
+ *
14
+ * @author Simon Lin
15
+ */
16
+@Data
17
+public class AccuracyStatisticsQueryDTO implements Serializable {
18
+
19
+    private static final long serialVersionUID = 1L;
20
+
21
+    /**
22
+     * 用户ID
23
+     */
24
+    private Long userId;
25
+
26
+    /**
27
+     * 部门ID
28
+     */
29
+    private Long deptId;
30
+
31
+    /**
32
+     * 时间范围(TODAY/WEEK/MONTH/YEAR)
33
+     */
34
+    private String timeRange;
35
+
36
+    /**
37
+     * 开始日期
38
+     */
39
+    @JsonFormat(pattern = "yyyy-MM-dd")
40
+    private Date startDate;
41
+
42
+    /**
43
+     * 结束日期
44
+     */
45
+    @JsonFormat(pattern = "yyyy-MM-dd")
46
+    private Date endDate;
47
+
48
+    /**
49
+     * 统计维度(USER/DEPT)
50
+     */
51
+    private String dimension;
52
+
53
+    /**
54
+     * 部门类型(STATION/BRIGADE/MANAGER/TEAMS)
55
+     */
56
+    private String deptType;
57
+}

+ 64 - 0
airport-exam/src/main/java/com/sundot/airport/exam/service/IAccuracyStatisticsService.java

@@ -0,0 +1,64 @@
1
+package com.sundot.airport.exam.service;
2
+
3
+import com.sundot.airport.common.core.domain.BaseLargeScreenQueryParamDto;
4
+import com.sundot.airport.common.core.domain.DailyTaskAccuracyRankingDto;
5
+import com.sundot.airport.exam.dto.AccuracyAggregateStatisticsDTO;
6
+import com.sundot.airport.exam.dto.AccuracyStatisticsDTO;
7
+import com.sundot.airport.exam.dto.AccuracyStatisticsQueryDTO;
8
+
9
+import java.math.BigDecimal;
10
+import java.util.List;
11
+
12
+/**
13
+ * <b>功能名:</b>IAccuracyStatisticsService<br>
14
+ * <b>说明:</b> 抽问抽答正确率统计Service接口 <br>
15
+ * <b>著作权:</b> Copyright (C) 2026 SUNDOT CORPORATION<br>
16
+ *
17
+ * @author Simon Lin
18
+ */
19
+public interface IAccuracyStatisticsService {
20
+
21
+    /**
22
+     * 获取当前用户或部门的正确率统计
23
+     *
24
+     * @param query 查询参数
25
+     * @return 正确率统计结果
26
+     */
27
+    AccuracyStatisticsDTO getAccuracyStatistics(AccuracyStatisticsQueryDTO query);
28
+
29
+    /**
30
+     * 获取指定用户的正确率统计
31
+     *
32
+     * @param userId    用户ID
33
+     * @param query     查询参数
34
+     * @return 正确率统计结果
35
+     */
36
+    AccuracyStatisticsDTO getUserAccuracyStatistics(Long userId, AccuracyStatisticsQueryDTO query);
37
+
38
+    /**
39
+     * 获取聚合统计数据
40
+     *
41
+     * @param query 查询参数
42
+     * @return 聚合统计结果
43
+     */
44
+    AccuracyAggregateStatisticsDTO getAggregateStatistics(AccuracyStatisticsQueryDTO query);
45
+
46
+    /**
47
+     * 获取首页正确率排名
48
+     *
49
+     * @param dto 大屏查询参数
50
+     * @return 排名DTO
51
+     */
52
+    DailyTaskAccuracyRankingDto getAccuracyRanking(BaseLargeScreenQueryParamDto dto);
53
+
54
+    /**
55
+     * 获取用户/部门正确率(用于能力对比)
56
+     *
57
+     * @param userId    用户ID(用户维度时使用)
58
+     * @param deptId    部门ID(部门维度时使用)
59
+     * @param startDate 开始日期
60
+     * @param endDate   结束日期
61
+     * @return 正确率(0-1之间的小数)
62
+     */
63
+    BigDecimal getAccuracyRate(Long userId, Long deptId, java.util.Date startDate, java.util.Date endDate);
64
+}

文件差异内容过多而无法显示
+ 1109 - 0
airport-exam/src/main/java/com/sundot/airport/exam/service/impl/AccuracyStatisticsServiceImpl.java