Quellcode durchsuchen

Merge branch 'dev'
1

wangliang vor 4 Jahren
Ursprung
Commit
4fa08c8fc8
20 geänderte Dateien mit 149 neuen und 48 gelöschten Zeilen
  1. 2 2
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java
  2. 4 1
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBTaskHistoryController.java
  3. 4 2
      themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java
  4. 2 1
      themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java
  5. 2 2
      themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamPaperController.java
  6. 5 6
      themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java
  7. 16 13
      themis-backend/src/main/resources/ehcache.xml
  8. 17 0
      themis-business/src/main/java/com/qmth/themis/business/annotation/ExcelDynamicExport.java
  9. 2 3
      themis-business/src/main/java/com/qmth/themis/business/dao/TBTaskHistoryMapper.java
  10. 4 0
      themis-business/src/main/java/com/qmth/themis/business/dto/ExcelDto.java
  11. 5 4
      themis-business/src/main/java/com/qmth/themis/business/dto/MarkResultStandardExportDto.java
  12. 17 3
      themis-business/src/main/java/com/qmth/themis/business/entity/TBTaskHistory.java
  13. 2 2
      themis-business/src/main/java/com/qmth/themis/business/service/TBTaskHistoryService.java
  14. 3 2
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TBTaskHistoryServiceImpl.java
  15. 40 5
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java
  16. 1 0
      themis-business/src/main/resources/db/init.sql
  17. 3 0
      themis-business/src/main/resources/mapper/TBTaskHistoryMapper.xml
  18. 2 2
      themis-business/src/main/resources/mapper/TEExamStudentMapper.xml
  19. 2 0
      themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java
  20. 16 0
      themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

+ 2 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/TBExamInvigilateUserController.java

@@ -148,7 +148,7 @@ public class TBExamInvigilateUserController {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
             } else {
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_INVIGILATE_USER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_INVIGILATE_USER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId(), tbUser.getOrgId());
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
             }
@@ -186,7 +186,7 @@ public class TBExamInvigilateUserController {
                 Map transMap = new HashMap();
                 TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_INVIGILATE_USER, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_INVIGILATE_USER, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
                 transMap.put("createId", tbUser.getId());

+ 4 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/TBTaskHistoryController.java

@@ -2,9 +2,11 @@ package com.qmth.themis.backend.api;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.dto.response.TBTaskDto;
+import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.enums.TaskStatusEnum;
 import com.qmth.themis.business.enums.TaskTypeEnum;
 import com.qmth.themis.business.service.TBTaskHistoryService;
+import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
@@ -34,6 +36,7 @@ public class TBTaskHistoryController {
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "任务信息", response = TBTaskDto.class)})
     public Result query(@ApiParam(value = "任务id", required = false) @RequestParam(required = false) Long id, @ApiParam(value = "业务对象id", required = false) @RequestParam(required = false) Long entityId, @ApiParam(value = "任务类型", required = false) @RequestParam(required = false) TaskTypeEnum type, @ApiParam(value = "任务状态", required = false) @RequestParam(required = false) TaskStatusEnum status, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
-        return ResultUtil.ok(tbTaskHistoryService.taskQuery(new Page<>(pageNumber, pageSize), id, entityId, type, status));
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+        return ResultUtil.ok(tbTaskHistoryService.taskQuery(new Page<>(pageNumber, pageSize), id, entityId, type, status, tbUser.getOrgId()));
     }
 }

