公章管理测试

This commit is contained in:
hejinbo
2023-11-15 09:01:20 +08:00
parent dac20a4a04
commit 4088cf7357
10 changed files with 140 additions and 186 deletions
@@ -61,9 +61,8 @@ public class DeptIdentifyController extends BaseController {
* @return
*/
@PostMapping("/sealUpload")
public AjaxResult sealUpload(@Validated @RequestBody DeptIdentify deptIdentify
, @RequestParam("file") MultipartFile file) {
return deptIdentifyService.sealUpload(deptIdentify, file);
public AjaxResult sealUpload(Long id, String sealName , @RequestParam("file") MultipartFile file) {
return deptIdentifyService.sealUpload(id,sealName, file);
}
/**
@@ -1,71 +0,0 @@
package com.ruoyi.web.controller.wisdomarbitrate;
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.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
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 com.ruoyi.wisdomarbitrate.utils.SignAward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping
public class MyTest {
@Autowired
private CaseApplicationMapper caseApplicationMapper;
@Autowired
private SealSignRecordMapper sealSignRecordMapper;
@Autowired
private CaseAttachMapper caseAttachMapper;
@Autowired
private DeptIdentifyMapper deptIdentifyMapper;
@GetMapping("/test")
public void myTest() 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();
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
System.out.println("这是orgId"+orgId+"=======================");
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
//将orgId保存到数据库里
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
deptIdentifynew.setOrgId(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);
deptIdentifynew.setIdentifyStatus(1);
deptIdentifynew.setSealName(sealName);
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
}
}
}
}
}
@@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://121.40.189.20:3306/smart_arbitration?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://121.40.189.20:3306/test_smart_arbitration?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: YMzc157#
# 从库数据源
@@ -18,7 +18,7 @@ ruoyi:
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 9001
port: 8001
servlet:
# 应用的访问路径
context-path: /
@@ -96,9 +96,7 @@ public class SealUtil {
//生成签名鉴权方式的的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;
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
}
/**
@@ -114,6 +112,7 @@ public class SealUtil {
return EsignHttpHelper.doUploadHttp(uploadUrl,requestType,esignFileBean.getFileBytes(),esignFileBean.getFileContentMD5(), EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE(),true);
}
public static void main(String[] args) throws Exception {
queryAuthProcess("OF-2b1e52987408005c");
// createOrgByImage();
// getOrgEmpower();
// queryAuthProcess("OF-2b00885895080028");
@@ -18,7 +18,7 @@ public interface IDeptIdentifyService {
AjaxResult enableDept(DeptIdentify deptIdentify);
AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file);
AjaxResult sealUpload(Long id, String sealName , MultipartFile file);
AjaxResult receiveNotify(String body);
@@ -71,6 +71,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
EsignHttpResponse identifyUrl = SignAward.deptIdentifyUrl(deptIdentifyselect);
JsonObject signUrlJsonObject = gson.fromJson(identifyUrl.getBody(), JsonObject.class);
int code = signUrlJsonObject.get("code").getAsInt();
if (code == 0){
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
String url = signUrlData.get("authUrl").getAsString();
//获取本次认证授权流程ID
@@ -80,6 +81,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
deptIdentify.setIdentifyDate(new Date());
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify);
}
}
return deptIdentifynew;
}
@@ -113,7 +115,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
}
@Override
public AjaxResult sealUpload(DeptIdentify deptIdentify, MultipartFile file) {
public AjaxResult sealUpload(Long id, String sealName , MultipartFile file) {
try {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
@@ -121,6 +123,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setId(id);
List<DeptIdentify> deptIdentifies = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentify);
if (deptIdentifies != null && deptIdentifies.size() > 0) {
for (DeptIdentify identify : deptIdentifies) {
@@ -133,21 +137,32 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "/uploadPath" + fileName.substring(startIndex);
//String annexPath = "home/ruoyi/uploadPath" + fileName.substring(startIndex);
//创建机构图片印章
String annexPath = "D:\\develop\\2.jpg";
identify.setSealName(sealName);
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);
DeptIdentify deptIdentify1 = new DeptIdentify();
deptIdentify1.setDeptId(identify.getDeptId());
deptIdentify1.setUserId(identify.getUserId());
deptIdentify1.setIdentifyStatus(identify.getIdentifyStatus());
deptIdentify1.setIdentifyDate(identify.getIdentifyDate());
deptIdentify1.setIsUse(identify.getIsUse());
deptIdentify1.setSealName(sealName);
deptIdentify1.setOrgId(identify.getOrgId());
deptIdentify1.setAuthFlowId(identify.getAuthFlowId());
deptIdentify1.setSealId(sealId);
int i = deptIdentifyMapper.insertDeptIdentify(deptIdentify1);
if (i > 0) {
return AjaxResult.success("上传成功");
}
}
return AjaxResult.error("公章上传失败,请检查印章名称是否重复");
}
return AjaxResult.error("企业用户未授予资源管理权限");
}
@@ -181,12 +181,15 @@ public class FixSelectFlowDetailUtils {
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);
int code = identifyInfoJsonObject.get("code").getAsInt();
if (code == 0) {
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
System.out.println("这是orgId"+orgId+"=======================");
System.out.println("这是orgId" + orgId + "=======================");
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
//将orgId保存到数据库里
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
@@ -211,6 +214,7 @@ public class FixSelectFlowDetailUtils {
}
}
}
}
/**
* 定时查询企业内部印章审核状态
@@ -228,16 +232,16 @@ public class FixSelectFlowDetailUtils {
for (DeptIdentify identify : deptIdentifies) {
//查询企业内部印章
Integer annexId = identify.getAnnexId();
if (annexId == null){
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++){
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 挂起
if (statusDescription == 1) {//印章状态 1已启用,2待审核,3审核不通过,4 挂起
//已启用证明审核通过,下载到数据库
String sealImageDownloadUrl = seal.getString("sealImageDownloadUrl");
LocalDate now = LocalDate.now();
@@ -265,7 +269,7 @@ public class FixSelectFlowDetailUtils {
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
int i1 = caseAttachMapper.save(caseAttach);
if (i1>0){
if (i1 > 0) {
//将附件id保存到公章管理表里
Integer annexId1 = caseAttach.getAnnexId();
identify.setAnnexId(annexId1);
@@ -119,7 +119,10 @@ public class SignAward {
// System.out.println(signFlowDetailJsonObject);
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setOrgId("db279dd50d844e6fa64770d9a6edc7dd");
EsignHttpResponse orgByImage = createOrgByImage(deptIdentify, "D:\\develop\\2.jpg");
System.out.println("这是结果===============" + orgByImage);
}
@@ -435,16 +438,6 @@ public class SignAward {
* @return
*/
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();
//上传印章图片
@@ -456,7 +449,7 @@ public class SignAward {
EsignHttpResponse response2 = SealUtil.fileStreamUpload(fileUploadUrl, filePath);
JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody());
int errCode = jsonObject2.getIntValue("errCode");
if (errCode == 0){ //业务码,0表示成功,非0表示异常。
if (errCode == 0) { //业务码,0表示成功,非0表示异常。
//获取步骤一里面的fileKey
String sealImageFileKey = jsonObject1.getJSONObject("data").getString("fileKey");
String sealName = deptIdentify.getSealName();
@@ -464,19 +457,19 @@ public class SignAward {
String jsonParm = "{\n" +
" \"orgId\": \"" + orgId + "\",\n" +
" \"sealImageFileKey\": \"" + sealImageFileKey + "\",\n" +
" \"sealName\": \" " + sealName + " \",\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, false);
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
//发起接口请求
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
}
}
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
}
return null;
}
@@ -485,35 +478,38 @@ public class SignAward {
*/
public static EsignHttpResponse orgOwnSealList(DeptIdentify deptIdentify) throws EsignDemoException {
String orgId=deptIdentify.getOrgId();
int pageNum=1;
int pageSize=20;
String orgId = deptIdentify.getOrgId();
int pageNum = 1;
int pageSize = 20;
String apiaddr="/v3/seals/org-own-seal-list?orgId="+orgId+"&pageNum="+pageNum+"&pageSize="+pageSize;
String apiaddr = "/v3/seals/org-own-seal-list?orgId=" + orgId + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
String jsonParm=null;
String jsonParm = null;
//请求方法
EsignRequestType requestType= EsignRequestType.GET;
EsignRequestType requestType = EsignRequestType.GET;
//生成签名鉴权方式的的header
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,false);
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
//发起接口请求
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,false);
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
}
/**
* 查询指定印章详情(机构)
*/
public static EsignHttpResponse getOrgSeal(String orgId,String sealId) throws EsignDemoException {
String apiaddr="/v3/seals/org-seal-info?orgId="+orgId+"&sealId="+sealId;
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;
String jsonParm = null;
//请求方法
EsignRequestType requestType= EsignRequestType.GET;
EsignRequestType requestType = EsignRequestType.GET;
//生成签名鉴权方式的的header
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,false);
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false);
//发起接口请求
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,false);
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false);
}
}
@@ -32,7 +32,7 @@
</select>
<select id="selectDeptIdentifyBydeptid" parameterType="DeptIdentify" resultMap="DeptIdentifyResult">
SELECT d.id ,d.dept_id ,d.user_id ,d.org_id ,d.auth_flow_id
SELECT d.*
from dept_identify d
<where>
<if test="deptId != null">
@@ -41,6 +41,9 @@
<if test="userId != null">
AND d.user_id = #{userId}
</if>
<if test="id != null">
AND d.id = #{id}
</if>
</where>
</select>
@@ -48,11 +51,23 @@
insert into dept_identify(
<if test="deptId != null">dept_id,</if>
<if test="userId != null">user_id,</if>
<if test="identifyStatus != null">identify_status</if>
<if test="identifyStatus != null">identify_status,</if>
<if test="identifyDate != null">identify_date,</if>
<if test="isUse != null">is_use,</if>
<if test="sealName != null and sealName != ''">seal_name,</if>
<if test="orgId != null and orgId != ''">org_id,</if>
<if test="authFlowId != null and authFlowId != ''">auth_flow_id,</if>
<if test="sealId != null and sealId != ''">seal_id</if>
)values(
<if test="deptId != null">#{deptId},</if>
<if test="userId != null">#{userId},</if>
<if test="identifyStatus != null">#{identifyStatus}</if>
<if test="identifyStatus != null">#{identifyStatus},</if>
<if test="identifyDate != null">#{identifyDate},</if>
<if test="isUse != null">#{isUse},</if>
<if test="sealName != null and sealName != ''">#{sealName},</if>
<if test="orgId != null and orgId != ''">#{orgId},</if>
<if test="authFlowId != null and authFlowId != '' ">#{authFlowId},</if>
<if test="sealId != null and sealId != ''">#{sealId}</if>
)
</insert>
@@ -104,14 +119,13 @@
<if test="orgId != null and orgId != ''">org_id = #{orgId},</if>
<if test="sealId != null and sealId != ''">seal_id = #{sealId},</if>
<if test="sealStatus != null ">seal_status = #{sealStatus},</if>
<if test="authFlowId != null and authFlowId != '' ">auth_flow_id = #{authFlowId},</if>
</set>
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="sealId != null">
AND seal_id = #{sealId}
</if>
</where>
</update>
@@ -119,6 +133,4 @@
</mapper>