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

mcj:修改预算返回,修改越界bug

上级 876b55e4
......@@ -288,7 +288,12 @@ public class InspectController {
//中间件难度
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<>();
for (PomDependency pomDependency:dependencies) {
String groupId = pomDependency.getGroupId();
......
......@@ -46,7 +46,7 @@ public class CoefficientModel {
private Integer scale;
public Double countCoefficient(Integer data) {
if(data==null){
if(data==null || data<0){
return 1D;
}
if(data<min){
......
......@@ -150,8 +150,10 @@ public class Inspector {
* @return
*/
public ReportVo inspect() {
codeSize=0;
ruleSuffixFilePathMap = new HashMap<>();
ruleSuffixMap = new HashMap<>();
technologyHashMap = new HashMap<>();
warns.clear();
rules.clear();
//查询技术,构造支持与非支持技术对象
......@@ -199,41 +201,10 @@ public class Inspector {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
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包
if (file.getFileName().toString().endsWith(".jar")) {
//新建一个pom对象
ProjectPom projectPom = new ProjectPom();
//截取jar名称
String patten = RegexUtil.patten(file.getFileName().toString());
//新建一个依赖对象
PomDependency pomDependency = new PomDependency();
......@@ -267,6 +238,36 @@ public class Inspector {
}
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;
}
......@@ -599,7 +600,6 @@ public class Inspector {
}
return supportStatus;
}
public class Counter {
private int i = 0;
......
......@@ -66,8 +66,6 @@ public class InspectServiceImpl implements InspectService {
//需要重构
inspector.setSuffixLanguageMapping(suffixLanguageMapping);
ReportVo reportVoReturn = inspector.inspect();
return reportVoReturn;
}
......
......@@ -127,103 +127,25 @@ public class BudgetUitl {
if(inspectParameter.getRecastMethod()==1){
//用户需要适配
double refactorProportion = Double.valueOf(doubleHashMap.get(4));
inspectParameter.setProportion(refactorProportion);
Budget budget = getCodeRefactor("代码修改预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
budgetVo.getBudget().add(budget);
// 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){
double refactorProportion1 = Double.valueOf(doubleHashMap.get(2));
inspectParameter.setProportion(refactorProportion1);
Budget budget1 = getCodeRefactor("代码重构预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
budgetVo.getBudget().add(budget1);
// Budget codeRefactor1 = new Budget();
// codeRefactor1.setProportion(refactorProportion1);
// codeRefactor1.setBudgetName("代码重构预算");
// 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);
return budgetVo;
}
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{
double refactorProportion = Double.valueOf(doubleHashMap.get(3));
inspectParameter.setProportion(refactorProportion);
Budget budget = getCodeRefactor("代码适配预算", inspectParameter.getProportion(), pow, systemFund, fund, moneyRate, coefficient);
budgetVo.getBudget().add(budget);
// Budget codeRefactor1 = new Budget();
// codeRefactor1.setProportion(refactorProportion);
// codeRefactor1.setBudgetName("代码修改预算");
// codeRefactor1.setSysFund(systemFund);
// codeRefactor1.setMoneyRate(moneyRate);
// codeRefactor1.setCoefficient(coefficient);
// double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund;
// double fundRepair1=fundNotRepair1*coefficient;
// fundNotRepair1+=fund;
// fundRepair1+=fund;
//
// fundNotRepair1 = BigDecimalUtil.get2precision(fundNotRepair1);
// fundRepair1 = BigDecimalUtil.get2precision(fundRepair1);
//
// 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);
}
}
return budgetVo;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论