11.9开发
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -9,6 +10,7 @@ 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.domain.DeptIdentify;
|
||||
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
|
||||
|
||||
@@ -18,10 +20,9 @@ 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;
|
||||
|
||||
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 {
|
||||
@@ -89,8 +90,6 @@ public class SignAward {
|
||||
// System.out.println("机构印章名称:" +sealNames.substring(0,sealNames.length()-1));
|
||||
|
||||
|
||||
|
||||
|
||||
//查询签署流程详情
|
||||
// EsignHttpResponse signFlowDetail = signFlowDetail(sealSignRecord);
|
||||
// JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
|
||||
@@ -120,31 +119,30 @@ public class SignAward {
|
||||
// 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 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);
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发起签署
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
@@ -174,8 +172,8 @@ public class SignAward {
|
||||
String jsonParm = "{\n" +
|
||||
" \"docs\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"fileName\": \"" + fileName + "\"\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"fileName\": \"" + fileName + "\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"signFlowConfig\": {\n" +
|
||||
@@ -203,22 +201,22 @@ public class SignAward {
|
||||
" \"signers\": [\n" +
|
||||
" {\n" +
|
||||
" \"psnSignerInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\",\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + psnName + "\"\n" +
|
||||
" \"psnName\": \"" + psnName + "\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"signFields\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\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" +
|
||||
" \"positionPage\": \"" + positionPagepsn + "\",\n" +
|
||||
" \"positionX\": " + positionXpsn + ",\n" +
|
||||
" \"positionY\": " + positionYpsn + "\n" +
|
||||
" },\n" +
|
||||
" \"signFieldStyle\": 1\n" +
|
||||
" },\n" +
|
||||
@@ -230,31 +228,31 @@ public class SignAward {
|
||||
|
||||
" {\n" +
|
||||
" \"orgSignerInfo\": {\n" +
|
||||
" \"orgName\": \"" + orgName + "\",\n" +
|
||||
" \"orgName\": \"" + orgName + "\",\n" +
|
||||
" \"transactorInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
|
||||
" \"psnAccount\": \"" + orgNamePsnAccount + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + orgNamepsnName + "\"\n" +
|
||||
" \"psnName\": \"" + orgNamepsnName + "\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
|
||||
" \"signFields\": [\n" +
|
||||
" {\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"fileId\": \"" + fileId + "\",\n" +
|
||||
" \"normalSignFieldConfig\": {\n" +
|
||||
" \"autoSign\": false,\n" +
|
||||
" \"freeMode\": false,\n" +
|
||||
|
||||
" \"availableSealIds\": [\n" +
|
||||
" \"" + availableSealId + "\"\n" +
|
||||
" \"" + availableSealId + "\"\n" +
|
||||
" ],\n" +
|
||||
|
||||
|
||||
" \"signFieldPosition\": {\n" +
|
||||
" \"positionPage\": \"" + positionPageorg + "\",\n" +
|
||||
" \"positionX\": " + positionXorg + ",\n" +
|
||||
" \"positionY\": " + positionYorg + "\n" +
|
||||
" \"positionPage\": \"" + positionPageorg + "\",\n" +
|
||||
" \"positionX\": " + positionXorg + ",\n" +
|
||||
" \"positionY\": " + positionYorg + "\n" +
|
||||
" },\n" +
|
||||
" \"signFieldStyle\": 1\n" +
|
||||
" },\n" +
|
||||
@@ -277,6 +275,7 @@ public class SignAward {
|
||||
|
||||
/**
|
||||
* 获取合同文件签名链接
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
@@ -291,7 +290,7 @@ public class SignAward {
|
||||
" \"clientType\": \"PC\",\n" +
|
||||
|
||||
" \"operator\": {\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
@@ -304,6 +303,7 @@ public class SignAward {
|
||||
|
||||
/**
|
||||
* 获取合同文件用印链接
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
@@ -317,10 +317,10 @@ public class SignAward {
|
||||
String jsonParm = "{\n" +
|
||||
" \"operator\": {\n" +
|
||||
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" \"psnAccount\": \"" + psnAccount + "\"\n" +
|
||||
" },\n" +
|
||||
" \"organization\": {\n" +
|
||||
" \"orgName\": \"" + orgName + "\"\n" +
|
||||
" \"orgName\": \"" + orgName + "\"\n" +
|
||||
|
||||
" }\n" +
|
||||
"}";
|
||||
@@ -346,10 +346,10 @@ public class SignAward {
|
||||
" \"orgAuthConfig\": {\n" +
|
||||
" \"orgName\": \"" + deptName + " \",\n" +
|
||||
" \"transactorInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + phonenumber + "\",\n" +
|
||||
" \"psnAccount\": \"" + phonenumber + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + nickName + "\",\n" +
|
||||
" \"psnMobile\": \"" + phonenumber + "\"\n" +
|
||||
" \"psnName\": \"" + nickName + "\",\n" +
|
||||
" \"psnMobile\": \"" + phonenumber + "\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
@@ -377,36 +377,37 @@ public class SignAward {
|
||||
* 查询企业认证状态
|
||||
*/
|
||||
public static EsignHttpResponse getDeptIdentifyInfo(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr="/v3/organizations/identity-info?orgName="+deptIdentify.getDeptName();
|
||||
String apiaddr = "/v3/organizations/identity-info?orgName=" + deptIdentify.getDeptName();
|
||||
|
||||
String jsonParm="{}";
|
||||
String jsonParm = "{}";
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.GET;
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询企业认证印章信息
|
||||
*/
|
||||
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;
|
||||
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;
|
||||
EsignRequestType requestType = EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件签名印章位置
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
@@ -432,27 +433,70 @@ public class SignAward {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr = "/v3/seals/org-seals/create-by-image";
|
||||
String orgId = deptIdentify.getOrgId();
|
||||
String sealImageFileKey = "";
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm = "{\n" +
|
||||
" \"orgId\": \"" + orgId + "\",\n" +
|
||||
" \"sealImageFileKey\": \"" + sealImageFileKey + "\",\n" +
|
||||
" \"sealName\": \"企业公章1\",\n" +
|
||||
" \"sealWidth\": 50,\n" +
|
||||
" \"sealHeight\": 50,\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
EsignHttpResponse response = EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
System.out.println(response);
|
||||
return response;
|
||||
public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify, String filePath) throws EsignDemoException {
|
||||
//获取认证授权流程ID
|
||||
String authFlowId = deptIdentify.getAuthFlowId();
|
||||
//查询认证授权流程详情
|
||||
EsignHttpResponse response = SealUtil.queryAuthProcess(authFlowId);
|
||||
String body = response.getBody();
|
||||
if (body != null) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
//查询授权流程状态
|
||||
int authorizedStatus = jsonObject.getJSONObject("data").getIntValue("authorizedStatus");
|
||||
if (authorizedStatus == 1) {//0 -流程过期失效 1 - 已授权 2 - 授权中 3 - 审批未通过
|
||||
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");
|
||||
String sealName = deptIdentify.getSealName();
|
||||
//请求参数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" +
|
||||
"}";
|
||||
//请求方法
|
||||
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 orgOwnSealList(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String orgId=deptIdentify.getOrgId();
|
||||
int pageNum=1;
|
||||
int pageSize=20;
|
||||
|
||||
String apiaddr="/v3/seals/org-own-seal-list?orgId="+orgId+"&pageNum="+pageNum+"&pageSize="+pageSize;
|
||||
|
||||
//请求参数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,true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user