王宁 пре 2 недеља
родитељ
комит
2e75cf4c99

smarking/src/main/java/com/xhkjedu/smarking/controller/wholeparam/MspGradeparamController.java → smarking/src/main/java/com/xhkjedu/smarking/controller/wholeparam/MspReportparamController.java Прегледај датотеку


smarking/src/main/java/com/xhkjedu/smarking/mapper/wholeparam/MspGradeparamMapper.java → smarking/src/main/java/com/xhkjedu/smarking/mapper/wholeparam/MspReportparamMapper.java Прегледај датотеку

@@ -17,5 +17,8 @@ public interface MspGradeparamMapper extends TkMapper<MspReportparam> {
17 17
     //获取学校年级下指定模块参数
18 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 Прегледај датотеку

@@ -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
     }

smarking/src/main/resources/mapper/wholeparam/MsGradeparamMapper.xml → smarking/src/main/resources/mapper/wholeparam/MspReportparamMapper.xml Прегледај датотеку

@@ -9,6 +9,12 @@
9 9
 
10 10
     <!--删除-->
11 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 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 20
 </mapper>

Loading…
Откажи
Сачувај