提交 b0210a28 authored 作者: 孙洁清's avatar 孙洁清

解决内存溢出

上级 e0d50e1c
......@@ -151,19 +151,7 @@ public class EvaluationController {
return ServerResponse.ok(new PageResult<>(pageList.getTotalElements(), pageList.getContent()));
}
/**
* 获取评估报告内的输出,转换为map结构
*
* @param id id
* @return wps
*/
@GetMapping(value = "/map/{id}")
@ApiOperation("获取评估报告内的map ")
public ServerResponse<Map<String, String>> findAll(@PathVariable String id) {
Evaluation evaluation = evaluationService.findById(id);
Map<String, String> wps = WpsUtil.createWps(evaluation);
return ServerResponse.ok(wps);
}
@ApiOperation("下载报告")
@ApiImplicitParams({
@ApiImplicitParam(name="id",value = "报告主键"),
......@@ -177,37 +165,32 @@ public class EvaluationController {
public ServerResponse download(@RequestBody Download download){
// return ResponseEntity.ok("http://120.55.57.35:12345/static/uplaods/a36b17568d4e466dacf9f088a29b4dbc.docx");
// return ResponseEntity.ok("http://120.55.57.35:8078/static/defult.docx");
String w=null;
Evaluation evaluation = evaluationService.findById(download.getId());
Map<String, String> wps = WpsUtil.createWps(evaluation);
wps.put("danjia",download.getDanjia());
wps.put("yusuan",download.getYusuan());
wps.put("gong",download.getGong());
wps.put("ewai",download.getEwai());
System.out.println("downloadid:"+download.getId());
System.out.println("evaluation:"+evaluation);
if(evaluation!=null) {
Map<String, Object> wps = WpsUtil.createWps(evaluation);
wps.put("danjia", download.getDanjia());
wps.put("yusuan", download.getYusuan());
wps.put("gong", download.getGong());
wps.put("ewai", download.getEwai());
Double aDouble = Double.valueOf(download.getDanjia());
BigDecimal b1 = BigDecimal.valueOf(aDouble);
BigDecimal b2 = BigDecimal.valueOf(1.5);
double v = b1.subtract(b2).doubleValue();
String format = new DecimalFormat("0.00").format(v);
wps.put("rgcz",format);
if(download.getAgree().equals("1")) {
wps.put("rgcz", format);
if (download.getAgree().equals("1")) {
wps.put("agree", "同意");
}else{
} else {
wps.put("agree", "不同意");
}
Set<String> strings = wps.keySet();
for (String str : strings) {
String s = wps.get(str);
if(!StringUtils.isEmpty(s)&&s.equals("-1")){
wps.put(str,"0");
}else if(StringUtils.isEmpty(s)){
wps.put(str,"无");
w = FreeMakerUtils.parseTpl("reportTemplate", wps);
}
if(org.apache.commons.lang3.StringUtils.isNotEmpty(w)){
return ServerResponse.ok(w);
}
String w = FreeMakerUtils.parseTpl("reportTemplate", wps);
if(StringUtils.isEmpty(w)){
return ServerResponse.error(500);
}
return ServerResponse.ok(w);
}
}
......@@ -102,7 +102,6 @@ public class DocumentWordUtil {
String s3 = tableTile(technologyName, stra);
String s4 = Matcher.quoteReplacement(s3);
StringBuilder sb=new StringBuilder();
sb.append(s4);
for (int j = 0; j < tables.size(); j++) {
String gettb = gettb(tables.get(j));
String s1 = Matcher.quoteReplacement(gettb);
......
......@@ -24,8 +24,7 @@ public class FreeMakerUtils {
return null;
}
}
public static String createWord(Template template, Map<String, List<TechnologyContent>> dataMap){
try {
public static String createWord(Template template, Map<String, List<TechnologyContent>> dataMap)throws Exception{
//文件路径
String filePath= "/opt/monitor/inspect/static/ins/doc/";
......@@ -49,10 +48,6 @@ public class FreeMakerUtils {
out.flush();
out.close();
return fileName;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
public static void writeFile(String file, String conent) {
......
......@@ -17,11 +17,11 @@ import java.util.*;
public class WpsUtil {
public static Map<String, String> createWps(Evaluation evaluation) {
public static Map<String, Object> createWps(Evaluation evaluation) {
HashMap<String, List<TechnologyContent>> teMap = new HashMap<>();
Reform reform = JSON.parseObject(evaluation.getInEva(), Reform.class);
AssessmentReport assessmentReport = JSON.parseObject(evaluation.getOutEva(), AssessmentReport.class);
HashMap<String, String> keyValue = new HashMap<>();
Map keyValue = new HashMap<>();
keyValue.put("username", reform.getUsername());
keyValue.put("mode", getMode(reform.getMode()));
keyValue.put("projectName", reform.getProjectName());
......@@ -180,46 +180,35 @@ public class WpsUtil {
TechnologyList technologyList = assessmentReport.getTechnologyList();
keyValue.put("technologyDes", technologyList.getDes());
List<TechnologyReport> technologyReports = technologyList.getTechnologyReports();
for (int i = 0; i < technologyList.getTechnologyReports().size(); i++) {
int i2 = i + 1;
keyValue.put("technology" + i2, technologyReports.get(i).getTechnology());
for (int i1 = 0; i1 < technologyReports.get(i).getTechnologyContents().size(); i1++) {
int i3 = i1 + 1;
TechnologyContent technologyContent = technologyReports.get(i).getTechnologyContents().get(i1);
keyValue.put("technologyContentLocal" + i2 + "-" + i3, technologyContent.getLocal());
keyValue.put("technologyContentKeyWord" + i2 + "-" + i3, technologyContent.getKeyWord());
keyValue.put("technologyContentFile" + i2 + "-" + i3, technologyContent.getFile());
keyValue.put("technologyContentPosition" + i2 + "-" + i3, technologyContent.getPosition());
keyValue.put("technologyContentStrategy" + i2 + "-" + i3, getMode(technologyContent.getStrategy()));
// for (int i = 0; i < technologyList.getTechnologyReports().size(); i++) {
// int i2 = i + 1;
// keyValue.put("technology" + i2, technologyReports.get(i).getTechnology());
// for (int i1 = 0; i1 < technologyReports.get(i).getTechnologyContents().size(); i1++) {
// int i3 = i1 + 1;
// TechnologyContent technologyContent = technologyReports.get(i).getTechnologyContents().get(i1);
// keyValue.put("technologyContentLocal" + i2 + "-" + i3, technologyContent.getLocal());
// keyValue.put("technologyContentKeyWord" + i2 + "-" + i3, technologyContent.getKeyWord());
// keyValue.put("technologyContentFile" + i2 + "-" + i3, technologyContent.getFile());
// keyValue.put("technologyContentPosition" + i2 + "-" + i3, technologyContent.getPosition());
// keyValue.put("technologyContentStrategy" + i2 + "-" + i3, getMode(technologyContent.getStrategy()));
// }
// }
HashMap<String, List<TechnologyContent>> yhMap = new HashMap<>();
HashMap<String, List<TechnologyContent>> nsMap = new HashMap<>();
HashMap<String, List<TechnologyContent>> wzMap = new HashMap<>();
for (TechnologyReport technologyReport : technologyReports) {
if(technologyReport.getTechnology().contains("优化")){
yhMap.put(technologyReport.getTechnology(), technologyReport.getTechnologyContents());
}else if(technologyReport.getTechnology().contains("不支持")) {
nsMap.put(technologyReport.getTechnology(), technologyReport.getTechnologyContents());
}else if(technologyReport.getTechnology().contains("未知")){
wzMap.put(technologyReport.getTechnology(), technologyReport.getTechnologyContents());
}
}
for (TechnologyReport technologyReport : technologyReports) {
teMap.put(technologyReport.getTechnology(), technologyReport.getTechnologyContents());
}
Set<String> strings = teMap.keySet();
StringBuilder youhua = new StringBuilder();
StringBuilder xiugai = new StringBuilder();
StringBuilder weizhi = new StringBuilder();
DocumentWordUtil documentWordUtil=new DocumentWordUtil();
for (String string : strings) {
if (string.contains("优化")) {
List<TechnologyContent> technologyContents = teMap.get(string);
String str = documentWordUtil.getTableString(technologyContents, string, "优化");
youhua.append(str);
} else if (string.contains("不支持")) {
List<TechnologyContent> technologyContents = teMap.get(string);
String str = documentWordUtil.getTableString(technologyContents, string, "重新开发");
xiugai.append(str);
} else if (string.contains("未知")) {
List<TechnologyContent> technologyContents = teMap.get(string);
String str = documentWordUtil.getTableString(technologyContents, string, "验证修改或重新开发");
weizhi.append(str);
}
}
keyValue.put("teyouhua", youhua.toString());
keyValue.put("texiugai", xiugai.toString());
keyValue.put("teweizhi", weizhi.toString());
keyValue.put("yh",yhMap);
keyValue.put("ns",nsMap);
keyValue.put("wz",wzMap);
Workload workload = assessmentReport.getWorkload();
keyValue.put("workloadDes", workload.getDes());
keyValue.put("workloadCost", String.valueOf(workload.getCost()));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论