From 8b0eae8dcad57706e91542242a77f93be63080a0 Mon Sep 17 00:00:00 2001 From: hejinbo Date: Wed, 15 Nov 2023 18:27:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9C=BA=E6=9E=84=E7=AE=A1=E7=90=86.?= =?UTF-8?q?=E5=85=AC=E7=AB=A0=E7=AE=A1=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeptIdentifyController.java | 37 ++- .../wisdomarbitrate/domain/DeptIdentify.java | 165 +--------- .../wisdomarbitrate/domain/SealManage.java | 38 +++ .../wisdomarbitrate/domain/vo/SealListVO.java | 2 +- .../mapper/DeptIdentifyMapper.java | 13 +- .../mapper/SealManageMapper.java | 16 + .../service/IDeptIdentifyService.java | 7 +- .../impl/CaseApplicationServiceImpl.java | 78 +++-- .../service/impl/DeptIdentifyServiceImpl.java | 186 ++++++----- .../utils/FixSelectFlowDetailUtils.java | 295 ++++++++---------- .../wisdomarbitrate/utils/SignAward.java | 51 +-- .../wisdomarbitrate/DeptIdentifyMapper.xml | 100 ++---- .../wisdomarbitrate/SealManageMapper.xml | 61 ++++ 13 files changed, 495 insertions(+), 554 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/SealManage.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/SealManageMapper.java create mode 100644 ruoyi-system/src/main/resources/mapper/wisdomarbitrate/SealManageMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java index 49f61a3..9c0c1a5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java @@ -1,16 +1,9 @@ package com.ruoyi.web.controller.wisdomarbitrate; - -import com.alibaba.fastjson.JSONObject; -import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.EsignDemoException; -import com.ruoyi.wisdomarbitrate.domain.CaseApplication; -import com.ruoyi.wisdomarbitrate.domain.DeptIdentify; -import com.ruoyi.wisdomarbitrate.domain.SealSignRecord; -import com.ruoyi.wisdomarbitrate.domain.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.*; import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO; import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +19,16 @@ public class DeptIdentifyController extends BaseController { @Autowired private IDeptIdentifyService deptIdentifyService; + /** + * 新增机构 + * @param deptIdentify + * @return + */ + @PostMapping("/insert") + public AjaxResult insertDeptIdentify(@RequestBody DeptIdentify deptIdentify){ + return deptIdentifyService.insertDeptIdentify(deptIdentify); + } + /** * 查询部门认证数据 */ @@ -46,7 +49,7 @@ public class DeptIdentifyController extends BaseController { } /** - * 启用 + * 机构启用/禁用 */ @PostMapping("/enableDept") public AjaxResult enableDept(@Validated @RequestBody DeptIdentify deptIdentify) { @@ -56,13 +59,13 @@ public class DeptIdentifyController extends BaseController { /** * 上传自定义公章 * - * @param deptIdentify + * @param * @param file * @return */ @PostMapping("/sealUpload") - public AjaxResult sealUpload(Long id, String sealName , @RequestParam("file") MultipartFile file) { - return deptIdentifyService.sealUpload(id,sealName, file); + public AjaxResult sealUpload(Long id, @RequestParam("file") MultipartFile file) { + return deptIdentifyService.sealUpload(id, file); } /** @@ -76,7 +79,7 @@ public class DeptIdentifyController extends BaseController { } /** - * 签章图片列表查询 + * 公章列表查询 * @param deptIdentify * @return */ @@ -89,14 +92,14 @@ public class DeptIdentifyController extends BaseController { /** * 印章启用或者禁用 - * @param deptIdentify + * @param sealManage * @return */ @PostMapping("/updateSealLockStatus") - public AjaxResult updateSealLockStatus(@Validated @RequestBody DeptIdentify deptIdentify){ - if(deptIdentify.getSealId()==null ||deptIdentify.getSealStatus()==null){ + public AjaxResult updateSealLockStatus(@Validated @RequestBody SealManage sealManage){ + if(sealManage.getId()==null ||sealManage.getSealStatus()==null){ return error("参数校验失败"); } - return deptIdentifyService.updateSealLockStatus(deptIdentify); + return deptIdentifyService.updateSealLockStatus(sealManage); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/DeptIdentify.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/DeptIdentify.java index 8d4c5b9..e34c90d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/DeptIdentify.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/DeptIdentify.java @@ -2,182 +2,39 @@ package com.ruoyi.wisdomarbitrate.domain; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseEntity; -import java.util.Date; +import lombok.Data; +import java.util.Date; +@Data public class DeptIdentify extends BaseEntity { private static final long serialVersionUID = 1L; /** ID */ private Long id; - /** 部门ID */ - private Long deptId; - /** 用户ID */ - private Long userId; - + /** 机构名称 */ + private String identifyName; /** 认证状态 */ 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; + /** 经办人姓名 */ + private String operName; + /** 经办人手机号 */ + private String operPhone; /** 机构账号ID */ private String orgId; - /** 认证授权流程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; - /** - * 印章状态 0禁用,1启用 - */ - private Integer sealStatus; - - public Integer getAnnexId() { - return annexId; - } - - public void setAnnexId(Integer annexId) { - this.annexId = annexId; - } - - public String getAuthFlowId() { - return authFlowId; - } - - public void setAuthFlowId(String authFlowId) { - this.authFlowId = authFlowId; - } - - public String getOrgId() { - return orgId; - } - - public void setOrgId(String orgId) { - this.orgId = orgId; - } - - public String getSealName() { - return sealName; - } - - public void setSealName(String sealName) { - this.sealName = sealName; - } - /** 部门认证链接 */ private String identifyUrl; - public String getIdentifyUrl() { - return identifyUrl; - } + /** 机构类型(1 仲裁机构) */ + private Integer identifyType; - 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; - } - - public Integer getSealStatus() { - return sealStatus; - } - - public void setSealStatus(Integer sealStatus) { - this.sealStatus = sealStatus; - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/SealManage.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/SealManage.java new file mode 100644 index 0000000..54bc0ba --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/SealManage.java @@ -0,0 +1,38 @@ +package com.ruoyi.wisdomarbitrate.domain; + +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +@Data +public class SealManage extends BaseEntity { + private static final long serialVersionUID = 1L; + /** + * ID + */ + private Long id; + + /** + * 机构关联id + */ + private Long identifyId; + + /** + * 印章名称 + */ + private String sealName; + + + /** + * 印章id + */ + private String sealId; + /** + * 附件id + */ + private Integer annexId; + + /** + * 印章状态(0禁用,1启用) + */ + private Integer sealStatus; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SealListVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SealListVO.java index 32edfea..1bfcefb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SealListVO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/SealListVO.java @@ -21,7 +21,7 @@ public class SealListVO { */ private String annexPath; /** - * 附件类型,立案申请书(1)、申请人证据材料(2)、仲裁文书(3)、案件视频(4)、身份证件(5)、被申请人证据材料 (6)、庭审笔录(7)、缴费凭证(8)' + * 附件类型 */ private Integer annexType; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/DeptIdentifyMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/DeptIdentifyMapper.java index 5d93476..cf78b09 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/DeptIdentifyMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/DeptIdentifyMapper.java @@ -1,23 +1,20 @@ package com.ruoyi.wisdomarbitrate.mapper; -import com.ruoyi.wisdomarbitrate.domain.CaseApplication; import com.ruoyi.wisdomarbitrate.domain.DeptIdentify; +import org.apache.ibatis.annotations.Mapper; import java.util.List; +@Mapper public interface DeptIdentifyMapper { - + /* + 查询仲裁机构信息 + */ List selectDeptIdentify(DeptIdentify deptIdentify); - List selectDeptIdentifyBydeptid(DeptIdentify deptIdentify); - int insertDeptIdentify(DeptIdentify deptIdentify); - List selectDeptIdentifylist(DeptIdentify deptIdentify); - int updateDeptIdentify(DeptIdentify deptIdentify); - List selectDeptIdentifylistother(DeptIdentify deptIdentify); - } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/SealManageMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/SealManageMapper.java new file mode 100644 index 0000000..a071eaf --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/SealManageMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.wisdomarbitrate.mapper; + +import com.ruoyi.wisdomarbitrate.domain.SealManage; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface SealManageMapper { + + List selectSealList(SealManage sealManage); + + int insertSealManage(SealManage sealManage); + + int updateSealManage(SealManage sealManage1); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java index 5d7007b..00de51c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java @@ -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 com.ruoyi.wisdomarbitrate.domain.SealManage; import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO; import org.springframework.web.multipart.MultipartFile; @@ -18,14 +19,16 @@ public interface IDeptIdentifyService { AjaxResult enableDept(DeptIdentify deptIdentify); - AjaxResult sealUpload(Long id, String sealName , MultipartFile file); + AjaxResult sealUpload(Long id,MultipartFile file); AjaxResult receiveNotify(String body); List getSealList(DeptIdentify deptIdentify); - AjaxResult updateSealLockStatus(DeptIdentify deptIdentify); + AjaxResult updateSealLockStatus(SealManage sealManage); + AjaxResult insertDeptIdentify(DeptIdentify deptIdentify); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java index 729025e..9704957 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java @@ -115,6 +115,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { private ReservedConferenceMapper reservedConferenceMapper; @Autowired private SysDeptMapper deptMapper; + @Autowired + private SealManageMapper sealManageMapper; // 手机号正则 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}$"); @@ -177,7 +179,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { deptIds.add(sysUser.getDeptId()); caseApplication.setDeptIds(deptIds); } - if ( role.getRoleName().equals("申请人")) { + if (role.getRoleName().equals("申请人")) { // 查询角色有关的用户部门 caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId())); } @@ -238,7 +240,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { deptIds.add(sysUser.getDeptId()); caseApplication.setDeptIds(deptIds); } - if ( role.getRoleName().equals("申请人")) { + if (role.getRoleName().equals("申请人")) { // 查询角色有关的用户部门 caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId())); } @@ -1686,7 +1688,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); if (jsonObject1.getIntValue("errCode") == 0) { //查看文件上传状态 - Thread.sleep(5000); + Thread.sleep(3000); EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); JSONObject data = jsonObject2.getJSONObject("data"); @@ -1716,12 +1718,12 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { DeptIdentify deptIdentify = new DeptIdentify(); deptIdentify.setIsUse(1); DeptIdentify deptIdentifyselect = new DeptIdentify(); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); + List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { deptIdentifyselect = deptIdentifysnew.get(0); - sealSignRecord.setOrgnizeName(deptIdentifyselect.getDeptName()); - sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getPhonenumber()); - sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getNickName()); + sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); + sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperName()); + sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperPhone()); } else { return AjaxResult.error("没有用印时的机构名称及经办人信息"); } @@ -1781,19 +1783,45 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { sealIds.add(sealId); } }*/ - EsignHttpResponse response3 = SignAward.createByFile(sealSignRecord); - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3.getIntValue("code") == 0) { - //获取签署流程ID - JSONObject data1 = jsonObject3.getJSONObject("data"); - String signFlowId = data1.getString("signFlowId"); - //保存案件id,文件id,文件名称.流程id到签署用印记录表里 - sealSignRecord.setCaseAppliId(caseApplication.getId()); - sealSignRecord.setSignFlowid(signFlowId); - sealSignRecord.setSignFlowStatus(1);//待签名 - sealSignRecordMapper.insertSealSignRecord(sealSignRecord); - } else { - throw new ServiceException("发起签署流程失败,请检查参数是否有误"); + String orgnizeName = sealSignRecord.getOrgnizeName(); //机构名称 + String orgnizeNamepsnName = sealSignRecord.getOrgnizeNamepsnName(); //机构经办人姓名 + String orgnizeNamePsnAccount = sealSignRecord.getOrgnizeNamePsnAccount(); //机构经办人联系方式 + //查询机构信息 + DeptIdentify deptIdentify1 = new DeptIdentify(); + deptIdentify1.setIdentifyName(orgnizeName); + deptIdentify1.setOperName(orgnizeNamepsnName); + deptIdentify1.setOperPhone(orgnizeNamePsnAccount); + List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify1); + if (deptIdentifies != null && deptIdentifies.size() > 0) { + Long id = deptIdentifies.get(0).getId(); + SealManage sealManage = new SealManage(); + sealManage.setIdentifyId(id); + List sealIdList = new ArrayList<>(); + List selectSealList = sealManageMapper.selectSealList(sealManage); + if (selectSealList != null && selectSealList.size() > 0) { + for (SealManage manage : selectSealList) { + Integer sealStatus = manage.getSealStatus(); + if (sealStatus == 1){ + sealIdList.add(manage.getSealId()); + } + } + EsignHttpResponse response3 = SignAward.createByFile(sealSignRecord,sealIdList); + JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); + if (jsonObject3.getIntValue("code") == 0) { + //获取签署流程ID + JSONObject data1 = jsonObject3.getJSONObject("data"); + String signFlowId = data1.getString("signFlowId"); + //保存案件id,文件id,文件名称.流程id到签署用印记录表里 + sealSignRecord.setCaseAppliId(caseApplication.getId()); + sealSignRecord.setSignFlowid(signFlowId); + sealSignRecord.setSignFlowStatus(1);//待签名 + sealSignRecordMapper.insertSealSignRecord(sealSignRecord); + } else { + throw new ServiceException("发起签署流程失败,请检查参数是否有误"); + } + } + + } } } @@ -2580,7 +2608,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { // 新增预约会议表 ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), roomId, - reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime(),1); + reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime(), 1); reservedConferenceMapper.insert(conference); return AjaxResult.success("预约会议成功"); @@ -2608,20 +2636,21 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { String roomId = generateRoomId(); // 新增预约会议表 ReservedConference conference = new ReservedConference(caseId, roomId, - null, null,0); + null, null, 0); reservedConferenceMapper.insert(conference); return roomId; } /** * 获取房间号 + * * @return */ public String generateRoomId() { // 查询最大房间号 Integer maxRoomId = caseApplicationMapper.selectMaxRoomId(); - if (null == maxRoomId || maxRoomId >999999) { + if (null == maxRoomId || maxRoomId > 999999) { return "000001"; } else { return String.format("%06d", maxRoomId); @@ -2662,13 +2691,14 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { /** * 删除房间号 + * * @param roomId * @return */ @Override public AjaxResult deleteRoom(String roomId) { - return AjaxResult.success( reservedConferenceMapper.deleteByRoomId(roomId)); + return AjaxResult.success(reservedConferenceMapper.deleteByRoomId(roomId)); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java index cdb824e..3b95eb2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java @@ -12,9 +12,11 @@ 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.domain.SealManage; import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO; import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper; import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper; +import com.ruoyi.wisdomarbitrate.mapper.SealManageMapper; import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService; import com.ruoyi.wisdomarbitrate.utils.SignAward; import org.springframework.beans.factory.annotation.Autowired; @@ -37,33 +39,20 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { private DeptIdentifyMapper deptIdentifyMapper; @Autowired private CaseAttachMapper caseAttachMapper; + @Autowired + private SealManageMapper sealManageMapper; @Override @Transactional public List selectDeptIdentify(DeptIdentify deptIdentify) { - List deptIdentifys = deptIdentifyMapper.selectDeptIdentify(deptIdentify); - if (deptIdentifys != null && deptIdentifys.size() > 0) { - for (int i = 0; i < deptIdentifys.size(); i++) { - DeptIdentify deptIdentifyselect = deptIdentifys.get(i); - List deptIdentifylist = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentifyselect); - if (deptIdentifylist != null && deptIdentifylist.size() > 0) { - continue; - } else { - deptIdentifyselect.setIdentifyStatus(0); - deptIdentifyMapper.insertDeptIdentify(deptIdentifyselect); - } - } - } - - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); - return deptIdentifysnew; + return deptIdentifyMapper.selectDeptIdentify(deptIdentify); } @Override @Transactional public DeptIdentify selectDeptIndefiUrl(DeptIdentify deptIdentify) throws EsignDemoException { - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); + List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); DeptIdentify deptIdentifynew = new DeptIdentify(); if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { Gson gson = new Gson(); @@ -71,7 +60,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){ + if (code == 0) { JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); String url = signUrlData.get("authUrl").getAsString(); //获取本次认证授权流程ID @@ -88,34 +77,36 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { @Override @Transactional public AjaxResult enableDept(DeptIdentify deptIdentify) { - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); + //参数校验 + if (deptIdentify.getId() == null) { + return AjaxResult.error("请检查参数"); + } + List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(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 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); + Integer isUse = deptIdentifyselect.getIsUse(); + if (isUse == 0) { //机构为未启用状态 + Integer identifyStatus = deptIdentifyselect.getIdentifyStatus(); + if (identifyStatus == 0) { + return AjaxResult.error("这个认证数据未进行认证,不能启用"); + } else { + deptIdentifyselect.setIsUse(1); + int i = deptIdentifyMapper.updateDeptIdentify(deptIdentifyselect); + if (i > 0) { + return AjaxResult.success("启用成功"); } } - + } else { //机构为已启用状态 + deptIdentifyselect.setIsUse(0); + int i = deptIdentifyMapper.updateDeptIdentify(deptIdentifyselect); + if (i > 0) { + return AjaxResult.success(); + } } - return AjaxResult.success(); - + return AjaxResult.error(); } @Override - public AjaxResult sealUpload(Long id, String sealName , MultipartFile file) { + public AjaxResult sealUpload(Long id, MultipartFile file) { try { if (file.isEmpty()) { return AjaxResult.error("请选择要上传的文件"); @@ -125,11 +116,14 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { String fileName = FileUploadUtils.upload(filePath, file); DeptIdentify deptIdentify = new DeptIdentify(); deptIdentify.setId(id); - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifyBydeptid(deptIdentify); + List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify); if (deptIdentifies != null && deptIdentifies.size() > 0) { for (DeptIdentify identify : deptIdentifies) { //先判断企业用户是否授予资源管理权限 String authFlowId = identify.getAuthFlowId(); + if (authFlowId == null) { + return AjaxResult.error("改机构尚未认证,不能上传自定义公章"); + } EsignHttpResponse response1 = SealUtil.queryAuthProcess(authFlowId); JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); int authorizedStatus = jsonObject1.getJSONObject("data").getIntValue("authorizedStatus"); @@ -137,32 +131,27 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { String prefix = "/profile"; int startIndex = fileName.indexOf(prefix); startIndex += prefix.length(); - //String annexPath = "home/ruoyi/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); + // String annexPath = "D:\\develop\\2.jpg"; + String sealName = "自定义" + UUID.randomUUID() + ""; //自定义印章印章名称不能重复,所以用UUID确保唯一性 + EsignHttpResponse response = SignAward.createOrgByImage(identify,sealName,annexPath); JSONObject jsonObject = JSONObject.parseObject(response.getBody()); int code = jsonObject.getIntValue("code"); if (code == 0) { //业务码,0表示成功,非0表示异常。 String sealId = jsonObject.getJSONObject("data").getString("sealId"); //保存到表里 - 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); + SealManage sealManage = new SealManage(); + sealManage.setIdentifyId(identify.getId()); + sealManage.setSealName(sealName); + sealManage.setSealId(sealId); + sealManage.setSealStatus(0); //默认为禁用 + int i = sealManageMapper.insertSealManage(sealManage); if (i > 0) { return AjaxResult.success("上传成功"); } } - return AjaxResult.error("公章上传失败,请检查印章名称是否重复"); + return AjaxResult.error("公章上传失败,请检查参数"); } return AjaxResult.error("企业用户未授予资源管理权限"); } @@ -233,14 +222,14 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { if (i1 > 0) { //将附件id保存到公章管理表里 Integer annexId1 = caseAttach.getAnnexId(); - DeptIdentify identify = new DeptIdentify(); - identify.setSealId(sealId); - List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(identify); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - DeptIdentify identify1 = deptIdentifies.get(0); - identify1.setAnnexId(annexId1); - identify1.setSealStatus(1); //启用 - deptIdentifyMapper.updateDeptIdentify(identify1); + SealManage sealManage = new SealManage(); + sealManage.setSealId(sealId); + List selectSealList = sealManageMapper.selectSealList(sealManage); + if (selectSealList != null && selectSealList.size() > 0) { + SealManage sealManage1 = selectSealList.get(0); + sealManage1.setAnnexId(annexId1); + sealManage1.setSealStatus(1); //启用 + sealManageMapper.updateSealManage(sealManage1); } } } @@ -258,33 +247,62 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { @Override public List getSealList(DeptIdentify deptIdentify) { - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentify); + if (deptIdentify.getId() == null) { + return null; + } + SealManage sealManage = new SealManage(); + sealManage.setIdentifyId(deptIdentify.getId()); + List selectSealList = sealManageMapper.selectSealList(sealManage); List sealListVOS = new ArrayList<>(); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - for (DeptIdentify identify : deptIdentifies) { - SealListVO sealListVO = new SealListVO(); - sealListVO.setSealId(identify.getSealId()); - sealListVO.setSealName(identify.getSealName()); - sealListVO.setSealStatus(identify.getSealStatus()); - Integer annexId = identify.getAnnexId(); - //根据附件id查询路径 - CaseAttach caseAttach = caseAttachMapper.queryAnnexById(annexId); - String annexName = caseAttach.getAnnexName(); - String prefix = "/profile"; - int startIndex = annexName.indexOf(prefix); - startIndex += prefix.length(); - String annexPath = "/uploadPath" + annexName.substring(startIndex); - sealListVO.setAnnexPath(annexPath); - sealListVO.setAnnexType(caseAttach.getAnnexType()); - sealListVOS.add(sealListVO); + if (selectSealList != null && selectSealList.size() > 0) { + for (SealManage sealManage1 : selectSealList) { + Integer annexId = sealManage1.getAnnexId(); + if (annexId != null) { //附件id有值,证明是审核通过了的 + SealListVO sealListVO = new SealListVO(); + sealListVO.setSealId(sealManage1.getSealId()); + sealListVO.setSealName(sealManage1.getSealName()); + sealListVO.setSealStatus(sealManage1.getSealStatus()); + //根据附件id查询路径 + CaseAttach caseAttach = caseAttachMapper.queryAnnexById(annexId); + String annexName = caseAttach.getAnnexName(); + String prefix = "/profile"; + int startIndex = annexName.indexOf(prefix); + startIndex += prefix.length(); + String annexPath = "/uploadPath" + annexName.substring(startIndex); + sealListVO.setAnnexPath(annexPath); + sealListVO.setAnnexType(caseAttach.getAnnexType()); + sealListVOS.add(sealListVO); + } } } return sealListVOS; } @Override - public AjaxResult updateSealLockStatus(DeptIdentify deptIdentify) { - deptIdentifyMapper.updateDeptIdentify(deptIdentify); + public AjaxResult updateSealLockStatus(SealManage sealManage) { + sealManageMapper.updateSealManage(sealManage); return AjaxResult.success(); } + + @Override + public AjaxResult insertDeptIdentify(DeptIdentify deptIdentify) { + //参数校验 + String identifyName = deptIdentify.getIdentifyName(); + String operName = deptIdentify.getOperName(); + String operPhone = deptIdentify.getOperPhone(); + if (identifyName == null || operName == null || operPhone == null) { + AjaxResult.error("请检查参数是否完整"); + } + Integer identifyType = deptIdentify.getIdentifyType(); + if (identifyType == null) { + deptIdentify.setIdentifyType(1); // 设置机构默认为仲裁机构 + } + deptIdentify.setIdentifyStatus(0); //设置认证状态默认为未认证 + deptIdentify.setIsUse(0); //设置认证状态默认为未认证 + int i = deptIdentifyMapper.insertDeptIdentify(deptIdentify);//设置机构默认为未启用 + if (i > 0) { + return AjaxResult.success("新增成功"); + } + return AjaxResult.error(); + } } 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 5b0d162..2ccf59f 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.ruoyi.common.constant.CaseApplicationConstants; import com.ruoyi.common.constant.FileTransformation; @@ -11,14 +12,8 @@ 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.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 com.ruoyi.wisdomarbitrate.domain.*; +import com.ruoyi.wisdomarbitrate.mapper.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -27,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import java.io.File; import java.io.IOException; import java.time.LocalDate; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -41,7 +37,11 @@ public class FixSelectFlowDetailUtils { private CaseAttachMapper caseAttachMapper; @Autowired private DeptIdentifyMapper deptIdentifyMapper; - + @Autowired + private SealManageMapper sealManageMapper; + /* + 定时查询签署流程详情 + */ @Scheduled(cron = "0/10 * * * * ?") @Transactional public void fixExecuteSelectFlowDetailUtils() { @@ -171,17 +171,21 @@ public class FixSelectFlowDetailUtils { } - @Scheduled(cron = "0/30 * * * * ?") + /** + * 定时查询企业认证状态 + * @throws Exception + */ + @Scheduled(cron = "0 0/30 * * * ?") @Transactional - public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException { + public void fixExecuteSelectDeptIndentifyUtils() throws Exception { Gson gson = new Gson(); DeptIdentify deptIdentify = new DeptIdentify(); deptIdentify.setIdentifyStatus(0); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); + List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { for (int i = 0; i < deptIdentifysnew.size(); i++) { - EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentifysnew.get(i)); - + DeptIdentify deptIdentify1 = deptIdentifysnew.get(i); + EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentify1); JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class); int code = identifyInfoJsonObject.get("code").getAsInt(); if (code == 0) { @@ -189,27 +193,66 @@ public class FixSelectFlowDetailUtils { 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 + ","; + //查询企业内部印章 + EsignHttpResponse response = SignAward.deptIdentifySealList(orgId); + JsonObject jsonObject = gson.fromJson(response.getBody(), JsonObject.class); + int code1 = jsonObject.get("code").getAsInt(); + if (code1 == 0){ + JsonObject data = jsonObject.getAsJsonObject("data"); + JsonArray seals = data.get("seals").getAsJsonArray(); + if (seals.size() > 0) { + for (int j = 0; j < seals.size(); j++) { + //保存印章信息到数据库 + JsonObject asJsonObject = seals.get(j).getAsJsonObject(); + SealManage sealManage = new SealManage(); + String sealName = asJsonObject.get("sealName").toString(); + String sealId = asJsonObject.get("sealId").toString(); + String url = asJsonObject.get("sealImageDownloadUrl").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/"; + // 创建日期目录 + 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(url, resultFilePath); + if (downLoadFile) { + CaseAttach caseAttach = new CaseAttach(); + caseAttach.setAnnexType(10); //10代表印章图片 + caseAttach.setAnnexPath(savePath); + caseAttach.setAnnexName(saveName); + int i1 = caseAttachMapper.save(caseAttach); + if (i1 > 0) { + //将印章信息保存到公章管理表里 + Integer annexId1 = caseAttach.getAnnexId(); + sealManage.setAnnexId(annexId1); + sealManage.setSealId(sealId); + sealManage.setSealName(sealName); + sealManage.setIdentifyId(deptIdentify1.getId()); + sealManage.setSealStatus(1); + sealManageMapper.insertSealManage(sealManage); + } + } + } } + } - String sealName = sealNames.substring(0, sealNames.length() - 1); - deptIdentifynew.setIdentifyStatus(1); - deptIdentifynew.setSealName(sealName); - int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew); + //将orgId保存到数据库里 + deptIdentify1.setOrgId(orgId); + deptIdentify1.setIdentifyStatus(1); + deptIdentify1.setIsUse(0); //默认机构为未启用 + int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify1); } } } @@ -217,68 +260,77 @@ public class FixSelectFlowDetailUtils { } /** - * 定时查询企业内部印章审核状态 - * - * @throws EsignDemoException + * 定时查询印章审核状态 */ - // @Scheduled(cron = "0/30 * * * * ?") + @Scheduled(cron = "0/30 * * * * ?") @Transactional public void searchForInstitutionalSeal() { try { - DeptIdentify deptIdentify = new DeptIdentify(); - deptIdentify.setIsUse(0); - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifylist(deptIdentify); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - for (DeptIdentify identify : deptIdentifies) { + SealManage sealManage = new SealManage(); + sealManage.setSealStatus(0); + List sealManageList = sealManageMapper.selectSealList(sealManage); + if (sealManageList != null && sealManageList.size() > 0) { + for (SealManage sealManage1 : sealManageList) { //查询企业内部印章 - 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); - int i1 = caseAttachMapper.save(caseAttach); - if (i1 > 0) { - //将附件id保存到公章管理表里 - Integer annexId1 = caseAttach.getAnnexId(); - identify.setAnnexId(annexId1); - deptIdentifyMapper.updateDeptIdentify(identify); + Integer annexId = sealManage1.getAnnexId(); + String sealId = sealManage1.getSealId(); + DeptIdentify deptIdentify = new DeptIdentify(); + deptIdentify.setId(sealManage1.getIdentifyId()); + List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify); + if (deptIdentifies != null && deptIdentifies.size() > 0) { + DeptIdentify deptIdentify1 = deptIdentifies.get(0); + String orgId = deptIdentify1.getOrgId(); + if (orgId == null) { + continue; + } + if (annexId == null) { + //说明之前没有下载过 + EsignHttpResponse response = SignAward.getOrgSeal(orgId, sealId); + JSONObject jsonObject = JSONObject.parseObject(response.getBody()); + int code = jsonObject.getIntValue("code"); + if (code == 0) { + JSONObject data = jsonObject.getJSONObject("data"); + int sealStatus = data.getIntValue("sealStatus"); + if (sealStatus == 1) {//印章状态 1已启用,2待审核,3审核不通过,4 挂起 + //已启用证明审核通过,下载到数据库 + String sealImageDownloadUrl = data.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); + int i1 = caseAttachMapper.save(caseAttach); + if (i1 > 0) { + //将附件id保存到公章管理表里 + Integer annexId1 = caseAttach.getAnnexId(); + sealManage1.setAnnexId(annexId1); + sealManageMapper.updateSealManage(sealManage1); + } } } } } } + } } } catch (EsignDemoException e) { @@ -288,79 +340,6 @@ public class FixSelectFlowDetailUtils { } } - /* public static void main(String[] args) throws Exception { - Gson gson = new Gson(); - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setCaseAppliId(1350L); - sealSignRecord.setSignFlowid("24ca7172f1a242238937d952c2e7fbff"); - EsignHttpResponse signFlowDetail = SignAward.signFlowDetail(sealSignRecord); - 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); - - if (!(signerObject.get("psnSigner").toString()).equals("null")) { - JsonObject psnSignerData = signerObject.getAsJsonObject("psnSigner"); - if (psnSignerData != null) { - psnsignStatus = signerObject.get("signStatus").getAsInt(); - } - } - if (!(signerObject.get("orgSigner").toString()).equals("null")) { - JsonObject orgSignerData = signerObject.getAsJsonObject("orgSigner"); - if (orgSignerData != null) { - orgsignStatus = signerObject.get("signStatus").getAsInt(); - } - } - - } - - if ((psnsignStatus.intValue() == 2) && (orgsignStatus.intValue() == 2)) { - - //下载审核完成的裁决书, - String signFlowId = "24ca7172f1a242238937d952c2e7fbff"; - 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(); - System.out.println(fileDownloadUrl); - String filearbitraUrl = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); - System.out.println(filearbitraUrl); - 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(); - } - - String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); - boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); - if (downLoadFile) { - System.out.println("chenggong ==============="); - } - } - } - }*/ - } 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 f1ead65..82a4a35 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 @@ -18,6 +18,7 @@ import java.io.File; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.UUID; public class SignAward { @@ -119,10 +120,7 @@ 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); + } @@ -150,7 +148,7 @@ public class SignAward { * @return * @throws EsignDemoException */ - public static EsignHttpResponse createByFile(SealSignRecord sealSignRecord) throws EsignDemoException { + public static EsignHttpResponse createByFile(SealSignRecord sealSignRecord ,List sealIdList) throws EsignDemoException { String apiaddr = "/v3/sign-flow/create-by-file"; String fileId = sealSignRecord.getFileid(); @@ -248,10 +246,10 @@ public class SignAward { " \"autoSign\": false,\n" + " \"freeMode\": false,\n" + - " \"availableSealIds\": [\n" + + /* " \"availableSealIds\": [\n" + " \"" + availableSealId + "\"\n" + - " ],\n" + - + " ],\n" +*/ + " \"availableSealIds\": " + new Gson().toJson(sealIdList) + "\n" + " \"signFieldPosition\": {\n" + " \"positionPage\": \"" + positionPageorg + "\",\n" + @@ -343,16 +341,16 @@ public class SignAward { */ 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 psnName = deptIdentify.getOperName(); + String phonenumber = deptIdentify.getOperPhone(); + String orgName = deptIdentify.getIdentifyName(); String jsonParm = "{\n" + " \"orgAuthConfig\": {\n" + - " \"orgName\": \"" + deptName + " \",\n" + + " \"orgName\": \"" + orgName + " \",\n" + " \"transactorInfo\": {\n" + " \"psnAccount\": \"" + phonenumber + "\",\n" + " \"psnInfo\": {\n" + - " \"psnName\": \"" + nickName + "\",\n" + + " \"psnName\": \"" + psnName + "\",\n" + " \"psnMobile\": \"" + phonenumber + "\"\n" + " }\n" + " }\n" + @@ -381,7 +379,7 @@ 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.getIdentifyName(); String jsonParm = "{}"; //请求方法 @@ -392,8 +390,9 @@ public class SignAward { return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false); } + /** - * 查询企业认证印章信息 + * 查询企业内部印章 */ public static EsignHttpResponse deptIdentifySealList(String orgId) throws EsignDemoException { int pageNum = 1; @@ -437,7 +436,7 @@ public class SignAward { * * @return */ - public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify, String filePath) throws EsignDemoException { + public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify,String sealName, String filePath) throws EsignDemoException { String apiaddr = "/v3/seals/org-seals/create-by-image"; String orgId = deptIdentify.getOrgId(); //上传印章图片 @@ -452,7 +451,7 @@ public class SignAward { 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" + @@ -473,26 +472,8 @@ public class SignAward { 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 header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false); - //发起接口请求 - return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false); - } /** * 查询指定印章详情(机构) diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/DeptIdentifyMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/DeptIdentifyMapper.xml index 454a9ca..0b9f183 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/DeptIdentifyMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/DeptIdentifyMapper.xml @@ -5,48 +5,46 @@ - - - - - - - - + + + - - + insert into dept_identify( dept_id, @@ -54,59 +52,22 @@ identify_status, identify_date, is_use, - seal_name, org_id, - auth_flow_id, - seal_id + auth_flow_id )values( #{deptId}, #{userId}, #{identifyStatus}, #{identifyDate}, #{isUse}, - #{sealName}, #{orgId}, - #{authFlowId}, - #{sealId} + #{authFlowId} ) - - + + @@ -115,11 +76,8 @@ identify_date = #{identifyDate}, is_use = #{isUse}, identify_status = #{identifyStatus}, - seal_name = #{sealName}, org_id = #{orgId}, - seal_id = #{sealId}, - seal_status = #{sealStatus}, - auth_flow_id = #{authFlowId}, + auth_flow_id = #{authFlowId} diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/SealManageMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/SealManageMapper.xml new file mode 100644 index 0000000..a6bb7a0 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/SealManageMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + insert into seal_manage( + identify_id, + seal_name, + seal_id, + annex_id, + seal_status + )values( + #{identifyId}, + #{sealName}, + #{sealId}, + #{annexId}, + #{sealStatus} + ) + + + + update dept_identify + + identify_id = #{identifyId}, + seal_name = #{sealName}, + seal_id = #{sealId}, + annex_id = #{annexId}, + seal_status = #{sealStatus} + + + + AND id = #{id} + + + + + \ No newline at end of file From a4e834783593c00e9b80ade7418c443a48ff0347 Mon Sep 17 00:00:00 2001 From: hejinbo Date: Thu, 16 Nov 2023 10:42:19 +0800 Subject: [PATCH 2/2] zancun --- .../DeptIdentifyController.java | 2 +- .../service/impl/DeptIdentifyServiceImpl.java | 10 ++++- .../utils/ImageToBase64Converter.java | 30 +++++++++++++++ .../ruoyi/wisdomarbitrate/utils/MyTest.java | 37 ------------------- 4 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java delete mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java index 9c0c1a5..13df556 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java @@ -30,7 +30,7 @@ public class DeptIdentifyController extends BaseController { } /** - * 查询部门认证数据 + * 查询机构信息 */ @GetMapping("/list") public TableDataInfo list(DeptIdentify deptIdentify) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java index 3b95eb2..4792ed9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java @@ -135,13 +135,13 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { //创建机构图片印章 // String annexPath = "D:\\develop\\2.jpg"; String sealName = "自定义" + UUID.randomUUID() + ""; //自定义印章印章名称不能重复,所以用UUID确保唯一性 - EsignHttpResponse response = SignAward.createOrgByImage(identify,sealName,annexPath); + EsignHttpResponse response = SignAward.createOrgByImage(identify, sealName, annexPath); JSONObject jsonObject = JSONObject.parseObject(response.getBody()); int code = jsonObject.getIntValue("code"); if (code == 0) { //业务码,0表示成功,非0表示异常。 String sealId = jsonObject.getJSONObject("data").getString("sealId"); //保存到表里 - SealManage sealManage = new SealManage(); + SealManage sealManage = new SealManage(); sealManage.setIdentifyId(identify.getId()); sealManage.setSealName(sealName); sealManage.setSealId(sealId); @@ -297,6 +297,12 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { if (identifyType == null) { deptIdentify.setIdentifyType(1); // 设置机构默认为仲裁机构 } + //先查询看数据库里有没有相同的机构经办人 + List deptIdentifies = deptIdentifyMapper.selectDeptIdentify(deptIdentify); + if (deptIdentifies != null && deptIdentifies.size() > 0) { + //说明之前新增过 + return AjaxResult.error("信息重复"); + } deptIdentify.setIdentifyStatus(0); //设置认证状态默认为未认证 deptIdentify.setIsUse(0); //设置认证状态默认为未认证 int i = deptIdentifyMapper.insertDeptIdentify(deptIdentify);//设置机构默认为未启用 diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java new file mode 100644 index 0000000..752b36b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/ImageToBase64Converter.java @@ -0,0 +1,30 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import java.io.BufferedInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Base64; + +public class ImageToBase64Converter { + public static String imageToBase64(String imagePath) throws Exception { + Path path = Paths.get(imagePath); + byte[] imageBytes = Files.readAllBytes(path); + String base64Image = Base64.getEncoder().encodeToString(imageBytes); + return base64Image; + } + + public static void main(String[] args) { + String imagePath = "D:\\develop\\2.jpg"; + try { + String base64Image = imageToBase64(imagePath); + System.out.println(base64Image); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java deleted file mode 100644 index 586b79b..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/MyTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ruoyi.wisdomarbitrate.utils; - -import java.io.BufferedInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -public class MyTest { - public static void download(String fileUrl, String saveFilePath) throws IOException { - URL url = new URL(fileUrl); - InputStream inputStream = url.openStream(); - BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); - FileOutputStream fileOutputStream = new FileOutputStream(saveFilePath); - - byte[] buffer = new byte[1024]; - int bytesRead = 0; - while ((bytesRead = bufferedInputStream.read(buffer, 0, buffer.length)) != -1) { - fileOutputStream.write(buffer, 0, bytesRead); - } - - fileOutputStream.close(); - bufferedInputStream.close(); - inputStream.close(); - } - - public static void main(String[] args) { - String fileUrl = "https://esignoss.esign.cn/1111563786/0e16cc53-fe2e-403b-b901-587778a8ea92/3ed8f1b0bd2640e895fcfbaffdec0a1e.pdf?Expires=1698742492&OSSAccessKeyId=LTAI4G23YViiKnxTC28ygQzF&Signature=K%2Bb5k7DqNmaxeu%2Fct5qis4qor7s%3D"; - String saveFilePath = "D:\\home\\example.pdf"; - try { - download(fileUrl, saveFilePath); - System.out.println("File downloaded successfully."); - } catch (IOException e) { - e.printStackTrace(); - } - } -}