浏览代码

成绩查询和导出

wangliang 3 年之前
父节点
当前提交
626a4aefad
共有 16 个文件被更改,包括 794 次插入27 次删除
  1. 0 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/TSchoolPrivilegeParam.java
  2. 301 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TSyncExamStudentScoreResult.java
  3. 13 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TSyncExamStudentScore.java
  4. 43 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TSyncExamStudentScoreMapper.java
  5. 17 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  6. 40 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TSyncExamStudentScoreService.java
  7. 50 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceServiceImpl.java
  8. 43 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncExamStudentScoreServiceImpl.java
  9. 65 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncScoreExportService.java
  10. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java
  11. 47 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  12. 85 0
      distributed-print-business/src/main/resources/mapper/TSyncExamStudentScoreMapper.xml
  13. 7 4
      distributed-print/src/main/java/com/qmth/distributed/print/api/MenuCustomController.java
  14. 72 2
      distributed-print/src/main/java/com/qmth/distributed/print/api/TSyncExamStudentScoreController.java
  15. 3 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/TaskTypeEnum.java
  16. 0 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java

+ 0 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/TSchoolPrivilegeParam.java

@@ -5,8 +5,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.entity.TSchoolPrivilege;
 
-import javax.validation.constraints.NotEmpty;
-
 /**
  * @Description: 学校自定义菜单 param
  * @Param:
@@ -18,7 +16,6 @@ import javax.validation.constraints.NotEmpty;
 public class TSchoolPrivilegeParam extends TSchoolPrivilege {
 
     @JsonSerialize(using = ToStringSerializer.class)
-    @NotEmpty(message = "权限集合不能为空")
     private Long[] privilegeIds;
 
     public Long[] getPrivilegeIds() {

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

@@ -0,0 +1,301 @@
+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.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * @Description: 成绩同步result
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/11/1
+ */
+public class TSyncExamStudentScoreResult implements Serializable {
+
+    @ApiModelProperty(value = "主键")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long id;
+
+    @ApiModelProperty(value = "学期id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long semesterId;
+
+    @ExcelProperty(name = "学期", width = 30, index = 1)
+    @ApiModelProperty(value = "学期")
+    String semesterName;
+
+    @ExcelProperty(name = "姓名", width = 30, index = 2)
+    @ApiModelProperty(value = "考生姓名")
+    String examStudentName;
+
+    @ExcelProperty(name = "学号", width = 30, index = 3)
+    @ApiModelProperty(value = "学号")
+    String studentCode;
+
+    @ApiModelProperty(value = "学院id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long orgId;
+
+    @ExcelProperty(name = "院系", width = 30, index = 4)
+    @ApiModelProperty(value = "学院名称")
+    String orgName;
+
+    @ApiModelProperty(value = "专业id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long majorId;
+
+    @ApiModelProperty(value = "专业名称")
+    @ExcelProperty(name = "专业", width = 30, index = 5)
+    String majorName;
+
+    @ApiModelProperty(value = "班级id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long clazzId;
+
+    @ExcelProperty(name = "班级", width = 30, index = 6)
+    @ApiModelProperty(value = "班级")
+    String clazzName;
+
+    @ApiModelProperty(value = "课程编码")
+    String courseCode;
+
+    @ExcelProperty(name = "课程名称", width = 30, index = 7)
+    @ApiModelProperty(value = "课程名称")
+    String courseName;
+
+    @ApiModelProperty(value = "考生状态,1-正常,2-缺考(包含未上传),3-违纪")
+    Integer status;
+
+    @ApiModelProperty(value = "考生状态")
+    String statusStr;
+
+    @ApiModelProperty(value = "轨迹图url")
+    String trajectoryUrls;
+
+    @ApiModelProperty(value = "轨迹坐标")
+    String trajectoryCoordinate;
+
+    @ApiModelProperty(value = "同步时间")
+    Long syncTime;
+
+    @ApiModelProperty(value = "原卷url")
+    private String sheetUrls;
+
+    @ExcelProperty(name = "成绩总分", width = 30, index = 8)
+    @ApiModelProperty(value = "总分")
+    private Double totalScore;
+
+    @ApiModelProperty(value = "客观题分数")
+    private Double objectiveScore;
+
+    @ApiModelProperty(value = "主观题分数")
+    private Double subjectiveScore;
+
+    @ApiModelProperty(value = "轨迹图是否生成,1:已生成,0:未生成")
+    private Boolean trajectory;
+
+    public String getSemesterName() {
+        return semesterName;
+    }
+
+    public void setSemesterName(String semesterName) {
+        this.semesterName = semesterName;
+    }
+
+    public String getExamStudentName() {
+        return examStudentName;
+    }
+
+    public void setExamStudentName(String examStudentName) {
+        this.examStudentName = examStudentName;
+    }
+
+    public String getStatusStr() {
+        if (Objects.nonNull(getStatus())) {
+            String statusStr = null;
+            switch (getStatus()) {
+                case 1:
+                    statusStr = "正常";
+                    break;
+                case 2:
+                    statusStr = "缺考";
+                    break;
+                default:
+                    statusStr = "违纪";
+                    break;
+            }
+            return statusStr;
+        } else {
+            return statusStr;
+        }
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getSemesterId() {
+        return semesterId;
+    }
+
+    public void setSemesterId(Long semesterId) {
+        this.semesterId = semesterId;
+    }
+
+    public String getStudentCode() {
+        return studentCode;
+    }
+
+    public void setStudentCode(String studentCode) {
+        this.studentCode = studentCode;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public Long getMajorId() {
+        return majorId;
+    }
+
+    public void setMajorId(Long majorId) {
+        this.majorId = majorId;
+    }
+
+    public String getMajorName() {
+        return majorName;
+    }
+
+    public void setMajorName(String majorName) {
+        this.majorName = majorName;
+    }
+
+    public Long getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(Long clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public String getClazzName() {
+        return clazzName;
+    }
+
+    public void setClazzName(String clazzName) {
+        this.clazzName = clazzName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public void setStatusStr(String statusStr) {
+        this.statusStr = statusStr;
+    }
+
+    public String getTrajectoryUrls() {
+        return trajectoryUrls;
+    }
+
+    public void setTrajectoryUrls(String trajectoryUrls) {
+        this.trajectoryUrls = trajectoryUrls;
+    }
+
+    public String getTrajectoryCoordinate() {
+        return trajectoryCoordinate;
+    }
+
+    public void setTrajectoryCoordinate(String trajectoryCoordinate) {
+        this.trajectoryCoordinate = trajectoryCoordinate;
+    }
+
+    public Long getSyncTime() {
+        return syncTime;
+    }
+
+    public void setSyncTime(Long syncTime) {
+        this.syncTime = syncTime;
+    }
+
+    public String getSheetUrls() {
+        return sheetUrls;
+    }
+
+    public void setSheetUrls(String sheetUrls) {
+        this.sheetUrls = sheetUrls;
+    }
+
+    public Double getTotalScore() {
+        return totalScore;
+    }
+
+    public void setTotalScore(Double totalScore) {
+        this.totalScore = totalScore;
+    }
+
+    public Double getObjectiveScore() {
+        return objectiveScore;
+    }
+
+    public void setObjectiveScore(Double objectiveScore) {
+        this.objectiveScore = objectiveScore;
+    }
+
+    public Double getSubjectiveScore() {
+        return subjectiveScore;
+    }
+
+    public void setSubjectiveScore(Double subjectiveScore) {
+        this.subjectiveScore = subjectiveScore;
+    }
+
+    public Boolean getTrajectory() {
+        return trajectory;
+    }
+
+    public void setTrajectory(Boolean trajectory) {
+        this.trajectory = trajectory;
+    }
+}

+ 13 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TSyncExamStudentScore.java

@@ -15,7 +15,7 @@ import java.io.Serializable;
  * @author wangliang
  * @since 2021-10-28
  */
-@ApiModel(value="TSyncExamStudentScore对象", description="同步考生成绩表")
+@ApiModel(value = "TSyncExamStudentScore对象", description = "同步考生成绩表")
 public class TSyncExamStudentScore implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -40,6 +40,10 @@ public class TSyncExamStudentScore implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long examStudentId;
 
+    @ApiModelProperty(value = "学期id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long semesterId;
+
     @ApiModelProperty(value = "云阅卷考试id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long examId;
@@ -106,6 +110,14 @@ public class TSyncExamStudentScore implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Long createTime;
 
+    public Long getSemesterId() {
+        return semesterId;
+    }
+
+    public void setSemesterId(Long semesterId) {
+        this.semesterId = semesterId;
+    }
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }

+ 43 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TSyncExamStudentScoreMapper.java

@@ -1,7 +1,13 @@
 package com.qmth.distributed.print.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
 import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +19,41 @@ import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
  */
 public interface TSyncExamStudentScoreMapper extends BaseMapper<TSyncExamStudentScore> {
 
+    /**
+     * 同步成绩查询列表
+     *
+     * @param iPage
+     * @param schoolId
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    public IPage<TSyncExamStudentScoreResult> list(IPage<Map> iPage,
+                                                   @Param("schoolId") Long schoolId,
+                                                   @Param("semesterId") Long semesterId,
+                                                   @Param("orgId") Long orgId,
+                                                   @Param("majorId") Long majorId,
+                                                   @Param("clazzId") Long clazzId,
+                                                   @Param("courseCode") String courseCode);
+
+    /**
+     * 成绩导出
+     *
+     * @param schoolId
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    public List<TSyncExamStudentScoreResult> export(@Param("schoolId") Long schoolId,
+                                                    @Param("semesterId") Long semesterId,
+                                                    @Param("orgId") Long orgId,
+                                                    @Param("majorId") Long majorId,
+                                                    @Param("clazzId") Long clazzId,
+                                                    @Param("courseCode") String courseCode);
 }

+ 17 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java

@@ -6,7 +6,6 @@ import com.qmth.distributed.print.business.bean.dto.PdfDto;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
 import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamStudent;
-import com.qmth.distributed.print.business.entity.ExamTaskPrint;
 import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.SysOrg;
@@ -18,6 +17,7 @@ import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
@@ -59,12 +59,13 @@ public interface PrintCommonService {
 
     /**
      * 保存html附件和该html转成pdf的附件
-     * @param fileName 文件名称
+     *
+     * @param fileName    文件名称
      * @param htmlContent html内容
-     * @param userId 创建人
+     * @param userId      创建人
      * @return 附件对象
      */
-    public BasicAttachment saveAttachmentHtmlAndPdf(String fileName, String htmlContent,Long userId) throws IOException;
+    public BasicAttachment saveAttachmentHtmlAndPdf(String fileName, String htmlContent, Long userId) throws IOException;
 
     /**
      * 保存附件公用
@@ -203,6 +204,7 @@ public interface PrintCommonService {
 
     /**
      * 保存推送
+     *
      * @param pushTypeEnum 推送类型
      * @return 结果
      */
@@ -240,6 +242,7 @@ public interface PrintCommonService {
 
     /**
      * 保存考务数据
+     *
      * @param schoolId
      * @param extendFields
      * @param classIds
@@ -250,8 +253,18 @@ public interface PrintCommonService {
 
     /**
      * 生成准考证号
+     *
      * @param serialNumberParams
      * @return
      */
     public String createTempNumber(SerialNumberParams serialNumberParams);
+
+    /**
+     * 保存任务附件(导出)
+     *
+     * @param fos
+     * @param oss
+     * @return
+     */
+    public String saveTaskAttachment(ByteArrayOutputStream fos, boolean oss) throws IOException;
 }

+ 40 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TSyncExamStudentScoreService.java

@@ -1,8 +1,13 @@
 package com.qmth.distributed.print.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
 import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 同步考生成绩表 服务类
@@ -13,4 +18,39 @@ import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
  */
 public interface TSyncExamStudentScoreService extends IService<TSyncExamStudentScore> {
 
+    /**
+     * 同步成绩查询列表
+     *
+     * @param iPage
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    public IPage<TSyncExamStudentScoreResult> list(IPage<Map> iPage,
+                                                   Long semesterId,
+                                                   Long orgId,
+                                                   Long majorId,
+                                                   Long clazzId,
+                                                   String courseCode);
+
+    /**
+     * 成绩导出
+     *
+     * @param schoolId
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    public List<TSyncExamStudentScoreResult> export(Long schoolId,
+                                                    Long semesterId,
+                                                    Long orgId,
+                                                    Long majorId,
+                                                    Long clazzId,
+                                                    String courseCode);
 }

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

@@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.itextpdf.text.DocumentException;
 import com.itextpdf.text.pdf.PdfReader;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.boot.tools.codec.CodecUtils;
 import com.qmth.boot.tools.models.ByteArray;
 import com.qmth.distributed.print.business.bean.dto.PdfDto;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
@@ -19,7 +18,6 @@ import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.service.*;
-import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
 import com.qmth.distributed.print.business.util.PdfUtil;
 import com.qmth.teachcloud.common.bean.dto.MqDto;
@@ -1059,4 +1057,54 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
     public String createTempNumber(SerialNumberParams serialNumberParams) {
         return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());
     }
+
+    /**
+     * 保存任务附件(导出)
+     *
+     * @param fos
+     * @param oss
+     * @return
+     */
+    @Override
+    public String saveTaskAttachment(ByteArrayOutputStream fos, boolean oss) throws IOException {
+        InputStream inputStream = null;
+        JSONObject jsonObject = null;
+        try {
+            inputStream = new ByteArrayInputStream(fos.toByteArray());
+            LocalDateTime nowTime = LocalDateTime.now();
+            StringJoiner stringJoiner = new StringJoiner("");
+            if (!oss) {
+                stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
+            }
+            stringJoiner.add(UploadFileEnum.FILE.getTitle()).add(File.separator);
+            stringJoiner.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(".").add(SystemConstant.XLSX);
+            jsonObject = new JSONObject();
+            if (oss) {//上传至oss
+                String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
+                fileStoreUtil.ossUpload(dirName, inputStream, DigestUtils.md5Hex(new ByteArrayInputStream(fos.toByteArray())), UploadFileEnum.FILE.getFssType());
+                jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
+                jsonObject.put(SystemConstant.PATH, dirName);
+            } else {
+                File finalFile = new File(stringJoiner.toString());
+                if (!finalFile.exists()) {
+                    finalFile.getParentFile().mkdirs();
+                    finalFile.createNewFile();
+                }
+                FileUtils.copyInputStreamToFile(inputStream, finalFile);
+                jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
+                jsonObject.put(SystemConstant.PATH, stringJoiner.toString());
+            }
+            jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (Objects.nonNull(inputStream)) {
+                inputStream.close();
+            }
+        }
+        return Objects.nonNull(jsonObject) ? jsonObject.toJSONString() : null;
+    }
 }

+ 43 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncExamStudentScoreServiceImpl.java

@@ -1,11 +1,19 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
 import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
 import com.qmth.distributed.print.business.mapper.TSyncExamStudentScoreMapper;
 import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 同步考生成绩表 服务实现类
@@ -17,4 +25,39 @@ import org.springframework.stereotype.Service;
 @Service
 public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStudentScoreMapper, TSyncExamStudentScore> implements TSyncExamStudentScoreService {
 
+    @Resource
+    TSyncExamStudentScoreMapper tSyncExamStudentScoreMapper;
+
+    /**
+     * 同步成绩查询列表
+     *
+     * @param iPage
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    @Override
+    public IPage<TSyncExamStudentScoreResult> list(IPage<Map> iPage, Long semesterId, Long orgId, Long majorId, Long clazzId, String courseCode) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        return tSyncExamStudentScoreMapper.list(iPage, sysUser.getSchoolId(), semesterId, orgId, majorId, clazzId, courseCode);
+    }
+
+    /**
+     * 成绩导出
+     *
+     * @param schoolId
+     * @param semesterId
+     * @param orgId
+     * @param majorId
+     * @param clazzId
+     * @param courseCode
+     * @return
+     */
+    @Override
+    public List<TSyncExamStudentScoreResult> export(Long schoolId, Long semesterId, Long orgId, Long majorId, Long clazzId, String courseCode) {
+        return tSyncExamStudentScoreMapper.export(schoolId, semesterId, orgId, majorId, clazzId, courseCode);
+    }
 }

+ 65 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncScoreExportService.java

@@ -0,0 +1,65 @@
+package com.qmth.distributed.print.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
+import com.qmth.distributed.print.business.templete.service.TaskLogicService;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
+import com.qmth.teachcloud.common.enums.TaskStatusEnum;
+import com.qmth.teachcloud.common.service.TBTaskService;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * @Description: 成绩导出
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/11/1
+ */
+@Service
+public class AsyncScoreExportService extends AsyncExportTaskTemplete {
+
+    public static final String OBJ_TITLE = "成绩";
+    private final static Logger log = LoggerFactory.getLogger(AsyncScoreExportService.class);
+
+    @Override
+    public Result exportTask(Map<String, Object> map) {
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
+        tbTask.setStatus(TaskStatusEnum.RUNNING);
+        TBTaskService tbTaskService = SpringContextHolder.getBean(TBTaskService.class);
+        tbTaskService.updateById(tbTask);
+        try {
+            TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
+            Map<String, Object> result = taskLogicService.executeExportScoreLogic(map);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, Long.valueOf(String.valueOf(result.get("count"))), FINISH_SIZE));
+            tbTask.setResult(TaskResultEnum.SUCCESS);
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
+            tbTask.setResult(TaskResultEnum.ERROR);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {//生成txt文件
+            tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
+        }
+        return ResultUtil.ok();
+    }
+}

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java

@@ -107,4 +107,12 @@ public interface TaskLogicService {
      * @throws Exception 异常
      */
     Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception;
+
+    /**
+     * 成绩导出
+     *
+     * @param map
+     * @return
+     */
+    Map<String, Object> executeExportScoreLogic(Map<String, Object> map) throws Exception;
 }

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

@@ -9,12 +9,11 @@ import com.aliyun.oss.common.utils.BinaryUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.common.collect.Lists;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import com.itextpdf.text.DocumentException;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
+import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
 import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.*;
@@ -23,16 +22,11 @@ import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
-import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.excel.*;
 import com.qmth.teachcloud.common.bean.params.ArraysParams;
-import com.qmth.teachcloud.common.bean.params.PushBeforeRoleParam;
-import com.qmth.teachcloud.common.bean.params.UserPushParam;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
 import com.qmth.teachcloud.common.enums.*;
-import com.qmth.teachcloud.common.enums.userPush.BeforeJudgeEnum;
-import com.qmth.teachcloud.common.enums.userPush.SyncStatusEnum;
 import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.*;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
@@ -47,6 +41,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Service;
@@ -165,7 +160,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     TCStatisticsTempService tcStatisticsTempService;
 
     @Resource
-    SysUserRoleService sysUserRoleService;
+    TSyncExamStudentScoreService tSyncExamStudentScoreService;
+
+    @Resource
+    @Lazy
+    PrintCommonService printCommonService;
 
     /**
      * 创建pdf前置条件
@@ -1256,7 +1255,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         checkCode.put(code, name);
                     }
                     // 如果电话有值则检验电话excel中唯一性
-                    if (SystemConstant.strNotNull(phoneNumber)){
+                    if (SystemConstant.strNotNull(phoneNumber)) {
                         if (checkPhoneMap.containsKey(phoneNumber)) {
                             throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【电话号码】:" + phoneNumber);
                         } else {
@@ -1402,6 +1401,45 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
+    /**
+     * 成绩导出
+     *
+     * @param map
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public Map<String, Object> executeExportScoreLogic(Map<String, Object> map) throws Exception {
+        ByteArrayOutputStream fos = null;
+        try {
+            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;
+            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;
+
+            fos = new ByteArrayOutputStream();
+            List<TSyncExamStudentScoreResult> tSyncExamStudentScoreResultList = tSyncExamStudentScoreService.export(sysUser.getSchoolId(), semesterId, orgId, majorId, clazzId, courseCode);
+            ExcelUtil.excelMake(TSyncExamStudentScoreResult.class, tSyncExamStudentScoreResultList, fos);
+            String excelExportFilePath = printCommonService.saveTaskAttachment(fos, (boolean) map.get(SystemConstant.OSS));
+            map.computeIfAbsent("count", v -> Objects.isNull(tSyncExamStudentScoreResultList) ? 0 : tSyncExamStudentScoreResultList.size());
+            TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+            tbTask.setResultFilePath(excelExportFilePath);
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            e.printStackTrace();
+        } finally {
+            if (Objects.nonNull(fos)) {
+                fos.flush();
+                fos.close();
+            }
+        }
+        return map;
+    }
+
 
     public String createTempNumber(SerialNumberParams serialNumberParams) {
         return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());

+ 85 - 0
distributed-print-business/src/main/resources/mapper/TSyncExamStudentScoreMapper.xml

@@ -2,4 +2,89 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.distributed.print.business.mapper.TSyncExamStudentScoreMapper">
 
+    <sql id="headCommonSql">
+         select
+            tsess.id,
+            bs.id as semesterId,
+            bs.name as semesterName,
+            tsess.name as examStudentName,
+            tsess.student_code as studentCode,
+            so.id as orgId,
+            so.name as orgName,
+            bm.id as majorId,
+            bm.name as majorName,
+            bc.id as clazz_id,
+            bc.clazz_name as clazzName,
+            tsess.subject_code as courseCode,
+            tsess.subject_name as courseName,
+            tsess.total_score as totalScore,
+            tsess.objective_score as objectiveScore,
+            tsess.subjective_score as subjectiveScore,
+            tsess.sheet_urls as sheetUrls,
+            tsess.status,
+            tsess.trajectory,
+            IF(tsess.attachment_id = null,
+            null,
+            (
+            select
+                ba.`path`
+            from
+                basic_attachment ba
+            where
+                ba.id = tsess.attachment_id)) as trajectoryUrls,
+            tsess.sync_data as trajectoryCoordinate,
+            tsess.create_time as syncTime
+        from
+            t_sync_exam_student_score tsess
+    </sql>
+
+    <sql id="middleCommonSql">
+        join basic_semester bs on
+            bs.id = tsess.semester_id
+        join basic_student bs2 on
+            bs2.id = tsess.student_id
+        join basic_clazz bc on
+            bc.id = bs2.clazz_id
+        join exam_student es on
+            es.id = tsess.exam_student_id
+        join basic_major bm on
+            bm.id = bs2.major_id
+        join sys_org so on
+            so.id = tsess.org_id
+    </sql>
+
+    <sql id="footCommonSql">
+        <where>
+            <if test="schoolId != null and schoolId != ''">
+                and tsess.school_id = #{schoolId}
+            </if>
+            <if test="semesterId != null and semesterId != ''">
+                and tsess.semester_id = #{semesterId}
+            </if>
+            <if test="orgId != null and orgId != ''">
+                and tsess.org_id = #{orgId}
+            </if>
+            <if test="majorId != null and majorId != ''">
+                and bm.id = #{majorId}
+            </if>
+            <if test="clazzId != null and clazzId != ''">
+                and bc.id = #{clazzId}
+            </if>
+            <if test="courseCode != null and courseCode != ''">
+                and tsess.subject_code = #{courseCode}
+            </if>
+        </where>
+    </sql>
+
+    <select id="list" resultType="com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult">
+        <include refid="headCommonSql"/>
+        <include refid="middleCommonSql"/>
+        <include refid="footCommonSql"/>
+    </select>
+
+    <select id="export" resultType="com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult">
+        <include refid="headCommonSql"/>
+        <include refid="middleCommonSql"/>
+        <include refid="footCommonSql"/>
+    </select>
 </mapper>

+ 7 - 4
distributed-print/src/main/java/com/qmth/distributed/print/api/MenuCustomController.java

@@ -132,11 +132,14 @@ public class MenuCustomController {
             }
             tSchoolPrivilegeService.remove(tSchoolPrivilegeQueryWrapper);
         }
-        List<TSchoolPrivilege> tSchoolPrivilegeList = new ArrayList<>();
-        for (int i = 0; i < tSchoolPrivilegeParam.getPrivilegeIds().length; i++) {
-            tSchoolPrivilegeList.add(new TSchoolPrivilege(tSchoolPrivilegeParam.getSchoolId(), tSchoolPrivilegeParam.getPrivilegeIds()[i]));
+        Long[] privilegeIds = tSchoolPrivilegeParam.getPrivilegeIds();
+        if (Objects.nonNull(privilegeIds) && privilegeIds.length > 0) {
+            List<TSchoolPrivilege> tSchoolPrivilegeList = new ArrayList<>();
+            for (int i = 0; i < privilegeIds.length; i++) {
+                tSchoolPrivilegeList.add(new TSchoolPrivilege(tSchoolPrivilegeParam.getSchoolId(), privilegeIds[i]));
+            }
+            tSchoolPrivilegeService.saveBatch(tSchoolPrivilegeList);
         }
-        tSchoolPrivilegeService.saveBatch(tSchoolPrivilegeList);
 
         //清缓存
         if (Objects.nonNull(roleSetIds)) {

+ 72 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/TSyncExamStudentScoreController.java

@@ -1,12 +1,33 @@
 package com.qmth.distributed.print.api;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
-import io.swagger.annotations.Api;
+import com.qmth.distributed.print.business.entity.TFFlow;
+import com.qmth.distributed.print.business.service.PrintCommonService;
+import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
+import com.qmth.distributed.print.business.templete.execute.AsyncScoreExportService;
+import com.qmth.teachcloud.common.config.DictionaryConfig;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.TaskTypeEnum;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import io.swagger.annotations.*;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.util.Map;
+import java.util.Objects;
+
 /**
  * <p>
  * 同步考生成绩表 前端控制器
@@ -18,8 +39,57 @@ import org.springframework.web.bind.annotation.RestController;
 @Api(tags = "成绩归档Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.sync}")
-//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
+@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
 @Validated
 public class TSyncExamStudentScoreController {
 
+    @Resource
+    TSyncExamStudentScoreService tSyncExamStudentScoreService;
+
+    @Resource
+    PrintCommonService printCommonService;
+
+    @Resource
+    AsyncScoreExportService asyncScoreExportService;
+
+    @Resource
+    DictionaryConfig dictionaryConfig;
+
+    @ApiOperation(value = "成绩归档查询列表")
+    @ApiResponses({@ApiResponse(code = 200, message = "流程信息", response = TFFlow.class)})
+    @RequestMapping(value = "/score/list", method = RequestMethod.POST)
+    public Result list(@ApiParam(value = "学期id", required = true) @RequestParam String semesterId,
+                       @ApiParam(value = "学院id", required = true) @RequestParam String orgId,
+                       @ApiParam(value = "专业id", required = false) @RequestParam(required = false) String majorId,
+                       @ApiParam(value = "班级id", required = false) @RequestParam(required = false) String clazzId,
+                       @ApiParam(value = "课程编码", required = false) @RequestParam(required = false) String courseCode,
+                       @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                       @ApiParam(value = "数量", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok(tSyncExamStudentScoreService.list(new Page<>(pageNumber, pageSize),
+                SystemConstant.convertIdToLong(semesterId),
+                SystemConstant.convertIdToLong(orgId),
+                SystemConstant.convertIdToLong(majorId),
+                SystemConstant.convertIdToLong(clazzId),
+                courseCode));
+    }
+
+    @ApiOperation(value = "成绩导出")
+    @ApiResponses({@ApiResponse(code = 200, message = "流程信息", response = TFFlow.class)})
+    @RequestMapping(value = "/score/export", method = RequestMethod.POST)
+    public Result export(@ApiParam(value = "学期id", required = true) @RequestParam String semesterId,
+                         @ApiParam(value = "学院id", required = true) @RequestParam String orgId,
+                         @ApiParam(value = "专业id", required = false) @RequestParam(required = false) String majorId,
+                         @ApiParam(value = "班级id", required = false) @RequestParam(required = false) String clazzId,
+                         @ApiParam(value = "课程编码", required = false) @RequestParam(required = false) String courseCode) {
+        Map<String, Object> map = printCommonService.saveTask(TaskTypeEnum.SCORE_EXPORT);
+        map.computeIfAbsent("semesterId", v -> semesterId);
+        map.computeIfAbsent("orgId", v -> orgId);
+        map.computeIfAbsent("majorId", v -> majorId);
+        map.computeIfAbsent("clazzId", v -> clazzId);
+        map.computeIfAbsent("courseCode", v -> courseCode);
+        map.computeIfAbsent(SystemConstant.OSS, v -> dictionaryConfig.sysDomain().isOss());
+        asyncScoreExportService.exportTask(map);
+        TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
+        return Objects.nonNull(tbTask) ? ResultUtil.ok(tbTask.getId()) : ResultUtil.error("创建任务失败");
+    }
 }

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

@@ -39,7 +39,9 @@ public enum TaskTypeEnum {
 
     STATISTICS_IMPORT("命题统计导入"),
 
-    USER_PUSH("用户推送");
+    USER_PUSH("用户推送"),
+
+    SCORE_EXPORT("成绩导出");
 
     private String title;
 

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

@@ -245,7 +245,6 @@ 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();
-
         TBTask tbTask = new TBTask(taskTypeEnum,
                 TaskStatusEnum.INIT,
                 Objects.nonNull(basicAttachment) ? basicAttachment.getName() : null,