合并分支 'fix_foton_20230613' 到 'master'

Fix foton 20230613

查看合并请求 laws-foton-slrs/foton-slrs-system-rest!110
This commit is contained in:
高嵩
2023-06-19 17:19:03 +08:00
9 changed files with 384 additions and 59 deletions
@@ -1041,7 +1041,7 @@ public class WorkFlowController extends BaseController {
@ApiOperation(value = "查找在线编辑文件")
@GetMapping("/selectOnlineFile")
public ResponseMessage selectOnlineFile(@RequestParam("onlineFileId") String onlineFileId,@RequestParam("standName") String standName) {
public ResponseMessage selectOnlineFile(@RequestParam("onlineFileId") String onlineFileId,@RequestParam("standName") String standName,@RequestParam("key") String key) {
logger.info("======================standName===============================!!!!!!!!!!!!!!!!!!!!!!"+standName);
String path = standEditFilePath+"/hisFile/";
File file = null;
@@ -1091,6 +1091,7 @@ public class WorkFlowController extends BaseController {
onlineFileLog.setCreateTime(new Date());
onlineFileLog.setFileName(String.valueOf(time));
onlineFileLog.setValidFlag("0");
onlineFileLog.setFilekey(key);
onlineFileLogDao.insert(onlineFileLog);
logger.info("======================日志存入成功==============================="+onlineFileLog.toString());
if(StringUtils.isNotBlank(standName)) {
@@ -1516,4 +1517,10 @@ public class WorkFlowController extends BaseController {
public String fushen(){
return workFlowFeignClient.fushen();
}
@ApiOperation(value = "|在线文件调用api")
@PostMapping("/conversionOnlineFilePDF")
public void conversionOnlineFilePDF(){
// return workFlowFeignClient.conversionOnlineFilePDF();
}
}
@@ -67,6 +67,9 @@ public class OnlineFileLog extends BaseEntity {
@TableField("VALID_FLAG")
private String validFlag;
@ApiModelProperty(value = "文件key")
@TableField("FILE_KEY")
private String filekey;
//跨服io流转换
@TableField(exist = false)
private byte[] bytes;
@@ -41,20 +41,20 @@ public class PDMCSarLawsStandInfoController extends BaseController<PDMCSarLawsSt
public ResponseMessage<PageInfo<PDMCSarLawsStandInfo>> getSarStandardsInfoPage(
@RequestParam(value = "current", defaultValue = "1") Long current,
@RequestParam(value = "limit",required = false) Long limit) throws Exception {
Long count = pdmcSarLawsStandInfoService.getSarStandardsCount();
if (ObjectUtil.isEmpty(limit)){
int count = pdmcSarLawsStandInfoService.getSarStandardsCount();
if (count == 0) {
return Result.error("文件信息为空");
}
limit = (long) count;
limit = count;
}
Page<PDMCSarLawsStandInfo> page = new Page<>(current, limit);
Page<PDMCSarLawsStandInfo> page = new Page<>(current, limit,false);
Page<PDMCSarLawsStandInfo> sarStandardsInfoPage = pdmcSarLawsStandInfoService.getSarStandardsInfo(page);
PageInfo<PDMCSarLawsStandInfo> pdmcSarLawsStandInfoPageInfo = new PageInfo<>();
pdmcSarLawsStandInfoPageInfo.setList(sarStandardsInfoPage.getRecords());
pdmcSarLawsStandInfoPageInfo.setPageNo((int)sarStandardsInfoPage.getCurrent());
pdmcSarLawsStandInfoPageInfo.setCount(sarStandardsInfoPage.getTotal());
pdmcSarLawsStandInfoPageInfo.setCount(count);
pdmcSarLawsStandInfoPageInfo.setPageSize((int) sarStandardsInfoPage.getSize());
if (pdmcSarLawsStandInfoPageInfo.getList().isEmpty()) {
return Result.error("404","文件信息为空",pdmcSarLawsStandInfoPageInfo);
@@ -12,5 +12,5 @@ import java.util.List;
public interface PDMCSarLawsStandInfoDao extends BaseMapper<PDMCSarLawsStandInfo> {
Page<PDMCSarLawsStandInfo> getSarStandardsInfo(@Param("page")Page<PDMCSarLawsStandInfo> page);
int getSarStandardsCount();
Long getSarStandardsCount();
}
@@ -15,5 +15,5 @@ import java.util.List;
public interface PDMCSarLawsStandInfoService extends IService<PDMCSarLawsStandInfo> {
Page<PDMCSarLawsStandInfo> getSarStandardsInfo(Page<PDMCSarLawsStandInfo> page);
int getSarStandardsCount();
Long getSarStandardsCount();
}
@@ -25,7 +25,7 @@ public class PDMCSarLawsStandInfoServiceImpl extends ServiceImpl<PDMCSarLawsStan
}
@Override
public int getSarStandardsCount() {
public Long getSarStandardsCount() {
return baseMapper.getSarStandardsCount();
}
}
@@ -877,7 +877,10 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
public void saveUpdateLog(SarBussionessStand sarStandardsInfoEO,SarBussionessStand beforeSarStandardsInfo) throws Exception{
Map<String,Object> newMap = new HashMap<>();
Map<String,Object> oldMap = beforeSarStandardsInfo.getAttrInfoMap();
Map<String,Object> oldMap = null;
if(beforeSarStandardsInfo!=null){
oldMap = beforeSarStandardsInfo.getAttrInfoMap();
}
String attrStr = sarStandardsInfoEO.getSarStandAttrEOStr();
if (StringUtils.isNotBlank(attrStr)) {
newMap = JSONObject.fromObject(attrStr);
@@ -1363,13 +1366,13 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
sarBussionessStandEO = newStandList.get(0);
}
// 处理 在线编辑pdf存储失败问题 发布稿的在线编辑文件 判断文件表是否有没有则 添加 每次进入 都进行判断
// Object fbgbuss = sarBussionessStandEO.getAttrInfoCaseMap().get("fbgbuss");
// if(fbgbuss!=null) {
// String fbgbussStr = fbgbuss.toString();
// if(StringUtils.isNotBlank(fbgbussStr)){
// sarStandFilePdf(fbgbussStr);
// }
// }
Object fbgbuss = sarBussionessStandEO.getAttrInfoCaseMap().get("fbgbuss");
if(fbgbuss!=null) {
String fbgbussStr = fbgbuss.toString();
if(StringUtils.isNotBlank(fbgbussStr)){
sarStandFilePdf(fbgbussStr);
}
}
return sarBussionessStandEO;
}
@@ -4922,48 +4925,45 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
objectQueryWrapperSarBussStandFile.eq("USE_MODEL", "WEB_FILE");
List<SarBussStandFile> sarBussStandFilesList = sarBussStandFileEODao.selectList(objectQueryWrapperSarBussStandFile);
if(sarBussStandFilesList.isEmpty() && sarBussStandFilesList.size()==0){
// AttFileVo attFileVo = attFileEOService.wordConversionFilePdf(sarBussStandFiles.get(0).getOriAttId());
// if(attFileVo!=null){
// SarBussStandFile sarBussStandFile = new SarBussStandFile();
// //sarBussStandFile.setId();
// String uuId = com.adc.da.util.utils.UUID.randomUUID(20);
// sarBussStandFile.setId(uuId);
// sarBussStandFile.setStandId(sarBussStandFiles.get(0).getStandId());
// sarBussStandFile.setStandFileClassify(sarBussStandFiles.get(0).getStandFileClassify());
// sarBussStandFile.setAttId(attFileVo.getId());
// sarBussStandFile.setFileName(filePath+attFileVo.getFilePath()+attFileVo.getFileName());
// sarBussStandFile.setFileSuffix(attFileVo.getFileSuffix());
// sarBussStandFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
// sarBussStandFile.setPassword(sarBussStandFiles.get(0).getPassword());
// sarBussStandFile.setValidFlag(0);
// sarBussStandFile.setCreationTime(new Date());
// sarBussStandFile.setModifyTime(new Date());
// sarBussStandFile.setOriAttId(sarBussStandFiles.get(0).getOriAttId());
// sarBussStandFileEODao.insert(sarBussStandFile);
// }else {
// logger.info("======================================word.doc转换失败=================================");
// }
AttFileEO fileInfo = attFileEOService.getFileInfo(sarBussStandFiles.get(0).getOriAttId());
if(fileInfo!=null){
String fileName = "";
if(StringUtils.isNotBlank(fileInfo.getFileName())){
String[] splitInfo = fileInfo.getFileName().split("\\.");
fileName = splitInfo[0];
//存储的名称key 路径
QueryWrapper<OnlineFileLog> onlineFileLogWrapper = new QueryWrapper<>();
onlineFileLogWrapper.eq("ATT_FILE_ID",sarBussStandFilesList.get(0).getOriAttId());
List<OnlineFileLog> onlineFileLogs = onlineFileLogDao.selectList(onlineFileLogWrapper);
if(!onlineFileLogs.isEmpty()){
if(StringUtils.isNotBlank(onlineFileLogs.get(0).getOLdFileName()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilekey()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilePath())){
try {
OnlyofficePdfUtil.downloadFile(filePath,onlineFileLogs.get(0).getOLdFileName(), onlineFileLogs.get(0).getFilekey(), onlineFileLogs.get(0).getFilePath());
File file = new File(filePath+"/onlineFile/"+onlineFileLogs.get(0).getOLdFileName());
if(file.exists()){
AttFileVo attFileVo = attFileEOService.saveFileInfo(file);
if(attFileVo!=null){
SarBussStandFile sarBussStandFile = new SarBussStandFile();
//sarBussStandFile.setId();
String uuId = com.adc.da.util.utils.UUID.randomUUID(20);
sarBussStandFile.setId(uuId);
sarBussStandFile.setStandId(sarBussStandFiles.get(0).getStandId());
sarBussStandFile.setStandFileClassify(sarBussStandFiles.get(0).getStandFileClassify());
sarBussStandFile.setAttId(attFileVo.getId());
sarBussStandFile.setFileName(filePath+attFileVo.getFilePath()+attFileVo.getFileName());
sarBussStandFile.setFileSuffix(attFileVo.getFileSuffix());
sarBussStandFile.setUseModel(UseModuleEnum.WEB_FILE.getValue());
sarBussStandFile.setPassword(sarBussStandFiles.get(0).getPassword());
sarBussStandFile.setValidFlag(0);
sarBussStandFile.setCreationTime(new Date());
sarBussStandFile.setModifyTime(new Date());
sarBussStandFile.setOriAttId(sarBussStandFiles.get(0).getOriAttId());
sarBussStandFileEODao.insert(sarBussStandFile);
}else {
logger.info("======================================word.doc转换失败=================================");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Map<String, String> bussMap = new HashMap<>();
bussMap.put("FILE_SUFFIX",sarBussStandFiles.get(0).getFileSuffix());
bussMap.put("CONVERFILENAME",filePath+fileInfo.getFilePath()+fileInfo.getFileName());
bussMap.put("SAVEPDFPATH",filePath+fileInfo.getFilePath()+fileName+".pdf");
bussMap.put("STANDID",sarBussStandFiles.get(0).getStandId());
bussMap.put("STANDFILECLASSIFY",sarBussStandFiles.get(0).getStandFileClassify());
bussMap.put("FILENAME",filePath+fileInfo.getFilePath()+fileName+".pdf");
bussMap.put("PASSWORD",sarBussStandFiles.get(0).getPassword());
bussMap.put("OAIATTID",sarBussStandFiles.get(0).getOriAttId());
logger.info("======================================word.doc发送mq=================================");
createOnlineEditingFileMQService.OnlineEditingFileMQ(bussMap);
}else {
logger.info("======================================word.doc转换失败=================================");
logger.info("======================未能查询到在线编辑的日志文件================");
}
}
}
@@ -0,0 +1,306 @@
package com.adc.da.utils.util;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Value;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
public class OnlyofficePdfUtil {
public static ResponseMessage downloadFile(String filePathInfo,String filePdfName, String key, String onlineFilePath) throws Exception {
String filePath = filePathInfo+"/onlineFile/"+filePdfName;
System.out.println("================"+filePath);
String fileUrl = convertFile(key,onlineFilePath);
System.out.println("=============================="+fileUrl);
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpGet get = new HttpGet(fileUrl);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(60000)
.setConnectionRequestTimeout(60000)
.setConnectTimeout(60000)
.build();
get.setConfig(requestConfig);
CloseableHttpResponse response = null;
try {
//发送get请求
response = closeableHttpClient.execute(get);
if (response == null || response.getStatusLine() == null) {
throw new Exception("发送GET请求失败,返回结果为空!");
}
//返回状态是否200
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
//得到请求结果
HttpEntity entityRes = response.getEntity();
if (entityRes != null) {
InputStream content = entityRes.getContent();
byte[] getData = readInputStream(content);
File file = new File(filePath);
FileOutputStream fos = new FileOutputStream(file);
fos.write(getData);
fos.close();
}
} else {
throw new Exception("发送GET请求出错:" + response);
}
} catch (Exception e) {
throw new Exception("发送GET请求出现异常," + e.getMessage());
} finally {
try {
// 关闭连接释放资源
if (response != null) {
response.close();
}
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return Result.success();
}
public static String analysisXML(String xmlString) throws DocumentException {
Document document = DocumentHelper.parseText(xmlString);
Element rootElement = document.getRootElement();
String fileUrl = rootElement.elementText("FileUrl");
String newFileUrl = fileUrl.replaceAll("&amp;", "&");
return newFileUrl;
}
public static String convertFile(String key, String onlineFilePath) throws Exception{
String url = "http://47.92.92.38:8103/7.2.1-34/ConvertService.ashx";
Map<String,Object> map = new HashMap<>();
map.put("async",false);
map.put("filetype","docx");
map.put("key",key);
map.put("outputtype","pdf");
map.put("title","test.pdf");
map.put("url","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");
JSONObject requestJson = new JSONObject(map);
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(url);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(60000)
.setConnectionRequestTimeout(60000)
.setConnectTimeout(60000)
.build();
httpPost.setConfig(requestConfig);
CloseableHttpResponse response = null;
try {
//设置post请求方式为JSON
StringEntity data = new StringEntity(String.valueOf(requestJson), "UTF-8");
data.setContentType("application/json; charset=UTF-8");
httpPost.setEntity(data);
//发送post请求
response = closeableHttpClient.execute(httpPost);
if (response == null || response.getStatusLine() == null) {
throw new Exception("发送POST请求失败,返回结果为空!");
}
//返回状态是否200
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
//得到请求结果
HttpEntity entityRes = response.getEntity();
if (entityRes != null) {
String responsetData = EntityUtils.toString(entityRes, "UTF-8");
String fileUrl = analysisXML(responsetData);
return fileUrl;
}
} else {
throw new Exception("发送POST-JSON请求出错:" + response);
}
} catch (Exception e) {
throw new Exception("发送POST请求出现异常," + e.getMessage());
} finally {
try {
// 关闭连接释放资源
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();
}
}
@@ -25,7 +25,14 @@
IFNULL(CONCAT('-', CASE WHEN ssi.STAND_YEAR='' THEN NULL ELSE ssi.STAND_YEAR END), '')) as STAND_NUMBER,
ssi.STAND_NAME as STAND_NAME,
ssi.STAND_EN_NAME as STAND_EN_NAME,
ssi.STAND_STATE as TEXT_STATE,
(SELECT
ts_dictype.DIC_TYPE_NAME
FROM
ts_dictype
WHERE
DIC_ID = ( SELECT id FROM ts_dictionary WHERE DICTIONARY_CODE = "STANDSTATE" )
and VALID_FLAG = 0
and ssi.stand_state = ts_dictype.DIC_TYPE_CODE) as TEXT_STATE,
ssi.ISSUE_TIME as ISSUE_TIME,
ssi.REPLACE_STAND_NUM as REPLACE_STAND_NUM,
concat('https://srms.foton.com.cn/#/otherStandardDetails/',ssi.ID,'/',ssi.STAND_TYPE,'_STAND') as LINK
@@ -38,10 +45,12 @@
from sar_standards_info ssi
left join sar_stand_menu ssm on ssi.id=ssm.STAND_ID order by ssi.ID asc
</select>
<select id="getSarStandardsCount" resultType="java.lang.Integer">
<select id="getSarStandardsCount" resultType="long">
select
count(1)
from sar_standards_info
left join sar_stand_menu on sar_standards_info.id=sar_stand_menu.STAND_ID order by sar_standards_info.ID asc
from (select
<include refid="Base_Column_List_Show"/>
from sar_standards_info ssi
left join sar_stand_menu ssm on ssi.id=ssm.STAND_ID) temp
</select>
</mapper>