xiatian 9 mēneši atpakaļ
vecāks
revīzija
3e4bcb5144

+ 111 - 0
src/main/java/cn/com/qmth/scancentral/controller/admin/CheckController.java

@@ -10,10 +10,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.task.AsyncTaskExecutor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -25,6 +27,8 @@ import org.springframework.web.multipart.MultipartFile;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.core.collection.PageResult;
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
+import com.qmth.boot.core.exception.ReentrantException;
 import com.qmth.boot.core.exception.StatusException;
 import com.qmth.boot.tools.excel.ExcelWriter;
 import com.qmth.boot.tools.excel.enums.ExcelType;
@@ -33,20 +37,32 @@ import com.qmth.boot.tools.iterator.PageListIterator;
 import com.qmth.boot.tools.iterator.SingletonIterator;
 
 import cn.com.qmth.scancentral.bean.AbsentQueryDomain;
+import cn.com.qmth.scancentral.bean.AnswerQueryDomain;
 import cn.com.qmth.scancentral.controller.BaseController;
+import cn.com.qmth.scancentral.entity.ExamEntity;
 import cn.com.qmth.scancentral.entity.SubjectEntity;
 import cn.com.qmth.scancentral.enums.ConditionType;
+import cn.com.qmth.scancentral.enums.ExamStatus;
+import cn.com.qmth.scancentral.enums.ExamStatusCheckMode;
 import cn.com.qmth.scancentral.enums.GroupType;
+import cn.com.qmth.scancentral.enums.LockType;
+import cn.com.qmth.scancentral.exception.ParameterExceptions;
 import cn.com.qmth.scancentral.model.ManualAbsentImportDTO;
+import cn.com.qmth.scancentral.service.ExamService;
 import cn.com.qmth.scancentral.service.StudentService;
 import cn.com.qmth.scancentral.service.SubjectService;
+import cn.com.qmth.scancentral.task.thread.ExamStatusImportThread;
+import cn.com.qmth.scancentral.task.thread.ExamStatusResetThread;
 import cn.com.qmth.scancentral.vo.AbsentInfoVo;
 import cn.com.qmth.scancentral.vo.AbsentManualImportVo;
 import cn.com.qmth.scancentral.vo.AbsentQueryVo;
+import cn.com.qmth.scancentral.vo.ExamStatusSaveVo;
 import cn.com.qmth.scancentral.vo.OmrConditionsVo;
 import cn.com.qmth.scancentral.vo.UpdateTimeVo;
+import cn.com.qmth.scancentral.vo.answerquery.AnswerQueryVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import net.sf.json.JSONObject;
 
 @RestController
 @Api(tags = "缺考接口")
