wangliang 4 سال پیش
والد
کامیت
a56d1620b2

+ 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()));
     }
 }

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

@@ -113,7 +113,7 @@ public class TBUserController {
         }
 
         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());

+ 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);
 }

+ 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);
     }
 }

+ 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>