zhaoy 6 жил өмнө
parent
commit
dd02717a0e

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

@@ -324,6 +324,7 @@ public class ScoreServiceImpl implements ScoreService{
         SysClazz sysClazz = sysClazzMapper.selectByClazzName(main.getSi_grade(), main.getSi_class() , schoolId);
         SysClazz sysClazz = sysClazzMapper.selectByClazzName(main.getSi_grade(), main.getSi_class() , schoolId);
         Long classId = sysClazz.getClazz_id();
         Long classId = sysClazz.getClazz_id();
         Long gradeId = sysClazz.getGrade_id();
         Long gradeId = sysClazz.getGrade_id();
+        Long mId = main.getSi_id();
         if (null == main.getSi_id() || 0 == main.getSi_id()){
         if (null == main.getSi_id() || 0 == main.getSi_id()){
             main.setSi_date(new Date());
             main.setSi_date(new Date());
             main.setSi_creator(BaseContextHolder.getUserName());
             main.setSi_creator(BaseContextHolder.getUserName());
@@ -333,7 +334,6 @@ public class ScoreServiceImpl implements ScoreService{
             main.setSi_gradeid(gradeId);
             main.setSi_gradeid(gradeId);
             main.setSi_classid(classId);
             main.setSi_classid(classId);
             scoreMapper.insertScoreImport(main);
             scoreMapper.insertScoreImport(main);
-            Long mId = main.getSi_id();
             if (null != items && items.size() > 0) {
             if (null != items && items.size() > 0) {
                 for (ScoreImportdetail item : items) {
                 for (ScoreImportdetail item : items) {
                     if(!StringUtils.isEmpty(item.getSd_stuNumber()) && !StringUtils.isEmpty(item.getSd_stu())) {
                     if(!StringUtils.isEmpty(item.getSd_stuNumber()) && !StringUtils.isEmpty(item.getSd_stu())) {
@@ -358,6 +358,45 @@ public class ScoreServiceImpl implements ScoreService{
                 }
                 }
             }
             }
 
 
+        }else{
+            scoreMapper.updateScoreImport(main);
+            if (null != items && items.size() > 0) {
+                List<ScoreImportdetail> insertList = new ArrayList<ScoreImportdetail>();
+                List<ScoreImportdetail> updateList = new ArrayList<ScoreImportdetail>();
+                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);
+
+                    if(item.getSd_id() != null && 0 != item.getSd_id()) {
+                        updateList.add(item);
+                    }else {
+                        insertList.add(item);
+                    }
+                    if (insertList.size() > 0) {
+                        scoreMapper.insertDetailSelective(insertList);
+                    }
+                    if (updateList.size() > 0) {
+                        scoreMapper.updateDetailSelective(updateList);
+                    }
+
+                }
+            }
         }
         }
         return new DocBaseDTO(main.getSi_id(), CODE, NAME);
         return new DocBaseDTO(main.getSi_id(), CODE, NAME);
     }
     }

+ 6 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/ScoreMapper.java

@@ -26,6 +26,8 @@ public interface ScoreMapper {
 
 
     int insertScoreImport(ScoreImport scoreImport);
     int insertScoreImport(ScoreImport scoreImport);
 
 
+    int updateScoreImport(ScoreImport scoreImport);
+
     void insertScoreImportDetail(ScoreImportdetail detail);
     void insertScoreImportDetail(ScoreImportdetail detail);
 
 
     List<ScoreImportdetail> selectDetail(Long id);
     List<ScoreImportdetail> selectDetail(Long id);
@@ -43,4 +45,8 @@ public interface ScoreMapper {
     Long selectCountBySubjectAndCode(@Param("si_id") Long si_id, @Param("stu_number") String stu_number, @Param("subject")String subject);
     Long selectCountBySubjectAndCode(@Param("si_id") Long si_id, @Param("stu_number") String stu_number, @Param("subject")String subject);
 
 
     List<ScoreNoticer> selectWechatMsg(Long id);
     List<ScoreNoticer> selectWechatMsg(Long id);
+
+    void insertDetailSelective(List<ScoreImportdetail> scoreImportdetail);
+
+    void updateDetailSelective(List<ScoreImportdetail> scoreImportdetail);
 }
 }

+ 90 - 0
applications/school/school-server/src/main/resources/mapper/ScoreMapper.xml

@@ -432,4 +432,94 @@
 	  where sd_siid=#{id}     and  ifnull(sys_parents.openid,'') != '' and  parents_status=1
 	  where sd_siid=#{id}     and  ifnull(sys_parents.openid,'') != '' and  parents_status=1
   </select>
   </select>
 
 
+  <update id="updateScoreImport" parameterType="com.usoftchina.smartschool.school.po.ScoreImport" >
+    update score_import
+    <set >
+      <if test="si_date != null" >
+        si_date = #{si_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="si_creator != null" >
+        si_creator = #{si_creator,jdbcType=VARCHAR},
+      </if>
+      <if test="si_creatorid != null" >
+        si_creatorid = #{si_creatorid,jdbcType=BIGINT},
+      </if>
+      <if test="si_examtitle != null" >
+        si_examtitle = #{si_examtitle,jdbcType=VARCHAR},
+      </if>
+      <if test="si_examscope != null" >
+        si_examscope = #{si_examscope,jdbcType=VARCHAR},
+      </if>
+      <if test="si_term != null" >
+        si_term = #{si_term,jdbcType=VARCHAR},
+      </if>
+      <if test="si_class != null" >
+        si_class = #{si_class,jdbcType=VARCHAR},
+      </if>
+      <if test="si_classid != null" >
+        si_classid = #{si_classid,jdbcType=BIGINT},
+      </if>
+      <if test="si_grade != null" >
+        si_grade = #{si_grade,jdbcType=VARCHAR},
+      </if>
+      <if test="si_gradeid != null" >
+        si_gradeid = #{si_gradeid,jdbcType=BIGINT},
+      </if>
+      <if test="school_id != null" >
+        school_id = #{school_id,jdbcType=BIGINT},
+      </if>
+      <if test="si_examdate != null" >
+        si_examdate = #{si_examdate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="si_publish != null" >
+        si_publish = #{si_publish,jdbcType=INTEGER},
+      </if>
+    </set>
+    where si_id = #{si_id,jdbcType=INTEGER}
+  </update>
+
+  <insert id="insertDetailSelective" parameterType="java.util.List">
+    insert into score_importdetail
+    (sd_siid,sd_stuid,sd_stu,sd_score,
+    sd_subject,sd_remark,school_id,sd_stuNumber
+    ) values
+      (
+      #{sd_siid, jdbcType=BIGINT},#{sd_stuid,jdbcType=BIGINT},#{sd_stu,jdbcType=VARCHAR},#{sd_score,jdbcType=INTEGER},#{sd_subject,jdbcType=VARCHAR},
+      #{sd_remark,jdbcType=VARCHAR},#{school_id,jdbcType=BIGINT},#{sd_stuNumber,jdbcType=VARCHAR}
+      )
+  </insert>
+
+  <update id="updateDetailSelective" parameterType="com.usoftchina.smartschool.school.dto.CurriculumDetailDTO">
+    <foreach collection="list" item="item" index="index" separator=";">
+      update score_importdetail
+      <set>
+        <if test="sd_siid != null and sd_siid != 0">
+          sd_siid = #{sd_siid, jdbcType=BIGINT},
+        </if>
+        <if test="sd_stuid != null">
+          sd_stuid = #{sd_stuid,jdbcType=BIGINT},
+        </if>
+        <if test="sd_stu != null">
+          sd_stu = #{sd_stu,jdbcType=VARCHAR},
+        </if>
+        <if test="sd_score != null">
+          sd_score = #{sd_score,jdbcType=INTEGER},
+        </if>
+        <if test="sd_subject != null">
+          sd_subject = #{sd_subject,jdbcType=VARCHAR},
+        </if>
+        <if test="sd_remark != null">
+          sd_remark = #{sd_remark,jdbcType=VARCHAR},
+        </if>
+        <if test="school_id != null">
+          school_id = #{school_id,jdbcType=BIGINT},
+        </if>
+        <if test="sd_stuNumber != null">
+          sd_stuNumber = #{sd_stuNumber,jdbcType=VARCHAR},
+        </if>
+      </set>
+      WHERE sd_id= #{sd_id,jdbcType=INTEGER}
+    </foreach>
+  </update>
+
 </mapper>
 </mapper>