Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
a2093f05
提交
a2093f05
authored
3月 23, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
df
上级
da9becd6
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
31 行增加
和
28 行删除
+31
-28
ProjectInitRun.java
src/main/java/com/zjty/autotest/config/ProjectInitRun.java
+2
-5
AutoResultSetController.java
...com/zjty/autotest/controller/AutoResultSetController.java
+1
-0
AutoResultSetDao.java
src/main/java/com/zjty/autotest/dao/AutoResultSetDao.java
+2
-1
TestReportDao.java
src/main/java/com/zjty/autotest/dao/TestReportDao.java
+5
-4
PushBlockQueueHandler.java
...main/java/com/zjty/autotest/mq/PushBlockQueueHandler.java
+5
-10
AsyncServiceImpl.java
...java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
+3
-0
AutoResultSetServiceImpl.java
.../zjty/autotest/service/impl/AutoResultSetServiceImpl.java
+7
-5
TestReportServiceImpl.java
...com/zjty/autotest/service/impl/TestReportServiceImpl.java
+6
-3
没有找到文件。
src/main/java/com/zjty/autotest/config/ProjectInitRun.java
浏览文件 @
a2093f05
package
com
.
zjty
.
autotest
.
config
;
import
com.zjty.autotest.mq.PushBlockQueue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ProjectInitRun
implements
CommandLineRunner
{
@Autowired
private
PushBlockQueue
pushBlockQueue
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
pushBlockQueue
.
start
();
}
}
src/main/java/com/zjty/autotest/controller/AutoResultSetController.java
浏览文件 @
a2093f05
...
...
@@ -42,6 +42,7 @@ public class AutoResultSetController {
public
ResponseResult
delete
(
@PathVariable
String
id
){
return
autoResultSetService
.
deleteByid
(
id
);
}
@ApiOperation
(
"新增"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
ResponseResult
add
(
@RequestBody
TestChannel
testChannel
){
...
...
src/main/java/com/zjty/autotest/dao/AutoResultSetDao.java
浏览文件 @
a2093f05
...
...
@@ -5,9 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
public
interface
AutoResultSetDao
extends
JpaRepository
<
AutoResultSet
,
String
>,
JpaSpecificationExecutor
<
AutoResultSet
>
{
@Modifying
@Query
(
"update AutoResultSet set status=1 where id=:id"
)
int
updateStatus
(
String
id
);
int
updateStatus
(
@Param
(
"id"
)
String
id
);
}
src/main/java/com/zjty/autotest/dao/TestReportDao.java
浏览文件 @
a2093f05
...
...
@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
/**
* 数据访问接口
...
...
@@ -13,12 +14,12 @@ import org.springframework.data.jpa.repository.Query;
*/
public
interface
TestReportDao
extends
JpaRepository
<
TestReport
,
String
>,
JpaSpecificationExecutor
<
TestReport
>
{
@Query
(
value
=
"SELECT input_report FROM test_report WHERE result_id = :resultId"
,
nativeQuery
=
true
)
String
findByInResultId
(
String
resultId
);
String
findByInResultId
(
@Param
(
"resultId"
)
String
resultId
);
@Query
(
value
=
"select out_report from test_report where result_id =:resultId"
,
nativeQuery
=
true
)
String
findByOutResultId
(
String
resultId
);
String
findByOutResultId
(
@Param
(
"resultId"
)
String
resultId
);
@Query
(
value
=
"select * from test_report where result_id=:resultId"
,
nativeQuery
=
true
)
TestReport
findByResultId
(
String
resultId
);
TestReport
findByResultId
(
@Param
(
"resultId"
)
String
resultId
);
@Modifying
int
deleteByResultId
(
String
resultId
);
int
deleteByResultId
(
@Param
(
"resultId"
)
String
resultId
);
}
src/main/java/com/zjty/autotest/mq/PushBlockQueueHandler.java
浏览文件 @
a2093f05
...
...
@@ -2,6 +2,7 @@ package com.zjty.autotest.mq;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.autotest.pojo.sjq.*
;
import
com.zjty.autotest.service.AsyncService
;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
import
com.zjty.autotest.util.TimeUtil
;
...
...
@@ -17,13 +18,7 @@ import java.util.List;
@Component
public
class
PushBlockQueueHandler
implements
Runnable
{
@Autowired
private
TestReportService
testReportService
;
@Autowired
private
AutoResultSetService
autoResultSetService
;
@PostConstruct
public
void
init
(){
new
Thread
(
this
).
start
();
}
private
AsyncService
asyncService
;
//消费的对象
private
Object
obj
;
...
...
@@ -37,12 +32,12 @@ public class PushBlockQueueHandler implements Runnable {
//消费线程
@Override
public
void
run
()
{
doBusiness
();
//
doBusiness();
}
//消费行为
private
void
doBusiness
()
{
String
id
=
(
String
)
obj
;
/*
String id = (String) obj;
System.out.println("id:" + id);
TestChannel testChannel = (TestChannel) CacheManager.getCache(id);
if (testChannel != null) {
...
...
@@ -123,7 +118,7 @@ public class PushBlockQueueHandler implements Runnable {
e.printStackTrace();
}
}
}
*/
System
.
out
.
println
(
Thread
.
currentThread
().
getName
()
+
"-收到消息:"
+
obj
);
}
}
src/main/java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
浏览文件 @
a2093f05
...
...
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
java.beans.Transient
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -22,6 +23,8 @@ public class AsyncServiceImpl implements AsyncService {
private
TestReportService
testReportService
;
@Override
@Async
(
"asyncServiceExecutor"
)
@Transient
public
void
executeAsync
(
String
id
)
{
System
.
out
.
println
(
"id:"
+
id
);
TestChannel
testChannel
=
(
TestChannel
)
CacheManager
.
getCache
(
id
);
...
...
src/main/java/com/zjty/autotest/service/impl/AutoResultSetServiceImpl.java
浏览文件 @
a2093f05
...
...
@@ -22,10 +22,12 @@ import org.springframework.data.domain.Sort;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
javax.persistence.RollbackException
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.beans.Transient
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -36,7 +38,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
@Autowired
private
AutoResultSetDao
autoResultSetDao
;
@Autowired
private
PushBlockQueue
pushBlockQueu
e
;
private
AsyncService
asyncServic
e
;
@Autowired
private
TestReportService
testReportService
;
@Autowired
...
...
@@ -69,7 +71,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
}
@Transient
@Override
public
ResponseResult
deleteByid
(
String
id
)
{
try
{
...
...
@@ -81,7 +83,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
return
ResponseResult
.
okResult
(
AppHttpCodeEnum
.
SUCCESS
);
}
@Transient
@Override
public
ResponseResult
updateByid
(
String
id
)
{
int
i
=
autoResultSetDao
.
updateStatus
(
id
);
...
...
@@ -90,7 +92,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
}
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
UPDATE_ERROR
);
}
@Transient
@Override
public
ResponseResult
addResultSet
(
TestChannel
testChannel
)
{
String
tid
=
idWorker
.
nextId
()+
""
;
...
...
@@ -106,7 +108,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
CacheManager
.
putCache
(
tid
,
testChannel
);
//将数据保存到队列
try
{
pushBlockQueue
.
put
(
tid
);
asyncService
.
executeAsync
(
tid
);
// PushBlockQueue.getInstance().put(tid);
return
ResponseResult
.
okResult
(
save
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/zjty/autotest/service/impl/TestReportServiceImpl.java
浏览文件 @
a2093f05
package
com
.
zjty
.
autotest
.
service
.
impl
;
import
java.beans.Transient
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -63,11 +64,12 @@ public class TestReportServiceImpl implements TestReportService {
* 增加
* @param testReport
*/
@Transient
public
void
add
(
TestReport
testReport
)
{
testReport
.
setId
(
idWorker
.
nextId
()+
""
);
testReportDao
.
save
(
testReport
);
}
@Transient
/**
* 修改
* @param testReport
...
...
@@ -80,11 +82,12 @@ public class TestReportServiceImpl implements TestReportService {
* 删除
* @param resultId
*/
@Transient
public
ResponseResult
deleteByResultId
(
String
resultId
)
{
int
i
=
testReportDao
.
deleteByResultId
(
resultId
);
return
ResponseResult
.
okResult
(
i
);
}
@Transient
@Override
public
ResponseResult
save
(
TestReport
testReport
)
{
System
.
out
.
println
(
testReport
);
...
...
@@ -98,7 +101,7 @@ public class TestReportServiceImpl implements TestReportService {
}
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
ERROR
);
}
@Transient
@Override
public
ResponseResult
addInReport
(
String
id
,
String
inReport
)
{
TestReport
testReport
=
new
TestReport
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论