Browse Source

Merge branch 'dev_v2.2.0' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v2.2.0

xiaof 3 năm trước cách đây
mục cha
commit
275ab9e066
21 tập tin đã thay đổi với 319 bổ sung26 xóa
  1. 13 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTask.java
  2. 12 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java
  3. 4 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java
  4. 9 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  5. 26 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java
  6. 35 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  7. 98 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceServiceImpl.java
  8. 3 3
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  9. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/BasicClazzController.java
  10. 19 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java
  11. 0 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java
  12. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/auth/DistributedPrintAuthenticationService.java
  13. 17 0
      distributed-print/src/test/java/com/qmth/distributed/print/ServiceTest.java
  14. 3 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/FlowApproveOperationEnum.java
  15. 11 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/CommonCacheService.java
  16. 10 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TeachcloudCommonService.java
  17. 9 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/CommonCacheServiceImpl.java
  18. 20 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java
  19. 2 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/AuthUtil.java
  20. 25 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ConvertUtil.java
  21. 1 1
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/auth/TeachcloudReportAuthenticationService.java

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTask.java

@@ -120,6 +120,11 @@ public class ExamTask extends BaseEntity implements Serializable {
     @TableField(value = "flow_id", updateStrategy = FieldStrategy.IGNORED)
     private Long flowId;
 
+    @ApiModelProperty(value = "命题任务审批表记录")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @TableField(value = "approve_form_attachment_id")
+    private Long approveFormAttachmentId;
+
     public Long getFlowId() {
         return flowId;
     }
@@ -291,4 +296,12 @@ public class ExamTask extends BaseEntity implements Serializable {
     public void setUsers(List<Map<String, String>> users) {
         this.users = users;
     }
+
+    public Long getApproveFormAttachmentId() {
+        return approveFormAttachmentId;
+    }
+
+    public void setApproveFormAttachmentId(Long approveFormAttachmentId) {
+        this.approveFormAttachmentId = approveFormAttachmentId;
+    }
 }

+ 12 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java

@@ -55,7 +55,7 @@ public class TFFlowLog extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
 
-    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止")
+    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
     private FlowApproveOperationEnum approveOperation;
 
     public TFFlowLog() {
@@ -73,6 +73,17 @@ public class TFFlowLog extends BaseEntity implements Serializable {
         insertInfo(userId);
     }
 
+    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long userId, String approveRemark, FlowApproveOperationEnum approveOperation) {
+        setId(SystemConstant.getDbUuid());
+        this.schoolId = schoolId;
+        this.orgId = orgId;
+        this.flowId = flowId;
+        this.taskId = taskId;
+        this.approveRemark = approveRemark;
+        this.approveOperation = approveOperation;
+        insertInfo(userId);
+    }
+
     public Long getSchoolId() {
         return schoolId;
     }

+ 4 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java

@@ -20,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 
@@ -219,4 +220,7 @@ public interface ExamTaskService extends IService<ExamTask> {
      * @return 命题任务审核表参数
      */
     ExamTaskApprovalFormDto findExamTaskApprovalForm(Long examTaskId);
+
+
+    void findExamTaskApprovalPdf(HttpServletResponse response,Long examTaskId, String htmlContext) throws Exception;
 }

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java

@@ -55,6 +55,15 @@ public interface PrintCommonService {
      */
     public BasicAttachment saveAttachmentHtml(String fileName, String htmlContent, Long userId, List<PdfDto> localFileList) throws IOException;
 
+    /**
+     * 保存html附件和该html转成pdf的附件
+     * @param fileName 文件名称
+     * @param htmlContent html内容
+     * @param userId 创建人
+     * @return 附件对象
+     */
+    public BasicAttachment saveAttachmentHtmlAndPdf(String fileName, String htmlContent,Long userId) throws IOException;
+
     /**
      * 保存附件公用
      *

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

@@ -585,7 +585,8 @@ public class ActivitiServiceImpl implements ActivitiService {
         if (Objects.isNull(task)) {
             throw ExceptionResultEnum.ERROR.exception("流程任务为空");
         }
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(Long.parseLong(task.getProcessInstanceId()));
+        Long flowId = Long.parseLong(task.getProcessInstanceId());
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
         if (Objects.isNull(tfFlowApprove)) {
             throw ExceptionResultEnum.ERROR.exception("未找到流程状态记录");
         }
@@ -615,6 +616,30 @@ public class ActivitiServiceImpl implements ActivitiService {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         taskService.deleteCandidateUser(taskId, String.valueOf(sysUser.getId()));
         taskService.addCandidateUser(taskId, userId);
+
+        QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
+        examTaskQueryWrapper.lambda().eq(ExamTask::getFlowId, flowId);
+        ExamTask examTask = examTaskService.getOne(examTaskQueryWrapper);
+
+        String processDefinitionId = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult().getProcessDefinitionId();
+        ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
+        //获取当前流程节点
+        String currActivityId = task.getTaskDefinitionKey();
+        BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
+        FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
+
+        SysUser exchangeUser = sysUserService.getById(userId);
+        //流程流水日志
+        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE);
+        if (currFlow instanceof UserTask) {
+            UserTask userTask = (UserTask) currFlow;
+            //广东医科大学流程
+            if (Objects.nonNull(processDefinitionEntity) && processDefinitionEntity.getKey().contains(SystemConstant.GDYKDX_FLOW_KEY)) {
+                FlowGdykdxApproveSetupEnum setupEnum = FlowGdykdxApproveSetupEnum.convertToInstance(userTask.getId());
+                tfFlowLog.setApproveSetup(setupEnum.getSetup());
+            }
+        }
+        tfFlowLogService.save(tfFlowLog);
         return true;
     }
 

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

@@ -27,10 +27,7 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
 import com.qmth.teachcloud.common.enums.*;
 import com.qmth.teachcloud.common.service.*;
-import com.qmth.teachcloud.common.util.ExcelUtil;
-import com.qmth.teachcloud.common.util.RedisUtil;
-import com.qmth.teachcloud.common.util.ResultUtil;
-import com.qmth.teachcloud.common.util.ServletUtil;
+import com.qmth.teachcloud.common.util.*;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
 import org.activiti.engine.ActivitiObjectNotFoundException;
 import org.activiti.engine.TaskService;
@@ -48,7 +45,9 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -154,6 +153,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     BasicClazzService basicClazzService;
 
+    @Resource
+    FileStoreUtil fileStoreUtil;
+
     @Override
     public List<ExamTask> listByCourseCode(Long schoolId, String code) {
         QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
@@ -1689,8 +1691,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         // 流程id
         Long flowId = examTask.getFlowId();
 
-
-
         // 2.ExamRoomInfo 部分
         List<ExamRoomInfo> examRoomInfoList = new ArrayList<>();
         List<ExamPackageDetail> examPackageDetailDatasource = this.baseMapper.findExamPackageDetailByPaperNumber(paperNumber);
@@ -1784,6 +1784,35 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         return examTaskApprovalFormDto;
     }
 
+    @Transactional
+    @Override
+    public void findExamTaskApprovalPdf(HttpServletResponse response,Long examTaskId, String htmlContext) throws Exception {
+        ExamTask examTask = this.getById(examTaskId);
+        String fileName = examTask.getPaperNumber() + "审批表";
+//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        if (Objects.isNull(examTask)){
+            throw ExceptionResultEnum.ERROR.exception("未找到命题任务");
+        }
+        Long approveFormAttachmentId = examTask.getApproveFormAttachmentId();
+        BasicAttachment basicAttachment = basicAttachmentService.getById(approveFormAttachmentId);
+        if (Objects.isNull(basicAttachment)) {
+            // 命题任务试卷审批表字段为空 -> 保存html并生成pdf附件
+            basicAttachment = printCommonService.saveAttachmentHtmlAndPdf(fileName, htmlContext, 1L);
+            examTask.setApproveFormAttachmentId(basicAttachment.getId());
+            this.updateById(examTask);
+        }
+        JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
+        String pdfPath = (String) jsonObject.get(SystemConstant.PDF_PATH);
+        String type = (String) jsonObject.get(SystemConstant.TYPE);
+        InputStream inputStream = null;
+        if (Objects.equals(type, SystemConstant.OSS)) {
+            inputStream = fileStoreUtil.ossDownloadIs(pdfPath, fileStoreUtil.getUploadEnumByPath(pdfPath).getFssType());
+        } else {
+            inputStream = new FileInputStream(new File(pdfPath));
+        }
+        ConvertUtil.outputFile(response,inputStream,fileName + SystemConstant.PDF_PREFIX);
+    }
+
     /**
      * 简单校验提交参数
      *

+ 98 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceServiceImpl.java

@@ -45,6 +45,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -332,6 +333,103 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
         return basicAttachment;
     }
 
+    /**
+     * 保存html附件和该html转成pdf的附件
+     * @param fileName 文件名称
+     * @param htmlContent html内容
+     * @param userId 创建人
+     * @return 两个附件对象
+     */
+    @Transactional
+    @Override
+    public BasicAttachment saveAttachmentHtmlAndPdf(String fileName, String htmlContent, Long userId) {
+        BasicAttachment basicAttachment = null;
+        try {
+            byte[] bytes = htmlContent.getBytes();
+            int size = bytes.length;
+            boolean oss = dictionaryConfig.sysDomain().isOss();
+            LocalDateTime nowTime = LocalDateTime.now();
+            StringJoiner stringJoiner = new StringJoiner("");
+            if (!oss) {
+                stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
+            }
+            stringJoiner.add(UploadFileEnum.HTML.getTitle()).add(File.separator)
+                    .add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getDayOfMonth()));
+
+            JSONObject jsonObject = new JSONObject();
+            stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.HTML_PREFIX);
+            String fileMd5 = null;
+
+            if (oss) {//上传至oss
+                String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
+                fileStoreUtil.ossUpload(dirName, htmlContent, fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
+                jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
+                jsonObject.put(SystemConstant.PATH, dirName);
+                String url = SystemConstant.TEMP_FILES_DIR + File.separator + dirName;
+                File localHtmlFile = fileStoreUtil.ossDownload(dirName, url, fileStoreUtil.getUploadEnumByPath(dirName).getFssType());
+                StringJoiner pdfStringJoiner = new StringJoiner("");
+                pdfStringJoiner.add(UploadFileEnum.PDF.getTitle()).add(File.separator);
+                pdfStringJoiner.add(String.valueOf(nowTime.getYear())).add(File.separator)
+                        .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                        .add(String.format("%02d", nowTime.getDayOfMonth()));
+                pdfStringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.PDF_PREFIX);
+
+                String pdfDirName = pdfStringJoiner.toString();
+                String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
+//                destUrl = destUrl.replaceAll("\\\\","/");
+
+                HtmlToPdfUtil.convert(localHtmlFile.getPath(), destUrl, PageSizeEnum.A3);
+//                File pdfFile = asposePdfUtil.documentToPdf(localHtmlFile.getPath(), destUrl, PaperSize.A3);
+                File pdfFile = new File(destUrl);
+                if (!pdfFile.exists()) {
+                    pdfFile.getParentFile().mkdirs();
+                    pdfFile.createNewFile();
+                }
+                fileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
+//                ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)));
+                pdfDirName = pdfDirName.replaceAll("\\\\", "/");
+                fileStoreUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)), fileStoreUtil.getUploadEnumByPath(pdfDirName).getFssType());
+//                localHtmlFile.delete();
+                jsonObject.put(SystemConstant.PDF_PATH, pdfDirName);
+                // htmlMd5
+                jsonObject.put("htmlMd5", DigestUtils.md5Hex(new FileInputStream(localHtmlFile)));
+                jsonObject.put("pdfMd5", fileMd5);
+            }else {//上传至服务器
+                File finalFile = new File(stringJoiner.toString());
+                if (!finalFile.exists()) {
+                    finalFile.getParentFile().mkdirs();
+                    finalFile.createNewFile();
+                }
+                FileCopyUtils.copy(bytes, new File(stringJoiner.toString()));
+                fileMd5 = DigestUtils.md5Hex(new FileInputStream(stringJoiner.toString()));
+                jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
+                jsonObject.put(SystemConstant.PATH, stringJoiner.toString());
+                String destUrl = finalFile.getPath().replaceAll(SystemConstant.HTML_PREFIX, SystemConstant.PDF_PREFIX).replaceAll(UploadFileEnum.HTML.name().toLowerCase(), UploadFileEnum.PDF.name().toLowerCase());
+                HtmlToPdfUtil.convert(finalFile.getPath(), destUrl, PageSizeEnum.A3);
+//                File pdfFile = asposePdfUtil.documentToPdf(finalFile.getPath(), destUrl, PaperSize.A3);
+                jsonObject.put(SystemConstant.PDF_PATH, destUrl);
+                jsonObject.put("htmlMd5", DigestUtils.md5Hex(new FileInputStream(finalFile)));
+                jsonObject.put("pdfMd5", fileMd5);
+            }
+            jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
+                    UploadFileEnum.HTML, UploadFileEnum.PDF
+            });
+            basicAttachment = new BasicAttachment(jsonObject.toJSONString(), fileName, SystemConstant.HTML_PREFIX, new BigDecimal(size), fileMd5, userId);
+            basicAttachmentService.save(basicAttachment);
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            basicAttachmentService.deleteAttachment(basicAttachment);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        }
+        return basicAttachment;
+    }
+
     /**
      * 保存附件公用
      *

+ 3 - 3
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -266,10 +266,10 @@
         <where>
             a.enable = true
             AND a.review = true
-            AND a.status = 'SUBMIT' and (f.status = 'AUDITING' or f.status = 'REJECT')
             and EXISTS(
-            <include refid="findFlowIdToMySelfSql" />
-            and art.PROC_INST_ID_ = a.flow_id)
+            select * from
+            (<include refid="findFlowIdToMySelfSql" />) t where t.flowId = a.flow_id)
+            and f.status <![CDATA[ <> ]]> 'START'
             <if test="schoolId != null and schoolId != ''">
                 and a.school_id = #{schoolId}
             </if>

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

@@ -34,7 +34,7 @@ import java.util.Objects;
 @Api(tags = "班级管理controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.basic}/clazz")
-//@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
+@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
 public class BasicClazzController {
     @Resource
     private BasicClazzService basicClazzService;

+ 19 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.api;
 
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailCardDto;
@@ -17,6 +19,7 @@ import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
 import com.qmth.distributed.print.business.templete.execute.AsyncTaskReviewSampleExportService;
 import com.qmth.teachcloud.common.bean.params.ArraysParams;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -56,6 +59,7 @@ import java.util.stream.Collectors;
 @Api(tags = "命题任务Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.exam}/task")
+//@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
 public class ExamTaskController {
 
     @Autowired
@@ -803,10 +807,24 @@ public class ExamTaskController {
     @ApiOperation(value = "命题任务-审批-获取试卷审批表数据")
     @RequestMapping(value = "/find_approve_form_json", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
-    public Result findApproveFormJson(@ApiParam(value = "题卡规则id", required = true) @RequestParam String examTaskId) {
+    public Result findApproveFormJson(@ApiParam(value = "命题任务id", required = true) @RequestParam String examTaskId) {
         return ResultUtil.ok((Object) examTaskService.findExamTaskApprovalForm(SystemConstant.convertIdToLong(examTaskId)));
     }
 
+    @ApiOperation(value = "命题任务-审批-获取试卷审批表pdf")
+    @RequestMapping(value = "/find_approve_form_pdf", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
+    public void findApproveFormPdf(@ApiParam(value = "命题任务id", required = true) @RequestParam String examTaskId,
+                                   @ApiParam(value = "html", required = true) @RequestParam String htmlContent) throws Exception {
+        // -- 测试用html --
+        Long id = 165147096339447808L;
+        ExamCardDetailService examCardDetailService = SpringContextHolder.getBean(ExamCardDetailService.class);
+        ExamCardDetail examCardDetail = examCardDetailService.getById(id);
+        htmlContent = examCardDetail.getHtmlContent();
+        // --
+        HttpServletResponse response = ServletUtil.getResponse();
+        examTaskService.findExamTaskApprovalPdf(response,SystemConstant.convertIdToLong(examTaskId), htmlContent);
+    }
 
 }
 

+ 0 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java

@@ -76,7 +76,6 @@ public class TFFlowController {
     @Resource
     TFFlowApproveLogService tfFlowApproveLogService;
 
-
     @ApiOperation(value = "注册流程")
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/auth/DistributedPrintAuthenticationService.java

@@ -118,7 +118,7 @@ public class DistributedPrintAuthenticationService implements AuthorizationServi
             return true;
         }
         //系统公用接口不拦截
-        List<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS);
+        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
         int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(path)).count() : 0;
         if (sysCount > 0) {
             return true;

+ 17 - 0
distributed-print/src/test/java/com/qmth/distributed/print/ServiceTest.java

@@ -3,20 +3,24 @@ package com.qmth.distributed.print;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.distributed.print.business.bean.result.TemplatePrintInfoResult;
+import com.qmth.distributed.print.business.entity.ExamCardDetail;
 import com.qmth.distributed.print.business.entity.ExamPrintPlan;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.enums.MessageEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.service.BasicCourseService;
 import com.qmth.teachcloud.common.util.ConvertUtil;
+import org.activiti.engine.task.Attachment;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -44,6 +48,10 @@ public class ServiceTest {
     private BasicCourseService basicCourseService;
     @Resource
     private ExamTaskService examTaskService;
+    @Resource
+    private PrintCommonService printCommonService;
+    @Resource
+    private ExamCardDetailService examCardDetailService;
 
 
     @Test
@@ -124,4 +132,13 @@ public class ServiceTest {
         System.out.println(JSON.toJSONString(examTaskService.findExamTaskApprovalForm(examTask)));
     }
 
+    @Test
+    public void saveHtmlAndPdf() throws IOException {
+        Long id = 165147096339447808L;
+        ExamCardDetail examCardDetail = examCardDetailService.getById(id);
+        String htmlContent = examCardDetail.getHtmlContent();
+        BasicAttachment basicAttachment = printCommonService.saveAttachmentHtmlAndPdf("那不勒斯",htmlContent,1L);
+        System.out.println(JSON.toJSONString(basicAttachment));
+    }
+
 }

+ 3 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/FlowApproveOperationEnum.java

@@ -17,7 +17,9 @@ public enum FlowApproveOperationEnum {
 
     REJECT("驳回"),
 
-    END("终止");
+    END("终止"),
+
+    EXCHANGE("转他人审批");
 
     private String title;
 

+ 11 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/CommonCacheService.java

@@ -139,7 +139,16 @@ public interface CommonCacheService {
      * @param privilegePropertyEnum
      * @return
      */
