Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王飞
vehicle-quality-review
Commits
c2b6649f
Commit
c2b6649f
authored
Mar 25, 2024
by
wdy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
每5秒调用第三方接口&总任务文件列表
parent
db1d1f2f
Changes
24
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
659 additions
and
267 deletions
+659
-267
TaskFileRelation.java
...view/src/main/java/com/ruoyi/domain/TaskFileRelation.java
+28
-0
TestRecords.java
...ty-review/src/main/java/com/ruoyi/domain/TestRecords.java
+2
-5
ModelTestTaskMapper.java
...w/src/main/java/com/ruoyi/mapper/ModelTestTaskMapper.java
+5
-0
TaskFileRelationMapper.java
...rc/main/java/com/ruoyi/mapper/TaskFileRelationMapper.java
+14
-0
TaskMapper.java
...ity-review/src/main/java/com/ruoyi/mapper/TaskMapper.java
+2
-0
TestRecordsMapper.java
...iew/src/main/java/com/ruoyi/mapper/TestRecordsMapper.java
+5
-0
Main.java
...ty-review/src/main/java/com/ruoyi/scheduledTask/Main.java
+12
-0
ScheduledTask.java
.../src/main/java/com/ruoyi/scheduledTask/ScheduledTask.java
+38
-0
TaskEnableSchedulingConfig.java
...a/com/ruoyi/scheduledTask/TaskEnableSchedulingConfig.java
+12
-0
TaskFileRelationService.java
.../main/java/com/ruoyi/service/TaskFileRelationService.java
+11
-0
TestRecordsService.java
...w/src/main/java/com/ruoyi/service/TestRecordsService.java
+15
-0
TaskFileRelationServiceImpl.java
...a/com/ruoyi/service/impl/TaskFileRelationServiceImpl.java
+27
-0
TaskServiceImpl.java
...src/main/java/com/ruoyi/service/impl/TaskServiceImpl.java
+214
-127
TestRecordsServiceImpl.java
...n/java/com/ruoyi/service/impl/TestRecordsServiceImpl.java
+79
-129
TaskCreateRequest.java
...rc/main/java/com/ruoyi/web/request/TaskCreateRequest.java
+4
-0
TaskEditRequest.java
.../src/main/java/com/ruoyi/web/request/TaskEditRequest.java
+4
-0
TaskGetInfoResponse.java
...main/java/com/ruoyi/web/response/TaskGetInfoResponse.java
+4
-0
ModelTestTaskMapper.xml
...-review/src/main/resources/mapper/ModelTestTaskMapper.xml
+36
-0
TaskFileRelationMapper.xml
...view/src/main/resources/mapper/TaskFileRelationMapper.xml
+17
-0
TaskMapper.xml
quality-review/src/main/resources/mapper/TaskMapper.xml
+13
-0
TestRecordsMapper.xml
...ty-review/src/main/resources/mapper/TestRecordsMapper.xml
+8
-4
application-prod.yml
ruoyi-admin/src/main/resources/application-prod.yml
+5
-1
application.yml
ruoyi-admin/src/main/resources/application.yml
+6
-1
TestRecordsTest.java
ruoyi-admin/src/test/java/com/ruoyi/TestRecordsTest.java
+98
-0
No files found.
quality-review/src/main/java/com/ruoyi/domain/TaskFileRelation.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
domain
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
@ApiModel
@TableName
(
value
=
"t_task_file_relation"
)
@Data
@Accessors
(
chain
=
true
)
public
class
TaskFileRelation
{
@ApiModelProperty
(
"任务id"
)
@TableId
(
type
=
IdType
.
ASSIGN_ID
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
)
private
Long
taskId
;
@ApiModelProperty
(
"路径"
)
private
String
url
;
@ApiModelProperty
(
"文件名称"
)
private
String
name
;
}
quality-review/src/main/java/com/ruoyi/domain/TestRecords.java
View file @
c2b6649f
...
...
@@ -44,9 +44,6 @@ public class TestRecords {
@ApiModelProperty
(
"测试结果"
)
private
String
testResult
;
@ApiModelProperty
(
"测试结果描述"
)
private
String
testResultDescription
;
@ApiModelProperty
(
"漏洞危害"
)
private
String
loophole
;
@ApiModelProperty
(
"修复建议"
)
private
String
remediation
;
}
quality-review/src/main/java/com/ruoyi/mapper/ModelTestTaskMapper.java
View file @
c2b6649f
...
...
@@ -4,10 +4,15 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.ruoyi.domain.ModelTestTask
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* 车型试验Mapper层
* @author gxk
*/
@Repository
public
interface
ModelTestTaskMapper
extends
BaseMapper
<
ModelTestTask
>
{
// 查询pending状态下的所有任务
List
<
ModelTestTask
>
findByStatus
();
}
quality-review/src/main/java/com/ruoyi/mapper/TaskFileRelationMapper.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.ruoyi.domain.TaskFileRelation
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
interface
TaskFileRelationMapper
extends
BaseMapper
<
TaskFileRelation
>
{
List
<
TaskFileRelation
>
findByTaskId
(
@Param
(
"taskId"
)
Long
taskId
);
}
quality-review/src/main/java/com/ruoyi/mapper/TaskMapper.java
View file @
c2b6649f
...
...
@@ -37,6 +37,8 @@ public interface TaskMapper extends BaseMapper<Task> {
Long
findTaskName
(
@Param
(
"taskName"
)
String
taskName
);
Task
findByName
(
@Param
(
"taskName"
)
String
taskName
);
/**
* 通过总任务ID,获取企业文件数据
* @param taskId
...
...
quality-review/src/main/java/com/ruoyi/mapper/TestRecordsMapper.java
View file @
c2b6649f
...
...
@@ -2,8 +2,13 @@ package com.ruoyi.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.ruoyi.domain.TestRecords
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
interface
TestRecordsMapper
extends
BaseMapper
<
TestRecords
>
{
List
<
TestRecords
>
findByTaskId
(
@Param
(
"id"
)
String
id
);
}
quality-review/src/main/java/com/ruoyi/scheduledTask/Main.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
scheduledTask
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
ScheduledExecutorService
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
();
scheduledExecutorService
.
scheduleAtFixedRate
(
new
ScheduledTask
(),
0
,
5
,
TimeUnit
.
SECONDS
);
}
}
quality-review/src/main/java/com/ruoyi/scheduledTask/ScheduledTask.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
scheduledTask
;
import
com.ruoyi.domain.ModelTestTask
;
import
com.ruoyi.mapper.ModelTestTaskMapper
;
import
com.ruoyi.service.TestRecordsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.stereotype.Component
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
java.util.*
;
@Component
@EnableAsync
public
class
ScheduledTask
implements
Runnable
{
@Autowired
private
TestRecordsService
testRecordsService
;
@Autowired
private
ModelTestTaskMapper
modelTestTaskMapper
;
@Scheduled
(
fixedDelay
=
5000
)
@Override
public
void
run
()
{
List
<
ModelTestTask
>
modelList
=
modelTestTaskMapper
.
findByStatus
();
for
(
ModelTestTask
testTask
:
modelList
)
{
if
(
testTask
.
getTestSchemeId
()
!=
null
)
{
testRecordsService
.
sendPost
(
testTask
.
getTestSchemeId
());
}
}
}
}
quality-review/src/main/java/com/ruoyi/scheduledTask/TaskEnableSchedulingConfig.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
scheduledTask
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.scheduling.annotation.SchedulingConfiguration
;
@Configuration
@ConditionalOnExpression
(
value
=
"${task.scheduling}"
)
@Import
(
SchedulingConfiguration
.
class
)
public
class
TaskEnableSchedulingConfig
{
}
quality-review/src/main/java/com/ruoyi/service/TaskFileRelationService.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ruoyi.domain.TaskFileRelation
;
import
java.util.List
;
public
interface
TaskFileRelationService
extends
IService
<
TaskFileRelation
>
{
List
<
TaskFileRelation
>
findByTaskId
(
Long
taskId
);
}
quality-review/src/main/java/com/ruoyi/service/TestRecordsService.java
View file @
c2b6649f
...
...
@@ -3,5 +3,20 @@ package com.ruoyi.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ruoyi.domain.TestRecords
;
import
java.util.List
;
public
interface
TestRecordsService
extends
IService
<
TestRecords
>
{
/**
* 根据项目id获取用例
* @param id
* @return
*/
List
<
TestRecords
>
findByTaskId
(
String
id
);
/**
* 发送请求
* @param id
*/
void
sendPost
(
String
id
);
}
quality-review/src/main/java/com/ruoyi/service/impl/TaskFileRelationServiceImpl.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.ruoyi.domain.ResultFileRelation
;
import
com.ruoyi.domain.TaskFileRelation
;
import
com.ruoyi.mapper.ResultFileRelationMapper
;
import
com.ruoyi.mapper.TaskFileRelationMapper
;
import
com.ruoyi.service.ResultFileRelationService
;
import
com.ruoyi.service.TaskFileRelationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Transactional
@Service
public
class
TaskFileRelationServiceImpl
extends
ServiceImpl
<
TaskFileRelationMapper
,
TaskFileRelation
>
implements
TaskFileRelationService
{
@Autowired
private
TaskFileRelationMapper
taskFileRelationMapper
;
@Override
public
List
<
TaskFileRelation
>
findByTaskId
(
Long
taskId
)
{
return
taskFileRelationMapper
.
findByTaskId
(
taskId
);
}
}
quality-review/src/main/java/com/ruoyi/service/impl/TaskServiceImpl.java
View file @
c2b6649f
This diff is collapsed.
Click to expand it.
quality-review/src/main/java/com/ruoyi/service/impl/TestRecordsServiceImpl.java
View file @
c2b6649f
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.StringUtils
;
import
com.ruoyi.domain.TestRecords
;
import
com.ruoyi.domain.vo.CaseResultVO
;
import
com.ruoyi.domain.vo.StepResultVO
;
import
com.ruoyi.mapper.TestRecordsMapper
;
import
com.ruoyi.service.TestRecordsService
;
import
okhttp3.Request
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.*
;
@Transactional
@Service
public
class
TestRecordsServiceImpl
extends
ServiceImpl
<
TestRecordsMapper
,
TestRecords
>
implements
TestRecordsService
{
@Autowired
private
TestRecordsService
testRecordsService
;
public
void
getValue
()
throws
IOException
{
JSONObject
jsonObject
=
getInverseParamByUrl
(
"http://10.12.48.78:8090/DescribeProjectTestResult"
);
}
@Autowired
private
TestRecordsMapper
testRecordsMapper
;
@Override
public
void
sendPost
(
String
id
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
id
);
map
.
put
(
"verbose"
,
"ALL"
);
//以post形式请求接口
String
result
=
HttpUtil
.
post
(
"https://10.12.48.78:8090/DescribeProjectTestResult"
,
JSONObject
.
toJSONString
(
map
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
// 获取项目id
String
projectId
=
(
String
)
jsonObject
.
get
(
"id"
);
// 获取项目用例结果列表
List
<
CaseResultVO
>
caseResultVOS
=
jsonObject
.
getList
(
"case_result_list"
,
CaseResultVO
.
class
);
// 获取本地存储的列表
List
<
TestRecords
>
recordsList
=
testRecordsService
.
findByTaskId
(
id
);
public
static
JSONObject
getInverseParamByUrl
(
String
apiUrl
)
throws
IOException
{
// 调用请求
URL
url
=
new
URL
(
apiUrl
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
StringBuilder
response
=
new
StringBuilder
();
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
response
.
append
(
line
);
List
<
TestRecords
>
list
=
new
ArrayList
<>();
if
(
caseResultVOS
.
size
()
!=
0
&&
caseResultVOS
!=
null
)
{
for
(
CaseResultVO
caseResultVO
:
caseResultVOS
)
{
// 检查 usecaseId 是否在 recordsList 中存在
boolean
exists
=
false
;
if
(
recordsList
.
size
()
!=
0
&&
recordsList
!=
null
)
{
for
(
TestRecords
records
:
recordsList
)
{
if
(
Objects
.
equals
(
caseResultVO
.
getId
(),
records
.
getUsecaseId
()))
{
exists
=
true
;
break
;
}
}
reader
.
close
();
// 解析成JSON对象
String
jsonResponseString
=
response
.
toString
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jsonResponseString
);
return
jsonObject
;
}
public
static
String
doPost
(
String
url
,
JSONObject
json
){
try
{
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
HttpPost
post
=
new
HttpPost
(
url
);
// 首先Header部分需要设定字符集为:uft-8
post
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
// 此处也需要设定
post
.
setHeader
(
"Accept"
,
"*/*"
);
post
.
setHeader
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
post
.
setHeader
(
"Connection"
,
"keep-alive"
);
// post.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36");
post
.
setEntity
(
new
StringEntity
(
json
.
toString
(),
Charset
.
forName
(
"UTF-8"
)));
//设置请求参数
HttpResponse
response
=
httpClient
.
execute
(
post
);
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
HttpStatus
.
SC_OK
==
statusCode
){
//返回String
String
res
=
EntityUtils
.
toString
(
response
.
getEntity
());
System
.
out
.
println
(
res
);
return
res
;
}
else
{
return
"调用POST请求失败"
;
if
((
Objects
.
equals
(
caseResultVO
.
getStatus
(),
"PASSED"
)
||
Objects
.
equals
(
caseResultVO
.
getStatus
(),
"FAILED"
))
&&
!
exists
)
{
TestRecords
testRecords
=
new
TestRecords
();
testRecords
.
setTaskId
(
projectId
);
testRecords
.
setUsecase
(
caseResultVO
.
getName
());
testRecords
.
setUsecaseId
(
caseResultVO
.
getId
());
testRecords
.
setDescription
(
caseResultVO
.
getDescription
());
testRecords
.
setRiskLevel
(
caseResultVO
.
getRisk_level
());
testRecords
.
setTestResult
(
caseResultVO
.
getStatus
());
testRecords
.
setRemediation
(
caseResultVO
.
getRemediation
());
// 用例步骤
List
<
StepResultVO
>
stepResultVOS
=
caseResultVO
.
getStep_result_list
();
if
(
stepResultVOS
.
size
()
!=
0
&&
stepResultVOS
!=
null
)
{
List
<
String
>
stepList
=
new
ArrayList
<>();
for
(
StepResultVO
stepResultVO
:
stepResultVOS
)
{
String
stepName
=
stepResultVO
.
getName
();
stepList
.
add
(
stepName
);
}
testRecords
.
setTestMethod
(
StringUtils
.
join
(
stepList
,
","
));
}
list
.
add
(
testRecords
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
"调用POST请求失败"
;
}
}
// public static void main(String[] args) {
// Map<String, Object> map = new HashMap<>();
// map.put("id", "project_items;1");
// map.put("verbose", "ALL");
// JSONObject json = new JSONObject(map);
//
// //以post形式请求接口
// String result = doPost("http://10.12.48.78:8090/DescribeProjectTestResult", json);
// JSONObject jsonObject = JSONObject.parseObject(result);
// String data = jsonObject.get("data").toString();
//
// System.out.println("data = " + data);
// }
// public static void main(String[] args) {
//
// try {
// String apiUrl = "http://10.12.48.78:8090/DescribeProjectTestResult"; // 第三方URL
//
//
// URL url = new URL(apiUrl);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// conn.setRequestMethod("POST");
// conn.setDoInput(true);
// conn.setDoOutput(true);
//
// // 参数设置 ||
// conn.setRequestProperty("Content-Type","application/json");
// conn.connect();
//
// // 设置请求体
// OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
// JSONObject parm = new JSONObject();
// parm.put("id","project_items;1");
// parm.put("verbose","ALL");
// writer.write(URLEncoder.encode(parm.toString(),"UTF-8"));
// writer.flush();
//
//
// int responseCode = conn.getResponseCode();
// if (responseCode == HttpURLConnection.HTTP_OK) {
// BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
// String inputLine;
// StringBuilder response = new StringBuilder();
//// StringBuffer response = new StringBuffer();
//
// while ((inputLine = in.readLine()) != null) {
// response.append(inputLine);
// }
// in.close();
// conn.disconnect();
//
// String result = response.toString();
// System.out.println("result = " + result);
//
//// String responseBody = response.toString();
//// JSONObject jsonObject = JSONObject.parseObject(responseBody);
//// System.out.println("Response body: " + responseBody);
//// System.out.println("jsonObject = " + jsonObject);
// } else {
// System.out.println("Request failed. Response code: " + responseCode);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
testRecordsService
.
saveBatch
(
list
);
}
}
@Override
public
List
<
TestRecords
>
findByTaskId
(
String
id
)
{
return
testRecordsMapper
.
findByTaskId
(
id
);
}
}
quality-review/src/main/java/com/ruoyi/web/request/TaskCreateRequest.java
View file @
c2b6649f
...
...
@@ -2,6 +2,7 @@ package com.ruoyi.web.request;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.ruoyi.common.core.domain.entity.SysDictData
;
import
com.ruoyi.domain.TaskFileRelation
;
import
com.ruoyi.domain.TaskSampleRelation
;
import
com.ruoyi.domain.TaskUserRelation
;
import
io.swagger.annotations.Api
;
...
...
@@ -65,4 +66,7 @@ public class TaskCreateRequest {
@ApiModelProperty
(
"选择的测试场景"
)
private
List
<
Long
>
testScenarioList
;
@ApiModelProperty
(
"上传的文件"
)
private
List
<
TaskFileRelation
>
fileList
;
}
quality-review/src/main/java/com/ruoyi/web/request/TaskEditRequest.java
View file @
c2b6649f
...
...
@@ -3,6 +3,7 @@ package com.ruoyi.web.request;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.ruoyi.domain.TaskFileRelation
;
import
com.ruoyi.domain.TaskSampleRelation
;
import
com.ruoyi.domain.TaskUserRelation
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -69,4 +70,7 @@ public class TaskEditRequest {
@ApiModelProperty
(
"选择的测试场景"
)
private
List
<
Long
>
testScenarioList
;
@ApiModelProperty
(
"上传的文件"
)
private
List
<
TaskFileRelation
>
fileList
;
}
quality-review/src/main/java/com/ruoyi/web/response/TaskGetInfoResponse.java
View file @
c2b6649f
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.ruoyi.domain.Sample
;
import
com.ruoyi.domain.TaskFileRelation
;
import
com.ruoyi.domain.TaskSampleRelation
;
import
com.ruoyi.domain.TaskUserRelation
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -130,4 +131,7 @@ public class TaskGetInfoResponse {
@ApiModelProperty
(
"测试场景"
)
private
List
<
Long
>
testScenarioList
;
@ApiModelProperty
(
"上传的文件"
)
private
List
<
TaskFileRelation
>
fileList
;
}
quality-review/src/main/resources/mapper/ModelTestTaskMapper.xml
0 → 100644
View file @
c2b6649f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.mapper.ModelTestTaskMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.ruoyi.domain.ModelTestTask"
>
<id
property=
"id"
column=
"id"
jdbcType=
"BIGINT"
/>
<result
property=
"taskNo"
column=
"task_no"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskStatus"
column=
"task_status"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskInitiator"
column=
"task_initiator"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskInitiatorDept"
column=
"task_initiator_dept"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskResult"
column=
"task_result"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskBeginTime"
column=
"task_begin_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"taskEndTime"
column=
"task_end_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"testCase"
column=
"test_case"
typeHandler=
"com.ruoyi.common.StandardJsonTypeHandler"
/>
<result
property=
"createTime"
column=
"create_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"leaderId"
column=
"leader_id"
jdbcType=
"BIGINT"
/>
<result
property=
"leader"
column=
"leader"
jdbcType=
"VARCHAR"
/>
<result
property=
"standardId"
column=
"standard_id"
jdbcType=
"BIGINT"
/>
<result
property=
"name"
column=
"name"
jdbcType=
"VARCHAR"
/>
<result
property=
"standardNo"
column=
"standard_no"
jdbcType=
"VARCHAR"
/>
<result
property=
"submitId"
column=
"submit_id"
jdbcType=
"BIGINT"
/>
<result
property=
"submitName"
column=
"submit_name"
jdbcType=
"VARCHAR"
/>
<result
property=
"imagesUrl"
column=
"images_url"
jdbcType=
"VARCHAR"
/>
<result
property=
"details"
column=
"details"
jdbcType=
"INTEGER"
/>
<result
property=
"standards"
column=
"standards"
jdbcType=
"INTEGER"
/>
<result
property=
"testSchemeId"
column=
"test_scheme_id"
jdbcType=
"VARCHAR"
/>
</resultMap>
<select
id=
"findByStatus"
resultType=
"com.ruoyi.domain.ModelTestTask"
>
SELECT id,task_no,task_status,task_initiator,task_initiator_dept,task_result,task_begin_time,task_end_time,test_case,create_time,leader_id,leader,standard_id,name,standard_no,submit_id,submit_name,images_url,details,standards,test_scheme_id
FROM t_model_test_task WHERE task_status = 'PENDING'
</select>
</mapper>
quality-review/src/main/resources/mapper/TaskFileRelationMapper.xml
0 → 100644
View file @
c2b6649f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.mapper.TaskFileRelationMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.ruoyi.domain.TaskFileRelation"
>
<result
property=
"taskId"
column=
"task_id"
jdbcType=
"BIGINT"
/>
<result
property=
"url"
column=
"url"
jdbcType=
"VARCHAR"
/>
<result
property=
"name"
column=
"name"
jdbcType=
"VARCHAR"
/>
</resultMap>
<select
id=
"findByTaskId"
resultType=
"com.ruoyi.domain.TaskFileRelation"
>
select task_id,url,name from t_task_file_relation
where task_id = #{taskId}
</select>
</mapper>
quality-review/src/main/resources/mapper/TaskMapper.xml
View file @
c2b6649f
...
...
@@ -328,6 +328,19 @@
where t.id = #{taskId}
group by t.id
</select>
<select
id=
"findByName"
resultType=
"com.ruoyi.domain.Task"
>
SELECT id, system_review_task_id, car_review_task_id,model_test_task_id,
task_status,run_status,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file,task_list
FROM t_task
WHERE task_name = #{taskName}
</select>
</mapper>
quality-review/src/main/resources/mapper/TestRecordsMapper.xml
View file @
c2b6649f
...
...
@@ -10,13 +10,17 @@
<result
property=
"usecase"
column=
"usecase"
jdbcType=
"VARCHAR"
/>
<result
property=
"usecaseId"
column=
"usecase_id"
jdbcType=
"VARCHAR"
/>
<result
property=
"testTime"
column=
"test_time"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"description"
column=
"description"
jdbcType=
"VARCHAR"
/>
<result
property=
"description"
column=
"description"
jdbcType=
"
LONGN
VARCHAR"
/>
<result
property=
"riskLevel"
column=
"risk_level"
jdbcType=
"VARCHAR"
/>
<result
property=
"testMethod"
column=
"test_method"
jdbcType=
"VARCHAR"
/>
<result
property=
"testMethod"
column=
"test_method"
jdbcType=
"
LONGN
VARCHAR"
/>
<result
property=
"testResult"
column=
"test_result"
jdbcType=
"VARCHAR"
/>
<result
property=
"testResultDescription"
column=
"test_result_description"
jdbcType=
"VARCHAR"
/>
<result
property=
"loophole"
column=
"loophole"
jdbcType=
"VARCHAR"
/>
<result
property=
"remediation"
column=
"remediation"
jdbcType=
"VARCHAR"
/>
</resultMap>
<select
id=
"findByTaskId"
resultType=
"com.ruoyi.domain.TestRecords"
>
SELECT id, task_id, usecase, usecase_id, test_time, description, risk_level, test_method, test_result, remediation
FROM t_test_records
WHERE task_id = #{id}
</select>
</mapper>
ruoyi-admin/src/main/resources/application-prod.yml
View file @
c2b6649f
...
...
@@ -148,3 +148,7 @@ minio:
accessKey
:
${MINIO_ACCESSKEY}
secretKey
:
${MINIO_SECRETKEY}
bucketName
:
vehicle-quality-review-oss
# 定时任务开启状态
task
:
scheduling
:
true
\ No newline at end of file
ruoyi-admin/src/main/resources/application.yml
View file @
c2b6649f
...
...
@@ -150,3 +150,8 @@ minio:
accessKey
:
lB7WhZYiQwLzhHPutRGn
secretKey
:
7XMWpLm6p4d20OFe9uXKifEyhF3cp4sTCowI2fhJ
bucketName
:
vehicle-quality-review-oss
# 定时任务开启状态
task
:
scheduling
:
true
\ No newline at end of file
ruoyi-admin/src/test/java/com/ruoyi/TestRecordsTest.java
0 → 100644
View file @
c2b6649f
package
com
.
ruoyi
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.domain.TestRecords
;
import
com.ruoyi.domain.vo.CaseResultVO
;
import
com.ruoyi.domain.vo.StepResultVO
;
import
com.ruoyi.mapper.TestRecordsMapper
;
import
com.ruoyi.service.TestRecordsService
;
import
com.ruoyi.service.impl.TestRecordsServiceImpl
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.util.*
;
@SpringBootTest
public
class
TestRecordsTest
{
@Autowired
private
TestRecordsService
testRecordsService
;
@Autowired
private
TestRecordsMapper
testRecordsMapper
;
@Test
public
void
test
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
"project_items;27"
);
map
.
put
(
"verbose"
,
"ALL"
);
//以post形式请求接口
String
result
=
HttpUtil
.
post
(
"https://10.12.48.78:8090/DescribeProjectTestResult"
,
JSONObject
.
toJSONString
(
map
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
// 获取关联项目id
String
projectId
=
(
String
)
jsonObject
.
get
(
"id"
);
// 获取项目用例结果列表
List
<
CaseResultVO
>
caseResultVOS
=
jsonObject
.
getList
(
"case_result_list"
,
CaseResultVO
.
class
);
// 获取本地存储的列表
List
<
TestRecords
>
recordsList
=
testRecordsService
.
findByTaskId
(
"project_items;29"
);
List
<
TestRecords
>
list
=
new
ArrayList
<>();
if
(
caseResultVOS
.
size
()
!=
0
&&
caseResultVOS
!=
null
)
{
for
(
CaseResultVO
caseResultVO
:
caseResultVOS
)
{
// 检查 usecaseId 是否在 recordsList 中存在
boolean
exists
=
false
;
if
(
recordsList
.
size
()
!=
0
&&
recordsList
!=
null
)
{
for
(
TestRecords
records
:
recordsList
)
{
if
(
Objects
.
equals
(
caseResultVO
.
getId
(),
records
.
getUsecaseId
()))
{
exists
=
true
;
break
;
}
}
}
if
((
Objects
.
equals
(
caseResultVO
.
getStatus
(),
"PASSED"
)
||
Objects
.
equals
(
caseResultVO
.
getStatus
(),
"FAILED"
))
&&
!
exists
)
{
TestRecords
testRecords
=
new
TestRecords
();
testRecords
.
setTaskId
(
projectId
);
testRecords
.
setUsecase
(
caseResultVO
.
getName
());
testRecords
.
setUsecaseId
(
caseResultVO
.
getId
());
testRecords
.
setDescription
(
caseResultVO
.
getDescription
());
testRecords
.
setRiskLevel
(
caseResultVO
.
getRisk_level
());
testRecords
.
setTestResult
(
caseResultVO
.
getStatus
());
testRecords
.
setRemediation
(
caseResultVO
.
getRemediation
());
List
<
StepResultVO
>
stepResultVOS
=
caseResultVO
.
getStep_result_list
();
if
(
stepResultVOS
.
size
()
!=
0
&&
stepResultVOS
!=
null
)
{
List
<
String
>
stepList
=
new
ArrayList
<>();
for
(
StepResultVO
stepResultVO
:
stepResultVOS
)
{
String
stepName
=
stepResultVO
.
getName
();
stepList
.
add
(
stepName
);
}
testRecords
.
setTestMethod
(
StringUtils
.
join
(
stepList
,
","
));
}
list
.
add
(
testRecords
);
}
}
testRecordsService
.
saveBatch
(
list
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment