| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- package com.ruoyi.wisdomarbitrate.utils;
-
- import com.google.gson.Gson;
- import com.google.gson.JsonArray;
- import com.google.gson.JsonObject;
- import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
- import com.ruoyi.common.enums.EsignRequestType;
- import com.ruoyi.common.exception.EsignDemoException;
- import com.ruoyi.common.utils.EsignApplicaConfig;
- import com.ruoyi.common.utils.EsignHttpHelper;
- import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
-
- import java.util.Map;
-
- public class SignAward {
-
- private static String eSignHost= EsignApplicaConfig.EsignHost;
- private static String eSignAppId= EsignApplicaConfig.EsignAppId;
- private static String eSignAppSecret= EsignApplicaConfig.EsignAppSecret;
- // public static String fileId = "95d0c307d91e4985bdb8874f6f84daa5";
- public static String fileId = "a0c2ad21065f48ff8b872412c39d5d3a";
-
-
-
- public static void main(String[] args) throws EsignDemoException {
- Gson gson = new Gson();
-
- SealSignRecord sealSignRecord = new SealSignRecord();
-
- sealSignRecord.setFileid("a808f1f39a744357a2f018e4ab34c55d");
- sealSignRecord.setFilename("23893bfd3f2249ffa5c82850c11c482e.pdf");
- sealSignRecord.setSignFlowid("41e6732b48c54c63a91b2379c352212d");
-
-
- sealSignRecord.setPensonAccount("18209231185");
- sealSignRecord.setPensonName("秦桃则");
- sealSignRecord.setOrgnizeName("西安云美电子科技有限公司");
- sealSignRecord.setOrgnizeNamePsnAccount("17691338406");
- sealSignRecord.setOrgnizeNamepsnName("韩超勃");
- sealSignRecord.setPositionPagepsn("2");
-
- sealSignRecord.setPositionXpsn(279+20);
- sealSignRecord.setPositionYpsn(216.336-20);
-
- sealSignRecord.setPositionPageorg("2");
-
- sealSignRecord.setPositionXorg(342+30);
- sealSignRecord.setPositionYorg(185.136);
-
-
-
-
- /* 发起签署*/
- // EsignHttpResponse createByFile = createByFile(sealSignRecord);
- // JsonObject createByFileJsonObject = gson.fromJson(createByFile.getBody(), JsonObject.class);
- // JsonObject createByFileData = createByFileJsonObject.getAsJsonObject("data");
- // String signFlowId = createByFileData.get("signFlowId").getAsString();
- // System.err.println("流程id:"+signFlowId);
-
- /* 获取文件签名印章位置*/
- // EsignHttpResponse positions = getPositions(sealSignRecord);
- // JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class);
- // JsonObject positionsData = positionsJsonObject.getAsJsonObject("data");
- // JsonArray keywordPositions = positionsData.get("keywordPositions").getAsJsonArray();
- // System.out.println("获取文件签名印章位置:" +keywordPositions.toString());
-
- // String signFlowId = "c9955453716344f9971d308abdc13464";
- //获取合同文件签名链接
- // EsignHttpResponse signUrl = signUrl(sealSignRecord);
- // JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class);
- // JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
- // String shortUrl = signUrlData.get("shortUrl").getAsString();
- // String url = signUrlData.get("url").getAsString();
- // System.out.println("签署短链接:" +shortUrl);
- // System.out.println("签署长链接:"+url);
-
- //获取合同文件用印链接
- // EsignHttpResponse usesealUrl = usesealUrl(sealSignRecord);
- // JsonObject usesealUrlJsonObject = gson.fromJson(usesealUrl.getBody(), JsonObject.class);
- // JsonObject usesealUrlData = usesealUrlJsonObject.getAsJsonObject("data");
- // String shortusesealUrl = usesealUrlData.get("shortUrl").getAsString();
- // String sealUrl = usesealUrlData.get("url").getAsString();
- // System.out.println("签署长链接:" +shortusesealUrl);
- // System.out.println("签署短链接:"+sealUrl);
-
- //查询签署流程详情
- EsignHttpResponse signFlowDetail = signFlowDetail(sealSignRecord);
- JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
- JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
- JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
- for (int i = 0; i < signersArray.size(); i++) {
- JsonObject signerObject = (JsonObject)signersArray.get(i);
- Integer psnsignStatus ;
- Integer orgsignStatus ;
- if(!(signerObject.get("psnSigner").toString()).equals("null")){
- JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
- if(psnSignerData!=null){
- psnsignStatus = signerObject.get("signStatus").getAsInt();
- sealSignRecord.setPsnsignStatus(psnsignStatus);
- }
- }
- if(!(signerObject.get("orgSigner").toString()).equals("null")){
- JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
- if(orgSignerData!=null){
- orgsignStatus = signerObject.get("signStatus").getAsInt();
- sealSignRecord.setOrgsignStatus(orgsignStatus);
- }
-
- }
- }
-
- System.out.println(signFlowDetailJsonObject);
-
-
- }
-
-
-
- /**
- * 查询签署流程详情
- * @return
- */
- public static EsignHttpResponse signFlowDetail(SealSignRecord sealSignRecord) throws EsignDemoException {
- String signFlowId = sealSignRecord.getSignFlowid();
- String apiaddr= "/v3/sign-flow/"+ signFlowId + "/detail";
- String jsonParm = null;
- //请求方法
- EsignRequestType requestType = EsignRequestType.GET;
- //生成签名鉴权方式的的header
- Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
- //发起接口请求
- return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
- }
-
-
- /**
- * 发起签署
- * @return
- * @throws EsignDemoException
- */
- public static EsignHttpResponse createByFile(SealSignRecord sealSignRecord) throws EsignDemoException {
- String apiaddr = "/v3/sign-flow/create-by-file";
-
- String fileId = sealSignRecord.getFileid();
- String fileName = sealSignRecord.getFilename();
-
- String psnAccount = sealSignRecord.getPensonAccount();
- String psnName = sealSignRecord.getPensonName();
-
- String orgName = sealSignRecord.getOrgnizeName();
- String orgNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount();
- String orgNamepsnName = sealSignRecord.getOrgnizeNamepsnName();
-
- String positionPagepsn = sealSignRecord.getPositionPagepsn();
- double positionXpsn = sealSignRecord.getPositionXpsn();
- double positionYpsn = sealSignRecord.getPositionYpsn();
-
- String positionPageorg = sealSignRecord.getPositionPageorg();
- double positionXorg = sealSignRecord.getPositionXorg();
- double positionYorg = sealSignRecord.getPositionYorg();
-
-
- String jsonParm = "{\n" +
- " \"docs\": [\n" +
- " {\n" +
-
- // " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
- " \"fileId\": \"" + fileId + "\",\n" +
-
- // " \"fileName\": \"477470a7741b4536a200c792b6ddf966.pdf\"\n" +
- " \"fileName\": \"" + fileName + "\"\n" +
-
- " }\n" +
- " ],\n" +
- " \"signFlowConfig\": {\n" +
- " \"signFlowTitle\": \"测试合同\",\n" +
- " \"autoStart\": true,\n" +
- " \"authConfig\": {\n" +
- " \"willingnessAuthModes\": [\n" +
- " \"CODE_SMS\"\n" +
- " ],\n" +
- " \"psnAvailableAuthModes\": [\n" +
- " \"PSN_MOBILE3\"\n" +
- " ],\n" +
- " \"orgAvailableAuthModes\": [\n" +
- " \"ORG_LEGALREP\"\n" +
- " ]\n" +
- " },\n" +
- " \"autoFinish\": true\n" +
- " },\n" +
-
- " \"signers\": [\n" +
-
- " {\n" +
-
- " \"psnSignerInfo\": {\n" +
-
- // " \"psnAccount\": \"18209231185\",\n" +
- " \"psnAccount\": \"" + psnAccount + "\",\n" +
-
- " \"psnInfo\": {\n" +
-
- // " \"psnName\": \"秦桃则\"\n" +
- " \"psnName\": \"" + psnName + "\"\n" +
- " }\n" +
-
-
- " },\n" +
-
-
- " \"signFields\": [\n" +
- " {\n" +
-
- // " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
- " \"fileId\": \"" + fileId + "\",\n" +
-
- " \"normalSignFieldConfig\": {\n" +
- " \"autoSign\": false,\n" +
- " \"freeMode\": false,\n" +
- " \"movableSignField\": false,\n" +
- " \"signFieldPosition\": {\n" +
-
- // " \"positionPage\": \"2\",\n" +
- " \"positionPage\": \"" + positionPagepsn + "\",\n" +
-
- // " \"positionX\": 310.0,\n" +
- " \"positionX\": " + positionXpsn + ",\n" +
-
- // " \"positionY\": 247.536\n" +
- " \"positionY\": " + positionYpsn + "\n" +
-
- " },\n" +
- " \"signFieldStyle\": 1\n" +
- " },\n" +
- " \"signFieldType\": 0\n" +
- " }\n" +
- " ],\n" +
- " \"signerType\": 0\n" +
- " },\n" +
-
-
- " {\n" +
- " \"orgSignerInfo\": {\n" +
-
- // " \"orgName\": \"西安云美电子科技有限公司\",\n" +
- " \"orgName\": \"" + orgName + "\",\n" +
-
- " \"transactorInfo\": {\n" +
-
-
- // " \"psnAccount\": \"17691338406\",\n" +
- " \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
-
- " \"psnInfo\": {\n" +
-
- // " \"psnName\": \"韩超勃\"\n" +
- " \"psnName\": \"" + orgNamepsnName + "\"\n" +
- " }\n" +
-
- " }\n" +
- " },\n" +
-
- " \"signFields\": [\n" +
- " {\n" +
-
- // " \"fileId\": \"5bd34a81e8084acaab3287c019e82fe8\",\n" +
- " \"fileId\": \"" + fileId + "\",\n" +
-
- " \"normalSignFieldConfig\": {\n" +
- " \"autoSign\": false,\n" +
- " \"freeMode\": false,\n" +
-
- " \"signFieldPosition\": {\n" +
-
- // " \"positionPage\": \"2\",\n" +
- " \"positionPage\": \"" + positionPageorg + "\",\n" +
-
- // " \"positionX\": 340.0,\n" +
- " \"positionX\": " + positionXorg + ",\n" +
-
- // " \"positionY\": 340.736\n" +
- " \"positionY\": " + positionYorg + "\n" +
- " },\n" +
- " \"signFieldStyle\": 1\n" +
- " },\n" +
- " \"signFieldType\": 0\n" +
- " }\n" +
- " ],\n" +
- " \"signerType\": 1\n" +
- " }\n" +
-
- " ]\n" +
- "}";
-
- //请求方法
- EsignRequestType requestType = EsignRequestType.POST;
- //生成请求签名鉴权方式的Header
- Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
- //发起接口请求
- return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
- }
-
- /**
- * 获取合同文件签名链接
- * @return
- * @throws EsignDemoException
- */
- public static EsignHttpResponse signUrl(SealSignRecord sealSignRecord) throws EsignDemoException {
-
- String signFlowId = sealSignRecord.getSignFlowid();
- String psnAccount = sealSignRecord.getPensonAccount();
-
- String apiaddr = "/v3/sign-flow/" + signFlowId + "/sign-url";
- String jsonParm = "{\n" +
- " \"operator\": {\n" +
- // " \"psnAccount\":\"18209231185\"\n" +
- " \"psnAccount\": \"" + psnAccount + "\"\n" +
- " }\n" +
- "}";
- //请求方法
- EsignRequestType requestType = EsignRequestType.POST;
- //生成请求签名鉴权方式的Header
- Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
- //发起接口请求
- return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
- }
-
- /**
- * 获取合同文件用印链接
- * @return
- * @throws EsignDemoException
- */
- public static EsignHttpResponse usesealUrl(SealSignRecord sealSignRecord) throws EsignDemoException {
- String signFlowId = sealSignRecord.getSignFlowid();
- String apiaddr = "/v3/sign-flow/" + signFlowId + "/sign-url";
-
- String psnAccount = sealSignRecord.getOrgnizeNamePsnAccount();
- String orgName = sealSignRecord.getOrgnizeName();
-
- String jsonParm = "{\n" +
- // " \"needLogin\": true,\n" +
- " \"operator\": {\n" +
-
- // " \"psnAccount\":\"17691338406\"\n" +
- " \"psnAccount\": \"" + psnAccount + "\"\n" +
- " },\n" +
- " \"organization\": {\n" +
-
- // " \"orgName\": \"西安云美电子科技有限公司\"\n" +
- " \"orgName\": \"" + orgName + "\"\n" +
-
- " }\n" +
- "}";
- //请求方法
- EsignRequestType requestType = EsignRequestType.POST;
- //生成请求签名鉴权方式的Header
- Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
- //发起接口请求
- return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
- }
-
- /**
- * 获取文件签名印章位置
- * @return
- * @throws EsignDemoException
- */
- public static EsignHttpResponse getPositions(SealSignRecord sealSignRecord) throws EsignDemoException {
- String fileId = sealSignRecord.getFileid();
- String apiaddr = "/v3/files/" + fileId + "/keyword-positions";
- String jsonParm = "{\n" +
- " \"keywords\": [\n" +
- " \"仲裁员:\",\n" +
- " \"(仲裁委员会盖章)\"\n" +
- " ]\n" +
- "}";
- //请求方法
- EsignRequestType requestType = EsignRequestType.POST;
- //生成请求签名鉴权方式的Header
- Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
- //发起接口请求
- return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
- }
-
-
-
-
- }
|