Commit eca56010 authored by wdy's avatar wdy

Merge branch 'dev' into 'master'

dev - master 20

See merge request !350
parents 2e27565b c30cdd26
......@@ -7,6 +7,7 @@ import com.ruoyi.web.response.DataStatisticsResponse;
import com.ruoyi.web.response.TaskFindResponse;
import com.ruoyi.web.response.TaskGetInfoResponse;
import java.io.IOException;
import java.util.List;
public interface TaskService extends IService<Task> {
......@@ -65,4 +66,6 @@ public interface TaskService extends IService<Task> {
TaskGetInfoResponse getBySubtaskId(TaskSubGetInfoRequest request);
DataStatisticsResponse dataStatistics(TaskGetInfoRequest request);
String createProject(String request) throws IOException;
}
......@@ -73,4 +73,12 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @throws IOException
*/
List<UseCaseUrlVO> getUseCaseByChapter(String request) throws IOException;
/**
* 根据场景查询测试用例集合
* @param request
* @return
* @throws IOException
*/
List<String> selectCaseListByScenario(String request) throws IOException;
}
......@@ -8,8 +8,10 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
......@@ -21,10 +23,12 @@ import com.ruoyi.service.*;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.request.*;
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.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
......@@ -154,10 +158,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
// TODO 任务名称验重
// Long sum = taskMapper.findTaskName(request.getTaskName());
// if (sum > 0) {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// } else {
Long sum = taskMapper.findTaskName(request.getTaskName());
if (sum > 0) {
throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
} else {
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
Standard standard = standardService.findListById(request.getStandardId());
......@@ -218,7 +222,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
taskStateFacade.doCreate(task, request.getTaskList());
// }
}
}
/**
......@@ -290,8 +294,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
public void editTask(TaskEditRequest request) {
// TODO 任务名称验重
// Task oldTask = taskMapper.findByName(request.getTaskName());
// if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
Task oldTask = taskMapper.findByName(request.getTaskName());
if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
......@@ -339,9 +343,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 保存任务关联的文件信息
saveFileList(request.getFileList(),task);
// } else {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// }
} else {
throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
}
}
......@@ -519,10 +523,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
public void temporaryStorageTask(TaskCreateRequest request) {
// TODO 任务名称验重
// Long sum = taskMapper.findTaskName(request.getTaskName());
// if (sum > 0) {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// } else {
Long sum = taskMapper.findTaskName(request.getTaskName());
if (sum > 0) {
throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
} else {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
TaskGetInfoResponse temporaryStorageTask = taskService.getByUserId(loginUser.getUserId());
......@@ -587,7 +591,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
saveFileList(request.getFileList(),task);
}
// }
}
}
......@@ -599,8 +603,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
public void editTemporaryStorageTask(TaskEditRequest request) {
// TODO 任务名称验重
// Task oldTask = taskMapper.findByName(request.getTaskName());
// if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
Task oldTask = taskMapper.findByName(request.getTaskName());
if (oldTask == null || Objects.equals(oldTask.getId(), request.getId())) {
// 构建任务创建者
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser initiator = sysUserService.selectUserById(loginUser.getUserId());
......@@ -650,9 +654,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
// 保存任务关联的文件信息
saveFileList(request.getFileList(),task);
// } else {
// throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
// }
} else {
throw new ServiceException("任务名称重复,请检查", HttpStatus.ERROR);
}
}
......@@ -783,6 +787,38 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>implements Tas
}
@Override
public String createProject(String request) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"mutation quickCreateProjct($name:String$description:String$useCaseList:[ID!]!){project{quickCreateProject(input:{name:$name description:$description useCaseIDList:$useCaseList}){id name status description createTime}}}\",\"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("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
// .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);
// 获取id
String testSchemeId = "";
if (jsonObject.getJSONObject("data").getJSONObject("project") != null) {
testSchemeId = (String) jsonObject.getJSONObject("data").getJSONObject("project").getJSONObject("quickCreateProject").get("id");
}
return testSchemeId;
}
private void carTestStatistics(DataStatisticsResponse response, Task task) {
if (task.getModelTestTaskId() != null) {
......
......@@ -3,7 +3,6 @@ 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.*;
import com.ruoyi.service.TestUseCaseService;
......@@ -13,6 +12,7 @@ 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 lombok.Data;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -233,6 +233,39 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return list;
}
@Override
public List<String> selectCaseListByScenario(String request) throws IOException {
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$searchFields:Map){useCases(offset:$offset orderBy:$orderBy filterFields:$filter search:$search searchFields:$searchFields){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")
.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);
// 获取测试用例
return jsonObject.getJSONObject("data").getJSONObject("useCases").getJSONArray("nodes")
.stream()
.map(node -> ((JSONObject) node).getString("id"))
.distinct() // 去除重复项
.collect(Collectors.toList());
}
}
......
......@@ -6,6 +6,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ReviewEnterpriseArchive;
import com.ruoyi.domain.vo.EnterpriseImportFileVO;
......@@ -117,10 +118,14 @@ public class ReviewEnterpriseArchiveController extends BaseController {
@ApiOperation("车企文件导入")
@RequestMapping(method = RequestMethod.POST, value = "/importExcel")
public R<String> importEnterprise(HttpServletResponse response,ImportEnterpriseRequest request) throws IOException {
ExcelUtil<EnterpriseImportFileVO> util = new ExcelUtil<>(EnterpriseImportFileVO.class);
List<EnterpriseImportFileVO> list = util.importExcel(request.getFile().getInputStream());
reviewEnterpriseArchiveService.importEnterprise(list, request.getTaskId(),response);
return R.ok();
try{
ExcelUtil<EnterpriseImportFileVO> util = new ExcelUtil<>(EnterpriseImportFileVO.class);
List<EnterpriseImportFileVO> list = util.importExcel(request.getFile().getInputStream());
reviewEnterpriseArchiveService.importEnterprise(list, request.getTaskId(),response);
return R.ok();
}catch (Exception e){
throw new ServiceException("文件有误请重新上传!");
}
}
}
......@@ -27,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
@Api(tags = "总任务")
......@@ -190,4 +192,16 @@ public class TaskController extends BaseController {
return R.ok(response);
}
/**
* 快速创建检测项目
* @param request
* @return
* @throws IOException
*/
@ApiOperation("快速创建检测项目(科恩)")
@RequestMapping(method = RequestMethod.POST, value = "/createProject", produces="application/json;charset=UTF-8")
public R<String> createProject(@Validated @RequestBody String request) throws IOException {
return R.ok(taskService.createProject(request));
}
}
......@@ -62,6 +62,18 @@ public class TestUserCaseController extends BaseController{
return R.ok(testUseCaseService.selectCaseByScenario(request));
}
/**
* 根据场景查询测试用例集合
* @param request
* @return
* @throws IOException
*/
@ApiOperation("根据场景查询测试用例集合")
@RequestMapping(method = RequestMethod.POST, value = "/getUseCaseListByScenario", produces="application/json;charset=UTF-8")
public R<List<String>> getUseCaseListByScenario(@Validated @RequestBody String request) throws IOException {
return R.ok(testUseCaseService.selectCaseListByScenario(request));
}
/**
* 科恩获取测试用例
* @param request
......
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