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

mcj:修复规则添加bug

上级 90ec662c
......@@ -27,7 +27,7 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
Rule findByTarget(String target);
Rule findByTargetAndSuffixEquals(String target,String suffix);
Rule findByTargetAndSuffixEqualsAndTechnologyIdEquals(String target,String suffix,String technologyId);
/**
* 根据技术id查询规则
......
......@@ -23,9 +23,8 @@ public class RuleQo {
/**
* 匹配的文件后缀
*/
private List<String> suffixes;
private List<String> suffix;
private String suffix;
/**
* 适配技术id
......
......@@ -164,6 +164,9 @@ public class Inspector {
if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) {
ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>());
}
if(!ruleMap.containsKey(rule.getTarget()+":"+rule.getSuffix())){
ruleMap.put(rule.getTarget()+":"+rule.getSuffix(),rule);
}
}
try {
//以下为计算文件名称匹配正则表达式
......@@ -226,7 +229,7 @@ public class Inspector {
}
}
//检查到普通jar包
if (file.toString().endsWith(".jar")) {
if (file.getFileName().toString().endsWith(".jar")) {
//新建一个pom对象
ProjectPom projectPom = new ProjectPom();
//截取jar名称
......@@ -523,7 +526,6 @@ public class Inspector {
stringBuilder.append(dependency.getGroupId()).append(":").append(dependency.getArtifactId());
if (inspectParameter.getAdmin() == 1) {
Rule rule = new Rule();
System.out.println(JSON.toJSONString(techJavaSupport));
rule.setTechnologyId(techJavaSupport.getId());
rule.setTarget(dependency.getGroupId());
rule.setTechnologyName(techJavaSupport.getTechnologyName());
......
......@@ -61,9 +61,9 @@ public class RuleServiceImpl implements RuleService {
*/
@Override
public void addRule(RuleQo ruleQo) {
List<String> suffixes = ruleQo.getSuffixes();
List<String> suffixes = ruleQo.getSuffix();
for (String suffix : suffixes) {
Rule rule1 = ruleDao.findByTargetAndSuffixEquals(ruleQo.getTarget(), suffix);
Rule rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix,ruleQo.getTechnologyId());
if (rule1 != null) {
return;
}
......@@ -118,13 +118,18 @@ public class RuleServiceImpl implements RuleService {
@Override
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.setSuffix(ruleQo.getSuffix());
rule1.setSuffix(suffix);
rule1.setTechnologyId(ruleQo.getTechnologyId());
rule1.setTechnologyName(ruleQo.getTechnologyName());
ruleDao.save(rule1);
}
}
@Override
......
......@@ -129,72 +129,112 @@ public class BudgetUitl {
//用户需要适配
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);
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 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);
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);
}
}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;
}
private Budget getCodeRefactor(String budgetName,double proportion,double pow,int systemFund,int fund,double moneyRate,double coefficient){
Budget codeRefactor1 = new Budget();
codeRefactor1.setProportion(refactorProportion);
codeRefactor1.setBudgetName("代码修改预算");
codeRefactor1.setProportion(proportion);
codeRefactor1.setBudgetName(budgetName);
codeRefactor1.setSysFund(systemFund);
codeRefactor1.setMoneyRate(moneyRate);
codeRefactor1.setCoefficient(coefficient);
double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund;
double fundNotRepair1 = proportion * pow * systemFund;
double fundRepair1=fundNotRepair1*coefficient;
fundNotRepair1+=fund;
fundRepair1+=fund;
......@@ -212,9 +252,6 @@ public class BudgetUitl {
codeRefactor1.setFundDetail("普通业务开发费用:"+fundNotRepair1);
codeRefactor1.setFundDetail("普通业务开发费用(修正):"+fundRepair1);
codeRefactor1.setFundDetail("关键适配技术成本:"+fund);
budgetVo.getBudget().add(codeRefactor1);
}
return budgetVo;
return codeRefactor1;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论