Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
70da9d0a
提交
70da9d0a
authored
4月 08, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect
上级
26cca863
318026c5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
67 行增加
和
56 行删除
+67
-56
AopIntercept.java
src/main/java/com/zjty/inspect/aop/AopIntercept.java
+1
-1
RuleController.java
...main/java/com/zjty/inspect/controller/RuleController.java
+3
-3
RuleService.java
src/main/java/com/zjty/inspect/service/RuleService.java
+4
-4
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+59
-48
没有找到文件。
src/main/java/com/zjty/inspect/aop/AopIntercept.java
浏览文件 @
70da9d0a
...
@@ -32,7 +32,7 @@ public class AopIntercept {
...
@@ -32,7 +32,7 @@ public class AopIntercept {
this
.
user
=
user
;
this
.
user
=
user
;
}
}
@Pointcut
(
"
execution(* com.zjty.inspect.inspect.Inspector.inspect(..)
)"
)
@Pointcut
(
"
@annotation(com.zjty.inspect.aop.AuthAnnotation
)"
)
public
void
doPointCut
()
{
public
void
doPointCut
()
{
}
}
...
...
src/main/java/com/zjty/inspect/controller/RuleController.java
浏览文件 @
70da9d0a
...
@@ -39,7 +39,7 @@ public class RuleController {
...
@@ -39,7 +39,7 @@ public class RuleController {
@PostMapping
@PostMapping
@ApiOperation
(
"新增规则"
)
@ApiOperation
(
"新增规则"
)
public
ResponseEntity
rule
(
@RequestBody
Rule
rule
){
public
ResponseEntity
rule
(
@RequestBody
Rule
rule
){
Rule
rule1
=
ruleService
.
addRulePlu
g
s
(
rule
);
Rule
rule1
=
ruleService
.
addRulePlus
(
rule
);
if
(
rule1
!=
null
){
if
(
rule1
!=
null
){
return
ResponseEntity
.
ok
(
rule1
);
return
ResponseEntity
.
ok
(
rule1
);
}
}
...
@@ -53,7 +53,7 @@ public class RuleController {
...
@@ -53,7 +53,7 @@ public class RuleController {
@PostMapping
(
value
=
"/update"
)
@PostMapping
(
value
=
"/update"
)
@ApiOperation
(
"修改规则"
)
@ApiOperation
(
"修改规则"
)
public
ResponseEntity
update
(
@RequestBody
Rule
rule
){
public
ResponseEntity
update
(
@RequestBody
Rule
rule
){
ruleService
.
upRulePlu
g
s
(
rule
);
ruleService
.
upRulePlus
(
rule
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
/**
/**
...
@@ -64,7 +64,7 @@ public class RuleController {
...
@@ -64,7 +64,7 @@ public class RuleController {
@ApiOperation
(
"根据数据封装删除规则"
)
@ApiOperation
(
"根据数据封装删除规则"
)
@DeleteMapping
@DeleteMapping
public
ResponseEntity
deleteByQo
(
@RequestBody
String
id
){
public
ResponseEntity
deleteByQo
(
@RequestBody
String
id
){
ruleService
.
deleteRulePlu
g
s
(
id
);
ruleService
.
deleteRulePlus
(
id
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
...
...
src/main/java/com/zjty/inspect/service/RuleService.java
浏览文件 @
70da9d0a
...
@@ -17,8 +17,8 @@ public interface RuleService {
...
@@ -17,8 +17,8 @@ public interface RuleService {
* @param ruleQo 规则封装类
* @param ruleQo 规则封装类
*/
*/
public
void
addRule
(
RuleQo
ruleQo
);
public
void
addRule
(
RuleQo
ruleQo
);
public
Rule
addRulePlu
g
s
(
Rule
rule
);
public
Rule
addRulePlus
(
Rule
rule
);
public
void
addListRulePlu
g
s
(
List
<
Rule
>
rules
);
public
void
addListRulePlus
(
List
<
Rule
>
rules
);
public
void
addRule
(
List
<
Rule
>
rules
);
public
void
addRule
(
List
<
Rule
>
rules
);
/**
/**
...
@@ -26,14 +26,14 @@ public interface RuleService {
...
@@ -26,14 +26,14 @@ public interface RuleService {
* @param ruleQo 规则封装类
* @param ruleQo 规则封装类
*/
*/
public
void
upRule
(
RuleQo
ruleQo
);
public
void
upRule
(
RuleQo
ruleQo
);
public
void
upRulePlu
g
s
(
Rule
rule
);
public
void
upRulePlus
(
Rule
rule
);
public
String
exportData
();
public
String
exportData
();
/**
/**
* 删除规则
* 删除规则
* @param ruleQo 规则封装类
* @param ruleQo 规则封装类
*/
*/
public
void
deleteRule
(
RuleQo
ruleQo
);
public
void
deleteRule
(
RuleQo
ruleQo
);
public
void
deleteRulePlu
g
s
(
String
id
);
public
void
deleteRulePlus
(
String
id
);
/**
/**
* 查询所有规则
* 查询所有规则
...
...
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
浏览文件 @
70da9d0a
...
@@ -56,16 +56,16 @@ public class RuleServiceImpl implements RuleService {
...
@@ -56,16 +56,16 @@ public class RuleServiceImpl implements RuleService {
private
RuleCollectionDao
ruleCollectionDao
;
private
RuleCollectionDao
ruleCollectionDao
;
public
List
<
Rule
>
mcjAllRule
(){
public
List
<
Rule
>
mcjAllRule
()
{
List
<
Rule
>
rules
=
ruleDao
.
findAll
();
List
<
Rule
>
rules
=
ruleDao
.
findAll
();
List
<
Rule
>
ruleList
=
new
ArrayList
<>();
List
<
Rule
>
ruleList
=
new
ArrayList
<>();
if
(
rules
!=
null
&&
rules
.
size
()>
0
)
{
if
(
rules
!=
null
&&
rules
.
size
()
>
0
)
{
for
(
Rule
rule
:
rules
)
{
for
(
Rule
rule
:
rules
)
{
String
suffix
=
rule
.
getSuffix
();
String
suffix
=
rule
.
getSuffix
();
String
[]
split
=
suffix
.
split
(
","
);
String
[]
split
=
suffix
.
split
(
","
);
for
(
String
s
:
split
)
{
for
(
String
s
:
split
)
{
Rule
rule1
=
new
Rule
();
Rule
rule1
=
new
Rule
();
BeanUtils
.
copyProperties
(
rule
,
rule1
);
BeanUtils
.
copyProperties
(
rule
,
rule1
);
rule1
.
setSuffix
(
s
);
rule1
.
setSuffix
(
s
);
ruleList
.
add
(
rule1
);
ruleList
.
add
(
rule1
);
}
}
...
@@ -73,18 +73,21 @@ public class RuleServiceImpl implements RuleService {
...
@@ -73,18 +73,21 @@ public class RuleServiceImpl implements RuleService {
}
}
return
ruleList
;
return
ruleList
;
}
}
public
Rule
addRulePlugs
(
Rule
rule
){
if
(
StringUtils
.
isEmpty
(
rule
.
getTarget
())){
@Override
public
Rule
addRulePlus
(
Rule
rule
)
{
if
(
StringUtils
.
isEmpty
(
rule
.
getTarget
()))
{
return
null
;
return
null
;
}
}
Rule
rule1
=
ruleDao
.
findByTarget
(
rule
.
getTarget
());
Rule
rule1
=
ruleDao
.
findByTarget
(
rule
.
getTarget
());
if
(
rule1
==
null
)
{
if
(
rule1
==
null
)
{
rule
.
setId
(
UUIDUtil
.
getUUID
());
rule
.
setId
(
UUIDUtil
.
getUUID
());
Rule
save
=
ruleDao
.
save
(
rule
);
Rule
save
=
ruleDao
.
save
(
rule
);
return
save
;
return
save
;
}
}
return
null
;
return
null
;
}
}
/**
/**
* 新增规则
* 新增规则
*
*
...
@@ -94,8 +97,8 @@ public class RuleServiceImpl implements RuleService {
...
@@ -94,8 +97,8 @@ public class RuleServiceImpl implements RuleService {
public
void
addRule
(
RuleQo
ruleQo
)
{
public
void
addRule
(
RuleQo
ruleQo
)
{
List
<
String
>
suffixes
=
ruleQo
.
getSuffix
();
List
<
String
>
suffixes
=
ruleQo
.
getSuffix
();
for
(
String
suffix
:
suffixes
)
{
for
(
String
suffix
:
suffixes
)
{
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
ruleQo
.
getTarget
(),
suffix
,
ruleQo
.
getTechnologyId
());
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
ruleQo
.
getTarget
(),
suffix
,
ruleQo
.
getTechnologyId
());
if
(
rule1
!=
null
&&
rule1
.
size
()>
0
)
{
if
(
rule1
!=
null
&&
rule1
.
size
()
>
0
)
{
continue
;
continue
;
}
}
Rule
rule
=
new
Rule
();
Rule
rule
=
new
Rule
();
...
@@ -110,11 +113,12 @@ public class RuleServiceImpl implements RuleService {
...
@@ -110,11 +113,12 @@ public class RuleServiceImpl implements RuleService {
ruleCollectionDao
.
save
(
ruleCollection
);
ruleCollectionDao
.
save
(
ruleCollection
);
}
}
public
void
saveRule
(
Rule
rule
)
{
public
void
saveRule
(
Rule
rule
)
{
String
suffix
=
rule
.
getSuffix
();
String
suffix
=
rule
.
getSuffix
();
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
rule
.
getTarget
(),
suffix
,
rule
.
getTechnologyId
());
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
rule
.
getTarget
(),
suffix
,
rule
.
getTechnologyId
());
if
(
rule1
!=
null
&&
rule1
.
size
()>
0
)
{
if
(
rule1
!=
null
&&
rule1
.
size
()
>
0
)
{
if
(
rule1
.
size
()>
1
)
{
if
(
rule1
.
size
()
>
1
)
{
for
(
int
i
=
1
;
i
<
rule1
.
size
();
i
++)
{
for
(
int
i
=
1
;
i
<
rule1
.
size
();
i
++)
{
ruleDao
.
deleteById
(
rule1
.
get
(
i
).
getId
());
ruleDao
.
deleteById
(
rule1
.
get
(
i
).
getId
());
}
}
...
@@ -123,12 +127,15 @@ public class RuleServiceImpl implements RuleService {
...
@@ -123,12 +127,15 @@ public class RuleServiceImpl implements RuleService {
}
}
ruleDao
.
save
(
rule
);
ruleDao
.
save
(
rule
);
}
}
//批量添加
//批量添加
public
void
addListRulePlugs
(
List
<
Rule
>
rules
){
@Override
public
void
addListRulePlus
(
List
<
Rule
>
rules
)
{
for
(
Rule
rule
:
rules
)
{
for
(
Rule
rule
:
rules
)
{
addRulePlu
g
s
(
rule
);
addRulePlus
(
rule
);
}
}
}
}
@Override
@Override
public
void
addRule
(
List
<
Rule
>
rules
)
{
public
void
addRule
(
List
<
Rule
>
rules
)
{
ruleDao
.
saveAll
(
rules
);
ruleDao
.
saveAll
(
rules
);
...
@@ -159,7 +166,6 @@ public class RuleServiceImpl implements RuleService {
...
@@ -159,7 +166,6 @@ public class RuleServiceImpl implements RuleService {
}
}
/**
/**
* 动态条件构建
* 动态条件构建
*
*
...
@@ -198,23 +204,24 @@ public class RuleServiceImpl implements RuleService {
...
@@ -198,23 +204,24 @@ public class RuleServiceImpl implements RuleService {
for
(
Rule
rule
:
rules
)
{
for
(
Rule
rule
:
rules
)
{
ruleDao
.
deleteById
(
rule
.
getId
());
ruleDao
.
deleteById
(
rule
.
getId
());
}
}
if
(
ruleCollection
!=
null
)
{
if
(
ruleCollection
!=
null
)
{
ruleCollectionDao
.
deleteById
(
ruleCollection
.
getId
());
ruleCollectionDao
.
deleteById
(
ruleCollection
.
getId
());
}
}
addRule
(
ruleQo
);
addRule
(
ruleQo
);
}
}
@Override
@Override
public
void
upRulePlu
g
s
(
Rule
rule
)
{
public
void
upRulePlus
(
Rule
rule
)
{
Rule
rule1
=
ruleDao
.
findByTargetAndIdNot
(
rule
.
getTarget
(),
rule
.
getId
());
Rule
rule1
=
ruleDao
.
findByTargetAndIdNot
(
rule
.
getTarget
(),
rule
.
getId
());
if
(
rule1
==
null
)
{
if
(
rule1
==
null
)
{
ruleDao
.
save
(
rule
);
ruleDao
.
save
(
rule
);
}
else
{
}
else
{
ruleDao
.
deleteById
(
rule
.
getId
());
ruleDao
.
deleteById
(
rule
.
getId
());
}
}
}
}
public
void
deleteRulePlugs
(
String
id
){
@Override
public
void
deleteRulePlus
(
String
id
)
{
ruleDao
.
deleteById
(
id
);
ruleDao
.
deleteById
(
id
);
}
}
...
@@ -227,7 +234,7 @@ public class RuleServiceImpl implements RuleService {
...
@@ -227,7 +234,7 @@ public class RuleServiceImpl implements RuleService {
ruleDao
.
deleteById
(
rule
.
getId
());
ruleDao
.
deleteById
(
rule
.
getId
());
}
}
RuleCollection
ruleCollection
=
ruleCollectionDao
.
findAllByTechnologyIdEqualsAndTargetEquals
(
ruleQo
.
getTechnologyId
(),
ruleQo
.
getTarget
());
RuleCollection
ruleCollection
=
ruleCollectionDao
.
findAllByTechnologyIdEqualsAndTargetEquals
(
ruleQo
.
getTechnologyId
(),
ruleQo
.
getTarget
());
if
(
ruleCollection
!=
null
)
{
if
(
ruleCollection
!=
null
)
{
ruleCollectionDao
.
deleteById
(
ruleCollection
.
getId
());
ruleCollectionDao
.
deleteById
(
ruleCollection
.
getId
());
}
}
...
@@ -239,8 +246,9 @@ public class RuleServiceImpl implements RuleService {
...
@@ -239,8 +246,9 @@ public class RuleServiceImpl implements RuleService {
* target:xx,suffix:js:tech:gjfgj
* target:xx,suffix:js:tech:gjfgj
* target:xx,suffix:html:tech:gjfgj
* target:xx,suffix:html:tech:gjfgj
* target:xx,suffix:css:tech:gjfgj
* target:xx,suffix:css:tech:gjfgj
*
*
<p>
* target:xx,suffix:html,css,js:tech:gjfgj
* target:xx,suffix:html,css,js:tech:gjfgj
*
* @return RuleVoList
* @return RuleVoList
*/
*/
@Override
@Override
...
@@ -260,7 +268,7 @@ public class RuleServiceImpl implements RuleService {
...
@@ -260,7 +268,7 @@ public class RuleServiceImpl implements RuleService {
return
rules
;
return
rules
;
}
}
private
RuleCollection
dataQo2RuleCollection
(
RuleQo
ruleQo
){
private
RuleCollection
dataQo2RuleCollection
(
RuleQo
ruleQo
)
{
RuleCollection
ruleCollection
=
new
RuleCollection
();
RuleCollection
ruleCollection
=
new
RuleCollection
();
ruleCollection
.
setTechnologyName
(
ruleQo
.
getTechnologyName
());
ruleCollection
.
setTechnologyName
(
ruleQo
.
getTechnologyName
());
ruleCollection
.
setTechnologyId
(
ruleQo
.
getTechnologyId
());
ruleCollection
.
setTechnologyId
(
ruleQo
.
getTechnologyId
());
...
@@ -268,9 +276,9 @@ public class RuleServiceImpl implements RuleService {
...
@@ -268,9 +276,9 @@ public class RuleServiceImpl implements RuleService {
ruleCollection
.
setId
(
UUIDUtil
.
getUUID
());
ruleCollection
.
setId
(
UUIDUtil
.
getUUID
());
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
String
suffix
:
ruleQo
.
getSuffix
())
{
for
(
String
suffix
:
ruleQo
.
getSuffix
())
{
if
(
stringBuilder
.
length
()==
0
)
{
if
(
stringBuilder
.
length
()
==
0
)
{
stringBuilder
.
append
(
suffix
);
stringBuilder
.
append
(
suffix
);
}
else
{
}
else
{
stringBuilder
.
append
(
","
).
append
(
suffix
);
stringBuilder
.
append
(
","
).
append
(
suffix
);
}
}
}
}
...
@@ -278,19 +286,19 @@ public class RuleServiceImpl implements RuleService {
...
@@ -278,19 +286,19 @@ public class RuleServiceImpl implements RuleService {
return
ruleCollection
;
return
ruleCollection
;
}
}
private
List
<
RuleCollection
>
dataList2RuleCollection
(
List
<
Rule
>
rules
){
private
List
<
RuleCollection
>
dataList2RuleCollection
(
List
<
Rule
>
rules
)
{
ArrayList
<
RuleCollection
>
ruleCollections
=
new
ArrayList
<>();
ArrayList
<
RuleCollection
>
ruleCollections
=
new
ArrayList
<>();
HashMap
<
String
,
ArrayList
<
String
>>
map
=
new
HashMap
<>();
HashMap
<
String
,
ArrayList
<
String
>>
map
=
new
HashMap
<>();
HashMap
<
String
,
Rule
>
ruleMap
=
new
HashMap
<>();
HashMap
<
String
,
Rule
>
ruleMap
=
new
HashMap
<>();
for
(
Rule
rule
:
rules
)
{
for
(
Rule
rule
:
rules
)
{
ruleMap
.
put
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
(),
rule
);
ruleMap
.
put
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
(),
rule
);
if
(
map
.
containsKey
(
rule
.
getTarget
()+
":"
+
rule
.
getTechnologyId
()))
{
if
(
map
.
containsKey
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
()))
{
ArrayList
<
String
>
suffix
=
map
.
get
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
());
ArrayList
<
String
>
suffix
=
map
.
get
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
());
suffix
.
add
(
rule
.
getSuffix
());
suffix
.
add
(
rule
.
getSuffix
());
}
else
{
}
else
{
ArrayList
<
String
>
suffix
=
new
ArrayList
<>();
ArrayList
<
String
>
suffix
=
new
ArrayList
<>();
suffix
.
add
(
rule
.
getSuffix
());
suffix
.
add
(
rule
.
getSuffix
());
map
.
put
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
(),
suffix
);
map
.
put
(
rule
.
getTarget
()
+
":"
+
rule
.
getTechnologyId
(),
suffix
);
}
}
}
}
...
@@ -303,9 +311,9 @@ public class RuleServiceImpl implements RuleService {
...
@@ -303,9 +311,9 @@ public class RuleServiceImpl implements RuleService {
ruleCollection
.
setId
(
UUIDUtil
.
getUUID
());
ruleCollection
.
setId
(
UUIDUtil
.
getUUID
());
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
String
suffix
:
map
.
get
(
target
))
{
for
(
String
suffix
:
map
.
get
(
target
))
{
if
(
stringBuilder
.
length
()==
0
)
{
if
(
stringBuilder
.
length
()
==
0
)
{
stringBuilder
.
append
(
suffix
);
stringBuilder
.
append
(
suffix
);
}
else
{
}
else
{
stringBuilder
.
append
(
","
).
append
(
suffix
);
stringBuilder
.
append
(
","
).
append
(
suffix
);
}
}
}
}
...
@@ -315,33 +323,35 @@ public class RuleServiceImpl implements RuleService {
...
@@ -315,33 +323,35 @@ public class RuleServiceImpl implements RuleService {
return
ruleCollections
;
return
ruleCollections
;
}
}
public
String
exportData
(){
@Override
SyncData
syncData
=
new
SyncData
();
public
String
exportData
()
{
List
<
TechnologySyn
>
technologySyns
=
new
ArrayList
<>();
SyncData
syncData
=
new
SyncData
();
List
<
TechnologySyn
>
technologySyns
=
new
ArrayList
<>();
//1.生成数据
//1.生成数据
List
<
Technology
>
technologies
=
technologyService
.
findAllTechnology
();
List
<
Technology
>
technologies
=
technologyService
.
findAllTechnology
();
for
(
Technology
technology
:
technologies
)
{
for
(
Technology
technology
:
technologies
)
{
TechnologySyn
technologySyn
=
new
TechnologySyn
();
TechnologySyn
technologySyn
=
new
TechnologySyn
();
BeanUtils
.
copyProperties
(
technology
,
technologySyn
);
BeanUtils
.
copyProperties
(
technology
,
technologySyn
);
List
<
Rule
>
rules
=
ruleDao
.
findAllByTechnologyId
(
technology
.
getId
());
List
<
Rule
>
rules
=
ruleDao
.
findAllByTechnologyId
(
technology
.
getId
());
technologySyn
.
setRules
(
rules
);
technologySyn
.
setRules
(
rules
);
technologySyns
.
add
(
technologySyn
);
technologySyns
.
add
(
technologySyn
);
}
}
syncData
.
setTechnologies
(
technologySyns
);
syncData
.
setTechnologies
(
technologySyns
);
String
s
=
JSON
.
toJSONString
(
syncData
);
String
s
=
JSON
.
toJSONString
(
syncData
);
String
path
=
System
.
getProperty
(
"user.dir"
)+
File
.
separator
+
"inspect"
+
File
.
separator
+
"inspect.txt"
;
String
path
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"inspect"
+
File
.
separator
+
"inspect.txt"
;
//2.生成json文件
//2.生成json文件
FileUtil
.
write
(
s
,
path
);
FileUtil
.
write
(
s
,
path
);
return
path
;
return
path
;
}
}
@Override
@Override
public
void
importRules
(
MultipartFile
file
)
{
public
void
importRules
(
MultipartFile
file
)
{
if
(
file
.
isEmpty
())
{
if
(
file
.
isEmpty
())
{
return
;
return
;
}
}
String
fileName
=
file
.
getOriginalFilename
();
String
fileName
=
file
.
getOriginalFilename
();
String
fileType
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
));
String
fileType
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
));
File
dest
=
new
File
(
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"inspect"
+
File
.
separator
+
UUIDUtil
.
getUUID
()+
File
.
separator
+
fileType
);
File
dest
=
new
File
(
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"inspect"
+
File
.
separator
+
UUIDUtil
.
getUUID
()
+
File
.
separator
+
fileType
);
if
(!
dest
.
getParentFile
().
exists
())
{
if
(!
dest
.
getParentFile
().
exists
())
{
dest
.
getParentFile
().
mkdirs
();
dest
.
getParentFile
().
mkdirs
();
}
}
...
@@ -353,16 +363,16 @@ public class RuleServiceImpl implements RuleService {
...
@@ -353,16 +363,16 @@ public class RuleServiceImpl implements RuleService {
//1.导入json文件
//1.导入json文件
String
s
=
readTxt
(
dest
.
getAbsolutePath
());
String
s
=
readTxt
(
dest
.
getAbsolutePath
());
System
.
out
.
println
(
s
);
System
.
out
.
println
(
s
);
if
(!
StringUtils
.
isEmpty
(
s
))
{
if
(!
StringUtils
.
isEmpty
(
s
))
{
//2.清洗规则数据
//2.清洗规则数据
//3.将数据添加到数据库中
//3.将数据添加到数据库中
SyncData
syncData
=
JSON
.
parseObject
(
s
,
SyncData
.
class
);
SyncData
syncData
=
JSON
.
parseObject
(
s
,
SyncData
.
class
);
List
<
TechnologySyn
>
technologies
=
syncData
.
getTechnologies
();
List
<
TechnologySyn
>
technologies
=
syncData
.
getTechnologies
();
if
(
technologies
!=
null
&&
technologies
.
size
()>
0
)
{
if
(
technologies
!=
null
&&
technologies
.
size
()
>
0
)
{
for
(
TechnologySyn
technology
:
technologies
)
{
for
(
TechnologySyn
technology
:
technologies
)
{
List
<
Rule
>
rules
=
technology
.
getRules
();
List
<
Rule
>
rules
=
technology
.
getRules
();
if
(
rules
!=
null
&&
rules
.
size
()>
0
)
{
if
(
rules
!=
null
&&
rules
.
size
()
>
0
)
{
for
(
Rule
rule
:
rules
)
{
for
(
Rule
rule
:
rules
)
{
saveRule
(
rule
);
saveRule
(
rule
);
}
}
...
@@ -377,7 +387,7 @@ public class RuleServiceImpl implements RuleService {
...
@@ -377,7 +387,7 @@ public class RuleServiceImpl implements RuleService {
}
}
public
String
readTxt
(
String
filePath
){
public
String
readTxt
(
String
filePath
)
{
try
{
try
{
String
encoding
=
"UTF-8"
;
String
encoding
=
"UTF-8"
;
File
file
=
new
File
(
filePath
);
File
file
=
new
File
(
filePath
);
...
@@ -403,7 +413,8 @@ public class RuleServiceImpl implements RuleService {
...
@@ -403,7 +413,8 @@ public class RuleServiceImpl implements RuleService {
}
}
return
null
;
return
null
;
}
}
public
void
syncData
(){
public
void
syncData
()
{
//1.导入json数据
//1.导入json数据
//2.清空数据库
//2.清空数据库
//3.导入到标准库
//3.导入到标准库
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论