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

解决内存溢出

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