+ 4 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -111,9 +111,11 @@ public class TBUserController {
         if (Objects.isNull(tbOrg)) {
             throw new BusinessException(ExceptionResultEnum.ORG_NO);
         }
-
+        if (Objects.nonNull(tbOrg.getEnable()) && tbOrg.getEnable().intValue() == 0) {
+            throw new BusinessException(ExceptionResultEnum.ORG_ENABLE);
+        }
         QueryWrapper<TBUser> wrapper = new QueryWrapper<>();
-        wrapper.lambda().eq(TBUser::getLoginName, loginName);
+        wrapper.lambda().eq(TBUser::getLoginName, loginName).eq(TBUser::getOrgId, tbOrg.getId());
         TBUser user = tbUserService.getOne(wrapper);
         //用户不存在
         if (Objects.isNull(user)) {

+ 2 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -483,10 +483,11 @@ public class TEExamController {
         try {
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             //往任务表里插一条数据
-            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.CALCULATE_EXAM_SCORE, TaskStatusEnum.INIT, "重新算分", 0d, tbUser.getId());
+            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.CALCULATE_EXAM_SCORE, TaskStatusEnum.INIT, "重新算分", 0d, tbUser.getId(), tbUser.getOrgId());
             tbTaskHistory.setEntityId(id);
             taskHistoryService.save(tbTaskHistory);
             transMap.put("examId", id);
+            transMap.put("orgId", tbUser.getOrgId());
             transMap.put(SystemConstant.TASK_ID, tbTaskHistory.getId());
             //mq发送消息start
             MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_SCORE_CALCULATE.name(), transMap, MqTagEnum.EXAM_SCORE_CALCULATE, String.valueOf(tbTaskHistory.getId()), tbUser.getName());

+ 2 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamPaperController.java

@@ -135,13 +135,13 @@ public class TEExamPaperController {
                 throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
             } else {
                 //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_PAPER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId());
+                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_PAPER, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId(), tbUser.getOrgId());
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
             }
             transMap.put("examId", examId);
             transMap.put("createId", tbUser.getId());
-
+            transMap.put("orgId", tbUser.getOrgId());
             //先查询考试相关信息
             TEExam teExam = teExamService.getById(examId);
             if (Objects.isNull(teExam)) {

+ 5 - 6
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java

@@ -95,10 +95,10 @@ public class TEExamStudentController {
         Map<String, Object> transMap = new HashMap<String, Object>();
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         //往任务表里插一条数据
-        tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_EXAM_STUDENT, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId());
+        tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_EXAM_STUDENT, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
         taskHistoryService.save(tbTaskHistory);
         transMap.put("tbTaskHistory", tbTaskHistory);
-
+        transMap.put("orgId", tbUser.getOrgId());
         transMap.put("examId", examId);
         transMap.put("activityId", activityId);
         transMap.put("identity", identity);
@@ -109,7 +109,6 @@ public class TEExamStudentController {
         transMap.put("enable", enable);
         transMap.put("classNo", classNo);
         transMap.put("hasPhoto", hasPhoto);
-
         transMap.put("createId", tbUser.getId());
 
         //mq发送消息start
@@ -284,7 +283,7 @@ public class TEExamStudentController {
                 // 往任务表里插一条数据
                 tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_STUDENT, examId, TaskStatusEnum.INIT,
                         SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(),
-                        tbUser.getId());
+                        tbUser.getId(), tbUser.getOrgId());
                 taskHistoryService.save(tbTaskHistory);
                 transMap.put("tbTaskHistory", tbTaskHistory);
             }
@@ -375,7 +374,7 @@ public class TEExamStudentController {
             Map transMap = new HashMap();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             //往任务表里插一条数据
-            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_SIMPLE, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId());
+            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_SIMPLE, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
             taskHistoryService.save(tbTaskHistory);
             transMap.put("tbTaskHistory", tbTaskHistory);
             transMap.put("createId", tbUser.getId());
