提交 b661068b authored 作者: czq's avatar czq

czq

package com.zjty.inspect.controller;
import com.zjty.inspect.service.CategoryService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/category")
@Api(value = "类型管理接口",description = "类型管理接口,提供页面的增、删、改、查")
public class CategoryCotroller {
@Autowired
private CategoryService categoryService;
/**
* 查询所有类型
* @return
*/
@ApiOperation("查询所有类型")
@GetMapping
public ResponseEntity getCategorys(){
return ResponseEntity.ok(categoryService.findAll());
}
}
......@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/config")
......@@ -29,16 +31,15 @@ public class ConfigController {
}
/**
* 根据name修改参数
* @param config 参数
* @param name name
* 根据id修改参数
* @param
* @param
* @return
*/
@PostMapping(value = "/{name}")
@ApiOperation("根据name修改参数")
public ResponseEntity update(@RequestBody Config config, @PathVariable String name){
config.setName(name);
configService.updateConfig(config);
@PostMapping("/updates")
@ApiOperation("根据id修改参数,需要传id和value")
public ResponseEntity update(@RequestBody List<Config> configs){
configService.updateConfig(configs);
return ResponseEntity.ok(200);
}
}
......@@ -103,29 +103,9 @@ public class InspectController {
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);
// try {
// String template = FreemarkerUtils.getTemplate("pg.ftl", map);
// String s = inspectService.generateHtml(template, map);
// String filePath = FileUtil.createFilePath();
// File file1 = new File("./pgbg/" + filePath + "/" + file.getName() + ".html");
// FileUtil.write(s,"./pgbg/"+filePath+"/"+file.getName()+".html");
// reportVo.setHtmlAddress(file1.getCanonicalPath());
// System.out.println("内容"+s);
// } catch (TemplateException e) {
// e.printStackTrace();
// }
// String filePath = inspectService.freemakerData(inspect,count,support);
reportVo.setHtmlAddress(null);
Report report = new Report();
String random = RandomUtil.getRandom();
report.setId(RandomUtil.getRandom());
......
package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface CategoryDao extends JpaRepository<Category,String>, JpaSpecificationExecutor<Category> {
}
......@@ -3,6 +3,8 @@ package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Config;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
/**
* @author Mcj
* @date 2020-03-05 20:55
......@@ -10,4 +12,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface ConfigParamDao extends JpaRepository<Config,Integer> {
Config findByName(String name);
Optional<Config> findById(String id);
}
......@@ -50,6 +50,10 @@ public class Technology {
@ApiModelProperty(value = "是否支持",example = "1")
private Integer support;
/**
* 分类id
*/
private String category_id;
/**
* 技术类型
* 1:前端技术
......
package com.zjty.inspect.service;
import com.zjty.inspect.entity.Category;
import java.util.List;
public interface CategoryService {
List<Category> findAll();
}
......@@ -6,6 +6,6 @@ import java.util.List;
public interface ConfigService {
public void updateConfig(Config config);
public void updateConfig(List<Config> configs);
List<Config> findAll();
}
......@@ -14,4 +14,8 @@ public interface InspectService {
*/
ReportVo inspect(ReportVo reportVo,InspectParameter inspectParameter);
String generateHtml(String templateContent, Map model );
String freemakerData(ReportVo inspect, int count, int support);
}
package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.CategoryDao;
import com.zjty.inspect.entity.Category;
import com.zjty.inspect.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
@Autowired
private CategoryDao categoryDao;
@Override
public List<Category> findAll() {
return categoryDao.findAll();
}
}
......@@ -6,17 +6,28 @@ import com.zjty.inspect.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
public class ConfigServiceImpl implements ConfigService {
@Autowired
private ConfigParamDao configParamDao;
@Override
public void updateConfig(Config config) {
Config c = configParamDao.findByName(config.getName());
public void updateConfig(List<Config> configs) {
List<Config> configList=new ArrayList<>();
for (Config config : configs) {
Optional<Config> optional = configParamDao.findById(config.getId());
if (optional.isPresent()) {
Config c = optional.get();
c.setValue(config.getValue());
configParamDao.save(c);
configList.add(c);
}
}
configParamDao.saveAll(configList);
}
@Override
......
package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.ReportDao;
import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.entity.Report;
import com.zjty.inspect.entity.ReportVo;
import com.zjty.inspect.entity.*;
import com.zjty.inspect.enums.Language;
import com.zjty.inspect.service.InspectService;
import com.zjty.inspect.inspect.Inspector;
import com.zjty.inspect.service.ParameterService;
import com.zjty.inspect.service.TechnologyService;
import com.zjty.inspect.utils.FileUtil;
import com.zjty.inspect.utils.FreemarkerUtils;
import com.zjty.inspect.utils.RandomUtil;
import com.zjty.inspect.utils.TimeUtil;
import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -33,6 +38,8 @@ public class InspectServiceImpl implements InspectService {
@Autowired
private ReportDao reportDao;
@Autowired
private TechnologyService technologyService;
@Autowired
private ParameterService parameterService;
......@@ -64,8 +71,44 @@ public class InspectServiceImpl implements InspectService {
return reportVoReturn;
}
/**
* 处理数据
* @return
* count 总共的关键技术
* notSupport 不支持的关键技术数量
*/
@Override
public String freemakerData(ReportVo inspect, int count, int notSupport) {
try {
Map map = new HashMap();
map.put("inspect", inspect);
map.put("time", TimeUtil.getTime());
HashMap<String, List<Warn>> warnMap = inspect.getWarnDetails();
List<Technology> technologies = technologyService.findAllTechnology();
Map techMap = new HashMap();
for (Technology technology : technologies) {
techMap.put(technology.getTechnologyName(), technology.getSupport());
}
map.put("techMap", techMap);
map.put("count",count);
map.put("notSupport",notSupport);
map.put("warnMap", warnMap);
map.put("technologies", technologies);
String template = FreemarkerUtils.getTemplate("pg.ftl", map);
String s = generateHtml(template, map);
String filePath = FileUtil.createFilePath();
FileUtil.write(s,"/opt/inspect/freemaker/"+filePath+"/"+inspect.getProjectName()+".html");
String fn="/freemaker/"+filePath+"/"+inspect.getProjectName()+".html";
return fn;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//执行静态化
public String generateHtml(String templateContent,Map model ){
//创建配置对象
Configuration configuration = new Configuration(Configuration.getVersion());
//创建模板加载器
......@@ -85,4 +128,6 @@ public class InspectServiceImpl implements InspectService {
return null;
}
}
......@@ -105,8 +105,8 @@ public class RuleServiceImpl implements RuleService {
@Override
public Predicate toPredicate(Root<Rule> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicateList = new ArrayList<Predicate>();
if (searchMap.get("target") != null && !"".equals(searchMap.get("target"))) {
predicateList.add(cb.like(root.get("target").as(String.class), "%" + (String) searchMap.get("target") + "%"));
if (searchMap.get("technologyName") != null && !"".equals(searchMap.get("technologyName"))) {
predicateList.add(cb.like(root.get("technologyName").as(String.class), "%" + (String) searchMap.get("technologyName") + "%"));
}
return cb.and(predicateList.toArray(new Predicate[predicateList.size()]));
......@@ -118,7 +118,7 @@ public class RuleServiceImpl implements RuleService {
@Override
public void upRule(RuleQo ruleQo) {
Rule rule1 = ruleDao.findByTarget(ruleQo.getId());
if (rule1 == null) {
if (rule1 != null) {
return;
}
rule1.setTarget(ruleQo.getTarget());
......
......@@ -2,10 +2,7 @@ package com.zjty.inspect.utils;
import com.alibaba.fastjson.JSON;
import com.zjty.inspect.entity.*;
import com.zjty.inspect.enums.CompatibleBrowser;
import com.zjty.inspect.enums.DatabaseType;
import com.zjty.inspect.enums.Framework;
import com.zjty.inspect.enums.MiddlewareEnum;
import com.zjty.inspect.enums.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -48,8 +45,8 @@ public class WorkLoadUtil {
Browser browser = reform.getBrowser();
if(browser!=null) {
//如果原浏览器包含IE,+10
System.out.println(JSON.toJSONString(browser));
if (browser.getCompatibleBrowsers().contains(CompatibleBrowser.IETRIDENT)) {
List<CompatibleBrowser> compatibleBrowsers = browser.getCompatibleBrowsers();
if (compatibleBrowsers!=null&&compatibleBrowsers.contains(CompatibleBrowser.IETRIDENT)) {
score += 10;
logger.info("包含IE+10:" + score);
}
......@@ -101,10 +98,13 @@ public class WorkLoadUtil {
Middleware middleware = reform.getMiddleware();
if(middleware!=null) {
List<MiddlewareEnum> middlewareEnums = middleware.getMiddlewareEnums();
int effectMidNum = middlewareEnums.size();
int effectMidNum = 0;
if(middlewareEnums!=null) {
effectMidNum = middlewareEnums.size();
if (middlewareEnums.contains(MiddlewareEnum.TOMCAT)) {
effectMidNum--;
}
}
if (middleware.getOtherMiddleware() != null && !middleware.getOtherMiddleware().trim().equals("")) {
effectMidNum++;
}
......@@ -138,10 +138,13 @@ public class WorkLoadUtil {
Database database = reform.getDatabase();
if(database!=null) {
List<DatabaseType> databaseType = database.getDatabaseType();
int effectDatabaseNum = databaseType.size();
int effectDatabaseNum = 0;
if(databaseType!=null) {
effectDatabaseNum = databaseType.size();
if (databaseType.contains(DatabaseType.MYSQL)) {
effectDatabaseNum--;
}
}
if (database.getOtherType() != null && !database.getOtherType().trim().equals("")) {
effectDatabaseNum++;
}
......@@ -223,7 +226,7 @@ public class WorkLoadUtil {
//f:工作量(马)
//r:人工费
public AssessmentReport result(Reform reform,AssessmentReport report,double f,double r){
public void result(Reform reform,AssessmentReport report,double f,double r){
logger.info("计算工作量,输入:"+JSON.toJSONString(report));
//总计J = F(马) * 人工费
......@@ -318,7 +321,7 @@ public class WorkLoadUtil {
eDatabase *= (1+(databaseDifficulty.getSafe()==1?1:0)/100)*
(1+(databaseDifficulty.getSeparate()==1?1:0)/100)*
(1+(databaseDifficulty.getPerformance()==1?1:0)/100)*
(1+(databaseDifficulty.getOtherContent()!=null?1:0)/100);
(1+(databaseDifficulty.getOtherContent()==1?1:0)/100);
logger.info("数据库难度:"+eDatabase);
databaseDifficulty.setDifficulty(eDatabase);
//工作量2*j*(z-1)
......@@ -367,12 +370,43 @@ public class WorkLoadUtil {
report.getWorkload().getDeploy().setDevelopmentVolume(deploymentWorkload);
report.getWorkload().getDeploy().setCorrectionFactor(deploymentCorrectionFactor);
report.getWorkload().getTotal().setDevelopmentVolume(totalWorkload);
return report;
}
public static void main(String[] args) {
WorkLoadUtil workLoadUtil = new WorkLoadUtil();
workLoadUtil.result(new Reform(),new AssessmentReport(),1,1);
String reform = "{\n" +
"\t\"mode\":1,\n" +
"\t\"reformUrl\":\"www\",\n" +
"\t\"adaptationUrl\":\"\",\n" +
"\t\"projectName\":\"\",\n" +
"\t\"uploadType\":\"\",\n" +
"\t\"codeUrl\":\"\",\n" +
"\t\"moduleNum\":\"\",\n" +
"\t\"language\":\"\",\n" +
"\t\"cost\":2.3,\n" +
"\t\"cycle\":1,\n" +
"\t\"serverNum\":1,\n" +
"\t\"applicationType\":\"OA\",\n" +
"\t\"address\":1,\n" +
"\t\"secret\":1,\n" +
"\t\"message\":\"\",\n" +
"\t\"systemStructure\":{\n" +
"\t\t\"distributed\":1,\n" +
"\t\t\"loadBanlance\":1,\n" +
"\t\t\"disaster\":1\n" +
"\t},\n" +
"\t\"browser\":{\n" +
// "\t\t\"compatibleBrowsers\":\"IETRIDENT\",\n" +
// "\t\t\"peripheral\":1\n" +
"\t},\n" +
"\t\"middleware\":{\n" +
"\t\t\"web\":1\n" +
"\t},\n" +
"\t\"database\":{\n" +
"\t\t\"otherType\":\"aaa\"\n" +
"\t},\n" +
"\t\"strategy\":1\n" +
"}";
workLoadUtil.result(JSON.parseObject(reform,Reform.class),new AssessmentReport(),1,1);
}
}
......@@ -224,8 +224,8 @@
<div class="line"></div>
<div class="onAnaly" id="thirdClick">
<div class="onAonAnalysis">关键技术总共:<span>1000</span></div>
<div class="onAonAnalysis">需要改造的关键技术:<span>1000</span></div>
<div class="onAonAnalysis">关键技术总共:<span>${count?default("0")}</span></div>
<div class="onAonAnalysis">需要改造的关键技术:<span>${notSupport?default("0")}</span></div>
<div class="onAonAnalysis">泰源系统安可改造评估引擎:<span>版本号:10.6.9</span></div>
</div>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论