Bladeren bron

Merge remote-tracking branch 'origin/dev_v3.4.0' into dev_v3.4.0

wangliang 11 maanden geleden
bovenliggende
commit
a687f29a98

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ConditionMapper.java

@@ -4,6 +4,7 @@ import com.qmth.distributed.print.business.bean.result.PrintPlanBrief;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.bean.result.DictionaryResult;
 import com.qmth.teachcloud.common.entity.BasicCourse;
+import com.qmth.teachcloud.common.entity.SysOrg;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -69,7 +70,8 @@ public interface ConditionMapper {
 
     List<BasicCourse> listCourseForDocument(@Param("examId") Long examId, @Param("dpr") DataPermissionRule dpr);
 
-    List<BasicCourse> listCourseForBasicExamStudent(@Param("examId") Long examId, @Param("dpr") DataPermissionRule dpr);
+    List<BasicCourse> listCourseForBasicExamStudent(@Param("examId") Long examId, @Param("openCollegeId") Long openCollegeId, @Param("dpr") DataPermissionRule dpr);
 
     List<String> listPaperNumberFromBasicExamStudent(@Param("examId") Long examId, @Param("courseId") Long courseId, @Param("dpr") DataPermissionRule dpr);
+
 }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java

@@ -91,4 +91,6 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @return
      */
     ExamStudentDto queryExamStudent(Long examId, Long courseId, String paperNumber);
+
+    List<BasicExamStudent> listByExamIdAndCourseIdAndTeachClassName(Long examId, Long courseId, String teachClassName);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ConditionService.java

