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

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

# Conflicts: # src/main/java/com/zjty/inspect/controller/InspectController.java
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);
}
}
...@@ -103,18 +103,18 @@ public class InspectController { ...@@ -103,18 +103,18 @@ public class InspectController {
int support = technologyService.findAllTechnologyNotSupport(); int support = technologyService.findAllTechnologyNotSupport();
reportVo.setTechnologiesRepair(support); reportVo.setTechnologiesRepair(support);
log.info("inspect:代码评估完成"); log.info("inspect:代码评估完成");
Map map = new HashMap(); // Map map = new HashMap();
map.put("inspect", inspect); // map.put("inspect", inspect);
map.put("time", TimeUtil.getTime()); // map.put("time", TimeUtil.getTime());
HashMap<String, List<Warn>> warnMap = inspect.getWarnDetails(); // HashMap<String, List<Warn>> warnMap = inspect.getWarnDetails();
List<Technology> technologies = inspect.getTechnologies(); // List<Technology> technologies = inspect.getTechnologies();
Map techMap = new HashMap(); // Map techMap = new HashMap();
for (Technology technology : technologies) { // for (Technology technology : technologies) {
techMap.put(technology.getTechnologyName(), technology.getSupport()); // techMap.put(technology.getTechnologyName(), technology.getSupport());
} // }
map.put("techMap", techMap); // map.put("techMap", techMap);
map.put("warnMap", warnMap); // map.put("warnMap", warnMap);
map.put("technologies", technologies); // map.put("technologies", technologies);
// try { // try {
// String template = FreemarkerUtils.getTemplate("pg.ftl", map); // String template = FreemarkerUtils.getTemplate("pg.ftl", map);
// String s = inspectService.generateHtml(template, map); // String s = inspectService.generateHtml(template, map);
...@@ -131,8 +131,6 @@ public class InspectController { ...@@ -131,8 +131,6 @@ public class InspectController {
report.setId(RandomUtil.getRandom()); report.setId(RandomUtil.getRandom());
report.setHtmlAddress(reportVo.getHtmlAddress()); report.setHtmlAddress(reportVo.getHtmlAddress());
reportService.saveReport(report); reportService.saveReport(report);
inspectParameter.setReportId(random);
parameterService.saveParameter(inspectParameter);
return ResponseEntity.ok(inspect); return ResponseEntity.ok(inspect);
} }
......
...@@ -9,4 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -9,4 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
*/ */
public interface ConfigParamDao extends JpaRepository<Config,Integer> { public interface ConfigParamDao extends JpaRepository<Config,Integer> {
Config findByName(String name);
} }
...@@ -337,6 +337,7 @@ public class Inspector { ...@@ -337,6 +337,7 @@ public class Inspector {
//将得到的告警信息根据技术id进行转换 //将得到的告警信息根据技术id进行转换
Set<String> collect = warns.stream().map(Warn::getTechnologyId).collect(Collectors.toSet()); Set<String> collect = warns.stream().map(Warn::getTechnologyId).collect(Collectors.toSet());
List<Technology> allById = technologyDao.findAllById(collect); List<Technology> allById = technologyDao.findAllById(collect);
//计算技术金额 //计算技术金额
Integer fund = 0; Integer fund = 0;
for (Technology tech : allById) { for (Technology tech : allById) {
...@@ -355,11 +356,7 @@ public class Inspector { ...@@ -355,11 +356,7 @@ public class Inspector {
//填充依赖 //填充依赖
report.setDependencyVo(dependencyVo); report.setDependencyVo(dependencyVo);
//数据转换 //数据转换
HashMap<String, Technology> map = new HashMap<>(64); HashMap<String, List<Warn>> warnMap = getWarnMap();
for (Technology technology1 : allById) {
map.put(technology1.getId(), technology1);
}
HashMap<String, List<Warn>> warnMap = getWarnMap(map);
ruleDao.saveAll(rules); ruleDao.saveAll(rules);
report.setWarnDetails(warnMap); report.setWarnDetails(warnMap);
return report; return report;
...@@ -457,17 +454,33 @@ public class Inspector { ...@@ -457,17 +454,33 @@ public class Inspector {
techUnKnowSupport = technologyDao.findAllByTechnologyNameEquals("未知依赖(未知)"); 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<>(); HashMap<String, List<Warn>> warnMap = new HashMap<>();
for (Warn warn : warns) { 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<>(); ArrayList<Warn> warns1 = new ArrayList<>();
warns1.add(warn); warns1.add(warn);
warnMap.put(map.get(warn.getTechnologyId()).getTechnologyName(), warns1); warnMap.put(techMap.get(warn.getTechnologyId()).getTechnologyName(), warns1);
} else { }else{
warnMap.get(map.get(warn.getTechnologyId()).getTechnologyName()).add(warn); 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; 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();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论