Bläddra i källkod

实现签名功能

qitz 2 år sedan
förälder
incheckning
6248473cd7

+ 4
- 3
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java Visa fil

@@ -88,7 +88,8 @@ public class SaaSAPIFileUtils {
88 88
 
89 89
 
90 90
   public static void main(String[] args) throws EsignDemoException {
91
-      String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
91
+//        String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
92
+        String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\12\\调解书测试.docx";
92 93
         EsignHttpResponse uploadUrl = getUploadUrl(filePath);
93 94
         String body = uploadUrl.getBody();
94 95
         JSONObject jsonObject = new JSONObject(body);
@@ -100,8 +101,8 @@ public class SaaSAPIFileUtils {
100 101
       //String fileUploadUrl = "https://esignoss.esign.cn/1111564182/ccf6db5a-92da-4523-89ba-385a30423596/23893bfd3f2249ffa5c82850c11c482e.docx?Expires=1697021257&OSSAccessKeyId=STS.NTmgvSC8n5Zg1y7EciQftF23N&Signature=CxVZmpwFksWmLYkxPjVz9K4mVyA%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDAyODhjOTg3LWNlNzgtNDM1OC04NWYwLTdlNmUyM2NjOTJmNiQzNDk1NzQ3MjE5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fYLMznrudPgpiMM1%2BGoWM8XelYqfeYrDz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEofT7katr4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAaxcPCSY0Du8wgErfR1llD8t2zeFG%2B1mktU4Rsl7AgxsSFxrwILBUk2x7imVsFVA0kkS8rNBMDKGIsIZTCl5M7S2L%2BD8364htwcZgIZYHK2fCN6gCuy%2Bfk9C%2FfQaTc00IWBMw8OubuJ%2Fq2mdMh32yoi7dLuJyhwt1z%2F%2BWf5vIFHdIAA%3D";
101 102
         EsignHttpResponse esignHttpResponse = uploadFile(fileUploadUrl, filePath);
102 103
         System.out.println("这是上传文件流的结果:"+esignHttpResponse.getBody());
103
-//       EsignHttpResponse fileStatus = getFileStatus(fileId);
104
-//        System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody());
104
+        EsignHttpResponse fileStatus = getFileStatus(fileId);
105
+        System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody());
105 106
 //        getFileStatus("a808f1f39a744357a2f018e4ab34c55d");
106 107
 //     fileDownloadUrl("");
107 108
 

+ 14
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/mscase/SealSignRecord.java Visa fil

@@ -23,6 +23,12 @@ public class SealSignRecord extends BaseEntity {
23 23
     private String pensonAccount;
24 24
     /** 签名人姓名 */
25 25
     private String pensonName;
26
+
27
+    /** 被申请人账户 */
28
+    private String pensonAccountRes;
29
+    /** 被申请人姓名 */
30
+    private String pensonNameRes;
31
+
26 32
     /** 机构名称 */
27 33
     private String orgnizeName;
28 34
     /** 机构经办人 */
@@ -52,6 +58,14 @@ public class SealSignRecord extends BaseEntity {
52 58
     private double positionXpsn;
53 59
     /** 签名位置y坐标 */
54 60
     private double positionYpsn;
61
+
62
+    /** 被申请人签名位置页数 */
63
+    private String positionPagepsnRes;
64
+    /** 被申请人签名位置x坐标 */
65
+    private double positionXpsnRes;
66
+    /** 被申请人签名位置y坐标 */
67
+    private double positionYpsnRes;
68
+
55 69
     /** 印章位置页数 */
56 70
     private String positionPageorg;
57 71
     /** 印章位置x坐标 */

+ 232
- 4
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java Visa fil

@@ -3,6 +3,8 @@ package com.ruoyi.wisdomarbitrate.utils;
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.alibaba.fastjson.JSONObject;
5 5
 import com.google.gson.Gson;
6
+import com.google.gson.JsonArray;
7
+import com.google.gson.JsonObject;
6 8
 import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
7 9
 import com.ruoyi.common.enums.EsignRequestType;
8 10
 import com.ruoyi.common.exception.EsignDemoException;
@@ -13,6 +15,7 @@ import com.ruoyi.wisdomarbitrate.domain.vo.base.StringIdsReq;
13 15
 import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify;
14 16
 import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord;
15 17
 
18
+import java.util.ArrayList;
16 19
 import java.util.List;
17 20
 import java.util.Map;
18 21
 
@@ -28,23 +31,28 @@ public class SignAward {
28 31
 
29 32
 
30 33
 
34
+
31 35
         /* 发起签署*/
32
-//        EsignHttpResponse createByFile = createByFile(sealSignRecord);
36
+//        EsignHttpResponse createByFile = createByFileMediation(sealSignRecord,sealIdList);
33 37
 //        JsonObject createByFileJsonObject = gson.fromJson(createByFile.getBody(), JsonObject.class);
34 38
 //        JsonObject createByFileData = createByFileJsonObject.getAsJsonObject("data");
35 39
 //        String signFlowId = createByFileData.get("signFlowId").getAsString();
36
-//        System.err.println("流程id:"+signFlowId);
40
+//        System.out.println("流程id:"+signFlowId);
41
+
42
+
43
+
37 44
 
38 45
         /* 获取文件签名印章位置*/
39
-//        EsignHttpResponse positions = getPositions(sealSignRecord);
46
+//        EsignHttpResponse positions = getPositionsMediation(sealSignRecord);
40 47
 //        JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class);
41 48
 //        JsonObject positionsData = positionsJsonObject.getAsJsonObject("data");
42 49
 //        JsonArray keywordPositions = positionsData.get("keywordPositions").getAsJsonArray();
43 50
 //        System.out.println("获取文件签名印章位置:" +keywordPositions.toString());
44 51
 
45 52
 //        String signFlowId = "c9955453716344f9971d308abdc13464";
53
+
46 54
         //获取合同文件签名链接
47
-//        EsignHttpResponse signUrl = signUrl(sealSignRecord);
55
+//        EsignHttpResponse signUrl = signUrlMediation(sealSignRecord);
48 56
 //        JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
49 57
 //        JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
50 58
 //        String shortUrl = signUrlData.get("shortUrl").getAsString();
@@ -274,6 +282,173 @@ public class SignAward {
274 282
         return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
275 283
     }
276 284
 
285
+    /**
286
+     * 发起签署
287
+     *
288
+     * @return
289
+     * @throws EsignDemoException
290
+     */
291
+    public static EsignHttpResponse createByFileMediation(SealSignRecord sealSignRecord ,List<String> sealIdList) throws EsignDemoException {
292
+        String apiaddr = "/v3/sign-flow/create-by-file";
293
+
294
+        String fileId = sealSignRecord.getFileid();
295
+        String fileName = sealSignRecord.getFilename();
296
+
297
+        String psnAccount = sealSignRecord.getPensonAccount();
298
+        String psnName = sealSignRecord.getPensonName();
299
+
300
+        String psnAccountRes = sealSignRecord.getPensonAccountRes();
301
+        String psnNameRes = sealSignRecord.getPensonNameRes();
302
+
303
+        String orgName = sealSignRecord.getOrgnizeName();
304
+        String orgNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount();
305
+        String orgNamepsnName = sealSignRecord.getOrgnizeNamepsnName();
306
+
307
+        String positionPagepsn = sealSignRecord.getPositionPagepsn();
308
+        double positionXpsn = sealSignRecord.getPositionXpsn();
309
+        double positionYpsn = sealSignRecord.getPositionYpsn();
310
+
311
+        String positionPagepsnRes = sealSignRecord.getPositionPagepsnRes();
312
+        double positionXpsnRes = sealSignRecord.getPositionXpsnRes();
313
+        double positionYpsnRes = sealSignRecord.getPositionYpsnRes();
314
+
315
+        String positionPageorg = sealSignRecord.getPositionPageorg();
316
+        double positionXorg = sealSignRecord.getPositionXorg();
317
+        double positionYorg = sealSignRecord.getPositionYorg();
318
+        String availableSealId = "209af82b-5f87-4e0a-b0d8-cc4923b6e652";
319
+
320
+
321
+        String jsonParm = "{\n" +
322
+                "    \"docs\": [\n" +
323
+                "        {\n" +
324
+                "            \"fileId\": \"" + fileId + "\",\n" +
325
+                "            \"fileName\": \"" + fileName + "\"\n" +
326
+                "        }\n" +
327
+                "    ],\n" +
328
+                "    \"signFlowConfig\": {\n" +
329
+                "        \"signFlowTitle\": \"测试合同\",\n" +
330
+                "        \"autoStart\": true,\n" +
331
+                "       \"authConfig\": {\n" +
332
+                "           \"willingnessAuthModes\": [\n" +
333
+                "               \"CODE_SMS\"\n" +
334
+                "           ],\n" +
335
+                "           \"psnAvailableAuthModes\": [\n" +
336
+                "               \"PSN_MOBILE3\"\n" +
337
+                "           ],\n" +
338
+                "           \"orgAvailableAuthModes\": [\n" +
339
+                "               \"ORG_LEGALREP\"\n" +
340
+                "           ]\n" +
341
+                "       },\n" +
342
+
343
+                "       \"signConfig\": {\n" +
344
+                "           \"availableSignClientTypes\":  \"1\"\n" +
345
+                "       },\n" +
346
+
347
+                "        \"autoFinish\": true\n" +
348
+                "    },\n" +
349
+
350
+                "    \"signers\": [\n" +
351
+                "          {\n" +
352
+                "            \"psnSignerInfo\": {\n" +
353
+                "                \"psnAccount\": \"" + psnAccount + "\",\n" +
354
+                "                \"psnInfo\": {\n" +
355
+                "                            \"psnName\": \"" + psnName + "\"\n" +
356
+                "                        }\n" +
357
+                "            },\n" +
358
+                "            \"signFields\": [\n" +
359
+                "                {\n" +
360
+                "                    \"fileId\": \"" + fileId + "\",\n" +
361
+                "                    \"normalSignFieldConfig\": {\n" +
362
+                "                        \"autoSign\": false,\n" +
363
+                "                        \"freeMode\": false,\n" +
364
+                "                        \"movableSignField\": false,\n" +
365
+                "                        \"signFieldPosition\": {\n" +
366
+                "                            \"positionPage\": \"" + positionPagepsn + "\",\n" +
367
+                "                            \"positionX\": " + positionXpsn + ",\n" +
368
+                "                            \"positionY\": " + positionYpsn + "\n" +
369
+                "                        },\n" +
370
+                "                        \"signFieldStyle\": 1\n" +
371
+                "                    },\n" +
372
+                "                    \"signFieldType\": 0\n" +
373
+                "                }\n" +
374
+                "            ],\n" +
375
+                "            \"signerType\": 0\n" +
376
+                "        },\n" +
377
+
378
+                "        {\n" +
379
+                "            \"psnSignerInfo\": {\n" +
380
+                "                \"psnAccount\": \"" + psnAccountRes + "\",\n" +
381
+                "                \"psnInfo\": {\n" +
382
+                "                            \"psnName\": \"" + psnNameRes + "\"\n" +
383
+                "                        }\n" +
384
+                "            },\n" +
385
+                "            \"signFields\": [\n" +
386
+                "                {\n" +
387
+                "                    \"fileId\": \"" + fileId + "\",\n" +
388
+                "                    \"normalSignFieldConfig\": {\n" +
389
+                "                        \"autoSign\": false,\n" +
390
+                "                        \"freeMode\": false,\n" +
391
+                "                        \"movableSignField\": false,\n" +
392
+                "                        \"signFieldPosition\": {\n" +
393
+                "                            \"positionPage\": \"" + positionPagepsnRes + "\",\n" +
394
+                "                            \"positionX\": " + positionXpsnRes + ",\n" +
395
+                "                            \"positionY\": " + positionYpsnRes + "\n" +
396
+                "                        },\n" +
397
+                "                        \"signFieldStyle\": 1\n" +
398
+                "                    },\n" +
399
+                "                    \"signFieldType\": 0\n" +
400
+                "                }\n" +
401
+                "            ],\n" +
402
+                "            \"signerType\": 0\n" +
403
+                "        },\n" +
404
+
405
+                "        {\n" +
406
+                "            \"orgSignerInfo\": {\n" +
407
+                "                \"orgName\": \"" + orgName + "\",\n" +
408
+                "                \"transactorInfo\": {\n" +
409
+                "                \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
410
+                "                \"psnInfo\": {\n" +
411
+                "                            \"psnName\": \"" + orgNamepsnName + "\"\n" +
412
+                "                        }\n" +
413
+                "                }\n" +
414
+                "            },\n" +
415
+
416
+                "            \"signFields\": [\n" +
417
+                "                {\n" +
418
+                "                    \"fileId\": \"" + fileId + "\",\n" +
419
+                "                    \"normalSignFieldConfig\": {\n" +
420
+                "                        \"autoSign\": false,\n" +
421
+                "                        \"freeMode\": false,\n" +
422
+
423
+             /*       "                        \"availableSealIds\": [\n" +
424
+                "                               \"" + availableSealId + "\"\n" +
425
+                "                           ],\n" +*/
426
+                //     "                               \"availableSealIds\": " + new Gson().toJson(sealIdList) + ",\n" +
427
+
428
+                "                        \"signFieldPosition\": {\n" +
429
+                "                            \"positionPage\": \"" + positionPageorg + "\",\n" +
430
+                "                            \"positionX\": " + positionXorg + ",\n" +
431
+                "                            \"positionY\": " + positionYorg + "\n" +
432
+                "                        },\n" +
433
+                "                        \"signFieldStyle\": 1\n" +
434
+                "                    },\n" +
435
+                "                    \"signFieldType\": 0\n" +
436
+                "                }\n" +
437
+                "            ],\n" +
438
+                "            \"signerType\": 1\n" +
439
+                "        }\n" +
440
+
441
+                "    ]\n" +
442
+                "}";
443
+
444
+        //请求方法
445
+        EsignRequestType requestType = EsignRequestType.POST;
446
+        //生成请求签名鉴权方式的Header
447
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
448
+        //发起接口请求
449
+        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
450
+    }
451
+
277 452
     /**
278 453
      * 获取合同文件签名链接
279 454
      *
@@ -301,6 +476,35 @@ public class SignAward {
301 476
         //发起接口请求
302 477
         return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
303 478
     }
479
+
480
+    /**
481
+     * 获取合同文件移动端签名链接
482
+     *
483
+     * @return
484
+     * @throws EsignDemoException
485
+     */
486
+    public static EsignHttpResponse signUrlMediation(SealSignRecord sealSignRecord) throws EsignDemoException {
487
+
488
+        String signFlowId = sealSignRecord.getSignFlowid();
489
+        String psnAccount = sealSignRecord.getPensonAccount();
490
+
491
+        String apiaddr = "/v3/sign-flow/" + signFlowId + "/sign-url";
492
+        String jsonParm = "{\n" +
493
+
494
+                "    \"clientType\": \"H5\",\n" +
495
+
496
+                "    \"operator\": {\n" +
497
+                "        \"psnAccount\": \"" + psnAccount + "\"\n" +
498
+                "    }\n" +
499
+                "}";
500
+        //请求方法
501
+        EsignRequestType requestType = EsignRequestType.POST;
502
+        //生成请求签名鉴权方式的Header
503
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
504
+        //发起接口请求
505
+        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
506
+    }
507
+
304 508
     /**
305 509
      * 获取批量签页面链接
306 510
      *
@@ -474,6 +678,30 @@ public class SignAward {
474 678
         return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
475 679
     }
476 680
 
681
+    /**
682
+     * 获取文件签名印章位置
683
+     *
684
+     * @return
685
+     * @throws EsignDemoException
686
+     */
687
+    public static EsignHttpResponse getPositionsMediation(SealSignRecord sealSignRecord) throws EsignDemoException {
688
+        String fileId = sealSignRecord.getFileid();
689
+        String apiaddr = "/v3/files/" + fileId + "/keyword-positions";
690
+        String jsonParm = "{\n" +
691
+                "    \"keywords\": [\n" +
692
+                "        \"申请人:\",\n" +
693
+                "        \"被申请人:\",\n" +
694
+                "        \"(盖章)\"\n" +
695
+                "    ]\n" +
696
+                "}";
697
+        //请求方法
698
+        EsignRequestType requestType = EsignRequestType.POST;
699
+        //生成请求签名鉴权方式的Header
700
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
701
+        //发起接口请求
702
+        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
703
+    }
704
+
477 705
     /**
478 706
      * 创建机构图片印章
479 707
      *