|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+package com.ruoyi.common.utils;
|
|
|
2
|
+
|
|
|
3
|
+import com.google.gson.Gson;
|
|
|
4
|
+import com.google.gson.JsonArray;
|
|
|
5
|
+import com.google.gson.JsonObject;
|
|
|
6
|
+import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
|
|
7
|
+import com.ruoyi.common.enums.EsignRequestType;
|
|
|
8
|
+import com.ruoyi.common.exception.EsignDemoException;
|
|
|
9
|
+import com.ruoyi.common.utils.bean.SealSignRecord;
|
|
|
10
|
+
|
|
|
11
|
+import java.util.Map;
|
|
|
12
|
+
|
|
|
13
|
+public class SignAward {
|
|
|
14
|
+
|
|
|
15
|
+ private static String eSignHost= EsignApplicaConfig.EsignHost;
|
|
|
16
|
+ private static String eSignAppId= EsignApplicaConfig.EsignAppId;
|
|
|
17
|
+ private static String eSignAppSecret= EsignApplicaConfig.EsignAppSecret;
|
|
|
18
|
+// public static String fileId = "95d0c307d91e4985bdb8874f6f84daa5";
|
|
|
19
|
+ public static String fileId = "a0c2ad21065f48ff8b872412c39d5d3a";
|
|
|
20
|
+
|
|
|
21
|
+
|
|
|
22
|
+
|
|
|
23
|
+ public static void main(String[] args) throws EsignDemoException {
|
|
|
24
|
+ Gson gson = new Gson();
|
|
|
25
|
+
|
|
|
26
|
+ SealSignRecord sealSignRecord = new SealSignRecord();
|
|
|
27
|
+
|
|
|
28
|
+ sealSignRecord.setFileid("a808f1f39a744357a2f018e4ab34c55d");
|
|
|
29
|
+ sealSignRecord.setFilename("23893bfd3f2249ffa5c82850c11c482e.pdf");
|
|
|
30
|
+ sealSignRecord.setSignFlowid("41e6732b48c54c63a91b2379c352212d");
|
|
|
31
|
+
|
|
|
32
|
+
|
|
|
33
|
+ sealSignRecord.setPensonAccount("18209231185");
|
|
|
34
|
+ sealSignRecord.setPensonName("秦桃则");
|
|
|
35
|
+ sealSignRecord.setOrgnizeName("西安云美电子科技有限公司");
|
|
|
36
|
+ sealSignRecord.setOrgnizeNamePsnAccount("17691338406");
|
|
|
37
|
+ sealSignRecord.setOrgnizeNamepsnName("韩超勃");
|
|
|
38
|
+ sealSignRecord.setPositionPagepsn("2");
|
|
|
39
|
+
|
|
|
40
|
+ sealSignRecord.setPositionXpsn(279+20);
|
|
|
41
|
+ sealSignRecord.setPositionYpsn(216.336-20);
|
|
|
42
|
+
|
|
|
43
|
+ sealSignRecord.setPositionPageorg("2");
|
|
|
44
|
+
|
|
|
45
|
+ sealSignRecord.setPositionXorg(342+30);
|
|
|
46
|
+ sealSignRecord.setPositionYorg(185.136);
|
|
|
47
|
+
|
|
|
48
|
+
|
|
|
49
|
+
|
|
|
50
|
+
|
|
|
51
|
+ /* 发起签署*/
|
|
|
52
|
+// EsignHttpResponse createByFile = createByFile(sealSignRecord);
|
|
|
53
|
+// JsonObject createByFileJsonObject = gson.fromJson(createByFile.getBody(), JsonObject.class);
|
|
|
54
|
+// JsonObject createByFileData = createByFileJsonObject.getAsJsonObject("data");
|
|
|
55
|
+// String signFlowId = createByFileData.get("signFlowId").getAsString();
|
|
|
56
|
+// System.err.println("流程id:"+signFlowId);
|
|
|
57
|
+
|
|
|
58
|
+ /* 获取文件签名印章位置*/
|
|
|
59
|
+ EsignHttpResponse positions = getPositions(sealSignRecord);
|
|
|
60
|
+ JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class);
|
|
|
61
|
+ JsonObject positionsData = positionsJsonObject.getAsJsonObject("data");
|
|
|
62
|
+ JsonArray keywordPositions = positionsData.get("keywordPositions").getAsJsonArray();
|
|
|
63
|
+ System.out.println("获取文件签名印章位置:" +keywordPositions.toString());
|
|
|
64
|
+
|
|
|
65
|
+// String signFlowId = "c9955453716344f9971d308abdc13464";
|
|
|
66
|
+ //获取合同文件签名链接
|
|
|
67
|
+// EsignHttpResponse signUrl = signUrl(sealSignRecord);
|
|
|
68
|
+// JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
|
|
|
69
|
+// JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
|
|
|
70
|
+// String shortUrl = signUrlData.get("shortUrl").getAsString();
|
|
|
71
|
+// String url = signUrlData.get("url").getAsString();
|
|
|
72
|
+// System.out.println("签署短链接:" +shortUrl);
|
|
|
73
|
+// System.out.println("签署长链接:"+url);
|
|
|
74
|
+
|
|
|
75
|
+ //获取合同文件用印链接
|
|
|
76
|
+// EsignHttpResponse usesealUrl = usesealUrl(sealSignRecord);
|
|
|
77
|
+// JsonObject usesealUrlJsonObject = gson.fromJson(usesealUrl.getBody(), JsonObject.class);
|
|
|
78
|
+// JsonObject usesealUrlData = usesealUrlJsonObject.getAsJsonObject("data");
|
|
|
79
|
+// String shortusesealUrl = usesealUrlData.get("shortUrl").getAsString();
|
|
|
80
|
+// String sealUrl = usesealUrlData.get("url").getAsString();
|
|
|
81
|
+// System.out.println("签署长链接:" +shortusesealUrl);
|
|
|
82
|
+// System.out.println("签署短链接:"+sealUrl);
|
|
|
83
|
+
|
|
|
84
|
+ //查询签署流程详情
|
|
|
85
|
+// EsignHttpResponse signFlowDetail = signFlowDetail(sealSignRecord);
|
|
|
86
|
+// JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
|
|
|
87
|
+// System.out.println(signFlowDetailJsonObject);
|
|
|
88
|
+
|
|
|
89
|
+
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ /**
|
|
|
93
|
+ * 查询签署流程详情
|
|
|
94
|
+ * @return
|
|
|
95
|
+ */
|
|
|
96
|
+ public static EsignHttpResponse signFlowDetail(SealSignRecord sealSignRecord) throws EsignDemoException {
|
|
|
97
|
+ String signFlowId = sealSignRecord.getSignFlowid();
|
|
|
98
|
+ String apiaddr= "/v3/sign-flow/"+ signFlowId + "/detail";
|
|
|
99
|
+ String jsonParm = null;
|
|
|
100
|
+ //请求方法
|
|
|
101
|
+ EsignRequestType requestType = EsignRequestType.GET;
|
|
|
102
|
+ //生成签名鉴权方式的的header
|
|
|
103
|
+ Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
|
|
104
|
+ //发起接口请求
|
|
|
105
|
+ return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
|
|
106
|
+ }
|
|
|
107
|
+
|
|
|
108
|
+
|
|
|
109
|
+ /**
|
|
|
110
|
+ * 发起签署
|
|
|
111
|
+ * @return
|
|
|
112
|
+ * @throws EsignDemoException
|
|
|
113
|
+ */
|
|
|
114
|
+ public static EsignHttpResponse createByFile(SealSignRecord sealSignRecord) throws EsignDemoException {
|
|
|
115
|
+ String apiaddr = "/v3/sign-flow/create-by-file";
|
|
|
116
|
+
|
|
|
117
|
+ String fileId = sealSignRecord.getFileid();
|
|
|
118
|
+ String fileName = sealSignRecord.getFilename();
|
|
|
119
|
+
|
|
|
120
|
+ String psnAccount = sealSignRecord.getPensonAccount();
|
|
|
121
|
+ String psnName = sealSignRecord.getPensonName();
|
|
|
122
|
+
|
|
|
123
|
+ String orgName = sealSignRecord.getOrgnizeName();
|
|
|
124
|
+ String orgNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount();
|
|
|
125
|
+ String orgNamepsnName = sealSignRecord.getOrgnizeNamepsnName();
|
|
|
126
|
+
|
|
|
127
|
+ String positionPagepsn = sealSignRecord.getPositionPagepsn();
|
|
|
128
|
+ double positionXpsn = sealSignRecord.getPositionXpsn();
|
|
|
129
|
+ double positionYpsn = sealSignRecord.getPositionYpsn();
|
|
|
130
|
+
|
|
|
131
|
+ String positionPageorg = sealSignRecord.getPositionPageorg();
|
|
|
132
|
+ double positionXorg = sealSignRecord.getPositionXorg();
|
|
|
133
|
+ double positionYorg = sealSignRecord.getPositionYorg();
|
|
|
134
|
+
|
|
|
135
|
+
|
|
|
136
|
+ String jsonParm = "{\n" +
|
|
|
137
|
+ " \"docs\": [\n" +
|
|
|
138
|
+ " {\n" +
|
|
|
139
|
+
|
|
|
140
|
+// " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
|
|
|
141
|
+ " \"fileId\": \"" + fileId + "\",\n" +
|
|
|
142
|
+
|
|
|
143
|
+// " \"fileName\": \"477470a7741b4536a200c792b6ddf966.pdf\"\n" +
|
|
|
144
|
+ " \"fileName\": \"" + fileName + "\"\n" +
|
|
|
145
|
+
|
|
|
146
|
+ " }\n" +
|
|
|
147
|
+ " ],\n" +
|
|
|
148
|
+ " \"signFlowConfig\": {\n" +
|
|
|
149
|
+ " \"signFlowTitle\": \"测试合同\",\n" +
|
|
|
150
|
+ " \"autoStart\": true,\n" +
|
|
|
151
|
+ " \"authConfig\": {\n" +
|
|
|
152
|
+ " \"willingnessAuthModes\": [\n" +
|
|
|
153
|
+ " \"CODE_SMS\"\n" +
|
|
|
154
|
+ " ],\n" +
|
|
|
155
|
+ " \"psnAvailableAuthModes\": [\n" +
|
|
|
156
|
+ " \"PSN_MOBILE3\"\n" +
|
|
|
157
|
+ " ],\n" +
|
|
|
158
|
+ " \"orgAvailableAuthModes\": [\n" +
|
|
|
159
|
+ " \"ORG_LEGALREP\"\n" +
|
|
|
160
|
+ " ]\n" +
|
|
|
161
|
+ " },\n" +
|
|
|
162
|
+ " \"autoFinish\": true\n" +
|
|
|
163
|
+ " },\n" +
|
|
|
164
|
+
|
|
|
165
|
+ " \"signers\": [\n" +
|
|
|
166
|
+
|
|
|
167
|
+ " {\n" +
|
|
|
168
|
+
|
|
|
169
|
+ " \"psnSignerInfo\": {\n" +
|
|
|
170
|
+
|
|
|
171
|
+// " \"psnAccount\": \"18209231185\",\n" +
|
|
|
172
|
+ " \"psnAccount\": \"" + psnAccount + "\",\n" +
|
|
|
173
|
+
|
|
|
174
|
+ " \"psnInfo\": {\n" +
|
|
|
175
|
+
|
|
|
176
|
+// " \"psnName\": \"秦桃则\"\n" +
|
|
|
177
|
+ " \"psnName\": \"" + psnName + "\"\n" +
|
|
|
178
|
+ " }\n" +
|
|
|
179
|
+
|
|
|
180
|
+
|
|
|
181
|
+ " },\n" +
|
|
|
182
|
+
|
|
|
183
|
+
|
|
|
184
|
+ " \"signFields\": [\n" +
|
|
|
185
|
+ " {\n" +
|
|
|
186
|
+
|
|
|
187
|
+// " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
|
|
|
188
|
+ " \"fileId\": \"" + fileId + "\",\n" +
|
|
|
189
|
+
|
|
|
190
|
+ " \"normalSignFieldConfig\": {\n" +
|
|
|
191
|
+ " \"autoSign\": false,\n" +
|
|
|
192
|
+ " \"freeMode\": false,\n" +
|
|
|
193
|
+ " \"movableSignField\": false,\n" +
|
|
|
194
|
+ " \"signFieldPosition\": {\n" +
|
|
|
195
|
+
|
|
|
196
|
+// " \"positionPage\": \"2\",\n" +
|
|
|
197
|
+ " \"positionPage\": \"" + positionPagepsn + "\",\n" +
|
|
|
198
|
+
|
|
|
199
|
+// " \"positionX\": 310.0,\n" +
|
|
|
200
|
+ " \"positionX\": " + positionXpsn + ",\n" +
|
|
|
201
|
+
|
|
|
202
|
+// " \"positionY\": 247.536\n" +
|
|
|
203
|
+ " \"positionY\": " + positionYpsn + "\n" +
|
|
|
204
|
+
|
|
|
205
|
+ " },\n" +
|
|
|
206
|
+ " \"signFieldStyle\": 1\n" +
|
|
|
207
|
+ " },\n" +
|
|
|
208
|
+ " \"signFieldType\": 0\n" +
|
|
|
209
|
+ " }\n" +
|
|
|
210
|
+ " ],\n" +
|
|
|
211
|
+ " \"signerType\": 0\n" +
|
|
|
212
|
+ " },\n" +
|
|
|
213
|
+
|
|
|
214
|
+
|
|
|
215
|
+ " {\n" +
|
|
|
216
|
+ " \"orgSignerInfo\": {\n" +
|
|
|
217
|
+
|
|
|
218
|
+// " \"orgName\": \"西安云美电子科技有限公司\",\n" +
|
|
|
219
|
+ " \"orgName\": \"" + orgName + "\",\n" +
|
|
|
220
|
+
|
|
|
221
|
+ " \"transactorInfo\": {\n" +
|
|
|
222
|
+
|
|
|
223
|
+
|
|
|
224
|
+// " \"psnAccount\": \"17691338406\",\n" +
|
|
|
225
|
+ " \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
|
|
|
226
|
+
|
|
|
227
|
+ " \"psnInfo\": {\n" +
|
|
|
228
|
+
|
|
|
229
|
+// " \"psnName\": \"韩超勃\"\n" +
|
|
|
230
|
+ " \"psnName\": \"" + orgNamepsnName + "\"\n" +
|
|
|
231
|
+ " }\n" +
|
|
|
232
|
+
|
|
|
233
|
+ " }\n" +
|
|
|
234
|
+ " },\n" +
|
|
|
235
|
+
|
|
|
236
|
+ " \"signFields\": [\n" +
|
|
|
237
|
+ " {\n" +
|
|
|
238
|
+
|
|
|
239
|
+// " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
|
|
|
240
|
+ " \"fileId\": \"" + fileId + "\",\n" +
|
|
|
241
|
+
|
|
|
242
|
+ " \"normalSignFieldConfig\": {\n" +
|
|
|
243
|
+ " \"autoSign\": false,\n" +
|
|
|
244
|
+ " \"freeMode\": false,\n" +
|
|
|
245
|
+
|
|
|
246
|
+ " \"signFieldPosition\": {\n" +
|
|
|
247
|
+
|
|
|
248
|
+// " \"positionPage\": \"2\",\n" +
|
|
|
249
|
+ " \"positionPage\": \"" + positionPageorg + "\",\n" +
|
|
|
250
|
+
|
|
|
251
|
+// " \"positionX\": 340.0,\n" +
|
|
|
252
|
+ " \"positionX\": " + positionXorg + ",\n" +
|
|
|
253
|
+
|
|
|
254
|
+// " \"positionY\": 340.736\n" +
|
|
|
255
|
+ " \"positionY\": " + positionYorg + "\n" +
|
|
|
256
|
+ " },\n" +
|
|
|
257
|
+ " \"signFieldStyle\": 1\n" +
|
|
|
258
|
+ " },\n" +
|
|
|
259
|
+ " \"signFieldType\": 0\n" +
|
|
|
260
|
+ " }\n" +
|
|
|
261
|
+ " ],\n" +
|
|
|
262
|
+ " \"signerType\": 1\n" +
|
|
|
263
|
+ " }\n" +
|
|
|
264
|
+
|
|
|
265
|
+ " ]\n" +
|
|
|
266
|
+ "}";
|
|
|
267
|
+
|
|
|
268
|
+ //请求方法
|
|
|
269
|
+ EsignRequestType requestType = EsignRequestType.POST;
|
|
|
270
|
+ //生成请求签名鉴权方式的Header
|
|
|
271
|
+ Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
|
|
272
|
+ //发起接口请求
|
|
|
273
|
+ return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
|
|
274
|
+ }
|
|
|
275
|
+
|
|
|
276
|
+ /**
|
|
|
277
|
+ * 获取合同文件签名链接
|
|
|
278
|
+ * @return
|
|
|
279
|
+ * @throws EsignDemoException
|
|
|
280
|
+ */
|
|
|
281
|
+ public static EsignHttpResponse signUrl(SealSignRecord sealSignRecord) throws EsignDemoException {
|
|
|
282
|
+
|
|
|
283
|
+ String signFlowId = sealSignRecord.getSignFlowid();
|
|
|
284
|
+ String psnAccount = sealSignRecord.getPensonAccount();
|
|
|
285
|
+
|
|
|
286
|
+ String apiaddr = "/v3/sign-flow/" + signFlowId + "/sign-url";
|
|
|
287
|
+ String jsonParm = "{\n" +
|
|
|
288
|
+ " \"operator\": {\n" +
|
|
|
289
|
+// " \"psnAccount\":\"18209231185\"\n" +
|
|
|
290
|
+ " \"psnAccount\": \"" + psnAccount + "\"\n" +
|
|
|
291
|
+ " }\n" +
|
|
|
292
|
+ "}";
|
|
|
293
|
+ //请求方法
|
|
|
294
|
+ EsignRequestType requestType = EsignRequestType.POST;
|
|
|
295
|
+ //生成请求签名鉴权方式的Header
|
|
|
296
|
+ Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
|
|
297
|
+ //发起接口请求
|
|
|
298
|
+ return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
|
|
299
|
+ }
|
|
|
300
|
+
|
|
|
301
|
+ /**
|
|
|
302
|
+ * 获取合同文件用印链接
|
|
|
303
|
+ * @return
|
|
|
304
|
+ * @throws EsignDemoException
|
|
|
305
|
+ */
|
|
|
306
|
+ public static EsignHttpResponse usesealUrl(SealSignRecord sealSignRecord) throws EsignDemoException {
|
|
|
307
|
+ String signFlowId = sealSignRecord.getSignFlowid();
|
|
|
308
|
+ String apiaddr = "/v3/sign-flow/" + signFlowId + "/sign-url";
|
|
|
309
|
+
|
|
|
310
|
+ String psnAccount = sealSignRecord.getOrgnizeNamePsnAccount();
|
|
|
311
|
+ String orgName = sealSignRecord.getOrgnizeName();
|
|
|
312
|
+
|
|
|
313
|
+ String jsonParm = "{\n" +
|
|
|
314
|
+// " \"needLogin\": true,\n" +
|
|
|
315
|
+ " \"operator\": {\n" +
|
|
|
316
|
+
|
|
|
317
|
+// " \"psnAccount\":\"17691338406\"\n" +
|
|
|
318
|
+ " \"psnAccount\": \"" + psnAccount + "\"\n" +
|
|
|
319
|
+ " },\n" +
|
|
|
320
|
+ " \"organization\": {\n" +
|
|
|
321
|
+
|
|
|
322
|
+// " \"orgName\": \"西安云美电子科技有限公司\"\n" +
|
|
|
323
|
+ " \"orgName\": \"" + orgName + "\"\n" +
|
|
|
324
|
+
|
|
|
325
|
+ " }\n" +
|
|
|
326
|
+ "}";
|
|
|
327
|
+ //请求方法
|
|
|
328
|
+ EsignRequestType requestType = EsignRequestType.POST;
|
|
|
329
|
+ //生成请求签名鉴权方式的Header
|
|
|
330
|
+ Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
|
|
331
|
+ //发起接口请求
|
|
|
332
|
+ return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
|
|
333
|
+ }
|
|
|
334
|
+
|
|
|
335
|
+ /**
|
|
|
336
|
+ * 获取文件签名印章位置
|
|
|
337
|
+ * @return
|
|
|
338
|
+ * @throws EsignDemoException
|
|
|
339
|
+ */
|
|
|
340
|
+ public static EsignHttpResponse getPositions(SealSignRecord sealSignRecord) throws EsignDemoException {
|
|
|
341
|
+ String fileId = sealSignRecord.getFileid();
|
|
|
342
|
+ String apiaddr = "/v3/files/" + fileId + "/keyword-positions";
|
|
|
343
|
+ String jsonParm = "{\n" +
|
|
|
344
|
+ " \"keywords\": [\n" +
|
|
|
345
|
+ " \"仲裁员:\",\n" +
|
|
|
346
|
+ " \"(仲裁委员会盖章)\"\n" +
|
|
|
347
|
+ " ]\n" +
|
|
|
348
|
+ "}";
|
|
|
349
|
+ //请求方法
|
|
|
350
|
+ EsignRequestType requestType = EsignRequestType.POST;
|
|
|
351
|
+ //生成请求签名鉴权方式的Header
|
|
|
352
|
+ Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
|
|
353
|
+ //发起接口请求
|
|
|
354
|
+ return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
|
|
355
|
+ }
|
|
|
356
|
+
|
|
|
357
|
+
|
|
|
358
|
+
|
|
|
359
|
+
|
|
|
360
|
+}
|