|
@@ -38,6 +38,10 @@ public class ReportServiceImpl implements IReportService {
|
|
@Override
|
|
@Override
|
|
public void createReport(Map<String, String> mFlyCountMap, Map<String, String> mSummaryMap, List<PlaneInspectionResultBo> planeInspectionResultBoList) {
|
|
public void createReport(Map<String, String> mFlyCountMap, Map<String, String> mSummaryMap, List<PlaneInspectionResultBo> planeInspectionResultBoList) {
|
|
|
|
|
|
|
|
+ FileOutputStream fileOutputStream = null;
|
|
|
|
+ OutputStreamWriter outputStreamWriter = null;
|
|
|
|
+ File mFile = null;
|
|
|
|
+
|
|
try {
|
|
try {
|
|
|
|
|
|
Calendar mCalendar = Calendar.getInstance();
|
|
Calendar mCalendar = Calendar.getInstance();
|
|
@@ -79,18 +83,38 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
Template template = configuration.getTemplate("report.ftl", StandardCharsets.UTF_8.toString());
|
|
Template template = configuration.getTemplate("report.ftl", StandardCharsets.UTF_8.toString());
|
|
|
|
|
|
- Writer writer = null;
|
|
|
|
-
|
|
|
|
//todo: 记得修改路径和名字(这里后面确定路径后要挂载目录)
|
|
//todo: 记得修改路径和名字(这里后面确定路径后要挂载目录)
|
|
- File mFile = new File("D:\\temp\\1.doc");
|
|
|
|
- writer = new OutputStreamWriter(new FileOutputStream(mFile), StandardCharsets.UTF_8);
|
|
|
|
|
|
+ mFile = new File("D:\\temp\\1.doc");
|
|
|
|
+
|
|
|
|
+ fileOutputStream = new FileOutputStream(mFile);
|
|
|
|
|
|
- template.process(mValueMap, writer);
|
|
|
|
|
|
+ outputStreamWriter = new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8);
|
|
|
|
|
|
- writer.flush();
|
|
|
|
- writer.close();
|
|
|
|
|
|
+ template.process(mValueMap, outputStreamWriter);
|
|
|
|
+
|
|
|
|
+ outputStreamWriter.flush();
|
|
}catch (Exception e) {
|
|
}catch (Exception e) {
|
|
- log.error(e.toString());
|
|
|
|
|
|
+ //生成失败删除垃圾文件
|
|
|
|
+ if (mFile != null) {
|
|
|
|
+ if (mFile.exists()) {
|
|
|
|
+ mFile.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }finally {
|
|
|
|
+ if (outputStreamWriter != null) {
|
|
|
|
+ try {
|
|
|
|
+ outputStreamWriter.close();
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (fileOutputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ fileOutputStream.close();
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|