@@ -418,7 +417,7 @@ public class TEExamStudentController {
             Map transMap = new HashMap();
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             //往任务表里插一条数据
-            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_STANDARD, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId());
+            tbTaskHistory = new TBTaskHistory(TaskTypeEnum.EXPORT_MARK_RESULT_STANDARD, TaskStatusEnum.INIT, SystemConstant.EXPORT_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
             taskHistoryService.save(tbTaskHistory);
             transMap.put("tbTaskHistory", tbTaskHistory);
             transMap.put("createId", tbUser.getId());

+ 16 - 13
themis-backend/src/main/resources/ehcache.xml

@@ -7,30 +7,33 @@
     <!--overflowToDisk:是否保存到磁盘,当系统宕机时-->
     <!--diskPersistent:是否在磁盘上持久化。指重启jvm后,数据是否有效。默认为false。-->
     <defaultCache
-            eternal="false"
-            maxElementsInMemory="10000"
-            overflowToDisk="false"
-            diskPersistent="false"
+            eternal="true"
+            maxElementsInMemory="1"
+            maxElementsOnDisk="0"
+            overflowToDisk="true"
+            diskPersistent="true"
             timeToIdleSeconds="0"
-            timeToLiveSeconds="2400"
+            timeToLiveSeconds="43200"
             memoryStoreEvictionPolicy="LRU" />
 
     <cache
             name="org_code_cache"
-            eternal="false"
-            maxElementsInMemory="1000"
-            overflowToDisk="false"
-            diskPersistent="false"
+            eternal="true"
+            maxElementsInMemory="1"
+            maxElementsOnDisk="0"
+            overflowToDisk="true"
+            diskPersistent="true"
             timeToIdleSeconds="0"
             timeToLiveSeconds="43200"
             memoryStoreEvictionPolicy="LRU" />
 
     <cache
             name="role_cache"
-            eternal="false"
-            maxElementsInMemory="1000"
-            overflowToDisk="false"
-            diskPersistent="false"
+            eternal="true"
+            maxElementsInMemory="1"
+            maxElementsOnDisk="0"
+            overflowToDisk="true"
+            diskPersistent="true"
             timeToIdleSeconds="0"
             timeToLiveSeconds="43200"
             memoryStoreEvictionPolicy="LRU" />

+ 17 - 0
themis-business/src/main/java/com/qmth/themis/business/annotation/ExcelDynamicExport.java

@@ -0,0 +1,17 @@
+package com.qmth.themis.business.annotation;
+
+import java.lang.annotation.*;
+
+/**
+* @Description: excel字段动态导出注释
+* @Param:
+* @return:
+* @Author: wangliang
+* @Date: 2020/7/20
+*/
+@Documented
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExcelDynamicExport {
+
+}

+ 2 - 3
themis-business/src/main/java/com/qmth/themis/business/dao/TBTaskHistoryMapper.java

@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.dto.response.TBTaskDto;
 import com.qmth.themis.business.entity.TBTaskHistory;
-import com.qmth.themis.business.enums.TaskStatusEnum;
-import com.qmth.themis.business.enums.TaskTypeEnum;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -29,7 +27,8 @@ public interface TBTaskHistoryMapper extends BaseMapper<TBTaskHistory> {
      * @param entityId
      * @param type
      * @param status
+     * @param orgId
      * @return
      */
-    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, @Param("taskId") Long taskId, @Param("entityId") Long entityId, @Param("type") String type, @Param("status") String status);
+    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, @Param("taskId") Long taskId, @Param("entityId") Long entityId, @Param("type") String type, @Param("status") String status, @Param("orgId") Long orgId);
 }

+ 4 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/ExcelDto.java

@@ -23,6 +23,10 @@ public class ExcelDto implements Serializable {
 
     }
 
