Przeglądaj źródła

Merge branch 'dev' of ssh://10.10.100.21/source/smartschool-platform into dev

RaoMeng 7 lat temu
rodzic
commit
2ab37e10e9

+ 11 - 5
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/CurriculumServiceImpl.java

@@ -302,18 +302,24 @@ public class CurriculumServiceImpl implements CurriculumService {
 
     @Override
     public void publish(Long id) {
-        if(org.springframework.util.StringUtils.isEmpty(id) || "0".equals(id)) {
-            return;
+        if(null == id || 0 == id) {
+            throw new BizException(BizExceptionCode.USELESS_DATA);
         }
+        //同一个班级只允许有一张有效的课表
+        String clazzId = curriculumMapper.selectMain(id).getClazzId();
+        curriculumMapper.updateMainBeforePublish(clazzId);
+        curriculumMapper.updateDetailBeforePublish(clazzId);
+
         curriculumMapper.updateByPublish(id);
-        curriculumMapper.updateByPublishFrom(id);
+        curriculumMapper.updateByPublishFrom(id, 1L);
     }
 
     @Override
     public void republish(Long id) {
-        if(org.springframework.util.StringUtils.isEmpty(id) || "0".equals(id)) {
-            return;
+        if(null == id || 0 == id) {
+            throw new BizException(BizExceptionCode.USELESS_DATA);
         }
         curriculumMapper.updateByRepublish(id);
+        curriculumMapper.updateByPublishFrom(id, 0L);
     }
 }

+ 11 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java

@@ -242,8 +242,13 @@ public class GradeServiceImpl implements GradeService{
         if (StringUtils.isEmpty(grade)) {
             throw new BizException(BizExceptionCode.USELESS_DATA);
         }
+        //名称发生修改时,更新对应的学生信息教师信息中的年级名称
+        SysGrade oldGrade = sysGradeMapper.selectByPrimaryKey(grade.getGrade_id());
+        if (!oldGrade.getGrade_name().equals(grade.getGrade_name())) {
+            List<SysClazz> clazzList = sysClazzMapper.selectBygrade(grade.getGrade_id());
+            sysStudentMapper.updateGradeName(grade.getGrade_name(), clazzList);
+        }
         sysGradeMapper.updateByPrimaryKeySelective(grade);
-
     }
 
     @Override
@@ -251,6 +256,11 @@ public class GradeServiceImpl implements GradeService{
         if (StringUtils.isEmpty(sysClass)) {
             throw new BizException(BizExceptionCode.USELESS_DATA);
         }
+        //名称发生修改时,更新对应的学生信息教师信息中的班级名称
+        SysClazz oldClazz = sysClazzMapper.selectByPrimaryKey(sysClass.getClazz_id());
+        if (!oldClazz.getClazz_name().equals(sysClass.getClazz_name())) {
+            sysStudentMapper.updateClazzName(sysClass.getClazz_name(), sysClass.getClazz_id());
+        }
         sysClazzMapper.updateByPrimaryKeySelective(sysClass);
     }
 }

+ 15 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/StudentServiceImpl.java

@@ -15,6 +15,8 @@ import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.DataImportMapper;
+import com.usoftchina.smartschool.school.mapper.SysClazzMapper;
+import com.usoftchina.smartschool.school.mapper.SysGradeMapper;
 import com.usoftchina.smartschool.school.mapper.SysStudentMapper;
 import com.usoftchina.smartschool.school.po.*;
 import com.usoftchina.smartschool.utils.CollectionUtils;
@@ -41,6 +43,10 @@ public class StudentServiceImpl implements StudentService{
     private DataImportMapper dataImportMapper;
     @Autowired
     private AccountApi accountApi;
+    @Autowired
+    private SysGradeMapper sysGradeMapper;
+    @Autowired
+    private SysClazzMapper sysClazzMapper;
 
     @Override
     public PageInfo<SysStudent> getListData(PageRequest page, ListReqDTO listReqDTO) {
@@ -216,6 +222,15 @@ public class StudentServiceImpl implements StudentService{
 
                 SysStudent stu = JSONObject.parseObject(json.toJSONString(), SysStudent.class);
 
+                //校验年级班级是否存在
+                SysGrade sysGrade = sysGradeMapper.selectByName(stu.getStu_grade(), schoolId);
+                if (ObjectUtils.isEmpty(sysGrade)) {
+                    throw new BizException(BizExceptionCode.NONGRADE);
+                }
+                SysClazz sysClazz = sysClazzMapper.selectByName(stu.getStu_class(), sysGrade.getGrade_id(), schoolId);
+                if (ObjectUtils.isEmpty(sysClazz)) {
+                    throw new BizException(BizExceptionCode.NONCLAZZ);
+                }
                 //学生不存在
                 if (null == student) {
                     stu.setSchool_id(schoolId);

+ 22 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/CurriculumMapper.java

@@ -85,13 +85,34 @@ public interface CurriculumMapper {
 
     int courseStatus(Long id);
 
+    /**
+     * 发布前更新班级课表主表状态为未发布
+     * @param clazzId
+     * @return
+     */
+    int updateMainBeforePublish(@Param("clazzId") String clazzId);
+
+    /**
+     * 发布前更新班级课表明细表状态为未发布
+     * @param clazzId
+     * @return
+     */
+    int updateDetailBeforePublish(@Param("clazzId") String clazzId);
+
     /**
      * 发布
      * @param
      * @return
      */
     int updateByPublish(Long id);
-    int updateByPublishFrom(Long id);
+
+    /**
+     * 发布/取消发布 更新明细
+     * @param id
+     * @param status
+     * @return
+     */
+    int updateByPublishFrom(@Param("id") Long id, @Param("status") Long status);
 
     /**
      * 取消发布

+ 17 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysStudentMapper.java

@@ -1,5 +1,6 @@
 package com.usoftchina.smartschool.school.mapper;
 
+import com.usoftchina.smartschool.school.po.SysClazz;
 import com.usoftchina.smartschool.school.po.SysParents;
 import com.usoftchina.smartschool.school.po.SysStudent;
 import org.apache.ibatis.annotations.Mapper;
@@ -79,4 +80,20 @@ public interface SysStudentMapper {
      * @return
      */
     List<String> selectIdByClazzId(Long clazzId);
+
+    /**
+     * 更新年级名称
+     * @param grade_name
+     * @param clazzIdList
+     * @return
+     */
+    int updateGradeName(@Param("grade_name") String grade_name, @Param("list") List<SysClazz> clazzIdList);
+
+    /**
+     * 更新班级名称
+     * @param clazz_name
+     * @param clazz_id
+     * @return
+     */
+    int updateClazzName(@Param("clazz_name") String clazz_name, @Param("clazz_id") Long clazz_id);
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/NotifyDO.java

@@ -52,5 +52,7 @@ public class NotifyDO implements Serializable {
 
 	private List<NotifyrecordsDO> unRead;
 
+    private String creator;
 
+    private Date publishDate;
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/wxschool/basic/service/impl/WxNotifyServiceImpl.java

@@ -69,6 +69,7 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 		JSONObject json = JSONObject.parseObject(jsonNotify);
 		NotifyDO notifyDO = new NotifyDO();
 		notifyDO.setCreateDate(new Date());
+		notifyDO.setPublishDate(new Date());
 		String notifyTitle = json.getString("notifyTitle");
 		notifyDO.setNotifyTitle(notifyTitle);
 		String notifyDetails = json.getString("notifyDetails");
@@ -80,6 +81,7 @@ public class WxNotifyServiceImpl implements WxNotifyService {
 		if (ObjectUtils.isNotEmpty(teacherDO1)){
 			schoolId = teacherDO1.getSchoolId();
 			notifyDO.setSchoolId(schoolId);
+			notifyDO.setCreator(teacherDO1.getTeacherName());
 		}
 		notifyDO.setNotifyType(json.getInteger("notifyType"));
 		notifyDO.setNotifyFiles(json.getString("notifyFiles"));

+ 10 - 1
applications/school/school-server/src/main/resources/mapper/CurriculumMapper.xml

@@ -263,15 +263,24 @@
     select count(1) from clazz_main_curriculum where mcur_status=1 and id=#{id}
   </select>
 
+  <update id="updateMainBeforePublish">
+    UPDATE clazz_main_curriculum SET mcur_status = 0 WHERE clazz_id = #{clazzId}
+  </update>
+
+  <update id="updateDetailBeforePublish">
+    UPDATE clazz_curriculum SET cur_status = 0 WHERE clazz_id = #{clazzId}
+  </update>
+
   <update id="updateByPublish" parameterType="java.lang.Long">
     update clazz_main_curriculum
     set mcur_status = 1 ,
       createTime = now()
     where id = #{id,jdbcType=BIGINT}
   </update>
+  
   <update id="updateByPublishFrom" parameterType="java.lang.Long">
     update clazz_curriculum
-    set clazz_curriculum.cur_status = 1
+    set clazz_curriculum.cur_status = #{status}
     where cur_mid = #{id,jdbcType=BIGINT}
   </update>
 

+ 11 - 0
applications/school/school-server/src/main/resources/mapper/SysStudentMapper.xml

@@ -503,4 +503,15 @@
   <select id="selectIdByClazzId" resultType="string" parameterType="long">
     SELECT stu_id FROM sys_student WHERE clazz_id = #{clazzId}
   </select>
+
+  <update id="updateGradeName">
+    update sys_student set stu_grade = #{grade_name} where clazz_id in
+    <foreach collection="list" index="index" item="item" separator="," close=")" open="(" >
+      #{item.clazz_id}
+    </foreach>
+  </update>
+
+  <update id="updateClazzName">
+    update sys_student set stu_class = #{clazz_name} where clazz_id = #{clazz_id}
+  </update>
 </mapper>

+ 6 - 2
applications/school/school-server/src/main/resources/mapper/WxNotifyMapper.xml

@@ -71,7 +71,9 @@
 			`notify_teacher`,
 			`notify_stu`,
 			`notify_remarks`,
-			`school_id`
+			`school_id`,
+			`creator`,
+			`publish_date`
 		)
 		values
 		(
@@ -85,7 +87,9 @@
 			#{notifyTeacher},
 			#{notifyStu},
 			#{notifyRemarks},
-			#{schoolId}
+			#{schoolId},
+			#{creator},
+			#{publishDate}
 		)
 	</insert>