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