|
@@ -0,0 +1,121 @@
|
|
1
|
+package com.xhkjedu.smarking.service.report.reportother;
|
|
2
|
+
|
|
3
|
+import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
|
|
4
|
+import com.xhkjedu.smarking.mapper.wholeparam.MspReportparamMapper;
|
|
5
|
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
|
|
6
|
+import com.xhkjedu.smarking.model.wholeparam.MspReportparam;
|
|
7
|
+import com.xhkjedu.smarking.vo.report.reportother.ReportParams;
|
|
8
|
+import com.xhkjedu.utils.N_Utils;
|
|
9
|
+import org.springframework.stereotype.Service;
|
|
10
|
+import org.springframework.transaction.annotation.Transactional;
|
|
11
|
+
|
|
12
|
+import javax.annotation.Resource;
|
|
13
|
+import java.util.ArrayList;
|
|
14
|
+import java.util.List;
|
|
15
|
+import java.util.Map;
|
|
16
|
+import java.util.stream.Collectors;
|
|
17
|
+
|
|
18
|
+/**
|
|
19
|
+ * @Description:考试参数
|
|
20
|
+ * @Author: WN
|
|
21
|
+ * @Date: 2024/12/9 14:13:17
|
|
22
|
+ **/
|
|
23
|
+@Service
|
|
24
|
+public class MsrReportparamService {
|
|
25
|
+ @Resource
|
|
26
|
+ private MsrReportparamMapper msrReportparamMapper;
|
|
27
|
+ @Resource
|
|
28
|
+ private MspReportparamMapper mspReportparamMapper;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+ /*
|
|
32
|
+ * @Description 考试参数--保存
|
|
33
|
+ * @Date 2024/12/9 14:55:30
|
|
34
|
+ * @Author WN
|
|
35
|
+ * @Param [reportParams]
|
|
36
|
+ * @Return void
|
|
37
|
+ **/
|
|
38
|
+ @Transactional(rollbackFor = Exception.class)
|
|
39
|
+ public void saveReportparam(ReportParams reportParams) {
|
|
40
|
+ List<MsrReportparam> originalParams = msrReportparamMapper.listReportparamByRpbelong(reportParams.getRpbelong(), reportParams.getExamid());
|
|
41
|
+
|
|
42
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
43
|
+ List<MsrReportparam> params = reportParams.getParams();
|
|
44
|
+ List<Integer> delids = new ArrayList<>();
|
|
45
|
+ for(MsrReportparam param : params) {
|
|
46
|
+ param.setRpbelong(reportParams.getRpbelong());
|
|
47
|
+ param.setExamid(reportParams.getExamid());
|
|
48
|
+ param.setHandleid(reportParams.getHandleid());
|
|
49
|
+ param.setHandletime(timestamp);
|
|
50
|
+ if(param.getRptype() == null) param.setRptype(0);
|
|
51
|
+ if(param.getGradenum() == null) param.setGradenum(0);
|
|
52
|
+
|
|
53
|
+ //如果同类型同科目的数据已存在,删除原数据
|
|
54
|
+ if(originalParams!= null && originalParams.size() > 0) {
|
|
55
|
+ MsrReportparam oldParam;
|
|
56
|
+ if(N_Utils.isNotEmpty(param.getSubjectid())){
|
|
57
|
+ oldParam = originalParams.stream().filter(p -> param.getRptype().equals(p.getRptype()) && param.getSubjectid().equals(p.getSubjectid())).findFirst().orElse(null);
|
|
58
|
+ }else{
|
|
59
|
+ oldParam = originalParams.stream().filter(p -> param.getRptype().equals(p.getRptype())).findFirst().orElse(null);
|
|
60
|
+ }
|
|
61
|
+ if(oldParam!= null) {
|
|
62
|
+ delids.add(oldParam.getRpid());
|
|
63
|
+ }
|
|
64
|
+ }
|
|
65
|
+ }
|
|
66
|
+ if(delids.size() > 0) {
|
|
67
|
+ msrReportparamMapper.deleteBatchReportparam(delids);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ msrReportparamMapper.insertList(params);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ /*
|
|
74
|
+ * @Description 考试参数--获取
|
|
75
|
+ * @Date 2024/12/9 14:56:14
|
|
76
|
+ * @Author WN
|
|
77
|
+ * @Param [rpbelong, examid]
|
|
78
|
+ * @Return java.util.List<com.xhkjedu.smarking.model.report.reportother.MsrReportparam>
|
|
79
|
+ **/
|
|
80
|
+ public List<MsrReportparam> listReportparamByRpbelong(String rpbelong, Integer examid) {
|
|
81
|
+ return msrReportparamMapper.listReportparamByRpbelong(rpbelong, examid);
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ /*
|
|
85
|
+ * @Description 初始化参数
|
|
86
|
+ * @Date 2024/12/9 15:06:42
|
|
87
|
+ * @Author WN
|
|
88
|
+ * @Param [schoolid, gradeid, examid, handleid]
|
|
89
|
+ * @Return void
|
|
90
|
+ **/
|
|
91
|
+ public void initReportparam(Integer schoolid,Integer gradeid,Integer examid,Integer handleid) {
|
|
92
|
+ List<MspReportparam> mspParams = mspReportparamMapper.listAllByGrade(schoolid,gradeid);
|
|
93
|
+ List<MsrReportparam> saveParams = new ArrayList<>();
|
|
94
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
95
|
+ //按类型进行分组
|
|
96
|
+ Map<String,List<MspReportparam>> mspParamMap = mspParams.stream().collect(Collectors.groupingBy(MspReportparam::getRpbelong));
|
|
97
|
+ for (Map.Entry<String, List<MspReportparam>> entry : mspParamMap.entrySet()) {
|
|
98
|
+ List<MspReportparam> params = entry.getValue();
|
|
99
|
+ //获取对应年级的
|
|
100
|
+ List<MspReportparam> gradeParams = params.stream().filter(p -> p.getGradeid().equals(gradeid)).collect(Collectors.toList());
|
|
101
|
+ if(gradeParams == null || gradeParams.size() == 0){
|
|
102
|
+ gradeParams = params;
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ //说明对应年级下有设置
|
|
106
|
+ for(MspReportparam param : gradeParams){
|
|
107
|
+ MsrReportparam rp = new MsrReportparam();
|
|
108
|
+ rp.setExamid(examid);
|
|
109
|
+ rp.setRpbelong(entry.getKey());
|
|
110
|
+ rp.setRptype(param.getRptype());
|
|
111
|
+ rp.setGradenum(param.getGradenum());
|
|
112
|
+ rp.setSubjectid(param.getSubjectid());
|
|
113
|
+ rp.setSzjson(param.getSzjson());
|
|
114
|
+ rp.setHandletime(timestamp);
|
|
115
|
+ rp.setHandleid(handleid);
|
|
116
|
+ saveParams.add(rp);
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ msrReportparamMapper.insertList(saveParams);
|
|
120
|
+ }
|
|
121
|
+}
|