提交 4a996493 authored 作者: 马晨俊's avatar 马晨俊

mcj:修改变量名称,删除无用注释

上级 4b753e73
......@@ -55,10 +55,10 @@ public class InspectController {
inspectParameter.setDisaster(disaster);
inspectParameter.setData(data);
inspectParameter.setFramework(framework);
inspectParameter.setPath(file.getPath());
inspectParameter.setPath(file.getCanonicalPath());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo reportVo = new ReportVo();
reportVo.setSourceAddress(file.getPath());
reportVo.setSourceAddress(file.getCanonicalPath());
ReportVo inspect = inspectService.inspect(reportVo,inspectParameter);
return ResponseEntity.ok(inspect);
}
......@@ -70,7 +70,7 @@ public class InspectController {
*/
@PostMapping("/git")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress());
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(),inspectParameter.getGitName());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo report1 = new ReportVo();
report1.setSourceAddress(path);
......
......@@ -6,8 +6,6 @@ import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.List;
/**
* 传入参数表
......@@ -99,6 +97,11 @@ public class InspectParameter {
*/
private String gitAddress;
/**
* 项目名称
*/
private String gitName;
/**
* 源代码存储地址
*/
......
......@@ -78,6 +78,6 @@ public class Report {
MAVEN,GRADLE,ANT
}
public enum Language{
JAVA,PYTHON,CPP,JSP,ASP,ONLYVIEW,UNKNOW,JAVASCRIPT,GO,VUE
JAVA,PYTHON,CPP,JSP,ASP,ONLYVIEW,UNKNOW,JAVASCRIPT,GO,VUE,HTML
}
}
......@@ -12,13 +12,7 @@ import javax.persistence.Id;
*/
@Data
@Entity
public class Warn {
/**
* 主键id
*/
@Id
private String id;
/**
* 发现问题的文件地址
......
......@@ -26,6 +26,7 @@ public class InspectServiceImpl implements InspectService {
@Transactional
@Override
public ReportVo inspect(ReportVo reportVo,InspectParameter inspectParameter) {
//统计文件后缀数量
Map<String, Report.Language> suffixLanguageMapping = new HashMap<>();
suffixLanguageMapping.put("java", Report.Language.JAVA);
suffixLanguageMapping.put("vue", Report.Language.VUE);
......@@ -33,10 +34,11 @@ public class InspectServiceImpl implements InspectService {
suffixLanguageMapping.put("py", Report.Language.PYTHON);
suffixLanguageMapping.put("jsp", Report.Language.JSP);
suffixLanguageMapping.put("go", Report.Language.GO);
suffixLanguageMapping.put("js", Report.Language.JAVASCRIPT);
suffixLanguageMapping.put("html", Report.Language.HTML);
inspector.setInspectParameter(inspectParameter);
inspector.setReport(reportVo);
inspector.setSuffixLanguageMapping(suffixLanguageMapping);
inspector.setPath(inspectParameter.getPath());
ReportVo report = inspector.inspect();
return report;
}
......
......@@ -48,8 +48,8 @@ public class task implements CommandLineRunner {
coefficientModel.setScale(1);
coefficientModel.setId(UUIDUtil.getUUID());
coefficientModel.setName("安全能力");
coefficientModel.setMin(0);
coefficientModel.setMax(2);
coefficientModel.setMin(1);
coefficientModel.setMax(3);
coefficientModel.setBelowCoefficient(0D);
coefficientModel.setMediumCoefficient(0.1);
coefficientModel.setTopCoefficient(0.2);
......@@ -58,8 +58,8 @@ public class task implements CommandLineRunner {
coefficientMode2.setScale(2);
coefficientMode2.setId(UUIDUtil.getUUID());
coefficientMode2.setName("安全能力");
coefficientMode2.setMin(0);
coefficientMode2.setMax(2);
coefficientMode2.setMin(1);
coefficientMode2.setMax(3);
coefficientMode2.setBelowCoefficient(-0.1);
coefficientMode2.setMediumCoefficient(0D);
coefficientMode2.setTopCoefficient(0.1);
......@@ -68,8 +68,8 @@ public class task implements CommandLineRunner {
coefficientMode3.setScale(3);
coefficientMode3.setId(UUIDUtil.getUUID());
coefficientMode3.setName("安全能力");
coefficientMode3.setMin(0);
coefficientMode3.setMax(2);
coefficientMode3.setMin(1);
coefficientMode3.setMax(3);
coefficientMode3.setBelowCoefficient(-0.2);
coefficientMode3.setMediumCoefficient(-0.1);
coefficientMode3.setTopCoefficient(0D);
......@@ -78,7 +78,7 @@ public class task implements CommandLineRunner {
coefficientMode4.setScale(1);
coefficientMode4.setId(UUIDUtil.getUUID());
coefficientMode4.setName("容灾能力");
coefficientMode4.setMin(0);
coefficientMode4.setMin(1);
coefficientMode4.setMax(2);
coefficientMode4.setBelowCoefficient(0D);
coefficientMode4.setMediumCoefficient(0D);
......@@ -88,8 +88,8 @@ public class task implements CommandLineRunner {
coefficientMode5.setScale(2);
coefficientMode5.setId(UUIDUtil.getUUID());
coefficientMode5.setName("容灾能力");
coefficientMode5.setMin(0);
coefficientMode5.setMax(2);
coefficientMode5.setMin(1);
coefficientMode5.setMax(3);
coefficientMode5.setBelowCoefficient(0.05);
coefficientMode5.setMediumCoefficient(0D);
coefficientMode5.setTopCoefficient(0D);
......@@ -128,13 +128,14 @@ public class task implements CommandLineRunner {
coefficientMode7.setScale(3);
coefficientMode7.setId(UUIDUtil.getUUID());
coefficientMode7.setName("容灾能力");
coefficientMode7.setMin(0);
coefficientMode7.setMax(2);
coefficientMode7.setMin(1);
coefficientMode7.setMax(3);
coefficientMode7.setBelowCoefficient(-0.1);
coefficientMode7.setMediumCoefficient(0D);
coefficientMode7.setTopCoefficient(0D);
coefficientModels.add(coefficientMode6);
coefficientModels.add(coefficientMode5);
coefficientModels.add(coefficientMode4);
......
......@@ -95,7 +95,6 @@ public class AnalysisFile {
warn.setLineNum(i);
warn.setTechnologyId(rule.getTechnologyId());
warn.setRuleId(rule.getId());
warn.setId(UUIDUtil.getUUID());
warns.add(warn);
}
}
......
......@@ -28,6 +28,8 @@ public class FileUtil {
* @throws IOException
*/
public static File saveToLocal(MultipartFile multipartFile) throws IOException {
String name = LocalDate.now().toString();
String[] split1 = UUIDUtil.getUUID().split("-");
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
......@@ -36,16 +38,16 @@ public class FileUtil {
final File excelFile = File.createTempFile(LocalDateTime.now()+fileName, prefix);
// MultipartFile to File
multipartFile.transferTo(excelFile);
if(prefix.equals(".zip")){
FileUtil.unPackZip(excelFile,"", "./");
FileUtil.unPackZip(excelFile,"", "./"+name+"/"+split1[0]);
}else{
FileUtil.unPackRar(excelFile, "./");
FileUtil.unPackRar(excelFile, "./"+name+"/"+split1[0]);
}
String[] split = fileName.split("\\.");
File file3 = new File("./"+split[0]);
File file3 = new File("./"+name+"/"+split1[0]+"/"+split[0]);
excelFile.delete();
log.info("end unpack file");
System.out.println(file3.getCanonicalPath());
return file3;
}
......@@ -114,11 +116,9 @@ public class FileUtil {
public static void main(String[] args) throws IOException {
File file = new File("/Users/mcj/Downloads/acq-server.zip");
String[] split = file.getName().split("\\.");
System.out.println(split[0]);
System.out.println(file.getName());
System.out.println(LocalDate.now().toString());
String[] split1 = UUIDUtil.getUUID().split("-");
System.out.println(split1[0]);
// FileUtil.unPackZip(new File("/Users/mcj/Downloads/acq-server.zip"),"", "./");
//FileUtils.deleteDirectory(new File("./acq-server"));
SAXReader reader = new SAXReader();
......
......@@ -6,6 +6,8 @@ import org.eclipse.jgit.api.errors.GitAPIException;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
/**
* @author Mcj
......@@ -14,19 +16,26 @@ import java.io.File;
@Component
public class GitLabUtil {
public static String downLoadProject(String path) {
public static String downLoadProject(String path,String name) {
String name1 = LocalDate.now().toString();
String[] split1 = UUIDUtil.getUUID().split("-");
//String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git";
CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI(path);
// cloneCommand.setCredentialsProvider(mcj);
File file = new File("./");
File file = new File("./"+name1+"/"+split1[0]+"/"+name);
file.mkdirs();
cloneCommand.setDirectory(file);
try {
cloneCommand.call();
} catch (GitAPIException e) {
e.printStackTrace();
}
return file.getPath();
try {
return file.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
return file.getAbsolutePath();
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论