调解系统初始化版本
This commit is contained in:
@@ -0,0 +1,546 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.DateUtils;
|
||||
import com.ruoyi.common.utils.EsignApplicaConfig;
|
||||
import com.ruoyi.common.utils.EsignHttpHelper;
|
||||
import com.ruoyi.common.utils.SealUtil;
|
||||
import com.ruoyi.wisdomarbitrate.StringIdsReq;
|
||||
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
|
||||
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SignAward {
|
||||
|
||||
private static String eSignHost = EsignApplicaConfig.EsignHost;
|
||||
private static String eSignAppId = EsignApplicaConfig.EsignAppId;
|
||||
private static String eSignAppSecret = EsignApplicaConfig.EsignAppSecret;
|
||||
|
||||
|
||||
public static void main(String[] args) throws EsignDemoException {
|
||||
Gson gson = new Gson();
|
||||
|
||||
|
||||
|
||||
/* 发起签署*/
|
||||
// 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);
|
||||
|
||||
//查询机构认证信息
|
||||
// DeptIdentify deptIdentify = new DeptIdentify();
|
||||
// deptIdentify.setDeptName("西安云美电子科技有限公司");
|
||||
// EsignHttpResponse identifyInfo = getDeptIdentifyInfo(deptIdentify);
|
||||
// JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
|
||||
// JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
|
||||
// int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
|
||||
// String orgId = identifyInfoData.get("orgId").getAsString();
|
||||
// System.out.println("机构认证状态:" +realnameStatus);
|
||||
// System.out.println("机构id:" +orgId);
|
||||
|
||||
// EsignHttpResponse identifyInfo = deptIdentifySealList(orgId);
|
||||
// JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
|
||||
// JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
|
||||
// JsonArray sealArray = identifyInfoData.get("seals").getAsJsonArray();
|
||||
// String sealNames = "";
|
||||
// if(sealArray.size()>0){
|
||||
// for (int i = 0; i < sealArray.size(); i++) {
|
||||
// JsonObject sealObject = (JsonObject)sealArray.get(i);
|
||||
// String sealName = sealObject.get("sealName").toString();
|
||||
// String sealNamenew = sealName.substring(1,sealName.length()-1);
|
||||
// sealNames += sealNamenew +",";
|
||||
// }
|
||||
// }
|
||||
// System.out.println("机构印章名称:" +sealNames.substring(0,sealNames.length()-1));
|
||||
|
||||
|
||||
//查询签署流程详情
|
||||
// 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);
|
||||
DeptIdentify deptIdentify = new DeptIdentify();
|
||||
deptIdentify.setAuthFlowId("OF-2b5883bf4508000c");
|
||||
EsignHttpResponse deptIdentifyInfo = getDeptIdentifyInfo(deptIdentify);
|
||||
System.out.println(deptIdentifyInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询签署流程详情
|
||||
*
|
||||
* @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, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起签署
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static EsignHttpResponse createByFile(SealSignRecord sealSignRecord ,List<String> sealIdList) 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 availableSealId = "209af82b-5f87-4e0a-b0d8-cc4923b6e652";
|
||||
|
||||
|
||||
String jsonParm = "{\n" +
|
||||
" \"docs\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\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" +
|
||||
|
||||
" \"signConfig\": {\n" +
|
||||
" \"availableSignClientTypes\": \"1\"\n" +
|
||||
" },\n" +
|
||||
|
||||
" \"autoFinish\": true\n" +
|
||||
" },\n" +
|
||||
|
||||
" \"signers\": [\n" +
|
||||
" {\n" +
|
||||
" \"psnSignerInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + psnName + "\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"signFields\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"normalSignFieldConfig\": {\n" +
|
||||
" \"autoSign\": false,\n" +
|
||||
" \"freeMode\": false,\n" +
|
||||
" \"movableSignField\": false,\n" +
|
||||
" \"signFieldPosition\": {\n" +
|
||||
" \"positionPage\": \"" + positionPagepsn + "\",\n" +
|
||||
" \"positionX\": " + positionXpsn + ",\n" +
|
||||
" \"positionY\": " + positionYpsn + "\n" +
|
||||
" },\n" +
|
||||
" \"signFieldStyle\": 1\n" +
|
||||
" },\n" +
|
||||
" \"signFieldType\": 0\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"signerType\": 0\n" +
|
||||
" },\n" +
|
||||
|
||||
" {\n" +
|
||||
" \"orgSignerInfo\": {\n" +
|
||||
" \"orgName\": \"" + orgName + "\",\n" +
|
||||
" \"transactorInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + orgNamepsnName + "\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
|
||||
" \"signFields\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"normalSignFieldConfig\": {\n" +
|
||||
" \"autoSign\": false,\n" +
|
||||
" \"freeMode\": false,\n" +
|
||||
|
||||
/* " \"availableSealIds\": [\n" +
|
||||
" \"" + availableSealId + "\"\n" +
|
||||
" ],\n" +*/
|
||||
// " \"availableSealIds\": " + new Gson().toJson(sealIdList) + ",\n" +
|
||||
|
||||
" \"signFieldPosition\": {\n" +
|
||||
" \"positionPage\": \"" + positionPageorg + "\",\n" +
|
||||
" \"positionX\": " + positionXorg + ",\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, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取合同文件签名链接
|
||||
*
|
||||
* @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" +
|
||||
|
||||
" \"clientType\": \"PC\",\n" +
|
||||
|
||||
" \"operator\": {\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
/**
|
||||
* 获取批量签页面链接
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static EsignHttpResponse batchSignUrl(StringIdsReq idsReq) throws EsignDemoException {
|
||||
|
||||
List<String> signFlowIds = idsReq.getIds();
|
||||
String psnAccount = idsReq.getPsnAccount();
|
||||
String apiaddr = "/v3/sign-flow/batch-sign-url";
|
||||
JSONObject paramObj = new JSONObject();
|
||||
paramObj.put("operatorId",idsReq.getPsnId());
|
||||
paramObj.put("signFlowIds",signFlowIds);
|
||||
paramObj.put("clientType","PC");
|
||||
String jsonParm = JSON.toJSONString(paramObj);
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
/**
|
||||
* 根据手机号获取账户id
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static EsignHttpResponse identityInfo(StringIdsReq idsReq) throws EsignDemoException {
|
||||
|
||||
List<String> signFlowIds = idsReq.getIds();
|
||||
String psnAccount = idsReq.getPsnAccount();
|
||||
String apiaddr = "/v3/persons/identity-info?psnAccount=" +psnAccount;
|
||||
|
||||
String jsonParm = "{}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取合同文件用印链接
|
||||
*
|
||||
* @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" +
|
||||
" \"operator\": {\n" +
|
||||
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" },\n" +
|
||||
" \"organization\": {\n" +
|
||||
" \"orgName\": \"" + orgName + "\"\n" +
|
||||
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机构认证&授权页面链接
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse deptIdentifyUrl(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr = "/v3/org-auth-url";
|
||||
String psnName = deptIdentify.getOperName();
|
||||
String phonenumber = deptIdentify.getOperPhone();
|
||||
String orgName = deptIdentify.getIdentifyName();
|
||||
String jsonParm = "{\n" +
|
||||
" \"orgAuthConfig\": {\n" +
|
||||
" \"orgName\": \"" + orgName + " \",\n" +
|
||||
" \"transactorInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + phonenumber + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + psnName + "\",\n" +
|
||||
" \"psnMobile\": \"" + phonenumber + "\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"authorizeConfig\": {\n" +
|
||||
" \"authorizedScopes\": [\n" +
|
||||
" \"get_org_identity_info\",\n" +
|
||||
" \"get_psn_identity_info\",\n" +
|
||||
" \"org_initiate_sign\",\n" +
|
||||
" \"psn_initiate_sign\",\n" +
|
||||
" \"manage_org_resource\",\n" +
|
||||
" \"manage_psn_resource\",\n" +
|
||||
" \"use_org_order\"\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询企业认证状态
|
||||
*/
|
||||
public static EsignHttpResponse getDeptIdentifyInfo(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr = "/v3/organizations/identity-info?orgName=" + deptIdentify.getIdentifyName();
|
||||
|
||||
String jsonParm = "{}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询企业内部印章
|
||||
*/
|
||||
public static EsignHttpResponse deptIdentifySealList(String orgId) throws EsignDemoException {
|
||||
int pageNum = 1;
|
||||
int pageSize = 10;
|
||||
String apiaddr = "/v3/seals/org-own-seal-list?orgId=" + orgId + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
|
||||
String jsonParm = null;
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件签名印章位置
|
||||
*
|
||||
* @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, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建机构图片印章
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify,String sealName, String filePath) throws EsignDemoException {
|
||||
String apiaddr = "/v3/seals/org-seals/create-by-image";
|
||||
String orgId = deptIdentify.getOrgId();
|
||||
//上传印章图片
|
||||
//步骤一:获取印章图片上传地址fileUploadUrl
|
||||
EsignHttpResponse response1 = SealUtil.getFileUploadUrl(filePath);
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody());
|
||||
String fileUploadUrl = jsonObject1.getJSONObject("data").getString("fileUploadUrl");
|
||||
//步骤二:将印章图片文件流上传到fileUploadUrl
|
||||
EsignHttpResponse response2 = SealUtil.fileStreamUpload(fileUploadUrl, filePath);
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody());
|
||||
int errCode = jsonObject2.getIntValue("errCode");
|
||||
if (errCode == 0) { //业务码,0表示成功,非0表示异常。
|
||||
//获取步骤一里面的fileKey
|
||||
String sealImageFileKey = jsonObject1.getJSONObject("data").getString("fileKey");
|
||||
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm = "{\n" +
|
||||
" \"orgId\": \"" + orgId + "\",\n" +
|
||||
" \"sealImageFileKey\": \"" + sealImageFileKey + "\",\n" +
|
||||
" \"sealName\": \"" + sealName + "\",\n" +
|
||||
" \"sealWidth\": 50,\n" +
|
||||
" \"sealHeight\": 50,\n" +
|
||||
" \"sealBizType\": \"COMMON\"\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 null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询指定印章详情(机构)
|
||||
*/
|
||||
|
||||
public static EsignHttpResponse getOrgSeal(String orgId, String sealId) throws EsignDemoException {
|
||||
String apiaddr = "/v3/seals/org-seal-info?orgId=" + orgId + "&sealId=" + sealId;
|
||||
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm = null;
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user