From 619734469ddb48d9c114f4adc9e52eecc916f372 Mon Sep 17 00:00:00 2001 From: qitz <18810291185@163.com> Date: Wed, 13 Mar 2024 14:41:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=AD=BE=E7=BD=B2=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mscase/MsSignSealController.java | 20 ++ .../src/main/resources/application.yml | 3 + .../service/mscase/MsSignSealService.java | 3 + .../mscase/impl/MsSignSealServiceImpl.java | 287 ++++++++++++++++++ .../wisdomarbitrate/utils/DigesdateUtils.java | 51 ++++ .../utils/FixSelectFlowDetailUtils.java | 2 +- .../wisdomarbitrate/utils/SignAward.java | 6 +- .../utils/SignVerifyUtils.java | 99 ++++++ 8 files changed, 469 insertions(+), 2 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/DigesdateUtils.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignVerifyUtils.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsSignSealController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsSignSealController.java index 69098d0..8e96a71 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsSignSealController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsSignSealController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.wisdomarbitrate.mscase; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.EsignDemoException; @@ -10,6 +12,8 @@ import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO; import com.ruoyi.wisdomarbitrate.service.mscase.MsSignSealService; +import com.ruoyi.wisdomarbitrate.utils.SignVerifyUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -57,6 +61,22 @@ public class MsSignSealController extends BaseController { return success(sealUrlRecordselect); } + /** + * 签名用印回调 + */ + @Anonymous + @PostMapping("/signSeaalCaseApplicaCallback") + public AjaxResult signSeaalCaseApplicaCallback() throws Exception { + boolean checkResult= SignVerifyUtils.checkSignuter(); + if(checkResult){ + String reqbodystr =SignVerifyUtils.getRequestBody(); + return msSignSealService.signSeaalCaseApplicaCallback(reqbodystr); + }else { + return AjaxResult.error("error"); + } + + } + /** * 查询案件进度 */ diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index aa0993a..0199305 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -191,6 +191,9 @@ organizeConfig: # 引入仲裁系统url配置 arbitrateConfig: url: http://121.40.189.20:9001/callArbitrateCaseApplication/generateCaseApplication +# 回调通知 +signSealCallbackConfig: + url: http://121.40.189.20:6001/mssignSeal/signSeaalCaseApplicaCallback #jodconverter: # local: # host: 121.40.189.20 diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsSignSealService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsSignSealService.java index 8ed426d..82f07d4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsSignSealService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsSignSealService.java @@ -7,6 +7,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO; +import java.io.IOException; import java.util.List; public interface MsSignSealService { @@ -34,4 +35,6 @@ public interface MsSignSealService { AjaxResult msCaseSignUrlApplyAPP(MsSignSealDTO dto) throws EsignDemoException; AjaxResult msCaseSignUrlResAPP(MsSignSealDTO dto) throws EsignDemoException; + + AjaxResult signSeaalCaseApplicaCallback(String reqbodystr) throws EsignDemoException, IOException; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java index b1f26c8..82433af 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsSignSealServiceImpl.java @@ -60,6 +60,7 @@ import tk.mybatis.mapper.entity.Example; import javax.annotation.Resource; import java.io.File; +import java.io.IOException; import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -83,6 +84,8 @@ public class MsSignSealServiceImpl implements MsSignSealService { MsCaseFlowMapper caseFlowMapper; @Autowired private SysUserMapper userMapper; + @Autowired + private MsCaseAttachMapper caseAttachMapper; @Autowired private SysUserMapper sysUserMapper; @@ -1008,6 +1011,290 @@ public class MsSignSealServiceImpl implements MsSignSealService { return AjaxResult.success(sealSignRecordres); } + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult signSeaalCaseApplicaCallback(String reqbodystr) throws EsignDemoException, IOException { + + System.out.println("请求参数reqbodystr:----------->>>>>>"+reqbodystr); + + JSONObject jsonObjectCallback = JSONObject.parseObject(reqbodystr); + Gson gson = new Gson(); + if (jsonObjectCallback != null) { + int signResult = jsonObjectCallback.getIntValue("signResult"); + String action = jsonObjectCallback.getString("action"); + String signFlowId = jsonObjectCallback.getString("signFlowId"); + Long operateTime = jsonObjectCallback.getLongValue("operateTime"); + JSONObject operator = jsonObjectCallback.getJSONObject("operator"); + JSONObject psnAccount = operator.getJSONObject("psnAccount"); + String accountMobile = psnAccount.getString("accountMobile"); + + System.out.println("请求参数signResult:----------->>>>>>"+signResult); + System.out.println("请求参数action:---------->>>>>>"+action); + System.out.println("请求参数signFlowId:---------->>>>>>"+signFlowId); + System.out.println("请求参数accountMobile:---------->>>>>>"+accountMobile); + + Example msSealSignRecordExample = new Example(MsSealSignRecord.class); + msSealSignRecordExample.createCriteria().andEqualTo("signFlowId", signFlowId); + MsSealSignRecord sealSignRecordsel = sealSignRecordMapper.selectOneByExample(msSealSignRecordExample); + + String pensonAccountApply = sealSignRecordsel.getPensonAccount(); + String orgnNamePsnAcc = sealSignRecordsel.getOrgnNamePsnAcc(); + String pensonAccountRes = sealSignRecordsel.getPensonAccountRes(); + String pensonAccountMedi = sealSignRecordsel.getPensonAccountMedi(); + + Integer signStatusApply = sealSignRecordsel.getSignStatusApply(); + Integer signStatusResponse = sealSignRecordsel.getSignStatusResponse(); + Integer signStatusMediator = sealSignRecordsel.getSignStatusMediator(); + Integer sealStatus = sealSignRecordsel.getSealStatus(); + + Long caseAppliId = sealSignRecordsel.getCaseAppliId(); + MsCaseApplication caseApplicationselect = msCaseApplicationMapper.selectByPrimaryKey(caseAppliId); + Integer mediaResult = caseApplicationselect.getMediaResult(); + + if("SIGN_MISSON_COMPLETE".equals(action) && signResult==2){ + if(mediaResult.intValue()==1){ + //调解 + if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){ + //申请人签名 + sealSignRecordsel.setSignStatusApply(1); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if(signStatusResponse!=null&&signStatusResponse.intValue()==1&& + signStatusMediator!=null&&signStatusMediator.intValue()==1){ + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //修改"签署用印记录表"的状态为待用印 + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } + }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){ + //被申请人签名 + sealSignRecordsel.setSignStatusResponse(1); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if(signStatusApply!=null&&signStatusApply.intValue()==1&& + signStatusMediator!=null&&signStatusMediator.intValue()==1){ + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //修改"签署用印记录表"的状态为待用印 + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } + }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountMedi)){ + //调解员签名 + sealSignRecordsel.setSignStatusMediator(1); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if(signStatusApply!=null&&signStatusApply.intValue()==1&& + signStatusResponse!=null&&signStatusResponse.intValue()==1){ + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //修改"签署用印记录表"的状态为待用印 + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } + }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(orgnNamePsnAcc)){ + sealSignRecordsel.setSealStatus(1); + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //下载审核完成的调解书 + EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); + 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); + String fileDownloadUrl = fileObject.get("downloadUrl").toString(); + 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/"; + String saveName = fileName; + String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } + String resultFilePath = saveFolderPath + "/" + fileName; + 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) { + MsCaseAttach caseAttach = new MsCaseAttach(); + caseAttach.setCaseAppliId(caseAppliId); + caseAttach.setAnnexType(7); + caseAttach.setAnnexPath(savePath); + caseAttach.setAnnexName(saveName); + caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } + } + + }else if(mediaResult.intValue()==5){ + //和解 + if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){ + //申请人签名 + sealSignRecordsel.setSignStatusApply(1); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if(signStatusResponse!=null&&signStatusResponse.intValue()==1){ + MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //修改"签署用印记录表"的状态为完成 + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + + //下载审核完成的调解书 + EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); + 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); + String fileDownloadUrl = fileObject.get("downloadUrl").toString(); + 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/"; + String saveName = fileName; + String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } + String resultFilePath = saveFolderPath + "/" + fileName; + 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) { + MsCaseAttach caseAttach = new MsCaseAttach(); + caseAttach.setCaseAppliId(caseAppliId); + caseAttach.setAnnexType(7); + caseAttach.setAnnexPath(savePath); + caseAttach.setAnnexName(saveName); + caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } + } + }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){ + //被申请人签名 + sealSignRecordsel.setSignStatusResponse(1); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if(signStatusApply!=null&&signStatusApply.intValue()==1){ + MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseApplication application = new MsCaseApplication(); + application.setId(caseApplicationselect.getId()); + application.setCaseFlowId(nextFlow.getId()); + application.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(application); + + //修改"签署用印记录表"的状态为完成 + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + + //下载审核完成的调解书 + EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); + 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); + String fileDownloadUrl = fileObject.get("downloadUrl").toString(); + 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/"; + String saveName = fileName; + String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } + String resultFilePath = saveFolderPath + "/" + fileName; + 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) { + MsCaseAttach caseAttach = new MsCaseAttach(); + caseAttach.setCaseAppliId(caseAppliId); + caseAttach.setAnnexType(7); + caseAttach.setAnnexPath(savePath); + caseAttach.setAnnexName(saveName); + caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } + } + } + } + } + + }else{ + return AjaxResult.error("error"); + } + return AjaxResult.success("success"); + } + /** * 通过邮件发送裁决书文件 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/DigesdateUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/DigesdateUtils.java new file mode 100644 index 0000000..4d60115 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/DigesdateUtils.java @@ -0,0 +1,51 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +public class DigesdateUtils { + + public static String getSignStr(String paramsStr, String accessSec ) { + Mac macDiges = null; + try { + macDiges = Mac.getInstance("HmacSHA256"); + SecretKeySpec accessSecKey = new SecretKeySpec(accessSec.getBytes("UTF-8"), "HmacSHA256"); + macDiges.init(accessSecKey); + macDiges.update(paramsStr.getBytes("UTF-8")); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return null; + } catch (InvalidKeyException e) { + e.printStackTrace(); + return null; + } + return byteTrasferhex(macDiges.doFinal()); + } + + public static String byteTrasferhex(byte[] byteArrayData) { + StringBuilder hashBuilder = new StringBuilder(); + String stmpHex; + for (int n = 0; byteArrayData != null && n < byteArrayData.length; n++) { + stmpHex = Integer.toHexString(byteArrayData[n] & 0XFF); + if (stmpHex.length() == 1){ + hashBuilder.append('0'); + }else { + hashBuilder.append(stmpHex); + } + } + return hashBuilder.toString(); + } + + + + + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java index 2ba57da..8435211 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java @@ -243,7 +243,7 @@ public class FixSelectFlowDetailUtils { /* 定时查询签署流程详情 */ - @Scheduled(cron = "0/10 * * * * ?") +// @Scheduled(cron = "0/10 * * * * ?") @Transactional public void fixExecuteSelectFlowDetailUtils() { Gson gson = new Gson(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java index 91990d3..f213fb7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java @@ -12,6 +12,7 @@ import com.ruoyi.common.utils.SealUtil; import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; import com.ruoyi.wisdomarbitrate.domain.vo.base.StringIdsReq; +import org.springframework.beans.factory.annotation.Value; import java.util.List; import java.util.Map; @@ -22,6 +23,9 @@ public class SignAward { private static String eSignAppId = EsignApplicaConfig.EsignAppId; private static String eSignAppSecret = EsignApplicaConfig.EsignAppSecret; + @Value("${signSealCallbackConfig.url}") + private static String signSealCallbackUrl; + public static void main(String[] args) throws EsignDemoException { Gson gson = new Gson(); @@ -351,7 +355,7 @@ public class SignAward { " \"signConfig\": {\n" + " \"availableSignClientTypes\": \"1\"\n" + " },\n" + - + " \"notifyUrl\": \"" + signSealCallbackUrl + "\",\n" + " \"autoFinish\": true\n" + " },\n" + diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignVerifyUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignVerifyUtils.java new file mode 100644 index 0000000..a5e6168 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignVerifyUtils.java @@ -0,0 +1,99 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import com.ruoyi.common.utils.EsignApplicaConfig; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; + +public class SignVerifyUtils { + private static String eSignAppSecret = EsignApplicaConfig.EsignAppSecret; + + + public static boolean checkSignuter() throws Exception { + HttpServletRequest httprequest = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest(); + String orialsignature = httprequest.getHeader("X-Tsign-Open-SIGNATURE"); + String timestampreq = httprequest.getHeader("X-Tsign-Open-TIMESTAMP"); + String reqQuerystr =getHttpreqQuery(); + //获取请求参数 + String reqbodystr =getRequestBody(); + String signOriaData = timestampreq + reqQuerystr + reqbodystr; + String newDisgSignuter= DigesdateUtils.getSignStr(signOriaData, eSignAppSecret); + + System.out.println("请求参数timestampreq:----------->>>>>>"+timestampreq); + System.out.println("请求参数reqQuerystr:---------->>>>>>"+reqQuerystr); + System.out.println("请求参数reqbodystr:---------->>>>>>"+reqbodystr); + System.out.println("加密出来的签名值:----------->>>>>>"+newDisgSignuter); + System.out.println("header里面的签名值:---------->>>>>>"+orialsignature); + + if (StringUtils.equals(orialsignature, newDisgSignuter)) { + return true; + }else { + return false; + } + } + + public static String getHttpreqQuery() { + HttpServletRequest httprequest = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest(); + List reqNames= new ArrayList(); + Enumeration httpreqEle =httprequest.getParameterNames(); + while (httpreqEle.hasMoreElements()){ + reqNames.add(httpreqEle.nextElement()); + } + Collections.sort(reqNames); + String httpreqQuery = ""; + for (String reqName : reqNames) { + String reqvalue = httprequest.getParameter(reqName); + httpreqQuery += reqvalue == null ? "" : reqvalue; + } + System.out.println("获取请求字符串是:---"+httpreqQuery); + return httpreqQuery; + } + + public static String getRequestBody() { + HttpServletRequest httprequest = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest(); + String requestBody = ""; + int reqContentLen = httprequest.getContentLength(); + if (reqContentLen < 0) { + return null; + } + byte bufByteArray[] = new byte[reqContentLen]; + try { + for (int i = 0; i < reqContentLen;) { + int lengthReadInputStream = httprequest.getInputStream().read(bufByteArray, i, reqContentLen - i); + if (lengthReadInputStream == -1) { + break; + } + i += lengthReadInputStream; + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + requestBody = new String(bufByteArray, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return requestBody; + } + + + + + + + + + + + + + +}