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

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

......@@ -47,7 +47,44 @@ public class BrowserDifficulty {
/**
* 用户额外需求
*/
private String demand = "*********";
/**
* 地理信息系统 int 1:是 2:否
*/
private Integer geography;
/**
* 调用外设
*/
private Integer peripheral;
/**
*动画
*/
private Integer animation;
/**
* 3d展示
*/
private Integer threeD;
/**
* 公文显现与编辑
*/
private Integer document;
/**
* 多媒体
*/
private Integer media;
/**
* Flash
*/
private Integer flash;
/**
* 其他
*/
private Integer otherDemand;
}
......@@ -44,4 +44,14 @@ public class Budget {
*/
private Integer sysFund;
/**
* 年利率
*/
private double moneyRate;
/**
* 修正系数
*/
private double coefficient;
}
......@@ -99,6 +99,15 @@ public class ReportVo {
*/
private Integer technologiesRepair;
/**
* 文件个数
*/
private Integer fileNum;
/**
* 文件行数
*/
private Integer fileLine;
/**
* 评估时间
......
package com.zjty.inspect.enums;
import jdk.internal.dynalink.beans.BeansLinker;
/**
* <h4>Description : 兼容的浏览器</h4>
......
......@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.charset.MalformedInputException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
......@@ -80,7 +81,19 @@ public class Inspector {
*/
private InspectParameter inspectParameter;
/**
* 源代码大小
*/
private double codeSize = 0;
/**
* 文件数量
*/
private Integer fileNum = 0;
/**
* 文件行数
*/
private Integer fileLine = 0;
/**
* 报告对象
*/
......@@ -169,6 +182,7 @@ public class Inspector {
ruleSuffixMap.put(aDefault.getPathMatcher("glob:**/*." + s), s);
}
//文件读取
Files.walkFileTree(Paths.get(inspectParameter.getSourceAddress()), new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
......@@ -180,6 +194,15 @@ 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)) {
......@@ -256,6 +279,8 @@ public class Inspector {
e.printStackTrace();
}
inspectParameter.setCodeSize((int) codeSize);
report.setFileNum(fileNum);
report.setFileLine(fileLine);
log.info("inspect:源代码扫描完成,统计各个文件后缀完成");
return analysis();
}
......@@ -359,6 +384,8 @@ public class Inspector {
HashMap<String, List<Warn>> warnMap = getWarnMap();
ruleDao.saveAll(rules);
report.setWarnDetails(warnMap);
fileLine=0;
fileNum=0;
return report;
}
......
package com.zjty.inspect.utils;
import java.math.BigDecimal;
/**
* @author Mcj
* @date 2020-03-06 16:38
*/
public class BigDecimalUtil {
public static double get2precision(double data){
BigDecimal bigDecimal = new BigDecimal(data);
double value = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return value;
}
public static void main(String[] args) {
double precision = BigDecimalUtil.get2precision(1.1111111D);
System.out.println(precision);
}
}
......@@ -6,6 +6,7 @@ import com.zjty.inspect.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -120,6 +121,8 @@ public class BudgetUitl {
budgetVo.getCoefficientModelVos().add(coefficientModelVo);
}
coefficient = BigDecimalUtil.get2precision(coefficient);
if(inspectParameter.getRecastMethod()==1){
//用户需要适配
double refactorProportion = Double.valueOf(doubleHashMap.get(4));
......@@ -128,10 +131,18 @@ public class BudgetUitl {
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){
......@@ -149,9 +160,15 @@ public class BudgetUitl {
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){
......@@ -173,10 +190,16 @@ public class BudgetUitl {
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){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论