xiaof 4 سال پیش
والد
کامیت
e12e15f36c

+ 53 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ClientPrintBackupDataDto.java

@@ -0,0 +1,53 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+/**
+ * @Date: 2021/3/31.
+ */
+public class ClientPrintBackupDataDto {
+
+    private String courseCode;
+    private String courseName;
+    private String paperNumber;
+    private String paperType;
+    private String url;
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+}

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

@@ -2,6 +2,9 @@ package com.qmth.distributed.print.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.distributed.print.business.entity.ClientStatus;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +15,4 @@ import com.qmth.distributed.print.business.entity.ClientStatus;
  * @since 2021-04-19
  */
 public interface ClientStatusMapper extends BaseMapper<ClientStatus> {
-
 }

+ 1 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskDetailMapper.java

@@ -25,4 +25,5 @@ public interface ExamTaskDetailMapper extends BaseMapper<ExamTaskDetail> {
     List<ExamTaskDetail> listByTemplateId(Long templateId);
 
     List<Map<String, String>> listByExamDetailId(@Param("schoolId") Long schoolId, @Param("examDetailId") Long examDetailId);
+
 }

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

@@ -5,7 +5,6 @@ import com.qmth.distributed.print.business.bean.dto.ClientExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.ClientExamTaskDto;
 import com.qmth.distributed.print.business.bean.dto.ClientPrintTaskDto;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,4 +24,6 @@ public interface ClientService {
     Map<String, Object> getReprintData(Long schoolId, Long examDetailId, String ticketNumber, String type);
 
     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);
+
+    Map<String, Object> getPrintData(Long schoolId, Long examDetailId, String machineCode, Boolean isForceTry, String printUser);
 }

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientStatusService.java

@@ -3,6 +3,8 @@ package com.qmth.distributed.print.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.entity.ClientStatus;
 
+import java.util.List;
+
 /**
  * <p>
  * 客户端下载状态 服务类
@@ -13,4 +15,5 @@ import com.qmth.distributed.print.business.entity.ClientStatus;
  */
 public interface ClientStatusService extends IService<ClientStatus> {
     Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId);
+
 }

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

@@ -37,4 +37,5 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
     String getUrl(Long schoolId, Long examTaskId);
 
     List<Map<String, String>> listByExamDetailId(Long schoolId, Long examDetailId);
+
 }

+ 156 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -1,16 +1,14 @@
 package com.qmth.distributed.print.business.service.impl;
 
 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.qmth.distributed.print.business.bean.dto.ClientExamStudentDto;
