hejinbo 2 лет назад
Родитель
Сommit
1cdf3abc30

+ 125
- 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/SealUtil.java Просмотреть файл

@@ -0,0 +1,125 @@
1
+package com.ruoyi.common.utils;
2
+
3
+import com.ruoyi.common.config.EsignDemoConfig;
4
+import com.ruoyi.common.constant.EsignHeaderConstant;
5
+import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
6
+import com.ruoyi.common.enums.EsignRequestType;
7
+import com.ruoyi.common.exception.EsignDemoException;
8
+import com.ruoyi.common.utils.bean.EsignFileBean;
9
+
10
+import java.util.Map;
11
+
12
+public class SealUtil {
13
+    private static String eSignHost = EsignDemoConfig.EsignHost;
14
+    private static String eSignAppId = EsignDemoConfig.EsignAppId;
15
+    private static String eSignAppSecret = EsignDemoConfig.EsignAppSecret;
16
+
17
+    /**
18
+     * 获取机构认证&授权页面链接
19
+     *
20
+     * @return
21
+     */
22
+    public static EsignHttpResponse getOrgEmpower() throws EsignDemoException {
23
+        String apiaddr = "/v3/org-auth-url";
24
+        String nickName = "何进波";
25
+        String phonenumber = "15191509780";
26
+        String deptName = "西安云美公司";
27
+        String jsonParm = "{\n" +
28
+                "    \"orgAuthConfig\": {\n" +
29
+                "        \"orgName\": \"" + deptName + " \",\n" +
30
+                "        \"transactorInfo\": {\n" +
31
+                "            \"psnAccount\": \"" + phonenumber +  "\",\n" +
32
+                "            \"psnInfo\": {\n" +
33
+                "                \"psnName\": \"" + nickName +  "\",\n" +
34
+               "                 \"psnMobile\": \"" + phonenumber +  "\"\n" +
35
+                "            }\n" +
36
+                "        }\n" +
37
+                "    },\n" +
38
+                "    \"authorizeConfig\": {\n" +
39
+                "        \"authorizedScopes\": [\n" +
40
+                "            \"get_org_identity_info\",\n" +
41
+                "            \"get_psn_identity_info\",\n" +
42
+                "            \"org_initiate_sign\",\n" +
43
+                "            \"psn_initiate_sign\",\n" +
44
+                "            \"manage_org_resource\",\n" +
45
+                "            \"manage_psn_resource\",\n" +
46
+                "            \"use_org_order\"\n" +
47
+                "        ]\n" +
48
+                "    }\n" +
49
+                "}";
50
+        //请求方法
51
+        EsignRequestType requestType = EsignRequestType.POST;
52
+        //生成请求签名鉴权方式的Header
53
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
54
+        //发起接口请求
55
+        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
56
+
57
+    }
58
+    /**
59
+     * 查询认证授权流程详情
60
+     *
61
+     * @return
62
+     */
63
+    public static EsignHttpResponse queryAuthProcess(String authFlowId ) throws EsignDemoException {
64
+        String apiaddr = "/v3/auth-flow/" + authFlowId;
65
+        //请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
66
+        String jsonParm=null;
67
+        //请求方法
68
+        EsignRequestType requestType= EsignRequestType.GET;
69
+        //生成签名鉴权方式的的header
70
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
71
+        //发起接口请求
72
+        return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
73
+    }
74
+
75
+
76
+
77
+
78
+    /**
79
+     *   步骤一:获取印章图片上传地址fileUploadUrl
80
+     *
81
+     * @return
82
+     */
83
+    public static EsignHttpResponse getFileUploadUrl() throws EsignDemoException {
84
+        //自定义的文件封装类,传入文件地址可以获取文件的名称大小,文件流等数据
85
+        String filePath = "D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg";
86
+        EsignFileBean esignFileBean = new EsignFileBean(filePath);
87
+        String apiaddr="/v3/files/file-key";
88
+        //请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
89
+        String jsonParm="{\n" +
90
+                "    \"contentMd5\": \""+esignFileBean.getFileContentMD5()+"\",\n" +
91
+                "    \"fileName\":\""+esignFileBean.getFileName()+"\"," +
92
+                "    \"fileSize\": "+esignFileBean.getFileSize()+",\n" +
93
+                "    \"contentType\": \""+ EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE()+"\"\n" +
94
+                "}";
95
+        //请求方法
96
+        EsignRequestType requestType= EsignRequestType.POST;
97
+        //生成签名鉴权方式的的header
98
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
99
+        //发起接口请求
100
+        EsignHttpResponse response = EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
101
+        System.out.println(response);
102
+        return response;
103
+    }
104
+
105
+    /**
106
+     *   步骤二:将印章图片文件流上传到fileUploadUrl
107
+     *
108
+     * @return
109
+     */
110
+    public static EsignHttpResponse fileStreamUpload(String uploadUrl,String filePath) throws EsignDemoException {
111
+        //根据文件地址获取文件contentMd5
112
+        EsignFileBean esignFileBean = new EsignFileBean(filePath);
113
+        //请求方法
114
+        EsignRequestType requestType= EsignRequestType.PUT;
115
+        return EsignHttpHelper.doUploadHttp(uploadUrl,requestType,esignFileBean.getFileBytes(),esignFileBean.getFileContentMD5(), EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE(),true);
116
+    }
117
+    public static void main(String[] args) throws Exception {
118
+       // createOrgByImage();
119
+      //  getOrgEmpower();
120
+       // queryAuthProcess("OF-2b00885895080028");
121
+       // getFileUploadUrl();
122
+//        String uplodUrl = "https://esignoss.esign.cn/7438987614/8e278262-5960-4004-bff3-297c11e2652e/Snipaste_2023-10-27_09-59-23.jpg?Expires=1699439095&OSSAccessKeyId=STS.NTZ8NBHcTVQXgsxVRH4iyC5AY&Signature=3yu3ZQifphZsnOgN0CI0SJdqFhY%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDliM2Y3ZjkyLTdkOWUtNGZkZi04NWU4LWE4ZDU4MzEwZjIzOCQ0MTQwNTE2ODk5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fvc%2FT2pbx14ZOzZVXJslIdOOZVrPDquzz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEoWWWTbdH4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAXGx8FDtPQxW3RSasFgOFBJaxbYjH3WFFrbV25v8a%2BS9OWPAYqOCvmkxbM7N4hOge2iaBAG4SRLMb6ypPJ15YEpoZI8KkdeDvQJryZEWchmc0Lhz0yDRqrN%2BzYhgu4VpBJu1WJg%2FyXrvAZ0gWhBN%2BILrblSR9QHVWVVYZTAKN4ejIAA%3D";
123
+//       fileStreamUpload(uplodUrl,"D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
124
+    }
125
+}

