合并分支 'fix_foton_20230613' 到 'master'
Fix foton 20230613 查看合并请求 laws-foton-slrs/foton-slrs-system-rest!114
This commit is contained in:
+5
-4
@@ -4927,7 +4927,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
objectQueryWrapperSarBussStandFile.eq("ORI_ATT_ID", sarBussStandFiles.get(0).getOriAttId());
|
||||
objectQueryWrapperSarBussStandFile.eq("USE_MODEL", "WEB_FILE");
|
||||
List<SarBussStandFile> sarBussStandFilesList = sarBussStandFileEODao.selectList(objectQueryWrapperSarBussStandFile);
|
||||
if(sarBussStandFilesList.isEmpty() && sarBussStandFilesList.size()==0){
|
||||
if(sarBussStandFilesList.size() == 0){
|
||||
//存储的名称,key 路径
|
||||
QueryWrapper<OnlineFileLog> onlineFileLogWrapper = new QueryWrapper<>();
|
||||
onlineFileLogWrapper.eq("ATT_FILE_ID",sarBussStandFiles.get(0).getOriAttId());
|
||||
@@ -4936,11 +4936,12 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
||||
if(StringUtils.isNotBlank(onlineFileLogs.get(0).getOLdFileName()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilekey()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilePath())){
|
||||
try {
|
||||
logger.info("======================================远程调用转换开始启动=================================");
|
||||
OnlyofficePdfUtil.downloadFile(onlyofficeUrl,filePath+"/",onlineFileLogs.get(0).getOLdFileName(), onlineFileLogs.get(0).getFilekey(), onlineFileLogs.get(0).getFilePath());
|
||||
logger.info("=================================="+ onlineFileLogs.get(0).toString());
|
||||
File file = OnlyofficePdfUtil.downloadFile(filePath+"/",onlineFileLogs.get(0).getOLdFileName(), onlineFileLogs.get(0).getFilekey(), onlineFileLogs.get(0).getFilePath());
|
||||
logger.info("======================================远程调用转换开始结束=================================");
|
||||
File file = new File(filePath+"/onlineFile/"+onlineFileLogs.get(0).getOLdFileName()+onlineFileLogs.get(0).getOLdFileName()+".pdf");
|
||||
// File file = new File(filePath+"/onlineFile/"+onlineFileLogs.get(0).getOLdFileName());
|
||||
logger.info("======================================file文件路径================================="+filePath+"/onlineFile/"+onlineFileLogs.get(0).getOLdFileName());
|
||||
if(file.exists()){
|
||||
if(file != null && file.exists()){
|
||||
logger.info("======================================file文件保存================================="+filePath+"/onlineFile/"+onlineFileLogs.get(0).getOLdFileName());
|
||||
AttFileVo attFileVo = attFileEOService.saveFileInfo(file);
|
||||
if(attFileVo!=null){
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarBussionessStand.service.impl.SarBussionessStandServiceImpl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
@@ -21,20 +22,26 @@ import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class OnlyofficePdfUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SarBussionessStandServiceImpl.class);
|
||||
|
||||
@Value("${onlyoffice.url}")
|
||||
private static String onlyOfficeUrl; //onlyoffice文件转换服务URL
|
||||
|
||||
public static ResponseMessage downloadFile(String url,String filePathInfo,String filePdfName, String key, String onlineFilePath) throws Exception {
|
||||
|
||||
public static File downloadFile(String filePathInfo,String filePdfName, String key, String onlineFilePath) throws Exception {
|
||||
String filePath = filePathInfo+"/onlineFile/"+filePdfName;
|
||||
logger.info("================================="+filePath);
|
||||
String fileUrl = convertFile(url,filePdfName,key,onlineFilePath);
|
||||
logger.info("====================filePdfName:{},key:{},onlineFilePath:{}",filePdfName,key,onlineFilePath);
|
||||
String fileUrl = convertFile(filePdfName,key,onlineFilePath);
|
||||
logger.info("================================="+fileUrl);
|
||||
// 创建HttpClientBuilder
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
@@ -62,11 +69,15 @@ public class OnlyofficePdfUtil {
|
||||
HttpEntity entityRes = response.getEntity();
|
||||
if (entityRes != null) {
|
||||
InputStream content = entityRes.getContent();
|
||||
byte[] getData = readInputStream(content);
|
||||
// byte[] getData = readInputStream(content);
|
||||
// File file = new File(filePath);
|
||||
// FileOutputStream fos = new FileOutputStream(file);
|
||||
// fos.write(getData);
|
||||
// fos.close();
|
||||
// File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("")).getPath()+ filePdfName);
|
||||
File file = new File(filePath);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(getData);
|
||||
fos.close();
|
||||
FileUtils.copyInputStreamToFile(content,file);
|
||||
return file;
|
||||
}
|
||||
} else {
|
||||
throw new Exception("发送GET请求出错:" + response);
|
||||
@@ -87,8 +98,8 @@ public class OnlyofficePdfUtil {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Result.success();
|
||||
|
||||
// return Result.success();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String analysisXML(String xmlString) throws DocumentException {
|
||||
@@ -99,7 +110,7 @@ public class OnlyofficePdfUtil {
|
||||
return newFileUrl;
|
||||
}
|
||||
|
||||
public static String convertFile(String url,String titleName,String key, String onlineFilePath) throws Exception{
|
||||
public static String convertFile(String titleName,String key, String onlineFilePath) throws Exception{
|
||||
//String url = "http://47.92.92.38:8103/7.2.1-34/ConvertService.ashx";
|
||||
// String url = "http://10.100.5.116:8088/7.2.1-34/ConvertService.ashx";
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
@@ -108,14 +119,18 @@ public class OnlyofficePdfUtil {
|
||||
map.put("key",key);
|
||||
map.put("outputtype","pdf");
|
||||
map.put("title",titleName+".pdf");
|
||||
map.put("url","https://10.100.5.111:3306/file/"+onlineFilePath);
|
||||
// map.put("url","https://10.100.5.111:3306/file/"+onlineFilePath);
|
||||
map.put("url","https://srms.foton.com.cn/file/"+onlineFilePath);
|
||||
logger.info("=======================================https://srms.foton.com.cn/file/"+onlineFilePath);
|
||||
//map.put("url","https://srms.foton.com.cn/file/model/task_768330d8/task_768330d8_top_768330d8_node.docx");
|
||||
logger.info("=========================map:{}",map);
|
||||
JSONObject requestJson = new JSONObject(map);
|
||||
// 创建HttpClientBuilder
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
logger.info("=======================================服务器路径"+onlyOfficeUrl);
|
||||
HttpPost httpPost = new HttpPost(onlyOfficeUrl);
|
||||
// 设置请求和传输超时时间
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setSocketTimeout(60000)
|
||||
@@ -157,40 +172,13 @@ public class OnlyofficePdfUtil {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
|
||||
if (closeableHttpClient != null) {
|
||||
closeableHttpClient.close();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static byte[] readInputStream(InputStream inputStream) throws IOException {
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
int len = 0;
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
||||
while((len = inputStream.read(buffer)) != -1) {
|
||||
|
||||
bos.write(buffer, 0, len);
|
||||
|
||||
}
|
||||
|
||||
bos.close();
|
||||
|
||||
return bos.toByteArray();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -346,6 +347,7 @@ public class AttFileEOController {
|
||||
response.reset();
|
||||
try {
|
||||
String fileOldName = fileNameEncoding(attFileEO.getOldFileName(),request);
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=\""+fileOldName+"\"");
|
||||
response.setContentType("application/octet-stream");
|
||||
File file = new File(filePath+attFileEO.getFilePath()+attFileEO.getFileName());
|
||||
|
||||
Reference in New Issue
Block a user