caozixuan 3 年之前
父節點
當前提交
14cf3019cb

+ 42 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/ApproveFormParams.java

@@ -0,0 +1,42 @@
+package com.qmth.distributed.print.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author: CaoZixuan
+ * @Date:
+ */
+public class ApproveFormParams {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "命题任务id")
+    @NotNull(message = "请选择命题任务")
+    @Range(min = 1L,message = "请选择命题任务")
+    private Long examTaskId;
+
+    @ApiModelProperty(value = "html")
+    @NotNull(message = "请提供html")
+    private String htmlContent;
+
+    public Long getExamTaskId() {
+        return examTaskId;
+    }
+
+    public void setExamTaskId(Long examTaskId) {
+        this.examTaskId = examTaskId;
+    }
+
+    public String getHtmlContent() {
+        return htmlContent;
+    }
+
+    public void setHtmlContent(String htmlContent) {
+        this.htmlContent = htmlContent;
+    }
+}

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

@@ -1788,16 +1788,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @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("未找到命题任务");
         }
+        String fileName = examTask.getPaperNumber() + "审批表";
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+
         Long approveFormAttachmentId = examTask.getApproveFormAttachmentId();
         BasicAttachment basicAttachment = basicAttachmentService.getById(approveFormAttachmentId);
         if (Objects.isNull(basicAttachment)) {
             // 命题任务试卷审批表字段为空 -> 保存html并生成pdf附件
-            basicAttachment = printCommonService.saveAttachmentHtmlAndPdf(fileName, htmlContext, 1L);
+            basicAttachment = printCommonService.saveAttachmentHtmlAndPdf(fileName, htmlContext, sysUser.getId());
             examTask.setApproveFormAttachmentId(basicAttachment.getId());
             this.updateById(examTask);
         }

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

@@ -380,7 +380,7 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
                 String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
 //                destUrl = destUrl.replaceAll("\\\\","/");
 
-                HtmlToPdfUtil.convert(localHtmlFile.getPath(), destUrl, PageSizeEnum.A3);
+                HtmlToPdfUtil.convert(localHtmlFile.getPath(), destUrl, PageSizeEnum.A4);
 //                File pdfFile = asposePdfUtil.documentToPdf(localHtmlFile.getPath(), destUrl, PaperSize.A3);
                 File pdfFile = new File(destUrl);
                 if (!pdfFile.exists()) {

+ 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;

+ 7 - 9
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -7,8 +7,10 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailCardDto;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskImportDto;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskPrintDto;
+import com.qmth.distributed.print.business.bean.params.ApproveFormParams;
 import com.qmth.distributed.print.business.bean.params.ExamTaskApplyParam;
 import com.qmth.distributed.print.business.bean.params.ExamTaskPrintParams;
+import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
@@ -815,16 +817,12 @@ public class ExamTaskController {
     @RequestMapping(value = "/find_approve_form_pdf", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
 //    @Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
-    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();
-        // --
+    public void findApproveFormPdf(@Valid @RequestBody ApproveFormParams approveFormParams, BindingResult bindingResult) throws Exception {
+        if (bindingResult.hasErrors()) {
+            throw ExceptionResultEnum.ERROR.exception(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
         HttpServletResponse response = ServletUtil.getResponse();
-        examTaskService.findExamTaskApprovalPdf(response,SystemConstant.convertIdToLong(examTaskId), htmlContent);
+        examTaskService.findExamTaskApprovalPdf(response,approveFormParams.getExamTaskId(), approveFormParams.getHtmlContent());
     }
 
 }