Commit 59318740 authored by 王飞's avatar 王飞

Merge branch 'wangdingyi' into 'dev'

开始一个车辆审查任务中的问卷任务

See merge request !33
parents 8ba7bb00 81c4a376
......@@ -161,4 +161,34 @@ public class CarReviewTask implements Serializable {
@ApiModelProperty("车型测试任务状态[NONE、NEW、PENDING、FINISH]")
private String testStatus;
/**
* 车型问卷开始时间
*/
@ApiModelProperty("车型问卷开始时间")
private Date reviewStartTime;
/**
* 车型问卷提交时间
*/
@ApiModelProperty("车型问卷提交时间")
private Date reviewSubmitTime;
/**
* 车型问卷提交人id
*/
@ApiModelProperty("车型问卷提交人id")
private Long reviewSubmitId;
/**
* 车型问卷提交人姓名
*/
@ApiModelProperty("车型问卷提交人姓名")
private String reviewSubmitName;
/**
* 车型问卷审查结果
*/
@ApiModelProperty("车型问卷审查结果")
private String reviewResult;
}
......@@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
* @TableName t_review_task_inbox
*/
@ApiModel
@TableName(value ="t_system_review_task_inbox")
@TableName(value ="t_review_task_inbox")
@Accessors(chain = true)
@Data
public class ReviewTaskInbox {
......
......@@ -6,4 +6,8 @@ import com.ruoyi.web.response.CarReviewTaskViewResponse;
public interface StrategyCarReviewTask {
CarReviewTaskViewResponse doView(CarReviewTask carReviewTask);
void doStartReview(CarReviewTask carReviewTask);
void doSubmitReview(CarReviewTask carReviewTask);
}
......@@ -5,10 +5,8 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SnowflakeUtil;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.ReviewTaskUserRelation;
import com.ruoyi.domain.Standard;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.ReviewDetailsMapper;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.mapper.CarReviewTaskMapper;
import com.ruoyi.service.ReviewTaskUserRelationService;
......@@ -54,6 +52,9 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Autowired
private ReviewDetailsMapper reviewDetailsMapper;
@Override
public List<CarReviewTask> findListByReviewStatus(String reviewStatus) {
return carReviewTaskMapper.findListByReviewStatus(reviewStatus);
......@@ -117,17 +118,18 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
@Override
public CarReviewTaskViewResponse viewReviewTask(Long taskId) {
CarReviewTask carReviewTask = carReviewTaskService.getById(taskId);
return strategyCarReviewTaskContext.getResource(carReviewTask.getTaskStatus() + "SystemReviewTask").doView(carReviewTask);
return strategyCarReviewTaskContext.getResource(carReviewTask.getReviewStatus()).doView(carReviewTask);
}
@Override
public void startReviewTask(CarReviewTaskStartRequest request) {
CarReviewTask carReviewTask = carReviewTaskService.getById(request.getTaskId());
strategyCarReviewTaskContext.getResource(carReviewTask.getReviewStatus()).doStartReview(carReviewTask);
}
@Override
public void submitReviewTask(CarReviewTaskSubmitRequest request) {
List<ReviewDetails> detailsList = reviewDetailsMapper.findNoResult(request.getTaskId());
}
@Override
......
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.service.StrategySystemReviewTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -13,8 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Service
public class StrategyCarReviewTaskContext {
@Autowired
private final Map<String, StrategyCarReviewTask> resourceMap = new ConcurrentHashMap<>();
private Map<String, StrategyCarReviewTask> resourceMap = new ConcurrentHashMap<>();
public void putResource(String key, StrategyCarReviewTask strategyCarReviewTask) {
resourceMap.put(key, strategyCarReviewTask);
......
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
public class StrategyCarReviewTaskFinish implements StrategyCarReviewTask, InitializingBean {
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
// FINISH状态下
// 1.standard字段使用task中归档的问卷
// 2.不查询场景变更任务
// 3.无需联查问卷答案
@Override
public CarReviewTaskViewResponse doView(CarReviewTask carReviewTask) {
CarReviewTaskViewResponse response = new CarReviewTaskViewResponse();
response.setCarReviewTask(carReviewTask);
return response;
}
@Override
public void doStartReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能开始一个结束的任务", HttpStatus.ERROR);
}
@Override
public void doSubmitReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能提交一个结束的任务", HttpStatus.ERROR);
}
@Override
public void afterPropertiesSet() throws Exception {
strategyCarReviewTaskContext.putResource(CarReviewTask.REVIEW_STATUS_FINISH, applicationContext.getBean(this.getClass()));
}
}
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.domain.ReviewStandard;
import com.ruoyi.mapper.CarReviewTaskMapper;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Date;
import java.util.List;
public class StrategyCarReviewTaskNew implements StrategyCarReviewTask, InitializingBean {
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewStandardService reviewStandardService;
@Autowired
private CarReviewTaskMapper carReviewTaskMapper;
// NEW状态下
// 1.standard字段查询当前最新问卷
// 2.不查询场景变更任务
// 3.无需联查问卷答案
@Override
public CarReviewTaskViewResponse doView(CarReviewTask carReviewTask) {
// 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR);
// 将问卷赋值到任务
carReviewTask.setStandard(standardTree);
// 生成返回结果
CarReviewTaskViewResponse response = new CarReviewTaskViewResponse();
response.setCarReviewTask(carReviewTask);
return response;
}
@Override
public void doStartReview(CarReviewTask carReviewTask) {
carReviewTask.setReviewStartTime(new Date());
carReviewTask.setReviewStatus(CarReviewTask.REVIEW_STATUS_PENDING);
carReviewTaskMapper.updateById(carReviewTask);
}
@Override
public void doSubmitReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能提交一个未开始的任务", HttpStatus.ERROR);
}
@Override
public void afterPropertiesSet() throws Exception {
strategyCarReviewTaskContext.putResource(CarReviewTask.REVIEW_STATUS_NEW, applicationContext.getBean(this.getClass()));
}
}
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.CarReviewTask;
import com.ruoyi.service.StrategyCarReviewTask;
import com.ruoyi.web.response.CarReviewTaskViewResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
public class StrategyCarReviewTaskNone implements StrategyCarReviewTask, InitializingBean {
@Autowired
private StrategyCarReviewTaskContext strategyCarReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Override
public CarReviewTaskViewResponse doView(CarReviewTask carReviewTask) {
throw new ServiceException("不能查看一个不存在的任务", HttpStatus.ERROR);
}
@Override
public void doStartReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能开始一个不存在的任务", HttpStatus.ERROR);
}
@Override
public void doSubmitReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能提交一个不存在的任务", HttpStatus.ERROR);
}
@Override
public void afterPropertiesSet() throws Exception {
strategyCarReviewTaskContext.putResource(CarReviewTask.REVIEW_STATUS_NONE, applicationContext.getBean(this.getClass()));
}
}
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.CarReviewTaskMapper;
import com.ruoyi.mapper.ReviewDetailsResultMapper;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewDetailsResultService;
......@@ -14,6 +19,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
......@@ -38,7 +44,7 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
private ReviewSceneChangeTaskService reviewSceneChangeTaskService;
@Autowired
private SystemReviewTaskMapper systemReviewTaskMapper;
private CarReviewTaskMapper carReviewTaskMapper;
@Autowired
private ReviewDetailsResultMapper reviewDetailsResultMapper;
......@@ -73,6 +79,43 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
return response;
}
@Override
public void doStartReview(CarReviewTask carReviewTask) {
throw new ServiceException("不能开始一个进行中的任务", HttpStatus.ERROR);
}
@Override
public void doSubmitReview(CarReviewTask carReviewTask) {
// 1. 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(carReviewTask.getStandardId(), ReviewStandard.TYPE_CAR);
// 2. 所有细则必须有对应答案
List<ReviewDetailsResult> results = reviewDetailsResultService.findByTaskId(carReviewTask.getId());
// 3. 将最终问卷归档到 standard 字段
setDetailsResult(standardTree, results);
carReviewTask.setStandard(standardTree);
// 4. 填充review_submit_time
carReviewTask.setReviewSubmitTime(new Date());
// 5. 修改任务状态为 FINISH
carReviewTask.setReviewStatus(CarReviewTask.REVIEW_STATUS_FINISH);
// 6. 填写当前用户id
// 获取当前登陆人
SysUser loginUser = SecurityUtils.getLoginUser().getUser();
carReviewTask.setReviewSubmitId(loginUser.getUserId());
carReviewTask.setReviewSubmitName(loginUser.getNickName());
// 7. 设置问卷结果
if (reviewDetailsResultMapper.findNotPass(carReviewTask.getId()) > 0) {
carReviewTask.setReviewResult("REJECT");
} else {
carReviewTask.setReviewResult("PASS");
}
carReviewTaskMapper.updateById(carReviewTask);
}
private void setDetailsResult(List<ReviewStandard> standards, List<ReviewDetailsResult> results) {
Map<Long, ReviewDetailsResult> resultMap = results.stream().collect(Collectors.toMap(ReviewDetailsResult::getReviewDetailsId, Function.identity(), (v1, v2) -> v1));
......@@ -92,6 +135,6 @@ public class StrategyCarReviewTaskPending implements StrategyCarReviewTask, Init
@Override
public void afterPropertiesSet() throws Exception {
strategyCarReviewTaskContext.putResource(CarReviewTask.TASK_STATUS_PENDING, applicationContext.getBean(this.getClass()));
strategyCarReviewTaskContext.putResource(CarReviewTask.REVIEW_STATUS_PENDING, applicationContext.getBean(this.getClass()));
}
}
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategyReviewSceneChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -12,7 +11,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Service
public class StrategyReviewSceneChangeContext {
@Autowired
private final Map<String, StrategyReviewSceneChange> strategyMap = new ConcurrentHashMap<>();
public void putResource(String key, StrategyReviewSceneChange strategySystemReviewTask) {
......
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategySystemReviewTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -12,7 +11,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Service
public class StrategySystemReviewTaskContext {
@Autowired
private final Map<String, StrategySystemReviewTask> resourceMap = new ConcurrentHashMap<>();
public void putResource(String key, StrategySystemReviewTask strategySystemReviewTask) {
......
......@@ -24,6 +24,11 @@
<result property="file" column="file" jdbcType="VARCHAR"/>
<result property="reviewStatus" column="review_status" jdbcType="VARCHAR"/>
<result property="testStatus" column="test_status" jdbcType="VARCHAR"/>
<result property="reviewStartTime" column="review_start_time" jdbcType="TIMESTAMP"/>
<result property="reviewSubmitTime" column="review_submit_time" jdbcType="TIMESTAMP"/>
<result property="reviewSubmitId" column="review_submit_id" jdbcType="BIGINT"/>
<result property="reviewSubmitName" column="review_submit_name" jdbcType="VARCHAR"/>
<result property="reviewResult" column="review_result" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -33,10 +38,14 @@
biz_info,create_time,leader_id,
leader,standard_id,name,
standard_no,file,review_status,
test_status
test_status,review_start_time,
review_submit_time,
review_submit_id,
review_submit_name,
review_result
</sql>
<select id="findListByReviewStatus" resultType="com.ruoyi.domain.CarReviewTask">
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,standard,biz_info,create_time,leader_id,leader,standard_id,name,standard_no,file,review_status,test_status
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,standard,biz_info,create_time,leader_id,leader,standard_id,name,standard_no,file,review_status,test_status,review_start_time,review_submit_time,review_submit_id,review_submit_name,review_result
FROM t_system_review_task WHERE review_status = #{reviewStatus} AND task_status = 'PENDING'
</select>
</mapper>
......@@ -44,7 +44,7 @@
<select id="findLastChangeByTaskId" resultType="com.ruoyi.domain.ReviewSceneChangeTask">
SELECT * FROM t_review_scene_change_task WHERE id IN
(
SELECT MAX(id) FROM t_review_scene_change_task WHERE task_status = 'FINISH' AND task_result = 'PASS' AND id IN (SELECT review_scene_change_task_id FROM t_system_review_task_inbox WHERE system_review_task_id = #{taskId} AND is_confirm = 0) GROUP BY review_scene_id
SELECT MAX(id) FROM t_review_scene_change_task WHERE task_status = 'FINISH' AND task_result = 'PASS' AND id IN (SELECT review_scene_change_task_id FROM t_review_task_inbox WHERE review_task_id = #{taskId} AND is_confirm = 0) GROUP BY review_scene_id
)
</select>
......
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