|
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
8
|
8
|
import org.springframework.transaction.annotation.Transactional;
|
9
|
9
|
|
10
|
10
|
import javax.annotation.Resource;
|
|
11
|
+import java.util.ArrayList;
|
11
|
12
|
import java.util.List;
|
12
|
13
|
|
13
|
14
|
/**
|
|
@@ -31,12 +32,9 @@ public class MspGradeparamService {
|
31
|
32
|
public void saveGradeparam(GradeParams gradeParams) {
|
32
|
33
|
List<MspReportparam> originalParams = mspGradeparamMapper.getGradeParamByGradeAndBelong(gradeParams);
|
33
|
34
|
|
34
|
|
- if(originalParams!= null && originalParams.size() > 0) {
|
35
|
|
- mspGradeparamMapper.deleteGradeparam(gradeParams);
|
36
|
|
- }
|
37
|
|
-
|
38
|
35
|
Integer timestamp = N_Utils.getSecondTimestamp();
|
39
|
36
|
List<MspReportparam> params = gradeParams.getParams();
|
|
37
|
+ List<Integer> delids = new ArrayList<>();
|
40
|
38
|
for(MspReportparam param : params) {
|
41
|
39
|
param.setRpbelong(gradeParams.getRpbelong());
|
42
|
40
|
param.setGradeid(gradeParams.getGradeid());
|
|
@@ -45,7 +43,24 @@ public class MspGradeparamService {
|
45
|
43
|
param.setHandletime(timestamp);
|
46
|
44
|
if(param.getRptype() == null) param.setRptype(0);
|
47
|
45
|
if(param.getGradenum() == null) param.setGradenum(0);
|
|
46
|
+
|
|
47
|
+ //如果同类型同科目的数据已存在,删除原数据
|
|
48
|
+ if(originalParams!= null && originalParams.size() > 0) {
|
|
49
|
+ MspReportparam oldParam;
|
|
50
|
+ if(N_Utils.isNotEmpty(param.getSubjectid())){
|
|
51
|
+ oldParam = originalParams.stream().filter(p -> param.getRptype().equals(p.getRptype()) && param.getSubjectid().equals(p.getSubjectid())).findFirst().orElse(null);
|
|
52
|
+ }else{
|
|
53
|
+ oldParam = originalParams.stream().filter(p -> param.getRptype().equals(p.getRptype())).findFirst().orElse(null);
|
|
54
|
+ }
|
|
55
|
+ if(oldParam!= null) {
|
|
56
|
+ delids.add(oldParam.getRpid());
|
|
57
|
+ }
|
|
58
|
+ }
|
48
|
59
|
}
|
|
60
|
+ if(delids.size() > 0) {
|
|
61
|
+ mspGradeparamMapper.deleteGradeparam(delids);
|
|
62
|
+ }
|
|
63
|
+
|
49
|
64
|
mspGradeparamMapper.insertList(params);
|
50
|
65
|
|
51
|
66
|
}
|