@@ -57,6 +73,15 @@ public class CheckController extends BaseController {
     @Autowired
     private StudentService studentService;
 
+    @Resource
+    private ConcurrentService concurrentService;
+
+    @Autowired
+    private ExamService examService;
+
+    @Autowired
+    private AsyncTaskExecutor taskExecutor;
+
     @Autowired
     private SubjectService subjectService;
 
@@ -180,4 +205,90 @@ public class CheckController extends BaseController {
             @RequestParam String examNumber) {
         return studentService.absentSuspectUpdate(examId, subjectCode, examNumber, false);
     }
+
+    @ApiOperation(value = "缺考校验列表")
+    @RequestMapping(value = "exam-status/list", method = RequestMethod.POST)
+    public PageResult<AnswerQueryVo> examStatusList(@Validated AnswerQueryDomain query) {
+        return studentService.query(query);
+    }
+
+    @ApiOperation(value = "缺考校验提交")
+    @RequestMapping(value = "exam-status/save", method = RequestMethod.POST)
+    public ExamStatusSaveVo examStatusSave(@RequestParam Long id, @RequestParam ExamStatus examStatus) {
+        studentService.updateExamStatus(id, examStatus);
+        return ExamStatusSaveVo.create(examStatus);
+    }
+
+    @ApiOperation(value = "缺考校验导入")
+    @RequestMapping(value = "exam-status/import", method = RequestMethod.POST)
+    public JSONObject examStatusImportFile(@RequestParam Long examId, @RequestParam ExamStatusCheckMode mode,
+            @RequestParam MultipartFile file) throws IOException {
+        ExamEntity exam = examService.getById(examId);
+        if (exam == null) {
+            throw ParameterExceptions.EXAM_NOT_FOUND;
+        }
+
+        if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId)) {
+            taskExecutor.submit(
+                    new ExamStatusImportThread(examId, mode, file.getInputStream(), studentService, concurrentService));
+        } else {
+            throw new ReentrantException("正在导入,请稍后再试");
+        }
+        JSONObject result = new JSONObject();
+        result.put("updateTime", System.currentTimeMillis());
+        result.put("synching", true);
+        return result;
+    }
+
+    @ApiOperation(value = "缺考校验导入状态")
+    @RequestMapping(value = "exam-status/import/status", method = RequestMethod.POST)
+    public Map<String, Object> examStatusImportStatus(@RequestParam Long examId) {
+        ExamEntity exam = examService.getById(examId);
+        if (exam == null) {
+            throw ParameterExceptions.EXAM_NOT_FOUND;
+        }
+
+        Map<String, Object> result = new HashMap<String, Object>();
+        result.put("synching", concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
+        return result;
+    }
+
+    @ApiOperation(value = "缺考校验重新生成")
+    @RequestMapping(value = "exam-status/reset", method = RequestMethod.POST)
+    public JSONObject examStatusReset(@RequestParam Long examId, @RequestParam Integer examNumberFillCount) {
+        ExamEntity exam = examService.getById(examId);
+        if (exam == null) {
+            throw ParameterExceptions.EXAM_NOT_FOUND;
+        }
+
+        if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId)) {
+            taskExecutor
+                    .submit(new ExamStatusResetThread(examId, examNumberFillCount, studentService, concurrentService));
+        } else {
+            throw new ReentrantException("正在重新生成,请稍后再试");
+        }
+        JSONObject result = new JSONObject();
+        result.put("updateTime", System.currentTimeMillis());
+        result.put("synching", true);
+        return result;
+    }
+
+    @ApiOperation(value = "缺考校验重新生成状态")
+    @RequestMapping(value = "exam-status/reset/status", method = RequestMethod.POST)
+    public Map<String, Object> examStatusResetStatus(@RequestParam Long examId) {
+        ExamEntity exam = examService.getById(examId);
+        if (exam == null) {
+            throw ParameterExceptions.EXAM_NOT_FOUND;
+        }
+
+        Map<String, Object> result = new HashMap<String, Object>();
+        result.put("synching", concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
+        return result;
+    }
+
+    @ApiOperation(value = "缺考校验查询概要")
+    @RequestMapping(value = "exam-status/summary", method = RequestMethod.POST)
+    public List<String> examStatusSummary(@Validated AnswerQueryDomain query) {
+        return studentService.summary(query);
+    }
 }

+ 116 - 133
src/main/java/cn/com/qmth/scancentral/controller/admin/ExamStatusCheckController.java

@@ -1,40 +1,13 @@
 package cn.com.qmth.scancentral.controller.admin;
 
-import cn.com.qmth.scancentral.bean.AnswerQueryDomain;
-import cn.com.qmth.scancentral.bean.User;
-import cn.com.qmth.scancentral.controller.BaseController;
-import cn.com.qmth.scancentral.entity.ExamEntity;
-import cn.com.qmth.scancentral.enums.ExamStatusCheckMode;
-import cn.com.qmth.scancentral.enums.LockType;
-import cn.com.qmth.scancentral.exception.ParameterExceptions;
-import cn.com.qmth.scancentral.service.ExamService;
-import cn.com.qmth.scancentral.service.StudentService;
-import cn.com.qmth.scancentral.task.thread.ExamStatusImportThread;
-import cn.com.qmth.scancentral.task.thread.ExamStatusResetThread;
-import cn.com.qmth.scancentral.vo.ExamStatusSaveVo;
-import cn.com.qmth.scancentral.vo.answerquery.AnswerQueryVo;
-import com.qmth.boot.api.annotation.Aac;
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.boot.core.collection.PageResult;
-import com.qmth.boot.core.concurrent.service.ConcurrentService;
-import com.qmth.boot.core.exception.ReentrantException;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import net.sf.json.JSONObject;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.task.AsyncTaskExecutor;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+
+import cn.com.qmth.scancentral.controller.BaseController;
+import io.swagger.annotations.Api;
 
 @RestController
 @Api(tags = "缺考校验接口")
