Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
cc866ccb
提交
cc866ccb
authored
4月 21, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mcj:
修复websocket输送问题,文件上传问题
上级
67b1e5a5
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
69 行增加
和
33 行删除
+69
-33
EvaluationController.java
...ava/com/zjty/inspect/controller/EvaluationController.java
+0
-12
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+52
-12
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
+5
-5
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
+7
-2
WpsUtil.java
src/main/java/com/zjty/inspect/utils/WpsUtil.java
+0
-0
没有找到文件。
src/main/java/com/zjty/inspect/controller/EvaluationController.java
浏览文件 @
cc866ccb
...
...
@@ -91,18 +91,6 @@ public class EvaluationController {
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
浏览文件 @
cc866ccb
...
...
@@ -10,11 +10,15 @@ import com.zjty.inspect.utils.*;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
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.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.File
;
import
java.util.*
;
...
...
@@ -53,6 +57,8 @@ public class InspectController {
//应用类型转换:大型4
private
Integer
[]
big
=
{
5
,
9
};
@Value
(
"${upload.location}"
)
private
String
uploadPath
;
/**
* 上传代码进行评估
*
...
...
@@ -381,23 +387,58 @@ public class InspectController {
return
ServerResponse
.
ok
(
save
.
getId
());
}
@ApiOperation
(
"大文件分片上传"
)
// @PostMapping("/chunkUpload")
@PostMapping
(
"/uploads"
)
private
ServerResponse
uploads
(
@RequestParam
(
value
=
"file"
)
MultipartFile
multfile
)
{
public
ServerResponse
fileChunkUpload
(
MultipartFileParam
param
,
HttpServletRequest
request
,
HttpServletResponse
response
){
// OSSInformation ossInformation = ossInformationService.queryOne();
// 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: 当前块上传失败,会取消整个文件上传。
// 其他状态码: 出错了,但是会自动重试上传。
try
{
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"unzip"
,
"获取压缩文件"
);
File
file
=
FileUtil
.
saveToLocal
(
multfile
);
map
.
put
(
"unzip"
,
"压缩文件解压完毕"
);
asyncTask
.
sendMessageToAll
(
map
);
String
name
=
file
.
getName
();
String
path
=
file
.
getCanonicalPath
();
return
ServerResponse
.
ok
(
new
com
.
zjty
.
inspect
.
entity
.
File
(
name
,
path
));
}
catch
(
IOException
e
)
{
/**
* 判断前端Form表单格式是否支持文件上传
*/
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
();
return
ServerResponse
.
error
(
500
);
// System.out.println("上传文件失败");
// response.setStatus(415);
return
ServerResponse
.
error
(
415
,
"上传文件失败"
);
}
}
@PostMapping
(
"/gitdownload"
)
private
ServerResponse
gitDownloads
(
String
gitAddress
,
String
username
,
String
password
)
{
try
{
...
...
@@ -412,7 +453,6 @@ public class InspectController {
private
ServerResponse
<
Reform
>
uploadFileToInspect
(
MultipartFile
file
,
String
username
)
throws
IOException
{
Reform
reform
=
ExcelUtil
.
parseExcel
(
file
.
getInputStream
(),
file
.
getOriginalFilename
());
reform
.
setUsername
(
username
);
System
.
out
.
println
(
"1"
);
return
ServerResponse
.
ok
(
reform
);
}
}
src/main/java/com/zjty/inspect/entity/BaseDes.java
浏览文件 @
cc866ccb
...
...
@@ -15,4 +15,6 @@ public class BaseDes {
private
String
des
;
@ApiModelProperty
(
value
=
"版本号"
)
private
String
version
;
@ApiModelProperty
(
value
=
"是否为其他项"
)
private
Integer
other
;
}
src/main/java/com/zjty/inspect/entity/ServerResponse.java
浏览文件 @
cc866ccb
...
...
@@ -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
){
return
new
ServerResponse
(
400
,
"请求失败"
,
data
);
}
...
...
src/main/java/com/zjty/inspect/inspect/Inspector.java
浏览文件 @
cc866ccb
...
...
@@ -156,10 +156,10 @@ public class Inspector {
initData
();
//扫描文件,进行文件分类
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"
file
"
,
"开始扫描文件"
);
map
.
put
(
"
msg
"
,
"开始扫描文件"
);
asyncTask
.
sendMessageToAll
(
map
);
scanFiles
();
map
.
put
(
"
file
"
,
"文件扫描结束"
);
map
.
put
(
"
msg
"
,
"文件扫描结束"
);
asyncTask
.
sendMessageToAll
(
map
);
//配置参数
inspectParameter
.
setCodeSize
((
int
)
codeSize
);
...
...
@@ -171,10 +171,10 @@ public class Inspector {
//根据扫描结果以及用户配置得出需要使用的规则及技术
ruleTransform
(
inspectParameter
.
getRecastMethod
());
//扫描源代码文件
map
.
put
(
"
file
"
,
"开始扫描源代码文件"
);
map
.
put
(
"
msg
"
,
"开始扫描源代码文件"
);
asyncTask
.
sendMessageToAll
(
map
);
forEachFilesMap
();
map
.
put
(
"
file
"
,
"源代码文件扫描结束"
);
map
.
put
(
"
msg
"
,
"源代码文件扫描结束"
);
asyncTask
.
sendMessageToAll
(
map
);
//将得到的告警信息根据技术id进行转换
Set
<
String
>
technologyIds
=
warns
.
stream
().
map
(
Warn:
:
getTechnologyId
).
collect
(
Collectors
.
toSet
());
...
...
@@ -256,7 +256,7 @@ public class Inspector {
for
(
Path
path1
:
entry
.
getValue
())
{
try
{
fileNum
=
fileNum
+
1
;
map
.
put
(
"
totalFile
"
,
fileNum
+
"/"
+
fileSize
);
map
.
put
(
"
msg
"
,
fileNum
+
"/"
+
fileSize
);
System
.
out
.
println
(
fileNum
+
"/"
+
fileSize
);
asyncTask
.
sendMessageToAll
(
map
);
//如果文件类型为jar活着class则不读取
...
...
src/main/java/com/zjty/inspect/thread/task/AsyncTask.java
浏览文件 @
cc866ccb
...
...
@@ -24,7 +24,6 @@ public class AsyncTask {
* @Author: LiuJie
* @Date: 2019/5/20
*/
@Async
(
"myTaskAsyncPool"
)
public
void
sendMessageToAll
(
Map
<
String
,
String
>
map
)
{
webSocketServer
.
sendMessageToAll
(
map
);
}
...
...
src/main/java/com/zjty/inspect/utils/ExcelUtil.java
浏览文件 @
cc866ccb
...
...
@@ -311,9 +311,14 @@ public class ExcelUtil {
ArrayList
<
DatabaseType
>
databaseTypes
=
new
ArrayList
<>();
for
(
int
i
=
74
;
i
<
77
;
i
++)
{
String
database
=
getExcelCell
(
i
,
2
,
sheetAt
);
String
version
=
getExcelCell
(
i
,
3
,
sheetAt
);
String
remark
=
getExcelCell
(
i
,
4
,
sheetAt
);
if
(!
""
.
equals
(
database
))
{
DatabaseType
byName
=
DatabaseType
.
getByName
(
database
);
databaseTypes
.
add
(
byName
);
DatabaseType
databaseType
=
DatabaseType
.
getByName
(
database
);
databaseTypes
.
add
(
databaseType
);
}
if
(!
""
.
equals
(
remark
)){
database1
.
setOtherContent
(
remark
);
}
}
database1
.
setDatabaseType
(
databaseTypes
);
...
...
src/main/java/com/zjty/inspect/utils/WpsUtil.java
浏览文件 @
cc866ccb
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论