@@ -19,7 +19,7 @@ public interface ConditionService {
 
     List<BasicExam> listExam(Long semesterId, ExamCategoryEnum category, Boolean enable);
 
-    List<BasicCourse> listCourse(Long semesterId, Long examId, Boolean enable, List<String> printPlanId);
+    List<BasicCourse> listCourse(Long semesterId, Long examId, Boolean enable, List<String> printPlanId, Long openCollegeId);
 
     List<String> listPaperNumber(Long semesterId, Long examId, Long courseId, List<String> printPlanId);
 

+ 39 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -86,7 +86,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     private ExamTaskDetailService examTaskDetailService;
 
     @Override
-    public IPage<BasicExamStudentResult> page(Long semesterId, Long examId, Long courseId,String paperNumber,
+    public IPage<BasicExamStudentResult> page(Long semesterId, Long examId, Long courseId, String paperNumber,
                                               String teacher, String college, String major, String teachClassName, String className, String examStudentInfo, int pageNumber,
                                               int pageSize) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
@@ -277,6 +277,23 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         basicExamStudent.setSchoolId(schoolId);
         basicExamStudent.setTeacherId(teacherId);
 
+        // 同一课程+教学班下只能有一位任课老师
+        List<BasicExamStudent> basicExamStudentList = this.listByExamIdAndCourseIdAndTeachClassName(basicExamStudent.getExamId(), basicExamStudent.getCourseId(), basicExamStudent.getTeachClassName());
+        if(CollectionUtils.isNotEmpty(basicExamStudentList)){
+            List<Long> teacherIds = basicExamStudentList.stream().map(BasicExamStudent::getTeacherId).distinct().collect(Collectors.toList());
+            if(teacherIds.size() >1){
+                throw ExceptionResultEnum.ERROR.exception("课程下同一教学班,只允许有一个任课老师");
+            } else{
+                if(basicExamStudent.getTeacherId() != null && teacherIds.get(0) == null){
+                    throw ExceptionResultEnum.ERROR.exception("教学班其它学生任课老师为空,本次不填任课老师信息");
+                } else if (basicExamStudent.getTeacherId() == null && teacherIds.get(0) != null){
+                    throw ExceptionResultEnum.ERROR.exception("教学班其它学生任课老师不为空,任课老师必填");
+                } else if (basicExamStudent.getTeacherId() != null && teacherIds.get(0) != null && basicExamStudent.getTeacherId().equals(teacherIds.get(0))){
+                    throw ExceptionResultEnum.ERROR.exception("任课老师与教学班其它学生任课老师不一致");
+                }
+            }
+        }
+
         if (SystemConstant.longNotNull(basicExamStudent.getId())) {
             // 编辑 (学号不可更改)
             BasicExamStudent dbBasicExamStudent = this.getById(basicExamStudent.getId());
@@ -464,13 +481,19 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
             BasicCourse basicCourse = basicCourseService.getById(basicExamStudent.getCourseId());
             SysOrg sysOrg = sysOrgService.getById(basicCourse != null ? basicCourse.getTeachingRoomId() : null);
             List<MarkStudent> markStudentList = markStudentService.listByStudentId(basicExamStudent.getId());
-            if (CollectionUtils.isNotEmpty(markStudentList)) {
-                for (MarkStudent markStudent : markStudentList) {
-                    DeleteBasicExamStudentStatusDto deleteBasicExamStudentStatusDto = new DeleteBasicExamStudentStatusDto(basicExamStudent.getStudentName(), basicExamStudent.getStudentCode(), basicCourse != null ? basicCourse.getCode() : null, basicCourse != null ? basicCourse.getName() : null, sysOrg != null ? sysOrg.getName() : null);
-                    deleteBasicExamStudentStatusDto.setScanStatus(markStudent.getUpload() != null ? markStudent.getUpload() : false);
-                    deleteBasicExamStudentStatusDto.setMarkTaskStatus(markTaskService.countByStudentId(markStudent.getId()) > 0);
-                    list.add(deleteBasicExamStudentStatusDto);
+            Map<Long, List<MarkStudent>> map = markStudentList.stream().collect(Collectors.groupingBy(MarkStudent::getBasicStudentId));
+            for (Map.Entry<Long, List<MarkStudent>> entry : map.entrySet()) {
+                DeleteBasicExamStudentStatusDto deleteBasicExamStudentStatusDto = new DeleteBasicExamStudentStatusDto(basicExamStudent.getStudentName(), basicExamStudent.getStudentCode(), basicCourse != null ? basicCourse.getCode() : null, basicCourse != null ? basicCourse.getName() : null, sysOrg != null ? sysOrg.getName() : null);
+                deleteBasicExamStudentStatusDto.setScanStatus(entry.getValue().stream().filter(m -> m.getUpload() != null && m.getUpload()).count() > 0);
+                int taskCount = 0;
+                for (MarkStudent markStudent : entry.getValue()) {
+                    if (taskCount > 0) {
+                        break;
+                    }
+                    taskCount += markTaskService.countByStudentId(markStudent.getId());
                 }
+                deleteBasicExamStudentStatusDto.setMarkTaskStatus(taskCount > 0);
+                list.add(deleteBasicExamStudentStatusDto);
             }
         }
         return list;
@@ -488,4 +511,13 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     public ExamStudentDto queryExamStudent(Long examId, Long courseId, String paperNumber) {
         return this.baseMapper.queryExamStudent(examId, courseId, paperNumber);
     }
+
+    @Override
+    public List<BasicExamStudent> listByExamIdAndCourseIdAndTeachClassName(Long examId, Long courseId, String teachClassName) {
+        QueryWrapper<BasicExamStudent> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(BasicExamStudent::getExamId, examId)
+                .eq(BasicExamStudent::getCourseId, courseId)
+                .eq(BasicExamStudent::getTeachClassName, teachClassName);
+        return this.list(queryWrapper);
+    }
 }

+ 2 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ConditionServiceImpl.java

@@ -19,7 +19,6 @@ import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
 import com.qmth.teachcloud.common.service.BasicSemesterService;
 import com.qmth.teachcloud.common.service.SysOrgService;
 import com.qmth.teachcloud.common.util.ServletUtil;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -82,7 +81,7 @@ public class ConditionServiceImpl implements ConditionService {
     }
 
     @Override
-    public List<BasicCourse> listCourse(Long semesterId, Long examId, Boolean enable, List<String> printPlanIds) {
+    public List<BasicCourse> listCourse(Long semesterId, Long examId, Boolean enable, List<String> printPlanIds, Long openCollegeId) {
         // 考试ID为空,默认返回空
         if (examId == null) {
             return new ArrayList<>();
@@ -95,7 +94,7 @@ public class ConditionServiceImpl implements ConditionService {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         // 考生管理(1100)
         if ("1100".equals(privilegeIdString)) {
-            return conditionMapper.listCourseForBasicExamStudent(examId, dpr);
+            return conditionMapper.listCourseForBasicExamStudent(examId, openCollegeId, dpr);
         }
         // 命题任务管理(39)
         else if ("39".equals(privilegeIdString)) {

+ 8 - 2
distributed-print-business/src/main/resources/mapper/ConditionMapper.xml

@@ -229,7 +229,7 @@
                     AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = mp.course_id)
                 </if>
                 <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
-                    AND su.org_id IN
+                    AND bc.teaching_room_id IN
                     <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                         #{item}
                     </foreach>
@@ -890,7 +890,12 @@
         </if>)
     </select>
     <select id="listCourseForBasicExamStudent" resultType="com.qmth.teachcloud.common.entity.BasicCourse">
-        select * from basic_course bc where exists(
+        select * from basic_course bc
+            <where>
+            <if test="openCollegeId != null">
+                and bc.teaching_room_id = #{openCollegeId}
+            </if>
+            and exists(
             select 1 from basic_exam_student bes where exam_id = #{examId} and bc.id = bes.course_id
                 <if test="dpr != null">
                     <if test="dpr.requestUserId != null">
@@ -906,6 +911,7 @@
                         </foreach>
                     </if>
                 </if> )
+            </where>
     </select>
     <select id="listPaperNumberFromBasicExamStudent" resultType="java.lang.String">
         select distinct bes.paper_number from basic_exam_student bes left join basic_course bc on bes.course_id = bc.id

+ 3 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/ConditionController.java

@@ -58,8 +58,9 @@ public class ConditionController {
     @RequestMapping(value = "/list_course", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = BasicCourse.class)})
     public Result listCourse(@ApiParam(value = "学期ID") @RequestParam(required = false) Long semesterId, @ApiParam(value = "考试ID") @RequestParam(required = false) Long examId,
-                             @ApiParam(value = "启用/禁用") @RequestParam(required = false) Boolean enable, @RequestParam(value = "printPlanId", required = false) List<String> printPlanId) {
-        return ResultUtil.ok(conditionService.listCourse(semesterId, examId, enable, printPlanId));
+                             @ApiParam(value = "启用/禁用") @RequestParam(required = false) Boolean enable, @RequestParam(value = "printPlanId", required = false) List<String> printPlanId,
+                             @ApiParam(value = "开课学院ID") @RequestParam(required = false) Long openCollegeId) {
+        return ResultUtil.ok(conditionService.listCourse(semesterId, examId, enable, printPlanId, openCollegeId));
     }
 
     @ApiOperation(value = "试卷编号")

+ 3 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/mapper/MarkStudentMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.entity.BasicTeachClazz;
+import com.qmth.teachcloud.common.enums.BasicExamStudentStatusEnum;
 import com.qmth.teachcloud.mark.bean.archivescore.*;
 import com.qmth.teachcloud.mark.bean.scananswer.AnswerQueryDomain;
 import com.qmth.teachcloud.mark.bean.scananswer.AnswerQueryVo;
@@ -129,4 +130,6 @@ public interface MarkStudentMapper extends BaseMapper<MarkStudent> {
     IPage<MarkStudentVo> listMarkStudentVo(@Param("page") Page<MarkStudentVo> page, @Param("markStudentQuery") MarkStudentQuery markStudentQuery);
 
     int countOmrAbsentStudent(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType, @Param("isOmrAbsentConfirm") boolean isOmrAbsentConfirm, @Param("teachClassName") String teachClassName);
+
+    void updateBasicExamStudentStatus(@Param("status") String status, @Param("basicStudentId") Long basicStudentId);
 }

+ 3 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java

@@ -8,6 +8,7 @@ import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.entity.BasicExam;
 import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.BasicExamStudentStatusEnum;
 import com.qmth.teachcloud.common.enums.ScanStatus;
 import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
 import com.qmth.teachcloud.common.enums.mark.SubjectiveStatus;
@@ -222,4 +223,6 @@ public interface MarkStudentService extends IService<MarkStudent> {
     IPage<MarkStudentVo> pageMarkStudentVo(Page<MarkStudentVo> page, MarkStudentQuery markStudentQuery);
 
     MarkStudent findByBasicStudentId(Long basicStudentId);
+
+    void updateBasicExamStudentStatus(Long markStudentId);
 }

+ 27 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -26,6 +26,7 @@ import com.qmth.teachcloud.common.entity.BasicExam;
 import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.BasicExamStudentStatusEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.PageSizeEnum;
 import com.qmth.teachcloud.common.enums.ScanStatus;
@@ -613,6 +614,8 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                 this.countUploadedByExamIdAndPaperNumber(student.getExamId(), student.getPaperNumber()));
         markPaperService.updateAbsentCount(student.getExamId(), student.getPaperNumber(),
                 this.countAbsentByExamIdAndPaperNumber(student.getExamId(), student.getPaperNumber()));
+        // 更新考生管理中考生状态
+        this.updateBasicExamStudentStatus(student.getId());
         if (updateOmrTask) {
             // 清除识别对照任务
             scanOmrTaskService.deleteByStudentId(student.getExamId(), student.getId());
@@ -1044,10 +1047,14 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         lw.set(MarkStudent::getScanStatus, status);
         lw.set(MarkStudent::getManualAbsent, ScanStatus.MANUAL_ABSENT.equals(status));
         lw.set(MarkStudent::getAbsent, ScanStatus.MANUAL_ABSENT.equals(status));
+        lw.set(MarkStudent::getMissScan, false);
         lw.eq(MarkStudent::getId, student.getId());
         update(lw);
         markPaperService.updateAbsentCount(examId, student.getPaperNumber(),
                 this.countAbsentByExamIdAndPaperNumber(examId, student.getPaperNumber()));
+
+        // 更新考生管理中考生状态
+        this.updateBasicExamStudentStatus(student.getId());
         return AbsentManualUpdateVo.create(status);
     }
 
@@ -1074,6 +1081,8 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                 this.countUploadedByExamIdAndPaperNumber(examId, student.getPaperNumber()));
         markPaperService.updateAbsentCount(examId, student.getPaperNumber(),
                 this.countAbsentByExamIdAndPaperNumber(examId, student.getPaperNumber()));
+        // 更新考生管理状态
+        this.updateBasicExamStudentStatus(student.getId());
         return UpdateTimeVo.create();
     }
 
@@ -1862,6 +1871,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         }
     }
 
+    @Transactional
     @Override
     public Boolean missScanUpdate(Long examId, String coursePaperId, String studentCode, Boolean missScan) {
         MarkStudent student = findByExamIdAndCoursePaperIdAndStudentCode(examId, coursePaperId, studentCode);
@@ -1872,9 +1882,16 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
             throw new ParameterException("考生不是未扫描状态");
         }
         LambdaUpdateWrapper<MarkStudent> lw = new LambdaUpdateWrapper<>();
+        lw.set(MarkStudent::getScanStatus, ScanStatus.UNEXIST);
+        lw.set(MarkStudent::getManualAbsent, false);
+        lw.set(MarkStudent::getAbsent, false);
         lw.set(MarkStudent::getMissScan, missScan);
         lw.eq(MarkStudent::getId, student.getId());
-        return this.update(lw);
+        this.update(lw);
+
+        // 更新考生管理状态
+        this.updateBasicExamStudentStatus(student.getId());
+        return true;
     }
 
     @Override