+    public ExcelDto(String title) {
+        this.title = title;
+    }
+
     public ExcelDto(String title, String content) {
         this.title = title;
         this.content = content;

+ 5 - 4
themis-business/src/main/java/com/qmth/themis/business/dto/MarkResultStandardExportDto.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.dto;
 
+import com.qmth.themis.business.annotation.ExcelDynamicExport;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
 import io.swagger.annotations.ApiModelProperty;
@@ -75,6 +76,10 @@ public class MarkResultStandardExportDto implements Serializable{
     @ExcelNote(value = "总分")
     private String sumScore;
 
+    @ApiModelProperty(value = "答题记录")
+    @ExcelDynamicExport
+    private Map<Long, List<ExcelDto>> answerExcetDto;
+
     @ApiModelProperty(value = "考试记录ID")
     @ExcelNotExport
     private Long recordId;
@@ -87,10 +92,6 @@ public class MarkResultStandardExportDto implements Serializable{
     @ExcelNotExport
     private Long examStudentId;
 
-    @ApiModelProperty(value = "答题记录")
-    @ExcelNotExport
-    private Map<Long, List<ExcelDto>> answerExcetDto;
-
     public Map<Long, List<ExcelDto>> getAnswerExcetDto() {
         return answerExcetDto;
     }

+ 17 - 3
themis-business/src/main/java/com/qmth/themis/business/entity/TBTaskHistory.java

@@ -12,7 +12,6 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
-import java.util.Date;
 
 /**
  * @Description: 异步任务
@@ -84,11 +83,16 @@ public class TBTaskHistory implements Serializable {
     @TableField(value = "finish_time")
     private Long finishTime;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "机构id")
+    @TableId(value = "org_id")
+    private Long orgId;
+
     public TBTaskHistory() {
 
     }
 
-    public TBTaskHistory(TaskTypeEnum type, Long entityId, TaskStatusEnum status, String summary, Double progress, String importFileName, String importFilePath, Long createId) {
+    public TBTaskHistory(TaskTypeEnum type, Long entityId, TaskStatusEnum status, String summary, Double progress, String importFileName, String importFilePath, Long createId, Long orgId) {
         this.id = Constants.idGen.next();
         this.type = type;
         this.entityId = entityId;
@@ -99,9 +103,10 @@ public class TBTaskHistory implements Serializable {
         this.importFilePath = importFilePath;
         this.createId = createId;
         this.startTime = System.currentTimeMillis();
+        this.orgId = orgId;
     }
 
-    public TBTaskHistory(TaskTypeEnum type, TaskStatusEnum status, String summary, Double progress, Long createId) {
+    public TBTaskHistory(TaskTypeEnum type, TaskStatusEnum status, String summary, Double progress, Long createId, Long orgId) {
         this.id = Constants.idGen.next();
         this.type = type;
         this.status = status;
@@ -109,6 +114,15 @@ public class TBTaskHistory implements Serializable {
         this.progress = progress;
         this.createId = createId;
         this.startTime = System.currentTimeMillis();
+        this.orgId = orgId;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
     }
 
     public static long getSerialVersionUID() {

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/service/TBTaskHistoryService.java

@@ -6,7 +6,6 @@ import com.qmth.themis.business.dto.response.TBTaskDto;
 import com.qmth.themis.business.entity.TBTaskHistory;
 import com.qmth.themis.business.enums.TaskStatusEnum;
 import com.qmth.themis.business.enums.TaskTypeEnum;
-import org.apache.ibatis.annotations.Param;
 
 import java.util.Map;
 
@@ -27,7 +26,8 @@ public interface TBTaskHistoryService extends IService<TBTaskHistory> {
      * @param entityId
      * @param type
      * @param status
+     * @param orgId
      * @return
      */
-    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, Long taskId, Long entityId, TaskTypeEnum type, TaskStatusEnum status);
+    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, Long taskId, Long entityId, TaskTypeEnum type, TaskStatusEnum status, Long orgId);
 }

+ 3 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBTaskHistoryServiceImpl.java

@@ -35,10 +35,11 @@ public class TBTaskHistoryServiceImpl extends ServiceImpl<TBTaskHistoryMapper, T
      * @param entityId
      * @param type
      * @param status
+     * @param orgId
      * @return
      */
     @Override
-    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, Long taskId, Long entityId, TaskTypeEnum type, TaskStatusEnum status) {
-        return tbTaskHistoryMapper.taskQuery(iPage, taskId, entityId, Objects.isNull(type) ? null : type.name(), Objects.isNull(status) ? null : status.name());
+    public IPage<TBTaskDto> taskQuery(IPage<Map> iPage, Long taskId, Long entityId, TaskTypeEnum type, TaskStatusEnum status, Long orgId) {
+        return tbTaskHistoryMapper.taskQuery(iPage, taskId, entityId, Objects.isNull(type) ? null : type.name(), Objects.isNull(status) ? null : status.name(), orgId);
     }
 }

+ 40 - 5
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
+import com.qmth.themis.business.annotation.ExcelDynamicExport;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
 import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
@@ -92,6 +93,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             }.getType());
             Map<Long, List<ExcelDto>> excelDtoMap = null;
             Map<Long, Map<String, ObjectiveAnswerCacheBean>> paperObjectiveAnswerMap = new HashMap<>();
