实现机构认证功能

This commit is contained in:
qitz
2023-10-30 20:06:38 +08:00
parent 9e16fc1b1a
commit 0cda870fbd
13 changed files with 595 additions and 17 deletions
@@ -0,0 +1,126 @@
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 {
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 部门ID */
private Long deptId;
/** 用户ID */
private Long userId;
/** 认证状态 */
private Integer identifyStatus;
/** 认证时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date identifyDate;
/** 是否启用 */
private Integer isUse;
/** 用户名称 */
private String nickName;
/** 手机号码 */
private String phonenumber;
/** 部门名称 */
private String deptName;
/** 印章名称 */
private String sealName;
public String getSealName() {
return sealName;
}
public void setSealName(String sealName) {
this.sealName = sealName;
}
/** 部门认证链接 */
private String identifyUrl;
public String getIdentifyUrl() {
return identifyUrl;
}
public void setIdentifyUrl(String identifyUrl) {
this.identifyUrl = identifyUrl;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Integer getIdentifyStatus() {
return identifyStatus;
}
public void setIdentifyStatus(Integer identifyStatus) {
this.identifyStatus = identifyStatus;
}
public Date getIdentifyDate() {
return identifyDate;
}
public void setIdentifyDate(Date identifyDate) {
this.identifyDate = identifyDate;
}
public Integer getIsUse() {
return isUse;
}
public void setIsUse(Integer isUse) {
this.isUse = isUse;
}
}
@@ -0,0 +1,22 @@
package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import java.util.List;
public interface DeptIdentifyMapper {
List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify);
List<DeptIdentify> selectDeptIdentifyBydeptid(DeptIdentify deptIdentify);
int insertDeptIdentify(DeptIdentify deptIdentify);
List<DeptIdentify> selectDeptIdentifylist(DeptIdentify deptIdentify);
int updateDeptIdentify(DeptIdentify deptIdentify);
List<DeptIdentify> selectDeptIdentifylistother(DeptIdentify deptIdentify);
}
@@ -38,7 +38,7 @@ public interface ICaseApplicationService {
int verificationArbitrateRecord(CaseApplication caseApplication);
int checkArbitrateRecord(CaseApplication caseApplication);
AjaxResult checkArbitrateRecord(CaseApplication caseApplication);
int submitCaseApplicationCheck(List<Long> ids, Integer agreeOrNotCheck);
@@ -0,0 +1,18 @@
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 java.util.List;
public interface IDeptIdentifyService {
List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify);
DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException;
AjaxResult enableDept(DeptIdentify deptIdentify);
}
@@ -89,6 +89,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
private CaseEvidenceDirectoryMapper caseEvidenceDirectoryMapper;
@Autowired
private SmsRecordMapper smsRecordMapper;
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
// 手机号正则
private static final Pattern TELEPHONE_REGX = Pattern.compile("^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$");
@@ -1537,7 +1539,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
@Override
@Transactional
public int checkArbitrateRecord(CaseApplication caseApplication) {
public AjaxResult checkArbitrateRecord(CaseApplication caseApplication) {
int rows = 0;
ArbitrateRecord arbitrateRecord = caseApplication.getArbitrateRecord();
arbitrateRecordMapper.updataArbitrateRecord(arbitrateRecord);
@@ -1587,14 +1589,25 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if (arbitratorId!=null){
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(arbitratorId));
if (sysUser == null){
return rows;
return AjaxResult.error();
}
sealSignRecord.setPensonAccount(sysUser.getPhonenumber());
sealSignRecord.setPensonName(sysUser.getNickName());
}
sealSignRecord.setOrgnizeName("西安云美电子科技有限公司");
sealSignRecord.setOrgnizeNamePsnAccount("17691338406");
sealSignRecord.setOrgnizeNamepsnName("韩超勃");
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIsUse(1);
DeptIdentify deptIdentifyselect = new DeptIdentify();
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
if(deptIdentifysnew!=null&&deptIdentifysnew.size()>0){
deptIdentifyselect = deptIdentifysnew.get(0);
sealSignRecord.setOrgnizeName(deptIdentifyselect.getDeptName());
sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getPhonenumber());
sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getNickName());
}else {
return AjaxResult.error("没有用印时的机构名称及经办人信息");
}
//解析文件签名印章位置
JSONArray jsonArray = JSONArray.parseArray(keywordPositions);
for (int i = 0; i < jsonArray.size(); i++) {
@@ -1671,7 +1684,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
rows = caseApplicationMapper.submitCaseApplication(caseApplication);
}
return rows;
return AjaxResult.success();
}
@Override
@@ -0,0 +1,97 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
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 java.util.Date;
import java.util.List;
@Service
public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
@Override
@Transactional
public List<DeptIdentify> selectDeptIdentify(DeptIdentify deptIdentify) {
List<DeptIdentify> deptIdentifys = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
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){
continue;
}else {
deptIdentifyselect.setIdentifyStatus(0);
deptIdentifyMapper.insertDeptIdentify(deptIdentifyselect);
}
}
}
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
return deptIdentifysnew;
}
@Override
@Transactional
public DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifynew = new DeptIdentify();
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);
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String url = signUrlData.get("authUrl").getAsString();
deptIdentifynew.setIdentifyUrl(url);
}
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
return deptIdentifynew;
}
@Override
@Transactional
public AjaxResult enableDept(DeptIdentify deptIdentify) {
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
DeptIdentify deptIdentifyselect = deptIdentifysnew.get(0);
Integer identifyStatus = deptIdentifyselect.getIdentifyStatus();
if(identifyStatus.intValue()==0){
return AjaxResult.error("这个认证数据未进行认证,不能启用");
}else if(identifyStatus.intValue()==1){
deptIdentifyselect.setIsUse(1);
deptIdentifyMapper.updateDeptIdentify(deptIdentifyselect);
DeptIdentify deptIdentifySel = new DeptIdentify();
deptIdentifySel.setId(deptIdentify.getId());
deptIdentifySel.setIdentifyStatus(1);
List<DeptIdentify> deptIdentifysother = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentifySel);
if(deptIdentifysother!=null&&deptIdentifysother.size()>0){
for (int i = 0; i < deptIdentifysother.size(); i++) {
DeptIdentify deptIdentifyother = deptIdentifysother.get(i);
deptIdentifyother.setIsUse(0);
deptIdentifyMapper.updateDeptIdentify(deptIdentifyother);
}
}
}
return AjaxResult.success();
}
}
@@ -10,9 +10,11 @@ import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
import com.ruoyi.wisdomarbitrate.mapper.SealSignRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -32,6 +34,8 @@ public class FixSelectFlowDetailUtils {
private SealSignRecordMapper sealSignRecordMapper;
@Autowired
private CaseAttachMapper caseAttachMapper;
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
@Scheduled(cron = "0/3 * * * * ?")
@Transactional
@@ -121,6 +125,48 @@ public class FixSelectFlowDetailUtils {
}
@Scheduled(cron = "0/10 * * * * ?")
@Transactional
public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
Gson gson = new Gson();
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIdentifyStatus(0);
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify);
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();
String orgId = identifyInfoData.get("orgId").getAsString();
if(realnameStatus==1){
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
String sealNames = "";
if(sealArray.size()>0){
for (int j = 0; j < sealArray.size(); j++) {
JsonObject sealObject = (JsonObject)sealArray.get(j);
String sealName = sealObject.get("sealName").toString();
String sealNamenew = sealName.substring(1,sealName.length()-1);
sealNames += sealNamenew +",";
}
}
String sealName = sealNames.substring(0,sealNames.length()-1);
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
deptIdentifynew.setIdentifyStatus(1);
deptIdentifynew.setSealName(sealName);
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
}
}
}
}
@@ -9,6 +9,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.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.SealSignRecord;
import java.util.Date;
@@ -19,8 +20,6 @@ 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";
@@ -63,6 +62,35 @@ public class SignAward {
// 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);
@@ -91,12 +119,7 @@ public class SignAward {
// System.out.println(signFlowDetailJsonObject);
String annexName = "/profile/upload/2023/10/26/1f6fe04f5f984e8ab5bbaf70dd47100a.docx";
String prefix = "/profile/upload/";
int startIndex = prefix.length();
String annexPath = "/home/ruoyi/uploadPath/upload/";
String annexPathnew = annexPath + annexName.substring(startIndex);
System.out.println(annexPathnew);
}
@@ -317,6 +340,69 @@ public class SignAward {
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
}
/**
* 获取机构认证链接
* @return
* @throws EsignDemoException
*/
public static EsignHttpResponse deptIdentifyUrl(DeptIdentify deptIdentify) throws EsignDemoException {
String apiaddr = "/v3/org-auth-url";
String nickName = deptIdentify.getNickName();
String phonenumber = deptIdentify.getPhonenumber();
String deptName = deptIdentify.getDeptName();
String jsonParm = "{\n" +
" \"orgAuthConfig\": {\n" +
" \"orgName\": \"" + deptName + "\",\n" +
" \"transactorInfo\": {\n" +
" \"psnAccount\": \"" + phonenumber + "\",\n" +
" \"psnInfo\": {\n" +
" \"psnName\": \"" + nickName + "\",\n" +
" \"psnMobile\": \"" + phonenumber + "\"\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);
}
/**
* 查询企业认证状态
*/
public static EsignHttpResponse getDeptIdentifyInfo(DeptIdentify deptIdentify) throws EsignDemoException {
String apiaddr="/v3/organizations/identity-info?orgName="+deptIdentify.getDeptName();
String jsonParm="{}";
//请求方法
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);
}
/**
* 查询企业认证印章信息
*/
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,true);
//发起接口请求
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
}
/**
* 获取文件签名印章位置
* @return