-    public List<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum);
+    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum);
+
+    /**
+     * 获取鉴权url
+     *
+     * @param privilegePropertyEnum
+     * @param schoolId
+     * @return
+     */
+    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId);
 
     /**
      * 修改鉴权url
@@ -147,7 +156,7 @@ public interface CommonCacheService {
      * @param privilegePropertyEnum
      * @return
      */
-    public List<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum);
+    public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum);
 
 
     /**

+ 10 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TeachcloudCommonService.java

@@ -93,7 +93,16 @@ public interface TeachcloudCommonService {
      * @param privilegePropertyEnum
      * @return
      */
-    public List<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum);
+    public Set<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum);
+
+    /**
+     * 获取鉴权url
+     *
+     * @param privilegePropertyEnum
+     * @param schoolId
+     * @return
+     */
+    public Set<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId);
 
     /**
      * 给学校赋予权限的公共方法(权限是否启用跟学校联动)

+ 9 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/CommonCacheServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Set;
 
 /**
  * @Description: 缓存操作serviceImpl 实现类
@@ -230,10 +231,16 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      */
     @Override
     @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0")
-    public List<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
+    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
         return commonService.getPrivilegeUrl(privilegePropertyEnum);
     }
 
+    @Override
+    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0 + '-' + #p1")
+    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId) {
+        return commonService.getPrivilegeUrl(privilegePropertyEnum, schoolId);
+    }
+
     /**
      * 修改鉴权url
      *
@@ -242,7 +249,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      */
     @Override
     @CachePut(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0")
-    public List<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
+    public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
         return commonService.getPrivilegeUrl(privilegePropertyEnum);
     }
 

