Browse Source

学年升级添加记录

tags/正式3.10.0
雍文秀 1 year ago
parent
commit
5d01f97dc5

+ 34
- 12
sapi/src/main/java/com/xhkjedu/sapi/controller/system/SchoolController.java View File

@@ -66,7 +66,7 @@ public class SchoolController {
66 66
         Integer pageSize = tSchool.getPageSize();
67 67
         N_Utils.validation(new Object[]{page,"显示页码",1,pageSize,"显示条数",1});
68 68
         PageHelper.startPage(page, pageSize);
69
-        List<Map> list = schoolService.findAll();
69
+        List<Map<String,Object>> list = schoolService.findAll();
70 70
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
71 71
         return new ResultVo(0,"获取列表成功",pageResult);
72 72
     }
@@ -82,7 +82,7 @@ public class SchoolController {
82 82
         N_Utils.validation(new Object[]{schoolid,"学校id",1});
83 83
 
84 84
         try {
85
-            Map rtnmap = schoolService.checkSchoolUpgrade(schoolid);
85
+            Map<String,Object> rtnmap = schoolService.checkSchoolUpgrade(schoolid);
86 86
             return new ResultVo(0,"成功检测学年升级",rtnmap);
87 87
         } catch (Exception e) {
88 88
             log.error("检测学年升级失败:" + e.getMessage());
@@ -94,12 +94,13 @@ public class SchoolController {
94 94
     @PostMapping("/upgrade")
95 95
     public ResultVo upgrade(@RequestBody TSchool tSchool) {
96 96
         Integer schoolid = tSchool.getSchoolid();
97
-        N_Utils.validation(new Object[]{schoolid,"学校id",1});
97
+        Integer createid = tSchool.getCreateid();
98
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1, createid, "用户id", 1});
98 99
         Integer year = schoolService.getYearById(schoolid);
99 100
         Integer nowYear = N_Utils.getNodeDateTime("year");//当前年份
100 101
         if (year >= nowYear) return new ResultVo(1,"当前学年不用升级");
101 102
         try {
102
-            schoolService.upgrade(schoolid, year);
103
+            schoolService.upgrade(schoolid, year, createid);
103 104
             return new ResultVo(0,"学年升级成功");
104 105
         } catch (Exception e) {
105 106
             log.error("学年升级失败:" + e.getMessage());
@@ -111,23 +112,44 @@ public class SchoolController {
111 112
     @PostMapping("/downgrade")
112 113
     public ResultVo downgrade(@RequestBody TSchool tSchool) {
113 114
         Integer schoolid = tSchool.getSchoolid();
115
+        Integer createid = tSchool.getCreateid();
116
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1, createid, "用户id", 1});
114 117
         Integer year = schoolService.getYearById(schoolid);
115
-        N_Utils.validation(new Object[]{schoolid,"学校id",1});
116
-        schoolService.downgrade(schoolid, year);
117
-        return new ResultVo(0,"学年降级成功");
118
+        try {
119
+            schoolService.downgrade(schoolid, year, createid);
120
+            return new ResultVo(0,"学年降级成功");
121
+        } catch (Exception e) {
122
+            log.error("学年降级失败:" + e.getMessage());
123
+            return new ResultVo(1,"学年降级失败");
124
+        }
125
+    }
126
+
127
+    /**
128
+     * @Description 学校升级记录
129
+     * @Param [tSchool]
130
+     * @Author ywx
131
+     * @Date 2023/6/30 9:24
132
+     * @return com.xhkjedu.vo.ResultVo
133
+     **/
134
+    @PostMapping("/list_up")
135
+    public ResultVo listUpgrade(@RequestBody TSchool tSchool) {
136
+        Integer schoolid = tSchool.getSchoolid();
137
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
138
+        List<Map<String,Object>> list = schoolService.listUpgrade(schoolid);
139
+        return new ResultVo(0, "获取学校升级记录成功", list);
118 140
     }
119 141
 
120 142
     @PostMapping("/detail")
121 143
     public ResultVo detail(@RequestBody TSchool tSchool) {
122 144
         Integer schoolid = tSchool.getSchoolid();
123 145
         N_Utils.validation(new Object[]{schoolid, "学校id", 1});
124
-        Map school = schoolService.findById(schoolid);
146
+        Map<String,Object> school = schoolService.findById(schoolid);
125 147
         return new ResultVo(0, "获取学校详情成功", school);
126 148
     }
127 149
 
128 150
     @PostMapping("/list_sel")
129 151
     public ResultVo listForSel(@RequestBody TSchool tSchool) {
130
-        List<Map> list = schoolService.listForSel(tSchool.getSchoolname());
152
+        List<Map<String,Object>> list = schoolService.listForSel(tSchool.getSchoolname());
131 153
         return new ResultVo(0, "获取学校选择列表成功", list);
132 154
     }
133 155
 
@@ -173,7 +195,7 @@ public class SchoolController {
173 195
     public ResultVo getFschoolids(@RequestBody SchoolParams params) {
174 196
         Integer schoolid = params.getSchoolid();
175 197
         N_Utils.validation(new Object[]{schoolid, "学校id", 1});
176
-        List<Map> list = schoolService.listFSchoolidsBySchoolid(schoolid);
198
+        List<Map<String,Object>> list = schoolService.listFSchoolidsBySchoolid(schoolid);
177 199
         return new ResultVo(0, "获取成功",list);
178 200
     }
179 201
 
@@ -188,7 +210,7 @@ public class SchoolController {
188 210
     public ResultVo listSchoolClass(@RequestBody SchoolParams params) {
189 211
         Integer schoolid = params.getSchoolid();
190 212
         N_Utils.validation(new Object[]{schoolid, "学校id", 1});
191
-        List<Map> list = schoolService.listSchoolAndFriendSchools(schoolid);
213
+        List<Map<String,Object>> list = schoolService.listSchoolAndFriendSchools(schoolid);
192 214
         return new ResultVo(0, "获取成功",list);
193 215
     }
194 216
 
@@ -232,7 +254,7 @@ public class SchoolController {
232 254
     @PostMapping("/list_fsel")
233 255
     public ResultVo listFriendForSel(@RequestBody TSchool school) {
234 256
         N_Utils.validation(new Object[]{school.getSchoolid(), "学校id", 1});
235
-        List<Map> list = schoolService.listFriendForSel(school);
257
+        List<Map<String,Object>> list = schoolService.listFriendForSel(school);
236 258
         return new ResultVo(0, "获取伙伴学校选择列表成功", list);
237 259
     }
238 260
 }

+ 3
- 4
sapi/src/main/java/com/xhkjedu/sapi/mapper/gradeclass/ClassMapper.java View File

@@ -15,7 +15,7 @@ public interface ClassMapper extends TkMapper<TClass> {
15 15
     Integer getClassIdByName(String classname, Integer schoolid, Integer gradeid, Integer year);
16 16
 
17 17
     //修改班级状态
18
-    void updateClassState(@Param("classstate") Integer classstate, @Param("classids") String classids);
18
+    int updateClassState(@Param("classstate") Integer classstate, @Param("classids") String classids);
19 19
 
20 20
 
21 21
     //要升级的班级列表
@@ -23,9 +23,6 @@ public interface ClassMapper extends TkMapper<TClass> {
23 23
     //升级时要毕业的班级列表
24 24
     List<TClass> listClassBiyeBySchoolId(@Param("schoolid") Integer schoolid,@Param("year") Integer year,@Param("classstate") Integer classstate);
25 25
 
26
-    //要升级的班级id字符串
27
-    String listClassIdBySchoolId(@Param("schoolid") Integer schoolid,@Param("year") Integer year);
28
-
29 26
     //获取要升级的学生列表
30 27
     List<TClassStudent> listStudentByClassIds(@Param("classIds") String classIds);
31 28
     //要升级的教师列表
@@ -35,4 +32,6 @@ public interface ClassMapper extends TkMapper<TClass> {
35 32
     //获取要升级的学生列表
36 33
     List<TGroupStudent> listStudentByGroupIds(@Param("groupIds") String groupIds);
37 34
 
35
+    //班级学生id列表
36
+    List<Integer> listStudentIdByClassIds(@Param("classIds") String classIds);
38 37
 }

+ 3
- 3
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolFriendMapper.java View File

@@ -17,14 +17,14 @@ import java.util.Map;
17 17
 public interface SchoolFriendMapper extends TkMapper<TSchoolFriend> {
18 18
 
19 19
     //获取关联学校id
20
-    List<Map> listFSchoolidsBySchoolid(@Param("schoolid")Integer schoolid);
20
+    List<Map<String,Object>> listFSchoolidsBySchoolid(@Param("schoolid")Integer schoolid);
21 21
 
22 22
     //删除学校附属学校
23 23
     void deleteBySchoolid(@Param("schoolid")Integer schoolid);
24 24
 
25 25
     //获取学校关联的所有行政班
26
-    List<Map> listSchoolClass(@Param("schoolid")Integer schoolid);
26
+    List<Map<String,Object>> listSchoolClass(@Param("schoolid")Integer schoolid);
27 27
 
28 28
     //获取附属学校关联的所有行政班
29
-    List<Map> listFriendSchoolClass(@Param("schoolid")Integer schoolid);
29
+    List<Map<String,Object>> listFriendSchoolClass(@Param("schoolid")Integer schoolid);
30 30
 }

+ 9
- 6
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolMapper.java View File

@@ -12,7 +12,7 @@ public interface SchoolMapper extends TkMapper<TSchool> {
12 12
     Integer deleteById(@Param("schoolid") Integer schoolid);
13 13
 
14 14
     //列表
15
-    List<Map> findAll();
15
+    List<Map<String,Object>> findAll();
16 16
 
17 17
     /**
18 18
      * 学年升级
@@ -33,7 +33,7 @@ public interface SchoolMapper extends TkMapper<TSchool> {
33 33
     Integer downgrade(@Param("schoolid") Integer schoolid, @Param("year") Integer year);
34 34
 
35 35
     //学校选择列表
36
-    List<Map> listForSel(@Param("schoolname")String schoolname);
36
+    List<Map<String,Object>> listForSel(@Param("schoolname")String schoolname);
37 37
 
38 38
     TSchool getSchoolDetailById(@Param("schoolid") Integer schoolid);//获取区域码
39 39
 
@@ -68,14 +68,17 @@ public interface SchoolMapper extends TkMapper<TSchool> {
68 68
     List<Integer> listCloudYear();
69 69
 
70 70
     //详情
71
-    Map findById(@Param("schoolid") Integer schoolid);
71
+    Map<String,Object> findById(@Param("schoolid") Integer schoolid);
72 72
 
73 73
     //伙伴学校列表
74
-    List<Map> listSchool(@Param("schoolid") Integer schoolid);
74
+    List<Map<String,Object>> listSchool(@Param("schoolid") Integer schoolid);
75 75
 
76 76
     //加入学校列表
77
-    List<Map> listJoinSchool(@Param("schoolid") Integer schoolid);
77
+    List<Map<String,Object>> listJoinSchool(@Param("schoolid") Integer schoolid);
78 78
 
79 79
     //伙伴学校选择列表
80
-    List<Map> listFriendForSel(@Param("school") TSchool school);
80
+    List<Map<String,Object>> listFriendForSel(@Param("school") TSchool school);
81
+
82
+    //学校升级记录
83
+    List<Map<String,Object>> listUpgrade(Integer schoolid);
81 84
 }

+ 14
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolUpgradeHistoryMapper.java View File

@@ -0,0 +1,14 @@
1
+package com.xhkjedu.sapi.mapper.system;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.sapi.model.system.TSchoolUpgradeHistory;
5
+import org.springframework.stereotype.Repository;
6
+
7
+/**
8
+ * @Description 学校学年升级年级记录表
9
+ * @Author ywx
10
+ * Date 2023/6/30 12:24
11
+ **/
12
+@Repository
13
+public interface SchoolUpgradeHistoryMapper extends TkMapper<TSchoolUpgradeHistory> {
14
+}

+ 14
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/SchoolUpgradeMapper.java View File

@@ -0,0 +1,14 @@
1
+package com.xhkjedu.sapi.mapper.system;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.sapi.model.system.TSchoolUpgrade;
5
+import org.springframework.stereotype.Repository;
6
+
7
+/**
8
+ * @Description 学校升级记录
9
+ * @Author ywx
10
+ * Date 2023/6/29 15:44
11
+ **/
12
+@Repository
13
+public interface SchoolUpgradeMapper extends TkMapper<TSchoolUpgrade> {
14
+}

+ 1
- 1
sapi/src/main/java/com/xhkjedu/sapi/mapper/system/UserMapper.java View File

@@ -33,7 +33,7 @@ public interface UserMapper extends TkMapper<TUser> {
33 33
     UserVo getSchoolAdminBySchoolid(@Param("schoolid")Integer schoolid);
34 34
 
35 35
     //批量修改学生状态
36
-    void batchUpdateState(@Param("users")List<TClassStudent> users, @Param("userstate")Integer userstate);
36
+    int batchUpdateState(@Param("users")List<Integer> users, @Param("userstate")Integer userstate);
37 37
 
38 38
     //根据用户id获取学校id
39 39
     Integer getSchoolIdByUserId(Integer userid);

+ 26
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/system/TSchoolUpgrade.java View File

@@ -0,0 +1,26 @@
1
+package com.xhkjedu.sapi.model.system;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description 学校升级记录表
11
+ * @Author ywx
12
+ * Date 2023/6/29 15:08
13
+ **/
14
+@Table(name = "t_school_upgrade")
15
+@Data
16
+public class TSchoolUpgrade extends BaseBean {
17
+    @Id
18
+    private Integer suid;//学校升级记录表
19
+    private Integer schoolid;//学校id
20
+    private Integer uptype;//类型:1升级2降级
21
+    private Integer oldyear;//旧年份
22
+    private Integer newyear;//新年份
23
+    private Integer uptime;//升级时间
24
+    private Integer upuserid;//升级人
25
+    private Integer upresult;//升级结果1成功2失败
26
+}

+ 28
- 0
sapi/src/main/java/com/xhkjedu/sapi/model/system/TSchoolUpgradeHistory.java View File

@@ -0,0 +1,28 @@
1
+package com.xhkjedu.sapi.model.system;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description 学校学年升级年级记录表
11
+ * @Author ywx
12
+ * Date 2023/6/29 15:08
13
+ **/
14
+@Table(name = "t_school_upgrade_history")
15
+@Data
16
+public class TSchoolUpgradeHistory extends BaseBean {
17
+    @Id
18
+    private Integer suhid;//学校学年升级年级记录表
19
+    private Integer schoolid;//学校id
20
+    private Integer suid;//学年升级id
21
+    private Integer gradeid;//学年升级id
22
+    private Integer classyxznum;//应升级行政班数量
23
+    private Integer classsxznum;//实际升级行政班数量
24
+    private Integer classyxnnum;//应升级虚拟班数量
25
+    private Integer classsxnnum;//实际升级虚拟班数量
26
+    private Integer stuyupnum;//应升级学生数量
27
+    private Integer stusupnum;//实际升级学生数量
28
+}

+ 328
- 179
sapi/src/main/java/com/xhkjedu/sapi/service/system/SchoolService.java View File

@@ -11,7 +11,6 @@ import com.xhkjedu.sapi.vo.analyze.SchoolParams;
11 11
 import com.xhkjedu.utils.MD5;
12 12
 import com.xhkjedu.utils.N_Utils;
13 13
 import lombok.extern.slf4j.Slf4j;
14
-import org.springframework.beans.factory.annotation.Autowired;
15 14
 import org.springframework.dao.DuplicateKeyException;
16 15
 import org.springframework.stereotype.Service;
17 16
 import org.springframework.transaction.annotation.Transactional;
@@ -48,16 +47,20 @@ public class SchoolService {
48 47
     private GroupStudentMapper groupStudentMapper;
49 48
     @Resource
50 49
     private UserMapper userMapper;
51
-    @Autowired
50
+    @Resource
52 51
     private RoleMapper roleMapper;
53
-    @Autowired
52
+    @Resource
54 53
     private RoleModuleMapper roleModuleMapper;
55
-    @Autowired
54
+    @Resource
56 55
     private UserRoleMapper userRoleMapper;
57 56
     @Resource
58 57
     private SchoolFriendMapper schoolFriendMapper;
59 58
     @Resource
60 59
     private CloudMapper cloudMapper;
60
+    @Resource
61
+    private SchoolUpgradeMapper schoolUpgradeMapper;
62
+    @Resource
63
+    private SchoolUpgradeHistoryMapper schoolUpgradeHistoryMapper;
61 64
 
62 65
     //添加
63 66
     @Transactional(rollbackFor = Exception.class)
@@ -65,7 +68,7 @@ public class SchoolService {
65 68
         //添加学校信息
66 69
         model.setSchoolstate(1);
67 70
         model.setCreatetime(N_Utils.getSecondTimestamp());
68
-        Integer schoolid = null;
71
+        Integer schoolid;
69 72
         try {
70 73
             schoolMapper.insertUseGeneratedKeys(model);
71 74
             schoolid = model.getId();
@@ -108,16 +111,14 @@ public class SchoolService {
108 111
      * @Param [userid, roleid]
109 112
      * @Author ywx
110 113
      * @Date 2020/7/2 11:52
111
-     * @return java.lang.Integer
112 114
      **/
113
-    private Integer saveUserRole(Integer userid, Integer roleid) {
115
+    private void saveUserRole(Integer userid, Integer roleid) {
114 116
         TUserRole userRole = new TUserRole();
115 117
         userRole.setUserid(userid);
116 118
         userRole.setRoleid(roleid);
117 119
         userRole.setCreateid(userid);
118 120
         userRole.setCreatetime(N_Utils.getSecondTimestamp());
119 121
         userRoleMapper.insertUseGeneratedKeys(userRole);
120
-        return userRole.getId();
121 122
     }
122 123
 
123 124
     /**
@@ -166,7 +167,6 @@ public class SchoolService {
166 167
     /**
167 168
      * 保存子模块信息并设置角色模块信息
168 169
      *
169
-     * @return void
170 170
      * @Param [schoolid, userid, roleid, roleModules, module]
171 171
      * @Author ywx
172 172
      * @Date 2020/7/2 11:47
@@ -196,7 +196,6 @@ public class SchoolService {
196 196
     /**
197 197
      * 保存子模块信息
198 198
      *
199
-     * @return void
200 199
      * @Param [schoolid, userid, module, roleModules, roleid]
201 200
      * @Author ywx
202 201
      * @Date 2020/7/2 11:46
@@ -230,28 +229,18 @@ public class SchoolService {
230 229
     }
231 230
 
232 231
     //获取列表
233
-    public List <Map> findAll() {
232
+    public List <Map<String,Object>> findAll() {
234 233
         return schoolMapper.findAll();
235 234
     }
236 235
 
237
-    public Map checkSchoolUpgrade(Integer schoolid) throws Exception{
238
-        Map rtnMap = new HashMap();
236
+    public Map<String,Object> checkSchoolUpgrade(Integer schoolid) throws Exception{
237
+        HashMap<String,Object> rtnMap = new HashMap<>();
239 238
         TCloud cloud = cloudMapper.getCloudUpTime();
240
-        boolean isup = false;
241
-        if(ApiUtil.compareCurrDateTime(cloud.getStarttime(),cloud.getStoptime())){
242
-            isup = true;
243
-        }
239
+        boolean isup = ApiUtil.compareCurrDateTime(cloud.getStarttime(), cloud.getStoptime());
244 240
 
245 241
         //获取当前学校的学年
246 242
         int year = schoolMapper.getYearById(schoolid);
247 243
 
248
-        //前端进行年份判断
249
-        /*Integer nowYear = N_Utils.getNodeDateTime("year");//当前年份
250
-        //如果学校年份大于等于当前年份无需升级
251
-        if(year >= nowYear){
252
-            isup = false;
253
-        }*/
254
-
255 244
         rtnMap.put("isup",isup);
256 245
         rtnMap.put("year",year);
257 246
         rtnMap.put("starttime",cloud.getStarttime());
@@ -264,137 +253,241 @@ public class SchoolService {
264 253
      * @Param [schoolid, year]
265 254
      * @Author ywx
266 255
      * @Date 2020/6/12 13:50
267
-     * @return void
268 256
      **/
269 257
     @Transactional(rollbackFor = Exception.class)
270
-    public void upgrade(Integer schoolid, Integer year) throws Exception {
271
-        //获取区域限制学年升级时间
272
-        TCloud cloud = cloudMapper.getCloudUpTime();
273
-        if(!ApiUtil.compareCurrDateTime(cloud.getStarttime(),cloud.getStoptime())){
274
-           throw new Exception("不在学年升级时间范围,禁止升级");
275
-        }
276
-
258
+    public void upgrade(Integer schoolid, Integer year, Integer createid) throws Exception {
259
+        checkUpTime();
260
+
261
+        int timestamp = N_Utils.getSecondTimestamp();
262
+        TSchoolUpgrade su = new TSchoolUpgrade();
263
+        su.setSchoolid(schoolid);
264
+        su.setUptype(1);
265
+        su.setOldyear(year);
266
+        su.setNewyear(year + 1);
267
+        su.setUptime(timestamp);
268
+        su.setUpuserid(createid);
269
+        int classyxznum;//应升级行政班数量
270
+        int classsxznum;//实际升级行政班数量
271
+        int classyxnnum;//应升级虚拟班数量
272
+        int classsxnnum;//实际升级虚拟班数量
273
+        int stuyupnum;//应升级学生数量
274
+        int stusupnum;//实际升级学生数量
275
+        int gradeid;//学年升级id
276
+        List<TSchoolUpgradeHistory> histories = new ArrayList<>();
277 277
         try {
278
+            //不需要升级,需要标识毕业的班级,学生
279
+            List<TClass> biyeclass = classMapper.listClassBiyeBySchoolId(schoolid, year, 1);
280
+            List<String> xzList = biyeclass.stream().filter(c -> c.getClasstype().equals(1))
281
+                                           .map(c -> c.getClassid().toString()).collect(Collectors.toList());
282
+            String xzClassIds = String.join(",", xzList);
283
+            List<Integer> bystudents = new ArrayList<>();
284
+            if (N_Utils.isNotEmpty(xzClassIds)) {
285
+                bystudents = classMapper.listStudentIdByClassIds(xzClassIds);//要毕业的学生列表
286
+            }
287
+
278 288
             List<TClass> classes = classMapper.listClassBySchoolId(schoolid, year);//要升级的班级列表
279 289
             if (N_Utils.isListNotEmpty(classes)) {
280
-                String classIds = classMapper.listClassIdBySchoolId(schoolid, year);
290
+                List<String> classids = classes.stream().filter(c -> c.getClasstype().equals(1)).map(c -> c.getClassid().toString()).collect(Collectors.toList());
291
+                String classIds = String.join(",", classids);
281 292
                 List<TClassStudent> cStudents = classMapper.listStudentByClassIds(classIds);//要升级的学生列表
282 293
                 List<TClassTeacher> cTeachers = classMapper.listTeacherByClassIds(classIds);//要升级的教师列表
283
-
284 294
                 List<TGroup> groups = classMapper.listGroupByClassIds(classIds);//要升级的全体分组列表
285
-                StringBuilder sb = new StringBuilder();
286
-                groups.forEach(g -> {
287
-                    sb.append(g.getGroupid()).append(",");
288
-                });
289
-                String groupIds = sb.toString().substring(0, sb.toString().length() - 1);
295
+                String groupIds = groups.stream().map(g -> g.getGroupid().toString()).collect(Collectors.joining(","));
290 296
                 List<TGroupStudent> gStudents = classMapper.listStudentByGroupIds(groupIds);//要升级的学生列表
291
-
292
-                List<TClassStudent> classStudents = new ArrayList<>();//升级后的班级学生
293
-                List<TClassTeacher> classTeachers = new ArrayList<>();//升级后的班级教师
294
-                List<TGroupStudent> groupStudents = new ArrayList<>();//升级后的分组学生
295
-                for (TClass c : classes) {
296
-                    //复制班级信息
297
-                    c.setYear(c.getYear() + 1);
298
-                    c.setGradeid(c.getGradeid() + 1);
299
-                    c.setClassstate(1);
300
-                    c.setCreatetime(N_Utils.getSecondTimestamp());
301
-                }
302
-                classMapper.insertList(classes);//保存升级后的班级信息
303
-                for (TClass c : classes) {
304
-                    //复制班级信息
305
-                    Integer oldClassId = c.getClassid();
306
-                    Integer classid = c.getId();
307
-
308
-                    //复制班级学生信息
309
-                    boolean rtn = false;
310
-                    for (TClassStudent s : cStudents) {
311
-                        if (oldClassId.equals(s.getClassid())) {
312
-                            s.setClassid(classid);
313
-                            s.setCreatetime(N_Utils.getSecondTimestamp());
314
-                            classStudents.add(s);
315
-                            rtn = true;
316
-                        } else if (!oldClassId.equals(s.getClassid()) && rtn) {
317
-                            break;
318
-                        }
319
-                    }
320
-
321
-                    //复制班级教师信息
322
-                    rtn = false;
323
-                    for (TClassTeacher t : cTeachers) {
324
-                        if (oldClassId.equals(t.getClassid())){
325
-                            t.setClassid(classid);
326
-                            t.setCreatetime(N_Utils.getSecondTimestamp());
327
-                            classTeachers.add(t);
328
-                            rtn = true;
329
-                        } else if (!oldClassId.equals(t.getClassid()) && rtn){
330
-                            break;
331
-                        }
332
-                    }
333
-
334
-                    for (TGroup g : groups) {
335
-                        if (oldClassId.equals(g.getClassid())) {
336
-                            //复制班级分组信息
337
-                            g.setClassid(classid);
338
-                            g.setCreatetime(N_Utils.getSecondTimestamp());
339
-                            break;
340
-                        }
297
+                Map<Integer, List<TClass>> gcollect = classes.stream().collect(Collectors.groupingBy(c -> c.getGradeid()));
298
+                for (Map.Entry<Integer, List<TClass>> entry : gcollect.entrySet()) {
299
+                    gradeid = entry.getKey();
300
+                    List<TClass> classList = entry.getValue();
301
+                    List<TClass> xzbList = classList.stream().filter(c -> c.getClasstype().equals(1)).collect(Collectors.toList());
302
+                    List<TClass> xnbList = classList.stream().filter(c -> c.getClasstype().equals(2)).collect(Collectors.toList());
303
+                    if (N_Utils.isListNotEmpty(xzbList)) {
304
+                        String cIds = xzbList.stream().map(c -> c.getClassid().toString()).collect(Collectors.joining(","));
305
+                        List<TClassStudent> studentList = cStudents.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
306
+                        List<TClassTeacher> teacherList = cTeachers.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
307
+                        List<TGroup> gList = groups.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
308
+                        List<TGroupStudent> gsList = gStudents.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
309
+                        List<Integer> list = saveClass(timestamp, xzbList, studentList, teacherList, gList, gsList);
310
+                        classyxznum = xzbList.size();
311
+                        classsxznum = list.get(0);
312
+                        stuyupnum = studentList.size();
313
+                        stusupnum = list.get(1);
314
+                    } else {
315
+                        classyxznum = 0;
316
+                        classsxznum = 0;
317
+                        stuyupnum = 0;
318
+                        stusupnum = 0;
341 319
                     }
342
-                }
343
-                groupMapper.insertList(groups);//保存升级后的班级分组信息
344
-                for (TGroup g : groups) {
345
-                    Integer classid = g.getClassid();
346
-                    Integer oldGroupId = g.getGroupid();
347
-                    Integer groupid = g.getId();
348
-                    //复制分组学生信息
349
-                    boolean rtn = false;
350
-                    for (TGroupStudent s : gStudents) {
351
-                        if (oldGroupId.equals(s.getGroupid())) {
352
-                            s.setClassid(classid);
353
-                            s.setGroupid(groupid);
354
-                            s.setCreatetime(N_Utils.getSecondTimestamp());
355
-                            groupStudents.add(s);
356
-                            rtn = true;
357
-                        } else if (!oldGroupId.equals(s.getGroupid()) && rtn) {
358
-                            break;
320
+                    if (N_Utils.isListNotEmpty(xnbList)) {
321
+                        String cIds = xnbList.stream().map(c -> c.getClassid().toString()).collect(Collectors.joining(","));
322
+                        List<TClassStudent> studentList = new ArrayList<>();
323
+                        for (TClassStudent cs : cStudents) {
324
+                            if (cIds.contains(cs.getClassid().toString()) && !bystudents.contains(cs.getStudentid())) {
325
+                                studentList.add(cs);
326
+                            }
359 327
                         }
328
+                        List<TClassTeacher> teacherList = cTeachers.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
329
+                        List<TGroup> gList = groups.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
330
+                        List<TGroupStudent> gsList = gStudents.stream().filter(cs -> cIds.contains(String.valueOf(cs.getClassid()))).collect(Collectors.toList());
331
+                        List<Integer> list = saveClass(timestamp, xzbList, studentList, teacherList, gList, gsList);
332
+                        classyxnnum = xnbList.size();
333
+                        classsxnnum = list.get(0);
334
+                    } else {
335
+                        classyxnnum = 0;
336
+                        classsxnnum = 0;
360 337
                     }
338
+                    TSchoolUpgradeHistory suh = new TSchoolUpgradeHistory();
339
+                    suh.setGradeid(gradeid);
340
+                    suh.setClassyxznum(classyxznum);
341
+                    suh.setClasssxznum(classsxznum);
342
+                    suh.setClassyxnnum(classyxnnum);
343
+                    suh.setClasssxnnum(classsxnnum);
344
+                    suh.setStuyupnum(stuyupnum);
345
+                    suh.setStusupnum(stusupnum);
346
+                    histories.add(suh);
361 347
                 }
362
-                classStudentMapper.insertList(classStudents);//保存升级后的班级学生信息
363
-                classTeacherMapper.insertList(classTeachers);//保存升级后的班级教师信息
364
-                groupStudentMapper.insertList(groupStudents);//保存升级后的分组学生信息
365 348
             }
366 349
 
367
-            //不需要升级,需要标识毕业的班级,学生
368
-            List<TClass> biyeclass = classMapper.listClassBiyeBySchoolId(schoolid,year,1);
369
-
370 350
 
371
-            if(N_Utils.isListNotEmpty(biyeclass)){
372
-                String byclassIds = "";
373
-                for(int i=0;i<biyeclass.size();i++){
374
-                    TClass c = biyeclass.get(i);
375
-                    if(i>0){
376
-                        byclassIds = byclassIds + "," + c.getClassid();
377
-                    }else{
378
-                        byclassIds = c.getClassid().toString();
379
-                    }
351
+            if (N_Utils.isListNotEmpty(biyeclass)) {
352
+                gradeid = biyeclass.get(0).getGradeid();
353
+                List<String> xnList = biyeclass.stream().filter(c -> c.getClasstype().equals(2))
354
+                                               .map(c -> c.getClassid().toString()).collect(Collectors.toList());
355
+                String xnClassIds = String.join(",", xnList);
356
+                if (N_Utils.isNotEmpty(xzClassIds)) {
357
+                    classyxznum = xzList.size();
358
+                    classsxznum = classMapper.updateClassState(3, xzClassIds);//修改班级状态
359
+                } else {
360
+                    classyxznum = 0;
361
+                    classsxznum = 0;
380 362
                 }
381
-
382
-                List<TClassStudent> bystudents = classMapper.listStudentByClassIds(byclassIds);//要毕业的学生列表
383
-
384
-                if (N_Utils.isNotEmpty(byclassIds)) {
385
-                    classMapper.updateClassState(3, byclassIds);//修改班级状态
363
+                if (N_Utils.isNotEmpty(xnClassIds)) {
364
+                    classyxnnum = xnList.size();
365
+                    classsxnnum = classMapper.updateClassState(3, xnClassIds);//修改班级状态
366
+                } else {
367
+                    classyxnnum = 0;
368
+                    classsxnnum = 0;
386 369
                 }
387 370
                 if (N_Utils.isListNotEmpty(bystudents)) {
388
-                    userMapper.batchUpdateState(bystudents, 3);   //修改学生状态为已毕业状态
371
+                    stuyupnum = bystudents.size();
372
+                    stusupnum = userMapper.batchUpdateState(bystudents, 3);//修改学生状态为已毕业状态
373
+                } else {
374
+                    stuyupnum = 0;
375
+                    stusupnum = 0;
389 376
                 }
377
+                TSchoolUpgradeHistory suh = new TSchoolUpgradeHistory();
378
+                suh.setGradeid(gradeid);
379
+                suh.setClassyxznum(classyxznum);
380
+                suh.setClasssxznum(classsxznum);
381
+                suh.setClassyxnnum(classyxnnum);
382
+                suh.setClasssxnnum(classsxnnum);
383
+                suh.setStuyupnum(stuyupnum);
384
+                suh.setStusupnum(stusupnum);
385
+                histories.add(suh);
390 386
             }
391 387
 
392 388
             schoolMapper.upgrade(schoolid);//学校年份升级
393
-        }catch (Exception e){
389
+            su.setUpresult(1);
390
+        } catch (Exception e) {
394 391
             log.error("学年升级失败:" + e.getMessage());
395 392
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
393
+            su.setUpresult(2);
396 394
             throw new RuntimeException("学年升级失败");
395
+        } finally {
396
+            schoolUpgradeMapper.insertUseGeneratedKeys(su);
397
+            if (N_Utils.isListNotEmpty(histories)) {
398
+                Integer suId = su.getId();
399
+                histories.forEach(h -> {
400
+                    h.setSchoolid(schoolid);
401
+                    h.setSuid(suId);
402
+                });
403
+                schoolUpgradeHistoryMapper.insertList(histories);
404
+            }
405
+        }
406
+    }
407
+
408
+    //保存班级信息
409
+    private List<Integer> saveClass(int timestamp, List<TClass> classes, List<TClassStudent> cStudents
410
+            , List<TClassTeacher> cTeachers, List<TGroup> groups, List<TGroupStudent> gStudents) {
411
+        List<TClassStudent> classStudents = new ArrayList<>();//升级后的班级学生
412
+        List<TClassTeacher> classTeachers = new ArrayList<>();//升级后的班级教师
413
+        List<TGroupStudent> groupStudents = new ArrayList<>();//升级后的分组学生
414
+        for (TClass c : classes) {
415
+            //复制班级信息
416
+            c.setYear(c.getYear() + 1);
417
+            c.setGradeid(c.getGradeid() + 1);
418
+            c.setClassstate(1);
419
+            c.setCreatetime(timestamp);
420
+        }
421
+        int classnum = classMapper.insertList(classes);//保存升级后的班级信息
422
+        for (TClass c : classes) {
423
+            //复制班级信息
424
+            Integer oldClassId = c.getClassid();
425
+            Integer classid = c.getId();
426
+
427
+            //复制班级学生信息
428
+            boolean rtn = false;
429
+            for (TClassStudent s : cStudents) {
430
+                if (oldClassId.equals(s.getClassid())) {
431
+                    s.setClassid(classid);
432
+                    s.setCreatetime(timestamp);
433
+                    classStudents.add(s);
434
+                    rtn = true;
435
+                } else if (!oldClassId.equals(s.getClassid()) && rtn) {
436
+                    break;
437
+                }
438
+            }
439
+
440
+            //复制班级教师信息
441
+            rtn = false;
442
+            for (TClassTeacher t : cTeachers) {
443
+                if (oldClassId.equals(t.getClassid())) {
444
+                    t.setClassid(classid);
445
+                    t.setCreatetime(timestamp);
446
+                    classTeachers.add(t);
447
+                    rtn = true;
448
+                } else if (!oldClassId.equals(t.getClassid()) && rtn) {
449
+                    break;
450
+                }
451
+            }
452
+
453
+            for (TGroup g : groups) {
454
+                if (oldClassId.equals(g.getClassid())) {
455
+                    //复制班级分组信息
456
+                    g.setClassid(classid);
457
+                    g.setCreatetime(timestamp);
458
+                    break;
459
+                }
460
+            }
461
+        }
462
+        if (N_Utils.isListNotEmpty(groups)) groupMapper.insertList(groups);//保存升级后的班级分组信息
463
+        for (TGroup g : groups) {
464
+            Integer classid = g.getClassid();
465
+            Integer oldGroupId = g.getGroupid();
466
+            Integer groupid = g.getId();
467
+            //复制分组学生信息
468
+            boolean rtn = false;
469
+            for (TGroupStudent s : gStudents) {
470
+                if (oldGroupId.equals(s.getGroupid())) {
471
+                    s.setClassid(classid);
472
+                    s.setGroupid(groupid);
473
+                    s.setCreatetime(timestamp);
474
+                    groupStudents.add(s);
475
+                    rtn = true;
476
+                } else if (!oldGroupId.equals(s.getGroupid()) && rtn) {
477
+                    break;
478
+                }
479
+            }
480
+        }
481
+        int stunum = 0;
482
+        if (N_Utils.isListNotEmpty(classStudents)) {
483
+            stunum = classStudentMapper.insertList(classStudents);//保存升级后的班级学生信息
397 484
         }
485
+        if (N_Utils.isListNotEmpty(classTeachers)) classTeacherMapper.insertList(classTeachers);//保存升级后的班级教师信息
486
+        if (N_Utils.isListNotEmpty(groupStudents)) groupStudentMapper.insertList(groupStudents);//保存升级后的分组学生信息
487
+        List<Integer> list = new ArrayList<>();
488
+        list.add(classnum);
489
+        list.add(stunum);
490
+        return list;
398 491
     }
399 492
 
400 493
     /**
@@ -402,29 +495,80 @@ public class SchoolService {
402 495
      * @Param [schoolid, year]
403 496
      * @Author ywx
404 497
      * @Date 2020/6/16 13:51
405
-     * @return void
406 498
      **/
407
-    public void downgrade(Integer schoolid, Integer year) {
408
-
409
-        schoolMapper.downgrade(schoolid, year);
410
-        //之前已毕业的班级进行恢复
411
-        List<TClass> biyeclass = classMapper.listClassBiyeBySchoolId(schoolid,year,3);
412
-
413
-        if(N_Utils.isListNotEmpty(biyeclass)){
414
-            String byclassIds = "";
415
-            for(int i=0;i<biyeclass.size();i++){
416
-                TClass c = biyeclass.get(i);
417
-                if(i>0){
418
-                    byclassIds = "," + c.getClassid();
419
-                }else{
420
-                    byclassIds = c.getClassid().toString();
499
+    @Transactional(rollbackFor = Exception.class)
500
+    public void downgrade(Integer schoolid, Integer year, Integer createid) throws Exception {
501
+        checkUpTime();
502
+
503
+        int timestamp = N_Utils.getSecondTimestamp();
504
+        TSchoolUpgrade su = new TSchoolUpgrade();
505
+        su.setSchoolid(schoolid);
506
+        su.setUptype(2);
507
+        su.setOldyear(year);
508
+        su.setNewyear(year - 1);
509
+        su.setUptime(timestamp);
510
+        su.setUpuserid(createid);
511
+        int classyxznum = 0;//应升级行政班数量
512
+        int classsxznum = 0;//实际升级行政班数量
513
+        int classyxnnum = 0;//应升级虚拟班数量
514
+        int classsxnnum = 0;//实际升级虚拟班数量
515
+        int stuyupnum = 0;//应升级学生数量
516
+        int stusupnum = 0;//实际升级学生数量
517
+        int gradeid = 0;//学年升级id
518
+        try {
519
+            //之前已毕业的班级进行恢复
520
+            List<TClass> biyeclass = classMapper.listClassBiyeBySchoolId(schoolid, year - 1, 3);
521
+
522
+            if (N_Utils.isListNotEmpty(biyeclass)) {
523
+                gradeid = biyeclass.get(0).getGradeid();
524
+                List<String> xzList = biyeclass.stream().filter(c -> c.getClasstype().equals(1))
525
+                                               .map(c -> c.getClassid().toString()).collect(Collectors.toList());
526
+                classyxznum = xzList.size();
527
+                List<String> xnList = biyeclass.stream().filter(c -> c.getClasstype().equals(2))
528
+                                               .map(c -> c.getClassid().toString()).collect(Collectors.toList());
529
+                classyxnnum = xnList.size();
530
+                String xzClassIds = String.join(",", xzList);
531
+                String xnClassIds = String.join(",", xnList);
532
+                List<Integer> bystudents = null;
533
+                if (N_Utils.isNotEmpty(xzClassIds)) {
534
+                    bystudents = classMapper.listStudentIdByClassIds(xzClassIds);//要毕业的学生列表
535
+                    stuyupnum = bystudents.size();
421 536
                 }
422
-            }
423 537
 
424
-            List<TClassStudent> bystudents = classMapper.listStudentByClassIds(byclassIds);//要毕业的学生列表
538
+                classsxznum = classMapper.updateClassState(1, xzClassIds);//修改班级状态
539
+                classsxnnum = classMapper.updateClassState(1, xnClassIds);//修改班级状态
540
+                if (N_Utils.isListNotEmpty(bystudents)) {
541
+                    stusupnum = userMapper.batchUpdateState(bystudents, 1);//修改学生状态
542
+                }
543
+            }
544
+            schoolMapper.downgrade(schoolid, year);
545
+            su.setUpresult(1);
546
+        } catch (Exception e) {
547
+            log.error("学年降级失败:" + e.getMessage());
548
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
549
+            su.setUpresult(2);
550
+            throw new RuntimeException("学年降级失败");
551
+        } finally {
552
+            schoolUpgradeMapper.insertUseGeneratedKeys(su);
553
+            TSchoolUpgradeHistory suh = new TSchoolUpgradeHistory();
554
+            suh.setSchoolid(schoolid);
555
+            suh.setSuid(su.getId());
556
+            suh.setGradeid(gradeid);
557
+            suh.setClassyxznum(classyxznum);
558
+            suh.setClasssxznum(classsxznum);
559
+            suh.setClassyxnnum(classyxnnum);
560
+            suh.setClasssxnnum(classsxnnum);
561
+            suh.setStuyupnum(stuyupnum);
562
+            suh.setStusupnum(stusupnum);
563
+            schoolUpgradeHistoryMapper.insertSelective(suh);
564
+        }
565
+    }
425 566
 
426
-            classMapper.updateClassState(1,byclassIds);//修改班级状态
427
-            userMapper.batchUpdateState(bystudents,1);   //修改学生状态
567
+    private void checkUpTime() throws Exception {
568
+        //获取区域限制学年升级时间
569
+        TCloud cloud = cloudMapper.getCloudUpTime();
570
+        if (!ApiUtil.compareCurrDateTime(cloud.getStarttime(), cloud.getStoptime())) {
571
+            throw new Exception("不在学年升级时间范围,禁止升级");
428 572
         }
429 573
     }
430 574
 
@@ -440,7 +584,7 @@ public class SchoolService {
440 584
     }
441 585
 
442 586
     //学校选择列表
443
-    public List<Map> listForSel(String schoolname) {
587
+    public List<Map<String,Object>> listForSel(String schoolname) {
444 588
         return schoolMapper.listForSel(schoolname);
445 589
     }
446 590
 
@@ -487,35 +631,35 @@ public class SchoolService {
487 631
     }
488 632
 
489 633
     //获取学校附属学校
490
-    public List<Map> listFSchoolidsBySchoolid(Integer schoolid){
634
+    public List<Map<String,Object>> listFSchoolidsBySchoolid(Integer schoolid){
491 635
         return schoolFriendMapper.listFSchoolidsBySchoolid(schoolid);
492 636
     }
493 637
 
494 638
     //获取学校及附属学校班级
495
-    public List<Map> listSchoolAndFriendSchools(Integer schoolid){
496
-        List<Map> rtnlist = new ArrayList<>();
497
-        List<Map> schools = schoolFriendMapper.listSchoolClass(schoolid);
639
+    public List<Map<String,Object>> listSchoolAndFriendSchools(Integer schoolid){
640
+        List<Map<String,Object>> rtnlist = new ArrayList<>();
641
+        List<Map<String,Object>> schools = schoolFriendMapper.listSchoolClass(schoolid);
498 642
         setSchoolGradeSclass(rtnlist,schools);
499
-        List<Map> fschools = schoolFriendMapper.listFriendSchoolClass(schoolid);
643
+        List<Map<String,Object>> fschools = schoolFriendMapper.listFriendSchoolClass(schoolid);
500 644
         setFriendSchoolGradeSclass(rtnlist,fschools);
501 645
         return rtnlist;
502 646
     }
503 647
 
504
-    private void setSchoolGradeSclass(List<Map> rtnlist,List<Map> schools){
648
+    private void setSchoolGradeSclass(List<Map<String,Object>> rtnlist,List<Map<String,Object>> schools){
505 649
         //处理学校
506
-        Map schoolsmap = schools.get(0);
507
-        Map schoolm = new LinkedHashMap();
650
+        Map<String,Object> schoolsmap = schools.get(0);
651
+        LinkedHashMap<String,Object> schoolm = new LinkedHashMap<>();
508 652
         schoolm.put("schoolid",Integer.parseInt(schoolsmap.get("schoolid").toString()));
509 653
         schoolm.put("schoolname",schoolsmap.get("schoolname").toString());
510 654
 
511
-        List<Map> gradelist = new ArrayList<>();
655
+        List<Map<String,Object>> gradelist = new ArrayList<>();
512 656
         //根据年级进行分组
513
-        Map<String,List<Map>> grademap =  schools.stream().collect(Collectors.groupingBy(s -> s.get("gradeid").toString(), Collectors.toList()));
514
-        for(Map.Entry<String, List<Map>> entry : grademap.entrySet()){
515
-            Map gmap = new LinkedHashMap();
657
+        Map<String,List<Map<String,Object>>> grademap =  schools.stream().collect(Collectors.groupingBy(s -> s.get("gradeid").toString(), Collectors.toList()));
658
+        for(Map.Entry<String, List<Map<String,Object>>> entry : grademap.entrySet()){
659
+            LinkedHashMap<String,Object> gmap = new LinkedHashMap<>();
516 660
             gmap.put("gradeid",Integer.parseInt(entry.getKey()));
517
-            List<Map> classlist = entry.getValue();
518
-            for(Map cmap : classlist){
661
+            List<Map<String,Object>> classlist = entry.getValue();
662
+            for(Map<String,Object> cmap : classlist){
519 663
                 cmap.remove("schoolid");
520 664
                 cmap.remove("schoolname");
521 665
                 cmap.remove("gradeid");
@@ -527,22 +671,22 @@ public class SchoolService {
527 671
         rtnlist.add(schoolm);
528 672
     }
529 673
 
530
-    private void setFriendSchoolGradeSclass(List<Map> rtnlist,List<Map> schools){
531
-        Map<String,List<Map>> schoolmap =  schools.stream().collect(Collectors.groupingBy(s -> s.get("schoolid").toString(), Collectors.toList()));
532
-        for(Map.Entry<String, List<Map>> entry : schoolmap.entrySet()){
533
-            Map schoolm = new LinkedHashMap();
674
+    private void setFriendSchoolGradeSclass(List<Map<String,Object>> rtnlist,List<Map<String,Object>> schools){
675
+        Map<String,List<Map<String,Object>>> schoolmap =  schools.stream().collect(Collectors.groupingBy(s -> s.get("schoolid").toString(), Collectors.toList()));
676
+        for(Map.Entry<String, List<Map<String,Object>>> entry : schoolmap.entrySet()){
677
+            Map<String,Object> schoolm = new LinkedHashMap<>();
534 678
             schoolm.put("schoolid",Integer.parseInt(entry.getKey()));
535
-            Map schoolm2 = entry.getValue().get(0);
679
+            Map<String,Object> schoolm2 = entry.getValue().get(0);
536 680
             schoolm.put("schoolname",schoolm2.get("schoolname").toString());
537
-            List<Map> gradelist = entry.getValue();
538
-            List<Map> savegradelist = new ArrayList<>();
681
+            List<Map<String,Object>> gradelist = entry.getValue();
682
+            List<Map<String,Object>> savegradelist = new ArrayList<>();
539 683
             //根据年级进行分组
540
-            Map<String,List<Map>> grademap =  gradelist.stream().collect(Collectors.groupingBy(s -> s.get("gradeid").toString(), Collectors.toList()));
541
-            for(Map.Entry<String, List<Map>> entryg : grademap.entrySet()){
542
-                Map gmap = new LinkedHashMap();
684
+            Map<String,List<Map<String,Object>>> grademap =  gradelist.stream().collect(Collectors.groupingBy(s -> s.get("gradeid").toString(), Collectors.toList()));
685
+            for(Map.Entry<String, List<Map<String,Object>>> entryg : grademap.entrySet()){
686
+                Map<String,Object> gmap = new LinkedHashMap<>();
543 687
                 gmap.put("gradeid",Integer.parseInt(entryg.getKey()));
544
-                List<Map> classlist = entryg.getValue();
545
-                for(Map cmap : classlist){
688
+                List<Map<String,Object>> classlist = entryg.getValue();
689
+                for(Map<String,Object> cmap : classlist){
546 690
                     cmap.remove("schoolid");
547 691
                     cmap.remove("schoolname");
548 692
                     cmap.remove("gradeid");
@@ -567,17 +711,22 @@ public class SchoolService {
567 711
     }
568 712
 
569 713
     //详情
570
-    public Map findById(Integer schoolid) {
571
-        Map map = schoolMapper.findById(schoolid);
572
-        List<Map> friendSchools=schoolMapper.listSchool(schoolid);
714
+    public Map<String,Object> findById(Integer schoolid) {
715
+        Map<String,Object> map = schoolMapper.findById(schoolid);
716
+        List<Map<String,Object>> friendSchools=schoolMapper.listSchool(schoolid);
573 717
         map.put("friendSchools",friendSchools);//伙伴学校列表
574
-        List<Map> joinSchools=schoolMapper.listJoinSchool(schoolid);
718
+        List<Map<String,Object>> joinSchools=schoolMapper.listJoinSchool(schoolid);
575 719
         map.put("joinSchools",joinSchools);//加入学校列表
576 720
         return map;
577 721
     }
578 722
 
579 723
     //伙伴学校选择列表
580
-    public List<Map> listFriendForSel(TSchool school) {
724
+    public List<Map<String,Object>> listFriendForSel(TSchool school) {
581 725
         return schoolMapper.listFriendForSel(school);
582 726
     }
727
+
728
+    //学校升级记录
729
+    public List<Map<String,Object>> listUpgrade(Integer schoolid) {
730
+        return schoolMapper.listUpgrade(schoolid);
731
+    }
583 732
 }

+ 5
- 6
sapi/src/main/resources/mapper/gradeclass/ClassMapper.xml View File

@@ -22,11 +22,7 @@
22 22
     </select>
23 23
     <!--升级时要毕业的班级列表-->
24 24
     <select id="listClassBiyeBySchoolId" resultType="com.xhkjedu.sapi.model.gradeclass.TClass">
25
-        select * from t_class where schoolid=#{schoolid} and year=#{year} and classtype in(1,2) and classstate=#{classstate} and gradeid in(6,9,12)
26
-    </select>
27
-    <!--要升级的班级id字符串-->
28
-    <select id="listClassIdBySchoolId" resultType="java.lang.String">
29
-        select group_concat(classid) from t_class where schoolid=#{schoolid} and year=#{year} and classtype in(1,2) and classstate=1 and gradeid in(1,2,3,4,5,7,8,10,11)
25
+        select classid,classtype,gradeid from t_class where schoolid=#{schoolid} and year=#{year} and classtype in(1,2) and classstate=#{classstate} and gradeid in(6,9,12)
30 26
     </select>
31 27
 
32 28
     <!--获取要升级的学生列表-->
@@ -45,5 +41,8 @@
45 41
     <select id="listStudentByGroupIds" resultType="com.xhkjedu.sapi.model.gradeclass.TGroupStudent">
46 42
         select * from t_group_student where groupid in(${groupIds}) order by groupid;
47 43
     </select>
48
-
44
+    <!--班级学生id列表-->
45
+    <select id="listStudentIdByClassIds" resultType="java.lang.Integer">
46
+        select distinct studentid from t_class_student where classid in(${classIds})
47
+    </select>
49 48
 </mapper>

+ 10
- 3
sapi/src/main/resources/mapper/system/SchoolMapper.xml View File

@@ -7,7 +7,7 @@
7 7
     </update>
8 8
 
9 9
     <select id="listSchool" resultType="java.util.Map">
10
-        select f.fschoolid schoolid,s2.schoolname
10
+        select f.fschoolid as schoolid,s2.schoolname
11 11
         from t_school_friend f left join t_school s2 on f.fschoolid=s2.schoolid
12 12
         where f.schoolid=#{schoolid}
13 13
     </select>
@@ -20,7 +20,7 @@
20 20
     <select id="findAll" resultType="java.util.Map">
21 21
         select s.schoolid,s.schoolname,s.shortname,s.schoollevel,s.errorrate,s.`year`
22 22
         ,(select u.loginname from t_user u where u.schoolid=s.schoolid and u.usertype=0 and u.userstate=1
23
-        ORDER BY u.userid ASC LIMIT 1)loginname
23
+        ORDER BY u.userid LIMIT 1)loginname
24 24
         ,(select count(sf.schoolid) from t_school_friend sf where sf.fschoolid=s.schoolid)joinnum
25 25
         ,(select count(sf.fschoolid) from t_school_friend sf where sf.schoolid=s.schoolid)friendnum
26 26
         from t_school s
@@ -101,7 +101,7 @@
101 101
     <select id="findById" resultType="java.util.Map">
102 102
         select s.*,tu.username createname
103 103
         ,(select u.loginname from t_user u where u.schoolid=s.schoolid and u.usertype=0 and u.userstate=1
104
-        order by u.userid asc limit 1)loginname
104
+        order by u.userid limit 1) as loginname
105 105
         from t_school s left join t_user tu on s.createid = tu.userid
106 106
         where s.schoolid=#{schoolid}
107 107
     </select>
@@ -115,4 +115,11 @@
115 115
         </if>
116 116
         order by s2.createtime desc
117 117
     </select>
118
+    <!--学校升级记录-->
119
+    <select id="listUpgrade" resultType="java.util.Map">
120
+        select su.suid,uptype,oldyear,newyear,uptime,upresult
121
+        ,classxznum,classxnnum,stuupnum,stubynum,u.username
122
+        from t_school_upgrade su left join t_user u on su.upuserid=u.userid
123
+        where su.schoolid=#{schoolid} order by su.suid desc
124
+    </select>
118 125
 </mapper>

+ 2
- 2
sapi/src/main/resources/mapper/system/UserMapper.xml View File

@@ -23,8 +23,8 @@
23 23
     <!--批量修改用户状态-->
24 24
     <update id="batchUpdateState">
25 25
         update t_user set userstate=#{userstate} where
26
-        <foreach collection="users" item="user" index="index" separator="or">
27
-            userid=${user.studentid}
26
+        <foreach collection="users" item="userid" index="index" separator="or">
27
+            userid=${userid}
28 28
         </foreach>
29 29
     </update>
30 30
 

Loading…
Cancel
Save