فهرست منبع

图片生成类

wangliang 3 سال پیش
والد
کامیت
972ac8bdd2

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TSyncExamStudentScoreResult.java

@@ -47,6 +47,9 @@ public class TSyncExamStudentScoreResult implements Serializable {
     @ApiModelProperty(value = "学号")
     String studentCode;
 
+    @ApiModelProperty(value = "准考证号")
+    String examNumber;
+
     @ApiModelProperty(value = "学院id")
     @JsonSerialize(using = ToStringSerializer.class)
     Long orgId;
@@ -106,6 +109,14 @@ public class TSyncExamStudentScoreResult implements Serializable {
     @ApiModelProperty(value = "主观题分数")
     private Double subjectiveScore;
 
+    public String getExamNumber() {
+        return examNumber;
+    }
+
+    public void setExamNumber(String examNumber) {
+        this.examNumber = examNumber;
+    }
+
     public Long getExamId() {
         return examId;
     }

+ 33 - 19
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TSyncExamStudentScore.java

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.File;
 import java.io.Serializable;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -105,18 +106,22 @@ public class TSyncExamStudentScore implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Long createTime;
 
-    @ApiModelProperty(value = "轨迹图路径")
-    @TableField(exist = false)
-    private String path;
+    @ApiModelProperty(value = "专业id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long majorId;
+
+    @ApiModelProperty(value = "班级id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long clazzId;
 
     @ApiModelProperty(value = "轨迹图文件")
     @TableField(exist = false)
-    private File trajectoryFile;
+    private List<File> trajectoryFileList;
 
     public void setErrorInfo() {
-        this.trajectoryFile = null;
+        this.trajectoryFileList = null;
         this.trajectoryUrls = null;
-        this.path = null;
+//        this.path = null;
     }
 
     public TSyncExamStudentScore() {
@@ -128,6 +133,8 @@ public class TSyncExamStudentScore implements Serializable {
         this.schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
         this.orgId = (Long) map.get("orgId");
         this.semesterId = (Long) map.get("semesterId");
+        this.majorId = (Long) map.get("majorId");
+        this.clazzId = (Long) map.get("clazzId");
         this.examId = Long.parseLong(String.valueOf(map.get("examId")));
         this.examCode = (String) map.get("examCode");
         this.examNumber = (String) map.get("examNumber");
@@ -142,7 +149,7 @@ public class TSyncExamStudentScore implements Serializable {
         this.status = (Integer) map.get("status");
         JSONArray jsonArray = (JSONArray) map.get("sheetUrls");
         if (Objects.nonNull(jsonArray) && jsonArray.size() > 0) {
-            this.sheetUrls = jsonArray.get(0).toString();
+            this.sheetUrls = jsonArray.toJSONString();
         }
         this.totalScore = Double.parseDouble(String.valueOf(map.get("totalScore")));
         this.objectiveScore = Double.parseDouble(String.valueOf(map.get("objectiveScore")));
@@ -153,36 +160,43 @@ public class TSyncExamStudentScore implements Serializable {
         JSONObject jsonObject = new JSONObject();
         JSONArray objectiveScoreDetailJsonArray = (JSONArray) map.get("objectiveScoreDetail");
         JSONArray subjectiveScoreDetailJsonArray = (JSONArray) map.get("subjectiveScoreDetail");
-        JSONArray markTagsJsonArray = (JSONArray) map.get("markTags");
+        JSONObject markTagsJsonObject = (JSONObject) map.get("markTags");
         if (Objects.nonNull(objectiveScoreDetailJsonArray) && objectiveScoreDetailJsonArray.size() > 0) {
             jsonObject.put("objectiveScoreDetail", objectiveScoreDetailJsonArray.toJSONString());
         }
         if (Objects.nonNull(subjectiveScoreDetailJsonArray) && subjectiveScoreDetailJsonArray.size() > 0) {
             jsonObject.put("subjectiveScoreDetail", subjectiveScoreDetailJsonArray.toJSONString());
         }
-        if (Objects.nonNull(markTagsJsonArray) && markTagsJsonArray.size() > 0) {
-            jsonObject.put("markTags", markTagsJsonArray.toJSONString());
-            System.out.println("studentCode markTags:" + this.studentCode);
+        if (Objects.nonNull(markTagsJsonObject)) {
+            jsonObject.put("markTags", markTagsJsonObject.toJSONString());
         }
         if (!jsonObject.isEmpty()) {
             this.syncData = jsonObject.toJSONString();
         }
     }
 
-    public String getPath() {
-        return path;
+    public Long getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(Long clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public Long getMajorId() {
+        return majorId;
     }
 
-    public void setPath(String path) {
-        this.path = path;
+    public void setMajorId(Long majorId) {
+        this.majorId = majorId;
     }
 
-    public File getTrajectoryFile() {
-        return trajectoryFile;
+    public List<File> getTrajectoryFileList() {
+        return trajectoryFileList;
     }
 
-    public void setTrajectoryFile(File trajectoryFile) {
-        this.trajectoryFile = trajectoryFile;
+    public void setTrajectoryFileList(List<File> trajectoryFileList) {
+        this.trajectoryFileList = trajectoryFileList;
     }
 
     public Long getSemesterId() {

+ 4 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TBSyncTaskServiceImpl.java

@@ -11,12 +11,10 @@ import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.PushTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
-import com.qmth.teachcloud.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * @Date: 2021/5/20.
@@ -50,10 +48,10 @@ public class TBSyncTaskServiceImpl extends ServiceImpl<TBSyncTaskMapper, TBSyncT
     @Transactional
     @Override
     public TBSyncTask savePushCommon(PushTypeEnum pushTypeEnum, Map map, SysUser sysUser) {
-        SysUser requestUser = Objects.nonNull(sysUser) ? sysUser : (SysUser) ServletUtil.getRequestUser();
-//        SysUser requestUser = new SysUser();
-//        requestUser.setId(187219022012481536L);
-//        requestUser.setSchoolId(2L);
+//        SysUser requestUser = Objects.nonNull(sysUser) ? sysUser : (SysUser) ServletUtil.getRequestUser();
+        SysUser requestUser = new SysUser();
+        requestUser.setId(187219022012481536L);
+        requestUser.setSchoolId(2L);
         TBSyncTask tbSyncTask = new TBSyncTask(pushTypeEnum,
                 TaskStatusEnum.INIT,
                 requestUser.getId(),

+ 66 - 47
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncExamStudentScoreServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -11,6 +12,7 @@ import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
 import com.qmth.teachcloud.common.util.FileStoreUtil;
@@ -24,10 +26,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileInputStream;
 import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.StringJoiner;
+import java.util.*;
 
 /**
  * <p>
@@ -94,74 +93,94 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
      */
     @Override
     public TSyncExamStudentScore createImageTrajectory(TSyncExamStudentScore tSyncExamStudentScore, ImageTrajectoryEnum imageTrajectoryEnum) {
-        File fileSource = null, fileTarget = null;
+        List<File> fileSourceList = new ArrayList<>(), fileTargetList = new ArrayList<>();
         try {
+            Optional.ofNullable(tSyncExamStudentScore.getSheetUrls()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未获取到考生原卷地址"));
             StringJoiner stringJoiner = new StringJoiner("");
             stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
             if (Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {
+                JSONArray jsonArray = JSONArray.parseArray(tSyncExamStudentScore.getSheetUrls());
                 boolean oss = dictionaryConfig.sysDomain().isOss();
-                String format = tSyncExamStudentScore.getSheetUrls().substring(tSyncExamStudentScore.getSheetUrls().lastIndexOf("."), tSyncExamStudentScore.getSheetUrls().length());
-                LocalDateTime nowTime = LocalDateTime.now();
-                StringJoiner dirJpgName = new StringJoiner("");
-                dirJpgName.add(UploadFileEnum.FILE.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()))
-                        .add(File.separator).add(SystemConstant.getUuid()).add(format);
-                fileSource = new File(stringJoiner.toString() + dirJpgName.toString());
-                if (!fileSource.exists()) {
-                    fileSource.getParentFile().mkdirs();
-                    fileSource.createNewFile();
-                }
-                fileSource = HttpUtil.httpDownload(tSyncExamStudentScore.getSheetUrls(), fileSource.getPath());
-
-                StringJoiner dirTargetJpgName = new StringJoiner("");
-                dirTargetJpgName.add(UploadFileEnum.FILE.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()))
-                        .add(File.separator).add(SystemConstant.getUuid()).add(format);
-                fileTarget = new File(stringJoiner.toString() + dirTargetJpgName.toString());
-                if (!fileTarget.exists()) {
-                    fileTarget.getParentFile().mkdirs();
-                    fileTarget.createNewFile();
-                }
-
-                ImageTrajectoryUtil.createImage(fileSource, fileTarget, 10, 10);
                 JSONObject jsonObject = new JSONObject();
                 jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
                 if (oss) {
-                    fileStoreUtil.ossUpload(dirTargetJpgName.toString(), fileTarget, DigestUtils.md5Hex(new FileInputStream(fileTarget)), UploadFileEnum.FILE.getFssType());
                     jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
-                    jsonObject.put(SystemConstant.PATH, dirTargetJpgName.toString());
-                    tSyncExamStudentScore.setPath(teachcloudCommonService.filePreview(jsonObject.toJSONString()));
                 } else {
                     jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
-                    jsonObject.put(SystemConstant.PATH, dirTargetJpgName.toString());
-                    tSyncExamStudentScore.setPath(stringJoiner.toString() + dirTargetJpgName.toString());
                 }
+                JSONArray jsonImageTrajectoryPathArray = new JSONArray();
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    String url = (String) jsonArray.get(i);
+                    String format = url.substring(url.lastIndexOf("."), url.length());
+                    LocalDateTime nowTime = LocalDateTime.now();
+                    StringJoiner dirJpgName = new StringJoiner("");
+                    dirJpgName.add(UploadFileEnum.FILE.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()))
+                            .add(File.separator)
+                            .add(tSyncExamStudentScore.getExamNumber())
+                            .add(File.separator).add(SystemConstant.getUuid()).add(format);
+                    File fileSource = new File(stringJoiner.toString() + dirJpgName.toString());
+                    if (!fileSource.exists()) {
+                        fileSource.getParentFile().mkdirs();
+                        fileSource.createNewFile();
+                    }
+                    fileSource = HttpUtil.httpDownload(url, fileSource.getPath());
+                    fileSourceList.add(fileSource);
+
+                    StringJoiner dirTargetJpgName = new StringJoiner("");
+                    dirTargetJpgName.add(UploadFileEnum.FILE.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()))
+                            .add(File.separator)
+                            .add(tSyncExamStudentScore.getExamNumber())
+                            .add(File.separator).add(SystemConstant.getUuid()).add(format);
+                    File fileTarget = new File(stringJoiner.toString() + dirTargetJpgName.toString());
+                    if (!fileTarget.exists()) {
+                        fileTarget.getParentFile().mkdirs();
+                        fileTarget.createNewFile();
+                    }
+                    ImageTrajectoryUtil.createImage(fileSource, fileTarget, 10, 10);
+                    fileTargetList.add(fileTarget);
+                    if (oss) {
+                        fileStoreUtil.ossUpload(dirTargetJpgName.toString(), fileTarget, DigestUtils.md5Hex(new FileInputStream(fileTarget)), UploadFileEnum.FILE.getFssType());
+                    }
+                    jsonImageTrajectoryPathArray.add(dirTargetJpgName.toString());
+                }
+                jsonObject.put(SystemConstant.PATH, jsonImageTrajectoryPathArray.toJSONString());
                 tSyncExamStudentScore.setTrajectoryUrls(jsonObject.toJSONString());
             } else {
                 JSONObject jsonObject = JSONObject.parseObject(tSyncExamStudentScore.getTrajectoryUrls());
                 String ossType = (String) jsonObject.get(SystemConstant.TYPE);
+                JSONArray jsonArray = JSONArray.parseArray(jsonObject.get(SystemConstant.PATH).toString());
                 if (Objects.equals(ossType, SystemConstant.OSS)) {
-                    tSyncExamStudentScore.setPath(teachcloudCommonService.filePreview(jsonObject.toJSONString()));
-                    fileTarget = fileStoreUtil.ossDownload(jsonObject.get(SystemConstant.PATH).toString(), stringJoiner.toString() + jsonObject.get(SystemConstant.PATH).toString(), UploadFileEnum.FILE.getFssType());
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        String url = (String) jsonArray.get(i);
+                        fileTargetList.add(fileStoreUtil.ossDownload(url, stringJoiner.toString() + url, UploadFileEnum.FILE.getFssType()));
+                    }
                 } else {
-                    tSyncExamStudentScore.setPath(stringJoiner.toString() + jsonObject.get(SystemConstant.PATH));
-                    fileTarget = new File(stringJoiner.toString() + jsonObject.get(SystemConstant.PATH).toString());
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        String url = (String) jsonArray.get(i);
+                        fileTargetList.add(new File(stringJoiner.toString() + url));
+                    }
                 }
             }
-            tSyncExamStudentScore.setTrajectoryFile(fileTarget);
+            tSyncExamStudentScore.setTrajectoryFileList(fileTargetList);
         } catch (Exception e) {
             e.printStackTrace();
             tSyncExamStudentScore.setErrorInfo();
-            if (Objects.nonNull(fileTarget)) {
-                fileTarget.delete();
+            if (Objects.nonNull(fileTargetList)) {
+                for (File f : fileTargetList) {
+                    f.delete();
+                }
             }
         } finally {
-            if (Objects.nonNull(fileSource)) {
-                fileSource.delete();
+            if (Objects.nonNull(fileSourceList)) {
+                for (File f : fileSourceList) {
+                    f.delete();
+                }
             }
         }
         return tSyncExamStudentScore;

+ 14 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PushLogicServiceImpl.java

@@ -102,11 +102,16 @@ public class PushLogicServiceImpl implements PushLogicService {
         Long schoolId = 2L;
         Integer examId = (Integer) map.get("examId");
         String examCode = (String) map.get("examCode");
+
+        //测试
+        String examNumber = "1503495";
+        String studentCode = "106561095131004";
+
         Long examIdLong = Long.parseLong(String.valueOf(examId));
         List<TSyncExamStudentScore> tSyncExamStudentScoreList = null;
         List<String> errorTSyncExamStudentScoreList = null;
         try {
-            int totalCount = stmmsUtils.getStudentCount(schoolId, examId, examCode, null, null, null, null, null, null);
+            int totalCount = stmmsUtils.getStudentCount(schoolId, examId, examCode, examNumber, studentCode, null, null, null, null, true);
             log.info("云阅卷:考试成绩考生数量查询接口调用,返回数量:{}", totalCount);
             if (totalCount > 0) {
                 int pageSize = stmmsUtils.getDefaultPageSize();
@@ -118,7 +123,7 @@ public class PushLogicServiceImpl implements PushLogicService {
                 tSyncExamStudentScoreList = new ArrayList<>();
                 errorTSyncExamStudentScoreList = new ArrayList<>();
                 for (int i = 1; i <= pageNos; i++) {
-                    List<Map> students = stmmsUtils.getStudentScore(schoolId, examId, examCode, null, null, null, null, null, null, i, pageSize);
+                    List<Map> students = stmmsUtils.getStudentScore(schoolId, examId, examCode, examNumber, studentCode, null, null, null, null, true, i, pageSize);
                     for (Map student : students) {
                         try {
                             //查学院id
@@ -150,17 +155,20 @@ public class PushLogicServiceImpl implements PushLogicService {
                             student.put("semesterId", semesterId);
                             student.put("orgId", orgId);
                             student.put("clazzId", clazzId);
+                            student.put("majorId", majorId);
                             student.put("userId", 2L);
                             tSyncExamStudentScoreList.add(new TSyncExamStudentScore(student));
                         } catch (Exception e) {
                             log.info("同步学生成绩信息失败:{}", e.getMessage());
                             e.printStackTrace();
-                            errorTSyncExamStudentScoreList.add(student.get("name") + "," + student.get("studentCode") + "\r\n");
+                            errorTSyncExamStudentScoreList.add(student.get("name") + "," + student.get("examNumber") + "\r\n");
                         }
                     }
                 }
-                tSyncExamStudentScoreService.remove(new QueryWrapper<TSyncExamStudentScore>().lambda().eq(TSyncExamStudentScore::getSchoolId, schoolId).eq(TSyncExamStudentScore::getExamId, examIdLong));
-                tSyncExamStudentScoreService.saveOrUpdateBatch(tSyncExamStudentScoreList);
+                if (tSyncExamStudentScoreList.size() > 0) {
+                    tSyncExamStudentScoreService.remove(new QueryWrapper<TSyncExamStudentScore>().lambda().eq(TSyncExamStudentScore::getSchoolId, schoolId).eq(TSyncExamStudentScore::getExamId, examIdLong));
+                    tSyncExamStudentScoreService.saveOrUpdateBatch(tSyncExamStudentScoreList);
+                }
             }
             map.computeIfAbsent("count", v -> totalCount);
             List<TSyncExamStudentScore> finalTSyncExamStudentScoreList = tSyncExamStudentScoreList;
@@ -169,8 +177,7 @@ public class PushLogicServiceImpl implements PushLogicService {
                 List<String> finalErrorTSyncExamStudentScoreList = errorTSyncExamStudentScoreList;
                 map.computeIfAbsent("error", v -> "未同步成功数据" + finalErrorTSyncExamStudentScoreList.size() + "条:\r\n" + finalErrorTSyncExamStudentScoreList.toString());
             }
-        } catch (
-                Exception e) {
+        } catch (Exception e) {
             log.info("云阅卷:接口调用失败:{}", e.getMessage());
             throw new RuntimeException("云阅卷:接口调用失败:" + e.getMessage());
         }

+ 18 - 14
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -1459,8 +1459,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
             Long semesterId = null, orgId = null, majorId = null, clazzId = null;
             String courseCode = null;
-            semesterId = Objects.nonNull(map.get("semesterId")) ? (Long) map.get(semesterId) : null;
-            orgId = Objects.nonNull(map.get("orgId")) ? (Long) map.get(orgId) : null;
+            semesterId = Objects.nonNull(map.get("semesterId")) ? (Long) map.get("semesterId") : null;
+            orgId = Objects.nonNull(map.get("orgId")) ? (Long) map.get("orgId") : null;
             majorId = Objects.nonNull(map.get("majorId")) ? (Long) map.get("majorId") : null;
             clazzId = Objects.nonNull(map.get("clazzId")) ? (Long) map.get("clazzId") : null;
             courseCode = Objects.nonNull(map.get("courseCode")) ? (String) map.get("courseCode") : null;
@@ -1483,20 +1483,25 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     zipFile.getParentFile().mkdirs();
                     zipFile.createNewFile();
                 }
-                sourceFiles = new ArrayList<>();
+                sourceFiles = new LinkedList<>();
                 List<TSyncExamStudentScore> updateTSyncExamStudentScoreList = new ArrayList<>();
                 errorTSyncExamStudentScoreList = new ArrayList<>();
                 for (TSyncExamStudentScore t : tSyncExamStudentScoreList) {
-                    boolean update = Objects.isNull(t.getTrajectoryUrls()) ? true : false;
-                    t = tSyncExamStudentScoreService.createImageTrajectory(t, ImageTrajectoryEnum.DOWNLOAD);
-                    if (Objects.nonNull(t.getTrajectoryUrls())) {
-                        sourceFiles.add(t.getTrajectoryFile());
-                    } else {
+                    try {
+                        boolean update = Objects.isNull(t.getTrajectoryUrls()) ? true : false;
+                        t = tSyncExamStudentScoreService.createImageTrajectory(t, ImageTrajectoryEnum.DOWNLOAD);
+                        if (Objects.nonNull(t.getTrajectoryFileList())) {
+                            sourceFiles.add(t.getTrajectoryFileList().get(0).getParentFile());
+                        } else {
+                            errorTSyncExamStudentScoreList.add(t);
+                        }
+                        if (update || Objects.isNull(t.getTrajectoryUrls())) {
+                            updateTSyncExamStudentScoreList.add(t);
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
                         errorTSyncExamStudentScoreList.add(t);
                     }
-                    if (update || Objects.isNull(t.getTrajectoryUrls())) {
-                        updateTSyncExamStudentScoreList.add(t);
-                    }
                 }
                 tSyncExamStudentScoreService.saveOrUpdateBatch(updateTSyncExamStudentScoreList);
                 if (Objects.nonNull(sourceFiles) && sourceFiles.size() > 0) {
@@ -1516,12 +1521,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     tbTask.setResultFilePath(jsonObject.toJSONString());
                 }
             }
-            List<File> finalSourceFiles = sourceFiles;
-            map.computeIfAbsent("count", v -> Objects.isNull(finalSourceFiles) ? 0 : finalSourceFiles.size());
+            map.computeIfAbsent("count", v -> tSyncExamStudentScoreResultList.size());
             if (Objects.nonNull(errorTSyncExamStudentScoreList) && errorTSyncExamStudentScoreList.size() > 0) {
                 StringJoiner stringJoiner = new StringJoiner("").add("\r\n");
                 for (TSyncExamStudentScore t : errorTSyncExamStudentScoreList) {
-                    stringJoiner.add("[").add(t.getStudentCode()).add(",").add(t.getName()).add("]\r\n");
+                    stringJoiner.add("[").add(t.getName()).add(",").add(t.getExamNumber()).add("]\r\n");
                 }
                 List<TSyncExamStudentScore> finalErrorTSyncExamStudentScoreList = errorTSyncExamStudentScoreList;
                 map.computeIfAbsent("error", v -> "其中未下载成功数据" + finalErrorTSyncExamStudentScoreList.size() + "条:" + stringJoiner.toString());

+ 5 - 4
distributed-print-business/src/main/resources/mapper/TSyncExamStudentScoreMapper.xml

@@ -11,6 +11,7 @@
             tsess.exam_code as examCode,
             tsess.name,
             tsess.student_code as studentCode,
+            tsess.exam_number as examNumber,
             so.id as orgId,
             so.name as orgName,
             bm.id as majorId,
@@ -33,11 +34,11 @@
         join basic_student bs2 on
             bs2.student_code = tsess.student_code
         join basic_clazz bc on
-            bc.id = bs2.clazz_id
+            bc.id = tsess.clazz_id
         join exam_student es on
             es.student_code = tsess.student_code
         join basic_major bm on
-            bm.id = bs2.major_id
+            bm.id = tsess.major_id
         join sys_org so on
             so.id = tsess.org_id
     </sql>
@@ -54,10 +55,10 @@
                 and tsess.org_id = #{orgId}
             </if>
             <if test="majorId != null and majorId != ''">
-                and bm.id = #{majorId}
+                and tsess.major_id = #{majorId}
             </if>
             <if test="clazzId != null and clazzId != ''">
-                and bc.id = #{clazzId}
+                and tsess.clazz_id = #{clazzId}
             </if>
             <if test="courseCode != null and courseCode != ''">
                 and tsess.subject_code = #{courseCode}

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

@@ -18,11 +18,12 @@ import com.qmth.distributed.print.business.templete.execute.AsyncScoreExportServ
 import com.qmth.distributed.print.business.templete.execute.AsyncScorePushService;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.TBTask;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.PushTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
+import com.qmth.teachcloud.common.enums.UploadFileEnum;
+import com.qmth.teachcloud.common.util.FileUtil;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -37,11 +38,11 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.io.BufferedOutputStream;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.OutputStream;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.time.LocalDateTime;
+import java.util.*;
 
 /**
  * <p>
@@ -133,23 +134,46 @@ public class TSyncExamStudentScoreController {
     @RequestMapping(value = "/score/download", method = RequestMethod.POST)
     @Transactional
     public void download(@ApiParam(value = "学号", required = true) @RequestParam String studentCode) throws Exception {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+//        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         QueryWrapper<TSyncExamStudentScore> tSyncExamStudentScoreQueryWrapper = new QueryWrapper<>();
-        tSyncExamStudentScoreQueryWrapper.lambda().eq(TSyncExamStudentScore::getSchoolId, sysUser.getSchoolId()).eq(TSyncExamStudentScore::getStudentCode, studentCode);
+        tSyncExamStudentScoreQueryWrapper.lambda().eq(TSyncExamStudentScore::getSchoolId, 2L).eq(TSyncExamStudentScore::getStudentCode, studentCode);
         TSyncExamStudentScore tSyncExamStudentScore = tSyncExamStudentScoreService.getOne(tSyncExamStudentScoreQueryWrapper);
+        Optional.ofNullable(tSyncExamStudentScore).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到此考生信息"));
         boolean update = Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls()) ? true : false;
         tSyncExamStudentScore = tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, ImageTrajectoryEnum.PREVIEW);
         Optional.ofNullable(tSyncExamStudentScore.getTrajectoryUrls()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("资源未获取到,请稍候再试"));
         if (update || Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {
             tSyncExamStudentScoreService.updateById(tSyncExamStudentScore);
         }
+        File zipFile = null;
         OutputStream outputStream = null;
         try {
-            if (Objects.nonNull(tSyncExamStudentScore.getTrajectoryFile())) {
+            if (Objects.nonNull(tSyncExamStudentScore.getTrajectoryFileList())) {
+                StringJoiner stringJoiner = new StringJoiner("");
+                stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
+                LocalDateTime nowTime = LocalDateTime.now();
+                StringJoiner dirZipName = new StringJoiner("");
+                dirZipName.add(UploadFileEnum.FILE.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()))
+                        .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
+                zipFile = new File(stringJoiner.toString() + dirZipName.toString());
+                if (!zipFile.exists()) {
+                    zipFile.getParentFile().mkdirs();
+                    zipFile.createNewFile();
+                }
+                FileUtil.doZip(zipFile, Arrays.asList(tSyncExamStudentScore.getTrajectoryFileList().get(0).getParentFile()));
                 HttpServletResponse response = ServletUtil.getResponse();
-                response.setContentType("image/jpeg");
+//                response.setContentType("image/jpeg");
+//                outputStream = new BufferedOutputStream(response.getOutputStream());
+//                IOUtils.copy(new FileInputStream(zipFile), outputStream);
+                response.reset();
+                response.setHeader("Content-Disposition", "attachment;fileName=" + zipFile.getName());
+                response.addHeader("Content-Length", "" + zipFile.length());
+                response.setContentType("application/octet-stream;charset=UTF-8");
                 outputStream = new BufferedOutputStream(response.getOutputStream());
-                IOUtils.copy(new FileInputStream(tSyncExamStudentScore.getTrajectoryFile()), outputStream);
+                IOUtils.copy(new FileInputStream(zipFile), outputStream);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -158,6 +182,9 @@ public class TSyncExamStudentScoreController {
                 outputStream.flush();
                 outputStream.close();
             }
+            if (Objects.nonNull(zipFile)) {
+                zipFile.delete();
+            }
         }
     }
 

+ 4 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java

@@ -244,7 +244,10 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
      */
     @Override
     public TBTask saveTaskCommon(BasicAttachment basicAttachment, TaskTypeEnum taskTypeEnum, Map map, SysUser sysUser) {
-        SysUser requestUser = Objects.nonNull(sysUser) ? sysUser : (SysUser) ServletUtil.getRequestUser();
+//        SysUser requestUser = Objects.nonNull(sysUser) ? sysUser : (SysUser) ServletUtil.getRequestUser();
+        SysUser requestUser = new SysUser();
+        requestUser.setId(187219022012481536L);
+        requestUser.setSchoolId(2L);
         TBTask tbTask = new TBTask(taskTypeEnum,
                 TaskStatusEnum.INIT,
                 Objects.nonNull(basicAttachment) ? basicAttachment.getName() : null,

+ 10 - 6
teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/StmmsUtils.java

@@ -454,18 +454,20 @@ public class StmmsUtils {
      * @param college
      * @param className
      * @param teacher
+     * @param withMarkTrack
      * @return
      */
-    public int getStudentCount(Long schoolId, Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher) {
+    public int getStudentCount(Long schoolId, Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher, boolean withMarkTrack) {
         Map<String, Object> map = new HashMap<>();
         map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
 //        map.put("examCode", validParam(examCode, null, false, "考试编码"));
-//        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
-//        map.put("studentCode", validParam(studentCode, null, false, "学号"));
+        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
+        map.put("studentCode", validParam(studentCode, null, false, "学号"));
 //        map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
 //        map.put("college", validParam(college, null, false, "学院"));
 //        map.put("className", validParam(className, null, false, "班级"));
 //        map.put("teacher", validParam(teacher, null, false, "教师"));
+        map.put("withMarkTrack", validParam(withMarkTrack, true, false, "评分标记"));
 
         String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();
         String studentCountUrl = dictionaryConfig.syncDataDomain().getStudentCountUrl();
@@ -500,20 +502,22 @@ public class StmmsUtils {
      * @param college
      * @param className
      * @param teacher
+     * @param withMarkTrack
      * @param pageNo
      * @param pageSize
      * @return
      */
-    public List<Map> getStudentScore(Long schoolId, Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher, int pageNo, int pageSize) {
+    public List<Map> getStudentScore(Long schoolId, Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher, boolean withMarkTrack, int pageNo, int pageSize) {
         Map<String, Object> map = new HashMap<>();
         map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
 //        map.put("examCode", validParam(examCode, null, false, "考试编码"));
-//        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
-//        map.put("studentCode", validParam(studentCode, null, false, "学号"));
+        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
+        map.put("studentCode", validParam(studentCode, null, false, "学号"));
 //        map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
 //        map.put("college", validParam(college, null, false, "学院"));
 //        map.put("className", validParam(className, null, false, "班级"));
 //        map.put("teacher", validParam(teacher, null, false, "教师"));
+        map.put("withMarkTrack", validParam(withMarkTrack, true, false, "评分标记"));
         map.put("pageNumber", validParam(String.valueOf(pageNo), null, true, "页码"));
         map.put("pageSize", validParam(String.valueOf(pageSize), null, true, "数量"));