提交 d482af48 authored 作者: 孙洁清's avatar 孙洁清

Merge branch 'lj-project' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into lj-project

...@@ -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<>());
}
}
/** /**
* 修改评估报告 * 修改评估报告
* *
......
...@@ -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);
} }
} }
...@@ -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;
} }
...@@ -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);
} }
......
...@@ -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则不读取
......
...@@ -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);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论