Commit dfeccb81 authored by 高滢's avatar 高滢
parents 1ee9350a c775e161
package com.ruoyi.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 检验报告PDF VO类
......
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel( description = "测试场景VO")
@Data
public class ScenarioVO {
private Long id;
private String name;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel( description = "测试方法(类型)VO")
@Data
public class TestTypeVO {
private Long id;
private String name;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ApiModel( description = "测试用例VO")
@Data
public class UseCaseVO {
private String id;
private String name;
// 测试场景
private String scenario;
// 测试方法
private String test_type;
/**
* 返回用例在矩阵中的坐标
* @return
*/
public String getCoordinates() {
return scenario + test_type;
}
}
......@@ -66,4 +66,5 @@ public interface TaskMapper extends BaseMapper<Task> {
List<UserNameResponse> findByRelation(@Param("relation") List<TaskUserRelation> relation);
List<UserNameResponse> findByFinishTaskList(@Param("taskList") List<Task> taskList);
}
......@@ -2,7 +2,6 @@ package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.domain.TestType;
import com.ruoyi.web.request.TestScenarioRequest;
import java.util.List;
......@@ -16,4 +15,10 @@ public interface ITestScenarioService extends IService<TestScenario> {
* @return 测试场景库集合
*/
public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest);
/**
* 获取测试场景列表(科恩)
* @return
*/
public List<String> selectScenarioList();
}
......@@ -6,4 +6,6 @@ public interface MatrixService {
MatrixResponse getMatrix();
MatrixResponse getMatrixForUrl();
}
package com.ruoyi.service;
import com.alibaba.fastjson2.JSONObject;
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.TestUserCaseRequest;
import java.util.List;
import java.util.Map;
/**
* @author wangfei
......@@ -27,4 +30,19 @@ public interface TestUseCaseService extends IService<TestUseCase> {
* @return
*/
List<String> selectCaseIdList(TestUseCaseIdListRequest request);
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
List<String> selectCaseByScenario(TestUseCaseByScenarioRequest request);
/**
* 调用第三方接口
* @param url
* @param map
* @return
*/
JSONObject callThirdPartyInterface(String url, Map<String, Object> map);
}
package com.ruoyi.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.domain.TestType;
import com.ruoyi.domain.TestUseCase;
import com.ruoyi.domain.vo.MatrixColumnVO;
import com.ruoyi.domain.vo.MatrixRowVO;
import com.ruoyi.domain.vo.*;
import com.ruoyi.service.ITestScenarioService;
import com.ruoyi.service.ITestTypeService;
import com.ruoyi.service.MatrixService;
......@@ -13,8 +14,6 @@ import com.ruoyi.web.response.MatrixResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -47,6 +46,88 @@ public class MatrixServiceImpl implements MatrixService {
return response;
}
@Override
public MatrixResponse getMatrixForUrl() {
//以post形式请求接口
String result= HttpUtil.post("https://10.12.48.78:8090/DescribeScenarioTestTypeList","");
JSONObject jsonObject = JSONObject.parseObject(result);
// 获取测试场景列表
List<ScenarioVO> scenarioList = jsonObject.getList("scenario_list", ScenarioVO.class);
if (scenarioList != null && scenarioList.size() != 0 ) {
for (int i = 0; i < scenarioList.size(); i++) {
scenarioList.get(i).setId((long) i);
}
}
// 获取测试方法列表
List<TestTypeVO> testTypeList = jsonObject.getList("test_type_list", TestTypeVO.class);
if (testTypeList != null && testTypeList.size() != 0 ) {
for (int i = 0; i < testTypeList.size(); i++) {
testTypeList.get(i).setId((long) i);
}
}
String caseResult= HttpUtil.post("https://10.12.48.78:8090/DescribeCaseList","");
JSONObject object = JSONObject.parseObject(caseResult);
// 获取测试用例列表
List<UseCaseVO> caseList = object.getList("case_list", UseCaseVO.class);
MatrixResponse response = new MatrixResponse();
setHeaderName(response, testTypeList);
setRowsName(response, scenarioList, testTypeList, caseList);
return response;
}
private void setRowsName(MatrixResponse response, List<ScenarioVO> scenarioList, List<TestTypeVO> testTypeList, List<UseCaseVO> caseList) {
List<Map<String, Object>> rows = new ArrayList();
for(ScenarioVO scenario : scenarioList) {
Map<String, Object> row = new HashMap();
row.put("name", scenario.getName());
for(TestTypeVO type : testTypeList) {
String column = type.getName();
String columnId = String.valueOf(type.getId());
String coordinates = scenario.getName() + column;
String useCase = getUseCaseIdByCoordinatesName(caseList, coordinates);
row.put(columnId, useCase == null ? "" : useCase);
}
rows.add(row);
}
response.setRows(rows);
}
public String getUseCaseIdByCoordinatesName(List<UseCaseVO> caseList, String coordinates) {
for(UseCaseVO useCase : caseList) {
if(useCase.getCoordinates().equals(coordinates)) {
return useCase.getId();
}
}
return null;
}
private void setHeaderName(MatrixResponse response, List<TestTypeVO> testTypeList) {
List<MatrixColumnVO> columns = new ArrayList();
for(TestTypeVO type : testTypeList) {
MatrixColumnVO column = new MatrixColumnVO(String.valueOf(type.getId()),type.getName());
columns.add(column);
}
response.setHeader(columns);
}
private void setHeader(MatrixResponse response, List<TestType> types) {
List<MatrixColumnVO> columns = new ArrayList();
......
......@@ -158,7 +158,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
? Optional.of(pictureList.get(i))
: Optional.empty();
if (optionalElement.isPresent() && StrUtil.isNotEmpty(optionalElement.get())) {
Image image = Image.getInstance(new URL(minioEndpoint + optionalElement.get()));
Image image = Image.getInstance(new URL((minioEndpoint + optionalElement.get()).replace(" ", "%20")));
image.scaleAbsolute(100, 100);
cell.addElement(image);
} else {
......
package com.ruoyi.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.mapper.TestScenarioMapper;
import com.ruoyi.service.ITestScenarioService;
import com.ruoyi.service.TestUseCaseService;
import com.ruoyi.web.request.TestScenarioRequest;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional
......@@ -18,6 +22,11 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
@Autowired
private TestScenarioMapper testScenarioMapper;
@Autowired
private TestUseCaseService testUseCaseService;
private static String url = "https://10.12.48.78:8090/DescribeScenarioTestTypeList";
@Override
public List<TestScenario> selectTestScenarioList(TestScenarioRequest testScenarioRequest){
if(testScenarioRequest.getTestScenario() != null && (testScenarioRequest.getTestScenario().contains("%") ||testScenarioRequest.getTestScenario().contains("_") )){
......@@ -25,4 +34,25 @@ public class TestScenarioServiceImpl extends ServiceImpl<TestScenarioMapper, Tes
}
return testScenarioMapper.selectTestScenarioList(testScenarioRequest);
}
/**
* 获取测试场景列表(科恩)
* @return
*/
@Override
public List<String> selectScenarioList() {
JSONObject jsonObject = testUseCaseService.callThirdPartyInterface(url, null);
List<String> scenarioList = jsonObject.getList("scenario_list", Scenario.class)
.stream()
.map(Scenario::getName)
.collect(Collectors.toList());
return scenarioList;
}
@Data
public class Scenario {
private String name;
}
}
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.domain.TestUseCase;
import com.ruoyi.domain.vo.CaseResultVO;
import com.ruoyi.domain.vo.TestUsecaseVO;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -23,6 +30,8 @@ import java.util.stream.Collectors;
@Transactional
public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestUseCase> implements TestUseCaseService{
private String describeCaseList = "https://10.12.48.78:8090/DescribeCaseList";
@Autowired
private TestUseCaseMapper testUseCaseMapper;
......@@ -46,6 +55,39 @@ public class TestUseCaseServiceImpl extends ServiceImpl<TestUseCaseMapper, TestU
return list.stream().map(TestUsecaseVO::getCaseId).collect(Collectors.toList());
}
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
@Override
public List<String> selectCaseByScenario(TestUseCaseByScenarioRequest request) {
// 根据场景名遍历查询所绑定用例
List<String> resultList = new ArrayList<>();
request.getScenarioNameList()
.forEach(scenarioName -> {
Map<String, Object> map = new HashMap<>();
map.put("scenario", scenarioName);
JSONObject jsonObject = callThirdPartyInterface(describeCaseList, map);
List<String> list = jsonObject.getList("case_list", CaseResultVO.class)
.stream().map(CaseResultVO::getId).collect(Collectors.toList());
resultList.addAll(list);
});
return resultList;
}
/**
* 调用第三方接口
* @param url
* @param map
* @return
*/
@Override
public JSONObject callThirdPartyInterface(String url, Map<String, Object> map) {
String result = HttpUtil.post(url, JSONObject.toJSONString(map));
return JSONObject.parseObject(result);
}
}
......
......@@ -25,7 +25,7 @@ public class MatrixController {
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/getInfo")
public R<MatrixResponse> getInfo() {
return R.ok(matrixService.getMatrix());
return R.ok(matrixService.getMatrixForUrl());
}
}
......@@ -3,7 +3,6 @@ package com.ruoyi.web;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.Sample;
import com.ruoyi.domain.TestScenario;
import com.ruoyi.service.ITestScenarioService;
import com.ruoyi.web.request.TestScenarioRequest;
......@@ -14,10 +13,7 @@ import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -54,4 +50,13 @@ public class TestScenarioController extends BaseController {
return R.ok(testScenarioService.selectTestScenarioList(testScenarioRequest));
}
/**
* 获取测试场景列表(科恩)
*/
@ApiOperation("查询测试场景(科恩)")
@PostMapping("/getScenarioList")
public R<List<String>> getScenarioList(){
return R.ok(testScenarioService.selectScenarioList());
}
}
package com.ruoyi.web;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
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.TestUserCaseRequest;
import io.swagger.annotations.Api;
......@@ -41,10 +41,20 @@ public class TestUserCaseController extends BaseController{
* @param request
* @return
*/
@Anonymous
@ApiOperation("根据场景查询用例ID集合")
@PostMapping("/getCaseIdList")
public R<List<String>> getCaseIdList(@Validated @RequestBody TestUseCaseIdListRequest request) {
return R.ok(testUseCaseService.selectCaseIdList(request));
}
/**
* 通过测试场景获取所绑定的测试用例
* @param request
* @return
*/
@ApiOperation("根据场景查询用例ID集合(科恩)")
@PostMapping("/getCaseByScenario")
public R<List<String>> getCaseByScenario(@Validated @RequestBody TestUseCaseByScenarioRequest request) {
return R.ok(testUseCaseService.selectCaseByScenario(request));
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 通过测试场景获取测试用例ID集合 DTO
* @author gxk
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("通过测试场景获取测试用例ID集合 DTO")
public class TestUseCaseByScenarioRequest {
@ApiModelProperty("测试场景名称集合")
private List<String> scenarioNameList;
}
......@@ -307,16 +307,16 @@
t.entrusted_unit_address AS clientAddress,
t.entrusted_unit_phone AS entrustedUnitTelephone,
t.entrusted_unit_code AS clientPostalCode,
GROUP_CONCAT(s.sample_name) AS sampleName,
SUBSTRING_INDEX(GROUP_CONCAT(s.sample_name), ',', 1) AS sampleName,
t.product_model AS typeSpecification,
DATE_FORMAT(t.task_begin_time, '%Y年%m月%d日') AS taskBeginTime,
DATE_FORMAT(t.task_end_time, '%Y年%m月%d日') AS taskEndTime,
concat(st.standard_no, ' ', st.name) AS inspectionBasis,
GROUP_CONCAT(distinct ae.enterprise_name) AS productionEnterprise,
GROUP_CONCAT(s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
count(s.id) AS sampleQuantity,
CONVERT(sum(s.number_of_samples), UNSIGNED) AS sampleSum,
SUBSTRING_INDEX(GROUP_CONCAT(distinct ae.enterprise_name), ',', 1) AS productionEnterprise,
SUBSTRING_INDEX(GROUP_CONCAT(s.sample_sender), ',', 1) AS sampleSender,
SUBSTRING_INDEX(GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')), ',', 1) AS sampleDeliveryDate,
sum(CASE WHEN s.flag = '0' THEN 1 ELSE 0 END) AS sampleQuantity,
CONVERT(sum(CASE WHEN s.flag = '0' THEN s.number_of_samples ELSE 0 END), UNSIGNED) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicleModel,
t.id AS taskNumber,
......
......@@ -6,16 +6,16 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://49.232.167.247:22030/vehicle-quality-review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://49.232.167.247:22030/vehicle-quality-review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sessionVariables=group_concat_max_len=3000
username: root
password: 1qaz@WSX
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
......@@ -39,7 +39,7 @@ spring:
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
......@@ -58,4 +58,4 @@ spring:
merge-sql: true
wall:
config:
multi-statement-allow: true
\ No newline at end of file
multi-statement-allow: true
......@@ -6,16 +6,16 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://${MYSQL_IP}:${MYSQL_PORT}/vehicle-quality-review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://${MYSQL_IP}:${MYSQL_PORT}/vehicle-quality-review?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sessionVariables=group_concat_max_len=3000
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
......@@ -39,7 +39,7 @@ spring:
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
......@@ -58,4 +58,4 @@ spring:
merge-sql: true
wall:
config:
multi-statement-allow: true
\ No newline at end of file
multi-statement-allow: true
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