浏览代码

印刷任务管理

xiaof 4 年之前
父节点
当前提交
4defdd89f8

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

@@ -39,5 +39,5 @@ public interface ClientService {
 
     List<Map<String, String>> getBatchUrl(Long schoolId, String machineCode, Long orgId, Long printPlanId, String courseCode, String paperNumber, Boolean isTry, Boolean isPass);
 
-    List<ClientPrintTaskDto> listClientPrintTask(HttpServletResponse response, 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);
+    void exportClientPrintTask(HttpServletResponse response, 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) throws Exception;
 }

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

@@ -105,7 +105,7 @@ public interface CommonService {
      * @param path
      * @return
      */
-    public String filePreviewByPath(String path, Boolean isExpire);
+    public String filePreviewByPathAndType(String path, String type, Boolean isExpire);
 
     /**
      * 文件预览

+ 84 - 46
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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.business.util.ExcelUtil;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import org.apache.commons.lang3.StringUtils;
@@ -134,24 +135,43 @@ public class ClientServiceImpl implements ClientService {
         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"));
-            // todo
-            /*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"));
-            // todo
-            /*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);
+        //印品附件信息
+        String attachmentPath = examDetail.getAttachmentPath();
+        if (StringUtils.isNotBlank(attachmentPath)) {
+            JSONObject jsonObject = JSONObject.parseObject(attachmentPath);
+            String pathString = jsonObject.getString("path");
+            List<Map> pathList = JSONObject.parseArray(pathString, Map.class);
+            if(!pathList.isEmpty()) {
+                for (Map variable : variableList) {
+                    Map vMap = new HashMap();
+                    vMap.put("type", variable.get("type"));
+                    for (Map path : pathList) {
+                        String printType = path.get("printType").toString();
+                        if(printType.equals(variable.get("type").toString())){
+                            vMap.put("htmlUrl", commonService.filePreviewByPathAndType(path.get("htmlPath").toString(), path.get("type").toString(), false));
+                            vMap.put("htmlMd5", path.get("htmlMd5"));
+                            vMap.put("pdfUrl", commonService.filePreviewByPathAndType(path.get("pdfPath").toString(), path.get("type").toString(), false));
+                            vMap.put("pdfMd5", path.get("pdfMd5"));
+                        }
+                    }
+                    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"));
+                    for (Map path : pathList) {
+                        String printType = path.get("printType").toString();
+                        if(printType.equals(ordinary.get("type").toString())){
+                            vMap.put("htmlUrl", commonService.filePreviewByPathAndType(path.get("htmlPath").toString(), path.get("type").toString(), false));
+                            vMap.put("htmlMd5", path.get("htmlMd5"));
+                            vMap.put("pdfUrl", commonService.filePreviewByPathAndType(path.get("pdfPath").toString(), path.get("type").toString(), false));
+                            vMap.put("pdfMd5", path.get("pdfMd5"));
+                        }
+                    }
+                    otherList.add(vMap);
+                }
+            }
         }
         finalMap.put("other", otherList);
         return finalMap;
@@ -294,32 +314,51 @@ public class ClientServiceImpl implements ClientService {
         String ordinaryContent = examPrintPlan.getOrdinaryContent();
         List<Map> variableList = JSONObject.parseArray(variableContent, Map.class);
         List<Map> otherList = new ArrayList<>();
-        for (Map variable : variableList) {
-            int count = Integer.parseInt(variable.get("backupCount").toString());
-            for (int i = 0; i < count; i++) {
-                Map vMap = new HashMap();
-                vMap.put("type", variable.get("type"));
-                // todo
-                /*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);
+        //印品附件信息
+        String attachmentPath = examDetail.getAttachmentPath();
+        if (StringUtils.isNotBlank(attachmentPath)) {
+            JSONObject jsonObject = JSONObject.parseObject(attachmentPath);
+            String pathString = jsonObject.getString("path");
+            List<Map> pathList = JSONObject.parseArray(pathString, Map.class);
+            if(!pathList.isEmpty()) {
+                for (Map variable : variableList) {
+                    int count = Integer.parseInt(variable.get("backupCount").toString());
+                    for (int i = 0; i < count; i++) {
+                        Map vMap = new HashMap();
+                        vMap.put("type", variable.get("type"));
+                        for (Map path : pathList) {
+                            String printType = path.get("printType").toString();
+                            if(printType.equals(variable.get("type").toString())){
+                                vMap.put("htmlUrl", commonService.filePreviewByPathAndType(path.get("htmlPath").toString(), path.get("type").toString(), false));
+                                vMap.put("htmlMd5", path.get("htmlMd5"));
+                                vMap.put("pdfUrl", commonService.filePreviewByPathAndType(path.get("pdfPath").toString(), path.get("type").toString(), false));
+                                vMap.put("pdfMd5", path.get("pdfMd5"));
+                            }
+                        }
+                        otherList.add(vMap);
+                    }
+                }
+                List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
+                for (Map ordinary : ordinaryList) {
+                    int count = Integer.parseInt(ordinary.get("backupCount").toString());
+                    for (int i = 0; i < count; i++) {
+                        Map vMap = new HashMap();
+                        vMap.put("type", ordinary.get("type"));
+                        for (Map path : pathList) {
+                            String printType = path.get("printType").toString();
+                            if(printType.equals(ordinary.get("type").toString())){
+                                vMap.put("htmlUrl", commonService.filePreviewByPathAndType(path.get("htmlPath").toString(), path.get("type").toString(), false));
+                                vMap.put("htmlMd5", path.get("htmlMd5"));
+                                vMap.put("pdfUrl", commonService.filePreviewByPathAndType(path.get("pdfPath").toString(), path.get("type").toString(), false));
+                                vMap.put("pdfMd5", path.get("pdfMd5"));
+                            }
+                        }
+                        otherList.add(vMap);
+                    }
+
+                }
             }
         }
-        List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
-        for (Map ordinary : ordinaryList) {
-            int count = Integer.parseInt(ordinary.get("backupCount").toString());
-            for (int i = 0; i < count; i++) {
-                Map vMap = new HashMap();
-                vMap.put("type", ordinary.get("type"));
-                // todo
-                /*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;
     }
@@ -455,11 +494,10 @@ public class ClientServiceImpl implements ClientService {
     }
 
     @Override
-    public List<ClientPrintTaskDto> listClientPrintTask(HttpServletResponse response, 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) {
+    public void exportClientPrintTask(HttpServletResponse response, 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) throws Exception {
         Set<Long> orgIds = commonService.listSubOrgIds(null);
-        List<ClientPrintTaskDto> clientPrintTaskDtos = examPrintPlanService.listClientPrintTask(schoolId, machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, orgIds);
-        // todo 导出excel操作
-        return null;
+        List<ClientPrintTaskDto> printTaskDtoIList = examPrintPlanService.listClientPrintTask(schoolId, machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate, orgIds);
+        ExcelUtil.excelExport("印刷管理", ClientPrintTaskDto.class, printTaskDtoIList, response);
     }
 
     /**

+ 6 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CommonServiceImpl.java

@@ -356,26 +356,24 @@ public class CommonServiceImpl implements CommonService {
      * 文件预览
      *
      * @param path 附件路径
+     * @param type 保存类型:本地、OSS
      * @param isExpire     url是否带过期时间
      * @return
      */
     @Override
-    public String filePreviewByPath(String path, Boolean isExpire) {
+    public String filePreviewByPathAndType(String path, String type, Boolean isExpire) {
         if (StringUtils.isBlank(path)) {
             return null;
         }
 
         String pathUrl;
-        JSONObject jsonObject = JSONObject.parseObject(path);
-        String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
-        String filePath = (String) jsonObject.get(SystemConstant.PATH);
-        if (Objects.equals(attachmentType, SystemConstant.LOCAL)) {
-            pathUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
+        if (Objects.equals(type, SystemConstant.LOCAL)) {
+            pathUrl = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + path;
         } else {
             if (isExpire) {
-                pathUrl = ossUtil.getPrivateUrl(filePath);
+                pathUrl = ossUtil.getPrivateUrl(path);
             } else {
-                pathUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + filePath;
+                pathUrl = dictionaryConfig.aliYunOssDomain().getUrl() + File.separator + path;
             }
 
         }

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

@@ -263,8 +263,7 @@ public class ClientController {
                                       @RequestParam(value = "examEndTime", required = false) Long examEndTime,
                                       @RequestParam(value = "isDownload", required = false) Boolean isDownload,
                                       @RequestParam(value = "validate", required = false) Boolean validate) throws Exception {
-        List<ClientPrintTaskDto> printTaskDtoIList = clientService.listClientPrintTask(response, schoolId, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
-        ExcelUtil.excelExport("印刷管理", ClientPrintTaskDto.class, printTaskDtoIList, response);
+        clientService.exportClientPrintTask(response, schoolId, machineCode, orgId, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime, isDownload, validate);
     }
 
     /**