wangxx 1 miesiąc temu
rodzic
commit
6bafa027ae

+ 300 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/exam/ExamMonthlyScoreController.java

@@ -0,0 +1,300 @@
1
+package com.sundot.airport.web.controller.exam;
2
+
3
+import cn.hutool.core.collection.CollectionUtil;
4
+import cn.hutool.core.util.StrUtil;
5
+import com.sundot.airport.common.annotation.Log;
6
+import com.sundot.airport.common.core.controller.BaseController;
7
+import com.sundot.airport.common.core.domain.AjaxResult;
8
+import com.sundot.airport.common.core.domain.entity.SysUser;
9
+import com.sundot.airport.common.core.page.TableDataInfo;
10
+import com.sundot.airport.common.enums.BusinessType;
11
+import com.sundot.airport.common.exception.ServiceException;
12
+import com.sundot.airport.common.utils.poi.ExcelUtil;
13
+import com.sundot.airport.exam.domain.ExamMonthlyScore;
14
+import com.sundot.airport.exam.dto.ExamMonthlyScoreImportVO;
15
+import com.sundot.airport.exam.service.IExamMonthlyScoreService;
16
+import com.sundot.airport.system.service.ISysUserService;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.security.access.prepost.PreAuthorize;
19
+import org.springframework.web.bind.annotation.*;
20
+import org.springframework.web.multipart.MultipartFile;
21
+
22
+import javax.servlet.http.HttpServletResponse;
23
+import java.util.List;
24
+
25
+/**
26
+ * 月考成绩Controller
27
+ *
28
+ * @author ruoyi
29
+ * @date 2026-05-06
30
+ */
31
+@RestController
32
+@RequestMapping("/exam/monthlyScore")
33
+public class ExamMonthlyScoreController extends BaseController {
34
+    @Autowired
35
+    private IExamMonthlyScoreService examMonthlyScoreService;
36
+
37
+    @Autowired
38
+    private ISysUserService userService;
39
+
40
+    /**
41
+     * 查询月考成绩列表
42
+     */
43
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:list')")
44
+    @GetMapping("/list")
45
+    public TableDataInfo list(ExamMonthlyScore examMonthlyScore) {
46
+        startPage();
47
+        List<ExamMonthlyScore> list = examMonthlyScoreService.selectExamMonthlyScoreList(examMonthlyScore);
48
+        return getDataTable(list);
49
+    }
50
+
51
+    /**
52
+     * 导出月考成绩列表
53
+     */
54
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:export')")
55
+    @Log(title = "月考成绩", businessType = BusinessType.EXPORT)
56
+    @PostMapping("/export")
57
+    public void export(HttpServletResponse response, ExamMonthlyScore examMonthlyScore) {
58
+        List<ExamMonthlyScore> list = examMonthlyScoreService.selectExamMonthlyScoreList(examMonthlyScore);
59
+        ExcelUtil<ExamMonthlyScore> util = new ExcelUtil<ExamMonthlyScore>(ExamMonthlyScore.class);
60
+        util.exportExcel(response, list, "月考成绩数据");
61
+    }
62
+
63
+    /**
64
+     * 获取月考成绩详细信息
65
+     */
66
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:query')")
67
+    @GetMapping(value = "/{id}")
68
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
69
+        return success(examMonthlyScoreService.selectExamMonthlyScoreById(id));
70
+    }
71
+
72
+    /**
73
+     * 新增月考成绩
74
+     */
75
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:add')")
76
+    @Log(title = "月考成绩", businessType = BusinessType.INSERT)
77
+    @PostMapping
78
+    public AjaxResult add(@RequestBody ExamMonthlyScore examMonthlyScore) {
79
+        return toAjax(examMonthlyScoreService.insertExamMonthlyScore(examMonthlyScore));
80
+    }
81
+
82
+    /**
83
+     * 修改月考成绩
84
+     */
85
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:edit')")
86
+    @Log(title = "月考成绩", businessType = BusinessType.UPDATE)
87
+    @PutMapping
88
+    public AjaxResult edit(@RequestBody ExamMonthlyScore examMonthlyScore) {
89
+        return toAjax(examMonthlyScoreService.updateExamMonthlyScore(examMonthlyScore));
90
+    }
91
+
92
+    /**
93
+     * 删除月考成绩
94
+     */
95
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:remove')")
96
+    @Log(title = "月考成绩", businessType = BusinessType.DELETE)
97
+    @DeleteMapping("/{ids}")
98
+    public AjaxResult remove(@PathVariable Long[] ids) {
99
+        return toAjax(examMonthlyScoreService.deleteExamMonthlyScoreByIds(ids));
100
+    }
101
+
102
+    /**
103
+     * 下载导入模板
104
+     */
105
+    @PostMapping("/importTemplate")
106
+    public void importTemplate(HttpServletResponse response) {
107
+        ExcelUtil<ExamMonthlyScoreImportVO> util = new ExcelUtil<ExamMonthlyScoreImportVO>(ExamMonthlyScoreImportVO.class);
108
+        util.importTemplateExcel(response, "月考成绩数据");
109
+    }
110
+
111
+    /**
112
+     * 导入月考成绩数据
113
+     */
114
+    @Log(title = "月考成绩", businessType = BusinessType.IMPORT)
115
+    @PreAuthorize("@ss.hasPermi('exam:monthlyScore:import')")
116
+    @PostMapping("/importData")
117
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
118
+        ExcelUtil<ExamMonthlyScoreImportVO> util = new ExcelUtil<ExamMonthlyScoreImportVO>(ExamMonthlyScoreImportVO.class);
119
+        List<ExamMonthlyScoreImportVO> list = util.importExcel(file.getInputStream());
120
+        if (CollectionUtil.isEmpty(list)) {
121
+            throw new ServiceException("导入月考成绩数据不能为空");
122
+        }
123
+        String message = importData(list, updateSupport);
124
+        return success(message);
125
+    }
126
+
127
+    /**
128
+     * 导入数据处理
129
+     */
130
+    private String importData(List<ExamMonthlyScoreImportVO> list, boolean updateSupport) {
131
+        if (CollectionUtil.isEmpty(list)) {
132
+            throw new ServiceException("导入月考成绩数据不能为空!");
133
+        }
134
+
135
+        int successNum = 0;
136
+        int failureNum = 0;
137
+        StringBuilder successMsg = new StringBuilder();
138
+        StringBuilder failureMsg = new StringBuilder();
139
+
140
+        // 1. 预处理:提取所有学生姓名,批量查询用户
141
+        List<String> studentNames = list.stream()
142
+                .map(ExamMonthlyScoreImportVO::getStudentName)
143
+                .filter(StrUtil::isNotBlank)
144
+                .distinct()
145
+                .collect(java.util.stream.Collectors.toList());
146
+
147
+        // 批量查询用户(同时按用户名和昵称查询)
148
+        java.util.Map<String, SysUser> userMap = new java.util.HashMap<>();
149
+        if (CollectionUtil.isNotEmpty(studentNames)) {
150
+            List<SysUser> users = userService.selectUsersByNames(studentNames);
151
+            for (SysUser user : users) {
152
+                // 优先用用户名做key,如果没有则用昵称
153
+                if (StrUtil.isNotBlank(user.getUserName())) {
154
+                    userMap.put(user.getUserName(), user);
155
+                }
156
+                if (StrUtil.isNotBlank(user.getNickName())) {
157
+                    userMap.put(user.getNickName(), user);
158
+                }
159
+            }
160
+        }
161
+
162
+        List<Long> userIds = userMap.values().stream()
163
+                .map(SysUser::getUserId)
164
+                .distinct()
165
+                .collect(java.util.stream.Collectors.toList());
166
+
167
+        java.util.Map<String, ExamMonthlyScore> existScoreMap = new java.util.HashMap<>();
168
+        if (CollectionUtil.isNotEmpty(userIds)) {
169
+            // 批量查询这些用户的月考成绩
170
+            List<ExamMonthlyScore> allScores = examMonthlyScoreService.selectByUserIds(userIds);
171
+            for (ExamMonthlyScore score : allScores) {
172
+                String key = score.getUserId() + "_" + score.getYearMonth();
173
+                existScoreMap.put(key, score);
174
+            }
175
+        }
176
+
177
+        List<ExamMonthlyScore> insertList = new java.util.ArrayList<>();
178
+        List<ExamMonthlyScore> updateList = new java.util.ArrayList<>();
179
+
180
+        for (int i = 0; i < list.size(); i++) {
181
+            ExamMonthlyScoreImportVO vo = list.get(i);
182
+            int rowNum = i + 2;
183
+
184
+            try {
185
+                // 验证必填字段
186
+                if (StrUtil.isBlank(vo.getStudentName())) {
187
+                    failureNum++;
188
+                    failureMsg.append("<br/>").append(failureNum).append("、第").append(rowNum).append("行:学生姓名不能为空");
189
+                    continue;
190
+                }
191
+
192
+                if (StrUtil.isBlank(vo.getYearMonth())) {
193
+                    failureNum++;
194
+                    failureMsg.append("<br/>").append(failureNum).append("、第").append(rowNum).append("行:年月不能为空");
195
+                    continue;
196
+                }
197
+
198
+                // 从缓存中获取用户
199
+                SysUser user = userMap.get(vo.getStudentName());
200
+                if (user == null) {
201
+                    failureNum++;
202
+                    failureMsg.append("<br/>").append(failureNum).append("、第").append(rowNum).append("行:用户【").append(vo.getStudentName()).append("】不存在");
203
+                    continue;
204
+                }
205
+
206
+                // 转换年月格式
207
+                String yearMonth = convertYearMonth(vo.getYearMonth());
208
+
209
+                // 从缓存中检查是否已存在
210
+                String key = user.getUserId() + "_" + yearMonth;
211
+                ExamMonthlyScore existScore = existScoreMap.get(key);
212
+
213
+                ExamMonthlyScore score = new ExamMonthlyScore();
214
+                score.setUserId(user.getUserId());
215
+                score.setStudentName(vo.getStudentName());
216
+                score.setYearMonth(yearMonth);
217
+                score.setTeam(vo.getTeam());
218
+                score.setJobPosition(vo.getJobPosition());
219
+                score.setComprehensiveScore(vo.getComprehensiveScore());
220
+                score.setComprehensiveTime(vo.getComprehensiveTime());
221
+                score.setSpecialScore(vo.getSpecialScore());
222
+                score.setSpecialTime(vo.getSpecialTime());
223
+
224
+                if (existScore != null) {
225
+                    // 已存在
226
+                    if (updateSupport) {
227
+                        score.setId(existScore.getId());
228
+                        score.setUpdateBy(getLoginUser().getUsername());
229
+                        updateList.add(score);
230
+                        successNum++;
231
+                        successMsg.append("<br/>").append(successNum).append("、用户【").append(vo.getStudentName()).append("】").append(yearMonth).append(" 月考成绩更新成功");
232
+                    } else {
233
+                        failureNum++;
234
+                        failureMsg.append("<br/>").append(failureNum).append("、第").append(rowNum).append("行:用户【").append(vo.getStudentName()).append("】").append(yearMonth).append(" 月考成绩已存在");
235
+                    }
236
+                } else {
237
+                    // 新增
238
+                    score.setCreateBy(getLoginUser().getUsername());
239
+                    insertList.add(score);
240
+                    successNum++;
241
+                    successMsg.append("<br/>").append(successNum).append("、用户【").append(vo.getStudentName()).append("】").append(yearMonth).append(" 月考成绩导入成功");
242
+                }
243
+            } catch (Exception e) {
244
+                failureNum++;
245
+                String msg = "<br/>" + failureNum + "、第" + rowNum + "行:导入失败:";
246
+                failureMsg.append(msg).append(e.getMessage());
247
+            }
248
+        }
249
+
250
+        // 4. 批量插入和更新
251
+        if (CollectionUtil.isNotEmpty(insertList)) {
252
+            for (ExamMonthlyScore score : insertList) {
253
+                examMonthlyScoreService.insertExamMonthlyScore(score);
254
+            }
255
+        }
256
+        if (CollectionUtil.isNotEmpty(updateList)) {
257
+            for (ExamMonthlyScore score : updateList) {
258
+                examMonthlyScoreService.updateExamMonthlyScore(score);
259
+            }
260
+        }
261
+
262
+        if (failureNum > 0) {
263
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
264
+            throw new ServiceException(failureMsg.toString());
265
+        } else {
266
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
267
+        }
268
+        return successMsg.toString();
269
+    }
270
+
271
+    /**
272
+     * 转换年月格式
273
+     */
274
+    private String convertYearMonth(String yearMonth) {
275
+        if (StrUtil.isBlank(yearMonth)) {
276
+            return yearMonth;
277
+        }
278
+
279
+        yearMonth = yearMonth.trim();
280
+
281
+        if (yearMonth.contains("年") && yearMonth.contains("月")) {
282
+            yearMonth = yearMonth.replace("年", "-").replace("月", "");
283
+        }
284
+
285
+        if (yearMonth.contains(".")) {
286
+            yearMonth = yearMonth.replace(".", "-");
287
+        }
288
+
289
+        String[] parts = yearMonth.split("-");
290
+        if (parts.length == 2) {
291
+            String month = parts[1];
292
+            if (month.length() == 1) {
293
+                month = "0" + month;
294
+            }
295
+            yearMonth = parts[0] + "-" + month;
296
+        }
297
+
298
+        return yearMonth;
299
+    }
300
+}

