deason 9 ヶ月 前
コミット
8faa535c57

+ 1 - 1
src/main/java/cn/com/qmth/scancentral/controller/admin/StudentImportController.java

@@ -57,7 +57,7 @@ public class StudentImportController extends BaseController {
     @ApiOperation(value = "考生清空")
     @PostMapping(value = "/clear")
     public ResultVo studentClean(@RequestParam Long examId, @RequestParam String subjectCode) {
-        // studentService.studentClean(examId);
+        studentService.studentClean(examId, subjectCode);
         return new ResultVo(System.currentTimeMillis());
     }
 

+ 5 - 5
src/main/java/cn/com/qmth/scancentral/controller/admin/ToolController.java

@@ -114,11 +114,11 @@ public class ToolController extends BaseController {
         return subjectService.findByExamIdAndCode(examId, code);
     }
 
-    @ApiOperation(value = "清空考生数据")
-    @RequestMapping(value = "/exam/student/clean", method = RequestMethod.POST)
-    public void studentClean(@RequestParam Long examId) {
-        studentService.studentClean(examId);
-    }
+    // @ApiOperation(value = "清空考生数据")
+    // @RequestMapping(value = "/exam/student/clean", method = RequestMethod.POST)
+    // public void studentClean(@RequestParam Long examId) {
+    //     studentService.studentClean(examId);
+    // }
 
     @ApiOperation(value = "cet导入违纪接口")
     @PostMapping("/import/cet/breach")

+ 3 - 0
src/main/java/cn/com/qmth/scancentral/dao/StudentDao.java

@@ -2,6 +2,7 @@ package cn.com.qmth.scancentral.dao;
 
 import java.util.List;
 
+import cn.com.qmth.scancentral.vo.studentimport.StudentCountVo;
 import org.apache.ibatis.annotations.Param;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -65,6 +66,8 @@ public interface StudentDao extends BaseMapper<StudentEntity> {
 
     int countByQuery(@Param("query") ImportStudentQueryVo query);
 
+    List<StudentCountVo> countStudent(@Param("examId")  Long examId);
+
     IPage<ImportStudentVo> listPageQuery(Page<ImportStudentVo> page, @Param("query") ImportStudentQueryVo query);
 
     List<StudentUploadVo> findToPictureCopy(@Param("pageSize") Integer pageSize);

+ 1 - 1
src/main/java/cn/com/qmth/scancentral/service/StudentService.java

@@ -115,7 +115,7 @@ public interface StudentService extends IService<StudentEntity> {
 
     Double getUploadProgress(Long examId);
 
-    void studentClean(Long examId);
+    void studentClean(Long examId, String subjectCode);
 
     AnswerRefixVo answerRefix(User user, AnswerRefixDomain domain);
 

+ 1 - 1
src/main/java/cn/com/qmth/scancentral/service/SubjectService.java

@@ -24,7 +24,7 @@ public interface SubjectService extends IMppService<SubjectEntity> {
 
     int importSubject(List<ImportSubjectDomain> subjects);
 
-    int cleanByExamId(Long examId);
+    int cleanByExamId(Long examId, String subjectCode);
 
     SubjectConfigVo config(User user, SubjectConfigDomain domain);
 

+ 14 - 8
src/main/java/cn/com/qmth/scancentral/service/impl/StudentServiceImpl.java

@@ -45,6 +45,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.gson.Gson;
@@ -921,19 +922,22 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
 
     @Transactional
     @Override
-    public void studentClean(Long examId) {
+    public void studentClean(Long examId, String subjectCode) {
         ExamEntity exam = examService.getById(examId);
         if (exam == null) {
             throw ParameterExceptions.EXAM_NOT_FOUND;
         }
+
         if (batchService.getCountByExam(examId) > 0) {
             throw new ParameterException("已开始扫描不能清空");
         }
-        QueryWrapper<StudentEntity> wrapper = new QueryWrapper<>();
-        LambdaQueryWrapper<StudentEntity> lw = wrapper.lambda();
-        lw.eq(StudentEntity::getExamId, examId);
-        this.baseMapper.delete(wrapper);
-        subjectService.cleanByExamId(examId);
+
+        LambdaQueryWrapper<StudentEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(StudentEntity::getExamId, examId);
+        wrapper.eq(StudentEntity::getSubjectCode, subjectCode);
+        baseMapper.delete(wrapper);
+
+        subjectService.cleanByExamId(examId, subjectCode);
     }
 
     @Transactional
@@ -2573,8 +2577,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
 
     @Override
     public List<StudentCountVo> countStudent(Long examId) {
-        //todo
-        return Collections.emptyList();
+        if (examId == null) {
+            throw new ParameterException("examId不能为空");
+        }
+        return baseMapper.countStudent(examId);
     }
 
 }

+ 2 - 1
src/main/java/cn/com/qmth/scancentral/service/impl/SubjectServiceImpl.java

@@ -54,10 +54,11 @@ public class SubjectServiceImpl extends MppServiceImpl<SubjectDao, SubjectEntity
 
     @Transactional
     @Override
-    public int cleanByExamId(Long examId) {
+    public int cleanByExamId(Long examId, String subjectCode) {
         QueryWrapper<SubjectEntity> wrapper = new QueryWrapper<>();
         LambdaQueryWrapper<SubjectEntity> lw = wrapper.lambda();
         lw.eq(SubjectEntity::getExamId, examId);
+        lw.eq(SubjectEntity::getCode, subjectCode);
         return this.baseMapper.delete(wrapper);
     }
 

+ 0 - 10
src/main/java/cn/com/qmth/scancentral/vo/studentimport/StudentCountVo.java

@@ -2,22 +2,12 @@ package cn.com.qmth.scancentral.vo.studentimport;
 
 public class StudentCountVo {
 
-    private Long id;
-
     private String subjectCode;
 
     private String subjectName;
 
     private Integer studentCount;
 
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
     public String getSubjectCode() {
         return subjectCode;
     }

+ 36 - 27
src/main/resources/mapper/StudentMapper.xml

@@ -129,7 +129,7 @@
           and e.enable = 1
           and (t.file_upload_status = 'WAITING_UPLOAD' or t.data_upload_status =
                                                           'WAITING_UPLOAD')
-            limit #{pageSize}
+        limit #{pageSize}
     </select>
 
     <select id="findUploadError"
@@ -142,7 +142,7 @@
           and e.enable_upload = 1
           and e.enable = 1
           and (t.file_upload_status = 'ERROR' or t.data_upload_status = 'ERROR')
-            limit #{pageSize}
+        limit #{pageSize}
     </select>
 
     <select id="getPackageCountByExam" resultType="int">
@@ -183,6 +183,14 @@
         </if>
     </select>
 
+    <select id="countStudent" resultType="cn.com.qmth.scancentral.vo.studentimport.StudentCountVo">
+        select stu.subject_code, sb.name as subjectName, count(stu.id) studentCount
+        from sc_student stu
+                 left join sc_subject sb on sb.exam_id = stu.exam_id and sb.code = stu.subject_code
+        where stu.exam_id = #{examId}
+        group by stu.subject_code
+    </select>
+
     <select id="listPageQuery"
             resultType="cn.com.qmth.scancentral.vo.ImportStudentVo">
         select
@@ -242,7 +250,7 @@
         where e.enable = 1
           and (e.image_transfer_mode = 'OW' or e.image_transfer_mode = 'CET')
           and t.file_upload_status = 'WAITING_UPLOAD'
-            limit #{pageSize}
+        limit #{pageSize}
     </select>
 
     <select id="getUploadedCount" resultType="int">
@@ -258,8 +266,8 @@
         from sc_student t
         where t.exam_id = #{examId}
           and (
-                    t.file_upload_status in ('WAITING_UPLOAD', 'ERROR') or
-                    t.data_upload_status in ('WAITING_UPLOAD', 'ERROR')
+            t.file_upload_status in ('WAITING_UPLOAD', 'ERROR') or
+            t.data_upload_status in ('WAITING_UPLOAD', 'ERROR')
             )
     </select>
 
@@ -482,7 +490,7 @@
           and t.assigned_check_count = #{checkCount}
           and t.assigned = 1
         order by t.id
-            limit #{pageNumber}, #{pageSize}
+        limit #{pageNumber}, #{pageSize}
     </select>
 
 
@@ -502,7 +510,8 @@
                           where student_id = #{id}
                             and user_id = #{userId}
                             and exam_id = #{examId})
-        order by h.id desc limit #{pageSize}
+        order by h.id desc
+        limit #{pageSize}
     </select>
 
     <update id="updateAssignedCheckCount">
@@ -513,22 +522,22 @@
         WHERE id = #{id}
     </update>
     <select id="scanProgress" resultType="cn.com.qmth.scancentral.vo.subject.SubjectScanProgressVo">
-    	select t.subject_code,t.subject_name,
-    	sum(case when t.status='UNEXIST' then 1 else 0 end) unexistCount,
-    	count(1) studentCount
-    	from sc_student t
-    	where t.exam_id=#{examId}
+        select t.subject_code,t.subject_name,
+        sum(case when t.status='UNEXIST' then 1 else 0 end) unexistCount,
+        count(1) studentCount
+        from sc_student t
+        where t.exam_id=#{examId}
         <if test="subjectCode != null and subjectCode !=''">
             and t.subject_code=#{subjectCode}
         </if>
         group by t.subject_code
     </select>
     <select id="examRoomScannedPage" resultType="cn.com.qmth.scancentral.vo.examroom.ExamRoomScannedVo">
-    	select tm.* from(
-    	select t.subject_code,s.name subjectName,t.campus_code,t.exam_site,t.exam_room,
-    	sum(case when t.status='SCANNED' then 1 else 0 end) scannedCount
-    	from sc_student t inner join sc_subject s on t.exam_id=s.exam_id and t.subject_code=s.code
-    	where t.exam_id=#{req.examId}
+        select tm.* from(
+        select t.subject_code,s.name subjectName,t.campus_code,t.exam_site,t.exam_room,
+        sum(case when t.status='SCANNED' then 1 else 0 end) scannedCount
+        from sc_student t inner join sc_subject s on t.exam_id=s.exam_id and t.subject_code=s.code
+        where t.exam_id=#{req.examId}
         <if test="req.campusCode != null and req.campusCode !=''">
             and t.campus_code=#{req.campusCode}
         </if>
@@ -548,19 +557,19 @@
         ) tm
         where 1=1
         <if test="req.scanned != null">
-           <if test="req.scanned">
-           	and tm.scannedCount>0
-           </if>
-           <if test="!req.scanned">
-           	and tm.scannedCount=0
-           </if>
+            <if test="req.scanned">
+                and tm.scannedCount>0
+            </if>
+            <if test="!req.scanned">
+                and tm.scannedCount=0
+            </if>
         </if>
         order by tm.subject_code,tm.subjectName,tm.campus_code,tm.exam_site,tm.exam_room
     </select>
     <select id="studentPage" resultType="cn.com.qmth.scancentral.vo.student.StudentPageVo">
-    	select t.* 
-    	from sc_student t 
-    	where t.exam_id=#{req.examId}
+        select t.*
+        from sc_student t
+        where t.exam_id=#{req.examId}
         <if test="req.campusCode != null and req.campusCode !=''">
             and t.campus_code=#{req.campusCode}
         </if>
@@ -608,5 +617,5 @@
         ) tm
         order by tm.exam_site,tm.exam_room
     </select>
-    
+
 </mapper>