Browse Source

添加班级人数

tags/正式3.2.0
王宁 2 years ago
parent
commit
ab6f1b1f8e

+ 25
- 14
slive/src/main/java/com/xhkjedu/slive/service/xz/XzService.java View File

239
                             course.setBegintime(kjVo.getBegintime());
239
                             course.setBegintime(kjVo.getBegintime());
240
                             course.setEndtime(kjVo.getEndtime());
240
                             course.setEndtime(kjVo.getEndtime());
241
                             course.setKjid(kjVo.getKjid());
241
                             course.setKjid(kjVo.getKjid());
242
-                            //保存行政直播课程表,该方式解决事务不生效问题
243
-                            ((XzService)applicationContext.getBean("xzService")).saveCourseAll(xjTeas, course);
242
+
243
+                            //获取集合中所有的班级id
244
+                            List classidlst = xjTeas.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
245
+                            List<Map> users = courseMapper.listUid(classidlst);//获取课班级下学生
246
+                            //只有当班级下有学生时进行保存
247
+                            if(users!=null && users.size() > 0){
248
+                                //保存行政直播课程表,该方式解决事务不生效问题
249
+                                ((XzService)applicationContext.getBean("xzService")).saveCourseAll(xjTeas, course,users);
250
+                            }
244
                         }
251
                         }
245
                     }
252
                     }
246
                 }
253
                 }
365
 
372
 
366
     //保存行政直播课程表
373
     //保存行政直播课程表
367
     @Transactional(rollbackFor = Exception.class)
374
     @Transactional(rollbackFor = Exception.class)
368
-    public Integer saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course) {
375
+    public Integer saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course,List<Map> users) {
369
         Integer courseid = 0;
376
         Integer courseid = 0;
370
         try {
377
         try {
371
-            //获取集合中所有的班级id
372
             List classidlst = xjTeas.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
378
             List classidlst = xjTeas.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
373
-            List<Map> users = courseMapper.listUid(classidlst);//获取课班级下学生
374
-
375
-            if(users==null || users.size()==0){
376
-                throw new Exception("所选班级无学生");
377
-            }
378
 
379
 
379
             //新生成直播班班级信息
380
             //新生成直播班班级信息
380
             TClass c = new TClass();
381
             TClass c = new TClass();
464
         List<XzDateKjVo> kjs = xzKjMapper.listXzKjsByXzid(xz.getXzid());
465
         List<XzDateKjVo> kjs = xzKjMapper.listXzKjsByXzid(xz.getXzid());
465
         map.put("kjs", kjs);//保存所有课节信息
466
         map.put("kjs", kjs);//保存所有课节信息
466
 
467
 
467
-        List<XzDateVo> classdatelst = new ArrayList<>();//班级日期课节
468
-
469
         //根据行政直播id获取该学校当前年份指定年级下的行政班和提高班
468
         //根据行政直播id获取该学校当前年份指定年级下的行政班和提高班
470
         List<XzClassVo> classlst = classMapper.listClassByXzid(xz.getXzid());
469
         List<XzClassVo> classlst = classMapper.listClassByXzid(xz.getXzid());
471
         //先获取选择要看的有效日期,不能超出行政直播结束的日期
470
         //先获取选择要看的有效日期,不能超出行政直播结束的日期
603
             return new ResultVo(0, "保存成功",courseid);
602
             return new ResultVo(0, "保存成功",courseid);
604
         } catch (Exception e) {
603
         } catch (Exception e) {
605
             log.error("保存课程表单个课程出错:" + e.getMessage());
604
             log.error("保存课程表单个课程出错:" + e.getMessage());
606
-            return new ResultVo(1, "保存失败");
605
+            if(e.getMessage().equals("所选班级无学生")){
606
+                return new ResultVo(1, "保存失败:所选班级无学生");
607
+            }else{
608
+                return new ResultVo(1, "保存失败");
609
+            }
607
         }
610
         }
608
     }
611
     }
609
 
612
 
