Commit 451f75d9 authored by chenhao's avatar chenhao

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 124397e2 8f276b49
...@@ -238,7 +238,9 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto, ...@@ -238,7 +238,9 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,
private VoiceRecordFileDto buildFilePath(VoiceRecordFileDto record) { private VoiceRecordFileDto buildFilePath(VoiceRecordFileDto record) {
Map<String, String> callRecord = fusionService.getCallRecordByCID(record.getConnectId()); Map<String, String> callRecord = fusionService.getCallRecordByCID(record.getConnectId());
record.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName"))); if (!ValidationUtil.isEmpty(callRecord)){
record.setFilePath(String.format("/%s/%s", callRecord.get("subPath"), callRecord.get("recordName")));
}
return record; return record;
} }
} }
\ No newline at end of file
...@@ -46,10 +46,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -46,10 +46,7 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream; import java.io.*;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.ParseException; import java.text.ParseException;
import java.util.Arrays; import java.util.Arrays;
...@@ -296,37 +293,42 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep ...@@ -296,37 +293,42 @@ public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckRep
report.setReportDate(getCheckReportDateStr(report)); report.setReportDate(getCheckReportDateStr(report));
report.setNowDate(DateUtils.dateFormat(new Date(), DateUtils.CHN_DATE_PATTERN)); report.setNowDate(DateUtils.dateFormat(new Date(), DateUtils.CHN_DATE_PATTERN));
if (!ValidationUtil.isEmpty(report)) { if (!ValidationUtil.isEmpty(report)) {
String checkReportTemplatePath = this.getClass().getClassLoader().getResource("templates/check-report-template" + // String checkReportTemplatePath = this.getClass().getClassLoader().getResource("templates/check-report-template.docx").getFile();
".docx").getFile();
String fileName = report.getName() + ".docx"; String fileName = report.getName() + ".docx";
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("templates/check-report-template.docx");
CheckDangerTablePolicy checkDangerTablePolicy = new CheckDangerTablePolicy(); CheckDangerTablePolicy checkDangerTablePolicy = new CheckDangerTablePolicy();
ReviewDangerTablePolicy reviewDangerTablePolicy = new ReviewDangerTablePolicy(); ReviewDangerTablePolicy reviewDangerTablePolicy = new ReviewDangerTablePolicy();
Configure.ConfigureBuilder configureBuilder = Configure.newBuilder(); Configure.ConfigureBuilder configureBuilder = Configure.newBuilder();
configureBuilder.setElMode(ELMode.SPEL_MODE).bind("checkDangerList", checkDangerTablePolicy).bind("reviewDangerList", reviewDangerTablePolicy).build(); configureBuilder.setElMode(ELMode.SPEL_MODE).bind("checkDangerList", checkDangerTablePolicy).bind("reviewDangerList", reviewDangerTablePolicy).build();
XWPFTemplate template = XWPFTemplate.compile(checkReportTemplatePath, configureBuilder.build()).render(report); // XWPFTemplate template = XWPFTemplate.compile(checkReportTemplatePath, configureBuilder.build()).render(report);
response.setContentType("application/msword"); if (resourceAsStream != null) {
response.setHeader("Content-Disposition", XWPFTemplate template = XWPFTemplate.compile(resourceAsStream, configureBuilder.build()).render(report);
"attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); response.setContentType("application/msword");
OutputStream out = null; response.setHeader("Content-Disposition",
BufferedOutputStream bos = null; "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
try { OutputStream out = null;
out = response.getOutputStream(); BufferedOutputStream bos = null;
bos = new BufferedOutputStream(out);
template.write(bos);
bos.flush();
out.flush();
} catch (IOException e) {
log.error("生成文档失败---------->");
e.printStackTrace();
} finally {
try { try {
bos.close(); out = response.getOutputStream();
out.close(); bos = new BufferedOutputStream(out);
template.close(); template.write(bos);
bos.flush();
out.flush();
} catch (IOException e) { } catch (IOException e) {
log.error("生成文档失败---------->");
e.printStackTrace(); e.printStackTrace();
} finally {
try {
bos.close();
out.close();
template.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
} else {
log.error("获取模板失败---------->");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment