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

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

......@@ -4,6 +4,8 @@ target/
**/lib/**
**/.DS_Store
./2020-**-**/**
!**/src/main/**
!**/src/test/**
mvnw
......
package com.zjty.inspect.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfig {
public WebMvcConfigurer webMvcConfigurer(){
return new WebMvcConfigurer() {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/freemaker/**").addResourceLocations("file:/opt/inspect/freemaker/");
}
};
}
}
package com.zjty.inspect.controller;
import com.zjty.inspect.entity.Config;
import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.service.ConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/config")
@Api(value = "参数配置接口管理接口",description = "参数配置管理接口,提供页面的增、删、改、查")
public class ConfigController {
@Autowired
private ConfigService configService;
/**
* 查询所有参数配置
* @return 参数配置
*/
@ApiOperation("查询所有参数配置")
@GetMapping
public ResponseEntity getConfigs(){
return ResponseEntity.ok(configService.findAll());
}
/**
* 根据name修改参数
* @param config 参数
* @param name name
* @return
*/
@PostMapping(value = "/{name}")
@ApiOperation("根据name修改参数")
public ResponseEntity update(@RequestBody Config config, @PathVariable String name){
config.setName(name);
configService.updateConfig(config);
return ResponseEntity.ok(200);
}
}
......@@ -27,12 +27,13 @@ import java.util.Map;
/**
* 评估接口
*
* @author mcj
*/
@Slf4j
@RestController
@RequestMapping("/inspect")
@Api(value = "评估接口管理接口",description = "评估管理接口,提供页面的增、删、改、查")
@Api(value = "评估接口管理接口", description = "评估管理接口,提供页面的增、删、改、查")
public class InspectController {
@Autowired
private InspectService inspectService;
......@@ -45,8 +46,10 @@ public class InspectController {
@Autowired
private ReportService reportService;
/**
* 上传代码进行评估
*
* @param years 系统开发时间
* @param systemFund 系统开发费用
* @param modules 模块数
......@@ -62,20 +65,16 @@ public class InspectController {
*/
@PostMapping("/path")
@ApiOperation("上传代码进行评估")
public ResponseEntity inspect(Integer years,Integer systemFund,Integer modules
,String valid,Integer framework,Integer safety,Integer disaster,Integer data
,Integer admin,String projectName,Integer tables,String databaseType,Integer method,String username, MultipartFile multfile) throws IOException {
public ResponseEntity inspect(Integer years, Integer systemFund, Integer modules
, String valid, Integer framework, Integer safety, Integer disaster, Integer data
, Integer admin, String projectName, Integer tables, String databaseType, Integer method, String username, MultipartFile multfile) throws IOException {
File file = FileUtil.saveToLocal(multfile);
log.info("inspect:代码解压完成,地址为{}",file.getCanonicalPath());
InspectParameter inspectParameter = parameterService.getParameterByUsername(username);
log.info("inspect:代码解压完成,地址为{}", file.getCanonicalPath());
InspectParameter inspectParameter = new InspectParameter();
if(inspectParameter==null){
inspectParameter = new InspectParameter();
inspectParameter.setUsername(username);
inspectParameter.setSourceAddress(file.getCanonicalPath());
inspectParameter.setSystemFund(systemFund);
inspectParameter.setAdmin(admin);
inspectParameter.setModules(modules);
inspectParameter.setSafety(safety);
inspectParameter.setTables(tables);
......@@ -84,15 +83,12 @@ public class InspectController {
inspectParameter.setDisaster(disaster);
inspectParameter.setData(data);
inspectParameter.setFramework(framework);
inspectParameter.setPath(file.getCanonicalPath());
inspectParameter.setRecastMethod(method);
inspectParameter.setId(UUIDUtil.getUUID());
}
inspectParameter.setAdmin(admin);
inspectParameter.setSystemFund(systemFund);
inspectParameter.setRecastMethod(method);
inspectParameter.setSourceAddress(file.getCanonicalPath());
ReportVo reportVo = new ReportVo();
int count = technologyService.findAllTechnologyCount();
reportVo.setTechnologiesNum(count);
int support = technologyService.findAllTechnologyNotSupport();
reportVo.setTechnologiesRepair(support);
reportVo.setId(RandomUtil.getRandom());
reportVo.setUploadType("文件上传");
......@@ -100,21 +96,25 @@ public class InspectController {
reportVo.setProjectName(projectName);
reportVo.setSourceAddress(file.getCanonicalPath());
reportVo.setDatabaseType(databaseType);
//查找当前用户的参数是否存在
ReportVo inspect = inspectService.inspect(reportVo,inspectParameter);
ReportVo inspect = inspectService.inspect(reportVo, inspectParameter);
int count = technologyService.findAllTechnologyCount();
reportVo.setTechnologiesNum(count);
int support = technologyService.findAllTechnologyNotSupport();
reportVo.setTechnologiesRepair(support);
log.info("inspect:代码评估完成");
Map map=new HashMap();
map.put("inspect",inspect);
map.put("time",TimeUtil.getTime());
HashMap<String, List<Warn>> warnMap = inspect.getWarnDetails();
List<Technology> technologies = inspect.getTechnologies();
Map techMap=new HashMap();
for (Technology technology : technologies) {
techMap.put(technology.getTechnologyName(),technology.getSupport());
}
map.put("techMap",techMap);
map.put("warnMap",warnMap);
map.put("technologies",technologies);
// Map map = new HashMap();
// map.put("inspect", inspect);
// map.put("time", TimeUtil.getTime());
// HashMap<String, List<Warn>> warnMap = inspect.getWarnDetails();
// List<Technology> technologies = inspect.getTechnologies();
// Map techMap = new HashMap();
// for (Technology technology : technologies) {
// techMap.put(technology.getTechnologyName(), technology.getSupport());
// }
// map.put("techMap", techMap);
// map.put("warnMap", warnMap);
// map.put("technologies", technologies);
// try {
// String template = FreemarkerUtils.getTemplate("pg.ftl", map);
// String s = inspectService.generateHtml(template, map);
......@@ -131,20 +131,19 @@ public class InspectController {
report.setId(RandomUtil.getRandom());
report.setHtmlAddress(reportVo.getHtmlAddress());
reportService.saveReport(report);
inspectParameter.setReportId(random);
parameterService.saveParameter(inspectParameter);
return ResponseEntity.ok(inspect);
}
/**
* git下载代码进行评估
*
* @param inspectParameter 封装
* @return
*/
@PostMapping("/git")
@ApiOperation("git下载代码进行评估")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(),inspectParameter.getGitName());
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter) {
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(), inspectParameter.getGitName());
inspectParameter.setId(UUIDUtil.getUUID());
inspectParameter.setSourceAddress(path);
ReportVo reportVo = new ReportVo();
......
......@@ -9,4 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
*/
public interface ConfigParamDao extends JpaRepository<Config,Integer> {
Config findByName(String name);
}
......@@ -34,4 +34,24 @@ public class Budget {
*/
private String fundDetail;
/**
* 占比
*/
private double proportion;
/**
* 系统开发费用
*/
private Integer sysFund;
/**
* 年利率
*/
private double moneyRate;
/**
* 修正系数
*/
private double coefficient;
}
......@@ -16,5 +16,9 @@ public class BudgetVo {
private List<Budget> budget = new ArrayList<>();
/**
* 修正系数
*/
private List<CoefficientModelVo> coefficientModelVos = new ArrayList<>();
}
......@@ -13,8 +13,8 @@ import java.util.List;
*/
@Data
public class DependencyVo implements Serializable {
private List<ProjectPom> depTreeList = new ArrayList<>();
private List<ProjectPom> frontend = new ArrayList<>();
private List<ProjectPom> depTreeList = new ArrayList<>(64);
private List<ProjectPom> frontend = new ArrayList<>(64);
public void add(ProjectPom projectPom){
depTreeList.add(projectPom);
......
......@@ -91,11 +91,6 @@ public class InspectParameter {
*/
private Integer disaster;
/**
* git地址
*/
private String path;
/**
* null:无效
*/
......
......@@ -99,6 +99,15 @@ public class ReportVo {
*/
private Integer technologiesRepair;
/**
* 文件个数
*/
private Integer fileNum;
/**
* 文件行数
*/
private Integer fileLine;
/**
* 评估时间
......
......@@ -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.*;
......@@ -49,8 +50,8 @@ public class Inspector {
private ParameterDao parameterDao;
private DependencyVo dependencyVo = new DependencyVo();
private ArrayList<Rule> rules = new ArrayList<Rule>();
private ArrayList<Warn> warns = new ArrayList<>();
private ArrayList<Rule> rules = new ArrayList<>(512);
private ArrayList<Warn> warns = new ArrayList<>(64);
/**
* 添加规则时去重使用
......@@ -60,7 +61,7 @@ public class Inspector {
* <p>
* value:随意
*/
private HashMap<String, Rule> ruleMap = new HashMap<>();
private HashMap<String, Rule> ruleMap = new HashMap<>(512);
/**
* 支持的国产化技术
......@@ -80,7 +81,19 @@ public class Inspector {
*/
private InspectParameter inspectParameter;
/**
* 源代码大小
*/
private double codeSize = 0;
/**
* 文件数量
*/
private Integer fileNum = 0;
/**
* 文件行数
*/
private Integer fileLine = 0;
/**
* 报告对象
*/
......@@ -91,14 +104,14 @@ public class Inspector {
* key:java
* value:10
*/
private Map<String, Counter> languageMatchMap = new HashMap<>();
private Map<String, Counter> languageMatchMap = new HashMap<>(16);
/**
* 后缀语言
* key:properties
* value:[{/Users/path},{/Users/path}]
*/
private Map<String, Language> suffixLanguageMapping = new HashMap<>();
private Map<String, Language> suffixLanguageMapping = new HashMap<>(16);
/**
* 规则列表
......@@ -110,9 +123,9 @@ public class Inspector {
* xml:list【路径】
*/
private Map<String, List<Path>> configFileTypePathsMapping = new HashMap<>();
private Map<String, List<Path>> configFileTypePathsMapping = new HashMap<>(512);
private Map<String, List<Path>> ruleSuffixFileMap;
private Map<String, List<Path>> ruleSuffixFilePathMap;
private Map<String, List<Rule>> ruleSuffixMap;
/**
......@@ -120,7 +133,7 @@ public class Inspector {
* key:技术id
* value:Technology
*/
private Map<String, Technology> technologyHashMap = new HashMap<>();
private Map<String, Technology> technologyHashMap = new HashMap<>(64);
/**
* 统计各后缀文件路径与出现次数,顺便解析jar与js文件
......@@ -135,17 +148,21 @@ public class Inspector {
* @return
*/
public ReportVo inspect() {
ruleSuffixFileMap = new HashMap<>();
ruleSuffixFilePathMap = new HashMap<>();
ruleSuffixMap = new HashMap<>();
warns.clear();
rules.clear();
//查询技术,构造支持与非支持技术对象
findExistTechnology();
statisticsLanguage();
this.ruleList = ruleDao.findAll();
//统计项目组成文件构成
//统计配置文件地址
statisticsConfigFile();
this.ruleList = ruleDao.findAll();
//根据后缀名,收集文件进行操作
for (Rule rule : ruleList) {
if (!ruleSuffixFilePathMap.containsKey(rule.getSuffix())) {
ruleSuffixFilePathMap.put(rule.getSuffix(), new ArrayList<>());
}
}
try {
//以下为计算文件名称匹配正则表达式
FileSystem aDefault = FileSystems.getDefault();
......@@ -160,12 +177,13 @@ public class Inspector {
configFileMatcherSuffixMapping.put(aDefault.getPathMatcher("glob:**/*." + s), s);
}
//构造规则后缀的正则表达式
Map<PathMatcher, String> ruleSuffix = new HashMap<>(16);
for (String s : ruleSuffixFileMap.keySet()) {
ruleSuffix.put(aDefault.getPathMatcher("glob:**/*." + s), s);
Map<PathMatcher, String> ruleSuffixMap = new HashMap<>(16);
for (String s : ruleSuffixFilePathMap.keySet()) {
ruleSuffixMap.put(aDefault.getPathMatcher("glob:**/*." + s), s);
}
//文件读取
Files.walkFileTree(Paths.get(inspectParameter.getPath()), new FileVisitor<Path>() {
Files.walkFileTree(Paths.get(inspectParameter.getSourceAddress()), new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
//这里是对于路径(文件夹)的过滤,在这里读不到文件如果能判断,可以返回FileVisitResult.SKIP_SUBTREE 不访问子目录
......@@ -176,7 +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)) {
......@@ -191,10 +217,10 @@ public class Inspector {
configFileTypePathsMapping.get(entry.getValue()).add(file);
}
}
for (Map.Entry<PathMatcher, String> entry : ruleSuffix.entrySet()) {
for (Map.Entry<PathMatcher, String> entry : ruleSuffixMap.entrySet()) {
//通过规则匹配后缀正则表达式匹配,记录匹配上的文件地址
if (entry.getKey().matches(file)) {
ruleSuffixFileMap.get(entry.getValue()).add(file);
ruleSuffixFilePathMap.get(entry.getValue()).add(file);
}
}
//检查到普通jar包
......@@ -253,6 +279,8 @@ public class Inspector {
e.printStackTrace();
}
inspectParameter.setCodeSize((int) codeSize);
report.setFileNum(fileNum);
report.setFileLine(fileLine);
log.info("inspect:源代码扫描完成,统计各个文件后缀完成");
return analysis();
}
......@@ -266,10 +294,8 @@ public class Inspector {
public ReportVo analysis() {
DependencyVo dependencyVo = new DependencyVo();
setReportLanguageAndFrame();
//查询所有规则
ruleTransform(report.getRecastMethod());
//解析配置文件集合
for (Map.Entry<String, List<Path>> entry : configFileTypePathsMapping.entrySet()) {
switch (entry.getKey()) {
......@@ -311,7 +337,7 @@ public class Inspector {
}
}
//指定后缀到文件匹配关键字
for (Map.Entry<String, List<Path>> entry : ruleSuffixFileMap.entrySet()) {
for (Map.Entry<String, List<Path>> entry : ruleSuffixFilePathMap.entrySet()) {
//entry,key为后缀,value为文件列表
String key = entry.getKey();
//从ruleSuffixList获取指定后缀的规则列表
......@@ -336,6 +362,7 @@ public class Inspector {
//将得到的告警信息根据技术id进行转换
Set<String> collect = warns.stream().map(Warn::getTechnologyId).collect(Collectors.toSet());
List<Technology> allById = technologyDao.findAllById(collect);
//计算技术金额
Integer fund = 0;
for (Technology tech : allById) {
......@@ -354,13 +381,11 @@ public class Inspector {
//填充依赖
report.setDependencyVo(dependencyVo);
//数据转换
HashMap<String, Technology> map = new HashMap<>();
for (Technology technology1 : allById) {
map.put(technology1.getId(), technology1);
}
HashMap<String, List<Warn>> warnMap = getWarnMap(map);
HashMap<String, List<Warn>> warnMap = getWarnMap();
ruleDao.saveAll(rules);
report.setWarnDetails(warnMap);
fileLine=0;
fileNum=0;
return report;
}
......@@ -385,9 +410,10 @@ public class Inspector {
//设置是否需要重构
if (languageMatchMap.get("jsp").i == 0 & languageMatchMap.get("java").i == 0) {
report.setRecastMethod(RecastMethod.适配重构.getStatus());
log.info("inspect:代码解析完成,建议进行");
log.info("inspect:代码解析完成,建议进行适配重构");
} else {
report.setRecastMethod(RecastMethod.代码修改.getStatus());
log.info("inspect:代码解析完成,建议进行代码修改");
}
}
......@@ -413,12 +439,6 @@ public class Inspector {
for (Technology technology : technologies) {
technologyHashMap.put(technology.getId(), technology);
}
//根据后缀名,收集文件进行操作
for (Rule rule : ruleList) {
if (!ruleSuffixFileMap.containsKey(rule.getSuffix())) {
ruleSuffixFileMap.put(rule.getSuffix(), new ArrayList<>());
}
}
//根据后缀名进行规则收集
for (Rule rule : ruleList) {
if (!ruleSuffixMap.containsKey(rule.getSuffix())) {
......@@ -428,6 +448,15 @@ public class Inspector {
ruleSuffixMap.get(rule.getSuffix()).add(rule);
}
}
ArrayList<String> keys = new ArrayList<>();
for (String s : ruleSuffixFilePathMap.keySet()) {
if(!ruleSuffixMap.containsKey(s)){
keys.add(s);
}
}
for (String key : keys) {
ruleSuffixFilePathMap.remove(key);
}
}
private void statisticsConfigFile() {
......@@ -452,17 +481,33 @@ public class Inspector {
techUnKnowSupport = technologyDao.findAllByTechnologyNameEquals("未知依赖(未知)");
}
private HashMap<String, List<Warn>> getWarnMap(HashMap<String, Technology> map) {
private HashMap<String, List<Warn>> getWarnMap() {
List<Technology> technologies = technologyDao.findAll();
HashMap<String, Technology> techMap = new HashMap<>();
for (Technology technology : technologies) {
if(!techMap.containsKey(technology.getId())){
techMap.put(technology.getId(),technology);
}
}
HashMap<String, List<Warn>> warnMap = new HashMap<>();
for (Warn warn : warns) {
if (!warnMap.containsKey(map.get(warn.getTechnologyId()).getTechnologyName())) {
if(!warnMap.containsKey(techMap.get(warn.getTechnologyId()).getId())){
ArrayList<Warn> warns1 = new ArrayList<>();
warns1.add(warn);
warnMap.put(map.get(warn.getTechnologyId()).getTechnologyName(), warns1);
} else {
warnMap.get(map.get(warn.getTechnologyId()).getTechnologyName()).add(warn);
warnMap.put(techMap.get(warn.getTechnologyId()).getTechnologyName(), warns1);
}else{
warnMap.get(techMap.get(warn.getTechnologyId()).getTechnologyName()).add(warn);
}
}
for (Technology technology : technologies) {
if(!warnMap.containsKey(technology.getTechnologyName())){
ArrayList<Warn> warns1 = new ArrayList<>();
warnMap.put(technology.getTechnologyName(), warns1);
}
}
return warnMap;
}
......
package com.zjty.inspect.service;
import com.zjty.inspect.entity.Config;
import java.util.List;
public interface ConfigService {
public void updateConfig(Config config);
List<Config> findAll();
}
package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.ConfigParamDao;
import com.zjty.inspect.entity.Config;
import com.zjty.inspect.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ConfigServiceImpl implements ConfigService {
@Autowired
private ConfigParamDao configParamDao;
@Override
public void updateConfig(Config config) {
Config c = configParamDao.findByName(config.getName());
c.setValue(config.getValue());
configParamDao.save(c);
}
@Override
public List<Config> findAll() {
return configParamDao.findAll();
}
}
......@@ -60,20 +60,23 @@ public class RuleServiceImpl implements RuleService {
*/
@Override
public void addRule(RuleQo ruleQo) {
Rule rule1 = ruleDao.findByTargetAndSuffixEquals(ruleQo.getTarget(), ruleQo.getSuffix());
List<String> suffixes = ruleQo.getSuffixes();
for (String suffix : suffixes) {
Rule rule1 = ruleDao.findByTargetAndSuffixEquals(ruleQo.getTarget(), suffix);
if (rule1 != null) {
return;
}
Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget());
rule.setSuffix(ruleQo.getSuffix());
rule.setSuffix(suffix);
rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setId(UUIDUtil.getUUID());
ruleDao.save(rule);
}
}
/**
* 条件查询+分页
*
......@@ -114,17 +117,15 @@ public class RuleServiceImpl implements RuleService {
@Override
public void upRule(RuleQo ruleQo) {
Rule rule1 = ruleDao.findByTarget(ruleQo.getTarget());
if (rule1 != null) {
Rule rule1 = ruleDao.findByTarget(ruleQo.getId());
if (rule1 == null) {
return;
}
Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget());
rule.setSuffix(ruleQo.getSuffix());
rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setId(ruleQo.getId());
ruleDao.save(rule);
rule1.setTarget(ruleQo.getTarget());
rule1.setSuffix(ruleQo.getSuffix());
rule1.setTechnologyId(ruleQo.getTechnologyId());
rule1.setTechnologyName(ruleQo.getTechnologyName());
ruleDao.save(rule1);
}
@Override
......
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,14 +121,28 @@ public class BudgetUitl {
budgetVo.getCoefficientModelVos().add(coefficientModelVo);
}
coefficient = BigDecimalUtil.get2precision(coefficient);
if(inspectParameter.getRecastMethod()==1){
//用户需要适配
double refactorProportion = Double.valueOf(doubleHashMap.get(4));
inspectParameter.setProportion(refactorProportion);
Budget codeRefactor = new Budget();
codeRefactor.setBudgetName("代码修改预算");
double fundNotRepair = inspectParameter.getProportion() * pow * systemFund + fund;
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){
......@@ -143,9 +158,19 @@ public class BudgetUitl {
double refactorProportion1 = Double.valueOf(doubleHashMap.get(2));
inspectParameter.setProportion(refactorProportion1);
Budget codeRefactor1 = new Budget();
codeRefactor1.setProportion(refactorProportion1);
codeRefactor1.setBudgetName("代码重构预算");
double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund + fund;
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){
......@@ -162,9 +187,19 @@ public class BudgetUitl {
double refactorProportion = Double.valueOf(doubleHashMap.get(3));
inspectParameter.setProportion(refactorProportion);
Budget codeRefactor1 = new Budget();
codeRefactor1.setProportion(refactorProportion);
codeRefactor1.setBudgetName("代码修改预算");
double fundNotRepair1 = inspectParameter.getProportion() * pow * systemFund + fund;
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){
......
......@@ -43,15 +43,14 @@ public class FileUtil {
// MultipartFile to File
multipartFile.transferTo(excelFile);
if(prefix.equals(".zip")){
FileUtil.unPackZip(excelFile,"", ".././"+name+"/"+split1[0]);
FileUtil.unPackZip(excelFile,"", "./"+name+"/"+split1[0]);
}else{
FileUtil.unPackRar(excelFile, ".././"+name+"/"+split1[0]);
FileUtil.unPackRar(excelFile, "./"+name+"/"+split1[0]);
}
String[] split = fileName.split("\\.");
File file3 = new File(".././"+name+"/"+split1[0]+"/"+split[0]);
File file3 = new File("./"+name+"/"+split1[0]+"/"+split[0]);
excelFile.delete();
log.info("end unpack file");
System.out.println(file3.getCanonicalPath());
return file3;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论