+ 22
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/DeptIdentify.java Просмотреть файл

@@ -33,6 +33,28 @@ public class DeptIdentify   extends BaseEntity {
33 33
     /** 印章名称 */
34 34
     private String sealName;
35 35
 
36
+    /** 机构账号ID */
37
+    private String orgId;
38
+
39
+    /** 认证授权流程ID */
40
+    private String authFlowId;
41
+
42
+    public String getAuthFlowId() {
43
+        return authFlowId;
44
+    }
45
+
46
+    public void setAuthFlowId(String authFlowId) {
47
+        this.authFlowId = authFlowId;
48
+    }
49
+
50
+    public String getOrgId() {
51
+        return orgId;
52
+    }
53
+
54
+    public void setOrgId(String orgId) {
55
+        this.orgId = orgId;
56
+    }
57
+
36 58
     public String getSealName() {
37 59
         return sealName;
38 60
     }

+ 3
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java Просмотреть файл

@@ -56,6 +56,9 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
56 56
             JsonObject signUrlJsonObject = gson.fromJson(identifyUrl.getBody(), JsonObject.class);
57 57
             JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
58 58
             String url = signUrlData.get("authUrl").getAsString();
59
+            //获取本次认证授权流程ID
60
+            String authFlowId = signUrlData.get("authFlowId").getAsString();
61
+            deptIdentify.setAuthFlowId(authFlowId);
59 62
             deptIdentifynew.setIdentifyUrl(url);
60 63
         }
61 64
 

+ 5
- 7
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java Просмотреть файл

@@ -7,6 +7,7 @@ import com.ruoyi.common.constant.CaseApplicationConstants;
7 7
 import com.ruoyi.common.constant.FileTransformation;
8 8
 import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
9 9
 import com.ruoyi.common.exception.EsignDemoException;
10
+import com.ruoyi.common.utils.SealUtil;
10 11
 import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
11 12
 import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
12 13
 import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
@@ -168,7 +169,6 @@ public class FixSelectFlowDetailUtils {
168 169
 
169 170
     }
170 171
 
171
-
172 172
     @Scheduled(cron = "0/30 * * * * ?")
173 173
     @Transactional
174 174
     public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
