xiaof 3 년 전
부모
커밋
b66c8676be

+ 28 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailCardDto.java

@@ -16,7 +16,11 @@ public class ExamTaskDetailCardDto {
     private String unexposedPaperType;
     private Boolean enable;
     private String makeMethod;
+    private Integer drawCount;
     private String status;
+    private String flowId;
+    // 审核流程taskId
+    private String flowTaskId;
 
     public String getExamTaskId() {
         return examTaskId;
@@ -106,6 +110,14 @@ public class ExamTaskDetailCardDto {
         this.makeMethod = makeMethod;
     }
 
+    public Integer getDrawCount() {
+        return drawCount;
+    }
+
+    public void setDrawCount(Integer drawCount) {
+        this.drawCount = drawCount;
+    }
+
     public String getStatus() {
         return status;
     }
@@ -113,4 +125,20 @@ public class ExamTaskDetailCardDto {
     public void setStatus(String status) {
         this.status = status;
     }
+
+    public String getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(String flowId) {
+        this.flowId = flowId;
+    }
+
+    public String getFlowTaskId() {
+        return flowTaskId;
+    }
+
+    public void setFlowTaskId(String flowTaskId) {
+        this.flowTaskId = flowTaskId;
+    }
 }

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDto.java

@@ -27,6 +27,8 @@ public class ExamTaskDto {
     private Long createTime;
     private String auditStatus;
     private String reviewStatus;
+    private String flowId;
+    private Integer setup;
 
     private List<BlurryUserDto> users;
 
@@ -181,4 +183,20 @@ public class ExamTaskDto {
     public void setReviewStatus(String reviewStatus) {
         this.reviewStatus = reviewStatus;
     }
+
+    public String getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(String flowId) {
+        this.flowId = flowId;
+    }
+
+    public Integer getSetup() {
+        return setup;
+    }
+
+    public void setSetup(Integer setup) {
+        this.setup = setup;
+    }
 }

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskDetail.java

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.teachcloud.common.base.BaseEntity;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.io.Serializable;
 
@@ -57,6 +59,9 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     @TableField("card_id")
     private Long cardId;
+
+    @TableField("make_method")
+    private MakeMethodEnum makeMethod;
     /**
      * [
      * {
@@ -130,6 +135,14 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
         this.cardId = cardId;
     }
 
+    public MakeMethodEnum getMakeMethod() {
+        return makeMethod;
+    }
+
+    public void setMakeMethod(MakeMethodEnum makeMethod) {
+        this.makeMethod = makeMethod;
+    }
+
     public String getPaperConfirmAttachmentIds() {
         return paperConfirmAttachmentIds;
     }

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

@@ -35,7 +35,7 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
 
     IPage<ExamTaskDto> listTaskReviewAudited(Page<ExamTaskDto> page, @Param("schoolId") Long schoolId, @Param("reviewStatus") String reviewStatus, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("userId") Long userId, @Param("cardRuleId") Long cardRuleId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("orgIds") Set<Long> orgIds, @Param("startCreateTime") Long startCreateTime, @Param("endCreateTime") Long endCreateTime, @Param("createName") String createName);
 
-    IPage<ExamTaskDetailDto> listTaskPaper(Page<ExamTaskDetailDto> page, @Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("orgIds") Set<Long> orgIds, @Param("containsQuestionTeacher") boolean containsQuestionTeacher, @Param("userId") Long userId, @Param("makeMethod") MakeMethodEnum makeMethod, @Param("cardRuleName") String cardRuleName);
+    IPage<ExamTaskDetailDto> listTaskPaper(Page<ExamTaskDetailDto> page, @Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("orgIds") Set<Long> orgIds, @Param("containsQuestionTeacher") boolean containsQuestionTeacher, @Param("userId") Long userId, @Param("makeMethod") MakeMethodEnum makeMethod, @Param("cardRuleId") Long cardRuleId);
 
     List<RelatePaperDto> listPaperNumbers(@Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("status") String status);
 

+ 4 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java

@@ -3,6 +3,7 @@ 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.dto.*;
+import com.qmth.distributed.print.business.bean.params.ExamTaskApplyParam;
 import com.qmth.distributed.print.business.bean.result.WorkResult;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.entity.ExamTaskDetail;
@@ -68,7 +69,7 @@ public interface ExamTaskService extends IService<ExamTask> {
 
     boolean taskReviewSaveBatch(ExamTaskReviewLog taskReviewLog) throws IOException;
 
-    IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethodEnum, String cardRuleName, Integer pageNumber, Integer pageSize);
+    IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethodEnum, Long cardRuleId, Integer pageNumber, Integer pageSize);
 
     List<RelatePaperDto> listPaperTypes(Long examTaskId, Long printPlanId, String courseCode);
 
@@ -177,4 +178,6 @@ public interface ExamTaskService extends IService<ExamTask> {
     List<ExamTask> findByFlowStatus(Long schoolId, String courseCode, String courseName, String paperNumber, FlowStatusEnum flowStatus);
 
     void removeByExamTaskId(Long examTaskId);
+
+    ExamTask saveExamTaskAndExamTaskDetail(ExamTaskApplyParam examTaskApplyParam);
 }

+ 158 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.google.gson.Gson;
 import com.qmth.distributed.print.business.bean.dto.*;
+import com.qmth.distributed.print.business.bean.params.ExamTaskApplyParam;
 import com.qmth.distributed.print.business.bean.result.WorkResult;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.*;
@@ -30,7 +31,9 @@ import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
 import org.activiti.engine.ActivitiObjectNotFoundException;
+import org.activiti.engine.TaskService;
 import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -134,6 +137,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     TFFlowService tfFlowService;
 
+    @Resource
+    TaskService taskService;
+
     @Override
     public List<ExamTask> listByCourseCode(Long schoolId, String code) {
         QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
@@ -759,14 +765,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
 
     @Override
-    public IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethod, String cardRuleName, Integer pageNumber, Integer pageSize) {
-        if (SystemConstant.strNotNull(cardRuleName)) {
-            if (cardRuleName.equals("全部通卡")) {
-                cardRuleName = "-1";
-            } else {
-                cardRuleName = SystemConstant.translateSpecificSign(cardRuleName);
-            }
-        }
+    public IPage<ExamTaskDetailDto> listTaskPaper(String courseCode, String paperNumber, Long startTime, Long endTime, MakeMethodEnum makeMethod, Long cardRuleId, Integer pageNumber, Integer pageSize) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         // 查询用户角色是否包含命题老师
         List<SysRole> list = sysUserRoleService.listRoleByUserId(sysUser.getId());
@@ -774,7 +773,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
         Page<ExamTaskDetailDto> page = new Page<>(pageNumber, pageSize);
-        IPage<ExamTaskDetailDto> examTaskDtoIPage = this.baseMapper.listTaskPaper(page, schoolId, courseCode, paperNumber, startTime, endTime, orgIds, containsQuestionTeacher, sysUser.getId(), makeMethod, cardRuleName);
+        IPage<ExamTaskDetailDto> examTaskDtoIPage = this.baseMapper.listTaskPaper(page, schoolId, courseCode, paperNumber, startTime, endTime, orgIds, containsQuestionTeacher, sysUser.getId(), makeMethod, cardRuleId);
         return examTaskDtoIPage;
     }
 
@@ -843,6 +842,10 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (StringUtils.isBlank(examTaskDetail.getPaperConfirmAttachmentIds())) {
                 throw ExceptionResultEnum.ERROR.exception("入库审核ID不能为空");
             }
+            String[] paperTypes = examTaskDetail.getPaperType().split(",");
+            if (paperTypes.length - examTaskDetail.getDrawCount().intValue() < 0) {
+                throw ExceptionResultEnum.ERROR.exception("单次抽卷数量不能大于卷型数量");
+            }
 
             // 校验题卡是否提交
             ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
@@ -873,8 +876,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
         // 更新examTask状态status
         ExamTask examTask = this.getById(examTaskDetail.getExamTaskId());
-        if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
-            examTask.setStatus(ExamStatusEnum.SUBMIT);
+        if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name())) {
+            if (Objects.isNull(examTask.getFlowId())) {
+                //TODO 这里以后要判断学校code来取流程key
+                examTask.setStatus(ExamStatusEnum.SUBMIT);
+                if (examTask.getReview()) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
+                    ProcessInstance processInstance = activitiService.startActivity(SystemConstant.GDYKDX_FLOW_KEY, map);
+                    examTask.setFlowId(Long.parseLong(processInstance.getId()));
+                }
+            }
         }
 
         UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
@@ -883,6 +895,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 .set(ExamTask::getUpdateId, sysUser.getId())
                 .set(ExamTask::getUpdateTime, System.currentTimeMillis())
                 .set(ExamTask::getReviewStatus, null)
+                .set(ExamTask::getFlowId, examTask.getFlowId())
                 .eq(ExamTask::getId, examTask.getId());
         this.update(updateWrapper);
 
@@ -1320,4 +1333,138 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
         examTaskDetailService.removeById(examTaskDetail.getId());
     }
+
+    @Transactional
+    @Override
+    public ExamTask saveExamTaskAndExamTaskDetail(ExamTaskApplyParam examTaskApplyParam) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        ExamTask examTask = examTaskApplyParam.getExamTask();
+        ExamTaskDetail examTaskDetail = examTaskApplyParam.getExamTaskDetail();
+        try {
+            if (StringUtils.isNotBlank(examTask.getPaperNumber())) {
+                QueryWrapper<ExamTask> taskQueryWrapper = new QueryWrapper<>();
+                taskQueryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getPaperNumber, examTask.getPaperNumber());
+                ExamTask task = this.getOne(taskQueryWrapper);
+                if (task != null && Objects.nonNull(examTask.getId()) && examTask.getId().longValue() != task.getId().longValue()) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷编号已存在");
+                }
+            } else {
+                // 试卷编号生成规则:年月日(例如:20100419)+0000(例如:0001)顺序编号
+                String paperNumber = printCommonService.createPaperNumber(schoolId);
+                examTask.setPaperNumber(paperNumber);
+            }
+
+            BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
+            if (basicExamRule == null) {
+                throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
+            }
+            examTask.setId(Objects.isNull(examTask.getId()) ? SystemConstant.getDbUuid() : examTask.getId());
+            examTask.setSchoolId(schoolId);
+            examTask.setOrgId(sysUser.getOrgId());
+            examTask.setCreateId(sysUser.getId());
+            examTask.setReview(basicExamRule.getReview());
+            examTask.setUserId(sysUser.getId());
+            if (examTask.getUserId() == null || !ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
+                examTask.setStatus(ExamStatusEnum.DRAFT);
+            } else {
+                if (Objects.isNull(examTask.getFlowId())) {
+                    //TODO 这里以后要判断学校code来取流程key
+                    examTask.setStatus(ExamStatusEnum.SUBMIT);
+                    if (basicExamRule.getReview()) {
+                        Map<String, Object> map = new HashMap<>();
+                        map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
+                        ProcessInstance processInstance = activitiService.startActivity(SystemConstant.GDYKDX_FLOW_KEY, map);
+                        examTask.setFlowId(Long.parseLong(processInstance.getId()));
+
+                    }
+                }
+            }
+            this.saveOrUpdate(examTask);
+
+            // 提交时,校验
+            if (ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
+
+                if(Objects.nonNull(examTask.getFlowId())){
+                    // 审核一级
+                    Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(examTask.getFlowId())).singleResult();
+                    if(Objects.nonNull(task)) {
+                        Map<String, Object> map1 = new HashMap<>();
+                        map1.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
+                        activitiService.taskApprove(map1);
+                    }
+                }
+
+                if (StringUtils.isBlank(examTaskDetail.getPaperType())) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷类型不能为空");
+                }
+                if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷ID不能为空");
+                }
+                if (examTaskDetail.getCardId() == null) {
+                    throw ExceptionResultEnum.ERROR.exception("题卡ID不能为空");
+                }
+                if (StringUtils.isBlank(examTaskDetail.getPaperConfirmAttachmentIds())) {
+                    throw ExceptionResultEnum.ERROR.exception("入库审核ID不能为空");
+                }
+                String[] paperTypes = examTaskDetail.getPaperType().split(",");
+                if (paperTypes.length - examTaskDetail.getDrawCount().intValue() < 0) {
+                    throw ExceptionResultEnum.ERROR.exception("单次抽卷数量不能大于卷型数量");
+                }
+
+                // 校验题卡是否提交
+                ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
+                if (!ExamCardStatusEnum.SUBMIT.name().equals(examCard.getStatus().name())) {
+                    throw ExceptionResultEnum.ERROR.exception("请先提交题卡");
+                }
+
+                // 是否强制包含试卷
+
+                List<Map> paperAttachmentIds = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
+                // 未上传试卷的类型个数
+                long count = paperAttachmentIds.stream().filter(m -> StringUtils.isBlank(m.get("attachmentId").toString())).count();
+                if (basicExamRule.getIncludePaper()) {
+                    if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
+                        throw ExceptionResultEnum.ERROR.exception("试卷文件未上传");
+                    }
+                    if (count > 0) {
+                        throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传");
+                    }
+                } else {
+                    // count == 0为全部上传
+                    if (count != 0 && paperAttachmentIds.size() != count) {
+                        throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传或全部不上传");
+                    }
+                }
+            }
+
+            QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTask.getId());
+            ExamTaskDetail detail = examTaskDetailService.getOne(queryWrapper);
+            if (detail != null) {
+                examTaskDetail.setId(detail.getId());
+                // 已曝光试卷和未曝光试卷赋值
+                examTaskDetail.setExposedPaperType(detail.getExposedPaperType());
+                examTaskDetail.setUnexposedPaperType(examTaskDetail.getPaperType());
+            } else {
+                // 已曝光试卷和未曝光试卷赋值(新增时,已曝光试卷为null,未曝光试卷为paper_type)
+                examTaskDetail.setUnexposedPaperType(examTaskDetail.getPaperType());
+            }
+            examTaskDetail.setExamTaskId(examTask.getId());
+            examTaskDetail.setUpdateId(sysUser.getId());
+            examTaskDetail.setUpdateTime(System.currentTimeMillis());
+
+            examTaskDetailService.saveOrUpdate(examTaskDetail);
+
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            if (e instanceof ActivitiObjectNotFoundException) {
+                ResultUtil.error("流程不存在");
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+            e.printStackTrace();
+        }
+        return examTask;
+    }
 }

+ 75 - 71
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -188,46 +188,50 @@
     </select>
     <select id="listTaskReviewUnaudited" resultType="com.qmth.distributed.print.business.bean.dto.ExamTaskDto">
         SELECT
-        a.id,
-        a.school_id schoolId,
-        a.course_code courseCode,
-        a.course_name courseName,
-        a.specialty,
-        a.paper_number paperNumber,
-        a.card_rule_id cardRuleId,
-        case a.card_rule_id when -1 then '全部通卡' else b.name end cardRuleName,
-        a.user_id userId,
-        c.real_name userName,
-        d.real_name createName,
-        a.start_time startTime,
-        a.end_time endTime,
-        a.enable,
-        a.create_id createId,
-        a.create_time createTime,
-        a.status,
-        CASE
-        WHEN a.review = 1 AND a.status = 'SUBMIT' THEN 'NOT_AUDITED'
-        WHEN a.review = 1 AND a.status IN ('STAGE', 'FINISH') AND a.review_status IS NOT NULL THEN 'AUDITED'
-        ELSE ''
-        END auditStatus,
-        CASE
-        WHEN a.review_status IS NULL THEN ''
-        ELSE a.review_status
-        END reviewStatus
+            a.id,
+            a.school_id schoolId,
+            a.course_code courseCode,
+            a.course_name courseName,
+            a.specialty,
+            a.paper_number paperNumber,
+            a.card_rule_id cardRuleId,
+            case a.card_rule_id when -1 then '全部通卡' else b.name end cardRuleName,
+            a.user_id userId,
+            c.real_name userName,
+            d.real_name createName,
+            a.start_time startTime,
+            a.end_time endTime,
+            a.enable,
+            a.create_id createId,
+            a.create_time createTime,
+            a.status,
+            a.flow_id flowId,
+            f.setup,
+            CASE
+                WHEN a.review = 1 AND a.status = 'SUBMIT' THEN 'NOT_AUDITED'
+                WHEN a.review = 1 AND a.status IN ('STAGE', 'FINISH') AND a.review_status IS NOT NULL THEN 'AUDITED'
+                ELSE ''
+            END auditStatus,
+            CASE
+                WHEN a.review_status IS NULL THEN ''
+                ELSE a.review_status
+            END reviewStatus
         FROM
-        exam_task a
+            exam_task a
         LEFT JOIN
-        basic_card_rule b ON a.card_rule_id = b.id
+            basic_card_rule b ON a.card_rule_id = b.id
         LEFT JOIN
-        sys_user c ON a.user_id = c.id
+            sys_user c ON a.user_id = c.id
         LEFT JOIN
-        sys_user d ON a.create_id = d.id
+            sys_user d ON a.create_id = d.id
         LEFT JOIN
-        exam_task_paper_log e ON a.id = e.exam_task_id AND e.review = false
+            exam_task_paper_log e ON a.id = e.exam_task_id AND e.review = false
+        LEFT JOIN
+            t_f_flow_approve f ON a.flow_id = f.flow_id
         <where>
             a.enable = true
-            and a.review = true
-            and ((a.status = 'SUBMIT' and a.review_status is null) or (a.status = 'FINISH' and e.id is not null ))
+            AND a.review = true
+            AND f.status != 'FINISH'
             <if test="schoolId != null and schoolId != ''">
                 and a.school_id = #{schoolId}
             </if>
@@ -350,46 +354,45 @@
     </select>
     <select id="listTaskPaper" resultType="com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto">
         SELECT
-        a.id,
-        a.school_id schoolId,
-        a.course_code courseCode,
-        a.course_name courseName,
-        a.specialty,
-        a.paper_number paperNumber,
-        a.user_id userId,
-        a.card_rule_id cardRuleId,
-        c.real_name userName,
-        d.real_name createName,
-        a.start_time startTime,
-        a.end_time endTime,
-        a.create_id createId,
-        ifnull(e.operate_time, a.update_time) createTime,
-        b.enable,
-        b.paper_type paperType,
-        b.exposed_paper_type exposedPaperType,
-        b.unexposed_paper_type unexposedPaperType,
-        case a.card_rule_id when -1 then '全部通卡' else e.name end cardRuleName,
+            a.id,
+            a.school_id schoolId,
+            a.course_code courseCode,
+            a.course_name courseName,
+            a.specialty,
+            a.paper_number paperNumber,
+            a.user_id userId,
+            a.card_rule_id cardRuleId,
+            c.real_name userName,
+            d.real_name createName,
+            a.start_time startTime,
+            a.end_time endTime,
+            a.create_id createId,
+            IFNULL(g.update_time, a.update_time) createTime,
+            b.enable,
+            b.paper_type paperType,
+            b.exposed_paper_type exposedPaperType,
+            b.unexposed_paper_type unexposedPaperType,
+            CASE a.card_rule_id
+            WHEN - 1 THEN '全部通卡'
+            ELSE e.name
+            END cardRuleName,
         f.make_method makeMethod
         FROM
         exam_task a
-        LEFT JOIN
+            LEFT JOIN
         exam_task_detail b ON a.id = b.exam_task_id
-        LEFT JOIN
-        (SELECT
-        a.exam_task_id, MAX(operate_time) operate_time
-        FROM
-        exam_task_review_log a
-        GROUP BY a.exam_task_id) e ON e.exam_task_id = a.id
-        LEFT JOIN
+            LEFT JOIN
+        t_f_flow_approve g ON g.flow_id = a.flow_id
+            LEFT JOIN
         sys_user c ON a.user_id = c.id
-        LEFT JOIN
+            LEFT JOIN
         sys_user d ON a.create_id = d.id
-        LEFT JOIN
+            LEFT JOIN
         basic_card_rule e ON a.card_rule_id = e.id
-        LEFT JOIN
+            LEFT JOIN
         exam_card f ON b.card_id = f.id
         <where>
-            a.status = 'FINISH'
+            (a.flow_id is null or (a.flow_id is not null and g.status = 'FINISH'))
             <if test="schoolId != null and schoolId != ''">
                 and a.school_id = #{schoolId}
             </if>
@@ -417,11 +420,8 @@
             <if test="makeMethod != null and makeMethod != ''">
                 and f.make_method = #{makeMethod}
             </if>
-            <if test="cardRuleName != null and cardRuleName != ''">
-                and e.name like concat('%',#{cardRuleName},'%')
-            </if>
-            <if test="cardRuleName != null and cardRuleName = -1">
-                and a.card_rule_id = -1
+            <if test="cardRuleId != null and cardRuleId != ''">
+                and a.card_rule_id = #{cardRuleId}
             </if>
         </where>
         order by a.create_time desc
@@ -447,11 +447,15 @@
             case #{source} when 'REVIEW' then ifnull(c.card_id, a.card_id) else a.card_id end cardId,
             a.paper_confirm_attachment_ids paperConfirmAttachmentIds,
             a.remark,
-            ifnull(d.make_method, b.make_method) makeMethod,
-            ifnull(d.status, b.status) status
+            ifnull(d.make_method, a.make_method) makeMethod,
+            a.draw_count drawCount,
+            ifnull(d.status, b.status) status,
+            e.flow_id flowId
         FROM
             exam_task_detail a
                 LEFT JOIN
+            exam_task e on a.exam_task_id = e.id
+                LEFT JOIN
             exam_task_paper_log c ON a.exam_task_id = c.exam_task_id and c.review = false
                 LEFT JOIN
             exam_card b ON a.card_id = b.id

+ 17 - 12
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -32,6 +32,8 @@ import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.task.Task;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
@@ -90,6 +92,9 @@ public class ExamTaskController {
     @Resource
     AsyncCreatePdfTempleteService asyncCreatePdfTempleteService;
 
+    @Resource
+    TaskService taskService;
+
     /**
      *
      * @param enable
@@ -300,6 +305,12 @@ public class ExamTaskController {
                               @RequestParam(value = "examTaskId", required = true) Long examTaskId,
                               @RequestParam(value = "source", required = false) String source) {
         ExamTaskDetailCardDto detail = examTaskService.applyGetOne(examTaskId, source);
+        if(Objects.nonNull(detail.getFlowId())){
+            Task task = taskService.createTaskQuery().processInstanceId(detail.getFlowId()).singleResult();
+            if(Objects.nonNull(task)){
+                detail.setFlowTaskId(task.getId());
+            }
+        }
         return ResultUtil.ok(detail);
     }
 
@@ -486,10 +497,10 @@ public class ExamTaskController {
                                 @RequestParam(value = "startTime", required = false) Long startTime,
                                 @RequestParam(value = "endTime", required = false) Long endTime,
                                 @RequestParam(value = "makeMethod", required = false) MakeMethodEnum makeMethod,
-                                @RequestParam(value = "cardRuleName", required = false) String cardRuleName,
+                                @RequestParam(value = "cardRuleId", required = false) Long cardRuleId,
                                 @RequestParam("pageNumber") Integer pageNumber,
                                 @RequestParam("pageSize") Integer pageSize) {
-        IPage<ExamTaskDetailDto> examTaskDtoIPage = examTaskService.listTaskPaper(courseCode, paperNumber, startTime, endTime,makeMethod,cardRuleName, pageNumber, pageSize);
+        IPage<ExamTaskDetailDto> examTaskDtoIPage = examTaskService.listTaskPaper(courseCode, paperNumber, startTime, endTime,makeMethod,cardRuleId, pageNumber, pageSize);
         return ResultUtil.ok(examTaskDtoIPage);
     }
 
@@ -578,19 +589,13 @@ public class ExamTaskController {
     @ApiOperation(value = "入库申请-新建命题任务-暂存/提交")
     @RequestMapping(value = "/save_task_apply", method = RequestMethod.POST)
     public Result saveTaskApply(@RequestBody ExamTaskApplyParam examTaskApplyParam) throws IOException {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        examTaskApplyParam.getExamTask().setUserId(sysUser.getId());
-        ExamTask task = examTaskService.saveExamTaskNew(examTaskApplyParam.getExamTask());
-        ExamTaskDetail examTaskDetail = examTaskApplyParam.getExamTaskDetail();
-        examTaskDetail.setExamTaskId(task.getId());
-        boolean isSuccess = examTaskService.saveExamTaskDetail(examTaskDetail);
-        ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
-        if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
+        ExamTask task = examTaskService.saveExamTaskAndExamTaskDetail(examTaskApplyParam);
+        if (examTaskApplyParam.getExamTaskDetail().getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !task.getReview()) {
             // 校验是否可以提交打印状态
-            printCommonService.checkData(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber(), (SysUser) ServletUtil.getRequestUser());
+            printCommonService.checkData(task.getSchoolId(), task.getCourseCode(), task.getPaperNumber(), (SysUser) ServletUtil.getRequestUser());
         }
 
-        return ResultUtil.ok(task.getId());
+        return ResultUtil.ok(String.valueOf(task.getId()), "");
     }
 
     /**