+ 87 - 0
airport-exam/src/main/java/com/sundot/airport/exam/domain/ExamMonthlyScore.java

@@ -0,0 +1,87 @@
1
+package com.sundot.airport.exam.domain;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.sundot.airport.common.annotation.Excel;
6
+import com.sundot.airport.common.core.domain.BaseEntity;
7
+import lombok.Getter;
8
+import lombok.Setter;
9
+
10
+import java.io.Serializable;
11
+
12
+/**
13
+ * 月考成绩对象 exam_monthly_score
14
+ *
15
+ * @author ruoyi
16
+ * @date 2026-05-06
17
+ */
18
+@Getter
19
+@Setter
20
+public class ExamMonthlyScore extends BaseEntity implements Serializable {
21
+    private static final long serialVersionUID = 1L;
22
+
23
+    /**
24
+     * 主键ID
25
+     */
26
+    @TableId(value = "id", type = IdType.AUTO)
27
+    private Long id;
28
+
29
+    /**
30
+     * 用户ID
31
+     */
32
+    @Excel(name = "用户ID")
33
+    private Long userId;
34
+
35
+    /**
36
+     * 年月(格式:YYYY-MM,如2026-03)
37
+     */
38
+    @Excel(name = "年月")
39
+    private String yearMonth;
40
+
41
+    /**
42
+     * 学生姓名
43
+     */
44
+    @Excel(name = "学生姓名")
45
+    private String studentName;
46
+
47
+    /**
48
+     * 科队(T2一大队/T2二大队/T2三大队/综合大队/T1一大队/T1二大队/T1三大队)
49
+     */
50
+    @Excel(name = "科队")
51
+    private String team;
52
+
53
+    /**
54
+     * 岗位(X光机操作员/四级安检员)
55
+     */
56
+    @Excel(name = "岗位")
57
+    private String jobPosition;
58
+
59
+    /**
60
+     * 综合成绩
61
+     */
62
+    @Excel(name = "综合成绩")
63
+    private Integer comprehensiveScore;
64
+
65
+    /**
66
+     * 综合成绩用时(格式:XX分XX秒,如24分3秒)
67
+     */
68
+    @Excel(name = "综合用时")
69
+    private String comprehensiveTime;
70
+
71
+    /**
72
+     * 专项成绩
73
+     */
74
+    @Excel(name = "专项成绩")
75
+    private Integer specialScore;
76
+
77
+    /**
78
+     * 专项成绩用时(格式:XX分XX秒,如18分56秒)
79
+     */
80
+    @Excel(name = "专项用时")
81
+    private String specialTime;
82
+
83
+    /**
84
+     * 删除标志(0代表存在 1代表删除)
85
+     */
86
+    private String delFlag;
87
+}

