|
@@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
33
|
33
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
34
|
34
|
|
35
|
35
|
import javax.annotation.Resource;
|
|
36
|
+import javax.annotation.security.DenyAll;
|
36
|
37
|
import java.util.ArrayList;
|
37
|
38
|
import java.util.HashMap;
|
38
|
39
|
import java.util.List;
|
|
@@ -321,9 +322,6 @@ public class XzService {
|
321
|
322
|
cc.setCreateid(course.getCreateid());
|
322
|
323
|
cc.setCreatetime(course.getCreatetime());
|
323
|
324
|
cclist.add(cc);
|
324
|
|
- //通知班级
|
325
|
|
- ClassVo classVo = new ClassVo();
|
326
|
|
- classVo.setClassid(cid);
|
327
|
325
|
}
|
328
|
326
|
courseClassMapper.insertList(cclist);//保存原班级和直播的关联关系
|
329
|
327
|
|
|
@@ -341,7 +339,6 @@ public class XzService {
|
341
|
339
|
cs.setCreateid(course.getCreateid());
|
342
|
340
|
cs.setCreatetime(course.getCreatetime());
|
343
|
341
|
courseSectionMapper.insertUseGeneratedKeys(cs);//保存课程课节信息
|
344
|
|
-
|
345
|
342
|
} catch (Exception e) {
|
346
|
343
|
log.info("保存行政直播课程表出错:" + e.getMessage());
|
347
|
344
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
@@ -457,64 +454,91 @@ public class XzService {
|
457
|
454
|
}
|
458
|
455
|
|
459
|
456
|
/**
|
460
|
|
- * @Description 修改单个单元格
|
|
457
|
+ * @Description 保存单个单元格(单元格)
|
461
|
458
|
* @Param [kjTeaVo]
|
462
|
459
|
* @Return com.xhkjedu.vo.ResultVo
|
463
|
460
|
* @Author wn
|
464
|
461
|
* @Date 2022/4/2 15:19
|
465
|
462
|
**/
|
466
|
|
- public ResultVo updateXzKjDyg(XzDateKjTeaVo kjTeaVo) {
|
|
463
|
+ public ResultVo saveOneXzKjDyg(XzDateKjTeaVo kjTeaVo) {
|
467
|
464
|
try {
|
468
|
|
- //判断课程的状态,如果已经开始上课则不能修改
|
469
|
|
- LCourse course = courseMapper.selectByPrimaryKey(kjTeaVo.getCourseid());
|
470
|
|
- Integer kjid = course.getKjid();
|
471
|
|
- Integer classid = kjTeaVo.getClassid();//行政班id
|
472
|
|
- if (course.getCoursestate() > 0) {
|
473
|
|
- throw new Exception("选择的课程已经开始上课,不允许修改");
|
|
465
|
+ LXz xz = xzMapper.getXzByXzkjid(kjTeaVo.getKjid());
|
|
466
|
+ kjTeaVo.setGradeid(xz.getGradeid());
|
|
467
|
+ kjTeaVo.setSchoolid(xz.getSchoolid());
|
|
468
|
+
|
|
469
|
+ //先判断是保存当前课程还是后续日期的课
|
|
470
|
+ if (N_Utils.isEmptyInteger(kjTeaVo.getKfollow())) {
|
|
471
|
+ //kfollow为0或者空,则只需要保存当前选中的课程
|
|
472
|
+ ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
|
474
|
473
|
} else {
|
475
|
|
- //先判断是修改当前课程还是后续日期的课
|
476
|
|
- if (N_Utils.isEmptyInteger(kjTeaVo.getKfollow())) {
|
477
|
|
- //kfollow为0或者空,则只需要修改当前选中的课程
|
478
|
|
- ((XzService)applicationContext.getBean("xzService")).updateXzkjDygForDetail(kjTeaVo, course);
|
479
|
|
- } else {
|
480
|
|
- //需要修改后续和当前日期相同的星期相同课节的课程
|
481
|
|
- //获取已生成课程的最后日期
|
482
|
|
- List<String> alldates = xzMapper.getAllDatesForKj(kjid, classid, course.getBegindate());
|
483
|
|
- if (alldates != null && alldates.size() > 0) {
|
484
|
|
- //已经成课程中符合周的需要修改的日期
|
485
|
|
- List<String> deldates = LiveUtil.getMeetDayOfDates(alldates, course.getBegindate());
|
486
|
|
- if (deldates != null && deldates.size() > 0) {
|
487
|
|
- for (int i = 0; i < deldates.size(); i++) {
|
488
|
|
- //先获取指定日期对应的课程
|
489
|
|
- course.setBegintime(deldates.get(i));
|
490
|
|
- ((XzService)applicationContext.getBean("xzService")).updateXzkjDygForDetail(kjTeaVo, course);
|
491
|
|
- }
|
|
474
|
+ //需要保存后续和当前日期相同的星期相同课节的课程,判断后续日期是否有课程,如果有则提示先删除后再添加
|
|
475
|
+ //获取已生成课程的往后日期
|
|
476
|
+ List<String> alldates = xzMapper.getAllDatesForKj(kjTeaVo.getKjid(), kjTeaVo.getClassid(), kjTeaVo.getSeldate());
|
|
477
|
+ if(alldates != null && alldates.size() > 0){
|
|
478
|
+ //去匹配是否包含在当前选中日期后续周对应的日期
|
|
479
|
+ List<String> afterlst = LiveUtil.getMeetDayOfDates(alldates,kjTeaVo.getSeldate());
|
|
480
|
+ if(afterlst != null && afterlst.size() > 0){
|
|
481
|
+ return new ResultVo(1,"同日期同班级同课节有数据,不能保存");
|
|
482
|
+ }else{
|
|
483
|
+
|
|
484
|
+ //获取seldate至结束日期时端内符合条件的日期
|
|
485
|
+ List<String> savedates = LiveUtil.getDaysForMeetDates(kjTeaVo.getSeldate(),xz.getEnddate());
|
|
486
|
+ for (int i = 0; i < savedates.size(); i++) {
|
|
487
|
+ kjTeaVo.setSeldate(savedates.get(i));
|
|
488
|
+// ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
|
492
|
489
|
}
|
493
|
490
|
}
|
494
|
491
|
}
|
495
|
|
- return new ResultVo(0, "成功修改课程表单个课程");
|
496
|
492
|
}
|
|
493
|
+ return new ResultVo(0, "成功保存课程表单个课程");
|
497
|
494
|
} catch (Exception e) {
|
498
|
|
- log.error("修改课程表单个课程出错:" + e.getMessage());
|
499
|
|
- return new ResultVo(1, "修改课程表单个课程失败");
|
|
495
|
+ log.error("保存课程表单个课程出错:" + e.getMessage());
|
|
496
|
+ return new ResultVo(1, "保存课程表单个课程失败");
|
500
|
497
|
}
|
501
|
498
|
}
|
502
|
499
|
|
503
|
|
- //修改单个课程
|
|
500
|
+ //保存单个课程
|
504
|
501
|
@Transactional(rollbackFor = Exception.class)
|
505
|
|
- public void updateXzkjDygForDetail(XzDateKjTeaVo kjTeaVo, LCourse course) {
|
|
502
|
+ public void saveOneXzkjDygForDetail(XzDateKjTeaVo kjTeaVo) {
|
506
|
503
|
try {
|
507
|
504
|
//先看新选择的教师情况,先判断选中的同一日期课节教师是否还有其他直播课
|
508
|
|
- CourseVo courseVo = courseMapper.getCourseByDateKjTeacher(course.getKjid(), kjTeaVo.getTeacherid(),
|
509
|
|
- course.getBegindate());
|
|
505
|
+ CourseVo courseVo = courseMapper.getCourseByDateKjTeacher(kjTeaVo);
|
510
|
506
|
if (courseVo == null) {
|
511
|
|
- //说明该老师之前没有直播课,则直接修改课程任课教师,直播班关联教师以及科目
|
512
|
|
- courseMapper.updateCourseSectionClassTeacher(course.getCourseid(), kjTeaVo.getTeacherid(),
|
513
|
|
- kjTeaVo.getSubjectid());
|
|
507
|
+ //说明该老师之前没有直播课,则直接保存为新的课程
|
|
508
|
+ LCourse course = new LCourse();
|
|
509
|
+ course.setGradeid(kjTeaVo.getGradeid());
|
|
510
|
+ course.setBegindate(kjTeaVo.getSeldate());
|
|
511
|
+ course.setEnddate(kjTeaVo.getSeldate());
|
|
512
|
+ course.setCoursenum(1);
|
|
513
|
+ course.setCoursetype(1);
|
|
514
|
+ course.setCourseclass(1);
|
|
515
|
+ course.setCoursestate(0);
|
|
516
|
+ course.setDeleted(1);
|
|
517
|
+ course.setCourseselected(0);
|
|
518
|
+ course.setCreateid(kjTeaVo.getCreateid());
|
|
519
|
+ course.setCreatetime(N_Utils.getSecondTimestamp());
|
|
520
|
+ course.setSchoolid(kjTeaVo.getSchoolid());
|
|
521
|
+
|
|
522
|
+ String datezhou = LiveUtil.getDateZhou(kjTeaVo.getSeldate());
|
|
523
|
+ LXzKj kj = xzKjMapper.selectByPrimaryKey(kjTeaVo.getKjid());//课节详情
|
|
524
|
+
|
|
525
|
+ //单个教师课程信息
|
|
526
|
+ String coursename = datezhou + kj.getKjname() + kjTeaVo.getSubjectname() + "(" + kjTeaVo.getTeachername() + ")";
|
|
527
|
+
|
|
528
|
+ course.setCoursename(coursename);
|
|
529
|
+ course.setSubjectid(kjTeaVo.getSubjectid());
|
|
530
|
+ course.setTeacherid(kjTeaVo.getTeacherid());
|
|
531
|
+ course.setBegintime(kj.getBegintime());
|
|
532
|
+ course.setEndtime(kj.getEndtime());
|
|
533
|
+ course.setKjid(kjTeaVo.getKjid());
|
|
534
|
+ //保存行政直播课程表,调用保存整个课表时的方法
|
|
535
|
+ List<XzDateKjTeaVo> lst = new ArrayList<>();
|
|
536
|
+ lst.add(kjTeaVo);
|
|
537
|
+ ((XzService)applicationContext.getBean("xzService")).saveCourseAll(lst, course);
|
514
|
538
|
} else {
|
515
|
539
|
//说明该教师当前有其他直播课,则把班级加入课程,完成直播课学生数量
|
516
|
540
|
TClassStudent cs = new TClassStudent();
|
517
|
|
- cs.setSchoolid(course.getSchoolid());
|
|
541
|
+ cs.setSchoolid(kjTeaVo.getSchoolid());
|
518
|
542
|
cs.setClassid(kjTeaVo.getClassid());
|
519
|
543
|
cs.setCreateid(kjTeaVo.getCreateid());
|
520
|
544
|
classStudentMapper.saveAllClassStu(cs, courseVo.getClassid());
|
|
@@ -523,25 +547,9 @@ public class XzService {
|
523
|
547
|
groupMapper.saveAllClassGroupStu(cs, courseVo.getClassid(), groupid);
|
524
|
548
|
classMapper.updateNum2(courseVo.getClassid());//更改直播班级以及班级分组人数
|
525
|
549
|
courseMapper.updateStuNum(courseVo.getCourseid());//更新直播课学生数量
|
526
|
|
-
|
527
|
|
- //把指定的班级从原直播班中移除
|
528
|
|
- //修改原单元格中设置的教师信息,先判断该单元格对应的课程是否有其他班级
|
529
|
|
- Integer coursenum = courseClassMapper.getOtherClassnumByCourseid(kjTeaVo.getCourseid(),
|
530
|
|
- kjTeaVo.getClassid());
|
531
|
|
- if (coursenum == 0) {
|
532
|
|
- //说明该课程仅关联一个班级,直接修改该课程以及该课程对应的直播班
|
533
|
|
- courseMapper.deleteCourseClassByCourseid(kjTeaVo.getCourseid());
|
534
|
|
- } else {
|
535
|
|
- //说明关联的还有其他班级,修改该班级在直播班级中的学生,
|
536
|
|
- courseClassMapper.deleteByCourseidAndClassid(kjTeaVo.getCourseid(), kjTeaVo.getClassid());
|
537
|
|
- //处理对应直播班级中学生
|
538
|
|
- classMapper.deleteClassstu(course.getClassid(), kjTeaVo.getClassid());
|
539
|
|
- classMapper.updateNum2(course.getClassid());//更改班级以及班级分组人数
|
540
|
|
- courseMapper.updateStuNum(kjTeaVo.getCourseid());//更新直播课学生数量
|
541
|
|
- }
|
542
|
550
|
}
|
543
|
551
|
} catch (Exception e) {
|
544
|
|
- log.error("修改单个课程出错:" + e.getMessage());
|
|
552
|
+ log.error("保存单个课程出错:" + e.getMessage());
|
545
|
553
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
546
|
554
|
}
|
547
|
555
|
}
|