Commit 43543c34 authored by litengwei's avatar litengwei

中心检测问题处理

parent 08481913
...@@ -180,20 +180,23 @@ public class TaskController extends AbstractBaseController{ ...@@ -180,20 +180,23 @@ public class TaskController extends AbstractBaseController{
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
Date date = new Date();
Source source = new StreamSource(inputStream); Source source = new StreamSource(inputStream);
try { String path = request.getSession().getServletContext().getRealPath("/");
String dir = path.substring(0, path.indexOf(File.separator)+1) + "print";
String html = path.substring(0, path.indexOf(File.separator)+1) + "print"+File.separator+"task_" + date.getTime() + ".html";
File dirFile = new File(dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
File htmlFile = new File(html);
try (
FileInputStream fis = new FileInputStream(htmlFile);
){
ClassPathResource classPathResource = new ClassPathResource("temp/template.xsl"); ClassPathResource classPathResource = new ClassPathResource("temp/template.xsl");
InputStream stream = classPathResource.getInputStream(); InputStream stream = classPathResource.getInputStream();
Source template = new StreamSource(stream); Source template = new StreamSource(stream);
//String html = "D://10.html"; //String html = "D://10.html";
Date date = new Date();
String path = request.getSession().getServletContext().getRealPath("/");
String dir = path.substring(0, path.indexOf(File.separator)+1) + "print";
String html = path.substring(0, path.indexOf(File.separator)+1) + "print"+File.separator+"task_" + date.getTime() + ".html";
File dirFile = new File(dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
Result result=new StreamResult(html); Result result=new StreamResult(html);
TransformerFactory transformerFactory = TransformerFactory.newInstance(); TransformerFactory transformerFactory = TransformerFactory.newInstance();
...@@ -202,8 +205,6 @@ public class TaskController extends AbstractBaseController{ ...@@ -202,8 +205,6 @@ public class TaskController extends AbstractBaseController{
Transformer transformer = transformerFactory.newTransformer(template); Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result); transformer.transform(source, result);
File htmlFile = new File(html);
FileInputStream fis = new FileInputStream(htmlFile);
String data = IOUtils.toString(fis, "utf-8"); String data = IOUtils.toString(fis, "utf-8");
fis.close(); fis.close();
if (htmlFile.exists()) { if (htmlFile.exists()) {
......
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