+ 62 - 0
airport-exam/src/main/java/com/sundot/airport/exam/dto/ExamMonthlyScoreImportVO.java

@@ -0,0 +1,62 @@
1
+package com.sundot.airport.exam.dto;
2
+
3
+import com.sundot.airport.common.annotation.Excel;
4
+import lombok.Data;
5
+
6
+/**
7
+ * 月考成绩导入VO
8
+ *
9
+ * @author ruoyi
10
+ * @date 2026-05-06
11
+ */
12
+@Data
13
+public class ExamMonthlyScoreImportVO {
14
+
15
+    /**
16
+     * 年月(格式:2026年3月)
17
+     */
18
+    @Excel(name = "年月")
19
+    private String yearMonth;
20
+
21
+    /**
22
+     * 学生姓名
23
+     */
24
+    @Excel(name = "学生")
25
+    private String studentName;
26
+
27
+    /**
28
+     * 科队
29
+     */
30
+    @Excel(name = "科队")
31
+    private String team;
32
+
33
+    /**
34
+     * 岗位
35
+     */
36
+    @Excel(name = "岗位")
37
+    private String jobPosition;
38
+
39
+    /**
40
+     * 综合成绩
41
+     */
42
+    @Excel(name = "综合成绩")
43
+    private Integer comprehensiveScore;
44
+
45
+    /**
46
+     * 综合成绩用时(格式:24分3秒)
47
+     */
48
+    @Excel(name = "综合用时")
49
+    private String comprehensiveTime;
50
+
51
+    /**
52
+     * 专项成绩
53
+     */
54
+    @Excel(name = "专项成绩")
55
+    private Integer specialScore;
56
+
57
+    /**
58
+     * 专项成绩用时(格式:18分56秒)
59
+     */
60
+    @Excel(name = "专项用时")
61
+    private String specialTime;
62
+}

