Selaa lähdekoodia

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

xiaof 3 vuotta sitten
vanhempi
commit
6ebbfc3436
14 muutettua tiedostoa jossa 160 lisäystä ja 31 poistoa
  1. 12 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/CalculateNotifyResult.java
  2. 28 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/GradeBatch.java
  3. 3 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/GradeBatchPaper.java
  4. 29 13
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java
  5. 2 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/importData/AsyncImportTaskTemplete.java
  6. 7 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  7. 7 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/FreemarkerUtil.java
  8. 50 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/NotifyApiController.java
  9. 0 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/TSAuthController.java
  10. 9 3
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicAttachmentServiceImpl.java
  11. 8 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java
  12. 1 0
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CalculateTaskTemplate.java
  13. 0 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CourseCodeSyncTaskService.java
  14. 4 4
      teachcloud-task/src/main/resources/application-task.properties

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/CalculateNotifyResult.java

@@ -3,6 +3,7 @@ package com.qmth.distributed.print.business.bean.result;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.enums.GradeAnalyzePaperStatusEnum;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -34,6 +35,17 @@ public class CalculateNotifyResult implements Serializable {
     @ApiModelProperty(value = "时间戳")
     private Long time;
 
+    @ApiModelProperty(value = "数据结果,SUCCESS:成功,ERROR:失败")
+    private String result;
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
     public Long getExamId() {
         return examId;
     }

+ 28 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/GradeBatch.java

@@ -1,9 +1,12 @@
 package com.qmth.distributed.print.business.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.enums.GradeAnalyzePaperStatusEnum;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -41,6 +44,7 @@ public class GradeBatch extends BaseEntity implements Serializable {
     private Long batchTime;
 
     @ApiModelProperty(value = "批次状态")
+    @TableField(value = "status", updateStrategy = FieldStrategy.IGNORED)
     private GradeAnalyzePaperStatusEnum status;
 
     @ApiModelProperty(value = "第三方考试id")
@@ -51,11 +55,35 @@ public class GradeBatch extends BaseEntity implements Serializable {
     private String source;
 
     @ApiModelProperty(value = "进度")
+    @TableField(value = "progress", updateStrategy = FieldStrategy.IGNORED)
     private BigDecimal progress;
 
     @ApiModelProperty(value = "报告路径")
     private String reportFilePath;
 
+    @ApiModelProperty(value = "回调时间")
+    private Long notifyTime;
+
+    @ApiModelProperty(value = "数据结果,SUCCESS:成功,ERROR:失败")
+    @TableField(value = "result", updateStrategy = FieldStrategy.IGNORED)
+    private TaskResultEnum result;
+
+    public TaskResultEnum getResult() {
+        return result;
+    }
+
+    public void setResult(TaskResultEnum result) {
+        this.result = result;
+    }
+
+    public Long getNotifyTime() {
+        return notifyTime;
+    }
+
+    public void setNotifyTime(Long notifyTime) {
+        this.notifyTime = notifyTime;
+    }
+
     public BigDecimal getProgress() {
         return progress;
     }

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/GradeBatchPaper.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
@@ -44,6 +46,7 @@ public class GradeBatchPaper extends BaseEntity implements Serializable {
     private String paperName;
 
     @ApiModelProperty(value = "分析试卷状态")
+    @TableField(value = "status", updateStrategy = FieldStrategy.IGNORED)
     private GradeAnalyzePaperStatusEnum status;
 
     @ApiModelProperty(value = "开课学院id")

+ 29 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -176,13 +176,14 @@ public class PrintCommonServiceImpl implements PrintCommonService {
                 url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
                 UploadFileEnum uploadType = Enum.valueOf(UploadFileEnum.class, (String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
 //                htmlFile = ossUtil.ossDownload(filePath, url);
-                htmlFile = fileStoreUtil.ossDownload(filePath, url, uploadType.getFssType());
+                if (oss) {
+                    htmlFile = fileStoreUtil.ossDownload(filePath, url, uploadType.getFssType());
+                } else {
+                    htmlFile = new File(filePath);
+                }
             }
             LocalDateTime nowTime = LocalDateTime.now();
             StringJoiner pdfStringJoiner = new StringJoiner("");
-            if (!oss) {
-                pdfStringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
-            }
             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)
@@ -212,10 +213,8 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             String md5 = ByteArray.md5(data).toHexString();
             InputStream ins = new ByteArrayInputStream(data);
             //String pdfFileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
-            PdfDto pdfDto = null;
+            PdfDto pdfDto = PdfUtil.addPdfPage(pdfFile);
             if (oss) {//上传至oss
-                pdfDto = PdfUtil.addPdfPage(pdfFile);
-//                ossUtil.ossUpload(pdfDirNameStr, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(pdfFileMd5)));
                 fileStoreUtil.ossUpload(pdfDirNameStr, ins, md5, fileStoreUtil.getUploadEnumByPath(pdfDirNameStr).getFssType());
 //                htmlFile.delete();
                 ins.close();
@@ -229,7 +228,11 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             object.put(SystemConstant.HTML_PATH, filePath);
             object.put("htmlMd5", htmlFileMd5);
             object.put("pdfMd5", md5);
-            object.put(SystemConstant.PDF_PATH, pdfDirNameStr);
+            if (!oss) {
+                object.put(SystemConstant.PDF_PATH, pdfFile.getPath());
+            } else {
+                object.put(SystemConstant.PDF_PATH, pdfDirNameStr);
+            }
             object.put(SystemConstant.TYPE, SystemConstant.OSS);
             object.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
                     UploadFileEnum.HTML,
@@ -336,12 +339,19 @@ public class PrintCommonServiceImpl implements PrintCommonService {
                     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());
+                String destUrl = finalFile.getPath().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);
+                File pdfFile = new File(destUrl);
+                if (!pdfFile.exists()) {
+                    pdfFile.getParentFile().mkdirs();
+                    pdfFile.createNewFile();
+                }
+                pdfDto = PdfUtil.addPdfPage(pdfFile);
+                fileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
+                localFileList.add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+
                 jsonObject.put(SystemConstant.PDF_PATH, destUrl);
                 jsonObject.put("htmlMd5", DigestUtils.md5Hex(new FileInputStream(finalFile)));
                 jsonObject.put("pdfMd5", fileMd5);
@@ -438,9 +448,15 @@ public class PrintCommonServiceImpl implements PrintCommonService {
                 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());
+                String destUrl = finalFile.getPath().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);
+                File pdfFile = new File(destUrl);
+                if (!pdfFile.exists()) {
+                    pdfFile.getParentFile().mkdirs();
+                    pdfFile.createNewFile();
+                }
+                fileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
+
                 jsonObject.put(SystemConstant.PDF_PATH, destUrl);
                 jsonObject.put("htmlMd5", DigestUtils.md5Hex(new FileInputStream(finalFile)));
                 jsonObject.put("pdfMd5", fileMd5);

+ 2 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/importData/AsyncImportTaskTemplete.java

@@ -117,8 +117,9 @@ public abstract class AsyncImportTaskTemplete {
                 path = path.replaceAll(UploadFileEnum.PDF.getTitle(), UploadFileEnum.FILE.getTitle());
             }
 
+            path = path.substring(0, path.lastIndexOf("/") + 1);
+            stringJoiner.add(path).add(SystemConstant.getUuid()).add(TXT_PREFIX).toString();
             if (Objects.equals(type, SystemConstant.OSS)) {//上传至oss
-                path = path.substring(0, path.lastIndexOf("/") + 1);
                 stringJoiner.add(path).add(SystemConstant.getUuid()).add(TXT_PREFIX).toString();
                 FileStoreUtil fileStoreUtil = SpringContextHolder.getBean(FileStoreUtil.class);
                 fileStoreUtil.ossUpload(stringJoiner.toString(), inputStream, DigestUtils.md5Hex(new ByteArrayInputStream(bookByteAry)), fileStoreUtil.getUploadEnumByPath(stringJoiner.toString()).getFssType());

+ 7 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -14,6 +14,7 @@ import com.qmth.distributed.print.business.enums.PrintMethodEnum;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.distributed.print.business.service.PrintCommonService;
+import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
 import com.qmth.teachcloud.common.enums.*;
@@ -94,6 +95,9 @@ public class CreatePdfUtil {
     @Resource
     ExamStudentService examStudentService;
 
+    @Resource
+    DictionaryConfig dictionaryConfig;
+
     /**
      * 创建登记表
      *
@@ -781,6 +785,7 @@ public class CreatePdfUtil {
                                           ExamDetail examDetail,
                                           BasicExamRule basicExamRule,
                                           List<PdfDto> mergePdfDeleteList) throws Exception {
+        boolean oss = dictionaryConfig.sysDomain().isOss();
         StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.PDF_TEMP_FILES_DIR).add(File.separator);
         // oss上只认"/",windows生成的路径分隔符全部替换为"/"
         File localA4PdfFile = null, localA3PdfFile = null, localA3PdfCardFile = null;
@@ -819,12 +824,12 @@ public class CreatePdfUtil {
             examDetail.setStatus(ExamDetailStatusEnum.READY);
         }
         detailService.saveOrUpdate(examDetail);
-        if (Objects.nonNull(localA3PdfFile)) {
+        if (Objects.nonNull(localA3PdfFile) && oss) {
 //            ossUtil.ossUpload(dirNameA3, localA3PdfFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfFile)));
             fileStoreUtil.ossUpload(dirNameA3, localA3PdfFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfFile)), fileStoreUtil.getUploadEnumByPath(dirNameA3).getFssType());
             localA3PdfFile.delete();
         }
-        if (Objects.nonNull(localA3PdfCardFile)) {
+        if (Objects.nonNull(localA3PdfCardFile) && oss) {
             fileStoreUtil.ossUpload(dirNameCardA3, localA3PdfCardFile, DigestUtils.md5Hex(new FileInputStream(localA3PdfCardFile)), fileStoreUtil.getUploadEnumByPath(dirNameCardA3).getFssType());
             localA3PdfCardFile.delete();
         }

+ 7 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/FreemarkerUtil.java

@@ -96,7 +96,12 @@ public class FreemarkerUtil {
             String ftlName = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf("."));
 
             Configuration configuration = new Configuration(Configuration.VERSION_2_3_29);
-            File templates = ResourceUtils.getFile(SystemConstant.TEMP_FILES_DIR + File.separator + ftlPath);
+            File templates = null;
+            if (ftlPath.contains(SystemConstant.TEMP_FILES_DIR)) {
+                templates = ResourceUtils.getFile(ftlPath);
+            } else {
+                templates = ResourceUtils.getFile(SystemConstant.TEMP_FILES_DIR + File.separator + ftlPath);
+            }
             configuration.setDirectoryForTemplateLoading(templates);
             // step1 加载模版文件
             Template template = configuration.getTemplate(ftlName + SystemConstant.FTL_PREFIX);
@@ -123,7 +128,7 @@ public class FreemarkerUtil {
             if (oss) {
                 String htmlStringJoinerStr = htmlStringJoiner.toString().replace("\\", "/");
 //                ossUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)));
-                fileStoreUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)),fileStoreUtil.getUploadEnumByPath(htmlStringJoinerStr).getFssType());
+                fileStoreUtil.ossUpload(htmlStringJoinerStr, htmlFile, DigestUtils.md5Hex(new FileInputStream(htmlFile)), fileStoreUtil.getUploadEnumByPath(htmlStringJoinerStr).getFssType());
                 jsonObject.put(SystemConstant.HTML_PATH, htmlStringJoinerStr);
                 jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
                         UploadFileEnum.FILE,

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

@@ -1,18 +1,26 @@
 package com.qmth.distributed.print.api;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.result.CalculateNotifyResult;
+import com.qmth.distributed.print.business.entity.GradeBatch;
+import com.qmth.distributed.print.business.entity.GradeBatchPaper;
+import com.qmth.distributed.print.business.service.GradeBatchPaperService;
+import com.qmth.distributed.print.business.service.GradeBatchService;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.enums.GradeAnalyzePaperStatusEnum;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import com.qmth.teachcloud.common.util.*;
 import io.swagger.annotations.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -43,10 +51,17 @@ public class NotifyApiController {
     @Resource
     DictionaryConfig dictionaryConfig;
 
+    @Resource
+    GradeBatchService gradeBatchService;
+
+    @Resource
+    GradeBatchPaperService gradeBatchPaperService;
+
     @ApiOperation(value = "教研分析进度回调")
     @ApiResponses({@ApiResponse(code = 200, message = "教研分析进度回调", response = CalculateNotifyResult.class)})
     @RequestMapping(value = "/analysis/progress", method = RequestMethod.POST)
     @Aac(auth = BOOL.FALSE)
+    @Transactional
     public Result analysisProgress(@ApiParam(value = "接收教研分析回调数据", required = true) @RequestBody String result) throws UnsupportedEncodingException {
         try {
             log.info("analysis_progress,result:{}", result);
@@ -66,6 +81,7 @@ public class NotifyApiController {
             if (!Objects.equals(localSign, sign)) {
                 throw ExceptionResultEnum.ERROR.exception("签名不匹配");
             }
+
             CalculateNotifyResult calculateNotifyResult = JSONObject.toJavaObject(JSONObject.parseObject(decodeJson), CalculateNotifyResult.class);
             List<String> courseCodeList = new ArrayList<>();
             courseCodeList.addAll(calculateNotifyResult.getCourseCode().keySet());
@@ -73,7 +89,40 @@ public class NotifyApiController {
 
             String source = Base64Util.encode(ShaUtils.sha1(calculateNotifyResult.getExamId() + courseCodeList.toString()));
             log.info("source:{}", source);
-            //TODO 更新grade_batch(状态和进度)和grade_batch_paper(状态)
+
+            QueryWrapper<GradeBatch> gradeBatchQueryWrapper = new QueryWrapper<>();
+            gradeBatchQueryWrapper.lambda().eq(GradeBatch::getThirdExamId, calculateNotifyResult.getExamId())
+                    .eq(GradeBatch::getSource, source);
+            GradeBatch gradeBatch = gradeBatchService.getOne(gradeBatchQueryWrapper);
+            Optional.ofNullable(gradeBatch).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("批次数据为空"));
+
+            if (Objects.isNull(gradeBatch.getNotifyTime()) ||
+                    (Objects.nonNull(gradeBatch.getNotifyTime())
+                            && gradeBatch.getNotifyTime().longValue() <= calculateNotifyResult.getTime().longValue())) {
+                gradeBatch.setStatus(Objects.nonNull(calculateNotifyResult.getStatus()) ? GradeAnalyzePaperStatusEnum.valueOf(calculateNotifyResult.getStatus()) : null);
+                gradeBatch.setProgress(calculateNotifyResult.getProgress());
+                gradeBatch.setNotifyTime(System.currentTimeMillis());
+                gradeBatch.setResult(Objects.nonNull(calculateNotifyResult.getResult()) ? TaskResultEnum.valueOf(calculateNotifyResult.getResult()) : null);
+                gradeBatchService.updateById(gradeBatch);
+
+                QueryWrapper<GradeBatchPaper> gradeBatchPaperQueryWrapper = new QueryWrapper<>();
+                gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getBatchId, gradeBatch.getId());
+
+                List<GradeBatchPaper> gradeBatchPaperList = new ArrayList<>();
+                calculateNotifyResult.getCourseCode().forEach((k, v) -> {
+                    gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getPaperNumber, k)
+                            .eq(GradeBatchPaper::getEnable, true);
+                    GradeBatchPaper gradeBatchPaper = gradeBatchPaperService.getOne(gradeBatchPaperQueryWrapper);
+                    Optional.ofNullable(gradeBatchPaper).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("批次科目[" + k + "]数据为空"));
+
+                    if (Objects.isNull(gradeBatchPaper.getStatus()) || (Objects.nonNull(gradeBatchPaper.getStatus()) && gradeBatchPaper.getStatus() != v)) {
+                        gradeBatchPaper.setStatus(v);
+                        gradeBatchPaper.setUpdateTime(System.currentTimeMillis());
+                        gradeBatchPaperList.add(gradeBatchPaper);
+                    }
+                });
+                gradeBatchPaperService.updateBatchById(gradeBatchPaperList);
+            }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {

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

@@ -166,7 +166,6 @@ public class TSAuthController {
                     2022052700001L + "G"));//试卷编号+卷型
             String source = Base64Util.encode(ShaUtils.sha1(map.get("examId") + map.get("courseCode").toString()));
             log.info("source:{}", source);
-            //TODO 更新grade_batch source
             String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, dictionaryConfig.reportOpenDomain().getCalculateApi(), timestamp, basicSchool.getAccessKey(), basicSchool.getAccessSecret());
             String result = HttpUtil.postJson(dictionaryConfig.reportOpenDomain().getHostUrl() + dictionaryConfig.reportOpenDomain().getCalculateApi(), JacksonUtil.parseJson(map), accessToken, timestamp);
             if (Objects.nonNull(result)) {

+ 9 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicAttachmentServiceImpl.java

@@ -102,9 +102,15 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
                 localPdfFile.getParentFile().mkdirs();
                 localPdfFile.createNewFile();
             }
+            boolean oss = dictionaryConfig.sysDomain().isOss();
             JSONObject jsonPdf = new JSONObject();
-            jsonPdf.put(SystemConstant.TYPE, SystemConstant.OSS);
-            jsonPdf.put(SystemConstant.PATH, dirName);
+            if (oss) {
+                jsonPdf.put(SystemConstant.TYPE, SystemConstant.OSS);
+                jsonPdf.put(SystemConstant.PATH, dirName);
+            } else {
+                jsonPdf.put(SystemConstant.TYPE, SystemConstant.LOCAL);
+                jsonPdf.put(SystemConstant.PATH, localPdfFile);
+            }
             jsonPdf.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.PDF);
             basicAttachment = new BasicAttachment(jsonPdf.toJSONString(), localPdfFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localPdfFile.length()), DigestUtils.md5Hex(new FileInputStream(localPdfFile)), userId);
             save(basicAttachment);
@@ -200,7 +206,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
             stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(format);
             if (oss) {//上传至oss\
                 String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
-                fileStoreUtil.ossUpload(dirName,file.getInputStream(),DigestUtils.md5Hex(file.getInputStream()),type.getFssType());
+                fileStoreUtil.ossUpload(dirName, file.getInputStream(), DigestUtils.md5Hex(file.getInputStream()), type.getFssType());
                 jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
                 jsonObject.put(SystemConstant.PATH, dirName);
             } else {//上传至服务器

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

@@ -585,7 +585,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         String filePath = (String) jsonObject.get(SystemConstant.PATH);
         UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
         if (Objects.equals(attachmentType, SystemConstant.LOCAL)) {
-            url = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;
+            url = SystemConstant.HTTP + dictionaryConfig.sysDomain().getFileHost() + filePath;
         } else {
 //            if (uploadFileEnum == UploadFileEnum.PAPER) {
 //                url = ossUtil.getPrivateUrl(filePath);
@@ -773,11 +773,17 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         String filePath = pdf ? (String) jsonObject.get(SystemConstant.PDF_PATH) : (String) jsonObject.get(SystemConstant.PATH);
         UploadFileEnum uploadType = Enum.valueOf(UploadFileEnum.class, (String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
 
-        StringJoiner localPath = new StringJoiner("").add(SystemConstant.TEMP_FILES_DIR).add(File.separator).add(filePath);
+        StringJoiner localPath = new StringJoiner("");
         if (Objects.equals(attachmentType, SystemConstant.OSS)) {
 //            file = ossUtil.ossDownload(filePath, localPath.toString());
+            localPath = localPath.add(SystemConstant.TEMP_FILES_DIR).add(File.separator).add(filePath);
             file = fileStoreUtil.ossDownload(filePath, localPath.toString(), uploadType.getFssType());
         } else {
+            if (!filePath.contains(SystemConstant.TEMP_FILES_DIR)) {
+                localPath = localPath.add(SystemConstant.TEMP_FILES_DIR).add(File.separator).add(filePath);
+            } else {
+                localPath = localPath.add(filePath);
+            }
             file = new File(localPath.toString());
         }
         return file;

+ 1 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CalculateTaskTemplate.java

@@ -150,6 +150,7 @@ public abstract class CalculateTaskTemplate {
         jsonObject.put("courseCode", calculateParams.getCourseCodeMap());
         jsonObject.put("progress", tbSyncTask.getProgress());
         jsonObject.put("status", tbSyncTask.getStatus());
+        jsonObject.put("result", tbSyncTask.getResult());
         jsonObject.put("time", time);
 
         String sign = URLEncoder.encode(Base64Util.encode(ShaUtils.sha1(dictionaryConfig.printOpenDomain().getCallbackPwd() + jsonObject.toJSONString())), SystemConstant.CHARSET_NAME);

+ 0 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CourseCodeSyncTaskService.java

@@ -44,7 +44,6 @@ public class CourseCodeSyncTaskService extends CalculateTaskTemplate {
         tbSyncTask.setStatus(TaskStatusEnum.DATA_VALID);
         updateProgress(calculateParams);
 
-        //TODO 此处加校验数据具体逻辑方法,推荐service方法然后加@Transactional注解
         analyzeDataCheckService.analyzeDataCheck(calculateParams);
     }
 
@@ -67,7 +66,6 @@ public class CourseCodeSyncTaskService extends CalculateTaskTemplate {
 //        tbSyncTask.setObj(jsonObject.toJSONString());
 //        updateProgress(calculateParams);
 
-        //TODO 此处加计算数据具体逻辑方法,推荐service方法然后加@Transactional注解
         analyzeDataCalculateService.dataCalculateStart(calculateParams);
     }
 }

+ 4 - 4
teachcloud-task/src/main/resources/application-task.properties

@@ -20,7 +20,7 @@ db.password=123456789
 #redis\u6570\u636E\u6E90\u914D\u7F6E
 com.qmth.redis.host=${db.host}
 com.qmth.redis.port=6379
-com.qmth.redis.db=15
+com.qmth.redis.db=1
 #com.qmth.redis.password
 
 #mysql\u914D\u7F6E
@@ -62,7 +62,7 @@ com.qmth.fss.private.config=oss://key:secret@teachcloud-print-dev-private.oss-ap
 com.qmth.fss.private.server=http://oss-file.qmth.com.cn/teachcloud-print-dev-private
 
 #\u7CFB\u7EDF\u914D\u7F6E
-sys.config.oss=true
+sys.config.oss=false
 sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav,.dll,.exe,.ftl,.bpmn,.xml
 sys.config.attachmentLength=100
 sys.config.attachmentSize=200
@@ -74,8 +74,8 @@ sys.config.serverHost=localhost:7011
 sys.config.accessKey=274f823e5f59410f8b3bb6edcd8e2b6e
 sys.config.accessSecret=y7AO6W0TOdTF8HpWBwGHbp3wfIHsmUKr
 sys.config.adminLogoUrl=http://qmth-test.oss-cn-shenzhen.aliyuncs.com/frontend/wx_logo.png
-#sys.config.htmlToPdfUrl=/usr/local/bin/wkhtmltopdf
-sys.config.htmlToPdfUrl=E:/devUtils/wkhtmltopdf/bin/wkhtmltopdf.exe
+sys.config.htmlToPdfUrl=/usr/local/bin/wkhtmltopdf
+#sys.config.htmlToPdfUrl=E:/devUtils/wkhtmltopdf/bin/wkhtmltopdf.exe
 sys.config.autoCreatePdfResetMaxCount=5
 sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=true