xiaofei 2 жил өмнө
parent
commit
ae310c735a
17 өөрчлөгдсөн 133 нэмэгдсэн , 24 устгасан
  1. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java
  2. 3 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicCardRuleService.java
  3. 14 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicCardRuleServiceImpl.java
  4. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java
  5. 7 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java
  6. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncExamStudentScoreServiceImpl.java
  7. 13 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/HtmlToJpgUtil.java
  8. 3 0
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  9. 14 2
      distributed-print/src/main/java/com/qmth/distributed/print/api/BasicCardRuleController.java
  10. 8 5
      distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java
  11. 21 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/SchoolDto.java
  12. 23 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/TaskListResult.java
  13. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/UploadFileEnum.java
  14. 19 3
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ExcelUtil.java
  15. 1 1
      teachcloud-common/src/main/resources/mapper/BasicOperationLogMapper.xml
  16. 1 1
      teachcloud-common/src/main/resources/mapper/BasicSchoolMapper.xml
  17. 2 1
      teachcloud-common/src/main/resources/mapper/TBTaskMapper.xml

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java

@@ -95,7 +95,7 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
 
     ExamTaskDto getByExamTaskId(Long examTaskId);
 
-    IPage<ExamTaskDetailDto> listExamTaskDetailDownload(@Param("page") Page<ExamTaskDetailDto> page, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseName") String courseName, @Param("orgId") Long orgId, @Param("dpr") DataPermissionRule dpr);
+    IPage<ExamTaskDetailDto> listExamTaskDetailDownload(@Param("page") Page<ExamTaskDetailDto> page, @Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseName") String courseName, @Param("orgId") Long orgId, @Param("dpr") DataPermissionRule dpr);
 
     /**
      * 根据条件查询要下载的试卷文件

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicCardRuleService.java

@@ -21,7 +21,9 @@ public interface BasicCardRuleService extends IService<BasicCardRule> {
 
     List<BasicCardRule> list(String param);
 
-    boolean enable(BasicCardRule cardRule);
+    boolean delete(BasicCardRule cardRule);
 
     boolean saveCardRule(BasicCardRule cardRule);
+
+    boolean enable(Long id, Boolean enable);
 }

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

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -72,7 +73,7 @@ public class BasicCardRuleServiceImpl extends ServiceImpl<BasicCardRuleMapper, B
     }
 
     @Override
-    public boolean enable(BasicCardRule cardRule) {
+    public boolean delete(BasicCardRule cardRule) {
         QueryWrapper<BasicPrintConfig> basicPrintConfigQueryWrapper = new QueryWrapper<>();
         basicPrintConfigQueryWrapper.lambda().eq(BasicPrintConfig::getCardRuleId, cardRule.getId());
         int basicPrintConfigCount = basicPrintConfigService.count(basicPrintConfigQueryWrapper);
@@ -138,4 +139,16 @@ public class BasicCardRuleServiceImpl extends ServiceImpl<BasicCardRuleMapper, B
 //        basicTemplateOrgService.saveBatch(schoolId, TemplateTypeEnum.CARD_RULE, cardRule.getId(), cardRule.getOrgIds(), cardRule.getCreateId());
         return isSuccess;
     }
+
+    @Override
+    public boolean enable(Long id, Boolean enable) {
+        BasicCardRule basicCardRule = this.getById(id);
+        if(basicCardRule == null){
+            throw ExceptionResultEnum.ERROR.exception("题卡规则不存在");
+        }
+        UpdateWrapper<BasicCardRule> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(BasicCardRule::getEnable, enable)
+                .eq(BasicCardRule::getId, id);
+        return this.update(updateWrapper);
+    }
 }

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

@@ -93,7 +93,7 @@ public class DownloadServiceImpl implements DownloadService {
         Long schoolId = SystemConstant.convertIdToLong(String.valueOf(ServletUtil.getRequestHeaderSchoolId()));
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
-        return examTaskMapper.listExamTaskDetailDownload(page, semesterId, examId, courseName, orgId, dpr);
+        return examTaskMapper.listExamTaskDetailDownload(page, schoolId, semesterId, examId, courseName, orgId, dpr);
     }
 
     @Override

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

@@ -125,7 +125,13 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     @Override
     public double calculateTotalSubjects(Long printPlanId) {
         List<ExamDetail> examDetailList = this.list(new QueryWrapper<ExamDetail>().lambda().eq(ExamDetail::getPrintPlanId, printPlanId));
-        return examDetailList.stream().collect(Collectors.summarizingDouble(ExamDetail::getTotalSubjects)).getSum();
+        List<Long> examDetailIds = examDetailList.stream().map(m->m.getId()).collect(Collectors.toList());
+
+        if(examDetailIds.isEmpty()){
+            return 0;
+        }
+        List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.list(new QueryWrapper<ExamDetailCourse>().lambda().in(ExamDetailCourse::getExamDetailId, examDetailIds));
+        return examDetailCourseList.isEmpty() ? 0 : examDetailCourseList.stream().map(m->m.getCourseCode()).distinct().count();
     }
 
     @Transactional(rollbackFor = Exception.class)

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

@@ -159,7 +159,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
                         fileSource = HttpUtil.httpDownload(url, fileSource.getPath());
                         fileSourceList.add(fileSource);
                         JSONObject sheetObject = new JSONObject();
-                        sheetObject.put(SystemConstant.PATH, dirJpgName);
+                        sheetObject.put(SystemConstant.PATH, dirJpgName.toString());
                         String jpgFileMd5 = DigestUtils.md5Hex(new FileInputStream(fileSource));
                         if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
                             fileStoreUtil.ossUpload(dirJpgName.toString(), fileSource, DigestUtils.md5Hex(new FileInputStream(fileSource)), UploadFileEnum.FILE.getFssType());

+ 13 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/HtmlToJpgUtil.java

@@ -10,6 +10,7 @@ import com.qmth.teachcloud.common.enums.PageSizeEnum;
 import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import com.qmth.teachcloud.common.util.ConvertUtil;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.entity.ContentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -27,6 +28,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.StringJoiner;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -55,9 +57,15 @@ public class HtmlToJpgUtil {
      * @param pageSizeEnum 转化pdf的纸张类型
      */
     public List<BasicAttachment> convertHtmlToJpg(String cardTitle, String htmlContent, PageSizeEnum pageSizeEnum) throws Exception {
+        boolean oss = dictionaryConfig.sysDomain().isOss();
+        StringJoiner stringJoiner = new StringJoiner("");
+        if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
+            stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
+        }
+        stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.IMAGE, true);
+
         // 本地存储目录
-        File file = SystemConstant.getFileTempVar(SystemConstant.TEMP_PREFIX);
-        String rootPath = file.getParent();
+        String rootPath = stringJoiner.toString();
         // html临时路径
         String htmlPath = rootPath + File.separator + "html" + File.separator + cardTitle + SystemConstant.HTML_PREFIX;
         // pdf临时路径
@@ -68,6 +76,9 @@ public class HtmlToJpgUtil {
         // html
         try {
             File htmlFile = new File(htmlPath);
+            if(!htmlFile.exists()){
+                htmlFile.getParentFile().mkdirs();
+            }
             // 生成html文件
             FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), htmlFile);
             // 转pdf文件
@@ -85,9 +96,6 @@ public class HtmlToJpgUtil {
         } catch (Exception e) {
             log.error(e.getMessage());
         } finally {
-            if (Objects.nonNull(file)) {
-                file.delete();
-            }
             ConvertUtil.delFolder(rootPath);
         }
         return basicAttachmentList;

+ 3 - 0
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -1095,6 +1095,9 @@
             a.status = 'SUBMIT'
           AND (a.review = 0
             OR (a.review = 1 AND g.status = 'FINISH'))
+            <if test="schoolId != null and schoolId != ''">
+                and a.school_id = #{schoolId}
+            </if>
             <if test="semesterId != null and semesterId != ''">
                 and be.semester_id = #{semesterId}
             </if>

+ 14 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicCardRuleController.java

@@ -117,8 +117,20 @@ public class BasicCardRuleController {
     @ApiOperation(value = "删除")
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.DELETE)
-    public Result enable(@RequestBody BasicCardRule cardRule) {
-        boolean isSuccess = basicCardRuleService.enable(cardRule);
+    public Result delete(@RequestBody BasicCardRule cardRule) {
+        boolean isSuccess = basicCardRuleService.delete(cardRule);
+        return ResultUtil.ok(isSuccess);
+    }
+
+    /**
+     * 启用/禁用
+     *
+     */
+    @ApiOperation(value = "启用/禁用")
+    @RequestMapping(value = "/enable", method = RequestMethod.POST)
+    @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UPDATE)
+    public Result enable(@RequestBody BasicCardRule basicCardRule) {
+        boolean isSuccess = basicCardRuleService.enable(basicCardRule.getId(), basicCardRule.getEnable());
         return ResultUtil.ok(isSuccess);
     }
 }

