From ef6973ff508614098040a9e2761edfaf456c6d0f Mon Sep 17 00:00:00 2001 From: qitz <18810291185@163.com> Date: Fri, 6 Oct 2023 17:40:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=A3=81=E5=86=B3=E4=B9=A6?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestsign/domain/ArbitrSignatuVO.java | 27 ++++ .../bestsign/utils/BestsignOpenApiClient.java | 140 +++++++++++++++++- 2 files changed, 164 insertions(+), 3 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java index 1edcaec..6210f34 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/domain/ArbitrSignatuVO.java @@ -13,10 +13,37 @@ public class ArbitrSignatuVO { /** * 用户帐号 * 任务id + * 文件MD5 + * 文件内容 + * 文件总页数 + * 文件名称 + * 文件类型 + * 合同标题 + * 有效期 + * 合同编号 + * 签署者账号 + * 签名位置页码 + * x坐标 + * y坐标 */ private String account; private String taskId; + private String fileMd5; + private String fileData; + private String filePages; + private String fileName; + private String fileType; + private String contractTitle; + private String periodValidity; + + private String contractNum; + private String signerAccout; + private String pageNumSigner; + private String pageNumSignerX; + private String pageNumSignerY; + + diff --git a/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java index 185b86b..cdc669d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java +++ b/ruoyi-system/src/main/java/com/ruoyi/bestsign/utils/BestsignOpenApiClient.java @@ -1,7 +1,9 @@ package com.ruoyi.bestsign.utils; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.bestsign.domain.ArbitrSignatuVO; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -173,11 +175,8 @@ public class BestsignOpenApiClient { // 签名参数追加为url参数 String fullUrlParams = String.format(urlSignParams, this.developerId, timestamsParam, paramsSign); - String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke, fullUrlParams, requestParam.toJSONString()); - - JSONObject responseObj = JSON.parseObject(responseResult); // 返回errno为0,表示成功,其他表示失败 if (responseObj.getIntValue("errno") == 0) { @@ -193,4 +192,139 @@ public class BestsignOpenApiClient { } return responseObj.toJSONString(); } + + /** + * 上传文件 + * + * @param arbitrSignatuVO + * @return + * @throws Exception + */ + public String uploadContact(ArbitrSignatuVO arbitrSignatuVO) throws Exception { + String methodInvoke = "/storage/contract/upload/"; + JSONObject requestParam = new JSONObject(); + + requestParam.put("account", arbitrSignatuVO.getAccount()); + requestParam.put("fmd5", arbitrSignatuVO.getFileMd5()); + requestParam.put("fdata", arbitrSignatuVO.getFileData()); + requestParam.put("fpages", arbitrSignatuVO.getFilePages()); + requestParam.put("fname", arbitrSignatuVO.getFileName()); + requestParam.put("ftype", arbitrSignatuVO.getFileType()); + requestParam.put("title", arbitrSignatuVO.getContractTitle()); + requestParam.put("expireTime", arbitrSignatuVO.getPeriodValidity()); + + + String timestamsParam = RSAUtils.getRtick(); + // 计算参数签名 + String paramsSign = RSAUtils.calcRsaSign(this.developerId, + this.privateKey, this.serverHost, methodInvoke, timestamsParam, null, + requestParam.toJSONString()); + // 签名参数追加为url参数 + String fullUrlParams = String.format(urlSignParams, this.developerId, + timestamsParam, paramsSign); + String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke, + fullUrlParams, requestParam.toJSONString()); + JSONObject responseObj = JSON.parseObject(responseResult); + // 返回errno为0,表示成功,其他表示失败 + if (responseObj.getIntValue("errno") == 0) { + JSONObject data = responseObj.getJSONObject("data"); + if (data != null) { + String contractId = data.getString("contractId"); + return contractId; + } + } else { + + log.error("上传文件异常:" + responseObj.toJSONString()); + } + return responseObj.toJSONString(); + } + + /** + * 获取签署链接 + * + * @param arbitrSignatuVO + * @return + * @throws Exception + */ + public String getSignLink(ArbitrSignatuVO arbitrSignatuVO) throws Exception { + String methodInvoke = "/contract/send/"; + JSONObject requestParam = new JSONObject(); + + requestParam.put("contractId", arbitrSignatuVO.getContractNum()); + requestParam.put("signer", arbitrSignatuVO.getSignerAccout()); + + JSONArray signatureArray = new JSONArray(); + + JSONObject signatuItem = new JSONObject(); + signatuItem.put("pageNum", arbitrSignatuVO.getPageNumSigner()); + //x坐标 + signatuItem.put("x", arbitrSignatuVO.getPageNumSignerX()); + //y坐标 + signatuItem.put("y", arbitrSignatuVO.getPageNumSignerY()); + signatureArray.add(signatuItem); + + requestParam.put("signaturePositions", signatureArray); + + + String timestamsParam = RSAUtils.getRtick(); + // 计算参数签名 + String paramsSign = RSAUtils.calcRsaSign(this.developerId, + this.privateKey, this.serverHost, methodInvoke, timestamsParam, null, + requestParam.toJSONString()); + // 签名参数追加为url参数 + String fullUrlParams = String.format(urlSignParams, this.developerId, + timestamsParam, paramsSign); + String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke, + fullUrlParams, requestParam.toJSONString()); + JSONObject responseObj = JSON.parseObject(responseResult); + // 返回errno为0,表示成功,其他表示失败 + if (responseObj.getIntValue("errno") == 0) { + JSONObject data = responseObj.getJSONObject("data"); + if (data != null) { + String signLink = data.getString("url"); + return signLink; + } + } else { + + log.error("获取签署链接异常:" + responseObj.toJSONString()); + } + return responseObj.toJSONString(); + } + + /** + * 完成签署 + * + * @param arbitrSignatuVO + * @return + * @throws Exception + */ + public String finishSign(ArbitrSignatuVO arbitrSignatuVO) throws Exception { + String methodInvoke = "/storage/contract/lock/"; + JSONObject requestParam = new JSONObject(); + requestParam.put("contractId", arbitrSignatuVO.getContractNum()); + String timestamsParam = RSAUtils.getRtick(); + // 计算参数签名 + String paramsSign = RSAUtils.calcRsaSign(this.developerId, + this.privateKey, this.serverHost, methodInvoke, timestamsParam, null, + requestParam.toJSONString()); + // 签名参数追加为url参数 + String fullUrlParams = String.format(urlSignParams, this.developerId, + timestamsParam, paramsSign); + String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke, + fullUrlParams, requestParam.toJSONString()); + JSONObject responseObj = JSON.parseObject(responseResult); + // 返回errno为0,表示成功,其他表示失败 + if (responseObj.getIntValue("errno") == 0) { + return "完成签名"; + } else { + + log.error("完成签署异常:" + responseObj.toJSONString()); + } + return responseObj.toJSONString(); + } + + + + + }