|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
package com.dsideal.QingLong.DataShare.Controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.aspose.cells.PdfSaveOptions;
|
|
|
|
|
import com.aspose.cells.Workbook;
|
|
|
|
|
import com.dsideal.QingLong.DataShare.Model.DataShareModel;
|
|
|
|
|
import com.dsideal.QingLong.Gtzz.Model.GtzzModel;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.*;
|
|
|
|
|
import com.dsideal.QingLong.Util.AsposeUtil;
|
|
|
|
|
import com.dsideal.QingLong.Util.CommonUtil;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.core.Controller;
|
|
|
|
@ -16,8 +19,12 @@ import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.upload.UploadFile;
|
|
|
|
|
import org.apache.poi.ss.formula.ptg.ErrPtg;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
@ -110,8 +117,18 @@ public class DataShareController extends Controller {
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
public void downloadXlsx(int system_id) {
|
|
|
|
|
Record record = dm.getSystemById(system_id);
|
|
|
|
|
String url = record.getStr("url");
|
|
|
|
|
if (StrKit.isBlank(url)) {
|
|
|
|
|
boolean Error = false;
|
|
|
|
|
String url = "";
|
|
|
|
|
if (record == null) {
|
|
|
|
|
Error = true;
|
|
|
|
|
} else {
|
|
|
|
|
url = record.getStr("url");
|
|
|
|
|
if (StrKit.isBlank(url)) {
|
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Error) {
|
|
|
|
|
Kv kv = Kv.by("success", false);
|
|
|
|
|
kv.set("message", "此系统还没有上传说明文档,无法下载!");
|
|
|
|
|
renderJson(kv);
|
|
|
|
@ -133,12 +150,21 @@ public class DataShareController extends Controller {
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
@IsNumericInterface({"system_id"})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
public void previewXlsx(int system_id) {
|
|
|
|
|
public void previewXlsx(int system_id) throws Exception {
|
|
|
|
|
Record record = dm.getSystemById(system_id);
|
|
|
|
|
String url = record.getStr("url");
|
|
|
|
|
if (StrKit.isBlank(url)) {
|
|
|
|
|
boolean Error = false;
|
|
|
|
|
String url = "";
|
|
|
|
|
if (record == null) {
|
|
|
|
|
Error = true;
|
|
|
|
|
} else {
|
|
|
|
|
url = record.getStr("url");
|
|
|
|
|
if (StrKit.isBlank(url)) {
|
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Error) {
|
|
|
|
|
Kv kv = Kv.by("success", false);
|
|
|
|
|
kv.set("message", "此系统还没有上传说明文档,无法预览!");
|
|
|
|
|
kv.set("message", "此系统还没有上传说明文档,无法下载!");
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -147,15 +173,36 @@ public class DataShareController extends Controller {
|
|
|
|
|
String file_name = array[array.length - 1];
|
|
|
|
|
String basePath = PathKit.getWebRootPath() + "/upload/";
|
|
|
|
|
String realPath = basePath + file_name;
|
|
|
|
|
GtzzModel gm = new GtzzModel();
|
|
|
|
|
gm.uploadForPreview(realPath);
|
|
|
|
|
//获取预览地址
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
String previewName = "https://ow365.cn/?i=14531&ssl=1&info=3&fname=" + file_name + "&furl=" + "https://video.edusoa.com/ccsjy-gtzz/" + file_name;
|
|
|
|
|
kv.set("forPrintUrl", previewName);
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
|
|
|
|
|
realPath=realPath.replace("\\","/");
|
|
|
|
|
String system_name = record.getStr("system_name");
|
|
|
|
|
//注册信息
|
|
|
|
|
AsposeUtil.getLicense();
|
|
|
|
|
Workbook wb = new Workbook(realPath);// 原始excel路径
|
|
|
|
|
String targetPath = realPath.replace(".xlsx", ".pdf");
|
|
|
|
|
FileOutputStream fileOS = new FileOutputStream(targetPath);
|
|
|
|
|
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
|
|
|
|
|
pdfSaveOptions.setOnePagePerSheet(true);
|
|
|
|
|
wb.save(fileOS, pdfSaveOptions);
|
|
|
|
|
fileOS.flush();
|
|
|
|
|
fileOS.close();
|
|
|
|
|
//renderFile(new File(targetPath), "【" + system_name + "】文档说明.pdf");
|
|
|
|
|
|
|
|
|
|
HttpServletResponse response = getResponse();
|
|
|
|
|
BufferedInputStream br = new BufferedInputStream(new FileInputStream(targetPath));
|
|
|
|
|
byte[] buf = new byte[1024];
|
|
|
|
|
int len;
|
|
|
|
|
response.reset(); // 非常重要
|
|
|
|
|
URI uri = new URI("file:///" + targetPath);
|
|
|
|
|
URL u = uri.toURL();
|
|
|
|
|
response.setContentType(u.openConnection().getContentType());
|
|
|
|
|
String fileName = "【" + system_name + "】文档说明.pdf";
|
|
|
|
|
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
|
|
|
|
|
OutputStream out = response.getOutputStream();
|
|
|
|
|
while ((len = br.read(buf)) > 0)
|
|
|
|
|
out.write(buf, 0, len);
|
|
|
|
|
br.close();
|
|
|
|
|
out.close();
|
|
|
|
|
renderNull();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|