+            List<ExcelDto> dynamicExcelHead = new ArrayList<>();
             if (Objects.nonNull(markResultStandardExportDtoList) && markResultStandardExportDtoList.size() > 0) {
                 for (MarkResultStandardExportDto m : markResultStandardExportDtoList) {
                     excelDtoMap = new HashMap<>();
@@ -103,6 +105,16 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                         } else {
                             objectiveAnswerCacheBeanMap = paperObjectiveAnswerMap.get(m.getPaperId());
                         }
+                        if (dynamicExcelHead.size() == 0) {
+                            objectiveAnswerCacheBeanMap.forEach((k, v) -> {
+                                ObjectiveAnswerCacheBean objectiveAnswerCacheBean = v;
+                                String title = QuestionTypeEnum.convertToTitle(objectiveAnswerCacheBean.getStructType()) + k;
+                                ExcelDto excelAnswerDto = new ExcelDto(title + "作答");
+                                ExcelDto excelScoreDto = new ExcelDto(title + "得分");
+                                dynamicExcelHead.add(excelAnswerDto);
+                                dynamicExcelHead.add(excelScoreDto);
+                            });
+                        }
                     } else {
                         continue;
                     }
@@ -165,18 +177,30 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
             Row row = sheet.createRow(0);
             Field[] fields = MarkResultStandardExportDto.class.getDeclaredFields();
+            int num = 0;
             //绘制表头
             for (int i = 0; i < fields.length; i++) {
                 Field field = fields[i];
                 field.setAccessible(true);
-                Annotation annotation = field.getAnnotation(ExcelNotExport.class);
-                if (Objects.isNull(annotation)) {
+                Annotation annotation = field.getAnnotation(ExcelNote.class);
+                if (Objects.nonNull(annotation)) {
                     Cell cell = row.createCell(i);
                     cell.setCellValue(field.getAnnotation(ExcelNote.class).value());
                     cell.setCellStyle(style);
-//                    sheet.setColumnWidth(i, 15 * 256);
+                    num = i;
                 }
             }
+            num++;
+            Map<String, Integer> position = new HashMap<>();
+            //动态表头
+            for (ExcelDto excelDto : dynamicExcelHead) {
+                Cell cell = row.createCell(num);
+                cell.setCellValue(excelDto.getTitle());
+                cell.setCellStyle(style);
+                sheet.setColumnWidth(num, 15 * 256);
+                position.put(excelDto.getTitle(), num);
+                num++;
+            }
             int cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultStandardExportDtoList.size();
             if (max >= size) {
                 max = size;
@@ -193,8 +217,19 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
                         field.setAccessible(true);
                         Annotation annotation = field.getAnnotation(ExcelNotExport.class);
                         if (Objects.isNull(annotation)) {
-                            taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultStandardExportDto), style);
-                            cellIndex++;
+                            Annotation dynamicExport = field.getAnnotation(ExcelDynamicExport.class);
+                            if (Objects.nonNull(dynamicExport)) {
+                                Map<Long, List<ExcelDto>> answerExcetDto = markResultStandardExportDto.getAnswerExcetDto();
+                                if (Objects.nonNull(answerExcetDto)) {
+                                    List<ExcelDto> excelDtoList = answerExcetDto.get(markResultStandardExportDto.getExamStudentId());
+                                    excelDtoList.forEach(s -> {
+                                        taskExportCommon.createExcelCell(sxssfRow, position.get(s.getTitle()), s.getContent(), style);
+                                    });
+                                }
+                            } else {
+                                taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultStandardExportDto), style);
+                                cellIndex++;
+                            }
                         }
                     }
                 }

+ 1 - 0
themis-business/src/main/resources/db/init.sql

