Commit dc69b020 authored by W_Y's avatar W_Y

提交体系审查任务

parent 8e7a14ce
......@@ -11,4 +11,11 @@ import java.util.List;
@Repository
public interface ReviewDetailsMapper extends BaseMapper<ReviewDetails> {
List<ReviewDetails> findByKeyPointList(@Param("reviewKeyPointList") List<ReviewKeyPoint> reviewKeyPointList);
/**
* 根据任务id查询没有回答细则的数量
* @param taskId
* @return
*/
List<ReviewDetails> findNoResult(@Param("taskId") Long taskId);
}
......@@ -20,6 +20,11 @@ public interface ReviewDetailsResultMapper extends BaseMapper<ReviewDetailsResul
ReviewDetailsResult findByTaskIdAndDetailsId(@Param("taskId") Long taskId,@Param("reviewDetailsId") Long reviewDetailsId);
/**
* 根据任务id查询不通过的数量
* @param taskId
* @return
*/
Long findNotPass(@Param("taskId") Long taskId);
}
......
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.*;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
......@@ -32,6 +35,10 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
@Autowired
private SystemReviewTaskMapper systemReviewTaskMapper;
@Autowired
private ReviewDetailsResultMapper reviewDetailsResultMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已经开始的任务", HttpStatus.ERROR);
......@@ -41,11 +48,33 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
public void doSubmit(SystemReviewTask systemReviewTask) {
// TODO
// 1. 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(systemReviewTask.getStandardId(), ReviewStandard.TYPE_SYSTEM);
// 2. 所有细则必须有对应答案
// 3. 答案的 id + text 必须与细则对应的答案一致
// 4. 将最终问卷归档到 standard 字段
// 5. 填充task_end_time
// 6. 修改任务状态为 FINISH
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(systemReviewTask.getId());
// 3. 将最终问卷归档到 standard 字段
setDetailsResult(standardTree, results);
systemReviewTask.setStandard(standardTree);
// 4. 填充task_end_time
systemReviewTask.setTaskEndTime(new Date());
// 5. 修改任务状态为 FINISH
systemReviewTask.setTaskStatus(SystemReviewTask.STATUS_FINISH);
// 6. 填写当前用户id
// 获取当前登陆人
SysUser loginUser = SecurityUtils.getLoginUser().getUser();
systemReviewTask.setSubmitById(loginUser.getUserId());
systemReviewTask.setSubmitByName(loginUser.getNickName());
// 7. 设置问卷结果
if (reviewDetailsResultMapper.findNotPass(systemReviewTask.getId()) > 0) {
systemReviewTask.setTaskResult("REJECT");
} else {
systemReviewTask.setTaskResult("PASS");
}
systemReviewTaskMapper.updateById(systemReviewTask);
}
@Override
......
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SnowflakeUtil;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.ReviewDetailsMapper;
import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService;
......@@ -46,6 +50,9 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
@Autowired
private StandardService standardService;
@Autowired
private ReviewDetailsMapper reviewDetailsMapper;
@Override
public void createTaskTest(SystemReviewTaskCreateRequest request) {
......@@ -114,8 +121,13 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
@Override
public void submit(SystemReviewTaskSubmitRequest request) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(request.getTaskId());
strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doSubmit(systemReviewTask);
List<ReviewDetails> detailsList = reviewDetailsMapper.findNoResult(request.getTaskId());
if (detailsList != null) {
throw new ServiceException("存在未填写的问卷,请填写完整", HttpStatus.ERROR);
} else {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(request.getTaskId());
strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doSubmit(systemReviewTask);
}
}
}
......
......@@ -13,4 +13,8 @@
</foreach>
</select>
<select id="findNoResult" resultType="com.ruoyi.domain.ReviewDetails">
SELECT * FROM t_review_details WHERE id NOT IN (SELECT review_details_id FROM t_review_details_result WHERE task_id = #{taskId})
</select>
</mapper>
......@@ -33,8 +33,4 @@
WHERE passed = 0 AND task_id = #{taskId}
</select>
<select id="findNoResult" resultType="long">
SELECT COUNT(*) sum FROM t_review_details_result
WHERE passed is null AND task_id = #{taskId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment