Browse Source

考试参数

ywx
王宁 2 weeks ago
parent
commit
2e75cf4c99

smarking/src/main/java/com/xhkjedu/smarking/controller/wholeparam/MspGradeparamController.java → smarking/src/main/java/com/xhkjedu/smarking/controller/wholeparam/MspReportparamController.java View File


smarking/src/main/java/com/xhkjedu/smarking/mapper/wholeparam/MspGradeparamMapper.java → smarking/src/main/java/com/xhkjedu/smarking/mapper/wholeparam/MspReportparamMapper.java View File

17
     //获取学校年级下指定模块参数
17
     //获取学校年级下指定模块参数
18
     List<MspReportparam> getGradeParamByGradeAndBelong(@Param("gp") GradeParams gp);
18
     List<MspReportparam> getGradeParamByGradeAndBelong(@Param("gp") GradeParams gp);
19
     //删除
19
     //删除
20
-    int deleteGradeparam(@Param("gp")GradeParams gp);
20
+    int deleteGradeparam(@Param("list")List<Integer> list);
21
+
22
+    //获取学校指定年级下所有参数
23
+    List<MspReportparam> listAllByGrade(@Param("schoolid") Integer schoolid,@Param("gradeid") Integer gradeid);
21
 }
24
 }

smarking/src/main/java/com/xhkjedu/smarking/service/wholeparam/MspGradeparamService.java → smarking/src/main/java/com/xhkjedu/smarking/service/wholeparam/MspReportparamService.java View File

8
 import org.springframework.transaction.annotation.Transactional;
8
 import org.springframework.transaction.annotation.Transactional;
9
 
9
 
10
 import javax.annotation.Resource;
10
 import javax.annotation.Resource;
11
+import java.util.ArrayList;
11
 import java.util.List;
12
 import java.util.List;
12
 
13
 
13
 /**
14
 /**
31
     public void saveGradeparam(GradeParams gradeParams) {
32
     public void saveGradeparam(GradeParams gradeParams) {
32
         List<MspReportparam> originalParams = mspGradeparamMapper.getGradeParamByGradeAndBelong(gradeParams);
33
         List<MspReportparam> originalParams = mspGradeparamMapper.getGradeParamByGradeAndBelong(gradeParams);
33
 
34
 
34
-        if(originalParams!= null && originalParams.size() > 0) {
35
-            mspGradeparamMapper.deleteGradeparam(gradeParams);
36
-        }
37
-
38
         Integer timestamp = N_Utils.getSecondTimestamp();
35
         Integer timestamp = N_Utils.getSecondTimestamp();
39
         List<MspReportparam> params = gradeParams.getParams();
36
         List<MspReportparam> params = gradeParams.getParams();
37
+        List<Integer> delids = new ArrayList<>();
40
         for(MspReportparam param : params) {
38
         for(MspReportparam param : params) {
41
             param.setRpbelong(gradeParams.getRpbelong());
39
             param.setRpbelong(gradeParams.getRpbelong());
42
             param.setGradeid(gradeParams.getGradeid());
40
             param.setGradeid(gradeParams.getGradeid());
45
             param.setHandletime(timestamp);
43
             param.setHandletime(timestamp);
46
             if(param.getRptype() == null) param.setRptype(0);
44
             if(param.getRptype() == null) param.setRptype(0);
47
             if(param.getGradenum() == null) param.setGradenum(0);
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
         mspGradeparamMapper.insertList(params);
64
         mspGradeparamMapper.insertList(params);
50
 
65
 
51
     }
66
     }

smarking/src/main/resources/mapper/wholeparam/MsGradeparamMapper.xml → smarking/src/main/resources/mapper/wholeparam/MspReportparamMapper.xml View File

9
 
9
 
10
     <!--删除-->
10
     <!--删除-->
11
     <delete id="deleteGradeparam">
11
     <delete id="deleteGradeparam">
12
-        delete from msp_reportparam where schoolid = #{gp.schoolid} and gradeid=#{gp.gradeid} and rpbelong = #{gp.rpbelong}
12
+        delete from msp_reportparam where rpid in
13
+        <foreach collection="list" item="rpid" open="(" separator="," close=")">#{rpid}</foreach>
13
     </delete>
14
     </delete>
15
+
16
+    <!--获取学校指定年级下所有参数-->
17
+    <select id="listAllByGrade" resultType="com.xhkjedu.smarking.model.wholeparam.MspReportparam">
18
+        select * from msp_reportparam where schoolid = #{schoolid} and (gradeid = #{gradeid} or gradeid = 0)
19
+    </select>
14
 </mapper>
20
 </mapper>

Loading…
Cancel
Save