+ 20 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -301,13 +301,31 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
      * @return
      */
     @Override
-    public List<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum) {
+    public Set<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum) {
         QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
         sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
                 .eq(SysPrivilege::getProperty, privilegePropertyEnum)
                 .eq(SysPrivilege::getEnable, true);
         List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
-        return Objects.nonNull(sysPrivilegeList) && sysPrivilegeList.size() > 0 ? sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toList()) : null;
+        return Objects.nonNull(sysPrivilegeList) && sysPrivilegeList.size() > 0 ? sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()) : null;
+    }
+
+    /**
+     * 获取鉴权url
+     *
+     * @param privilegePropertyEnum
+     * @param schoolId
+     * @return
+     */
+    @Override
+    public Set<String> getPrivilegeUrl(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId) {
+        QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
+        sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
+                .eq(SysPrivilege::getProperty, privilegePropertyEnum)
+                .eq(SysPrivilege::getEnable, true)
+                .eq(SysPrivilege::getSchoolId, schoolId);
+        List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
+        return Objects.nonNull(sysPrivilegeList) && sysPrivilegeList.size() > 0 ? sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()) : null;
     }
 
     @Transactional

+ 2 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/AuthUtil.java

@@ -46,7 +46,7 @@ public class AuthUtil {
     public static boolean adminAuthInterceptor(HttpServletRequest request, HttpServletResponse response, Object handler) {
         String url = request.getServletPath();
         commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-        List<String> privilegeUrl = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.NO_AUTH);
+        Set<String> privilegeUrl = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.NO_AUTH);
         //无需鉴权的url
         int noAuthCount = Objects.nonNull(privilegeUrl) ? (int) privilegeUrl.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
         if (noAuthCount > 0) {
@@ -159,7 +159,7 @@ public class AuthUtil {
             return true;
         }
         //系统公用接口不拦截
-        List<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS);
+        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
         int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
         if (sysCount > 0) {
             return true;

+ 25 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ConvertUtil.java

@@ -10,6 +10,7 @@ import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
@@ -299,4 +300,28 @@ public class ConvertUtil {
             return false;
         }
     }
+
+    public static void outputFile(HttpServletResponse response, InputStream inputStream, String fileName) {
+        try {
+            byte[] buf = new byte[1024];
+            int len = 0;
+
+            String fName = new String(fileName.getBytes(), "ISO-8859-1");
+
+            response.reset();
+            response.setContentType("application/x-msdownload");
+            response.setHeader("Content-Disposition", "attachment; filename=" + fName);
+
+            OutputStream outStream = response.getOutputStream();
+
+            while ((len = inputStream.read(buf)) > 0) {
+                outStream.write(buf, 0, len);
+            }
+
+            inputStream.close();
+            outStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 1 - 1
teachcloud-report/src/main/java/com/qmth/teachcloud/report/auth/TeachcloudReportAuthenticationService.java

@@ -118,7 +118,7 @@ public class TeachcloudReportAuthenticationService implements AuthorizationServi
             return true;
         }
         //系统公用接口不拦截
-        List<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS);
+        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
         int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(path)).count() : 0;
         if (sysCount > 0) {
             return true;