Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
middleware-automatic
Overview
Overview
Details
Activity
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
shenjunjie
middleware-automatic
Commits
db299a6f
Commit
db299a6f
authored
May 26, 2023
by
liuyu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!69
parents
15b1c55b
c375014c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
35 deletions
+62
-35
middleware-automatic-center-client/src/main/java/com/zhiwei/middleware/automatic/server/core/AutoMaticClient.java
+10
-0
middleware-automatic-center-client/src/main/java/com/zhiwei/middleware/automatic/server/dubbo/service/AutoMaticService.java
+9
-5
middleware-automatic-center-server/src/main/java/com/zhiwei/middleware/automatic/server/mission/ScheduledMission.java
+2
-1
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/service/TemplateTitleService.java
+7
-6
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/service/impl/TemplateTitleServiceImpl.java
+31
-21
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/task/service/TaskServiceTemplate.java
+3
-2
No files found.
middleware-automatic-center-client/src/main/java/com/zhiwei/middleware/automatic/server/core/AutoMaticClient.java
View file @
db299a6f
package
com
.
zhiwei
.
middleware
.
automatic
.
server
.
core
;
package
com
.
zhiwei
.
middleware
.
automatic
.
server
.
core
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.base.entity.subclass.mark.MarkInfo
;
import
com.zhiwei.base.entity.subclass.mark.MarkInfo
;
import
com.zhiwei.middleware.automatic.server.dubbo.service.AutoMaticService
;
import
com.zhiwei.middleware.automatic.server.dubbo.service.AutoMaticService
;
import
com.zhiwei.middleware.automatic.server.pojo.MarkInfoMulti
;
import
com.zhiwei.middleware.automatic.server.pojo.MarkInfoMulti
;
import
com.zhiwei.middleware.automatic.server.pojo.PageVO
;
import
com.zhiwei.middleware.automatic.server.pojo.TemplateTitleVo
;
import
com.zhiwei.middleware.automatic.server.pojo.TemplateTitleVo
;
import
java.util.List
;
import
java.util.List
;
...
@@ -53,4 +55,12 @@ public class AutoMaticClient {
...
@@ -53,4 +55,12 @@ public class AutoMaticClient {
public
Map
<
String
,
Object
>
compareWithTemplateTileOL
(
String
project
,
String
title
)
{
public
Map
<
String
,
Object
>
compareWithTemplateTileOL
(
String
project
,
String
title
)
{
return
autoMaticService
.
compareWithTemplateTileOL
(
project
,
title
);
return
autoMaticService
.
compareWithTemplateTileOL
(
project
,
title
);
}
}
public
PageVO
<
JSONObject
>
getTemplateDaySumData
(
int
page
,
int
pageSize
,
String
templateId
)
{
return
autoMaticService
.
getTemplateDaySumData
(
page
,
pageSize
,
templateId
);
}
public
PageVO
<
JSONObject
>
getTemplateTotalSumData
(
int
page
,
int
pageSize
,
String
templateId
)
{
return
autoMaticService
.
getTemplateTotalSumData
(
page
,
pageSize
,
templateId
);
}
}
}
middleware-automatic-center-client/src/main/java/com/zhiwei/middleware/automatic/server/dubbo/service/AutoMaticService.java
View file @
db299a6f
...
@@ -72,13 +72,17 @@ public interface AutoMaticService {
...
@@ -72,13 +72,17 @@ public interface AutoMaticService {
* @return 返回值
* @return 返回值
*/
*/
Map
<
String
,
Object
>
compareWithTemplateTileOL
(
String
project
,
String
title
);
Map
<
String
,
Object
>
compareWithTemplateTileOL
(
String
project
,
String
title
);
/**
* 分页查询模板声量统计详细数据
* @param templateId 模板id
* @return page
*/
PageVO
<
JSONObject
>
getTemplateDaySumData
(
int
page
,
int
pageSize
,
String
templateId
);
/**
/**
* 分页查询模板声量统计详细数据
* 分页查询模板声量统计详细数据
* @param templateId
* @param templateId 模板id
* @param startTime
* @return page
* @param endTime
* @return
*/
*/
PageVO
<
JSONObject
>
getTemplate
SumData
(
String
templateId
,
Long
startTime
,
Long
endTime
);
PageVO
<
JSONObject
>
getTemplate
TotalSumData
(
int
page
,
int
pageSize
,
String
templateId
);
}
}
middleware-automatic-center-server/src/main/java/com/zhiwei/middleware/automatic/server/mission/ScheduledMission.java
View file @
db299a6f
...
@@ -121,7 +121,8 @@ public class ScheduledMission {
...
@@ -121,7 +121,8 @@ public class ScheduledMission {
TaskManager
.
getInstance
().
putTask
(
autoTask
);
TaskManager
.
getInstance
().
putTask
(
autoTask
);
continue
;
continue
;
}
}
if
(
value
.
getUpdateTime
().
getTime
()
>
(
System
.
currentTimeMillis
()
-
GenericAttribute
.
WEEK_TIME
))
{
if
(
value
.
getStatus
()
==
TemplateStatus
.
已重置
&&
value
.
getUpdateTime
().
getTime
()
>
(
System
.
currentTimeMillis
()
-
GenericAttribute
.
WEEK_TIME
))
{
AutoTask
autoTask
=
new
AutoTask
(
TaskType
.
TEMPLATE_LOST_RESET
.
getType
(),
group
);
AutoTask
autoTask
=
new
AutoTask
(
TaskType
.
TEMPLATE_LOST_RESET
.
getType
(),
group
);
autoTask
.
getParamSource
().
put
(
GenericAttribute
.
TEMPLATE_TITLE
,
entry
.
getKey
());
autoTask
.
getParamSource
().
put
(
GenericAttribute
.
TEMPLATE_TITLE
,
entry
.
getKey
());
log
.
info
(
"任务类型:{},项目:{},标题:{}已创建"
,
autoTask
.
getType
(),
autoTask
.
getGroup
(),
entry
.
getKey
());
log
.
info
(
"任务类型:{},项目:{},标题:{}已创建"
,
autoTask
.
getType
(),
autoTask
.
getGroup
(),
entry
.
getKey
());
...
...
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/service/TemplateTitleService.java
View file @
db299a6f
...
@@ -74,12 +74,6 @@ public interface TemplateTitleService {
...
@@ -74,12 +74,6 @@ public interface TemplateTitleService {
*/
*/
void
setTemplateValue
(
String
group
,
String
title
,
String
fixTag
);
void
setTemplateValue
(
String
group
,
String
title
,
String
fixTag
);
/**
* 清除模板
* @param group 项目
* @param title 标题
*/
void
deleteTemplate
(
String
group
,
String
title
);
/**
/**
* 修改模板特征值信息
* 修改模板特征值信息
...
@@ -94,4 +88,11 @@ public interface TemplateTitleService {
...
@@ -94,4 +88,11 @@ public interface TemplateTitleService {
* @param group 项目
* @param group 项目
*/
*/
void
clearDaySum
(
String
group
,
Long
startTime
,
Long
endTime
);
void
clearDaySum
(
String
group
,
Long
startTime
,
Long
endTime
);
/**
* 模板转移到失效中
* @param group 项目
* @param templateTitleVo 模板
*/
void
transferTemplate
(
String
group
,
TemplateTitleVo
templateTitleVo
);
}
}
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/service/impl/TemplateTitleServiceImpl.java
View file @
db299a6f
...
@@ -109,9 +109,8 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
...
@@ -109,9 +109,8 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
// 只要在运行中的模板 才能重置
// 只要在运行中的模板 才能重置
if
(
Objects
.
isNull
(
templateTitleVo
.
getStatus
())
||
templateTitleVo
.
getStatus
().
name
().
equals
(
TemplateStatus
.
运行中
.
name
()))
{
if
(
Objects
.
isNull
(
templateTitleVo
.
getStatus
())
||
templateTitleVo
.
getStatus
().
name
().
equals
(
TemplateStatus
.
运行中
.
name
()))
{
templateTitleVo
.
setStatus
(
TemplateStatus
.
已重置
);
templateTitleVo
.
setStatus
(
TemplateStatus
.
已重置
);
setTemplateValue
(
group
,
templateTitle
,
templateTitleVo
);
// setTemplateValue(group, templateTitle, templateTitleVo);
redissonUtil
.
setMapValue
(
Tools
.
assembleKey
(
GenericAttribute
.
REDIS_MAP_LOSE_KEY
,
group
),
templateTitle
,
JSONObject
.
toJSONString
(
templateTitleVo
));
transferTemplate
(
group
,
templateTitleVo
);
deleteTemplate
(
group
,
title
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -132,24 +131,12 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
...
@@ -132,24 +131,12 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
setTemplateValue
(
group
,
title
,
null
,
null
,
daySum
);
setTemplateValue
(
group
,
title
,
null
,
null
,
daySum
);
}
}
@Override
public
void
deleteTemplate
(
String
group
,
String
title
)
{
redissonUtil
.
removeMapValue
(
Tools
.
assembleKey
(
GenericAttribute
.
REDIS_MAP_KEY
,
group
),
title
);
}
private
Map
<
String
,
TemplateTitleVo
>
getTemplateTitleByProject
(
String
key
,
String
project
)
{
Map
<
String
,
String
>
mapValue
=
redissonUtil
.
getMapValue
(
Tools
.
assembleKey
(
key
,
project
));
if
(
Tools
.
isEmpty
(
mapValue
))
{
return
new
HashMap
<>();
}
return
Tools
.
restoreTMap
(
mapValue
,
TemplateTitleVo
.
class
);
}
/**
/**
* 模板自动标注的历史数据修改为新标签
* 模板自动标注的历史数据修改为新标签
* @param title 模板
* @param title 模板
* @return 是否修改成功
* @return 是否修改成功
*/
*/
@Override
public
boolean
modifyTemplateMarkerInfo
(
String
title
,
String
project
)
{
public
boolean
modifyTemplateMarkerInfo
(
String
title
,
String
project
)
{
TemplateTitleVo
templateTitleVo
=
getTemplateTitleByProjectLost
(
project
).
get
(
title
);
TemplateTitleVo
templateTitleVo
=
getTemplateTitleByProjectLost
(
project
).
get
(
title
);
try
{
try
{
...
@@ -166,7 +153,7 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
...
@@ -166,7 +153,7 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
// mongo 查询记录信息
// mongo 查询记录信息
List
<
TemplateRecord
>
templateRecord
=
templateRecordDao
.
findTemplateRecord
(
query
);
List
<
TemplateRecord
>
templateRecord
=
templateRecordDao
.
findTemplateRecord
(
query
);
// es 查询
// es 查询
SearchHits
hits
=
findByMupdateInfos
(
templateRecord
.
stream
().
map
(
TemplateRecord:
:
get
Mupdate
).
collect
(
Collectors
.
toList
())
);
SearchHits
hits
=
findByMupdateInfos
(
templateRecord
.
stream
().
map
(
TemplateRecord:
:
get
Id
).
collect
(
Collectors
.
toList
()),
project
);
// 转换成markInfo
// 转换成markInfo
List
<
MarkInfo
>
collect
=
Arrays
.
stream
(
hits
.
getHits
())
List
<
MarkInfo
>
collect
=
Arrays
.
stream
(
hits
.
getHits
())
.
map
(
e
->
MarkInfoUtil
.
distinguishMarkInfo
(
e
,
null
))
.
map
(
e
->
MarkInfoUtil
.
distinguishMarkInfo
(
e
,
null
))
...
@@ -197,6 +184,19 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
...
@@ -197,6 +184,19 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
}
}
}
}
@Override
public
void
transferTemplate
(
String
group
,
TemplateTitleVo
templateTitleVo
)
{
String
lockKey
=
Tools
.
assembleKey
(
GenericAttribute
.
LOCK
,
templateTitleVo
.
getTemplateTitle
());
try
{
redissonUtil
.
setMapValue
(
Tools
.
assembleKey
(
GenericAttribute
.
REDIS_MAP_LOSE_KEY
,
group
),
templateTitleVo
.
getTemplateTitle
(),
JSONObject
.
toJSONString
(
templateTitleVo
));
redissonUtil
.
removeMapValue
(
Tools
.
assembleKey
(
GenericAttribute
.
REDIS_MAP_KEY
,
group
),
templateTitleVo
.
getTemplateTitle
());
}
catch
(
Exception
e
)
{
log
.
error
(
"转移模板失败,项目:{},title:{}"
,
group
,
templateTitleVo
.
getTemplateTitle
(),
e
);
}
finally
{
redissonUtil
.
unlock
(
lockKey
);
}
}
private
void
setTemplateValue
(
String
group
,
String
title
,
TemplateTitleVo
templateTitleVo
,
String
fixTag
,
Long
daySum
)
{
private
void
setTemplateValue
(
String
group
,
String
title
,
TemplateTitleVo
templateTitleVo
,
String
fixTag
,
Long
daySum
)
{
String
lockKey
=
Tools
.
assembleKey
(
GenericAttribute
.
LOCK
,
title
);
String
lockKey
=
Tools
.
assembleKey
(
GenericAttribute
.
LOCK
,
title
);
try
{
try
{
...
@@ -231,21 +231,31 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
...
@@ -231,21 +231,31 @@ public class TemplateTitleServiceImpl implements TemplateTitleService {
}
}
}
}
private
Map
<
String
,
TemplateTitleVo
>
getTemplateTitleByProject
(
String
key
,
String
project
)
{
Map
<
String
,
String
>
mapValue
=
redissonUtil
.
getMapValue
(
Tools
.
assembleKey
(
key
,
project
));
if
(
Tools
.
isEmpty
(
mapValue
))
{
return
new
HashMap
<>();
}
return
Tools
.
restoreTMap
(
mapValue
,
TemplateTitleVo
.
class
);
}
/**
/**
* 根据特征值查询es数据
* 根据特征值查询es数据
* @param
mupdate
特征值
* @param
ids
特征值
* @return es返回值
* @return es返回值
*/
*/
private
SearchHits
findByMupdateInfos
(
List
<
String
>
mupdate
)
throws
IOException
{
private
SearchHits
findByMupdateInfos
(
List
<
String
>
ids
,
String
project
)
throws
IOException
{
List
<
String
>
mark2
=
esIndexes
.
getMarkIndexes
(
Index
.
mark2
.
name
());
List
<
String
>
mark2
=
esIndexes
.
getMarkIndexes
(
Index
.
mark2
.
name
());
String
[]
indexes
=
new
String
[
mark2
.
size
()];
String
[]
indexes
=
new
String
[
mark2
.
size
()];
mark2
.
toArray
(
indexes
);
mark2
.
toArray
(
indexes
);
// 查询条件
// 查询条件
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
();
query
.
must
(
QueryBuilders
.
termQuery
(
"mperson"
,
GenericAttribute
.
AUTO_PERSON
));
query
.
must
(
QueryBuilders
.
termQuery
(
"mperson"
,
GenericAttribute
.
AUTO_PERSON
));
query
.
must
(
QueryBuilders
.
termQuery
(
"mgroup"
,
project
));
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
should
=
QueryBuilders
.
boolQuery
();
mupdate
.
forEach
(
e
->
{
ids
.
forEach
(
e
->
{
should
.
should
(
QueryBuilders
.
termQuery
(
"
mupdate
"
,
e
));
should
.
should
(
QueryBuilders
.
termQuery
(
"
_id
"
,
e
));
});
});
query
.
must
(
should
);
query
.
must
(
should
);
return
esDao
.
search
(
indexes
,
null
,
query
,
null
,
0
,
1000
,
null
);
return
esDao
.
search
(
indexes
,
null
,
query
,
null
,
0
,
1000
,
null
);
...
...
middleware-automatic-center-son/src/main/java/com/zhiwei/middleware/automatic/son/task/service/TaskServiceTemplate.java
View file @
db299a6f
...
@@ -210,11 +210,12 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
...
@@ -210,11 +210,12 @@ public class TaskServiceTemplate extends BaseTaskTypePair<TaskServiceTemplate.Ta
// 移除1天有效期外的数据
// 移除1天有效期外的数据
if
(
System
.
currentTimeMillis
()
-
updateTime
>
ONE_DAY
*
1000
)
{
if
(
System
.
currentTimeMillis
()
-
updateTime
>
ONE_DAY
*
1000
)
{
log
.
info
(
"{}-移除过期模板标题:{},最后更新时间:{}"
,
group
,
title
,
updateTime
);
log
.
info
(
"{}-移除过期模板标题:{},最后更新时间:{}"
,
group
,
title
,
updateTime
);
templateTitleService
.
deleteTemplate
(
group
,
title
);
templateTitleVo
.
setStatus
(
TemplateStatus
.
待删除
);
templateTitleService
.
transferTemplate
(
group
,
templateTitleVo
);
return
false
;
return
false
;
}
else
if
(
e
.
getValue
().
getStatus
()
==
TemplateStatus
.
已重置
)
{
}
else
if
(
e
.
getValue
().
getStatus
()
==
TemplateStatus
.
已重置
)
{
log
.
info
(
"已重置的模板从内存中删除,模板title:{}"
,
e
.
getKey
());
log
.
info
(
"已重置的模板从内存中删除,模板title:{}"
,
e
.
getKey
());
templateTitleService
.
deleteTemplate
(
group
,
title
);
templateTitleService
.
transferTemplate
(
group
,
templateTitleVo
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
...
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