Commit 7eeaf27c authored by wdy's avatar wdy

Merge branch 'dev' of http://gitlab.91isoft.com:90/wangfei/vehicle-quality-review into wangdingyi

 Conflicts:
	quality-review/src/main/java/com/ruoyi/domain/Task.java
parents c71f150f 1bc2f4ec
...@@ -24,11 +24,16 @@ import java.util.List; ...@@ -24,11 +24,16 @@ import java.util.List;
public class Task { public class Task {
@TableField(exist = false) @TableField(exist = false)
public static final String STATUS_RUNNABLE = "RUNNABLE"; public static final String RUN_STATUS_RUNNABLE = "RUNNABLE";
@TableField(exist = false) @TableField(exist = false)
public static final String STATUS_RUNNING = "RUNNING"; public static final String RUN_STATUS_STATUS_RUNNING = "RUNNING";
@TableField(exist = false)
public static final String TASK_STATUS_NEW = "NEW";
@TableField(exist = false)
public static final String TASK_STATUS_PENDING = "PENDING";
@TableField(exist = false) @TableField(exist = false)
public static final String STATUS_FINISH = "FINISH"; public static final String TASK_STATUS_FINISH = "FINISH";
/** /**
* 汽车信息安全一般要求 * 汽车信息安全一般要求
......
...@@ -41,6 +41,11 @@ public interface CarReviewTaskService extends IService<CarReviewTask> { ...@@ -41,6 +41,11 @@ public interface CarReviewTaskService extends IService<CarReviewTask> {
*/ */
void startReviewTask(CarReviewTaskStartRequest request); void startReviewTask(CarReviewTaskStartRequest request);
/**
* 开始一个车辆审查任务中的问卷任务
*/
void startReviewTask(Long id);
/** /**
* 确认一个车辆审查任务中的问卷任务 * 确认一个车辆审查任务中的问卷任务
* @param request * @param request
......
...@@ -36,6 +36,12 @@ public interface SystemReviewTaskService extends IService<SystemReviewTask> { ...@@ -36,6 +36,12 @@ public interface SystemReviewTaskService extends IService<SystemReviewTask> {
*/ */
void start(SystemReviewTaskStartRequest request); void start(SystemReviewTaskStartRequest request);
/**
* 开始一个任务
* @param id
*/
void start(Long id);
/** /**
* 根据状态查找体系审查任务 * 根据状态查找体系审查任务
* @return * @return
......
package com.ruoyi.service;
import com.ruoyi.domain.Task;
import java.util.List;
public interface TaskState {
void doCreate(Task task, List<String> taskList);
void doStart(Task task);
void doSubmit(Task task);
}
...@@ -113,7 +113,12 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C ...@@ -113,7 +113,12 @@ public class CarReviewTaskServiceImpl extends ServiceImpl<CarReviewTaskMapper, C
@Override @Override
public void startReviewTask(CarReviewTaskStartRequest request) { public void startReviewTask(CarReviewTaskStartRequest request) {
CarReviewTask carReviewTask = carReviewTaskService.getById(request.getTaskId()); startReviewTask(request.getTaskId());
}
@Override
public void startReviewTask(Long id) {
CarReviewTask carReviewTask = carReviewTaskService.getById(id);
strategyCarReviewTaskContext.getResource(carReviewTask.getTaskStatus()).doStartReview(carReviewTask); strategyCarReviewTaskContext.getResource(carReviewTask.getTaskStatus()).doStartReview(carReviewTask);
} }
......
...@@ -43,6 +43,9 @@ public class StrategyCarReviewTaskSigned implements StrategyCarReviewTask, Initi ...@@ -43,6 +43,9 @@ public class StrategyCarReviewTaskSigned implements StrategyCarReviewTask, Initi
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
@Autowired
private TaskStateFacade taskStateFacade;
// SIGNED状态下 // SIGNED状态下
// 1.standard字段使用task中归档的问卷 // 1.standard字段使用task中归档的问卷
// 2.不查询场景变更任务 // 2.不查询场景变更任务
...@@ -84,7 +87,7 @@ public class StrategyCarReviewTaskSigned implements StrategyCarReviewTask, Initi ...@@ -84,7 +87,7 @@ public class StrategyCarReviewTaskSigned implements StrategyCarReviewTask, Initi
// 5.再找带该子任务所属的总任务,将总任务的状态由 RUNNING 改回 RUNNABLE // 5.再找带该子任务所属的总任务,将总任务的状态由 RUNNING 改回 RUNNABLE
Task task = taskMapper.selectById(taskMapper.findByCarReviewTaskId(carReviewTask.getId())); Task task = taskMapper.selectById(taskMapper.findByCarReviewTaskId(carReviewTask.getId()));
task.setTaskStatus(Task.STATUS_RUNNABLE); taskStateFacade.doSubmit(task);
carReviewTaskMapper.updateById(carReviewTask); carReviewTaskMapper.updateById(carReviewTask);
taskMapper.updateById(task); taskMapper.updateById(task);
......
...@@ -42,6 +42,9 @@ public class StrategySystemReviewTaskSigned implements StrategySystemReviewTask, ...@@ -42,6 +42,9 @@ public class StrategySystemReviewTaskSigned implements StrategySystemReviewTask,
@Autowired @Autowired
private TaskMapper taskMapper; private TaskMapper taskMapper;
@Autowired
private TaskStateFacade taskStateFacade;
@Override @Override
public void doStart(SystemReviewTask systemReviewTask) { public void doStart(SystemReviewTask systemReviewTask) {
...@@ -73,7 +76,7 @@ public class StrategySystemReviewTaskSigned implements StrategySystemReviewTask, ...@@ -73,7 +76,7 @@ public class StrategySystemReviewTaskSigned implements StrategySystemReviewTask,
// 5.再找带该子任务所属的总任务,将总任务的状态由 RUNNING 改回 RUNNABLE // 5.再找带该子任务所属的总任务,将总任务的状态由 RUNNING 改回 RUNNABLE
Task task = taskMapper.selectById(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId())); Task task = taskMapper.selectById(taskMapper.findBySystemReviewTaskId(systemReviewTask.getId()));
task.setTaskStatus(Task.STATUS_RUNNABLE); taskStateFacade.doSubmit(task);
systemReviewTaskMapper.updateById(systemReviewTask); systemReviewTaskMapper.updateById(systemReviewTask);
taskMapper.updateById(task); taskMapper.updateById(task);
......
...@@ -102,7 +102,12 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap ...@@ -102,7 +102,12 @@ public class SystemReviewTaskServiceImpl extends ServiceImpl<SystemReviewTaskMap
@Override @Override
public void start(SystemReviewTaskStartRequest request) { public void start(SystemReviewTaskStartRequest request) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(request.getTaskId()); start(request.getTaskId());
}
@Override
public void start(Long id) {
SystemReviewTask systemReviewTask = systemReviewTaskService.getById(id);
strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doStart(systemReviewTask); strategySystemReviewTaskContext.getResource(systemReviewTask.getTaskStatus()).doStart(systemReviewTask);
} }
......
...@@ -56,6 +56,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -56,6 +56,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Autowired @Autowired
private AutomobileEnterpriseMapper automobileEnterpriseMapper; private AutomobileEnterpriseMapper automobileEnterpriseMapper;
@Autowired
private TaskStateFacade taskStateFacade;
@Override @Override
public List<Task> findList(TaskListRequest request) { public List<Task> findList(TaskListRequest request) {
return taskMapper.findList(request); return taskMapper.findList(request);
...@@ -87,7 +91,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -87,7 +91,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
task.setTaskInitiatorId(loginUser.getUserId()); task.setTaskInitiatorId(loginUser.getUserId());
task.setTaskInitiator(initiator.getNickName()); task.setTaskInitiator(initiator.getNickName());
task.setTaskInitiatorDept(initiator.getDept().getDeptName()); task.setTaskInitiatorDept(initiator.getDept().getDeptName());
task.setTaskStatus(Task.STATUS_RUNNABLE); task.setTaskStatus(Task.TASK_STATUS_NEW);
task.setLeaderId(leader.getUserId()); task.setLeaderId(leader.getUserId());
task.setLeader(leader.getName()); task.setLeader(leader.getName());
task.setCreateTime(new Date()); task.setCreateTime(new Date());
...@@ -96,24 +100,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -96,24 +100,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
task.setFile(standard.getFile()); task.setFile(standard.getFile());
BeanUtils.copyBeanProp(task, request); BeanUtils.copyBeanProp(task, request);
String nextNode = null;
if(request.getTaskList().contains(Task.SUB_TASK_TRFIS)) {
nextNode = Task.SUB_TASK_TRFIS;
}
if(request.getTaskList().contains(Task.SUB_TASK_GRFIS)) { if(request.getTaskList().contains(Task.SUB_TASK_GRFIS)) {
// 保存车型审查问卷任务 // 保存车型审查问卷任务
nextNode = Task.SUB_TASK_GRFIS;;
task.setCarReviewTaskId(saveCarReview(request,initiator,standard,leader)); task.setCarReviewTaskId(saveCarReview(request,initiator,standard,leader));
} }
if(request.getTaskList().contains(Task.SUB_TASK_SRAIF)) { if(request.getTaskList().contains(Task.SUB_TASK_SRAIF)) {
// 保存体系审查任务 // 保存体系审查任务
nextNode = Task.SUB_TASK_SRAIF;
task.setSystemReviewTaskId(saveSystemReview(request,initiator,standard,leader)); task.setSystemReviewTaskId(saveSystemReview(request,initiator,standard,leader));
} }
task.setNextNode(nextNode);
taskService.save(task); taskService.save(task);
// 构建并保存该任务所关联的审核组信息 // 构建并保存该任务所关联的审核组信息
...@@ -123,6 +118,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -123,6 +118,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
taskUserRelationService.saveBatch(auditors); taskUserRelationService.saveBatch(auditors);
taskStateFacade.doCreate(task, request.getTaskList());
} }
@Override @Override
...@@ -185,26 +182,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta ...@@ -185,26 +182,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
@Override @Override
public void startTask(TaskStartRequest request) { public void startTask(TaskStartRequest request) {
Task task = taskMapper.selectById(request.getId()); Task task = taskMapper.selectById(request.getId());
taskStateFacade.doStart(task);
SystemReviewTaskStartRequest systemRequest = new SystemReviewTaskStartRequest();
systemRequest.setTaskId(task.getSystemReviewTaskId());
CarReviewTaskStartRequest carRequest = new CarReviewTaskStartRequest();
carRequest.setTaskId(task.getCarReviewTaskId());
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(systemRequest);
task.setTaskStatus(Task.STATUS_RUNNING);
task.setNextNode(Task.SUB_TASK_GRFIS);
taskMapper.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(carRequest);
task.setTaskStatus(Task.STATUS_RUNNING);
task.setNextNode(Task.SUB_TASK_TRFIS);
taskMapper.updateById(task);
}
} }
public Long saveSystemReview(TaskCreateRequest request,SysUser initiator,Standard standard,TaskUserRelation leader) { public Long saveSystemReview(TaskCreateRequest request,SysUser initiator,Standard standard,TaskUserRelation leader) {
......
package com.ruoyi.service.impl;
import com.ruoyi.service.StrategyReviewSceneChange;
import com.ruoyi.service.TaskState;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Transactional
@Service
public class TaskStateContext {
private final Map<String, TaskState> strategyMap = new ConcurrentHashMap<>();
public void putResource(String key, TaskState taskState) {
strategyMap.put(key, taskState);
}
public TaskState getResource(String operation){
return strategyMap.get(operation);
}
}
package com.ruoyi.service.impl;
import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Transactional
@Component
public class TaskStateFacade implements TaskState {
@Autowired
private TaskStateContext taskStateContext;
@Override
public void doCreate(Task task, List<String> taskList) {
taskStateContext.getResource(task.getTaskStatus()).doCreate(task, taskList);
}
@Override
public void doStart(Task task) {
taskStateContext.getResource(task.getTaskStatus()).doStart(task);
}
@Override
public void doSubmit(Task task) {
taskStateContext.getResource(task.getTaskStatus()).doSubmit(task);
}
}
package com.ruoyi.service.impl;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskState;
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.List;
@Transactional
@Service
public class TaskStateFinish implements TaskState, InitializingBean {
@Autowired
private TaskStateContext taskStateContext;
@Autowired
private ApplicationContext applicationContext;
@Override
public void doCreate(Task task, List<String> taskList) {
throw new ServiceException("不能创建一个已经结束的任务", HttpStatus.ERROR);
}
@Override
public void doStart(Task task) {
throw new ServiceException("不能开始一个已经结束的任务", HttpStatus.ERROR);
}
@Override
public void doSubmit(Task task) {
throw new ServiceException("不能完成一个已经结束的任务", HttpStatus.ERROR);
}
@Override
public void afterPropertiesSet() throws Exception {
taskStateContext.putResource(Task.TASK_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.Task;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState;
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.List;
import java.util.Objects;
@Transactional
@Service
public class TaskStateNew implements TaskState, InitializingBean {
@Autowired
private TaskStateContext taskStateContext;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private TaskService taskService;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override
public void doCreate(Task task, List<String> taskList) {
String nextNode = null;
if(taskList.contains(Task.SUB_TASK_TRFIS)) {
nextNode = Task.SUB_TASK_TRFIS;
}
if(taskList.contains(Task.SUB_TASK_GRFIS)) {
// 保存车型审查问卷任务
nextNode = Task.SUB_TASK_GRFIS;;
}
if(taskList.contains(Task.SUB_TASK_SRAIF)) {
// 保存体系审查任务
nextNode = Task.SUB_TASK_SRAIF;
}
task.setNextNode(nextNode);
}
@Override
public void doStart(Task task) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId());
task.setNextNode(Task.SUB_TASK_GRFIS);
taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
task.setNextNode(Task.SUB_TASK_TRFIS);
taskService.updateById(task);
}
taskService.updateById(task);
}
@Override
public void doSubmit(Task task) {
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
}
@Override
public void afterPropertiesSet() throws Exception {
taskStateContext.putResource(Task.TASK_STATUS_PENDING, 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.SystemReviewTask;
import com.ruoyi.domain.Task;
import com.ruoyi.mapper.ReviewDetailsMapper;
import com.ruoyi.service.CarReviewTaskService;
import com.ruoyi.service.SystemReviewTaskService;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState;
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.List;
import java.util.Objects;
@Transactional
@Service
public class TaskStatePending implements TaskState, InitializingBean {
@Autowired
private TaskStateContext taskStateContext;
private ReviewDetailsMapper reviewDetailsMapper;
@Autowired
private TaskService taskService;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private SystemReviewTaskService systemReviewTaskService;
@Autowired
private CarReviewTaskService carReviewTaskService;
@Override
public void doCreate(Task task, List<String> taskList) {
throw new ServiceException("不能创建一个已经开始的任务", HttpStatus.ERROR);
}
@Override
public void doStart(Task task) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
if (Objects.equals(task.getNextNode(), Task.SUB_TASK_SRAIF)) {
systemReviewTaskService.start(task.getSystemReviewTaskId());
task.setNextNode(Task.SUB_TASK_GRFIS);
taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
task.setNextNode(Task.SUB_TASK_TRFIS);
taskService.updateById(task);
}
}
@Override
public void doSubmit(Task task) {
long subTaskCount = 0;
if(task.getSystemReviewTaskId() != null) {
subTaskCount = reviewDetailsMapper.count(task.getSystemReviewTaskId(), SystemReviewTask.TYPE);
}
if(task.getCarReviewTaskId() != null) {
subTaskCount = reviewDetailsMapper.count(task.getCarReviewTaskId(), CarReviewTask.TYPE);
}
if(subTaskCount > 0) {
task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_RUNNABLE);
} else {
task.setTaskStatus(Task.TASK_STATUS_FINISH);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
}
taskService.updateById(task);
}
@Override
public void afterPropertiesSet() throws Exception {
taskStateContext.putResource(Task.TASK_STATUS_PENDING, applicationContext.getBean(this.getClass()));
}
}
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