+ 79 - 0
airport-exam/src/main/java/com/sundot/airport/exam/mapper/ExamMonthlyScoreMapper.java

@@ -0,0 +1,79 @@
1
+package com.sundot.airport.exam.mapper;
2
+
3
+import com.sundot.airport.exam.domain.ExamMonthlyScore;
4
+import org.apache.ibatis.annotations.Param;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * 月考成绩Mapper接口
10
+ *
11
+ * @author ruoyi
12
+ * @date 2026-05-06
13
+ */
14
+public interface ExamMonthlyScoreMapper {
15
+    /**
16
+     * 查询月考成绩
17
+     *
18
+     * @param id 月考成绩主键
19
+     * @return 月考成绩
20
+     */
21
+    public ExamMonthlyScore selectExamMonthlyScoreById(Long id);
22
+
23
+    /**
24
+     * 查询月考成绩列表
25
+     *
26
+     * @param examMonthlyScore 月考成绩
27
+     * @return 月考成绩集合
28
+     */
29
+    public List<ExamMonthlyScore> selectExamMonthlyScoreList(ExamMonthlyScore examMonthlyScore);
30
+
31
+    /**
32
+     * 新增月考成绩
33
+     *
34
+     * @param examMonthlyScore 月考成绩
35
+     * @return 结果
36
+     */
37
+    public int insertExamMonthlyScore(ExamMonthlyScore examMonthlyScore);
38
+
39
+    /**
40
+     * 修改月考成绩
41
+     *
42
+     * @param examMonthlyScore 月考成绩
43
+     * @return 结果
44
+     */
45
+    public int updateExamMonthlyScore(ExamMonthlyScore examMonthlyScore);
46
+
47
+    /**
48
+     * 删除月考成绩
49
+     *
50
+     * @param id 月考成绩主键
51
+     * @return 结果
52
+     */
53
+    public int deleteExamMonthlyScoreById(Long id);
54
+
55
+    /**
56
+     * 批量删除月考成绩
57
+     *
58
+     * @param ids 需要删除的数据主键集合
59
+     * @return 结果
60
+     */
61
+    public int deleteExamMonthlyScoreByIds(Long[] ids);
62
+
63
+    /**
64
+     * 根据用户ID和年月查询月考成绩
65
+     *
66
+     * @param userId    用户ID
67
+     * @param yearMonth 年月
68
+     * @return 月考成绩
69
+     */
70
+    public ExamMonthlyScore selectByUserIdAndYearMonth(@Param("userId") Long userId, @Param("yearMonth") String yearMonth);
71
+
72
+    /**
73
+     * 批量查询指定用户的月考成绩
74
+     *
75
+     * @param userIds 用户ID列表
76
+     * @return 月考成绩集合
77
+     */
78
+    public List<ExamMonthlyScore> selectByUserIds(@Param("userIds") List<Long> userIds);
79
+}