@@ -182,9 +182,12 @@ public class FixSelectFlowDetailUtils {
182 182
                 JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
183 183
                 JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
184 184
                 int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
185
-                String orgId = identifyInfoData.get("orgId").getAsString();
186 185
                 if(realnameStatus==1){
186
+                    String orgId = identifyInfoData.get("orgId").getAsString();
187 187
                     EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
188
+                    //将orgId保存到数据库里
189
+                    DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
190
+                    deptIdentifynew.setOrgId(orgId);
188 191
                     JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
189 192
                     JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
190 193
                     JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
@@ -198,16 +201,11 @@ public class FixSelectFlowDetailUtils {
198 201
                         }
199 202
                     }
200 203
                     String sealName = sealNames.substring(0,sealNames.length()-1);
201
-                    DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
202 204
                     deptIdentifynew.setIdentifyStatus(1);
203 205
                     deptIdentifynew.setSealName(sealName);
204 206
                     int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
205 207
                 }
206
-
207 208
             }
208
-
209 209
         }
210
-
211 210
     }
212
-
213 211
 }

+ 48
- 13
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java Просмотреть файл

@@ -333,9 +333,9 @@ public class SignAward {
333 333
     }
334 334
 
335 335
     /**
336
-     * 获取机构认证链接
336
+     * 获取机构认证&授权页面链接
337
+     *
337 338
      * @return
338
-     * @throws EsignDemoException
339 339
      */
340 340
     public static EsignHttpResponse deptIdentifyUrl(DeptIdentify deptIdentify) throws EsignDemoException {
341 341
         String apiaddr = "/v3/org-auth-url";
@@ -343,17 +343,27 @@ public class SignAward {
343 343
         String phonenumber = deptIdentify.getPhonenumber();
344 344
         String deptName = deptIdentify.getDeptName();
345 345
         String jsonParm = "{\n" +
346
-                "            \"orgAuthConfig\": {\n" +
347
-                "                \"orgName\": \"" + deptName +  "\",\n" +
348
-                "                \"transactorInfo\": {\n" +
349
-                "                   \"psnAccount\": \"" + phonenumber +  "\",\n" +
350
-                "                   \"psnInfo\": {\n" +
351
-                "                              \"psnName\": \"" + nickName +  "\",\n" +
352
-                "                              \"psnMobile\": \"" + phonenumber +  "\"\n" +
353
-                "                         }\n" +
354
-
355
-                "                   }\n" +
346
+                "    \"orgAuthConfig\": {\n" +
347
+                "        \"orgName\": \"" + deptName + " \",\n" +
348
+                "        \"transactorInfo\": {\n" +
349
+                "            \"psnAccount\": \"" + phonenumber +  "\",\n" +
350
+                "            \"psnInfo\": {\n" +
351
+                "                \"psnName\": \"" + nickName +  "\",\n" +
352
+                "                 \"psnMobile\": \"" + phonenumber +  "\"\n" +
356 353
                 "            }\n" +
354
+                "        }\n" +
355
+                "    },\n" +
356
+                "    \"authorizeConfig\": {\n" +
357
+                "        \"authorizedScopes\": [\n" +
358
+                "            \"get_org_identity_info\",\n" +
359
+                "            \"get_psn_identity_info\",\n" +
360
+                "            \"org_initiate_sign\",\n" +
361
+                "            \"psn_initiate_sign\",\n" +
362
+                "            \"manage_org_resource\",\n" +
363
+                "            \"manage_psn_resource\",\n" +
364
+                "            \"use_org_order\"\n" +
365
+                "        ]\n" +
366
+                "    }\n" +
357 367
                 "}";
358 368
         //请求方法
359 369
         EsignRequestType requestType = EsignRequestType.POST;
@@ -417,7 +427,32 @@ public class SignAward {
417 427
         return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
418 428
     }
419 429
 
420
-
430
+    /**
431
+     * 创建机构图片印章
432
+     *
433
+     * @return
434
+     */
435
+    public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify) throws EsignDemoException {
436
+        String apiaddr = "/v3/seals/org-seals/create-by-image";
437
+        String orgId = deptIdentify.getOrgId();
438
+        String sealImageFileKey = "";
439
+        //请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
440
+        String jsonParm = "{\n" +
441
+                "  \"orgId\": \"" + orgId + "\",\n" +
442
+                "  \"sealImageFileKey\": \"" + sealImageFileKey + "\",\n" +
443
+                "  \"sealName\": \"企业公章1\",\n" +
444
+                "  \"sealWidth\": 50,\n" +
445
+                "  \"sealHeight\": 50,\n" +
446
+                "}";
447
+        //请求方法
448
+        EsignRequestType requestType = EsignRequestType.POST;
449
+        //生成签名鉴权方式的的header
450
+        Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
451
+        //发起接口请求
452
+        EsignHttpResponse response = EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
453
+        System.out.println(response);
454
+        return response;
455
+    }
421 456
 
422 457
 
423 458
 }