|
@@ -68,6 +68,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.net.URL;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
@@ -516,28 +517,41 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
try {
|
|
|
//获取onlyOffice缓存中的文件流
|
|
|
URL url = new URL(downloadUri);
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String filecode = SnowFlakeUtil.getId() + "";
|
|
|
+ String dataUrl=file_path + "/excel/" + filecode + ".pdf";
|
|
|
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
+ connection.setConnectTimeout(5 * 1000);
|
|
|
InputStream inputStream = connection.getInputStream();
|
|
|
if (inputStream == null) {
|
|
|
throw new Exception("文件为空");
|
|
|
}
|
|
|
- Long tabId = callback.getKey();
|
|
|
+ String tabId = callback.getKey();
|
|
|
if (tabId == null) {
|
|
|
throw new Exception("excel为空");
|
|
|
+ }else{
|
|
|
+ tabId = tabId.substring(0,tabId.lastIndexOf("_"));
|
|
|
}
|
|
|
//获取数据库信息
|
|
|
- ExcelTab excelTab = baseMapper.selectById(tabId);
|
|
|
+ ExcelTab excelTab = baseMapper.selectById(Long.parseLong(tabId));
|
|
|
//上传新文件到文件服务器
|
|
|
byte[] officeByte = IoUtil.readToByteArray(inputStream);
|
|
|
- BladeFile bladeFile = this.newIOSSClient.updateFile(officeByte, excelTab.getExtension());
|
|
|
- //修改本地数据信息
|
|
|
- excelTab.setFileUrl(bladeFile.getLink());
|
|
|
+
|
|
|
+ FileOutputStream fs = new FileOutputStream(dataUrl);
|
|
|
+ fs.write(officeByte);
|
|
|
+ fs.flush();
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(excelTab.getExtension(), dataUrl);
|
|
|
//获取文件大小
|
|
|
int size = connection.getContentLength() / 1024 / 1024; //单位M
|
|
|
excelTab.setAttachSize(Long.parseLong(size + ""));
|
|
|
excelTab.setStatus(3);
|
|
|
+ excelTab.setFileUrl(bladeFile.getLink());
|
|
|
baseMapper.updateById(excelTab);
|
|
|
- connection.disconnect();
|
|
|
+ File file = new File(dataUrl);
|
|
|
+ if(file.exists()){
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
System.out.println("123456");
|
|
|
} catch (Exception e) {
|
|
|
editCallback.setError(1);
|