提交 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,54 +46,49 @@ public class InspectController {
@Autowired
private ReportService reportService;
/**
* 上传代码进行评估
*
* @param years 系统开发时间
* @param systemFund 系统开发费用
* @param modules 模块数
* @param valid 预算数据是否可用
* @param framework 架构
* @param safety 安全能力
* @param disaster 容灾能力
* @param data 数据量
* @param admin 是否管理员
* @param multfile 文件
* @param systemFund 系统开发费用
* @param modules 模块数
* @param valid 预算数据是否可用
* @param framework 架构
* @param safety 安全能力
* @param disaster 容灾能力
* @param data 数据量
* @param admin 是否管理员
* @param multfile 文件
* @return
* @throws IOException
*/
@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);
inspectParameter.setValid(valid);
inspectParameter.setYears(years);
inspectParameter.setDisaster(disaster);
inspectParameter.setData(data);
inspectParameter.setFramework(framework);
inspectParameter.setPath(file.getCanonicalPath());
inspectParameter.setRecastMethod(method);
inspectParameter.setId(UUIDUtil.getUUID());
}
inspectParameter.setUsername(username);
inspectParameter.setSystemFund(systemFund);
inspectParameter.setModules(modules);
inspectParameter.setSafety(safety);
inspectParameter.setTables(tables);
inspectParameter.setValid(valid);
inspectParameter.setYears(years);
inspectParameter.setDisaster(disaster);
inspectParameter.setData(data);
inspectParameter.setFramework(framework);
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;
/**
* 评估时间
......
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,18 +60,21 @@ public class RuleServiceImpl implements RuleService {
*/
@Override
public void addRule(RuleQo ruleQo) {
Rule rule1 = ruleDao.findByTargetAndSuffixEquals(ruleQo.getTarget(), ruleQo.getSuffix());
if (rule1 != null) {
return;
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(suffix);
rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setId(UUIDUtil.getUUID());
ruleDao.save(rule);
}
Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget());
rule.setSuffix(ruleQo.getSuffix());
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论