Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
e69a771b
提交
e69a771b
authored
4月 03, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
评估报告管理页面修改v1.0.4
上级
17880927
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
184 行增加
和
2 行删除
+184
-2
RuleController.java
...main/java/com/zjty/inspect/controller/RuleController.java
+18
-0
SyncData.java
src/main/java/com/zjty/inspect/entity/SyncData.java
+9
-0
TechnologySyn.java
src/main/java/com/zjty/inspect/entity/TechnologySyn.java
+63
-0
RuleService.java
src/main/java/com/zjty/inspect/service/RuleService.java
+4
-1
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+89
-0
application.properties
src/main/resources/application.properties
+1
-1
没有找到文件。
src/main/java/com/zjty/inspect/controller/RuleController.java
浏览文件 @
e69a771b
...
@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
...
@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -100,4 +101,21 @@ public class RuleController {
...
@@ -100,4 +101,21 @@ public class RuleController {
CustomPage
<
RuleCollection
>
search
=
ruleService
.
findSearch
(
searchMap
,
page
,
size
);
CustomPage
<
RuleCollection
>
search
=
ruleService
.
findSearch
(
searchMap
,
page
,
size
);
return
ResponseEntity
.
ok
(
search
);
return
ResponseEntity
.
ok
(
search
);
}
}
/**
* 导出所有规则
* @return 规则
*/
@ApiOperation
(
"导出所有规则"
)
@GetMapping
(
"/export"
)
public
ResponseEntity
exportAllRules
(){
String
path
=
ruleService
.
exportData
();
return
ResponseEntity
.
ok
(
path
);
}
@PostMapping
(
"/importRules"
)
@ApiOperation
(
"导入所有规则"
)
public
ResponseEntity
importRules
(
@RequestParam
(
"file"
)
MultipartFile
file
){
ruleService
.
importRules
(
file
);
return
null
;
}
}
}
src/main/java/com/zjty/inspect/entity/SyncData.java
0 → 100644
浏览文件 @
e69a771b
package
com
.
zjty
.
inspect
.
entity
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
SyncData
{
private
List
<
TechnologySyn
>
technologies
;
}
src/main/java/com/zjty/inspect/entity/TechnologySyn.java
0 → 100644
浏览文件 @
e69a771b
package
com
.
zjty
.
inspect
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.annotations.Generated
;
import
org.hibernate.annotations.GenerationTime
;
import
javax.persistence.Column
;
import
java.sql.Timestamp
;
import
java.util.List
;
@Data
public
class
TechnologySyn
{
private
String
id
;
/**
* 技术名称
*/
private
String
technologyName
;
/**
* 技术建议
*/
private
String
advice
;
/**
* 金额(万元)
*/
@ApiModelProperty
(
value
=
"金额"
,
example
=
"123"
)
private
Integer
fund
;
/**
* 1:支持
* 2:不支持
* 3:未知
* 4:不完全支持
* 5:优化
*/
@ApiModelProperty
(
value
=
"是否支持"
,
example
=
"1"
)
private
Integer
support
;
/**
* 分类id
*/
private
String
category_id
;
/**
* 技术类型
* 1:前端技术
* 2:后端技术
*/
@ApiModelProperty
(
value
=
"技术类型"
,
example
=
"2"
)
private
Integer
backOrFront
=
2
;
/**
* 数据创建时间
*/
private
Timestamp
createDate
;
/**
* 数据更新时间
*/
private
Timestamp
updateDate
;
private
List
<
Rule
>
rules
;
}
src/main/java/com/zjty/inspect/service/RuleService.java
浏览文件 @
e69a771b
...
@@ -4,6 +4,7 @@ import com.zjty.inspect.entity.CustomPage;
...
@@ -4,6 +4,7 @@ import com.zjty.inspect.entity.CustomPage;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleCollection
;
import
com.zjty.inspect.entity.RuleCollection
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleQo
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -25,7 +26,7 @@ public interface RuleService {
...
@@ -25,7 +26,7 @@ public interface RuleService {
* @param ruleQo 规则封装类
* @param ruleQo 规则封装类
*/
*/
public
void
upRule
(
RuleQo
ruleQo
);
public
void
upRule
(
RuleQo
ruleQo
);
public
String
exportData
();
/**
/**
* 删除规则
* 删除规则
* @param ruleQo 规则封装类
* @param ruleQo 规则封装类
...
@@ -49,4 +50,6 @@ public interface RuleService {
...
@@ -49,4 +50,6 @@ public interface RuleService {
CustomPage
<
RuleCollection
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
CustomPage
<
RuleCollection
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
List
<
Rule
>
findAllByTechnologyIdIn
(
List
<
String
>
technologyIds
);
List
<
Rule
>
findAllByTechnologyIdIn
(
List
<
String
>
technologyIds
);
void
importRules
(
MultipartFile
file
);
}
}
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
浏览文件 @
e69a771b
package
com
.
zjty
.
inspect
.
service
.
impl
;
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.inspect.dao.RuleCollectionDao
;
import
com.zjty.inspect.dao.RuleCollectionDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.service.RuleService
;
import
com.zjty.inspect.service.RuleService
;
import
com.zjty.inspect.service.TechnologyService
;
import
com.zjty.inspect.utils.FileUtil
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
...
@@ -13,9 +17,14 @@ import org.springframework.data.jpa.domain.Specification;
...
@@ -13,9 +17,14 @@ import org.springframework.data.jpa.domain.Specification;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
java.io.*
;
import
java.io.File
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
/**
* 规则库
* 规则库
...
@@ -34,6 +43,8 @@ public class RuleServiceImpl implements RuleService {
...
@@ -34,6 +43,8 @@ public class RuleServiceImpl implements RuleService {
@Autowired
@Autowired
private
RuleDao
ruleDao
;
private
RuleDao
ruleDao
;
@Autowired
private
TechnologyService
technologyService
;
@Autowired
@Autowired
private
RuleCollectionDao
ruleCollectionDao
;
private
RuleCollectionDao
ruleCollectionDao
;
...
@@ -97,6 +108,8 @@ public class RuleServiceImpl implements RuleService {
...
@@ -97,6 +108,8 @@ public class RuleServiceImpl implements RuleService {
return
ruleDao
.
findAllByTechnologyIdIn
(
technologyIds
);
return
ruleDao
.
findAllByTechnologyIdIn
(
technologyIds
);
}
}
/**
/**
* 动态条件构建
* 动态条件构建
*
*
...
@@ -229,4 +242,80 @@ public class RuleServiceImpl implements RuleService {
...
@@ -229,4 +242,80 @@ public class RuleServiceImpl implements RuleService {
}
}
return
ruleCollections
;
return
ruleCollections
;
}
}
public
String
exportData
(){
SyncData
syncData
=
new
SyncData
();
List
<
TechnologySyn
>
technologySyns
=
new
ArrayList
<>();
//1.生成数据
List
<
Technology
>
technologies
=
technologyService
.
findAllTechnology
();
for
(
Technology
technology
:
technologies
)
{
TechnologySyn
technologySyn
=
new
TechnologySyn
();
BeanUtils
.
copyProperties
(
technology
,
technologySyn
);
List
<
Rule
>
rules
=
ruleDao
.
findAllByTechnologyId
(
technology
.
getId
());
technologySyn
.
setRules
(
rules
);
technologySyns
.
add
(
technologySyn
);
}
syncData
.
setTechnologies
(
technologySyns
);
String
s
=
JSON
.
toJSONString
(
syncData
);
String
path
=
System
.
getProperty
(
"user.dir"
)+
File
.
separator
+
"inspect"
+
File
.
separator
+
"评测微服务数据.txt"
;
//2.生成json文件
FileUtil
.
write
(
s
,
path
);
return
path
;
}
@Override
public
void
importRules
(
MultipartFile
file
)
{
if
(
file
.
isEmpty
())
{
return
;
}
String
fileName
=
file
.
getOriginalFilename
();
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
);
if
(!
dest
.
getParentFile
().
exists
())
{
dest
.
getParentFile
().
mkdirs
();
}
try
{
file
.
transferTo
(
dest
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
s
=
readTxt
(
dest
.
getAbsolutePath
());
System
.
out
.
println
(
s
);
//1.导入json文件
//2.清洗规则数据
//3.将数据添加到数据库中
//4.生成json文件
}
public
String
readTxt
(
String
filePath
){
try
{
String
encoding
=
"UTF-8"
;
File
file
=
new
File
(
filePath
);
if
(
file
.
isFile
()
&&
file
.
exists
())
{
// 判断文件是否存在
InputStreamReader
read
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
encoding
);
// 考虑到编码格式
BufferedReader
bufferedReader
=
new
BufferedReader
(
read
);
String
lineTxt
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
while
((
lineTxt
=
bufferedReader
.
readLine
())
!=
null
)
{
sb
.
append
(
lineTxt
);
}
String
s
=
sb
.
toString
();
read
.
close
();
return
s
;
}
else
{
System
.
out
.
println
(
"找不到指定的文件"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"读取文件内容出错"
);
e
.
printStackTrace
();
}
return
null
;
}
public
void
syncData
(){
//1.导入json数据
//2.清空数据库
//3.导入到标准库
}
}
}
src/main/resources/application.properties
浏览文件 @
e69a771b
...
@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/
...
@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/
# mysql\u6570\u636E\u5E93\u914D\u7F6E
# mysql\u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
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://192.168.1.249:3306/bservice?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.url
=
jdbc:mysql://
120.55.57.35
:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.username
=
root
spring.datasource.username
=
root
spring.datasource.password
=
root
spring.datasource.password
=
root
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论