فهرست منبع

成绩发布添加

zhaoy 6 سال پیش
والد
کامیت
617a9ef5aa

+ 7 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/controller/ScoreController.java

@@ -6,6 +6,7 @@ import com.usoftchina.smartschool.page.PageDefault;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.business.service.ScoreService;
 import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.po.ScoreForm;
 import com.usoftchina.smartschool.school.po.ScoreImportList;
@@ -61,4 +62,10 @@ public class ScoreController {
         return Result.success();
     }
 
+    @PostMapping("/save")
+    public Result save(@RequestBody ScoreForm data) {
+        DocBaseDTO baseDTO = scoreService.save(data);
+        return Result.success(baseDTO);
+    }
+
 }

+ 5 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/ScoreService.java

@@ -3,8 +3,10 @@ package com.usoftchina.smartschool.school.business.service;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.page.PageRequest;
 import com.usoftchina.smartschool.school.dto.BatchDealBaseDTO;
+import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
-import com.usoftchina.smartschool.school.po.*;
+import com.usoftchina.smartschool.school.po.ScoreForm;
+import com.usoftchina.smartschool.school.po.ScoreImportList;
 
 /**
  * @author: guq
@@ -22,4 +24,6 @@ public interface ScoreService {
     void publish(Long id);
 
     ScoreForm getFormdata(Long id);
+
+    DocBaseDTO save(ScoreForm data);
 }

+ 51 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/ScoreServiceImpl.java

@@ -15,6 +15,7 @@ import com.usoftchina.smartschool.school.enums.NoticeTemplate;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
 import com.usoftchina.smartschool.school.mapper.*;
 import com.usoftchina.smartschool.school.po.*;
+import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
 import com.usoftchina.smartschool.utils.CollectionUtils;
 import com.usoftchina.smartschool.utils.DateUtils;
 import com.usoftchina.smartschool.wechat.api.WechatApi;
@@ -310,4 +311,54 @@ public class ScoreServiceImpl implements ScoreService{
         form.setItems(detail);
         return form;
     }
+
+    @Override
+    public DocBaseDTO save(ScoreForm data) {
+        if (ObjectUtils.isEmpty(data)){
+            throw new BizException(BizExceptionCode.EMPTY_DATA);
+        }
+        ScoreImport main = data.getMain();
+        List<ScoreImportdetail> items = data.getItems();
+        Long schoolId = BaseContextHolder.getSchoolId();
+        //Long gradeId = sysGradeMapper.selectByName(main.getSi_grade(), schoolId).getGrade_id();
+        SysClazz sysClazz = sysClazzMapper.selectByClazzName(main.getSi_grade(), main.getSi_class() , schoolId);
+        Long classId = sysClazz.getClazz_id();
+        Long gradeId = sysClazz.getGrade_id();
+        if (null == main.getSi_id() || 0 == main.getSi_id()){
+            main.setSi_date(new Date());
+            main.setSi_creator(BaseContextHolder.getUserName());
+            main.setSi_creatorid(BaseContextHolder.getUserId());
+            main.setSchool_id(schoolId);
+            main.setSi_publish(0);
+            main.setSi_gradeid(gradeId);
+            main.setSi_classid(classId);
+            scoreMapper.insertScoreImport(main);
+            Long mId = main.getSi_id();
+            if (null != items && items.size() > 0) {
+                for (ScoreImportdetail item : items) {
+                    if(!StringUtils.isEmpty(item.getSd_stuNumber()) && !StringUtils.isEmpty(item.getSd_stu())) {
+                        Integer check = 0;
+                        //学生检测
+                        check = sysStudentMapper.count(item.getSd_stuNumber(), schoolId);
+                        if (check < 1) {
+                            throw new BizException(BizExceptionCode.NONSTU);
+                        }
+                        check = sysStudentMapper.countName(item.getSd_stu(), schoolId);
+                        if (check < 1) {
+                            throw new BizException(BizExceptionCode.NONSTU);
+                        }
+                        SysStudent sysStudent = sysStudentMapper.selectByStudent(item.getSd_stu() ,classId,schoolId);
+                        Long stuId = sysStudent.getStu_id();
+                        item.setSd_stuid(stuId);
+                    }
+                    item.setSchool_id(schoolId);
+                    item.setSd_siid(mId);
+                    //插入从表
+                    scoreMapper.insertScoreImportDetail(item);
+                }
+            }
+
+        }
+        return new DocBaseDTO(main.getSi_id(), CODE, NAME);
+    }
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysClazzMapper.java

@@ -36,4 +36,6 @@ public interface SysClazzMapper {
     int countClazz(@Param("clazz_name") String clazz_name, @Param("clazz_grade") String clazz_grade, @Param("school_id") Long school_id);
 
     Integer teacherClazz(@Param("subject_name") String subject_name, @Param("clazz_id") Long clazz_id);
+
+    SysClazz selectByClazzName(@Param("clazz_grade") String clazz_grade, @Param("clazz_name") String clazz_name, @Param("school_id") Long school_id);
 }

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

@@ -96,4 +96,12 @@ public interface SysStudentMapper {
      * @return
      */
     int updateClazzName(@Param("clazz_name") String clazz_name, @Param("clazz_id") Long clazz_id);
+
+    SysStudent selectByStudent(@Param("stu_name") String stu_name, @Param("clazz_id") Long clazz_id , @Param("school_id") Long school_id);
+
+    /**
+     * 学生信息:姓名重复
+     * @return
+     */
+    int countName(@Param("stu_name") String stu_name, @Param("school_id") Long school_id);
 }

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/SysClazzMapper.xml

@@ -260,4 +260,8 @@
     </where>
   </select>
 
+  <select id="selectByClazzName" resultMap="BaseResultMap">
+    select * from sys_clazz where clazz_grade=#{clazz_grade} and clazz_name=#{clazz_name} and school_id=#{school_id}
+  </select>
+
 </mapper>

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

@@ -514,4 +514,20 @@
   <update id="updateClazzName">
     update sys_student set stu_class = #{clazz_name} where clazz_id = #{clazz_id}
   </update>
+
+    <select id="selectByStudent" resultMap="BaseResultMap">
+    select * from sys_student where stu_name=#{stu_name} and clazz_id=#{clazz_id} and school_id=#{school_id}
+  </select>
+
+    <select id="countName" resultType="int">
+        select count(*) from sys_student
+        <where>
+            <if test="stu_name != null">
+                stu_name = #{stu_name}
+            </if>
+            <if test="school_id != null">
+                and school_id=#{school_id}
+            </if>
+        </where>
+    </select>
 </mapper>