@@ -42,106 +15,116 @@ import java.util.Map;
 @Aac(strict = false, auth = true)
 public class ExamStatusCheckController extends BaseController {
 
-    @Autowired
-    private StudentService studentService;
-
-    @Resource
-    private ConcurrentService concurrentService;
-
-    @Autowired
-    private ExamService examService;
-
-    @Autowired
-    private AsyncTaskExecutor taskExecutor;
-
-    @ApiOperation(value = "列表")
-    @RequestMapping(value = "/list", method = RequestMethod.POST)
-    public PageResult<AnswerQueryVo> list(@Validated AnswerQueryDomain query) {
-        return studentService.query(query);
-    }
-
-    @ApiOperation(value = "提交")
-    @RequestMapping(value = "/save", method = RequestMethod.POST)
-    public ExamStatusSaveVo save(@RequestParam Long id, @RequestParam Boolean absent) {
-        studentService.updateExamStatus(id, absent);
-        return ExamStatusSaveVo.create(absent);
-    }
-
-    @ApiOperation(value = "导入")
-    @RequestMapping(value = "/import", method = RequestMethod.POST)
-    public JSONObject importFile(@RequestParam Long examId, @RequestParam ExamStatusCheckMode mode,
-            @RequestParam MultipartFile file) throws IOException {
-        User user = getAccessUser();
-        ExamEntity exam = examService.getById(examId);
-        if (exam == null) {
-            throw ParameterExceptions.EXAM_NOT_FOUND;
-        }
-
-        if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId)) {
-            taskExecutor.submit(
-                    new ExamStatusImportThread(examId, mode, file.getInputStream(), studentService, concurrentService));
-        } else {
-            throw new ReentrantException("正在导入,请稍后再试");
-        }
-        JSONObject result = new JSONObject();
-        result.put("updateTime", System.currentTimeMillis());
-        result.put("synching", true);
-        return result;
-    }
-
-    @ApiOperation(value = "导入状态")
-    @RequestMapping(value = "/import/status", method = RequestMethod.POST)
-    public Map<String, Object> importStatus(@RequestParam Long examId) {
-        User user = getAccessUser();
-        ExamEntity exam = examService.getById(examId);
-        if (exam == null) {
-            throw ParameterExceptions.EXAM_NOT_FOUND;
-        }
-
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("synching", concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
-        return result;
-    }
-
-    @ApiOperation(value = "重新生成")
-    @RequestMapping(value = "/reset", method = RequestMethod.POST)
-    public JSONObject reset(@RequestParam Long examId, @RequestParam Integer examNumberFillCount) {
-        User user = getAccessUser();
-        ExamEntity exam = examService.getById(examId);
-        if (exam == null) {
-            throw ParameterExceptions.EXAM_NOT_FOUND;
-        }
-
-        if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId)) {
-            taskExecutor
-                    .submit(new ExamStatusResetThread(examId, examNumberFillCount, studentService, concurrentService));
-        } else {
-            throw new ReentrantException("正在重新生成,请稍后再试");
-        }
-        JSONObject result = new JSONObject();
-        result.put("updateTime", System.currentTimeMillis());
-        result.put("synching", true);
-        return result;
-    }
-
-    @ApiOperation(value = "重新生成状态")
-    @RequestMapping(value = "/reset/status", method = RequestMethod.POST)
-    public Map<String, Object> resetStatus(@RequestParam Long examId) {
-        User user = getAccessUser();
-        ExamEntity exam = examService.getById(examId);
-        if (exam == null) {
-            throw ParameterExceptions.EXAM_NOT_FOUND;
-        }
-
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("synching", concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
-        return result;
-    }
-
-    @ApiOperation(value = "查询概要")
-    @RequestMapping(value = "/summary", method = RequestMethod.POST)
-    public List<String> summary(@Validated AnswerQueryDomain query) {
-        return studentService.summary(query);
-    }
+    // @Autowired
+    // private StudentService studentService;
+    //
+    // @Resource
+    // private ConcurrentService concurrentService;
+    //
+    // @Autowired
+    // private ExamService examService;
+    //
+    // @Autowired
+    // private AsyncTaskExecutor taskExecutor;
+    //
+    // @ApiOperation(value = "列表")
+    // @RequestMapping(value = "/list", method = RequestMethod.POST)
+    // public PageResult<AnswerQueryVo> list(@Validated AnswerQueryDomain query)
+    // {
+    // return studentService.query(query);
+    // }
+    //
+    // @ApiOperation(value = "提交")
+    // @RequestMapping(value = "/save", method = RequestMethod.POST)
+    // public ExamStatusSaveVo save(@RequestParam Long id, @RequestParam Boolean
+    // absent) {
+    // studentService.updateExamStatus(id, absent);
+    // return ExamStatusSaveVo.create(absent);
+    // }
+    //
+    // @ApiOperation(value = "导入")
+    // @RequestMapping(value = "/import", method = RequestMethod.POST)
+    // public JSONObject importFile(@RequestParam Long examId, @RequestParam
+    // ExamStatusCheckMode mode,
+    // @RequestParam MultipartFile file) throws IOException {
+    // User user = getAccessUser();
+    // ExamEntity exam = examService.getById(examId);
+    // if (exam == null) {
+    // throw ParameterExceptions.EXAM_NOT_FOUND;
+    // }
+    //
+    // if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" +
+    // examId)) {
+    // taskExecutor.submit(
+    // new ExamStatusImportThread(examId, mode, file.getInputStream(),
+    // studentService, concurrentService));
+    // } else {
+    // throw new ReentrantException("正在导入,请稍后再试");
+    // }
+    // JSONObject result = new JSONObject();
+    // result.put("updateTime", System.currentTimeMillis());
+    // result.put("synching", true);
+    // return result;
+    // }
+    //
+    // @ApiOperation(value = "导入状态")
+    // @RequestMapping(value = "/import/status", method = RequestMethod.POST)
+    // public Map<String, Object> importStatus(@RequestParam Long examId) {
+    // User user = getAccessUser();
+    // ExamEntity exam = examService.getById(examId);
+    // if (exam == null) {
+    // throw ParameterExceptions.EXAM_NOT_FOUND;
+    // }
+    //
+    // Map<String, Object> result = new HashMap<String, Object>();
+    // result.put("synching",
+    // concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
+    // return result;
+    // }
+    //
+    // @ApiOperation(value = "重新生成")
+    // @RequestMapping(value = "/reset", method = RequestMethod.POST)
+    // public JSONObject reset(@RequestParam Long examId, @RequestParam Integer
+    // examNumberFillCount) {
+    // User user = getAccessUser();
+    // ExamEntity exam = examService.getById(examId);
+    // if (exam == null) {
+    // throw ParameterExceptions.EXAM_NOT_FOUND;
+    // }
+    //
+    // if (!concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" +
+    // examId)) {
+    // taskExecutor
+    // .submit(new ExamStatusResetThread(examId, examNumberFillCount,
+    // studentService, concurrentService));
+    // } else {
+    // throw new ReentrantException("正在重新生成,请稍后再试");
+    // }
+    // JSONObject result = new JSONObject();
+    // result.put("updateTime", System.currentTimeMillis());
+    // result.put("synching", true);
+    // return result;
+    // }
+    //
+    // @ApiOperation(value = "重新生成状态")
+    // @RequestMapping(value = "/reset/status", method = RequestMethod.POST)
+    // public Map<String, Object> resetStatus(@RequestParam Long examId) {
+    // User user = getAccessUser();
+    // ExamEntity exam = examService.getById(examId);
+    // if (exam == null) {
+    // throw ParameterExceptions.EXAM_NOT_FOUND;
+    // }
+    //
+    // Map<String, Object> result = new HashMap<String, Object>();
+    // result.put("synching",
+    // concurrentService.isLocked(LockType.EXAM_STATUS_RESET + "-" + examId));
+    // return result;
+    // }
+    //
+    // @ApiOperation(value = "查询概要")
+    // @RequestMapping(value = "/summary", method = RequestMethod.POST)
+    // public List<String> summary(@Validated AnswerQueryDomain query) {
+    // return studentService.summary(query);
+    // }
 
 }

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

