Browse Source

修改保存单个课程返回值

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

+ 20
- 8
slive/src/main/java/com/xhkjedu/slive/service/xz/XzService.java View File

@@ -360,7 +360,8 @@ public class XzService {
360 360
 
361 361
     //保存行政直播课程表
362 362
     @Transactional(rollbackFor = Exception.class)
363
-    public void saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course) {
363
+    public Integer saveCourseAll(List<XzDateKjTeaVo> xjTeas, LCourse course) {
364
+        Integer courseid = 0;
364 365
         try {
365 366
             //获取集合中所有的班级id
366 367
             List classidlst = xjTeas.stream().map(XzDateKjTeaVo::getClassid).collect(Collectors.toList());
@@ -393,7 +394,7 @@ public class XzService {
393 394
 
394 395
             //保存课程信息
395 396
             courseMapper.insertUseGeneratedKeys(course);
396
-            Integer courseid = course.getId();//课程id
397
+            courseid = course.getId();//课程id
397 398
 
398 399
             List<Integer> studentids = new ArrayList<>();
399 400
             users.forEach(userVo -> {
@@ -430,10 +431,12 @@ public class XzService {
430 431
             cs.setCreateid(course.getCreateid());
431 432
             cs.setCreatetime(course.getCreatetime());
432 433
             courseSectionMapper.insertUseGeneratedKeys(cs);//保存课程课节信息
434
+
433 435
         } catch (Exception e) {
434 436
             log.info("保存行政直播课程表出错:" + e.getMessage());
435 437
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
436 438
         }
439
+        return courseid;
437 440
     }
438 441
 
439 442
     /**
@@ -557,10 +560,12 @@ public class XzService {
557 560
             kjTeaVo.setGradeid(xz.getGradeid());
558 561
             kjTeaVo.setSchoolid(xz.getSchoolid());
559 562
 
563
+            Integer courseid = 0;//存放新添加课程id
564
+
560 565
             //先判断是保存当前课程还是后续日期的课
561 566
             if (N_Utils.isEmptyInteger(kjTeaVo.getKfollow())) {
562 567
                 //kfollow为0或者空,则只需要保存当前选中的课程
563
-                ((XzService) applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
568
+                courseid = ((XzService) applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
564 569
             } else {
565 570
                 //需要保存后续和当前日期相同的星期相同课节的课程,判断后续日期是否有课程,如果有则提示先删除后再添加
566 571
                 //获取已生成课程的往后日期
@@ -571,17 +576,21 @@ public class XzService {
571 576
                     if (afterlst != null && afterlst.size() > 0) {
572 577
                         return new ResultVo(1, "同日期同班级同课节有数据,不能保存");
573 578
                     } else {
574
-
575 579
                         //获取seldate至结束日期时端内符合条件的日期
576 580
                         List<String> savedates = LiveUtil.getDaysForMeetDates(kjTeaVo.getSeldate(), xz.getEnddate());
577 581
                         for (int i = 0; i < savedates.size(); i++) {
578 582
                             kjTeaVo.setSeldate(savedates.get(i));
579
-//                            ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
583
+
584
+                            Integer rtnid = ((XzService)applicationContext.getBean("xzService")).saveOneXzkjDygForDetail(kjTeaVo);
585
+                            if(i==0){
586
+                                courseid = rtnid;
587
+                            }
588
+
580 589
                         }
581 590
                     }
582 591
                 }
583 592
             }
584
-            return new ResultVo(0, "成功保存课程表单个课程");
593
+            return new ResultVo(0, "成功保存课程表单个课程",courseid);
585 594
         } catch (Exception e) {
586 595
             log.error("保存课程表单个课程出错:" + e.getMessage());
587 596
             return new ResultVo(1, "保存课程表单个课程失败");
@@ -590,7 +599,8 @@ public class XzService {
590 599
 
591 600
     //保存单个课程
592 601
     @Transactional(rollbackFor = Exception.class)
593
-    public void saveOneXzkjDygForDetail(XzDateKjTeaVo kjTeaVo) {
602
+    public Integer saveOneXzkjDygForDetail(XzDateKjTeaVo kjTeaVo) {
603
+        Integer courseid = 0;
594 604
         try {
595 605
             //先看新选择的教师情况,先判断选中的同一日期课节教师是否还有其他直播课
596 606
             CourseVo courseVo = courseMapper.getCourseByDateKjTeacher(kjTeaVo);
@@ -625,8 +635,9 @@ public class XzService {
625 635
                 //保存行政直播课程表,调用保存整个课表时的方法
626 636
                 List<XzDateKjTeaVo> lst = new ArrayList<>();
627 637
                 lst.add(kjTeaVo);
628
-                ((XzService) applicationContext.getBean("xzService")).saveCourseAll(lst, course);
638
+                courseid = ((XzService) applicationContext.getBean("xzService")).saveCourseAll(lst, course);
629 639
             } else {
640
+                courseid = courseVo.getCourseid();
630 641
                 //说明该教师当前有其他直播课,则把班级加入课程,完成直播课学生数量
631 642
                 TClassStudent cs = new TClassStudent();
632 643
                 cs.setSchoolid(kjTeaVo.getSchoolid());
@@ -643,6 +654,7 @@ public class XzService {
643 654
             log.error("保存单个课程出错:" + e.getMessage());
644 655
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
645 656
         }
657
+        return courseid;
646 658
     }
647 659
 
648 660
 

+ 2
- 0
suser/src/main/java/com/xhkjedu/suser/controller/gradeclass/ClassStudentController.java View File

@@ -105,6 +105,8 @@ public class ClassStudentController {
105 105
         Integer classid = tClassStudent.getClassid();
106 106
         N_Utils.validation(new Object[]{classid, "班级id", 1,tClassStudent.getSchoolid(),"学校id",1});
107 107
         Integer page = tClassStudent.getPage();
108
+        Integer year = classStudentService.getSchoolyear(tClassStudent.getSchoolid());
109
+        tClassStudent.setYear(year);
108 110
         if (N_Utils.isEmptyInteger(page)) {
109 111
             List<ClassStudentVo> list = classStudentService.listStudentForliveclass(tClassStudent);
110 112
             return new ResultVo(0,"获取列表成功",list);

+ 4
- 2
suser/src/main/java/com/xhkjedu/suser/service/gradeclass/ClassStudentService.java View File

@@ -236,11 +236,13 @@ public class ClassStudentService {
236 236
         return classStudentMapper.findAll(student);
237 237
     }
238 238
 
239
+    public Integer getSchoolyear(Integer schoolid){
240
+        return schoolMapper.getYearById(schoolid);
241
+    }
242
+
239 243
     //直播班中班级集合
240 244
     public List<ClassStudentVo> listStudentForliveclass(TClassStudent student) {
241 245
         setOrderField(student);
242
-        Integer year = schoolMapper.getYearById(student.getSchoolid());
243
-        student.setYear(year);
244 246
         List<ClassStudentVo> rtnlst = classStudentMapper.listStudentForliveclass(student);
245 247
         for (int i=0;i<rtnlst.size();i++){
246 248
             ClassStudentVo cs = rtnlst.get(i);

+ 1
- 1
suser/src/main/resources/mapper/gradeclass/ClassStudentMapper.xml View File

@@ -120,7 +120,7 @@
120 120
 
121 121
     <!--直播班中学生信息-->
122 122
     <select id="listStudentForliveclass" resultType="com.xhkjedu.suser.vo.gradeclass.ClassStudentVo">
123
-        select cs.csid,cs.classid,u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,cs.createtime
123
+        select distinct cs.csid,cs.classid,u.username studentname,u.studentno,u.usersex,u.userid studentid,u.loginname,cs.createtime
124 124
         ,u.bindmac,u.mac,u.headpic,u.userphone,u.usertime,
125 125
         (select concat(c2.gradeid,'_',c2.classname) from t_class_student cs2 left join t_class c2 on cs2.classid=c2.classid
126 126
         where cs2.studentid=cs.studentid and c2.classtype=1 and c2.classstate=1 and c2.year=#{student.year} order by c2.classid desc limit 1)classname

Loading…
Cancel
Save