|
@@ -1,14 +1,38 @@
|
1
|
1
|
package com.xhkjedu.slive.service.xz;
|
2
|
2
|
|
|
3
|
+import com.xhkjedu.slive.mapper.gradeclass.ClassTeacherMapper;
|
|
4
|
+import com.xhkjedu.slive.mapper.gradeclass.SchoolMapper;
|
|
5
|
+import com.xhkjedu.slive.mapper.liveplay.CourseClassMapper;
|
|
6
|
+import com.xhkjedu.slive.mapper.liveplay.CourseMapper;
|
|
7
|
+import com.xhkjedu.slive.mapper.liveplay.CourseSectionMapper;
|
|
8
|
+import com.xhkjedu.slive.mapper.xz.XzKjMapper;
|
3
|
9
|
import com.xhkjedu.slive.mapper.xz.XzMapper;
|
|
10
|
+import com.xhkjedu.slive.model.gradeclass.TClass;
|
|
11
|
+import com.xhkjedu.slive.model.gradeclass.TClassTeacher;
|
|
12
|
+import com.xhkjedu.slive.model.liveplay.LCourse;
|
|
13
|
+import com.xhkjedu.slive.model.liveplay.LCourseClass;
|
|
14
|
+import com.xhkjedu.slive.model.liveplay.LCourseSection;
|
4
|
15
|
import com.xhkjedu.slive.model.xz.LXz;
|
|
16
|
+import com.xhkjedu.slive.model.xz.LXzKj;
|
|
17
|
+import com.xhkjedu.slive.service.gradeclass.ClassService;
|
|
18
|
+import com.xhkjedu.slive.utils.LiveUtil;
|
|
19
|
+import com.xhkjedu.slive.vo.gradeclass.ClassVo;
|
|
20
|
+import com.xhkjedu.slive.vo.xz.XzDateVo;
|
|
21
|
+import com.xhkjedu.slive.vo.xz.XzDateXjTeaVo;
|
|
22
|
+import com.xhkjedu.slive.vo.xz.XzDateXjVo;
|
5
|
23
|
import com.xhkjedu.utils.N_Utils;
|
|
24
|
+import com.xhkjedu.vo.ResultVo;
|
|
25
|
+import lombok.extern.slf4j.Slf4j;
|
6
|
26
|
import org.springframework.stereotype.Service;
|
7
|
27
|
import org.springframework.transaction.annotation.Transactional;
|
|
28
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
8
|
29
|
|
9
|
30
|
import javax.annotation.Resource;
|
|
31
|
+import java.util.ArrayList;
|
|
32
|
+import java.util.HashMap;
|
10
|
33
|
import java.util.List;
|
11
|
34
|
import java.util.Map;
|
|
35
|
+import java.util.stream.Collectors;
|
12
|
36
|
|
13
|
37
|
/**
|
14
|
38
|
* @Description 行政直播概要
|
|
@@ -16,9 +40,24 @@ import java.util.Map;
|
16
|
40
|
* Date 2022/3/30 13:42
|
17
|
41
|
**/
|
18
|
42
|
@Service
|
|
43
|
+@Slf4j
|
19
|
44
|
public class XzService {
|
20
|
45
|
@Resource
|
21
|
46
|
private XzMapper xzMapper;
|
|
47
|
+ @Resource
|
|
48
|
+ private XzKjMapper xzKjMapper;
|
|
49
|
+ @Resource
|
|
50
|
+ private CourseMapper courseMapper;
|
|
51
|
+ @Resource
|
|
52
|
+ private CourseSectionMapper courseSectionMapper;
|
|
53
|
+ @Resource
|
|
54
|
+ private CourseClassMapper courseClassMapper;
|
|
55
|
+ @Resource
|
|
56
|
+ private SchoolMapper schoolMapper;
|
|
57
|
+ @Resource
|
|
58
|
+ private ClassService classService;
|
|
59
|
+ @Resource
|
|
60
|
+ private ClassTeacherMapper classTeacherMapper;
|
22
|
61
|
|
23
|
62
|
/**
|
24
|
63
|
* @Description 行政直播列表
|
|
@@ -27,8 +66,8 @@ public class XzService {
|
27
|
66
|
* @Author wn
|
28
|
67
|
* @Date 2022/3/30 14:03
|
29
|
68
|
**/
|
30
|
|
- public List<Map> listXzs(Integer schoolid, String xzname) {
|
31
|
|
- return xzMapper.listXzs(schoolid, xzname);
|
|
69
|
+ public List<Map> listXzs(LXz xz) {
|
|
70
|
+ return xzMapper.listXzs(xz);
|
32
|
71
|
}
|
33
|
72
|
|
34
|
73
|
/**
|
|
@@ -38,11 +77,29 @@ public class XzService {
|
38
|
77
|
* @Author wn
|
39
|
78
|
* @Date 2022/3/30 14:07
|
40
|
79
|
**/
|
|
80
|
+ @Transactional
|
41
|
81
|
public Integer saveXz(LXz xz) {
|
42
|
|
- xz.setCreatetime(N_Utils.getSecondTimestamp());
|
|
82
|
+ Integer timestamp = N_Utils.getSecondTimestamp();
|
|
83
|
+ xz.setCreatetime(timestamp);
|
43
|
84
|
xz.setDeleted(1);
|
44
|
|
- xzMapper.insertUseGeneratedKeys(xz);
|
45
|
|
- return xz.getId();
|
|
85
|
+ xzMapper.insertUseGeneratedKeys(xz);//保存行政直播信息
|
|
86
|
+ Integer xzid = xz.getId();
|
|
87
|
+ //保存对应的课节信息
|
|
88
|
+ List<LXzKj> kjlst = new ArrayList<>();
|
|
89
|
+ for (int i = 0; i < xz.getDaynum(); i++) {
|
|
90
|
+ LXzKj kj = new LXzKj();
|
|
91
|
+ kj.setXzid(xzid);
|
|
92
|
+ String kjname = LiveUtil.getChineStrByNum(i);
|
|
93
|
+ kj.setKjname("第" + kjname + "节");
|
|
94
|
+ kj.setKjorder(i+1);
|
|
95
|
+ kj.setCreateid(xz.getCreateid());
|
|
96
|
+ kj.setCreatetime(timestamp);
|
|
97
|
+
|
|
98
|
+ kjlst.add(kj);
|
|
99
|
+ }
|
|
100
|
+ //批量保存行政直播对应的课节
|
|
101
|
+ xzKjMapper.insertList(kjlst);
|
|
102
|
+ return xzid;
|
46
|
103
|
}
|
47
|
104
|
|
48
|
105
|
/**
|
|
@@ -72,20 +129,186 @@ public class XzService {
|
72
|
129
|
* @Author wn
|
73
|
130
|
* @Date 2022/3/30 15:24
|
74
|
131
|
**/
|
75
|
|
- @Transactional
|
|
132
|
+ @Transactional(rollbackFor = Exception.class)
|
76
|
133
|
public void deleteXz(Integer xzid) {
|
77
|
|
- //如果行政直播下所有的课都未开始,则可以直接删除,
|
78
|
|
- //如果有直播课已经开始则进行逻辑删除,并删除所有未开始上的直播课
|
79
|
|
- Integer sectionnum = xzMapper.getXzSectionKsNum(xzid);
|
80
|
|
- if (sectionnum != null && sectionnum > 0) {
|
81
|
|
- //说明直播下有开始或结束的课节,只能删除未开始的直播和直播班级信息
|
82
|
|
- xzMapper.deleteCourseClassKjByXzid(xzid);
|
83
|
|
- //修改行政直播的状态未已删除
|
84
|
|
- xzMapper.updateXzDeleted(10, xzid);
|
85
|
|
- } else {
|
86
|
|
- //说明该行政直播课程可以直接删除
|
87
|
|
- xzMapper.deleteCourseClassByXzid(xzid);
|
88
|
|
- xzMapper.deleteXzAndKjByXzid(xzid);
|
|
134
|
+ try {
|
|
135
|
+ //如果行政直播下所有的课都未开始,则可以直接删除,
|
|
136
|
+ //如果有直播课已经开始则进行逻辑删除,并删除所有未开始上的直播课
|
|
137
|
+ Integer sectionnum = xzMapper.getXzSectionKsNum(xzid);
|
|
138
|
+ if (sectionnum != null && sectionnum > 0) {
|
|
139
|
+ //说明直播下有开始或结束的课节,只能删除未开始的直播和直播班级信息
|
|
140
|
+ xzMapper.deleteCourseClassKjByXzid(xzid);
|
|
141
|
+ //修改行政直播的状态未已删除
|
|
142
|
+ xzMapper.updateXzDeleted(10, xzid);
|
|
143
|
+ } else {
|
|
144
|
+ //说明该行政直播课程可以直接删除
|
|
145
|
+ xzMapper.deleteCourseClassByXzid(xzid);
|
|
146
|
+ xzMapper.deleteXzAndKjByXzid(xzid);
|
|
147
|
+ }
|
|
148
|
+ }catch (Exception e){
|
|
149
|
+ log.error("删除行政直播出错:"+e.getMessage());
|
|
150
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
89
|
151
|
}
|
|
152
|
+
|
|
153
|
+
|
90
|
154
|
}
|
|
155
|
+ /**
|
|
156
|
+ * @Description 保存行政直播课程表
|
|
157
|
+ * @Param [xzDatelst]
|
|
158
|
+ * @Return com.xhkjedu.vo.ResultVo
|
|
159
|
+ * @Author wn
|
|
160
|
+ * @Date 2022/3/31 21:46
|
|
161
|
+ **/
|
|
162
|
+ public ResultVo saveXzCourse(LXz xz) {
|
|
163
|
+ //保存行政直播课程表,参数层级为日期--课节--班级和教师
|
|
164
|
+ //根据同一个课节下根据班级和教师确认是否是同一个直播课,保存进course,section(单课节课程)
|
|
165
|
+ LXz x = xzMapper.selectByPrimaryKey(xz.getXzid());
|
|
166
|
+ List<XzDateVo> xzDatelst = xz.getXzdatas();
|
|
167
|
+ for (int i = 0; i < xzDatelst.size(); i++) {
|
|
168
|
+ //日期下的课节情况
|
|
169
|
+ XzDateVo xzDateVo = xzDatelst.get(i);
|
|
170
|
+ String datazhou = LiveUtil.getDateZhou(xzDateVo.getCurrentdate());//要保存日期对应的周
|
|
171
|
+ List<XzDateXjVo> dateKjlst = xzDateVo.getKjs();//指定日期下课节情况
|
|
172
|
+
|
|
173
|
+ for (int j = 0; j < dateKjlst.size(); j++) {
|
|
174
|
+ //单课节情况
|
|
175
|
+ XzDateXjVo dateKjVo = dateKjlst.get(j);
|
|
176
|
+ List<XzDateXjTeaVo> xjTealst = dateKjVo.getKjteas();//单课节下各班级情况
|
|
177
|
+ //处理成教师下班级形式,生成课程
|
|
178
|
+ Map<Integer, List<XzDateXjTeaVo>> map = listChangeTeacherClass(xjTealst);
|
|
179
|
+ LCourse course = new LCourse();
|
|
180
|
+ course.setGradeid(x.getGradeid());
|
|
181
|
+ course.setBegindate(x.getBegindate());
|
|
182
|
+ course.setEnddate(x.getEnddate());
|
|
183
|
+ course.setCoursenum(1);
|
|
184
|
+ course.setCoursetype(1);
|
|
185
|
+ course.setCourseclass(1);
|
|
186
|
+ course.setCoursestate(0);
|
|
187
|
+ course.setDeleted(1);
|
|
188
|
+ course.setCreateid(xz.getCreateid());
|
|
189
|
+ course.setCreatetime(N_Utils.getSecondTimestamp());
|
|
190
|
+ course.setSchoolid(x.getSchoolid());
|
|
191
|
+
|
|
192
|
+ for(Map.Entry<Integer, List<XzDateXjTeaVo>> entry : map.entrySet()){
|
|
193
|
+ List<XzDateXjTeaVo> xjTeas = entry.getValue();
|
|
194
|
+ String teachername = xjTeas.get(0).getTeachername();
|
|
195
|
+ //单个教师课程信息
|
|
196
|
+ String coursename = datazhou + dateKjVo.getKjname() +xjTeas.get(0).getSubjectname()+ "("+ teachername +")";
|
|
197
|
+
|
|
198
|
+ course.setCoursename(coursename);
|
|
199
|
+ course.setSubjectid(xjTeas.get(0).getSubjectid());
|
|
200
|
+ course.setTeacherid(entry.getKey());
|
|
201
|
+ course.setBegintime(dateKjVo.getBegintime());
|
|
202
|
+ course.setEndtime(dateKjVo.getEndtime());
|
|
203
|
+ course.setKjid(dateKjVo.getKjid());
|
|
204
|
+ //保存行政直播课程表
|
|
205
|
+ saveCourseAll(xjTeas,course,xzDateVo.getCurrentdate());
|
|
206
|
+ }
|
|
207
|
+ }
|
|
208
|
+ }
|
|
209
|
+ return new ResultVo(0, "");
|
|
210
|
+ }
|
|
211
|
+
|
|
212
|
+ //指定天某天某节课下的教师班级层级关系
|
|
213
|
+ private Map<Integer, List<XzDateXjTeaVo>> listChangeTeacherClass(List<XzDateXjTeaVo> xjTealst) {
|
|
214
|
+ Map<Integer, List<XzDateXjTeaVo>> map = new HashMap<>();
|
|
215
|
+
|
|
216
|
+ for (int i = 0; i < xjTealst.size(); i++) {
|
|
217
|
+ XzDateXjTeaVo xzDateXjTeaVo = xjTealst.get(i);
|
|
218
|
+ if (map.containsKey(xzDateXjTeaVo.getTeacherid())) {
|
|
219
|
+ map.get(xzDateXjTeaVo.getTeacherid()).add(xzDateXjTeaVo);
|
|
220
|
+ } else {
|
|
221
|
+ List<XzDateXjTeaVo> classlst = new ArrayList<>();
|
|
222
|
+ classlst.add(xzDateXjTeaVo);
|
|
223
|
+ map.put(xzDateXjTeaVo.getTeacherid(), classlst);
|
|
224
|
+ }
|
|
225
|
+ }
|
|
226
|
+ return map;
|
|
227
|
+ }
|
|
228
|
+
|
|
229
|
+ //保存行政直播课程表
|
|
230
|
+ @Transactional(rollbackFor = Exception.class)
|
|
231
|
+ public void saveCourseAll(List<XzDateXjTeaVo> xjTeas,LCourse course,String currentdate){
|
|
232
|
+ try {
|
|
233
|
+ //获取集合中所有的班级id
|
|
234
|
+ List classidlst = xjTeas.stream().map(XzDateXjTeaVo::getClassid).collect(Collectors.toList());
|
|
235
|
+ List<Map> users = courseMapper.listUid(classidlst);//获取课班级下学生
|
|
236
|
+
|
|
237
|
+ //新生成直播班班级信息
|
|
238
|
+ TClass c = new TClass();
|
|
239
|
+ c.setClassname(course.getCoursename() + "班");
|
|
240
|
+ c.setCreateid(course.getCreateid());
|
|
241
|
+ c.setSchoolid(course.getSchoolid());
|
|
242
|
+ Integer year = schoolMapper.getYearById(course.getSchoolid());
|
|
243
|
+ c.setSchoolyear(year);
|
|
244
|
+ c.setYear(year);
|
|
245
|
+ c.setClassorder(999);
|
|
246
|
+ c.setGradeid(course.getGradeid());
|
|
247
|
+ c.setClasstype(99);//已直播班级
|
|
248
|
+
|
|
249
|
+ Integer classid = classService.save(c);//新生成直播班id
|
|
250
|
+ course.setClassid(classid);
|
|
251
|
+
|
|
252
|
+ //设置班级对应教师
|
|
253
|
+ //班级教师
|
|
254
|
+ TClassTeacher teacher = new TClassTeacher();
|
|
255
|
+ teacher.setClassid(classid);
|
|
256
|
+ teacher.setTeacherid(course.getTeacherid());
|
|
257
|
+ teacher.setCreateid(course.getCreateid());
|
|
258
|
+ teacher.setCreatetime(N_Utils.getSecondTimestamp());
|
|
259
|
+ teacher.setSchoolid(course.getSchoolid());
|
|
260
|
+ classTeacherMapper.insertSelective(teacher);
|
|
261
|
+
|
|
262
|
+ //保存课程信息
|
|
263
|
+ courseMapper.insertUseGeneratedKeys(course);
|
|
264
|
+ Integer courseid = course.getId();//课程id
|
|
265
|
+
|
|
266
|
+ List<Integer> studentids = new ArrayList<>();
|
|
267
|
+ users.forEach(userVo -> {
|
|
268
|
+ studentids.add((Integer) userVo.get("userid"));
|
|
269
|
+ });
|
|
270
|
+
|
|
271
|
+ classService.batchSaveStu(course.getCreateid(), course.getSchoolid(), classid, studentids);//批量添加报名学生
|
|
272
|
+ courseMapper.updateStuNum(courseid);//更新已报学生数量
|
|
273
|
+
|
|
274
|
+ //保存直播关联班级
|
|
275
|
+ List<LCourseClass> cclist = new ArrayList<>();
|
|
276
|
+ for(int i=0;i<classidlst.size();i++){
|
|
277
|
+ Integer cid = Integer.parseInt(classidlst.get(i).toString());
|
|
278
|
+ LCourseClass cc = new LCourseClass();
|
|
279
|
+ cc.setCourseid(courseid);
|
|
280
|
+ cc.setClassid(cid);
|
|
281
|
+ cc.setCreateid(course.getCreateid());
|
|
282
|
+ cc.setCreatetime(course.getCreatetime());
|
|
283
|
+ cclist.add(cc);
|
|
284
|
+ //通知班级
|
|
285
|
+ ClassVo classVo = new ClassVo();
|
|
286
|
+ classVo.setClassid(cid);
|
|
287
|
+ }
|
|
288
|
+ courseClassMapper.insertList(cclist);//保存原班级和直播的关联关系
|
|
289
|
+
|
|
290
|
+ //获取班级人数
|
|
291
|
+ ClassVo classVo = classService.getById(classid);
|
|
292
|
+
|
|
293
|
+ //保存课程课节关联关系
|
|
294
|
+ LCourseSection cs = new LCourseSection();
|
|
295
|
+ cs.setCourseid(courseid);
|
|
296
|
+ cs.setTeacherid(course.getTeacherid());
|
|
297
|
+ cs.setSectionname(course.getCoursename());
|
|
298
|
+ cs.setSectionorder(1);
|
|
299
|
+ cs.setSectiondate(currentdate);
|
|
300
|
+ cs.setPlanbegintime(course.getBegintime());
|
|
301
|
+ cs.setPlanendtime(course.getEndtime());
|
|
302
|
+ cs.setStunum(classVo.getClassnum());
|
|
303
|
+ cs.setSectionstate(0);
|
|
304
|
+ cs.setCreateid(course.getCreateid());
|
|
305
|
+ cs.setCreatetime(course.getCreatetime());
|
|
306
|
+ courseSectionMapper.insertUseGeneratedKeys(cs);//保存课程课节信息
|
|
307
|
+
|
|
308
|
+ }catch (Exception e){
|
|
309
|
+ log.info("保存行政直播课程表出错:"+e.getMessage());
|
|
310
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+
|
91
|
314
|
}
|