Commit 478d6450 authored by 李秀明's avatar 李秀明
parent 0b5beb36
...@@ -31,6 +31,7 @@ import com.yeejoin.amos.patrol.mqtt.WebMqttComponent; ...@@ -31,6 +31,7 @@ import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -51,10 +52,10 @@ import javax.xml.transform.*; ...@@ -51,10 +52,10 @@ import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import java.io.*; import java.io.*;
import java.util.Date; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.nio.file.Files;
import java.util.List; import java.nio.file.Paths;
import java.util.Map; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -848,16 +849,19 @@ public class CheckController extends AbstractBaseController { ...@@ -848,16 +849,19 @@ public class CheckController extends AbstractBaseController {
return CommonResponseUtil.failure(); return CommonResponseUtil.failure();
} }
InputStream inputStream = new ByteArrayInputStream(xml.getBytes()); InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
;
Source source = new StreamSource(inputStream); Source source = new StreamSource(inputStream);
try { try {
FileInputStream fis1 = new FileInputStream( String filePath = Objects.requireNonNull(this.getClass().getResource("/")).getPath() + "temp" + File.separator + "checkTemplate.xsl";
this.getClass().getResource("/").getPath() + "temp/checkTemplate.xsl"); if (Files.notExists(Paths.get(filePath))) {
throw new RuntimeException("模板文件不存在");
}
FileInputStream fis1 = new FileInputStream(FilenameUtils.normalize(filePath));
Source template = new StreamSource(fis1); Source template = new StreamSource(fis1);
Date date = new Date(); Date date = new Date();
String path = request.getSession().getServletContext().getRealPath("/"); String path = request.getSession().getServletContext().getRealPath("/");
String dir = path.substring(0, path.indexOf(File.separator) + 1) + "check"; String subPath = path.substring(0, path.indexOf(File.separator) + 1);
String html = path.substring(0, path.indexOf(File.separator) + 1) + "check" + File.separator + "task_" String dir = subPath + "check";
String html = subPath + "check" + File.separator + "task_"
+ date.getTime() + ".html"; + date.getTime() + ".html";
File dirFile = new File(dir); File dirFile = new File(dir);
if (!dirFile.exists()) { if (!dirFile.exists()) {
...@@ -871,7 +875,7 @@ public class CheckController extends AbstractBaseController { ...@@ -871,7 +875,7 @@ public class CheckController extends AbstractBaseController {
File htmlFile = new File(html); File htmlFile = new File(html);
FileInputStream fis = new FileInputStream(htmlFile); FileInputStream fis = new FileInputStream(htmlFile);
String data = IOUtils.toString(fis, "utf-8"); String data = IOUtils.toString(fis, StandardCharsets.UTF_8);
fis.close(); fis.close();
if (htmlFile.exists()) { if (htmlFile.exists()) {
htmlFile.delete(); htmlFile.delete();
......
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