+ 78 - 0
airport-exam/src/main/java/com/sundot/airport/exam/service/IExamMonthlyScoreService.java

@@ -0,0 +1,78 @@
1
+package com.sundot.airport.exam.service;
2
+
3
+import com.sundot.airport.exam.domain.ExamMonthlyScore;
4
+
5
+import java.util.List;
6
+
7
+/**
8
+ * 月考成绩Service接口
9
+ *
10
+ * @author ruoyi
11
+ * @date 2026-05-06
12
+ */
13
+public interface IExamMonthlyScoreService {
14
+    /**
15
+     * 查询月考成绩
16
+     *
17
+     * @param id 月考成绩主键
18
+     * @return 月考成绩
19
+     */
20
+    public ExamMonthlyScore selectExamMonthlyScoreById(Long id);
21
+
22
+    /**
23
+     * 查询月考成绩列表
24
+     *
25
+     * @param examMonthlyScore 月考成绩
26
+     * @return 月考成绩集合
27
+     */
28
+    public List<ExamMonthlyScore> selectExamMonthlyScoreList(ExamMonthlyScore examMonthlyScore);
29
+
30
+    /**
31
+     * 新增月考成绩
32
+     *
33
+     * @param examMonthlyScore 月考成绩
34
+     * @return 结果
35
+     */
36
+    public int insertExamMonthlyScore(ExamMonthlyScore examMonthlyScore);
37
+
38
+    /**
39
+     * 修改月考成绩
40
+     *
41
+     * @param examMonthlyScore 月考成绩
42
+     * @return 结果
43
+     */
44
+    public int updateExamMonthlyScore(ExamMonthlyScore examMonthlyScore);
45
+
46
+    /**
47
+     * 批量删除月考成绩
48
+     *
49
+     * @param ids 需要删除的月考成绩主键集合
50
+     * @return 结果
51
+     */
52
+    public int deleteExamMonthlyScoreByIds(Long[] ids);
53
+
54
+    /**
55
+     * 删除月考成绩信息
56
+     *
57
+     * @param id 月考成绩主键
58
+     * @return 结果
59
+     */
60
+    public int deleteExamMonthlyScoreById(Long id);
61
+
62
+    /**
63
+     * 根据用户ID和年月查询月考成绩
64
+     *
65
+     * @param userId    用户ID
66
+     * @param yearMonth 年月
67
+     * @return 月考成绩
68
+     */
69
+    public ExamMonthlyScore selectByUserIdAndYearMonth(Long userId, String yearMonth);
70
+
71
+    /**
72
+     * 批量查询指定用户的月考成绩
73
+     *
74
+     * @param userIds 用户ID列表
75
+     * @return 月考成绩集合
76
+     */
77
+    public List<ExamMonthlyScore> selectByUserIds(List<Long> userIds);
78
+}

+ 111 - 0
airport-exam/src/main/java/com/sundot/airport/exam/service/impl/ExamMonthlyScoreServiceImpl.java

