Commit 6859cd85 authored by wdy's avatar wdy

获取首页测试用例信息&测试用例分页查询添加字段&通过项目ID获取审查表单

parent bd8af023
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
public class CountVO {
private int count;
private String value;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "ModelTestResultVO", description = "结果VO")
public class ModelTestResultVO {
// 用例描述
@ApiModelProperty("用例描述")
private String description;
// 对应输入
@ApiModelProperty("对应输入")
private String requirements;
// 用例名称
@ApiModelProperty("用例名称")
private String name;
// 测试结果
@ApiModelProperty("测试结果")
private String status;
// 测试场景
@ApiModelProperty("测试场景")
private String scenario;
// 测试类型
@ApiModelProperty("测试类型")
private String test_type;
// 用例编号
@ApiModelProperty("用例编号")
private String serial_number;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "ModelTestViewVO", description = "审查表单概要VO类")
public class ModelTestViewVO {
// 标准技术要求
@ApiModelProperty("标准技术要求")
private String requirements;
// 章节号
@ApiModelProperty("章节号")
private String serial_number;
// 标准测试方法
@ApiModelProperty("标准测试方法")
private String test_method;
@ApiModelProperty("结果列表")
List<ModelTestResultVO> case_result_list;
}
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
public class NameVO {
private String name;
}
......@@ -20,4 +20,16 @@ public class UseCaseUrlVO {
// 对应输入
private String requirements;
// 测试方法
private NameVO method;
// 测试场景
private NameVO scenario;
// 测试方法
private String testMethod;
// 测试场景
private String testScenario;
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
/**
* 车型试验任务Service接口
......@@ -37,4 +38,10 @@ public interface ModelTestTaskService extends IService<ModelTestTask> {
*/
void submitModelTestTask(ModelTestTaskSubmitRequest request);
/**
* 查看车型试验任务详情(科恩)
* @param taskId
* @return
*/
ModelTestUrlResponse taskViewModelTestTask(Long taskId);
}
......@@ -2,6 +2,7 @@ package com.ruoyi.service;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import java.util.List;
......@@ -36,4 +37,11 @@ public interface StrategyModelTestTask {
*/
void doSubmitTest(ModelTestTask modelTestTask, List<String> imagesUrl);
/**
* 查看任务
* @param modelTestTask
* @return
*/
ModelTestUrlResponse doTaskView(ModelTestTask modelTestTask);
}
......@@ -5,9 +5,9 @@ import com.ruoyi.domain.TestUseCase;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse;
import java.io.IOException;
import java.util.List;
......@@ -56,4 +56,12 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @throws IOException
*/
TestUserCaseListResponse getUseCaseList(String request) throws IOException;
/**
* 科恩获取首页信息
* @param request
* @return
* @throws IOException
*/
UseCaseResponse getUseCaseMsg(String request) throws IOException;
}
......@@ -6,6 +6,7 @@ import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.service.ModelTestTaskService;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -61,4 +62,10 @@ public class ModelTestTaskServiceImpl extends ServiceImpl<ModelTestTaskMapper, M
ModelTestTask modelTestTask = modelTestTaskMapper.selectById(request.getTaskId());
strategyModelTestTaskContext.getResource(modelTestTask.getTaskStatus()).doSubmitTest(modelTestTask, request.getImagesUrl());
}
@Override
public ModelTestUrlResponse taskViewModelTestTask(Long taskId) {
ModelTestTask modelTestTask = modelTestTaskMapper.selectById(taskId);
return strategyModelTestTaskContext.getResource(modelTestTask.getTaskStatus()).doTaskView(modelTestTask);
}
}
......@@ -5,6 +5,7 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.ModelTestTask;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
......@@ -23,9 +24,14 @@ public class StrategyModelTestTaskFinish implements StrategyModelTestTask, Initi
@Autowired
private StrategyModelTestTaskContext strategyModelTestTaskContext;
@Autowired
private StrategyModelTestTaskNew strategyModelTestTaskNew;
@Override
public ModelTestResponse doView(ModelTestTask modelTestTask) {
throw new ServiceException("不能开始一个结束的任务", HttpStatus.ERROR);
ModelTestResponse response = strategyModelTestTaskNew.getTestScheme(modelTestTask);
return response;
}
@Override
......@@ -43,6 +49,12 @@ public class StrategyModelTestTaskFinish implements StrategyModelTestTask, Initi
throw new ServiceException("不能提交一个结束的任务", HttpStatus.ERROR);
}
@Override
public ModelTestUrlResponse doTaskView(ModelTestTask modelTestTask) {
ModelTestUrlResponse response = strategyModelTestTaskNew.getTestSchemeFormKe(modelTestTask);
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategyModelTestTaskContext.putResource(ModelTestTask.TASK_STATUS_FINISH, applicationContext.getBean(this.getClass()));
......
package com.ruoyi.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.*;
import com.ruoyi.domain.vo.ModelTestResultVO;
import com.ruoyi.domain.vo.ModelTestViewVO;
import com.ruoyi.domain.vo.TestCaseVO;
import com.ruoyi.domain.vo.TestUsecaseVO;
import com.ruoyi.mapper.ModelTestTaskMapper;
......@@ -14,6 +18,7 @@ import com.ruoyi.mapper.TestUseCaseMapper;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestTaskViewResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -60,7 +65,7 @@ public class StrategyModelTestTaskNew implements StrategyModelTestTask, Initiali
/**
* 获取试验方案
* @param taskId
* @param modelTestTask
* @return
*/
public ModelTestResponse getTestScheme(ModelTestTask modelTestTask) {
......@@ -146,6 +151,40 @@ public class StrategyModelTestTaskNew implements StrategyModelTestTask, Initiali
throw new ServiceException("不能提交一个尚未开始的任务", HttpStatus.ERROR);
}
@Override
public ModelTestUrlResponse doTaskView(ModelTestTask modelTestTask) {
ModelTestUrlResponse response = getTestSchemeFormKe(modelTestTask);
return response;
}
public ModelTestUrlResponse getTestSchemeFormKe(ModelTestTask modelTestTask) {
ModelTestUrlResponse response = new ModelTestUrlResponse();
if (modelTestTask.getTestSchemeId() != null) {
Map<String, Object> map = new HashMap<>();
map.put("id", modelTestTask.getTestSchemeId());
map.put("verbose", "DETAILED");
//以post形式请求接口
String result= HttpUtil.post("https://10.12.48.78:8090/DescribeProjectComplianceResult", JSONObject.toJSONString(map));
JSONObject jsonObject = JSONObject.parseObject(result);
List<ModelTestViewVO> list = jsonObject.getList("regulation_item_result_list",ModelTestViewVO.class);
response.setModelTestTaskViewResponseList(list);
}
Task task = taskMapper.selectOne(new QueryWrapper<Task>().lambda().eq(Task::getModelTestTaskId, modelTestTask.getId()));
response.setTaskNo(task.getTaskNo());
response.setTaskName(task.getTaskName());
response.setEntrustedUnit(task.getEntrustedUnit());
response.setTaskStatus(modelTestTask.getTaskStatus());
return response;
}
/**
* 根据任务状态获取对应的策略
* @throws Exception
......
......@@ -10,6 +10,7 @@ import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -92,6 +93,12 @@ public class StrategyModelTestTaskPending implements StrategyModelTestTask, Init
throw new ServiceException("不能提交一个进行中的任务", HttpStatus.ERROR);
}
@Override
public ModelTestUrlResponse doTaskView(ModelTestTask modelTestTask) {
ModelTestUrlResponse response = strategyModelTestTaskNew.getTestSchemeFormKe(modelTestTask);
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategyModelTestTaskContext.putResource(ModelTestTask.TASK_STATUS_PENDING, applicationContext.getBean(this.getClass()));
......
......@@ -14,6 +14,7 @@ import com.ruoyi.mapper.ModelTestTaskMapper;
import com.ruoyi.mapper.TaskMapper;
import com.ruoyi.service.StrategyModelTestTask;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
......@@ -81,6 +82,12 @@ public class StrategyModelTestTaskSigned implements StrategyModelTestTask, Initi
}
}
@Override
public ModelTestUrlResponse doTaskView(ModelTestTask modelTestTask) {
ModelTestUrlResponse response = strategyModelTestTaskNew.getTestSchemeFormKe(modelTestTask);
return response;
}
@Override
public void afterPropertiesSet() throws Exception {
strategyModelTestTaskContext.putResource(ModelTestTask.TASK_STATUS_SIGNED, applicationContext.getBean(this.getClass()));
......
......@@ -3,16 +3,16 @@ package com.ruoyi.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.domain.vo.CaseResultVO;
import com.ruoyi.domain.vo.TestUsecaseVO;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import com.ruoyi.domain.vo.*;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.mapper.TestUseCaseMapper;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -108,7 +108,7 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query useCases($offset:OffsetConnectionInput$orderBy:OrderByInput$filter:Map$search:String){useCases(offset:$offset orderBy:$orderBy filterFields:$filter search:$search){nodes{id displayID class name description remediation requirements riskLevel}totalCount}}\",\"variables\":"+ request +"}");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query useCases($offset:OffsetConnectionInput$orderBy:OrderByInput$filter:Map$search:String){useCases(offset:$offset orderBy:$orderBy filterFields:$filter search:$search){nodes{id displayID class name description remediation requirements riskLevel method{name}scenario{name}}totalCount}}\",\"variables\":"+ request +"}");
Request requestKE = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
......@@ -126,6 +126,15 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
JSONObject jsonObject = JSONObject.parseObject(string);
// 获取测试用例
List<UseCaseUrlVO> list = jsonObject.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseUrlVO.class);
for (UseCaseUrlVO useCaseUrlVO : list) {
if (useCaseUrlVO.getMethod() != null) {
useCaseUrlVO.setTestMethod(useCaseUrlVO.getMethod().getName());
}
if (useCaseUrlVO.getScenario() != null) {
useCaseUrlVO.setTestScenario(useCaseUrlVO.getScenario().getName());
}
}
userCaseResponse.setUseCases(list);
// 获取总条数
Integer totalCount = (Integer) jsonObject.getJSONObject("data").getJSONObject("useCases").get("totalCount");
......@@ -134,6 +143,49 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return userCaseResponse;
}
/**
* 科恩获取首页信息
* @param request
* @return
* @throws IOException
*/
@Override
public UseCaseResponse getUseCaseMsg(String request) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationStatistics($name:String!){regulationStatistics:regulationByName(name:$name){id name description useCaseCount testMethodCount testScenarioCount useCases{fieldValuesWithCount(fields:[\\\"testType\\\" \\\"riskLevel\\\"])}}}\",\"variables\":"+request+"}");
Request requestKE = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
// TODO 连接
// .addHeader("Host", "10.12.48.80:8089")
// .addHeader("Origin", "http://10.12.48.80:8089")
// .addHeader("Referer", "http://10.12.48.80:8089/api/graphql/playground")
// .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36")
.build();
Response response = client.newCall(requestKE).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
UseCaseResponse caseResponse = jsonObject.getJSONObject("data").getObject("regulationStatistics",UseCaseResponse.class);
List<CountVO> riskLevel = jsonObject.getJSONObject("data").getJSONObject("regulationStatistics").getJSONObject("useCases").getJSONObject("fieldValuesWithCount").getList("riskLevel",CountVO.class);
List<CountVO> testType = jsonObject.getJSONObject("data").getJSONObject("regulationStatistics").getJSONObject("useCases").getJSONObject("fieldValuesWithCount").getList("testType",CountVO.class);
caseResponse.setRiskLevel(riskLevel);
caseResponse.setTestType(testType);
return caseResponse;
}
}
......
......@@ -7,6 +7,7 @@ import com.ruoyi.web.request.CarReviewTaskViewRequest;
import com.ruoyi.web.request.ModelTestTaskConfirmRequest;
import com.ruoyi.web.request.ModelTestTaskSubmitRequest;
import com.ruoyi.web.response.ModelTestResponse;
import com.ruoyi.web.response.ModelTestUrlResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,12 +36,24 @@ public class ModelTestTaskController extends BaseController {
* @return
*/
@ApiOperation("查看车型试验任务详情")
@PostMapping("/getById")
@PostMapping("/getByIdOld")
public R<ModelTestResponse> view(@Validated @RequestBody CarReviewTaskViewRequest request) {
ModelTestResponse modelTestTaskList = modelTestTaskService.viewModelTestTask(request.getTaskId());
return R.ok(modelTestTaskList);
}
/**
* 查看车型试验任务详情(科恩)
* @param request
* @return
*/
@ApiOperation("查看车型试验任务详情(科恩)")
@PostMapping("/getById")
public R<ModelTestUrlResponse> taskView(@Validated @RequestBody CarReviewTaskViewRequest request) {
ModelTestUrlResponse response = modelTestTaskService.taskViewModelTestTask(request.getTaskId());
return R.ok(response);
}
/**
* 开始车型试验任务
* @param request
......
......@@ -6,9 +6,9 @@ import com.ruoyi.domain.TestUseCase;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.TestUseCaseByScenarioRequest;
import com.ruoyi.web.request.TestUseCaseIdListRequest;
import com.ruoyi.web.request.TestUserCaseListRequest;
import com.ruoyi.web.request.TestUserCaseRequest;
import com.ruoyi.web.response.TestUserCaseListResponse;
import com.ruoyi.web.response.UseCaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag;
......@@ -77,4 +77,21 @@ public class TestUserCaseController extends BaseController{
}
/**
* 科恩获取首页信息
* @param request
* @return
* @throws IOException
*/
@ApiOperation("科恩获取首页信息")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getUseCaseMsg", produces="application/json;charset=UTF-8")
public R<UseCaseResponse> getUseCaseMsg(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.getUseCaseMsg(request));
}
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.ModelTestViewVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "ModelTestUrlResponse", description = "车型试验查看VO类")
public class ModelTestUrlResponse {
@ApiModelProperty("任务编号")
private String taskNo;
@ApiModelProperty("任务名称")
private String taskName;
@ApiModelProperty("委托单位")
private String entrustedUnit;
@ApiModelProperty("子任务状态")
private String taskStatus;
@ApiModelProperty("审查表单概要")
private List<ModelTestViewVO> modelTestTaskViewResponseList;
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.CountVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("测试用例VO")
public class UseCaseResponse {
@ApiModelProperty("用例数量")
private Integer useCaseCount;
@ApiModelProperty("测试场景数量")
private Integer testScenarioCount;
@ApiModelProperty("测试方法数量")
private Integer testMethodCount;
@ApiModelProperty("用例风险程度")
List<CountVO> riskLevel;
@ApiModelProperty("用例测试类型")
List<CountVO> testType;
}
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