@@ -795,6 +795,7 @@ CREATE TABLE `t_b_task_history` (
   `create_time` bigint DEFAULT NULL COMMENT '创建时间',
   `start_time` bigint DEFAULT NULL COMMENT '开始时间',
   `finish_time` bigint DEFAULT NULL COMMENT '结束时间',
+  `org_id` bigint DEFAULT NULL COMMENT '机构id',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='异步任务';
 

+ 3 - 0
themis-business/src/main/resources/mapper/TBTaskHistoryMapper.xml

@@ -31,6 +31,9 @@
                 <if test="taskId != null and taskId != ''">
                     and tbth.id = #{taskId}
                 </if>
+                <if test="orgId != null and orgId != ''">
+                    and tbth.org_id = #{orgId}
+                </if>
                 <if test="entityId != null and entityId != ''">
                     and tbth.entity_id = #{entityId}
                 </if>

+ 2 - 2
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -322,14 +322,14 @@
 		left join t_e_exam_student tees on
 		tees.student_id = tes.id
 		left join (select
-			max(toer.objective_score) as objective_score,toer.id,toer.exam_student_id,toer.paper_id
+			max(toer.objective_score) as objective_score,max(toer.id) as id,toer.exam_student_id,toer.paper_id
 			from
 			t_oe_exam_record toer
 			where
 			(toer.breach_status = 1
 			or breach_status is null)
 			and (toer.status = 'FINISHED'
-			or toer.status = 'PERSISTED') group by toer.id,toer.paper_id,toer.exam_student_id order by toer.id desc limit 1) temp on temp.exam_student_id = tees.id
+			or toer.status = 'PERSISTED') group by toer.paper_id,toer.exam_student_id) temp on temp.exam_student_id = tees.id
 		left join t_e_exam tee on
 		tee.id = tees.exam_id
 		left join t_e_exam_activity teea on

+ 2 - 0
themis-common/src/main/java/com/qmth/themis/common/enums/ExceptionResultEnum.java

@@ -207,6 +207,8 @@ public enum ExceptionResultEnum {
 
     EXAM_ACTIVITY_NO(500, 500003, "考试场次信息不存在"),
 
+    ORG_ENABLE(500, 500004, "机构已停用"),
+
     ORG_NO(500, 500005, "机构信息不存在"),
 
     TASK_NO(500, 500006, "任务不存在"),

+ 16 - 0
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -18,6 +18,7 @@ import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.dto.response.TEExamActivityDto;
 import com.qmth.themis.business.dto.response.TEExamDto;
 import com.qmth.themis.business.dto.response.TEExamResultDto;
+import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TEStudent;
@@ -95,6 +96,9 @@ public class TEStudentController {
     @Resource
     TOeExamRecordService tOeExamRecordService;
 
+    @Resource
+    TBOrgService tbOrgService;
+
     @ApiOperation(value = "学生登录接口")
     @RequestMapping(value = "/login", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "学生信息", response = TEExamResultDto.class)})
@@ -118,12 +122,24 @@ public class TEStudentController {
             orgId = Long.parseLong(String.valueOf(mapParameter.get("orgId")));
         }
         Long examId = null;
+        TBOrg tbOrg = null;
         if (Objects.nonNull(mapParameter.get("examId"))) {
             examId = Long.parseLong(String.valueOf(mapParameter.get("examId")));
+            ExamCacheBean ec = teExamService.getExamCacheBean(examId);
+            tbOrg = Objects.isNull(redisUtil.getOrg(ec.getOrgId())) ? tbOrgService.getById(ec.getOrgId()) : (TBOrg) redisUtil.getOrg(ec.getOrgId());
         }
         if (Objects.isNull(orgId) && Objects.isNull(examId)) {
             throw new BusinessException(ExceptionResultEnum.ORG_ID_OR_EXAM_ID_NOT_CHOOSE);
         }
+        if (Objects.nonNull(orgId)) {
+            tbOrg = Objects.isNull(redisUtil.getOrg(orgId)) ? tbOrgService.getById(orgId) : (TBOrg) redisUtil.getOrg(orgId);
+        }
+        if (Objects.isNull(tbOrg)) {
+            throw new BusinessException(ExceptionResultEnum.ORG_NO);
+        }
+        if (Objects.nonNull(tbOrg.getEnable()) && tbOrg.getEnable().intValue() == 0) {
+            throw new BusinessException(ExceptionResultEnum.ORG_ENABLE);
+        }
         String identity = String.valueOf(mapParameter.get("identity"));
         String password = String.valueOf(mapParameter.get("password"));