Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
7ce3fe83
提交
7ce3fe83
authored
4月 08, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into mcj-dev
上级
960ffcd9
90f3ecf6
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
94 行增加
和
18 行删除
+94
-18
MvcConfig.java
src/main/java/com/zjty/inspect/config/MvcConfig.java
+16
-0
EvaluationController.java
...ava/com/zjty/inspect/controller/EvaluationController.java
+9
-3
RuleDao.java
src/main/java/com/zjty/inspect/dao/RuleDao.java
+1
-1
TechnologyService.java
...main/java/com/zjty/inspect/service/TechnologyService.java
+1
-0
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+41
-8
TechnologyServiceImpl.java
.../com/zjty/inspect/service/impl/TechnologyServiceImpl.java
+13
-0
FileUtil.java
src/main/java/com/zjty/inspect/utils/FileUtil.java
+12
-5
application.properties
src/main/resources/application.properties
+1
-1
没有找到文件。
src/main/java/com/zjty/inspect/config/MvcConfig.java
浏览文件 @
7ce3fe83
package
com
.
zjty
.
inspect
.
config
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
public
class
MvcConfig
extends
WebMvcConfigurationSupport
{
@Autowired
...
...
@@ -26,4 +32,14 @@ public class MvcConfig extends WebMvcConfigurationSupport {
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
super
.
configureMessageConverters
(
converters
);
FastJsonHttpMessageConverter
fastConverter
=
new
FastJsonHttpMessageConverter
();
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
PrettyFormat
);
fastConverter
.
setFastJsonConfig
(
fastJsonConfig
);
converters
.
add
(
fastConverter
);
}
}
src/main/java/com/zjty/inspect/controller/EvaluationController.java
浏览文件 @
7ce3fe83
package
com
.
zjty
.
inspect
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.inspect.entity.AssessmentReport
;
import
com.zjty.inspect.entity.Evaluation
;
import
com.zjty.inspect.entity.PageResult
;
import
com.zjty.inspect.entity.Reform
;
import
com.zjty.inspect.service.EvaluationService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -39,13 +42,15 @@ public class EvaluationController {
if
(
StringUtils
.
isEmpty
(
id
)||
id
.
equals
(
"null"
)){
Evaluation
e
=
evaluationService
.
findByName
(
name
);
if
(
e
!=
null
){
return
ResponseEntity
.
ok
(
e
.
getOutEva
());
AssessmentReport
assessmentReport
=
JSON
.
parseObject
(
e
.
getOutEva
(),
AssessmentReport
.
class
);
return
ResponseEntity
.
ok
(
assessmentReport
);
}
return
ResponseEntity
.
ok
(
null
);
}
Evaluation
evaluation
=
evaluationService
.
findById
(
id
);
if
(
evaluation
!=
null
){
return
ResponseEntity
.
ok
(
evaluation
.
getOutEva
());
AssessmentReport
assessmentReport
=
JSON
.
parseObject
(
evaluation
.
getOutEva
(),
AssessmentReport
.
class
);
return
ResponseEntity
.
ok
(
assessmentReport
);
}
return
ResponseEntity
.
ok
(
null
);
}
...
...
@@ -54,7 +59,8 @@ public class EvaluationController {
public
ResponseEntity
getInName
(
@PathVariable
String
name
)
{
Evaluation
evaluation
=
evaluationService
.
findById
(
name
);
if
(
evaluation
!=
null
){
return
ResponseEntity
.
ok
(
evaluation
.
getInEva
());
Reform
reform
=
JSON
.
parseObject
(
evaluation
.
getInEva
(),
Reform
.
class
);
return
ResponseEntity
.
ok
(
reform
);
}
return
ResponseEntity
.
ok
(
null
);
}
...
...
src/main/java/com/zjty/inspect/dao/RuleDao.java
浏览文件 @
7ce3fe83
...
...
@@ -28,7 +28,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
Rule
findByTarget
(
String
target
);
Rule
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
String
target
,
String
suffix
,
String
technologyId
);
List
<
Rule
>
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
String
target
,
String
suffix
,
String
technologyId
);
/**
* 根据技术id查询规则
...
...
src/main/java/com/zjty/inspect/service/TechnologyService.java
浏览文件 @
7ce3fe83
...
...
@@ -17,6 +17,7 @@ public interface TechnologyService {
*/
public
void
addAdvice
(
TechnologyQo
technologyQo
);
public
void
add
(
Technology
technology
);
public
void
addTech
(
Technology
technology
);
/**
* 查询所有技术
...
...
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
浏览文件 @
7ce3fe83
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zjty.inspect.dao.RuleCollectionDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.entity.*
;
...
...
@@ -17,6 +18,7 @@ import org.springframework.data.jpa.domain.Specification;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.persistence.criteria.Predicate
;
...
...
@@ -57,8 +59,8 @@ public class RuleServiceImpl implements RuleService {
public
void
addRule
(
RuleQo
ruleQo
)
{
List
<
String
>
suffixes
=
ruleQo
.
getSuffix
();
for
(
String
suffix
:
suffixes
)
{
Rule
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
ruleQo
.
getTarget
(),
suffix
,
ruleQo
.
getTechnologyId
());
if
(
rule1
!=
null
)
{
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
ruleQo
.
getTarget
(),
suffix
,
ruleQo
.
getTechnologyId
());
if
(
rule1
!=
null
&&
rule1
.
size
()>
0
)
{
continue
;
}
Rule
rule
=
new
Rule
();
...
...
@@ -73,7 +75,19 @@ public class RuleServiceImpl implements RuleService {
ruleCollectionDao
.
save
(
ruleCollection
);
}
public
void
saveRule
(
Rule
rule
)
{
String
suffix
=
rule
.
getSuffix
();
List
<
Rule
>
rule1
=
ruleDao
.
findByTargetAndSuffixEqualsAndTechnologyIdEquals
(
rule
.
getTarget
(),
suffix
,
rule
.
getTechnologyId
());
if
(
rule1
!=
null
&&
rule1
.
size
()>
0
)
{
if
(
rule1
.
size
()>
1
){
for
(
int
i
=
1
;
i
<
rule1
.
size
();
i
++)
{
ruleDao
.
deleteById
(
rule1
.
get
(
i
).
getId
());
}
}
return
;
}
ruleDao
.
save
(
rule
);
}
@Override
public
void
addRule
(
List
<
Rule
>
rules
)
{
ruleDao
.
saveAll
(
rules
);
...
...
@@ -257,7 +271,7 @@ public class RuleServiceImpl implements RuleService {
}
syncData
.
setTechnologies
(
technologySyns
);
String
s
=
JSON
.
toJSONString
(
syncData
);
String
path
=
System
.
getProperty
(
"user.dir"
)+
File
.
separator
+
"inspect"
+
File
.
separator
+
"
评测微服务数据
.txt"
;
String
path
=
System
.
getProperty
(
"user.dir"
)+
File
.
separator
+
"inspect"
+
File
.
separator
+
"
inspect
.txt"
;
//2.生成json文件
FileUtil
.
write
(
s
,
path
);
return
path
;
...
...
@@ -278,12 +292,31 @@ public class RuleServiceImpl implements RuleService {
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
//1.导入json文件
String
s
=
readTxt
(
dest
.
getAbsolutePath
());
System
.
out
.
println
(
s
);
//1.导入json文件
//2.清洗规则数据
//3.将数据添加到数据库中
//4.生成json文件
if
(!
StringUtils
.
isEmpty
(
s
)){
//2.清洗规则数据
//3.将数据添加到数据库中
SyncData
syncData
=
JSON
.
parseObject
(
s
,
SyncData
.
class
);
List
<
TechnologySyn
>
technologies
=
syncData
.
getTechnologies
();
if
(
technologies
!=
null
&&
technologies
.
size
()>
0
)
{
for
(
TechnologySyn
technology
:
technologies
)
{
List
<
Rule
>
rules
=
technology
.
getRules
();
if
(
rules
!=
null
&&
rules
.
size
()>
0
){
for
(
Rule
rule
:
rules
)
{
saveRule
(
rule
);
}
}
}
ruleCollectionDao
.
deleteAll
();
List
<
Rule
>
all
=
ruleDao
.
findAll
();
List
<
RuleCollection
>
ruleCollections
=
dataList2RuleCollection
(
all
);
ruleCollectionDao
.
saveAll
(
ruleCollections
);
}
}
}
public
String
readTxt
(
String
filePath
){
...
...
src/main/java/com/zjty/inspect/service/impl/TechnologyServiceImpl.java
浏览文件 @
7ce3fe83
...
...
@@ -13,6 +13,7 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StringUtils
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
...
...
@@ -75,6 +76,18 @@ public class TechnologyServiceImpl implements TechnologyService {
technologyDao
.
save
(
technology
);
}
@Override
public
void
addTech
(
Technology
technology
)
{
Optional
<
Technology
>
optional
=
technologyDao
.
findById
(
technology
.
getId
());
if
(
optional
.
isPresent
()){
Technology
te
=
optional
.
get
();
if
(
te
.
getTechnologyName
().
equals
(
technology
.
getTechnologyName
())){
return
;
}
}
}
@Override
public
List
<
Technology
>
findAllTechnology
()
{
return
technologyDao
.
findAll
();
...
...
src/main/java/com/zjty/inspect/utils/FileUtil.java
浏览文件 @
7ce3fe83
...
...
@@ -152,13 +152,20 @@ public class FileUtil {
}
}
File
file
=
new
File
(
path
);
if
(!
file
.
exists
())
{
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
if
(
file
.
exists
()){
file
.
delete
();
}
if
(!
file
.
getParentFile
().
exists
())
{
boolean
mkdir
=
file
.
getParentFile
().
mkdirs
();
if
(!
mkdir
)
{
throw
new
RuntimeException
(
"创建目标文件所在目录失败!"
);
}
}
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
file
;
}
...
...
src/main/resources/application.properties
浏览文件 @
7ce3fe83
...
...
@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/
# mysql\u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:mysql://192.168.1.249:3306/bservice?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.url
=
jdbc:mysql://
120.55.57.35
:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.url
=
jdbc:mysql://
localhost
:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.username
=
root
spring.datasource.password
=
root
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论