Commit 89b6b7d3 authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

检验内容库查询车型试验(科恩) & 查询测试用例分页查询(科恩)

See merge request !307
parents abf0eb91 bf0e181b
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
/**
* 车型试验VO
*/
public class InspectionContentVO {
// id
private String id;
// 标准章节
private String serialNumber;
// 标准要求
private String requirements;
// 标准测试方法
private String testMethod;
}
package com.ruoyi.domain.vo;
import lombok.Data;
@Data
/**
* 测试用例VO
*/
public class UseCaseUrlVO {
// 用例编号
private String displayID;
// 用例名称
private String name;
// 用例描述
private String description;
// 对应输入
private String requirements;
}
package com.ruoyi.enums;
import com.baomidou.mybatisplus.annotation.IEnum;
import java.io.Serializable;
/**
* 基础枚举 接口
* @author YangAo
*/
public interface BaseEnum<T extends Serializable> extends IEnum<T> {
/**
* 获取描述
*
* @return 描述
*/
String getDesc();
/**
* 根据值获取枚举
*
* @param value 值
* @return 枚举
*/
static <T extends Serializable> BaseEnum<T> getEnumByValue(T value, Class<? extends BaseEnum<T>> clazz) {
for (BaseEnum<T> code : clazz.getEnumConstants()) {
if (code.getValue().equals(value)) {
return code;
}
}
return null;
}
}
package com.ruoyi.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum UseCaseRiskLevelEnum implements BaseEnum<String> {
HIGH("HIGH", "高危"),
MEDIUM("MEDIUM", "中危"),
GRADUATE("GRADUATE", "低危"),
UNKNOWN("UNKNOWN", "无");
/**
* 枚举值
*/
@JsonValue
private final String value;
/**
* 枚举描述
*/
private final String desc;
}
......@@ -8,6 +8,7 @@ import com.ruoyi.web.request.ReviewStandardListRequest;
import com.ruoyi.web.request.ReviewStandardSaveStandardUsecaseRequest;
import com.ruoyi.web.response.*;
import java.io.IOException;
import java.util.List;
public interface ReviewStandardService extends IService<ReviewStandard> {
......@@ -70,4 +71,12 @@ public interface ReviewStandardService extends IService<ReviewStandard> {
* @param request
*/
void saveStandardUsecase(ReviewStandardSaveStandardUsecaseRequest request);
/**
* 检验内容库科恩获取车型试验
* @param request
* @return
* @throws IOException
*/
InspectionContentResponse getList(String request) throws IOException;
}
......@@ -5,8 +5,11 @@ 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 java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -45,4 +48,12 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @return
*/
JSONObject callThirdPartyInterface(String url, Map<String, Object> map);
/**
* 科恩获取测试用例
* @param request
* @return
* @throws IOException
*/
TestUserCaseListResponse getUseCaseList(String request) throws IOException;
}
package com.ruoyi.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.SnowflakeUtil;
import com.ruoyi.domain.*;
import com.ruoyi.domain.vo.InspectionContentVO;
import com.ruoyi.domain.vo.OptionalUseCasesVO;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import com.ruoyi.mapper.*;
import com.ruoyi.service.*;
import com.ruoyi.web.request.ReviewFindListRequest;
......@@ -14,10 +17,12 @@ import com.ruoyi.web.request.ReviewStandardListByPageRequest;
import com.ruoyi.web.request.ReviewStandardListRequest;
import com.ruoyi.web.request.ReviewStandardSaveStandardUsecaseRequest;
import com.ruoyi.web.response.*;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -184,6 +189,47 @@ public class ReviewStandardServiceImpl extends ServiceImpl<ReviewStandardMapper,
}
}
/**
* 检验内容库科恩获取车型试验
* @param request
* @return
* @throws IOException
*/
@Override
public InspectionContentResponse getList(String request) throws IOException {
InspectionContentResponse inspectionContentResponse = new InspectionContentResponse();
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
// 创建请求体
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationItems($name:String!$offset:OffsetConnectionInput$orderBy:OrderByInput){regulationByName(name:$name){items(offset:$offset orderBy:$orderBy){totalCount nodes{id serialNumber requirements testMethod}}}}\",\"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);
// 获取测试用例
List<InspectionContentVO> list = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").getList("nodes", InspectionContentVO.class);
inspectionContentResponse.setInspectionContent(list);
// 获取总条数
Integer totalCount = (Integer) jsonObject.getJSONObject("data").getJSONObject("regulationByName").getJSONObject("items").get("totalCount");
inspectionContentResponse.setTotalCount(totalCount);
return inspectionContentResponse;
}
/**
* 将审查 标准、要点、细则、场景 按照父子关系拆分写入到各自的表中
* @param reviewStandardList
......
......@@ -6,15 +6,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.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 okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -88,6 +92,48 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return JSONObject.parseObject(result);
}
/**
* 科恩获取测试用例
* @param request
* @return
* @throws IOException
*/
@Override
public TestUserCaseListResponse getUseCaseList(String request) throws IOException {
TestUserCaseListResponse userCaseResponse = new TestUserCaseListResponse();
OkHttpClient client = new OkHttpClient().newBuilder().build();
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 +"}");
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);
// 获取测试用例
List<UseCaseUrlVO> list = jsonObject.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseUrlVO.class);
userCaseResponse.setUseCases(list);
// 获取总条数
Integer totalCount = (Integer) jsonObject.getJSONObject("data").getJSONObject("useCases").get("totalCount");
userCaseResponse.setTotalCount(totalCount);
return userCaseResponse;
}
}
......
......@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
/**
......@@ -120,4 +121,20 @@ public class ReviewStandardController extends BaseController {
public TableDataInfo<ReviewStandard> findDetailsList(@Validated @RequestBody ReviewFindListRequest request) {
return getDataTable(reviewStandardService.findDetailsList(request));
}
/**
* 检验内容库科恩获取车型试验
* @param request
* @return
* @throws IOException
*/
@ApiOperation("检验内容库查询车型试验(科恩)")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getList", produces="application/json;charset=UTF-8")
public R<InspectionContentResponse> getList(@Validated @RequestBody String request) throws IOException {
return R.ok(reviewStandardService.getList(request));
}
}
......@@ -6,7 +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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.skywalking.apm.toolkit.trace.Tag;
......@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
@Api(tags = "测试用例")
......@@ -57,4 +60,21 @@ public class TestUserCaseController extends BaseController{
public R<List<String>> getCaseByScenario(@Validated @RequestBody TestUseCaseByScenarioRequest request) {
return R.ok(testUseCaseService.selectCaseByScenario(request));
}
/**
* 科恩获取测试用例
* @param request
* @return
* @throws IOException
*/
@ApiOperation("查询测试用例分页查询(科恩)")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getUseCaseList", produces="application/json;charset=UTF-8")
public R<TestUserCaseListResponse> getUseCaseList(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.getUseCaseList(request));
}
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.InspectionContentVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "InspectionContentResponse", description = "查询检验内容库车型试验")
@Data
public class InspectionContentResponse {
@ApiModelProperty("测试用例")
List<InspectionContentVO> inspectionContent;
@ApiModelProperty("总条数")
Integer totalCount;
}
package com.ruoyi.web.response;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel(value = "TestUserCaseListResponse", description = "查询测试用例")
@Data
public class TestUserCaseListResponse {
@ApiModelProperty("测试场景")
private String testScenario;
@ApiModelProperty("测试方法")
private String testType;
@ApiModelProperty("用例编号")
private String useCaseNo;
@ApiModelProperty("用例名称")
private String useCaseName;
@ApiModelProperty("测试用例")
List<UseCaseUrlVO> useCases;
@ApiModelProperty("对应输入")
private String input;
@ApiModelProperty("总条数")
Integer totalCount;
@ApiModelProperty("用例描述")
private String description;
}
package com.ruoyi;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import okhttp3.*;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.IOException;
import java.util.List;
@SpringBootTest
public class TestUrl {
@Test
public void test() throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
// 定义查询变量
String variables = "{ \"offset\": { \"offset\": 0, \"limit\": 10 }, \"orderBy\": { \"field\": \"displayID\", \"order\": \"DESC\" }, \"search\": \"Z\"}";
// 创建请求体
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\":"+ variables +"}");
Request request = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
// .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(request).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
List<UseCaseUrlVO> list = jsonObject.getJSONObject("data").getJSONObject("useCases").getList("nodes", UseCaseUrlVO.class);
list.forEach(item -> {
System.out.println("item = " + item);
});
}
}
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