ApplySignTmplSample.java 5.23 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.ApplySignTmplRequest;
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.Maps;
import org.ebaoquan.rop.thirdparty.com.google.common.collect.Sets;

import java.util.HashSet;
import java.util.Map;

/**
 * Created by wlinguo on 2016-05-16.
 */
public class ApplySignTmplSample extends JunziqianClientInit {
    public static void main(String[] args) {
        ApplySignTmplRequest.Builder builder = new ApplySignTmplRequest.Builder();
        builder.withContractName("测试合同20160608");
        builder.withTemplateNo("00154");

        Map<String, Object> params = Maps.newHashMap();
        params.put("NO", "SN123456789");
        params.put("projectName", "君子签");
        params.put("dept", "技术部");
        params.put("name", "文林果");
        builder.withContractParams(params);

      

        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().applySignTmpl(builder.build());
        LogUtils.logResponse(response);
    }
}