谐波报告删除多余代码

This commit is contained in:
wr
2023-04-19 14:11:26 +08:00
parent 90c83a0c6b
commit 92aceff1e3
2 changed files with 3 additions and 31 deletions

View File

@@ -19,7 +19,7 @@ public class WordUtil2 {
// 日志记录 // 日志记录
private static final Logger logger = LoggerFactory.getLogger(WordUtil2.class); private static final Logger logger = LoggerFactory.getLogger(WordUtil2.class);
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response, HttpSession session) public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response)
throws Exception { throws Exception {
path = ClearPathUtil.cleanString(path); path = ClearPathUtil.cleanString(path);
File file = new File(path); File file = new File(path);
@@ -38,43 +38,15 @@ public class WordUtil2 {
inStream.close(); inStream.close();
} }
} }
// //读取配置文件
// Properties pros = PubUtils.readProperties(getClass().getClassLoader(), "java.properties");
// String tmpPath = pros.get("TMP_PATH").toString() +File.separator+ "offlinereoprt";
// tmpPath= ClearPathUtil.cleanString(tmpPath);
// OutputStream os = null;
// File tmpfile = new File(tmpPath);
// if(!tmpfile.exists()){
// tmpfile.mkdir();
// }
// tmpPath = tmpPath +File.separator+ fileName;
// tmpPath= ClearPathUtil.cleanString(tmpPath);
// File tmp = new File(tmpPath);
// if(tmp.exists()){
// tmp.delete();
// }
// PubUtils.createFile(tmpPath);
try { try {
// os = new FileOutputStream(tmpPath);
// if (doc != null) {
// doc.write(os);
// }
ServletOutputStream outputStream = response.getOutputStream(); ServletOutputStream outputStream = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=UTF-8"); response.setContentType("application/octet-stream;charset=UTF-8");
doc.write(outputStream); doc.write(outputStream);
outputStream.close(); outputStream.close();
// session.setAttribute("tmpPath", tmpPath);
// session.setAttribute("fileName", fileName);
} catch (Exception e) { } catch (Exception e) {
session.setAttribute("tmpPath", "");
session.setAttribute("fileName", "");
logger.error("输出稳态报告异常,原因为:" + e.toString()); logger.error("输出稳态报告异常,原因为:" + e.toString());
} finally { } finally {
// if (os != null) {
// os.close();
// }
if (doc != null) { if (doc != null) {
doc.close(); doc.close();
} }

View File

@@ -70,7 +70,7 @@ public class ExportModelController extends BaseController {
@PostMapping("/exportModel") @PostMapping("/exportModel")
@ApiOperation("word报告") @ApiOperation("word报告")
public String exportworld(HttpSession session, HttpServletResponse response, public String exportworld(HttpServletResponse response,
String startTime, String endTime, Integer type, String lineIndex, String startTime, String endTime, Integer type, String lineIndex,
String name, String reportNumber, String crmName, String name, String reportNumber, String crmName,
MultipartFile file) throws IOException { MultipartFile file) throws IOException {
@@ -1195,7 +1195,7 @@ public class ExportModelController extends BaseController {
WordUtil2 oRTF = new WordUtil2(); WordUtil2 oRTF = new WordUtil2();
try { try {
oRTF.getWord(rtfPath, reportmap, name + formatter.format(currentTime) + ".docx", response, session); oRTF.getWord(rtfPath, reportmap, name + formatter.format(currentTime) + ".docx", response);
} catch (Exception e) { } catch (Exception e) {
log.error("获取报告发生异常,异常是" + e.getMessage()); log.error("获取报告发生异常,异常是" + e.getMessage());
} }