From a2b8c918eb13eb59e50681107e8860b83ab15bab Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Tue, 12 Dec 2023 09:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=BB=93=E6=9E=84=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wps/entity/KingSoftWpsPreviewVo.java | 45 ++++++++++++ .../wps/service/impl/WpsServiceImpl.java | 73 ++++++++++++------- .../ebtp/extend/wps/vo/WpsClientInVo.java | 5 ++ 3 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/entity/KingSoftWpsPreviewVo.java diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/entity/KingSoftWpsPreviewVo.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/entity/KingSoftWpsPreviewVo.java new file mode 100644 index 0000000..59a3e71 --- /dev/null +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/entity/KingSoftWpsPreviewVo.java @@ -0,0 +1,45 @@ +package com.chinaunicom.mall.ebtp.extend.wps.entity; + +import lombok.Data; + +@Data +public class KingSoftWpsPreviewVo { + /** + * 前端 host + */ + private String srcWpsNgProxy; + /** + * 当前编辑用户工号 + */ + private String staffCode; + + /** + * 文件唯一标识 + */ + private String fileKey; + /** + * 文件名 + */ + private String fileName; + /** + * 文件下载URL + */ + private String fileUrl; + /** + * 文件大小 + */ + private Integer fileSize; + /** + * 文件创建者工号 + */ + private String fileCreator; + /** + * 文件创建时间;yyyy-MM-dd HH:mm:ss + */ + private String fileCreateTime; + /** + * 文件最近一次修改时间;yyyy-MM-dd HH:mm:ss + */ + private String fileLastModifiedTime; + +} diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java index 29bbc53..6081d65 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java @@ -24,6 +24,7 @@ import com.chinaunicom.mall.ebtp.extend.feign.client.UnicomOAuthClient; import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA; import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil; import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo; +import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsPreviewVo; import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsRet; import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsVo; import com.chinaunicom.mall.ebtp.extend.wps.enums.WpsExceptionEnum; @@ -501,42 +502,62 @@ public class WpsServiceImpl implements WpsService { @Override public String getKSWpsUrl(WpsClientInVo in){ - KingSoftWpsVo vo = new KingSoftWpsVo(); - vo.setSrcId(7); - vo.setStaffCode("ebtp"); - vo.setFileKey(in.getFileId()); - String fileName = in.getFileName(); - vo.setFileName(fileName); - vo.setFileExtension(fileName.substring(fileName.lastIndexOf(".")+1,fileName.length())); - vo.setVersion(1); - + String url = ""; + String dataJson = ""; + String callBackUrl = ""; + byte[] b = getFileByFileId(in.getFileId()); + String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); try { - String url = kswdownloadUrl+"?key="+URLEncoder.encode(getDownloadEncrypt(in.getFileId(),in.getUserToken()), "utf-8"); - vo.setDownloadUrl(url); + callBackUrl = kswdownloadUrl+"?key="+URLEncoder.encode(getDownloadEncrypt(in.getFileId(),in.getUserToken()), "utf-8"); + }catch (UnsupportedEncodingException e){ log.error("url转换失败",e); CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("url获取失败", true); } - - byte[] b = getFileByFileId(in.getFileId()); - vo.setSize(b.length); - vo.setCreator("ebtp"); - vo.setModifier("ebtp"); - String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - vo.setCreateTime(time); - - //HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); - - vo.setHost(kswhost); - - vo.setLastModifiedTime(time); - String url = ""; if("9527007".equals(in.getType())){ + url = kswpsurl; + + KingSoftWpsVo vo = new KingSoftWpsVo(); + vo.setSrcId(7); + vo.setStaffCode("ebtp"); + vo.setFileKey(in.getFileId()); + String fileName = in.getFileName(); + vo.setFileName(fileName); + vo.setFileExtension(fileName.substring(fileName.lastIndexOf(".")+1,fileName.length())); + vo.setVersion(1); + vo.setDownloadUrl(callBackUrl); + + vo.setSize(b.length); + vo.setCreator("ebtp"); + vo.setModifier("ebtp"); + + vo.setCreateTime(time); + + //HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + + vo.setHost(kswhost); + vo.setLastModifiedTime(time); + + dataJson = JSON.toJSONString(vo); }else{ + url = kswpsurl_preview; + + KingSoftWpsPreviewVo vo = new KingSoftWpsPreviewVo(); + vo.setSrcWpsNgProxy(kswhost); + vo.setStaffCode("ebtp"); + vo.setFileKey(in.getFileId()); + vo.setFileName(in.getFileName()); + vo.setFileUrl(callBackUrl); + vo.setFileSize(b.length); + vo.setFileCreator("ebtp"); + vo.setFileCreateTime(time); + vo.setFileLastModifiedTime(time); + + dataJson = JSON.toJSONString(vo); } - String retJson = HttpsUtils.UrlPost(url, "utf-8", JSON.toJSONString(vo));//httpPost(kswpsurl,json); + String retJson = HttpsUtils.UrlPost(url, "utf-8", dataJson);//httpPost(kswpsurl,json); log.info("ret:"+retJson); //String retJson = HttpUtils.httpPost(kswpsurl,json); diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java index 35f8eea..29fcf5e 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java @@ -30,4 +30,9 @@ public class WpsClientInVo { *0 查看 9527007 编辑 */ private String type; + + /** + * 文件后缀 初次编辑需要传 doc docx xls ... + */ + private String fileExtension; }