Commit 0f9d0abe authored by 王飞's avatar 王飞

Feat

1、实现了任务的开始和关闭功能。

Reference N/A
parent 3b05cea6
...@@ -5,6 +5,12 @@ import com.ruoyi.web.response.SystemReviewTaskViewResponse; ...@@ -5,6 +5,12 @@ import com.ruoyi.web.response.SystemReviewTaskViewResponse;
public interface StrategySystemReviewTask { public interface StrategySystemReviewTask {
void doStart(SystemReviewTask systemReviewTask);
void doSubmit(SystemReviewTask systemReviewTask);
void doClose(SystemReviewTask systemReviewTask);
SystemReviewTaskViewResponse doView(SystemReviewTask systemReviewTask); SystemReviewTaskViewResponse doView(SystemReviewTask systemReviewTask);
} }
...@@ -3,6 +3,7 @@ package com.ruoyi.service; ...@@ -3,6 +3,7 @@ package com.ruoyi.service;
import com.ruoyi.domain.SystemReviewTask; import com.ruoyi.domain.SystemReviewTask;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.web.request.SystemReviewTaskCreateRequest; import com.ruoyi.web.request.SystemReviewTaskCreateRequest;
import com.ruoyi.web.request.SystemReviewTaskStartRequest;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
/** /**
...@@ -25,4 +26,10 @@ public interface SystemReviewTaskService extends IService<SystemReviewTask> { ...@@ -25,4 +26,10 @@ public interface SystemReviewTaskService extends IService<SystemReviewTask> {
*/ */
SystemReviewTaskViewResponse view(Long taskId); SystemReviewTaskViewResponse view(Long taskId);
/**
* 开始一个任务
* @param request
*/
void start(SystemReviewTaskStartRequest request);
} }
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.SystemReviewTask; import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.service.StrategySystemReviewTask; import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
...@@ -10,6 +12,21 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -10,6 +12,21 @@ import org.springframework.transaction.annotation.Transactional;
@Service(SystemReviewTask.STATUS_CLOSE) @Service(SystemReviewTask.STATUS_CLOSE)
public class StrategySystemReviewTaskClose implements StrategySystemReviewTask { public class StrategySystemReviewTaskClose implements StrategySystemReviewTask {
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已关闭的任务", HttpStatus.ERROR);
}
@Override
public void doSubmit(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能提交一个已关闭的任务", HttpStatus.ERROR);
}
@Override
public void doClose(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能关闭一个已关闭的任务", HttpStatus.ERROR);
}
// CLOSE状态下 // CLOSE状态下
// 1.standard字段使用task中归档的问卷 // 1.standard字段使用task中归档的问卷
// 2.不查询场景变更任务 // 2.不查询场景变更任务
......
...@@ -10,12 +10,12 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -10,12 +10,12 @@ import java.util.concurrent.ConcurrentHashMap;
@Transactional @Transactional
@Service @Service
public class StateSystemReviewTaskContext { public class StrategySystemReviewTaskContext {
@Autowired @Autowired
private final Map<String, StrategySystemReviewTask> resourceMap = new ConcurrentHashMap<>(); private final Map<String, StrategySystemReviewTask> resourceMap = new ConcurrentHashMap<>();
public StateSystemReviewTaskContext(Map<String, StrategySystemReviewTask> strategyMap) { public StrategySystemReviewTaskContext(Map<String, StrategySystemReviewTask> strategyMap) {
this.resourceMap.clear(); this.resourceMap.clear();
strategyMap.forEach(resourceMap::put); strategyMap.forEach(resourceMap::put);
} }
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.SystemReviewTask; import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.service.StrategySystemReviewTask; import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
...@@ -10,6 +12,21 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -10,6 +12,21 @@ import org.springframework.transaction.annotation.Transactional;
@Service(SystemReviewTask.STATUS_FINISH) @Service(SystemReviewTask.STATUS_FINISH)
public class StrategySystemReviewTaskFinish implements StrategySystemReviewTask { public class StrategySystemReviewTaskFinish implements StrategySystemReviewTask {
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已完成的任务", HttpStatus.ERROR);
}
@Override
public void doSubmit(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能提交一个已完成的任务", HttpStatus.ERROR);
}
@Override
public void doClose(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能关闭一个已完成的任务", HttpStatus.ERROR);
}
// FINISH状态下 // FINISH状态下
// 1.standard字段使用task中归档的问卷 // 1.standard字段使用task中归档的问卷
// 2.不查询场景变更任务 // 2.不查询场景变更任务
......
package com.ruoyi.service.impl; 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.ReviewStandard;
import com.ruoyi.domain.SystemReviewTask; import com.ruoyi.domain.SystemReviewTask;
import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewStandardService; import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategySystemReviewTask; import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
...@@ -9,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
@Transactional @Transactional
...@@ -18,6 +22,28 @@ public class StrategySystemReviewTaskNew implements StrategySystemReviewTask { ...@@ -18,6 +22,28 @@ public class StrategySystemReviewTaskNew implements StrategySystemReviewTask {
@Autowired @Autowired
private ReviewStandardService reviewStandardService; 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) {
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
}
@Override
public void doClose(SystemReviewTask systemReviewTask) {
systemReviewTask.setTaskEndTime(new Date());
systemReviewTask.setTaskStatus(SystemReviewTask.STATUS_CLOSE);
systemReviewTaskMapper.updateById(systemReviewTask);
}
// NEW状态下 // NEW状态下
// 1.standard字段查询当前最新问卷 // 1.standard字段查询当前最新问卷
// 2.不查询场景变更任务 // 2.不查询场景变更任务
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.*; import com.ruoyi.domain.*;
import com.ruoyi.service.ReviewDetailsResultService; import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.ReviewSceneChangeTaskService; import com.ruoyi.service.*;
import com.ruoyi.service.ReviewStandardService;
import com.ruoyi.service.StrategySystemReviewTask;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
...@@ -28,6 +29,32 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask ...@@ -28,6 +29,32 @@ public class StrategySystemReviewTaskPending implements StrategySystemReviewTask
@Autowired @Autowired
private ReviewSceneChangeTaskService reviewSceneChangeTaskService; private ReviewSceneChangeTaskService reviewSceneChangeTaskService;
@Autowired
private SystemReviewTaskMapper systemReviewTaskMapper;
@Override
public void doStart(SystemReviewTask systemReviewTask) {
throw new ServiceException("不能开始一个已经开始的任务", HttpStatus.ERROR);
}
@Override
public void doSubmit(SystemReviewTask systemReviewTask) {
// TODO
// 1. 获取最新问卷
// 2. 所有细则必须有对应答案
// 3. 答案的 id + text 必须与细则对应的答案一致
// 4. 将最终问卷归档到 standard 字段
// 5. 填充task_end_time
// 6. 修改任务状态为 FINISH
}
@Override
public void doClose(SystemReviewTask systemReviewTask) {
systemReviewTask.setTaskEndTime(new Date());
systemReviewTask.setTaskStatus(SystemReviewTask.STATUS_CLOSE);
systemReviewTaskMapper.updateById(systemReviewTask);
}
// PENDING状态下 // PENDING状态下
// 1.standard字段查询当前最新问卷 // 1.standard字段查询当前最新问卷
// 2.查询场景变更任务 // 2.查询场景变更任务
......
...@@ -10,14 +10,13 @@ import com.ruoyi.mapper.SystemReviewTaskMapper; ...@@ -10,14 +10,13 @@ import com.ruoyi.mapper.SystemReviewTaskMapper;
import com.ruoyi.service.*; import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.SystemReviewTaskCreateRequest; import com.ruoyi.web.request.SystemReviewTaskCreateRequest;
import com.ruoyi.web.request.SystemReviewTaskStartRequest;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* @author wangfei * @author wangfei
...@@ -35,13 +34,7 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap ...@@ -35,13 +34,7 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
private SystemReviewTaskService systemReviewTaskService; private SystemReviewTaskService systemReviewTaskService;
@Autowired @Autowired
private ReviewStandardService reviewStandardService; private StrategySystemReviewTaskContext strategySystemReviewTaskContext;
@Autowired
private ReviewDetailsResultService reviewDetailsResultService;
@Autowired
private StateSystemReviewTaskContext stateSystemReviewTaskContext;
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
...@@ -88,7 +81,13 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap ...@@ -88,7 +81,13 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
@Override @Override
public SystemReviewTaskViewResponse view(Long taskId) { public SystemReviewTaskViewResponse view(Long taskId) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(taskId); SystemReviewTask systemReviewTask = systemReviewTaskService.getById(taskId);
return stateSystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doView(systemReviewTask); return strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doView(systemReviewTask);
}
@Override
public void start(SystemReviewTaskStartRequest request) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(request.getTaskId());
strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doStart(systemReviewTask);
} }
} }
......
...@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult; ...@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.SystemReviewTaskService; import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.web.request.SystemReviewTaskCreateRequest; import com.ruoyi.web.request.SystemReviewTaskCreateRequest;
import com.ruoyi.web.request.SystemReviewTaskStartRequest;
import com.ruoyi.web.request.SystemReviewTaskViewRequest; import com.ruoyi.web.request.SystemReviewTaskViewRequest;
import com.ruoyi.web.response.SystemReviewTaskViewResponse; import com.ruoyi.web.response.SystemReviewTaskViewResponse;
import org.apache.skywalking.apm.toolkit.trace.Tag; import org.apache.skywalking.apm.toolkit.trace.Tag;
...@@ -42,4 +43,11 @@ public class SystemReviewTaskController extends BaseController { ...@@ -42,4 +43,11 @@ public class SystemReviewTaskController extends BaseController {
return AjaxResult.success(systemReviewTaskViewResponse); return AjaxResult.success(systemReviewTaskViewResponse);
} }
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/start")
public AjaxResult view(@Validated @RequestBody SystemReviewTaskStartRequest request) {
systemReviewTaskService.start(request);
return AjaxResult.success();
}
} }
package com.ruoyi.web.request;
import lombok.Data;
@Data
public class SystemReviewTaskStartRequest {
private Long taskId;
}
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