@@ -0,0 +1,111 @@
1
+package com.sundot.airport.exam.service.impl;
2
+
3
+import cn.hutool.core.collection.CollectionUtil;
4
+import com.sundot.airport.exam.domain.ExamMonthlyScore;
5
+import com.sundot.airport.exam.mapper.ExamMonthlyScoreMapper;
6
+import com.sundot.airport.exam.service.IExamMonthlyScoreService;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Service;
9
+
10
+import java.util.List;
11
+
12
+/**
13
+ * 月考成绩Service业务层处理
14
+ *
15
+ * @author ruoyi
16
+ * @date 2026-05-06
17
+ */
18
+@Service
19
+public class ExamMonthlyScoreServiceImpl implements IExamMonthlyScoreService {
20
+    @Autowired
21
+    private ExamMonthlyScoreMapper examMonthlyScoreMapper;
22
+
23
+    /**
24
+     * 查询月考成绩
25
+     *
26
+     * @param id 月考成绩主键
27
+     * @return 月考成绩
28
+     */
29
+    @Override
30
+    public ExamMonthlyScore selectExamMonthlyScoreById(Long id) {
31
+        return examMonthlyScoreMapper.selectExamMonthlyScoreById(id);
32
+    }
33
+
34
+    /**
35
+     * 查询月考成绩列表
36
+     *
37
+     * @param examMonthlyScore 月考成绩
38
+     * @return 月考成绩
39
+     */
40
+    @Override
41
+    public List<ExamMonthlyScore> selectExamMonthlyScoreList(ExamMonthlyScore examMonthlyScore) {
42
+        return examMonthlyScoreMapper.selectExamMonthlyScoreList(examMonthlyScore);
43
+    }
44
+
45
+    /**
46
+     * 新增月考成绩
47
+     *
48
+     * @param examMonthlyScore 月考成绩
49
+     * @return 结果
50
+     */
51
+    @Override
52
+    public int insertExamMonthlyScore(ExamMonthlyScore examMonthlyScore) {
53
+        return examMonthlyScoreMapper.insertExamMonthlyScore(examMonthlyScore);
54
+    }
55
+
56
+    /**
57
+     * 修改月考成绩
58
+     *
59
+     * @param examMonthlyScore 月考成绩
60
+     * @return 结果
61
+     */
62
+    @Override
63
+    public int updateExamMonthlyScore(ExamMonthlyScore examMonthlyScore) {
64
+        return examMonthlyScoreMapper.updateExamMonthlyScore(examMonthlyScore);
65
+    }
66
+
67
+    /**
68
+     * 批量删除月考成绩
69
+     *
70
+     * @param ids 需要删除的月考成绩主键
71
+     * @return 结果
72
+     */
73
+    @Override
74
+    public int deleteExamMonthlyScoreByIds(Long[] ids) {
75
+        return examMonthlyScoreMapper.deleteExamMonthlyScoreByIds(ids);
76
+    }
77
+
78
+    /**
79
+     * 删除月考成绩信息
80
+     *
81
+     * @param id 月考成绩主键
82
+     * @return 结果
83
+     */
84
+    @Override
85
+    public int deleteExamMonthlyScoreById(Long id) {
86
+        return examMonthlyScoreMapper.deleteExamMonthlyScoreById(id);
87
+    }
88
+
89
+    /**
90
+     * 根据用户ID和年月查询月考成绩
91
+     *
92
+     * @param userId    用户ID
93
+     * @param yearMonth 年月
94
+     * @return 月考成绩
95
+     */
96
+    @Override
97
+    public ExamMonthlyScore selectByUserIdAndYearMonth(Long userId, String yearMonth) {
98
+        return examMonthlyScoreMapper.selectByUserIdAndYearMonth(userId, yearMonth);
99
+    }
100
+
101
+    /**
102
+     * 批量查询指定用户的月考成绩
103
+     *
104
+     * @param userIds 用户ID列表
105
+     * @return 月考成绩集合
106
+     */
107
+    @Override
108
+    public List<ExamMonthlyScore> selectByUserIds(List<Long> userIds) {
109
+        return examMonthlyScoreMapper.selectByUserIds(userIds);
110
+    }
111
+}

+ 152 - 0
airport-exam/src/main/resources/mapper/exam/ExamMonthlyScoreMapper.xml