+ 8 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java

@@ -12,10 +12,7 @@ import com.qmth.teachcloud.common.bean.result.TaskListResult;
 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.MqTagEnum;
-import com.qmth.teachcloud.common.enums.TaskResultEnum;
-import com.qmth.teachcloud.common.enums.TaskStatusEnum;
-import com.qmth.teachcloud.common.enums.TaskTypeEnum;
+import com.qmth.teachcloud.common.enums.*;
 import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
 import com.qmth.teachcloud.common.service.TBTaskService;
 import com.qmth.teachcloud.common.util.RedisUtil;
@@ -44,7 +41,7 @@ import java.util.*;
  */
 @Api(tags = "数据管理-任务管理Controller")
 @RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX  + SystemConstant.PREFIX_URL_DATA +"/task")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DATA + "/task")
 @Validated
 public class TBTaskController {
     private final static Logger log = LoggerFactory.getLogger(TBTaskController.class);
@@ -75,6 +72,12 @@ public class TBTaskController {
                         && Objects.isNull(taskListResult.getErrorMessage())) {
                     taskListResult.setResetCreatePdf(true);
                 }
+                // 类型为create_pdf,hasResultFile默认为false
+                if (Objects.equals(taskListResult.getType(), TaskTypeEnum.CREATE_PDF.getTitle())) {
+                    taskListResult.setHasResultFile(false);
+                }
+                // 下载类型
+                taskListResult.setDownloadType(taskListResult.getHasImportFile() ? DownloadFileEnum.IMPORT_FILE.name() : DownloadFileEnum.RESULT.name());
             }
         }
         return ResultUtil.ok(taskListResultIPage);

