ApplySignFileUrlSample.java 5.18 KB
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.ApplySignFileUrlRequest;
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.util.HashSet;

/**
 * Created by yfx on 2017-05-24 0024.
 */
public class ApplySignFileUrlSample extends JunziqianClientInit {
    public static void main(String[] args) {
        ApplySignFileUrlRequest.Builder builder = new ApplySignFileUrlRequest.Builder();
        
        builder.withFileUrl("我的文件.pdf","http://www.junziqian.dev/test2.pdf");
        builder.withContractName("只用保全"); // 合同名称,必填
        builder.withContractAmount(20000.00); // 合同金额
        
//     //上传签约附件,目前最大只支持上传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("512501197203035172"); //证件号码
       signatory.setMobile("18623559255");
      
       /*
        * 设置签约方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", 0);
       JSONArray chaptes=new JSONArray();
       pageJson.put("chaptes", chaptes);
       chapteJsonArray.add(pageJson);
       
       JSONObject chapte=new JSONObject();
       chapte.put("offsetX", 0.12);
       chapte.put("offsetY", 0.25);
       chaptes.add(chapte);
       
       chapte=new JSONObject();
       chapte.put("offsetX", 0.52);
       chapte.put("offsetY", 0.75);
       chaptes.add(chapte);
       
       signatory.withChapteJson(chapteJsonArray);
		signatory.setSignLevel(0); //0:标准图形章   1:公章或手写
       signatories.add(signatory);

       
       /**
        * 签约方2     
        */
      signatory = new Signatory();
      signatory.setFullName("TT测试公司"); //姓名
      signatory.setSignatoryIdentityType(IdentityType.BIZLIC); //证件类型
      signatory.setIdentityCard("500903000035447");//证件号码(营业执照号或统一社会信用代码)
      signatory.setEmail("demvrsot@www.bccto.me");//企业账户注册邮箱
      signatory.setMobile("18623559271");//企业代表手机
       
      /*
       * 设置签约方2的签章位置,签约位置平台自行设置
       * 签字位置 (以文件页左上角(0.0,0.0)为基准,按百分比进行设置)offsetX,offsetY(x,y为比例,值范设置为0-1之间) page为页码,page从0开始计数,
       * 每页为一个数组,每页不能超过10个签字位置
       */
      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.5);
     chapte3.put("offsetY", 0.5);
      chaptes3.add(chapte3);

     JSONObject pageJson4 = new JSONObject();
      pageJson4.put("page", 0);
     JSONArray chaptes4 = new JSONArray();
      pageJson4.put("chaptes", chaptes4);
      chapteJsonArray3.add(pageJson4);
      
     JSONObject chapte4 = new JSONObject();
     chapte4.put("offsetX", 0.5);
      chapte4.put("offsetY", 0.5);
      chaptes4.add(chapte4);
      
     
     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().applySignFileUrl(builder.build());
        LogUtils.logResponse(response);
    }
}