@@ -0,0 +1,152 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.sundot.airport.exam.mapper.ExamMonthlyScoreMapper">
6
+
7
+    <resultMap type="ExamMonthlyScore" id="ExamMonthlyScoreResult">
8
+        <id property="id" column="id"/>
9
+        <result property="userId" column="user_id"/>
10
+        <result property="yearMonth" column="year_month"/>
11
+        <result property="studentName" column="student_name"/>
12
+        <result property="team" column="team"/>
13
+        <result property="jobPosition" column="job_position"/>
14
+        <result property="comprehensiveScore" column="comprehensive_score"/>
15
+        <result property="comprehensiveTime" column="comprehensive_time"/>
16
+        <result property="specialScore" column="special_score"/>
17
+        <result property="specialTime" column="special_time"/>
18
+        <result property="delFlag" column="del_flag"/>
19
+        <result property="createBy" column="create_by"/>
20
+        <result property="createTime" column="create_time"/>
21
+        <result property="updateBy" column="update_by"/>
22
+        <result property="updateTime" column="update_time"/>
23
+        <result property="remark" column="remark"/>
24
+    </resultMap>
25
+
26
+    <sql id="selectExamMonthlyScoreVo">
27
+        select id,
28
+               user_id,
29
+               `year_month`,
30
+               student_name,
31
+               team,
32
+               job_position,
33
+               comprehensive_score,
34
+               comprehensive_time,
35
+               special_score,
36
+               special_time,
37
+               del_flag,
38
+               create_by,
39
+               create_time,
40
+               update_by,
41
+               update_time,
42
+               remark
43
+        from exam_monthly_score
44
+    </sql>
45
+
46
+    <select id="selectExamMonthlyScoreList" parameterType="ExamMonthlyScore" resultMap="ExamMonthlyScoreResult">
47
+        <include refid="selectExamMonthlyScoreVo"/>
48
+        <where>
49
+            del_flag = '0'
50
+            <if test="userId != null">
51
+                AND user_id = #{userId}
52
+            </if>
53
+            <if test="yearMonth != null and yearMonth != ''">
54
+                AND `year_month` = #{yearMonth}
55
+            </if>
56
+            <if test="studentName != null and studentName != ''">
57
+                AND student_name like concat('%', #{studentName}, '%')
58
+            </if>
59
+            <if test="team != null and team != ''">
60
+                AND team = #{team}
61
+            </if>
62
+            <if test="jobPosition != null and jobPosition != ''">
63
+                AND job_position = #{jobPosition}
64
+            </if>
65
+        </where>
66
+        order by `year_month` desc, create_time desc
67
+    </select>
68
+
69
+    <select id="selectExamMonthlyScoreById" parameterType="Long" resultMap="ExamMonthlyScoreResult">
70
+        <include refid="selectExamMonthlyScoreVo"/>
71
+        where id = #{id} and del_flag = '0'
72
+    </select>
73
+
74
+    <select id="selectByUserIdAndYearMonth" resultMap="ExamMonthlyScoreResult">
75
+        <include refid="selectExamMonthlyScoreVo"/>
76
+        where user_id = #{userId} and `year_month` = #{yearMonth} and del_flag = '0'
77
+        limit 1
78
+    </select>
79
+
80
+    <select id="selectByUserIds" resultMap="ExamMonthlyScoreResult">
81
+        <include refid="selectExamMonthlyScoreVo"/>
82
+        where del_flag = '0'
83
+        and user_id in
84
+        <foreach item="userId" collection="userIds" open="(" separator="," close=")">
85
+            #{userId}
86
+        </foreach>
87
+    </select>
88
+
89
+    <insert id="insertExamMonthlyScore" parameterType="ExamMonthlyScore" useGeneratedKeys="true" keyProperty="id">
90
+        insert into exam_monthly_score
91
+        <trim prefix="(" suffix=")" suffixOverrides=",">
92
+            <if test="userId != null">user_id,</if>
93
+            <if test="yearMonth != null and yearMonth != ''">`year_month`,</if>
94
+            <if test="studentName != null and studentName != ''">student_name,</if>
95
+            <if test="team != null and team != ''">team,</if>
96
+            <if test="jobPosition != null and jobPosition != ''">job_position,</if>
97
+            <if test="comprehensiveScore != null">comprehensive_score,</if>
98
+            <if test="comprehensiveTime != null and comprehensiveTime != ''">comprehensive_time,</if>
99
+            <if test="specialScore != null">special_score,</if>
100
+            <if test="specialTime != null and specialTime != ''">special_time,</if>
101
+            <if test="delFlag != null and delFlag != ''">del_flag,</if>
102
+            <if test="createBy != null and createBy != ''">create_by,</if>
103
+            <if test="remark != null">remark,</if>
104
+            create_time
105
+        </trim>
106
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
107
+            <if test="userId != null">#{userId},</if>
108
+            <if test="yearMonth != null and yearMonth != ''">#{yearMonth},</if>
109
+            <if test="studentName != null and studentName != ''">#{studentName},</if>
110
+            <if test="team != null and team != ''">#{team},</if>
111
+            <if test="jobPosition != null and jobPosition != ''">#{jobPosition},</if>
112
+            <if test="comprehensiveScore != null">#{comprehensiveScore},</if>
113
+            <if test="comprehensiveTime != null and comprehensiveTime != ''">#{comprehensiveTime},</if>
114
+            <if test="specialScore != null">#{specialScore},</if>
115
+            <if test="specialTime != null and specialTime != ''">#{specialTime},</if>
116
+            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
117
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
118
+            <if test="remark != null">#{remark},</if>
119
+            sysdate()
120
+        </trim>
121
+    </insert>
122
+
123
+    <update id="updateExamMonthlyScore" parameterType="ExamMonthlyScore">
124
+        update exam_monthly_score
125
+        <trim prefix="SET" suffixOverrides=",">
126
+            <if test="userId != null">user_id = #{userId},</if>
127
+            <if test="yearMonth != null and yearMonth != ''">`year_month` = #{yearMonth},</if>
128
+            <if test="studentName != null and studentName != ''">student_name = #{studentName},</if>
129
+            <if test="team != null and team != ''">team = #{team},</if>
130
+            <if test="jobPosition != null and jobPosition != ''">job_position = #{jobPosition},</if>
131
+            <if test="comprehensiveScore != null">comprehensive_score = #{comprehensiveScore},</if>
132
+            <if test="comprehensiveTime != null and comprehensiveTime != ''">comprehensive_time = #{comprehensiveTime},</if>
133
+            <if test="specialScore != null">special_score = #{specialScore},</if>
134
+            <if test="specialTime != null and specialTime != ''">special_time = #{specialTime},</if>
135
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
136
+            <if test="remark != null">remark = #{remark},</if>
137
+            update_time = sysdate()
138
+        </trim>
139
+        where id = #{id}
140
+    </update>
141
+
142
+    <delete id="deleteExamMonthlyScoreById" parameterType="Long">
143
+        update exam_monthly_score set del_flag = '1' where id = #{id}
144
+    </delete>
145
+
146
+    <delete id="deleteExamMonthlyScoreByIds" parameterType="Long">
147
+        update exam_monthly_score set del_flag = '1' where id in
148
+        <foreach item="id" collection="array" open="(" separator="," close=")">
149
+            #{id}
150
+        </foreach>
151
+    </delete>
152
+</mapper>

+ 8 - 0
airport-system/src/main/java/com/sundot/airport/system/mapper/SysUserMapper.java

@@ -263,4 +263,12 @@ public interface SysUserMapper {
263 263
      * @return 用户信息集合
264 264
      */
265 265
     public List<SysUser> selectUserLeaderByDeptIdAndRoleKeyList(@Param("deptId") Long deptId, @Param("list") List<String> list);
266
+
267
+    /**
268
+     * 批量根据用户名或昵称查询用户
269
+     *
270
+     * @param names 用户名或昵称列表
271
+     * @return 用户信息集合
272
+     */
273
+    public List<SysUser> selectUsersByNames(@Param("names") List<String> names);
266 274
 }

+ 8 - 0
airport-system/src/main/java/com/sundot/airport/system/service/ISysUserService.java

@@ -353,4 +353,12 @@ public interface ISysUserService {
353 353
      * @return 用户信息集合
354 354
      */
355 355
     public List<SysUser> selectUserLeaderListByCondition(SysUserLeaderConditionDto dto);
356
+
357
+    /**
358
+     * 批量根据用户名或昵称查询用户
359
+     *
360
+     * @param names 用户名或昵称列表
361
+     * @return 用户信息集合
362
+     */
363
+    public List<SysUser> selectUsersByNames(List<String> names);
356 364
 }

+ 11 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/SysUserServiceImpl.java

@@ -819,6 +819,17 @@ public class SysUserServiceImpl implements ISysUserService {
819 819
     }
820 820
 
821 821
     /**
822
+     * 批量根据用户名或昵称查询用户
823
+     *
824
+     * @param names 用户名或昵称列表
825
+     * @return 用户信息集合
826
+     */
827
+    @Override
828
+    public List<SysUser> selectUsersByNames(List<String> names) {
829
+        return userMapper.selectUsersByNames(names);
830
+    }
831
+
832
+    /**
822 833
      * 能力画像-协同配合
823 834
      *
824 835
      * @param dto 上行参数

+ 15 - 0
airport-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -1204,4 +1204,19 @@
1204 1204
             #{item}
1205 1205
         </foreach>
1206 1206
     </select>
1207
+
1208
+    <select id="selectUsersByNames" resultMap="SysUserResult">
1209
+        <include refid="selectUserVo"/>
1210
+        where u.del_flag = '0'
1211
+        and (
1212
+            u.user_name in
1213
+            <foreach collection="names" item="name" open="(" separator="," close=")">
1214
+                #{name}
1215
+            </foreach>
1216
+            or u.nick_name in
1217
+            <foreach collection="names" item="name" open="(" separator="," close=")">
1218
+                #{name}
1219
+            </foreach>
1220
+        )
1221
+    </select>
1207 1222
 </mapper>