From 72026ee6f4957d649e0053bb55b2cf3ac20558dc Mon Sep 17 00:00:00 2001 From: 18792927508 <1322446236@qq.com> Date: Tue, 2 Apr 2024 15:56:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=A7=A3=E7=B3=BB=E7=BB=9F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/RuoYiApplication.java | 21 + .../controller/system/SysLoginController.java | 11 + .../controller/tool/TestApiController.java | 8 +- .../mscase/MsCaseApplicationController.java | 14 +- .../mscase/MsSignSealController.java | 64 +- .../mscase/MsVideoConferenceController.java | 4 +- .../ruoyi/common/constant/CacheConstants.java | 17 + .../com/ruoyi/common/constant/Constants.java | 3 + .../common/core/domain/entity/SMSNotice.java | 26 + .../core/domain/entity/SMSNoticeDO.java | 34 + .../common/core/domain/entity/SysDept.java | 36 +- .../common/core/domain/entity/SysUser.java | 44 + .../ruoyi/common/enums/DocumentTypeEnum.java | 18 + .../com/ruoyi/common/utils/EmailOutUtil.java | 36 +- .../web/service/SysLoginService.java | 28 +- .../framework/web/service/TokenService.java | 5 +- .../domain/entity/log/MsRequestLog.java | 55 + .../ruoyi/system/mapper/SysUserMapper.java | 12 +- .../system/mapper/SysUserRoleMapper.java | 7 + .../system/mapper/log/MsRequestLogMapper.java | 7 + .../system/service/BeiMingInterface.java | 17 +- .../system/service/MsRequestLogService.java | 14 + .../service/impl/BeiMingInterfaceService.java | 102 +- .../service/impl/MsRequestLogServiceImpl.java | 24 + .../service/impl/SysDeptServiceImpl.java | 28 +- .../service/impl/SysRoleServiceImpl.java | 34 +- .../domain/entity/mscase/MsCaseAffiliate.java | 206 +- .../entity/mscase/MsCaseApplication.java | 20 +- .../domain/entity/mscase/MsCaseAttach.java | 5 + .../domain/vo/mscase/MsCaseAffiliateBase.java | 32 + .../vo/mscase/MsCaseAffiliateParent.java | 11 + .../domain/vo/mscase/MsCaseAffiliateVO.java | 32 + .../vo/mscase/MsCaseApplicationReq.java | 13 + .../domain/vo/mscase/MsCaseApplicationVO.java | 15 +- .../mapper/mscase/MsCaseAffiliateMapper.java | 23 + .../mscase/MsCaseApplicationMapper.java | 160 +- .../mscase/MsCaseApplicationService.java | 97 +- .../service/mscase/MsCasePaymentService.java | 7 + .../service/mscase/MsSignSealService.java | 9 +- .../mscase/VideoConferenceService.java | 2 +- .../impl/MsCaseApplicationServiceImpl.java | 3945 ++++++++--------- .../mscase/impl/MsCasePaymentServiceImpl.java | 149 +- .../mscase/impl/MsSignSealServiceImpl.java | 633 +-- .../impl/VideoConferenceServiceImpl.java | 51 +- .../system/mapper/log/MsRequestLogMapper.xml | 15 + .../resources/mapper/system/SysDeptMapper.xml | 12 + .../resources/mapper/system/SysUserMapper.xml | 27 +- .../mapper/system/SysUserRoleMapper.xml | 6 +- .../mscase/MsCaseAffiliateMapper.xml | 92 +- .../mscase/MsCaseApplicationMapper.xml | 109 + .../mscase/MsCaseAttachMapper.xml | 4 + 51 files changed, 3102 insertions(+), 3242 deletions(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNotice.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNoticeDO.java create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/enums/DocumentTypeEnum.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/log/MsRequestLog.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/log/MsRequestLogMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/MsRequestLogService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MsRequestLogServiceImpl.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateBase.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateParent.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateVO.java create mode 100644 ruoyi-system/src/main/resources/com/ruoyi/system/mapper/log/MsRequestLogMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 61b4e13..8e2591f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -2,9 +2,13 @@ package com.ruoyi; import cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.constant.CacheConstants; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysUserMapper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -45,6 +49,23 @@ public class RuoYiApplication if(CollectionUtil.isNotEmpty(sysUsers)){ for (SysUser sysUser : sysUsers) { redisCache.setCacheObject(CacheConstants.USER_KEY+sysUser.getUserId(),sysUser); + redisCache.setCacheObject(CacheConstants.USER_EMAIL_KEY+sysUser.getEmail(),sysUser); + } + } + // 初始化角色redis + SysRoleMapper roleMapper = SpringUtils.getBean(SysRoleMapper.class); + List roles = roleMapper.selectRoleList(new SysRole()); + if(CollectionUtil.isNotEmpty(roles)){ + for (SysRole role : roles) { + redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId()); + } + } + // 初始化部门redis + SysDeptMapper deptMapper = SpringUtils.getBean(SysDeptMapper.class); + List depts = deptMapper.selectDeptList(new SysDept()); + if(CollectionUtil.isNotEmpty(depts)){ + for (SysDept dept : depts) { + redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId()); } } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index e42104d..acfe355 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -116,6 +116,17 @@ public class SysLoginController { } return loginService.loginSSO(loginBody); + } + /**对接BM,根据用户名查询token*/ + @GetMapping("selectTokenByUserName") + public AjaxResult selectTokenByUserName( LoginBody loginBody){ + if(StrUtil.isEmpty(loginBody.getUsername()) || StrUtil.isEmpty(loginBody.getTicket()) + ){ + return AjaxResult.error("参数错误"); + } + + return loginService.selectTokenByUserName(loginBody); + } public static void main(String[] args) { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestApiController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestApiController.java index 7454856..2c66e62 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestApiController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestApiController.java @@ -2,12 +2,12 @@ package com.ruoyi.web.controller.tool; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.AttachmentOperateTypeEnum; import com.ruoyi.common.enums.PushCaseStatusEnum; import com.ruoyi.system.service.impl.BeiMingInterfaceService; +import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController; import java.io.File; import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt; -import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt; @RestController @RequestMapping("/beiming/api") @@ -57,12 +56,13 @@ public class TestApiController { return AjaxResult.success(); } + @GetMapping("/testfile") @Anonymous public AjaxResult testfile() { // File file = new File("D:/WorkDoc/TJ/File/证据1.png"); File file = new File("D:/WorkDoc/TJ/File/证据3.png"); - JSONObject jsonObject1 = beiMingInterfaceService.pushAttachmentInfo("BWT_MEDIATION", "86251b190e3a40f3942v215d1762c663", file, "123abc", "BWT_MEDIATION", "zc2024032700012"); + MsCaseFileInfo jsonObject1 = beiMingInterfaceService.pushAttachmentInfo("BWT_MEDIATION", "86251b190e3a40f3942v215d1762c663", file, "BWT_MEDIATION", "zc2024032700012", AttachmentOperateTypeEnum.ADD); System.out.println("fanhui:" + jsonObject1.toString()); return AjaxResult.success(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java index 23462d6..4af3ce4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsCaseApplicationController.java @@ -77,7 +77,7 @@ public class MsCaseApplicationController extends BaseController { @PostMapping("/insert") public AjaxResult insert(@RequestBody MsCaseApplicationVO caseApplication ) { - if(caseApplication.getAffiliate()==null||caseApplication.getAffiliate().getOrganizeFlag()==null){ + if( caseApplication.getAffiliate()==null|| caseApplication.getOrganizeFlag()==null){ error("参数校验失败"); } AjaxResult ajaxResult = AjaxResult.success(); @@ -344,19 +344,7 @@ public class MsCaseApplicationController extends BaseController { return caseApplicationService.updateTrialPen(attach); } - /** - * 确认调解书 - * @param - * @return - */ - @PostMapping("/confirmMediation") - public AjaxResult confirmMediation(@RequestBody MsCaseAttachVO attach) throws EsignDemoException, InterruptedException { - if (attach.getCaseFlowId()==null || attach.getCaseAppliId()==null ) { - return error("参数校验失败"); - } - return caseApplicationService.confirmMediation(attach); - } /** * 获取userSign * @param userId 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 adee87e..17f835a 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,18 +2,15 @@ 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; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO; 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; @@ -29,16 +26,7 @@ public class MsSignSealController extends BaseController { @Autowired private MsSignSealService msSignSealService; - /** - * 调解书签名 - */ - @PostMapping("/sureMediationSeal") - public AjaxResult sureMediationSeal(@RequestBody MsCaseApplicationVO caseApplication ) throws EsignDemoException, InterruptedException { - if(caseApplication.getId()==null){ - error("id不能为空"); - } - return msSignSealService.sureMediationSeal(caseApplication); - } + /** * 用印申请 @@ -151,55 +139,5 @@ public class MsSignSealController extends BaseController { return msSignSealService.msCaseSignUrlApplyPC(dto); } - /** - * PC端被申请人签名 - * @param dto - * @return - */ - @PostMapping("/msCaseSignUrlResPC") - public AjaxResult msCaseSignUrlResPC(@RequestBody MsSignSealDTO dto) throws EsignDemoException { - if (dto.getCaseId() == null) { - return error("参数校验失败"); - } - return msSignSealService.msCaseSignUrlResPC(dto); - } - - - /** - * 小程序端申请人签名 - * @param dto - * @return - */ - @PostMapping("/msCaseSignUrlApplyAPP") - public AjaxResult msCaseSignUrlApplyAPP(@RequestBody MsSignSealDTO dto) throws EsignDemoException { - if (dto.getCaseId() == null) { - return error("参数校验失败"); - } - return msSignSealService.msCaseSignUrlApplyAPP(dto); - } - - /** - * 小程序端被申请人签名 - * @param dto - * @return - */ - @PostMapping("/msCaseSignUrlResAPP") - public AjaxResult msCaseSignUrlResAPP(@RequestBody MsSignSealDTO dto) throws EsignDemoException { - if (dto.getCaseId() == null) { - return error("参数校验失败"); - } - return msSignSealService.msCaseSignUrlResAPP(dto); - } - - - - - - - - - - - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsVideoConferenceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsVideoConferenceController.java index 03d6e87..5b83233 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsVideoConferenceController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/mscase/MsVideoConferenceController.java @@ -106,9 +106,9 @@ public class MsVideoConferenceController extends BaseController { */ @Anonymous @GetMapping("secretaryRoleByUserId") - public AjaxResult secretaryRoleByUserId( @RequestParam(value = "userId",required = true) Long userId) { + public AjaxResult secretaryRoleByUserId( @RequestParam(value = "userId",required = true) Long userId,@RequestParam(value = "caseId",required = true) Long caseId) { - return videoService.secretaryRoleByUserId(userId); + return videoService.secretaryRoleByUserId(userId,caseId); } /** * 根据html字符串转pdf并和案件关联 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java index dab65a0..d3cf20f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java @@ -11,6 +11,11 @@ public class CacheConstants * 登录用户 redis key */ public static final String LOGIN_TOKEN_KEY = "login_tokens:"; + /** + * 登录用户名 redis key + */ + + public static final String LOGIN_USERNAME_TOKEN_KEY = "login_username_tokens:"; /** * 验证码 redis key @@ -50,4 +55,16 @@ public class CacheConstants * 所有用户 redis key */ public static final String USER_KEY = "user_key:"; + /** + * 用户邮箱 redis key + */ + public static final String USER_EMAIL_KEY = "user_email_key:"; + /** + * 角色 redis key + */ + public static final String ROLE_KEY = "role_key:"; + /** + * 部门 redis key + */ + public static final String DEPT_KEY = "dept_key:"; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index 4e8981f..b1b5c79 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -141,7 +141,10 @@ public class Constants */ public static final String LOOKUP_LDAPS = "ldaps:"; public static final String DEFAULT_PASSWORD = "123456"; + // 英文逗号分隔符 public static final String SPLIT_COMMA =","; + // 中文逗号分隔符 + public static final String CN_SPLIT_COMMA =","; /** * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNotice.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNotice.java new file mode 100644 index 0000000..f08c5a9 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNotice.java @@ -0,0 +1,26 @@ +package com.ruoyi.common.core.domain.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Classname SMSNotice + * @Description 消息通知 + * @Version 1.0.0 + * @Date 2024/3/26 11:13 + * @Created wangqiong + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SMSNotice { + /** + * 申请人通知 + */ + private SMSNoticeDO applicantNotice; + /** + * 被申通知 + */ + private SMSNoticeDO resNotice; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNoticeDO.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNoticeDO.java new file mode 100644 index 0000000..2eaec15 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SMSNoticeDO.java @@ -0,0 +1,34 @@ +package com.ruoyi.common.core.domain.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Classname SMSNoticeDO + * @Description 消息通知实体 + * @Version 1.0.0 + * @Date 2024/3/26 11:10 + * @Created wangqiong + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SMSNoticeDO { + /** + * 主题 + */ + private String subject; + /** + * 发送内容 + */ + private String content; + /** + * 模板id + */ + private String templateId; + /** + * 模板参数 + */ + private String[] templateParamSet; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java index f98291a..31c8054 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -1,14 +1,15 @@ package com.ruoyi.common.core.domain.entity; -import java.util.ArrayList; -import java.util.List; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; +import java.util.ArrayList; +import java.util.List; /** * 部门表 sys_dept @@ -54,6 +55,31 @@ public class SysDept extends BaseEntity /** 父部门名称 */ private String parentName; + /** + * 代码(统一社会信用代码或者身份证号) + */ + private String code; + + /** + * 法定代表人 + */ + private String compLegalPerson; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getCompLegalPerson() { + return compLegalPerson; + } + + public void setCompLegalPerson(String compLegalPerson) { + this.compLegalPerson = compLegalPerson; + } public Integer getDeptType() { return deptType; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index eb193fc..73e6e16 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -69,6 +69,18 @@ public class SysUser extends BaseEntity /** 国籍,0-国内,1-国外,默认0 */ private Integer nationality; + /** + * 生日 + */ + private Date birth; + /** + * 住所 + */ + private String home; + /** + * 联系地址 + */ + private String address; /** 用户邮箱 */ @Excel(name = "用户邮箱") @@ -140,6 +152,38 @@ public class SysUser extends BaseEntity this.userId = userId; } + public Date getBirth() { + return birth; + } + + public void setBirth(Date birth) { + this.birth = birth; + } + + public String getHome() { + return home; + } + + public void setHome(String home) { + this.home = home; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public List getDepts() { + return depts; + } + + public void setDepts(List depts) { + this.depts = depts; + } + public Integer getIdType() { return idType; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DocumentTypeEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DocumentTypeEnum.java new file mode 100644 index 0000000..0d462ff --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DocumentTypeEnum.java @@ -0,0 +1,18 @@ +package com.ruoyi.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum DocumentTypeEnum { + EVEDENT_METERIAL("EVEDENT_METERIAL", "证据材料", 1), + EVEDENT_APPLY_BOOK("EVEDENT_APPLY_BOOK", "调解申请书", 2), + EVEDENT_MEDIATION_VIDEO("EVEDENT_MEDIATION_VIDEO", "调解视频", 3), + EVEDENT_MEDIATION_RECORD("EVEDENT_MEDIATION_RECORD", "调解笔录", 4), + EVEDENT_AGREEMENT("EVEDENT_AGREEMENT", "调解书或和解协议", 5), + ; + private String code; + private String name; + private Integer value; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java index f4d7539..1769609 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EmailOutUtil.java @@ -1,10 +1,12 @@ package com.ruoyi.common.utils; +import cn.hutool.core.util.StrUtil; import com.ruoyi.common.utils.uuid.UUID; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.mail.MailException; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; @@ -72,17 +74,29 @@ public class EmailOutUtil { * @param subject 邮件主题 * @param content 邮件内容(发送内容) */ - public void sendMessage(String to, String subject, String content, String from, JavaMailSender mailSender) { - // 创建一个邮件对象 - SimpleMailMessage msg = new SimpleMailMessage(); - msg.setFrom(from); - msg.setTo(to); - // 设置邮件主题 - msg.setSubject(subject); - // 设置邮件内容 - msg.setText(content); - // 发送邮件 - mailSender.send(msg); + public Boolean sendMessage(String to, String subject, String content, String from, JavaMailSender mailSender) { + try { + if(mailSender==null){ + rebuildMailSender(); + } + // 创建一个邮件对象 + SimpleMailMessage msg = new SimpleMailMessage(); + if(StrUtil.isEmpty(from)){ + msg.setFrom(usernameOut); + }else { + msg.setFrom(from); + } + msg.setTo(to); + // 设置邮件主题 + msg.setSubject(subject); + // 设置邮件内容 + msg.setText(content); + // 发送邮件 + mailSender.send(msg); + } catch (MailException e) { + return false; + } + return true; ////System.out.println("发送成功:" + from + ":to:" + to); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 9cb1ac1..326e1ce 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -1,5 +1,6 @@ package com.ruoyi.framework.web.service; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.crypto.digest.MD5; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.Constants; @@ -237,9 +238,8 @@ public class SysLoginService user.setUserName(username); user.setPassword(SecurityUtils.encryptPassword("abc123456")); user.setNickName(username); - // 代理人角色相当于申请人角色 - if(loginBody.getRoleName().contains("代理人")){ - loginBody.setRoleName("申请人"); + if(username.contains("@")){ + user.setEmail(username); } // 根据角色名查询角色id Long roleIdByName = roleMapper.selectRoleIdByName(loginBody.getRoleName()); @@ -258,4 +258,26 @@ public class SysLoginService ajax.put(Constants.TOKEN, token); return ajax; } + + /** + * 对接BM,根据用户名查询token + * @param loginBody + * @return + */ + public AjaxResult selectTokenByUserName(LoginBody loginBody) { + String username = loginBody.getUsername(); + String currentTicket = MD5.create().digestHex("BM" + username); + if(!currentTicket.equals(loginBody.getTicket())){ + return AjaxResult.error("ticket校验失败"); + } + + Object cacheObject = redisCache.getCacheObject(CacheConstants.LOGIN_USERNAME_TOKEN_KEY + username); + if(ObjectUtil.isEmpty(cacheObject)){ + return AjaxResult.error("登录时间过长,请重新登录"); + } + + AjaxResult result = AjaxResult.success(); + result.put("token",(String) cacheObject); + return result; + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index 5d4e6ff..9bab643 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -123,7 +123,9 @@ public class TokenService claims.put("userName",loginUser.getUsername()); claims.put("userId",loginUser.getUserId()); claims.put(Constants.LOGIN_USER_KEY, token); - return createToken(claims); + String createToken = createToken(claims); + redisCache.setCacheObject(CacheConstants.LOGIN_USERNAME_TOKEN_KEY+loginUser.getUsername(),createToken, expireTime, TimeUnit.MINUTES); + return createToken; } /** @@ -154,6 +156,7 @@ public class TokenService // 根据uuid将loginUser缓存 String userKey = getTokenKey(loginUser.getToken()); redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); + } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/log/MsRequestLog.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/log/MsRequestLog.java new file mode 100644 index 0000000..dfc47dc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/log/MsRequestLog.java @@ -0,0 +1,55 @@ +package com.ruoyi.system.domain.entity.log; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Getter +@Setter +@ToString +@Table(name = "ms_request_log") +public class MsRequestLog { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * 状态,0-成功,1-失败 + */ + private Integer status; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + + /** + * 请求url + */ + @Column(name = "request_url") + private String requestUrl; + + /** + * 请求内容 + */ + @Column(name = "content") + private String content; + + /** + * 失败原因 + */ + @Column(name = "reason") + private String reason; + /** + * 返回内容 + */ + @Column(name = "return_content") + private String returnContent; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 39f6f2a..1f86de0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -1,9 +1,9 @@ package com.ruoyi.system.mapper; -import java.util.List; - -import org.apache.ibatis.annotations.Param; import com.ruoyi.common.core.domain.entity.SysUser; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 用户表 数据层 @@ -144,11 +144,11 @@ public interface SysUserMapper */ SysUser selectUserByIdCard(@Param("idCard")String identityNo); /** - * 根据手机号查询用户信息 - * @param phone + * 根据邮箱查询用户信息 + * @param email * @return */ - SysUser selectUserByPhone(@Param("phone")String phone); + SysUser selectUserByEmail(@Param("email")String email); /** * 根据部门和角色查询用户 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index 8ea3d50..95439b9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -67,4 +67,11 @@ public interface SysUserRoleMapper * @param roleId */ void insertUserRole(@Param("userId")Long userId, @Param("roleId")Long roleId); + + /** + * 根据用户id查询关联的角色id + * @param userId + * @return + */ + public List selectRoleIdsByUserId(@Param("userId") Long userId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/log/MsRequestLogMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/log/MsRequestLogMapper.java new file mode 100644 index 0000000..9274729 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/log/MsRequestLogMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.log; + +import com.ruoyi.system.domain.entity.log.MsRequestLog; +import tk.mybatis.mapper.common.Mapper; + +public interface MsRequestLogMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/BeiMingInterface.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/BeiMingInterface.java index 6ed7801..e134bc6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/BeiMingInterface.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/BeiMingInterface.java @@ -1,18 +1,15 @@ package com.ruoyi.system.service; import com.alibaba.fastjson.JSONObject; -import com.ruoyi.wisdomarbitrate.domain.entity.casestatus.MsCaseStatus; +import com.ruoyi.common.enums.AttachmentOperateTypeEnum; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo; -import org.apache.ibatis.annotations.Case; -import org.apache.poi.hmef.Attachment; -import org.springframework.web.multipart.MultipartFile; import java.io.File; public interface BeiMingInterface { /** - * 1.获取北明接口令牌token + * 1.获取北明接口令牌token对象 * * @param userName * @param password @@ -73,5 +70,13 @@ public interface BeiMingInterface { * @param caseNo 案件编号 * @return */ - JSONObject pushAttachmentInfo(String username, String password, File file, String abutmentId, String syncSource, String caseNo); + MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo, AttachmentOperateTypeEnum operateTypeEnum); + + /** + * 删除附件 + * @param file + * @param caseNo + * @return + */ + public JSONObject deleteAttachmentInfo( String caseNo,String fileId,String fileName); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/MsRequestLogService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/MsRequestLogService.java new file mode 100644 index 0000000..350f3f5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/MsRequestLogService.java @@ -0,0 +1,14 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.entity.log.MsRequestLog; + +/** + * @Classname MsRequestLogService + * @Description TODO + * @Version 1.0.0 + * @Date 2024/4/2 14:18 + * @Created wangqiong + */ +public interface MsRequestLogService { + void insert(MsRequestLog requestLog); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BeiMingInterfaceService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BeiMingInterfaceService.java index 50ad1c8..e0ad538 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BeiMingInterfaceService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BeiMingInterfaceService.java @@ -5,7 +5,10 @@ import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.ruoyi.common.enums.AttachmentOperateTypeEnum; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.system.domain.entity.log.MsRequestLog; import com.ruoyi.system.service.BeiMingInterface; +import com.ruoyi.system.service.MsRequestLogService; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo; import com.ruoyi.wisdomarbitrate.utils.CommonInputStreamResource; @@ -15,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestClientException; @@ -22,6 +26,8 @@ import org.springframework.web.client.RestTemplate; import java.io.File; import java.io.FileInputStream; +import java.util.Date; +import java.util.Objects; import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt; import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt; @@ -34,6 +40,10 @@ import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt; public class BeiMingInterfaceService implements BeiMingInterface { @Autowired RestTemplate restTemplate; + @Autowired + MsRequestLogService requestLogService; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; /** * 接口地址 */ @@ -46,6 +56,13 @@ public class BeiMingInterfaceService implements BeiMingInterface { public String apiprefix; @Value("${beimingprivatekey}") public String privateKey; + // 北明配置 + @Value("${BMConfig.userName}") + private String BMUserName; + @Value("${BMConfig.password}") + private String BMPassword; + @Value("${BMConfig.syncSource}") + private String BMSyncSource; /** * 1.获取北明接口令牌token @@ -54,9 +71,11 @@ public class BeiMingInterfaceService implements BeiMingInterface { * @param password * @param times */ + @Transactional @Override public String getApiToken(String userName, String password, Long times) { JSONObject result = new JSONObject(); + MsRequestLog requestLog = new MsRequestLog(); try { //设置请求头 HttpHeaders httpHeaders = new HttpHeaders(); @@ -79,13 +98,25 @@ public class BeiMingInterfaceService implements BeiMingInterface { System.out.println("encryptString:" + encryptString); fromEntity = new HttpEntity(body, httpHeaders); String url = apihost + apiprefix + "/getToken"; + + requestLog.setRequestUrl(url); + requestLog.setContent(param.toString()); + requestLog.setCreateTime((new Date())); + requestLog.setStatus(0); result = restTemplate.postForObject(url, fromEntity, JSONObject.class); + requestLog.setReturnContent(result!=null?result.toString():null); } catch (RestClientException e) { e.printStackTrace(); + requestLog.setReason(e.getMessage()); + requestLog.setStatus(1); + requestLogService.insert(requestLog); + throw new ServiceException("推送失败"); } - return result.toString(); + requestLogService.insert(requestLog); + return analysisResultToken(Objects.requireNonNull(result).toString()); } + /** * 解析加密后端token * @@ -97,9 +128,7 @@ public class BeiMingInterfaceService implements BeiMingInterface { if (token != null && !token.isEmpty()) { JSONObject jsonObject = JSON.parseObject(token); String tokenString = jsonObject.getString("data"); - System.out.println("data信息:" + tokenString); String tokenstr = sm4Decrypt(tokenString, privateKey); - System.out.println("解密后的字符串:" + tokenstr); if (tokenstr != null && !tokenstr.isEmpty()) { JSONObject tokenObject = JSON.parseObject(tokenstr); resultToken = tokenObject.getString("token"); @@ -117,9 +146,11 @@ public class BeiMingInterfaceService implements BeiMingInterface { * @param syncSource 同步来源(账户名) * @return */ + @Transactional @Override public JSONObject submitCaseStatusInfo(String token, String abutmentId, String syncSource, MsCaseStatusInfo msCaseStatusInfo) { JSONObject result = new JSONObject(); + MsRequestLog requestLog = new MsRequestLog(); try { //设置请求头 HttpHeaders httpHeaders = new HttpHeaders(); @@ -146,10 +177,20 @@ public class BeiMingInterfaceService implements BeiMingInterface { fromEntity = new HttpEntity(body, httpHeaders); String url = apihost + apiprefix + "/caseMediation/status"; + requestLog.setRequestUrl(url); + requestLog.setContent(param.toString()); + requestLog.setCreateTime((new Date())); + requestLog.setStatus(0); result = restTemplate.postForObject(url, fromEntity, JSONObject.class); + requestLog.setReturnContent(result!=null?result.toString():null); } catch (RestClientException e) { e.printStackTrace(); + requestLog.setReason(e.getMessage()); + requestLog.setStatus(1); + requestLogService.insert(requestLog); + throw new ServiceException("推送失败"); } + requestLogService.insert(requestLog); return result; } @@ -160,11 +201,13 @@ public class BeiMingInterfaceService implements BeiMingInterface { * @param file * @return */ + @Transactional @Override public JSONObject uploadFile(File file, String token, String syncSource) { System.out.println("文件:" + file.getName()); System.out.println("文件:" + file.toString()); JSONObject result = new JSONObject(); + MsRequestLog requestLog = new MsRequestLog(); try { //设置请求头 HttpHeaders httpHeaders = new HttpHeaders(); @@ -184,10 +227,20 @@ public class BeiMingInterfaceService implements BeiMingInterface { requestBody.add("file", commonInputStreamResource); HttpEntity fromEntity = new HttpEntity(requestBody, httpHeaders); String url = apihost + apiprefix + "/uploadFile"; + requestLog.setRequestUrl(url); + requestLog.setContent(fromEntity.toString()); + requestLog.setCreateTime((new Date())); + requestLog.setStatus(0); result = restTemplate.postForObject(url, fromEntity, JSONObject.class); + requestLog.setReturnContent(result!=null?result.toString():null); } catch (RestClientException e) { e.printStackTrace(); + requestLog.setReason(e.getMessage()); + requestLog.setStatus(1); + requestLogService.insert(requestLog); + throw new ServiceException("推送失败"); } + requestLogService.insert(requestLog); return result; } @@ -201,9 +254,11 @@ public class BeiMingInterfaceService implements BeiMingInterface { * @param msCaseFileInfo 案件附件信息 * @return */ + @Transactional @Override public JSONObject syncAttachmentInfo(String token, String syncSource, String action, String caseNo, MsCaseFileInfo msCaseFileInfo) { JSONObject result = new JSONObject(); + MsRequestLog requestLog = new MsRequestLog(); try { //设置请求头 HttpHeaders httpHeaders = new HttpHeaders(); @@ -238,21 +293,31 @@ public class BeiMingInterfaceService implements BeiMingInterface { body.put("encryptString", encryptString); fromEntity = new HttpEntity(body, httpHeaders); String url = apihost + apiprefix + "/caseMediation/attachment/accept"; + requestLog.setRequestUrl(url); + requestLog.setContent(param.toString()); + requestLog.setCreateTime((new Date())); + requestLog.setStatus(0); result = restTemplate.postForObject(url, fromEntity, JSONObject.class); + requestLog.setReturnContent(result!=null?result.toString():null); } catch (RestClientException e) { e.printStackTrace(); + requestLog.setReason(e.getMessage()); + requestLog.setStatus(1); + requestLogService.insert(requestLog); + throw new ServiceException("推送失败"); } + requestLogService.insert(requestLog); return result; } /** * 推送案件状态信息 */ + @Transactional @Override public JSONObject pushCaseStatusInfo(String username, String password, String caseNo, String statusCode, String caseClosureExplanation) { JSONObject result = new JSONObject(); - String token = getApiToken(username, password, System.currentTimeMillis()); - token = analysisResultToken(token); + String token = beiMingInterfaceService.getApiToken(username, password, System.currentTimeMillis()); if (token != null && !token.isEmpty()) { MsCaseStatusInfo info = MsCaseStatusInfo.builder().caseNo(caseNo).statusCode(statusCode).caseClosureExplanation(caseClosureExplanation).build(); result = submitCaseStatusInfo(token, caseNo, username, info); @@ -265,16 +330,16 @@ public class BeiMingInterfaceService implements BeiMingInterface { } return result; } - /** * 推送案件附件信息 */ + @Transactional @Override - public JSONObject pushAttachmentInfo(String username, String password, File file, String abutmentId, String syncSource, String caseNo) { + public MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo,AttachmentOperateTypeEnum operateTypeEnum) { JSONObject result = new JSONObject(); + MsCaseFileInfo fileInfo=null; //1.获取token - String token = getApiToken(username, password, System.currentTimeMillis()); - token = analysisResultToken(token); + String token = beiMingInterfaceService.getApiToken(username, password, System.currentTimeMillis()); if (token != null && !token.isEmpty()) { //2.上传文件 JSONObject fileResult = uploadFile(file, token, syncSource); @@ -289,16 +354,25 @@ public class BeiMingInterfaceService implements BeiMingInterface { System.out.println("fileId====:" + fileId); if (fileId != null) { //3.同步附件更新信息 - MsCaseFileInfo fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(file.getName()).abutmentId(abutmentId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build(); - result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.ADD.getCode(), caseNo, fileInfo); - result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.UPD.getCode(), caseNo, fileInfo); - result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo); + fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(file.getName()).abutmentId(fileId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build(); + result = syncAttachmentInfo(token, username, operateTypeEnum.getCode(), caseNo, fileInfo); + // 更新到附件表将fileId +// result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.UPD.getCode(), caseNo, fileInfo); +// result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo); } } } } } - return result; + return fileInfo; + } + + @Override + public JSONObject deleteAttachmentInfo( String caseNo,String fileId,String fileName) { + String token = beiMingInterfaceService.getApiToken(BMUserName, BMPassword, System.currentTimeMillis()); + MsCaseFileInfo fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(fileName).abutmentId(fileId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build(); + + return syncAttachmentInfo(token, BMUserName, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MsRequestLogServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MsRequestLogServiceImpl.java new file mode 100644 index 0000000..2e3e871 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MsRequestLogServiceImpl.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.entity.log.MsRequestLog; +import com.ruoyi.system.mapper.log.MsRequestLogMapper; +import com.ruoyi.system.service.MsRequestLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Classname MsRequestLogServiceImpl + * @Description TODO + * @Version 1.0.0 + * @Date 2024/4/2 14:19 + * @Created wangqiong + */ +@Service +public class MsRequestLogServiceImpl implements MsRequestLogService { + @Autowired + private MsRequestLogMapper logMapper; + @Override + public void insert(MsRequestLog requestLog) { + logMapper.insert(requestLog); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index e5c8307..ccc6b16 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,17 +1,13 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; @@ -20,6 +16,13 @@ import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.service.ISysDeptService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; /** * 部门管理 服务实现 @@ -34,6 +37,8 @@ public class SysDeptServiceImpl implements ISysDeptService @Autowired private SysRoleMapper roleMapper; + @Autowired + private RedisCache redisCache; /** * 查询部门管理数据 @@ -221,7 +226,9 @@ public class SysDeptServiceImpl implements ISysDeptService } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); } - return deptMapper.insertDept(dept); + int i = deptMapper.insertDept(dept); + redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId()); + return i; } /** @@ -249,6 +256,8 @@ public class SysDeptServiceImpl implements ISysDeptService // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatusNormal(dept); } + // 修改缓存 + redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId()); return result; } @@ -293,6 +302,11 @@ public class SysDeptServiceImpl implements ISysDeptService @Override public int deleteDeptById(Long deptId) { + SysDept sysDept = deptMapper.selectDeptById(deptId); + if(sysDept!=null) { + // 删除缓存 + redisCache.deleteObject(CacheConstants.DEPT_KEY + sysDept.getDeptName()); + } return deptMapper.deleteDeptById(deptId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index d6cee80..c56b093 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,17 +1,12 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; @@ -24,6 +19,12 @@ import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMenuMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.service.ISysRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.stream.Collectors; /** * 角色 业务层处理 @@ -44,6 +45,8 @@ public class SysRoleServiceImpl implements ISysRoleService @Autowired private SysRoleDeptMapper roleDeptMapper; + @Autowired + private RedisCache redisCache; /** * 根据条件分页查询角色数据 @@ -233,6 +236,7 @@ public class SysRoleServiceImpl implements ISysRoleService { // 新增角色信息 roleMapper.insertRole(role); + redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId()); return insertRoleMenu(role); } @@ -250,6 +254,7 @@ public class SysRoleServiceImpl implements ISysRoleService roleMapper.updateRole(role); // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); + redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId()); return insertRoleMenu(role); } @@ -341,10 +346,15 @@ public class SysRoleServiceImpl implements ISysRoleService @Transactional public int deleteRoleById(Long roleId) { + // 根据角色id查询角色名 + SysRole role = roleMapper.selectRoleById(roleId); // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(roleId); // 删除角色与部门关联 roleDeptMapper.deleteRoleDeptByRoleId(roleId); + if(role!=null) { + redisCache.deleteObject(CacheConstants.ROLE_KEY + role.getRoleName()); + } return roleMapper.deleteRoleById(roleId); } @@ -358,6 +368,11 @@ public class SysRoleServiceImpl implements ISysRoleService @Transactional public int deleteRoleByIds(Long[] roleIds) { + List roles = roleMapper.selectRoleList(new SysRole()); + if(CollectionUtil.isEmpty(roles)){ + return 0; + } + Map roleMap = roles.stream().collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName, (n1, n2) -> n2)); for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); @@ -367,6 +382,9 @@ public class SysRoleServiceImpl implements ISysRoleService { throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); } + if(roleMap.containsKey(roleId)) { + redisCache.deleteObject(CacheConstants.ROLE_KEY + roleMap.get(roleId)); + } } // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenu(roleIds); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java index 437a075..efdce9e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAffiliate.java @@ -1,5 +1,6 @@ package com.ruoyi.wisdomarbitrate.domain.entity.mscase; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -7,161 +8,128 @@ import lombok.ToString; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Transient; import java.util.Date; @Getter @Setter @ToString @Table(name = "ms_case_affiliate") -public class MsCaseAffiliate { +public class MsCaseAffiliate{ + /** + * id + */ + @Id + @Column(name = "id") + private Long id; /** * 案件主表id,案件申请表主键 */ - @Id @Column(name = "case_appli_id") private Long caseAppliId; /** - * 是否机构申请,0-自然人,1-申请机构,默认0 + * 用户id,用户表user_id关联 */ - @Column(name = "organize_flag") - private Integer organizeFlag; - - + @Column(name = "user_id") + private Long userId; /** - * 申请人id + * 申请机构id,和部门表id关联 */ - @Column(name = "application_id") - private String applicationId; - - /** - * 申请人名称 - */ - @Column(name = "application_name") - private String applicationName; + @Column(name = "applicant_dept_id") + private Long applicantDeptId; /** * 代码(统一社会信用代码或者身份证号) */ - @Column(name = "code") + @Transient private String code; - /** - * 申请人联系电话 - */ - @Column(name = "application_phone") - private String applicationPhone; - /** - * 申请人邮箱 - */ - @Column(name = "application_email") - private String applicationEmail; /** * 法定代表人 */ - @Column(name = "comp_legal_person") + @Transient private String compLegalPerson; + /** + * 角色类别,1-申请操作人/申请人,2-申请人代理人,3-被申请人操作人/被申请人,4-被申请人代理人 + */ + @Column(name = "role_type") + private Integer roleType=1; + /** + * 组别 + */ + @Column(name = "group_order") + private Integer groupOrder; + /** + * 是否操作人,0-否,1-是 + */ + @Column(name = "operator_flag") + private Integer operatorFlag=1; + /** + * 电话 + */ + @Transient + private String phone; + /** + * 邮箱 + */ + @Transient + private String email; + /** + * 姓名 + */ + @Transient + private String name; + /** + * 住所 + */ + @Transient + private String home; + /** + * 联系地址 + */ + @Transient + private String address; + /** + * 身份证号 + */ + @Transient + private String idCard; /** - * 申请人住所 + * '身份类别,0-身份证,1-护照,默认0' */ - @Column(name = "applicant_home") - private String applicantHome; - + @Transient + private Integer idType; /** - * 申请人联系地址 + * 国籍,0-境内,1-境外,默认0 */ - @Column(name = "applicant_address") - private String applicantAddress; - + @Transient + private Integer nationality; /** - * 委托代理人姓名 + * 生日 */ - @Column(name = "name_agent") - private String nameAgent; - + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Shanghai") + @Transient + private Date birth; /** - * 代理人联系电话 + * 性别,0-男,1-女 */ - @Column(name = "contact_telphone_agent") - private String contactTelphoneAgent; - - /** - * 代理人邮箱 - */ - @Column(name = "agent_email") - private String agentEmail; - - /** - * 申请人快递单号 - */ - @Column(name = "applicant_track_num") - private String applicantTrackNum; - + @Transient + private String sex; /** * 被申请人姓名 */ - @Column(name = "respondent_name") - private String respondentName; + @Transient + private String resName; + /** + * 角色名称 + */ + @Transient + private String roleName; + /** + * 申请机构名称 + */ + @Transient + private String applicantOrgName; - /** - * 被申请人身份证号 - */ - @Column(name = "respondent_identity_num") - private String respondentIdentityNum; - /** - * 被申请人联系电话 - */ - @Column(name = "respondent_phone") - private String respondentPhone; - - /** - * 被申请人性别(0=男,女=1) - */ - @Column(name = "respondent_sex") - private String respondentSex; - - /** - * 被申请人出生年月日 - */ - @Column(name = "respondent_birth") - private Date respondentBirth; - - /** - * 被申请人申请人住所 - */ - @Column(name = "respondent_home") - private String respondentHome; - - /** - * 被申请人邮箱 - */ - @Column(name = "respondent_email") - private String respondentEmail; - - /** - * 被申请人快递单号 - */ - @Column(name = "respondent_track_num") - private String respondentTrackNum; - - /** - * 申请人是否签收 - */ - @Column(name = "is_sign_apply") - private Integer isSignApply; - /** - * 被申请人是否签收 - */ - @Column(name = "is_sign_respon") - private Integer isSignRespon; - /** - * 身份类别,0-身份证,1-护照,默认0 - */ - @Column(name = "id_type") - private Integer idType; - /** - * 国籍,0-国内,1-国外,默认0 - */ - @Column(name = "nationality") - private Integer nationality; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseApplication.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseApplication.java index 62ba0da..16c08cb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseApplication.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseApplication.java @@ -6,10 +6,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.math.BigDecimal; import java.util.Date; @@ -208,5 +205,20 @@ public class MsCaseApplication { */ @Column(name = "is_reconci") private Integer isReconci; + /** + * 是否机构申请,0-自然人,1-申请机构,默认0 + */ + @Column(name = "organize_flag") + private Integer organizeFlag; + /** + * 案件来源,YC-乙巢,空字符串-北明 + */ + @Column(name = "case_source") + private String caseSource; + /** + * 拒绝原因 + */ + @Transient + private String rejectReason; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAttach.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAttach.java index b0c4c49..287db7b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAttach.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/entity/mscase/MsCaseAttach.java @@ -77,4 +77,9 @@ public class MsCaseAttach { */ @Column(name = "only_office_file_id") private String onlyOfficeFileId; + /** + * 对接其它系统返回的附件id + */ + @Column(name = "other_sys_file_id") + private String otherSysFileId; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateBase.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateBase.java new file mode 100644 index 0000000..e5c5e02 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateBase.java @@ -0,0 +1,32 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.mscase; + +import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate; +import lombok.Data; + +/** + * @Classname MsCaseAffiliateList + * @Description TODO + * @Version 1.0.0 + * @Date 2024/3/27 16:08 + * @Created wangqiong + */ +@Data +public class MsCaseAffiliateBase { + /** + * 申请人/操作人 + */ + private MsCaseAffiliate applicant; + /** + * 申请人代理人 + */ + private MsCaseAffiliate applicantAgent; + /** + * 被申请人/操作人 + */ + private MsCaseAffiliate res; + /** + * 被申请人代理人 + */ + private MsCaseAffiliate resAgent; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateParent.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateParent.java new file mode 100644 index 0000000..0c9943c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateParent.java @@ -0,0 +1,11 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.mscase; + +/** + * @Classname MsCaseAffiliateParent + * @Description TODO + * @Version 1.0.0 + * @Date 2024/3/27 16:05 + * @Created wangqiong + */ +public class MsCaseAffiliateParent extends MsCaseAffiliateVO { +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateVO.java new file mode 100644 index 0000000..1627382 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseAffiliateVO.java @@ -0,0 +1,32 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.mscase; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * @Classname MsCaseAffiliateVO + * @Description TODO + * @Version 1.0.0 + * @Date 2024/3/22 11:46 + * @Created wangqiong + */ +@Getter +@Setter +@ToString +@Data +public class MsCaseAffiliateVO { + /** + * 申请人/操作人 + */ + private List applicant; + + /** + * 被申请人/操作人 + */ + private List res; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java index 7e98510..1628f50 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationReq.java @@ -107,5 +107,18 @@ public class MsCaseApplicationReq { * 代理人电话 */ private String contactTelphoneAgent; + /** + * 邮箱 + */ + private String resEmail; + /** + * 申请人邮箱 + */ + private String email; + /** + * 角色类别 + */ + private Integer roleType; + private Long userId; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationVO.java index e814d11..107ca6a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationVO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseApplicationVO.java @@ -1,7 +1,6 @@ package com.ruoyi.wisdomarbitrate.domain.vo.mscase; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; import lombok.AllArgsConstructor; @@ -34,7 +33,7 @@ public class MsCaseApplicationVO extends MsCaseApplication { /** * 案件相关人员 */ - private MsCaseAffiliate affiliate; + private MsCaseAffiliateVO affiliate; /** * 是否压缩包导入,默认false */ @@ -84,5 +83,17 @@ public class MsCaseApplicationVO extends MsCaseApplication { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") private Date endTime; + /** + * 是否申请操作人,0-否,1-是 + */ + private Integer appOperatorFlag; + /** + * 是否被申请操作人,0-否,1-是 + */ + private Integer resOperatorFlag; + /** + * 是否财务,部门长,秘书,0-否,1-是 + */ + private Integer otherFlag; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAffiliateMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAffiliateMapper.java index c05d979..d721fb6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAffiliateMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAffiliateMapper.java @@ -1,7 +1,30 @@ package com.ruoyi.wisdomarbitrate.mapper.mscase; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate; +import org.apache.ibatis.annotations.Param; import tk.mybatis.mapper.common.Mapper; +import java.util.List; + public interface MsCaseAffiliateMapper extends Mapper { + /** + * 查询申请人被申请人 + * @param caseIds + * @return + */ + List listGroupConcat(@Param("caseIds") List caseIds); + + /** + * 根据案件id查询案件人员 + * @param id + * @return + */ + List selectByCaseId(@Param("id") Long id); + + /** + * 根据案件id查询相关人员及角色 + * @param id + * @return + */ + List selectUserRoleByCaseIds(@Param("caseIds") List caseIds); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java index 61ef9d7..6780ee2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseApplicationMapper.java @@ -29,125 +29,14 @@ public interface MsCaseApplicationMapper extends Mapper { " ") Integer selectCaseNumLike(@Param("caseNum") String caseNum, @Param("length") int length); - /** + /** * 案件列表查询 * @param req - * @param caseStatusNames + * @param caseFlowIds * @return */ - @Select("") - List list(@Param("req")MsCaseApplicationReq req, @Param("caseStatusNames") List caseStatusNames); + List list(@Param("req")MsCaseApplicationReq req, @Param("caseFlowIds") List caseFlowIds , @Param("roleIds") List roleIds ); /** * 查询调解员列表 @@ -162,46 +51,5 @@ public interface MsCaseApplicationMapper extends Mapper { @Select("select max(room_id) maxRoomId from ms_reserved_conference") Long selectMaxRoomId(); - /** - * 待办数量 - * @param o - * @return - */ - @Select(" " - ) - List todoCount(@Param("req")MsCaseApplicationReq req, @Param("caseStatusNames") List caseStatusNames); + List todoCount(@Param("req")MsCaseApplicationReq req, @Param("caseFlowIds") List caseFlowIds, @Param("roleIds") List roleIds); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java index c3c8d03..e34709e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCaseApplicationService.java @@ -1,9 +1,13 @@ package com.ruoyi.wisdomarbitrate.service.mscase; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SMSNotice; +import com.ruoyi.common.core.domain.entity.SMSNoticeDO; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.enums.PushCaseStatusEnum; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; @@ -49,6 +53,20 @@ public interface MsCaseApplicationService { * @return */ String insert(MsCaseApplicationVO caseApplication); + /** + * 设置案件相关信息 + * @param caseApplication + * @param affiliate + * @param groupOrder 组别 + */ + public void setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder); + /** + * 新增案件相关人员信息 + * @param affiliate 相关人员信息 + * @param roleId 角色id + + */ + public void insertAfficateUser(MsCaseAffiliate affiliate, List roleIdList); /** * 新增案件 @@ -62,13 +80,7 @@ public interface MsCaseApplicationService { * @return */ AjaxResult batchInsert(MsCaseBatchInsertVO vo); - /** - * 新增用户 - * @param affiliate - * @param agentFlag 是否代理人,0-否,1-是 - * @param roleId - */ - void insertApplicantUser( MsCaseAffiliate affiliate,boolean agentFlag, Long roleId); + /** * 新增申请机构代理人 * @param affiliate @@ -150,6 +162,13 @@ public interface MsCaseApplicationService { * @return */ AjaxResult submit(MsCaseApplication req); + /** + * 北明推送案件状态 + * @param caseApplication 案件 + * @param pushCaseStatusEnum 案件状态 + * @return + */ + public JSONObject pushStatusToBM(MsCaseApplication caseApplication, PushCaseStatusEnum pushCaseStatusEnum); /** * 删除案件 * @param req @@ -204,22 +223,16 @@ public interface MsCaseApplicationService { AjaxResult updateTrialPen(MsCaseAttach attach); - /** - * 确认调解书 - * @param attach - * @return - */ - AjaxResult confirmMediation(MsCaseAttachVO attach) throws EsignDemoException, InterruptedException ; /** * 生成调解申请书 * @param application 案件基本信息 - * @param affiliate 案件相关人员 + * @param affiliates 案件相关人员 * @param templatePath 模板路径 * @param bookmarkList 标签 * @param dictDataList 内置字段 */ - void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List bookmarkList, List dictDataList, Integer templateType) ; + void createMediateApplication(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList, Integer templateType) ; /** * 调解书上传到onlyoffice服务器 * @param annexPath @@ -231,8 +244,15 @@ public interface MsCaseApplicationService { * @param req * @param affiliateMap */ - void accept(MsCaseApplication application, MsCaseApplicationVO req, Map affiliateMap) ; + void accept(MsCaseApplication application, MsCaseApplicationVO req, Map> affiliateMap) ; /** + * 受理分配通知 + * @param application 案件基本信息 + * @param affiliates 案件人员 + * @param applicantFlag 是否申请人 + */ + public void isAcceptNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag); + /** * 判断申请人/被申请人是否预约 * @param vo * @param userIds 选择的调解员ids @@ -268,4 +288,49 @@ public interface MsCaseApplicationService { */ AjaxResult saveOnlyOfficeFile(MsCaseAttach caseAttach); + /** + * 发送短信 + * @param smsFlag 短信是否发送成功 + * @param application 案件基本信息 + * @param affiliate 案件人员 + * @param sendContent 发送内容 + */ + public void sendSMS(Boolean smsFlag ,MsCaseApplication application, MsCaseAffiliate affiliate, String sendContent); + /** + * 发送邮件 + * @param application 案件基本信息 + * @param affiliate 案件人员 + * @param subject 主题 + * @param sendContent 内容 + */ + public void sendEmail(MsCaseApplication application, MsCaseAffiliate affiliate, String subject, String sendContent); + /** + * 发送开庭日期短信 + * @param application + * @param affiliates + */ + public void sendHearDateSms(MsCaseApplication application, List affiliates); + /** + * 发送短信 + * @param application + * @param affiliate + * @param notice + */ + public void sendNotice(MsCaseApplication application, MsCaseAffiliate affiliate, + SMSNoticeDO notice); + /** + * 申请操作人/被申操作人发送通知 + * @param application + * @param affiliates + * @param applicantFlag + * @param notice + */ + public void sendNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag, + SMSNotice notice); + /** + * 根据案件id查询案件相关人员 + * @param id + * @return + */ + public List selectAffliatesByCaseId(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCasePaymentService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCasePaymentService.java index f51d36f..faf1ca3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCasePaymentService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/MsCasePaymentService.java @@ -64,4 +64,11 @@ public interface MsCasePaymentService { */ public void confirmPayment(MsCaseFlow currentFlow,MsCaseFlow nextFlow, MsCaseApplication application, CaseConfirmPayDTO dto); + + /** + * 发送受理短信 + * @param dto + * @param caseAppllication + */ + public void sendAcceptSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication,String userName,String phone ); } 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 e364b3c..5fe23f2 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 @@ -4,7 +4,6 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.MsSignSealDTO; 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; @@ -13,7 +12,7 @@ import java.util.List; public interface MsSignSealService { - AjaxResult sureMediationSeal(MsCaseApplicationVO caseApplication) throws EsignDemoException, InterruptedException; + AjaxResult sealApply(MsSignSealDTO dto); @@ -30,12 +29,6 @@ public interface MsSignSealService { AjaxResult msCaseSignUrlApplyPC(MsSignSealDTO dto) throws EsignDemoException; - AjaxResult msCaseSignUrlResPC(MsSignSealDTO dto) throws EsignDemoException; - - AjaxResult msCaseSignUrlApplyAPP(MsSignSealDTO dto) throws EsignDemoException; - - AjaxResult msCaseSignUrlResAPP(MsSignSealDTO dto) throws EsignDemoException; - AjaxResult signSeaalCaseApplicaCallback(String reqbodystr) throws EsignDemoException, IOException; AjaxResult sealCheckCallback(String reqbodystr) throws EsignDemoException, IOException; diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/VideoConferenceService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/VideoConferenceService.java index b29be4c..7355d46 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/VideoConferenceService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/VideoConferenceService.java @@ -44,7 +44,7 @@ public interface VideoConferenceService { * @param userId * @return */ - AjaxResult secretaryRoleByUserId(Long userId); + AjaxResult secretaryRoleByUserId(Long userId, Long caseId); /** * 根据html字符串转pdf并和案件关联 diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java index 9dc3503..5fe3ec4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCaseApplicationServiceImpl.java @@ -2,6 +2,8 @@ package com.ruoyi.wisdomarbitrate.service.mscase.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; @@ -12,14 +14,13 @@ import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.*; import com.ruoyi.common.core.domain.model.LoginUser; -import com.ruoyi.common.enums.AnnexTypeEnum; -import com.ruoyi.common.enums.MediatorTypeEnum; -import com.ruoyi.common.enums.TemplateTypeEnum; -import com.ruoyi.common.enums.YesOrNoEnum; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.enums.*; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.*; @@ -30,9 +31,11 @@ import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated; import com.ruoyi.system.mapper.*; import com.ruoyi.system.mapper.flow.MsCaseFlowMapper; import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper; +import com.ruoyi.system.service.impl.BeiMingInterfaceService; import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify; import com.ruoyi.wisdomarbitrate.domain.dto.dept.SealManage; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.SealSignRecord; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule; import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage; @@ -43,6 +46,7 @@ import com.ruoyi.wisdomarbitrate.mapper.dept.DeptIdentifyMapper; import com.ruoyi.wisdomarbitrate.mapper.dept.MsSealSignRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.dept.SealManageMapper; import com.ruoyi.wisdomarbitrate.mapper.mscase.*; +import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.template.FatchRuleMapper; import com.ruoyi.wisdomarbitrate.mapper.template.TemplateManageMapper; @@ -94,6 +98,13 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { private String arbitrateUrl; @Value("${onlyOfficeConfig.url}") private String onlyOfficeUrl; + // 北明配置 + @Value("${BMConfig.userName}") + private String BMUserName; + @Value("${BMConfig.password}") + private String BMPassword; + @Value("${BMConfig.syncSource}") + private String BMSyncSource; @Autowired MsCaseApplicationService caseApplicationService; @Autowired @@ -148,6 +159,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { private MsSealSignRecordMapper sealSignRecordMapper; @Autowired private MsCaseAuditMapper auditMapper; + @Autowired + private RedisCache redisCache; + @Autowired + private EmailOutUtil emailOutUtil; + @Autowired + private SendMailRecordMapper sendMailRecordMapper; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + @Value("${beimingprivatekey}") + public String privateKey; // 案件基本字段 public static final List CASE_BASE_COLUMN = Arrays.asList("caseSubjectAmount", "arbitratClaims", "facts", "requestRule"); public static final SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd"); @@ -160,23 +181,25 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { */ @Override public List list(MsCaseApplicationReq req) { - + // 是否调解员 + boolean isMediatorRole=false; // 根据用户查询角色 LoginUser loginUser = SecurityUtils.getLoginUser(); // 根据id查询用户 SysUser sysUser = sysUserMapper.selectUserById(loginUser.getUserId()); - List roles = loginUser.getUser().getRoles(); - if (StrUtil.equals(SecurityUtils.getUsername(), "admin")||CollectionUtil.isEmpty(roles)) { - // 如果角色为空,按admin处理,查所有案件 + List roles = sysUser.getRoles(); + req.setUserName(sysUser.getUserName()); + if (StrUtil.equals(SecurityUtils.getUsername(), "admin")) { startPage(); - List list = msCaseApplicationMapper.list(req, null); - for (MsCaseApplicationVO vo : list) { - vo.setSignButtonFlag(0); - } + List list = msCaseApplicationMapper.list(req, null,null); + // 设置申请人被申请人及签名按钮限 + setAfflicate(isMediatorRole,list,loginUser.getUserId(),roles); return list; } - req.setUserName(SecurityUtils.getUsername()); - req.setContactTelphoneAgent(sysUser.getPhonenumber()); + if(CollectionUtil.isEmpty(roles) ){ + throw new RuntimeException("用户未分配角色,请联系管理员"); + } + List roleIds = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); // 根据角色查询关联的案件状态 Example example = new Example(MsCaseFlowRoleRelated.class); example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList())); @@ -191,64 +214,134 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (CollectionUtil.isEmpty(caseFlows)) { throw new ServiceException("该角色为绑定案件流程"); } - // Map flowMap = caseFlows.stream().collect(Collectors.toMap(MsCaseFlow::getButtonAuthFlag, Function.identity())); - List caseStatusNames = caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()); - // 是否调解员 - boolean isMediatorRole=false; - // 如果是申请人,可以看见申请人为自己(即自然人)或者委托代理人为自己的案件(即机构) + List caseFlowIds = caseFlows.stream().map(MsCaseFlow::getId).collect(Collectors.toList()); + // 是否查询所有 + boolean isSelectAll = false; + for (SysRole role : roles) { if(StrUtil.isNotEmpty(role.getRoleName())){ - if(StrUtil.equals(role.getRoleName(),"申请人")) { - List applicationOrganIds=new ArrayList<>(); - applicationOrganIds.add(sysUser.getUserId()); - caseStatusNames.add("待调解"); - req.setApplicantFlag(1); - // 根据用户查询部门ids - List deptList = sysDeptMapper.selectDeptByUserId(loginUser.getUserId()); - if(CollectionUtil.isNotEmpty(deptList)) { - List deptIds = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()); - applicationOrganIds.addAll(deptIds); - - } - req.setApplicationOrganIds(applicationOrganIds); - break; - } - if(StrUtil.equals(role.getRoleName(),"被申请人")){ - caseStatusNames.add("待调解"); - req.setRespondentIdentityNum(sysUser.getIdCard()); - break; + if(StrUtil.contains(role.getRoleName(),"财务") + ||StrUtil.contains(role.getRoleName(),"法律顾问") + ||StrUtil.contains(role.getRoleName(),"部门长") + ){ + isSelectAll=true; + roleIds=null; } if(StrUtil.equals(role.getRoleName(),"调解员")) { isMediatorRole=true; req.setMediatorId(String.valueOf(sysUser.getUserId())); - break; } } } + if(!isSelectAll){ + req.setUserId(loginUser.getUserId()); + } if(req.getMediationMethod()!=null){ // 查询视频审理 req.setCaseFlowId(9); } startPage(); + // 查询案件列表 - List list = msCaseApplicationMapper.list(req, caseStatusNames); - if (CollectionUtil.isNotEmpty(list)) { - // 判断调解员签名按钮权限,0-显示,1-不显示 - for (MsCaseApplicationVO vo : list) { - // 如果是调解员并且是和解协议并且是代签名状态,不显示 - if (isMediatorRole && vo.getMediaResult()!=null && vo.getMediaResult()==5 && vo.getCaseStatusName().equals("待签名")) { - // 是调解员并且是和解协议,不显示 - vo.setSignButtonFlag(1); - - }else { - vo.setSignButtonFlag(0); - } - } - - } + List list = msCaseApplicationMapper.list(req, caseFlowIds,roleIds); + // 设置申请人被申请人及签名按钮限 + setAfflicate(isMediatorRole,list,loginUser.getUserId(),roles); return list; } + /** + * 设置申请人被申请人及签名按钮限 + * @param isMediatorRole 是否调解员 + * @param list + * @param loginUserId 当前登录用户id + */ + private void setAfflicate(boolean isMediatorRole,List list,Long loginUserId, List roles ) { + if(CollectionUtil.isEmpty(list)){ + return; + } + // 查询申请人和被申请人 + List caseIds = list.stream().map(MsCaseApplicationVO::getId).collect(Collectors.toList()); + + + List affiliateList = msCaseAffiliateMapper.selectUserRoleByCaseIds(caseIds); + // 根据案件id分组 + Map> affiliateMap=null; + if(CollectionUtil.isNotEmpty(affiliateList)){ + affiliateMap = affiliateList.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getCaseAppliId)); + } + + for (MsCaseApplicationVO vo : list) { + // 设置申请人和被申请人 + if(affiliateMap!=null && affiliateMap.containsKey(vo.getId())){ + List affiliates = affiliateMap.get(vo.getId()); + StringBuilder applicantName = new StringBuilder(); + StringBuilder respondentName = new StringBuilder(); + for (MsCaseAffiliate affiliate : affiliates) { + // 当前用户是操作人 + if(affiliate.getUserId()!=null && affiliate.getUserId().equals(loginUserId) + && affiliate.getRoleType()!=null && affiliate.getOperatorFlag()!=null && affiliate.getOperatorFlag()==1) { + if (vo.getAppOperatorFlag() == null && (affiliate.getRoleType()==1 || affiliate.getRoleType()==2)) { + // 设置申请操作人标记 + vo.setAppOperatorFlag(1); + + } + if (vo.getResOperatorFlag() == null && (affiliate.getRoleType()==3 || affiliate.getRoleType()==4)) { + // 设置被申请操作人标记 + vo.setResOperatorFlag(1); + + } + } + if(StrUtil.isNotEmpty(affiliate.getRoleName()) && affiliate.getRoleName().equals("申请人") + && affiliate.getRoleType()!=null && affiliate.getRoleType()==1){ + applicantName.append(affiliate.getName()).append(Constants.CN_SPLIT_COMMA); + } + if(StrUtil.isNotEmpty(affiliate.getRoleName()) && affiliate.getRoleName().equals("被申请人") + && affiliate.getRoleType()!=null && affiliate.getRoleType()==3){ + respondentName.append(affiliate.getName()).append(Constants.CN_SPLIT_COMMA); + } + + } + vo.setApplicationName(removeLastComma(applicantName.toString(),Constants.CN_SPLIT_COMMA)); + vo.setRespondentName(removeLastComma(respondentName.toString(),Constants.CN_SPLIT_COMMA)); + } + // 判断调解员签名按钮权限,0-显示,1-不显示,如果是调解员并且是和解协议并且是代签名状态,不显示 + if (isMediatorRole && vo.getMediaResult()!=null && vo.getMediaResult()==5 && vo.getCaseStatusName().equals("待签名")) { + // 是调解员并且是和解协议,不显示 + vo.setSignButtonFlag(1); + + }else { + vo.setSignButtonFlag(0); + } + for (SysRole role : roles) { + if(StrUtil.isNotEmpty(role.getRoleName())){ + if(StrUtil.contains(role.getRoleName(),"财务") + ||StrUtil.contains(role.getRoleName(),"法律顾问") + ||StrUtil.contains(role.getRoleName(),"部门长") + ||StrUtil.contains(role.getRoleName(),"调解员") + ){ + vo.setOtherFlag(1); + } + + } + } + } + } + + /** + * 去除字符串末尾特殊字符 + * @param input 字符串 + * @param str 去除字符串末尾的特殊字符 + * @return + */ + public String removeLastComma(String input,String str) { + if(StrUtil.isEmpty(input)){ + return input; + } + if (input.endsWith(str)) { + return input.substring(0, input.length() - 1); + } + return input; // 如果没有末尾逗号,则直接返回原字符串 + } /** * 首页代办数量 * @return @@ -256,96 +349,93 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Override public CaseToDoCountVO todoCount() { CaseToDoCountVO vo = new CaseToDoCountVO(); - List selectTodoList=null; + List selectTodoList = null; // 根据用户查询角色 LoginUser loginUser = SecurityUtils.getLoginUser(); // 根据id查询用户 SysUser sysUser = sysUserMapper.selectUserById(loginUser.getUserId()); - List roles = loginUser.getUser().getRoles(); - - // 根据角色查询关联的案件状态 - Example example = new Example(MsCaseFlowRoleRelated.class); - - // 如果是admin,查询所有案件流程 - if (CollectionUtil.isNotEmpty(roles)) { - example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList())); - } - - List caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example); - if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) { - throw new ServiceException("该角色为绑定案件流程"); - } + List roles =sysUser.getRoles(); + // 查询所有流程 Example flowExample = new Example(MsCaseFlow.class); flowExample.setOrderByClause("sort asc"); - flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList())); - List caseFlows = caseFlowMapper.selectByExample(flowExample); - if (CollectionUtil.isEmpty(caseFlows)) { - throw new ServiceException("该角色为绑定案件流程"); + List allCaseFlows = caseFlowMapper.selectByExample(flowExample); + if (CollectionUtil.isEmpty(allCaseFlows)) { + throw new ServiceException("未配置案件流程"); } - MsCaseApplicationReq req=new MsCaseApplicationReq(); + List caseFlows = allCaseFlows; + MsCaseApplicationReq req = new MsCaseApplicationReq(); if (StrUtil.equals(SecurityUtils.getUsername(), "admin")) { - selectTodoList= msCaseApplicationMapper.todoCount( req,null); - }else { + selectTodoList = msCaseApplicationMapper.todoCount(req, null, null); + } else { + if (CollectionUtil.isEmpty(roles)) { + throw new RuntimeException("用户未分配角色,请联系管理员"); + } + List roleIds = roles.stream().map(SysRole::getRoleId).collect(Collectors.toList()); + // 根据角色查询关联的案件状态 + Example example = new Example(MsCaseFlowRoleRelated.class); + example.createCriteria().andIn("roleid", roles.stream().map(SysRole::getRoleId).collect(Collectors.toList())); + List caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example); + if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) { + throw new ServiceException("该角色未配置案件流程,请联系管理员"); + } + flowExample = new Example(MsCaseFlow.class); + flowExample.setOrderByClause("sort asc"); + flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList())); + caseFlows = caseFlowMapper.selectByExample(flowExample); + if (CollectionUtil.isEmpty(caseFlows)) { + throw new ServiceException("该角色未配置案件流程,请联系管理员"); + } + List caseFlowIds = caseFlows.stream().map(MsCaseFlow::getId).collect(Collectors.toList()); + // 是否查询所有案件 + boolean isSelectAll = false; + // 查询案件列表 - req.setUserName(SecurityUtils.getUsername()); - req.setContactTelphoneAgent(sysUser.getPhonenumber()); - - List caseStatusNames = caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()); - // 如果是申请人,可以看见申请人为自己(即自然人)或者委托代理人为自己的案件(即机构) for (SysRole role : roles) { - if (StrUtil.isNotEmpty(role.getRoleName())) { - if (StrUtil.equals(role.getRoleName(), "申请人")) { - List applicationOrganIds = new ArrayList<>(); - applicationOrganIds.add(sysUser.getUserId()); - caseStatusNames.add("待调解"); - req.setApplicantFlag(1); - // 根据用户查询部门ids - List deptList = sysDeptMapper.selectDeptByUserId(loginUser.getUserId()); - if (CollectionUtil.isNotEmpty(deptList)) { - List deptIds = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()); - applicationOrganIds.addAll(deptIds); + if(StrUtil.contains(role.getRoleName(),"财务") + ||StrUtil.contains(role.getRoleName(),"法律顾问") + ||StrUtil.contains(role.getRoleName(),"部门长") + ){ + isSelectAll = true; + roleIds=null; - } - req.setApplicationOrganIds(applicationOrganIds); - break; - } - if (StrUtil.equals(role.getRoleName(), "被申请人")) { - caseStatusNames.add("待调解"); - req.setRespondentIdentityNum(sysUser.getIdCard()); - break; - } + } + if (StrUtil.isNotEmpty(role.getRoleName())) { if (StrUtil.equals(role.getRoleName(), "调解员")) { req.setMediatorId(String.valueOf(sysUser.getUserId())); - break; + } } } + // 如果多个角色中有财务,顾问,部门长,则调解员查询所有 + if(!isSelectAll){ + req.setUserId(loginUser.getUserId()); + } if (req.getMediationMethod() != null) { // 查询视频审理 req.setCaseFlowId(9); } - // 查询案件列表 - selectTodoList = msCaseApplicationMapper.todoCount(req, caseStatusNames); + + selectTodoList = msCaseApplicationMapper.todoCount(req, caseFlowIds, roleIds); } // 设置每个案件节点的数量 List toDoCountList = new ArrayList<>(); - Map todoMap =null; - if(CollectionUtil.isNotEmpty(selectTodoList)){ - todoMap = selectTodoList.stream().collect(Collectors.toMap(CaseToDoCount::getCaseFlowId, CaseToDoCount::getCaseCount, (n1, n2) -> n2)); + Map todoMap = null; + if (CollectionUtil.isNotEmpty(selectTodoList)) { + todoMap = selectTodoList.stream().collect(Collectors.toMap(CaseToDoCount::getCaseFlowId, CaseToDoCount::getCaseCount, (n1, n2) -> n2)); } for (MsCaseFlow caseFlow : caseFlows) { - if(StrUtil.isEmpty(caseFlow.getCaseStatusName())||StrUtil.equals(caseFlow.getCaseStatusName(),"结束")){ + if (StrUtil.isEmpty(caseFlow.getCaseStatusName()) || StrUtil.equals(caseFlow.getCaseStatusName(), "结束")) { continue; } CaseToDoCount caseToDoCount = new CaseToDoCount(); caseToDoCount.setCaseFlowId(caseFlow.getId()); caseToDoCount.setCaseStatusName(caseFlow.getCaseStatusName()); caseToDoCount.setFileName(caseFlow.getFileName()); - if(null==todoMap){ + if (null == todoMap) { caseToDoCount.setCaseCount(0L); - }else { + } else { caseToDoCount.setCaseCount(todoMap.getOrDefault(caseFlow.getId(), 0L)); } toDoCountList.add(caseToDoCount); @@ -373,14 +463,70 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { Example example = new Example(MsCaseApplication.class); example.createCriteria().andEqualTo("caseNum", caseNum); caseApplication = msCaseApplicationMapper.selectOneByExample(example); + id=caseApplication.getId(); } if(caseApplication==null){ return vo; } BeanUtil.copyProperties(caseApplication, vo); - // 查询案件相关人员 - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); - vo.setAffiliate(caseAffiliate); + // 根据案件id查询案件相关人员 + List msCaseAffiliates = selectAffliatesByCaseId(id); + MsCaseAffiliateVO affiliateVO = new MsCaseAffiliateVO(); + if(CollectionUtil.isNotEmpty(msCaseAffiliates)) { + Map> affliateMap = msCaseAffiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getGroupOrder, Collectors.toList())); + + List applicantList = new ArrayList<>(); + List resList = new ArrayList<>(); + affiliateVO.setApplicant(applicantList); + affiliateVO.setRes(resList); + affliateMap.forEach((k,v)->{ + MsCaseAffiliateBase affiliateBase = null; + + MsCaseAffiliateBase resBase = null; + + for (MsCaseAffiliate affiliate : v) { + + switch (affiliate.getRoleType()){ + case 1: + if(affiliateBase==null){ + affiliateBase = new MsCaseAffiliateBase(); + } + affiliateBase.setApplicant(affiliate); + break; + case 2: + if(affiliateBase==null){ + affiliateBase = new MsCaseAffiliateBase(); + } + affiliateBase.setApplicantAgent(affiliate); + break; + case 3: + if(resBase==null){ + resBase = new MsCaseAffiliateBase(); + } + resBase.setRes(affiliate); + break; + case 4: + if(resBase==null){ + resBase = new MsCaseAffiliateBase(); + } + resBase.setResAgent(affiliate); + break; + default: + + break; + } + + } + if(affiliateBase!=null){ + applicantList.add(affiliateBase); + } + if(resBase!=null){ + resList.add(resBase); + } + }); + } + // todo + vo.setAffiliate(affiliateVO); // 查询附件 List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id); vo.setCaseAttachList(caseAttachList); @@ -394,6 +540,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return vo; } + /** + * 根据案件id查询案件相关人员 + * @param id + * @return + */ + public List selectAffliatesByCaseId(Long id) { + + return msCaseAffiliateMapper.selectByCaseId(id); + } + /** * 新增案件 * @@ -404,13 +560,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Override public String insert(MsCaseApplicationVO caseApplication) { - - // todo 第三方调用该接口,未绑定角色,暂时不根据角色查询流程,根据角色获取案件流程 - /** List caseFlows= selectCaseFlows(); - if (CollectionUtil.isEmpty(caseFlows)) { - throw new ServiceException("该角色未绑定案件流程"); - } - */ // 设置模板id,根据机构代码查询模板 Long templateId = getTemplate(); caseApplication.setTemplateId(templateId); @@ -429,6 +578,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Transactional @Override public String insert(MsCaseApplicationVO caseApplication, MsCaseFlow caseFlow) { + MsCaseAffiliateVO msCaseAffiliateVO = caseApplication.getAffiliate(); + if (null==msCaseAffiliateVO) { + throw new ServiceException("案件相关人员未填写"); + } if (caseApplication.getId() == null) { caseApplication.setId(IdWorkerUtil.getId()); } @@ -447,37 +600,32 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseApplication.setCreateBy(SecurityUtils.getUsername()); caseApplication.setUpdateBy(SecurityUtils.getUsername()); caseApplication.setVersion(1); - MsCaseAffiliate affiliate = caseApplication.getAffiliate(); - affiliate.setCaseAppliId(caseApplication.getId()); + + // 保存案件基本信息 if (msCaseApplicationMapper.insertSelective(caseApplication) > 0) { List caseAttachList = caseApplication.getCaseAttachList(); // 保存案件相关人员 - // 设置申请机构 - if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) { - // 组装申请机构 - // insertDept(affiliate); - // 新增申请机构和代理人 - caseApplicationService.insertAgentUser(affiliate); - }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){ - // 查询申请人角色id - Long roleId = roleMapper.selectRoleIdByName("申请人"); - caseApplicationService.insertApplicantUser(affiliate,false,roleId); - caseApplicationService.insertApplicantUser(affiliate,true,roleId); + List applicant = msCaseAffiliateVO.getApplicant(); + List res = msCaseAffiliateVO.getRes(); + if(CollectionUtil.isNotEmpty(applicant)){ + for (int i = 0; i < applicant.size(); i++) { + // 申请人 + setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i); + // 申请人代理人 + setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i); + } + } + if(CollectionUtil.isNotEmpty(res)){ + for (int i = 0; i < res.size(); i++) { + // 申请人 + setCaseAfflicate(caseApplication, res.get(i).getRes(),i); + // 申请人代理人 + setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i); + } + } - } - // 压缩包导入,则根据身份证号获取性别和出生日期 - if (caseApplication.isImportFlag() && StrUtil.isNotEmpty(affiliate.getRespondentIdentityNum())) { - setBirthByIdentityNum(affiliate); - } - if (StrUtil.isNotEmpty(affiliate.getAgentEmail())) { - affiliate.setAgentEmail(affiliate.getAgentEmail().replace("\n", "").replaceAll("\\s", "")); - } - if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) { - affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", "")); - } - msCaseAffiliateMapper.insert(affiliate); // 批量生成调解申请书 MsCaseApplicationReq req = new MsCaseApplicationReq(); req.setCaseFlowId(caseFlow.getId()); @@ -488,7 +636,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { req.setBatchNumber(caseApplication.getBatchNumber()); } // 生成调解申请书 - if(affiliate.getOrganizeFlag()==0){ + if(caseApplication.getOrganizeFlag()==0){ // 自然人 req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); }else { @@ -525,6 +673,178 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return ""; } + /** + * 设置案件相关信息 + * @param caseApplication + * @param affiliate + */ + @Transactional + public void setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder) { + if(affiliate==null || StrUtil.isEmpty(affiliate.getEmail()) || StrUtil.isEmpty(affiliate.getName())){ + return; + } + affiliate.setGroupOrder(groupOrder); + // 获取角色缓存 + Object commonCacheObj = redisCache.getCacheObject(CacheConstants.ROLE_KEY + "申请人操作人"); + Object RespondentCacheObj = redisCache.getCacheObject(CacheConstants.ROLE_KEY + "被申请人操作人"); + Object applicantObj = redisCache.getCacheObject(CacheConstants.ROLE_KEY + "申请人"); + Object respondentCacheObj = redisCache.getCacheObject(CacheConstants.ROLE_KEY + "被申请人"); + Object agentCacheObj = redisCache.getCacheObject(CacheConstants.ROLE_KEY + "委托代理人"); + + if(commonCacheObj==null || applicantObj==null || RespondentCacheObj==null || respondentCacheObj==null){ + throw new ServiceException("角色不全,请联系管理员新增角色"); + } + affiliate.setCaseAppliId(caseApplication.getId()); + List roleIdList = new ArrayList<>(); + // Long roleId = null; + + switch (affiliate.getRoleType()) { + case 1: + roleIdList.add((Long) applicantObj); + if (affiliate.getOperatorFlag() == 1) { + // 是操作人 + roleIdList.add( (Long) commonCacheObj); + } + break; + case 2: + // 申请代理人 + roleIdList.add((Long) agentCacheObj); + if (affiliate.getOperatorFlag() == 1) { + // 是操作人 + roleIdList.add( (Long) commonCacheObj); + } + break; + case 3: + roleIdList.add((Long) respondentCacheObj); + if (affiliate.getOperatorFlag() == 1) { + // 是操作人 + roleIdList.add( (Long) RespondentCacheObj); + } + + break; + case 4: + roleIdList.add((Long) agentCacheObj); + if (affiliate.getOperatorFlag() == 1) { + // 是操作人 + roleIdList.add( (Long) RespondentCacheObj); + } + break; + default: + + break; + } + // 如果是申请人,则和用户表关联 + if (caseApplication.getOrganizeFlag() == 0) { + caseApplicationService.insertAfficateUser(affiliate, roleIdList); + } else { + // 申请机构 + if (affiliate.getRoleType() == 1) { + // 申请人,从缓存中判断部门是否存在 + Object deptCache = redisCache.getCacheObject(CacheConstants.DEPT_KEY + affiliate.getName()); + if (ObjectUtil.isEmpty(deptCache)) { + // 不存在该部门,新增 + SysDept dept = new SysDept(); + dept.setParentId(0L); + dept.setDeptName(affiliate.getName()); + dept.setAncestors("0"); + dept.setOrderNum(1); + dept.setStatus("0"); + dept.setDelFlag("0"); + dept.setCode(affiliate.getCode()); + dept.setCompLegalPerson(affiliate.getCompLegalPerson()); + dept.setCreateBy(getUsername()); + dept.setUpdateBy(getUsername()); + sysDeptMapper.insertDept(dept); + // 更新缓存 + redisCache.setCacheObject(CacheConstants.DEPT_KEY + dept.getDeptName(), dept.getDeptId()); + } + affiliate.setApplicantDeptId(redisCache.getCacheObject(CacheConstants.DEPT_KEY + affiliate.getName())); + } else { + caseApplicationService.insertAfficateUser(affiliate, roleIdList); + } + } + // 保存人员 + msCaseAffiliateMapper.insert(affiliate); + } + + /** + * 新增案件相关人员信息 + * @param affiliate 相关人员信息 + * @param roleIdList 角色id + + */ + @Transactional + public void insertAfficateUser(MsCaseAffiliate affiliate, List roleIdList) { + + if(StrUtil.isEmpty(affiliate.getEmail())){ + return; + } + Object userEmailCache = redisCache.getCacheObject(CacheConstants.USER_EMAIL_KEY + affiliate.getEmail()); + SysUser user=null; + if(ObjectUtil.isEmpty(userEmailCache)){ + user = sysUserMapper.selectUserByUserName(affiliate.getEmail()); + }else { + user=(SysUser)userEmailCache; + } + + + // 判断该用户是否存在 + if(user==null){ + // 不存在,则新增 + user = new SysUser(); + user.setPassword(SecurityUtils.encryptPassword("abc123456")); + user.setUserName(affiliate.getEmail()); + user.setNickName(affiliate.getName()); + user.setEmail(affiliate.getEmail()); + user.setHome(affiliate.getHome()); + user.setSex(affiliate.getSex()); + user.setIdCard(affiliate.getIdCard()); + user.setBirth(affiliate.getBirth()); + user.setPhonenumber(affiliate.getPhone()); + user.setAddress(affiliate.getAddress()); + user.setIdType(affiliate.getIdType()); + user.setNationality(affiliate.getNationality()); + userMapper.insertUser(user); + affiliate.setUserId(user.getUserId()); + // 更新缓存 + redisCache.setCacheObject(CacheConstants.USER_EMAIL_KEY + affiliate.getEmail(),user); + // 查询该角色是否存在申请人角色 + List roleIds = userRoleMapper.selectRoleIdsByUserId(user.getUserId()); + for (Long roleId : roleIdList) { + if(CollectionUtil.isEmpty(roleIds) && !roleIds.contains(roleId) ){ + userRoleMapper.insertUserRole(user.getUserId(),roleId); + } + } + + // todo 发短信,有电话给电话发,没有电话给邮箱发 + + }else { + // 存在的话将案件人员信息同步到用户表,更新用户表 + user.setHome(affiliate.getHome()); + user.setNickName(affiliate.getName()); + user.setSex(affiliate.getSex()); + user.setIdCard(affiliate.getIdCard()); + user.setBirth(affiliate.getBirth()); + user.setPhonenumber(affiliate.getPhone()); + user.setAddress(affiliate.getAddress()); + user.setIdType(affiliate.getIdType()); + user.setNationality(affiliate.getNationality()); + user.setEmail(affiliate.getEmail()); + userMapper.updateUser(user); + affiliate.setUserId(user.getUserId()); + // 更新缓存 + redisCache.setCacheObject(CacheConstants.USER_EMAIL_KEY + affiliate.getEmail(),user); + // 查询该角色是否存在申请人角色 + List roleIds = userRoleMapper.selectRoleIdsByUserId(user.getUserId()); + for (Long roleId : roleIdList) { + if (CollectionUtil.isEmpty(roleIds) || !roleIds.contains(roleId)) { + userRoleMapper.insertUserRole(user.getUserId(), roleId); + } + } + + } + } + /** * 获取第一个流程节点 * @return @@ -576,66 +896,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return success; } - /** - * 新增用户 - * @param affiliate - * @param agentFlag 是否代理人,0-否,1-是 - * @param roleId - */ - @Transactional - public void insertApplicantUser( MsCaseAffiliate affiliate,boolean agentFlag, Long roleId) { - String phone=""; - String name=""; - if(agentFlag){ - // 代理人 - phone=affiliate.getContactTelphoneAgent(); - name=affiliate.getNameAgent(); - }else { - // 申请人 - phone=affiliate.getApplicationPhone(); - name=affiliate.getApplicationName(); - } - if(StrUtil.isNotEmpty(phone) && StrUtil.isNotEmpty(name)){ - // 查询用户是否存在 - SysUser sysUser = sysUserMapper.selectUserByPhone(phone); - if(sysUser==null){ - // 新增用户 - sysUser = new SysUser(); - sysUser.setUserName(phone); - sysUser.setNickName(name); - sysUser.setPhonenumber(phone); - sysUser.setPassword(SecurityUtils.encryptPassword("abc123456")); - sysUser.setIdType(affiliate.getIdType()); - sysUser.setNationality(affiliate.getNationality()); - sysUser.setCreateBy(SecurityUtils.getUsername()); - userMapper.insertUser(sysUser); - userRoleMapper.insertUserRole(sysUser.getUserId(), roleId); - // 发送短信 2064355 调解系统自动创建用户短信通知 尊敬的用户,您的案件已经创建,请使用账号为{1},密码为{2}登录调解系统,请知晓,如非本人操作,请忽略本短信。 - Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2064355", phone, new String[]{phone, "abc123456"}); - - }else { - // 用户不为空,查询角色是否为申请人 - if (CollectionUtil.isNotEmpty(sysUser.getRoles())) { - List longList = sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()); - if (!longList.contains(roleId)) { - userRoleMapper.insertUserRole(sysUser.getUserId(), roleId); - } - } else { - userRoleMapper.insertUserRole(sysUser.getUserId(), roleId); - } - - } - if(!agentFlag){ - // 自然人,将用户id设为申请人id - affiliate.setApplicationId(String.valueOf(sysUser.getUserId())); - affiliate.setApplicationName(sysUser.getNickName()); - - } - - - } - } /** * 查询案件流程 @@ -686,6 +947,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Transactional @Override public AjaxResult update(MsCaseApplicationVO caseApplication) { + MsCaseAffiliateVO msCaseAffiliateVO = caseApplication.getAffiliate(); + if (msCaseAffiliateVO==null) { + return AjaxResult.error("案件相关人员未填写"); + } // 计算仲裁费用 caseApplication.setCaseSubjectAmount(new BigDecimal("30000")); setFeePayableMethod(caseApplication); @@ -693,28 +958,32 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseApplication.setUpdateTime(new Date()); // 为null则不更新 msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication); - MsCaseAffiliate affiliate = caseApplication.getAffiliate(); - if (affiliate == null) { - return AjaxResult.error("案件相关人员未填写"); - } - affiliate.setCaseAppliId(caseApplication.getId()); - // 设置申请人 - if (StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==1) { - // 组装申请机构 - // insertDept(affiliate); - // 新增申请机构代理人 - caseApplicationService.insertAgentUser(affiliate); - }else if(StrUtil.isNotEmpty(affiliate.getApplicationName())&&affiliate.getOrganizeFlag()==0){ - // 查询申请人角色id - Long roleId = roleMapper.selectRoleIdByName("申请人"); - caseApplicationService.insertApplicantUser(affiliate,false,roleId); - caseApplicationService.insertApplicantUser(affiliate,true,roleId); + // 保存案件相关人员 + // 删除已存在的人员 + Example affliateExample = new Example(MsCaseAffiliate.class); + affliateExample.createCriteria().andEqualTo("caseAppliId", caseApplication.getId()); + msCaseAffiliateMapper.deleteByExample(affliateExample); + + + List applicant = msCaseAffiliateVO.getApplicant(); + List res = msCaseAffiliateVO.getRes(); + if(CollectionUtil.isNotEmpty(applicant)){ + for (int i = 0; i < applicant.size(); i++) { + // 申请人 + setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i); + // 申请人代理人 + setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i); + } } - if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) { - affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", "")); + if(CollectionUtil.isNotEmpty(res)){ + for (int i = 0; i < res.size(); i++) { + // 申请人 + setCaseAfflicate(caseApplication, res.get(i).getRes(),i); + // 申请人代理人 + setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i); + } } - msCaseAffiliateMapper.updateByPrimaryKeySelective(affiliate); if (CollectionUtil.isNotEmpty(caseApplication.getCaseAttachList())) { for (MsCaseAttach caseAttach : caseApplication.getCaseAttachList()) { @@ -737,7 +1006,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { MsCaseApplicationReq req = new MsCaseApplicationReq(); req.setCaseFlowId(caseFlow.getId()); req.setId(caseApplication.getId()); - if(affiliate.getOrganizeFlag()==0){ + if(caseApplication.getOrganizeFlag()==0){ // 自然人 req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); }else { @@ -870,7 +1139,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { BeanUtil.copyProperties(caseApplication, caseApplicationVO); // 组装附件 buildAttach(fileMap, caseApplicationVO, attachList); - caseApplicationVO.setAffiliate(affiliate); + ArrayList msCaseAffiliates = new ArrayList<>(); + msCaseAffiliates.add(affiliate); + // todo 结构发生变化,需要改相关人员设置 +// caseApplicationVO.setAffiliate(msCaseAffiliates); caseApplicationVO.setCaseAttachList(attachList); caseApplicationVO.setColumnValueList(columnValueList); caseApplicationVO.setImportFlag(true); @@ -966,408 +1238,39 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { fileMap.put(inFile.getName(), inFile.getAbsolutePath()); } if (!fileMap.isEmpty()) { - + List applicantList = new ArrayList<>(); + List resList = new ArrayList<>(); + MsCaseAffiliateBase applicantBase = new MsCaseAffiliateBase(); + MsCaseAffiliateBase resBase = new MsCaseAffiliateBase(); + applicantList.add(applicantBase); + resList.add(resBase); // 根据抓取规则设置字段值 for (Map.Entry> entry : fatchRuleMap.entrySet()) { getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue()); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } if (fatchMap.size() > 0) { - MsCaseAffiliate affiliate = new MsCaseAffiliate(); + List affiliateVOS = new ArrayList(); + MsCaseAffiliateVO affiliateVO = new MsCaseAffiliateVO(); + // 申请机构 + MsCaseAffiliate applicant = new MsCaseAffiliate(); + applicant.setRoleType(1); + applicant.setGroupOrder(1); + applicant.setOperatorFlag(null); + applicantBase.setApplicant(applicant); + // 申请人代理人 + MsCaseAffiliate applicantAgent = new MsCaseAffiliate(); + applicantAgent.setRoleType(2); + applicantAgent.setGroupOrder(1); + applicantBase.setApplicantAgent(applicantAgent); + // 被申请人 + MsCaseAffiliate res = new MsCaseAffiliate(); + res.setRoleType(3); + res.setGroupOrder(1); + resBase.setRes(res); + // 被申代理人 + MsCaseAffiliate resAgent = new MsCaseAffiliate(); + resBase.setResAgent(resAgent); + resAgent.setRoleType(4); // 组装案件内置字段 for (SysDictData dictData : dictDataList) { // 主表字段 @@ -1375,18 +1278,41 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { ObjectFieldUtils.setValue(caseApplication, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); } else { // 相关人员字段 - ObjectFieldUtils.setValue(affiliate, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); + // 申请机构字段 + if(dictData.getDictLabel().contains("被申请人")){ + ObjectFieldUtils.setValue(res, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); + }else if(dictData.getDictLabel().contains("被申请人委托代理人")){ + ObjectFieldUtils.setValue(resAgent, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); + }else if(dictData.getDictLabel().contains("申请人") + || dictData.getDictLabel().equals("统一社会信用代码") + || dictData.getDictLabel().equals("法定代表人") + ){ + ObjectFieldUtils.setValue(applicant, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); + }else if(dictData.getDictLabel().contains("委托代理人")){ + ObjectFieldUtils.setValue(applicantAgent, dictData.getDictValue(), fatchMap.get(dictData.getDictLabel())); + } + } } - // 识别身份证回显性别和出生年月日 - setBirthByIdentityNum(affiliate); + + affiliateVO.setApplicant(applicantList); + + // 如果身份证不为空,设置生日和性别 + if(StrUtil.isNotEmpty(res.getIdCard())){ + setBirthByIdentityNum(res); + } + affiliateVO.setRes(resList); BeanUtil.copyProperties(caseApplication, caseApplicationVO); - caseApplicationVO.setAffiliate(affiliate); + affiliateVOS.add(affiliateVO); + //todo + caseApplicationVO.setAffiliate(affiliateVO); + caseApplicationVO.setOrganizeFlag(1); } } } return AjaxResult.success(caseApplicationVO); + } /** @@ -1394,7 +1320,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { * @param affiliate */ private void setBirthByIdentityNum(MsCaseAffiliate affiliate) { - String identityNum = affiliate.getRespondentIdentityNum(); + String identityNum = affiliate.getIdCard(); if(StrUtil.isNotEmpty(identityNum)){ // 识别身份证回显性别和出生年月日 identityNum = identityNum.replace("\n", ""); @@ -1408,10 +1334,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { } catch (Exception e) { e.printStackTrace(); } - affiliate.setRespondentBirth(birthdayDate); + affiliate.setBirth(birthdayDate); } //从身份证抓取性别 - affiliate.setRespondentSex(identityNumMap.get("sexCode")); + affiliate.setSex(identityNumMap.get("sexCode")); } } } @@ -1471,12 +1397,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // 循环生成调解申请书 for (MsCaseApplication application : caseApplicationList) { - // 案件相关人员 - MsCaseAffiliate affiliate = affiliateMap.get(application.getId()); - if(affiliate==null){ - continue; - } - caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType()); + // todo 批量的未改案件相关人员,结构已发生变化 +// MsCaseAffiliate affiliate = affiliateMap.get(application.getId()); +// if(affiliate==null){ +// continue; +// } + // caseApplicationService.createMediateApplication(application, affiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType()); } }else { @@ -1484,12 +1410,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // 根据案件id查询案件信息 MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId()); // 查询案件关联人员 - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId()); - if (application == null || caseAffiliate == null) { + List msCaseAffiliates = selectAffliatesByCaseId(req.getId()); + if (application == null || msCaseAffiliates == null) { throw new ServiceException("该案件不存在"); } - caseApplicationService.createMediateApplication(application, caseAffiliate, templatePath, bookmarkList,dictDataList,req.getTemplateType()); + caseApplicationService.createMediateApplication(application, msCaseAffiliates, templatePath, bookmarkList,dictDataList,req.getTemplateType()); } @@ -1567,6 +1493,28 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { e.printStackTrace(); return AjaxResult.error("上传失败"); } + // todo 对接北明,调用上传附件接口 + MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id); + if(caseApplication==null){ + return AjaxResult.error("案件不存在"); + } + if(StrUtil.isEmpty(caseApplication.getCaseSource()) && CollectionUtil.isNotEmpty(successList)) { + // todo + + for (MsCaseAttach caseAttach : successList) { + if(StrUtil.isEmpty(caseAttach.getAnnexPath())){ + continue; + } + String templatePath = "/home/ruoyi" + caseAttach.getAnnexPath(); + File file = new File(templatePath.replace("/profile", "/uploadPath")); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplication.getCaseNum(),AttachmentOperateTypeEnum.ADD); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttach(caseAttach); + } + } + } return AjaxResult.success("上传成功", successList); } @@ -1579,31 +1527,31 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Override public AjaxResult accept(MsCaseApplicationVO req) { if (StrUtil.isNotEmpty(req.getBatchNumber())) { - // 根据批号查询未锁定的案件 - List applicationList = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId()); - if (CollectionUtil.isEmpty(applicationList)) { - return AjaxResult.error("该批次号下未找到案件"); - } - // 查询案件关联人员 - Example example = new Example(MsCaseAffiliate.class); - example.createCriteria().andIn("caseAppliId", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList())); - List affiliateList = msCaseAffiliateMapper.selectByExample(example); - if (CollectionUtil.isEmpty(affiliateList)) { - return AjaxResult.error("该批次号下未找到案件"); - } - Map affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity())); - for (MsCaseApplication application : applicationList) { - // 不受理 - if(req.getAgreeFlag().equals(YesOrNoEnum.NO.getCode())){ - if(StrUtil.isEmpty(req.getRejectReason())){ - throw new ServiceException("请填写拒绝原因"); - } - caseApplicationService.notAccept(String.valueOf(req.getId()),req.getRejectReason()); - }else { - caseApplicationService.accept(application,req,affiliateMap); - } - - } + // todo,结构发生变化,暂时不改批量操作,根据批号查询未锁定的案件 +// List applicationList = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId()); +// if (CollectionUtil.isEmpty(applicationList)) { +// return AjaxResult.error("该批次号下未找到案件"); +// } +// // 查询案件关联人员 +// Example example = new Example(MsCaseAffiliate.class); +// example.createCriteria().andIn("caseAppliId", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList())); +// List affiliateList = msCaseAffiliateMapper.selectByExample(example); +// if (CollectionUtil.isEmpty(affiliateList)) { +// return AjaxResult.error("该批次号下未找到案件"); +// } +// Map affiliateMap = affiliateList.stream().collect(Collectors.toMap(MsCaseAffiliate::getCaseAppliId, Function.identity())); +// for (MsCaseApplication application : applicationList) { +// // 不受理 +// if(req.getAgreeFlag().equals(YesOrNoEnum.NO.getCode())){ +// if(StrUtil.isEmpty(req.getRejectReason())){ +// throw new ServiceException("请填写拒绝原因"); +// } +// caseApplicationService.notAccept(String.valueOf(req.getId()),req.getRejectReason()); +// }else { +// caseApplicationService.accept(application,req,affiliateMap); +// } +// +// } } else { // 不受理 @@ -1616,14 +1564,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { // 查询案件信息 MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId()); // 根据案件id查询案件相关人 - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId()); - if (application==null||caseAffiliate == null) { + List msCaseAffiliates = selectAffliatesByCaseId(req.getId()); + if (application==null||CollectionUtil.isEmpty(msCaseAffiliates)) { return AjaxResult.error("该案件不存在"); } // 锁定该案件 application.setLockStatus(YesOrNoEnum.YES.getCode()); - Map affiliateMap=new HashMap<>(); - affiliateMap.put(req.getId(),caseAffiliate); + Map> affiliateMap=new HashMap<>(); + affiliateMap.put(req.getId(),msCaseAffiliates); caseApplicationService.accept(application,req,affiliateMap); } @@ -1638,44 +1586,139 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { * @param affiliateMap */ @Transactional - public void accept(MsCaseApplication application, MsCaseApplicationVO req, Map affiliateMap) { + public void accept(MsCaseApplication application, MsCaseApplicationVO req, Map> affiliateMap) { application.setPaperFlag(req.getPaperFlag()); application.setArbitrateConfirm(req.getArbitrateConfirm()); application.setMediationMethod(req.getMediationMethod()); application.setUpdateBy(SecurityUtils.getUsername()); application.setUpdateTime(new Date()); application.setBatchNumber(null); - msCaseApplicationMapper.updateByPrimaryKeySelective(application); - MsCaseFlow caseFlow = caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus()); // 给被申请人发送短信 if (affiliateMap.containsKey(application.getId())) { - MsCaseAffiliate affiliate = affiliateMap.get(application.getId()); - // 被申请人发送短信 - if (StrUtil.isNotEmpty(affiliate.getRespondentPhone())) { - String sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信"; - // 给被申请人发送案件受理短信 2074247 待缴费通知 尊敬的用户,您编号为{1}的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信 - Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2074247", affiliate.getRespondentPhone(), new String[]{ application.getCaseNum()}); - // CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getNodeName(), "向被申请人发送短信," + sendContent); - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getRespondentPhone(), new Date(), sendContent); - if (smsFlag) { - // 发送成功 - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + List affiliates = affiliateMap.get(application.getId()); + // todo 被申请人发送短信 + // 被申受理分配通知 + SMSNoticeDO resNotice = new SMSNoticeDO("待缴费通知", + "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信。", + "2074247", + new String[]{application.getCaseNum()} + ); + SMSNotice notice = new SMSNotice(null,resNotice); + caseApplicationService.sendNotice(application,affiliates,false,notice); + } + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus()); + } + + /** + * 受理分配通知 + * @param application 案件基本信息 + * @param affiliates 案件人员 + * @param applicantFlag 是否申请人 + */ + @Override + @Transactional + public void isAcceptNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag) { + + for (MsCaseAffiliate affiliate : affiliates) { + if(applicantFlag==null || applicantFlag) { + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + String sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信"; + String subject = "待缴费通知"; + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(affiliate.getPhone())) { + // 发送短信 + // 给被申请人发送案件受理短信 2074247 待缴费通知 尊敬的用户,您编号为{1}的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信 + Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2074247", affiliate.getPhone(), new String[]{application.getCaseNum()}); + sendSMS(smsFlag,application, affiliate, sendContent); + + } else { + // 发送邮件 + sendEmail(application, affiliate, subject, sendContent); + + } + } + } + if(applicantFlag==null || !applicantFlag) { + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + // 拒绝原因 + String rejectReason = application.getRejectReason() == null ? "" : application.getRejectReason(); + String subject = "案件不受理通知"; + String sendContent = "尊敬的用户,您编号为" + application.getCaseNum() + "的案件由于"+rejectReason+"所以不予受理,请知晓,如非本人操作,请忽略本短信。"; + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(affiliate.getPhone())) { + Boolean smsFlag = SmsUtils.sendSms(application.getId(), "2065809", affiliate.getPhone(), + new String[]{application.getCaseNum(), rejectReason}); + // 发送短信 + sendSMS(smsFlag,application, affiliate, sendContent); + + } else { + // 发送邮件 + sendEmail(application, affiliate, subject, sendContent); + + } } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); } } } + + /** + * 发送邮件 + * @param application 案件基本信息 + * @param affiliate 案件人员 + * @param subject 主题 + * @param sendContent 内容 + */ + @Override + @Transactional + public void sendEmail(MsCaseApplication application, MsCaseAffiliate affiliate, String subject, String sendContent) { + boolean emailFlag = emailOutUtil.sendMessage(affiliate.getEmail(), subject, sendContent, null, null); + + SendMailRecord sendMailRecord = new SendMailRecord(); + sendMailRecord.setCaseId(application.getId()); + sendMailRecord.setMailAddress(affiliate.getEmail()); + sendMailRecord.setMailContent(sendContent); + sendMailRecord.setMailName(subject); + sendMailRecord.setSendTime(new Date()); + sendMailRecord.setCreateBy(SecurityUtils.getUsername()); + if (emailFlag) { + sendMailRecord.setSendStatus(1); + } else { + sendMailRecord.setSendStatus(0); + } + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); + } + + /** + * 发送短信 + * @param smsFlag 短信是否发送成功 + * @param application 案件基本信息 + * @param affiliate 案件人员 + * @param sendContent 发送内容 + */ + @Override + @Transactional + public void sendSMS(Boolean smsFlag ,MsCaseApplication application, MsCaseAffiliate affiliate, String sendContent) { + SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), affiliate.getPhone(), new Date(), sendContent); + if (smsFlag) { + // 发送成功 + smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(smsSendRecord); + } + /** * 案件提交 * @param req * @return */ @Override + @Transactional public AjaxResult submit(MsCaseApplication req) { if(StrUtil.isNotEmpty(req.getBatchNumber())){ - // 批量提交 + // todo 暂时不改,批量提交 List list = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId()); if(CollectionUtil.isEmpty(list)){ return AjaxResult.error("该批次号下未找到案件"); @@ -1684,11 +1727,51 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { MsCaseFlow caseFlow = caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode()); } }else { + MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(req.getId()); + if(caseApplication==null){ + return AjaxResult.error("未找到案件"); + } + // 查询案件人员 + List affiliates = selectAffliatesByCaseId(req.getId()); + if(CollectionUtil.isEmpty(affiliates)){ + return AjaxResult.error("未找到案件人员"); + } + List operatorList = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() != null && affiliate.getOperatorFlag().equals(1)).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(operatorList)){ + return AjaxResult.error("未找到案件操作人员"); + } + long applicantCount = operatorList.stream().filter(affiliate -> (affiliate.getRoleType() != null) && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).count(); + long resCount = operatorList.stream().filter(affiliate -> (affiliate.getRoleType() != null) && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).count(); + if(applicantCount==0 && resCount==0){ + return AjaxResult.error("申请人操作人、被申请人操作人手机号不存在,请修改案件信息"); + }else if(applicantCount==0 ){ + return AjaxResult.error("申请人操作人手机号不存在,请修改案件信息"); + }else if( resCount==0){ + return AjaxResult.error("被申请人操作人手机号不存在,请修改案件信息"); + } MsCaseFlow caseFlow = caseApplicationService.nextFlow(req.getId(), req.getCaseFlowId(), YesOrNoEnum.NO.getCode()); - + // TODO 案件来源如果是空,则为北明案件,提交完向北明推送案件状态 + caseApplicationService.pushStatusToBM(caseApplication, PushCaseStatusEnum.MEDIATE); } return AjaxResult.success("提交成功"); } + + /** + * 北明推送案件状态 + * @param caseApplication 案件 + * @param pushCaseStatusEnum 案件状态 + * @return + */ + @Transactional + public JSONObject pushStatusToBM(MsCaseApplication caseApplication, PushCaseStatusEnum pushCaseStatusEnum){ + // 案件来源如果是空,则为北明案件,提交完向北明推送案件状态 + if(StrUtil.isEmpty(caseApplication.getCaseSource())) { + String BMToken = beiMingInterfaceService.getApiToken(BMUserName, BMPassword, System.currentTimeMillis()); + MsCaseStatusInfo info = MsCaseStatusInfo.builder().caseNo(caseApplication.getCaseNum()).statusCode(pushCaseStatusEnum.getCode()).caseClosureExplanation(pushCaseStatusEnum.getName()).build(); + return beiMingInterfaceService.submitCaseStatusInfo(BMToken, caseApplication.getCaseNum(), BMSyncSource, info); + } + return null; + } @Transactional @Override public AjaxResult delete(MsCaseApplication req) { @@ -1771,25 +1854,77 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseMap = caseApplicationList.stream().collect(Collectors.groupingBy(MsCaseApplication::getMediatorId, Collectors.toList())); } if(caseAppliId!=null) { + // 查询该用户是否是操作人,是申请操作人还是被申请操作人 + List affiliates = msCaseAffiliateMapper.selectByCaseId(caseAppliId); + if(CollectionUtil.isEmpty(affiliates)){ + return AjaxResult.error("未找到案件相关人员"); + } // 根据案件id和用户id查询已选择的调解员进行回显 Example example = new Example(MsCaseMediator.class); Example.Criteria criteria = example.createCriteria(); LoginUser loginUser = SecurityUtils.getLoginUser(); - if (loginUser != null && loginUser.getUser() != null && CollectionUtil.isNotEmpty(loginUser.getUser().getRoles())) { - for (SysRole role : loginUser.getUser().getRoles()) { - if (role.getRoleName().equals("被申请人")) { - criteria.andEqualTo("type", YesOrNoEnum.YES.getCode()); - } else if (role.getRoleName().equals("申请人")) { + +// if (loginUser.getUser() != null ) { +// // 查询角色 +// List roles = roleMapper.selectRolesByUserName(loginUser.getUser().getUserName()); +// if (CollectionUtil.isNotEmpty(roles)) { +// for (SysRole role : roles) { +// if (role.getRoleName().contains("被申请人")) { +// criteria.andEqualTo("type", YesOrNoEnum.YES.getCode()); +// break; +// } else if (role.getRoleName().contains("申请人")) { +// criteria.andEqualTo("type", YesOrNoEnum.NO.getCode()); +// break; +// } else if (role.getRoleName().contains("委托代理人")) { +// +// List operatorList = affiliates.stream().filter(affiliate -> +// affiliate.getOperatorFlag() != null && affiliate.getOperatorFlag() == 1 && affiliate.getRoleType() != null).collect(Collectors.toList()); +// if (CollectionUtil.isNotEmpty(operatorList)) { +// Map> map = operatorList.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getUserId)); +// if (map.containsKey(loginUser.getUserId())) { +// List msCaseAffiliates = map.get(loginUser.getUserId()); +// for (MsCaseAffiliate affiliate : msCaseAffiliates) { +// // 申请人 +// if (affiliate.getRoleType() == 1 || affiliate.getRoleType() == 2) { +// criteria.andEqualTo("type", YesOrNoEnum.NO.getCode()); +// break; +// } else if (affiliate.getRoleType() == 3 || affiliate.getRoleType() == 4) { +// criteria.andEqualTo("type", YesOrNoEnum.YES.getCode()); +// break; +// } +// } +// } +// } +// } +// } +// } +// +// criteria.andEqualTo("caseAppliId", caseAppliId); +// // 已选择的调解员 +// List selectedMediators = msCaseMediatorMapper.selectByExample(example); +// selectedMediatorIds = selectedMediators.stream().map(MsCaseMediator::getMediatorId).collect(Collectors.toList()); +// } + for (MsCaseAffiliate affiliate : affiliates) { + if(affiliate.getUserId().equals(loginUser.getUser().getUserId())){ + if( affiliate.getRoleType()==null){ + continue; + } + if(affiliate.getRoleType()==1|| affiliate.getRoleType()==2){ + // 申请人 criteria.andEqualTo("type", YesOrNoEnum.NO.getCode()); } + if(affiliate.getRoleType()==3|| affiliate.getRoleType()==4){ + // 申请人 + criteria.andEqualTo("type", YesOrNoEnum.YES.getCode()); + } } } - criteria.andEqualTo("caseAppliId", caseAppliId); // 已选择的调解员 List selectedMediators = msCaseMediatorMapper.selectByExample(example); selectedMediatorIds = selectedMediators.stream().map(MsCaseMediator::getMediatorId).collect(Collectors.toList()); } + for (SysUser user : users) { MediatorVO mediatorVO = new MediatorVO(); mediatorVO.setMediatorId(user.getUserId()); @@ -1821,27 +1956,67 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { */ @Transactional public AjaxResult updateBooking(BookingVO vo) { - // 查询案件相关人员 - MsCaseAffiliate msCaseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(vo.getId()); - if (msCaseAffiliate == null) { - return AjaxResult.error("该案件不存在"); - } // 查询当前节点 MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(vo.getCaseFlowId()); if (currentFlow == null) { return AjaxResult.error("当前流程不存在"); } - // Integer miniProgressFlag = vo.getMiniProgressFlag() == null ? MediatorTypeEnum.PC.getCode() : vo.getMiniProgressFlag(); // 预约,申请人预约为Null,否则为被申请人预约 Integer miniProgressFlag=YesOrNoEnum.NO.getCode(); - List roles = SecurityUtils.getLoginUser().getUser().getRoles(); - if(CollectionUtil.isNotEmpty(roles)){ - for (SysRole role : roles) { - if(role.getRoleName().equals("被申请人")){ - miniProgressFlag=YesOrNoEnum.YES.getCode(); + SysUser user = SecurityUtils.getLoginUser().getUser(); + List roles = roleMapper.selectRolesByUserName(user.getUserName()); + // 查询该用户是否是操作人,是申请操作人还是被申请操作人 + List affiliates = msCaseAffiliateMapper.selectByCaseId(vo.getId()); + if(CollectionUtil.isEmpty(affiliates)){ + return AjaxResult.error("未找到案件相关人员"); + } + for (MsCaseAffiliate affiliate : affiliates) { + if(affiliate.getUserId().equals(user.getUserId())){ + if( affiliate.getRoleType()==null){ + continue; + } + if(affiliate.getRoleType()==1|| affiliate.getRoleType()==2){ + // 申请人 + miniProgressFlag= YesOrNoEnum.NO.getCode(); + } + if(affiliate.getRoleType()==3|| affiliate.getRoleType()==4){ + // 申请人 + miniProgressFlag= YesOrNoEnum.YES.getCode(); } } } + +// if(CollectionUtil.isNotEmpty(roles)){ +// for (SysRole role : roles) { +// if(role.getRoleName().contains("被申请人")){ +// miniProgressFlag=YesOrNoEnum.YES.getCode(); +// } else if (role.getRoleName().contains("申请人")) { +// miniProgressFlag= YesOrNoEnum.NO.getCode(); +// break; +// }else if(role.getRoleName().contains("委托代理人")){ +// +// List operatorList = affiliates.stream().filter(affiliate -> +// affiliate.getOperatorFlag() != null && affiliate.getOperatorFlag() == 1 && affiliate.getRoleType() != null ).collect(Collectors.toList()); +// if(CollectionUtil.isNotEmpty(operatorList)){ +// Map> map = operatorList.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getUserId)); +// if(map.containsKey(user.getUserId())){ +// List msCaseAffiliates = map.get(user.getUserId()); +// for (MsCaseAffiliate affiliate : msCaseAffiliates) { +// // 申请人 +// if(affiliate.getRoleType()==1||affiliate.getRoleType()==2){ +// miniProgressFlag= YesOrNoEnum.NO.getCode(); +// break; +// } +// else if(affiliate.getRoleType()==3||affiliate.getRoleType()==4){ +// miniProgressFlag= YesOrNoEnum.YES.getCode(); +// break; +// } +// } +// } +// } +// } +// } +// } vo.setMiniProgressFlag(miniProgressFlag); // 先删除已选择的调解员,在新增 Example mediatorExample = new Example(MsCaseMediator.class); @@ -1867,10 +2042,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (vo.getMiniProgressFlag() == null || vo.getMiniProgressFlag().equals( YesOrNoEnum.NO.getCode())) { // 新增日志 CaseLogUtils.insertCaseLog(vo.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null); - - if (StrUtil.isEmpty(msCaseAffiliate.getRespondentIdentityNum())) { - return AjaxResult.error("被申请人身份证为空"); - } // 判断被申请人信息查询案件预约表 caseApplicationService. isReservation( vo,userIds); @@ -1908,7 +2079,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { criteria.andEqualTo("type", MediatorTypeEnum.PC.getCode()); } criteria.andEqualTo("caseAppliId", vo.getId()); - // criteria.andEqualTo("mediatorId", user.getUserId()); List msCaseMediators = msCaseMediatorMapper.selectByExample(example); if (CollectionUtil.isNotEmpty(msCaseMediators)) { MsCaseApplication application = new MsCaseApplication(); @@ -2002,6 +2172,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (nextFlow == null) { throw new ServiceException("未找到下一个流程节点"); } + if(vo.getMediatorId()!=null) { // setMediatorAndDate(application,vo); application.setMediatorId(vo.getMediatorId()); @@ -2017,34 +2188,39 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(application.getId()); // 发送开庭短信 if(CollectionUtil.isNotEmpty(vo.getHerDates())) { - - MsCaseAffiliate affiliate = msCaseAffiliateMapper.selectByPrimaryKey(application.getId()); - if (caseApplication == null || affiliate == null) { - throw new ServiceException("未找到该案件"); - } - // 申请人电话 - String phone = ""; - if (affiliate.getOrganizeFlag().equals(0)) { - // 自然人 - if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) { - phone = affiliate.getContactTelphoneAgent(); - } else { - phone = affiliate.getApplicationPhone(); - } - - } else { - phone = affiliate.getContactTelphoneAgent(); - } + List affiliates = selectAffliatesByCaseId(application.getId()); + // todo 申请人电话 caseApplication.setHearDate(application.getHearDate()); // 申请人发送开庭日期短信 - sendHearDateSms(caseApplication, phone); - // 被申发送开庭日期短信 - sendHearDateSms(caseApplication, affiliate.getRespondentPhone()); - // 调解员发送短信 - // 根据调解员id查询用户 + sendHearDateSms(caseApplication, affiliates); + + // 调解员发送短信,根据调解员id查询用户 if (caseApplication.getMediatorId() != null) { SysUser sysUser = sysUserMapper.selectUserById(caseApplication.getMediatorId()); - sendHearDateSms(caseApplication, sysUser.getPhonenumber()); + String content="尊敬的用户,您的" + caseApplication.getCaseNum() + "的案件,线上调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; + String templateId = "2075447"; + String subject="开庭日期通知"; + MsCaseAffiliate meditorAffliate = new MsCaseAffiliate(); + meditorAffliate.setPhone(sysUser.getPhonenumber()); + meditorAffliate.setEmail(sysUser.getEmail()); + // 线下调解 + if(StrUtil.isEmpty(application.getMediationMethod()) || !application.getMediationMethod().equals("1")){ + // 申请人/被申通知, 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + content="尊敬的用户,您的" + caseApplication.getCaseNum() + "的案件,线下调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; + templateId="2077966"; + } + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { + Boolean smsFlag = SmsUtils.sendSms(application.getId(), templateId, sysUser.getPhonenumber(), + new String[]{caseApplication.getCaseNum(),application.getHearDate()}); + // 发送短信 + caseApplicationService.sendSMS(smsFlag, application, meditorAffliate, content); + + } else { + // 发送邮件 + caseApplicationService.sendEmail(application, meditorAffliate, subject, content); + + } } } // 新增日志 @@ -2052,38 +2228,96 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); } - /** * 发送开庭日期短信 * @param application - * @param phone + * @param affiliates */ - private void sendHearDateSms(MsCaseApplication application, String phone) { - if(StrUtil.isEmpty(phone)){ - return; - } - Boolean smsFlag =true; - String sendContent=""; + @Override + @Transactional + public void sendHearDateSms(MsCaseApplication application, List affiliates) { + if(StrUtil.isNotEmpty(application.getMediationMethod()) && application.getMediationMethod().equals("1")){ + // 申请人/被申通知, 线上调解 2075447 尊敬的用户,您的{1}案件,线上调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + SMSNoticeDO noticeDO = new SMSNoticeDO("开庭日期通知", + "尊敬的用户,您的" + application.getCaseNum() + "的案件,线上调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。", + "2075447", + new String[]{application.getCaseNum(),application.getHearDate()} + ); - // 线上调解 2075447 尊敬的用户,您的{1}案件,线上调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 - smsFlag = SmsUtils.sendSms(application.getId(), "2075447", phone, new String[]{application.getCaseNum(),application.getHearDate()}); - sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件,线上调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; + SMSNotice notice = new SMSNotice(noticeDO,noticeDO); + caseApplicationService.sendNotice(application,affiliates,null,notice); }else { - // 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 - smsFlag = SmsUtils.sendSms(application.getId(), "2077966", phone, new String[]{application.getCaseNum(),application.getHearDate()}); - sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件,线下调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; - + // 申请人/被申通知, 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + SMSNoticeDO noticeDO = new SMSNoticeDO("开庭日期通知", + "尊敬的用户,您的" + application.getCaseNum() + "的案件,线下调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。", + "2077966", + new String[]{application.getCaseNum(),application.getHearDate()} + ); + SMSNotice notice = new SMSNotice(noticeDO,noticeDO); + caseApplicationService.sendNotice(application,affiliates,null,notice); } - // 新增短信记录 - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), phone, new Date(), sendContent); - if(smsFlag){ - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - }else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); } + /** + * 申请操作人/被申操作人发送通知 + * @param application + * @param affiliates + * @param applicantFlag + * @param notice + */ + @Override + @Transactional + public void sendNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag, + SMSNotice notice) { + + for (MsCaseAffiliate affiliate : affiliates) { + if (applicantFlag == null || applicantFlag) { + // 申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + SMSNoticeDO applicantNotice = notice.getApplicantNotice(); + caseApplicationService.sendNotice(application, affiliate, applicantNotice); + continue; + } + } + if (applicantFlag == null || !applicantFlag) { + // 被申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + SMSNoticeDO resNotice = notice.getResNotice(); + caseApplicationService.sendNotice(application, affiliate, resNotice); + } + + } + } + } + + /** + * 发送短信 + * @param application + * @param affiliate + * @param notice + */ + @Override + @Transactional + public void sendNotice(MsCaseApplication application, MsCaseAffiliate affiliate, + SMSNoticeDO notice) { + + if (notice != null) { + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(affiliate.getPhone())) { + Boolean smsFlag = SmsUtils.sendSms(application.getId(), notice.getTemplateId(), affiliate.getPhone(), + notice.getTemplateParamSet()); + // 发送短信 + caseApplicationService.sendSMS(smsFlag, application, affiliate, notice.getContent()); + + } else { + // 发送邮件 + caseApplicationService.sendEmail(application, affiliate, notice.getSubject(), notice.getContent()); + + } + } + } + + /** * 案件不予受理 @@ -2098,39 +2332,24 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { Long id = Long.valueOf(caseId); // 根据案件id查询案件 MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(id); - MsCaseAffiliate affiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); - if(application==null || affiliate==null){ + // 查询案件人员 + List affiliates = selectAffliatesByCaseId(id); + if(application==null || CollectionUtil.isEmpty(affiliates)){ return; } + application.setRejectReason(reason); if(application.getCaseFlowId()!=null && application.getCaseFlowId()==4){ - // 超过五日还没有受理,给申请人发送不受理通知 - String phone=""; - if(affiliate.getOrganizeFlag().equals(0)){ - // 自然人 - if(StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())){ - phone=affiliate.getContactTelphoneAgent(); - }else { - phone=affiliate.getApplicationPhone(); - } + // todo 超过五日还没有受理,给申请操作人发送不受理通知,有手机号发短信,没有手机号发邮箱 + // 申请人不受理分配通知 + String rejectReason = application.getRejectReason() == null ? "" : application.getRejectReason(); + SMSNoticeDO applicantNotice = new SMSNoticeDO("案件不受理通知", + "尊敬的用户,您编号为" + application.getCaseNum() + "的案件由于" + rejectReason + "所以不予受理,请知晓,如非本人操作,请忽略本短信。", + "2065809", + new String[]{application.getCaseNum(), rejectReason} + ); - }else { - phone=affiliate.getContactTelphoneAgent(); - } - if(StrUtil.isNotEmpty(phone)) { - // 发送短信 2065809 案件不予受理通知 尊敬的用户,您编号为{1}的案件由于{2}所以不予受理,请知晓,如非本人操作,请忽略本短信。 - Boolean smsFlag = SmsUtils.sendSms(id, "2065809", phone, new String[]{application.getCaseNum(),reason}); - String sendContent = "尊敬的用户,您编号为" + application.getCaseNum() + "的案件由于"+reason+"所以不予受理,请知晓,如非本人操作,请忽略本短信。"; - // CaseLogUtils.insertCaseLog(application.getId(), application.getCaseFlowId(), application.getCaseStatusName(), sendContent); - - // 新增短信记录 - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), phone, new Date(), sendContent); - if(smsFlag){ - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - }else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - } + SMSNotice notice = new SMSNotice(applicantNotice,null); + caseApplicationService.sendNotice(application,affiliates,true,notice); // 修改案件状态为17,结束 MsCaseApplication caseApplication = new MsCaseApplication(); caseApplication.setId(id); @@ -2138,7 +2357,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseApplication.setCaseStatusName("结束"); msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication); CaseLogUtils.insertCaseLog(application.getId(), 4, "受理分配", null); - + // todo 为结束时,记录结束节点 + CaseLogUtils.insertCaseLog(application.getId(), 17, "结束", null); + // todo 结束对接北明,为调解失败状态 + if(StrUtil.isEmpty(application.getCaseSource())) { + caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL); + } } } @@ -2226,12 +2450,24 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (currentFlow == null) { throw new ServiceException("未找到当前流程节点"); } + // 查询案件人员 + List affiliates = selectAffliatesByCaseId(application.getId()); + if (CollectionUtil.isEmpty(affiliates)) { + throw new ServiceException("未找到案件人员"); + } + // 申请操作人 + Optional applicantAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && StrUtil.isNotEmpty(affiliate.getPhone()) && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).findFirst(); + // 被申请操作人 + Optional resAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && StrUtil.isNotEmpty(affiliate.getPhone()) && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst(); + if (!applicantAffiliateOpt.isPresent() || !resAffiliateOpt.isPresent()) { + throw new ServiceException("未找到案件操作人员"); + } + // 调解结果 Integer mediaResult = req.getMediaResult(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(req.getId()); if (application.getMediationMethod().equals("1")) { // 线上调解 List attachList = req.getAttachList(); - if(CollectionUtil.isNotEmpty(attachList)) { + if (CollectionUtil.isNotEmpty(attachList)) { // 先删除已经存在的调解书 msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); for (MsCaseAttach attach : attachList) { @@ -2239,541 +2475,169 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { msCaseAttachMapper.updateCaseAttach(attach); } } - if(mediaResult ==1){ - //达成调解 - List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId()); - if (caseAttachList != null && caseAttachList.size() > 0) { - for (MsCaseAttach caseAttach : caseAttachList) { - if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { - // String prefix = "/profile"; - // int startIndex = prefix.length(); - String annexPath = caseAttach.getAnnexPath(); - // String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - String path = annexPath; - //获取文件上传地址 - EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); - String body = response.getBody(); - if (body != null) { - JSONObject jsonObject = JSONObject.parseObject(body); - String fileId = jsonObject.getJSONObject("data").getString("fileId"); - String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); - //上传文件流 - EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); - JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); - if (jsonObject1.getIntValue("errCode") == 0) { - //查看文件上传状态 - Thread.sleep(1000); - EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); - JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); - JSONObject data = jsonObject2.getJSONObject("data"); - int fileStatus = data.getIntValue("fileStatus"); - if (fileStatus == 2 || fileStatus == 5) { - String fileName = data.getString("fileName"); - //上传成功,获取文件签名印章位置 - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setFileid(fileId); - EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); - Gson gson = new Gson(); - JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); - JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); - String keywordPositions = positionsData.get("keywordPositions").toString(); - //发起签署 - sealSignRecord.setFilename(fileName); + if (mediaResult == 1) { + //达成调解 + List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId()); + if (caseAttachList != null && caseAttachList.size() > 0) { + for (MsCaseAttach caseAttach : caseAttachList) { + if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { + // String prefix = "/profile"; + // int startIndex = prefix.length(); + String annexPath = caseAttach.getAnnexPath(); + // String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); + String path = annexPath; + //获取文件上传地址 + EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); + String body = response.getBody(); + if (body != null) { + JSONObject jsonObject = JSONObject.parseObject(body); + String fileId = jsonObject.getJSONObject("data").getString("fileId"); + String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); + //上传文件流 + EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); + JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); + if (jsonObject1.getIntValue("errCode") == 0) { + //查看文件上传状态 + Thread.sleep(1000); + EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); + JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); + JSONObject data = jsonObject2.getJSONObject("data"); + int fileStatus = data.getIntValue("fileStatus"); + if (fileStatus == 2 || fileStatus == 5) { + String fileName = data.getString("fileName"); + //上传成功,获取文件签名印章位置 + SealSignRecord sealSignRecord = new SealSignRecord(); + sealSignRecord.setFileid(fileId); + EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); + Gson gson = new Gson(); + JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); + JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); + String keywordPositions = positionsData.get("keywordPositions").toString(); + //发起签署 + sealSignRecord.setFilename(fileName); - Long arbitratorId = application.getMediatorId(); - if (arbitratorId!=null) { - SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); - if (sysUser == null) { - return AjaxResult.error(); - } - sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); - sealSignRecord.setPensonNameMedi(sysUser.getNickName()); - } - - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - if(organizeFlag!=null){ - if(organizeFlag.intValue()==1){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - sealSignRecord.setPensonAccount(caseAffiliate.getApplicationPhone()); - sealSignRecord.setPensonName(caseAffiliate.getApplicationName()); - } - } - } - - sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone()); - sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName()); - - DeptIdentify deptIdentify = new DeptIdentify(); - deptIdentify.setIsUse(1); - DeptIdentify deptIdentifyselect = new DeptIdentify(); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); - if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { - deptIdentifyselect = deptIdentifysnew.get(0); - sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); - sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); - sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); - } else { - return AjaxResult.error("没有用印时的机构名称及经办人信息"); - } - - //解析文件签名印章位置 - JSONArray jsonArray = JSONArray.parseArray(keywordPositions); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsonObject3 = jsonArray.getJSONObject(i); - String keyword = jsonObject3.getString("keyword"); - if (keyword.equals("甲方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsn(positionX + 120); - sealSignRecord.setPositionYpsn(positionY); - } - }else if (keyword.equals("乙方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnRes(positionX + 120); - sealSignRecord.setPositionYpsnRes(positionY + 10); - } - }else if (keyword.equals("调解员(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnMedi(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnMedi(positionX + 120); - sealSignRecord.setPositionYpsnMedi(positionY + 10); - } - }else { - //用印 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPageorg(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXorg(positionX + 90); - sealSignRecord.setPositionYorg(positionY); - } - } - } - - 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 iddeptIdent = deptIdentifies.get(0).getId(); - SealManage sealManage = new SealManage(); - sealManage.setIdentifyId(iddeptIdent); - List sealIdList = new ArrayList<>(); - List selectSealList = sealManageMapper.selectSealList(sealManage); - if (selectSealList != null && selectSealList.size() > 0) { - for (SealManage manage : selectSealList) { - Integer sealStatus = manage.getSealStatus(); - Integer isUse = manage.getIsUse(); - if (sealStatus == 1 && isUse ==1) { - sealIdList.add(manage.getSealId()); - } - } - EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - if (jsonObject3.getIntValue("code") == 0) { - //获取签署流程ID - JSONObject data1 = jsonObject3.getJSONObject("data"); - String signFlowId = data1.getString("signFlowId"); - //保存案件id,文件id,文件名称.流程id到签署用印记录表里 - sealSignRecord.setCaseAppliId(application.getId()); - sealSignRecord.setSignFlowid(signFlowId); - sealSignRecord.setSignFlowStatus(1);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); - msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - }else { - sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone()); - } - - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - - if(StringUtils.isNotBlank(nameAgent)){ - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew}); - }else { - request.setPhone(caseAffiliate.getApplicationPhone()); - request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew}); - } - Boolean aBoolean = SmsUtils.sendSms(request); - - if(StringUtils.isNotBlank(nameAgent)){ - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getContactTelphoneAgent(), new Date(), "尊敬的" + caseAffiliate.getNameAgent() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBoolean) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - }else { - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getApplicationPhone(), new Date(), "尊敬的" + caseAffiliate.getApplicationName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBoolean) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - } - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getRespondentPhone(), new Date(), "尊敬的" + caseAffiliate.getRespondentName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnew + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBoolean1) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - - SealSignRecord sealSignRecordMedi = new SealSignRecord(); - sealSignRecordMedi.setSignFlowid(signFlowId); - sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi()); - EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi); - JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class); - JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data"); - String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString(); - String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest(); - requestMedi.setTemplateId("2047719"); - requestMedi.setPhone(sealSignRecord.getPensonAccountMedi()); - requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), application.getCaseNum(),urlResponnewMedi}); - Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi); - - SmsSendRecord smsSendRecord1 = new SmsSendRecord(application.getId(), application.getCaseNum(), sealSignRecord.getPensonAccountMedi(), new Date(), "尊敬的" + sealSignRecord.getPensonNameMedi() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnewMedi + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBooleanMedi) { - smsSendRecord1.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord1.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord1); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - } - } else { - return AjaxResult.error(); - } - - // 修改案件状态为待签名 - Example flowExample = new Example(MsCaseFlow.class); - flowExample.createCriteria().andEqualTo("caseStatusName", "待签名"); - MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ - application.setCaseFlowId(caseFlow.getId()); - application.setCaseStatusName(caseFlow.getCaseStatusName()); - msCaseApplicationMapper.updateByPrimaryKey(application); - // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); - } - - application.setMediaResult(mediaResult); - msCaseApplicationMapper.updateByPrimaryKeySelective(application); - }else{ + Long arbitratorId = application.getMediatorId(); + if (arbitratorId != null) { + SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); + if (sysUser == null) { return AjaxResult.error(); } - }else{ - return AjaxResult.error(); + sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); + sealSignRecord.setPensonNameMedi(sysUser.getNickName()); + } + // todo + // 设置申请人签名账户 + sealSignRecord.setPensonAccount(applicantAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonName(applicantAffiliateOpt.get().getName()); + // 设置被申请人签名账户 + sealSignRecord.setPensonAccountRes(resAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonNameRes(resAffiliateOpt.get().getName()); + // 设置用印账号 + DeptIdentify deptIdentify = new DeptIdentify(); + deptIdentify.setIsUse(1); + DeptIdentify deptIdentifyselect = new DeptIdentify(); + List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); + if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { + deptIdentifyselect = deptIdentifysnew.get(0); + sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); + sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); + sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); + } else { + return AjaxResult.error("没有用印时的机构名称及经办人信息"); } - } - break; - } - } - } - - return AjaxResult.success(); - }else if(mediaResult.intValue()==2){ - //未达成调解 - //发送终止调解短信,尊敬的{1}用户,您的{2}调解案件已终止调解,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2066725"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum()}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2066725"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum()}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - // 修改案件状态为结束 - Example flowExample = new Example(MsCaseFlow.class); - flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); - MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ - // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); - application.setCaseFlowId(caseFlow.getId()); - application.setCaseStatusName(caseFlow.getCaseStatusName()); - application.setMediaResult(mediaResult); - msCaseApplicationMapper.updateByPrimaryKey(application); - } - return AjaxResult.success(); - }else if(mediaResult.intValue()==3){ - //未达成调解但不再争议 - // 修改案件状态为结束 - Example flowExample = new Example(MsCaseFlow.class); - flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); - MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ - application.setCaseFlowId(caseFlow.getId()); - application.setCaseStatusName(caseFlow.getCaseStatusName()); - application.setMediaResult(mediaResult); - msCaseApplicationMapper.updateByPrimaryKey(application); - // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); - - } - return AjaxResult.success(); - }else if(mediaResult.intValue()==4){ - //未达成调解但同意引入仲裁 - String accessSec = "mCFMA6ffe938v79m"; - MsCaseApplicationVO applicationVO = new MsCaseApplicationVO(); - BeanUtils.copyProperties(application,applicationVO); - - CaseApplicationVO caseApplicationVO = new CaseApplicationVO(); - BeanUtils.copyProperties(applicationVO,caseApplicationVO); - boolean importFlag = applicationVO.isImportFlag(); - if(importFlag==true){ - caseApplicationVO.setImportFlag(1); - }else { - caseApplicationVO.setImportFlag(0); - } - String paramsbody = JSONUtil.toJsonStr(caseApplicationVO); - long timestamp = System.currentTimeMillis(); - String signStr = SignCheckUtils.getSign(paramsbody, accessSec, timestamp); - String urlstr = arbitrateUrl; - HttpResponse httpResponse = HttpRequest.post(urlstr) - .header("timestampstr", String.valueOf(timestamp)) - .header("signstr", signStr) - .body(paramsbody) - .execute(); - // 修改案件状态为结束 - Example flowExample = new Example(MsCaseFlow.class); - flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); - MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ - // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); - application.setCaseFlowId(caseFlow.getId()); - application.setCaseStatusName(caseFlow.getCaseStatusName()); - application.setMediaResult(mediaResult); - msCaseApplicationMapper.updateByPrimaryKey(application); - } - - return AjaxResult.success(); - }else if(mediaResult.intValue()==5){ - // 达成和解 - List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId()); - if (caseAttachList != null && caseAttachList.size() > 0) { - for (MsCaseAttach caseAttach : caseAttachList) { - if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { - // String prefix = "/profile"; - // int startIndex = prefix.length(); - String annexPath = caseAttach.getAnnexPath(); -// String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - String path = annexPath; - //获取文件上传地址 - EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); - String body = response.getBody(); - if (body != null) { - JSONObject jsonObject = JSONObject.parseObject(body); - String fileId = jsonObject.getJSONObject("data").getString("fileId"); - String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); - //上传文件流 - EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); - JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); - if (jsonObject1.getIntValue("errCode") == 0) { - //查看文件上传状态 - Thread.sleep(1000); - EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); - JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); - JSONObject data = jsonObject2.getJSONObject("data"); - int fileStatus = data.getIntValue("fileStatus"); - if (fileStatus == 2 || fileStatus == 5) { - String fileName = data.getString("fileName"); - //上传成功,获取文件签名印章位置 - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setFileid(fileId); - EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); - Gson gson = new Gson(); - JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); - JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); - String keywordPositions = positionsData.get("keywordPositions").toString(); - //发起签署 - sealSignRecord.setFilename(fileName); - - Long arbitratorId = application.getMediatorId(); - if (arbitratorId!=null) { - SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); - if (sysUser == null) { - return AjaxResult.error(); - } - sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); - sealSignRecord.setPensonNameMedi(sysUser.getNickName()); + //解析文件签名印章位置 + JSONArray jsonArray = JSONArray.parseArray(keywordPositions); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject3 = jsonArray.getJSONObject(i); + String keyword = jsonObject3.getString("keyword"); + if (keyword.equals("甲方(签字):")) { + //签名 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXpsn(positionX + 120); + sealSignRecord.setPositionYpsn(positionY); } + } else if (keyword.equals("乙方(签字):")) { + //签名 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXpsnRes(positionX + 120); + sealSignRecord.setPositionYpsnRes(positionY + 10); + } + } else if (keyword.equals("调解员(签字):")) { + //签名 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPagepsnMedi(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXpsnMedi(positionX + 120); + sealSignRecord.setPositionYpsnMedi(positionY + 10); + } + } else { + //用印 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPageorg(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXorg(positionX + 90); + sealSignRecord.setPositionYorg(positionY); + } + } + } - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - if(organizeFlag!=null){ - if(organizeFlag.intValue()==1){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - sealSignRecord.setPensonAccount(caseAffiliate.getApplicationPhone()); - sealSignRecord.setPensonName(caseAffiliate.getApplicationName()); - } + 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 iddeptIdent = deptIdentifies.get(0).getId(); + SealManage sealManage = new SealManage(); + sealManage.setIdentifyId(iddeptIdent); + List sealIdList = new ArrayList<>(); + List selectSealList = sealManageMapper.selectSealList(sealManage); + if (selectSealList != null && selectSealList.size() > 0) { + for (SealManage manage : selectSealList) { + Integer sealStatus = manage.getSealStatus(); + Integer isUse = manage.getIsUse(); + if (sealStatus == 1 && isUse == 1) { + sealIdList.add(manage.getSealId()); } } - - sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone()); - sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName()); - -// DeptIdentify deptIdentify = new DeptIdentify(); -// deptIdentify.setIsUse(1); -// DeptIdentify deptIdentifyselect = new DeptIdentify(); -// List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); -// if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { -// deptIdentifyselect = deptIdentifysnew.get(0); -// sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); -// sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); -// sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); -// } else { -// return AjaxResult.error("没有用印时的机构名称及经办人信息"); -// } - - //解析文件签名印章位置 - JSONArray jsonArray = JSONArray.parseArray(keywordPositions); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsonObject3 = jsonArray.getJSONObject(i); - String keyword = jsonObject3.getString("keyword"); - if (keyword.equals("甲方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsn(positionX + 120); - sealSignRecord.setPositionYpsn(positionY); - } - }else if (keyword.equals("乙方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnRes(positionX + 120); - sealSignRecord.setPositionYpsnRes(positionY + 10); - } - } - } - - EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord); + EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList); JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); if (jsonObject3 != null) { @@ -2790,149 +2654,485 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { msSealSignRecord.setFileId(sealSignRecord.getFileid()); msSealSignRecord.setFileName(sealSignRecord.getFilename()); msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); + msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); + msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); sealSignRecordMapper.insert(msSealSignRecord); SealSignRecord sealSignRecordapply = new SealSignRecord(); sealSignRecordapply.setSignFlowid(signFlowId); - - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - }else { - sealSignRecordapply.setPensonAccount(caseAffiliate.getApplicationPhone()); - } - + // todo + // 设置申请人账户 + sealSignRecordapply.setPensonAccount(applicantAffiliateOpt.get().getPhone()); EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); + String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/") + 1); //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - if(StringUtils.isNotBlank(nameAgent)){ - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), application.getCaseNum(),urlapplynew}); - }else { - request.setPhone(caseAffiliate.getApplicationPhone()); - request.setTemplateParamSet(new String[]{caseAffiliate.getApplicationName(), application.getCaseNum(),urlapplynew}); - } + request.setTemplateId("2115975"); + // todo + // 申请人发送短信 + request.setPhone(applicantAffiliateOpt.get().getPhone()); + request.setTemplateParamSet(new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum(), urlapplynew}); Boolean aBoolean = SmsUtils.sendSms(request); - - if(StringUtils.isNotBlank(nameAgent)){ - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getContactTelphoneAgent(), new Date(), "尊敬的" + caseAffiliate.getNameAgent() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBoolean) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - }else { - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getApplicationPhone(), new Date(), "尊敬的" + caseAffiliate.getApplicationName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); - // 新增短信记录 - if (aBoolean) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - } - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), application.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), caseAffiliate.getRespondentPhone(), new Date(), "尊敬的" + caseAffiliate.getRespondentName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnew + ",请点击链接签名,如非本人操作,请忽略本短信"); + SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), + applicantAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + applicantAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); // 新增短信记录 - if (aBoolean1) { + if (aBoolean) { smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); } else { smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); } smsRecordMapper.saveSmsSendRecord(smsSendRecord); + SealSignRecord sealSignRecordRespon = new SealSignRecord(); + sealSignRecordRespon.setSignFlowid(signFlowId); + // 被申请人账户 + sealSignRecordRespon.setPensonAccount(resAffiliateOpt.get().getPhone()); + EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); + JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); + JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); + String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); + String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/") + 1); + + SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); + request1.setTemplateId("2115975"); + request1.setPhone(resAffiliateOpt.get().getPhone()); + request1.setTemplateParamSet(new String[]{resAffiliateOpt.get().getName(), application.getCaseNum(), urlResponnew}); + Boolean aBoolean1 = SmsUtils.sendSms(request1); + + SmsSendRecord resSmsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), resAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + resAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnew + ",请点击链接签名,如非本人操作,请忽略本短信"); + // 新增短信记录 + if (aBoolean1) { + resSmsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + resSmsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(resSmsSendRecord); + // 调解员账户 + SealSignRecord sealSignRecordMedi = new SealSignRecord(); + sealSignRecordMedi.setSignFlowid(signFlowId); + sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi()); + EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi); + JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class); + JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data"); + String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString(); + String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/") + 1); + + SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest(); + requestMedi.setTemplateId("2115975"); + requestMedi.setPhone(sealSignRecord.getPensonAccountMedi()); + requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), application.getCaseNum(), urlResponnewMedi}); + Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi); + + SmsSendRecord smsSendRecord1 = new SmsSendRecord(application.getId(), application.getCaseNum(), sealSignRecord.getPensonAccountMedi(), new Date(), "尊敬的" + sealSignRecord.getPensonNameMedi() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnewMedi + ",请点击链接签名,如非本人操作,请忽略本短信"); + // 新增短信记录 + if (aBooleanMedi) { + smsSendRecord1.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + smsSendRecord1.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(smsSendRecord1); + } else { throw new ServiceException(jsonObject3.getString("message")); } } else { return AjaxResult.error(); } - - // 修改案件状态为待签名 - Example flowExample = new Example(MsCaseFlow.class); - flowExample.createCriteria().andEqualTo("caseStatusName", "待签名"); - MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ - application.setCaseFlowId(caseFlow.getId()); - application.setCaseStatusName(caseFlow.getCaseStatusName()); - // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); - } - - application.setMediaResult(mediaResult); - msCaseApplicationMapper.updateByPrimaryKeySelective(application); - return AjaxResult.success(); - }else{ - return AjaxResult.error(); } - }else{ + } else { return AjaxResult.error(); } + + // 修改案件状态为待签名 + Example flowExample = new Example(MsCaseFlow.class); + flowExample.createCriteria().andEqualTo("caseStatusName", "待签名"); + MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); + if (caseFlow != null) { + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + msCaseApplicationMapper.updateByPrimaryKey(application); + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + } + + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + } else { + return AjaxResult.error(); } - break; + } else { + return AjaxResult.error(); } } + break; + } + } } + return AjaxResult.success(); + } else if (mediaResult.intValue() == 2) { + //未达成调解 + //todo 发送终止调解短信,尊敬的{1}用户,您的{2}调解案件已终止调解,如非本人操作,请忽略本短信 + // 申请人短信 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId("2066725"); + request.setPhone(applicantAffiliateOpt.get().getPhone()); + request.setTemplateParamSet(new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum()}); + Boolean aBoolean = SmsUtils.sendSms(request); + // 新增短信记录 + SmsSendRecord appSmsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), applicantAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + applicantAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件已终止调解,如非本人操作,请忽略本短信"); + if (aBoolean) { + appSmsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + appSmsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(appSmsSendRecord); + // 被申请人短信 + SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); + request1.setTemplateId("2066725"); + request1.setPhone(resAffiliateOpt.get().getPhone()); + request1.setTemplateParamSet(new String[]{resAffiliateOpt.get().getName(), application.getCaseNum()}); + Boolean aBoolean1 = SmsUtils.sendSms(request1); + // 新增短信记录 + SmsSendRecord resSmsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), resAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + resAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件已终止调解,如非本人操作,请忽略本短信"); + if (aBoolean1) { + resSmsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + resSmsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(resSmsSendRecord); + // 修改案件状态为结束 + Example flowExample = new Example(MsCaseFlow.class); + flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); + MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); + if (caseFlow != null) { + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + // todo 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKey(application); + } + return AjaxResult.success(); + } else if (mediaResult.intValue() == 3) { + //未达成调解但不再争议 + // 修改案件状态为结束 + Example flowExample = new Example(MsCaseFlow.class); + flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); + MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); + if (caseFlow != null) { + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKey(application); + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + // todo 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + } + return AjaxResult.success(); + } else if (mediaResult.intValue() == 4) { + //未达成调解但同意引入仲裁 + String accessSec = "mCFMA6ffe938v79m"; + MsCaseApplicationVO applicationVO = new MsCaseApplicationVO(); + BeanUtils.copyProperties(application, applicationVO); + + CaseApplicationVO caseApplicationVO = new CaseApplicationVO(); + BeanUtils.copyProperties(applicationVO, caseApplicationVO); + boolean importFlag = applicationVO.isImportFlag(); + if (importFlag == true) { + caseApplicationVO.setImportFlag(1); + } else { + caseApplicationVO.setImportFlag(0); + } + String paramsbody = JSONUtil.toJsonStr(caseApplicationVO); + long timestamp = System.currentTimeMillis(); + String signStr = SignCheckUtils.getSign(paramsbody, accessSec, timestamp); + String urlstr = arbitrateUrl; + HttpResponse httpResponse = HttpRequest.post(urlstr) + .header("timestampstr", String.valueOf(timestamp)) + .header("signstr", signStr) + .body(paramsbody) + .execute(); + // 修改案件状态为结束 + Example flowExample = new Example(MsCaseFlow.class); + flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); + MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); + if (caseFlow != null) { + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + // todo 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKey(application); + } + + return AjaxResult.success(); + } else if (mediaResult.intValue() == 5) { + // 达成和解 + List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(req.getId()); + if (caseAttachList != null && caseAttachList.size() > 0) { + for (MsCaseAttach caseAttach : caseAttachList) { + if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { + // String prefix = "/profile"; + // int startIndex = prefix.length(); + String annexPath = caseAttach.getAnnexPath(); +// String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); + String path = annexPath; + //获取文件上传地址 + EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); + String body = response.getBody(); + if (body != null) { + JSONObject jsonObject = JSONObject.parseObject(body); + String fileId = jsonObject.getJSONObject("data").getString("fileId"); + String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); + //上传文件流 + EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); + JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); + if (jsonObject1.getIntValue("errCode") == 0) { + //查看文件上传状态 + Thread.sleep(1000); + EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); + JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); + JSONObject data = jsonObject2.getJSONObject("data"); + int fileStatus = data.getIntValue("fileStatus"); + if (fileStatus == 2 || fileStatus == 5) { + String fileName = data.getString("fileName"); + //上传成功,获取文件签名印章位置 + SealSignRecord sealSignRecord = new SealSignRecord(); + sealSignRecord.setFileid(fileId); + EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); + Gson gson = new Gson(); + JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); + JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); + String keywordPositions = positionsData.get("keywordPositions").toString(); + //发起签署 + sealSignRecord.setFilename(fileName); + + Long arbitratorId = application.getMediatorId(); + if (arbitratorId != null) { + SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); + if (sysUser == null) { + return AjaxResult.error(); + } + sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); + sealSignRecord.setPensonNameMedi(sysUser.getNickName()); + } + // todo 申请人账户 + sealSignRecord.setPensonAccount(applicantAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonName(applicantAffiliateOpt.get().getName()); + // 被申账户 + sealSignRecord.setPensonAccountRes(resAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonNameRes(resAffiliateOpt.get().getName()); + //解析文件签名印章位置 + JSONArray jsonArray = JSONArray.parseArray(keywordPositions); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject3 = jsonArray.getJSONObject(i); + String keyword = jsonObject3.getString("keyword"); + if (keyword.equals("甲方(签字):")) { + //签名 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXpsn(positionX + 120); + sealSignRecord.setPositionYpsn(positionY); + } + } else if (keyword.equals("乙方(签字):")) { + //签名 + JSONArray positionsArray = jsonObject3.getJSONArray("positions"); + // 遍历 positionsArray 中的每个元素 + for (int j = 0; j < positionsArray.size(); j++) { + JSONObject positionObj = positionsArray.getJSONObject(j); + int pageNum = positionObj.getIntValue("pageNum"); + sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); + JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); + JSONObject coordinateObj = coordinatesArray.getJSONObject(0); + double positionX = coordinateObj.getDoubleValue("positionX"); + double positionY = coordinateObj.getDoubleValue("positionY"); + sealSignRecord.setPositionXpsnRes(positionX + 120); + sealSignRecord.setPositionYpsnRes(positionY + 10); + } + } + } + + EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord); + + JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); + if (jsonObject3 != null) { + if (jsonObject3.getIntValue("code") == 0) { + //获取签署流程ID + JSONObject data1 = jsonObject3.getJSONObject("data"); + String signFlowId = data1.getString("signFlowId"); + //保存案件id,文件id,文件名称.流程id到签署用印记录表里 + sealSignRecord.setCaseAppliId(application.getId()); + sealSignRecord.setSignFlowid(signFlowId); + sealSignRecord.setSignFlowStatus(1);//待签名 + MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); + BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); + msSealSignRecord.setFileId(sealSignRecord.getFileid()); + msSealSignRecord.setFileName(sealSignRecord.getFilename()); + msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); + sealSignRecordMapper.insert(msSealSignRecord); + // 申请人签名记录 + SealSignRecord sealSignRecordapply = new SealSignRecord(); + sealSignRecordapply.setSignFlowid(signFlowId); + sealSignRecordapply.setPensonAccount(applicantAffiliateOpt.get().getPhone()); + EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); + JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); + JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); + String urlapply = signUrlData.get("shortUrl").getAsString(); + String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/") + 1); + + //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 + // 申请人短信 + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId("2047719"); + request.setPhone(applicantAffiliateOpt.get().getPhone()); + request.setTemplateParamSet(new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum(), urlapplynew}); + Boolean aBoolean = SmsUtils.sendSms(request); + SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), applicantAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + applicantAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlapplynew + ",请点击链接签名,如非本人操作,请忽略本短信"); + // 新增短信记录 + if (aBoolean) { + smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(smsSendRecord); + // 被申签名记录 + SealSignRecord sealSignRecordRespon = new SealSignRecord(); + sealSignRecordRespon.setSignFlowid(signFlowId); + sealSignRecordRespon.setPensonAccount(resAffiliateOpt.get().getPhone()); + EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); + JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); + JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); + String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); + String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/") + 1); + + SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); + request1.setTemplateId("2047719"); + request1.setPhone(resAffiliateOpt.get().getPhone()); + request1.setTemplateParamSet(new String[]{resAffiliateOpt.get().getName(), application.getCaseNum(), urlResponnew}); + Boolean aBoolean1 = SmsUtils.sendSms(request1); + + SmsSendRecord resSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), resAffiliateOpt.get().getPhone(), new Date(), "尊敬的" + resAffiliateOpt.get().getName() + "用户,您的" + application.getCaseNum() + "调解案件,签名链接https://smlt.esign.cn/" + urlResponnew + ",请点击链接签名,如非本人操作,请忽略本短信"); + // 新增短信记录 + if (aBoolean1) { + resSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + resSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(resSendRecord); + + } else { + throw new ServiceException(jsonObject3.getString("message")); + } + } else { + return AjaxResult.error(); + } + + // 修改案件状态为待签名 + Example flowExample = new Example(MsCaseFlow.class); + flowExample.createCriteria().andEqualTo("caseStatusName", "待签名"); + MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); + if (caseFlow != null) { + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + } + + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + return AjaxResult.success(); + } else { + return AjaxResult.error(); + } + } else { + return AjaxResult.error(); + } + } + break; + } + } + } + } + } else { // 线下调解 List attachList = req.getAttachList(); - if(CollectionUtil.isEmpty(attachList)){ + if (CollectionUtil.isEmpty(attachList)) { return AjaxResult.error("请上传调解资料"); } // 先删除已经存在的调解书 - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(),AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(StrUtil.isEmpty(application.getCaseSource())){ + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(CollectionUtil.isNotEmpty(existAttach)){ + // todo 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); for (MsCaseAttach attach : attachList) { attach.setCaseAppliId(req.getId()); msCaseAttachMapper.updateCaseAttach(attach); } + // todo 对接北明,调用上传附件接口 + List msCaseAttaches = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(StrUtil.isEmpty(application.getCaseSource()) && CollectionUtil.isNotEmpty(msCaseAttaches)) { + for (MsCaseAttach msCaseAttach : msCaseAttaches) { + String templatePath = "/home/ruoyi" + msCaseAttach.getAnnexPath(); + File file = new File(templatePath.replace("/profile", "/uploadPath")); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(),AttachmentOperateTypeEnum.ADD); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + msCaseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttach(msCaseAttach); + } + } + } // 修改案件状态为待送达 Example flowExample = new Example(MsCaseFlow.class); - if(mediaResult ==1 || mediaResult == 5){ + if (mediaResult == 1 || mediaResult == 5) { // 达成调解,达成和解,案件状态改为待送达 flowExample.createCriteria().andEqualTo("caseStatusName", "待送达"); - } else if(mediaResult == 2 || mediaResult == 3){ + } else if (mediaResult == 2 || mediaResult == 3) { // 未达成调解,未达成调解但不在争议改为结束状态 flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); - } - else if(mediaResult == 4){ + } else if (mediaResult == 4) { // 未达成调解但同意引入仲裁系统,改为结束状态,并调仲裁新增接口 flowExample.createCriteria().andEqualTo("caseStatusName", "结束"); String accessSec = "mCFMA6ffe938v79m"; MsCaseApplicationVO applicationVO = new MsCaseApplicationVO(); - BeanUtils.copyProperties(application,applicationVO); + BeanUtils.copyProperties(application, applicationVO); CaseApplicationVO caseApplicationVO = new CaseApplicationVO(); - BeanUtils.copyProperties(applicationVO,caseApplicationVO); + BeanUtils.copyProperties(applicationVO, caseApplicationVO); boolean importFlag = applicationVO.isImportFlag(); - if(importFlag==true){ + if (importFlag == true) { caseApplicationVO.setImportFlag(1); - }else { + } else { caseApplicationVO.setImportFlag(0); } String paramsbody = JSONUtil.toJsonStr(caseApplicationVO); @@ -2946,13 +3146,18 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { .execute(); } MsCaseFlow caseFlow = caseFlowMapper.selectOneByExample(flowExample); - if(caseFlow != null){ + if (caseFlow != null) { application.setCaseFlowId(caseFlow.getId()); application.setCaseStatusName(caseFlow.getCaseStatusName()); application.setMediaResult(mediaResult); msCaseApplicationMapper.updateByPrimaryKey(application); // 新增日志 - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + if (mediaResult == 2 || mediaResult == 3 || mediaResult == 4) { + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + // todo 结束对接北明,为调解失败状态 + caseApplicationService. pushStatusToBM(application, PushCaseStatusEnum.FAIL); + } } return AjaxResult.success(); } @@ -3012,689 +3217,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return AjaxResult.success(); } - /** - * 确认调解书 - * @param attach - * @return - */ - @Transactional(rollbackFor = Exception.class) - @Override - public AjaxResult confirmMediation(MsCaseAttachVO attach) throws EsignDemoException, InterruptedException { - if(attach.getAnnexId()!=null){ - // 删除之前的调解书 - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(attach.getCaseAppliId(),AnnexTypeEnum.MEDIATE_BOOK.getCode()); - msCaseAttachMapper.updateCaseAttach(attach); - } - // todo 发送短信 - // 更新流程节点 - caseApplicationService.nextFlow(attach.getCaseAppliId(),attach.getCaseFlowId(),YesOrNoEnum.YES.getCode()); - - Long id = attach.getCaseAppliId(); - MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id); - caseApplication.setIsReconci(attach.getIsReconci()); - msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication); - - // 查询案件相关人员 - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); - Integer isReconci = attach.getIsReconci(); - - if(attach.getAnnexId()!=null){ - MsCaseAttach caseAttach = msCaseAttachMapper.queryAnnexById(attach.getAnnexId()); - if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { - String prefix = "/profile"; - int startIndex = prefix.length(); - String annexPath = caseAttach.getAnnexPath(); - String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - //获取文件上传地址 - EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); - String body = response.getBody(); - if (body != null) { - JSONObject jsonObject = JSONObject.parseObject(body); - String fileId = jsonObject.getJSONObject("data").getString("fileId"); - String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); - //上传文件流 - EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); - JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); - if (jsonObject1.getIntValue("errCode") == 0) { - //查看文件上传状态 - Thread.sleep(1000); - EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); - JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); - JSONObject data = jsonObject2.getJSONObject("data"); - int fileStatus = data.getIntValue("fileStatus"); - if (fileStatus == 2 || fileStatus == 5) { - String fileName = data.getString("fileName"); - //上传成功,获取文件签名印章位置 - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setFileid(fileId); - EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); - Gson gson = new Gson(); - JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); - JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); - String keywordPositions = positionsData.get("keywordPositions").toString(); - //发起签署 - sealSignRecord.setFilename(fileName); - - Long arbitratorId = caseApplication.getMediatorId(); - if (null!=arbitratorId) { - SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); - if (sysUser == null) { - return AjaxResult.error(); - } - sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); - sealSignRecord.setPensonNameMedi(sysUser.getNickName()); - } - - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone()); - sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName()); - - DeptIdentify deptIdentify = new DeptIdentify(); - deptIdentify.setIsUse(1); - DeptIdentify deptIdentifyselect = new DeptIdentify(); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); - if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { - deptIdentifyselect = deptIdentifysnew.get(0); - sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); - sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); - sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); - } else { - return AjaxResult.error("没有用印时的机构名称及经办人信息"); - } - - //解析文件签名印章位置 - JSONArray jsonArray = JSONArray.parseArray(keywordPositions); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsonObject3 = jsonArray.getJSONObject(i); - String keyword = jsonObject3.getString("keyword"); - if (keyword.equals("甲方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsn(positionX + 120); - sealSignRecord.setPositionYpsn(positionY); - } - }else if (keyword.equals("乙方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnRes(positionX + 120); - sealSignRecord.setPositionYpsnRes(positionY + 10); - } - }else if (keyword.equals("调解员(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnMedi(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnMedi(positionX + 120); - sealSignRecord.setPositionYpsnMedi(positionY + 10); - } - }else { - //用印 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPageorg(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXorg(positionX + 90); - sealSignRecord.setPositionYorg(positionY); - } - } - } - - if(isReconci.intValue()==1){ - EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - 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);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), caseApplication.getCaseNum(),urlapplynew}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), caseApplication.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - - }else { - /*DeptIdentify deptIdentify1 = new DeptIdentify(); - deptIdentify1.setSealStatus(1); // 印章状态为启用 - //根据机构名称查询部门id - SysDept sysDept = new SysDept(); - sysDept.setDeptName(sealSignRecord.getOrgnizeName()); - List sysDepts = deptMapper.selectDeptList(sysDept); - if (sysDepts != null && sysDepts.size() > 0) { - Long deptId = sysDepts.get(0).getDeptId(); - deptIdentify1.setDeptId(deptId); - } - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentify1); - List sealIds = new ArrayList<>(); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - for (DeptIdentify identify : deptIdentifies) { - String sealId = identify.getSealId(); - sealIds.add(sealId); - } - }*/ - 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 iddeptIdent = deptIdentifies.get(0).getId(); - SealManage sealManage = new SealManage(); - sealManage.setIdentifyId(iddeptIdent); - List sealIdList = new ArrayList<>(); - List selectSealList = sealManageMapper.selectSealList(sealManage); - if (selectSealList != null && selectSealList.size() > 0) { - for (SealManage manage : selectSealList) { - Integer sealStatus = manage.getSealStatus(); - Integer isUse = manage.getIsUse(); - if (sealStatus == 1 && isUse ==1) { - sealIdList.add(manage.getSealId()); - } - } - EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - 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);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); - msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), caseApplication.getCaseNum(),urlapplynew}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), caseApplication.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - SealSignRecord sealSignRecordMedi = new SealSignRecord(); - sealSignRecordMedi.setSignFlowid(signFlowId); - sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi()); - EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi); - JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class); - JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data"); - String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString(); - String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest(); - requestMedi.setTemplateId("2047719"); - requestMedi.setPhone(sealSignRecord.getPensonAccountMedi()); - requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), caseApplication.getCaseNum(),urlResponnewMedi}); - Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - } - } else { - return AjaxResult.error(); - } - } - - - }else { - return AjaxResult.error(); - } - }else { - return AjaxResult.error(); - } - }else { - return AjaxResult.error(); - } - } - }else { - // 查询附件 - List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id); - if (caseAttachList != null && caseAttachList.size() > 0) { - for (MsCaseAttach caseAttach : caseAttachList) { - if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { - String prefix = "/profile"; - int startIndex = prefix.length(); - String annexPath = caseAttach.getAnnexPath(); - String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - //获取文件上传地址 - EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); - String body = response.getBody(); - if (body != null) { - JSONObject jsonObject = JSONObject.parseObject(body); - String fileId = jsonObject.getJSONObject("data").getString("fileId"); - String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); - //上传文件流 - EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); - JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); - if (jsonObject1.getIntValue("errCode") == 0) { - //查看文件上传状态 - Thread.sleep(1000); - EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); - JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); - JSONObject data = jsonObject2.getJSONObject("data"); - int fileStatus = data.getIntValue("fileStatus"); - if (fileStatus == 2 || fileStatus == 5) { - String fileName = data.getString("fileName"); - //上传成功,获取文件签名印章位置 - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setFileid(fileId); - EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); - Gson gson = new Gson(); - JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); - JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); - String keywordPositions = positionsData.get("keywordPositions").toString(); - //发起签署 - sealSignRecord.setFilename(fileName); - - Long arbitratorId = caseApplication.getMediatorId(); - if (arbitratorId!=null) { - SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); - if (sysUser == null) { - return AjaxResult.error(); - } - sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); - sealSignRecord.setPensonNameMedi(sysUser.getNickName()); - } - - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone()); - sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName()); - - DeptIdentify deptIdentify = new DeptIdentify(); - deptIdentify.setIsUse(1); - DeptIdentify deptIdentifyselect = new DeptIdentify(); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); - if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { - deptIdentifyselect = deptIdentifysnew.get(0); - sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); - sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); - sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); - } else { - return AjaxResult.error("没有用印时的机构名称及经办人信息"); - } - - //解析文件签名印章位置 - JSONArray jsonArray = JSONArray.parseArray(keywordPositions); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsonObject3 = jsonArray.getJSONObject(i); - String keyword = jsonObject3.getString("keyword"); - if (keyword.equals("甲方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsn(positionX + 120); - sealSignRecord.setPositionYpsn(positionY); - } - }else if (keyword.equals("乙方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnRes(positionX + 120); - sealSignRecord.setPositionYpsnRes(positionY + 10); - } - }else if (keyword.equals("调解员(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnMedi(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnMedi(positionX + 120); - sealSignRecord.setPositionYpsnMedi(positionY + 10); - } - }else { - //用印 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPageorg(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXorg(positionX + 90); - sealSignRecord.setPositionYorg(positionY); - } - } - } - - if(isReconci.intValue()==1){ - EsignHttpResponse response3 = SignAward.createByFileReconci(sealSignRecord); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - 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);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), caseApplication.getCaseNum(),urlapplynew}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), caseApplication.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - - }else { - /*DeptIdentify deptIdentify1 = new DeptIdentify(); - deptIdentify1.setSealStatus(1); // 印章状态为启用 - //根据机构名称查询部门id - SysDept sysDept = new SysDept(); - sysDept.setDeptName(sealSignRecord.getOrgnizeName()); - List sysDepts = deptMapper.selectDeptList(sysDept); - if (sysDepts != null && sysDepts.size() > 0) { - Long deptId = sysDepts.get(0).getDeptId(); - deptIdentify1.setDeptId(deptId); - } - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentify1); - List sealIds = new ArrayList<>(); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - for (DeptIdentify identify : deptIdentifies) { - String sealId = identify.getSealId(); - sealIds.add(sealId); - } - }*/ - 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 iddeptIdent = deptIdentifies.get(0).getId(); - SealManage sealManage = new SealManage(); - sealManage.setIdentifyId(iddeptIdent); - List sealIdList = new ArrayList<>(); - List selectSealList = sealManageMapper.selectSealList(sealManage); - if (selectSealList != null && selectSealList.size() > 0) { - for (SealManage manage : selectSealList) { - Integer sealStatus = manage.getSealStatus(); - Integer isUse = manage.getIsUse(); - if (sealStatus == 1 && isUse ==1) { - sealIdList.add(manage.getSealId()); - } - } - EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - 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);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); - msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), caseApplication.getCaseNum(),urlapplynew}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), caseApplication.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - SealSignRecord sealSignRecordMedi = new SealSignRecord(); - sealSignRecordMedi.setSignFlowid(signFlowId); - sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi()); - EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi); - JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class); - JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data"); - String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString(); - String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest(); - requestMedi.setTemplateId("2047719"); - requestMedi.setPhone(sealSignRecord.getPensonAccountMedi()); - requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), caseApplication.getCaseNum(),urlResponnewMedi}); - Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - - } - - - } else { - return AjaxResult.error(); - } - } - }else{ - return AjaxResult.error(); - } - }else{ - return AjaxResult.error(); - } - } - break; - } - - } - - } - } - return AjaxResult.success(); - } - /** @@ -3732,21 +3254,58 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { /** * 生成调解申请书 * @param application 案件基本信息 - * @param affiliate 案件相关人员 + * @param affiliates 案件相关人员 * @param templatePath 模板路径 * @param bookmarkList 标签 * @param dictDataList 内置字段 */ @Transactional - public void createMediateApplication(MsCaseApplication application, MsCaseAffiliate affiliate, String templatePath, List bookmarkList, List dictDataList,Integer templateType) { + public void createMediateApplication(MsCaseApplication application, List affiliates, String templatePath, List bookmarkList, List dictDataList,Integer templateType) { // 申请书需要的字段和内容,valueMap<占位符,替换的值> Map valueMap = new HashMap<>(); + // 操作人信息 + Map> operatorMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getOperatorFlag, Collectors.toList())); + // 按角色分类 + Map roleTypeMap = affiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1)); +// Map> roleTypeMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getRoleType, Collectors.toList())); + for (SysDictData dictData : dictDataList) { if (CASE_BASE_COLUMN.contains(dictData.getDictValue())) { valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(application, dictData.getDictValue())); } else { - // 相关人员字段 - valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(affiliate, dictData.getDictValue())); + // todo 相关人员字段,如果有多个申请人,被申请人,模板需要变化,待讨论,暂做成取第一个操作人 + List msCaseAffiliates = operatorMap.get(1); + if(CollectionUtil.isNotEmpty(msCaseAffiliates)) { + Map roleTypeOperatorMap = msCaseAffiliates.stream().collect(Collectors.toMap(MsCaseAffiliate::getRoleType, Function.identity(), (k1, k2) -> k1)); + if(dictData.getDictLabel().contains("被申请人")){ + if(roleTypeOperatorMap.get(3)!=null ) { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(3), dictData.getDictValue())); + }else { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(3), dictData.getDictValue())); + } + }else if(dictData.getDictLabel().contains("被申请人委托代理人")){ + if(roleTypeOperatorMap.get(4)!=null ) { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(4), dictData.getDictValue())); + }else { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(4), dictData.getDictValue())); + } + }else if(dictData.getDictLabel().contains("申请人") + || dictData.getDictLabel().equals("统一社会信用代码") + || dictData.getDictLabel().equals("法定代表人") + ){ + if(roleTypeOperatorMap.get(1)!=null ) { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(1), dictData.getDictValue())); + }else { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(1), dictData.getDictValue())); + } + }else if(dictData.getDictLabel().contains("委托代理人")){ + if(roleTypeOperatorMap.get(2)!=null ) { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeOperatorMap.get(2), dictData.getDictValue())); + }else { + valueMap.put(dictData.getDictLabel(), ObjectFieldUtils.getValue(roleTypeMap.get(2), dictData.getDictValue())); + } + } + } } } @@ -4074,130 +3633,102 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { */ @Transactional public void insertAgentUser(MsCaseAffiliate affiliate) { - // 查询申请人角色id - Long roleId = roleMapper.selectRoleIdByName("申请人"); - // 根据代理人手机号去用户表查询,有修改,么有新增 - SysUser agentUser = userMapper.selectUserByPhone(affiliate.getContactTelphoneAgent()); - // 代理人为空,新增代理人 - if (agentUser == null) { - agentUser = new SysUser(); - agentUser.setUserName(affiliate.getContactTelphoneAgent()); - agentUser.setNickName(affiliate.getNameAgent()); - agentUser.setPhonenumber(affiliate.getContactTelphoneAgent()); - agentUser.setPassword(SecurityUtils.encryptPassword("abc123456")); - agentUser.setNationality(affiliate.getNationality()); - agentUser.setIdType(affiliate.getIdType()); - // agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId())); - userMapper.insertUser(agentUser); - userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); - // 新增部门用户关联表 - SysUserDept sysUserDept = new SysUserDept(); - sysUserDept.setUserId(agentUser.getUserId()); - sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId())); - userDeptMapper.insert(sysUserDept); - // 发送短信 2064355 调解系统自动创建用户短信通知 尊敬的用户,您的案件已经创建,请使用账号为{1},密码为{2}登录调解系统,请知晓,如非本人操作,请忽略本短信。 - Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2064355", affiliate.getContactTelphoneAgent(), new String[]{affiliate.getContactTelphoneAgent(), "abc123456"}); - } else { - // 查询所有部门 - List sysDepts = sysDeptMapper.selectDeptList(new SysDept()); - Map> deptMap=new HashMap<>(); - if(CollectionUtil.isNotEmpty(sysDepts)){ - deptMap = sysDepts.stream().collect(Collectors.groupingBy(SysDept::getDeptName)); - } - - if(!deptMap.containsKey(affiliate.getApplicationName())){ - // 如果不存在则新增 - SysDept dept = new SysDept(); - dept.setParentId(0L); - dept.setDeptName(affiliate.getApplicationName()); - dept.setAncestors("0"); - dept.setOrderNum(1); - dept.setStatus("0"); - dept.setDelFlag("0"); - dept.setCreateBy(getUsername()); - dept.setUpdateBy(getUsername()); - sysDeptMapper.insertDept(dept); - List depts = new ArrayList<>(); - depts.add(dept); - deptMap.put(dept.getDeptName(), depts); - affiliate.setApplicationId(String.valueOf(dept.getDeptId())); - affiliate.setApplicationName(affiliate.getApplicationName()); - }else { - // 将组织机构id设为申请人名称 - affiliate.setApplicationId(deptMap.get(affiliate.getApplicationName()).get(0).getDeptId().toString()); - affiliate.setApplicationName(affiliate.getApplicationName()); - } - // 根据userId查询部门 - List userDeptList = userDeptMapper.selectUserDeptById(agentUser.getUserId()); - if(CollectionUtil.isEmpty(userDeptList)){ - // 未关联部门,关联部门,新增部门用户关联表 - SysUserDept sysUserDept = new SysUserDept(); - sysUserDept.setUserId(agentUser.getUserId()); - sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId())); - userDeptMapper.insert(sysUserDept); - }else { - List deptIdList = userDeptList.stream().map(SysUserDept::getDeptId).collect(Collectors.toList()); - if(!deptIdList.contains(Long.valueOf(affiliate.getApplicationId()))){ - // 未关联该部门,关联部门,新增部门用户关联表 - SysUserDept sysUserDept = new SysUserDept(); - sysUserDept.setUserId(agentUser.getUserId()); - sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId())); - userDeptMapper.insert(sysUserDept); - // 同步用户表和案件关联人表的手机号和名称 - affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent()); - affiliate.setNameAgent(agentUser.getNickName()); - affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail()); - List longList = new ArrayList<>(); - // 新增角色为申请人 - if (CollectionUtil.isNotEmpty(agentUser.getRoles())) { - longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()); - if (!longList.contains(roleId)) { - // 删除之前关联的角色 - userRoleMapper.deleteUserRoleByUserId(agentUser.getUserId()); - userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); - } - } else { - userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); - } - - } - } - } +// // 查询申请人角色id +// Long roleId = roleMapper.selectRoleIdByName("申请人"); +// // 根据代理人邮箱去用户表查询,有修改,么有新增 +// SysUser agentUser = userMapper.selectUserByEmail(affiliate.getEmail()); +// // 代理人为空,新增代理人 +// if (agentUser == null) { +// agentUser = new SysUser(); +// agentUser.setUserName(affiliate.getEmail()); +// agentUser.setNickName(affiliate.getName()); +// agentUser.setPhonenumber(affiliate.getPhone()); +// agentUser.setPassword(SecurityUtils.encryptPassword("abc123456")); +// agentUser.setNationality(affiliate.getNationality()); +// agentUser.setIdType(affiliate.getIdType()); +// agentUser.setIdCard(affiliate.getIdCard()); +// agentUser.setSex(affiliate.getSex()); +// agentUser.setHome(affiliate.getHome()); +// agentUser.setAddress(affiliate.getAddress()); +// // agentUser.setDeptId(Long.valueOf(affiliate.getApplicationId())); +// userMapper.insertUser(agentUser); +// userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); +// // 新增部门用户关联表 +// SysUserDept sysUserDept = new SysUserDept(); +// sysUserDept.setUserId(agentUser.getUserId()); +// sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicantDeptId())); +// userDeptMapper.insert(sysUserDept); +// // todo 发送短信 2064355 调解系统自动创建用户短信通知 尊敬的用户,您的案件已经创建,请使用账号为{1},密码为{2}登录调解系统,请知晓,如非本人操作,请忽略本短信。 +// // Boolean smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2064355", affiliate.getContactTelphoneAgent(), new String[]{affiliate.getContactTelphoneAgent(), "abc123456"}); +// } else { +// // 查询所有部门 +// List sysDepts = sysDeptMapper.selectDeptList(new SysDept()); +// Map> deptMap=new HashMap<>(); +// if(CollectionUtil.isNotEmpty(sysDepts)){ +// deptMap = sysDepts.stream().collect(Collectors.groupingBy(SysDept::getDeptName)); +// } +// +// if(!deptMap.containsKey(affiliate.getName())){ +// // 如果不存在则新增 +// SysDept dept = new SysDept(); +// dept.setParentId(0L); +// dept.setDeptName(affiliate.getName()); +// dept.setAncestors("0"); +// dept.setOrderNum(1); +// dept.setStatus("0"); +// dept.setDelFlag("0"); +// dept.setCreateBy(getUsername()); +// dept.setUpdateBy(getUsername()); +// sysDeptMapper.insertDept(dept); +// List depts = new ArrayList<>(); +// depts.add(dept); +// deptMap.put(dept.getDeptName(), depts); +// affiliate.setApplicantDeptId(dept.getDeptId()); +// }else { +// // 将组织机构id设为申请人名称 +// affiliate.setApplicantDeptId(deptMap.get(affiliate.getName()).get(0).getDeptId()); +// +// } +// // 根据userId查询部门 +// List userDeptList = userDeptMapper.selectUserDeptById(agentUser.getUserId()); +// if(CollectionUtil.isEmpty(userDeptList)){ +// // 未关联部门,关联部门,新增部门用户关联表 +// SysUserDept sysUserDept = new SysUserDept(); +// sysUserDept.setUserId(agentUser.getUserId()); +// sysUserDept.setDeptId(affiliate.getApplicantDeptId()); +// userDeptMapper.insert(sysUserDept); +// }else { +// List deptIdList = userDeptList.stream().map(SysUserDept::getDeptId).collect(Collectors.toList()); +// if(!deptIdList.contains(affiliate.getApplicantDeptId())){ +// // 未关联该部门,关联部门,新增部门用户关联表 +// SysUserDept sysUserDept = new SysUserDept(); +// sysUserDept.setUserId(agentUser.getUserId()); +// sysUserDept.setDeptId(Long.valueOf(affiliate.getApplicationId())); +// userDeptMapper.insert(sysUserDept); +// // 同步用户表和案件关联人表的手机号和名称 +// affiliate.setContactTelphoneAgent(StrUtil.isNotEmpty(agentUser.getPhonenumber()) ? agentUser.getPhonenumber() : affiliate.getContactTelphoneAgent()); +// affiliate.setNameAgent(agentUser.getNickName()); +// affiliate.setAgentEmail(StrUtil.isNotEmpty(agentUser.getEmail()) ? agentUser.getEmail() : affiliate.getAgentEmail()); +// List longList = new ArrayList<>(); +// // 新增角色为申请人 +// if (CollectionUtil.isNotEmpty(agentUser.getRoles())) { +// longList = agentUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()); +// if (!longList.contains(roleId)) { +// // 删除之前关联的角色 +// userRoleMapper.deleteUserRoleByUserId(agentUser.getUserId()); +// userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); +// } +// } else { +// userRoleMapper.insertUserRole(agentUser.getUserId(), roleId); +// } +// +// } +// } +// } } /** - * 新增部门 - * - * @param affiliate - */ - @Transactional - public void insertDept(MsCaseAffiliate affiliate) { - // 查询所有的组织机构,组装成map - List deptList = sysDeptMapper.selectDeptList(new SysDept()); - if (CollectionUtil.isEmpty(deptList)) { - deptList = new ArrayList<>(); - } - Map deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId, (oldV, newV) -> newV)); - // 将组织机构id设为申请人名称 - if (deptMap.containsKey(affiliate.getApplicationName())) { - affiliate.setApplicationId(String.valueOf(deptMap.get(affiliate.getApplicationName()))); - } else { - // 如果不存在则新增 - SysDept dept = new SysDept(); - dept.setParentId(0L); - dept.setDeptName(affiliate.getApplicationName()); - dept.setAncestors("0"); - dept.setOrderNum(1); - dept.setStatus("0"); - dept.setDelFlag("0"); - dept.setCreateBy(getUsername()); - dept.setUpdateBy(getUsername()); - sysDeptMapper.insertDept(dept); - deptMap.put(dept.getDeptName(), dept.getDeptId()); - affiliate.setApplicationId(String.valueOf(dept.getDeptId())); - } - } /** * 获取案件编码 diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java index 262359a..b90b50a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/MsCasePaymentServiceImpl.java @@ -12,6 +12,7 @@ import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.enums.AnnexTypeEnum; import com.ruoyi.common.enums.PaymentStatusEnum; import com.ruoyi.common.enums.YesOrNoEnum; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SmsUtils; import com.ruoyi.common.utils.spring.SpringUtils; @@ -40,6 +41,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Service public class MsCasePaymentServiceImpl implements MsCasePaymentService { @@ -226,7 +228,7 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } JSONObject jsonObject = new JSONObject(); jsonObject.set("totalFee", totalFee); - jsonObject.set("applicationOrganName", affiliate.getApplicationName()); + // jsonObject.set("applicationOrganName", affiliate.getApplicationName()); return AjaxResult.success(jsonObject); } @@ -248,10 +250,6 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { result.setCaseSubjectAmount(application.getCaseSubjectAmount()); result.setFeePayable(application.getFeePayable()); result.setCaseStatusName(application.getCaseStatusName()); - MsCaseAffiliate affiliate = caseAffiliateMapper.selectByPrimaryKey(application.getId()); - if(affiliate != null) { - result.setApplicationOrganName(affiliate.getApplicationName()); - } // 查询缴费单 result.setCaseAttachList(caseAttachMapper.listCaseAttachByCaseIdAndType(id, AnnexTypeEnum.PAYMENT_RECEIPT.getCode())); result.setResCaseAttachList(caseAttachMapper.listCaseAttachByCaseIdAndType(id, AnnexTypeEnum.RES_PAYMENT_RECEIPT.getCode())); @@ -369,12 +367,78 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } auditMapper.insert(audit); } - // 查询申请人电话,如果是自然人,代理人不为空,则给代理人发短信,代理人为空,给申请人发短信 - MsCaseAffiliate affiliate = caseAffiliateMapper.selectByPrimaryKey(application.getId()); - // 发送缴费通知 - sendPaymentSms(dto,caseAppllication, affiliate,flow); - + // 查询案件人员 + List affiliates = applicationService.selectAffliatesByCaseId(application.getId()); + if(CollectionUtil.isEmpty(affiliates)){ + throw new ServiceException("未找到案件相关人员"); + } + List operatorList = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() != null && affiliate.getOperatorFlag().equals(1) && StrUtil.isNotEmpty(affiliate.getPhone())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(operatorList)){ + throw new ServiceException("未找到案件操作人员"); + } + if(dto.getApplicantConfirm()) { + // 申请人确认缴费 + for (MsCaseAffiliate affiliate : operatorList) { + // 发送缴费通知 + if (affiliate.getRoleType() == null) { + continue; + } + if (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2)) { + Boolean smsFlag = true; + SmsSendRecord smsSendRecord = null; + if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { + // 缴费通过 + smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2051914", affiliate.getPhone(), new String[]{affiliate.getName()}); + smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), affiliate.getPhone(), new Date(), "尊敬的" + affiliate.getName() + ",您的调解申请费用已缴费成功。"); + } else { + smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2074402", affiliate.getPhone(), new String[]{affiliate.getName(), caseAppllication.getCaseNum(), dto.getReason()}); + // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信 + smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), affiliate.getPhone(), new Date(), "尊敬的" + affiliate.getName() + "用户,您的" + caseAppllication.getCaseNum() + "案件,确认缴费未通过,理由为" + dto.getReason() + ",请知晓,如非本人操作,请忽略本短信"); + } + // 新增短信记录 + if (smsFlag) { + smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(smsSendRecord); + } + } + }else { + // 被申请人确认缴费 + for (MsCaseAffiliate affiliate : operatorList) { + // 发送缴费通知 + if (affiliate.getRoleType() == null) { + continue; + } + if (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4)) { + Boolean smsFlag = true; + SmsSendRecord smsSendRecord = null; + if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { + // 缴费通过 + smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2051914", affiliate.getPhone(), new String[]{affiliate.getName()}); + smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), affiliate.getPhone(), new Date(), "尊敬的" + affiliate.getName() + ",您的调解申请费用已缴费成功。"); + } else { + smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2074402", affiliate.getPhone(), new String[]{affiliate.getName(), caseAppllication.getCaseNum(), dto.getReason()}); + // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信 + smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), affiliate.getPhone(), new Date(), "尊敬的" + affiliate.getName() + "用户,您的" + caseAppllication.getCaseNum() + "案件,确认缴费未通过,理由为" + dto.getReason() + ",请知晓,如非本人操作,请忽略本短信"); + } + // 新增短信记录 + if (smsFlag) { + smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + } else { + smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + } + smsRecordMapper.saveSmsSendRecord(smsSendRecord); + } + // 被申请人确认缴费,发送受理通知 + if( dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { + // 申请人发送受理短信 + casePaymentService.sendAcceptSms(dto, caseAppllication, affiliate.getName(), affiliate.getPhone()); + } + } + } } @@ -395,76 +459,15 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } - /** - * 发送缴费短信 - * @param dto - * @param caseAppllication - * @param affiliate - */ - private void sendPaymentSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication, MsCaseAffiliate affiliate,MsCaseFlow flow) { - if (affiliate != null) { - // 受理通知 - String phone = ""; - String userName = ""; - // 缴费通知 - String payPhone = ""; - String payUserName = ""; - if (affiliate.getOrganizeFlag().equals(0)) { - // 自然人 - if (StrUtil.isNotEmpty(affiliate.getContactTelphoneAgent())) { - phone = affiliate.getContactTelphoneAgent(); - userName = affiliate.getNameAgent(); - } else { - phone = affiliate.getApplicationPhone(); - userName = affiliate.getApplicationName(); - } - } else { - phone = affiliate.getContactTelphoneAgent(); - userName = affiliate.getNameAgent(); - } - if (StrUtil.isNotEmpty(phone)) { - payPhone=phone; - payUserName=userName; - if(!dto.getApplicantConfirm()) { - // 被申请人发送通知 - payPhone=affiliate.getRespondentPhone(); - payUserName=affiliate.getRespondentName(); - } - Boolean smsFlag =true; - SmsSendRecord smsSendRecord=null; - // 申请人被申请人发送缴费成功短信 2051914 调解缴费成功通知 尊敬的{1},您的调解申请费用已缴费成功。 - if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { - smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2051914", payPhone, new String[]{payUserName}); - smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), payPhone, new Date(), "尊敬的" + payUserName + ",您的调解申请费用已缴费成功。"); - } else { - smsFlag = SmsUtils.sendSms(affiliate.getCaseAppliId(), "2074402", payPhone, new String[]{payUserName, caseAppllication.getCaseNum(), dto.getReason()}); - // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信 - smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), payPhone, new Date(), "尊敬的" + payUserName + "用户,您的" + caseAppllication.getCaseNum() + "案件,确认缴费未通过,理由为" + dto.getReason() + ",请知晓,如非本人操作,请忽略本短信"); - } - // 新增短信记录 - if (smsFlag) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - if(!dto.getApplicantConfirm()&& dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { - // 申请人发送受理短信 - sendAcceptSms(dto, caseAppllication, userName, phone); - // 被申请人发送受理短信 - sendAcceptSms(dto, caseAppllication, affiliate.getRespondentName(), affiliate.getRespondentPhone()); - } - } - } - } /** * 发送受理短信 * @param dto * @param caseAppllication */ - private void sendAcceptSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication,String userName,String phone ) { + @Transactional + public void sendAcceptSms(CaseConfirmPayDTO dto, MsCaseApplication caseAppllication,String userName,String phone ) { // 申请人被申请人发送受理通知书 2073601 尊敬的{1}用户,您的{2}案件,已成功受理,请知晓,如非本人操作,请忽略本短信。 Boolean smsFlag = SmsUtils.sendSms(caseAppllication.getId(), "2073601", phone, new String[]{userName, caseAppllication.getCaseNum()}); SmsSendRecord smsSendRecord = new SmsSendRecord(caseAppllication.getId(), caseAppllication.getCaseNum(), phone, new Date(), "尊敬的" + userName + "用户,您的" + caseAppllication.getCaseNum() + "案件,已成功受理,请知晓,如非本人操作,请忽略本短信。"); 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 6b50870..515950e 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 @@ -4,8 +4,8 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonArray; @@ -16,18 +16,20 @@ import com.ruoyi.common.core.domain.entity.EsignHttpResponse; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.enums.AnnexTypeEnum; +import com.ruoyi.common.enums.AttachmentOperateTypeEnum; +import com.ruoyi.common.enums.PushCaseStatusEnum; import com.ruoyi.common.enums.YesOrNoEnum; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.EmailOutUtil; import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.SmsUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.SaaSAPIFileUtils; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.flow.MsCaseFlowMapper; +import com.ruoyi.system.service.impl.BeiMingInterfaceService; import com.ruoyi.wisdomarbitrate.domain.dto.dept.DeptIdentify; import com.ruoyi.wisdomarbitrate.domain.dto.dept.SealManage; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseLogRecord; @@ -40,6 +42,7 @@ import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseLogRecord; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO; +import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO; import com.ruoyi.wisdomarbitrate.mapper.dept.DeptIdentifyMapper; import com.ruoyi.wisdomarbitrate.mapper.dept.MsSealSignRecordMapper; @@ -54,6 +57,7 @@ import com.ruoyi.wisdomarbitrate.service.mscase.MsSignSealService; import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; import com.ruoyi.wisdomarbitrate.utils.SignAward; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import tk.mybatis.mapper.entity.Example; @@ -106,286 +110,19 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Autowired private SendMailRecordMapper sendMailRecordMapper; + // 北明配置 + @Value("${BMConfig.userName}") + private String BMUserName; + @Value("${BMConfig.password}") + private String BMPassword; + @Value("${BMConfig.syncSource}") + private String BMSyncSource; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; - @Override - @Transactional - public AjaxResult sureMediationSeal(MsCaseApplicationVO caseApplicationVO) throws EsignDemoException, InterruptedException { - Long id = caseApplicationVO.getId(); - MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id); - // 查询案件相关人员 - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); - // 查询附件 - List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id); - if (caseAttachList != null && caseAttachList.size() > 0) { - for (MsCaseAttach caseAttach : caseAttachList) { - if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { -// String annexPath = caseAttach.getAnnexPath(); -// String path = "/home/ruoyi" + annexPath; - String prefix = "/profile"; - int startIndex = prefix.length(); - String annexPath = caseAttach.getAnnexPath(); -// String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - String path = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\12\\f8551b0e003e4af89acae7b500dacb77调解书.docx"; - //获取文件上传地址 - EsignHttpResponse response = SaaSAPIFileUtils.getUploadUrl(path); - String body = response.getBody(); - if (body != null) { - JSONObject jsonObject = JSONObject.parseObject(body); - String fileId = jsonObject.getJSONObject("data").getString("fileId"); - String fileUploadUrl = jsonObject.getJSONObject("data").getString("fileUploadUrl"); - //上传文件流 - EsignHttpResponse response1 = SaaSAPIFileUtils.uploadFile(fileUploadUrl, path); - JSONObject jsonObject1 = JSONObject.parseObject(response1.getBody()); - if (jsonObject1.getIntValue("errCode") == 0) { - //查看文件上传状态 - Thread.sleep(1000); - EsignHttpResponse response2 = SaaSAPIFileUtils.getFileStatus(fileId); - JSONObject jsonObject2 = JSONObject.parseObject(response2.getBody()); - JSONObject data = jsonObject2.getJSONObject("data"); - int fileStatus = data.getIntValue("fileStatus"); - if (fileStatus == 2 || fileStatus == 5) { - String fileName = data.getString("fileName"); - //上传成功,获取文件签名印章位置 - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setFileid(fileId); - EsignHttpResponse positions = SignAward.getPositionsMediation(sealSignRecord); - Gson gson = new Gson(); - JsonObject positionsJsonObject = gson.fromJson(positions.getBody(), JsonObject.class); - JsonObject positionsData = positionsJsonObject.getAsJsonObject("data"); - String keywordPositions = positionsData.get("keywordPositions").toString(); - //发起签署 - sealSignRecord.setFilename(fileName); - - Long arbitratorId = caseApplication.getMediatorId(); - if (arbitratorId!=null) { - SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); - if (sysUser == null) { - return AjaxResult.error(); - } - sealSignRecord.setPensonAccountMedi(sysUser.getPhonenumber()); - sealSignRecord.setPensonNameMedi(sysUser.getNickName()); - } - - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - sealSignRecord.setPensonAccountRes(caseAffiliate.getRespondentPhone()); - sealSignRecord.setPensonNameRes(caseAffiliate.getRespondentName()); - - DeptIdentify deptIdentify = new DeptIdentify(); - deptIdentify.setIsUse(1); - DeptIdentify deptIdentifyselect = new DeptIdentify(); - List deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify); - if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) { - deptIdentifyselect = deptIdentifysnew.get(0); - sealSignRecord.setOrgnizeName(deptIdentifyselect.getIdentifyName()); - sealSignRecord.setOrgnizeNamePsnAccount(deptIdentifyselect.getOperPhone()); - sealSignRecord.setOrgnizeNamepsnName(deptIdentifyselect.getOperName()); - } else { - return AjaxResult.error("没有用印时的机构名称及经办人信息"); - } - - //解析文件签名印章位置 - JSONArray jsonArray = JSONArray.parseArray(keywordPositions); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsonObject3 = jsonArray.getJSONObject(i); - String keyword = jsonObject3.getString("keyword"); - if (keyword.equals("甲方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsn(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsn(positionX + 90); - sealSignRecord.setPositionYpsn(positionY + 30); - } - }else if (keyword.equals("乙方(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnRes(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnRes(positionX + 90); - sealSignRecord.setPositionYpsnRes(positionY); - } - }else if (keyword.equals("调解员(签字):")) { - //签名 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPagepsnMedi(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXpsnMedi(positionX + 90); - sealSignRecord.setPositionYpsnMedi(positionY); - } - }else { - //用印 - JSONArray positionsArray = jsonObject3.getJSONArray("positions"); - // 遍历 positionsArray 中的每个元素 - for (int j = 0; j < positionsArray.size(); j++) { - JSONObject positionObj = positionsArray.getJSONObject(j); - int pageNum = positionObj.getIntValue("pageNum"); - sealSignRecord.setPositionPageorg(String.valueOf(pageNum)); - JSONArray coordinatesArray = positionObj.getJSONArray("coordinates"); - JSONObject coordinateObj = coordinatesArray.getJSONObject(0); - double positionX = coordinateObj.getDoubleValue("positionX"); - double positionY = coordinateObj.getDoubleValue("positionY"); - sealSignRecord.setPositionXorg(positionX + 90); - sealSignRecord.setPositionYorg(positionY); - } - } - } - /*DeptIdentify deptIdentify1 = new DeptIdentify(); - deptIdentify1.setSealStatus(1); // 印章状态为启用 - //根据机构名称查询部门id - SysDept sysDept = new SysDept(); - sysDept.setDeptName(sealSignRecord.getOrgnizeName()); - List sysDepts = deptMapper.selectDeptList(sysDept); - if (sysDepts != null && sysDepts.size() > 0) { - Long deptId = sysDepts.get(0).getDeptId(); - deptIdentify1.setDeptId(deptId); - } - List deptIdentifies = deptIdentifyMapper.selectDeptIdentifylistother(deptIdentify1); - List sealIds = new ArrayList<>(); - if (deptIdentifies != null && deptIdentifies.size() > 0) { - for (DeptIdentify identify : deptIdentifies) { - String sealId = identify.getSealId(); - sealIds.add(sealId); - } - }*/ - 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 iddeptIdent = deptIdentifies.get(0).getId(); - SealManage sealManage = new SealManage(); - sealManage.setIdentifyId(iddeptIdent); - List sealIdList = new ArrayList<>(); - List selectSealList = sealManageMapper.selectSealList(sealManage); - if (selectSealList != null && selectSealList.size() > 0) { - for (SealManage manage : selectSealList) { - Integer sealStatus = manage.getSealStatus(); - Integer isUse = manage.getIsUse(); - if (sealStatus == 1 && isUse ==1) { - sealIdList.add(manage.getSealId()); - } - } - EsignHttpResponse response3 = SignAward.createByFileMediation(sealSignRecord, sealIdList); - - JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody()); - if (jsonObject3 != null) { - 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);//待签名 - MsSealSignRecord msSealSignRecord = new MsSealSignRecord(); - BeanUtil.copyProperties(sealSignRecord, msSealSignRecord); - msSealSignRecord.setFileId(sealSignRecord.getFileid()); - msSealSignRecord.setFileName(sealSignRecord.getFilename()); - msSealSignRecord.setSignFlowId(sealSignRecord.getSignFlowid()); - msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); - msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); - sealSignRecordMapper.insert(msSealSignRecord); - - SealSignRecord sealSignRecordapply = new SealSignRecord(); - sealSignRecordapply.setSignFlowid(signFlowId); - sealSignRecordapply.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecordapply); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - String urlapplynew = urlapply.substring(urlapply.lastIndexOf("/")+1); - - //发送签名链接短信,尊敬的{1}用户,您的{2}调解案件,签名链接{3},请点击链接签名,如非本人操作,请忽略本短信 - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("2047719"); - request.setPhone(caseAffiliate.getContactTelphoneAgent()); - request.setTemplateParamSet(new String[]{caseAffiliate.getNameAgent(), caseApplication.getCaseNum(),urlapplynew}); - Boolean aBoolean = SmsUtils.sendSms(request); - - SealSignRecord sealSignRecordRespon = new SealSignRecord(); - sealSignRecordRespon.setSignFlowid(signFlowId); - sealSignRecordRespon.setPensonAccount(caseAffiliate.getRespondentPhone()); - EsignHttpResponse signUrlRespon = SignAward.signUrlMediation(sealSignRecordRespon); - JsonObject signUrlJsonObjectRespon = gson.fromJson(signUrlRespon.getBody(), JsonObject.class); - JsonObject signUrlDataRespon = signUrlJsonObjectRespon.getAsJsonObject("data"); - String urlRespon = signUrlDataRespon.get("shortUrl").getAsString(); - String urlResponnew = urlRespon.substring(urlRespon.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest request1 = new SmsUtils.SendSmsRequest(); - request1.setTemplateId("2047719"); - request1.setPhone(caseAffiliate.getRespondentPhone()); - request1.setTemplateParamSet(new String[]{caseAffiliate.getRespondentName(), caseApplication.getCaseNum(),urlResponnew}); - Boolean aBoolean1 = SmsUtils.sendSms(request1); - - SealSignRecord sealSignRecordMedi = new SealSignRecord(); - sealSignRecordMedi.setSignFlowid(signFlowId); - sealSignRecordMedi.setPensonAccount(sealSignRecord.getPensonAccountMedi()); - EsignHttpResponse signUrlResponMedi = SignAward.signUrlMediation(sealSignRecordMedi); - JsonObject signUrlJsonObjectResponMedi = gson.fromJson(signUrlResponMedi.getBody(), JsonObject.class); - JsonObject signUrlDataResponMedi = signUrlJsonObjectResponMedi.getAsJsonObject("data"); - String urlResponMedi = signUrlDataResponMedi.get("shortUrl").getAsString(); - String urlResponnewMedi = urlResponMedi.substring(urlResponMedi.lastIndexOf("/")+1); - - SmsUtils.SendSmsRequest requestMedi = new SmsUtils.SendSmsRequest(); - requestMedi.setTemplateId("2047719"); - requestMedi.setPhone(sealSignRecord.getPensonAccountMedi()); - requestMedi.setTemplateParamSet(new String[]{sealSignRecord.getPensonNameMedi(), caseApplication.getCaseNum(),urlResponnewMedi}); - Boolean aBooleanMedi = SmsUtils.sendSms(requestMedi); - - } else { - throw new ServiceException(jsonObject3.getString("message")); - } - } else { - return AjaxResult.error(); - } - - } - - - } else { - return AjaxResult.error(); - } - } - } - } - break; - } - - } - - } - return AjaxResult.success(); - } @Override @Transactional @@ -457,8 +194,6 @@ public class MsSignSealServiceImpl implements MsSignSealService { public AjaxResult selectCaseProgress(MsSignSealDTO dto) { Map datas = new HashMap<>(); Long id = dto.getCaseId(); -// MsCaseLogRecord caseLogRecord = new MsCaseLogRecord(); -// caseLogRecord.setCaseAppliId(id); List records = caseLogRecordMapper.selectCaseLogRecordListCaseProgress(dto.getCaseId()); MsCaseApplication caseApplicationselect = msCaseApplicationMapper.selectByPrimaryKey(id); @@ -468,7 +203,6 @@ public class MsSignSealServiceImpl implements MsSignSealService { List recordsNew = new ArrayList<>(); if (records != null && records.size() > 0) { for (MsCaseLogRecordVO msCaseLogRecordVO : records) { -// String content = msCaseLogRecordVO.getContent(); String content = msCaseLogRecordVO.getCaseStatusName(); if(StringUtils.isNotEmpty(content)){ if(content.equals("结束")){ @@ -594,6 +328,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Override @Transactional(rollbackFor = Exception.class) public AjaxResult msCaseFile(List ids){ + // todo try { for (Long id : ids) { MsCaseApplication caseApplication1 = msCaseApplicationMapper.selectByPrimaryKey(id); @@ -606,10 +341,6 @@ public class MsSignSealServiceImpl implements MsSignSealService { if (caseAttachList != null && caseAttachList.size() > 0) { for (MsCaseAttach caseAttach : caseAttachList) { if (caseAttach.getAnnexType() == AnnexTypeEnum.MEDIATE_BOOK.getCode()) { -// String annexName = caseAttach.getAnnexName(); -// String prefix = "/profile/upload/"; -// int startIndex = prefix.length(); -// String path = caseAttach.getAnnexPath() + annexName.substring(startIndex); String prefix = "/profile"; int startIndex = prefix.length(); String annexPath = caseAttach.getAnnexPath(); @@ -638,9 +369,6 @@ public class MsSignSealServiceImpl implements MsSignSealService { 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; @@ -687,61 +415,48 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName()); caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1); - String appEmail = ""; - String resEmail = ""; - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); + // 获取案件相关人员 + List affiliates = applicationService.selectAffliatesByCaseId(id); + if(CollectionUtil.isEmpty(affiliates)){ + return AjaxResult.error("未找到案件相关人员"); + } + List oprratorList = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() != null + && affiliate.getOperatorFlag() == 1 && StrUtil.isNotEmpty(affiliate.getEmail())) + .collect(Collectors.toList()); + if(CollectionUtil.isEmpty(oprratorList)){ + return AjaxResult.error("未找到案件操作人员"); + } - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - if(organizeFlag!=null){ - if(organizeFlag.intValue()==1){ - appEmail = caseAffiliate.getAgentEmail(); - }else { - appEmail = caseAffiliate.getApplicationEmail(); + for (MsCaseAffiliate affiliate : oprratorList) { + if(affiliate.getRoleType()==null){ + continue; } - } - resEmail = caseAffiliate.getRespondentEmail(); - boolean appEmailFlag = sendCaseEmail(caseApplication1, appEmail, caseAttachList); + boolean appEmailFlag = sendCaseEmail(caseApplication1, affiliate.getEmail(), caseAttachList); - SendMailRecord sendMailRecord = new SendMailRecord(); - sendMailRecord.setCaseId(id); - sendMailRecord.setMailAddress(appEmail); - sendMailRecord.setMailContent("您好,审核后的调解书在附件中请查阅"); -// sendMailRecord.setMailContent("您好,您的{"+caseApplication1.getCaseNum()+"}案件,审核后的裁决书在附件中请查阅"); - sendMailRecord.setMailName("签署后的调解书"); - sendMailRecord.setSendTime(new Date()); - sendMailRecord.setCreateBy(SecurityUtils.getUsername()); - if (appEmailFlag) { - sendMailRecord.setSendStatus(1); - } else { - sendMailRecord.setSendStatus(0); + SendMailRecord sendMailRecord = new SendMailRecord(); + sendMailRecord.setCaseId(id); + sendMailRecord.setMailAddress(affiliate.getEmail()); + sendMailRecord.setMailContent("您好,审核后的调解书在附件中请查阅"); + sendMailRecord.setMailName("签署后的调解书"); + sendMailRecord.setSendTime(new Date()); + sendMailRecord.setCreateBy(SecurityUtils.getUsername()); + if (appEmailFlag) { + sendMailRecord.setSendStatus(1); + } else { + sendMailRecord.setSendStatus(0); + } + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); } - sendMailRecordMapper.saveSendMailRecord(sendMailRecord); - boolean resEmailFlag = sendCaseEmail(caseApplication1, resEmail, caseAttachList); - - SendMailRecord sendMailRecord1 = new SendMailRecord(); - sendMailRecord1.setCaseId(id); - sendMailRecord1.setMailAddress(resEmail); -// sendMailRecord.setMailContent("您好,您的{"+caseApplication1.getCaseNum()+"}案件,审核后的裁决书在附件中请查阅"); - sendMailRecord1.setMailContent("您好,审核后的调解书在附件中请查阅"); - sendMailRecord1.setMailName("签署后的调解书"); - sendMailRecord1.setSendTime(new Date()); - sendMailRecord1.setCreateBy(SecurityUtils.getUsername()); - if (resEmailFlag) { - sendMailRecord1.setSendStatus(1); - }else { - sendMailRecord1.setSendStatus(0); - } - sendMailRecordMapper.saveSendMailRecord(sendMailRecord1); - if(!appEmailFlag&&!resEmailFlag){ - throw new ServiceException("调解书发送失败"); - } - if(!appEmailFlag){ - throw new ServiceException("申请人调解书发送失败"); - } - if(!resEmailFlag){ - throw new ServiceException("被申请人调解书发送失败"); - } +// if(!appEmailFlag&&!resEmailFlag){ +// throw new ServiceException("调解书发送失败"); +// } +// if(!appEmailFlag){ +// throw new ServiceException("申请人调解书发送失败"); +// } +// if(!resEmailFlag){ +// throw new ServiceException("被申请人调解书发送失败"); +// } CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); @@ -778,8 +493,10 @@ public class MsSignSealServiceImpl implements MsSignSealService { // } // } if (dto.getIsSignApply() != null && dto.getIsSignApply().intValue() == 1) { - caseAffiliate.setIsSignApply(1); - msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); + // todo 签收不要该字段 + // caseAffiliate.setIsSignApply(1); + // todo 签收不要该字段 + // msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); // 根据流程id查找下一个流程节点 MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); @@ -802,8 +519,10 @@ public class MsSignSealServiceImpl implements MsSignSealService { // } if (dto.getIsSignRespon() != null && dto.getIsSignRespon().intValue() == 1) { - caseAffiliate.setIsSignRespon(1); - msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); + // todo 签收不要该字段 +// caseAffiliate.setIsSignRespon(1); + // todo 签收不要该字段 +// msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); // 根据流程id查找下一个流程节点 MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); @@ -811,6 +530,11 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null); + CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), 17, "结束", null); + // todo 被申请人签收结束对接北明,为调解成功状态 + if(StrUtil.isEmpty(caseApplicationselect.getCaseSource())) { + applicationService.pushStatusToBM(caseApplicationselect, PushCaseStatusEnum.SUCCESS); + } } return AjaxResult.success("签收成功"); @@ -819,12 +543,29 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Override public AjaxResult msCaseSignUrlApplyPC(MsSignSealDTO dto) throws EsignDemoException { + // todo Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); + //MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); + List affiliates = applicationService.selectAffliatesByCaseId(caseId); + if(CollectionUtil.isEmpty(affiliates)){ + return AjaxResult.error("未找到案件相关人员"); + } + List operatorList = affiliates.stream().filter(msCaseAffiliate -> msCaseAffiliate.getOperatorFlag() != null + && msCaseAffiliate.getOperatorFlag() == 1 + && StrUtil.isNotEmpty(msCaseAffiliate.getPhone())).collect(Collectors.toList()); + Optional appOpt =null; + Optional resOpt =null; + if(CollectionUtil.isNotEmpty(operatorList)){ + appOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null + && (msCaseAffiliate.getRoleType() == 1 || msCaseAffiliate.getRoleType() == 2)) + .findFirst(); + resOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null + && (msCaseAffiliate.getRoleType() == 3 || msCaseAffiliate.getRoleType() == 4)) + .findFirst(); + } MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(caseId); - + Integer organizeFlag = caseApplication.getOrganizeFlag(); SysUser user = new SysUser(); Long userId = SecurityUtils.getUserId(); user.setUserId(userId); @@ -836,6 +577,9 @@ public class MsSignSealServiceImpl implements MsSignSealService { } List roleNames = allSysRole.stream().map(SysRole::getRoleName).collect(Collectors.toList()); if(roleNames.contains("申请人")){ + if(appOpt==null || !appOpt.isPresent()){ + return AjaxResult.error("未找到案件申请操作人"); + } SealSignRecord sealSignRecordres = new SealSignRecord(); MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); mssealSignRecord.setCaseAppliId(caseId); @@ -844,19 +588,8 @@ public class MsSignSealServiceImpl implements MsSignSealService { String signFlowid = sealSignRecords.get(0).getSignFlowId(); if(organizeFlag!=null){ SealSignRecord sealSignRecord = new SealSignRecord(); - if(organizeFlag.intValue()==1){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - sealSignRecord.setPensonAccount(caseAffiliate.getApplicationPhone()); - sealSignRecord.setPensonName(caseAffiliate.getApplicationName()); - } - } + sealSignRecord.setPensonAccount(appOpt.get().getPhone()); + sealSignRecord.setPensonName(appOpt.get().getName()); sealSignRecord.setSignFlowid(signFlowid); Gson gson = new Gson(); @@ -873,6 +606,9 @@ public class MsSignSealServiceImpl implements MsSignSealService { }else if(roleNames.contains("被申请人")){ + if(resOpt==null || !resOpt.isPresent()){ + return AjaxResult.error("未找到案件申请操作人"); + } SealSignRecord sealSignRecordres = new SealSignRecord(); MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); mssealSignRecord.setCaseAppliId(caseId); @@ -880,7 +616,8 @@ public class MsSignSealServiceImpl implements MsSignSealService { if (sealSignRecords != null && sealSignRecords.size() > 0) { String signFlowid = sealSignRecords.get(0).getSignFlowId(); SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setPensonAccount(caseAffiliate.getRespondentPhone()); + sealSignRecord.setPensonAccount(resOpt.get().getPhone()); + sealSignRecord.setPensonName(resOpt.get().getName()); sealSignRecord.setSignFlowid(signFlowid); Gson gson = new Gson(); @@ -927,95 +664,6 @@ public class MsSignSealServiceImpl implements MsSignSealService { return AjaxResult.success(); } - @Override - public AjaxResult msCaseSignUrlResPC(MsSignSealDTO dto) throws EsignDemoException { - Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); - SealSignRecord sealSignRecordres = new SealSignRecord(); - MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); - mssealSignRecord.setCaseAppliId(caseId); - List sealSignRecords = sealSignRecordMapper.selectSealSignRecord(mssealSignRecord); - if (sealSignRecords != null && sealSignRecords.size() > 0) { - String signFlowid = sealSignRecords.get(0).getSignFlowId(); - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setPensonAccount(caseAffiliate.getRespondentPhone()); - sealSignRecord.setSignFlowid(signFlowid); - - Gson gson = new Gson(); - EsignHttpResponse signUrl = SignAward.signUrl(sealSignRecord); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - sealSignRecordres.setSealUrl(urlapply); - } - - return AjaxResult.success(sealSignRecordres); - } - - @Override - public AjaxResult msCaseSignUrlApplyAPP(MsSignSealDTO dto) throws EsignDemoException { - Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - SealSignRecord sealSignRecordres = new SealSignRecord(); - MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); - mssealSignRecord.setCaseAppliId(caseId); - List sealSignRecords = sealSignRecordMapper.selectSealSignRecord(mssealSignRecord); - if (sealSignRecords != null && sealSignRecords.size() > 0) { - String signFlowid = sealSignRecords.get(0).getSignFlowId(); - if(organizeFlag!=null){ - SealSignRecord sealSignRecord = new SealSignRecord(); - if(organizeFlag.intValue()==1){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - String nameAgent = caseAffiliate.getNameAgent(); - if(StringUtils.isNotBlank(nameAgent)){ - sealSignRecord.setPensonAccount(caseAffiliate.getContactTelphoneAgent()); - sealSignRecord.setPensonName(caseAffiliate.getNameAgent()); - }else { - sealSignRecord.setPensonAccount(caseAffiliate.getApplicationPhone()); - sealSignRecord.setPensonName(caseAffiliate.getApplicationName()); - } - } - sealSignRecord.setSignFlowid(signFlowid); - - Gson gson = new Gson(); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecord); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - sealSignRecordres.setSealUrl(urlapply); - } - } - return AjaxResult.success(sealSignRecordres); - - } - - @Override - public AjaxResult msCaseSignUrlResAPP(MsSignSealDTO dto) throws EsignDemoException { - Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); - SealSignRecord sealSignRecordres = new SealSignRecord(); - MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); - mssealSignRecord.setCaseAppliId(caseId); - List sealSignRecords = sealSignRecordMapper.selectSealSignRecord(mssealSignRecord); - if (sealSignRecords != null && sealSignRecords.size() > 0) { - String signFlowid = sealSignRecords.get(0).getSignFlowId(); - SealSignRecord sealSignRecord = new SealSignRecord(); - sealSignRecord.setPensonAccount(caseAffiliate.getRespondentPhone()); - sealSignRecord.setSignFlowid(signFlowid); - - Gson gson = new Gson(); - EsignHttpResponse signUrl = SignAward.signUrlMediation(sealSignRecord); - JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); - JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); - String urlapply = signUrlData.get("shortUrl").getAsString(); - sealSignRecordres.setSealUrl(urlapply); - } - - return AjaxResult.success(sealSignRecordres); - } @Override @Transactional(rollbackFor = Exception.class) @@ -1187,12 +835,38 @@ public class MsSignSealServiceImpl implements MsSignSealService { String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); if (downLoadFile) { + // 先删除已经存在的调解书 + if(StrUtil.isEmpty(application.getCaseSource())){ + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(CollectionUtil.isNotEmpty(existAttach)){ + // todo 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); MsCaseAttach caseAttach = new MsCaseAttach(); caseAttach.setCaseAppliId(caseAppliId); - caseAttach.setAnnexType(7); + caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode()); caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + caseAttachMapper.save(caseAttach); + // todo 对接北明,调用上传附件接口 + if(StrUtil.isEmpty(caseApplicationselect.getCaseSource()) ) { + String templatePath = "/home/ruoyi" + savePath; + File file = new File(templatePath.replace("/profile", "/uploadPath")); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplicationselect.getCaseNum(), AttachmentOperateTypeEnum.ADD); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } } } @@ -1256,12 +930,38 @@ public class MsSignSealServiceImpl implements MsSignSealService { String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); if (downLoadFile) { + // 先删除已经存在的调解书 + if(StrUtil.isEmpty(application.getCaseSource())){ + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(CollectionUtil.isNotEmpty(existAttach)){ + // todo 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); MsCaseAttach caseAttach = new MsCaseAttach(); caseAttach.setCaseAppliId(caseAppliId); - caseAttach.setAnnexType(7); + caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode()); caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + caseAttachMapper.save(caseAttach); + // todo 对接北明,调用上传附件接口 + if(StrUtil.isEmpty(caseApplicationselect.getCaseSource()) ) { + String templatePath = "/home/ruoyi" + savePath; + File file = new File(templatePath.replace("/profile", "/uploadPath")); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplicationselect.getCaseNum(), AttachmentOperateTypeEnum.ADD); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } } } @@ -1322,12 +1022,39 @@ public class MsSignSealServiceImpl implements MsSignSealService { String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); if (downLoadFile) { + // 先删除已经存在的调解书 + if(StrUtil.isEmpty(application.getCaseSource())){ + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if(CollectionUtil.isNotEmpty(existAttach)){ + // todo 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); MsCaseAttach caseAttach = new MsCaseAttach(); caseAttach.setCaseAppliId(caseAppliId); caseAttach.setAnnexType(7); caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); + caseAttachMapper.save(caseAttach); + // todo 对接北明,调用上传附件接口 + + if(StrUtil.isEmpty(caseApplicationselect.getCaseSource()) ) { + String templatePath = "/home/ruoyi" + savePath; + File file = new File(templatePath.replace("/profile", "/uploadPath")); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, caseApplicationselect.getCaseNum(), AttachmentOperateTypeEnum.ADD); + + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + } } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/VideoConferenceServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/VideoConferenceServiceImpl.java index d38cf8f..6be5493 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/VideoConferenceServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/mscase/impl/VideoConferenceServiceImpl.java @@ -31,9 +31,6 @@ import com.tencentcloudapi.trtc.v20190722.TrtcClient; import com.tencentcloudapi.trtc.v20190722.models.*; import com.tencentyun.TLSSigAPIv2; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; -import org.apache.poi.xwpf.usermodel.XWPFRun; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -42,18 +39,14 @@ import tk.mybatis.mapper.entity.Example; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Paths; -import java.util.Base64; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import static com.ruoyi.common.core.domain.AjaxResult.success; -import static com.ruoyi.common.utils.file.FileUploadUtils.*; +import static com.ruoyi.common.utils.file.FileUploadUtils.getAbsoluteFile; +import static com.ruoyi.common.utils.file.FileUploadUtils.getPathFileName; /** * @author wangqiong @@ -373,18 +366,27 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { * @return */ @Override - public AjaxResult secretaryRoleByUserId(Long userId) { - List roles = roleMapper.selectRolePermissionByUserId(userId); + public AjaxResult secretaryRoleByUserId(Long userId, Long caseId) { + // 根据案件id查询案件 + MsCaseApplication caseApplication = caseApplicationMapper.selectByPrimaryKey(caseId); + if(caseApplication==null){ + return AjaxResult.error("案件不存在"); + } JSONObject jsonObject = new JSONObject(); boolean isSecretaryRole=false; - if(CollectionUtil.isNotEmpty(roles)){ - for (SysRole role : roles) { - if("调解员".equals(role.getRoleName())){ - isSecretaryRole=true; - break; + if(caseApplication.getMediatorId()!=null&& Objects.equals(userId, caseApplication.getMediatorId())){ + // 是调解员 + List roles = roleMapper.selectRolePermissionByUserId(userId); + if(CollectionUtil.isNotEmpty(roles)){ + for (SysRole role : roles) { + if("调解员".equals(role.getRoleName())){ + isSecretaryRole=true; + break; + } } } } + jsonObject.put("isSecretaryRole",isSecretaryRole); return success(jsonObject); } @@ -424,21 +426,6 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { } } - public static void main(String[] args) throws Exception{ - String htmlContent = "

wangwu

喂喂喂

zhangsan

hello

zhangsan

我能听到你说话

wangwu

欧克

wangwu

关于XXX我有几点想说的,balalalalalal

zhangsan

看到回复的时刻双方都是华德福额外补充你下次u饿哦是那些二的河南省而很为难啊看的法国队哈哈哈哈哈哈哈哈哈

"; // HTML字符串 - String outputFileName="D://output.docx"; - XWPFDocument document = new XWPFDocument(); - XWPFParagraph paragraph = document.createParagraph(); - XWPFRun run = paragraph.createRun(); - run.setText(htmlContent); - FileOutputStream out = new FileOutputStream(new File(outputFileName)); - document.write(out); - out.close(); - System.out.printf("生成调解笔录成功"); - - - - } /** * 将视频下载到本地 diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/log/MsRequestLogMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/log/MsRequestLogMapper.xml new file mode 100644 index 0000000..fe390de --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/log/MsRequestLogMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index b5f7ba0..d7d1f9c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -21,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -111,6 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email, status, create_by, + code, + comp_legal_person, create_time )values( #{deptId}, @@ -124,6 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{email}, #{status}, #{createBy}, + #{code}, + #{compLegalPerson}, sysdate() ); @@ -140,6 +146,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email, status, create_by, + code, + comp_legal_person, create_time )values @@ -155,6 +163,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.email}, #{item.status}, #{item.createBy}, + #{item.code}, + #{item.compLegalPerson}, sysdate() ) ; @@ -174,6 +184,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email = #{email}, status = #{status}, update_by = #{updateBy}, + code = #{code}, + comp_legal_person = #{compLegalPerson}, update_time = sysdate() where dept_id = #{deptId} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index b303ede..3f1441b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -125,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select u.*,ur.role_id from ms_sys_user u left join ms_sys_user_role ur on u.user_id = ur.user_id left join ms_sys_role r on r.role_id = ur.role_id - where u.phonenumber = #{phone} and u.del_flag = '0' and u.status='0' order by u.create_time limit 1 + where u.eamil = #{eamil} and u.del_flag = '0' and u.status='0' order by u.create_time limit 1 select count(1) from ms_sys_user_role where role_id=#{roleId} - + + + delete from ms_sys_user_role where user_id in diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAffiliateMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAffiliateMapper.xml index 1d4e350..9ad7859 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAffiliateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAffiliateMapper.xml @@ -1,27 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseApplicationMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseApplicationMapper.xml index 38465a2..1a306fd 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseApplicationMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseApplicationMapper.xml @@ -34,7 +34,56 @@ + + FROM + ms_case_application c + JOIN ms_case_affiliate a ON c.id = a.case_appli_id + LEFT JOIN ms_sys_user u ON u.user_id = a.user_id + LEFT JOIN ms_sys_user u1 ON u1.user_id = c.mediator_id + LEFT JOIN ms_sys_user_role ur ON u.user_id = ur.user_id or u1.user_id = ur.user_id + LEFT JOIN ms_sys_role r ON r.role_id = ur.role_id or r.role_id = ur.role_id + LEFT JOIN ms_sys_dept d ON d.dept_id = a.applicant_dept_id + + + + AND (c.mediator_id = #{req.mediatorId} or a.user_id=#{req.userId}) + + + + AND (a.user_id=#{req.userId} ) + + + + and r.role_id in + + #{roleId} + + + + + and c.case_flow_id in + + #{flowId} + + + + + AND c.case_flow_id = #{req.caseFlowId} + + + + AND c.case_num = #{req.caseNum} + + + + and c.create_time >= #{req.startTime} + + + and c.create_time <= #{req.endTime} + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml index 23a8c3f..9779bc3 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml @@ -14,6 +14,7 @@ + INSERT INTO ms_case_attach (case_appli_id, annex_name, annex_path , annex_type,note,use_id,use_account,seal_status,only_office_file_id) @@ -109,7 +110,9 @@ update ms_case_attach set + other_sys_file_id=#{otherSysFileId}, case_appli_id= #{caseAppliId} + where annex_id = #{annexId} @@ -125,6 +128,7 @@ update ms_case_attach annex_name = #{annexName}, + other_sys_file_id=#{otherSysFileId}, annex_path = #{annexPath}