Browse Source

bug修改

xiaof 4 years ago
parent
commit
a3c3b9bf58

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

@@ -16,7 +16,7 @@ public interface ClientService {
 
     String getUrl(Long schoolId, Long examTaskId);
 
-    Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId);
+    Boolean tagPass(Long schoolId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
 
     Boolean updatePrintProgress(Long schoolId, Long examDetailId, Integer printProgress);
 
@@ -29,4 +29,10 @@ public interface ClientService {
     Map<String, Object> getPrintData(Long schoolId, Long examDetailId, String machineCode, String printUser);
 
     List<Map<String, Object>> getPrintDataBatch(Long schoolId, Long machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate);
+
+    String getUrlByExamDetailId(Long schoolId, Long examDetailId);
+
+    Boolean updateDownload(Long schoolId, Long examDetailId, String machineCode, Boolean isDownload);
+
+    Boolean validateData(Long schoolId, Long examDetailId, String packageCode, String lastCode);
 }

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

@@ -14,6 +14,5 @@ import java.util.List;
  * @since 2021-04-19
  */
 public interface ClientStatusService extends IService<ClientStatus> {
-    Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId);
-
+    Boolean tagPass(Long schoolId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
 }

+ 108 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.gson.JsonObject;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.service.*;
@@ -47,6 +46,9 @@ public class ClientServiceImpl implements ClientService {
     @Autowired
     private ExamPrintPlanService examPrintPlanService;
 
+    @Autowired
+    private ExamCardDetailService examCardDetailService;
+
     @Override
     public IPage<ClientExamTaskDto> listTryTask(Long schoolId, String machineCode, Long orgId, Long printPlanId, String courseCode, String paperNumber, Boolean isTry, Boolean isPass, Integer pageNumber, Integer pageSize) {
         return examTaskService.listTryTask(schoolId, machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass, pageNumber, pageSize);
@@ -58,8 +60,8 @@ public class ClientServiceImpl implements ClientService {
     }
 
     @Override
-    public Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId) {
-        return clientStatusService.tagPass(schoolId, examTaskId, machineCode, isPass, userId);
+    public Boolean tagPass(Long schoolId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
+        return clientStatusService.tagPass(schoolId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
     }
 
     @Override
@@ -153,7 +155,7 @@ public class ClientServiceImpl implements ClientService {
     public IPage<ClientPrintTaskDto> listClientPrintTask(Long schoolId, Long machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate, Integer pageNumber, Integer pageSize) {
         Set<Long> orgIds = commonService.listSubOrgIds(null);
         Page<ClientPrintTaskDto> page = new Page<>(pageNumber, pageSize);
-        IPage<ClientPrintTaskDto> pirntTaskDtoIPage = examPrintPlanService.listClientPrintTask(page, schoolId,machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime,isDownload,validate, orgIds);
+        IPage<ClientPrintTaskDto> pirntTaskDtoIPage = examPrintPlanService.listClientPrintTask(page, schoolId, machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, orgIds);
         return pirntTaskDtoIPage;
     }
 
@@ -163,18 +165,18 @@ public class ClientServiceImpl implements ClientService {
         Map<String, Object> finalMap = new HashMap<>();
         // 2.取生成的完整的pdf
         ExamDetail examDetail = examDetailService.getById(examDetailId);
-        if(examDetail.getAttachmentId() == null) {
+        if (examDetail.getAttachmentId() == null) {
             throw ExceptionResultEnum.ERROR.exception("考场pdf未生成");
         }
 
         BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
-        if(attachment == null){
+        if (attachment == null) {
             throw ExceptionResultEnum.ERROR.exception("考场pdf文件记录异常");
         }
 
         Map<String, String> attachMap = commonService.filePreview(examDetail.getAttachmentId().toString(), false);
         String totalPathUrl = attachMap.get("pathUrl");
-        if(StringUtils.isNotBlank(totalPathUrl)) {
+        if (StringUtils.isNotBlank(totalPathUrl)) {
             throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
         }
 
@@ -232,7 +234,7 @@ public class ClientServiceImpl implements ClientService {
         Map<String, Object> backupMap = new HashMap<>();
         int backupCount = examPrintPlan.getBackupCount().intValue();
         //试卷
-        List<Map<String, String>> keyMaps = studentList.stream().map(m->{
+        List<Map<String, String>> keyMaps = studentList.stream().map(m -> {
             Map<String, String> stringMap = new HashMap<>();
             stringMap.put("courseCode", m.get("courseCode"));
             stringMap.put("courseName", m.get("courseName"));
@@ -312,7 +314,7 @@ public class ClientServiceImpl implements ClientService {
     @Override
     public List<Map<String, Object>> getPrintDataBatch(Long schoolId, Long machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate) {
         Set<Long> orgIds = commonService.listSubOrgIds(null);
-        List<ClientPrintTaskDto> pirntTaskDtoList = examPrintPlanService.listClientPrintTask(schoolId,machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime,isDownload,validate, orgIds);
+        List<ClientPrintTaskDto> pirntTaskDtoList = examPrintPlanService.listClientPrintTask(schoolId, machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, orgIds);
         List<Map<String, Object>> finalList = new ArrayList<>();
         for (ClientPrintTaskDto clientPrintTaskDto : pirntTaskDtoList) {
             Map<String, Object> map = getPrintData(schoolId, Long.valueOf(clientPrintTaskDto.getExamDetailId()), null, null);
@@ -321,6 +323,103 @@ public class ClientServiceImpl implements ClientService {
         return finalList;
     }
 
+    @Override
+    public String getUrlByExamDetailId(Long schoolId, Long examDetailId) {
+        ExamDetail examDetail = examDetailService.getById(examDetailId);
+        BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
+        return attachment == null ? null : commonService.filePreview(attachment.getPath());
+    }
+
+    @Override
+    public Boolean updateDownload(Long schoolId, Long examDetailId, String machineCode, Boolean isDownload) {
+        QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
+        examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getSchoolId, schoolId).eq(ExamDetailCourse::getExamDetailId, examDetailId);
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.list(examDetailCourseQueryWrapper);
+        for (ExamDetailCourse examDetailCours : examDetailCourses) {
+            QueryWrapper<ClientStatus> clientStatusQueryWrapper = new QueryWrapper<>();
+            clientStatusQueryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId).eq(ClientStatus::getCourseCode, examDetailCours.getCourseCode()).eq(ClientStatus::getPaperNumber, examDetailCours.getPaperNumber()).eq(ClientStatus::getMachineCode, machineCode);
+            ClientStatus clientStatus = clientStatusService.getOne(clientStatusQueryWrapper);
+            if (clientStatus == null) {
+                clientStatus = new ClientStatus();
+                clientStatus.setId(SystemConstant.getDbUuid());
+                clientStatus.setSchoolId(schoolId);
+                clientStatus.setMachineCode(machineCode);
+                clientStatus.setCourseCode(examDetailCours.getCourseCode());
+                clientStatus.setCourseName(examDetailCours.getCourseName());
+                clientStatus.setPaperNumber(examDetailCours.getPaperNumber());
+                clientStatus.setTry(false);
+                clientStatus.setPass(false);
+                clientStatus.setDownload(isDownload);
+                clientStatusService.save(clientStatus);
+            } else {
+                clientStatus.setDownload(isDownload);
+                clientStatusService.updateById(clientStatus);
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public Boolean validateData(Long schoolId, Long examDetailId, String packageCode, String lastCode) {
+        ExamDetail examDetail = examDetailService.getById(examDetailId);
+        if (examDetail == null) {
+            throw ExceptionResultEnum.ERROR.exception("考场数据有误");
+        }
+        if (StringUtils.isBlank(packageCode)) {
+            throw ExceptionResultEnum.ERROR.exception("卷袋编号不能为空");
+        }
+        if (!packageCode.equals(examDetail.getPackageCode())) {
+            throw ExceptionResultEnum.ERROR.exception("卷袋编号与系统数据不一致");
+        }
+        // 取最后一张备卡
+        QueryWrapper<ExamDetailCourse> courseQueryWrapper = new QueryWrapper<>();
+        courseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetailId).orderByDesc(ExamDetailCourse::getPaperNumber);
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.list(courseQueryWrapper);
+        if (examDetailCourses.isEmpty()) {
+            throw ExceptionResultEnum.ERROR.exception("考场下课程数据异常");
+        }
+        ExamDetailCourse examDetailCourse = examDetailCourses.get(0);
+
+        QueryWrapper<ExamTask> taskQueryWrapper = new QueryWrapper<>();
+        taskQueryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode()).eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber());
+        ExamTask examTask = examTaskService.getOne(taskQueryWrapper);
+        if (examTask == null) {
+            throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
+        }
+
+        QueryWrapper<ExamTaskDetail> taskDetailQueryWrapper = new QueryWrapper<>();
+        taskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTask.getId());
+        ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(taskDetailQueryWrapper);
+        if (examTaskDetail == null) {
+            throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
+        }
+        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examTaskDetail.getCardId());
+        if (examCardDetail == null) {
+            throw ExceptionResultEnum.ERROR.exception("题卡数据异常");
+        }
+        String attachmentIds = examCardDetail.getAttachmentId();
+        if (StringUtils.isBlank(attachmentIds)) {
+            throw ExceptionResultEnum.ERROR.exception("备卡数据异常");
+        }
+        JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
+        String backupAttachmentIds = JSONObject.toJSONString(jsonObject.get("card"));
+        List<Map> list = JSONObject.parseArray(backupAttachmentIds, Map.class);
+        Map map = list.get(list.size() - 1);
+        String backupPackageCode = map.get("packageCode").toString();
+        if (StringUtils.isBlank(lastCode)) {
+            throw ExceptionResultEnum.ERROR.exception("最后一张备卡数据异常");
+        }
+        if (!lastCode.equals(backupPackageCode)) {
+            throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与系统数据不一致");
+        }
+
+        String lastCodeSub = lastCode.substring(0, lastCode.length() - 2);
+        if (packageCode.equals(lastCodeSub)) {
+            throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与试卷编号不一致");
+        }
+        return true;
+    }
+
     /**
      * 根据考场生成试卷map
      *

+ 5 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientStatusServiceImpl.java

@@ -3,7 +3,6 @@ package com.qmth.distributed.print.business.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.entity.ClientStatus;
-import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.mapper.ClientStatusMapper;
 import com.qmth.distributed.print.business.service.ClientStatusService;
 import com.qmth.distributed.print.business.service.ExamTaskService;
@@ -21,9 +20,9 @@ public class ClientStatusServiceImpl extends ServiceImpl<ClientStatusMapper, Cli
     private ExamTaskService examTaskService;
 
     @Override
-    public Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId) {
+    public Boolean tagPass(Long schoolId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
         QueryWrapper<ClientStatus> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId).eq(ClientStatus::getExamTaskId, examTaskId).eq(ClientStatus::getMachineCode, machineCode);
+        queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId).eq(ClientStatus::getCourseCode, courseCode).eq(ClientStatus::getPaperNumber, paperNumber).eq(ClientStatus::getMachineCode, machineCode);
         ClientStatus clientStatus = this.getOne(queryWrapper);
         if(clientStatus != null){
             clientStatus.setPass(isPass);
@@ -35,10 +34,9 @@ public class ClientStatusServiceImpl extends ServiceImpl<ClientStatusMapper, Cli
             clientStatus.setId(SystemConstant.getDbUuid());
             clientStatus.setSchoolId(schoolId);
             clientStatus.setMachineCode(machineCode);
-            ExamTask examTask = examTaskService.getById(examTaskId);
-            clientStatus.setExamTaskId(examTaskId);
-            clientStatus.setCourseCode(examTask.getCourseCode());
-            clientStatus.setCourseName(examTask.getCourseName());
+            clientStatus.setCourseCode(courseCode);
+            clientStatus.setCourseName(courseName);
+            clientStatus.setPaperNumber(paperNumber);
             clientStatus.setTry(true);
             clientStatus.setTryTime(System.currentTimeMillis());
             clientStatus.setPass(isPass);

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

@@ -470,7 +470,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Set<Long> orgIds = commonService.listSubOrgIds(null);
         Page<ExamTaskDto> page = new Page<>(pageNumber, pageSize);
-        String[] strings = new String[]{ExamStatusEnum.NEW.name(), ExamStatusEnum.SUBMIT.name()};
+        String[] strings = new String[]{ExamStatusEnum.NEW.name()};
         IPage<ExamTaskDto> examTaskDtoIPage = this.baseMapper.listTaskApply(page, schoolId, auditStatus, reviewStatus, cardRuleId, courseCode, paperNumber, startTime, endTime, strings, sysUser.getId(), orgIds);
         return examTaskDtoIPage;
     }

+ 1 - 0
distributed-print-business/src/main/resources/mapper/SysUserMapper.xml

@@ -68,6 +68,7 @@
                 LEFT JOIN
             basic_course e ON d.course_id = e.id
         <where>
+            and a.enable = true
             <if test="schoolId != null and schoolId != ''">
                 and a.school_id = #{schoolId}
             </if>

+ 28 - 14
distributed-print/src/main/java/com/qmth/distributed/print/api/ClientController.java

@@ -87,7 +87,7 @@ public class ClientController {
     public Result paperTryPrint(@RequestParam("schoolId") Long schoolId,
                                 @RequestParam("examTaskId") Long examTaskId) {
         String url = clientService.getUrl(schoolId, examTaskId);
-        return ResultUtil.ok(url);
+        return ResultUtil.ok(url, "");
     }
 
     /**
@@ -103,11 +103,13 @@ public class ClientController {
     @ApiOperation(value = "试卷打样-标记合格状态")
     @RequestMapping(value = "/paper_try/tag_pass", method = RequestMethod.POST)
     public Result paperTryTagPass(@RequestParam("schoolId") Long schoolId,
-                                  @RequestParam("examTaskId") Long examTaskId,
+                                  @RequestParam("courseCode") String courseCode,
+                                  @RequestParam("courseName") String courseName,
+                                  @RequestParam("paperNumber") String paperNumber,
                                   @RequestParam("machineCode") String machineCode,
                                   @RequestParam("isPass") Boolean isPass,
                                   @RequestParam("userId") Long userId) {
-        Boolean isSuccess = clientService.tagPass(schoolId, examTaskId, machineCode, isPass, userId);
+        Boolean isSuccess = clientService.tagPass(schoolId, courseCode,courseName, paperNumber, machineCode, isPass, userId);
         return ResultUtil.ok(isSuccess);
     }
 
@@ -194,17 +196,15 @@ public class ClientController {
      * 印刷管理-查看
      *
      * @param schoolId
-     * @param orgId
      * @param examDetailId
      * @return
      */
     @ApiOperation(value = "印刷管理-查看")
     @RequestMapping(value = "/print/preview", method = RequestMethod.POST)
     public Result printPreview(@RequestParam("schoolId") Long schoolId,
-                               @RequestParam("orgId") Long orgId,
                                @RequestParam("examDetailId") Long examDetailId) {
-
-        return null;
+        String url = clientService.getUrlByExamDetailId(schoolId, examDetailId);
+        return ResultUtil.ok(url,"");
     }
 
     /**
@@ -254,26 +254,40 @@ public class ClientController {
     }
 
     /**
-     * 印刷管理-校验
      *
      * @param schoolId
-     * @param orgId
      * @param examDetailId
      * @param machineCode
+     * @param isDownload
+     * @return
+     */
+    @ApiOperation(value = "印刷管理-缓存后更新状态")
+    @RequestMapping(value = "/print/update_download", method = RequestMethod.POST)
+    public Result updateDownload(@RequestParam("schoolId") Long schoolId,
+                                    @RequestParam("examDetailId") Long examDetailId,
+                                    @RequestParam("machineCode") String machineCode,
+                                    @RequestParam("isDownload") Boolean isDownload) {
+        Boolean isSuccess = clientService.updateDownload(schoolId, examDetailId, machineCode, isDownload);
+        return ResultUtil.ok(isSuccess);
+    }
+
+    /**
+     * 印刷管理-校验
+     *
+     * @param schoolId
+     * @param examDetailId
      * @param packageCode
      * @param lastCode
      * @return
      */
     @ApiOperation(value = "印刷管理-校验")
-    @RequestMapping(value = "/print/data_check", method = RequestMethod.POST)
+    @RequestMapping(value = "/print/validate_data", method = RequestMethod.POST)
     public Result dataCheck(@RequestParam("schoolId") Long schoolId,
-                            @RequestParam("orgId") Long orgId,
                             @RequestParam("examDetailId") Long examDetailId,
-                            @RequestParam("machineCode") String machineCode,
                             @RequestParam("packageCode") String packageCode,
                             @RequestParam("lastCode") String lastCode) {
-
-        return null;
+        Boolean isSuccess = clientService.validateData(schoolId, examDetailId, packageCode, lastCode);
+        return ResultUtil.ok(isSuccess);
     }
 
     /**