ApplySignFileSample.java
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.project.demo;
import com.junziqian.api.bean.Signatory;
import com.junziqian.api.common.DealType;
import com.junziqian.api.common.IdentityType;
import com.junziqian.api.common.SignLevel;
import com.junziqian.api.request.ApplySignFileRequest;
import com.junziqian.api.response.ApplySignResponse;
import com.junziqian.api.util.LogUtils;
import org.ebaoquan.rop.thirdparty.com.alibaba.fastjson.JSONArray;
import org.ebaoquan.rop.thirdparty.com.alibaba.fastjson.JSONObject;
import org.ebaoquan.rop.thirdparty.com.google.common.collect.Sets;
import java.io.IOException;
import java.util.HashSet;
/**
* Created by wlinguo on 2016-05-16.
*/
public class ApplySignFileSample extends JunziqianClientInit {
public static void main(String[] args) throws IOException {
ApplySignFileRequest.Builder builder = new ApplySignFileRequest.Builder();
builder.withContractName("只用保全"); // 合同名称,必填
builder.withContractAmount(1.00); // 合同金额
//1、本地文件方式
builder.withFile("/Users/xuwenhao/Downloads/居间服务协议2.pdf");
//2、字节流方式
//File file = new File("D:\\tmp\\买卖合同.pdf");
//builder.withFile(file.getName(), FileCopyUtils.copyToByteArray(file)); //合同文件
// //上传签约附件,目前最大只支持上传3份附件
// builder.withAttachFile1("D:\\tmp\\借款基础信息.xlsx");
// builder.withAttachFile2("D:\\tmp\\bbbb.jpg");
// builder.withAttachFile3("D:\\tmp\\shenqingshu.png");
HashSet<Signatory> signatories = Sets.newHashSet();
/**
* 签约方1
*/
Signatory signatory = new Signatory();
signatory.setFullName("徐文豪"); //姓名
signatory.setSignatoryIdentityType(IdentityType.IDCARD); //证件类型
signatory.setIdentityCard("320981199307111710"); //证件号码
signatory.setMobile("18896525239");
/*
* 设置签约方1的签章位置,签约位置平台自行设置
* 签字位置 (以文件页左上角(0.0,0.0)为基准,按百分比进行设置)offsetX,offsetY(x,y为比例,值范设置为0-1之间) page为页码,page从0开始计数,
* 每页为一个数组,每页不能超过10个签字位置
*/
JSONArray chapteJsonArray=new JSONArray();
JSONObject pageJson=new JSONObject();
pageJson.put("page", 1);
JSONArray chaptes=new JSONArray();
pageJson.put("chaptes", chaptes);
chapteJsonArray.add(pageJson);
JSONObject chapte=new JSONObject();
chapte.put("offsetX", 0.20);
chapte.put("offsetY", 0.68);
chaptes.add(chapte);
// chapte=new JSONObject();
// chapte.put("offsetX", 0.52);
// chapte.put("offsetY", 0.75);
// chaptes.add(chapte);
signatory.withChapteJson(chapteJsonArray);
signatory.setSignLevel(1); //0:标准图形章 1:公章或手写
signatories.add(signatory);
/**
* 签约方3
*/
signatory = new Signatory();
signatory.setFullName("史文斌"); //姓名
signatory.setSignatoryIdentityType(IdentityType.IDCARD); //证件类型
signatory.setIdentityCard("32058619850321881X"); //证件号码
signatory.setMobile("15162499345");
JSONArray chapteJsonArray2 = new JSONArray();
JSONObject pageJson2 = new JSONObject();
pageJson2.put("page", 1);
JSONArray chaptes2 = new JSONArray();
pageJson2.put("chaptes", chaptes2);
chapteJsonArray2.add(pageJson2);
JSONObject chapte2 = new JSONObject();
chapte2.put("offsetX", 0.20);
chapte2.put("offsetY", 0.73);
chaptes2.add(chapte2);
signatory.withChapteJson(chapteJsonArray2);
signatory.setSignLevel(1); //0:标准图形章 1:公章或手写
signatories.add(signatory);
/**
* 签约方2
*/
signatory = new Signatory();
signatory.setFullName("七彩投资"); //姓名
signatory.setSignatoryIdentityType(IdentityType.BIZLIC); //证件类型
signatory.setIdentityCard("500903000035447");//证件号码(营业执照号或统一社会信用代码)
signatory.setEmail("qicaitouzi@www.bccto.me");//企业账户注册邮箱
signatory.setMobile("15062592832");//企业代表手机
JSONArray chapteJsonArray3 = new JSONArray();
JSONObject pageJson3 = new JSONObject();
pageJson3.put("page", 1);
JSONArray chaptes3 = new JSONArray();
pageJson3.put("chaptes", chaptes3);
chapteJsonArray3.add(pageJson3);
JSONObject chapte3 = new JSONObject();
chapte3.put("offsetX", 0.20);
chapte3.put("offsetY", 0.73);
chaptes3.add(chapte3);
signatory.withChapteJson(chapteJsonArray3);
signatory.setSignLevel(1); //0:标准图形章 1:公章或手写
signatories.add(signatory);
builder.withSignatories(signatories); // 添加签约人
builder.withSignLevel(SignLevel.GENERAL.getCode()); // 签字类型,这里选择标准图形章
//builder.withRemark("这里是备注信息,不超过500个字符"); //备注
//builder.withPreRecored("前执记录,会计录到日志中!");
builder.withServerCa(1);//使用云证书,0 不使用,1 使用
builder.withDealType(DealType.AUTH_SIGN);//自动签
ApplySignResponse response = getClient().applySignFile(builder.build());
LogUtils.logResponse(response);
}
}