|
|
@@ -1,7 +1,9 @@
|
|
1
|
1
|
package com.ruoyi.bestsign.utils;
|
|
2
|
2
|
|
|
3
|
3
|
import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
|
4
|
5
|
import com.alibaba.fastjson.JSONObject;
|
|
|
6
|
+import com.ruoyi.bestsign.domain.ArbitrSignatuVO;
|
|
5
|
7
|
import lombok.Data;
|
|
6
|
8
|
import lombok.extern.slf4j.Slf4j;
|
|
7
|
9
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@@ -173,11 +175,8 @@ public class BestsignOpenApiClient {
|
|
173
|
175
|
// 签名参数追加为url参数
|
|
174
|
176
|
String fullUrlParams = String.format(urlSignParams, this.developerId,
|
|
175
|
177
|
timestamsParam, paramsSign);
|
|
176
|
|
-
|
|
177
|
178
|
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
|
178
|
179
|
fullUrlParams, requestParam.toJSONString());
|
|
179
|
|
-
|
|
180
|
|
-
|
|
181
|
180
|
JSONObject responseObj = JSON.parseObject(responseResult);
|
|
182
|
181
|
// 返回errno为0,表示成功,其他表示失败
|
|
183
|
182
|
if (responseObj.getIntValue("errno") == 0) {
|
|
|
@@ -193,4 +192,139 @@ public class BestsignOpenApiClient {
|
|
193
|
192
|
}
|
|
194
|
193
|
return responseObj.toJSONString();
|
|
195
|
194
|
}
|
|
|
195
|
+
|
|
|
196
|
+ /**
|
|
|
197
|
+ * 上传文件
|
|
|
198
|
+ *
|
|
|
199
|
+ * @param arbitrSignatuVO
|
|
|
200
|
+ * @return
|
|
|
201
|
+ * @throws Exception
|
|
|
202
|
+ */
|
|
|
203
|
+ public String uploadContact(ArbitrSignatuVO arbitrSignatuVO) throws Exception {
|
|
|
204
|
+ String methodInvoke = "/storage/contract/upload/";
|
|
|
205
|
+ JSONObject requestParam = new JSONObject();
|
|
|
206
|
+
|
|
|
207
|
+ requestParam.put("account", arbitrSignatuVO.getAccount());
|
|
|
208
|
+ requestParam.put("fmd5", arbitrSignatuVO.getFileMd5());
|
|
|
209
|
+ requestParam.put("fdata", arbitrSignatuVO.getFileData());
|
|
|
210
|
+ requestParam.put("fpages", arbitrSignatuVO.getFilePages());
|
|
|
211
|
+ requestParam.put("fname", arbitrSignatuVO.getFileName());
|
|
|
212
|
+ requestParam.put("ftype", arbitrSignatuVO.getFileType());
|
|
|
213
|
+ requestParam.put("title", arbitrSignatuVO.getContractTitle());
|
|
|
214
|
+ requestParam.put("expireTime", arbitrSignatuVO.getPeriodValidity());
|
|
|
215
|
+
|
|
|
216
|
+
|
|
|
217
|
+ String timestamsParam = RSAUtils.getRtick();
|
|
|
218
|
+ // 计算参数签名
|
|
|
219
|
+ String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
|
|
220
|
+ this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
|
|
221
|
+ requestParam.toJSONString());
|
|
|
222
|
+ // 签名参数追加为url参数
|
|
|
223
|
+ String fullUrlParams = String.format(urlSignParams, this.developerId,
|
|
|
224
|
+ timestamsParam, paramsSign);
|
|
|
225
|
+ String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
|
|
226
|
+ fullUrlParams, requestParam.toJSONString());
|
|
|
227
|
+ JSONObject responseObj = JSON.parseObject(responseResult);
|
|
|
228
|
+ // 返回errno为0,表示成功,其他表示失败
|
|
|
229
|
+ if (responseObj.getIntValue("errno") == 0) {
|
|
|
230
|
+ JSONObject data = responseObj.getJSONObject("data");
|
|
|
231
|
+ if (data != null) {
|
|
|
232
|
+ String contractId = data.getString("contractId");
|
|
|
233
|
+ return contractId;
|
|
|
234
|
+ }
|
|
|
235
|
+ } else {
|
|
|
236
|
+
|
|
|
237
|
+ log.error("上传文件异常:" + responseObj.toJSONString());
|
|
|
238
|
+ }
|
|
|
239
|
+ return responseObj.toJSONString();
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+ /**
|
|
|
243
|
+ * 获取签署链接
|
|
|
244
|
+ *
|
|
|
245
|
+ * @param arbitrSignatuVO
|
|
|
246
|
+ * @return
|
|
|
247
|
+ * @throws Exception
|
|
|
248
|
+ */
|
|
|
249
|
+ public String getSignLink(ArbitrSignatuVO arbitrSignatuVO) throws Exception {
|
|
|
250
|
+ String methodInvoke = "/contract/send/";
|
|
|
251
|
+ JSONObject requestParam = new JSONObject();
|
|
|
252
|
+
|
|
|
253
|
+ requestParam.put("contractId", arbitrSignatuVO.getContractNum());
|
|
|
254
|
+ requestParam.put("signer", arbitrSignatuVO.getSignerAccout());
|
|
|
255
|
+
|
|
|
256
|
+ JSONArray signatureArray = new JSONArray();
|
|
|
257
|
+
|
|
|
258
|
+ JSONObject signatuItem = new JSONObject();
|
|
|
259
|
+ signatuItem.put("pageNum", arbitrSignatuVO.getPageNumSigner());
|
|
|
260
|
+ //x坐标
|
|
|
261
|
+ signatuItem.put("x", arbitrSignatuVO.getPageNumSignerX());
|
|
|
262
|
+ //y坐标
|
|
|
263
|
+ signatuItem.put("y", arbitrSignatuVO.getPageNumSignerY());
|
|
|
264
|
+ signatureArray.add(signatuItem);
|
|
|
265
|
+
|
|
|
266
|
+ requestParam.put("signaturePositions", signatureArray);
|
|
|
267
|
+
|
|
|
268
|
+
|
|
|
269
|
+ String timestamsParam = RSAUtils.getRtick();
|
|
|
270
|
+ // 计算参数签名
|
|
|
271
|
+ String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
|
|
272
|
+ this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
|
|
273
|
+ requestParam.toJSONString());
|
|
|
274
|
+ // 签名参数追加为url参数
|
|
|
275
|
+ String fullUrlParams = String.format(urlSignParams, this.developerId,
|
|
|
276
|
+ timestamsParam, paramsSign);
|
|
|
277
|
+ String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
|
|
278
|
+ fullUrlParams, requestParam.toJSONString());
|
|
|
279
|
+ JSONObject responseObj = JSON.parseObject(responseResult);
|
|
|
280
|
+ // 返回errno为0,表示成功,其他表示失败
|
|
|
281
|
+ if (responseObj.getIntValue("errno") == 0) {
|
|
|
282
|
+ JSONObject data = responseObj.getJSONObject("data");
|
|
|
283
|
+ if (data != null) {
|
|
|
284
|
+ String signLink = data.getString("url");
|
|
|
285
|
+ return signLink;
|
|
|
286
|
+ }
|
|
|
287
|
+ } else {
|
|
|
288
|
+
|
|
|
289
|
+ log.error("获取签署链接异常:" + responseObj.toJSONString());
|
|
|
290
|
+ }
|
|
|
291
|
+ return responseObj.toJSONString();
|
|
|
292
|
+ }
|
|
|
293
|
+
|
|
|
294
|
+ /**
|
|
|
295
|
+ * 完成签署
|
|
|
296
|
+ *
|
|
|
297
|
+ * @param arbitrSignatuVO
|
|
|
298
|
+ * @return
|
|
|
299
|
+ * @throws Exception
|
|
|
300
|
+ */
|
|
|
301
|
+ public String finishSign(ArbitrSignatuVO arbitrSignatuVO) throws Exception {
|
|
|
302
|
+ String methodInvoke = "/storage/contract/lock/";
|
|
|
303
|
+ JSONObject requestParam = new JSONObject();
|
|
|
304
|
+ requestParam.put("contractId", arbitrSignatuVO.getContractNum());
|
|
|
305
|
+ String timestamsParam = RSAUtils.getRtick();
|
|
|
306
|
+ // 计算参数签名
|
|
|
307
|
+ String paramsSign = RSAUtils.calcRsaSign(this.developerId,
|
|
|
308
|
+ this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
|
|
309
|
+ requestParam.toJSONString());
|
|
|
310
|
+ // 签名参数追加为url参数
|
|
|
311
|
+ String fullUrlParams = String.format(urlSignParams, this.developerId,
|
|
|
312
|
+ timestamsParam, paramsSign);
|
|
|
313
|
+ String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
|
|
314
|
+ fullUrlParams, requestParam.toJSONString());
|
|
|
315
|
+ JSONObject responseObj = JSON.parseObject(responseResult);
|
|
|
316
|
+ // 返回errno为0,表示成功,其他表示失败
|
|
|
317
|
+ if (responseObj.getIntValue("errno") == 0) {
|
|
|
318
|
+ return "完成签名";
|
|
|
319
|
+ } else {
|
|
|
320
|
+
|
|
|
321
|
+ log.error("完成签署异常:" + responseObj.toJSONString());
|
|
|
322
|
+ }
|
|
|
323
|
+ return responseObj.toJSONString();
|
|
|
324
|
+ }
|
|
|
325
|
+
|
|
|
326
|
+
|
|
|
327
|
+
|
|
|
328
|
+
|
|
|
329
|
+
|
|
196
|
330
|
}
|