1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.ReviewStandard;
import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategySystemReviewTask;
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 org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Transactional
@Service
public class StrategySystemReviewTaskNew implements StrategySystemReviewTask, InitializingBean {
@Autowired
private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private ReviewStandardService reviewStandardService;
@Autowired
private SystemReviewTaskMapper systemReviewTaskMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
systemReviewTask.setTaskBeginTime(new Date());
systemReviewTask.setTaskStatus(SystemReviewTask.STATUS_PENDING);
systemReviewTaskMapper.updateById(systemReviewTask);
}
@Override
public void doSubmit(SystemReviewTask systemReviewTask, List<String> imagesUrl) {
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
}
@Override
public void doClose(SystemReviewTask systemReviewTask) {
systemReviewTask.setTaskEndTime(new Date());
systemReviewTask.setTaskStatus(SystemReviewTask.STATUS_CLOSE);
systemReviewTaskMapper.updateById(systemReviewTask);
}
@Override
public void doConfirm(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能确认一个尚未开始的任务", HttpStatus.ERROR);
}
// NEW状态下
// 1.standard字段查询当前最新问卷
// 2.不查询场景变更任务
// 3.无需联查问卷答案
@Override
public SystemReviewTaskViewResponse doView(SystemReviewTask systemReviewTask) {
// 获取最新问卷
List<ReviewStandard> standardTree = reviewStandardService.findTree(systemReviewTask.getStandardId(), ReviewStandard.TYPE_SYSTEM);
// 将问卷赋值到任务
systemReviewTask.setStandard(standardTree);
// 生成返回结果
SystemReviewTaskViewResponse response = new SystemReviewTaskViewResponse();
response.setSystemReviewTask(systemReviewTask);
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategySystemReviewTaskContext.putResource(SystemReviewTask.STATUS_NEW, applicationContext.getBean(this.getClass()));
}
}