11.9开发

This commit is contained in:
hejinbo
2023-11-09 17:34:12 +08:00
parent ae2c8fe59f
commit 94d3f1cb1e
10 changed files with 351 additions and 124 deletions
@@ -42,5 +42,9 @@ public class CaseAttach {
* 用户账户
*/
private String userName;
/**
* 印章状态(0未启用,1已启用)
*/
private Integer sealStatus;
}
@@ -2,7 +2,6 @@ package com.ruoyi.wisdomarbitrate.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
public class DeptIdentify extends BaseEntity {
@@ -39,6 +38,30 @@ public class DeptIdentify extends BaseEntity {
/** 认证授权流程ID */
private String authFlowId;
public String getSealId() {
return sealId;
}
public void setSealId(String sealId) {
this.sealId = sealId;
}
/** 印章id */
private String sealId;
/**
* 附件id
*/
private Integer annexId;
public Integer getAnnexId() {
return annexId;
}
public void setAnnexId(Integer annexId) {
this.annexId = annexId;
}
public String getAuthFlowId() {
return authFlowId;
}
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -15,4 +16,8 @@ public interface IDeptIdentifyService {
DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException;
AjaxResult enableDept(DeptIdentify deptIdentify);
AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file);
}
@@ -1,18 +1,26 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.utils.SealUtil;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService;
import com.ruoyi.wisdomarbitrate.utils.SignAward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -21,19 +29,21 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
@Autowired
private CaseAttachMapper caseAttachMapper;
@Override
@Transactional
public List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify) {
List<DeptIdentify> deptIdentifys = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
if(deptIdentifys!=null&&deptIdentifys.size()>0){
if (deptIdentifys != null && deptIdentifys.size() > 0) {
for (int i = 0; i < deptIdentifys.size(); i++) {
DeptIdentify deptIdentifyselect = deptIdentifys.get(i);
List<DeptIdentify> deptIdentifylist = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentifyselect);
if(deptIdentifylist!=null&&deptIdentifylist.size()>0){
if (deptIdentifylist != null && deptIdentifylist.size() > 0) {
continue;
}else {
} else {
deptIdentifyselect.setIdentifyStatus(0);
deptIdentifyMapper.insertDeptIdentify(deptIdentifyselect);
}
@@ -49,21 +59,21 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
public DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifynew = new DeptIdentify();
if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
Gson gson = new Gson();
DeptIdentify deptIdentifyselect = deptIdentifysnew.get(0);
EsignHttpResponse identifyUrl = SignAward.deptIdentifyUrl(deptIdentifyselect);
JsonObject signUrlJsonObject = gson.fromJson(identifyUrl.getBody(), JsonObject.class);
int code = signUrlJsonObject.get("code").getAsInt();
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String url = signUrlData.get("authUrl").getAsString();
//获取本次认证授权流程ID
String authFlowId = signUrlData.get("authFlowId").getAsString();
deptIdentify.setAuthFlowId(authFlowId);
deptIdentifynew.setIdentifyUrl(url);
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
}
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
return deptIdentifynew;
}
@@ -73,9 +83,9 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifyselect = deptIdentifysnew.get(0);
Integer identifyStatus = deptIdentifyselect.getIdentifyStatus();
if(identifyStatus.intValue()==0){
if (identifyStatus.intValue() == 0) {
return AjaxResult.error("这个认证数据未进行认证,不能启用");
}else if(identifyStatus.intValue()==1){
} else if (identifyStatus.intValue() == 1) {
deptIdentifyselect.setIsUse(1);
deptIdentifyMapper.updateDeptIdentify(deptIdentifyselect);
@@ -83,7 +93,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
deptIdentifySel.setId(deptIdentify.getId());
deptIdentifySel.setIdentifyStatus(1);
List<DeptIdentify> deptIdentifysother = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentifySel);
if(deptIdentifysother!=null&&deptIdentifysother.size()>0){
if (deptIdentifysother != null && deptIdentifysother.size() > 0) {
for (int i = 0; i < deptIdentifysother.size(); i++) {
DeptIdentify deptIdentifyother = deptIdentifysother.get(i);
deptIdentifyother.setIsUse(0);
@@ -96,5 +106,53 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
}
@Override
public AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file) {
try {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
}
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentify);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
for (DeptIdentify identify : deptIdentifies) {
//先判断企业用户是否授予资源管理权限
String authFlowId = identify.getAuthFlowId();
EsignHttpResponse response1 = SealUtil.queryAuthProcess(authFlowId);
JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody());
int authorizedStatus = jsonObject1.getJSONObject("data").getIntValue("authorizedStatus");
if (authorizedStatus == 1){//授权流程状态 0流程过期失效 1已授权 2授权中 3审批未通过
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "/uploadPath" + fileName.substring(startIndex);
//创建机构图片印章
EsignHttpResponse response = SignAward.createOrgByImage(identify, annexPath);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
int code = jsonObject.getIntValue("code");
if (code == 0) { //业务码,0表示成功,非0表示异常。
String sealId = jsonObject.getJSONObject("data").getString("sealId");
identify.setSealId(sealId);
identify.setIsUse(0); //设置印章使用状态为未启用
//保存到表里
int i = deptIdentifyMapper.updateDeptIdentify(identify);
if (i>0){
return AjaxResult.success("上传成功");
}
}
}
return AjaxResult.error("企业用户未授予资源管理权限");
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (EsignDemoException e) {
e.printStackTrace();
}
return AjaxResult.error();
}
}
@@ -1,5 +1,7 @@
package com.ruoyi.wisdomarbitrate.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -42,7 +44,7 @@ public class FixSelectFlowDetailUtils {
@Scheduled(cron = "0/10 * * * * ?")
@Transactional
public void fixExecuteSelectFlowDetailUtils(){
public void fixExecuteSelectFlowDetailUtils() {
Gson gson = new Gson();
SealSignRecord sealSignRecordselect = new SealSignRecord();
@@ -50,40 +52,40 @@ public class FixSelectFlowDetailUtils {
List<SealSignRecord> sealSignRecords = sealSignRecordMapper.selectSealSignRecordbyStat(sealSignRecordselect);
try {
if(sealSignRecords!=null&&sealSignRecords.size()>0){
if (sealSignRecords != null && sealSignRecords.size() > 0) {
for (int i = 0; i < sealSignRecords.size(); i++) {
SealSignRecord sealSignRecord = sealSignRecords.get(i);
EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord);
JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(),JsonObject.class);
JsonObject signFlowDetailJsonObject = gson.fromJson(signFlowDetail.getBody(), JsonObject.class);
JsonObject flowDetailData = signFlowDetailJsonObject.getAsJsonObject("data");
JsonArray signersArray = flowDetailData.get("signers").getAsJsonArray();
Integer psnsignStatus = null;
Integer orgsignStatus = null;
for (int j = 0; j < signersArray.size(); j++) {
JsonObject signerObject = (JsonObject)signersArray.get(j);
JsonObject signerObject = (JsonObject) signersArray.get(j);
if(!(signerObject.get("psnSigner").toString()).equals("null")){
if (!(signerObject.get("psnSigner").toString()).equals("null")) {
JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner");
if(psnSignerData!=null){
if (psnSignerData != null) {
psnsignStatus = signerObject.get("signStatus").getAsInt();
}
}
if(!(signerObject.get("orgSigner").toString()).equals("null")){
if (!(signerObject.get("orgSigner").toString()).equals("null")) {
JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner");
if(orgSignerData!=null){
if (orgSignerData != null) {
orgsignStatus = signerObject.get("signStatus").getAsInt();
}
}
}
if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==1)){
if ((psnsignStatus.intValue() == 2) && (orgsignStatus.intValue() == 1)) {
//更新立案申请状态为待用印
CaseApplication caseApplication = new CaseApplication();
caseApplication.setId(sealSignRecord.getCaseAppliId());
CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
if(caseApplicationselect!=null){
if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.SIGN_ARBITRATION)){
if (caseApplicationselect != null) {
if ((caseApplicationselect.getCaseStatus() != null) && (caseApplicationselect.getCaseStatus().intValue() == CaseApplicationConstants.SIGN_ARBITRATION)) {
caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
caseApplicationMapper.submitCaseApplication(caseApplication);
@@ -94,30 +96,30 @@ public class FixSelectFlowDetailUtils {
}
}
if((psnsignStatus.intValue()==2)&&(orgsignStatus.intValue()==2)){
if ((psnsignStatus.intValue() == 2) && (orgsignStatus.intValue() == 2)) {
//更新立案申请状态为待送达
CaseApplication caseApplication = new CaseApplication();
caseApplication.setId(sealSignRecord.getCaseAppliId());
CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication);
if(caseApplicationselect!=null){
if((caseApplicationselect.getCaseStatus()!=null)&&(caseApplicationselect.getCaseStatus().intValue()==CaseApplicationConstants.ARBITRATED_SEAL)){
if (caseApplicationselect != null) {
if ((caseApplicationselect.getCaseStatus() != null) && (caseApplicationselect.getCaseStatus().intValue() == CaseApplicationConstants.ARBITRATED_SEAL)) {
caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATION_DELIVERY);
//下载审核完成的裁决书,
String signFlowId = sealSignRecord.getSignFlowid();
EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId);
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class);
JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class);
JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data");
JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray();
if(filesArray!=null&&filesArray.size()>0){
JsonObject fileObject = (JsonObject)filesArray.get(0);
if (filesArray != null && filesArray.size() > 0) {
JsonObject fileObject = (JsonObject) filesArray.get(0);
String fileDownloadUrl = fileObject.get("downloadUrl").toString();
//修改"签署用印记录表"的状态为签署完成
sealSignRecord.setSignFlowStatus(3);
sealSignRecord.setFileDownloadUrl(fileDownloadUrl.substring(1,fileDownloadUrl.length()-1));
sealSignRecord.setFileDownloadUrl(fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1));
sealSignRecordMapper.updataSealSignRecord(sealSignRecord);
String filearbitraUrl = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
String filearbitraUrl = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
caseApplication.setFilearbitraUrl(filearbitraUrl);
caseApplicationMapper.submitCaseApplication(caseApplication);
@@ -136,22 +138,22 @@ public class FixSelectFlowDetailUtils {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if(downLoadFile) {
Long caseAppliId = sealSignRecord.getCaseAppliId();
CaseAttach caseAttach = new CaseAttach();
caseAttach.setCaseAppliId(caseAppliId);
caseAttach.setAnnexType(3);
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
}
String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if (downLoadFile) {
Long caseAppliId = sealSignRecord.getCaseAppliId();
CaseAttach caseAttach = new CaseAttach();
caseAttach.setCaseAppliId(caseAppliId);
caseAttach.setAnnexType(3);
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
}
}
}
@@ -163,7 +165,7 @@ public class FixSelectFlowDetailUtils {
}
} catch (EsignDemoException e) {
e.printStackTrace();
}catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
@@ -176,13 +178,13 @@ public class FixSelectFlowDetailUtils {
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIdentifyStatus(0);
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
for (int i = 0; i < deptIdentifysnew.size(); i++) {
EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentifysnew.get(i));
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
if(realnameStatus==1){
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
//将orgId保存到数据库里
@@ -192,15 +194,15 @@ public class FixSelectFlowDetailUtils {
JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
String sealNames = "";
if(sealArray.size()>0){
if (sealArray.size() > 0) {
for (int j = 0; j < sealArray.size(); j++) {
JsonObject sealObject = (JsonObject)sealArray.get(j);
JsonObject sealObject = (JsonObject) sealArray.get(j);
String sealName = sealObject.get("sealName").toString();
String sealNamenew = sealName.substring(1,sealName.length()-1);
sealNames += sealNamenew +",";
String sealNamenew = sealName.substring(1, sealName.length() - 1);
sealNames += sealNamenew + ",";
}
}
String sealName = sealNames.substring(0,sealNames.length()-1);
String sealName = sealNames.substring(0, sealNames.length() - 1);
deptIdentifynew.setIdentifyStatus(1);
deptIdentifynew.setSealName(sealName);
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
@@ -208,4 +210,79 @@ public class FixSelectFlowDetailUtils {
}
}
}
/**
* 定时查询企业内部印章审核状态
*
* @throws EsignDemoException
*/
@Scheduled(cron = "0/30 * * * * ?")
@Transactional
public void searchForInstitutionalSeal() {
try {
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIsUse(0);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
for (DeptIdentify identify : deptIdentifies) {
//查询企业内部印章
Integer annexId = identify.getAnnexId();
if (annexId == null){
//说明之前没有下载过
EsignHttpResponse response = SignAward.orgOwnSealList(identify);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
JSONObject data = jsonObject.getJSONObject("data");
JSONArray seals = data.getJSONArray("seals");
for (int i = 0; i < seals.size(); i++){
JSONObject seal = seals.getJSONObject(i);
int statusDescription = seal.getIntValue("statusDescription");
if (statusDescription==1){//印章状态 1已启用,2待审核,3审核不通过,4 挂起
//已启用证明审核通过,下载到数据库
String sealImageDownloadUrl = seal.getString("sealImageDownloadUrl");
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf";
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String savePath = "/home/ruoyi/uploadPath/upload/";
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
boolean downLoadFile = FileTransformation.downLoadFileByUrl(sealImageDownloadUrl, resultFilePath);
if (downLoadFile) {
CaseAttach caseAttach = new CaseAttach();
caseAttach.setAnnexType(10); //10代表印章图片
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
caseAttach.setSealStatus(1); //1代表印章启用
int i1 = caseAttachMapper.save(caseAttach);
if (i1>0){
//将附件id保存到公章管理表里
Integer annexId1 = caseAttach.getAnnexId();
identify.setAnnexId(annexId1);
deptIdentifyMapper.updateDeptIdentify(identify);
}
}
}
}
}
}
}
} catch (EsignDemoException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -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);
}
}
@@ -12,10 +12,11 @@
<result property="note" column="note" />
<result property="userId" column="use_id" />
<result property="userName" column="use_account" />
<result property="sealStatus" column="seal_status" />
</resultMap>
<insert id="save" useGeneratedKeys="true" keyProperty="annexId">
INSERT INTO case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account)
VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{userId},#{userName})
INSERT INTO case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status)
VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{userId},#{userName},#{sealStatus})
</insert>
<delete id="deleteByFileIds">
delete from case_attach
@@ -14,6 +14,9 @@
<result property="phonenumber" column="phonenumber" />
<result property="deptName" column="dept_name" />
<result property="sealName" column="seal_name" />
<result property="orgId" column="org_id" />
<result property="authFlowId" column="auth_flow_id" />
<result property="sealId" column="seal_id" />
</resultMap>
@@ -28,7 +31,7 @@
</select>
<select id="selectDeptIdentifyBydeptid" parameterType="DeptIdentify" resultMap="DeptIdentifyResult">
SELECT d.id ,d.dept_id ,d.user_id
SELECT d.id ,d.dept_id ,d.user_id ,d.org_id ,d.auth_flow_id
from dept_identify d
<where>
<if test="deptId != null">
@@ -53,8 +56,8 @@
</insert>
<select id="selectDeptIdentifylist" parameterType="DeptIdentify" resultMap="DeptIdentifyResult">
SELECT d.id ,d.dept_id ,d.user_id, d.identify_status ,d.identify_date ,d.is_use , d.seal_name, sd.dept_name ,
u.nick_name ,u.phonenumber
SELECT d.id ,d.dept_id ,d.user_id, d.identify_status ,d.identify_date ,d.is_use , d.seal_name,
d.org_id , d.seal_id ,sd.dept_name , u.nick_name ,u.phonenumber
from dept_identify d left join sys_dept sd on d.dept_id = sd.dept_id
left join sys_user u on u.user_id = d.user_id
<where>
@@ -90,6 +93,7 @@
<if test="isUse != null">is_use = #{isUse},</if>
<if test="identifyStatus != null ">identify_status = #{identifyStatus},</if>
<if test="sealName != null and sealName != ''">seal_name = #{sealName},</if>
<if test="sealId != null and sealId != ''">seal_id = #{sealId},</if>
</set>
where id = #{id}
</update>