Commit 46fe8a1f authored by 高滢's avatar 高滢
parents 65afa85c 4a6edec8
...@@ -115,4 +115,7 @@ public class ModelTestTask { ...@@ -115,4 +115,7 @@ public class ModelTestTask {
@ApiModelProperty("车型试验标准条款数") @ApiModelProperty("车型试验标准条款数")
private Integer standards; private Integer standards;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
...@@ -87,6 +87,9 @@ public class TestUseCase implements Serializable { ...@@ -87,6 +87,9 @@ public class TestUseCase implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String testType; private String testType;
@ApiModelProperty("用例ID")
private String caseId;
/** /**
* 返回用例在矩阵中的坐标 * 返回用例在矩阵中的坐标
* @return * @return
......
...@@ -21,6 +21,9 @@ public class TestUsecaseVO { ...@@ -21,6 +21,9 @@ public class TestUsecaseVO {
@ApiModelProperty("测试用例ID") @ApiModelProperty("测试用例ID")
private Long id; private Long id;
@ApiModelProperty("用例ID")
private String caseId;
@ApiModelProperty("测试场景") @ApiModelProperty("测试场景")
private String testScenario; private String testScenario;
......
...@@ -35,4 +35,6 @@ public interface TaskMapper extends BaseMapper<Task> { ...@@ -35,4 +35,6 @@ public interface TaskMapper extends BaseMapper<Task> {
Task getByUserIdTemporary(@Param("userId") Long userId); Task getByUserIdTemporary(@Param("userId") Long userId);
Task getBySubtaskId(@Param("subId") Long subId); Task getBySubtaskId(@Param("subId") Long subId);
Long findTaskName(@Param("taskName") String taskName);
} }
package com.ruoyi.service; package com.ruoyi.service;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.web.request.TaskStartRequest;
import java.util.List; import java.util.List;
public interface TaskState { public interface TaskState {
void doCreate(Task task, List<String> taskList); void doCreate(Task task, List<String> taskList);
void doStart(Task task); void doStart(Task task, TaskStartRequest request);
void doSubmit(Task task); void doSubmit(Task task);
......
...@@ -26,5 +26,5 @@ public interface TestUseCaseService extends IService<TestUseCase> { ...@@ -26,5 +26,5 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @param request * @param request
* @return * @return
*/ */
List<Long> selectCaseIdList(TestUseCaseIdListRequest request); List<String> selectCaseIdList(TestUseCaseIdListRequest request);
} }
...@@ -73,8 +73,8 @@ public class MatrixServiceImpl implements MatrixService { ...@@ -73,8 +73,8 @@ public class MatrixServiceImpl implements MatrixService {
for(TestType type : types) { for(TestType type : types) {
String columnId = String.valueOf(type.getId()); String columnId = String.valueOf(type.getId());
String coordinates = scenario.getId() + columnId; String coordinates = scenario.getId() + columnId;
Long useCaseId = getUseCaseIdByCoordinates(useCases, coordinates); String useCaseId = getUseCaseIdByCoordinates(useCases, coordinates);
row.put(columnId, useCaseId == null ? "" : String.valueOf(useCaseId)); row.put(columnId, useCaseId == null ? "" : useCaseId);
} }
rows.add(row); rows.add(row);
...@@ -83,11 +83,11 @@ public class MatrixServiceImpl implements MatrixService { ...@@ -83,11 +83,11 @@ public class MatrixServiceImpl implements MatrixService {
response.setRows(rows); response.setRows(rows);
} }
public Long getUseCaseIdByCoordinates(List<TestUseCase> useCases, String coordinates) { public String getUseCaseIdByCoordinates(List<TestUseCase> useCases, String coordinates) {
for(TestUseCase useCase : useCases) { for(TestUseCase useCase : useCases) {
if(useCase.getCoordinates().equals(coordinates)) { if(useCase.getCoordinates().equals(coordinates)) {
return useCase.getId(); return useCase.getCaseId();
} }
} }
return null; return null;
......
...@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.DataStatisticsUtils; import com.ruoyi.common.DataStatisticsUtils;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
...@@ -17,6 +19,7 @@ import com.ruoyi.service.*; ...@@ -17,6 +19,7 @@ import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.*; import com.ruoyi.web.request.*;
import com.ruoyi.web.response.DataStatisticsResponse; import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.ResultCountResponse;
import com.ruoyi.web.response.TaskFindResponse; import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse; import com.ruoyi.web.response.TaskGetInfoResponse;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -105,6 +108,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -105,6 +108,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@Override @Override
public void createTask(TaskCreateRequest request) { public void createTask(TaskCreateRequest request) {
Long sum = taskMapper.findTaskName(request.getTaskName());
if (sum > 0) {
throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
} else {
// 构建任务创建者 // 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId()); SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
...@@ -171,6 +179,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -171,6 +179,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskMapper.deleteById(temporaryStorageTask.getId()); taskMapper.deleteById(temporaryStorageTask.getId());
} }
} }
}
@Override @Override
public List<TaskFindResponse> findPending(TaskFindPendingRequest request,Long userId) { public List<TaskFindResponse> findPending(TaskFindPendingRequest request,Long userId) {
...@@ -267,7 +276,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas ...@@ -267,7 +276,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
@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); taskStateFacade.doStart(task, request);
} }
@Override @Override
......
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.CarReviewTaskService; import com.ruoyi.service.*;
import com.ruoyi.service.SystemReviewTaskService; import com.ruoyi.web.request.TaskStartRequest;
import com.ruoyi.service.TaskService;
import com.ruoyi.service.TaskState;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -24,8 +24,12 @@ public abstract class TaskStateAdapter implements TaskState { ...@@ -24,8 +24,12 @@ public abstract class TaskStateAdapter implements TaskState {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired
private ModelTestTaskService modelTestTaskService;
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
task.setTaskStatus(Task.TASK_STATUS_PENDING); task.setTaskStatus(Task.TASK_STATUS_PENDING);
task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING); task.setRunStatus(Task.RUN_STATUS_STATUS_RUNNING);
...@@ -36,6 +40,14 @@ public abstract class TaskStateAdapter implements TaskState { ...@@ -36,6 +40,14 @@ public abstract class TaskStateAdapter implements TaskState {
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) { } else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_GRFIS)) {
carReviewTaskService.startReviewTask(task.getCarReviewTaskId()); carReviewTaskService.startReviewTask(task.getCarReviewTaskId());
taskService.updateById(task); taskService.updateById(task);
} else if (Objects.equals(task.getNextNode(), Task.SUB_TASK_TRFIS)) {
modelTestTaskService.startModelTestTask(task.getModelTestTaskId());
// 更新车型试验的试验方案ID
modelTestTaskService.update(new ModelTestTask(),
new LambdaUpdateWrapper<ModelTestTask>()
.set(ModelTestTask::getTestSchemeId, request.getTestSchemeId())
.eq(ModelTestTask::getId, task.getModelTestTaskId()));
taskService.updateById(task);
} else { } else {
throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR); throw new ServiceException("已没有可执行的子任务节点", HttpStatus.ERROR);
} }
......
...@@ -2,6 +2,7 @@ package com.ruoyi.service.impl; ...@@ -2,6 +2,7 @@ package com.ruoyi.service.impl;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskState; import com.ruoyi.service.TaskState;
import com.ruoyi.web.request.TaskStartRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -21,8 +22,8 @@ public class TaskStateFacade implements TaskState { ...@@ -21,8 +22,8 @@ public class TaskStateFacade implements TaskState {
} }
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
taskStateContext.getResource(task.getTaskStatus()).doStart(task); taskStateContext.getResource(task.getTaskStatus()).doStart(task, request);
} }
@Override @Override
......
...@@ -4,6 +4,7 @@ import com.ruoyi.common.constant.HttpStatus; ...@@ -4,6 +4,7 @@ import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Task; import com.ruoyi.domain.Task;
import com.ruoyi.service.TaskState; import com.ruoyi.service.TaskState;
import com.ruoyi.web.request.TaskStartRequest;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
...@@ -28,7 +29,7 @@ public class TaskStateFinish extends TaskStateAdapter implements TaskState, Init ...@@ -28,7 +29,7 @@ public class TaskStateFinish extends TaskStateAdapter implements TaskState, Init
} }
@Override @Override
public void doStart(Task task) { public void doStart(Task task, TaskStartRequest request) {
throw new ServiceException("不能开始一个已经结束的任务", HttpStatus.ERROR); throw new ServiceException("不能开始一个已经结束的任务", HttpStatus.ERROR);
} }
......
...@@ -41,9 +41,9 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU ...@@ -41,9 +41,9 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
} }
@Override @Override
public List<Long> selectCaseIdList(TestUseCaseIdListRequest request) { public List<String> selectCaseIdList(TestUseCaseIdListRequest request) {
List<TestUsecaseVO> list = testUseCaseMapper.selectListByTaskId(request.getModelTestId()); List<TestUsecaseVO> list = testUseCaseMapper.selectListByTaskId(request.getModelTestId());
return list.stream().map(TestUsecaseVO::getId).collect(Collectors.toList()); return list.stream().map(TestUsecaseVO::getCaseId).collect(Collectors.toList());
} }
} }
......
...@@ -44,7 +44,7 @@ public class TestUserCaseController extends BaseController{ ...@@ -44,7 +44,7 @@ public class TestUserCaseController extends BaseController{
@Anonymous @Anonymous
@ApiOperation("根据场景查询用例ID集合") @ApiOperation("根据场景查询用例ID集合")
@PostMapping("/getCaseIdList") @PostMapping("/getCaseIdList")
public R<List<Long>> getCaseIdList(@Validated @RequestBody TestUseCaseIdListRequest request) { public R<List<String>> getCaseIdList(@Validated @RequestBody TestUseCaseIdListRequest request) {
return R.ok(testUseCaseService.selectCaseIdList(request)); return R.ok(testUseCaseService.selectCaseIdList(request));
} }
} }
...@@ -10,4 +10,8 @@ public class TaskStartRequest { ...@@ -10,4 +10,8 @@ public class TaskStartRequest {
@ApiModelProperty("ID") @ApiModelProperty("ID")
private Long id; private Long id;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
package com.ruoyi.web.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("计算问卷结果VO")
public class ResultCountResponse {
@ApiModelProperty("任务id")
private Long taskId;
@ApiModelProperty("任务状态")
private String taskStatus;
@ApiModelProperty("进度")
private Double schedule;
}
...@@ -118,4 +118,7 @@ public class TaskFindResponse { ...@@ -118,4 +118,7 @@ public class TaskFindResponse {
@ApiModelProperty("指向待执行节点的指针[0、1、2]") @ApiModelProperty("指向待执行节点的指针[0、1、2]")
private int pointer; private int pointer;
@ApiModelProperty("试验方案ID")
private String testSchemeId;
} }
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
and identify_number like concat('%',#{identifyNumber},'%') and identify_number like concat('%',#{identifyNumber},'%')
</if> </if>
</where> </where>
ORDER BY create_time DESC
</select> </select>
<select id="findByFileName" resultType="com.ruoyi.domain.ReviewEnterpriseArchive"> <select id="findByFileName" resultType="com.ruoyi.domain.ReviewEnterpriseArchive">
SELECT id, enterprise_name, file_name, version, publish_date, status, identify_number, storage, photo, task_id, create_by, create_time SELECT id, enterprise_name, file_name, version, publish_date, status, identify_number, storage, photo, task_id, create_by, create_time
...@@ -81,6 +80,5 @@ ...@@ -81,6 +80,5 @@
and identify_number like concat('%',#{identifyNumber},'%') and identify_number like concat('%',#{identifyNumber},'%')
</if> </if>
</where> </where>
ORDER BY create_time DESC
</select> </select>
</mapper> </mapper>
...@@ -106,7 +106,8 @@ ...@@ -106,7 +106,8 @@
crt.task_status car_review_status, crt.task_status car_review_status,
mtt.task_begin_time test_begin_time, mtt.task_begin_time test_begin_time,
mtt.task_end_time test_end_time, mtt.task_end_time test_end_time,
mtt.task_status test_status mtt.task_status test_status,
mtt.test_scheme_id testSchemeId
FROM t_task t FROM t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id left join t_car_review_task crt on t.car_review_task_id = crt.id
...@@ -276,6 +277,10 @@ ...@@ -276,6 +277,10 @@
FROM t_task FROM t_task
WHERE system_review_task_id = #{subId} OR car_review_task_id = #{subId} WHERE system_review_task_id = #{subId} OR car_review_task_id = #{subId}
</select> </select>
<select id="findTaskName" resultType="java.lang.Long">
select COUNT(*) sum from t_task
where task_name = #{taskName}
</select>
</mapper> </mapper>
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
<select id="selectListByTaskId" resultType="com.ruoyi.domain.vo.TestUsecaseVO"> <select id="selectListByTaskId" resultType="com.ruoyi.domain.vo.TestUsecaseVO">
select select
tu.id, tu.id,
tu.case_id caseId,
ts.test_scenario testScenario, ts.test_scenario testScenario,
tt.test_type testType, tt.test_type testType,
tu.usecase_no usecaseNo, tu.usecase_no usecaseNo,
......
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