提交 3223f7ff authored 作者: liujie's avatar liujie

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

...@@ -5,6 +5,7 @@ import com.zjty.inspect.dao.ConfigParamDao; ...@@ -5,6 +5,7 @@ import com.zjty.inspect.dao.ConfigParamDao;
import com.zjty.inspect.entity.*; import com.zjty.inspect.entity.*;
import com.zjty.inspect.enums.LanguageEnum; import com.zjty.inspect.enums.LanguageEnum;
import com.zjty.inspect.service.*; import com.zjty.inspect.service.*;
import com.zjty.inspect.thread.task.AsyncTask;
import com.zjty.inspect.utils.*; import com.zjty.inspect.utils.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -53,6 +54,8 @@ public class InspectController { ...@@ -53,6 +54,8 @@ public class InspectController {
@Value("${upload.location}") @Value("${upload.location}")
private String uploadPath; private String uploadPath;
@Autowired
private AsyncTask asyncTask;
//应用类型转换:小型0 //应用类型转换:小型0
Integer[] small = {3, 4}; Integer[] small = {3, 4};
//应用类型转换:中型2 //应用类型转换:中型2
...@@ -390,6 +393,7 @@ public class InspectController { ...@@ -390,6 +393,7 @@ public class InspectController {
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile) { private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile) {
try { try {
File file = FileUtil.saveToLocal(multfile); File file = FileUtil.saveToLocal(multfile);
String name = file.getName(); String name = file.getName();
String path = file.getCanonicalPath(); String path = file.getCanonicalPath();
return ResponseEntity.ok(new com.zjty.inspect.entity.File(name, path)); return ResponseEntity.ok(new com.zjty.inspect.entity.File(name, path));
......
...@@ -261,6 +261,7 @@ public class Inspector { ...@@ -261,6 +261,7 @@ public class Inspector {
* 比对源文件数量得出语言架构 * 比对源文件数量得出语言架构
*/ */
private void setReportLanguageAndFrame() { private void setReportLanguageAndFrame() {
HashSet<LanguageEnum> languageEnums = new HashSet<>();
String most = null; String most = null;
int mostStatus = 0; int mostStatus = 0;
int maxnum = 0; int maxnum = 0;
...@@ -272,20 +273,28 @@ public class Inspector { ...@@ -272,20 +273,28 @@ public class Inspector {
mostStatus = language.getCode(); mostStatus = language.getCode();
maxnum = entry.getValue().getNumber(); maxnum = entry.getValue().getNumber();
} }
if (entry.getValue().getNumber() > 0) {
LanguageEnum language = suffixLanguageMapping.get(entry.getKey());
languageEnums.add(language);
}
} }
//设置语言 List<LanguageEnum> languageEnums1 = languageEnums.stream()
report.setLanguage(most == null ? LanguageEnum.NONE.getCode() : mostStatus); .filter(e -> e.getCode() != 4 & e.getCode() != 5 & e.getCode() != 6)
//设置架构 .collect(Collectors.toList());
report.setFramework(languageMatchMap.get("jsp").i > 0 ? Framework.MIXTURE.getStatus() : Framework.SEPARATE.getStatus()); if (!languageEnums1.isEmpty()) {
//设置是否需要重构
if (languageMatchMap.get("jsp").i == 0 & languageMatchMap.get("java").i == 0) {
report.setRecastMethod(RecastMethod.RECONSITUTION.getStatus()); report.setRecastMethod(RecastMethod.RECONSITUTION.getStatus());
log.info("inspect:代码解析完成,建议进行适配重构"); log.info("inspect:代码解析完成,建议进行适配重构");
} else { } else {
report.setRecastMethod(RecastMethod.MODIFICATION.getStatus()); report.setRecastMethod(RecastMethod.MODIFICATION.getStatus());
log.info("inspect:代码解析完成,建议进行代码修改"); log.info("inspect:代码解析完成,建议进行代码修改");
} }
//设置语言
report.setLanguage(most == null ? LanguageEnum.NONE.getCode() : mostStatus);
//设置架构
report.setFramework(languageMatchMap.get("jsp").i > 0 ? Framework.MIXTURE.getStatus() : Framework.SEPARATE.getStatus());
//设置是否需要重构
} }
/** /**
...@@ -605,8 +614,8 @@ public class Inspector { ...@@ -605,8 +614,8 @@ public class Inspector {
try { try {
List<String> allLines = Files.readAllLines(file); List<String> allLines = Files.readAllLines(file);
fileLine += allLines.size(); fileLine += allLines.size();
}catch (IOException e){ } catch (IOException e) {
log.error("当前文件无法读取:{}",e.getMessage()); log.error("当前文件无法读取:{}", e.getMessage());
} }
for (Map.Entry<String, PathMatcher> entry : languageSuffixMatcherMapping.entrySet()) { for (Map.Entry<String, PathMatcher> entry : languageSuffixMatcherMapping.entrySet()) {
......
...@@ -42,9 +42,7 @@ public class DocumentServiceImpl implements DocumentService { ...@@ -42,9 +42,7 @@ public class DocumentServiceImpl implements DocumentService {
String name = titleHead.getName(); String name = titleHead.getName();
if (!StringUtils.isEmpty(name)) { if (!StringUtils.isEmpty(name)) {
//标题级别 //标题级别
int parentId = titleHead.getParentId(); String s = titleContent.replaceAll("#title#", name);
String s = titleContent.replaceAll("#title#", name)
.replaceAll("#parentId#", String.valueOf(parentId));
sb.append(s); sb.append(s);
} }
List<DocumentContent> documentContents = titleHead.getDocumentContents(); List<DocumentContent> documentContents = titleHead.getDocumentContents();
......
...@@ -10,7 +10,7 @@ import java.util.Map; ...@@ -10,7 +10,7 @@ import java.util.Map;
public class FreeMakerUtils { public class FreeMakerUtils {
public static String parseTpl(String viewName, Map<String, List<TechnologyContent>> params) { public static String parseTpl(String viewName, Map params) {
Configuration cfg = SpringContextHolder.getBean(Configuration.class); Configuration cfg = SpringContextHolder.getBean(Configuration.class);
String html = null; String html = null;
Template t = null; Template t = null;
...@@ -18,7 +18,7 @@ public class FreeMakerUtils { ...@@ -18,7 +18,7 @@ public class FreeMakerUtils {
t = cfg.getTemplate(viewName + ".ftl"); t = cfg.getTemplate(viewName + ".ftl");
createWord(t,params); createWord(t,params);
// html = FreeMarkerTemplateUtils.processTemplateIntoString(t, params); // html = FreeMarkerTemplateUtils.processTemplateIntoString(t, params);
System.out.println(html); // System.out.println(html);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -78,5 +78,32 @@ public class FreeMakerUtils { ...@@ -78,5 +78,32 @@ public class FreeMakerUtils {
} }
} }
} }
public static void createStringTemplate(Map map,String template){
try {
//文件路径
String filePath= "E://doc";
//文件名称
String fileName = System.currentTimeMillis()+".doc";
// 输出文件
File outFile = new File(filePath + File.separator + fileName);
// 如果输出目标文件夹不存在,则创建
if (!outFile.getParentFile().exists()) {
outFile.getParentFile().mkdirs();
}
// 将模板和数据模型合并生成文件
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outFile), "UTF-8"));
Template t = new Template("template", new StringReader(template), new Configuration(Configuration.VERSION_2_3_23));
t.process(map,out);
// 关闭流
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论