Bladeren bron

Merge remote-tracking branch 'origin/dev_v3.1.0' into dev_v3.1.0

wangliang 3 jaren geleden
bovenliggende
commit
1c1bac7ad0

+ 17 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncExamStudentScoreServiceImpl.java

@@ -176,9 +176,11 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
                     }
                     jsonImageTrajectoryPathArray.add(dirTargetJpgName.toString());
                 }
-                if (Objects.nonNull(jsonImageTrajectoryPathArray) && jsonImageTrajectoryPathArray.size() > 0) {
+                if (!jsonImageTrajectoryPathArray.isEmpty()) {
                     jsonObject.put(SystemConstant.PATH, jsonImageTrajectoryPathArray.toJSONString());
                     tSyncExamStudentScore.setTrajectoryUrls(jsonObject.toJSONString());
+
+                    this.updateById(tSyncExamStudentScore);
                 }
             } else {
                 JSONObject jsonObject = JSONObject.parseObject(tSyncExamStudentScore.getTrajectoryUrls());
@@ -199,13 +201,21 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
                         if (imageTrajectoryEnum == ImageTrajectoryEnum.DOWNLOAD) {
                             fileTargetList.add(new File(stringJoiner.toString() + url));
                         } else {
-                            trailUrlsList.add(stringJoiner.toString() + url);
+                            String hostUrl = SystemConstant.getLocalFileHost(dictionaryConfig.sysDomain().getFileHost());
+                            String trailUrl;
+                            String filePath = stringJoiner + url;
+                            if (filePath.startsWith("/")) {
+                                trailUrl = hostUrl +  filePath;
+                            } else {
+                                trailUrl = hostUrl + File.separator + filePath;
+                            }
+                            trailUrlsList.add(trailUrl);
                         }
                     }
                 }
             }
             tSyncExamStudentScore.setTrailUrls(trailUrlsList);
-            if (Objects.nonNull(fileTargetList) && fileTargetList.size() > 0) {
+            if (!fileTargetList.isEmpty()) {
                 tSyncExamStudentScore.setTrajectoryFileList(fileTargetList);
             }
         } catch (Exception e) {
@@ -253,6 +263,9 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
                     zipFile.createNewFile();
                 }
                 File[] files = tSyncExamStudentScore.getTrajectoryFileList().get(0).getParentFile().listFiles();
+                if(files == null || files.length == 0){
+                    throw ExceptionResultEnum.ERROR.exception("没有可下载文件");
+                }
                 List<File> fileList = new ArrayList<>(Arrays.asList(files));
                 fileList.removeAll(tSyncExamStudentScore.getTrajectoryFileList());
                 if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
@@ -274,6 +287,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {
             if (Objects.nonNull(outputStream)) {
                 outputStream.flush();

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

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.api;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
@@ -17,10 +19,8 @@ import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
 import com.qmth.distributed.print.business.templete.execute.AsyncScoreBatchDownloadService;
 import com.qmth.distributed.print.business.templete.execute.AsyncScoreExportService;
 import com.qmth.distributed.print.business.templete.execute.AsyncScorePushService;
-import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.BasicExam;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.TBTask;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
@@ -30,6 +30,7 @@ import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.validation.annotation.Validated;
@@ -39,7 +40,6 @@ import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -144,7 +144,11 @@ public class TSyncExamStudentScoreController {
     @Transactional
     public Result preview(@ApiParam(value = "主键", required = true) @RequestParam String id) throws Exception {
         TSyncExamStudentScore tSyncExamStudentScore = downloadOrPreview(id, ImageTrajectoryEnum.PREVIEW);
-        return ResultUtil.ok(tSyncExamStudentScore.getTrailUrls());
+        JSONObject jsonObject = new JSONObject();
+        String sheetUrlString = tSyncExamStudentScore.getSheetUrls();
+        jsonObject.put("sheetUrls", StringUtils.isBlank(sheetUrlString) ? new ArrayList<>() : JSON.parseArray(sheetUrlString, String.class));
+        jsonObject.put("trailUrls", tSyncExamStudentScore.getTrailUrls().isEmpty() ? new ArrayList<>() : tSyncExamStudentScore.getTrailUrls());
+        return ResultUtil.ok(jsonObject);
     }
 
     @ApiOperation(value = "成绩动态轨迹图一键下载")
@@ -197,7 +201,7 @@ public class TSyncExamStudentScoreController {
     private TSyncExamStudentScore downloadOrPreview(String id, ImageTrajectoryEnum imageTrajectoryEnum) {
         TSyncExamStudentScore tSyncExamStudentScore = tSyncExamStudentScoreService.getById(SystemConstant.convertIdToLong(id));
         Optional.ofNullable(tSyncExamStudentScore).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到此考生信息"));
-        boolean update = Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls()) ? true : false;
+        boolean update = Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls());
         tSyncExamStudentScore = tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, imageTrajectoryEnum);
         Optional.ofNullable(tSyncExamStudentScore.getTrajectoryUrls()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("阅卷方式未使用轨迹阅卷,无轨迹图"));
         if (update || Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {