xiaofei 2 жил өмнө
parent
commit
a24fc15222

+ 3 - 3
src/main/java/com/qmth/eds/mapper/CloudMarkingScoreMapper.java

@@ -19,7 +19,7 @@ public interface CloudMarkingScoreMapper extends BaseMapper<CloudMarkingScore> {
 
     IPage<CloudMarkingScoreDto> pageData(@Param("page") Page<CloudMarkingScoreDto> page, @Param("collegeId") Long collegeId, @Param("semesterId") Long semesterId, @Param("examTypeId") Long examTypeId, @Param("examId") String examId);
 
-    List<ExamSyncStudentDto> listExamSyncStudentDtos(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examTypeId") Long examTypeId, @Param("courseCode") String courseCode, @Param("openCollege") String openCollege);
+    List<ExamSyncStudentDto> listExamSyncStudentDtos(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examTypeId") Long examTypeId, @Param("courses") List<String> courses, @Param("openCollege") String openCollege);
 
     /**
      * 查询学生成绩
@@ -29,7 +29,7 @@ public interface CloudMarkingScoreMapper extends BaseMapper<CloudMarkingScore> {
      * @param semesterId
      * @param examTypeId
      * @param openCollege
-     * @param courseCode
+     * @param courses
      * @return
      */
     List<StudentMarkResult> queryStudentMark(@Param("schoolId") Long schoolId,
@@ -37,7 +37,7 @@ public interface CloudMarkingScoreMapper extends BaseMapper<CloudMarkingScore> {
                                              @Param("semesterId") Long semesterId,
                                              @Param("examTypeId") Long examTypeId,
                                              @Param("openCollege") String openCollege,
-                                             @Param("courseCode") String courseCode);
+                                             @Param("courses") List<String> courses);
 
     List<ScoreDownloadDto> listScoreBySemesterIdAndExamTypeIdAndCollegeIdAndCourseCodeAndOpenCollege(@Param("semesterId") Long semesterId, @Param("examTypeId") Long examTypeId, @Param("collegeId") Long collegeId, @Param("courseCode") String courseCode, @Param("openCollege") String openCollege);
 }

+ 3 - 2
src/main/java/com/qmth/eds/mapper/ExamAssignMapper.java

@@ -8,6 +8,7 @@ import com.qmth.eds.bean.result.AssignResultPreviewResult;
 import com.qmth.eds.common.entity.ExamAssign;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -27,7 +28,7 @@ public interface ExamAssignMapper extends BaseMapper<ExamAssign> {
      * @param collegeId
      * @param semesterId
      * @param examTypeId
-     * @param courseCode
+     * @param courses
      * @param openCollege
      * @param kcCollege
      * @param clazzId
@@ -41,7 +42,7 @@ public interface ExamAssignMapper extends BaseMapper<ExamAssign> {
                                                          @Param("collegeId") Long collegeId,
                                                          @Param("semesterId") Long semesterId,
                                                          @Param("examTypeId") Long examTypeId,
-                                                         @Param("courseCode") String courseCode,
+                                                         @Param("courses") List<String> courses,
                                                          @Param("openCollege") String openCollege,
                                                          @Param("kcCollege") String kcCollege,
                                                          @Param("clazzId") String clazzId,

+ 2 - 2
src/main/java/com/qmth/eds/mapper/ExamSyncStudentMapper.java

@@ -18,12 +18,12 @@ public interface ExamSyncStudentMapper extends BaseMapper<ExamSyncStudent> {
      * @param semesterId
      * @param orgId
      * @param examTypeId
-     * @param courseCode
+     * @param courses
      * @param openCollege
      * @param kcCollege
      * @param clazzId
      * @return
      */
-    List<ExamSyncStudent> queryByExamineCollegeList(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("orgId") Long orgId, @Param("examTypeId") Long examTypeId, @Param("courseCode") String courseCode
+    List<ExamSyncStudent> queryByExamineCollegeList(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("orgId") Long orgId, @Param("examTypeId") Long examTypeId, @Param("courses") List<String> courses
             , @Param("openCollege") String openCollege, @Param("kcCollege") String kcCollege, @Param("clazzId") String clazzId);
 }

+ 2 - 2
src/main/java/com/qmth/eds/service/AsyncTaskService.java

@@ -47,7 +47,7 @@ public class AsyncTaskService {
         whuDataSyncService.syncCloudMarkingStudentScoreData(schoolId, tbSyncTask, examId);
     }
 
-    public void calcAssignScore(ExamAssign examAssign) {
-        whuDataSyncService.calcAssignScore(examAssign);
+    public void calcAssignScore(Long schoolId, ExamAssign examAssign) {
+        whuDataSyncService.calcAssignScore(schoolId, examAssign);
     }
 }

+ 1 - 1
src/main/java/com/qmth/eds/service/CloudMarkingScoreService.java

@@ -19,7 +19,7 @@ public interface CloudMarkingScoreService extends IService<CloudMarkingScore> {
 
     IPage<CloudMarkingScoreDto> pageData(Long collegeId, Long semesterId, Long examTypeId, String examId, Integer pageNumber, Integer pageSize);
 
-    List<ExamSyncStudentDto> listExamSyncStudentDtos(Long schoolId, Long semesterId, Long examTypeId, String courseCode, String openCollege);
+    List<ExamSyncStudentDto> listExamSyncStudentDtos(Long schoolId, Long semesterId, Long examTypeId, List<String> courses, String openCollege);
 
     /**
      * 查询学生成绩

+ 1 - 1
src/main/java/com/qmth/eds/service/WhuDataSyncService.java

@@ -29,5 +29,5 @@ public interface WhuDataSyncService {
     void syncCloudMarkingStudentScoreData(Long schoolId, TBSyncTask tbSyncTask, Integer examId);
 
     @Async
-    void calcAssignScore(ExamAssign examAssign);
+    void calcAssignScore(Long schoolId, ExamAssign examAssign);
 }

+ 17 - 3
src/main/java/com/qmth/eds/service/impl/CloudMarkingScoreServiceImpl.java

@@ -9,19 +9,26 @@ import com.qmth.eds.bean.dto.ExamSyncStudentDto;
 import com.qmth.eds.bean.dto.ScoreDownloadDto;
 import com.qmth.eds.bean.result.StudentMarkResult;
 import com.qmth.eds.common.entity.CloudMarkingScore;
+import com.qmth.eds.common.entity.ExamCourseMapping;
 import com.qmth.eds.common.entity.SysUser;
 import com.qmth.eds.common.util.ServletUtil;
 import com.qmth.eds.mapper.CloudMarkingScoreMapper;
 import com.qmth.eds.service.CloudMarkingScoreService;
+import com.qmth.eds.service.ExamCourseMappingService;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 @Service
 public class CloudMarkingScoreServiceImpl extends ServiceImpl<CloudMarkingScoreMapper, CloudMarkingScore> implements CloudMarkingScoreService {
 
+    @Resource
+    ExamCourseMappingService examCourseMappingService;
     @Resource
     CloudMarkingScoreMapper cloudMarkingScoreMapper;
 
@@ -42,8 +49,8 @@ public class CloudMarkingScoreServiceImpl extends ServiceImpl<CloudMarkingScoreM
     }
 
     @Override
-    public List<ExamSyncStudentDto> listExamSyncStudentDtos(Long schoolId, Long semesterId, Long examTypeId, String courseCode, String openCollege) {
-        return this.baseMapper.listExamSyncStudentDtos(schoolId, semesterId, examTypeId, courseCode, openCollege);
+    public List<ExamSyncStudentDto> listExamSyncStudentDtos(Long schoolId, Long semesterId, Long examTypeId, List<String> courses, String openCollege) {
+        return this.baseMapper.listExamSyncStudentDtos(schoolId, semesterId, examTypeId, courses, openCollege);
     }
 
     /**
@@ -58,7 +65,14 @@ public class CloudMarkingScoreServiceImpl extends ServiceImpl<CloudMarkingScoreM
     @Override
     public List<StudentMarkResult> queryStudentMark(Long semesterId, Long examTypeId, Long collegeId, String openCollege, String courseCode) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        return cloudMarkingScoreMapper.queryStudentMark(schoolId, collegeId, semesterId, examTypeId, openCollege, courseCode);
+        // 查询关联课程
+        List<ExamCourseMapping> examCourseMappings = examCourseMappingService.listBySemesterIdAndExamTypeIdAndCloudMarkCourseCode(schoolId, semesterId, examTypeId, courseCode);
+
+        List<String> courses = Arrays.asList(courseCode.split(","));
+        if (!CollectionUtils.isEmpty(examCourseMappings)) {
+            courses = examCourseMappings.stream().map(ExamCourseMapping::getSyncCourseCode).collect(Collectors.toList());
+        }
+        return cloudMarkingScoreMapper.queryStudentMark(schoolId, collegeId, semesterId, examTypeId, openCollege, courses);
     }
 
     @Override

+ 10 - 3
src/main/java/com/qmth/eds/service/impl/ExamAssignServiceImpl.java

@@ -72,7 +72,6 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
             throw ExceptionResultEnum.ERROR.exception("未设置使用数据文件,请联系管理员处理");
         }
 
-
         List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
         for (ExamAssignDto record : assignListDtoIPage.getRecords()) {
             int actualCount = 0;
@@ -116,6 +115,7 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
 
     @Override
     public String calcData(String data) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
 
         ExamAssign examAssign = JSON.parseObject(data, ExamAssign.class);
@@ -132,7 +132,7 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
         this.saveOrUpdate(examAssign);
 
         // 计算赋分
-        asyncTaskService.calcAssignScore(examAssign);
+        asyncTaskService.calcAssignScore(schoolId, examAssign);
         return String.valueOf(examAssign.getId());
     }
 
@@ -164,7 +164,14 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
                                                                 String minAssignScore,
                                                                 String maxAssignScore) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        return examAssignMapper.assignResultPreview(iPage, schoolId, collegeId, semesterId, examTypeId, courseCode, openCollege, kcCollege, clazzId, teacherCode, minAssignScore, maxAssignScore);
+        // 查询关联课程
+        List<ExamCourseMapping> examCourseMappings = examCourseMappingService.listBySemesterIdAndExamTypeIdAndCloudMarkCourseCode(schoolId, semesterId, examTypeId, courseCode);
+
+        List<String> courses = Arrays.asList(courseCode.split(","));
+        if(!CollectionUtils.isEmpty(examCourseMappings)){
+            courses = examCourseMappings.stream().map(ExamCourseMapping::getSyncCourseCode).collect(Collectors.toList());
+        }
+        return examAssignMapper.assignResultPreview(iPage, schoolId, collegeId, semesterId, examTypeId, courses, openCollege, kcCollege, clazzId, teacherCode, minAssignScore, maxAssignScore);
     }
 
     @Override

+ 11 - 1
src/main/java/com/qmth/eds/service/impl/ExamSyncStudentServiceImpl.java

@@ -11,10 +11,13 @@ import com.qmth.eds.mapper.ExamSyncStudentMapper;
 import com.qmth.eds.service.ExamCourseMappingService;
 import com.qmth.eds.service.ExamSyncStudentService;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 @Service
 public class ExamSyncStudentServiceImpl extends ServiceImpl<ExamSyncStudentMapper, ExamSyncStudent> implements ExamSyncStudentService {
@@ -68,6 +71,13 @@ public class ExamSyncStudentServiceImpl extends ServiceImpl<ExamSyncStudentMappe
     public List<ExamSyncStudent> queryByExamineCollegeList(Long semesterId, Long examTypeId, String courseCode, String openCollege, String kcCollege, String clazzId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        return examSyncStudentMapper.queryByExamineCollegeList(schoolId, semesterId, sysUser.getOrgId(), examTypeId, courseCode, openCollege, kcCollege, clazzId);
+        // 查询关联课程
+        List<ExamCourseMapping> examCourseMappings = examCourseMappingService.listBySemesterIdAndExamTypeIdAndCloudMarkCourseCode(schoolId, semesterId, examTypeId, courseCode);
+
+        List<String> courses = Arrays.asList(courseCode.split(","));
+        if(!CollectionUtils.isEmpty(examCourseMappings)){
+            courses = examCourseMappings.stream().map(ExamCourseMapping::getSyncCourseCode).collect(Collectors.toList());
+        }
+        return examSyncStudentMapper.queryByExamineCollegeList(schoolId, semesterId, sysUser.getOrgId(), examTypeId, courses, openCollege, kcCollege, clazzId);
     }
 }

+ 14 - 2
src/main/java/com/qmth/eds/service/impl/WhuDataSyncServiceImpl.java

@@ -17,7 +17,9 @@ import com.qmth.eds.common.enums.*;
 import com.qmth.eds.common.tools.CloudMarkingUtils;
 import com.qmth.eds.common.tools.WhuUtils;
 import com.qmth.eds.common.util.FileUtil;
+import com.qmth.eds.common.util.ServletUtil;
 import com.qmth.eds.service.*;
+import net.sf.jsqlparser.expression.LongValue;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -77,6 +79,9 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
     @Resource
     private ExamAssignService examAssignService;
 
+    @Resource
+    private ExamCourseMappingService examCourseMappingService;
+
     @Async
     @Override
     public void syncWuhanUniversityExamData(ExamScheduleTask examScheduleTask, TBSyncTask tbSyncTask, boolean isAuto) {
@@ -274,7 +279,7 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
     }
 
     @Override
-    public void calcAssignScore(ExamAssign examAssign) {
+    public void calcAssignScore(Long schoolId, ExamAssign examAssign) {
         examAssign.setStatus(ExamAssignStatusEnum.RUNNING);
         examAssignService.updateById(examAssign);
         String errorMsg = null;
@@ -290,7 +295,14 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
             Double rebuildValue = object.getDoubleValue("rebuildValue");
 
             List<ExamSyncStudentDto> finalList = new ArrayList<>();
-            List<ExamSyncStudentDto> examSyncStudentDtoList = cloudMarkingScoreService.listExamSyncStudentDtos(examAssign.getSchoolId(), examAssign.getSemesterId(), examAssign.getExamTypeId(), examAssign.getCourseCode(), examAssign.getOpenCollege());
+            // 查询关联课程
+            List<ExamCourseMapping> examCourseMappings = examCourseMappingService.listBySemesterIdAndExamTypeIdAndCloudMarkCourseCode(schoolId, examAssign.getSemesterId(), examAssign.getExamTypeId(), examAssign.getCourseCode());
+
+            List<String> courses = Arrays.asList(examAssign.getCourseCode().split(","));
+            if(!CollectionUtils.isEmpty(examCourseMappings)){
+                courses = examCourseMappings.stream().map(ExamCourseMapping::getSyncCourseCode).collect(Collectors.toList());
+            }
+            List<ExamSyncStudentDto> examSyncStudentDtoList = cloudMarkingScoreService.listExamSyncStudentDtos(examAssign.getSchoolId(), examAssign.getSemesterId(), examAssign.getExamTypeId(), courses, examAssign.getOpenCollege());
             if (CollectionUtils.isEmpty(examSyncStudentDtoList)) {
                 throw ExceptionResultEnum.ERROR.exception("需要计算的数据有误,请联系管理员");
             }

+ 12 - 4
src/main/resources/mapper/CloudMarkingScoreMapper.xml

@@ -66,8 +66,12 @@
             <if test="examTypeId != null">
                 and cms.exam_type_id = #{examTypeId}
             </if>
-            <if test="courseCode != null and courseCode != ''">
-                and ess.kch = #{courseCode}
+            <if test="courses != null and courses != ''">
+                and ess.kch in
+                <foreach collection="courses" item="item" index="index" open="(" separator=
+                        "," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="openCollege != null and openCollege != ''">
                 and ess.kkbm = #{openCollege}
@@ -111,8 +115,12 @@
             <if test="examTypeId != null and examTypeId != ''">
                 and t.exam_type_id = #{examTypeId}
             </if>
-            <if test="courseCode != null and courseCode != ''">
-                and ess.kch = #{courseCode}
+            <if test="courses != null and courses != ''">
+                and ess.kch in
+                <foreach collection="courses" item="item" index="index" open="(" separator=
+                        "," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="openCollege != null and openCollege != ''">
                 and ess.kkbm = #{openCollege}

+ 6 - 2
src/main/resources/mapper/ExamAssignMapper.xml

@@ -60,8 +60,12 @@
             <if test="examTypeId != null and examTypeId != ''">
                 and cms.exam_type_id = #{examTypeId}
             </if>
-            <if test="courseCode != null and courseCode != ''">
-                and ess.kch = #{courseCode}
+            <if test="courses != null and courses != ''">
+                and ess.kch in
+                <foreach collection="courses" item="item" index="index" open="(" separator=
+                        "," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="openCollege != null and openCollege != ''">
                 and ess.kkbm = #{openCollege}

+ 6 - 2
src/main/resources/mapper/ExamSyncStudentMapper.xml

@@ -21,8 +21,12 @@
             <if test="examTypeId != null and examTypeId != ''">
                 and cms.exam_type_id = #{examTypeId}
             </if>
-            <if test="courseCode != null and courseCode != ''">
-                and ess.kch = #{courseCode}
+            <if test="courses != null and courses != ''">
+                and ess.kch in
+                <foreach collection="courses" item="item" index="index" open="(" separator=
+                        "," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="openCollege != null and openCollege != ''">
                 and ess.kkbm = #{openCollege}