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

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

# Conflicts: # src/main/java/com/zjty/inspect/dao/TechnologyDao.java
上级 f349f5ad
......@@ -34,10 +34,16 @@ public class InspectController {
/**
* 上传代码进行评估
* @param years
* @param systemFund
* @param modules
* @param multfile
* @param years 系统开发时间
* @param systemFund 系统开发费用
* @param modules 模块数
* @param valid 预算数据是否可用
* @param framework 架构
* @param safety 安全能力
* @param disaster 容灾能力
* @param data 数据量
* @param admin 是否管理员
* @param multfile 文件
* @return
* @throws IOException
*/
......@@ -45,7 +51,7 @@ public class InspectController {
@ApiOperation("上传代码进行评估")
public ResponseEntity inspect(Integer years,Integer systemFund,Integer modules
,String valid,Double framework,Double safety,Double disaster,Integer data
,Integer admin, MultipartFile multfile) throws IOException {
,Integer admin,String projectName,String fileName, MultipartFile multfile) throws IOException {
File file = FileUtil.saveToLocal(multfile);
InspectParameter inspectParameter = new InspectParameter();
......@@ -62,6 +68,9 @@ public class InspectController {
inspectParameter.setPath(file.getCanonicalPath());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo reportVo = new ReportVo();
reportVo.setUploadType("文件上传");
reportVo.setFileName(fileName);
reportVo.setProjectName(projectName);
reportVo.setSourceAddress(file.getCanonicalPath());
ReportVo inspect = inspectService.inspect(reportVo,inspectParameter);
return ResponseEntity.ok(inspect);
......@@ -77,9 +86,12 @@ public class InspectController {
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(),inspectParameter.getGitName());
inspectParameter.setId(UUIDUtil.getUUID());
ReportVo report1 = new ReportVo();
report1.setSourceAddress(path);
inspectService.inspect(report1,inspectParameter);
inspectParameter.setPath(path);
ReportVo reportVo = new ReportVo();
reportVo.setUploadType("git下载");
reportVo.setSourceAddress(path);
reportVo.setGitAddress(inspectParameter.getGitAddress());
inspectService.inspect(reportVo,inspectParameter);
return ResponseEntity.ok(200);
}
......
package com.zjty.inspect.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zjty.inspect.utils.Inspector;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -10,8 +8,6 @@ import org.hibernate.annotations.GenerationTime;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
/**
* 报告
......
package com.zjty.inspect.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.Column;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -12,6 +14,18 @@ import java.util.List;
@Data
public class ReportVo {
/**
* 文件名称
*/
private String fileName;
/**
* 项目名称
*/
private String projectName;
/**
* 上传类型
*/
private String uploadType;
/**
* git源代码地址
*/
......@@ -27,6 +41,11 @@ public class ReportVo {
*/
private String manager;
/**
* 数据库类型
*/
private String databaseType;
/**
* 语言
*/
......@@ -69,4 +88,10 @@ public class ReportVo {
* 告警点
*/
private HashMap<String, List<Warn>> warnDetails;
/**
* 评估时间
*/
@JsonFormat(pattern = "YYYY-MM-dd",timezone="GMT+8")
private Date createDate = new Date();
}
......@@ -29,10 +29,7 @@ public class Rule {
@Id
@Column(length = 48)
private String id;
/**
* 关键技术名称
*/
private String technologyName;
/**
* 目标关键字
*/
......
......@@ -4,7 +4,7 @@ import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.Report;
import com.zjty.inspect.entity.ReportVo;
import com.zjty.inspect.service.InspectService;
import com.zjty.inspect.utils.Inspector;
import com.zjty.inspect.inspect.Inspector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -43,6 +43,7 @@ public class InspectServiceImpl implements InspectService {
//需要重构
inspector.setSuffixLanguageMapping(suffixLanguageMapping);
ReportVo report = inspector.inspect();
return report;
}
}
......@@ -39,7 +39,6 @@ public class RuleServiceImpl implements RuleService {
// TODO: 2020-02-27 适配技术与扫描关键字关联
Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setSuffix(ruleQo.getSuffix());
rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setId(UUIDUtil.getUUID());
......@@ -51,7 +50,6 @@ public class RuleServiceImpl implements RuleService {
Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget());
rule.setSuffix(ruleQo.getSuffix());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setId(ruleQo.getId());
ruleDao.save(rule);
......
......@@ -94,10 +94,19 @@ public class task implements CommandLineRunner {
coefficientMode5.setMediumCoefficient(0D);
coefficientMode5.setTopCoefficient(0D);
CoefficientModel coefficientMode7 = new CoefficientModel();
coefficientMode7.setScale(3);
coefficientMode7.setId(UUIDUtil.getUUID());
coefficientMode7.setName("容灾能力");
coefficientMode7.setMin(1);
coefficientMode7.setMax(3);
coefficientMode7.setBelowCoefficient(-0.1);
coefficientMode7.setMediumCoefficient(0D);
coefficientMode7.setTopCoefficient(0D);
CoefficientModel coefficientMode6 = new CoefficientModel();
coefficientMode6.setScale(3);
coefficientMode6.setId(UUIDUtil.getUUID());
coefficientMode6.setName("模块");
coefficientMode6.setName("模块");
coefficientMode6.setMin(4);
coefficientMode6.setMax(10);
coefficientMode6.setBelowCoefficient(-0.3);
......@@ -107,7 +116,7 @@ public class task implements CommandLineRunner {
CoefficientModel coefficientMode8 = new CoefficientModel();
coefficientMode8.setScale(2);
coefficientMode8.setId(UUIDUtil.getUUID());
coefficientMode8.setName("模块");
coefficientMode8.setName("模块");
coefficientMode8.setMin(4);
coefficientMode8.setMax(10);
coefficientMode8.setBelowCoefficient(-0.3);
......@@ -117,23 +126,42 @@ public class task implements CommandLineRunner {
CoefficientModel coefficientMode9 = new CoefficientModel();
coefficientMode9.setScale(1);
coefficientMode9.setId(UUIDUtil.getUUID());
coefficientMode9.setName("模块");
coefficientMode9.setName("模块");
coefficientMode9.setMin(4);
coefficientMode9.setMax(10);
coefficientMode9.setBelowCoefficient(-0.3);
coefficientMode9.setMediumCoefficient(0D);
coefficientMode9.setTopCoefficient(0.3);
CoefficientModel coefficientMode7 = new CoefficientModel();
coefficientMode7.setScale(3);
coefficientMode7.setId(UUIDUtil.getUUID());
coefficientMode7.setName("容灾能力");
coefficientMode7.setMin(1);
coefficientMode7.setMax(3);
coefficientMode7.setBelowCoefficient(-0.1);
coefficientMode7.setMediumCoefficient(0D);
coefficientMode7.setTopCoefficient(0D);
CoefficientModel coefficientMode10 = new CoefficientModel();
coefficientMode10.setScale(1);
coefficientMode10.setId(UUIDUtil.getUUID());
coefficientMode10.setName("数据量");
coefficientMode10.setMin(1);
coefficientMode10.setMax(100);
coefficientMode10.setBelowCoefficient(-0.05);
coefficientMode10.setMediumCoefficient(0D);
coefficientMode10.setTopCoefficient(0.05);
CoefficientModel coefficientMode11 = new CoefficientModel();
coefficientMode11.setScale(2);
coefficientMode11.setId(UUIDUtil.getUUID());
coefficientMode11.setName("数据量");
coefficientMode11.setMin(1);
coefficientMode11.setMax(100);
coefficientMode11.setBelowCoefficient(-0.05);
coefficientMode11.setMediumCoefficient(0D);
coefficientMode11.setTopCoefficient(0.05);
CoefficientModel coefficientMode12 = new CoefficientModel();
coefficientMode12.setScale(3);
coefficientMode12.setId(UUIDUtil.getUUID());
coefficientMode12.setName("数据量");
coefficientMode12.setMin(1);
coefficientMode12.setMax(100);
coefficientMode12.setBelowCoefficient(-0.05);
coefficientMode12.setMediumCoefficient(0D);
coefficientMode12.setTopCoefficient(0.05);
coefficientModels.add(coefficientMode6);
coefficientModels.add(coefficientMode5);
coefficientModels.add(coefficientMode4);
......@@ -143,53 +171,56 @@ public class task implements CommandLineRunner {
coefficientModels.add(coefficientMode7);
coefficientModels.add(coefficientMode8);
coefficientModels.add(coefficientMode9);
coefficientModels.add(coefficientMode10);
coefficientModels.add(coefficientMode11);
coefficientModels.add(coefficientMode12);
coefficientModelDao.saveAll(coefficientModels);
Technology technology = new Technology();
technology.setTechnologyName("Java依赖");
technology.setAdvice("国产化支持的依赖");
technology.setFund(5);
technology.setId(UUIDUtil.getUUID());
technology.setSupport(1);
Technology technology1 = new Technology();
technology1.setTechnologyName("非国产化依赖");
technology1.setSupport(2);
technology1.setAdvice("国产化不支持的依赖");
technology1.setFund(5);
technology1.setId(UUIDUtil.getUUID());
Technology technology2 = new Technology();
technology2.setTechnologyName("未知依赖");
technology2.setSupport(3);
technology2.setAdvice("未知的依赖");
technology2.setFund(5);
technology2.setId(UUIDUtil.getUUID());
Technology JavaTechnology = new Technology();
JavaTechnology.setTechnologyName("Java依赖");
JavaTechnology.setAdvice("国产化支持的依赖");
JavaTechnology.setFund(5);
JavaTechnology.setId(UUIDUtil.getUUID());
JavaTechnology.setSupport(1);
Technology NotCnTechnology = new Technology();
NotCnTechnology.setTechnologyName("非国产化依赖");
NotCnTechnology.setSupport(2);
NotCnTechnology.setAdvice("国产化不支持的依赖");
NotCnTechnology.setFund(5);
NotCnTechnology.setId(UUIDUtil.getUUID());
Technology UnKnowunTechnology = new Technology();
UnKnowunTechnology.setTechnologyName("未知依赖");
UnKnowunTechnology.setSupport(3);
UnKnowunTechnology.setAdvice("未知的依赖");
UnKnowunTechnology.setFund(5);
UnKnowunTechnology.setId(UUIDUtil.getUUID());
Rule NotCnJavaTechnology = new Rule();
NotCnJavaTechnology.setId(UUIDUtil.getUUID());
NotCnJavaTechnology.setSuffix("*");
NotCnJavaTechnology.setTarget("mysql-connect");
NotCnJavaTechnology.setTechnologyId(NotCnTechnology.getId());
Rule rule = new Rule();
rule.setId(UUIDUtil.getUUID());
rule.setSuffix("*");
rule.setTarget("ruleService");
rule.setTechnologyId(technology.getId());
Rule rule1 = new Rule();
rule1.setId(UUIDUtil.getUUID());
rule1.setSuffix("*");
rule1.setTarget("mysql-connect");
rule1.setTechnologyId(technology1.getId());
Rule rule2 = new Rule();
rule2.setId(UUIDUtil.getUUID());
rule2.setSuffix("*");
rule2.setTarget("mysql-connect");
rule2.setTechnologyId(technology2.getId());
technologyDao.save(technology);
technologyDao.save(technology1);
technologyDao.save(technology2);
rule.setTarget("mysql-connect");
rule.setTechnologyId(UnKnowunTechnology.getId());
// Rule UnknowunMysqlRule = new Rule();
// UnknowunMysqlRule.setId(UUIDUtil.getUUID());
// UnknowunMysqlRule.setSuffix("*");
// UnknowunMysqlRule.setTarget("mysql-connect");
// UnknowunMysqlRule.setTechnologyId(UnKnowunTechnology.getId());
technologyDao.save(JavaTechnology);
technologyDao.save(NotCnTechnology);
technologyDao.save(UnKnowunTechnology);
ruleDao.save(rule);
ruleDao.save(rule1);
ruleDao.save(rule2);
ruleDao.save(NotCnJavaTechnology);
// ruleDao.save(UnknowunMysqlRule);
}
}
......@@ -59,10 +59,10 @@ public class BudgetUitl {
strings.add("安全能力");
strings.add("容灾能力");
strings.add("架构");
strings.add("数据量");
strings.add("模块数");
List<CoefficientModel> nameIn = coefficientModelDao.findAllByNameIn(strings);
List<CoefficientModel> collect = nameIn.stream().filter(a -> {
return a.getScale() == scale;
}).collect(Collectors.toList());
List<CoefficientModel> collect = nameIn.stream().filter(a -> a.getScale() == scale).collect(Collectors.toList());
for (CoefficientModel model : collect) {
if("架构".equals(model.getName())){
Double aDouble = model.countCoefficient(inspectParameter.getFramework());
......@@ -75,6 +75,14 @@ public class BudgetUitl {
Double aDouble = model.countCoefficient(inspectParameter.getSafety());
v1*=aDouble;
}
else if("数据量".equals(model.getName())){
Double aDouble = model.countCoefficient(Double.valueOf(inspectParameter.getData()));
v1*=aDouble;
}
else if("模块数".equals(model.getName())){
Double aDouble = model.countCoefficient(Double.valueOf(inspectParameter.getModules()));
v1*=aDouble;
}
}
if(v<v1){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论