@@ -1901,4 +1918,13 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         queryWrapper.lambda().eq(MarkStudent::getBasicStudentId, basicStudentId);
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public void updateBasicExamStudentStatus(Long markStudentId) {
+        MarkStudent markStudent = this.getById(markStudentId);
+        if (markStudent != null && markStudent.getBasicStudentId() != null) {
+            BasicExamStudentStatusEnum status = markStudent.getAbsent() || markStudent.getOmrAbsent() ? BasicExamStudentStatusEnum.M : BasicExamStudentStatusEnum.N;
+            this.baseMapper.updateBasicExamStudentStatus(status.name(), markStudent.getBasicStudentId());
+        }
+    }
 }

+ 1 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanPaperServiceImpl.java

@@ -184,6 +184,7 @@ public class ScanPaperServiceImpl extends ServiceImpl<ScanPaperMapper, ScanPaper
                 // 重置考生状态
                 resetStudent(previousStudent);
                 markStudentService.updateStudentAndPaper(user, previousStudent.getId(), null);
+                markStudentService.updateBasicExamStudentStatus(previousStudent.getId());
             }
             for (PaperMigratePaper vp : domain.getPapers()) {
                 ScanPaper paper = getById(vp.getPaperId());

+ 5 - 0
teachcloud-mark/src/main/resources/mapper/MarkStudentMapper.xml

@@ -217,6 +217,9 @@
             order by bes.student_code
         </if>
     </sql>
+    <update id="updateBasicExamStudentStatus">
+        update basic_exam_student set status = #{status} where id = #{basicStudentId}
+    </update>
 
     <select id="pageStudentScore" resultType="com.qmth.teachcloud.mark.dto.mark.score.StudentScoreDetailDto">
         <include refid="pageStudentScoreCommon" />
@@ -829,6 +832,8 @@
     <select id="listMarkStudentVo" resultType="com.qmth.teachcloud.mark.dto.mark.MarkStudentVo">
         SELECT
         ms.*,
+        ms.is_upload upload,
+        ms.is_absent absent,
         bes.student_name,
         bc.code courseCode,
         bc.name courseName,