@@ -135,7 +135,7 @@ public interface StudentService extends IService<StudentEntity> {
 
     void resetExamStatus(Long examId, Integer examNumberFillCount);
 
-    void updateExamStatus(Long id, Boolean absent);
+    void updateExamStatus(Long id, ExamStatus examStatus);
 
     ImportResult importExamStatus(Long examId, ExamStatusCheckMode mode, InputStream inputStream) throws IOException;
 

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

@@ -1668,52 +1668,52 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
         // }
     }
 
-    private String getFileName(String path) {
-        if (StringUtils.isBlank(path)) {
-            throw new StatusException("文件路径有误:" + (path == null ? "" : path));
-        }
-        return path.substring(path.lastIndexOf("//") + 1);
-    }
+    // private String getFileName(String path) {
+    // if (StringUtils.isBlank(path)) {
+    // throw new StatusException("文件路径有误:" + (path == null ? "" : path));
+    // }
+    // return path.substring(path.lastIndexOf("//") + 1);
+    // }
 
-    private String getPaperType(List<String> list, StringResult sr) {
-        String pt = sr != null ? sr.getResult() : null;
-        if (StringUtils.isBlank(pt)) {
-            return "#";
-        }
-        if (OmrType.BARCODE == sr.getType()) {
-            if (CollectionUtils.isEmpty(list)) {
-                if (pt.length() > 1) {
-                    return "#";
-                }
-                pt = pt.toUpperCase();
-                int pAscii = (int) pt.charAt(0);
-                if (pAscii >= 65 && pAscii <= 90) {
-                    return pt;
-                } else {
-                    return "#";
-                }
-            } else {
-                int index = list.indexOf(pt);
-                if (index == -1) {
-                    return "#";
-                }
-                return String.valueOf((char) (index + 65));
-            }
-        } else if (OmrType.FILL_AREA == sr.getType()) {
-            if (pt.length() > 1) {
-                return "#";
-            }
-            pt = pt.toUpperCase();
-            int pAscii = (int) pt.charAt(0);
-            if (pAscii >= 65 && pAscii <= 90) {
-                return pt;
-            } else {
-                return "#";
-            }
-        } else {
-            return "#";
-        }
-    }
+    // private String getPaperType(List<String> list, StringResult sr) {
+    // String pt = sr != null ? sr.getResult() : null;
+    // if (StringUtils.isBlank(pt)) {
+    // return "#";
+    // }
+    // if (OmrType.BARCODE == sr.getType()) {
+    // if (CollectionUtils.isEmpty(list)) {
+    // if (pt.length() > 1) {
+    // return "#";
+    // }
+    // pt = pt.toUpperCase();
+    // int pAscii = (int) pt.charAt(0);
+    // if (pAscii >= 65 && pAscii <= 90) {
+    // return pt;
+    // } else {
+    // return "#";
+    // }
+    // } else {
+    // int index = list.indexOf(pt);
+    // if (index == -1) {
+    // return "#";
+    // }
+    // return String.valueOf((char) (index + 65));
+    // }
+    // } else if (OmrType.FILL_AREA == sr.getType()) {
+    // if (pt.length() > 1) {
+    // return "#";
+    // }
+    // pt = pt.toUpperCase();
+    // int pAscii = (int) pt.charAt(0);
+    // if (pAscii >= 65 && pAscii <= 90) {
+    // return pt;
+    // } else {
+    // return "#";
+    // }
+    // } else {
+    // return "#";
+    // }
+    // }
 
     @Override
     @Transactional
@@ -1761,9 +1761,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
 
     @Override
     @Transactional
-    public void updateExamStatus(Long id, Boolean absent) {
+    public void updateExamStatus(Long id, ExamStatus examStatus) {
         LambdaUpdateWrapper<StudentEntity> lw = new LambdaUpdateWrapper<>();
-        lw.set(StudentEntity::getExamStatus, absent ? ExamStatus.ABSENT : ExamStatus.OK);
+        lw.set(StudentEntity::getExamStatus, examStatus);
         lw.eq(StudentEntity::getId, id);
         this.update(lw);
     }

+ 2 - 2
src/main/java/cn/com/qmth/scancentral/vo/ExamStatusSaveVo.java

@@ -6,9 +6,9 @@ public class ExamStatusSaveVo {
 
     private ExamStatus examStatus;
 
-    public static ExamStatusSaveVo create(Boolean absent) {
+    public static ExamStatusSaveVo create(ExamStatus examStatus) {
         ExamStatusSaveVo vo = new ExamStatusSaveVo();
-        vo.setExamStatus(absent ? ExamStatus.ABSENT : ExamStatus.OK);
+        vo.setExamStatus(examStatus);
         return vo;
     }