提交 9b205fc8 authored 作者: wyl's avatar wyl

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

...@@ -288,7 +288,12 @@ public class InspectController { ...@@ -288,7 +288,12 @@ public class InspectController {
//中间件难度 //中间件难度
MiddlewareDifficulty middlewareDifficulty = new MiddlewareDifficulty(); MiddlewareDifficulty middlewareDifficulty = new MiddlewareDifficulty();
//所有的依赖 //所有的依赖
List<PomDependency> dependencies = inspect.getDependencyVo().getDepTreeList().get(0).getDependencies(); List<PomDependency> dependencies = new ArrayList<>();
List<ProjectPom> depTreeList = inspect.getDependencyVo().getDepTreeList();
for (ProjectPom projectPom : depTreeList) {
dependencies.addAll(projectPom.getDependencies());
}
HashMap<String,Integer> num = new HashMap<>(); HashMap<String,Integer> num = new HashMap<>();
for (PomDependency pomDependency:dependencies) { for (PomDependency pomDependency:dependencies) {
String groupId = pomDependency.getGroupId(); String groupId = pomDependency.getGroupId();
......
...@@ -27,7 +27,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec ...@@ -27,7 +27,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
Rule findByTarget(String target); Rule findByTarget(String target);
Rule findByTargetAndSuffixEquals(String target,String suffix); Rule findByTargetAndSuffixEqualsAndTechnologyIdEquals(String target,String suffix,String technologyId);
/** /**
* 根据技术id查询规则 * 根据技术id查询规则
......
...@@ -46,7 +46,7 @@ public class CoefficientModel { ...@@ -46,7 +46,7 @@ public class CoefficientModel {
private Integer scale; private Integer scale;
public Double countCoefficient(Integer data) { public Double countCoefficient(Integer data) {
if(data==null){ if(data==null || data<0){
return 1D; return 1D;
} }
if(data<min){ if(data<min){
......
...@@ -23,9 +23,8 @@ public class RuleQo { ...@@ -23,9 +23,8 @@ public class RuleQo {
/** /**
* 匹配的文件后缀 * 匹配的文件后缀
*/ */
private List<String> suffixes; private List<String> suffix;
private String suffix;
/** /**
* 适配技术id * 适配技术id
......
...@@ -150,8 +150,10 @@ public class Inspector { ...@@ -150,8 +150,10 @@ public class Inspector {
* @return * @return
*/ */
public ReportVo inspect() { public ReportVo inspect() {
codeSize=0;
ruleSuffixFilePathMap = new HashMap<>(); ruleSuffixFilePathMap = new HashMap<>();
ruleSuffixMap = new HashMap<>(); ruleSuffixMap = new HashMap<>();
technologyHashMap = new HashMap<>();
warns.clear(); warns.clear();
rules.clear(); rules.clear();
//查询技术,构造支持与非支持技术对象 //查询技术,构造支持与非支持技术对象
...@@ -164,6 +166,9 @@ public class Inspector { ...@@ -164,6 +166,9 @@ public class Inspector {
if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) { if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) {
ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>()); ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>());
} }
if(!ruleMap.containsKey(rule.getTarget()+":"+rule.getSuffix())){
ruleMap.put(rule.getTarget()+":"+rule.getSuffix(),rule);
}
} }
try { try {
//以下为计算文件名称匹配正则表达式 //以下为计算文件名称匹配正则表达式
...@@ -196,41 +201,10 @@ public class Inspector { ...@@ -196,41 +201,10 @@ public class Inspector {
@Override @Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
fileNum+=1; if (file.getFileName().toString().endsWith(".jar")) {
try {
List<String> allLines = Files.readAllLines(file);
fileLine+=allLines.size();
}catch (MalformedInputException e){
return FileVisitResult.CONTINUE;
} catch (IOException e) {
e.printStackTrace();
}
for (Map.Entry<String, PathMatcher> entry : languageSuffixMatcherMapping.entrySet()) {
//通过正则表达式匹配.java类型后缀文件,并+1
if (entry.getValue().matches(file)) {
long length = file.toFile().length();
codeSize += length / 1024;
languageMatchMap.get(entry.getKey()).plus();
}
}
for (Map.Entry<PathMatcher, String> entry : configFileMatcherSuffixMapping.entrySet()) {
//通过配置文件正则表达式匹配.xml文件,记录文件地址
if (entry.getKey().matches(file)) {
configFileTypePathsMapping.get(entry.getValue()).add(file);
}
}
for (Map.Entry<PathMatcher, String> entry : ruleSuffixMap.entrySet()) {
//通过规则匹配后缀正则表达式匹配,记录匹配上的文件地址
if (entry.getKey().matches(file)) {
ruleSuffixFilePathMap.get(entry.getValue()).add(file);
}
}
//检查到普通jar包
if (file.toString().endsWith(".jar")) {
//新建一个pom对象 //新建一个pom对象
ProjectPom projectPom = new ProjectPom(); ProjectPom projectPom = new ProjectPom();
//截取jar名称 //截取jar名称
String patten = RegexUtil.patten(file.getFileName().toString()); String patten = RegexUtil.patten(file.getFileName().toString());
//新建一个依赖对象 //新建一个依赖对象
PomDependency pomDependency = new PomDependency(); PomDependency pomDependency = new PomDependency();
...@@ -264,6 +238,36 @@ public class Inspector { ...@@ -264,6 +238,36 @@ public class Inspector {
} }
dependencyVo.add(projectPom); dependencyVo.add(projectPom);
} }
fileNum+=1;
try {
List<String> allLines = Files.readAllLines(file);
fileLine+=allLines.size();
}catch (MalformedInputException e){
return FileVisitResult.CONTINUE;
} catch (IOException e) {
e.printStackTrace();
}
for (Map.Entry<String, PathMatcher> entry : languageSuffixMatcherMapping.entrySet()) {
//通过正则表达式匹配.java类型后缀文件,并+1
if (entry.getValue().matches(file)) {
long length = file.toFile().length();
codeSize += length / 1024;
languageMatchMap.get(entry.getKey()).plus();
}
}
for (Map.Entry<PathMatcher, String> entry : configFileMatcherSuffixMapping.entrySet()) {
//通过配置文件正则表达式匹配.xml文件,记录文件地址
if (entry.getKey().matches(file)) {
configFileTypePathsMapping.get(entry.getValue()).add(file);
}
}
for (Map.Entry<PathMatcher, String> entry : ruleSuffixMap.entrySet()) {
//通过规则匹配后缀正则表达式匹配,记录匹配上的文件地址
if (entry.getKey().matches(file)) {
ruleSuffixFilePathMap.get(entry.getValue()).add(file);
}
}
//检查到普通jar包
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
...@@ -523,7 +527,6 @@ public class Inspector { ...@@ -523,7 +527,6 @@ public class Inspector {
stringBuilder.append(dependency.getGroupId()).append(":").append(dependency.getArtifactId()); stringBuilder.append(dependency.getGroupId()).append(":").append(dependency.getArtifactId());
if (inspectParameter.getAdmin() == 1) { if (inspectParameter.getAdmin() == 1) {
Rule rule = new Rule(); Rule rule = new Rule();
System.out.println(JSON.toJSONString(techJavaSupport));
rule.setTechnologyId(techJavaSupport.getId()); rule.setTechnologyId(techJavaSupport.getId());
rule.setTarget(dependency.getGroupId()); rule.setTarget(dependency.getGroupId());
rule.setTechnologyName(techJavaSupport.getTechnologyName()); rule.setTechnologyName(techJavaSupport.getTechnologyName());
...@@ -597,7 +600,6 @@ public class Inspector { ...@@ -597,7 +600,6 @@ public class Inspector {
} }
return supportStatus; return supportStatus;
} }
public class Counter { public class Counter {
private int i = 0; private int i = 0;
......
...@@ -66,8 +66,6 @@ public class InspectServiceImpl implements InspectService { ...@@ -66,8 +66,6 @@ public class InspectServiceImpl implements InspectService {
//需要重构 //需要重构
inspector.setSuffixLanguageMapping(suffixLanguageMapping); inspector.setSuffixLanguageMapping(suffixLanguageMapping);
ReportVo reportVoReturn = inspector.inspect(); ReportVo reportVoReturn = inspector.inspect();
return reportVoReturn; return reportVoReturn;
} }
......
...@@ -61,9 +61,9 @@ public class RuleServiceImpl implements RuleService { ...@@ -61,9 +61,9 @@ public class RuleServiceImpl implements RuleService {
*/ */
@Override @Override
public void addRule(RuleQo ruleQo) { public void addRule(RuleQo ruleQo) {
List<String> suffixes = ruleQo.getSuffixes(); List<String> suffixes = ruleQo.getSuffix();
for (String suffix : suffixes) { for (String suffix : suffixes) {
Rule rule1 = ruleDao.findByTargetAndSuffixEquals(ruleQo.getTarget(), suffix); Rule rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix,ruleQo.getTechnologyId());
if (rule1 != null) { if (rule1 != null) {
return; return;
} }
...@@ -118,13 +118,18 @@ public class RuleServiceImpl implements RuleService { ...@@ -118,13 +118,18 @@ public class RuleServiceImpl implements RuleService {
@Override @Override
public void upRule(RuleQo ruleQo) { public void upRule(RuleQo ruleQo) {
Rule rule1 = new Rule(); List<String> suffixes = ruleQo.getSuffix();
for (String suffix : suffixes) {
Rule rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix,ruleQo.getTechnologyId());
if (rule1 != null) {
return;
}
rule1.setTarget(ruleQo.getTarget()); rule1.setTarget(ruleQo.getTarget());
rule1.setSuffix(ruleQo.getSuffix()); rule1.setSuffix(suffix);
rule1.setTechnologyId(ruleQo.getTechnologyId()); rule1.setTechnologyId(ruleQo.getTechnologyId());
rule1.setTechnologyName(ruleQo.getTechnologyName()); rule1.setTechnologyName(ruleQo.getTechnologyName());
ruleDao.save(rule1); ruleDao.save(rule1);
}
} }
@Override @Override
......
...@@ -127,74 +127,36 @@ public class BudgetUitl { ...@@ -127,74 +127,36 @@ public class BudgetUitl {
if(inspectParameter.getRecastMethod()==1){ if(inspectParameter.getRecastMethod()==1){
//用户需要适配 //用户需要适配
double refactorProportion = Double.valueOf(doubleHashMap.get(4));
inspectParameter.setProportion(refactorProportion);
Budget codeRefactor = new Budget();
codeRefactor.setBudgetName("代码修改预算");
codeRefactor.setProportion(refactorProportion);
codeRefactor.setSysFund(systemFund);
codeRefactor.setMoneyRate(moneyRate);
codeRefactor.setCoefficient(coefficient);
double fundNotRepair = inspectParameter.getProportion() * pow * systemFund;
double fundRepair=fundNotRepair*coefficient;
fundNotRepair+=fund;
fundRepair+=fund;
fundNotRepair = BigDecimalUtil.get2precision(fundNotRepair);
fundRepair = BigDecimalUtil.get2precision(fundRepair);
if(fundNotRepair<fundRepair){
codeRefactor.setFund(fundNotRepair +"--"+fundRepair);
}else if(fundNotRepair>fundRepair){
codeRefactor.setFund(fundRepair +"--"+fundNotRepair);
}else{
codeRefactor.setFund(fundRepair +"--"+fundNotRepair);
}
codeRefactor.setFundDetail("普通业务开发费用:"+fundNotRepair);
codeRefactor.setFundDetail("普通业务开发费用(修正):"+fundRepair);
codeRefactor.setFundDetail("关键适配技术成本:"+fund);
budgetVo.getBudget().add(codeRefactor);
if(report.getRecastMethod()==1){ if(report.getRecastMethod()==1){
double refactorProportion1 = Double.valueOf(doubleHashMap.get(2)); double refactorProportion1 = Double.valueOf(doubleHashMap.get(2));
inspectParameter.setProportion(refactorProportion1); inspectParameter.setProportion(refactorProportion1);
Budget codeRefactor1 = new Budget(); Budget budget1 = getCodeRefactor("代码重构预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
codeRefactor1.setProportion(refactorProportion1); budgetVo.getBudget().add(budget1);
codeRefactor1.setBudgetName("代码重构预算"); return budgetVo;
codeRefactor1.setMoneyRate(moneyRate);
codeRefactor1.setSysFund(systemFund);
codeRefactor1.setCoefficient(coefficient);
double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund;
double fundRepair1=fundNotRepair1*coefficient;
fundNotRepair1 = BigDecimalUtil.get2precision(fundNotRepair1);
fundRepair1 = BigDecimalUtil.get2precision(fundRepair1);
fundNotRepair1+=fund;
fundRepair1+=fund;
if(fundNotRepair1<fundRepair1){
codeRefactor1.setFund(fundNotRepair1 +"--"+fundRepair1);
}else if(fundNotRepair1>fundRepair1){
codeRefactor1.setFund(fundRepair1 +"--"+fundNotRepair1);
}else{
codeRefactor1.setFund(fundRepair1 +"--"+fundNotRepair1);
}
codeRefactor1.setFundDetail("普通业务开发费用:"+fundNotRepair1);
codeRefactor1.setFundDetail("普通业务开发费用(修正):"+fundRepair1);
codeRefactor1.setFundDetail("关键适配技术成本:"+fund);
budgetVo.getBudget().add(codeRefactor1);
} }
double refactorProportion = Double.valueOf(doubleHashMap.get(4));
inspectParameter.setProportion(refactorProportion);
Budget budget = getCodeRefactor("代码修改预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
budgetVo.getBudget().add(budget);
}else{ }else{
double refactorProportion = Double.valueOf(doubleHashMap.get(3)); double refactorProportion = Double.valueOf(doubleHashMap.get(3));
inspectParameter.setProportion(refactorProportion); inspectParameter.setProportion(refactorProportion);
Budget budget = getCodeRefactor("代码适配预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
budgetVo.getBudget().add(budget);
}
return budgetVo;
}
private Budget getCodeRefactor(String budgetName,double proportion,double pow,int systemFund,int fund,double moneyRate,double coefficient){
Budget codeRefactor1 = new Budget(); Budget codeRefactor1 = new Budget();
codeRefactor1.setProportion(refactorProportion); codeRefactor1.setProportion(proportion);
codeRefactor1.setBudgetName("代码修改预算"); codeRefactor1.setBudgetName(budgetName);
codeRefactor1.setSysFund(systemFund); codeRefactor1.setSysFund(systemFund);
codeRefactor1.setMoneyRate(moneyRate); codeRefactor1.setMoneyRate(moneyRate);
codeRefactor1.setCoefficient(coefficient); codeRefactor1.setCoefficient(coefficient);
double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund; double fundNotRepair1 = proportion * pow * systemFund;
double fundRepair1=fundNotRepair1*coefficient; double fundRepair1=fundNotRepair1*coefficient;
fundNotRepair1+=fund; fundNotRepair1+=fund;
fundRepair1+=fund; fundRepair1+=fund;
...@@ -212,9 +174,6 @@ public class BudgetUitl { ...@@ -212,9 +174,6 @@ public class BudgetUitl {
codeRefactor1.setFundDetail("普通业务开发费用:"+fundNotRepair1); codeRefactor1.setFundDetail("普通业务开发费用:"+fundNotRepair1);
codeRefactor1.setFundDetail("普通业务开发费用(修正):"+fundRepair1); codeRefactor1.setFundDetail("普通业务开发费用(修正):"+fundRepair1);
codeRefactor1.setFundDetail("关键适配技术成本:"+fund); codeRefactor1.setFundDetail("关键适配技术成本:"+fund);
budgetVo.getBudget().add(codeRefactor1); return codeRefactor1;
}
return budgetVo;
} }
} }
...@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/ ...@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/
# mysql\u6570\u636E\u5E93\u914D\u7F6E # mysql\u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://192.168.1.249:3306/bservice?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8 #spring.datasource.url=jdbc:mysql://192.168.1.249:3306/bservice?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.url=jdbc:mysql://localhost:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8 spring.datasource.url=jdbc:mysql://120.55.57.35:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=root spring.datasource.password=root
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论