|
@@ -4,10 +4,8 @@ import com.sundata.common.annotation.Auth;
|
|
|
import com.sundata.common.base.BaseAction;
|
|
|
import com.sundata.common.util.DBExecutor;
|
|
|
import com.sundata.common.util.FileUtil;
|
|
|
-import com.sundata.common.util.HtmlUtil;
|
|
|
import com.sundata.product.rwa.reportformconfigreportcreater.model.ReportFileExportModel;
|
|
|
import com.sundata.product.rwa.util.html.ToHtml;
|
|
|
-import com.sundata.product.rwa.util.html.ToMergeHtml;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -38,23 +36,23 @@ public class ReportFileExportController extends BaseAction {
|
|
|
String templatePath = DBExecutor.doQuery("select NOUNVALUE from sys_noun where NOUNITEM = 'ATTACHPATH'");
|
|
|
File reportResultDirPath = new File(templatePath + File.separator + "reportResult" + File.separator + model.getTerm() + File.separator + model.getReportNo() + File.separator + "default");
|
|
|
Map<String, Object> rsp = new HashMap<>();
|
|
|
- if (!reportResultDirPath.exists()) {
|
|
|
- rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (reportResultDirPath.listFiles() == null || reportResultDirPath.listFiles().length == 0) {
|
|
|
- rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
- return;
|
|
|
- }
|
|
|
- File report = reportResultDirPath.listFiles()[0];
|
|
|
- if (!report.exists()) {
|
|
|
- rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
- return;
|
|
|
- }
|
|
|
+ rsp.put("flag", true);
|
|
|
+ File tempFileDir = new File(templatePath + File.separator + "reportuploadconfig" + File.separator + model.getReportNo() + "/" + "default");
|
|
|
try {
|
|
|
+ if (!reportResultDirPath.exists()) {
|
|
|
+ rsp.put("flag", false);
|
|
|
+ }
|
|
|
+ if (reportResultDirPath.listFiles() == null || reportResultDirPath.listFiles().length == 0) {
|
|
|
+ rsp.put("flag", false);
|
|
|
+ }
|
|
|
+ File report = reportResultDirPath.listFiles()[0];
|
|
|
+ if (!report.exists()) {
|
|
|
+ rsp.put("flag", false);
|
|
|
+ }
|
|
|
+ if (rsp.get("flag").toString().equals("false")) {
|
|
|
+ FileUtil.getContent(report.getName(), response, Files.newInputStream(tempFileDir.listFiles()[0].toPath()));
|
|
|
+ return;
|
|
|
+ }
|
|
|
FileUtil.getContent(report.getName(), response, Files.newInputStream(report.toPath()));
|
|
|
} catch (IOException e) {
|
|
|
log.error("读取文件出现异常,请检查是否存在权限问题:{}", e.getMessage(), e);
|
|
@@ -72,27 +70,33 @@ public class ReportFileExportController extends BaseAction {
|
|
|
String templatePath = DBExecutor.doQuery("select NOUNVALUE from sys_noun where NOUNITEM = 'ATTACHPATH'");
|
|
|
File reportResultDirPath = new File(templatePath + File.separator + "reportResult" + File.separator + model.getTerm() + File.separator + model.getReportNo() + File.separator + "default");
|
|
|
Map<String, Object> rsp = new HashMap<>();
|
|
|
+ rsp.put("flag", true);
|
|
|
+ File tempFileDir = new File(templatePath + File.separator + "reportuploadconfig" + File.separator + model.getReportNo() + "/" + "default");
|
|
|
if (!reportResultDirPath.exists()) {
|
|
|
rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
- return;
|
|
|
}
|
|
|
if (reportResultDirPath.listFiles() == null || reportResultDirPath.listFiles().length == 0) {
|
|
|
rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
- return;
|
|
|
}
|
|
|
File report = reportResultDirPath.listFiles()[0];
|
|
|
if (!report.exists()) {
|
|
|
rsp.put("flag", false);
|
|
|
- HtmlUtil.writeJson(response, rsp);
|
|
|
}
|
|
|
StringWriter writer = new StringWriter();
|
|
|
+ if (rsp.get("flag").toString().equals("false")) {
|
|
|
+ ToHtml toHtml = ToHtml.create(Files.newInputStream(tempFileDir.listFiles()[0].toPath()), writer);
|
|
|
+ toHtml.setCompleteHTML(false);
|
|
|
+ toHtml.printPage();
|
|
|
+ rsp.put("flag", true);
|
|
|
+ rsp.put("htmlString", writer.toString());
|
|
|
+ sendData(response, rsp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
ToHtml toHtml = ToHtml.create(Files.newInputStream(report.toPath()), writer);
|
|
|
toHtml.setCompleteHTML(false);
|
|
|
toHtml.printPage();
|
|
|
rsp.put("flag", true);
|
|
|
- rsp.put("htmlString",writer.toString());
|
|
|
+ rsp.put("htmlString", writer.toString());
|
|
|
// rsp.put("htmlString", ToMergeHtml.mergeExcelHtml(report));
|
|
|
|
|
|
sendData(response, rsp);
|