+ 21 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/SchoolDto.java

@@ -10,6 +10,11 @@ public class SchoolDto {
     private String code;
     private String name;
     private Boolean enable;
+
+    private String accessKey;
+
+    private String accessSecret;
+
     private String logo;
 
     public String getId() {
@@ -44,6 +49,22 @@ public class SchoolDto {
         this.enable = enable;
     }
 
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
     public String getLogo() {
         return logo;
     }

+ 23 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/TaskListResult.java

@@ -49,6 +49,12 @@ public class TaskListResult implements Serializable {
     @ApiModelProperty(value = "创建时间")
     Long createTime;
 
+    @ApiModelProperty(value = "下载文件类型")
+    private String downloadType;
+
+    @ApiModelProperty(value = "是否有导入文件")
+    Boolean hasImportFile;
+
     @ApiModelProperty(value = "是否有导出文件")
     Boolean hasResultFile;
 
@@ -160,6 +166,23 @@ public class TaskListResult implements Serializable {
         this.createTime = createTime;
     }
 
+
+    public String getDownloadType() {
+        return downloadType;
+    }
+
+    public void setDownloadType(String downloadType) {
+        this.downloadType = downloadType;
+    }
+
+    public Boolean getHasImportFile() {
+        return hasImportFile;
+    }
+
+    public void setHasImportFile(Boolean hasImportFile) {
+        this.hasImportFile = hasImportFile;
+    }
+
     public Boolean getHasResultFile() {
         return hasResultFile;
     }

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/UploadFileEnum.java

@@ -24,6 +24,7 @@ public enum UploadFileEnum {
     FILE("file","public"),
 
     PDF("pdf","private"),
+    IMAGE("image","private"),
 
     HTML("html","private");
 

+ 19 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ExcelUtil.java

@@ -150,6 +150,7 @@ public class ExcelUtil {
             List<LinkedMultiValueMap<Integer, Object>> finalOList = new ArrayList<>();
             List<LinkedMultiValueMap<Integer, String>> finalColumnNameList = new ArrayList<>();
             List<LinkedMultiValueMap<Integer, ExcelError>> finalExcelErrorList = new ArrayList<>();
+            List<String> headList = new ArrayList<>();
             for (int y = 0; y < sheets; y++) {
                 //获取第一个表单sheet
                 XSSFSheet sheet = xb.getSheetAt(y);
@@ -169,17 +170,32 @@ public class ExcelUtil {
                         int lastcell = row.getLastCellNum();
                         o = clazz.get(y).newInstance();
                         Field[] fields = o.getClass().getDeclaredFields();
+
+                        // 只校验第一个sheet的第一行表头格式
+                        if (y == 0 && i == 0) {
+                            for (Field field : fields) {
+                                ExcelNote excelNote = field.getAnnotation(ExcelNote.class);
+                                headList.add(excelNote.value());
+                            }
+                        }
                         ExcelImportTempleteVaild excelImportTempleteVaild = o.getClass().getDeclaredAnnotation(ExcelImportTempleteVaild.class);
-                        if (Objects.nonNull(excelImportTempleteVaild) && excelImportTempleteVaild.value() && (lastcell > fields.length || sheets != clazz.size())) {
-                            throw ExceptionResultEnum.ERROR.exception("导入文件和模版不一致");
+                        if (Objects.nonNull(excelImportTempleteVaild) && excelImportTempleteVaild.value() && (lastcell != fields.length || sheets != clazz.size())) {
+                            throw ExceptionResultEnum.ERROR.exception("导入文件和模版不一致,表头应包含【" + String.join(",", headList) + "】");
                         }
+
                         boolean extend = fields[fields.length - 1].getName().contains(SystemConstant.EXTEND_COLUMN);
                         int emptyRowSum = 0;
                         for (int j = firstcell; j < lastcell; j++) {
                             //获取第j列
                             Cell cell = row.getCell(j);
                             if (i == 0) {
-                                columnNameList.add(y, String.valueOf(cell));
+                                String cellName = String.valueOf(cell);
+                                if (y == 0) {
+                                    if (!headList.contains(cellName)) {
+                                        throw ExceptionResultEnum.ERROR.exception("导入文件和模版不一致,表头应包含【" + String.join(",", headList) + "】");
+                                    }
+                                }
+                                columnNameList.add(y, cellName);
                             } else {
                                 if (Objects.nonNull(cell)) {
                                     Object obj = convert(cell);

+ 1 - 1
teachcloud-common/src/main/resources/mapper/BasicOperationLogMapper.xml

@@ -25,7 +25,7 @@
                 AND create_time >= #{startTime}
             </if>
             <if test="endTime != null">
-                AND #{endTime} >= endTime
+                AND #{endTime} >= create_time
             </if>
             <if test="operatorName != null and operatorName != ''">
                 AND user_name LIKE CONCAT('%',#{operatorName},'%')

+ 1 - 1
teachcloud-common/src/main/resources/mapper/BasicSchoolMapper.xml

@@ -21,7 +21,7 @@
         code, name, enable, access_key, access_secret, remark, create_time, update_time
     </sql>
     <select id="listSchool" resultType="com.qmth.teachcloud.common.bean.dto.SchoolDto">
-        select id, code, name, enable, logo from basic_school where enable = true order by create_time desc
+        select id, code, name, enable, access_key accessKey, access_secret accessSecret, logo from basic_school where enable = true order by create_time desc
     </select>
 
 </mapper>

+ 2 - 1
teachcloud-common/src/main/resources/mapper/TBTaskMapper.xml

@@ -13,7 +13,8 @@
             tbt.create_time as createTime,
             tbt.create_id as createId,
             su.real_name as createName,
-            if(ISNULL(tbt.result_file_path),false,true) as hasResultFile,
+            if(ISNULL(tbt.import_file_path),false,true) as hasImportFile,
+            if(ISNULL(tbt.result_file_path),false,true) or if(ISNULL(tbt.import_file_path),false,true) as hasResultFile,
             if(ISNULL(tbt.report_file_path),false,true) as hasReportFile,
             tbt.reset_count as resetCount,
             tbt.error_message as errorMessage