|
@@ -96,6 +96,7 @@ public class XzService {
|
96
|
96
|
xz.setCreatetime(timestamp);
|
97
|
97
|
xz.setDeleted(1);
|
98
|
98
|
xz.setCurstep(2);
|
|
99
|
+ xz.setSavestate(0);
|
99
|
100
|
xzMapper.insertUseGeneratedKeys(xz);//保存行政直播信息
|
100
|
101
|
Integer xzid = xz.getId();
|
101
|
102
|
//保存对应的课节信息
|
|
@@ -163,6 +164,8 @@ public class XzService {
|
163
|
164
|
@Transactional(rollbackFor = Exception.class)
|
164
|
165
|
public void deleteXz(Integer xzid) {
|
165
|
166
|
try {
|
|
167
|
+ Integer savestate = xzMapper.getSaveStateById(xzid);
|
|
168
|
+ if (savestate != 0) throw new Exception("有课表在保存中禁止操作");
|
166
|
169
|
//如果行政直播下所有的课都未开始,则可以直接删除,
|
167
|
170
|
//如果有直播课已经开始则进行逻辑删除,并删除所有未开始上的直播课
|
168
|
171
|
Integer sectionnum = xzMapper.getXzSectionKsNum(xzid);
|
|
@@ -191,25 +194,28 @@ public class XzService {
|
191
|
194
|
* @Date 2022/3/31 21:46
|
192
|
195
|
**/
|
193
|
196
|
public ResultVo saveXzCourse(LXz xz) {
|
|
197
|
+ Integer xzid = xz.getXzid();
|
194
|
198
|
try {
|
195
|
199
|
//保存行政直播课程表,参数层级为日期--课节--班级和教师
|
196
|
200
|
//根据同一个课节下根据班级和教师确认是否是同一个直播课,保存进course,section(单课节课程)
|
197
|
|
- LXz x = xzMapper.selectByPrimaryKey(xz.getXzid());//行政直播课程
|
|
201
|
+ LXz x = xzMapper.selectByPrimaryKey(xzid);//行政直播课程
|
|
202
|
+ if (x.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
|
|
203
|
+ xzMapper.updateSaveState(xzid, 1);//修改保存状态
|
198
|
204
|
List<XzDateVo> xzDatelst = xz.getXzdatas();
|
199
|
205
|
if (xzDatelst == null || xzDatelst.size() == 0) {
|
200
|
206
|
return new ResultVo(1, "未设置课节信息");
|
201
|
207
|
} else {
|
202
|
208
|
//日期转为map,先处理所有日期的数据
|
203
|
|
- TreeMap<String,TreeMap<Integer,List<XzDateKjTeaVo>>> datemap = listDateKjForSave(xzDatelst, x);
|
204
|
|
- Map<Integer,XzDateKjVo> kjVoMap = setKjMap(xz.getXzid());
|
|
209
|
+ TreeMap<String, TreeMap<Integer, List<XzDateKjTeaVo>>> datemap = listDateKjForSave(xzDatelst, x);
|
|
210
|
+ Map<Integer, XzDateKjVo> kjVoMap = setKjMap(xzid);
|
205
|
211
|
|
206
|
212
|
//开始保存
|
207
|
|
- for(Map.Entry<String, TreeMap<Integer,List<XzDateKjTeaVo>>> entry : datemap.entrySet()){
|
208
|
|
- TreeMap<Integer,List<XzDateKjTeaVo>> kjmap = entry.getValue();
|
|
213
|
+ for (Map.Entry<String, TreeMap<Integer, List<XzDateKjTeaVo>>> entry : datemap.entrySet()) {
|
|
214
|
+ TreeMap<Integer, List<XzDateKjTeaVo>> kjmap = entry.getValue();
|
209
|
215
|
String seldate = entry.getKey();
|
210
|
216
|
String datazhou = LiveUtil.getDateZhou(seldate);//要保存日期对应的周
|
211
|
217
|
|
212
|
|
- for(Map.Entry<Integer, List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()){
|
|
218
|
+ for (Map.Entry<Integer, List<XzDateKjTeaVo>> entrykj : kjmap.entrySet()) {
|
213
|
219
|
Integer kjid = entrykj.getKey();
|
214
|
220
|
XzDateKjVo kjVo = kjVoMap.get(kjid);
|
215
|
221
|
List<XzDateKjTeaVo> xjTealst = entrykj.getValue();
|
|
@@ -257,12 +263,13 @@ public class XzService {
|
257
|
263
|
}
|
258
|
264
|
|
259
|
265
|
//保存完课程表之后修改当前步骤
|
260
|
|
- xzMapper.updateCurstepByXzid(3,xz.getXzid());
|
|
266
|
+ xzMapper.updateCurstepByXzid(3, xzid);
|
261
|
267
|
|
262
|
268
|
return new ResultVo(0, "保存成功");
|
263
|
269
|
}
|
264
|
270
|
} catch (Exception e) {
|
265
|
271
|
log.error("保存行政直播课程表出错:" + e.getMessage());
|
|
272
|
+ xzMapper.updateSaveState(xzid, 0);//修改保存状态
|
266
|
273
|
return new ResultVo(1,"保存失败");
|
267
|
274
|
}
|
268
|
275
|
|
|
@@ -508,6 +515,8 @@ public class XzService {
|
508
|
515
|
**/
|
509
|
516
|
public ResultVo delXzkjDyg(XzDateKjTeaVo kjTeaVo) {
|
510
|
517
|
try {
|
|
518
|
+ Integer savestate = xzMapper.getSaveStateById(kjTeaVo.getXzid());
|
|
519
|
+ if (savestate != 0) return new ResultVo(1, "有课表在保存中禁止操作");
|
511
|
520
|
//判断课程的状态,如果已经开始上课则不能删除
|
512
|
521
|
LCourse course = courseMapper.selectByPrimaryKey(kjTeaVo.getCourseid());
|
513
|
522
|
Integer kjid = course.getKjid();
|
|
@@ -576,8 +585,11 @@ public class XzService {
|
576
|
585
|
* @Date 2022/4/2 15:19
|
577
|
586
|
**/
|
578
|
587
|
public ResultVo saveOneXzKjDyg(XzDateKjTeaVo kjTeaVo) {
|
|
588
|
+ LXz xz = xzMapper.getXzByXzkjid(kjTeaVo.getKjid());
|
|
589
|
+ Integer xzid = xz.getXzid();
|
579
|
590
|
try {
|
580
|
|
- LXz xz = xzMapper.getXzByXzkjid(kjTeaVo.getKjid());
|
|
591
|
+ if (xz.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
|
|
592
|
+ xzMapper.updateSaveState(xzid, 1);//修改保存状态
|
581
|
593
|
kjTeaVo.setGradeid(xz.getGradeid());
|
582
|
594
|
kjTeaVo.setSchoolid(xz.getSchoolid());
|
583
|
595
|
|
|
@@ -612,14 +624,16 @@ public class XzService {
|
612
|
624
|
|
613
|
625
|
}
|
614
|
626
|
}
|
615
|
|
- return new ResultVo(0, "保存成功",courseid);
|
|
627
|
+ return new ResultVo(0, "保存成功", courseid);
|
616
|
628
|
} catch (Exception e) {
|
617
|
629
|
log.error("保存课程表单个课程出错:" + e.getMessage());
|
618
|
|
- if(e.getMessage().equals("所选班级无学生")){
|
|
630
|
+ if (e.getMessage().equals("所选班级无学生")) {
|
619
|
631
|
return new ResultVo(1, "保存失败:所选班级无学生");
|
620
|
|
- }else{
|
|
632
|
+ } else {
|
621
|
633
|
return new ResultVo(1, "保存失败");
|
622
|
634
|
}
|
|
635
|
+ } finally {
|
|
636
|
+ xzMapper.updateSaveState(xzid, 0);//修改保存状态
|
623
|
637
|
}
|
624
|
638
|
}
|
625
|
639
|
|
|
@@ -721,6 +735,8 @@ public class XzService {
|
721
|
735
|
try {
|
722
|
736
|
//获取行政直播信息
|
723
|
737
|
LXz xz = xzMapper.selectByPrimaryKey(xzid);
|
|
738
|
+ if (xz.getSavestate() != 0) return new ResultVo(1, "有课表在保存中禁止操作");
|
|
739
|
+ xzMapper.updateSaveState(xzid, 1);//修改保存状态
|
724
|
740
|
List<XzKjVo> kjs = xzKjMapper.listXzKjByXzId(xzid);//获取行政直播课节详情
|
725
|
741
|
Integer noTimeKjNum = kjs.stream().filter(k -> k.getBegintime() == null).collect(Collectors.toList()).size();
|
726
|
742
|
if (noTimeKjNum != 0) return new ResultVo(1, "请设置课节时间");
|
|
@@ -730,22 +746,28 @@ public class XzService {
|
730
|
746
|
Integer schoolid = xz.getSchoolid();
|
731
|
747
|
Integer year = schoolMapper.getYearById(schoolid);
|
732
|
748
|
List<XzClassVo> classlst = classMapper.listClassByXzid(schoolid, gradeid);
|
733
|
|
- String classids = classlst.stream().map((XzClassVo::getClassid)).map(String::valueOf).collect(Collectors.joining(","));
|
|
749
|
+ String classids = classlst.stream().map((XzClassVo::getClassid)).map(String::valueOf).collect(Collectors.joining(","
|
|
750
|
+ ));
|
734
|
751
|
List<CTeacherVo> teachers = classTeacherMapper.listTeacherByClassIds(classids);//获取班级教师
|
735
|
|
- if(!N_Utils.isListNotEmpty(teachers)) return new ResultVo(1,"请设置班级任教老师");
|
|
752
|
+ if (!N_Utils.isListNotEmpty(teachers)) return new ResultVo(1, "请设置班级任教老师");
|
736
|
753
|
|
737
|
|
- String teacherids = teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).collect(Collectors.joining(","));
|
|
754
|
+ String teacherids =
|
|
755
|
+ teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).collect(Collectors.joining(","));
|
738
|
756
|
List<CTeacherVo> subjects = classTeacherMapper.listSubjectByTeacherIds(teacherids);//获取教师科目
|
739
|
757
|
String subjectids = subjects.stream().map(CTeacherVo::getSubjectid).distinct().collect(Collectors.joining("','"));
|
740
|
758
|
List<CTeacherVo> subjects2 = classTeacherMapper.listSubjectBySubjectIds(subjectids);
|
741
|
|
- Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid, CTeacherVo::getSubjectname));
|
742
|
|
- Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid, CTeacherVo::getSubjectid));
|
743
|
|
- Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid, XzClassVo::getClassname));
|
|
759
|
+ Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid,
|
|
760
|
+ CTeacherVo::getSubjectname));
|
|
761
|
+ Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid,
|
|
762
|
+ CTeacherVo::getSubjectid));
|
|
763
|
+ Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid,
|
|
764
|
+ XzClassVo::getClassname));
|
744
|
765
|
List<CTeacherVo> users = classTeacherMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
|
745
|
766
|
Set<String> userNameSet = users.stream().map(CTeacherVo::getUsername).collect(Collectors.toCollection(TreeSet::new));
|
746
|
767
|
Map<String, CTeacherVo> classTeacherMap = new HashMap<>();//班级教师map
|
747
|
768
|
for (CTeacherVo teacher : teachers) {
|
748
|
|
- CTeacherVo vo = users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
|
|
769
|
+ CTeacherVo vo =
|
|
770
|
+ users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
|
749
|
771
|
if (vo != null) teacher.setUsername(vo.getUsername());
|
750
|
772
|
teacher.setClassname(classMap.get(teacher.getClassid()));
|
751
|
773
|
teacher.setSubjectid(subjectMap.get(teacher.getTeacherid()));
|
|
@@ -783,6 +805,7 @@ public class XzService {
|
783
|
805
|
} catch (Exception e) {
|
784
|
806
|
log.error("导入课表出错:" + e.getMessage());
|
785
|
807
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
808
|
+ xzMapper.updateSaveState(xzid, 0);//修改保存状态
|
786
|
809
|
throw new MissingParametersException(e.getMessage());
|
787
|
810
|
}
|
788
|
811
|
}
|
|
@@ -907,4 +930,9 @@ public class XzService {
|
907
|
930
|
classStudentMapper.insertList(classStudentList);//批量保存课程班级学生
|
908
|
931
|
groupStudentMapper.insertList(groupStudentList);//批量保存课程分组学生
|
909
|
932
|
}
|
|
933
|
+
|
|
934
|
+ //获取保存状态
|
|
935
|
+ public Integer getSaveStateById(Integer xzid) {
|
|
936
|
+ return xzMapper.getSaveStateById(xzid);
|
|
937
|
+ }
|
910
|
938
|
}
|