From 1d0fd0548f96d0e6101433f710be835bec678d62 Mon Sep 17 00:00:00 2001
From: yss <17921@qq.com>
Date: Mon, 5 Jun 2023 11:15:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B2=83=E6=96=87=E6=A1=A3-=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E9=93=BE=E6=8E=A5=E3=80=81=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=EF=BC=9A=E6=9F=A5=E8=AF=A2=E6=96=87=E4=BB=B6=20=E5=8F=8A?=
=?UTF-8?q?=E4=BF=9D=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 4 +-
.../extend/crypconfigure/entity/CrypBean.java | 6 +
.../extend/wps/controller/WpsController.java | 84 ++++
.../extend/wps/enums/WpsExceptionEnum.java | 26 ++
.../ebtp/extend/wps/service/WpsService.java | 25 +
.../wps/service/impl/WpsServiceImpl.java | 439 ++++++++++++++++++
.../ebtp/extend/wps/vo/WpsClientInVo.java | 29 ++
.../mall/ebtp/extend/wps/vo/WpsFile.java | 24 +
.../mall/ebtp/extend/wps/vo/WpsResultVo.java | 23 +
.../mall/ebtp/extend/wps/vo/WpsUser.java | 11 +
.../mall/ebtp/extend/wps/vo/WpsUserAcl.java | 12 +
.../mall/ebtp/extend/wps/vo/WpsWatermark.java | 14 +
12 files changed, 695 insertions(+), 2 deletions(-)
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/enums/WpsExceptionEnum.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsFile.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsResultVo.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUser.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUserAcl.java
create mode 100644 src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsWatermark.java
diff --git a/pom.xml b/pom.xml
index 30887a1..08f9dd3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.chinaunicom.ebtp
mall-ebtp-cloud-parent
- 2.2.0-SNAPSHOT
+ 2.2.4-SNAPSHOT
com.chinaunicom.mall.ebtp
@@ -20,7 +20,7 @@
com.chinaunicom.mall.ebtp
uboot-core
- 2.2.0-SNAPSHOT
+ 2.2.4-SNAPSHOT
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java
index 37bb055..ed65e09 100644
--- a/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/crypconfigure/entity/CrypBean.java
@@ -42,4 +42,10 @@ public class CrypBean {
@ApiModelProperty(value = "operationCode")
public String operationCode;
+ /**
+ * 沃文档 content的json串
+ */
+ @ApiModelProperty(value = "签名")
+ public String contentJson;
+
}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java
new file mode 100644
index 0000000..2d27f3f
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java
@@ -0,0 +1,84 @@
+package com.chinaunicom.mall.ebtp.extend.wps.controller;
+
+
+import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
+import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail;
+import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogBusinessModule;
+import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogType;
+import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
+import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsClientInVo;
+import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsResultVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.io.File;
+
+@Slf4j
+@RestController
+@Api(value = "沃文档")
+@RequiredArgsConstructor
+@RequestMapping("/v1/wps")
+public class WpsController {
+
+ @Resource
+ private WpsService wpsService;
+
+ /**
+ * 获得编辑或查看链接
+ *
+ * @param in
+ * @return
+ */
+ @ApiOperation("调用天擎接口")
+ @PostMapping("/getWpsUrl")
+ public BaseResponse getWpsUrl(WpsClientInVo in) {
+ WpsResultVo str = this.wpsService.getWpsUrl(in);
+ log.info("----调用天擎WPS接口---getWpsUrl-------:"+str);
+ return BaseResponse.success(str);
+ }
+ /**
+ * 沃文档回调-查询文档
+ * 编辑 permission=write
+ * 预览 permission=read
+ * @param
+ * @return
+ */
+ @ApiOperation("沃文档回调-查询文档")
+ @GetMapping("/file/{permission}")
+ @OperationLogDetail(businessModule = EbtpLogBusinessModule.OTHER,operationType = EbtpLogType.SELECT,detail = "沃文档回调-查询文档")
+ public Object getFile(@RequestHeader("X-Weboffice-Token") String token,
+ @RequestParam("_w_third_user_id") String userId,
+ @RequestParam("_w_third_user_name") String userName,
+ @RequestParam("_w_third_file_id") String fileId,
+ @RequestParam("_w_third_file_name") String fileName,
+ @PathVariable String permission) {
+ return this.wpsService.getWpsFile(token, userId, userName, fileId, fileName, permission);
+ }
+
+ /**
+ * 沃文档回调-保存文档
+ * @param token
+ * @param userId
+ * @param userName
+ * @param fileId
+ * @param fileName
+ * @param file
+ * @return
+ */
+ @ApiOperation("沃文档回调-保存文档")
+ @GetMapping("/file/save")
+ @OperationLogDetail(businessModule = EbtpLogBusinessModule.OTHER,operationType = EbtpLogType.SELECT,detail = "沃文档回调-保存文档")
+ public Object saveFile(@RequestHeader("X-Weboffice-Token") String token,
+ @RequestParam("_w_third_user_id") String userId,
+ @RequestParam("_w_third_user_name") String userName,
+ @RequestParam("_w_third_file_id") String fileId,
+ @RequestParam("_w_third_file_name") String fileName,
+ @RequestPart("file") File file) {
+ return this.wpsService.saveWpsFile(token,userId,userName,fileId,fileName,file);
+ }
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/enums/WpsExceptionEnum.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/enums/WpsExceptionEnum.java
new file mode 100644
index 0000000..40487e2
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/enums/WpsExceptionEnum.java
@@ -0,0 +1,26 @@
+package com.chinaunicom.mall.ebtp.extend.wps.enums;
+
+import com.chinaunicom.mall.ebtp.common.exception.service.BusinessExceptionAssert;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum WpsExceptionEnum implements BusinessExceptionAssert {
+
+ FRAME_EXCEPTION_NO(5200001, ""),
+ FRAME_EXCEPTION_NO_IMAGE_INFO_FAIL(5200002, "文档中心异常!"),
+ /**
+ * 判断接口返回是否有数据
+ */
+ IS_SUCCESS(5200000, "查询返回null");
+
+ /**
+ * 返回码
+ */
+ private final int code;
+ /**
+ * 返回消息
+ */
+ private final String message;
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java
new file mode 100644
index 0000000..0926f08
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java
@@ -0,0 +1,25 @@
+package com.chinaunicom.mall.ebtp.extend.wps.service;
+
+
+import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
+import com.chinaunicom.mall.ebtp.extend.blockchain.entity.BlockChainLogVo;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
+import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsClientInVo;
+import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsResultVo;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * 操作的 service
+ * @author yss
+ *
+ */
+public interface WpsService{
+ WpsResultVo getWpsUrl(WpsClientInVo in);
+
+ Object getWpsFile(String token, String userId, String userName, String fileId, String fileName, String permission);
+
+ Object saveWpsFile(String token, String userId, String userName, String fileId, String fileName, File file);
+}
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
new file mode 100644
index 0000000..6f0b727
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java
@@ -0,0 +1,439 @@
+package com.chinaunicom.mall.ebtp.extend.wps.service.impl;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api.AttachmentClient;
+import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail;
+import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
+import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject;
+import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
+import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
+import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogBusinessModule;
+import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogType;
+import com.chinaunicom.mall.ebtp.common.log.service.OperationLogService;
+import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant;
+import com.chinaunicom.mall.ebtp.common.uniBss.entity.UniBss;
+import com.chinaunicom.mall.ebtp.common.uniBss.entity.UniBssAttached;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
+import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil;
+import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
+import com.chinaunicom.mall.ebtp.extend.wps.enums.WpsExceptionEnum;
+import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
+import com.chinaunicom.mall.ebtp.extend.wps.vo.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.*;
+import java.math.BigInteger;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 沃文档-wps在线文档
+ *
+ * @author yss
+ */
+@Slf4j
+@EnableAsync
+@Service
+public class WpsServiceImpl implements WpsService {
+
+ private @Autowired
+ IBaseCacheUserService cacheUserService;
+
+ @Autowired
+ private OperationLogService operationLogService;
+ /* 附件工具 */
+ @Autowired
+ private AttachmentClient attachmentClient;
+
+
+ @Value("${mconfig.bss.app-id}")
+ private String app_id;
+ @Value("${mconfig.bss.app-secret}")
+ private String app_secret;
+ @Value("${mconfig.bss.app-url-test}")
+ private String app_url_test;
+ @Value("${mconfig.bss.app-url}")
+ private String app_url;
+
+ @Value("${mconfig.wps.appid}")
+ private String wpsAppId;
+ @Value("${mconfig.wps.url.appKey}")
+ private String wpsAppKey;
+ @Value("${mconfig.wps.url.appTokenUrl}")
+ private String wpsAppTokenUrl;
+ @Value("${mconfig.wps.url.previewUrl}")
+ private String wpsPreviewUrl;
+ @Value("${mconfig.wps.url.editUrl}")
+ private String wpsEditUrl;
+ @Value("${mconfig.wps.url.downFileUrl}")
+ private String downFileUrlPrefix;
+
+ @Resource
+ private RedisTemplate redisTemplate;
+
+ /**
+ * 前端-获取编辑或查看链接
+ * @param in
+ * @return
+ */
+ @Override
+ public WpsResultVo getWpsUrl(WpsClientInVo in){
+ WpsResultVo re =new WpsResultVo();
+ String tokenValue =getWpsAppToken();
+ CrypBean bean=new CrypBean();
+ if("read".equals(in.getPermission())){
+ bean.setUrl(wpsPreviewUrl);
+ }
+ if("write".equals(in.getPermission())){
+ bean.setUrl(wpsEditUrl);
+ }
+ WpsExceptionEnum.FRAME_EXCEPTION_NO.customValidName("无法查询",StringUtils.isBlank(bean.getUrl()));
+ Map req=new HashMap<>();
+ req.put("app_token",tokenValue);
+ req.put("file_id",in.getFileId());
+ req.put("type","w");
+ req.put("scene_id",in.getId());
+ req.put("_w_third_user_id",cacheUserService.getCacheUser().getUserId());
+ req.put("_w_third_user_name",cacheUserService.getCacheUser().getFullName());
+ req.put("_w_third_file_name",in.getFileName());
+ bean.setObject(req);
+ bean.setReqName("APPTOKEN_REQ");
+ bean.setContentJson("");
+ Map urlMap=this.callUniWpsInterfaceJson(bean);
+ WpsExceptionEnum.IS_SUCCESS.customValid(urlMap==null);
+ re.setAppToken(tokenValue);
+ re.setUrl(String.valueOf(urlMap.get("url")));
+ re.setUserId(cacheUserService.getCacheUser().getUserId());
+ redisTemplate.opsForValue().set("wpsAppToken:"+in.getFileId(),in.getUserToken(),2, TimeUnit.HOURS);
+ return re;
+ }
+
+ /**
+ * 回调-获取文件信息
+ * @param token 用户token
+ * @param userId 用户id
+ * @param userName 用户名称
+ * @param fileId 文件id
+ * @param fileName 文件名称
+ * @param permission 读写标识
+ * @return
+ */
+ @Override
+ public Object getWpsFile(String token, String userId, String userName, String fileId, String fileName, String permission){
+ Optional op=attachmentClient.findByObjectId(fileId);
+ Map mess=validateWps(token,fileId,op,permission);
+ if(mess!=null){
+ return mess;
+ }
+ WpsFile wpsFile=new WpsFile();
+ wpsFile.setId(fileId);
+ wpsFile.setName(fileName);
+ wpsFile.setVersion(1);
+ wpsFile.setCreator(userId);
+ wpsFile.setModifier(userId);
+ wpsFile.setCreate_time(System.currentTimeMillis());
+ wpsFile.setModify_time(System.currentTimeMillis());
+ wpsFile.setPreview_pages(0);
+ WpsUserAcl wpsUserAcl=new WpsUserAcl();
+ wpsUserAcl.setRename(0);
+ wpsUserAcl.setCopy(1);
+ wpsUserAcl.setExport(1);
+ wpsUserAcl.setHistory(1);
+ wpsUserAcl.setPrint(1);
+ wpsFile.setUser_acl(wpsUserAcl);
+ WpsUser wpsUser=new WpsUser();
+ wpsUser.setId(userId);
+ wpsUser.setName(userName);
+ wpsUser.setPermission(permission);
+ wpsUser.setAvatar_url("");
+ wpsFile.setUser(wpsUser);
+
+ if(op.isPresent()){
+ AttachmentEntity file=op.get();
+ wpsFile.setDownload_url(downFileUrlPrefix+"?fileId="+op.get().getId());
+ wpsFile.setSize(Integer.valueOf(file.getFileSize()));
+ }else{
+ //上传文档中心一个空文档做为模板
+ AttachmentDetail upload = attachmentClient.copyByBid("bidOnlineWpsTemplate",fileId);
+ attachmentClient.updateFileNameByBid(fileId,fileName);
+ AttachmentEntity file=upload.get(fileId).get(0);
+ wpsFile.setSize(Integer.valueOf(file.getFileSize()));
+ wpsFile.setDownload_url(downFileUrlPrefix+"?fileId="+file.getId());
+ }
+ return wpsFile;
+ }
+
+ /**
+ * 回调-保存文件
+ * @param token
+ * @param userId
+ * @param userName
+ * @param fileId
+ * @param fileName
+ * @param file
+ * @return
+ */
+ @Override
+ public Object saveWpsFile(String token, String userId, String userName, String fileId, String fileName, File file) {
+ Optional op=attachmentClient.upload(fileId,file);
+ Map mess=validateWps(token,fileId,op,"save");
+ if(mess!=null){
+ return mess;
+ }
+ WpsFile wpsFile=new WpsFile();
+ wpsFile.setId(fileId);
+ wpsFile.setName(fileName);
+ wpsFile.setVersion(1);
+ wpsFile.setSize(new Long(file.length()).intValue());
+ wpsFile.setDownload_url(downFileUrlPrefix+"?fileId="+fileId);
+ return wpsFile;
+ }
+
+ private Map validateWps(String token,String fileId,Optional op,String permission){
+ Map mess= new HashMap<>();
+ mess.put("result","20501007");
+ if(redisTemplate.opsForValue().get("wpsAppToken:"+fileId)==null){
+ mess.put("msg","当前链接已失效");
+ return mess;
+ }
+ if(!String.valueOf(redisTemplate.opsForValue().get("wpsAppToken:"+fileId)).equals(token)){
+ mess.put("msg","您无权限访问");
+ return mess;
+ }
+ if(!op.isPresent() && !"read".equals(permission)){
+ mess.put("msg","查看的文件不存在");
+ return mess;
+ }
+ if(!op.isPresent() && !"save".equals(permission)){
+ mess.put("msg","文件上传失败");
+ return mess;
+ }
+ return null;
+ }
+ /**
+ * 获取应用权限
+ * ContentJson 没有就传空字符串
+ * @return
+ */
+ public String getWpsAppToken(){
+ if(redisTemplate.opsForValue().get("wpsAppToken:"+app_id)!=null){
+ return String.valueOf(redisTemplate.opsForValue().get("wpsAppToken:"+app_id));
+ }
+ CrypBean bean=new CrypBean();
+ bean.setUrl(wpsAppTokenUrl);
+ Map req=new HashMap<>();
+ req.put("scope","file_preview,file_edit,file_format_control");
+ req.put("app_id",wpsAppId);
+ bean.setObject(req);
+ bean.setReqName("APPTOKEN_REQ");
+ bean.setContentJson("");
+ Map tokenMap=this.callUniWpsInterfaceJson(bean);
+ redisTemplate.opsForValue().set("wpsAppToken:"+app_id,tokenMap.get("app_token"),23, TimeUnit.HOURS);
+ return String.valueOf(tokenMap.get("app_token"));
+ }
+
+ /**
+ * 调用天擎接口
+ * 使用对象:沃文档-wps在线文档
+ * @param bean
+ * @return
+ */
+ public Map callUniWpsInterfaceJson(CrypBean bean) {
+ log.info("沃文档-天擎接口------callUniInterface:---入参-----" + JSON.toJSONString(bean));
+ String url= "";
+ //天擎地址
+ if ("1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS".equals(app_secret)) {
+ //测试环境
+ url=app_url_test;
+ } else {
+ //生产环境
+ url=app_url;
+ }
+
+ log.info("请求路径:" +url+ bean.getUrl());
+ String json = "";
+ String str = "";
+ try {
+ Map map = JSONArray.parseObject(JSONArray.toJSONString(bean.getObject()), Map.class);
+
+ //传入数据解密
+ String contentMd5 = md5encode(bean.getContentJson());
+
+ json = getUniBss(bean.getReqName(), map);
+ String nlptDate=getGmtDate();
+ String contentType = "application/json;charset=utf-8";
+ String nlptAuth="WPS-3:"+wpsAppId+":"+sha1Encode(wpsAppKey+contentMd5+bean.getUrl()+contentType+nlptDate);
+ str = this.uniBssWpsHttpPost(url+bean.getUrl(), json,nlptDate,nlptAuth,contentMd5,contentType);
+ operationLogService.addOperationLog("沃文档天擎接口调用信息,请求地址{}"+bean.getUrl()+",参数{}"+json+",返回信息{}"+str,true, EbtpLogBusinessModule.OTHER, EbtpLogType.INSERT);
+ Map callMap = (Map)JSON.parse(str);
+ log.info("天擎接口--沃文档接口--返回数据callMap:"+ JSONObject.toJSONString(callMap));
+ Object head = callMap.get("UNI_BSS_HEAD");
+ log.info("天擎接口--沃文档接口--返回数据head:"+JSONObject.toJSONString(head));
+ Map headMap = JSONObject.parseObject(JSONObject.toJSONString(head),Map.class);
+ if(headMap.get("RESP_CODE")!=null&& UniBssConstant.RESP_CODE_00000.equals(headMap.get("RESP_CODE"))){
+ Object body = callMap.get("UNI_BSS_BODY");
+ log.info("天擎接口--沃文档接口--返回数据body:"+JSONObject.toJSONString(body));
+ Map bodyMap = JSONObject.parseObject(JSONObject.toJSONString(body),Map.class);
+
+ Object rsp = bodyMap.get(bean.getReqName().replace("REQ","RSP"));
+ log.info("天擎接口--沃文档接口--返回数据rsp:"+rsp);
+ Map rspMap = JSONObject.parseObject(JSONObject.toJSONString(rsp),Map.class);
+
+ Object status = rspMap.get("result");
+ log.info("天擎接口--沃文档接口--返回数据result:"+JSONObject.toJSONString(status));
+ if("0".equals(String.valueOf(status))){
+ return rspMap;
+ }else{
+ log.error("沃文档接口-调用失败,返回信息:",JSONObject.toJSONString(body));
+ Object result = rspMap.get("result");
+ log.info("天擎--沃文档接口--返回数据result:"+JSONObject.toJSONString(result));
+ CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("天擎沃文档接口调用失败,错误信息:"+String.valueOf(rspMap.get("msg")),true);
+ }
+
+ }else{
+ log.error("沃文档接口-天擎接口调用未成功,返回信息:",JSONObject.toJSONString(str));
+ CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("沃文档天擎接口调用失败,错误信息:"+String.valueOf(headMap.get("RESP_DESC")),true);
+ }
+ } catch (Exception e) {
+ log.error("沃文档--天擎接口返回参数!~-----------------",e);
+ operationLogService.addOperationLog("沃文档天擎接口调用信息失败,请求地址{}"+bean.getUrl()+",参数{}"+json+",返回信息{}"+str,false, EbtpLogBusinessModule.PAY_PUSH, EbtpLogType.INSERT);
+ }
+ log.info("---沃文档--天擎接口返回参数-----"+str);
+ return null;
+ }
+
+ /**
+ * 中信天擎接口 数据格式 获取加密签名
+ * REQ:{
+ * header:{}
+ * body:{}
+ * }
+ * @param map
+ * @return
+ */
+ private String getUniBss(String reqName, Map map) {
+
+ UniBss uniBss = new UniBss();
+ uniBss.setUniBssAttached(new UniBssAttached().setMediaInf(""));
+ //天擎部分head
+ UniBssUtil util = new UniBssUtil(app_id, app_secret);
+ uniBss.setUniBssHead(util.getUniBssHead());
+
+ log.info("业务参数封装前:" + map);
+ Map reqMap = new HashMap();
+ reqMap.put(reqName, map);
+ uniBss.setUniBssBodyMap(reqMap);
+ log.info("业务参数封装后:" + JSON.toJSONString(reqMap));
+ log.info("业务参数封装后uniBss:" + JSON.toJSONString(uniBss));
+
+ return JSON.toJSONString(uniBss);
+ }
+
+ /**
+ * 沃文档-在线文档 请求头参数
+ * "ClientId", "com.unicom.hq.bid"
+ * "OperationCode", "com.unicom.fcp.uapService.registeredMembers.process"
+ * @param path
+ * @param data
+ * @return
+ */
+ public String uniBssWpsHttpPost(String path, String data,String nlptDate,String nlptAuth,String nlptContentMd5,String contentType) {
+ String str = "";
+
+ try {
+ URL url = new URL(path);
+ if("https".equals(url.getProtocol())){
+ SslUtil.ignoreSsl();
+ }
+
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+ PrintWriter out = null;
+ conn.setRequestProperty("Content-Type", contentType);
+ conn.setRequestProperty("Accept", "application/json");
+ conn.setRequestProperty("Accept-Encoding", "");
+ conn.setRequestProperty("nlpt-Date", nlptDate);
+ conn.setRequestProperty("nlpt-X-Auth", nlptAuth);
+ conn.setRequestProperty("nlpt-Content-Md5",nlptContentMd5);
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ conn.setRequestMethod("POST");
+ out = new PrintWriter(conn.getOutputStream());
+ out.print(data);
+ out.flush();
+
+ InputStream is = conn.getInputStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+
+ for(String line = br.readLine(); line != null; line = br.readLine()) {
+ str = new String(line.getBytes(), "UTF-8");
+ System.out.println(str);
+ }
+
+ is.close();
+ conn.disconnect();
+ } catch (Exception var9) {
+ var9.printStackTrace();
+ }
+
+ return str;
+ }
+
+ public String getGmtDate(){
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH);
+ Calendar calendar = Calendar.getInstance();
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT")); // 设置时区为GMT
+ return sdf.format(calendar.getTime());
+ }
+
+ public String md5encode(String str) {
+ // 生成一个MD5加密计算摘要
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ // 计算md5函数
+ md.update(str.getBytes());
+ // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
+ // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
+ return new BigInteger(1, md.digest()).toString(16);
+ } catch (NoSuchAlgorithmException e) {
+
+ }
+ return "";
+ }
+
+ public String sha1Encode(String text) {
+ StringBuffer sb = new StringBuffer();
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ md.update(text.getBytes());
+ byte[] byteData = md.digest();
+
+ // 将字节数组转换为十六进制字符串
+ for (int i = 0; i < byteData.length; i++) {
+ sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
+ }
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return sb.toString();
+ }
+
+ public static void main(String[] args) {
+ System.out.println(String.valueOf(null));
+ }
+
+}
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
new file mode 100644
index 0000000..d3e09fa
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsClientInVo.java
@@ -0,0 +1,29 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+import lombok.Data;
+
+@Data
+public class WpsClientInVo {
+
+ /**
+ *前端文档id
+ */
+ private String fileId;
+
+ /**
+ * 前端文档名名称:可能是项目名、标段名、评标报告等
+ */
+ private String fileName;
+ /**
+ *请求沃文档的url
+ */
+ private String permission;
+ /**
+ *业务id,文档所属数据的id
+ */
+ private String id;
+ /**
+ *当前用户token
+ */
+ private String userToken;
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsFile.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsFile.java
new file mode 100644
index 0000000..33b4eb8
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsFile.java
@@ -0,0 +1,24 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+
+import lombok.Data;
+
+/**
+ * 参考文档 http://10.236.12.90/open#/docs/server/online-edit/callback-api
+ */
+@Data
+public class WpsFile {
+ private String id;
+ private String name;
+ private Integer version;
+ private Integer size;
+ private String creator;
+ private Long create_time;
+ private String modifier;
+ private Long modify_time;
+ private String download_url;
+ private Integer preview_pages;
+ private WpsUserAcl user_acl;
+ private WpsWatermark watermark;
+ private WpsUser user;
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsResultVo.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsResultVo.java
new file mode 100644
index 0000000..e89b805
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsResultVo.java
@@ -0,0 +1,23 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+import lombok.Data;
+
+@Data
+public class WpsResultVo {
+
+ /**
+ * 在线编辑或在线查看的链接
+ */
+ private String url;
+
+ /**
+ * 请求链接的用户:用来和当前操作用户判断 是否同一用户
+ */
+ private String userId;
+
+ /**
+ * 应用的token 24小时时效,给前端用于鉴权,此鉴权是在线文档插件用,与本系统token无关
+ */
+ private String appToken;
+
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUser.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUser.java
new file mode 100644
index 0000000..1af87f9
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUser.java
@@ -0,0 +1,11 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+import lombok.Data;
+
+@Data
+public class WpsUser {
+ private String id;
+ private String name;
+ private String permission;
+ private String avatar_url;
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUserAcl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUserAcl.java
new file mode 100644
index 0000000..50cce96
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsUserAcl.java
@@ -0,0 +1,12 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+import lombok.Data;
+
+@Data
+public class WpsUserAcl {
+ private Integer rename;
+ private Integer history;
+ private Integer copy;
+ private Integer export;
+ private Integer print;
+}
diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsWatermark.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsWatermark.java
new file mode 100644
index 0000000..d6557bd
--- /dev/null
+++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/vo/WpsWatermark.java
@@ -0,0 +1,14 @@
+package com.chinaunicom.mall.ebtp.extend.wps.vo;
+
+import lombok.Data;
+
+@Data
+public class WpsWatermark {
+ private Integer type;
+ private String value;
+ private String fillstyle;
+ private String font;
+ private float rotate;
+ private Integer horizontal;
+ private Integer vertical;
+}