|
@@ -16,7 +16,6 @@ import com.xhkjedu.slive.model.xz.LXz;
|
16
|
16
|
import com.xhkjedu.slive.model.xz.LXzKj;
|
17
|
17
|
import com.xhkjedu.slive.service.gradeclass.ClassService;
|
18
|
18
|
import com.xhkjedu.slive.utils.LiveUtil;
|
19
|
|
-import com.xhkjedu.slive.vo.gradeclass.ClassVo;
|
20
|
19
|
import com.xhkjedu.slive.vo.liveplay.CourseVo;
|
21
|
20
|
import com.xhkjedu.slive.vo.xz.XzClassVo;
|
22
|
21
|
import com.xhkjedu.slive.vo.xz.XzDateVo;
|
|
@@ -25,7 +24,6 @@ import com.xhkjedu.slive.vo.xz.XzDateKjVo;
|
25
|
24
|
import com.xhkjedu.utils.N_Utils;
|
26
|
25
|
import com.xhkjedu.vo.ResultVo;
|
27
|
26
|
import lombok.extern.slf4j.Slf4j;
|
28
|
|
-import org.springframework.aop.framework.AopContext;
|
29
|
27
|
import org.springframework.beans.factory.annotation.Autowired;
|
30
|
28
|
import org.springframework.context.ApplicationContext;
|
31
|
29
|
import org.springframework.stereotype.Service;
|
|
@@ -33,11 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
33
|
31
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
34
|
32
|
|
35
|
33
|
import javax.annotation.Resource;
|
36
|
|
-import javax.annotation.security.DenyAll;
|
37
|
|
-import java.util.ArrayList;
|
38
|
|
-import java.util.HashMap;
|
39
|
|
-import java.util.List;
|
40
|
|
-import java.util.Map;
|
|
34
|
+import java.util.*;
|
41
|
35
|
import java.util.stream.Collectors;
|
42
|
36
|
|
43
|
37
|
/**
|
|
@@ -195,57 +189,68 @@ public class XzService {
|
195
|
189
|
try {
|
196
|
190
|
//保存行政直播课程表,参数层级为日期--课节--班级和教师
|
197
|
191
|
//根据同一个课节下根据班级和教师确认是否是同一个直播课,保存进course,section(单课节课程)
|
198
|
|
- LXz x = xzMapper.selectByPrimaryKey(xz.getXzid());
|
|
192
|
+ LXz x = xzMapper.selectByPrimaryKey(xz.getXzid());//行政直播课程
|
199
|
193
|
List<XzDateVo> xzDatelst = xz.getXzdatas();
|
200
|
|
- for (int i = 0; i < xzDatelst.size(); i++) {
|
201
|
|
- //日期下的课节情况
|
202
|
|
- XzDateVo xzDateVo = xzDatelst.get(i);
|
203
|
|
- String datazhou = LiveUtil.getDateZhou(xzDateVo.getSelectdate());//要保存日期对应的周
|
204
|
|
- List<XzDateKjVo> dateKjlst = xzDateVo.getKjs();//指定日期下课节情况
|
205
|
|
-
|
206
|
|
- for (int j = 0; j < dateKjlst.size(); j++) {
|
207
|
|
- //单课节情况
|
208
|
|
- XzDateKjVo dateKjVo = dateKjlst.get(j);
|
209
|
|
- List<XzDateKjTeaVo> xjTealst = dateKjVo.getKjteas();//单课节下各班级情况
|
210
|
|
- //处理成教师下班级形式,生成课程
|
211
|
|
- Map<Integer, List<XzDateKjTeaVo>> map = listChangeTeacherClass(xjTealst);
|
212
|
|
- LCourse course = new LCourse();
|
213
|
|
- course.setGradeid(x.getGradeid());
|
214
|
|
- course.setBegindate(xzDateVo.getSelectdate());
|
215
|
|
- course.setEnddate(xzDateVo.getSelectdate());
|
216
|
|
- course.setCoursenum(1);
|
217
|
|
- course.setCoursetype(1);
|
218
|
|
- course.setCourseclass(1);
|
219
|
|
- course.setCoursestate(0);
|
220
|
|
- course.setDeleted(1);
|
221
|
|
- course.setCourseselected(0);
|
222
|
|
- course.setCreateid(xz.getCreateid());
|
223
|
|
- course.setCreatetime(N_Utils.getSecondTimestamp());
|
224
|
|
- course.setSchoolid(x.getSchoolid());
|
225
|
|
-
|
226
|
|
- for (Map.Entry<Integer, List<XzDateKjTeaVo>> entry : map.entrySet()) {
|
227
|
|
- List<XzDateKjTeaVo> xjTeas = entry.getValue();
|
228
|
|
- String teachername = xjTeas.get(0).getTeachername();
|
229
|
|
- //单个教师课程信息
|
230
|
|
- String coursename =
|
231
|
|
- datazhou + dateKjVo.getKjname() + xjTeas.get(0).getSubjectname() + "(" + teachername + ")";
|
232
|
|
-
|
233
|
|
- course.setCoursename(coursename);
|
234
|
|
- course.setSubjectid(xjTeas.get(0).getSubjectid());
|
235
|
|
- course.setTeacherid(entry.getKey());
|
236
|
|
- course.setBegintime(dateKjVo.getBegintime());
|
237
|
|
- course.setEndtime(dateKjVo.getEndtime());
|
238
|
|
- course.setKjid(dateKjVo.getKjid());
|
239
|
|
- //保存行政直播课程表,该方式解决事务不生效问题
|
240
|
|
- ((XzService)applicationContext.getBean("xzService")).saveCourseAll(xjTeas, course);
|
|
194
|
+ if (xzDatelst == null || xzDatelst.size() == 0) {
|
|
195
|
+ return new ResultVo(1, "未设置课节信息");
|
|
196
|
+ } else {
|
|
197
|
+ //日期转为map,先处理所有日期的数据
|
|
198
|
+ TreeMap<String,TreeMap<Integer,List<XzDateKjTeaVo>>> datemap = listDateKjForSave(xzDatelst, x);
|
|
199
|
+ Map<Integer,XzDateKjVo> kjVoMap = setKjMap(xz.getXzid());
|
|
200
|
+
|
|
201
|
+ //开始保存
|
|
202
|
+ for(Map.Entry<String, TreeMap<Integer,List<XzDateKjTeaVo>>> entry : datemap.entrySet()){
|
|
203
|
+ TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = entry.getValue();
|
|
204
|
+ String seldate = entry.getKey();
|
|
205
|
+ String datazhou = LiveUtil.getDateZhou(seldate);//要保存日期对应的周
|
|
206
|
+
|
|
207
|
+ for(Map.Entry<Integer, List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()){
|
|
208
|
+ Integer kjid = entrykj.getKey();
|
|
209
|
+ XzDateKjVo kjVo = kjVoMap.get(kjid);
|
|
210
|
+ List<XzDateKjTeaVo> xjTealst = entrykj.getValue();
|
|
211
|
+
|
|
212
|
+ //处理成教师下班级形式,生成课程
|
|
213
|
+ Map<Integer, List<XzDateKjTeaVo>> map = listChangeTeacherClass(xjTealst);
|
|
214
|
+
|
|
215
|
+ LCourse course = new LCourse();
|
|
216
|
+ course.setGradeid(x.getGradeid());
|
|
217
|
+ course.setBegindate(seldate);
|
|
218
|
+ course.setEnddate(seldate);
|
|
219
|
+ course.setCoursenum(1);
|
|
220
|
+ course.setCoursetype(1);
|
|
221
|
+ course.setCourseclass(1);
|
|
222
|
+ course.setCoursestate(0);
|
|
223
|
+ course.setDeleted(1);
|
|
224
|
+ course.setCourseselected(0);
|
|
225
|
+ course.setCreateid(xz.getCreateid());
|
|
226
|
+ course.setCreatetime(N_Utils.getSecondTimestamp());
|
|
227
|
+ course.setSchoolid(x.getSchoolid());
|
|
228
|
+
|
|
229
|
+ for (Map.Entry<Integer, List<XzDateKjTeaVo>> entrytea : map.entrySet()) {
|
|
230
|
+ List<XzDateKjTeaVo> xjTeas = entrytea.getValue();
|
|
231
|
+ String teachername = xjTeas.get(0).getTeachername();
|
|
232
|
+ //单个教师课程信息
|
|
233
|
+ String coursename = datazhou + kjVo.getKjname() + xjTeas.get(0).getSubjectname() + "(" + teachername + ")";
|
|
234
|
+
|
|
235
|
+ course.setCoursename(coursename);
|
|
236
|
+ course.setSubjectid(xjTeas.get(0).getSubjectid());
|
|
237
|
+ course.setTeacherid(entrytea.getKey());
|
|
238
|
+ course.setBegintime(kjVo.getBegintime());
|
|
239
|
+ course.setEndtime(kjVo.getEndtime());
|
|
240
|
+ course.setKjid(kjVo.getKjid());
|
|
241
|
+ //保存行政直播课程表,该方式解决事务不生效问题
|
|
242
|
+ ((XzService)applicationContext.getBean("xzService")).saveCourseAll(xjTeas, course);
|
|
243
|
+ }
|
241
|
244
|
}
|
242
|
245
|
}
|
|
246
|
+ return new ResultVo(0, "保存行政直播课程表成功");
|
243
|
247
|
}
|
244
|
248
|
} catch (Exception e) {
|
245
|
249
|
log.error("保存行政直播课程表出错:" + e.getMessage());
|
|
250
|
+ return new ResultVo(1,"保存行政直播课程表失败");
|
246
|
251
|
}
|
247
|
252
|
|
248
|
|
- return new ResultVo(0, "保存行政直播课程表成功");
|
|
253
|
+
|
249
|
254
|
}
|
250
|
255
|
|
251
|
256
|
//指定天某天某节课下的教师班级层级关系
|
|
@@ -267,6 +272,92 @@ public class XzService {
|
267
|
272
|
return map;
|
268
|
273
|
}
|
269
|
274
|
|
|
275
|
+ //转换日期下课节为map
|
|
276
|
+ private TreeMap<String, TreeMap<Integer,List<XzDateKjTeaVo>>> listDateKjForSave(List<XzDateVo> xzDatelst, LXz x) {
|
|
277
|
+ TreeMap<String, TreeMap<Integer,List<XzDateKjTeaVo>>> datemap = new TreeMap<>();
|
|
278
|
+ for (int i = 0; i < xzDatelst.size(); i++) {
|
|
279
|
+ XzDateVo xzdate = xzDatelst.get(i);
|
|
280
|
+ List<XzDateKjVo> kjlst = xzdate.getKjs();
|
|
281
|
+ if(kjlst!=null && kjlst.size()>0){
|
|
282
|
+ TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = new TreeMap<>();
|
|
283
|
+ for(int j=0;j<kjlst.size();j++){
|
|
284
|
+ XzDateKjVo kjvo = kjlst.get(j);
|
|
285
|
+ if(kjvo.getKjteas()!=null && kjvo.getKjteas().size()>0){
|
|
286
|
+ kjmap.put(kjvo.getKjid(),kjvo.getKjteas());
|
|
287
|
+ }
|
|
288
|
+ }
|
|
289
|
+ datemap.put(xzdate.getSelectdate(),kjmap);
|
|
290
|
+ }
|
|
291
|
+ }
|
|
292
|
+
|
|
293
|
+ TreeMap<String, TreeMap<Integer,List<XzDateKjTeaVo>>> rtnmap = new TreeMap<>();
|
|
294
|
+ rtnmap.putAll(datemap);
|
|
295
|
+
|
|
296
|
+ //开始处理所有日期的课程
|
|
297
|
+ for (Map.Entry<String, TreeMap<Integer,List<XzDateKjTeaVo>>> entry : datemap.entrySet()){
|
|
298
|
+ String datestr = entry.getKey();//日期
|
|
299
|
+ TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = entry.getValue();
|
|
300
|
+ //遍历当前天的课节,判断是否有需要后续同步的
|
|
301
|
+ for (Map.Entry<Integer,List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()){
|
|
302
|
+ List<XzDateKjTeaVo> kjTeaVolst = entrykj.getValue();
|
|
303
|
+ for (int i = 0; i < kjTeaVolst.size(); i++) {
|
|
304
|
+ XzDateKjTeaVo xtvo = kjTeaVolst.get(i);
|
|
305
|
+ if(!N_Utils.isEmptyInteger(xtvo.getKfollow())){
|
|
306
|
+ //说明需要同步到后续日期(结束时间之前所有当前天所属的周几)
|
|
307
|
+ List<String> dates = LiveUtil.getDaysForMeetDates(datestr,x.getEnddate());
|
|
308
|
+ if(dates!=null && dates.size()>1){
|
|
309
|
+ //说明直接有日期(不包含当前天),复制数据,处理时舍弃当前天
|
|
310
|
+ isSavechangeMapKj(dates,entrykj.getKey(),xtvo,rtnmap);
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+ }
|
|
314
|
+ }
|
|
315
|
+ }
|
|
316
|
+
|
|
317
|
+ return rtnmap;
|
|
318
|
+ }
|
|
319
|
+
|
|
320
|
+ //保存整体数据
|
|
321
|
+ private void isSavechangeMapKj( List<String> dates,Integer kjid,XzDateKjTeaVo xtvo,TreeMap<String, TreeMap<Integer,List<XzDateKjTeaVo>>> datemap){
|
|
322
|
+ //说明直接有日期(不包含当前天),复制数据,处理时舍弃当前天
|
|
323
|
+ for (int i = 1; i < dates.size(); i++) {
|
|
324
|
+ String dateobj = dates.get(i);
|
|
325
|
+ if(datemap.containsKey(dateobj)){
|
|
326
|
+ //说明该日期数据已存在
|
|
327
|
+ TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = datemap.get(dateobj);
|
|
328
|
+ if(kjmap.containsKey(kjid)){
|
|
329
|
+ kjmap.get(kjid).add(xtvo);
|
|
330
|
+ }else{
|
|
331
|
+ List<XzDateKjTeaVo> kjTeaVos = new ArrayList<>();
|
|
332
|
+ kjTeaVos.add(xtvo);
|
|
333
|
+ kjmap.put(kjid,kjTeaVos);
|
|
334
|
+ }
|
|
335
|
+ }else{
|
|
336
|
+ //新添加
|
|
337
|
+ TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = new TreeMap<>();
|
|
338
|
+ List<XzDateKjTeaVo> kjTeaVos = new ArrayList<>();
|
|
339
|
+ kjTeaVos.add(xtvo);
|
|
340
|
+ kjmap.put(kjid,kjTeaVos);
|
|
341
|
+
|
|
342
|
+ datemap.put(dateobj,kjmap);
|
|
343
|
+ }
|
|
344
|
+ }
|
|
345
|
+ }
|
|
346
|
+
|
|
347
|
+ //处理课节格式
|
|
348
|
+ private Map<Integer,XzDateKjVo> setKjMap(Integer xzid){
|
|
349
|
+ List<XzDateKjVo> lst = xzKjMapper.listXzKjsByXzid(xzid);
|
|
350
|
+ Map<Integer, XzDateKjVo> map = new HashMap<>();
|
|
351
|
+
|
|
352
|
+ for (int i = 0; i < lst.size(); i++) {
|
|
353
|
+ XzDateKjVo kj = lst.get(i);
|
|
354
|
+ map.put(kj.getKjid(), kj);
|
|
355
|
+ }
|
|
356
|
+ return map;
|
|
357
|
+ }
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
270
|
361
|
//保存行政直播课程表
|
271
|
362
|
@Transactional(rollbackFor = Exception.class)
|
272
|
363
|
public void saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course) {
|
|
@@ -372,7 +463,7 @@ public class XzService {
|
372
|
463
|
XzClassVo classVo = classlst.get(i);
|
373
|
464
|
List<XzDateVo> datelst = new ArrayList<>();//保存指定日期
|
374
|
465
|
for (int j = 0; j < seldates.size(); j++) {
|
375
|
|
- List<Map> kjlst = xzMapper.listXzDateKjDetail(seldates.get(j), xz.getXzid(),classVo.getClassid());//获取课节详情
|
|
466
|
+ List<Map> kjlst = xzMapper.listXzDateKjDetail(seldates.get(j), xz.getXzid(), classVo.getClassid());//获取课节详情
|
376
|
467
|
XzDateVo dateVo = new XzDateVo();
|
377
|
468
|
dateVo.setSelectdate(seldates.get(j));
|
378
|
469
|
dateVo.setKjsmap(kjlst);
|
|
@@ -399,12 +490,12 @@ public class XzService {
|
399
|
490
|
Integer kjid = course.getKjid();
|
400
|
491
|
Integer classid = kjTeaVo.getClassid();//行政班id
|
401
|
492
|
if (course.getCoursestate() > 0) {
|
402
|
|
- return new ResultVo(1,"选择的课程已经开始上课,不允许删除");
|
|
493
|
+ return new ResultVo(1, "选择的课程已经开始上课,不允许删除");
|
403
|
494
|
} else {
|
404
|
495
|
//先判断是删除当前课程还是后续日期的课
|
405
|
496
|
if (N_Utils.isEmptyInteger(kjTeaVo.getKfollow())) {
|
406
|
497
|
//kfollow为0或者空,则只需要删除当前选中的课程
|
407
|
|
- ((XzService)applicationContext.getBean("xzService")).delXzkjDygForDetail(kjTeaVo, course.getClassid());
|
|
498
|
+ ((XzService) applicationContext.getBean("xzService")).delXzkjDygForDetail(kjTeaVo, course.getClassid());
|
408
|
499
|
} else {
|
409
|
500
|
//需要删除后续和当前日期相同的星期相同课节的课程
|
410
|
501
|
//获取已生成课程从所选删除课程开始日期到结束日期内所有日期
|
|
@@ -417,7 +508,7 @@ public class XzService {
|
417
|
508
|
//先获取指定日期对应的课程
|
418
|
509
|
CourseVo courseVo = courseMapper.getCourseByKjidAndClassid(kjid, classid, deldates.get(i));
|
419
|
510
|
kjTeaVo.setCourseid(courseVo.getCourseid());
|
420
|
|
- ((XzService)applicationContext.getBean("xzService")).delXzkjDygForDetail(kjTeaVo,courseVo.getClassid());
|
|
511
|
+ ((XzService) applicationContext.getBean("xzService")).delXzkjDygForDetail(kjTeaVo, courseVo.getClassid());
|
421
|
512
|
}
|
422
|
513
|
}
|
423
|
514
|
}
|
|
@@ -435,7 +526,7 @@ public class XzService {
|
435
|
526
|
public void delXzkjDygForDetail(XzDateKjTeaVo kjTeaVo, Integer zbclassid) {
|
436
|
527
|
try {
|
437
|
528
|
//删除单个单元格中设置的教师信息,先判断该单元格对应的课程是否有其他班级
|
438
|
|
- Integer coursenum = courseClassMapper.getOtherClassnumByCourseid(kjTeaVo.getCourseid(),kjTeaVo.getClassid());
|
|
529
|
+ Integer coursenum = courseClassMapper.getOtherClassnumByCourseid(kjTeaVo.getCourseid(), kjTeaVo.getClassid());
|
439
|
530
|
if (coursenum == 0) {
|
440
|
531
|
//说明该课程仅关联一个班级,直接删除该课程以及该课程对应的直播班
|
441
|
532
|
courseMapper.deleteCourseClassByCourseid(kjTeaVo.getCourseid());
|
|
@@ -469,20 +560,20 @@ public class XzService {
|
469
|
560
|
//先判断是保存当前课程还是后续日期的课
|
470
|
561
|
if (N_Utils.isEmptyInteger(kjTeaVo.getKfollow())) {
|
471
|
562
|
//kfollow为0或者空,则只需要保存当前选中的课程
|
472
|
|
- ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
|
|
563
|
+ ((XzService) applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
|
473
|
564
|
} else {
|
474
|
565
|
//需要保存后续和当前日期相同的星期相同课节的课程,判断后续日期是否有课程,如果有则提示先删除后再添加
|
475
|
566
|
//获取已生成课程的往后日期
|
476
|
567
|
List<String> alldates = xzMapper.getAllDatesForKj(kjTeaVo.getKjid(), kjTeaVo.getClassid(), kjTeaVo.getSeldate());
|
477
|
|
- if(alldates != null && alldates.size() > 0){
|
|
568
|
+ if (alldates != null && alldates.size() > 0) {
|
478
|
569
|
//去匹配是否包含在当前选中日期后续周对应的日期
|
479
|
|
- List<String> afterlst = LiveUtil.getMeetDayOfDates(alldates,kjTeaVo.getSeldate());
|
480
|
|
- if(afterlst != null && afterlst.size() > 0){
|
481
|
|
- return new ResultVo(1,"同日期同班级同课节有数据,不能保存");
|
482
|
|
- }else{
|
|
570
|
+ List<String> afterlst = LiveUtil.getMeetDayOfDates(alldates, kjTeaVo.getSeldate());
|
|
571
|
+ if (afterlst != null && afterlst.size() > 0) {
|
|
572
|
+ return new ResultVo(1, "同日期同班级同课节有数据,不能保存");
|
|
573
|
+ } else {
|
483
|
574
|
|
484
|
575
|
//获取seldate至结束日期时端内符合条件的日期
|
485
|
|
- List<String> savedates = LiveUtil.getDaysForMeetDates(kjTeaVo.getSeldate(),xz.getEnddate());
|
|
576
|
+ List<String> savedates = LiveUtil.getDaysForMeetDates(kjTeaVo.getSeldate(), xz.getEnddate());
|
486
|
577
|
for (int i = 0; i < savedates.size(); i++) {
|
487
|
578
|
kjTeaVo.setSeldate(savedates.get(i));
|
488
|
579
|
// ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
|
|
@@ -534,7 +625,7 @@ public class XzService {
|
534
|
625
|
//保存行政直播课程表,调用保存整个课表时的方法
|
535
|
626
|
List<XzDateKjTeaVo> lst = new ArrayList<>();
|
536
|
627
|
lst.add(kjTeaVo);
|
537
|
|
- ((XzService)applicationContext.getBean("xzService")).saveCourseAll(lst, course);
|
|
628
|
+ ((XzService) applicationContext.getBean("xzService")).saveCourseAll(lst, course);
|
538
|
629
|
} else {
|
539
|
630
|
//说明该教师当前有其他直播课,则把班级加入课程,完成直播课学生数量
|
540
|
631
|
TClassStudent cs = new TClassStudent();
|