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

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

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