Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
d482af48
提交
d482af48
authored
4月 21, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'lj-project' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into lj-project
上级
7abc5cd9
337aa611
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
67 行增加
和
24 行删除
+67
-24
EvaluationController.java
...ava/com/zjty/inspect/controller/EvaluationController.java
+0
-12
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+52
-9
BaseDes.java
src/main/java/com/zjty/inspect/entity/BaseDes.java
+2
-0
ServerResponse.java
src/main/java/com/zjty/inspect/entity/ServerResponse.java
+3
-1
Inspector.java
src/main/java/com/zjty/inspect/inspect/Inspector.java
+10
-1
AsyncTask.java
src/main/java/com/zjty/inspect/thread/task/AsyncTask.java
+0
-1
ExcelUtil.java
src/main/java/com/zjty/inspect/utils/ExcelUtil.java
+0
-0
WpsUtil.java
src/main/java/com/zjty/inspect/utils/WpsUtil.java
+0
-0
没有找到文件。
src/main/java/com/zjty/inspect/controller/EvaluationController.java
浏览文件 @
d482af48
...
@@ -91,18 +91,6 @@ public class EvaluationController {
...
@@ -91,18 +91,6 @@ public class EvaluationController {
return
ServerResponse
.
ok
(
null
);
return
ServerResponse
.
ok
(
null
);
}
}
@ApiOperation
(
"根据报告id查询excel输入"
)
@GetMapping
(
value
=
"/in/excel/{id}"
)
public
ServerResponse
<
List
<
ExcelDataTemp
>>
exportInName
(
@PathVariable
String
id
)
{
Evaluation
evaluation
=
evaluationService
.
findById
(
id
);
if
(
evaluation
!=
null
)
{
List
<
ExcelDataTemp
>
excelDataTemp
=
ExcelUtil
.
parseExcel2Entity
(
evaluation
);
return
ServerResponse
.
ok
(
excelDataTemp
);
}
else
{
return
ServerResponse
.
ok
(
new
ArrayList
<>());
}
}
/**
/**
* 修改评估报告
* 修改评估报告
*
*
...
...
src/main/java/com/zjty/inspect/controller/InspectController.java
浏览文件 @
d482af48
...
@@ -10,11 +10,15 @@ import com.zjty.inspect.utils.*;
...
@@ -10,11 +10,15 @@ import com.zjty.inspect.utils.*;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
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
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.io.File
;
import
java.io.File
;
import
java.util.*
;
import
java.util.*
;
...
@@ -53,6 +57,8 @@ public class InspectController {
...
@@ -53,6 +57,8 @@ public class InspectController {
//应用类型转换:大型4
//应用类型转换:大型4
private
Integer
[]
big
=
{
5
,
9
};
private
Integer
[]
big
=
{
5
,
9
};
@Value
(
"${upload.location}"
)
private
String
uploadPath
;
/**
/**
* 上传代码进行评估
* 上传代码进行评估
*
*
...
@@ -381,20 +387,58 @@ public class InspectController {
...
@@ -381,20 +387,58 @@ public class InspectController {
return
ServerResponse
.
ok
(
save
.
getId
());
return
ServerResponse
.
ok
(
save
.
getId
());
}
}
@ApiOperation
(
"大文件分片上传"
)
// @PostMapping("/chunkUpload")
@PostMapping
(
"/uploads"
)
@PostMapping
(
"/uploads"
)
private
ServerResponse
uploads
(
@RequestParam
(
value
=
"file"
)
MultipartFile
multfile
)
{
public
ServerResponse
fileChunkUpload
(
MultipartFileParam
param
,
HttpServletRequest
request
,
HttpServletResponse
response
){
try
{
// OSSInformation ossInformation = ossInformationService.queryOne();
File
file
=
FileUtil
.
saveToLocal
(
multfile
);
// String root = ossInformation.getRoot();
String
root
=
uploadPath
;
//验证文件夹规则,不能包含特殊字符
java
.
io
.
File
file
=
new
java
.
io
.
File
(
root
);
// createDirectoryQuietly(file);
System
.
out
.
println
(
"88888888888888"
);
String
path
=
file
.
getAbsolutePath
();
response
.
setContentType
(
"text/html;charset=UTF-8"
);
// response.setStatus对接前端插件
// 200, 201, 202: 当前块上传成功,不需要重传。
// 404, 415. 500, 501: 当前块上传失败,会取消整个文件上传。
// 其他状态码: 出错了,但是会自动重试上传。
String
name
=
file
.
getName
();
try
{
String
path
=
file
.
getCanonicalPath
();
/**
return
ServerResponse
.
ok
(
new
com
.
zjty
.
inspect
.
entity
.
File
(
name
,
path
));
* 判断前端Form表单格式是否支持文件上传
}
catch
(
IOException
e
)
{
*/
boolean
isMultipart
=
ServletFileUpload
.
isMultipartContent
(
request
);
if
(!
isMultipart
){
//这里是我向前端发送数据的代码,可理解为 return 数据; 具体的就不贴了
System
.
out
.
println
(
"不支持的表单格式"
);
return
ServerResponse
.
badRequest
();
}
else
{
param
.
setTaskId
(
param
.
getIdentifier
());
File
myfile
=
inspectService
.
chunkUploadByMappedByteBuffer
(
param
,
path
);
//service层
if
(
myfile
!=
null
){
String
name
=
myfile
.
getName
();
String
myPath
=
myfile
.
getCanonicalPath
();
return
ServerResponse
.
ok
(
new
com
.
zjty
.
inspect
.
entity
.
File
(
name
,
myPath
));
}
else
{
return
ServerResponse
.
ok
(
"继续断点传续!"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
ServerResponse
.
error
(
500
);
// System.out.println("上传文件失败");
// response.setStatus(415);
return
ServerResponse
.
error
(
415
,
"上传文件失败"
);
}
}
}
}
@PostMapping
(
"/gitdownload"
)
@PostMapping
(
"/gitdownload"
)
private
ServerResponse
gitDownloads
(
String
gitAddress
,
String
username
,
String
password
)
{
private
ServerResponse
gitDownloads
(
String
gitAddress
,
String
username
,
String
password
)
{
try
{
try
{
...
@@ -409,7 +453,6 @@ public class InspectController {
...
@@ -409,7 +453,6 @@ public class InspectController {
private
ServerResponse
<
Reform
>
uploadFileToInspect
(
MultipartFile
file
,
String
username
)
throws
IOException
{
private
ServerResponse
<
Reform
>
uploadFileToInspect
(
MultipartFile
file
,
String
username
)
throws
IOException
{
Reform
reform
=
ExcelUtil
.
parseExcel
(
file
.
getInputStream
(),
file
.
getOriginalFilename
());
Reform
reform
=
ExcelUtil
.
parseExcel
(
file
.
getInputStream
(),
file
.
getOriginalFilename
());
reform
.
setUsername
(
username
);
reform
.
setUsername
(
username
);
System
.
out
.
println
(
"1"
);
return
ServerResponse
.
ok
(
reform
);
return
ServerResponse
.
ok
(
reform
);
}
}
}
}
src/main/java/com/zjty/inspect/entity/BaseDes.java
浏览文件 @
d482af48
...
@@ -15,4 +15,6 @@ public class BaseDes {
...
@@ -15,4 +15,6 @@ public class BaseDes {
private
String
des
;
private
String
des
;
@ApiModelProperty
(
value
=
"版本号"
)
@ApiModelProperty
(
value
=
"版本号"
)
private
String
version
;
private
String
version
;
@ApiModelProperty
(
value
=
"是否为其他项"
)
private
Integer
other
;
}
}
src/main/java/com/zjty/inspect/entity/ServerResponse.java
浏览文件 @
d482af48
...
@@ -45,7 +45,9 @@ public class ServerResponse<T> implements Serializable {
...
@@ -45,7 +45,9 @@ public class ServerResponse<T> implements Serializable {
}
}
public
static
<
T
>
ServerResponse
error
(
int
status
,
String
data
){
return
new
ServerResponse
(
status
,
"请求失败"
,
data
);
}
public
static
<
T
>
ServerResponse
error
(
Object
data
){
public
static
<
T
>
ServerResponse
error
(
Object
data
){
return
new
ServerResponse
(
400
,
"请求失败"
,
data
);
return
new
ServerResponse
(
400
,
"请求失败"
,
data
);
}
}
...
...
src/main/java/com/zjty/inspect/inspect/Inspector.java
浏览文件 @
d482af48
...
@@ -155,7 +155,12 @@ public class Inspector {
...
@@ -155,7 +155,12 @@ public class Inspector {
//初始化成员变量
//初始化成员变量
initData
();
initData
();
//扫描文件,进行文件分类
//扫描文件,进行文件分类
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"msg"
,
"开始扫描文件"
);
asyncTask
.
sendMessageToAll
(
map
);
scanFiles
();
scanFiles
();
map
.
put
(
"msg"
,
"文件扫描结束"
);
asyncTask
.
sendMessageToAll
(
map
);
//配置参数
//配置参数
inspectParameter
.
setCodeSize
((
int
)
codeSize
);
inspectParameter
.
setCodeSize
((
int
)
codeSize
);
report
.
setFileNum
(
fileNum
);
report
.
setFileNum
(
fileNum
);
...
@@ -166,7 +171,11 @@ public class Inspector {
...
@@ -166,7 +171,11 @@ public class Inspector {
//根据扫描结果以及用户配置得出需要使用的规则及技术
//根据扫描结果以及用户配置得出需要使用的规则及技术
ruleTransform
(
inspectParameter
.
getRecastMethod
());
ruleTransform
(
inspectParameter
.
getRecastMethod
());
//扫描源代码文件
//扫描源代码文件
map
.
put
(
"msg"
,
"开始扫描源代码文件"
);
asyncTask
.
sendMessageToAll
(
map
);
forEachFilesMap
();
forEachFilesMap
();
map
.
put
(
"msg"
,
"源代码文件扫描结束"
);
asyncTask
.
sendMessageToAll
(
map
);
//将得到的告警信息根据技术id进行转换
//将得到的告警信息根据技术id进行转换
Set
<
String
>
technologyIds
=
warns
.
stream
().
map
(
Warn:
:
getTechnologyId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
technologyIds
=
warns
.
stream
().
map
(
Warn:
:
getTechnologyId
).
collect
(
Collectors
.
toSet
());
List
<
Technology
>
technologies
=
technologyDao
.
findAllById
(
technologyIds
);
List
<
Technology
>
technologies
=
technologyDao
.
findAllById
(
technologyIds
);
...
@@ -247,7 +256,7 @@ public class Inspector {
...
@@ -247,7 +256,7 @@ public class Inspector {
for
(
Path
path1
:
entry
.
getValue
())
{
for
(
Path
path1
:
entry
.
getValue
())
{
try
{
try
{
fileNum
=
fileNum
+
1
;
fileNum
=
fileNum
+
1
;
map
.
put
(
"
totalFile
"
,
fileNum
+
"/"
+
fileSize
);
map
.
put
(
"
msg
"
,
fileNum
+
"/"
+
fileSize
);
System
.
out
.
println
(
fileNum
+
"/"
+
fileSize
);
System
.
out
.
println
(
fileNum
+
"/"
+
fileSize
);
asyncTask
.
sendMessageToAll
(
map
);
asyncTask
.
sendMessageToAll
(
map
);
//如果文件类型为jar活着class则不读取
//如果文件类型为jar活着class则不读取
...
...
src/main/java/com/zjty/inspect/thread/task/AsyncTask.java
浏览文件 @
d482af48
...
@@ -24,7 +24,6 @@ public class AsyncTask {
...
@@ -24,7 +24,6 @@ public class AsyncTask {
* @Author: LiuJie
* @Author: LiuJie
* @Date: 2019/5/20
* @Date: 2019/5/20
*/
*/
@Async
(
"myTaskAsyncPool"
)
public
void
sendMessageToAll
(
Map
<
String
,
String
>
map
)
{
public
void
sendMessageToAll
(
Map
<
String
,
String
>
map
)
{
webSocketServer
.
sendMessageToAll
(
map
);
webSocketServer
.
sendMessageToAll
(
map
);
}
}
...
...
src/main/java/com/zjty/inspect/utils/ExcelUtil.java
浏览文件 @
d482af48
差异被折叠。
点击展开。
src/main/java/com/zjty/inspect/utils/WpsUtil.java
浏览文件 @
d482af48
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论