|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.xhkjedu.slive.service.xz;
|
2
|
2
|
|
|
3
|
+import com.xhkjedu.slive.mapper.gradeclass.ClassMapper;
|
3
|
4
|
import com.xhkjedu.slive.mapper.gradeclass.ClassTeacherMapper;
|
4
|
5
|
import com.xhkjedu.slive.mapper.gradeclass.SchoolMapper;
|
5
|
6
|
import com.xhkjedu.slive.mapper.liveplay.CourseClassMapper;
|
|
@@ -18,8 +19,8 @@ import com.xhkjedu.slive.service.gradeclass.ClassService;
|
18
|
19
|
import com.xhkjedu.slive.utils.LiveUtil;
|
19
|
20
|
import com.xhkjedu.slive.vo.gradeclass.ClassVo;
|
20
|
21
|
import com.xhkjedu.slive.vo.xz.XzDateVo;
|
21
|
|
-import com.xhkjedu.slive.vo.xz.XzDateXjTeaVo;
|
22
|
|
-import com.xhkjedu.slive.vo.xz.XzDateXjVo;
|
|
22
|
+import com.xhkjedu.slive.vo.xz.XzDateKjTeaVo;
|
|
23
|
+import com.xhkjedu.slive.vo.xz.XzDateKjVo;
|
23
|
24
|
import com.xhkjedu.utils.N_Utils;
|
24
|
25
|
import com.xhkjedu.vo.ResultVo;
|
25
|
26
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -58,6 +59,8 @@ public class XzService {
|
58
|
59
|
private ClassService classService;
|
59
|
60
|
@Resource
|
60
|
61
|
private ClassTeacherMapper classTeacherMapper;
|
|
62
|
+ @Resource
|
|
63
|
+ private ClassMapper classMapper;
|
61
|
64
|
|
62
|
65
|
/**
|
63
|
66
|
* @Description 行政直播列表
|
|
@@ -91,7 +94,7 @@ public class XzService {
|
91
|
94
|
kj.setXzid(xzid);
|
92
|
95
|
String kjname = LiveUtil.getChineStrByNum(i);
|
93
|
96
|
kj.setKjname("第" + kjname + "节");
|
94
|
|
- kj.setKjorder(i+1);
|
|
97
|
+ kj.setKjorder(i + 1);
|
95
|
98
|
kj.setCreateid(xz.getCreateid());
|
96
|
99
|
kj.setCreatetime(timestamp);
|
97
|
100
|
|
|
@@ -145,13 +148,14 @@ public class XzService {
|
145
|
148
|
xzMapper.deleteCourseClassByXzid(xzid);
|
146
|
149
|
xzMapper.deleteXzAndKjByXzid(xzid);
|
147
|
150
|
}
|
148
|
|
- }catch (Exception e){
|
149
|
|
- log.error("删除行政直播出错:"+e.getMessage());
|
|
151
|
+ } catch (Exception e) {
|
|
152
|
+ log.error("删除行政直播出错:" + e.getMessage());
|
150
|
153
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
151
|
154
|
}
|
152
|
155
|
|
153
|
156
|
|
154
|
157
|
}
|
|
158
|
+
|
155
|
159
|
/**
|
156
|
160
|
* @Description 保存行政直播课程表
|
157
|
161
|
* @Param [xzDatelst]
|
|
@@ -168,14 +172,14 @@ public class XzService {
|
168
|
172
|
//日期下的课节情况
|
169
|
173
|
XzDateVo xzDateVo = xzDatelst.get(i);
|
170
|
174
|
String datazhou = LiveUtil.getDateZhou(xzDateVo.getSelectdate());//要保存日期对应的周
|
171
|
|
- List<XzDateXjVo> dateKjlst = xzDateVo.getKjs();//指定日期下课节情况
|
|
175
|
+ List<XzDateKjVo> dateKjlst = xzDateVo.getKjs();//指定日期下课节情况
|
172
|
176
|
|
173
|
177
|
for (int j = 0; j < dateKjlst.size(); j++) {
|
174
|
178
|
//单课节情况
|
175
|
|
- XzDateXjVo dateKjVo = dateKjlst.get(j);
|
176
|
|
- List<XzDateXjTeaVo> xjTealst = dateKjVo.getKjteas();//单课节下各班级情况
|
|
179
|
+ XzDateKjVo dateKjVo = dateKjlst.get(j);
|
|
180
|
+ List<XzDateKjTeaVo> xjTealst = dateKjVo.getKjteas();//单课节下各班级情况
|
177
|
181
|
//处理成教师下班级形式,生成课程
|
178
|
|
- Map<Integer, List<XzDateXjTeaVo>> map = listChangeTeacherClass(xjTealst);
|
|
182
|
+ Map<Integer, List<XzDateKjTeaVo>> map = listChangeTeacherClass(xjTealst);
|
179
|
183
|
LCourse course = new LCourse();
|
180
|
184
|
course.setGradeid(x.getGradeid());
|
181
|
185
|
course.setBegindate(xzDateVo.getSelectdate());
|
|
@@ -189,11 +193,12 @@ public class XzService {
|
189
|
193
|
course.setCreatetime(N_Utils.getSecondTimestamp());
|
190
|
194
|
course.setSchoolid(x.getSchoolid());
|
191
|
195
|
|
192
|
|
- for(Map.Entry<Integer, List<XzDateXjTeaVo>> entry : map.entrySet()){
|
193
|
|
- List<XzDateXjTeaVo> xjTeas = entry.getValue();
|
|
196
|
+ for (Map.Entry<Integer, List<XzDateKjTeaVo>> entry : map.entrySet()) {
|
|
197
|
+ List<XzDateKjTeaVo> xjTeas = entry.getValue();
|
194
|
198
|
String teachername = xjTeas.get(0).getTeachername();
|
195
|
199
|
//单个教师课程信息
|
196
|
|
- String coursename = datazhou + dateKjVo.getKjname() +xjTeas.get(0).getSubjectname()+ "("+ teachername +")";
|
|
200
|
+ String coursename =
|
|
201
|
+ datazhou + dateKjVo.getKjname() + xjTeas.get(0).getSubjectname() + "(" + teachername + ")";
|
197
|
202
|
|
198
|
203
|
course.setCoursename(coursename);
|
199
|
204
|
course.setSubjectid(xjTeas.get(0).getSubjectid());
|
|
@@ -202,7 +207,7 @@ public class XzService {
|
202
|
207
|
course.setEndtime(dateKjVo.getEndtime());
|
203
|
208
|
course.setKjid(dateKjVo.getKjid());
|
204
|
209
|
//保存行政直播课程表
|
205
|
|
- saveCourseAll(xjTeas,course);
|
|
210
|
+ saveCourseAll(xjTeas, course);
|
206
|
211
|
}
|
207
|
212
|
}
|
208
|
213
|
}
|
|
@@ -210,17 +215,19 @@ public class XzService {
|
210
|
215
|
}
|
211
|
216
|
|
212
|
217
|
//指定天某天某节课下的教师班级层级关系
|
213
|
|
- private Map<Integer, List<XzDateXjTeaVo>> listChangeTeacherClass(List<XzDateXjTeaVo> xjTealst) {
|
214
|
|
- Map<Integer, List<XzDateXjTeaVo>> map = new HashMap<>();
|
|
218
|
+ private Map<Integer, List<XzDateKjTeaVo>> listChangeTeacherClass(List<XzDateKjTeaVo> xjTealst) {
|
|
219
|
+ Map<Integer, List<XzDateKjTeaVo>> map = new HashMap<>();
|
215
|
220
|
|
216
|
221
|
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);
|
|
222
|
+ XzDateKjTeaVo xzDateXjTeaVo = xjTealst.get(i);
|
|
223
|
+ if (!N_Utils.isEmptyInteger(xzDateXjTeaVo.getTeacherid())) {
|
|
224
|
+ if (map.containsKey(xzDateXjTeaVo.getTeacherid())) {
|
|
225
|
+ map.get(xzDateXjTeaVo.getTeacherid()).add(xzDateXjTeaVo);
|
|
226
|
+ } else {
|
|
227
|
+ List<XzDateKjTeaVo> classlst = new ArrayList<>();
|
|
228
|
+ classlst.add(xzDateXjTeaVo);
|
|
229
|
+ map.put(xzDateXjTeaVo.getTeacherid(), classlst);
|
|
230
|
+ }
|
224
|
231
|
}
|
225
|
232
|
}
|
226
|
233
|
return map;
|
|
@@ -228,10 +235,10 @@ public class XzService {
|
228
|
235
|
|
229
|
236
|
//保存行政直播课程表
|
230
|
237
|
@Transactional(rollbackFor = Exception.class)
|
231
|
|
- public void saveCourseAll(List<XzDateXjTeaVo> xjTeas,LCourse course){
|
|
238
|
+ public void saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course) {
|
232
|
239
|
try {
|
233
|
240
|
//获取集合中所有的班级id
|
234
|
|
- List classidlst = xjTeas.stream().map(XzDateXjTeaVo::getClassid).collect(Collectors.toList());
|
|
241
|
+ List classidlst = xjTeas.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
|
235
|
242
|
List<Map> users = courseMapper.listUid(classidlst);//获取课班级下学生
|
236
|
243
|
|
237
|
244
|
//新生成直播班班级信息
|
|
@@ -273,7 +280,7 @@ public class XzService {
|
273
|
280
|
|
274
|
281
|
//保存直播关联班级
|
275
|
282
|
List<LCourseClass> cclist = new ArrayList<>();
|
276
|
|
- for(int i=0;i<classidlst.size();i++){
|
|
283
|
+ for (int i = 0; i < classidlst.size(); i++) {
|
277
|
284
|
Integer cid = Integer.parseInt(classidlst.get(i).toString());
|
278
|
285
|
LCourseClass cc = new LCourseClass();
|
279
|
286
|
cc.setCourseid(courseid);
|
|
@@ -287,9 +294,6 @@ public class XzService {
|
287
|
294
|
}
|
288
|
295
|
courseClassMapper.insertList(cclist);//保存原班级和直播的关联关系
|
289
|
296
|
|
290
|
|
- //获取班级人数
|
291
|
|
- ClassVo classVo = classService.getById(classid);
|
292
|
|
-
|
293
|
297
|
//保存课程课节关联关系
|
294
|
298
|
LCourseSection cs = new LCourseSection();
|
295
|
299
|
cs.setCourseid(courseid);
|
|
@@ -299,14 +303,14 @@ public class XzService {
|
299
|
303
|
cs.setSectiondate(course.getBegindate());
|
300
|
304
|
cs.setPlanbegintime(course.getBegintime());
|
301
|
305
|
cs.setPlanendtime(course.getEndtime());
|
302
|
|
- cs.setStunum(classVo.getClassnum());
|
|
306
|
+ cs.setStunum(0);
|
303
|
307
|
cs.setSectionstate(0);
|
304
|
308
|
cs.setCreateid(course.getCreateid());
|
305
|
309
|
cs.setCreatetime(course.getCreatetime());
|
306
|
310
|
courseSectionMapper.insertUseGeneratedKeys(cs);//保存课程课节信息
|
307
|
311
|
|
308
|
|
- }catch (Exception e){
|
309
|
|
- log.info("保存行政直播课程表出错:"+e.getMessage());
|
|
312
|
+ } catch (Exception e) {
|
|
313
|
+ log.info("保存行政直播课程表出错:" + e.getMessage());
|
310
|
314
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
311
|
315
|
}
|
312
|
316
|
}
|
|
@@ -319,12 +323,49 @@ public class XzService {
|
319
|
323
|
* @Date 2022/4/1 13:59
|
320
|
324
|
**/
|
321
|
325
|
public Map getXzKjDetail(LXz xz) {
|
322
|
|
- if(N_Utils.isNotEmpty(xz.getBegindate())){
|
323
|
|
- xz.setEnddate(LiveUtil.getSelectDateAfter(xz.getBegindate(),6));
|
|
326
|
+ if (N_Utils.isNotEmpty(xz.getBegindate())) {
|
|
327
|
+ xz.setEnddate(LiveUtil.getSelectDateAfter(xz.getBegindate(), 6));
|
324
|
328
|
}
|
325
|
329
|
//先获取课程基本信息
|
326
|
330
|
Map map = xzMapper.getXzForRtn(xz.getXzid());
|
327
|
|
- map.put("xzdates",xzMapper.listXzKjDetail(xz));
|
|
331
|
+ map.put("xzdates", xzMapper.listXzKjDetail(xz));
|
328
|
332
|
return map;
|
329
|
333
|
}
|
|
334
|
+
|
|
335
|
+ /**
|
|
336
|
+ * @Description 删除单个单元格
|
|
337
|
+ * @Param [kjTeaVo]
|
|
338
|
+ * @Return com.xhkjedu.vo.ResultVo
|
|
339
|
+ * @Author wn
|
|
340
|
+ * @Date 2022/4/1 17:42
|
|
341
|
+ **/
|
|
342
|
+ @Transactional
|
|
343
|
+ public ResultVo delXzkjDyg(XzDateKjTeaVo kjTeaVo) {
|
|
344
|
+ try {
|
|
345
|
+ //判断课程的状态,如果已经开始上课则不能删除
|
|
346
|
+ LCourse course = courseMapper.selectByPrimaryKey(kjTeaVo.getCourseid());
|
|
347
|
+ if (course.getCoursestate() > 0) {
|
|
348
|
+ return new ResultVo(1,"选择的课程已经开始上课,不允许删除");
|
|
349
|
+ } else {
|
|
350
|
+ //删除单个单元格中设置的教师信息,先判断该单元格对应的课程是否有其他班级
|
|
351
|
+ Integer coursenum = courseClassMapper.getOtherClassnumByCourseid(kjTeaVo.getCourseid(), kjTeaVo.getClassid());
|
|
352
|
+ if (coursenum == 0) {
|
|
353
|
+ //说明该课程仅关联一个班级,直接删除该课程以及该课程对应的直播班
|
|
354
|
+ courseMapper.deleteCourseClassByCourseid(kjTeaVo.getCourseid());
|
|
355
|
+ } else {
|
|
356
|
+ //说明关联的还有其他班级,删除该班级在直播班级中的学生,
|
|
357
|
+ courseClassMapper.deleteByCourseidAndClassid(kjTeaVo.getCourseid(),kjTeaVo.getClassid());
|
|
358
|
+ //处理对应直播班级中学生
|
|
359
|
+ classMapper.deleteClassstu(course.getClassid(),kjTeaVo.getClassid());
|
|
360
|
+ classMapper.updateNum2(course.getClassid());//更改班级以及班级分组人数
|
|
361
|
+ courseMapper.updateStuNum(kjTeaVo.getCourseid());//更新直播课学生数量
|
|
362
|
+ }
|
|
363
|
+ }
|
|
364
|
+ return new ResultVo(0,"成功删除课程表单个课程");
|
|
365
|
+ }catch (Exception e){
|
|
366
|
+ log.error("删除课程表单个课程出错:"+e.getMessage());
|
|
367
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
368
|
+ return new ResultVo(1,"删除课程表单个课程失败");
|
|
369
|
+ }
|
|
370
|
+ }
|
330
|
371
|
}
|