610
     //判断单个课程是否存在如果存在只需要合并班级不存在保存单个课程
613
     //判断单个课程是否存在如果存在只需要合并班级不存在保存单个课程
611
-    private Integer saveOneXzkjDygForDetail(XzDateKjTeaVo kjTeaVo) {
614
+    private Integer saveOneXzkjDygForDetail(XzDateKjTeaVo kjTeaVo) throws Exception{
612
         Integer courseid = 0;
615
         Integer courseid = 0;
613
         //先看新选择的教师情况,先判断选中的同一日期课节教师是否还有其他直播课
616
         //先看新选择的教师情况,先判断选中的同一日期课节教师是否还有其他直播课
614
         CourseVo courseVo = courseMapper.getCourseByDateKjTeacher(kjTeaVo);
617
         CourseVo courseVo = courseMapper.getCourseByDateKjTeacher(kjTeaVo);
643
             //保存行政直播课程表,调用保存整个课表时的方法
646
             //保存行政直播课程表,调用保存整个课表时的方法
644
             List<XzDateKjTeaVo> lst = new ArrayList<>();
647
             List<XzDateKjTeaVo> lst = new ArrayList<>();
645
             lst.add(kjTeaVo);
648
             lst.add(kjTeaVo);
646
-            courseid = ((XzService) applicationContext.getBean("xzService")).saveCourseAll(lst, course);
649
+
650
+            //获取集合中所有的班级id
651
+            List classidlst = lst.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
652
+            List<Map> users = courseMapper.listUid(classidlst);//获取课班级下学生
653
+            //如果所选班级无学生,则抛出异常 提示
654
+            if(users==null || users.size()==0){
655
+                throw new Exception("所选班级无学生");
656
+            }
657
+            courseid = ((XzService) applicationContext.getBean("xzService")).saveCourseAll(lst, course,users);
647
         } else {
658
         } else {
648
             courseid = courseVo.getCourseid();
659
             courseid = courseVo.getCourseid();
649
             ((XzService) applicationContext.getBean("xzService")).saveOneXzkjDygForDetailExist(kjTeaVo,courseVo);
660
             ((XzService) applicationContext.getBean("xzService")).saveOneXzkjDygForDetailExist(kjTeaVo,courseVo);

+ 2
- 0
slive/src/main/java/com/xhkjedu/slive/vo/xz/XzClassVo.java View File

15
 
15
 
16
     private String classname; //班级名称
16
     private String classname; //班级名称
17
 
17
 
18
+    private Integer classnum;//班级人数
19
+
18
     private Integer gradeid;//年级
20
     private Integer gradeid;//年级
19
 
21
 
20
     private Integer classtype;//班级类型
22
     private Integer classtype;//班级类型

+ 1
- 1
slive/src/main/resources/mapper/gradeclass/ClassMapper.xml View File

51
 
51
 
52
     <!--获取年级下所有行政班和提高班-->
52
     <!--获取年级下所有行政班和提高班-->
53
     <select id="listClassByXzid" resultType="com.xhkjedu.slive.vo.xz.XzClassVo">
53
     <select id="listClassByXzid" resultType="com.xhkjedu.slive.vo.xz.XzClassVo">
54
-        select DISTINCT c.classid,c.classname,c.classtype,c.gradeid from t_class c
54
+        select DISTINCT c.classid,c.classname,c.classnum,c.classtype,c.gradeid from t_class c
55
         left join t_school s on c.schoolid=s.schoolid and c.year=s.year
55
         left join t_school s on c.schoolid=s.schoolid and c.year=s.year
56
         left join l_xz x on s.schoolid=x.schoolid and c.gradeid=x.gradeid
56
         left join l_xz x on s.schoolid=x.schoolid and c.gradeid=x.gradeid
57
         where x.xzid=#{xzid} and c.classstate=1 and c.classtype in (1,2)
57
         where x.xzid=#{xzid} and c.classstate=1 and c.classtype in (1,2)

Loading…
Cancel
Save