-import com.qmth.distributed.print.business.bean.dto.ClientExamTaskDto;
-import com.qmth.distributed.print.business.bean.dto.ClientPrintDataDto;
-import com.qmth.distributed.print.business.bean.dto.ClientPrintTaskDto;
-import com.qmth.distributed.print.business.entity.BasicAttachment;
-import com.qmth.distributed.print.business.entity.ExamDetail;
-import com.qmth.distributed.print.business.entity.ExamPrintPlan;
+import com.qmth.distributed.print.business.bean.dto.*;
+import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.service.*;
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -35,6 +33,9 @@ public class ClientServiceImpl implements ClientService {
     @Autowired
     private ExamDetailService examDetailService;
 
+    @Autowired
+    private ExamDetailCourseService examDetailCourseService;
+
     @Autowired
     private BasicAttachmentService basicAttachmentService;
 
@@ -69,6 +70,7 @@ public class ClientServiceImpl implements ClientService {
         return examDetailService.listStudent(schoolId, examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
     }
 
+
     @Override
     public Map<String, Object> getReprintData(Long schoolId, Long examDetailId, String ticketNumber, String type) {
         Map<String, Object> finalMap = new HashMap<>();
@@ -152,6 +154,153 @@ public class ClientServiceImpl implements ClientService {
         return pirntTaskDtoIPage;
     }
 
+    @Override
+    public Map<String, Object> getPrintData(Long schoolId, Long examDetailId, String machineCode, Boolean isForceTry, String printUser) {
+        // 1.校验是否打样
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
+        if(isForceTry){
+            for (ExamDetailCourse examDetailCours : examDetailCourses) {
+                QueryWrapper<ClientStatus> queryWrapper = new QueryWrapper<>();
+                queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId)
+                        .eq(ClientStatus::getCourseCode, examDetailCours.getCourseCode())
+                        .eq(ClientStatus::getPaperNumber, examDetailCours.getPaperNumber())
+                        .eq(ClientStatus::getMachineCode, machineCode);
+                ClientStatus clientStatuse = clientStatusService.getOne(queryWrapper);
+                if(clientStatuse == null){
+                    throw ExceptionResultEnum.ERROR.exception("该机器没有打样");
+                } else {
+                    if (!clientStatuse.getPass()) {
+                        throw ExceptionResultEnum.ERROR.exception("该机器打样不合格");
+                    }
+                }
+            }
+        }
+
+        Map<String, Object> finalMap = new HashMap<>();
+        // 2.取生成的完整的pdf
+        ExamDetail examDetail = examDetailService.getById(examDetailId);
+        if(examDetail.getAttachmentId() == null) {
+            throw ExceptionResultEnum.ERROR.exception("考场pdf未生成");
+        }
+
+        BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
+        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)) {
+            throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
+        }
+
+        finalMap.put("total", totalPathUrl);
+
+        // 3.取学生试卷、题卡、备用试卷、题卡,印品
+        Map<String, Object> detailMap = new HashMap<>();
+        // 3.1取试卷
+        Map<String, String> map = mapCourseUrl(schoolId, examDetailId);
+        // 3.2取考生
+        List<Map<String, String>> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
+        // 3.3生成试卷List
+        List<ClientPrintDataDto> paperList = studentList.stream().map(m -> {
+            ClientPrintDataDto printDataDto = new ClientPrintDataDto();
+            String courseCode = m.get("courseCode");
+            String courseName = m.get("courseName");
+            String paperNumber = m.get("paperNumber");
+            String studentName = m.get("studentName");
+            String studentCode = m.get("studentCode");
+            String paperType = m.get("paperType");
+            printDataDto.setCourseCode(courseCode);
+            printDataDto.setCourseName(courseName);
+            printDataDto.setStudentName(studentName);
+            printDataDto.setStudentCode(studentCode);
+            printDataDto.setPaperType(paperType);
+
+            StringJoiner sj = new StringJoiner(":");
+            String key = sj.add(courseCode).add(paperNumber).add(paperType).toString();
+            printDataDto.setUrl(map.get(key));
+            return printDataDto;
+        }).collect(Collectors.toList());
+        detailMap.put("paper", paperList);
+        // 3.4生成题卡List
+        List<ClientPrintDataDto> cardList = studentList.stream().map(m -> {
+            ClientPrintDataDto printDataDto = new ClientPrintDataDto();
+            String courseCode = m.get("courseCode");
+            String courseName = m.get("courseName");
+            String studentName = m.get("studentName");
+            String studentCode = m.get("studentCode");
+            String paperType = m.get("paperType");
+            String attachmentId = m.get("attachmentId");
+            printDataDto.setCourseCode(courseCode);
+            printDataDto.setCourseName(courseName);
+            printDataDto.setStudentName(studentName);
+            printDataDto.setStudentCode(studentCode);
+            printDataDto.setPaperType(paperType);
+            Map<String, String> urlMap = commonService.filePreview(attachmentId, false);
+            printDataDto.setUrl(urlMap.get("pathUrl"));
+            return printDataDto;
+        }).collect(Collectors.toList());
+        detailMap.put("card", cardList);
+
+        //3.4备用试卷、题卡
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
+        Map<String, Object> backupMap = new HashMap<>();
+        int backupCount = examPrintPlan.getBackupCount().intValue();
+        //试卷
+        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"));
+            stringMap.put("paperNumber", m.get("paperNumber"));
+            stringMap.put("paperType", m.get("paperType"));
+            return stringMap;
+        }).distinct().collect(Collectors.toList());
+        List<ClientPrintBackupDataDto> paperBackupList = new ArrayList<>();
+        for (Map<String, String> keyMap : keyMaps) {
+            for (int i = 0; i < backupCount; i++) {
+                ClientPrintBackupDataDto clientPrintBackupDataDto = new ClientPrintBackupDataDto();
+                clientPrintBackupDataDto.setCourseCode(keyMap.get("courseCode"));
+                clientPrintBackupDataDto.setCourseName(keyMap.get("courseName"));
+                clientPrintBackupDataDto.setPaperNumber(keyMap.get("paperNumber"));
+                clientPrintBackupDataDto.setPaperType(keyMap.get("paperType"));
+                StringJoiner sj = new StringJoiner(":");
+                String key = sj.add(keyMap.get("courseCode")).add(keyMap.get("paperNumber")).add(keyMap.get("paperType")).toString();
+                clientPrintBackupDataDto.setUrl(map.get(key));
+                paperBackupList.add(clientPrintBackupDataDto);
+            }
+        }
+
+        backupMap.put("paper", paperBackupList);
+
+        // todo 备用题卡
+
+        //3.5
+        String variableContent = examPrintPlan.getVariableContent();
+        String ordinaryContent = examPrintPlan.getOrdinaryContent();
+        List<Map> variableList = JSONObject.parseArray(variableContent, Map.class);
+        List<Map> otherList = new ArrayList<>();
+        for (Map variable : variableList) {
+            Map vMap = new HashMap();
+            vMap.put("type", variable.get("type"));
+            Map<String, String> urlMap = commonService.filePreview(variable.get("attachmentId").toString(), false);
+            vMap.put("htmlUrl", urlMap.get("htmlUrl"));
+            vMap.put("pdfUrl", urlMap.get("pdfUrl"));
+            otherList.add(vMap);
+        }
+        List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
+        for (Map ordinary : ordinaryList) {
+            Map vMap = new HashMap();
+            vMap.put("type", ordinary.get("type"));
+            Map<String, String> urlMap = commonService.filePreview(ordinary.get("attachmentId").toString(), false);
+            vMap.put("htmlUrl", urlMap.get("htmlUrl"));
+            vMap.put("pdfUrl", urlMap.get("pdfUrl"));
+            otherList.add(vMap);
+        }
+        finalMap.put("other", otherList);
+        return finalMap;
+    }
+
     /**
      * 根据考场生成试卷map
      *

+ 23 - 0
distributed-print-business/src/main/resources/mapper/ClientStatusMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.qmth.distributed.print.business.mapper.ClientStatusMapper">
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.ClientStatus">
+        <result column="id" property="id"/>
+        <result column="school_id" property="schoolId"/>
+        <result column="machine_code" property="machineCode"/>
+        <result column="exam_task_id" property="examTaskId"/>
+        <result column="course_code" property="courseCode"/>
+        <result column="course_name" property="courseName"/>
+        <result column="paper_number" property="paperNumber"/>
+        <result column="is_try" property="isTry"/>
+        <result column="try_time" property="tryTime"/>
+        <result column="is_pass" property="isPass"/>
+        <result column="is_download" property="isDownload"/>
+        <result column="create_id" property="createId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_id" property="updateId"/>
+        <result column="update_time" property="updateTime"/>
+    </resultMap>
+
+</mapper>

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

@@ -211,21 +211,21 @@ public class ClientController {
      * 印刷管理-印刷/缓存数据
      *
      * @param schoolId
-     * @param orgId
      * @param examDetailId
      * @param machineCode
+     * @param isForceTry
      * @param printUser
      * @return
      */
     @ApiOperation(value = "印刷管理-印刷/缓存数据")
     @RequestMapping(value = "/print/get_print_data", method = RequestMethod.POST)
     public Result printGetPrintData(@RequestParam("schoolId") Long schoolId,
-                                    @RequestParam("orgId") Long orgId,
                                     @RequestParam("examDetailId") Long examDetailId,
                                     @RequestParam("machineCode") String machineCode,
-                                    @RequestParam("printUser") String printUser) {
-
-        return null;
+                                    @RequestParam("isForceTry") Boolean isForceTry,
+                                    @RequestParam(value = "printUser", required = false) String printUser) {
+        Map<String, Object> map = clientService.getPrintData(schoolId, examDetailId, machineCode, isForceTry, printUser);
+        return ResultUtil.ok(map);
     }
 
     /**