diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 61b4e13..b664542 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -2,9 +2,11 @@ package com.ruoyi; import cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.constant.CacheConstants; +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.SysRoleMapper; import com.ruoyi.system.mapper.SysUserMapper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -47,5 +49,14 @@ public class RuoYiApplication redisCache.setCacheObject(CacheConstants.USER_KEY+sysUser.getUserId(),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()); + } + } } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index eadfe28..b0c72a2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; +import static com.google.common.io.Files.getFileExtension; + /** * 通用请求处理 * @@ -116,6 +118,7 @@ public class CommonController .annexType(annexType) .useId(SecurityUtils.getUserId()) .useAccount(SecurityUtils.getUsername()) + .suffix(getFileExtension(path)) .build(); msCaseAttachMapper.save(caseAttach); return caseAttach.getAnnexId(); 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..d0bc8c7 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 @@ -5,9 +5,11 @@ import cn.hutool.crypto.digest.MD5; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginBody; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.framework.web.service.SysPermissionService; import com.ruoyi.framework.web.service.TokenService; @@ -22,6 +24,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -83,11 +87,20 @@ public class SysLoginController { public AjaxResult getInfo() { SysUser user = SecurityUtils.getLoginUser().getUser(); // 角色集合 - Set roles = permissionService.getRolePermission(user); + List roles = permissionService.getRolePermission(user); + Set permsSet = new HashSet<>(); + for (SysRole perm : roles) + { + if (StringUtils.isNotNull(perm)) + { + permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); + } + } + user.setRoles(roles); // 权限集合 Set permissions = permissionService.getMenuPermission(user); //查询用户角色关联的案件状态 - Set caseStatus = caseFlowService.getCaseStatusIdByRoleKey(roles); + Set caseStatus = caseFlowService.getCaseStatusIdByRoleKey(permsSet); AjaxResult ajax = AjaxResult.success(); ajax.put("user", user); ajax.put("roles", roles); @@ -116,6 +129,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/system/SysMenuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java index 03b6b65..36872d0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java @@ -1,17 +1,5 @@ package com.ruoyi.web.controller.system; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; @@ -20,6 +8,12 @@ import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.service.ISysMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * 菜单信息 @@ -139,4 +133,13 @@ public class SysMenuController extends BaseController } return toAjax(menuService.deleteMenuById(menuId)); } + /** + * 根据用户查询菜单权限字符 + */ + @GetMapping("/getMenuPermsByUser") + public AjaxResult getMenuPermsByUser() + { + + return menuService.getMenuPermsByUser(); + } } \ No newline at end of file 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 new file mode 100644 index 0000000..d6e93dc --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestApiController.java @@ -0,0 +1,70 @@ +package com.ruoyi.web.controller.tool; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.AttachmentOperateTypeEnum; +import com.ruoyi.common.enums.DocumentTypeEnum; +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; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.File; + +import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt; + +@RestController +@RequestMapping("/beiming/api") +public class TestApiController { + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + @Value("${beimingprivatekey}") + public String privateKey; + + @GetMapping("/test") + @Anonymous + public AjaxResult selectCaseFlow() { + String token = beiMingInterfaceService.getApiToken("BWT_MEDIATION", "86251b190e3a40f3942v215d1762c663", System.currentTimeMillis()); +// token = "f910e1441fc56e49d3f31396e8d9aa04228045815ee986a9587d7a5cb7312f9d11c7f80041745f38ec686ea1f819c8b8227f9c03196c6dd004f89215c4805c24355be4b57abeddb7b9d2cbda45fae74c49f4a83fb6496d84302ca8c07245786d682ecb68aed966fcbda3188b9c4d4376089471bb5aee371a62073b0ce15d72dccd6fbc8fd13957e2fb7aa018cb5937938bfc9773e570ac06ac633617cea8405759cf609c832074aaa03f972c0a6a93cde531da0d91d07770c037fdea1368ee5772941ba2a55ef155979d1ed8222faad92ed342530ef04f3746aa96499dee6ea4869ce46bd0dcfe7a69e7db49eb2aec388c47824c201b49825f24ffe82dde41b5"; + System.out.println("toke:" + token); + //解密 + 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); + String resultToken = tokenObject.getString("token"); + MsCaseStatusInfo info = MsCaseStatusInfo.builder().caseNo("zc2024032700012").statusCode(PushCaseStatusEnum.MEDIATE.getCode()).caseClosureExplanation(PushCaseStatusEnum.MEDIATE.getName()).build(); + JSONObject result = beiMingInterfaceService.submitCaseStatusInfo(resultToken, "zc2024032700012", "BWT_MEDIATION", info); + System.out.println("jieguo:" + result.toString()); + if (result != null) { + String data = result.getString("data"); + String datastr = sm4Decrypt(data, privateKey); + System.out.println("最终解密后的字符串:" + datastr); + } + } + } + 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"); + MsCaseFileInfo jsonObject1 = beiMingInterfaceService.pushAttachmentInfo("BWT_MEDIATION", "86251b190e3a40f3942v215d1762c663", file, "BWT_MEDIATION", "zc2024032700012", AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT); + System.out.println("fanhui:" + jsonObject1.toString()); + return AjaxResult.success(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/IdentityAuthenticationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/IdentityAuthenticationController.java index b8fbd93..8b7ee99 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/IdentityAuthenticationController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/IdentityAuthenticationController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.wisdomarbitrate.miniprogress; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.controller.BaseController; @@ -8,10 +9,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication; import com.ruoyi.wisdomarbitrate.service.miniprogress.IdentityAuthenticationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/identityAuthentication") @@ -25,9 +23,26 @@ public class IdentityAuthenticationController extends BaseController { @Anonymous @PostMapping("/selectIdentityAuthenticaEIDtoken") public AjaxResult selectIdentityAuthenticaEIDtoken() { - JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthenticaEIDtoken(); + JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(false); return success(tokenResult); } + /** + * 获取PC端EIDtoken + */ + @Anonymous + @PostMapping("/selectPCIdentityAuthenticaEIDtoken") + public AjaxResult selectPCIdentityAuthenticaEIDtoken() { + JSONObject tokenResult = identityAuthenticationService.selectIdentityAuthEIDToken(true); + return success(tokenResult); + } + /** + * H5轮询获取E证通Token状态 + */ + @Anonymous + @GetMapping("/selectPCEIDtokenStatus") + public AjaxResult selectPCEIDtokenStatus(@RequestParam String eidToken) { + return identityAuthenticationService.selectPCEIDtokenStatus(eidToken); + } /** * 小程序人脸核身后查询身份认证结果 @@ -35,6 +50,9 @@ public class IdentityAuthenticationController extends BaseController { @Anonymous @PostMapping("/selectIdentityAuthenticaRespon") public AjaxResult selectIdentityAuthenticaRespon(@Validated @RequestBody IdentityAuthentication ientityAuthentication) { + if(StrUtil.isEmpty(ientityAuthentication.getEidToken())){ + return error("EIDtoken不能为空"); + } AjaxResult checkResult = identityAuthenticationService.selectIdentityAuthenticaRespon(ientityAuthentication); return checkResult; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/WeChatUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/WeChatUserController.java index e48765c..26c587d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/WeChatUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/miniprogress/WeChatUserController.java @@ -44,6 +44,17 @@ public class WeChatUserController extends BaseController { } return weChatUserService.sendCode(userVO); } + /** + * 获取邮箱验证码 + * @param email + * @return + */ + @Anonymous + @GetMapping("/sendEmailCode") + public AjaxResult sendEmailCode( @RequestParam("email") String email) + { + return weChatUserService.sendEmailCode(email); + } @Anonymous @GetMapping("/roles") public AjaxResult roles() 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..f3e9892 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 @@ -10,7 +10,6 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.common.utils.IdCardUtils; -import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.*; @@ -73,11 +72,10 @@ public class MsCaseApplicationController extends BaseController { /** * 新增案件 */ - // todo 重复提交校验 @PostMapping("/insert") public AjaxResult insert(@RequestBody MsCaseApplicationVO caseApplication ) { - if(caseApplication.getAffiliate()==null||caseApplication.getAffiliate().getOrganizeFlag()==null){ + if( caseApplication.getAffiliate()==null){ error("参数校验失败"); } AjaxResult ajaxResult = AjaxResult.success(); @@ -252,7 +250,7 @@ public class MsCaseApplicationController extends BaseController { * @return */ @GetMapping("/listMediator") - public AjaxResult listMediator( @RequestParam(value = "caseAppliId",required = false) Long caseAppliId) { + public AjaxResult listMediator( @RequestParam(value = "caseAppliId",required = true) Long caseAppliId) { return caseApplicationService.listMediator(caseAppliId); } /** @@ -312,7 +310,7 @@ public class MsCaseApplicationController extends BaseController { */ @PostMapping("/mediation") public AjaxResult mediation(@RequestBody MsCaseApplicationReq req) throws EsignDemoException, InterruptedException { - if (req.getCaseFlowId() == null || req.getId() == null || req.getMediaResult()==null) { + if (req.getCaseFlowId() == null || req.getId() == null ) { return error("参数校验失败"); } @@ -344,19 +342,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 @@ -402,17 +388,7 @@ public class MsCaseApplicationController extends BaseController { return success(videoService.reserveConferenceList(caseId)); } - /** - * 查询短信发送记录 - * @param smsSendRecord - * @return - */ - @PostMapping("/smsRecord") - public TableDataInfo getSmsSendRecord(@RequestBody SmsSendRecord smsSendRecord){ - startPage(); - List list = caseApplicationService.getSmsSendRecord(smsSendRecord); - return getDataTable(list); - } + /** * 保存onlyOffice在线编辑的文件 * @param 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..fb42a37 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 @@ -1,17 +1,33 @@ package com.ruoyi.web.controller.wisdomarbitrate.mscase; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.AnnexTypeEnum; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.framework.config.ServerConfig; +import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsReservedConferenceVO; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.SendRoomNoMessageVO; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.VideoCallBackVO; +import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper; +import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService; import com.ruoyi.wisdomarbitrate.service.mscase.VideoConferenceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import java.util.Objects; + +import static com.google.common.io.Files.getFileExtension; /** * 视频会议控制层 @@ -19,11 +35,18 @@ import javax.validation.Valid; * @Date 2024/01/8 * @Version V1.0 */ +@CrossOrigin(origins = "*") @RestController @RequestMapping("/video") public class MsVideoConferenceController extends BaseController { @Autowired private VideoConferenceService videoService; + @Autowired + private ServerConfig serverConfig; + @Autowired + private MsCaseAttachMapper msCaseAttachMapper; + @Autowired + private MsCaseApplicationService caseApplicationService; /** * 根据案件ID查询视频 * @param caseId 案件id @@ -34,8 +57,110 @@ public class MsVideoConferenceController extends BaseController { return videoService.videoList(caseId); } + /** + * 通用上传请求(单个) + * param officeFlag: 是否上传到onlyoffice,0-否,1-是 + * param isMediaBook: 是否上调解书,1-是,其余为否 + */ + @PostMapping("/upload") + public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value = "isMediaBook",required = false) Integer isMediaBook, @RequestParam("annexType") Integer annexType, @RequestParam(value = "officeFlag", required = false) Integer officeFlag,@RequestParam(value = "caseId",required = false) Long caseId) throws Exception + { + try + { + // 上传文件路径 + String filePath = RuoYiConfig.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String suffix = getFileExtension(fileName); + if(StrUtil.isNotEmpty(suffix)&& suffix.contains("doc")){ + // 上传到onlyoffice + officeFlag=1; + } + String url = serverConfig.getUrl() + fileName; + if(officeFlag != null && officeFlag == 1){ + // officeFlag,fileName为annexPath + JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(fileName,caseId); + if(jsonArray!=null && jsonArray.size() > 0) { + // 先删除之前的附件 + if(Objects.equals(annexType, AnnexTypeEnum.MEDIATE_BOOK.getCode()) && caseId!=null) { + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseId, annexType); + } + MsCaseAttach caseAttach=null; + for (Object obj : jsonArray) { + JSONObject jsonObject = (JSONObject) obj; + caseAttach = MsCaseAttach.builder() + .caseAppliId(caseId) + .annexName(jsonObject.get("fileName")!=null?jsonObject.getString("fileName"):"") + .annexType(annexType) + .onlyOfficeFileId(jsonObject.getString("fileId")) + .build(); + if(jsonObject.get("filePath")!=null){ + String officePath = jsonObject.getString("filePath"); + String replace = officePath.replace("/home/ruoyi/uploadPath/", "/profile/"); + caseAttach.setAnnexPath(replace); + } + caseAttach.setSuffix( (getFileExtension(caseAttach.getAnnexPath()))); + msCaseAttachMapper.save(caseAttach); + } + if(caseAttach==null){ + return AjaxResult.error("上传失败"); + } + AjaxResult ajax = AjaxResult.success(); + ajax.put("annexId", caseAttach.getAnnexId()); + ajax.put("annexType", annexType); + // ajax.put("url", url); + ajax.put("fileName", fileName); + ajax.put("newFileName", FileUtils.getName(fileName)); + ajax.put("originalFilename", file.getOriginalFilename()); + return ajax; + }else { + return AjaxResult.error("上传失败"); + } + }else { + // 如果是调解书并且是pdf,则删除之前的在新增 + if(isMediaBook != null && isMediaBook == 1 ){ + if(StrUtil.isNotEmpty(suffix)&&!suffix.equals("pdf")){ + return AjaxResult.error("请上传pdf格式文件"); + } + annexType=AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode(); + // 先删除之前的附件 + if(caseId!=null) { + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseId, annexType); + } + } + Long annexId = saveCaseAttach(annexType, fileName, file.getOriginalFilename(), caseId); + // 是否上传到onlyoffice + AjaxResult ajax = AjaxResult.success(); + ajax.put("annexId", annexId); + ajax.put("annexType", annexType); + ajax.put("url", url); + ajax.put("fileName", fileName); + ajax.put("newFileName", FileUtils.getName(fileName)); + ajax.put("originalFilename", file.getOriginalFilename()); + return ajax; + } + } + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); + } + } + private Long saveCaseAttach(Integer annexType, String path, String originalFilename,Long caseId) { + MsCaseAttach caseAttach = MsCaseAttach.builder() + .annexName(originalFilename) + .caseAppliId(caseId) + .annexPath(path) + .annexType(annexType) + .useId(SecurityUtils.getUserId()) + .useAccount(SecurityUtils.getUsername()) + .suffix(getFileExtension(path)) + .build(); + + msCaseAttachMapper.save(caseAttach); + return caseAttach.getAnnexId(); + } /** * 从腾讯云下载文件到本地 * @param @@ -49,6 +174,13 @@ public class MsVideoConferenceController extends BaseController { } return success(); } + @Anonymous + @PostMapping("/smsRollBack") + public AjaxResult smsRollBack( @RequestBody String body, HttpServletRequest request) { + logger.info("短信回调======"+body); + videoService.smsRollBack(body,request); + return success(); + } /** * 根据房间号绑定案件ID * @param @@ -106,9 +238,20 @@ 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); + } + /** + * 根据案件id查询申请人/被申请人会议上传附件按钮权限 + * @param caseId + * @return + */ + @Anonymous + @GetMapping("selectRoleMenuByCaseId") + public AjaxResult selectRoleMenuByCaseId( @RequestParam(value = "caseId",required = true) Long caseId) { + + return videoService.selectRoleMenuByCaseId(caseId); } /** * 根据html字符串转pdf并和案件关联 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/SendMailRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/SendMailRecordController.java index 3d7e397..ab3edd8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/SendMailRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/SendMailRecordController.java @@ -1,19 +1,18 @@ package com.ruoyi.web.controller.wisdomarbitrate.sendrecord; import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; import com.ruoyi.wisdomarbitrate.service.sendrecord.ISendMailRecordService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/sendMailRecord") -public class SendMailRecordController extends BaseController { +public class SendMailRecordController extends BaseController { @Autowired private ISendMailRecordService sendMailRecordService; @@ -21,13 +20,30 @@ public class SendMailRecordController extends BaseController { * 查询发送邮件记录列表 */ @GetMapping("/list") - public TableDataInfo list(SendMailRecord sendMailRecord) - { + public TableDataInfo list(SendMailRecord sendMailRecord) { startPage(); List list = sendMailRecordService.selectSendMailRecordList(sendMailRecord); return getDataTable(list); } + /** + * 编辑邮件记录 + */ + @PostMapping("/update") + public AjaxResult update(@RequestBody SendMailRecord sendMailRecord) { + return sendMailRecordService.updateSendMailRecord(sendMailRecord); + } - + /** + * 重新发送邮件记录 + */ + @PostMapping("/reSendMailRecord") + public AjaxResult reSendMailRecord(@RequestBody SendMailRecord sendMailRecord) { + Boolean aBoolean = sendMailRecordService.reSendMailRecord(sendMailRecord); + if (aBoolean) { + return AjaxResult.success("发送成功"); + } else { + return AjaxResult.error("发送失败"); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java new file mode 100644 index 0000000..2d95125 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sendrecord/ShortMessageController.java @@ -0,0 +1,127 @@ +package com.ruoyi.web.controller.wisdomarbitrate.sendrecord; + +import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo; +import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendHistoryRecordParamMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendRecordParamMapper; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.ReSendMessageVO; +import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import tk.mybatis.mapper.entity.Example; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@RestController +@RequestMapping("/shortMessage") +public class ShortMessageController extends BaseController { + @Autowired + private SmsRecordMapper smsRecordMapper; + @Autowired + private ShortMessageService shortMessageService; + @Autowired + MsSmsSendRecordParamMapper recordParamMapper; + @Autowired + MsSmsSendHistoryRecordParamMapper historyRecordParamMapper; + + /** + * 查询短信发送记录 + * + * @param smsSendRecord + * @return + */ + @GetMapping("/recordList") + public TableDataInfo smsSendRecordList(SmsSendRecord smsSendRecord) { + startPage(); + List list = shortMessageService.smsSendRecordList(smsSendRecord); + return getDataTable(list); + } + + @Anonymous + @PostMapping("/updateSendContent") + public AjaxResult update(@RequestBody SmsSendRecord smsSendRecord) { + if (smsSendRecord == null || smsSendRecord.getId() == null || CollectionUtil.isEmpty(smsSendRecord.getTemplateParams())) { + return AjaxResult.error("参数校验失败"); + } + // 查询当前版本记录 + SmsSendRecord oldSendRecord = smsRecordMapper.selectById(smsSendRecord.getId()); + smsSendRecord.setUpdateTime(new Date()); + // 更新短信内容,先删除短信记录参数表 + Example recordParamExam = new Example(MsSmsSendRecordParam.class); + recordParamExam.createCriteria().andEqualTo("smsRecordId", smsSendRecord.getId()); + recordParamMapper.deleteByExample(recordParamExam); + // 新增短信记录参数表 + List recordParams = new ArrayList<>(); + for (MsSmsTemplateParam templateParam : smsSendRecord.getTemplateParams()) { + MsSmsSendRecordParam recordParam = new MsSmsSendRecordParam(); + recordParam.setSmsRecordId(smsSendRecord.getId()); + recordParam.setParamValue(templateParam.getParamValue()); + recordParams.add(recordParam); + } + recordParamMapper.batchInsert(recordParams); + shortMessageService.insertShortMessageHistoryRecord(oldSendRecord, recordParams); + return AjaxResult.success(); + + } + + /** + * 重新发送短信 + */ + @Anonymous + @PostMapping("/reSendShortMessage") + public AjaxResult reSendShortMessage(@RequestBody ReSendMessageVO reSendMessageVO) { + if (reSendMessageVO != null) { + AjaxResult result = shortMessageService.reSendShortMessage(reSendMessageVO); + return result; + } + return AjaxResult.error("参数缺失"); + } + + @Autowired + MeetingInfoMapper meetingInfoMapper; + @Autowired + SysUserMapper sysUserMapper; + @Autowired + private TokenService tokenService; + + /** + * 查询UID好的密钥 + */ + @Anonymous + @GetMapping("/getMeetingInfo") + public Object getEncryptInfoByUid(@RequestParam(name = "authId", required = true) String authId) { + MeetingInfoVO result = new MeetingInfoVO(); + if (authId != null) { + MeetingInfo meetingInfo = meetingInfoMapper.selectByPrimaryKey(authId); + if (meetingInfo != null && meetingInfo.getUserId() != null) { + BeanUtils.copyProperties(meetingInfo, result); + SysUser sysUser = sysUserMapper.selectUserById(meetingInfo.getUserId()); + LoginUser loginUser = new LoginUser(); + loginUser.setUserId(sysUser.getUserId()); + loginUser.setUser(sysUser); + String token = tokenService.createVideoToken(loginUser, 120); +// String createToken = createToken(claims); + result.setToken(token); + } + return result; + } + return AjaxResult.error("查询失败"); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sms/SMSTemplateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sms/SMSTemplateController.java new file mode 100644 index 0000000..23e024b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/sms/SMSTemplateController.java @@ -0,0 +1,55 @@ +package com.ruoyi.web.controller.wisdomarbitrate.sms; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; +import com.ruoyi.wisdomarbitrate.service.sms.SMSTemplateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 短信模板控制器 + */ +@RestController +@RequestMapping("/smsTemplate") +public class SMSTemplateController extends BaseController { + @Autowired + private SMSTemplateService templateService; + + /** + * 查询 + * @param + * @return + */ + @GetMapping("/page") + public TableDataInfo page( ){ + startPage(); + List list = templateService.page(); + return getDataTable(list); + } + /** + * 新增或者修改 + * @param + * @return + */ + @PostMapping("/insert") + public AjaxResult insert(@RequestBody MsSmsTemplate template){ + return templateService.insert(template); + } + /** + * 删除 + * @param + * @return + */ + @PostMapping("/delete") + public AjaxResult delete(@RequestBody MsSmsTemplate template){ + if(template.getId()==null){ + return AjaxResult.warn("id不能为空"); + } + return templateService.delete(template.getId()); + } + +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 4d5b672..4fc7270 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,8 +6,8 @@ spring: druid: # 主库数据源 master: -# url: jdbc:mysql://121.40.189.20:3306/mediation_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false - url: jdbc:mysql://121.40.189.20:3306/mediation_system_prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false + url: jdbc:mysql://121.40.189.20:3306/mediation_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false +# url: jdbc:mysql://121.40.189.20:3306/mediation_system_prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai&useSSL=false username: root password: YMzc157# # 从库数据源 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 2dc7d5f..89ddc74 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -18,7 +18,7 @@ ruoyi: # 开发环境配置 server: # 测试环境6001,开发环境7001 - port: 7001 + port: 6001 servlet: # 应用的访问路径 context-path: / @@ -72,8 +72,8 @@ spring: host: 121.40.189.20 # 端口,默认为6379 port: 6389 - # 数据库索引 - database: 0 + # 数据库索引,测试环境1,正式环境0 + database: 1 # 密码 password: # 连接超时时间 @@ -90,7 +90,7 @@ spring: max-wait: -1ms web: resources: - static-locations: file:/home/ruoyi/ + static-locations: file:/home/ruoyi/ mail: host: smtp.163.com port: 25 @@ -121,7 +121,7 @@ token: # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) - expireTime: 30 + expireTime: 120 # MyBatis配置 mybatis: @@ -172,7 +172,10 @@ elegent: identityAuthentication: credentialSecretId: AKID3xfHgroY4MQHvLXUXMwIQL1UjmbBX1Tv credentialSecretKey: INDrIXcT8YmomZBcsy0oNirnU0LTN4X7 +# 小程序端人脸核身商户id merchantId: 0NSJ2309281116194321 +# pc端人脸核身商户id + pcMerchantId: 0NSJ2404231626029804 privateKeyHexDecodeinfo: 4c3b311bf7b98969994e85928e069574a1e95777f24d1c510679cc3c2f460faf # 腾讯云即时通信相关配置 imConfig: @@ -196,17 +199,25 @@ signSealCallbackConfig: url: http://121.40.189.20:7001/mssignSeal/signSeaalCaseApplicaCallback # onlyOffice系统url配置 onlyOfficeConfig: -# url: http://172.16.0.254:9090/files/upload + # url: http://172.16.0.254:9090/files/upload url: http://121.40.189.20:9090/files/upload -#jodconverter: -# local: -# host: 121.40.189.20 +# 北明 +BMConfig: + userName: BWT_MEDIATION + password: 86251b190e3a40f3942v215d1762c663 + syncSource: BWT_MEDIATION + #jodconverter: + # local: + # host: 121.40.189.20 #暂时关闭预览,启动时会有点慢 -# enabled: true + # enabled: true #设置libreoffice主目录 linux地址如:/usr/lib64/libreoffice -# office-home: /usr/lib64/libreoffice/ -# office-home: D:\app\libreOffice\ - #开启多个libreoffice进程,每个端口对应一个进程 -# port-numbers: 8100 - #libreoffice进程重启前的最大进程数 + # office-home: /usr/lib64/libreoffice/ + # office-home: D:\app\libreOffice\ + #开启多个libreoffice进程,每个端口对应一个进程 + # port-numbers: 8100 + #libreoffice进程重启前的最大进程数 # max-tasks-per-process: 100 +beimingapihost: https://zj.odrcloud.cn +beimingapiprefix: /onestop/sync +beimingprivatekey: d7724e72c4be93196a35203e8379ded5 diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index a84dbae..e5d63d1 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -200,7 +200,7 @@ com.tencentcloudapi tencentcloud-sdk-java - 3.1.876 + 3.1.962 @@ -283,6 +283,11 @@ org.apache.httpcomponents httpclient + + org.thymeleaf + thymeleaf + 3.0.12.RELEASE + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/RestTemplateConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/RestTemplateConfig.java new file mode 100644 index 0000000..22f8a7b --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/RestTemplateConfig.java @@ -0,0 +1,25 @@ +package com.ruoyi.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(ClientHttpRequestFactory factory){ + return new RestTemplate(factory); + } + + @Bean + public ClientHttpRequestFactory simpleClientHttpRequestFactory(){ + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setReadTimeout(5000);//单位为ms + factory.setConnectTimeout(5000);//单位为ms + return factory; + } +} + 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..e3e9148 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 @@ -42,6 +47,7 @@ public class CacheConstants */ public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; public static final String WE_CHAT_SMS_VERIFY_CODE_KEY="we_chat_sms_verify_code:"; + public static final String EMAIL_VERIFY_CODE_KEY="email_verify_code:"; /** * 案件 redis key */ @@ -50,4 +56,13 @@ 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:"; + } 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..a185090 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 @@ -4,11 +4,10 @@ import io.jsonwebtoken.Claims; /** * 通用常量信息 - * + * * @author ruoyi */ -public class Constants -{ +public class Constants { /** * UTF-8 字符集 */ @@ -71,7 +70,7 @@ public class Constants * 登录失败 */ public static final String LOGIN_FAIL = "Error"; - + /** * 验证码有效期(分钟) */ @@ -95,6 +94,10 @@ public class Constants * 令牌前缀 */ public static final String LOGIN_USER_KEY = "login_user_key"; + /** + * 会议主键Id + */ + public static final String MEETING_KEY = "meeting_key"; /** * 用户ID @@ -141,21 +144,23 @@ 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 SPLIT_COMMA = ","; + // 中文逗号分隔符 + public static final String CN_SPLIT_COMMA = ","; /** * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) */ - public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" }; + public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.ruoyi"}; /** * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) */ - public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; + public static final String[] JOB_WHITELIST_STR = {"com.ruoyi"}; /** * 定时任务违规的字符 */ - public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", - "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" }; + public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config"}; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java index 96b149c..550d5b9 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -68,7 +68,7 @@ public class UserConstants * 用户名长度限制 */ public static final int USERNAME_MIN_LENGTH = 2; - public static final int USERNAME_MAX_LENGTH = 20; + public static final int USERNAME_MAX_LENGTH = 50; /** * 密码长度限制 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..f042fa6 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,68 @@ public class SysDept extends BaseEntity /** 父部门名称 */ private String parentName; + /** + * 代码(统一社会信用代码或者身份证号) + */ + private String code; + + /** + * 法定代表人 + */ + private String compLegalPerson; + /** + * 住所 + */ + private String home; + /** + * 联系地址 + */ + private String address; + /** + * + * 国籍,0-国内,1-国外 + */ + private Integer nationality; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Integer getNationality() { + return nationality; + } + + public String getHome() { + return home; + } + + public void setHome(String home) { + this.home = home; + } + + public void setNationality(Integer nationality) { + this.nationality = nationality; + } + + 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/AnnexTypeEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AnnexTypeEnum.java index 5f861d0..b3a220d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AnnexTypeEnum.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AnnexTypeEnum.java @@ -21,6 +21,8 @@ public enum AnnexTypeEnum implements EnumsInterface { RES_PAYMENT_RECEIPT(9, "被申请人缴费单"), SEAL_PICTURE(10, "印章图片"), FLOW_SVG(11, "流程节点SVG"), + MEETING_FILE(12, "被申请人证据"), + MEDIATE_BOOK_PDF(13, "PDF调解书或和解协议"), ; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentOperateTypeEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentOperateTypeEnum.java new file mode 100644 index 0000000..2e18edb --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentOperateTypeEnum.java @@ -0,0 +1,15 @@ +package com.ruoyi.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 案件附件操作类型 + */ +@AllArgsConstructor +@Getter +public enum AttachmentOperateTypeEnum { + ADD("ADD", "新增"), DEL("DEL", "删除"), UPD("UPD", "修改"); + private String code; + private String name; +} 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/enums/PushCaseStatusEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/PushCaseStatusEnum.java new file mode 100644 index 0000000..0686ded --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/PushCaseStatusEnum.java @@ -0,0 +1,13 @@ +package com.ruoyi.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum PushCaseStatusEnum { + MEDIATE("MEDIATE", "调解中", 1), SUCCESS("SUCCESS", "调解成功", 2), FAIL("FAIL", "调解失败", 3); + private String code; + private String name; + private Integer value; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/SMSStatusEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/SMSStatusEnum.java new file mode 100644 index 0000000..b4ec810 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/SMSStatusEnum.java @@ -0,0 +1,64 @@ +package com.ruoyi.common.enums; + +import com.ruoyi.common.interfaces.EnumsInterface; + +/** + * @author wangqiong + * @description 短信状态枚举 + * @date 2023-11-17 14:05 + */ +public enum SMSStatusEnum implements EnumsInterface +{ + SUCCESS(1, "成功"), + SENDING(2, "发送中"), + FAIL(3, "失败"), + + ; + + private final Integer code; + private final String text; + + SMSStatusEnum(Integer code, String text) + { + this.code = code; + this.text = text; + } + + public Integer getCode() + { + return code; + } + + public String getText() + { + return text; + } + + /** + * 根据code获取text + * @param codeNo + * @return + */ + public static String getTextByCode(Integer codeNo){ + for (SMSStatusEnum value : SMSStatusEnum.values()) { + if (value.getCode().equals(codeNo)){ + return value.getText(); + } + } + return codeNo.toString(); + } + + /** + * 根据text获取code + * @param textStr + * @return + */ + public static String getCodeByText(String textStr){ + for (SMSStatusEnum value : SMSStatusEnum.values()) { + if (value.getText().equals(textStr)){ + return value.getText(); + } + } + return textStr; + } +} 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..8ed272f 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; @@ -45,12 +47,12 @@ public class EmailOutUtil { // private static String fromOut; @Value("${spring.mail.host}") private String hostOut; -// @Value("${spring.mail.username}") -// private String usernameOut; - private String usernameOut="wq18792927508@163.com"; -// @Value("${spring.mail.password}") -// private String passwordOut; - private String passwordOut= "WDFHKSEMCKVRELEA"; + @Value("${spring.mail.username}") + private String usernameOut; + + @Value("${spring.mail.password}") + private String passwordOut; + @Value("${spring.mail.port}") private Integer portOut; @@ -72,18 +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); - ////System.out.println("发送成功:" + from + ":to:" + to); + public Boolean sendMessage(String to, String subject, String content, String from, JavaMailSender mailSender) { + try { + if(mailSender==null){ + mailSender= 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; } /** @@ -91,8 +104,9 @@ public class EmailOutUtil { * @param message 邮件内容 * @param subject 邮件主题 * @param fileList 邮件附件 + * @param fileNameMap 附件名称map,附件路径-附件名称 */ - public Boolean sendEmil(String to, String message, String subject, List fileList, File file) { + public Boolean sendEmil(String to, String message, String subject, List fileList, File file,Map fileNameMap) { try { String messageContent = "

"+message+"。

"; MimeBodyPart messageBodyPart = new MimeBodyPart(); @@ -149,7 +163,10 @@ public class EmailOutUtil { for (File tempfile : fileList) { MimeBodyPart attachmentPart = new MimeBodyPart(); attachmentPart.attachFile(tempfile); - attachmentPart.setFileName(MimeUtility.encodeText(tempfile.getName())); + // 设置附件名称 + if(fileNameMap!=null && fileNameMap.containsKey(tempfile.getPath())) { + attachmentPart.setFileName(MimeUtility.encodeText(fileNameMap.get(tempfile.getPath()))); + } multipart.addBodyPart(attachmentPart); } msg.setContent(multipart); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java new file mode 100644 index 0000000..455ec3f --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java @@ -0,0 +1,128 @@ +package com.ruoyi.common.utils; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import java.util.UUID; +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.pqc.math.linearalgebra.ByteUtils; + +@Slf4j +public class EncryptUtils { + static { + Security.addProvider(new BouncyCastleProvider()); + } + + /** + * sm4加密 + * @explain 加密模式:ECB 密文长度不固定,会随着被加密字符串长度的变化而变化 + * @param paramStr 待加密字符串 + * @return 返回16进制的加密字符串 + * @throws Exception + */ + public static String sm4Encrypt(String paramStr, String secretKey) { + if (StringUtils.isBlank(paramStr)) { + return null; + } + try { + // 16进制字符串-->byte[] + byte[] keyData = ByteUtils.fromHexString(secretKey); + // String-->byte[] + byte[] srcData = paramStr.getBytes(StandardCharsets.UTF_8); + // 加密后的数组 + Cipher cipher = Cipher.getInstance("SM4/ECB/PKCS5Padding", BouncyCastleProvider.PROVIDER_NAME); + Key sm4Key = new SecretKeySpec(keyData, "SM4"); + cipher.init(Cipher.ENCRYPT_MODE, sm4Key); + byte[] cipherArray = cipher.doFinal(srcData); + // byte[]-->hexString + return ByteUtils.toHexString(cipherArray); + } catch (Exception e) { + log.error("sm4加密失败:{}", paramStr, e); + } + return null; + + } + + /** + * sm4解密 + * @explain 解密模式:采用ECB + * @param cipherText 16进制的加密字符串(忽略大小写) + * @return 解密后的字符串 + * @throws Exception + */ + public static String sm4Decrypt(String cipherText, String secretKey) { + if (StringUtils.isBlank(cipherText)) { + return null; + } + try { + // hexString-->byte[] + byte[] keyData = ByteUtils.fromHexString(secretKey); + // hexString-->byte[] + byte[] cipherData = ByteUtils.fromHexString(cipherText); + // 解密 + Cipher cipher = Cipher.getInstance("SM4/ECB/PKCS5Padding", BouncyCastleProvider.PROVIDER_NAME); + Key sm4Key = new SecretKeySpec(keyData, "SM4"); + cipher.init(Cipher.DECRYPT_MODE, sm4Key); + byte[] cipherArray = cipher.doFinal(cipherData); + // byte[]-->String + return new String(cipherArray, StandardCharsets.UTF_8); + } catch (Exception e) { + log.error("sm4解密失败:{}", cipherText, e); + } + return null; + } + + /** + * @description: 初始化 HmacMD5 密钥 + */ + public static String initHmacMD5Key() throws NoSuchAlgorithmException { + //Init KeyGenerator. + KeyGenerator generator = KeyGenerator.getInstance("HmacSHA224"); + //Generate key. + SecretKey secretKey = generator.generateKey(); + return ByteUtils.toHexString(secretKey.getEncoded()); + } + + /** + * @description: HmacMD5 消息摘要 + */ + public static String encodeHmacMD5(String data, String key) throws NoSuchAlgorithmException, InvalidKeyException { + //Restore key. + SecretKey secretKey = new SecretKeySpec(ByteUtils.fromHexString(key), "HmacSHA224"); + //Instantiate Mac. + Mac mac = Mac.getInstance(secretKey.getAlgorithm()); + //Init Mac. + mac.init(secretKey); + //Execute. + return ByteUtils.toHexString(mac.doFinal(ByteUtils.fromHexString(data))); + } + + public static void main(String[] args) { + String privateKey = "936df5fd9aba3b86adc3c1a1c52dcde1"; + ObjectNode param = new ObjectMapper().createObjectNode(); + param.put("userName", "张三"); + param.put("caseNo", "ZC1234125"); + param.put("userId", "124124"); + param.put("roomId", "124125"); + param.put("systemType", "tiaojiexitong"); + String encryptString = sm4Encrypt(param.toString(), privateKey); + System.out.println("加密后的字符串:" + encryptString); + String uid = UUID.randomUUID().toString().replace("-", ""); + System.out.println("uid:" + uid); + System.out.println("解密后的字符串:" + sm4Decrypt(encryptString, privateKey)); + + } + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtils.java index 05afb65..be9e4ae 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/PdfUtils.java @@ -4,22 +4,16 @@ import com.documents4j.api.DocumentType; import com.documents4j.api.IConverter; import com.documents4j.job.LocalConverter; import com.itextpdf.text.Document; -import com.itextpdf.text.Font; import com.itextpdf.text.PageSize; -import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.tool.xml.XMLWorkerFontProvider; import com.itextpdf.tool.xml.XMLWorkerHelper; -import com.ruoyi.common.config.RuoYiConfig; -import com.tencentcloudapi.teo.v20220901.models.CC; import lombok.extern.slf4j.Slf4j; import java.io.*; import java.nio.charset.Charset; import java.nio.file.Files; -import static cn.hutool.core.util.ClassLoaderUtil.getClassLoader; - /** * @author wangqiong * @description pdf转换工具类 @@ -44,7 +38,7 @@ public class PdfUtils { document.setMarginMirroring(false); document.open(); // 解决PDF中文不显示 - String fontPath = "/D:/simsun.ttf"; //字体文件路径 + String fontPath = "/home/ruoyi/uploadPath/songfont/simsun.ttf"; //字体文件路径 XMLWorkerFontProvider provider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS); provider.register(fontPath);//注册字体 log.error("注册字体"); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java deleted file mode 100644 index 1a2e2b7..0000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtils.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.ruoyi.common.utils; - -import com.tencentcloudapi.common.Credential; -import com.tencentcloudapi.common.exception.TencentCloudSDKException; -import com.tencentcloudapi.sms.v20210111.SmsClient; -import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; -import com.tencentcloudapi.sms.v20210111.models.SendStatus; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import lombok.var; - -import java.util.Objects; - -@Slf4j -public class SmsUtils { - //应用id - private static final String SDK_APP_ID = "1400854852"; - //API的SecretId - private static final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp"; - //API的SecretKey - private static final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V"; - //签名内容 - private static final String SIGN_NAME = "乙巢智慧仲裁网"; - - public static Boolean sendSms(SendSmsRequest request) { - Credential cred = new Credential(SECRET_ID, SECRET_KEY ); - - SmsClient client = new SmsClient(cred, "ap-guangzhou"); - - final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest(); - req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()}); - req.setSmsSdkAppId(SDK_APP_ID ); - req.setSignName(SIGN_NAME); - req.setTemplateId(request.getTemplateId()); - req.setTemplateParamSet(request.getTemplateParamSet()); - SendSmsResponse res = null; - try { - res = client.SendSms(req); - } catch (TencentCloudSDKException e) { - log.error("发送短信出错:", e); - return Boolean.FALSE; - } - SendStatus sendStatus = res.getSendStatusSet()[0]; - log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage()); - - if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){ - return Boolean.TRUE; - } - return Boolean.FALSE; - } - public static Boolean sendSms(Long caseId,String templateId,String phone,String[] templateParamSet) { - SendSmsRequest request = new SendSmsRequest(phone,templateId,templateParamSet,caseId); - Credential cred = new Credential(SECRET_ID, SECRET_KEY ); - - SmsClient client = new SmsClient(cred, "ap-guangzhou"); - - final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest(); - req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()}); - req.setSmsSdkAppId(SDK_APP_ID ); - req.setSignName(SIGN_NAME); - req.setTemplateId(request.getTemplateId()); - req.setTemplateParamSet(request.getTemplateParamSet()); - SendSmsResponse res = null; - try { - res = client.SendSms(req); - } catch (TencentCloudSDKException e) { - log.error("发送短信出错:", e); - return Boolean.FALSE; - } - SendStatus sendStatus = res.getSendStatusSet()[0]; - log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage()); - - if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){ - return Boolean.TRUE; - } - return Boolean.FALSE; - } - /** - * 参数对象 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class SendSmsRequest { - /** - * 电话 - */ - private String phone; - - /** - * 模板 ID: 必须填写已审核通过的模板 ID - */ - private String templateId; - - /** - * 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 - */ - private String[] templateParamSet; - private Long caseId; - - } -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java index 236fee7..e4c75e4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java @@ -1,26 +1,19 @@ package com.ruoyi.common.utils; -import cn.hutool.core.io.resource.ClassPathResource; import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.config.Configure; import com.deepoove.poi.data.*; import com.deepoove.poi.data.style.ParagraphStyle; import com.deepoove.poi.data.style.Style; -import com.deepoove.poi.policy.PictureRenderPolicy; import com.deepoove.poi.util.PoitlIOUtils; -import org.apache.commons.io.FileUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.wp.usermodel.Paragraph; import org.apache.poi.xwpf.usermodel.*; -import javax.print.Doc; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -205,6 +198,24 @@ public class WordUtil { } } + /** + * 替换标签内容 + * @param map + * @param templatePath 模板路径 + * @param outputPath 文件输出路径 + */ + public static void render(Map map,String templatePath,String outputPath){ + XWPFTemplate template = XWPFTemplate.compile(templatePath).render(map); + try { + FileOutputStream out = new FileOutputStream(outputPath); + template.write(out); + out.flush(); + out.close(); + template.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java index 167abfd..b7e869a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/SaaSAPIFileUtils.java @@ -1,20 +1,13 @@ package com.ruoyi.common.utils.file; -import cn.hutool.json.JSONObject; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import com.ruoyi.common.config.EsignDemoConfig; import com.ruoyi.common.constant.EsignHeaderConstant; -import com.ruoyi.common.constant.FileTransformation; import com.ruoyi.common.core.domain.entity.EsignHttpResponse; import com.ruoyi.common.enums.EsignRequestType; import com.ruoyi.common.exception.EsignDemoException; import com.ruoyi.common.utils.EsignHttpHelper; import com.ruoyi.common.utils.bean.EsignFileBean; -import com.ruoyi.common.utils.uuid.IdUtils; -import java.time.LocalDate; import java.util.Map; public class SaaSAPIFileUtils { @@ -88,43 +81,27 @@ public class SaaSAPIFileUtils { public static void main(String[] args) throws EsignDemoException { - String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx"; - - EsignHttpResponse uploadUrl = getUploadUrl(filePath); - String body = uploadUrl.getBody(); - JSONObject jsonObject = new JSONObject(body); - JSONObject dataObj = jsonObject.getJSONObject("data"); - String fileUploadUrl = dataObj.get("fileUploadUrl").toString(); - System.out.println("这是fileUploadUrl:"+fileUploadUrl); - String fileId = dataObj.get("fileId").toString(); - System.out.println("这是fileId:"+fileId); - //String fileUploadUrl = "https://esignoss.esign.cn/1111564182/ccf6db5a-92da-4523-89ba-385a30423596/23893bfd3f2249ffa5c82850c11c482e.docx?Expires=1697021257&OSSAccessKeyId=STS.NTmgvSC8n5Zg1y7EciQftF23N&Signature=CxVZmpwFksWmLYkxPjVz9K4mVyA%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDAyODhjOTg3LWNlNzgtNDM1OC04NWYwLTdlNmUyM2NjOTJmNiQzNDk1NzQ3MjE5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fYLMznrudPgpiMM1%2BGoWM8XelYqfeYrDz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEofT7katr4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAaxcPCSY0Du8wgErfR1llD8t2zeFG%2B1mktU4Rsl7AgxsSFxrwILBUk2x7imVsFVA0kkS8rNBMDKGIsIZTCl5M7S2L%2BD8364htwcZgIZYHK2fCN6gCuy%2Bfk9C%2FfQaTc00IWBMw8OubuJ%2Fq2mdMh32yoi7dLuJyhwt1z%2F%2BWf5vIFHdIAA%3D"; - EsignHttpResponse esignHttpResponse = uploadFile(fileUploadUrl, filePath); - System.out.println("这是上传文件流的结果:"+esignHttpResponse.getBody()); - EsignHttpResponse fileStatus = getFileStatus(fileId); - System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody()); -// getFileStatus("a808f1f39a744357a2f018e4ab34c55d"); -// fileDownloadUrl(""); + fileDownloadUrl("8425b244bf4b417dbb22fd39a1c2d65f"); -// Gson gson = new Gson(); -// EsignHttpResponse fileDownload = fileDownloadUrl(signFlowId); -// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(),JsonObject.class); -// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); -// JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); -// if(filesArray!=null&&filesArray.size()>0){ -// JsonObject fileObject = (JsonObject)filesArray.get(0); -// String fileDownloadUrl = fileObject.get("downloadUrl").toString(); -// String fileName = java.util.UUID.randomUUID().toString().replace("-", "") + ".pdf"; -// String savePath = "/home/ruoyi/uploadPath/upload"; -// LocalDate now = LocalDate.now(); -// String year = Integer.toString(now.getYear()); -// String month = String.format("%02d", now.getMonthValue()); -// String day = String.format("%02d", now.getDayOfMonth()); -// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; -// String fileDownloadUrlnew = fileDownloadUrl.substring(1,fileDownloadUrl.length()-1); -// FileTransformation.downLoadFileByUrl(fileDownloadUrlnew,dir); -// } + + +// String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx"; +// +// EsignHttpResponse uploadUrl = getUploadUrl(filePath); +// String body = uploadUrl.getBody(); +// JSONObject jsonObject = new JSONObject(body); +// JSONObject dataObj = jsonObject.getJSONObject("data"); +// String fileUploadUrl = dataObj.get("fileUploadUrl").toString(); +// System.out.println("这是fileUploadUrl:"+fileUploadUrl); +// String fileId = dataObj.get("fileId").toString(); +// System.out.println("这是fileId:"+fileId); +// //String fileUploadUrl = "https://esignoss.esign.cn/1111564182/ccf6db5a-92da-4523-89ba-385a30423596/23893bfd3f2249ffa5c82850c11c482e.docx?Expires=1697021257&OSSAccessKeyId=STS.NTmgvSC8n5Zg1y7EciQftF23N&Signature=CxVZmpwFksWmLYkxPjVz9K4mVyA%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDAyODhjOTg3LWNlNzgtNDM1OC04NWYwLTdlNmUyM2NjOTJmNiQzNDk1NzQ3MjE5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fYLMznrudPgpiMM1%2BGoWM8XelYqfeYrDz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEofT7katr4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAaxcPCSY0Du8wgErfR1llD8t2zeFG%2B1mktU4Rsl7AgxsSFxrwILBUk2x7imVsFVA0kkS8rNBMDKGIsIZTCl5M7S2L%2BD8364htwcZgIZYHK2fCN6gCuy%2Bfk9C%2FfQaTc00IWBMw8OubuJ%2Fq2mdMh32yoi7dLuJyhwt1z%2F%2BWf5vIFHdIAA%3D"; +// EsignHttpResponse esignHttpResponse = uploadFile(fileUploadUrl, filePath); +// System.out.println("这是上传文件流的结果:"+esignHttpResponse.getBody()); +// EsignHttpResponse fileStatus = getFileStatus(fileId); +// System.out.println("这是获取文件上传状态的结果:"+fileStatus.getBody()); + 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..370e267 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; @@ -20,6 +21,7 @@ import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.framework.security.context.AuthenticationContextHolder; import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -55,6 +57,8 @@ public class SysLoginService private ISysConfigService configService; @Autowired private SysRoleMapper roleMapper; + @Autowired + private SysUserMapper userMapper; /** * 登录验证 @@ -230,16 +234,20 @@ public class SysLoginService AjaxResult ajax = AjaxResult.success(); String username = loginBody.getUsername(); // 根据用户名获取用户信息,如果用户不存在则新增用户 - SysUser user = userService.selectUserByUserName(username); + SysUser user =null; + if(username.contains("@")) { + user= userMapper.selectUserByEmail(username); + }else { + user= userService.selectUserByUserName(username); + } if(user==null){ // 新增用户 user = new SysUser(); 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 +266,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/SysPermissionService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java index d1fb4ed..a3f7a30 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java @@ -1,15 +1,17 @@ package com.ruoyi.framework.web.service; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * 用户权限处理 @@ -31,13 +33,16 @@ public class SysPermissionService * @param user 用户信息 * @return 角色权限信息 */ - public Set getRolePermission(SysUser user) + public List getRolePermission(SysUser user) { - Set roles = new HashSet(); + List roles = new ArrayList<>(); // 管理员拥有所有权限 if (user.isAdmin()) { - roles.add("admin"); + SysRole sysRole = new SysRole(); + sysRole.setRoleId(1L); + sysRole.setRoleKey("admin"); + roles.add(sysRole); } else { @@ -58,7 +63,9 @@ public class SysPermissionService // 管理员拥有所有权限 if (user.isAdmin()) { - perms.add("*:*:*"); + // 查询所有数据权限,排除案件管理下的权限即可 + perms.addAll(menuService.selectAdminMenu()); + // perms.add("*:*:*"); } else { 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..2ef790d 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,9 +123,24 @@ 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; + } + public String createVideoToken(LoginUser loginUser,int expireTime) + { + String token = IdUtils.fastUUID(); + loginUser.setToken(token); + setUserAgent(loginUser); + refreshToken(loginUser); + Map claims = new HashMap<>(); + claims.put("userName",loginUser.getUsername()); + claims.put("userId",loginUser.getUserId()); + claims.put(Constants.LOGIN_USER_KEY, token); + String createToken = createToken(claims); + redisCache.setCacheObject(CacheConstants.LOGIN_USERNAME_TOKEN_KEY+loginUser.getUsername(),createToken, expireTime, TimeUnit.MINUTES); + return createToken; } - /** * 验证令牌有效期,相差不足20分钟,自动刷新缓存 * @@ -154,6 +169,7 @@ public class TokenService // 根据uuid将loginUser缓存 String userKey = getTokenKey(loginUser.getToken()); redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); + } /** diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 9832e14..0ff3108 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -45,20 +45,20 @@ 2.1.5 - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/flow/MsCaseFlowRoleSmsRelated.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/flow/MsCaseFlowRoleSmsRelated.java new file mode 100644 index 0000000..e3b09c4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/flow/MsCaseFlowRoleSmsRelated.java @@ -0,0 +1,44 @@ +package com.ruoyi.system.domain.entity.flow; + +import java.util.Date; +import javax.persistence.*; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Table(name = "ms_case_flow_role_sms_related") +public class MsCaseFlowRoleSmsRelated { + /** + * id + */ + @Id + @GeneratedValue(generator = "JDBC") + private Integer id; + + /** + * 案件流程id + */ + @Column(name = "flow_id") + private Integer flowId; + + /** + * 用户角色id + */ + @Column(name = "receive_role_id") + private Long receiveRoleId; + + /** + * 短信模版id + */ + @Column(name = "sms_template_id") + private Long smsTemplateId; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; +} \ No newline at end of file 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..08539c9 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/log/MsRequestLog.java @@ -0,0 +1,56 @@ + +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/domain/entity/shortmessage/MeetingInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MeetingInfo.java new file mode 100644 index 0000000..3a3c1df --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MeetingInfo.java @@ -0,0 +1,60 @@ +package com.ruoyi.system.domain.entity.shortmessage; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "meeting_info") +public class MeetingInfo { + /** + * 主键Id + */ + @Id + private String uid; + + /** + * 案件Id + */ + @Column(name = "case_id") + private Long caseId; + + /** + * 用户Id + */ + @Column(name = "user_id") + private Long userId; + + /** + * 用户名称 + */ + @Column(name = "user_name") + private String userName; + + /** + * 房间Id + */ + @Column(name = "room_id") + private String roomId; + + /** + * 系统类型 + */ + @Column(name = "system_type") + private String systemType; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSendMailHistoryRecord.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSendMailHistoryRecord.java new file mode 100644 index 0000000..f951ee5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSendMailHistoryRecord.java @@ -0,0 +1,107 @@ +package com.ruoyi.system.domain.entity.shortmessage; + +import java.util.Date; +import javax.persistence.*; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Table(name = "ms_send_mail_history_record") +public class MsSendMailHistoryRecord { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * 邮件名称 + */ + @Column(name = "mail_name") + private String mailName; + + /** + * 邮件接收地址 + */ + @Column(name = "mail_address") + private String mailAddress; + + /** + * 发送时间 + */ + @Column(name = "send_time") + private Date sendTime; + + /** + * 案件编号 + */ + @Column(name = "case_num") + private String caseNum; + + /** + * 发送状态 + */ + @Column(name = "send_status") + private Long sendStatus; + + /** + * 立案申请id + */ + @Column(name = "case_id") + private Long caseId; + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + + /** + * 创建者 + */ + @Column(name = "create_by") + private String createBy; + + /** + * 更新者 + */ + @Column(name = "update_by") + private String updateBy; + + /** + * 更新时间 + */ + @Column(name = "update_time") + private Date updateTime; + + /** + * 附件id用英文逗号隔开 + */ + @Column(name = "file_ids") + private String fileIds; + + /** + * 邮件主题 + */ + @Column(name = "mail_subject") + private String mailSubject; + + /** + * 邮件发送地址 + */ + @Column(name = "mail_from_address") + private String mailFromAddress; + + /** + * 邮件父类id + */ + @Column(name = "parent_id") + private Long parentId; + + /** + * 邮件内容 + */ + @Column(name = "mail_content") + private String mailContent; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSmsSendHistoryRecord.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSmsSendHistoryRecord.java new file mode 100644 index 0000000..32eabf2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/shortmessage/MsSmsSendHistoryRecord.java @@ -0,0 +1,98 @@ +package com.ruoyi.system.domain.entity.shortmessage; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Table(name = "ms_sms_send_history_record") +public class MsSmsSendHistoryRecord { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * 案件id + */ + @Column(name = "case_appli_id") + private Long caseAppliId; + /** + * 短信模板表主键id + */ + @Column(name = "ms_sms_template_id") + private Long msSmsTemplateId; + + /** + * 案件编号 + */ + @Column(name = "case_num") + private String caseNum; + + /** + * 手机号 + */ + private String phone; + + /** + * 发送时间 + */ + @Column(name = "send_time") + private Date sendTime; + + /** + * 发送状态,0-失败,1-成功 + */ + @Column(name = "send_status") + private Long sendStatus; + + + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + + /** + * 更新时间 + */ + @Column(name = "update_time") + private Date updateTime; + + /** + * 创建人 + */ + @Column(name = "create_by") + private String createBy; + + /** + * 更新者 + */ + @Column(name = "update_by") + private String updateBy; + + /** + * 发送短信唯一标识 + */ + private String sid; + + /** + * 父类短信id + */ + @Column(name = "parent_id") + private Long parentId; + + /** + * 失败原因 + */ + private String reason; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendHistoryRecordParam.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendHistoryRecordParam.java new file mode 100644 index 0000000..b0d09cb --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendHistoryRecordParam.java @@ -0,0 +1,28 @@ +package com.ruoyi.system.domain.entity.sms; + +import javax.persistence.*; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@Table(name = "ms_sms_send_history_record_param") +public class MsSmsSendHistoryRecordParam { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * 短信历史记录表id + */ + @Column(name = "sms_record_history_id") + private Long smsRecordHistoryId; + + /** + * 参数值 + */ + @Column(name = "param_value") + private String paramValue; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendRecordParam.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendRecordParam.java new file mode 100644 index 0000000..440a239 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsSendRecordParam.java @@ -0,0 +1,33 @@ +package com.ruoyi.system.domain.entity.sms; + +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; + +@Getter +@Setter +@ToString +@Table(name = "ms_sms_send_record_param") +public class MsSmsSendRecordParam { + @Id + @GeneratedValue(generator = "JDBC") + private Integer id; + + /** + * 短信记录表id + */ + @Column(name = "sms_record_id") + private Long smsRecordId; + + + /** + * 参数值 + */ + @Column(name = "param_value") + private String paramValue; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplate.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplate.java new file mode 100644 index 0000000..54f6900 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplate.java @@ -0,0 +1,38 @@ +package com.ruoyi.system.domain.entity.sms; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import javax.persistence.*; +import java.util.List; + +@Getter +@Setter +@ToString +@Table(name = "ms_sms_template") +public class MsSmsTemplate { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * 腾讯云模板id + */ + @Column(name = "template_id") + private String templateId; + + /** + * 模板名称 + */ + private String name; + /** + * 模板内容 + */ + private String content; + /** + * 模板参数 + */ + @Transient + private List templateParams; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplateParam.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplateParam.java new file mode 100644 index 0000000..0150b33 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/entity/sms/MsSmsTemplateParam.java @@ -0,0 +1,38 @@ +package com.ruoyi.system.domain.entity.sms; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import javax.persistence.*; + +@Getter +@Setter +@ToString +@Table(name = "ms_sms_template_param") +public class MsSmsTemplateParam { + @Id + @GeneratedValue(generator = "JDBC") + private Long id; + + /** + * ms_sms_template表id + */ + @Column(name = "sms_template_id") + private Long smsTemplateId; + + /** + * 参数 + */ + private String param; + /** + * 参数名 + */ + @Column(name = "param_name") + private String paramName; + /** + * 参数值 + */ + @Transient + private String paramValue; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowRoleSmsRelatedVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowRoleSmsRelatedVO.java new file mode 100644 index 0000000..891a17a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowRoleSmsRelatedVO.java @@ -0,0 +1,39 @@ +package com.ruoyi.system.domain.vo.flow; + +import com.alibaba.fastjson2.JSONObject; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +public class MsCaseFlowRoleSmsRelatedVO { + /** + * 主键id + */ + private Integer id; + + /** + * 流程节点id + */ + private Integer flowId; + + + /** + * 短信模版id + */ + private Long smsTemplateId; + /** + * 发送短信的角色id + */ + private List receiveRoleIds; + /** + * 接收短信角色名称 + */ + public List receiveRoleNames; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowVO.java index 5ff8a51..7b1060c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowVO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/flow/MsCaseFlowVO.java @@ -1,5 +1,6 @@ package com.ruoyi.system.domain.vo.flow; +import com.alibaba.fastjson2.JSONObject; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -64,5 +65,16 @@ public class MsCaseFlowVO { * svg图片路径 */ private String fileName; - + /** + * 短信模版id + */ + private Long smsTemplateId; + /** + * 发送短信的角色id + */ + private List receiveRoleIds; + /** + * 接收短信角色名称 + */ + public List receiveRoleNames; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 7325df0..94fbd00 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -78,6 +78,13 @@ public interface SysDeptMapper */ public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); + /** + * 根据部门名称查询部门信息 + * @param deptName + * @return + */ + public SysDept selectDeptByName(@Param("deptName") String deptName); + /** * 新增部门信息 * 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/flow/MsCaseFlowRoleSmsRelatedMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.java new file mode 100644 index 0000000..1eb82cc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.flow; + +import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated; +import tk.mybatis.mapper.common.Mapper; + +public interface MsCaseFlowRoleSmsRelatedMapper extends Mapper { +} \ No newline at end of file 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/mapper/shortmessage/MeetingInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.java new file mode 100644 index 0000000..19a4a9c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.shortmessage; + +import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo; +import tk.mybatis.mapper.common.Mapper; + +public interface MeetingInfoMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.java new file mode 100644 index 0000000..5b62272 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.shortmessage; + +import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord; +import tk.mybatis.mapper.common.Mapper; + +public interface MsSendMailHistoryRecordMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.java new file mode 100644 index 0000000..d4152fc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.shortmessage; + +import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord; +import tk.mybatis.mapper.common.Mapper; + +public interface MsSmsSendHistoryRecordMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.java new file mode 100644 index 0000000..7dbe5bf --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.java @@ -0,0 +1,22 @@ +package com.ruoyi.system.mapper.sms; + +import com.ruoyi.system.domain.entity.sms.MsSmsSendHistoryRecordParam; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import tk.mybatis.mapper.common.Mapper; + +import java.util.List; + +public interface MsSmsSendHistoryRecordParamMapper extends Mapper { + /** + * 批量新增 + * @param historyRecordParams + */ + @Select("") + void batchInsert(@Param("list") List historyRecordParams); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.java new file mode 100644 index 0000000..01a92db --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.java @@ -0,0 +1,22 @@ +package com.ruoyi.system.mapper.sms; + +import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import tk.mybatis.mapper.common.Mapper; + +import java.util.List; + +public interface MsSmsSendRecordParamMapper extends Mapper { + /** + * 批量插入 + * @param list + */ + @Select("") + void batchInsert(@Param("list") List list); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.java new file mode 100644 index 0000000..b1396f8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.system.mapper.sms; + +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; +import tk.mybatis.mapper.common.Mapper; + +public interface MsSmsTemplateMapper extends Mapper { +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.java new file mode 100644 index 0000000..cb826b3 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.java @@ -0,0 +1,18 @@ +package com.ruoyi.system.mapper.sms; + +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import tk.mybatis.mapper.common.Mapper; + +import java.util.List; + +public interface MsSmsTemplateParamMapper extends Mapper { + @Select("") + void batchInsert(@Param("list") List templateParams); +} \ 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 new file mode 100644 index 0000000..ac61224 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/BeiMingInterface.java @@ -0,0 +1,83 @@ +package com.ruoyi.system.service; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.enums.AttachmentOperateTypeEnum; +import com.ruoyi.common.enums.DocumentTypeEnum; +import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; +import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo; + +import java.io.File; + +public interface BeiMingInterface { + /** + * 1.获取北明接口令牌token对象 + * + * @param userName + * @param password + * @param times + * @return + */ + String getApiToken(String userName, String password, Long times); + + + /** + * 2.提交案件状态信息 + * + * @param token 令牌 + * @param abutmentId 第三方平台案件唯一标识 + * @param msCaseStatusInfo 案件状态信息 + * @return + */ + JSONObject submitCaseStatusInfo(String token, String abutmentId, String syncSource, MsCaseStatusInfo msCaseStatusInfo); + + /** + * 3.上传附件 + * + * @param file + * @return + */ + JSONObject uploadFile(File file, String token, String syncSource); + + /** + * 4.同步附件信息 + * + * @param action + * @param caseNo + * @param msCaseFileInfo + * @return + */ + JSONObject syncAttachmentInfo(String token, String syncSource, String action, String caseNo, MsCaseFileInfo msCaseFileInfo); + + /** + * 推送案件状态信息(调解系统推送案件状态时调用) + * + * @param username 用户名 + * @param password 密码 + * @param caseNo 案件编号 + * @param statusCode 案件状态编码 + * @param caseClosureExplanation 案件状态描述(或结案信息) + * @return + */ + JSONObject pushCaseStatusInfo(String username, String password, String caseNo, String statusCode, String caseClosureExplanation); + + /** + * 推送案件附件信息(调解系统推送案件附件信息时调用) + * + * @param username 用户名 + * @param password 密码 + * @param file 文件 + * @param abutmentId 调解系统文件Id + * @param syncSource 用户名 + * @param caseNo 案件编号 + * @return + */ + MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo, AttachmentOperateTypeEnum operateTypeEnum, DocumentTypeEnum documentTypeEnum); + + /** + * 删除附件 + * @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/ISysMenuService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java index 7d60696..a33de8d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java @@ -1,11 +1,13 @@ package com.ruoyi.system.service; -import java.util.List; -import java.util.Set; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.system.domain.vo.RouterVo; +import java.util.List; +import java.util.Set; + /** * 菜单 业务层 * @@ -141,4 +143,17 @@ public interface ISysMenuService * @return 结果 */ public boolean checkMenuNameUnique(SysMenu menu); + + /** + * 查询管理员权限 + * @return + */ + + Set selectAdminMenu(); + + /** + * 根据用户查询菜单权限字符 + * @return + */ + AjaxResult getMenuPermsByUser(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index 6c29f09..1a396e2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -1,10 +1,10 @@ package com.ruoyi.system.service; -import java.util.List; -import java.util.Set; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.system.domain.SysUserRole; +import java.util.List; + /** * 角色业务层 * @@ -34,7 +34,7 @@ public interface ISysRoleService * @param userId 用户ID * @return 权限列表 */ - public Set selectRolePermissionByUserId(Long userId); + public List selectRolePermissionByUserId(Long userId); /** * 查询所有角色 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/flow/CaseFlowService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java index 27c8b38..012901b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service.flow; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO; import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO; import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO; @@ -9,18 +10,22 @@ import java.util.Set; public interface CaseFlowService { /** * 查询案件流程节点信息 + * * @param caseFlowSearchVO * @return */ Object queryCaseFlowInfo(MsCaseFlowSearchVO caseFlowSearchVO); + /** * 查询案件流程信息 + * * @return */ AjaxResult selectCaseFlow(); /** * 新增或编辑案件流程节点信息 + * * @param caseFlowVO * @return */ @@ -28,6 +33,7 @@ public interface CaseFlowService { /** * 删除案件流程节点信息 + * * @param caseFlowVO * @return */ @@ -35,6 +41,7 @@ public interface CaseFlowService { /** * 排序案件流程节点 + * * @param caseFlowSearchVO * @return */ @@ -42,10 +49,14 @@ public interface CaseFlowService { /** * 查询用户角色关联的案件状态 + * * @param roles * @return */ Set getCaseStatusIdByRoleKey(Set roles); - + /** + * 查询流程节点接收信息配置记录 + */ + MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java index ff8ffbb..08dc602 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service.flow; +import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.core.domain.AjaxResult; @@ -7,12 +8,15 @@ import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated; +import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleSmsRelated; import com.ruoyi.system.domain.vo.flow.MsBaseCaseFlow; +import com.ruoyi.system.domain.vo.flow.MsCaseFlowRoleSmsRelatedVO; import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO; import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.flow.MsCaseFlowMapper; import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper; +import com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper; import com.ruoyi.system.util.NewStringUtil; import com.ruoyi.system.util.TableDataUtil; import org.springframework.beans.BeanUtils; @@ -90,6 +94,30 @@ public class CaseFlowServiceImpl implements CaseFlowService { MsCaseFlow msCaseFlow1 = msCaseFlowMapper.selectByPrimaryKey(msCaseFlow.getBackFlowId()); temp.setBackFlowName(msCaseFlow1 != null ? msCaseFlow1.getNodeName() : ""); } + //短信接收角色 + if (msCaseFlow.getId() != null) { + Example example1 = new Example(MsCaseFlowRoleSmsRelated.class); + Example.Criteria criteria1 = example1.createCriteria(); + criteria1.andEqualTo("flowId", msCaseFlow.getId()); + List msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1); + List receiveRoleNames = new ArrayList<>(); + List receiveRoleIds = new ArrayList<>(); + for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) { + MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k); + if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) { + SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId()); + if (sysRole != null) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("roleId", sysRole.getRoleId()); + jsonObject.put("roleName", sysRole.getRoleName()); + receiveRoleNames.add(jsonObject); + receiveRoleIds.add(sysRole.getRoleId()); + } + } + } + temp.setReceiveRoleIds(receiveRoleIds); + temp.setReceiveRoleNames(receiveRoleNames); + } list.add(temp); } TableDataInfo tableDataInfo = TableDataUtil.rebuildTableDataInfo(list, total); @@ -134,15 +162,16 @@ public class CaseFlowServiceImpl implements CaseFlowService { /** * 本地图片装64 + * * @param imgPath * @return * @throws Exception */ - public static String convertToBase64( String imgPath) { + public static String convertToBase64(String imgPath) { byte[] data = null; // 读取图片字节数组 try { - imgPath=imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/"); + imgPath = imgPath.replace("/profile/upload", "/home/ruoyi/uploadPath/upload/"); InputStream in = Files.newInputStream(Paths.get(imgPath)); data = new byte[in.available()]; in.read(data); @@ -153,6 +182,7 @@ public class CaseFlowServiceImpl implements CaseFlowService { // 返回Base64编码过的字节数组字符串 return Base64.getEncoder().encodeToString(Objects.requireNonNull(data)); } + /** * 新增或编辑案件流程节点信息 * @@ -161,40 +191,78 @@ public class CaseFlowServiceImpl implements CaseFlowService { */ @Override public Boolean saveCaseFlow(MsCaseFlowVO caseFlowVO) { - - if (caseFlowVO.getId() != null) { - //更新案件流程信息 - MsCaseFlow msCaseFlow = new MsCaseFlow(); - BeanUtils.copyProperties(caseFlowVO, msCaseFlow); - int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow); - if (i > 0) { - //更新流程节点和角色之间的关系 - updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds()); - return true; - } - } else { - int sort = 1; - Example example = new Example(MsCaseFlow.class); - example.setOrderByClause("sort DESC limit 1"); - Example.Criteria criteria = example.createCriteria(); - List msCaseFlows = msCaseFlowMapper.selectByExample(example); - if (msCaseFlows != null && msCaseFlows.size() > 0) { - sort = msCaseFlows.get(0).getSort() + 1; - } - //新增案件流程信息 - MsCaseFlow msCaseFlow = new MsCaseFlow(); - BeanUtils.copyProperties(caseFlowVO, msCaseFlow); - msCaseFlow.setSort(sort); - int insert = msCaseFlowMapper.insert(msCaseFlow); - if (insert > 0) { - //更新流程节点和角色之间的关系 - updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds()); - return true; + try { + if (caseFlowVO.getId() != null) { + //更新案件流程信息 + MsCaseFlow msCaseFlow = new MsCaseFlow(); + BeanUtils.copyProperties(caseFlowVO, msCaseFlow); + int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow); + if (i > 0) { + //更新流程节点和角色之间的关系 + updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds()); + //更新流程节点和短信模板之间的关系 + updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId()); + return true; + } else { + return false; + } + } else { + int sort = 1; + Example example = new Example(MsCaseFlow.class); + example.setOrderByClause("sort DESC limit 1"); + Example.Criteria criteria = example.createCriteria(); + List msCaseFlows = msCaseFlowMapper.selectByExample(example); + if (msCaseFlows != null && msCaseFlows.size() > 0) { + sort = msCaseFlows.get(0).getSort() + 1; + } + //新增案件流程信息 + MsCaseFlow msCaseFlow = new MsCaseFlow(); + BeanUtils.copyProperties(caseFlowVO, msCaseFlow); + msCaseFlow.setSort(sort); + int insert = msCaseFlowMapper.insert(msCaseFlow); + if (insert > 0) { + //更新流程节点和角色之间的关系 + updateFlowRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getRoleIds()); + //更新流程节点和短信模板之间的关系 + updateFlowMessageRoleByFlowId(msCaseFlow.getId(), caseFlowVO.getReceiveRoleIds(), caseFlowVO.getSmsTemplateId()); + return true; + } } + } catch (Exception e) { + e.printStackTrace(); } return false; } + @Autowired + MsCaseFlowRoleSmsRelatedMapper msCaseFlowRoleSmsRelatedMapper; + + /** + * 更新流程节点和短信模板之间的关系 + * + * @param flowId + * @param receiveRoleIds + * @param smsTemplateId + */ + private void updateFlowMessageRoleByFlowId(Integer flowId, List receiveRoleIds, Long smsTemplateId) { + if (receiveRoleIds != null && receiveRoleIds.size() > 0) { + //删除历史流程与短信发送设置记录 + Example example = new Example(MsCaseFlowRoleSmsRelated.class); + example.createCriteria().andEqualTo("flowId", flowId); + int count = msCaseFlowRoleSmsRelatedMapper.deleteByExample(example); + //新增流程节点与短信发送设置记录 + for (int i = 0; i < receiveRoleIds.size(); i++) { + MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = new MsCaseFlowRoleSmsRelated(); + msCaseFlowRoleSmsRelated.setFlowId(flowId); + msCaseFlowRoleSmsRelated.setReceiveRoleId(receiveRoleIds.get(i)); + msCaseFlowRoleSmsRelated.setSmsTemplateId(smsTemplateId); + msCaseFlowRoleSmsRelated.setCreateTime(new Date()); + msCaseFlowRoleSmsRelatedMapper.insertSelective(msCaseFlowRoleSmsRelated); + } + } + + } + /** * 更新流程节点和角色之间的关系 * @@ -258,7 +326,6 @@ public class CaseFlowServiceImpl implements CaseFlowService { } - /** * 排序案件流程节点 * @@ -352,6 +419,44 @@ public class CaseFlowServiceImpl implements CaseFlowService { return caseStatusIds; } + /** + * 查询流程节点接收信息配置记录 + * + * @param flowId + */ + @Override + public MsCaseFlowRoleSmsRelatedVO queryFlowReceiveRoleSmsRelated(Integer flowId) { + MsCaseFlowRoleSmsRelatedVO result = new MsCaseFlowRoleSmsRelatedVO(); + //短信接收角色 + if (flowId != null) { + Example example1 = new Example(MsCaseFlowRoleSmsRelated.class); + Example.Criteria criteria1 = example1.createCriteria(); + criteria1.andEqualTo("flowId", flowId); + List msCaseFlowRoleSmsRelateds = msCaseFlowRoleSmsRelatedMapper.selectByExample(example1); + List receiveRoleNames = new ArrayList<>(); + List receiveRoleIds = new ArrayList<>(); + for (int k = 0; k < msCaseFlowRoleSmsRelateds.size(); k++) { + MsCaseFlowRoleSmsRelated msCaseFlowRoleSmsRelated = msCaseFlowRoleSmsRelateds.get(k); + if (k == 0) { + BeanUtils.copyProperties(msCaseFlowRoleSmsRelated, result); + } + if (msCaseFlowRoleSmsRelated.getReceiveRoleId() != null) { + SysRole sysRole = sysRoleMapper.selectRoleById(msCaseFlowRoleSmsRelated.getReceiveRoleId()); + if (sysRole != null) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("roleId", sysRole.getRoleId()); + jsonObject.put("roleName", sysRole.getRoleName()); + receiveRoleNames.add(jsonObject); + receiveRoleIds.add(sysRole.getRoleId()); + } + } + } + result.setReceiveRoleIds(receiveRoleIds); + result.setReceiveRoleNames(receiveRoleNames); + } + return result; + } + /** * 查询角色的案件状态id * 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 new file mode 100644 index 0000000..84c1abc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BeiMingInterfaceService.java @@ -0,0 +1,391 @@ +package com.ruoyi.system.service.impl; + +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.enums.AttachmentOperateTypeEnum; +import com.ruoyi.common.enums.DocumentTypeEnum; +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; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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; +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; + +/** + * @author ym + */ +@Slf4j +@Service +public class BeiMingInterfaceService implements BeiMingInterface { + @Autowired + RestTemplate restTemplate; + @Autowired + MsRequestLogService requestLogService; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + /** + * 接口地址 + */ + @Value("${beimingapihost}") + public String apihost; + /** + * 接口路径前缀 + */ + @Value("${beimingapiprefix}") + 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 + * + * @param userName + * @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(); + //传递请求体时必须设置传递参数的格式,为Content-Type : application/json + httpHeaders.add("Content-Type", "application/json;charset=UTF-8"); + httpHeaders.add("syncSource", userName); + // 2.请求头 & 请求体 + HttpEntity fromEntity = new HttpEntity(httpHeaders); + JSONObject body = new JSONObject(); +// body.put("account", userName); +// body.put("password", password); +// body.put("timestamp", times); + //对整体请求进行加密 + ObjectNode param = new ObjectMapper().createObjectNode(); + param.put("account", userName); + param.put("password", password); + param.put("timestamp", times); + String encryptString = sm4Encrypt(param.toString(), privateKey); + body.put("encryptString", encryptString); + 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("推送失败"); + } + requestLogService.insert(requestLog); + return analysisResultToken(Objects.requireNonNull(result).toString()); + } + + + /** + * 解析加密后端token + * + * @param token + * @return + */ + public String analysisResultToken(String token) { + String resultToken = null; + if (token != null && !token.isEmpty()) { + JSONObject jsonObject = JSON.parseObject(token); + String tokenString = jsonObject.getString("data"); + String tokenstr = sm4Decrypt(tokenString, privateKey); + if (tokenstr != null && !tokenstr.isEmpty()) { + JSONObject tokenObject = JSON.parseObject(tokenstr); + resultToken = tokenObject.getString("token"); + } + } + return resultToken; + } + + /** + * 2.推送案件状态信息 + * + * @param token 令牌 + * @param abutmentId 第三方平台案件唯一标识 + * @param msCaseStatusInfo 案件状态信息 + * @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(); + //传递请求体时必须设置传递参数的格式,为Content-Type : application/json + httpHeaders.add("Content-Type", "application/json;charset=UTF-8"); + httpHeaders.add("token", token); + httpHeaders.add("syncSource", syncSource); + //对整体请求进行加密 + ObjectNode param = new ObjectMapper().createObjectNode(); + param.put("abutmentId", abutmentId); + param.put("caseNo", msCaseStatusInfo.getCaseNo()); + param.put("statusCode", msCaseStatusInfo.getStatusCode()); + param.put("caseClosureExplanation", msCaseStatusInfo.getCaseClosureExplanation()); + String encryptString = sm4Encrypt(param.toString(), privateKey); + // 2.请求头 & 请求体 + HttpEntity fromEntity = new HttpEntity(httpHeaders); + JSONObject body = new JSONObject(); +// body.put("abutmentId", Encrypt("abutmentId",abutmentId)); +// body.put("caseNo", Encrypt("caseNo", msCaseStatusInfo.getCaseNo())); +// body.put("statusCode", Encrypt("statusCode",msCaseStatusInfo.getStatusCode())); +// body.put("caseClosureExplanation", Encrypt("caseClosureExplanation", msCaseStatusInfo.getCaseClosureExplanation())); + //对整体请求进行加密 + body.put("encryptString", encryptString); + 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; + + } + + /** + * 3.上传附件 + * + * @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(); + //传递请求体时必须设置传递参数的格式,为Content-Type : application/json + httpHeaders.add("Content-Type", "multipart/form-data"); + httpHeaders.add("token", token); + httpHeaders.add("syncSource", syncSource); + // 构建请求体 + MultiValueMap requestBody = new LinkedMultiValueMap<>(); + CommonInputStreamResource commonInputStreamResource = null; + try { + FileInputStream fileInputStream = new FileInputStream(file); + commonInputStreamResource = new CommonInputStreamResource(fileInputStream, file.length(), file.getName()); + } catch (Exception e) { + log.error("文件输入流转换错误", e); + } + 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; + } + + /** + * 4.同步附件信息 + * + * @param token + * @param syncSource 用户名 + * @param action 附件操作类型 + * @param caseNo 案件编号 + * @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(); + //传递请求体时必须设置传递参数的格式,为Content-Type : application/json + httpHeaders.add("Content-Type", "application/json;charset=UTF-8"); + httpHeaders.add("token", token); + httpHeaders.add("syncSource", syncSource); + //对整体请求进行加密 + ObjectNode param = new ObjectMapper().createObjectNode(); + param.put("caseNo", caseNo); + param.put("action", action); + param.put("abutmentId", msCaseFileInfo.getAbutmentId()); + param.put("abutmentCaseId", msCaseFileInfo.getAbutmentCaseId()); + param.put("documentSubject", msCaseFileInfo.getDocumentSubject()); + param.put("documentType", msCaseFileInfo.getDocumentType()); + param.put("fileName", msCaseFileInfo.getFileName()); + param.put("fileId", msCaseFileInfo.getFileId()); + if (msCaseFileInfo.getOwnerType() != null) { + param.put("ownerType", msCaseFileInfo.getOwnerType()); + } + if (msCaseFileInfo.getOwnerId() != null) { + param.put("ownerId", msCaseFileInfo.getOwnerId()); + } + if (msCaseFileInfo.getOwnerName() != null) { + param.put("ownerName", msCaseFileInfo.getOwnerName()); + } + String encryptString = sm4Encrypt(param.toString(), privateKey); + // 2.请求体 + HttpEntity fromEntity = new HttpEntity(httpHeaders); + JSONObject body = new JSONObject(); + //对整体请求进行加密 + 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 = 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); + System.out.println("jieguo:" + result.toString()); + if (result != null) { + String data = result.getString("data"); + String datastr = sm4Decrypt(data, privateKey); + System.out.println("最终解密后的字符串:" + datastr); + } + } + return result; + } + /** + * 推送案件附件信息 + */ + @Transactional + @Override + public MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo, AttachmentOperateTypeEnum operateTypeEnum, DocumentTypeEnum documentTypeEnum) { + JSONObject result = new JSONObject(); + MsCaseFileInfo fileInfo=null; + //1.获取token + String token = beiMingInterfaceService.getApiToken(username, password, System.currentTimeMillis()); + if (token != null && !token.isEmpty()) { + //2.上传文件 + JSONObject fileResult = uploadFile(file, token, syncSource); + if (fileResult != null) { + String data = fileResult.getString("data"); + String datastr = sm4Decrypt(data, privateKey); + System.out.println("最终解密后的字符串:" + datastr); + if (datastr != null) { + JSONObject parse = JSON.parseObject(datastr); + if (parse != null) { + String fileId = parse.getString("fileId"); + System.out.println("fileId====:" + fileId); + if (fileId != null) { + //3.同步附件更新信息 + fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(file.getName()).abutmentId(fileId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType(documentTypeEnum.getCode()).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 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); + } + + /** + * 对字段值进行加密 + * + * @return + */ + private String Encrypt(String filed, String filedValue) { + ObjectNode param = new ObjectMapper().createObjectNode(); + param.put(filed, filedValue); + String encryptString = sm4Encrypt(param.toString(), privateKey); + return encryptString; + } + +} 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..f18e5b4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MsRequestLogServiceImpl.java @@ -0,0 +1,27 @@ +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; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @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; + @Transactional(propagation = Propagation.REQUIRES_NEW) + @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..71fc89a 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 cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.annotation.DataScope; 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,14 @@ 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 com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper; +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 +38,10 @@ public class SysDeptServiceImpl implements ISysDeptService @Autowired private SysRoleMapper roleMapper; + @Autowired + private RedisCache redisCache; + @Autowired + MsCaseApplicationMapper caseApplicationMapper; /** * 查询部门管理数据 @@ -221,7 +229,8 @@ public class SysDeptServiceImpl implements ISysDeptService } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); } - return deptMapper.insertDept(dept); + int i = deptMapper.insertDept(dept); + return i; } /** @@ -293,6 +302,12 @@ public class SysDeptServiceImpl implements ISysDeptService @Override public int deleteDeptById(Long deptId) { + // 查询部门是否与案件有关 + List caseList = caseApplicationMapper.selectCaseByDeptId(deptId); + if(CollectionUtil.isNotEmpty(caseList)){ + throw new ServiceException("该部门有关联案件,不允许删除"); + } + return deptMapper.deleteDeptById(deptId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index 225c280..8fbf984 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -1,17 +1,9 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import cn.hutool.core.collection.CollectionUtil; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysRole; @@ -24,6 +16,11 @@ import com.ruoyi.system.mapper.SysMenuMapper; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMenuMapper; import com.ruoyi.system.service.ISysMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; /** * 菜单 业务层处理 @@ -120,6 +117,36 @@ public class SysMenuServiceImpl implements ISysMenuService } return permsSet; } + /** + * 查询管理员权限 + * @return + */ + @Override + public Set selectAdminMenu() { + Set permsSet = new HashSet<>(); + List sysMenus = menuMapper.selectMenuList(new SysMenu()); + Long caseMenuId =null; + if(CollectionUtil.isNotEmpty(sysMenus)){ + Optional optional = sysMenus.stream().filter(sysMenu -> sysMenu.getMenuName().equals("案件列表")).findFirst(); + if(optional.isPresent()){ + caseMenuId= optional.get().getMenuId(); + } + for (SysMenu sysMenu : sysMenus) { + if(!sysMenu.getParentId().equals(caseMenuId)&&StringUtils.isNotEmpty(sysMenu.getPerms())){ + permsSet.addAll(Arrays.asList(sysMenu.getPerms().trim().split(","))); + } + } + } + return permsSet; + } + + @Override + public AjaxResult getMenuPermsByUser() { + AjaxResult result = AjaxResult.success(); + List perms = menuMapper.selectMenuPermsByUserId(SecurityUtils.getUserId()); + result.put("perms",perms); + return result; + } /** * 根据用户ID查询菜单 @@ -346,6 +373,8 @@ public class SysMenuServiceImpl implements ISysMenuService return UserConstants.UNIQUE; } + + /** * 获取路由名称 * 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..91df2ad 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; /** * 根据条件分页查询角色数据 @@ -90,18 +93,11 @@ public class SysRoleServiceImpl implements ISysRoleService * @return 权限列表 */ @Override - public Set selectRolePermissionByUserId(Long userId) + public List selectRolePermissionByUserId(Long userId) { List perms = roleMapper.selectRolePermissionByUserId(userId); - Set permsSet = new HashSet<>(); - for (SysRole perm : perms) - { - if (StringUtils.isNotNull(perm)) - { - permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); - } - } - return permsSet; + + return perms; } /** @@ -233,6 +229,7 @@ public class SysRoleServiceImpl implements ISysRoleService { // 新增角色信息 roleMapper.insertRole(role); + redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId()); return insertRoleMenu(role); } @@ -250,6 +247,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 +339,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 +361,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 +375,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/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index cbf225b..f8a7bf7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -2,11 +2,13 @@ package com.ruoyi.system.service.impl; 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.AjaxResult; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUserDept; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; @@ -19,6 +21,7 @@ import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +31,7 @@ import org.springframework.util.CollectionUtils; import javax.validation.Validator; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -66,6 +70,10 @@ public class SysUserServiceImpl implements ISysUserService { @Autowired protected Validator validator; + @Autowired + private RedisCache redisCache; + @Autowired + MsCaseApplicationMapper msCaseApplicationMapper; /** * 根据条件分页查询用户列表 @@ -245,6 +253,7 @@ public class SysUserServiceImpl implements ISysUserService { user.setCreateBy("admin"); user.setCreateTime(DateUtils.getNowDate()); int rows = userMapper.insertUser(user); + // 新增用户部门关联 if(CollectionUtil.isNotEmpty(user.getDeptIds())) { // 先删除用户与部门关联 @@ -262,6 +271,8 @@ public class SysUserServiceImpl implements ISysUserService { insertUserPost(user); // 新增用户与角色管理 insertUserRole(user); + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); return AjaxResult.success("新建用户成功"); } @@ -273,7 +284,10 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public boolean registerUser(SysUser user) { - return userMapper.insertUser(user) > 0; + int i = userMapper.insertUser(user); + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); + return i > 0; } /** @@ -308,6 +322,9 @@ public class SysUserServiceImpl implements ISysUserService { // 新增用户与岗位管理 insertUserPost(user); userMapper.updateUser(user); + // redis缓存 + user=userMapper.selectUserById(userId); + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); return AjaxResult.success("更新用户成功"); } @@ -332,7 +349,10 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public int updateUserStatus(SysUser user) { - return userMapper.updateUser(user); + int i = userMapper.updateUser(user); + // redis缓存 + // redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); + return i; } /** @@ -343,7 +363,11 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public int updateUserProfile(SysUser user) { - return userMapper.updateUser(user); + int i = userMapper.updateUser(user); + // redis缓存 + user=userMapper.selectUserById(user.getUserId()); + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); + return i; } /** @@ -366,7 +390,8 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public int resetPwd(SysUser user) { - return userMapper.updateUser(user); + int i = userMapper.updateUser(user); + return i; } /** @@ -440,10 +465,20 @@ public class SysUserServiceImpl implements ISysUserService { @Transactional public int deleteUserById(Long userId) { // 删除用户与角色关联 - userRoleMapper.deleteUserRoleByUserId(userId); + // userRoleMapper.deleteUserRoleByUserId(userId); // 删除用户与岗位表 - userPostMapper.deleteUserPostByUserId(userId); - return userMapper.deleteUserById(userId); + // userPostMapper.deleteUserPostByUserId(userId); + // 与案件有关的人员不能删除 + List userIds = new ArrayList<>(); + userIds.add(userId); + List caseIds= msCaseApplicationMapper.countCasePerson(userIds); + if(CollectionUtil.isNotEmpty(caseIds)){ + throw new ServiceException("该人员已参与案件,不能删除"); + } + int i = userMapper.deleteUserById(userId); + // 删除缓存 + redisCache.deleteObject(CacheConstants.USER_KEY+userId); + return i; } /** @@ -455,17 +490,30 @@ public class SysUserServiceImpl implements ISysUserService { @Override @Transactional public int deleteUserByIds(Long[] userIds) { + // 校验是否与案件关联 + if(userIds==null || userIds.length==0){ + throw new ServiceException("请选择删除的用户"); + } + List caseIds= msCaseApplicationMapper.countCasePerson(new ArrayList<>(Arrays.asList(userIds))); + if(CollectionUtil.isNotEmpty(caseIds)){ + throw new ServiceException("删除人员中存在与案件关联的人员,不能删除"); + } for (Long userId : userIds) { checkUserAllowed(new SysUser(userId)); checkUserDataScope(userId); } // 删除用户与角色关联 - userRoleMapper.deleteUserRole(userIds); + // userRoleMapper.deleteUserRole(userIds); // 删除用户与岗位关联 - userPostMapper.deleteUserPost(userIds); + // userPostMapper.deleteUserPost(userIds); // 删除用户部门关联 - userDeptMapper.deleteUserByIds(userIds); - return userMapper.deleteUserByIds(userIds); + // userDeptMapper.deleteUserByIds(userIds); + int i = userMapper.deleteUserByIds(userIds); + for (Long userId : userIds) { + // 删除缓存 + redisCache.deleteObject(CacheConstants.USER_KEY+userId); + } + return i; } /** @@ -495,6 +543,8 @@ public class SysUserServiceImpl implements ISysUserService { user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); userMapper.insertUser(user); + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); } else if (isUpdateSupport) { @@ -504,6 +554,9 @@ public class SysUserServiceImpl implements ISysUserService { user.setUserId(u.getUserId()); user.setUpdateBy(operName); userMapper.updateUser(user); + // redis缓存 + user=userMapper.selectUserById(user.getUserId()); + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 更新成功"); } else { diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/miniprogress/IdentityAuthentication.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/miniprogress/IdentityAuthentication.java index 7eca08b..ea46bdf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/miniprogress/IdentityAuthentication.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/miniprogress/IdentityAuthentication.java @@ -31,6 +31,10 @@ public class IdentityAuthentication extends BaseEntity { * 短信验证码 */ private String VerifyCode; + /** + * email验证码 + */ + private String emailVerifyCode; private String passWord; private String phone; /** @@ -47,6 +51,14 @@ public class IdentityAuthentication extends BaseEntity { /** 认证状态 */ private Integer certificationStatus; + public String getEmailVerifyCode() { + return emailVerifyCode; + } + + public void setEmailVerifyCode(String emailVerifyCode) { + this.emailVerifyCode = emailVerifyCode; + } + public Integer getCertificationStatus() { return certificationStatus; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SendMailRecord.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SendMailRecord.java index 5c7e08c..3b3c9aa 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SendMailRecord.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SendMailRecord.java @@ -3,9 +3,10 @@ package com.ruoyi.wisdomarbitrate.domain.dto.sendrecord; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; import java.util.Date; - +@Data public class SendMailRecord extends BaseEntity { private static final long serialVersionUID = 1L; @@ -40,6 +41,15 @@ public class SendMailRecord extends BaseEntity { private Integer sendStatus; + /** 附件id */ + private String fileIds; + + /** 邮件主题 */ + private String mailSubject; + + /** 邮件发件人地址 */ + private String mailFromAddress; + public Integer getSendStatus() { return sendStatus; diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SmsSendRecord.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SmsSendRecord.java index 4e17d80..bc1a25e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SmsSendRecord.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/sendrecord/SmsSendRecord.java @@ -2,11 +2,13 @@ package com.ruoyi.wisdomarbitrate.domain.dto.sendrecord; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Date; +import java.util.List; @Data @AllArgsConstructor @@ -16,6 +18,10 @@ public class SmsSendRecord extends BaseEntity { * ID */ private Long id; + /** + * 短信模板主键id + */ + private Long msSmsTemplateId; /** * 案件申请id */ @@ -33,21 +39,39 @@ public class SmsSendRecord extends BaseEntity { */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date sendTime; - /** - * 发送内容 - */ - private String sendContent; /** * 发送状态 */ private Integer sendStatus; + /** + * 短信sid,发送的唯一标识 + */ + private String sid; + /** + * 失败原因 + */ + private String reason; + /** + * 短信内容 + */ + private String sendContent; + /** + * 腾讯云模板id + */ + private String templateId; + /** + * 模板内容 + */ + private String templateContent; + private List templateParams; - public SmsSendRecord(Long caseId, String caseNum, String phone, Date sendTime, String sendContent) { + public SmsSendRecord(Long caseId, String caseNum, String phone, Date sendTime, String sendContent,String sid) { this.caseId = caseId; this.caseNum = caseNum; this.phone = phone; this.sendTime = sendTime; this.sendContent = sendContent; + this.sid = sid; } } 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..5115f88 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,143 @@ 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; + @Transient + private String userName; /** * 法定代表人 */ - @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; + /** + * 是否机构申请,0-自然人,1-申请机构,默认0 + */ + @Column(name = "organize_flag") + private Integer organizeFlag=0; + /** + * 电话 + */ + @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; + /** + * 角色id + */ + @Transient + private Long roleId; - /** - * 被申请人身份证号 - */ - @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..86d6b1a 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; @@ -209,4 +206,22 @@ public class MsCaseApplication { @Column(name = "is_reconci") private Integer isReconci; + /** + * 案件来源,YC-乙巢,空字符串-北明 + */ + @Column(name = "case_source") + private String caseSource; + /** + * 是否需要用印,1-需要 + */ + @Column(name = "seal_flag") + private Integer sealFlag; + /** + * 拒绝原因 + */ + @Transient + private String rejectReason; + @Transient + private Integer organizeFlag=0; + } \ 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..ec3d3d9 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,14 @@ public class MsCaseAttach { */ @Column(name = "only_office_file_id") private String onlyOfficeFileId; + /** + * 对接其它系统返回的附件id + */ + @Column(name = "other_sys_file_id") + private String otherSysFileId; + /** + * 附件后缀 + */ + @Column(name = "suffix") + private String suffix; } \ 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..07df6e6 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,26 @@ public class MsCaseApplicationReq { * 代理人电话 */ private String contactTelphoneAgent; - + /** + * 邮箱 + */ + private String resEmail; + /** + * 申请人邮箱 + */ + private String email; + /** + * 角色类别 + */ + private Integer roleType; + private Long userId; + /** + * 案件id + */ + private Long caseId; + /** + * 是否需要用印,0-不需要,1-需要 + */ + // todo 等会放开 + private Integer sealFlag=1; } \ 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..3e29383 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,25 @@ 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; + /** + * 调解书上传下载按钮权限,调解员,顾问在调节之后,送达之前显示,0-否,1-是 + */ + private Integer mediationFileFlag=0; + /** + * 是否申请人被申请人签收按钮权限,0-否,1-是 + */ + private Integer signFlag=0; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseFileInfo.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseFileInfo.java new file mode 100644 index 0000000..621b4ff --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseFileInfo.java @@ -0,0 +1,54 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.mscase; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 北明接口案件附件信息入参 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MsCaseFileInfo { + + /** + * 第三方文件唯一标识 + */ + private String abutmentId; + /** + * 第三方平台案件唯一标识 + */ + private String abutmentCaseId; + /** + * 第一级文件类型 + */ + private String documentSubject; + /** + * 第二级文件类型 + */ + private String documentType; + /** + * 所属人类型(可不传) + */ + private String ownerType; + /** + * 文件所属人第三方平台对应的人员唯一标识(可不传) + */ + private String ownerId; + /** + * 文件所属人名称(可不传) + */ + private String ownerName; + /** + * 文件名称 + */ + private String fileName; + /** + * 一站式平台返回的文件ID + */ + private String fileId; + +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseStatusInfo.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseStatusInfo.java new file mode 100644 index 0000000..c7870e6 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/mscase/MsCaseStatusInfo.java @@ -0,0 +1,35 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.mscase; + +import lombok.*; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * 北明接口案件状态入参 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MsCaseStatusInfo { + /** + * 案号 + * 案件状态编码 + * 结案说明 + */ + private String caseNo; + + /** + * 案件状态编码 + */ + private String statusCode; + + /** + * 结案说明 + */ + private String caseClosureExplanation; + +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java new file mode 100644 index 0000000..0f30ac8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/MeetingInfoVO.java @@ -0,0 +1,41 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.shortmessage; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MeetingInfoVO { + /** + * 案件Id + */ + private Long caseId; + + /** + * 用户Id + */ + private Long userId; + + /** + * 用户名称 + */ + private String userName; + + /** + * 房间Id + */ + private String roomId; + + /** + * 系统类型 + */ + private String systemType; + /** + * 登录认证令牌 + */ + private String token; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/ReSendMessageVO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/ReSendMessageVO.java new file mode 100644 index 0000000..320072e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/shortmessage/ReSendMessageVO.java @@ -0,0 +1,33 @@ +package com.ruoyi.wisdomarbitrate.domain.vo.shortmessage; + +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReSendMessageVO { + /** + * 短信模版Id + */ + private String templateId; + /** + * 手机号 + */ + private String phone; + /** + * 短信id + */ + private Long id; + /** + * 短信模版参数值 + */ + private List templateParams; + +} 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..35d9780 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,19 @@ public interface MsCaseApplicationMapper extends Mapper { @Select("select max(room_id) maxRoomId from ms_reserved_conference") Long selectMaxRoomId(); + List todoCount(@Param("req")MsCaseApplicationReq req, @Param("caseFlowIds") List caseFlowIds, @Param("roleIds") List roleIds); + /** - * 待办数量 - * @param o + * 根据用户id查询是否和案件有关 + * @param userIds * @return */ - @Select(" " - ) - List todoCount(@Param("req")MsCaseApplicationReq req, @Param("caseStatusNames") List caseStatusNames); + List countCasePerson(@Param("userIds") List userIds); + + /** + * 查询部门是否与案件有关 + * @param deptId + * @return + */ + List selectCaseByDeptId(@Param("deptId") Long deptId); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAttachMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAttachMapper.java index 139d814..a3a543c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAttachMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/mscase/MsCaseAttachMapper.java @@ -25,6 +25,7 @@ public interface MsCaseAttachMapper { int deleteByFileIds(@Param("ids") List fileIds); List listCaseAttachByCaseIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType); + List listCaseAttachByCaseIdAndTypes(@Param("caseAppliId")Long caseAppliId,@Param("annexTypes") List annexTypes); MsCaseAttach queryAnnexById(@Param("annexId") Long annexId); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SendMailRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SendMailRecordMapper.java index 57fd469..379a771 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SendMailRecordMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SendMailRecordMapper.java @@ -5,10 +5,32 @@ import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; import java.util.List; public interface SendMailRecordMapper { + /** + * 新增发送邮件记录 + * + * @param sendMailRecord 发送邮件记录 + * @return 结果 + */ + int saveSendMailRecord(SendMailRecord sendMailRecord); - +/** + * 查询发送邮件记录 + * + * @param sendMailRecord 发送邮件记录 + * @return 结果 + */ List selectSendMailRecord(SendMailRecord sendMailRecord); +/** + * 修改发送邮件记录 + * + * @param sendMailRecord 发送邮件记录 + * @return 结果 + */ + int updateSendMailRecord(SendMailRecord sendMailRecord); - - + /** + * 根据id查询发送邮件记录 + * @param id + */ + SendMailRecord querySendMailRecordById(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SmsRecordMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SmsRecordMapper.java index 1c9f18d..638baff 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SmsRecordMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/sendrecord/SmsRecordMapper.java @@ -19,4 +19,13 @@ public interface SmsRecordMapper { * @return */ int batchSaveSmsSendRecord(@Param("list") List smsSendRecordList); + SmsSendRecord selectBySId(@Param("sid") String sid); + void updateStatus (SmsSendRecord smsSendRecord); + + /** + * 通过id查询短信发送记录 + */ + SmsSendRecord selectById(@Param("id") Long id); + + void update(SmsSendRecord smsSendRecord); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java index a1a44fb..0008281 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/dept/impl/DeptIdentifyServiceImpl.java @@ -47,6 +47,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.google.common.io.Files.getFileExtension; import static com.ruoyi.common.utils.SecurityUtils.getUsername; @Service @@ -256,6 +257,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode()); //10代表印章图片 caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); + caseAttach.setSuffix(getFileExtension(savePath)); int i1 = msCaseAttachMapper.save(caseAttach); if (i1 > 0) { //将附件id保存到公章管理表里 @@ -324,6 +326,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { if (identifyName == null) { AjaxResult.error("请检查参数是否完整"); } + // 查询是否存在机构 + SysDept sysDept = sysDeptMapper.selectDeptByName(identifyName); Integer identifyType = deptIdentify.getIdentifyType(); if (identifyType == null) { deptIdentify.setIdentifyType(1); // 设置机构默认为仲裁机构 @@ -331,11 +335,19 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { deptIdentify.setIdentifyStatus(0); //设置认证状态默认为未认证 deptIdentify.setIsUse(0); //设置机构默认为未启用 //将机构名称保存到部门表里 - SysDept sysDept = new SysDept(); - sysDept.setDeptName(identifyName); - sysDept.setParentId(0L); - sysDept.setDeptType(1); - int i1 = sysDeptMapper.insertDept(sysDept); + int i1=0; + if(sysDept == null) { + sysDept = new SysDept(); + sysDept.setParentId(0L); + sysDept.setDeptName(identifyName); + sysDept.setDeptType(1); + i1 = sysDeptMapper.insertDept(sysDept); + } + else { + sysDept.setDeptType(1); + sysDeptMapper.updateDept(sysDept); + } + if (i1 > 0) { /* //将经办人信息存入到用户表里 Long deptId = sysDept.getDeptId(); @@ -658,11 +670,5 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService { return ajax; } - private String getFileExtension(String fileName) { - int lastDotIndex = fileName.lastIndexOf("."); - if (lastDotIndex > 0 && lastDotIndex < fileName.length() - 1) { - return fileName.substring(lastDotIndex + 1); - } - return ""; - } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/IdentityAuthenticationService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/IdentityAuthenticationService.java index d53b3eb..aef1900 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/IdentityAuthenticationService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/IdentityAuthenticationService.java @@ -19,10 +19,10 @@ public interface IdentityAuthenticationService { /** * 获取Eidtoken - * + * isPC 是否PC端 * @return */ - JSONObject selectIdentityAuthenticaEIDtoken(); + JSONObject selectIdentityAuthEIDToken(boolean isPC); /** * 小程序人脸核身后查询身份认证结果 @@ -31,4 +31,10 @@ public interface IdentityAuthenticationService { * @return */ AjaxResult selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication); + + /** + * H5轮询获取EIDtoken状态 + * @return + */ + AjaxResult selectPCEIDtokenStatus(String eidToken); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/WeChatUserService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/WeChatUserService.java index 6d01cdc..e3ad11d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/WeChatUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/WeChatUserService.java @@ -14,4 +14,12 @@ public interface WeChatUserService { AjaxResult registerUser(IdentityAuthentication ientityAuthentication); + + /** + * 获取邮箱验证码 + * @param email + * @return + */ + + AjaxResult sendEmailCode(String email); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/IdentityAuthenticationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/IdentityAuthenticationServiceImpl.java index 9a3de7a..bcdf9e8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/IdentityAuthenticationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/IdentityAuthenticationServiceImpl.java @@ -2,12 +2,14 @@ package com.ruoyi.wisdomarbitrate.service.miniprogress.impl; import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SmUtil; import cn.hutool.crypto.asymmetric.SM2; import cn.hutool.crypto.symmetric.SymmetricCrypto; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication; import com.ruoyi.wisdomarbitrate.mapper.miniprogress.IdentityAuthenticationMapper; @@ -39,6 +41,8 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication private String credentialSecretKey; @Value("${identityAuthentication.merchantId}") private String merchantId; + @Value("${identityAuthentication.pcMerchantId}") + private String pcMerchantId; @Value("${identityAuthentication.privateKeyHexDecodeinfo}") private String privateKeyHexDecodeinfo; @@ -87,7 +91,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication * @return */ @Override - public JSONObject selectIdentityAuthenticaEIDtoken() { + public JSONObject selectIdentityAuthEIDToken(boolean isPC) { JSONObject objJSON = new JSONObject(); objJSON.put("EidToken", ""); try { @@ -102,15 +106,18 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication FaceidClient client = new FaceidClient(cred, "", clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 GetEidTokenRequest req = new GetEidTokenRequest(); - req.setMerchantId(merchantId); + if(true){ + req.setMerchantId(merchantId); + }else { + req.setMerchantId(pcMerchantId); + } // 返回的resp是一个GetEidTokenResponse的实例,与请求对象对应 GetEidTokenResponse resp = client.GetEidToken(req); // 输出json格式的字符串回包 String respJSON = GetEidTokenResponse.toJsonString(resp); objJSON = JSON.parseObject(respJSON); } catch (TencentCloudSDKException e) { - System.out.println(e.toString()); - System.out.println("获取Eidtoken失败"); + throw new ServiceException("获取Eidtoken失败"); } return objJSON; } @@ -132,13 +139,13 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication parse = JSON.parseObject(s); } } catch (Exception e) { - System.out.println(e.toString()); + throw new ServiceException(e.getMessage()); } return parse; } /** - * 小程序人脸核身后查询身份认证结果 + * 人脸核身后查询身份认证结果 * * @param ientityAuthentication * @return @@ -219,12 +226,93 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication } return AjaxResult.success(authentication); } catch (TencentCloudSDKException e) { - System.out.println(e.toString()); + return AjaxResult.error(e.getMessage()); } - return AjaxResult.success(); + } + + @Override + public AjaxResult selectPCEIDtokenStatus(String eidToken) { + // todo 送达时需要判断是否有pdf版的调解书,没有则不送达,签名完后下载pdf时不删除之前的doc调解书,上传调解书时,pdf的需要将类型设为13,异步发送短信邮件时将登录用户传参过来 + // todo E证通审核过后将PC端的机器id在YML文件中改掉 + JSONObject objJSON = null; + IdentityAuthentication authentication = new IdentityAuthentication(); + + try { + Credential cred = new Credential(credentialSecretId, credentialSecretKey); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("faceid.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + FaceidClient client = new FaceidClient(cred, "", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + GetEidResultRequest req = new GetEidResultRequest(); + req.setEidToken(eidToken); + // 返回的resp是一个GetEidResultResponse的实例,与请求对象对应 + GetEidResultResponse resp = client.GetEidResult(req); + // 输出json格式的字符串回包,Status String 枚举:init:token未验证 doing: 验证中 finished: 验证完成 timeout: token已超时 + String s = GetEidResultResponse.toJsonString(resp); + if(StrUtil.isNotEmpty(s)) { + objJSON = JSON.parseObject(s); + JSONObject text = objJSON.getJSONObject("Text"); + if (text != null) { + Integer comparestatus = text.getInteger("Comparestatus"); + if (comparestatus != null && comparestatus == 0) { + JSONObject eidInfo = objJSON.getJSONObject("EidInfo"); + if (eidInfo != null) { + String desKey = eidInfo.getString("DesKey"); + String userInfo = eidInfo.getString("UserInfo"); + //1.解密用户的信息 + JSONObject info = DecodeUserInfo(desKey, userInfo); + if (info != null) { + String idcardno = info.getString("idnum"); + String name = info.getString("name"); + //2.在用户认证表中插入用户认证记录 + // LoginUser loginUser = SecurityUtils.getLoginUser(); + + /** + * 用户名 + * 用户名id + * 姓名 + * 身份证号 + * 认证时间 + * 认证状态0表示成功 + * 请求id + */ + // authentication.setUserName(loginUser.getUsername()); + // authentication.setUserId(loginUser.getUserId()); + + authentication.setIdentityNo(idcardno); + // 查询认证表是否已存在该身份证信息的认证,不存在则新增,存在不处理 + IdentityAuthentication identityAuthentication = identityAuthenticationMapper.selectIdentityAuthentication(authentication); + if(identityAuthentication!=null) { + return AjaxResult.success(identityAuthentication); + } + authentication.setName(name); + authentication.setCertificationTime(new Date()); + authentication.setCertificationStatus(0); + authentication.setCreateBy(name); + // authentication.setCreateBy(loginUser.getUsername()); + try { + identityAuthenticationMapper.insertIdentityAuthentication(authentication); + authentication.setId(authentication.getId()); + } catch (Exception e) { + System.out.println("认证记录新增失败"); + } + } + + } + } + } + return AjaxResult.success(authentication); + } + } catch (TencentCloudSDKException e) { + return AjaxResult.error(e.getMessage()); + } + return AjaxResult.error("认证失败"); } - - } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/WeChatUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/WeChatUserServiceImpl.java index 20f9ec5..5b4306a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/WeChatUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/miniprogress/impl/WeChatUserServiceImpl.java @@ -2,13 +2,15 @@ package com.ruoyi.wisdomarbitrate.service.miniprogress.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.domain.AjaxResult; 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.enums.SMSStatusEnum; +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.spring.SpringUtils; import com.ruoyi.system.mapper.SysRoleMapper; @@ -18,6 +20,7 @@ import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication; import com.ruoyi.wisdomarbitrate.domain.vo.miniprogress.WeChatUserVO; import com.ruoyi.wisdomarbitrate.mapper.miniprogress.IdentityAuthenticationMapper; import com.ruoyi.wisdomarbitrate.service.miniprogress.WeChatUserService; +import com.ruoyi.wisdomarbitrate.utils.SmsUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -43,6 +46,10 @@ public class WeChatUserServiceImpl implements WeChatUserService { private SysUserRoleMapper userRoleMapper; @Autowired private IdentityAuthenticationMapper identityAuthenticationMapper; + @Autowired + private RedisCache redisCache; + @Autowired + private EmailOutUtil emailOutUtil; @Override public AjaxResult sendCode(WeChatUserVO userVO) { @@ -58,14 +65,33 @@ public class WeChatUserServiceImpl implements WeChatUserService { // 1954926 普通短信 短信验证码 验证码:,为了保证您的账户安全,请勿想他人泄露验证码信息。如非本人操作,请忽略本短信。 request.setPhone(userVO.getPhone()); request.setTemplateParamSet(new String[]{ code}); - Boolean flag = SmsUtils.sendSms(request); - if(flag){ - setCodeCache(userVO.getPhone(),code); + JSONObject resultObj = SmsUtils.sendSms(request); + if(resultObj.get("status")!=null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())){ + setCodeCache(CacheConstants.WE_CHAT_SMS_VERIFY_CODE_KEY + userVO.getPhone(),code); return AjaxResult.success("短信发送成功"); }else { return AjaxResult.warn("短信发送失败"); } } + @Override + public AjaxResult sendEmailCode(String email) { + Random random = new Random(); + String code = ""; + for (int i = 0; i < 6; i++) { + + code += random.nextInt(10); + } + + try { + emailOutUtil.sendMessage(email, "调解系统邮箱验证", "尊敬的用户,您好,您的邮箱验证码为:"+code+",有效期为5分钟。", null, null); + } catch (Exception e) { + return AjaxResult.warn("邮件发送失败"); + } + + // 1954926 普通短信 短信验证码 验证码:,为了保证您的账户安全,请勿想他人泄露验证码信息。如非本人操作,请忽略本短信。 + setCodeCache(CacheConstants.EMAIL_VERIFY_CODE_KEY +email,code); + return AjaxResult.success("邮件发送成功"); + } /** * 设置验证码缓存 * @@ -74,7 +100,7 @@ public class WeChatUserServiceImpl implements WeChatUserService { */ public static void setCodeCache(String key, String code) { - SpringUtils.getBean(RedisCache.class).setCacheObject(getVerifyCodeCacheKey(key), code, 5,TimeUnit.MINUTES); + SpringUtils.getBean(RedisCache.class).setCacheObject( key, code, 5,TimeUnit.MINUTES); } @@ -86,7 +112,7 @@ public class WeChatUserServiceImpl implements WeChatUserService { */ public static String getCodeCache(String key) { - String codeCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getVerifyCodeCacheKey(key)); + String codeCache = SpringUtils.getBean(RedisCache.class).getCacheObject( key); if (StringUtils.isNotNull(codeCache)) { return codeCache; @@ -94,19 +120,24 @@ public class WeChatUserServiceImpl implements WeChatUserService { return null; } - private static String getVerifyCodeCacheKey(String key) { - return CacheConstants.WE_CHAT_SMS_VERIFY_CODE_KEY + key; - } @Transactional @Override public AjaxResult registerUser(IdentityAuthentication ientityAuthentication) { - String codeCache = getCodeCache(ientityAuthentication.getPhone()); + String codeCache = getCodeCache(CacheConstants.WE_CHAT_SMS_VERIFY_CODE_KEY + ientityAuthentication.getPhone()); // 校验短信验证码 if(StrUtil.isEmpty(codeCache)){ return AjaxResult.warn("验证码校验失败"); }else if(!codeCache.equals(ientityAuthentication.getVerifyCode())){ return AjaxResult.warn("验证码校验失败"); } + // 校验邮箱验证码 + String emailCodeCache = getCodeCache(CacheConstants.EMAIL_VERIFY_CODE_KEY +ientityAuthentication.getEmail()); + if(StrUtil.isEmpty(emailCodeCache)){ + return AjaxResult.warn("验证码校验失败"); + }else if(!emailCodeCache.equals(ientityAuthentication.getEmailVerifyCode())){ + return AjaxResult.warn("验证码校验失败"); + } + // 根据用户名或者邮箱或者手机号查询系统用户表中是否存在该用户 SysUser sysUserName=sysUserMapper.checkUserNameUnique(ientityAuthentication.getUserName()); if(sysUserName!=null){ return AjaxResult.warn("账号已存在"); @@ -115,18 +146,11 @@ public class WeChatUserServiceImpl implements WeChatUserService { if(checkPhoneUnique!=null){ return AjaxResult.warn("手机号已存在"); } - SysUser checkEmailUnique = sysUserMapper.checkEmailUnique(ientityAuthentication.getEmail()); - if(checkEmailUnique!=null){ - return AjaxResult.warn("邮箱已存在"); - } - // 根据身份证查询系统用户表中是否存在该用户,存在则同步已认证的信息,不存在则新增 - SysUser sysUser=sysUserMapper.selectUserByIdCard(ientityAuthentication.getIdentityNo()); + // 根据邮箱查询系统用户表中是否存在该用户,存在则同步已认证的信息,不存在则新增 + SysUser sysUser=sysUserMapper.selectUserByEmail(ientityAuthentication.getEmail()); // 查询角色 Long roleIdByName =ientityAuthentication.getRoleId(); -// if(roleIdByName==null){ -// return AjaxResult.warn("被申请人角色不存在,请联系系统管理员新增角色"); -// } if(sysUser!=null){ sysUser.setIdCard(ientityAuthentication.getIdentityNo()); sysUser.setNickName(ientityAuthentication.getName()); @@ -135,10 +159,12 @@ public class WeChatUserServiceImpl implements WeChatUserService { sysUser.setEmail(ientityAuthentication.getEmail()); sysUser.setPassword(SecurityUtils.encryptPassword(ientityAuthentication.getPassWord())); sysUserMapper.updateUser(sysUser); + // redis缓存 + sysUser=sysUserMapper.selectUserById(sysUser.getUserId()); + redisCache.setCacheObject(CacheConstants.USER_KEY+sysUser.getUserId(),sysUser); ientityAuthentication.setUserId(sysUser.getUserId()); int count=0; if(CollectionUtil.isNotEmpty(sysUser.getRoles()) && roleIdByName!=null){ - for (SysRole role : sysUser.getRoles()) { if(Objects.equals(role.getRoleId(), roleIdByName)){ count++; @@ -168,6 +194,8 @@ public class WeChatUserServiceImpl implements WeChatUserService { if(row<1) { return AjaxResult.warn("注册失败"); } + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+sysUser.getUserId(),sysUser); if(roleIdByName!=null) { // 用户关联被申请人角色 userRoleMapper.insertUserRole(sysUser.getUserId(), roleIdByName); @@ -182,4 +210,6 @@ public class WeChatUserServiceImpl implements WeChatUserService { return AjaxResult.success("注册成功"); } + + } 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..3d5bea1 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,12 +1,14 @@ 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.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; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAffiliate; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; @@ -49,6 +51,21 @@ public interface MsCaseApplicationService { * @return */ String insert(MsCaseApplicationVO caseApplication); + /** + * 设置案件相关信息 + * @param caseApplication + * @param affiliate + * @param groupOrder 组别 + * @param operatorCount 操作人数量 + */ + public int setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder,int operatorCount); + /** + * 新增案件相关人员信息 + * @param affiliate 相关人员信息 + * @param roleId 角色id + + */ + public void insertAfficateUser(MsCaseAffiliate affiliate, List roleIdList); /** * 新增案件 @@ -62,18 +79,8 @@ 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 - */ - void insertAgentUser(MsCaseAffiliate affiliate); + + /** * 修改案件 @@ -97,6 +104,7 @@ public interface MsCaseApplicationService { */ AjaxResult userIdentify(MultipartFile file); + /** * 生成调解申请书 * @param req @@ -150,6 +158,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 +219,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 +240,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 @@ -255,12 +271,7 @@ public interface MsCaseApplicationService { * 根据登录人返回用户信息 */ SysUser getUserInfo(); - /** - * 查询短信发送记录 - * @param smsSendRecord - * @return - */ - List getSmsSendRecord(SmsSendRecord smsSendRecord); + /** * 保存onlyOffice在线编辑的文件 * @param @@ -268,4 +279,35 @@ public interface MsCaseApplicationService { */ AjaxResult saveOnlyOfficeFile(MsCaseAttach caseAttach); + + /** + * 发送邮件 + * @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 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..328c235 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,6 @@ public interface MsCasePaymentService { */ public void confirmPayment(MsCaseFlow currentFlow,MsCaseFlow nextFlow, MsCaseApplication application, CaseConfirmPayDTO dto); + + } 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..76661c9 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 @@ -1,10 +1,11 @@ package com.ruoyi.wisdomarbitrate.service.mscase; +import com.google.gson.Gson; 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.entity.mscase.MsCaseApplication; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseLogRecordVO; import java.io.IOException; @@ -13,7 +14,7 @@ import java.util.List; public interface MsSignSealService { - AjaxResult sureMediationSeal(MsCaseApplicationVO caseApplication) throws EsignDemoException, InterruptedException; + AjaxResult sealApply(MsSignSealDTO dto); @@ -30,13 +31,16 @@ 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; + + /** + * 签名后下载调解书 + * @param caseApplicationselect 案件信息 + * @param signFlowId 签名流程id + * @param gson + * @param caseAppliId 案件id + */ + void downloadMediationBook(MsCaseApplication caseApplicationselect, String signFlowId, Gson gson, Long caseAppliId); } 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..4a99039 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 @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.ReservedConference; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsReservedConferenceVO; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -44,7 +45,7 @@ public interface VideoConferenceService { * @param userId * @return */ - AjaxResult secretaryRoleByUserId(Long userId); + AjaxResult secretaryRoleByUserId(Long userId, Long caseId); /** * 根据html字符串转pdf并和案件关联 @@ -80,4 +81,13 @@ public interface VideoConferenceService { * @throws Exception */ AjaxResult reservedConference( MsReservedConferenceVO reservedConferenceVO) throws Exception; + + /** + * 短信回调 + * @param body + * @param request + */ + void smsRollBack(String body, HttpServletRequest request); + + AjaxResult selectRoleMenuByCaseId(Long caseId); } 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..6414647 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,7 @@ 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.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; @@ -12,14 +13,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.*; @@ -27,26 +27,32 @@ import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.SaaSAPIFileUtils; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated; +import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord; import com.ruoyi.system.mapper.*; import com.ruoyi.system.mapper.flow.MsCaseFlowMapper; import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper; +import com.ruoyi.system.mapper.shortmessage.MsSendMailHistoryRecordMapper; +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.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; import com.ruoyi.wisdomarbitrate.domain.dto.template.FatchRule; import com.ruoyi.wisdomarbitrate.domain.dto.template.TemplateManage; import com.ruoyi.wisdomarbitrate.domain.entity.dept.MsSealSignRecord; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.*; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.*; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; 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; import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; import com.ruoyi.wisdomarbitrate.utils.*; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument; @@ -68,9 +74,12 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.function.Function; import java.util.stream.Collectors; +import static com.google.common.io.Files.getFileExtension; import static com.ruoyi.common.utils.BookMarkUtil.getBookmarkByDocx; import static com.ruoyi.common.utils.PageUtils.startPage; import static com.ruoyi.common.utils.SecurityUtils.getUsername; @@ -94,6 +103,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 @@ -113,6 +129,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Autowired MsColumnValueLogMapper columnValueLogMapper; @Autowired + private MsSendMailHistoryRecordMapper sendMailHistoryRecordMapper; + @Autowired MsCaseFlowMapper caseFlowMapper; @Autowired MsCaseFlowRoleRelatedMapper caseFlowRoleRelatedMapper; @@ -148,9 +166,25 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { private MsSealSignRecordMapper sealSignRecordMapper; @Autowired private MsCaseAuditMapper auditMapper; + @Autowired + private RedisCache redisCache; + @Autowired + private EmailOutUtil emailOutUtil; + @Value("${spring.mail.username}") + private String emailFrom; + @Autowired + private SendMailRecordMapper sendMailRecordMapper; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + @Autowired + ShortMessageService shortMessageService; + @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"); + // 日期格式化年月日 + public static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); /** * 案件列表查询 @@ -160,95 +194,244 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { */ @Override public List list(MsCaseApplicationReq req) { - + // 查询所有流程 + Example allFlowExample = new Example(MsCaseFlow.class); + allFlowExample.setOrderByClause("sort asc"); + List allCaseFlows = caseFlowMapper.selectByExample(allFlowExample); + if (CollectionUtil.isEmpty(allCaseFlows)) { + throw new ServiceException("未配置案件流程"); + } // 根据用户查询角色 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(new HashMap<>(),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())); List caseFlowRoleRelatedList = caseFlowRoleRelatedMapper.selectByExample(example); if (CollectionUtil.isEmpty(caseFlowRoleRelatedList)) { - throw new ServiceException("该角色为绑定案件流程"); + throw new ServiceException("该角色未绑定案件流程"); } Example flowExample = new Example(MsCaseFlow.class); flowExample.createCriteria().andIn("id", caseFlowRoleRelatedList.stream().map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toList())); List caseFlows = caseFlowMapper.selectByExample(flowExample); if (CollectionUtil.isEmpty(caseFlows)) { - throw new ServiceException("该角色为绑定案件流程"); + 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()); + // 流程名称分组 + Map flowNameMap = allCaseFlows.stream().collect(Collectors.toMap(MsCaseFlow::getCaseStatusName, MsCaseFlow::getSort, (k1, k2) -> k2)); + + // 是否查询所有 + 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(flowNameMap,list,loginUser.getUserId(),roles); return list; } + /** + * 设置申请人被申请人及签名按钮限 + * @param + * @param list + * @param loginUserId 当前登录用户id + */ + private void setAfflicate( Map flowNameMap,List list,Long loginUserId, List roles ) { + if(CollectionUtil.isEmpty(list)){ + return; + } + // 是否调解员 + boolean isMediatorRole=false; + // 查询申请人和被申请人 + List caseIds = list.stream().map(MsCaseApplicationVO::getId).collect(Collectors.toList()); + Integer signSort = flowNameMap.get("待签名"); + Integer sendSort = flowNameMap.get("待送达"); + Integer mediatorSort = flowNameMap.get("待调解"); + 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(vo.getMediatorId()!=null&&vo.getMediatorId().equals(loginUserId)){ + isMediatorRole=true; + } + // 设置申请人和被申请人 + 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.getRoleType() != null && affiliate.getOperatorFlag() != null && affiliate.getOperatorFlag() == 1) { + if (vo.getAppOperatorFlag() == null && (affiliate.getRoleType() == 1 || affiliate.getRoleType() == 2)) { + // 申请人操作人 + if(affiliate.getUserId().equals(loginUserId) &&!vo.getCaseStatusName().equals("待签名")){ + vo.setAppOperatorFlag(1); + }else if(vo.getCaseStatusName().equals("待签名")) { + if(affiliate.getUserId().equals(loginUserId)){ + vo.setAppOperatorFlag(1); + }else { + vo.setAppOperatorFlag(0); + } + } + // 签收按钮权限 + if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().equals("待申请人签收")){ + vo.setSignFlag(1); + } + + } + if (vo.getResOperatorFlag() == null && (affiliate.getRoleType() == 3 || affiliate.getRoleType() == 4)) { + // 被申请人操作人 + if(Objects.equals(affiliate.getUserId(), loginUserId) &&!vo.getCaseStatusName().equals("待签名")){ + vo.setResOperatorFlag(1); + }else if(vo.getCaseStatusName().equals("待签名")) { + if(Objects.equals(affiliate.getUserId(), loginUserId)){ + vo.setResOperatorFlag(1); + }else { + vo.setResOperatorFlag(0); + } + } + // 签收按钮权限 + if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().equals("待被申请人签收")){ + vo.setSignFlag(1); + } + } + } + if(affiliate.getOrganizeFlag()==null || affiliate.getOrganizeFlag()!=1) { + if (StrUtil.isNotEmpty(affiliate.getRoleName()) && affiliate.getRoleName().equals("申请人") + && affiliate.getRoleType() != null && affiliate.getRoleType() == 1&&StrUtil.isNotEmpty(affiliate.getName()) + && !applicantName.toString().contains(affiliate.getName()+Constants.CN_SPLIT_COMMA)) { + applicantName.append(affiliate.getName()).append(Constants.CN_SPLIT_COMMA); + } + }else { + // 组织机构 + if ( affiliate.getRoleType() != null && affiliate.getRoleType() == 1&&StrUtil.isNotEmpty(affiliate.getApplicantOrgName()) + && !applicantName.toString().contains(affiliate.getApplicantOrgName()+Constants.CN_SPLIT_COMMA)) { + applicantName.append(affiliate.getApplicantOrgName()).append(Constants.CN_SPLIT_COMMA); + } + } + if(affiliate.getOrganizeFlag()==null || affiliate.getOrganizeFlag()!=1) { + if (StrUtil.isNotEmpty(affiliate.getRoleName()) && affiliate.getRoleName().equals("被申请人") + && affiliate.getRoleType() != null && affiliate.getRoleType() == 3&&StrUtil.isNotEmpty(affiliate.getName()) + && !respondentName.toString().contains(affiliate.getName()+Constants.CN_SPLIT_COMMA)) { + + respondentName.append(affiliate.getName()).append(Constants.CN_SPLIT_COMMA); + } + }else { + // 组织机构 + if ( affiliate.getRoleType() != null && affiliate.getRoleType() == 3&&StrUtil.isNotEmpty(affiliate.getApplicantOrgName())&& !respondentName.toString().contains(affiliate.getApplicantOrgName()+Constants.CN_SPLIT_COMMA)) { + respondentName.append(affiliate.getApplicantOrgName()).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); + } + // 1需要用印 + boolean sealFlag = vo.getSealFlag() == null || !vo.getSealFlag().equals(1); + // 调解书按钮,线下调解(待调解后,送达前)或者线上调解(调解员,法律顾问在不用印,签名后,送达前,)显示 + + boolean sendFlag=sendSort != null && null != flowNameMap.get(vo.getCaseStatusName()) && flowNameMap.get(vo.getCaseStatusName()) <= sendSort; + // 是否线上调解 + boolean offlineMediatorFlag=vo.getMediationMethod()!=null && vo.getMediationMethod().equals("1"); + // 线上调解调解书按钮 + boolean onlineMediatorFileFlag = offlineMediatorFlag && sealFlag && signSort != null + && flowNameMap.get(vo.getCaseStatusName()) > signSort + && sendFlag; + // 线下调解调解书按钮 + boolean offlineMediatorFileFlag=!offlineMediatorFlag && mediatorSort!=null && flowNameMap.get(vo.getCaseStatusName()) > mediatorSort + && sendFlag; + // 调解员调解书按钮 + if ( isMediatorRole && (onlineMediatorFileFlag || offlineMediatorFileFlag)) { + vo.setMediationFileFlag(1); + } + 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); + } + + if(role.getRoleName().equals("法律顾问") && (onlineMediatorFileFlag || offlineMediatorFileFlag) ){ + // 顾问可以上传下载调解书 + vo.setMediationFileFlag(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 +439,94 @@ 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 +554,69 @@ 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); + } + }); + } + vo.setAffiliate(affiliateVO); // 查询附件 List caseAttachList = msCaseAttachMapper.queryAnnexPathByCaseId(id); vo.setCaseAttachList(caseAttachList); @@ -389,11 +625,20 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { vo.setColumnValueList(columnValueVOS); // 查询拒绝原因 vo.setReason(auditMapper.selectByCaseId(id,caseApplication.getCaseFlowId())); - // todo 在日志表查詢结束时间返回 vo.setEndTime(caseLogRecordMapper.selectEndTimeByCaseId(caseApplication.getId(),"结束")); return vo; } + /** + * 根据案件id查询案件相关人员 + * @param id + * @return + */ + public List selectAffliatesByCaseId(Long id) { + + return msCaseAffiliateMapper.selectByCaseId(id); + } + /** * 新增案件 * @@ -404,13 +649,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,13 +667,16 @@ 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()); } caseApplication.setCaseStatusName(caseFlow.getCaseStatusName()); caseApplication.setCaseFlowId(caseFlow.getId()); caseApplication.setCreateTime(new Date()); - // todo 暂时写死,费用300元 caseApplication.setCaseSubjectAmount(new BigDecimal("30000")); setFeePayableMethod(caseApplication); // 设置批号 @@ -447,37 +688,40 @@ 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(); + int appOperatorCount=0; + int resOperatorCount=0; // 保存案件相关人员 - // 设置申请机构 - 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++) { + // 申请人 + appOperatorCount= setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i,appOperatorCount); + // 申请人代理人 + appOperatorCount=setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i,appOperatorCount); + } + } + if(CollectionUtil.isNotEmpty(res)){ + for (int i = 0; i < res.size(); i++) { + // 申请人 + resOperatorCount= setCaseAfflicate(caseApplication, res.get(i).getRes(),i,resOperatorCount); + // 申请人代理人 + resOperatorCount= setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i,resOperatorCount); + } + } + if (appOperatorCount < 1 && resOperatorCount < 1) { + throw new ServiceException("未设置申请操作人和被申请操作人"); + } else if (appOperatorCount < 1) { + throw new ServiceException("未设置申请操作人"); + } else if (resOperatorCount < 1) { + throw new ServiceException("未设置被申请操作人"); + } - - } - // 压缩包导入,则根据身份证号获取性别和出生日期 - 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,20 +732,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { req.setBatchNumber(caseApplication.getBatchNumber()); } // 生成调解申请书 - if(affiliate.getOrganizeFlag()==0){ - // 自然人 - req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); - }else { - // 机构 - req.setTemplateType(TemplateTypeEnum.MEDIATION_APPLICATION.getCode()); - } + req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); req.setTemplateId(String.valueOf(caseApplication.getTemplateId())); - // todo 部署放开 caseApplicationService.generateApplication(req); // 保存案件附件 if (CollectionUtil.isNotEmpty(caseAttachList)) { for (MsCaseAttach caseAttach : caseAttachList) { caseAttach.setCaseAppliId(caseApplication.getId()); + if(StrUtil.isNotEmpty(caseAttach.getAnnexPath())){ + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); + } } if(!caseApplication.isImportFlag()) { // 修改案件附件 @@ -525,6 +765,192 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return ""; } + /** + * 设置案件相关信息 + * @param caseApplication + * @param affiliate + */ + @Transactional + public int setCaseAfflicate(MsCaseApplicationVO caseApplication, MsCaseAffiliate affiliate,int groupOrder,int operatorCount) { + if(affiliate==null){ + return operatorCount; + } + + boolean b = affiliate.getOrganizeFlag() != 1 && (affiliate.getRoleType() == 1||affiliate.getRoleType() == 3) && StrUtil.isEmpty(affiliate.getEmail()); + if(b|| StrUtil.isEmpty(affiliate.getName())){ + return operatorCount; + } + 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 (affiliate.getOrganizeFlag() == 0) { + caseApplicationService.insertAfficateUser(affiliate, roleIdList); + } else { + // 申请机构 + if (affiliate.getRoleType() == 1 || affiliate.getRoleType()==3) { + affiliate.setOperatorFlag(0); + // 申请人,从缓存中判断部门是否存在 +// Object deptCache = redisCache.getCacheObject(CacheConstants.DEPT_KEY + affiliate.getName()); + SysDept dept = sysDeptMapper.selectDeptByName(affiliate.getName()); + if (dept==null) { + // 不存在该部门,新增 + 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.setHome(affiliate.getHome()); + dept.setAddress(affiliate.getAddress()); + dept.setCompLegalPerson(affiliate.getCompLegalPerson()); + dept.setCreateBy(getUsername()); + dept.setCreateTime(new Date()); + dept.setNationality(affiliate.getNationality()); + sysDeptMapper.insertDept(dept); + // 更新缓存 + // redisCache.setCacheObject(CacheConstants.DEPT_KEY + dept.getDeptName(), dept.getDeptId()); + }else { + // 更新部门 + dept.setCode(affiliate.getCode()); + dept.setCompLegalPerson(affiliate.getCompLegalPerson()); + dept.setUpdateBy(getUsername()); + dept.setUpdateTime(new Date()); + dept.setNationality(affiliate.getNationality()); + dept.setHome(affiliate.getHome()); + dept.setAddress(affiliate.getAddress()); + sysDeptMapper.updateDept(dept); + } + affiliate.setApplicantDeptId(dept.getDeptId()); + } else { + caseApplicationService.insertAfficateUser(affiliate, roleIdList); + } + } + // 保存人员 + msCaseAffiliateMapper.insert(affiliate); + if(affiliate.getOperatorFlag()!=null && affiliate.getOperatorFlag()==1){ + operatorCount++; + } + return operatorCount; + } + + /** + * 新增案件相关人员信息 + * @param affiliate 相关人员信息 + * @param roleIdList 角色id + + */ + @Transactional + public void insertAfficateUser(MsCaseAffiliate affiliate, List roleIdList) { + + if(StrUtil.isEmpty(affiliate.getEmail())){ + return; + } + SysUser user = sysUserMapper.selectUserByEmail(affiliate.getEmail()); + // 判断该用户是否存在 + 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()); + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),user); + // 查询该角色是否存在申请人角色 + List roleIds = userRoleMapper.selectRoleIdsByUserId(user.getUserId()); + for (Long roleId : roleIdList) { + if(CollectionUtil.isEmpty(roleIds) && !roleIds.contains(roleId) ){ + userRoleMapper.insertUserRole(user.getUserId(),roleId); + } + } + + }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()); + // redis缓存 + redisCache.setCacheObject(CacheConstants.USER_KEY+user.getUserId(),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 +1002,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 +1053,11 @@ 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,29 +1065,40 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseApplication.setUpdateTime(new Date()); // 为null则不更新 msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication); - MsCaseAffiliate affiliate = caseApplication.getAffiliate(); - if (affiliate == null) { - return AjaxResult.error("案件相关人员未填写"); + + // 保存案件相关人员 + // 删除已存在的人员 + Example affliateExample = new Example(MsCaseAffiliate.class); + affliateExample.createCriteria().andEqualTo("caseAppliId", caseApplication.getId()); + msCaseAffiliateMapper.deleteByExample(affliateExample); + int appOperatorCount=0; + int resOperatorCount=0; + + List applicant = msCaseAffiliateVO.getApplicant(); + List res = msCaseAffiliateVO.getRes(); + if(CollectionUtil.isNotEmpty(applicant)){ + for (int i = 0; i < applicant.size(); i++) { + // 申请人 + appOperatorCount=setCaseAfflicate(caseApplication, applicant.get(i).getApplicant(),i,appOperatorCount); + // 申请人代理人 + appOperatorCount= setCaseAfflicate(caseApplication, applicant.get(i).getApplicantAgent(),i,appOperatorCount); + } + } + if(CollectionUtil.isNotEmpty(res)){ + for (int i = 0; i < res.size(); i++) { + // 申请人 + resOperatorCount=setCaseAfflicate(caseApplication, res.get(i).getRes(),i,resOperatorCount); + // 申请人代理人 + resOperatorCount=setCaseAfflicate(caseApplication, res.get(i).getResAgent(),i,resOperatorCount); + } + } + if (appOperatorCount < 1 && resOperatorCount < 1) { + throw new ServiceException("未设置申请操作人和被申请操作人"); + } else if (appOperatorCount < 1) { + throw new ServiceException("未设置申请操作人"); + } else if (resOperatorCount < 1) { + throw new ServiceException("未设置被申请操作人"); } - 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); - - } - if (StrUtil.isNotEmpty(affiliate.getRespondentEmail())) { - affiliate.setRespondentEmail(affiliate.getRespondentEmail().replace("\n", "").replaceAll("\\s", "")); - } - msCaseAffiliateMapper.updateByPrimaryKeySelective(affiliate); - if (CollectionUtil.isNotEmpty(caseApplication.getCaseAttachList())) { for (MsCaseAttach caseAttach : caseApplication.getCaseAttachList()) { caseAttach.setCaseAppliId(caseApplication.getId()); @@ -737,13 +1120,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { MsCaseApplicationReq req = new MsCaseApplicationReq(); req.setCaseFlowId(caseFlow.getId()); req.setId(caseApplication.getId()); - if(affiliate.getOrganizeFlag()==0){ // 自然人 - req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); - }else { - // 机构 - req.setTemplateType(TemplateTypeEnum.MEDIATION_APPLICATION.getCode()); - } + req.setTemplateType(TemplateTypeEnum.PERSON_MEDIATION_APPLICATION.getCode()); req.setTemplateId(String.valueOf(selectByPrimaryKey.getTemplateId())); caseApplicationService.generateApplication(req); // 新增日志 @@ -870,7 +1248,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 +1347,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 +1387,42 @@ 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); + if(StrUtil.isNotEmpty(applicant.getIdCard())){ + setBirthByIdentityNum(applicant); + } + affiliateVO.setApplicant(applicantList); + + // 如果身份证不为空,设置生日和性别 + if(StrUtil.isNotEmpty(res.getIdCard())){ + setBirthByIdentityNum(res); + } + affiliateVO.setRes(resList); BeanUtil.copyProperties(caseApplication, caseApplicationVO); - caseApplicationVO.setAffiliate(affiliate); + affiliateVOS.add(affiliateVO); + caseApplicationVO.setAffiliate(affiliateVO); + caseApplicationVO.setOrganizeFlag(1); } } } return AjaxResult.success(caseApplicationVO); + } /** @@ -1394,7 +1430,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 +1444,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 +1507,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,18 +1520,19 @@ 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()); } return AjaxResult.success(); } + /** * 根据批次号查询该流程未锁定案件 * @param batchNumber @@ -1551,6 +1588,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { .annexType(annexType) .useId(SecurityUtils.getUserId()) .useAccount(SecurityUtils.getUsername()) + .suffix(getFileExtension(path)) .build(); int count = msCaseAttachMapper.save(caseAttach); if (count > 0 ) { @@ -1567,6 +1605,26 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { e.printStackTrace(); return AjaxResult.error("上传失败"); } + // 对接北明,调用上传附件接口 + MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(id); + if(caseApplication==null){ + return AjaxResult.error("案件不存在"); + } + if(StrUtil.isEmpty(caseApplication.getCaseSource()) && CollectionUtil.isNotEmpty(successList)) { + 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,DocumentTypeEnum.EVEDENT_METERIAL); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttach(caseAttach); + } + } + } return AjaxResult.success("上传成功", successList); } @@ -1579,31 +1637,6 @@ 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); - } - - } } else { // 不受理 @@ -1616,14 +1649,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 +1671,143 @@ 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()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - } - } + caseApplicationService.nextFlow(application.getId(), req.getCaseFlowId(),req.getLockStatus()); + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + // 给被申请人发送短信 + if (affiliateMap.containsKey(application.getId())) { + List affiliates = affiliateMap.get(application.getId()); + // 被申受理分配通知 + SMSNoticeDO resNotice = new SMSNoticeDO("待缴费通知", + "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信。", + "2074247", + new String[]{application.getCaseNum()} + ); + SMSNotice notice = new SMSNotice(null,resNotice); + caseApplicationService.sendNotice(application,affiliates,false,notice); + }}, executor); } + + /** + * 受理分配通知 + * @param application 案件基本信息 + * @param affiliates 案件人员 + * @param applicantFlag 是否申请人 + */ + @Override + @Transactional + public void isAcceptNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag) { + // 根据案件id查询案件 + MsCaseApplication selectApplication = msCaseApplicationMapper.selectByPrimaryKey(application.getId()); + if(selectApplication==null){ + return; + } + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + List appPhones=new ArrayList<>(); + List resPhones=new ArrayList<>(); + List appEmails=new ArrayList<>(); + List resEmails=new ArrayList<>(); + for (MsCaseAffiliate affiliate : affiliates) { + if(applicantFlag==null || applicantFlag) { + if ( affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + resPhones.add(affiliate.getPhone()); + String sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信"; + String subject = "待缴费通知"; + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(affiliate.getPhone()) && !resPhones.contains(affiliate.getPhone())) { + // 给被申请人发送案件受理短信 2074247 待缴费通知 尊敬的用户,您编号为{1}的案件已成功提交,请登录调解系统进行缴费处理。请知晓,如非本人操作,请忽略本短信 + SmsUtils.sendSms(selectApplication, "2074247", affiliate.getPhone(), new String[]{selectApplication.getCaseNum()}); + } else if(StrUtil.isNotEmpty(affiliate.getEmail()) && !resEmails.contains(affiliate.getEmail())){ + resEmails.add(affiliate.getEmail()); + // 发送邮件 + 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()) && !appPhones.contains(affiliate.getPhone())) { + appPhones.add(affiliate.getPhone()); + // 申请人发送案件不受理短信 + SmsUtils.sendSms(selectApplication, "2065809", affiliate.getPhone(), + new String[]{selectApplication.getCaseNum(), rejectReason}); + + } else if(StrUtil.isNotEmpty(affiliate.getEmail()) && !appEmails.contains(affiliate.getEmail())){ + appEmails.add(affiliate.getEmail()); + // 发送邮件 + sendEmail(application, affiliate, subject, sendContent); + + } + } + } + }}, executor); + } + + /** + * 发送邮件 + * @param application 案件基本信息 + * @param affiliate 案件人员 + * @param subject 主题 + * @param sendContent 内容 + */ + @Override + @Transactional + public void sendEmail(MsCaseApplication application, MsCaseAffiliate affiliate, String subject, String sendContent) { + if(StrUtil.isEmpty(affiliate.getEmail())){ + return; + } + 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()); + sendMailRecord.setCreateTime(new Date()); + sendMailRecord.setMailSubject(subject); + sendMailRecord.setMailFromAddress(emailFrom); + if (emailFlag) { + sendMailRecord.setSendStatus(1); + } else { + sendMailRecord.setSendStatus(0); + } + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); + // 新增历史记录 + MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord(); + BeanUtils.copyProperties(sendMailRecord, msSendMailHistoryRecord); + msSendMailHistoryRecord.setParentId(sendMailRecord.getId()); + msSendMailHistoryRecord.setId(null); + sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); + } + + /** * 案件提交 * @param req * @return */ @Override + @Transactional public AjaxResult submit(MsCaseApplication req) { if(StrUtil.isNotEmpty(req.getBatchNumber())){ - // 批量提交 List list = listByBatchNumber(req.getBatchNumber(), req.getCaseFlowId()); if(CollectionUtil.isEmpty(list)){ return AjaxResult.error("该批次号下未找到案件"); @@ -1684,11 +1816,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 ->StrUtil.isNotEmpty(affiliate.getPhone())&& (affiliate.getRoleType() != null) && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).count(); + long resCount = operatorList.stream().filter(affiliate ->StrUtil.isNotEmpty(affiliate.getPhone())&& (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()); - + // 提交完向北明推送案件状态 + 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) { @@ -1770,27 +1942,45 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (CollectionUtil.isNotEmpty(caseApplicationList)) { 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("未找到案件相关人员"); + } + List affiliateUserIds=new ArrayList<>(); // 根据案件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("申请人")) { + for (MsCaseAffiliate affiliate : affiliates) { + if(affiliate.getUserId()==null ){ + continue; + } + affiliateUserIds.add(affiliate.getUserId()); + 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) { + if(affiliateUserIds.contains(user.getUserId())){ + continue; + } MediatorVO mediatorVO = new MediatorVO(); mediatorVO.setMediatorId(user.getUserId()); mediatorVO.setMediatorName(user.getNickName()); @@ -1821,24 +2011,32 @@ 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()!=null && 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(); } } } @@ -1867,10 +2065,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 +2102,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(); @@ -1938,7 +2131,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (caseMap.containsKey(userId)) { List applications = caseMap.get(userId); // 已办案件 - long count = applications.stream().filter(caseApplication -> !caseApplication.getCaseStatusName().equals("结束")).count(); + long count = applications.stream().filter(caseApplication -> caseApplication.getCaseStatusName().equals("结束")).count(); if(count>=maxCount){ maxCount=count; application.setMediatorId(userId); @@ -1994,6 +2187,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { */ @Transactional public void verifyMediator(MsCaseApplication application,BookingVO vo) { + Long userId = SecurityUtils.getUserId(); + final List[] affiliates = new List[]{new ArrayList<>()}; + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture cf1 = CompletableFuture.supplyAsync(() -> { MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(vo.getCaseFlowId()); if (currentFlow == null) { throw new ServiceException("未找到当前流程节点"); @@ -2002,8 +2199,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { if (nextFlow == null) { throw new ServiceException("未找到下一个流程节点"); } + if(vo.getMediatorId()!=null) { - // setMediatorAndDate(application,vo); application.setMediatorId(vo.getMediatorId()); application.setMediatorName(vo.getMediatorName()); } @@ -2015,75 +2212,215 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { msCaseApplicationMapper.updateByPrimaryKeySelective(application); // 根据案件id查询案件 MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(application.getId()); - // 发送开庭短信 - if(CollectionUtil.isNotEmpty(vo.getHerDates())) { + if (caseApplication == null) { + throw new ServiceException("未找到案件"); + } - 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(); - } - caseApplication.setHearDate(application.getHearDate()); - // 申请人发送开庭日期短信 - sendHearDateSms(caseApplication, phone); - // 被申发送开庭日期短信 - sendHearDateSms(caseApplication, affiliate.getRespondentPhone()); - // 调解员发送短信 - // 根据调解员id查询用户 - if (caseApplication.getMediatorId() != null) { - SysUser sysUser = sysUserMapper.selectUserById(caseApplication.getMediatorId()); - sendHearDateSms(caseApplication, sysUser.getPhonenumber()); - } + affiliates[0] = selectAffliatesByCaseId(caseApplication.getId()); + if(CollectionUtil.isEmpty(affiliates[0])){ + throw new ServiceException("未找到案件相关人员"); } // 新增日志 + CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "",userId); + caseApplication.setHearDate(application.getHearDate()); + return caseApplication; + }); + if (CollectionUtil.isNotEmpty(vo.getHerDates())) { + cf1.thenAcceptAsync((result) -> { + // 申请人发送开庭日期短信 + sendHearDateSms(result, affiliates[0]); - CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + }, executor); + cf1.thenAcceptAsync((result) -> { + // 发送开庭短信 + if (CollectionUtil.isNotEmpty(vo.getHerDates())) { + + // 调解员发送开庭短信 + sendMeditorHearDateSms(result, vo); + + } + }, executor); + } + + + + } + + /** + * 调解员发送开庭短信 + * @param caseApplication + * @param vo + */ + private void sendMeditorHearDateSms(MsCaseApplication caseApplication, BookingVO vo) { + if (caseApplication.getMediatorId() != null && CollectionUtil.isNotEmpty(vo.getHerDates()) && StrUtil.isNotEmpty(caseApplication.getHearDate())) { + // 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + SysUser sysUser = sysUserMapper.selectUserById(caseApplication.getMediatorId()); + String content = "尊敬的用户,您的" + caseApplication.getCaseNum() + "的案件,线下调解日期已确定为" + caseApplication.getHearDate() + ",请知晓,如非本人操作,请忽略本短信。"; + String templateId = "2077966"; + String subject = "开庭日期通知"; + MsCaseAffiliate meditorAffliate = new MsCaseAffiliate(); + meditorAffliate.setPhone(sysUser.getPhonenumber()); + meditorAffliate.setEmail(sysUser.getEmail()); + String roomUuid = null; + // 线上调解 + if (StrUtil.isNotEmpty(caseApplication.getMediationMethod()) && caseApplication.getMediationMethod().equals("1")) { + // 获取短信链接uuid + MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(caseApplication.getId()).roomId(caseApplication.getRoomId()).systemType("TJ").build(); + roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + // 短信模板:2130103 线上调解时间和会议通知 尊敬的用户,您的{2}线上开庭时间为{3},会议链接https://txroom.xayunmei.com/#/home?{4},请点击链接参加会议,如非本人操作,请忽略本短信. + + content = "尊敬的用户,您的" + caseApplication.getCaseNum() + "线上开庭时间为" + caseApplication.getHearDate() + "会议链接https://txroom.xayunmei.com/#/home?" +"authId="+ roomUuid + ",请点击链接参加会议,如非本人操作,请忽略本短信."; + templateId = "2130103"; + } + // 电话号不为空,发送短信,否则发邮箱 + if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { + if (roomUuid == null) { + SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), + new String[]{caseApplication.getCaseNum(), caseApplication.getHearDate()}); + } else { + SmsUtils.sendSms(caseApplication, templateId, sysUser.getPhonenumber(), + new String[]{caseApplication.getCaseNum(), caseApplication.getHearDate(), "authId="+roomUuid}); + } + + + } else { + // 发送邮件 + caseApplicationService.sendEmail(caseApplication, meditorAffliate, subject, content); + + } + } } /** * 发送开庭日期短信 * @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},请知晓,如非本人操作,请忽略本短信。 - smsFlag = SmsUtils.sendSms(application.getId(), "2075447", phone, new String[]{application.getCaseNum(),application.getHearDate()}); - sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件,线上调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; - }else { - // 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 - smsFlag = SmsUtils.sendSms(application.getId(), "2077966", phone, new String[]{application.getCaseNum(),application.getHearDate()}); - sendContent = "尊敬的用户,您的" + application.getCaseNum() + "的案件,线下调解日期已确定为"+application.getHearDate()+",请知晓,如非本人操作,请忽略本短信。"; + List appPhones=new ArrayList<>(); + List resPhones=new ArrayList<>(); + List appEmails=new ArrayList<>(); + List resEmails=new ArrayList<>(); + ExecutorService executor = ThreadUtil.createThreadPool(); - } - // 新增短信记录 - SmsSendRecord smsSendRecord = new SmsSendRecord(application.getId(), application.getCaseNum(), phone, new Date(), sendContent); - if(smsFlag){ - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); + for (MsCaseAffiliate affiliate : affiliates) { + CompletableFuture.runAsync(() -> { + // 申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + // 获取短信链接uuid + MeetingInfoVO meetingInfoVO= MeetingInfoVO.builder().userId(affiliate.getUserId()).userName(affiliate.getUserName()).caseId(application.getId()).roomId(application.getRoomId()).systemType("TJ").build(); + String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + // 申请人/被申通知, 线上调解 2075447 尊敬的用户,您的{1}案件,线上调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + String content="尊敬的用户,您的" + application.getCaseNum() + "线上开庭时间为"+application.getHearDate()+"会议链接https://txroom.xayunmei.com/#/home?"+"authId="+roomUuid+",请点击链接参加会议,如非本人操作,请忽略本短信."; + if (StrUtil.isNotEmpty(affiliate.getPhone())&&!appPhones.contains(affiliate.getPhone())) { + appPhones.add(affiliate.getPhone()); + SmsUtils.sendSms(application,"2130103", affiliate.getPhone(), + new String[]{application.getCaseNum(),application.getHearDate(),"authId="+roomUuid}); + + } else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) { + appEmails.add(affiliate.getEmail()); + // 发送邮件 + caseApplicationService.sendEmail(application, affiliate, "开庭日期通知", content); + + } + } + // 被申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + // 获取短信链接uuid + MeetingInfoVO meetingInfoVO= MeetingInfoVO.builder().userId(affiliate.getUserId()).userName(affiliate.getUserName()).caseId(application.getId()).roomId(application.getRoomId()).systemType("TJ").build(); + String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + // 申请人/被申通知, 线上调解 2075447 尊敬的用户,您的{1}案件,线上调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。 + String content="尊敬的用户,您的" + application.getCaseNum() + "线上开庭时间为"+application.getHearDate()+"会议链接https://txroom.xayunmei.com/#/home?"+"authId="+roomUuid+",请点击链接参加会议,如非本人操作,请忽略本短信."; + if (StrUtil.isNotEmpty(affiliate.getPhone())&& !resPhones.contains(affiliate.getPhone())) { + resPhones.add(affiliate.getPhone()); + SmsUtils.sendSms(application,"2130103", affiliate.getPhone(), + new String[]{application.getCaseNum(),application.getHearDate(),"authId="+roomUuid}); + + } else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){ + resEmails.add(affiliate.getEmail()); + // 发送邮件 + caseApplicationService.sendEmail(application, affiliate, "开庭日期通知", content); + + } + + }}, executor); + } }else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); + // 申请人/被申通知, 线下调解 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); } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); } + /** + * 申请操作人/被申操作人发送通知 + * @param application + * @param affiliates + * @param applicantFlag + * @param notice + */ + @Override + @Transactional + public void sendNotice(MsCaseApplication application, List affiliates, Boolean applicantFlag, + SMSNotice notice) { + List appPhones=new ArrayList<>(); + List resPhones=new ArrayList<>(); + List appEmails=new ArrayList<>(); + List resEmails=new ArrayList<>(); + + for (MsCaseAffiliate affiliate : affiliates) { + if (applicantFlag == null || applicantFlag) { + // 申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + SMSNoticeDO applicantNotice = notice.getApplicantNotice(); + if (StrUtil.isNotEmpty(affiliate.getPhone())&&!appPhones.contains(affiliate.getPhone())) { + appPhones.add(affiliate.getPhone()); + SmsUtils.sendSms(application, applicantNotice.getTemplateId(), affiliate.getPhone(), + applicantNotice.getTemplateParamSet()); + + } else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) { + appEmails.add(affiliate.getEmail()); + // 发送邮件 + caseApplicationService.sendEmail(application, affiliate, applicantNotice.getSubject(), applicantNotice.getContent()); + + } + continue; + } + } + if (applicantFlag == null || !applicantFlag) { + // 被申请人 + if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + SMSNoticeDO resNotice = notice.getResNotice(); + if (StrUtil.isNotEmpty(affiliate.getPhone())&& !resPhones.contains(affiliate.getPhone())) { + resPhones.add(affiliate.getPhone()); + SmsUtils.sendSms(application, resNotice.getTemplateId(), affiliate.getPhone(), + resNotice.getTemplateParamSet()); + + } else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){ + resEmails.add(affiliate.getEmail()); + // 发送邮件 + caseApplicationService.sendEmail(application, affiliate, resNotice.getSubject(), resNotice.getContent()); + + } + } + + } + } + } + + + + /** * 案件不予受理 @@ -2098,39 +2435,27 @@ 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 超过五日还没有受理,给申请操作人发送不受理通知,有手机号发短信,没有手机号发邮箱 + // 申请人不受理分配通知 // todo 短信异步 + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + 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); + }, executor); // 修改案件状态为17,结束 MsCaseApplication caseApplication = new MsCaseApplication(); caseApplication.setId(id); @@ -2138,7 +2463,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { caseApplication.setCaseStatusName("结束"); msCaseApplicationMapper.updateByPrimaryKeySelective(caseApplication); CaseLogUtils.insertCaseLog(application.getId(), 4, "受理分配", null); - + CaseLogUtils.insertCaseLog(application.getId(), 17, "结束", null); + // 结束对接北明,为调解失败状态 + if(StrUtil.isEmpty(application.getCaseSource())) { + caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL); + } } } @@ -2146,16 +2475,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { public SysUser getUserInfo() { SysUser sysUser =new SysUser(); - if(StrUtil.isNotEmpty(SecurityUtils.getUsername())){ - sysUser = sysUserMapper.selectUserByUserName(getUsername()); + if(SecurityUtils.getUserId()!=null){ + sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); } return sysUser; } - @Override - public List getSmsSendRecord(SmsSendRecord smsSendRecord) { - return smsRecordMapper.getSmsSendRecord(smsSendRecord); - } /** * 保存onlyOffice在线编辑的文件 * @param @@ -2165,11 +2490,16 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Override public AjaxResult saveOnlyOfficeFile(MsCaseAttach caseAttach) { if(StrUtil.isEmpty(caseAttach.getAnnexName())) { - caseAttach.setAnnexName("调解书"); + caseAttach.setAnnexName("调解书.docx"); + } + if(StrUtil.isNotEmpty(caseAttach.getAnnexPath())) { + String replace = caseAttach.getAnnexPath().replace("/home/ruoyi/uploadPath", "/profile"); + caseAttach.setAnnexPath(replace); } caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode()); caseAttach.setUseId(getUserInfo().getUserId()); caseAttach.setUseAccount(getUserInfo().getUserName()); + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); // 先删除之前的在新增 msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), caseAttach.getAnnexType()); msCaseAttachMapper.save(caseAttach); @@ -2177,6 +2507,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return AjaxResult.success(); } + /** * 查询预约信息 * @param id @@ -2213,726 +2544,632 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Transactional(rollbackFor = Exception.class) @Override public AjaxResult mediation(MsCaseApplicationReq req) throws EsignDemoException, InterruptedException { + req.setSealFlag(null); // 查询案件是否存在 MsCaseApplication application = msCaseApplicationMapper.selectByPrimaryKey(req.getId()); if (application == null) { return AjaxResult.error("未找到案件"); } + req.setSealFlag(application.getSealFlag()); + if (StrUtil.isEmpty(application.getMediationMethod())) { return AjaxResult.error("未选择调解方式"); } + // 查询当前流程节点 MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(req.getCaseFlowId()); if (currentFlow == null) { 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)) { - // 先删除已经存在的调解书 - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); - for (MsCaseAttach attach : attachList) { - attach.setCaseAppliId(req.getId()); - msCaseAttachMapper.updateCaseAttach(attach); + // 查询案件人员 + 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("未找到案件操作人员"); + } + // 更新附件 + List attachList = req.getAttachList(); + if (CollectionUtil.isNotEmpty(attachList)) { + Map> annexTypeMap = attachList.stream().filter(attach -> attach.getAnnexType() != null).collect(Collectors.groupingBy(MsCaseAttach::getAnnexType)); + for (Map.Entry> entry : annexTypeMap.entrySet()) { + if(entry.getKey()!=null && entry.getValue().size()>1){ + return AjaxResult.error("同一案件同一类型附件只能上传一个"); } } - 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{ - return AjaxResult.error(); - } - }else{ - return AjaxResult.error(); - } - } - break; - - } - } + // 先删除已存在的调解书 + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndTypes(req.getId(), new ArrayList<>(annexTypeMap.keySet())); + if (CollectionUtil.isNotEmpty(existAttach)) { + // 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if (StrUtil.isEmpty(msCaseAttach.getOtherSysFileId()) || StrUtil.isEmpty(msCaseAttach.getAnnexPath())) { + continue; } - - 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); + beiMingInterfaceService.deleteAttachmentInfo(application.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); } - 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()); - } - - 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); - } - } - } - - 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); - - 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); - - } 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)){ - return AjaxResult.error("请上传调解资料"); - } - // 先删除已经存在的调解书 - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(req.getId(),AnnexTypeEnum.MEDIATE_BOOK.getCode()); for (MsCaseAttach attach : attachList) { + // 先删除已经存在的调解书 + attach.setCaseAppliId(req.getId()); msCaseAttachMapper.updateCaseAttach(attach); } + // 对接北明,调用上传附件接口 + List msCaseAttaches = msCaseAttachMapper.listCaseAttachByCaseIdAndType(req.getId(), AnnexTypeEnum.MEDIATE_BOOK.getCode()); + if (StrUtil.isEmpty(application.getCaseSource()) && CollectionUtil.isNotEmpty(msCaseAttaches)) { + for (MsCaseAttach msCaseAttach : msCaseAttaches) { + if (StrUtil.isEmpty(msCaseAttach.getAnnexPath())) { + continue; + } + + String replacePath = msCaseAttach.getAnnexPath().replace("/profile/", "/home/ruoyi/uploadPath/"); + File file = new File(replacePath); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_AGREEMENT); + // 更新附件表 + if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) { + msCaseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttach(msCaseAttach); + } + + + } + } + } + // 线上调解 + if (application.getMediationMethod().equals("1")) { + Integer mediaResult = application.getMediaResult()==null ? req.getMediaResult():application.getMediaResult(); + if (mediaResult == null) { + return AjaxResult.error("请选择调解结果"); + } + + 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 annexPath = caseAttach.getAnnexPath(); + if (annexPath.contains("/profile")) { + annexPath = annexPath.replace("/profile", "/home/ruoyi/uploadPath"); + } + 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()); + } + // 设置申请人签名账户 + sealSignRecord.setPensonAccount(applicantAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonName(applicantAffiliateOpt.get().getName()); + // 设置被申请人签名账户 + sealSignRecord.setPensonAccountRes(resAffiliateOpt.get().getPhone()); + sealSignRecord.setPensonNameRes(resAffiliateOpt.get().getName()); + // 设置用印账号 + if (req.getSealFlag().equals(1)) { + 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 + 40); + } + } 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 { + // 设置用印位置 + if (req.getSealFlag().equals(1)) { + //用印 + 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); + } + } + } + } + EsignHttpResponse response3 = new EsignHttpResponse(); + // 设置用印位置 + if (req.getSealFlag().equals(1)) { + 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()); + } + } + response3 = SignAward.createByFileSeal(sealSignRecord, sealIdList); + + } + } + } else { + // 不带用印 + response3 = SignAward.createByFileMediation(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()); + msSealSignRecord.setOrgnNamePsnAcc(sealSignRecord.getOrgnizeNamePsnAccount()); + msSealSignRecord.setOrgnNamePsnName(sealSignRecord.getOrgnizeNamepsnName()); + 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.sendSms(application,"2116857",applicantAffiliateOpt.get().getPhone(), + new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum(), urlapplynew}); + + 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.sendSms(application,"2116857",resAffiliateOpt.get().getPhone(),new String[]{resAffiliateOpt.get().getName(), application.getCaseNum(), urlResponnew}); + // 调解员账户 + 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.sendSms(application,"2116857",sealSignRecord.getPensonAccountMedi(),new String[]{sealSignRecord.getPensonNameMedi(), application.getCaseNum(), urlResponnewMedi}); + + } 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.updateByPrimaryKeySelective(application); + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + } + + application.setMediaResult(mediaResult); + application.setSealFlag(req.getSealFlag()); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + } else { + return AjaxResult.error(); + } + } else { + return AjaxResult.error(); + } + break; + } + + + } + } + return AjaxResult.success(); + + } else if (mediaResult == 2) { + //未达成调解,申请人短信 发送终止调解短信,尊敬的{1}用户,您的{2}调解案件已终止调解,如非本人操作,请忽略本短信 + SmsUtils.sendSms(application,"2066725",applicantAffiliateOpt.get().getPhone(),new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum()}); + // 被申请人短信 + SmsUtils.sendSms(application,"2066725",resAffiliateOpt.get().getPhone(),new String[]{resAffiliateOpt.get().getName(), application.getCaseNum()}); + // 修改案件状态为结束 + 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(), ""); + // 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + } + return AjaxResult.success(); + } else if (mediaResult == 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.updateByPrimaryKeySelective(application); + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + // 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + } + return AjaxResult.success(); + } else if (mediaResult == 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) { + 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(), ""); + // 新增结束日志 + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + application.setCaseFlowId(caseFlow.getId()); + application.setCaseStatusName(caseFlow.getCaseStatusName()); + application.setMediaResult(mediaResult); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + } + + return AjaxResult.success(); + } else if (mediaResult == 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 annexPath = caseAttach.getAnnexPath(); + if (annexPath.contains("/profile")) { + annexPath = annexPath.replace("/profile", "/home/ruoyi/uploadPath"); + } + 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()); + } + // 申请人账户 + 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.sendSms(application, "2047719",applicantAffiliateOpt.get().getPhone(), new String[]{applicantAffiliateOpt.get().getName(), application.getCaseNum(), urlapplynew}); + // 被申签名记录 + 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.sendSms(application, "2047719",resAffiliateOpt.get().getPhone(), new String[]{resAffiliateOpt.get().getName(), application.getCaseNum(), urlResponnew}); + + } else { + return AjaxResult.error(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 { + // 线下调解 + Integer mediaResult=req.getMediaResult(); + if(mediaResult==null){ + return AjaxResult.error("请选择调解结果"); + } // 修改案件状态为待送达 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,19 +3183,26 @@ 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(),""); + msCaseApplicationMapper.updateByPrimaryKeySelective(application); + if (mediaResult == 2 || mediaResult == 3 || mediaResult == 4) { + CaseLogUtils.insertCaseLog(application.getId(), caseFlow.getNodeId(), caseFlow.getCaseStatusName(), null); + // 结束对接北明,为调解失败状态 + caseApplicationService.pushStatusToBM(application, PushCaseStatusEnum.FAIL); + } + }else { + msCaseApplicationMapper.updateByPrimaryKeySelective(application); } + // 新增日志 + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); return AjaxResult.success(); } - return AjaxResult.success(); + return AjaxResult.error(); } /** @@ -2993,6 +3237,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { AjaxResult result = caseApplicationService.generateApplication(req); // 修改案件结果 application.setMediaResult(req.getMediaResult()); + application.setSealFlag(req.getSealFlag()); msCaseApplicationMapper.updateByPrimaryKeySelective(application); return AjaxResult.success(); } @@ -3012,689 +3257,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(); - } - /** @@ -3729,27 +3291,188 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { return nextFlow; } - /** - * 生成调解申请书 - * @param application 案件基本信息 - * @param affiliate 案件相关人员 - * @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<>(); 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())); } + } + // 按组分类 + Map> affliateMap = affiliates.stream().collect(Collectors.groupingBy(MsCaseAffiliate::getGroupOrder, Collectors.toList())); + // 申请人 + List applicantList = new ArrayList<>(); + // 被申 + List resList = new ArrayList<>(); + // 多个申请人拼接 + StringBuilder applicantName = new StringBuilder(); + 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); + if(!applicantName.toString().contains(affiliate.getName()+Constants.CN_SPLIT_COMMA)) { + applicantName.append(affiliate.getName()).append(Constants.CN_SPLIT_COMMA); + } + 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); + } + }); + // 设置基本字段 + String[] personBase={"申请人","被申请人"}; + for (String person : personBase) { + StringBuilder value = valueMap.get(person)==null?new StringBuilder():new StringBuilder(valueMap.get(person)); + if(person.equals("申请人")) { + for (MsCaseAffiliateBase affiliateBase : applicantList) { + MsCaseAffiliate applicant = affiliateBase.getApplicant(); + MsCaseAffiliate applicantAgent = affiliateBase.getApplicantAgent(); + if (applicant != null) { + // 申请人 + if(applicant.getOrganizeFlag()==0){ + + value.append("申请人:").append(applicant.getName()).append("\n"); + // 自然人 + if(StrUtil.isNotEmpty(applicant.getIdCard())){ + value.append("证件号码:").append(applicant.getIdCard()).append("\n"); + } + if(StrUtil.isNotEmpty(applicant.getPhone())){ + value.append("申请人电话:").append(applicant.getPhone()).append("\n"); + } + if(StrUtil.isNotEmpty(applicant.getEmail())){ + value.append("申请人邮箱:").append(applicant.getEmail()).append("\n"); + } + + }else { + // 机构 + value.append("申请人:").append(applicant.getApplicantOrgName()).append("\n"); + if (StrUtil.isNotEmpty(applicant.getCode())) { + value.append("统一社会信用代码:").append(applicant.getCode()).append("\n"); + } + if (StrUtil.isNotEmpty(applicant.getCompLegalPerson())) { + value.append("法定代表人:").append(applicant.getCompLegalPerson()).append("\n"); + } + + } + if (StrUtil.isNotEmpty(applicant.getHome())) { + value.append("申请人住所:").append(applicant.getHome()).append("\n"); + } + if (StrUtil.isNotEmpty(applicant.getAddress())) { + value.append("申请人联系地址:").append(applicant.getAddress()).append("\n"); + } + + } + if (applicantAgent != null ) { + // 代理人 + value.append("委托代理人:").append(applicantAgent.getName()).append("\n"); + if (StrUtil.isNotEmpty(applicantAgent.getPhone())) { + value.append("联系电话:").append(applicantAgent.getPhone()).append("\n"); + } + if (StrUtil.isNotEmpty(applicantAgent.getEmail())) { + value.append("邮箱:").append(applicantAgent.getEmail()).append("\n"); + } + } + } + valueMap.put(person,value.toString()); + }else { + // 被申请人 + for (MsCaseAffiliateBase affiliateBase : resList) { + MsCaseAffiliate res = affiliateBase.getRes(); + MsCaseAffiliate resAgent = affiliateBase.getResAgent(); + if (res != null ) { + // 被申请人 + if(res.getOrganizeFlag()==0){ + value.append("被申请人:").append(res.getName()).append("\n"); + // 自然人 + if(StrUtil.isNotEmpty(res.getIdCard())){ + value.append("证件号码:").append(res.getIdCard()).append("\n"); + } + if(StrUtil.isNotEmpty(res.getPhone())){ + value.append("被申请人电话:").append(res.getPhone()).append("\n"); + } + if(StrUtil.isNotEmpty(res.getEmail())){ + value.append("被申请人邮箱:").append(res.getEmail()).append("\n"); + } + + if(res.getBirth()!=null){ + value.append("被申请人出生年月:").append(sdf.format(res.getBirth())).append("\n"); + } + if(StrUtil.isNotEmpty(res.getSex())){ + value.append("被申请人性别:").append(res.getSex().equals("0")?"男":"女").append("\n"); + } + }else { + // 机构 + value.append("被申请人:").append(res.getApplicantOrgName()).append("\n"); + if (StrUtil.isNotEmpty(res.getCode())) { + value.append("统一社会信用代码:").append(res.getCode()).append("\n"); + } + if (StrUtil.isNotEmpty(res.getCompLegalPerson())) { + value.append("法定代表人:").append(res.getCompLegalPerson()).append("\n"); + } + + } + if(StrUtil.isNotEmpty(res.getHome())){ + value.append("被申请人住所:").append(res.getHome()).append("\n"); + } + if(StrUtil.isNotEmpty(res.getAddress())){ + value.append("被申请人联系地址:").append(res.getAddress()).append("\n"); + } + + } + if (resAgent != null && resAgent.getRoleType()!=null) { + // 代理人 + value.append("委托代理人:").append(resAgent.getName()).append("\n"); + if (StrUtil.isNotEmpty(resAgent.getPhone())) { + value.append("联系电话:").append(resAgent.getPhone()).append("\n"); + } + if (StrUtil.isNotEmpty(resAgent.getEmail())) { + value.append("邮箱:").append(resAgent.getEmail()).append("\n"); + } + } + } + valueMap.put(person,value.toString()); + } } + + valueMap.put("申请人签字",removeLastComma(applicantName.toString(),Constants.CN_SPLIT_COMMA)); + // 书签对应值 Map bookmarkValueMap = new HashMap<>(); // 读取调节申请书,找到占位符,替换值 @@ -3788,22 +3511,33 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { wordChangeText(templatePath, bookmarkValueMap,saveFolderPath,resultFilePath); MsCaseAttach caseAttach = null; - String annexPath=resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX); - // 如果是调解书或者调解协议上传到onlyoffice服务器 + String annexPath=resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX); + // 如果是调解书或者调解协议上传到onlyoffice服务器 if(annexType != null && annexType.equals(AnnexTypeEnum.MEDIATE_BOOK.getCode())){ JSONArray jsonArray = caseApplicationService.uploadOnlyOffice(annexPath,application.getId()); if(jsonArray!=null && jsonArray.size() > 0){ - for (Object obj : jsonArray) { - JSONObject jsonObject = (JSONObject) obj; - caseAttach= MsCaseAttach.builder() - .caseAppliId(application.getId()) - .annexName(jsonObject.getString("fileName")) - .annexPath(jsonObject.getString("filePath")) - .annexType(annexType) - .onlyOfficeFileId(jsonObject.getString("fileId")) - .build(); + for (Object obj : jsonArray) { + JSONObject jsonObject = (JSONObject) obj; + caseAttach= MsCaseAttach.builder() + .caseAppliId(application.getId()) + .annexName(jsonObject.getString("fileName")) + .annexType(annexType) + .onlyOfficeFileId(jsonObject.getString("fileId")) + .build(); + + if(jsonObject.get("filePath")!=null){ + String officePath = jsonObject.getString("filePath"); + String replace = officePath.replace("/home/ruoyi/uploadPath/", "/profile/"); + caseAttach.setAnnexPath(replace); + + } } + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); + + //保存到附件表里,先删除之前的在保存 + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType); + msCaseAttachMapper.save(caseAttach); } }else { @@ -3813,14 +3547,41 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { .annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX)) .annexType(annexType) .build(); - } - //保存到附件表里,先删除之前的在保存 - if(caseAttach != null) { - msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAttach.getCaseAppliId(), annexType); + // 查找已经存在的附件 + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(application.getId(), annexType); + if(CollectionUtil.isNotEmpty(existAttach)){ + // 对接北明,同步案件状态,删除 + 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(caseAttach.getCaseAppliId(), annexType); + if(StrUtil.isEmpty(application.getCaseSource())) { + // 北明推送 + if (StrUtil.isNotEmpty(caseAttach.getAnnexPath())) { + String replacePath = caseAttach.getAnnexPath().replace("/profile/", "/home/ruoyi/uploadPath/"); + File file = new File(replacePath); + MsCaseFileInfo caseFileInfo = beiMingInterfaceService.pushAttachmentInfo(BMUserName, BMPassword, file, BMSyncSource, application.getCaseNum(), AttachmentOperateTypeEnum.ADD, DocumentTypeEnum.EVEDENT_APPLY_BOOK); + + // 更新附件表 + if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) { + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + } + } + + } + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); msCaseAttachMapper.save(caseAttach); + } + } + + /** * 调解书上传到onlyoffice服务器 * @param annexPath @@ -3828,7 +3589,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { @Override @Transactional public JSONArray uploadOnlyOffice(String annexPath,Long caseId) { - annexPath=annexPath.replace("/profile","/home/ruoyi/uploadPath"); + annexPath=annexPath.replace("/profile/","/home/ruoyi/uploadPath/"); File file = new File(annexPath); if (file.exists()) { // 调用onlyoffice @@ -4067,137 +3828,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { } } - /** - * 新增申请机构代理人 - * - * @param affiliate - */ - @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); - } - - } - } - } - } /** - * 新增部门 - * - * @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())); - } - } /** * 获取案件编码 @@ -4205,8 +3839,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService { * @return */ private String getCaseNum() { - // todo 查询编码规则 - // 自动编码格式 zc+yyyyMMdd+001 String currentDay = DateUtils.dateTime(); String caseNum = "zc" + currentDay; 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..73f650b 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,16 +12,18 @@ 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.ThreadUtil; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.dto.PayRequest; import com.ruoyi.dto.PayResponse; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; import com.ruoyi.system.mapper.flow.MsCaseFlowMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendRecordParamMapper; +import com.ruoyi.system.mapper.sms.MsSmsTemplateMapper; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CaseConfirmPayDTO; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.CasePayDTO; -import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; import com.ruoyi.wisdomarbitrate.domain.entity.mscase.*; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.PaymentDetailVO; import com.ruoyi.wisdomarbitrate.mapper.mscase.*; @@ -29,6 +31,7 @@ import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService; import com.ruoyi.wisdomarbitrate.service.mscase.MsCasePaymentService; import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; +import com.ruoyi.wisdomarbitrate.utils.SmsUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,7 +42,10 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Service public class MsCasePaymentServiceImpl implements MsCasePaymentService { @@ -65,6 +71,10 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { private RedisCache redisCache; @Autowired private MsCaseAuditMapper auditMapper; + @Autowired + MsSmsTemplateMapper templateMapper; + @Autowired + MsSmsSendRecordParamMapper recordParamMapper; @Override @@ -226,7 +236,6 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } JSONObject jsonObject = new JSONObject(); jsonObject.set("totalFee", totalFee); - jsonObject.set("applicationOrganName", affiliate.getApplicationName()); return AjaxResult.success(jsonObject); } @@ -248,10 +257,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())); @@ -337,14 +342,14 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { } casePaymentRecord.setCaseId(application.getId()); Example example = new Example(MsCasePaymentRecord.class); - example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId());casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord, example); + example.createCriteria().andEqualTo("caseId", casePaymentRecord.getCaseId()); + casePaymentRecordMapper.updateByExampleSelective(casePaymentRecord, example); // 更改案件流程id和案件状态 application.setCaseFlowId(flow.getId()); application.setCaseStatusName(flow.getCaseStatusName()); caseApplicationMapper.updateByPrimaryKeySelective(application); if (dto.getApplicantConfirm() && dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { // 申请人确认缴费后将该案件存放到redis,5日之内如果案件状态还是待受理状态,则发送不受理通知书并自动结束 -// redisCache.setCacheObject(CacheConstants.CASE_KEY+application.getId(), application, Constants.CASE_ACCEPT_EXPIRATION, TimeUnit.DAYS); SpringUtils.getBean(RedisCache.class).setCacheObject(getVerifyCodeCacheKey(String.valueOf(application.getId())), application, Constants.CASE_ACCEPT_EXPIRATION, TimeUnit.DAYS); } @@ -369,12 +374,67 @@ 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("未找到案件操作人员"); + } + // 异步发送短信 + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + if(dto.getApplicantConfirm()) { + List appPhones=new ArrayList<>(); + // 申请人确认缴费 + for (MsCaseAffiliate affiliate : operatorList) { + // 发送缴费通知 + if (affiliate.getRoleType() == null) { + continue; + } + if (!appPhones.contains(affiliate.getPhone())&&(affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + appPhones.add(affiliate.getPhone()); + if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { + // 缴费通过 + SmsUtils.sendSms(caseAppllication, "2051914", affiliate.getPhone(), new String[]{affiliate.getName()}); + } else { + // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信 + SmsUtils.sendSms(caseAppllication, "2074402", affiliate.getPhone(), new String[]{affiliate.getName(), caseAppllication.getCaseNum(), dto.getReason()}); + } + } + } + }else { + List resPhones=new ArrayList<>(); + List resAcceptPhones=new ArrayList<>(); + // 被申请人确认缴费 + for (MsCaseAffiliate affiliate : operatorList) { + // 发送缴费通知 + if (affiliate.getRoleType() == null) { + continue; + } + if (!resPhones.contains(affiliate.getPhone())&&(affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4)) ) { + resPhones.add(affiliate.getPhone()); + if (dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode())) { + // 缴费通过 + SmsUtils.sendSms(caseAppllication, "2051914", affiliate.getPhone(), new String[]{affiliate.getName()}); + } else { + // 2074402 调解系统确认缴费不通过通知 尊敬的{1}用户,您的{2}案件,确认缴费未通过,理由为{3},请知晓,如非本人操作,请忽略本短信 + SmsUtils.sendSms(caseAppllication, "2074402", affiliate.getPhone(), new String[]{affiliate.getName(), caseAppllication.getCaseNum(), dto.getReason()}); + } + } + // 被申请人确认缴费,发送受理通知 + if( dto.getYesOrNo().equals(YesOrNoEnum.YES.getCode()) && !resAcceptPhones.contains(affiliate.getPhone())) { + resAcceptPhones.add(affiliate.getPhone()); + // 申请人被申请人发送受理通知书 2073601 尊敬的{1}用户,您的{2}案件,已成功受理,请知晓,如非本人操作,请忽略本短信。 + SmsUtils.sendSms(caseAppllication, "2073601", affiliate.getPhone(), new String[]{affiliate.getName(), caseAppllication.getCaseNum()}); + + } + } + }}, executor); } @@ -395,88 +455,9 @@ 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 ) { - // 申请人被申请人发送受理通知书 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() + "案件,已成功受理,请知晓,如非本人操作,请忽略本短信。"); - // 新增短信记录 - if (smsFlag) { - smsSendRecord.setSendStatus(YesOrNoEnum.YES.getCode()); - } else { - smsSendRecord.setSendStatus(YesOrNoEnum.NO.getCode()); - } - smsRecordMapper.saveSmsSendRecord(smsSendRecord); - } /** * 确认缴费 @@ -490,8 +471,6 @@ public class MsCasePaymentServiceImpl implements MsCasePaymentService { application.setPayType(dto.getPayType()); // 修改缴费附件 if (CollectionUtil.isNotEmpty(dto.getPayOrderList())) { - - for (MsCaseAttach caseAttach : dto.getPayOrderList()) { // 先删除之前的缴费 if(currentFlow.getButtonAuthFlag().equals("caseManagement:list:pay")){ 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..5db4cfb 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; @@ -15,19 +15,21 @@ import com.ruoyi.common.core.domain.AjaxResult; 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.YesOrNoEnum; +import com.ruoyi.common.enums.*; 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.ThreadUtil; import com.ruoyi.common.utils.file.SaaSAPIFileUtils; import com.ruoyi.system.domain.entity.flow.MsCaseFlow; +import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord; 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.mapper.shortmessage.MsSendMailHistoryRecordMapper; +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,7 +42,9 @@ 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.domain.vo.shortmessage.MeetingInfoVO; import com.ruoyi.wisdomarbitrate.mapper.dept.DeptIdentifyMapper; import com.ruoyi.wisdomarbitrate.mapper.dept.MsSealSignRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.dept.SealManageMapper; @@ -51,9 +55,14 @@ import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseLogRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper; import com.ruoyi.wisdomarbitrate.service.mscase.MsCaseApplicationService; import com.ruoyi.wisdomarbitrate.service.mscase.MsSignSealService; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils; import com.ruoyi.wisdomarbitrate.utils.SignAward; +import com.ruoyi.wisdomarbitrate.utils.SmsUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; 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; @@ -63,12 +72,18 @@ import java.io.File; import java.io.IOException; import java.time.LocalDate; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; +import static com.google.common.io.Files.getFileExtension; import static com.ruoyi.common.core.domain.AjaxResult.success; +@Slf4j @Service public class MsSignSealServiceImpl implements MsSignSealService { + @Autowired + private MsSignSealService msSignSealService; @Autowired MsCaseApplicationMapper msCaseApplicationMapper; @@ -106,287 +121,23 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Autowired private SendMailRecordMapper sendMailRecordMapper; + @Value("${spring.mail.username}") + private String emailFrom; + // 北明配置 + @Value("${BMConfig.userName}") + private String BMUserName; + @Value("${BMConfig.password}") + private String BMPassword; + @Value("${BMConfig.syncSource}") + private String BMSyncSource; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + @Autowired + private MsSendMailHistoryRecordMapper sendMailHistoryRecordMapper; + @Autowired + ShortMessageService shortMessageService; - - - @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 public AjaxResult sealApply(MsSignSealDTO dto) { @@ -411,7 +162,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { application.setCaseFlowId(nextFlow.getId()); application.setCaseStatusName(nextFlow.getCaseStatusName()); caseApplicationMapper.updateByPrimaryKeySelective(application); - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null); + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null); } } else { // 单独 @@ -421,7 +172,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { application.setCaseFlowId(nextFlow.getId()); application.setCaseStatusName(nextFlow.getCaseStatusName()); caseApplicationMapper.updateByPrimaryKeySelective(application); - CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null); + CaseLogUtils.insertCaseLog(application.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null); } return AjaxResult.success("用印申请成功"); @@ -457,8 +208,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,15 +217,14 @@ 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("结束")){ + if (StringUtils.isNotEmpty(content)) { + if (content.equals("结束")) { recordsNew.add(msCaseLogRecordVO); - }else { - if(!content.equals(msCaseFlow.getCaseStatusName())){ + } else { + if (!content.equals(msCaseFlow.getCaseStatusName())) { recordsNew.add(msCaseLogRecordVO); - }else{ + } else { break; } } @@ -487,28 +235,28 @@ public class MsSignSealServiceImpl implements MsSignSealService { CaseLogRecord caseLogRecordin = new CaseLogRecord(); List caseLogRecordsin = new ArrayList<>(); - if(!"结束".equals(msCaseFlow.getNodeName())){ + if (!"结束".equals(msCaseFlow.getNodeName())) { caseLogRecordin.setCaseNodeName(msCaseFlow.getNodeName()); List msCaseFlowvos = caseFlowMapper.selectFlowRole(caseFlowId); StringBuilder roleIn = new StringBuilder(); - for(MsCaseFlowVO mscaseFlowVO:msCaseFlowvos){ - if(!"结束".equals(mscaseFlowVO.getNodeName())){ - roleIn.append( mscaseFlowVO.getRoleName()+"正在进行"+mscaseFlowVO.getNodeName()+";"); + for (MsCaseFlowVO mscaseFlowVO : msCaseFlowvos) { + if (!"结束".equals(mscaseFlowVO.getNodeName())) { + roleIn.append(mscaseFlowVO.getRoleName() + "正在进行" + mscaseFlowVO.getNodeName() + ";"); } } - caseLogRecordin.setContent(roleIn.toString().substring(0,roleIn.toString().length()-1)); + caseLogRecordin.setContent(roleIn.toString().substring(0, roleIn.toString().length() - 1)); MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId); - if(nextFlow!=null){ + if (nextFlow != null) { String nodeName = nextFlow.getNodeName(); - if(StringUtils.isNotEmpty(nodeName)){ - if(!"结束".equals(nodeName)){ + if (StringUtils.isNotEmpty(nodeName)) { + if (!"结束".equals(nodeName)) { List nextMsCaseFlowvo = caseFlowMapper.selectFlowRole(nextFlow.getId()); StringBuilder roleIn1 = new StringBuilder(); - for(MsCaseFlowVO mscaseFlowVO:nextMsCaseFlowvo){ - roleIn1.append( mscaseFlowVO.getRoleName()+";"); + for (MsCaseFlowVO mscaseFlowVO : nextMsCaseFlowvo) { + roleIn1.append(mscaseFlowVO.getRoleName() + ";"); } - caseLogRecordin.setNextRoleName("下一节点角色:"+roleIn1.toString().substring(0,roleIn1.toString().length()-1)); + caseLogRecordin.setNextRoleName("下一节点角色:" + roleIn1.toString().substring(0, roleIn1.toString().length() - 1)); } } } @@ -527,24 +275,24 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseLogRecord1.setCaseNodeName(msCaseFlowVOs.get(0).getNodeName()); StringBuilder rolenext = new StringBuilder(); - for(MsCaseFlowVO mscaseFlowVO:msCaseFlowVOs){ + for (MsCaseFlowVO mscaseFlowVO : msCaseFlowVOs) { String nodeName1 = mscaseFlowVO.getNodeName(); - if(StringUtils.isNotEmpty(nodeName1)){ - if("结束".equals(nodeName1)){ + if (StringUtils.isNotEmpty(nodeName1)) { + if ("结束".equals(nodeName1)) { rolenext.append("结束;"); - }else { - rolenext.append( mscaseFlowVO.getRoleName()+"将进行"+mscaseFlowVO.getNodeName()+";"); + } else { + rolenext.append(mscaseFlowVO.getRoleName() + "将进行" + mscaseFlowVO.getNodeName() + ";"); } } } - caseLogRecord1.setContent( rolenext.toString().substring(0,rolenext.toString().length()-1)); + caseLogRecord1.setContent(rolenext.toString().substring(0, rolenext.toString().length() - 1)); caseLogRecordsnext.add(caseLogRecord1); } } - if(caseLogRecordsin!=null&&caseLogRecordsin.size()>0){ + if (caseLogRecordsin != null && caseLogRecordsin.size() > 0) { datas.put("finishCasenode", recordsNew); - }else { + } else { MsCaseLogRecordVO msCaseLogRecordVO1 = new MsCaseLogRecordVO(); msCaseLogRecordVO1.setContent("结束"); recordsNew.add(msCaseLogRecordVO1); @@ -561,27 +309,27 @@ public class MsSignSealServiceImpl implements MsSignSealService { MsCaseLogRecord caseLogRecord = new MsCaseLogRecord(); caseLogRecord.setCaseAppliId(id); List records = caseLogRecordMapper.selectCaseLogRecordList(caseLogRecord); - if(CollectionUtil.isNotEmpty(records)){ - records.forEach(record->{ + if (CollectionUtil.isNotEmpty(records)) { + records.forEach(record -> { StringBuilder contentBuilder = new StringBuilder(); - String caseNodeTime=""; - if(record.getCreateTime()!=null){ - caseNodeTime= DateUtil.format(record.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER); + String caseNodeTime = ""; + if (record.getCreateTime() != null) { + caseNodeTime = DateUtil.format(record.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER); } Integer caseNode = record.getCaseNode(); String createBy = record.getCreateBy(); - if(StrUtil.isNotEmpty(createBy)){ + if (StrUtil.isNotEmpty(createBy)) { contentBuilder.append(Optional.ofNullable(record.getCreateNickName()).orElse("")).append("(").append(record.getCreateBy()).append(")").append("于").append(caseNodeTime); - }else{ + } else { contentBuilder.append(Optional.ofNullable(record.getCreateNickName()).orElse("")).append("于").append(caseNodeTime); } - if(StrUtil.isNotEmpty(record.getContent())){ + if (StrUtil.isNotEmpty(record.getContent())) { contentBuilder.append(record.getContent()); - }else if(caseNode.intValue() == 0){ + } else if (caseNode.intValue() == 0) { contentBuilder.append(record.getCaseStatusName()); } - if(StrUtil.isNotEmpty(record.getNotes())){ + if (StrUtil.isNotEmpty(record.getNotes())) { contentBuilder.append(",").append(record.getNotes()); } record.setContent(contentBuilder.toString()); @@ -593,225 +341,187 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Override @Transactional(rollbackFor = Exception.class) - public AjaxResult msCaseFile(List ids){ + public AjaxResult msCaseFile(List ids) { + StringBuilder error = new StringBuilder(); try { for (Long id : ids) { MsCaseApplication caseApplication1 = msCaseApplicationMapper.selectByPrimaryKey(id); - if (caseApplication1 == null) { - return AjaxResult.error("未查询到相关案件"); - } - MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO(); - BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO); - List caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO); - 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(); - String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - File file = new File(path); - // todo 部署放开 - if (!file.exists()) { - Gson gson = new Gson(); - MsSealSignRecord sealSignRecord = new MsSealSignRecord(); - sealSignRecord.setCaseAppliId(id); - List sealSignRecords = sealSignRecordMapper.selectSealSignRecord(sealSignRecord); - if (sealSignRecords != null && sealSignRecords.size() > 0) { - String signFlowid = sealSignRecords.get(0).getSignFlowId(); - EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowid); - JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); - JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); - JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); - if (filesArray != null && filesArray.size() > 0) { - JsonObject fileObject = (JsonObject) filesArray.get(0); - String fileDownloadUrl = fileObject.get("downloadUrl").toString(); - String filearbitraUrl = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); + if (caseApplication1 != null) { - LocalDate now = LocalDate.now(); - String year = Integer.toString(now.getYear()); - String month = String.format("%02d", now.getMonthValue()); - String day = String.format("%02d", now.getDayOfMonth()); - String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; - String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; + MsCaseApplicationVO msCaseApplicationVO = new MsCaseApplicationVO(); + BeanUtil.copyProperties(caseApplication1, msCaseApplicationVO); + List caseAttachList = msCaseAttachMapper.queryCaseAttachList(msCaseApplicationVO); + // 只能送达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; + if (CollectionUtil.isNotEmpty(caseAttachList)) { + long count = caseAttachList.stream().filter(msCaseAttach -> msCaseAttach.getAnnexType() != null && msCaseAttach.getAnnexType().equals(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())).count(); + if (count > 0) { + Integer caseFlowId = caseApplication1.getCaseFlowId(); + // 查询当前节点 + MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId); + if (currentFlow != null) { + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId); + caseApplication1.setCaseFlowId(nextFlow.getId()); + caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1); - // 创建日期目录 - File saveFolder = new File(saveFolderPath); - if (!saveFolder.exists()) { - saveFolder.mkdirs(); - } - String resultFilePath = saveFolderPath + "/" + fileName; - File resultFilePathFile = new File(resultFilePath); - if (!resultFilePathFile.exists()) { - resultFilePathFile.createNewFile(); - } - - boolean downLoadFile = FileTransformation.downLoadFileByUrl(filearbitraUrl, resultFilePath); - if (downLoadFile) { - MsCaseAttach caseAttach1 = new MsCaseAttach(); - caseAttach1.setCaseAppliId(id); - caseAttach1.setAnnexType(7); - caseAttach1.setAnnexPath(savePath); - caseAttach1.setAnnexName(saveName); - msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach1); - - caseAttach.setAnnexPath(savePath); - caseAttach.setAnnexName(saveName); - } + // 获取案件相关人员 + List affiliates = applicationService.selectAffliatesByCaseId(id); + if (CollectionUtil.isNotEmpty(affiliates)) { + // 申请操作人 + Optional applicantAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))).findFirst(); + // 被申请操作人 + Optional resAffiliateOpt = affiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst(); + if (applicantAffiliateOpt.isPresent() && resAffiliateOpt.isPresent()) { + ExecutorService executor = ThreadUtil.createThreadPool(); + // 发送邮件 + CompletableFuture.runAsync(() -> { + if (StrUtil.isNotEmpty(applicantAffiliateOpt.get().getEmail())) { + boolean appEmailFlag = sendCaseEmail(caseApplication1, applicantAffiliateOpt.get().getEmail(), caseAttachList); + } + if (!StrUtil.isEmpty(resAffiliateOpt.get().getEmail())) { + boolean appEmailFlag = sendCaseEmail(caseApplication1, resAffiliateOpt.get().getEmail(), caseAttachList); + } + }, executor); + // 发送签收短信,2126313 尊敬的{1}用户,您的{2}文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?{3},如非本人操作,请忽略本短信 + CompletableFuture.runAsync(() -> { + SysUser sysUser = sysUserMapper.selectUserById(applicantAffiliateOpt.get().getUserId()); + // 获取短信链接uuid + MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(caseApplication1.getId()).systemType("TJ").build(); + String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + if (!StrUtil.isEmpty(sysUser.getPhonenumber())) { + SmsUtils.sendSms(caseApplication1, "2126313", sysUser.getPhonenumber(), new String[]{sysUser.getNickName(), caseApplication1.getCaseNum(), "authId=" + roomUuid}); + } else if (StrUtil.isNotEmpty(sysUser.getEmail())) { + String content = "尊敬的" + sysUser.getNickName() + "用户,您的" + caseApplication1.getCaseNum() + "文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?" + "authId=" + roomUuid + ",如非本人操作,请忽略本短信"; + sendEmail(caseApplication1, sysUser, "调解系统文件签收", content); + } + }, executor); } } - } + CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), ""); + } else { + error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n"); } + } else { + error.append("案件编号为" + caseApplication1.getCaseNum() + "未找到pdf版调解书,请上传\r\n"); } } - Integer caseFlowId = caseApplication1.getCaseFlowId(); - // 查询当前节点 - MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseFlowId); - if(currentFlow==null){ - return AjaxResult.error("未找到当前流程节点"); - } - // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseFlowId); - caseApplication1.setCaseFlowId(nextFlow.getId()); - caseApplication1.setCaseStatusName(nextFlow.getCaseStatusName()); - caseApplicationMapper.updateByPrimaryKeySelective(caseApplication1); - - String appEmail = ""; - String resEmail = ""; - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(id); - - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - if(organizeFlag!=null){ - if(organizeFlag.intValue()==1){ - appEmail = caseAffiliate.getAgentEmail(); - }else { - appEmail = caseAffiliate.getApplicationEmail(); - } - } - resEmail = caseAffiliate.getRespondentEmail(); - boolean appEmailFlag = sendCaseEmail(caseApplication1, appEmail, 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); - } - 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("被申请人调解书发送失败"); - } - - CaseLogUtils.insertCaseLog(caseApplication1.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),""); } } catch (Exception e) { throw new ServiceException("调解书发送失败"); } - + if (error.length() > 0) { + return AjaxResult.error(error.toString()); + } return AjaxResult.success(""); } + public void sendEmail(MsCaseApplication application, SysUser user, String subject, String sendContent) { + boolean emailFlag = emailOutUtil.sendMessage(user.getEmail(), subject, sendContent, null, null); + + SendMailRecord sendMailRecord = new SendMailRecord(); + sendMailRecord.setCaseId(application.getId()); + sendMailRecord.setMailAddress(user.getEmail()); + sendMailRecord.setMailContent(sendContent); + sendMailRecord.setMailName(subject); + sendMailRecord.setSendTime(new Date()); +// sendMailRecord.setCreateBy(SecurityUtils.getUsername()); + sendMailRecord.setCreateTime(new Date()); + sendMailRecord.setMailSubject(subject); + sendMailRecord.setMailFromAddress(emailFrom); + sendMailRecord.setCaseNum(application.getCaseNum()); + if (emailFlag) { + sendMailRecord.setSendStatus(1); + } else { + sendMailRecord.setSendStatus(0); + } + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); + // 新增历史记录 + MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord(); + BeanUtils.copyProperties(sendMailRecord, msSendMailHistoryRecord); + msSendMailHistoryRecord.setParentId(sendMailRecord.getId()); + msSendMailHistoryRecord.setId(null); + sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); + } + @Override @Transactional public AjaxResult msCaseSign(MsSignSealDTO dto) { Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); MsCaseApplication caseApplicationselect = msCaseApplicationMapper.selectByPrimaryKey(caseId); + if (caseApplicationselect == null) { + return AjaxResult.error("当前案件不存在"); + } // 查询当前节点 MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseApplicationselect.getCaseFlowId()); if (currentFlow == null) { return AjaxResult.error("当前流程不存在"); } -// if (dto.getIsSignApply() != null && dto.getIsSignApply().intValue() == 1) { -// caseAffiliate.setIsSignApply(1); -// msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); -// if (caseAffiliate.getIsSignRespon() != null && caseAffiliate.getIsSignRespon().intValue() == 1) { -// // 根据流程id查找下一个流程节点 -// MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); -// caseApplicationselect.setCaseFlowId(nextFlow.getId()); -// caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); -// caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); -// CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"签收"); -// } -// } - if (dto.getIsSignApply() != null && dto.getIsSignApply().intValue() == 1) { - caseAffiliate.setIsSignApply(1); - msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); - - // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); - caseApplicationselect.setCaseFlowId(nextFlow.getId()); - caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); - caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); - CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null); + Long loginUserId = SecurityUtils.getUserId(); + Example example = new Example(MsCaseAffiliate.class); + example.createCriteria().andEqualTo("caseAppliId", caseId); + List msCaseAffiliates = msCaseAffiliateMapper.selectByExample(example); + if (CollectionUtil.isEmpty(msCaseAffiliates)) { + return AjaxResult.error("未找到案件相关人员"); } -// if (dto.getIsSignRespon() != null && dto.getIsSignRespon().intValue() == 1) { -// caseAffiliate.setIsSignRespon(1); -// msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); -// if (caseAffiliate.getIsSignApply() != null && caseAffiliate.getIsSignApply().intValue() == 1) { -// // 根据流程id查找下一个流程节点 -// MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); -// caseApplicationselect.setCaseFlowId(nextFlow.getId()); -// caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); -// caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); -// CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), nextFlow.getNodeId(), nextFlow.getCaseStatusName(),"签收"); -// } -// } - - if (dto.getIsSignRespon() != null && dto.getIsSignRespon().intValue() == 1) { - caseAffiliate.setIsSignRespon(1); - msCaseAffiliateMapper.updateByPrimaryKeySelective(caseAffiliate); - - // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); - caseApplicationselect.setCaseFlowId(nextFlow.getId()); - caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); - caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); - CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(),null); + // 被申请操作人 + Optional resAffiliateOpt = msCaseAffiliates.stream().filter(affiliate -> affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))).findFirst(); + ExecutorService executor = ThreadUtil.createThreadPool(); + if (!resAffiliateOpt.isPresent()) { + return AjaxResult.error("案件相关人员不完整"); } + for (MsCaseAffiliate affiliate : msCaseAffiliates) { + // 申请人签收,根据流程id查找下一个流程节点 + if (affiliate.getUserId() != null + && loginUserId.equals(affiliate.getUserId()) + && affiliate.getRoleType() != null && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) { + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); + caseApplicationselect.setCaseFlowId(nextFlow.getId()); + caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); + CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null); + // 发送被申请人签收短信 + CompletableFuture.runAsync(() -> { + MsCaseAffiliate caseAffiliate = resAffiliateOpt.get(); + SysUser sysUser = sysUserMapper.selectUserById(caseAffiliate.getUserId()); + MeetingInfoVO meetingInfoVO = MeetingInfoVO.builder().userId(sysUser.getUserId()).userName(sysUser.getUserName()).caseId(caseApplicationselect.getId()).systemType("TJ").build(); + String roomUuid = shortMessageService.buildMeetingInfoRecord(meetingInfoVO); + if (StrUtil.isNotEmpty(sysUser.getPhonenumber())) { + SmsUtils.sendSms(caseApplicationselect, "2126313", sysUser.getPhonenumber(), new String[]{sysUser.getNickName(), caseApplicationselect.getCaseNum(), "authId=" + roomUuid}); + } else if (StrUtil.isNotEmpty(sysUser.getEmail())) { + String content = "尊敬的" + sysUser.getNickName() + "用户,您的" + caseApplicationselect.getCaseNum() + "文件已发送至邮箱,请点击链接进行确认签收https://txroom.xayunmei.com/#/sign?" + "authId=" + roomUuid + ",如非本人操作,请忽略本短信"; + emailOutUtil.sendMessage(sysUser.getEmail(), "调解系统文件签收", content, null, null); + sendEmail(caseApplicationselect, sysUser, "调解系统文件签收", content); + } + }, executor); + break; + } + + // 被申请人签收 + if (affiliate.getUserId() != null + && loginUserId.equals(affiliate.getUserId()) + && affiliate.getRoleType() != null && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) { + + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); + caseApplicationselect.setCaseFlowId(nextFlow.getId()); + caseApplicationselect.setCaseStatusName(nextFlow.getCaseStatusName()); + caseApplicationMapper.updateByPrimaryKeySelective(caseApplicationselect); + CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), null); + CaseLogUtils.insertCaseLog(caseApplicationselect.getId(), 17, "结束", null); + // 被申请人签收结束对接北明,为调解成功状态 + if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) { + applicationService.pushStatusToBM(caseApplicationselect, PushCaseStatusEnum.SUCCESS); + } + break; + } + } + return AjaxResult.success("签收成功"); @@ -820,59 +530,41 @@ public class MsSignSealServiceImpl implements MsSignSealService { @Override public AjaxResult msCaseSignUrlApplyPC(MsSignSealDTO dto) throws EsignDemoException { Long caseId = dto.getCaseId(); - MsCaseAffiliate caseAffiliate = msCaseAffiliateMapper.selectByPrimaryKey(caseId); - Integer organizeFlag = caseAffiliate.getOrganizeFlag(); - + List affiliates = applicationService.selectAffliatesByCaseId(caseId); + if (CollectionUtil.isEmpty(affiliates)) { + return AjaxResult.error("未找到案件相关人员"); + } + SysUser user = sysUserMapper.selectUserById(SecurityUtils.getLoginUser().getUser().getUserId()); + List roles = user.getRoles(); + if (CollectionUtil.isEmpty(roles)) { + return AjaxResult.error("该用户未绑定角色"); + } + long mediatorCount = roles.stream().filter(sysRole -> sysRole.getRoleName().equals("调解员")).count(); + 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.getUserId() != null + && (msCaseAffiliate.getRoleType() == 1 || msCaseAffiliate.getRoleType() == 2)) + .findFirst(); + resOpt = operatorList.stream().filter(msCaseAffiliate -> msCaseAffiliate.getRoleType() != null && msCaseAffiliate.getUserId() != null + && (msCaseAffiliate.getRoleType() == 3 || msCaseAffiliate.getRoleType() == 4)) + .findFirst(); + } + if (appOpt == null || !appOpt.isPresent()) { + return AjaxResult.error("未找到案件申请操作人"); + } + if (resOpt == null || !resOpt.isPresent()) { + return AjaxResult.error("未找到案件被申请操作人"); + } MsCaseApplication caseApplication = msCaseApplicationMapper.selectByPrimaryKey(caseId); - SysUser user = new SysUser(); Long userId = SecurityUtils.getUserId(); - user.setUserId(userId); - List listSysUser = userMapper.selectUserList(user); - List allSysRole = new ArrayList<>(); - for(SysUser sysUser :listSysUser){ - List roles = sysUser.getRoles(); - allSysRole.addAll(roles); - } - List roleNames = allSysRole.stream().map(SysRole::getRoleName).collect(Collectors.toList()); - if(roleNames.contains("申请人")){ - 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.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); - }else { - return AjaxResult.error(); - } - - - }else if(roleNames.contains("被申请人")){ + if (appOpt.get().getUserId() != null && appOpt.get().getUserId().equals(userId)) { + // 申请人链接 SealSignRecord sealSignRecordres = new SealSignRecord(); MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); mssealSignRecord.setCaseAppliId(caseId); @@ -880,7 +572,38 @@ 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(appOpt.get().getPhone()); + sealSignRecord.setPensonName(appOpt.get().getName()); + sealSignRecord.setSignFlowid(signFlowid); + + Gson gson = new Gson(); + EsignHttpResponse signUrl = SignAward.signUrl(sealSignRecord); + JsonObject signUrlJsonObject = gson.fromJson(signUrl.getBody(), JsonObject.class); + if (signUrlJsonObject.get("data") == null || signUrlJsonObject.get("data").isJsonNull()) { + throw new ServiceException("该用户和流程无关,不能查看当前流程"); + } else { + JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data"); + String urlapply = signUrlData.get("shortUrl").getAsString(); + sealSignRecordres.setSealUrl(urlapply); + } + return AjaxResult.success(sealSignRecordres); + } else { + return AjaxResult.error(); + } + + + } + if (resOpt.get().getUserId() != null && resOpt.get().getUserId().equals(userId)) { + // 被申 + 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(resOpt.get().getPhone()); + sealSignRecord.setPensonName(resOpt.get().getName()); sealSignRecord.setSignFlowid(signFlowid); Gson gson = new Gson(); @@ -890,10 +613,12 @@ public class MsSignSealServiceImpl implements MsSignSealService { String urlapply = signUrlData.get("shortUrl").getAsString(); sealSignRecordres.setSealUrl(urlapply); return AjaxResult.success(sealSignRecordres); - }else { + } else { return AjaxResult.error(); } - }else if(roleNames.contains("调解员")){ + } + if (mediatorCount > 0) { + // 调解员 SealSignRecord sealSignRecordres = new SealSignRecord(); MsSealSignRecord mssealSignRecord = new MsSealSignRecord(); mssealSignRecord.setCaseAppliId(caseId); @@ -903,7 +628,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { SealSignRecord sealSignRecord = new SealSignRecord(); Long arbitratorId = caseApplication.getMediatorId(); - if (arbitratorId!=null) { + if (arbitratorId != null) { SysUser sysUser = sysUserMapper.selectUserById(arbitratorId); if (sysUser == null) { return AjaxResult.error(); @@ -919,7 +644,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { String urlapply = signUrlData.get("shortUrl").getAsString(); sealSignRecordres.setSealUrl(urlapply); return AjaxResult.success(sealSignRecordres); - }else { + } else { return AjaxResult.error(); } @@ -927,95 +652,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) @@ -1023,6 +659,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { JSONObject jsonObjectCallback = JSONObject.parseObject(reqbodystr); Gson gson = new Gson(); if (jsonObjectCallback != null) { + log.info("签名回调======" + jsonObjectCallback); int signResult = jsonObjectCallback.getIntValue("signResult"); String action = jsonObjectCallback.getString("action"); String signFlowId = jsonObjectCallback.getString("signFlowId"); @@ -1056,10 +693,10 @@ public class MsSignSealServiceImpl implements MsSignSealService { MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(caseApplicationselect.getCaseFlowId()); Integer caseNode = currentFlow.getNodeId(); String caseStatusName = currentFlow.getCaseStatusName(); - if("SIGN_MISSON_COMPLETE".equals(action) && signResult==2){ - if(mediaResult.intValue()==1){ + if ("SIGN_MISSON_COMPLETE".equals(action) && signResult == 2) { + if (mediaResult.equals(1)) { //调解 - if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){ + if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountApply)) { //申请人签名 sealSignRecordsel.setSignStatusApply(1); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1070,10 +707,17 @@ public class MsSignSealServiceImpl implements MsSignSealService { operLog.setCaseNode(caseNode); operLog.setCreateTime(dateOperate); caseLogRecordMapper.insert(operLog); - if(signStatusResponse!=null&&signStatusResponse.intValue()==1&& - signStatusMediator!=null&&signStatusMediator.intValue()==1){ + if (signStatusResponse != null && signStatusResponse.equals(1) && + signStatusMediator != null && signStatusMediator.equals(1)) { // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseFlow nextFlow = null; + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag().equals(1)) { + // 需要用印 + nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); + } else { + // 不需要用印 + nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId()); + } MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1081,10 +725,19 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplicationMapper.updateByPrimaryKeySelective(application); //修改"签署用印记录表"的状态为待用印 - sealSignRecordsel.setSignFlowStatus(2); - sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } else { + // 否则为已完成 + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + // 下载调解书 + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); + } + } - }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){ + } else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountRes)) { //被申请人签名 sealSignRecordsel.setSignStatusResponse(1); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1095,10 +748,18 @@ public class MsSignSealServiceImpl implements MsSignSealService { operLog.setCaseNode(caseNode); operLog.setCreateTime(dateOperate); caseLogRecordMapper.insert(operLog); - if(signStatusApply!=null&&signStatusApply.intValue()==1&& - signStatusMediator!=null&&signStatusMediator.intValue()==1){ + if (signStatusApply != null && signStatusApply.equals(1) && + signStatusMediator != null && signStatusMediator.equals(1)) { // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = null; + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + // 需要用印 + nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); + } else { + // 不需要用印 + nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId()); + } MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1106,10 +767,19 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplicationMapper.updateByPrimaryKeySelective(application); //修改"签署用印记录表"的状态为待用印 - sealSignRecordsel.setSignFlowStatus(2); - sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } else { + // 否则为已完成 + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + // 下载调解书 + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); + } + } - }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountMedi)){ + } else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountMedi)) { //调解员签名 sealSignRecordsel.setSignStatusMediator(1); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1120,10 +790,18 @@ public class MsSignSealServiceImpl implements MsSignSealService { operLog.setCaseNode(caseNode); operLog.setCreateTime(dateOperate); caseLogRecordMapper.insert(operLog); - if(signStatusApply!=null&&signStatusApply.intValue()==1&& - signStatusResponse!=null&&signStatusResponse.intValue()==1){ + if (signStatusApply != null && signStatusApply.equals(1) && + signStatusResponse != null && signStatusResponse.equals(1)) { // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + // 根据流程id查找下一个流程节点 + MsCaseFlow nextFlow = null; + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + // 需要用印 + nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); + } else { + // 不需要用印 + nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId()); + } MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1131,10 +809,20 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplicationMapper.updateByPrimaryKeySelective(application); //修改"签署用印记录表"的状态为待用印 - sealSignRecordsel.setSignFlowStatus(2); - sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + if (caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + sealSignRecordsel.setSignFlowStatus(2); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + } else { + // 否则为已完成 + sealSignRecordsel.setSignFlowStatus(3); + sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); + // 下载调解书 + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); + } + } - }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(orgnNamePsnAcc)){ + } else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(orgnNamePsnAcc) && caseApplicationselect.getSealFlag() != null && caseApplicationselect.getSealFlag() == 1) { + //需要用印 sealSignRecordsel.setSealStatus(1); sealSignRecordsel.setSignFlowStatus(3); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1147,7 +835,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseLogRecordMapper.insert(operLog); // 根据流程id查找下一个流程节点 - MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId().intValue()); + MsCaseFlow nextFlow = caseFlowMapper.nextFlow(caseApplicationselect.getCaseFlowId()); MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1155,52 +843,13 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseApplicationMapper.updateByPrimaryKeySelective(application); //下载审核完成的调解书 - EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); - JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); - JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); - JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); - if (filesArray != null && filesArray.size() > 0) { - JsonObject fileObject = (JsonObject) filesArray.get(0); - String fileDownloadUrl = fileObject.get("downloadUrl").toString(); - LocalDate now = LocalDate.now(); - String year = Integer.toString(now.getYear()); - String month = String.format("%02d", now.getMonthValue()); - String day = String.format("%02d", now.getDayOfMonth()); - String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; - String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; -// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; -// String savePath = "/home/ruoyi/uploadPath/upload/"; - String saveName = fileName; - String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); - // 创建日期目录 - File saveFolder = new File(saveFolderPath); - if (!saveFolder.exists()) { - saveFolder.mkdirs(); - } - String resultFilePath = saveFolderPath + "/" + fileName; - File resultFilePathFile = new File(resultFilePath); - if (!resultFilePathFile.exists()) { - resultFilePathFile.createNewFile(); - } - - String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); - boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); - if (downLoadFile) { - MsCaseAttach caseAttach = new MsCaseAttach(); - caseAttach.setCaseAppliId(caseAppliId); - caseAttach.setAnnexType(7); - caseAttach.setAnnexPath(savePath); - caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); - } - - } } - }else if(mediaResult.intValue()==5){ + } else if (mediaResult.equals(5)) { //和解 - if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountApply)){ + if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountApply)) { //申请人签名 sealSignRecordsel.setSignStatusApply(1); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1211,8 +860,8 @@ public class MsSignSealServiceImpl implements MsSignSealService { operLog.setCaseNode(caseNode); operLog.setCreateTime(dateOperate); caseLogRecordMapper.insert(operLog); - if(signStatusResponse!=null&&signStatusResponse.intValue()==1){ - MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId().intValue()); + if (signStatusResponse != null && signStatusResponse.equals(1)) { + MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId()); MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1224,49 +873,74 @@ public class MsSignSealServiceImpl implements MsSignSealService { sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); //下载审核完成的调解书 - EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); - JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); - JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); - JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); - if (filesArray != null && filesArray.size() > 0) { - JsonObject fileObject = (JsonObject) filesArray.get(0); - String fileDownloadUrl = fileObject.get("downloadUrl").toString(); - LocalDate now = LocalDate.now(); - String year = Integer.toString(now.getYear()); - String month = String.format("%02d", now.getMonthValue()); - String day = String.format("%02d", now.getDayOfMonth()); - String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; - String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; -// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; -// String savePath = "/home/ruoyi/uploadPath/upload/"; - String saveName = fileName; - String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; - - // 创建日期目录 - File saveFolder = new File(saveFolderPath); - if (!saveFolder.exists()) { - saveFolder.mkdirs(); - } - String resultFilePath = saveFolderPath + "/" + fileName; - File resultFilePathFile = new File(resultFilePath); - if (!resultFilePathFile.exists()) { - resultFilePathFile.createNewFile(); - } - - String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); - boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); - if (downLoadFile) { - MsCaseAttach caseAttach = new MsCaseAttach(); - caseAttach.setCaseAppliId(caseAppliId); - caseAttach.setAnnexType(7); - caseAttach.setAnnexPath(savePath); - caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); - } - - } + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); +// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); +// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); +// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); +// JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); +// if (filesArray != null && filesArray.size() > 0) { +// JsonObject fileObject = (JsonObject) filesArray.get(0); +// String fileDownloadUrl = fileObject.get("downloadUrl").toString(); +// LocalDate now = LocalDate.now(); +// String year = Integer.toString(now.getYear()); +// String month = String.format("%02d", now.getMonthValue()); +// String day = String.format("%02d", now.getDayOfMonth()); +// String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; +// String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; +// String saveName = fileName; +// String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; +// +// // 创建日期目录 +// File saveFolder = new File(saveFolderPath); +// if (!saveFolder.exists()) { +// saveFolder.mkdirs(); +// } +// String resultFilePath = saveFolderPath + "/" + fileName; +// File resultFilePathFile = new File(resultFilePath); +// if (!resultFilePathFile.exists()) { +// resultFilePathFile.createNewFile(); +// } +// +// String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); +// boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); +// if (downLoadFile) { +// // 先删除已经存在的调解书 +// if(StrUtil.isEmpty(caseApplicationselect.getCaseSource())){ +// List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); +// if(CollectionUtil.isNotEmpty(existAttach)){ +// // 对接北明,同步案件状态,删除 +// for (MsCaseAttach msCaseAttach : existAttach) { +// if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ +// continue; +// } +// beiMingInterfaceService.deleteAttachmentInfo(caseApplicationselect.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); +// } +// } +// } +// msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); +// MsCaseAttach caseAttach = new MsCaseAttach(); +// caseAttach.setCaseAppliId(caseAppliId); +// caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK.getCode()); +// caseAttach.setAnnexPath(savePath); +// caseAttach.setAnnexName(saveName); +// caseAttachMapper.save(caseAttach); +// // 对接北明,调用上传附件接口 +// 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,DocumentTypeEnum.EVEDENT_AGREEMENT); +// // 更新附件表 +// if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ +// caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); +// msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach); +// } +// +// } +// } +// +// } } - }else if(StringUtils.isNotEmpty(accountMobile)&&accountMobile.equals(pensonAccountRes)){ + } else if (StringUtils.isNotEmpty(accountMobile) && accountMobile.equals(pensonAccountRes)) { //被申请人签名 sealSignRecordsel.setSignStatusResponse(1); sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); @@ -1277,8 +951,8 @@ public class MsSignSealServiceImpl implements MsSignSealService { operLog.setCaseNode(caseNode); operLog.setCreateTime(dateOperate); caseLogRecordMapper.insert(operLog); - if(signStatusApply!=null&&signStatusApply.intValue()==1){ - MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId().intValue()); + if (signStatusApply != null && signStatusApply.equals(1)) { + MsCaseFlow nextFlow = caseFlowMapper.nextFlow1(caseApplicationselect.getCaseFlowId()); MsCaseApplication application = new MsCaseApplication(); application.setId(caseApplicationselect.getId()); application.setCaseFlowId(nextFlow.getId()); @@ -1290,58 +964,171 @@ public class MsSignSealServiceImpl implements MsSignSealService { sealSignRecordMapper.updateByPrimaryKeySelective(sealSignRecordsel); //下载审核完成的调解书 - EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); - JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); - JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); - JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); - if (filesArray != null && filesArray.size() > 0) { - JsonObject fileObject = (JsonObject) filesArray.get(0); - String fileDownloadUrl = fileObject.get("downloadUrl").toString(); - LocalDate now = LocalDate.now(); - String year = Integer.toString(now.getYear()); - String month = String.format("%02d", now.getMonthValue()); - String day = String.format("%02d", now.getDayOfMonth()); - String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; - String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; -// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; -// String savePath = "/home/ruoyi/uploadPath/upload/"; - String saveName = fileName; - String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; - - // 创建日期目录 - File saveFolder = new File(saveFolderPath); - if (!saveFolder.exists()) { - saveFolder.mkdirs(); - } - String resultFilePath = saveFolderPath + "/" + fileName; - File resultFilePathFile = new File(resultFilePath); - if (!resultFilePathFile.exists()) { - resultFilePathFile.createNewFile(); - } - - String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); - boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); - if (downLoadFile) { - MsCaseAttach caseAttach = new MsCaseAttach(); - caseAttach.setCaseAppliId(caseAppliId); - caseAttach.setAnnexType(7); - caseAttach.setAnnexPath(savePath); - caseAttach.setAnnexName(saveName); - caseAttachMapper.updateCaseAttachBycaseid(caseAttach); - } - - } + msSignSealService.downloadMediationBook(caseApplicationselect, signFlowId, gson, caseAppliId); +// EsignHttpResponse fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); +// JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); +// JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); +// JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); +// if (filesArray != null && filesArray.size() > 0) { +// JsonObject fileObject = (JsonObject) filesArray.get(0); +// String fileDownloadUrl = fileObject.get("downloadUrl").toString(); +// LocalDate now = LocalDate.now(); +// String year = Integer.toString(now.getYear()); +// String month = String.format("%02d", now.getMonthValue()); +// String day = String.format("%02d", now.getDayOfMonth()); +// String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; +// String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; +// String saveName = fileName; +// String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; +// +// // 创建日期目录 +// File saveFolder = new File(saveFolderPath); +// if (!saveFolder.exists()) { +// saveFolder.mkdirs(); +// } +// String resultFilePath = saveFolderPath + "/" + fileName; +// File resultFilePathFile = new File(resultFilePath); +// if (!resultFilePathFile.exists()) { +// resultFilePathFile.createNewFile(); +// } +// +// String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); +// boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); +// if (downLoadFile) { +// // 先删除已经存在的调解书 +// if(StrUtil.isEmpty(caseApplicationselect.getCaseSource())){ +// List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK.getCode()); +// if(CollectionUtil.isNotEmpty(existAttach)){ +// // 对接北明,同步案件状态,删除 +// for (MsCaseAttach msCaseAttach : existAttach) { +// if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ +// continue; +// } +// beiMingInterfaceService.deleteAttachmentInfo(caseApplicationselect.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); +// +// // 对接北明,调用上传附件接口 +// +// 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,DocumentTypeEnum.EVEDENT_AGREEMENT); +// // 更新附件表 +// if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ +// caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); +// } +// } +// caseAttachMapper.save(caseAttach); +// } +// +// } } } } } - }else{ + } else { return AjaxResult.error("error"); } return AjaxResult.success("success"); } + /** + * 下载调解书 + * + * @param caseApplicationselect + * @param signFlowId + * @param gson + * @param caseAppliId + * @throws EsignDemoException + * @throws IOException + */ + @Transactional + public void downloadMediationBook(MsCaseApplication caseApplicationselect, String signFlowId, Gson gson, Long caseAppliId) { + EsignHttpResponse fileDownload = null; + try { + fileDownload = SaaSAPIFileUtils.fileDownloadUrl(signFlowId); + + JsonObject fileDownloadJsonObject = gson.fromJson(fileDownload.getBody(), JsonObject.class); + JsonObject fileDownloadData = fileDownloadJsonObject.getAsJsonObject("data"); + JsonArray filesArray = fileDownloadData.get("files").getAsJsonArray(); + if (filesArray != null && filesArray.size() > 0) { + JsonObject fileObject = (JsonObject) filesArray.get(0); + String fileDownloadUrl = fileObject.get("downloadUrl").toString(); + LocalDate now = LocalDate.now(); + String year = Integer.toString(now.getYear()); + String month = String.format("%02d", now.getMonthValue()); + String day = String.format("%02d", now.getDayOfMonth()); + String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day; + String fileName = UUID.randomUUID().toString().replace("-", "") + ".pdf"; + String saveName = fileName; + String savePath = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName; + + // 创建日期目录 + File saveFolder = new File(saveFolderPath); + if (!saveFolder.exists()) { + saveFolder.mkdirs(); + } + String resultFilePath = saveFolderPath + "/" + fileName; + File resultFilePathFile = new File(resultFilePath); + if (!resultFilePathFile.exists()) { + resultFilePathFile.createNewFile(); + } + + String fileDownloadUrlnew = fileDownloadUrl.substring(1, fileDownloadUrl.length() - 1); + boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath); + if (downLoadFile) { + // 先删除已经存在的pdf调解书 + if (StrUtil.isEmpty(caseApplicationselect.getCaseSource())) { + List existAttach = msCaseAttachMapper.listCaseAttachByCaseIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode()); + if (CollectionUtil.isNotEmpty(existAttach)) { + // 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if (StrUtil.isEmpty(msCaseAttach.getOtherSysFileId()) || StrUtil.isEmpty(msCaseAttach.getAnnexPath())) { + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(caseApplicationselect.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } + msCaseAttachMapper.deleteCaseAttachByCasedIdAndType(caseAppliId, AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode()); + + MsCaseAttach caseAttach = new MsCaseAttach(); + caseAttach.setCaseAppliId(caseAppliId); + caseAttach.setAnnexType(AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode()); + caseAttach.setAnnexPath(savePath); + caseAttach.setAnnexName(saveName); + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); + caseAttachMapper.save(caseAttach); + // 对接北明,调用上传附件接口 + 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, DocumentTypeEnum.EVEDENT_AGREEMENT); + // 更新附件表 + if (caseFileInfo != null && StrUtil.isNotEmpty(caseFileInfo.getFileId())) { + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + msCaseAttachMapper.updateCaseAttachBycaseid(caseAttach); + } + + } + } + + } + } catch (Exception e) { + throw new ServiceException("E签宝下载调解书失败"); + } + } + + @Override @Transactional(rollbackFor = Exception.class) public AjaxResult sealCheckCallback(String reqbodystr) throws EsignDemoException, IOException { @@ -1369,7 +1156,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { } } - if("SEAL_AUDIT".equals(action) && auditStatus==1){ + if ("SEAL_AUDIT".equals(action) && auditStatus == 1) { EsignHttpResponse response = SignAward.getOrgSeal(orgId, sealId); JSONObject jsonObject = JSONObject.parseObject(response.getBody()); int code = jsonObject.getIntValue("code"); @@ -1403,6 +1190,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode()); //10代表印章图片 caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); int i1 = caseAttachMapper.save(caseAttach); if (i1 > 0) { //将附件id保存到公章管理表里 @@ -1416,7 +1204,7 @@ public class MsSignSealServiceImpl implements MsSignSealService { } } } - }else{ + } else { return AjaxResult.error("error"); } return AjaxResult.success("success"); @@ -1425,40 +1213,66 @@ public class MsSignSealServiceImpl implements MsSignSealService { /** * 通过邮件发送裁决书文件 * - * @param caseApplication1 + * @param caseApplication */ - private boolean sendCaseEmail(MsCaseApplication caseApplication1, String email, List caseAttachList) { + private boolean sendCaseEmail(MsCaseApplication caseApplication, String email, List caseAttachList) { List fileList = new ArrayList<>(); File file = null; + Long fileId = null; + Map fileNameMap = new HashMap<>(); 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); + if (Objects.equals(caseAttach.getAnnexType(), AnnexTypeEnum.MEDIATE_BOOK_PDF.getCode())) { String prefix = "/profile"; int startIndex = prefix.length(); String annexPath = caseAttach.getAnnexPath(); - String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex+1); - // todo 部署放开 + String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex + 1); file = new File(path); fileList.add(file); + fileId = caseAttach.getAnnexId(); + fileNameMap.put(file.getPath(), caseAttach.getAnnexName()); System.out.println("文件长度==================:" + file.length()); } } } + SendMailRecord sendMailRecord = new SendMailRecord(); + sendMailRecord.setCaseId(caseApplication.getId()); + sendMailRecord.setCaseNum(caseApplication.getCaseNum()); + sendMailRecord.setMailAddress(email); + sendMailRecord.setMailContent("您好,审核后的调解书在附件中请查阅"); + sendMailRecord.setMailName("签署后的调解书"); + sendMailRecord.setSendTime(new Date()); + sendMailRecord.setMailSubject("签署后的调解书"); + sendMailRecord.setMailFromAddress(emailFrom); + sendMailRecord.setFileIds(fileId != null ? fileId.toString() : null); +// sendMailRecord.setCreateBy(SecurityUtils.getUsername()); + sendMailRecord.setCreateTime(new Date()); + sendMailRecord.setMailFromAddress(emailFrom); if (file != null && file.exists()) { try { - Boolean aBoolean = emailOutUtil.sendEmil(email, "您好,审核后的调解书在附件中请查阅", "签署后的调解书", fileList, null); + Boolean aBoolean = emailOutUtil.sendEmil(email, "您好,审核后的调解书在附件中请查阅", "签署后的调解书", fileList, null,fileNameMap); if (aBoolean) { + sendMailRecord.setSendStatus(1); + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); + MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord(); + BeanUtils.copyProperties(sendMailRecord, msSendMailHistoryRecord); + msSendMailHistoryRecord.setParentId(sendMailRecord.getId()); + msSendMailHistoryRecord.setId(null); + sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); return Boolean.TRUE; } } catch (Exception e) { System.out.println("邮件发送失败++++++++++++++++++++++++++++++++"); System.out.println(e.toString()); + sendMailRecord.setSendStatus(0); + MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord(); + BeanUtils.copyProperties(sendMailRecord, msSendMailHistoryRecord); + msSendMailHistoryRecord.setParentId(sendMailRecord.getId()); + msSendMailHistoryRecord.setId(null); + sendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); + sendMailRecordMapper.saveSendMailRecord(sendMailRecord); return Boolean.FALSE; } } @@ -1466,212 +1280,4 @@ public class MsSignSealServiceImpl implements MsSignSealService { } - private MsCaseLogRecordVO getNextCaseLogRecord(String nodeName) { - MsCaseLogRecordVO caseLogRecord = new MsCaseLogRecordVO(); - switch (nodeName) { - case "提交案件": - caseLogRecord.setCaseNodeName("提交案件"); - caseLogRecord.setContent("申请人将进行提交案件"); - break; - case "缴费": - caseLogRecord.setCaseNodeName("缴费"); - caseLogRecord.setContent("申请人将进行缴费"); - break; - case "确认缴费": - caseLogRecord.setCaseNodeName("确认缴费"); - caseLogRecord.setContent("财务将进行确认缴费"); - break; - case "受理分配": - caseLogRecord.setCaseNodeName("受理分配"); - caseLogRecord.setContent("法律顾问将进行受理分配"); - break; - case "选择调解员": - caseLogRecord.setCaseNodeName("选择调解员"); - caseLogRecord.setContent("申请人将进行选择调解员"); - break; - case "核实调解员": - caseLogRecord.setCaseNodeName("核实调解员"); - caseLogRecord.setContent("法律顾问将进行核实调解员"); - break; - case "确认调解员": - caseLogRecord.setCaseNodeName("确认调解员"); - caseLogRecord.setContent("部门长将进行确认调解员"); - break; - case "确定调解时间": - caseLogRecord.setCaseNodeName("确定调解时间"); - caseLogRecord.setContent("法律顾问将进行确定调解时间"); - break; - case "调解": - caseLogRecord.setCaseNodeName("调解"); - caseLogRecord.setContent("法律顾问将进行调解"); - break; - case "确认调解书": - caseLogRecord.setCaseNodeName("确认调解书"); - caseLogRecord.setContent("法律顾问将进行确认调解书"); - break; - case "签名": - caseLogRecord.setCaseNodeName("签名"); - caseLogRecord.setContent("申请人、被申请人将进行签名"); - break; - case "用印申请": - caseLogRecord.setCaseNodeName("用印申请"); - caseLogRecord.setContent("法律顾问将进行用印申请"); - break; - case "用印": - caseLogRecord.setCaseNodeName("用印"); - caseLogRecord.setContent("部门长将进行用印"); - break; - case "归档": - caseLogRecord.setCaseNodeName("归档"); - caseLogRecord.setContent("法律顾问将进行提交归档"); - break; - case "签收": - caseLogRecord.setCaseNodeName("签收"); - caseLogRecord.setContent("申请人、被申请人将进行签收"); - break; - case "申请人签收": - caseLogRecord.setCaseNodeName("申请人签收"); - caseLogRecord.setContent("申请人将进行签收"); - break; - case "被申请人签收": - caseLogRecord.setCaseNodeName("被申请人签收"); - caseLogRecord.setContent("被申请人将进行签收"); - break; - case "结束": - caseLogRecord.setCaseNodeName("结束"); - caseLogRecord.setContent("结束"); - break; - default: - caseLogRecord.setNextRoleName("没有下一节点角色"); - - } - return caseLogRecord; - } - - private CaseLogRecord getNextRole(String nodeName) { - CaseLogRecord caseLogRecord = new CaseLogRecord(); - switch (nodeName) { - case "提交案件": - caseLogRecord.setNextRoleName("下一节点角色:申请人"); - break; - case "缴费": - caseLogRecord.setNextRoleName("下一节点角色:申请人"); - break; - case "确认缴费": - caseLogRecord.setNextRoleName("下一节点角色:财务"); - break; - case "受理分配": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "选择调解员": - caseLogRecord.setNextRoleName("下一节点角色:申请人、被申请人"); - break; - case "核实调解员": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "确认调解员": - caseLogRecord.setNextRoleName("下一节点角色:部门长"); - break; - case "确定调解时间": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "调解": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "确认调解书": - caseLogRecord.setNextRoleName("下一节点角色:申请人、被申请人"); - break; - case "签名": - caseLogRecord.setNextRoleName("下一节点角色:申请人、被申请人"); - break; - case "用印申请": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "用印": - caseLogRecord.setNextRoleName("下一节点角色:部门长"); - break; - case "归档": - caseLogRecord.setNextRoleName("下一节点角色:法律顾问"); - break; - case "签收": - caseLogRecord.setNextRoleName("下一节点角色:申请人、被申请人"); - break; - default: - caseLogRecord.setNextRoleName("没有下一节点角色"); - - } - return caseLogRecord; - } - - private CaseLogRecord getInCasenode(String nodeName) { - CaseLogRecord caseLogRecord = new CaseLogRecord(); - switch (nodeName) { - case "提交案件": - caseLogRecord.setCaseNodeName("提交案件"); - caseLogRecord.setContent("申请人正在进行提交案件"); - break; - case "缴费": - caseLogRecord.setCaseNodeName("缴费"); - caseLogRecord.setContent("申请人正在进行缴费"); - break; - case "确认缴费": - caseLogRecord.setCaseNodeName("确认缴费"); - caseLogRecord.setContent("财务正在进行缴费确认"); - break; - case "受理分配": - caseLogRecord.setCaseNodeName("受理分配"); - caseLogRecord.setContent("法律顾问将进行受理分配"); - break; - case "选择调解员": - caseLogRecord.setCaseNodeName("选择调解员"); - caseLogRecord.setContent("申请人正在进行选择调解员"); - break; - case "核实调解员": - caseLogRecord.setCaseNodeName("核实调解员"); - caseLogRecord.setContent("法律顾问正在进行核实调解员"); - break; - case "确认调解员": - caseLogRecord.setCaseNodeName("确认调解员"); - caseLogRecord.setContent("部门长正在进行确认调解员"); - break; - case "调解": - caseLogRecord.setCaseNodeName("调解"); - caseLogRecord.setContent("法律顾问正在进行调解"); - break; - case "确认调解书": - caseLogRecord.setCaseNodeName("确认调解书"); - caseLogRecord.setContent("法律顾问正在进行确认调解书"); - break; - case "签名": - caseLogRecord.setCaseNodeName("签名"); - caseLogRecord.setContent("申请人、被申请人正在进行签名"); - break; - case "用印申请": - caseLogRecord.setCaseNodeName("用印申请"); - caseLogRecord.setContent("法律顾问正在进行确认用印申请"); - break; - case "用印": - caseLogRecord.setCaseNodeName("用印"); - caseLogRecord.setContent("部门长正在进行用印"); - break; - case "归档": - caseLogRecord.setCaseNodeName("归档"); - caseLogRecord.setContent("法律顾问正在进行归档"); - break; - case "签收": - caseLogRecord.setCaseNodeName("签收"); - caseLogRecord.setContent("申请人、被申请人正在进行签收"); - break; - default: - caseLogRecord.setCaseNodeName("无案件状态"); - caseLogRecord.setContent("无操作内容"); - - } - return caseLogRecord; - - } - - - - } 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..297684c 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 @@ -1,7 +1,11 @@ package com.ruoyi.wisdomarbitrate.service.mscase.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.config.RuoYiConfig; @@ -9,19 +13,28 @@ import com.ruoyi.common.core.domain.AjaxResult; 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.DocumentTypeEnum; +import com.ruoyi.common.enums.SMSStatusEnum; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.PdfUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.service.impl.BeiMingInterfaceService; import com.ruoyi.wisdomarbitrate.domain.dto.mscase.ReservedConference; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +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 com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO; +import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo; import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsReservedConferenceVO; +import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAffiliateMapper; import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseApplicationMapper; import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper; import com.ruoyi.wisdomarbitrate.mapper.mscase.ReservedConferenceMapper; +import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; import com.ruoyi.wisdomarbitrate.service.mscase.VideoConferenceService; import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.exception.TencentCloudSDKException; @@ -31,9 +44,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 +52,18 @@ import tk.mybatis.mapper.entity.Example; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import javax.servlet.http.HttpServletRequest; 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.google.common.io.Files.getFileExtension; +import static com.ruoyi.common.core.domain.AjaxResult.error; 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 @@ -80,11 +90,24 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { @Autowired private MsCaseAttachMapper caseAttachMapper; @Autowired + private MsCaseAffiliateMapper caseAffiliateMapper; + @Autowired private SysRoleMapper roleMapper; @Autowired private ReservedConferenceMapper reservedConferenceMapper; @Autowired private SysUserMapper sysUserMapper; + // 北明配置 + @Value("${BMConfig.userName}") + private String BMUserName; + @Value("${BMConfig.password}") + private String BMPassword; + @Value("${BMConfig.syncSource}") + private String BMSyncSource; + @Autowired + BeiMingInterfaceService beiMingInterfaceService; + @Autowired + private SmsRecordMapper smsRecordMapper; /** 视频回调 @@ -130,6 +153,74 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { return success("预约会议成功"); } + @Override + public void smsRollBack(String body, HttpServletRequest request) { + // 解析body + JSONArray jsonArray = JSONUtil.parseArray(body); + if (jsonArray != null && jsonArray.size() > 0) { + for (Object o : jsonArray) { + cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(o); + if (jsonObject.get("sid") != null) { + Object description = jsonObject.get("description"); + System.out.println(description); + // 查询sid对应的短信,更新短信状态 + SmsSendRecord smsSendRecord = smsRecordMapper.selectBySId(jsonObject.getStr("sid")); + if (smsSendRecord != null) { + if (jsonObject.get("report_status") != null && jsonObject.getStr("report_status").equals("SUCCESS")) { + smsSendRecord.setSendStatus(SMSStatusEnum.SUCCESS.getCode()); + } else { + smsSendRecord.setSendStatus(SMSStatusEnum.FAIL.getCode()); + smsSendRecord.setReason(description != null ? description.toString() : null); + } + smsRecordMapper.updateStatus(smsSendRecord); + } + } + } + } + } + + @Override + public AjaxResult selectRoleMenuByCaseId(Long caseId) { + AjaxResult result = success(); + // 根据案件id查询相关人员 + List msCaseAffiliates = caseAffiliateMapper.selectByCaseId(caseId); + if(CollectionUtil.isEmpty(msCaseAffiliates)){ + return error("未找到案件相关人员"); + } + Long userId = SecurityUtils.getUserId(); + if(userId==null){ + return error("未找到当前登录用户"); + } + for (MsCaseAffiliate affiliate : msCaseAffiliates) { + if(affiliate.getOperatorFlag()!=null && affiliate.getOperatorFlag()==1 && affiliate.getUserId()!=null&&affiliate.getUserId().equals(userId)&&affiliate.getRoleType()!=null){ + if(affiliate.getRoleType().equals(1)||affiliate.getRoleType().equals(2)){ + // 申请人操作人 + result.put("appFlag","1"); + } + if(affiliate.getRoleType().equals(3)||affiliate.getRoleType().equals(4)){ + // 被申请人操作人 + result.put("resFlag","1"); + } + } + } + return result; + } + + public static void main(String[] args) { + String body="[{\"mobile\":\"18792927508\",\"report_status\":\"FAIL\",\"description\":\"\\u8FD0\\u8425\\u5546\\u5173\\u952E\\u5B57\\u62E6\\u622A\",\"errmsg\":\"GB:0010\",\"user_receive_time\":\"2024-04-07 14:28:57\",\"sid\":\"9318:147045628317124713319032750\",\"nationcode\":\"86\"}]"; + JSONArray jsonArray = JSONUtil.parseArray(body); + if(jsonArray!=null && jsonArray.size()>0){ + for (Object o : jsonArray) { + cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(o); + if(jsonObject.get("sid")!=null){ + String reportStatus = jsonObject.getStr("report_status"); + String description = jsonObject.getStr("description"); + System.out.println(description); + } + } + } + } + /** * 根据案件id查询已预约的会议 * @@ -373,18 +464,37 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { * @return */ @Override - public AjaxResult secretaryRoleByUserId(Long userId) { + public AjaxResult secretaryRoleByUserId(Long userId, Long caseId) { + // 根据案件id查询案件 + MsCaseApplication caseApplication = caseApplicationMapper.selectByPrimaryKey(caseId); + if(caseApplication==null){ + return AjaxResult.error("案件不存在"); + } List roles = roleMapper.selectRolePermissionByUserId(userId); 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())){ + // 是调解员 + if(CollectionUtil.isNotEmpty(roles)){ + for (SysRole role : roles) { + if("调解员".equals(role.getRoleName())){ + isSecretaryRole=true; + break; + } } } + }else { + // 是调解员 + if(CollectionUtil.isNotEmpty(roles)){ + for (SysRole role : roles) { + if("法律顾问".equals(role.getRoleName())){ + isSecretaryRole=true; + break; + } + } + } } + jsonObject.put("isSecretaryRole",isSecretaryRole); return success(jsonObject); } @@ -397,6 +507,11 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { @Transactional @Override public AjaxResult htmlToPDF(MsReservedConferenceVO reservedConferenceVO) { + // 查询案件 + MsCaseApplication caseApplication = caseApplicationMapper.selectByPrimaryKey(reservedConferenceVO.getCaseId()); + if(caseApplication==null){ + return AjaxResult.error("案件不存在"); + } String currentFileName = System.currentTimeMillis() + ".pdf"; String fileName = null; try { @@ -411,12 +526,36 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { // 绑定案件 if(convertFlag){ // 删除之前的庭审笔录 + if(StrUtil.isEmpty(caseApplication.getCaseSource())){ + List existAttach = caseAttachMapper.listCaseAttachByCaseIdAndType(reservedConferenceVO.getCaseId(), AnnexTypeEnum.MEDIATE.getCode()); + if(CollectionUtil.isNotEmpty(existAttach)){ + // 对接北明,同步案件状态,删除 + for (MsCaseAttach msCaseAttach : existAttach) { + if(StrUtil.isEmpty(msCaseAttach.getOtherSysFileId())||StrUtil.isEmpty(msCaseAttach.getAnnexPath())){ + continue; + } + beiMingInterfaceService.deleteAttachmentInfo(caseApplication.getCaseNum(), msCaseAttach.getOtherSysFileId(), FileUtil.getName(msCaseAttach.getAnnexPath())); + } + } + } caseAttachMapper.deleteCaseAttachByCasedIdAndType(reservedConferenceVO.getCaseId(),AnnexTypeEnum.MEDIATE.getCode()); MsCaseAttach caseAttach = MsCaseAttach.builder().caseAppliId(reservedConferenceVO.getCaseId()) .annexName(currentFileName) .annexPath(fileName) .annexType(AnnexTypeEnum.MEDIATE.getCode()) .build(); + // 对接北明,调用上传附件接口 + + if(StrUtil.isEmpty(caseApplication.getCaseSource()) ) { + 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,DocumentTypeEnum.EVEDENT_MEDIATION_RECORD); + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + } + } + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); caseAttachMapper.save(caseAttach); return AjaxResult.success(); }else { @@ -424,21 +563,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("生成调解笔录成功"); - - - - } /** * 将视频下载到本地 @@ -473,7 +597,21 @@ public class VideoConferenceServiceImpl implements VideoConferenceService { .annexPath(annexName) .annexType(AnnexTypeEnum.MEETING_VIDEO.getCode()) .build(); + // 对接北明,调用上传附件接口 + + if(StrUtil.isEmpty(caseApplication.getCaseSource()) ) { + 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, DocumentTypeEnum.EVEDENT_MEDIATION_VIDEO); + + // 更新附件表 + if(caseFileInfo!=null && StrUtil.isNotEmpty(caseFileInfo.getFileId())){ + caseAttach.setOtherSysFileId(caseFileInfo.getFileId()); + } + } + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); caseAttachMapper.save(caseAttach); + return annexName; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ISendMailRecordService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ISendMailRecordService.java index 063dddc..f5a237e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ISendMailRecordService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/ISendMailRecordService.java @@ -1,15 +1,32 @@ package com.ruoyi.wisdomarbitrate.service.sendrecord; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; import java.util.List; public interface ISendMailRecordService { - + /** + * 查询邮件发送记录 + * + * @param sendMailRecord + * @return + */ List selectSendMailRecordList(SendMailRecord sendMailRecord); + /** + * 编辑邮件记录 + * + * @param sendMailRecord + */ + AjaxResult updateSendMailRecord(SendMailRecord sendMailRecord); - - + /** + * 重新发送邮件 + * + * @param sendMailRecord + * @return + */ + Boolean reSendMailRecord(SendMailRecord sendMailRecord); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/SendMailRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/SendMailRecordServiceImpl.java index 76207f3..da6676b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/SendMailRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sendrecord/impl/SendMailRecordServiceImpl.java @@ -1,12 +1,23 @@ package com.ruoyi.wisdomarbitrate.service.sendrecord.impl; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.EmailOutUtil; +import com.ruoyi.system.domain.entity.shortmessage.MsSendMailHistoryRecord; +import com.ruoyi.system.mapper.shortmessage.MsSendMailHistoryRecordMapper; import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SendMailRecord; +import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseAttach; +import com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseAttachMapper; import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SendMailRecordMapper; import com.ruoyi.wisdomarbitrate.service.sendrecord.ISendMailRecordService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.File; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class SendMailRecordServiceImpl implements ISendMailRecordService { @@ -20,6 +31,81 @@ public class SendMailRecordServiceImpl implements ISendMailRecordService { return records; } + @Autowired + MsSendMailHistoryRecordMapper msSendMailHistoryRecordMapper; + /** + * 编辑邮件记录 + * + * @param sendMailRecord + */ + @Override + public AjaxResult updateSendMailRecord(SendMailRecord sendMailRecord) { + try { + if (sendMailRecord != null && sendMailRecord.getId() != null) { + SendMailRecord old = sendMailRecordMapper.querySendMailRecordById(sendMailRecord.getId()); + MsSendMailHistoryRecord msSendMailHistoryRecord = new MsSendMailHistoryRecord(); + BeanUtils.copyProperties(old, msSendMailHistoryRecord); + msSendMailHistoryRecord.setParentId(old.getId()); + msSendMailHistoryRecord.setId(null); + msSendMailHistoryRecordMapper.insertSelective(msSendMailHistoryRecord); + sendMailRecord.setUpdateTime(new Date()); + sendMailRecordMapper.updateSendMailRecord(sendMailRecord); + return AjaxResult.success("编辑成功"); + } else { + return AjaxResult.error("编辑失败"); + } + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error("编辑失败"); + } + } + @Autowired + private EmailOutUtil emailOutUtil; + @Autowired + MsCaseAttachMapper msCaseAttachMapper; + + /** + * 重新发送邮件 + * + * @param sendMailRecord + * @return + */ + @Override + public Boolean reSendMailRecord(SendMailRecord sendMailRecord) { + List fileList = null; + // 附件名称map,路径-附件名称 + Map fileNameMap=new HashMap<>(); + if (sendMailRecord.getFileIds() != null && sendMailRecord.getFileIds() != "") { + String[] fileIds = sendMailRecord.getFileIds().split(","); + for (int i = 0; i < fileIds.length; i++) { + String fileId = fileIds[i]; + try { + Long id = Long.parseLong(fileId); + MsCaseAttach msCaseAttach = msCaseAttachMapper.queryAnnexById(id); + String annexPath = msCaseAttach.getAnnexPath(); + if (annexPath != null && annexPath != "") { + String prefix = "/profile"; + int startIndex = prefix.length(); + String path = "/home/ruoyi/uploadPath/" + annexPath.substring(startIndex + 1); + File file = new File(path); + fileList.add(file); + fileNameMap.put(file.getPath(), msCaseAttach.getAnnexName()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + Boolean flag = emailOutUtil.sendEmil(sendMailRecord.getMailAddress(), sendMailRecord.getMailContent(), sendMailRecord.getMailSubject(), fileList, null,fileNameMap); + //发送成功后更细邮件记录的发送时间和发送状态 + if (flag) { + sendMailRecord.setSendStatus(1); + sendMailRecord.setSendTime(new java.util.Date()); + sendMailRecord.setUpdateTime(new java.util.Date()); + sendMailRecordMapper.updateSendMailRecord(sendMailRecord); + } + return flag; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java new file mode 100644 index 0000000..c0d60c7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/ShortMessageService.java @@ -0,0 +1,38 @@ +package com.ruoyi.wisdomarbitrate.service.shortmessage; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.ReSendMessageVO; + +import java.util.List; + +public interface ShortMessageService { + public List smsSendRecordList(SmsSendRecord smsSendRecord); + + /** + * 新增发送历史记录 + */ + void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord,List recordParams); + + /** + * 重新发送短信 + * + * @param reSendMessageVO + */ + AjaxResult reSendShortMessage(ReSendMessageVO reSendMessageVO); + + /** + * 根据信息生成加密信息记录 + * + * @param meetingInfoVO + * @return + */ + String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO); + + /** + * 通过UID查询加密信息并解密成明文对象 + */ + Object getMeetingInfo(String uid); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java new file mode 100644 index 0000000..c9bfaf3 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/shortmessage/impl/ShortMessageServiceImpl.java @@ -0,0 +1,277 @@ +package com.ruoyi.wisdomarbitrate.service.shortmessage.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.json.JSONObject; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginBody; +import com.ruoyi.common.enums.SMSStatusEnum; +import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo; +import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord; +import com.ruoyi.system.domain.entity.sms.MsSmsSendHistoryRecordParam; +import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper; +import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendHistoryRecordParamMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendRecordParamMapper; +import com.ruoyi.system.mapper.sms.MsSmsTemplateMapper; +import com.ruoyi.system.mapper.sms.MsSmsTemplateParamMapper; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.MeetingInfoVO; +import com.ruoyi.wisdomarbitrate.domain.vo.shortmessage.ReSendMessageVO; +import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; +import com.ruoyi.wisdomarbitrate.utils.SmsUtils; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.springframework.beans.BeanUtils; +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; + +import java.text.MessageFormat; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class ShortMessageServiceImpl implements ShortMessageService { + @Autowired + MsSmsSendHistoryRecordMapper msSmsSendHistoryRecordMapper; + @Autowired + MeetingInfoMapper meetingInfoMapper; + @Autowired + SmsRecordMapper smsRecordMapper; + @Autowired + MsSmsTemplateMapper templateMapper; + @Autowired + MsSmsTemplateParamMapper templateParamMapper; + @Autowired + MsSmsSendRecordParamMapper recordParamMapper; + @Autowired + MsSmsSendHistoryRecordParamMapper historyRecordParamMapper; + + @Override + public List smsSendRecordList(SmsSendRecord smsSendRecord) { + List records = smsRecordMapper.getSmsSendRecord(smsSendRecord); + if (CollectionUtil.isEmpty(records)) { + return null; + } + List templateIds = records.stream().map(SmsSendRecord::getMsSmsTemplateId).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(templateIds)) { + return records; + } + List ids = records.stream().map(SmsSendRecord::getId).collect(Collectors.toList()); + // 查询记录表参数值 + Example recordParamExam = new Example(MsSmsSendRecordParam.class); + recordParamExam.createCriteria().andIn("smsRecordId", ids); + List recordParams = recordParamMapper.selectByExample(recordParamExam); + if (CollectionUtil.isEmpty(recordParams)) { + return records; + } + // 根据模板id查询模板参数 + Example templateParamExam = new Example(MsSmsTemplateParam.class); + templateParamExam.createCriteria().andIn("smsTemplateId", templateIds); + List templateParams = templateParamMapper.selectByExample(templateParamExam); + if (CollectionUtil.isEmpty(templateParams)) { + return records; + } + // 根据模板id对模板参数分组 + Map> templateParamMap = templateParams.stream().collect(Collectors.groupingBy(MsSmsTemplateParam::getSmsTemplateId)); + + // 根据记录id分组 + Map> recordParamContentMap = new HashMap<>(); + for (MsSmsSendRecordParam recordParam : recordParams) { + List list = recordParamContentMap.get(recordParam.getSmsRecordId()); + if (CollectionUtil.isEmpty(list)) { + list = new ArrayList<>(); + } + list.add(recordParam.getParamValue()); + recordParamContentMap.put(recordParam.getSmsRecordId(), list); + } + // 根据模板id查询模板 + Example templateExam = new Example(MsSmsTemplate.class); + templateExam.createCriteria().andIn("id", templateIds); + List templates = templateMapper.selectByExample(templateExam); + if (CollectionUtil.isEmpty(templates)) { + return records; + } + // 根据主键id获取模板内容 + Map templateMap = templates.stream().collect(Collectors.toMap(MsSmsTemplate::getId, MsSmsTemplate::getContent, (k1, k2) -> k2)); + Map templateIdMap = templates.stream().collect(Collectors.toMap(MsSmsTemplate::getId, MsSmsTemplate::getTemplateId, (k1, k2) -> k2)); + // 组装模板内容 + for (SmsSendRecord record : records) { + if (record.getMsSmsTemplateId() == null) { + continue; + } + if (!templateMap.containsKey(record.getMsSmsTemplateId())) { + continue; + } + + if (!recordParamContentMap.containsKey(record.getId())) { + continue; + } + if (templateIdMap.containsKey(record.getMsSmsTemplateId())) { + record.setTemplateId(templateIdMap.get(record.getMsSmsTemplateId())); + } + String templateContent = templateMap.get(record.getMsSmsTemplateId()); + record.setTemplateContent(templateContent); + List recordParamList = recordParamContentMap.get(record.getId()); + if (recordParamContentMap.containsKey(record.getId()) && templateParamMap.containsKey(record.getMsSmsTemplateId())) { + List templateParamList = templateParamMap.get(record.getMsSmsTemplateId()); + ArrayList copyParamList = new ArrayList<>(); + for (int i = 0; i < templateParamList.size(); i++) { + MsSmsTemplateParam templateParam = templateParamList.get(i); + MsSmsTemplateParam msSmsTemplateParam = new MsSmsTemplateParam(); + msSmsTemplateParam.setParam(templateParam.getParam()); + msSmsTemplateParam.setSmsTemplateId(templateParam.getSmsTemplateId()); + msSmsTemplateParam.setParamName(templateParam.getParamName()); + msSmsTemplateParam.setId(templateParam.getId()); + msSmsTemplateParam.setParamValue(recordParamContentMap.get(record.getId()).get(i)); + copyParamList.add(msSmsTemplateParam); + } + record.setTemplateParams(copyParamList); + + } + // 按顺序替换占位符 + if (CollectionUtil.isNotEmpty(recordParamList)) { + recordParamList.add(0, "0"); + + // 将List转换为String[]数组 + String[] paramArray = recordParamList.toArray(new String[recordParamList.size()]); + String formattedMessage = MessageFormat.format(templateContent, paramArray); + record.setSendContent(formattedMessage); + } + + + } + + return records; + } + + /** + * 新增发送历史记录 + * + * @param smsSendRecord + */ + @Transactional + @Override + public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord, List recordParams) { + if (smsSendRecord != null) { + MsSmsSendHistoryRecord historyRecord = new MsSmsSendHistoryRecord(); + BeanUtils.copyProperties(smsSendRecord, historyRecord); + historyRecord.setId(null); + historyRecord.setParentId(smsSendRecord.getId()); + int i = msSmsSendHistoryRecordMapper.insert(historyRecord); + if (i > 0 && CollectionUtil.isNotEmpty(recordParams)) { + // 新增参数表 + List historyRecordParams = new ArrayList<>(); + for (MsSmsSendRecordParam templateParam : recordParams) { + MsSmsSendHistoryRecordParam recordParam = new MsSmsSendHistoryRecordParam(); + BeanUtils.copyProperties(templateParam, recordParam); + recordParam.setId(null); + recordParam.setSmsRecordHistoryId(historyRecord.getId()); + historyRecordParams.add(recordParam); + } + historyRecordParamMapper.batchInsert(historyRecordParams); + } + } + } + + /** + * 重新发送短信 + * + * @param reSendMessageVO + */ + @Override + public AjaxResult reSendShortMessage(ReSendMessageVO reSendMessageVO) { + if (reSendMessageVO != null && reSendMessageVO.getTemplateId() != null && reSendMessageVO.getPhone() != null && reSendMessageVO.getTemplateParams() != null && reSendMessageVO.getTemplateParams().size() > 0 && reSendMessageVO.getId() != null) { + // 根据id查询短信记录 + SmsSendRecord smsSendRecord = smsRecordMapper.selectById(reSendMessageVO.getId()); + if (smsSendRecord == null) { + return AjaxResult.warn("短信记录不存在"); + } + + SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); + request.setTemplateId(reSendMessageVO.getTemplateId()); + request.setPhone(reSendMessageVO.getPhone()); + List paramsList = reSendMessageVO.getTemplateParams().stream().map(MsSmsTemplateParam::getParamValue).collect(Collectors.toList()); + String[] messageContent = paramsList.toArray(new String[0]); + request.setTemplateParamSet(messageContent); + JSONObject resultObj = SmsUtils.sendSms(request); + smsSendRecord.setSendTime(new Date()); + // 修改sid和状态 + if (resultObj.get("status") != null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())) { + smsSendRecord.setSendStatus(SMSStatusEnum.SENDING.getCode()); + smsSendRecord.setSid(resultObj.get("sid") == null ? null : resultObj.get("sid").toString()); + smsSendRecord.setReason(null); + // 修改 + smsRecordMapper.update(smsSendRecord); + + return AjaxResult.success("重新发送成功"); + } else { + smsSendRecord.setSid(resultObj.get("sid") == null ? null : resultObj.get("sid").toString()); + smsSendRecord.setSendStatus(SMSStatusEnum.FAIL.getCode()); + smsSendRecord.setSid(resultObj.get("reason") == null ? null : resultObj.get("reason").toString()); + // 修改 + smsRecordMapper.update(smsSendRecord); + return AjaxResult.warn("重新发送失败"); + } + } else { + return AjaxResult.warn("参数缺失"); + } + } + + /** + * 根据信息生成加密信息记录 + * + * @param meetingInfoVO + * @return + */ + @Override + public String buildMeetingInfoRecord(MeetingInfoVO meetingInfoVO) { + String uid = UUID.randomUUID().toString().replace("-", ""); + MeetingInfo meetingInfo = MeetingInfo.builder().userId(meetingInfoVO.getUserId()).userName(meetingInfoVO.getUserName()).caseId(meetingInfoVO.getCaseId()).roomId(meetingInfoVO.getRoomId()).systemType(meetingInfoVO.getSystemType()).createTime(new Date()).uid(uid).build(); + meetingInfo.setUid(uid); + meetingInfoMapper.insertSelective(meetingInfo); + return uid; + } + + /** + * 通过UID查询加密信息并解密成明文对象 + * + * @param uid + */ + @Override + public Object getMeetingInfo(String uid) { + MeetingInfoVO result = new MeetingInfoVO(); + MeetingInfo meetingInfo = meetingInfoMapper.selectByPrimaryKey(uid); + if (meetingInfo != null) { + BeanUtils.copyProperties(meetingInfo, result); + if (result != null) { + Map claims = new HashMap<>(); + claims.put("userName", meetingInfo.getUserName()); + claims.put("userId", meetingInfo.getUserId()); + claims.put(Constants.MEETING_KEY, uid); + String createToken = createToken(claims); + result.setToken(createToken); + } + return result; + } + return null; + } + + // 令牌秘钥 + @Value("${token.secret}") + private String secret; + + private String createToken(Map claims) { + String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact(); + return token; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/SMSTemplateService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/SMSTemplateService.java new file mode 100644 index 0000000..7aafddc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/SMSTemplateService.java @@ -0,0 +1,21 @@ +package com.ruoyi.wisdomarbitrate.service.sms; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; + +import java.util.List; + +/** + * @Classname SMSTemplateService + * @Description TODO + * @Version 1.0.0 + * @Date 2024/4/16 11:39 + * @Created wangqiong + */ +public interface SMSTemplateService { + List page(); + + AjaxResult insert(MsSmsTemplate template); + + AjaxResult delete(Long id); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/impl/SMSTemplateServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/impl/SMSTemplateServiceImpl.java new file mode 100644 index 0000000..18cb7d5 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/sms/impl/SMSTemplateServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.wisdomarbitrate.service.sms.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam; +import com.ruoyi.system.mapper.sms.MsSmsTemplateMapper; +import com.ruoyi.system.mapper.sms.MsSmsTemplateParamMapper; +import com.ruoyi.wisdomarbitrate.service.sms.SMSTemplateService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import tk.mybatis.mapper.entity.Example; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Classname SMSTemplateServiceImpl + * @Description TODO + * @Version 1.0.0 + * @Date 2024/4/16 11:40 + * @Created wangqiong + */ +@Service +public class SMSTemplateServiceImpl implements SMSTemplateService { + @Autowired + private MsSmsTemplateMapper templateMapper; + @Autowired + private MsSmsTemplateParamMapper templateParamMapper; + + @Override + public List page() { + // 分页查询模板 + Example templateExam = new Example(MsSmsTemplate.class); + List templates = templateMapper.selectByExample(templateExam); + if(CollectionUtil.isEmpty(templates)){ + return null; + } + + List templateIds = templates.stream().map(MsSmsTemplate::getId).collect(Collectors.toList()); + // 查询参数 + Example templateParamExam = new Example(MsSmsTemplateParam.class); + templateParamExam.createCriteria().andIn("smsTemplateId", templateIds); + List templateParams = templateParamMapper.selectByExample(templateParamExam); + // 根据模板id对模板参数分组 + Map> templateParamMap = templateParams.stream().collect(Collectors.groupingBy(MsSmsTemplateParam::getSmsTemplateId)); + for (MsSmsTemplate template : templates) { + if(templateParamMap.containsKey(template.getId())){ + template.setTemplateParams(templateParamMap.get(template.getId())); + } + } + return templates; + } + + /** + * 新增或者修改 + * @param template + * @return + */ + @Override + public AjaxResult insert(MsSmsTemplate template) { + if(template.getId() == null){ + templateMapper.insert(template); + + }else{ + templateMapper.updateByPrimaryKey(template); + for (MsSmsTemplateParam templateParam : template.getTemplateParams()) { + templateParam.setSmsTemplateId(template.getId()); + } + // todo 先删除 + Example paramExam = new Example(MsSmsTemplateParam.class); + paramExam.createCriteria().andEqualTo("smsTemplateId", template.getId()); + templateParamMapper.deleteByExample(paramExam); + } + // 新增参数表 + if(CollectionUtil.isNotEmpty(template.getTemplateParams())){ + for (MsSmsTemplateParam templateParam : template.getTemplateParams()) { + templateParam.setSmsTemplateId(template.getId()); + } + templateParamMapper.batchInsert(template.getTemplateParams()); + } + return AjaxResult.success(); + } + + @Override + public AjaxResult delete(Long id) { + // 删除 + templateMapper.deleteByPrimaryKey(id); + // 删除参数表 + Example paramExam = new Example(MsSmsTemplateParam.class); + paramExam.createCriteria().andEqualTo("smsTemplateId", id); + templateParamMapper.deleteByExample(paramExam); + return AjaxResult.success(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java index 810b1ec..7721205 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CaseLogUtils.java @@ -28,10 +28,14 @@ public class CaseLogUtils * @param caseNode 案件节点,不能为空 * @param notes 备注 */ - public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes ){ + public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes ){ MsCaseLogRecord operLog = new MsCaseLogRecord(); - // 获取当前的用户 - LoginUser loginUser = SecurityUtils.getLoginUser(); + LoginUser loginUser=null; + try { + loginUser = SecurityUtils.getLoginUser(); + } catch (Exception e) { + loginUser=null; + } if(loginUser!=null) { SysUser sysUser = userMapper.selectUserById(loginUser.getUserId()); operLog.setCreateBy(sysUser.getUserName()); @@ -49,4 +53,24 @@ public class CaseLogUtils operLog.setCreateTime(new Date()); caseLogRecordMapper.insert(operLog); } + /** + * 新增案件日志 + * @param caseAppliId 案件id,不能为空 + * @param caseNode 案件节点,不能为空 + * @param notes 备注 + */ + public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes,Long userId ){ + if(userId==null) + return; + MsCaseLogRecord operLog = new MsCaseLogRecord(); + SysUser sysUser = userMapper.selectUserById(userId); + operLog.setCreateBy(sysUser.getUserName()); + operLog.setCreateNickName(sysUser.getNickName()); + operLog.setCaseStatusName(caseStatusName); + operLog.setCaseAppliId(caseAppliId); + operLog.setCaseNode(caseNode); + operLog.setNotes(notes); + operLog.setCreateTime(new Date()); + caseLogRecordMapper.insert(operLog); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CommonInputStreamResource.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CommonInputStreamResource.java new file mode 100644 index 0000000..7dccb6f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/CommonInputStreamResource.java @@ -0,0 +1,42 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import org.springframework.core.io.InputStreamResource; +import java.io.InputStream; +public class CommonInputStreamResource extends InputStreamResource { + private long length; + private String fileName; + public CommonInputStreamResource(InputStream inputStream, long length, String fileName) { + super(inputStream); + this.length = length; + this.fileName = fileName; + } + + /** + * 覆写父类方法 + * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常 + * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded} + */ + @Override + public String getFilename() { + return fileName; + } + + /** + * 覆写父类 contentLength 方法 + * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件, + * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。 + */ + @Override + public long contentLength() { + long estimate = length; + return estimate == 0 ? 1 : estimate; + } + + public void setLength(long length) { + this.length = length; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java index 8435211..e4320e5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/FixSelectFlowDetailUtils.java @@ -36,6 +36,8 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; +import static com.google.common.io.Files.getFileExtension; + @Component public class FixSelectFlowDetailUtils { @Autowired @@ -121,6 +123,7 @@ public class FixSelectFlowDetailUtils { caseAttach.setAnnexType(AnnexTypeEnum.SEAL_PICTURE.getCode()); //10代表印章图片 caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); int i1 = caseAttachMapper.save(caseAttach); if (i1 > 0) { //将印章信息保存到公章管理表里 @@ -217,6 +220,7 @@ public class FixSelectFlowDetailUtils { caseAttach.setAnnexPath(savePath); caseAttach.setAnnexName(saveName); int i1 = caseAttachMapper.save(caseAttach); + caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath())); if (i1 > 0) { //将附件id保存到公章管理表里 Long annexId1 = caseAttach.getAnnexId(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java index 76bbf20..3db8b3c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SignAward.java @@ -288,12 +288,12 @@ public class SignAward { } /** - * 发起签署 + * 发起带有用印签署 * * @return * @throws EsignDemoException */ - public static EsignHttpResponse createByFileMediation(SealSignRecord sealSignRecord ,List sealIdList) throws EsignDemoException { + public static EsignHttpResponse createByFileSeal(SealSignRecord sealSignRecord ,List sealIdList) throws EsignDemoException { String apiaddr = "/v3/sign-flow/create-by-file"; String fileId = sealSignRecord.getFileid(); @@ -488,6 +488,162 @@ public class SignAward { //发起接口请求 return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false); } + /** + * 发起不带用印签署 + * + * @return + * @throws EsignDemoException + */ + public static EsignHttpResponse createByFileMediation(SealSignRecord sealSignRecord) throws EsignDemoException { + String apiaddr = "/v3/sign-flow/create-by-file"; + + String fileId = sealSignRecord.getFileid(); + String fileName = sealSignRecord.getFilename(); + + String psnAccount = sealSignRecord.getPensonAccount(); + String psnName = sealSignRecord.getPensonName(); + + String psnAccountRes = sealSignRecord.getPensonAccountRes(); + String psnNameRes = sealSignRecord.getPensonNameRes(); + + String psnAccountMedi = sealSignRecord.getPensonAccountMedi(); + String psnNameMedi = sealSignRecord.getPensonNameMedi(); + + + String positionPagepsn = sealSignRecord.getPositionPagepsn(); + double positionXpsn = sealSignRecord.getPositionXpsn(); + double positionYpsn = sealSignRecord.getPositionYpsn(); + + String positionPagepsnRes = sealSignRecord.getPositionPagepsnRes(); + double positionXpsnRes = sealSignRecord.getPositionXpsnRes(); + double positionYpsnRes = sealSignRecord.getPositionYpsnRes(); + + String positionPagepsnMedi = sealSignRecord.getPositionPagepsnMedi(); + double positionXpsnMedi = sealSignRecord.getPositionXpsnMedi(); + double positionYpsnMedi = sealSignRecord.getPositionYpsnMedi(); + + + String jsonParm = "{\n" + + " \"docs\": [\n" + + " {\n" + + " \"fileId\": \"" + fileId + "\",\n" + + " \"fileName\": \"" + fileName + "\"\n" + + " }\n" + + " ],\n" + + " \"signFlowConfig\": {\n" + + " \"signFlowTitle\": \"测试合同\",\n" + + " \"autoStart\": true,\n" + + " \"authConfig\": {\n" + + " \"willingnessAuthModes\": [\n" + + " \"CODE_SMS\"\n" + + " ],\n" + + " \"psnAvailableAuthModes\": [\n" + + " \"PSN_MOBILE3\"\n" + + " ],\n" + + " \"orgAvailableAuthModes\": [\n" + + " \"ORG_LEGALREP\"\n" + + " ]\n" + + " },\n" + + + " \"signConfig\": {\n" + + " \"availableSignClientTypes\": \"1\"\n" + + " },\n" + +// " \"notifyUrl\": \"" + signSealCallbackUrl + "\",\n" + + " \"autoFinish\": true\n" + + " },\n" + + + " \"signers\": [\n" + + " {\n" + + " \"psnSignerInfo\": {\n" + + " \"psnAccount\": \"" + psnAccount + "\",\n" + + " \"psnInfo\": {\n" + + " \"psnName\": \"" + psnName + "\"\n" + + " }\n" + + " },\n" + + " \"signFields\": [\n" + + " {\n" + + " \"fileId\": \"" + fileId + "\",\n" + + " \"normalSignFieldConfig\": {\n" + + " \"autoSign\": false,\n" + + " \"freeMode\": false,\n" + + " \"movableSignField\": false,\n" + + " \"signFieldPosition\": {\n" + + " \"positionPage\": \"" + positionPagepsn + "\",\n" + + " \"positionX\": " + positionXpsn + ",\n" + + " \"positionY\": " + positionYpsn + "\n" + + " },\n" + + " \"signFieldStyle\": 1\n" + + " },\n" + + " \"signFieldType\": 0\n" + + " }\n" + + " ],\n" + + " \"signerType\": 0\n" + + " },\n" + + + " {\n" + + " \"psnSignerInfo\": {\n" + + " \"psnAccount\": \"" + psnAccountRes + "\",\n" + + " \"psnInfo\": {\n" + + " \"psnName\": \"" + psnNameRes + "\"\n" + + " }\n" + + " },\n" + + " \"signFields\": [\n" + + " {\n" + + " \"fileId\": \"" + fileId + "\",\n" + + " \"normalSignFieldConfig\": {\n" + + " \"autoSign\": false,\n" + + " \"freeMode\": false,\n" + + " \"movableSignField\": false,\n" + + " \"signFieldPosition\": {\n" + + " \"positionPage\": \"" + positionPagepsnRes + "\",\n" + + " \"positionX\": " + positionXpsnRes + ",\n" + + " \"positionY\": " + positionYpsnRes + "\n" + + " },\n" + + " \"signFieldStyle\": 1\n" + + " },\n" + + " \"signFieldType\": 0\n" + + " }\n" + + " ],\n" + + " \"signerType\": 0\n" + + " },\n" + + + + " {\n" + + " \"psnSignerInfo\": {\n" + + " \"psnAccount\": \"" + psnAccountMedi + "\",\n" + + " \"psnInfo\": {\n" + + " \"psnName\": \"" + psnNameMedi + "\"\n" + + " }\n" + + " },\n" + + " \"signFields\": [\n" + + " {\n" + + " \"fileId\": \"" + fileId + "\",\n" + + " \"normalSignFieldConfig\": {\n" + + " \"autoSign\": false,\n" + + " \"freeMode\": false,\n" + + " \"movableSignField\": false,\n" + + " \"signFieldPosition\": {\n" + + " \"positionPage\": \"" + positionPagepsnMedi + "\",\n" + + " \"positionX\": " + positionXpsnMedi + ",\n" + + " \"positionY\": " + positionYpsnMedi + "\n" + + " },\n" + + " \"signFieldStyle\": 1\n" + + " },\n" + + " \"signFieldType\": 0\n" + + " }\n" + + " ],\n" + + " \"signerType\": 0\n" + + " }\n" + + " ]\n" + + "}"; + + //请求方法 + EsignRequestType requestType = EsignRequestType.POST; + //生成请求签名鉴权方式的Header + Map header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, false); + //发起接口请求 + return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, false); + } /** * 发起签署 @@ -850,8 +1006,8 @@ public class SignAward { String apiaddr = "/v3/files/" + fileId + "/keyword-positions"; String jsonParm = "{\n" + " \"keywords\": [\n" + - " \"甲方(签字):\",\n" + - " \"乙方(签字):\",\n" + + " \"申请人(签字):\",\n" + + " \"被申请人(签字):\",\n" + " \"调解员(签字):\",\n" + " \"调解机构(盖章):\"\n" + " ]\n" + diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SmsUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SmsUtils.java new file mode 100644 index 0000000..90bbcc1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/SmsUtils.java @@ -0,0 +1,193 @@ +package com.ruoyi.wisdomarbitrate.utils; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; +import cn.hutool.json.JSONObject; +import com.ruoyi.common.enums.SMSStatusEnum; +import com.ruoyi.common.utils.ThreadUtil; +import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam; +import com.ruoyi.system.domain.entity.sms.MsSmsTemplate; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.flow.MsCaseFlowRoleSmsRelatedMapper; +import com.ruoyi.system.mapper.sms.MsSmsSendRecordParamMapper; +import com.ruoyi.system.mapper.sms.MsSmsTemplateMapper; +import com.ruoyi.wisdomarbitrate.domain.dto.sendrecord.SmsSendRecord; +import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication; +import com.ruoyi.wisdomarbitrate.mapper.sendrecord.SmsRecordMapper; +import com.ruoyi.wisdomarbitrate.service.shortmessage.ShortMessageService; +import com.tencentcloudapi.common.Credential; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.sms.v20210111.SmsClient; +import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; +import com.tencentcloudapi.sms.v20210111.models.SendStatus; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import lombok.var; +import tk.mybatis.mapper.entity.Example; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; + +@Slf4j +public class SmsUtils { + //应用id + private static final String SDK_APP_ID = "1400854852"; + //API的SecretId + private static final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp"; + //API的SecretKey + private static final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V"; + //签名内容 + private static final String SIGN_NAME = "乙巢智慧仲裁网"; + private static SmsRecordMapper recordMapper = SpringUtil.getBean(SmsRecordMapper.class); + private static MsSmsSendRecordParamMapper recordParamMapper = SpringUtil.getBean(MsSmsSendRecordParamMapper.class); + private static MsSmsTemplateMapper templateMapper = SpringUtil.getBean(MsSmsTemplateMapper.class); + private static SysUserMapper sysUserMapper = SpringUtil.getBean(SysUserMapper.class); + private static MsCaseFlowRoleSmsRelatedMapper flowRoleRelatedMapper = SpringUtil.getBean(MsCaseFlowRoleSmsRelatedMapper.class); + private static SysRoleMapper roleMapper = SpringUtil.getBean(SysRoleMapper.class); + private static ShortMessageService shortMessageService = SpringUtil.getBean(ShortMessageService.class); + + public static JSONObject sendSms(SendSmsRequest request) { + JSONObject jsonObject = new JSONObject(); + Credential cred = new Credential(SECRET_ID, SECRET_KEY); + + SmsClient client = new SmsClient(cred, "ap-guangzhou"); + + final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest(); + req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()}); + req.setSmsSdkAppId(SDK_APP_ID); + req.setSignName(SIGN_NAME); + req.setTemplateId(request.getTemplateId()); + req.setTemplateParamSet(request.getTemplateParamSet()); + SendSmsResponse res = null; + try { + res = client.SendSms(req); + } catch (TencentCloudSDKException e) { + log.error("发送短信出错:", e); + jsonObject.set("status", SMSStatusEnum.FAIL.getCode()); + jsonObject.set("reason",e.getMessage()); + return jsonObject; + } + SendStatus sendStatus = res.getSendStatusSet()[0]; + log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage()); + + if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())) { + jsonObject.set("status", SMSStatusEnum.SENDING.getCode()); + } else { + jsonObject.set("status", SMSStatusEnum.FAIL.getCode()); + } + jsonObject.set("sid", sendStatus.getSerialNo()); + return jsonObject; + } + + public static void sendSms(MsCaseApplication application, String templateId, String phone, String[] templateParamSet) { + if(application==null||StrUtil.isEmpty(templateId)||StrUtil.isEmpty(phone)||templateParamSet==null||templateParamSet.length==0){ + return; + } + Example templateExam = new Example(MsSmsTemplate.class); + templateExam.createCriteria().andEqualTo("templateId", templateId); + List templates = templateMapper.selectByExample(templateExam); + if (CollectionUtil.isEmpty(templates)) { + return ; + } + MsSmsTemplate template = templates.get(0); + SendSmsRequest request = new SendSmsRequest(phone, templateId, templateParamSet, application.getId()); + Credential cred = new Credential(SECRET_ID, SECRET_KEY); + + SmsClient client = new SmsClient(cred, "ap-guangzhou"); + + final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest(); + req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()}); + req.setSmsSdkAppId(SDK_APP_ID); + req.setSignName(SIGN_NAME); + req.setTemplateId(request.getTemplateId()); + req.setTemplateParamSet(request.getTemplateParamSet()); + sendSms(client,template,application,phone, templateParamSet,req); + } + + + private static void sendSms(SmsClient client,MsSmsTemplate template, MsCaseApplication application, String phone, String[] templateParamSet, com.tencentcloudapi.sms.v20210111.models.SendSmsRequest req) { + SmsSendRecord smsSendRecord=new SmsSendRecord(); + smsSendRecord.setMsSmsTemplateId(template.getId()); + smsSendRecord.setCaseId(application.getId()); + smsSendRecord.setCaseNum(application.getCaseNum()); + smsSendRecord.setSendTime(new Date()); + smsSendRecord.setPhone(phone); + smsSendRecord.setCreateTime(new Date()); +// smsSendRecord.setCreateBy(SecurityUtils.getUsername()); + // SendSmsRequest request = new SendSmsRequest(phone, template.getTemplateId(), templateParamSet, application.getId()); + req.setPhoneNumberSet(new String[]{"+86" + phone}); + req.setTemplateId(template.getTemplateId()); + req.setTemplateParamSet(templateParamSet); + try { + SendSmsResponse res=client.SendSms(req); + SendStatus sendStatus = res.getSendStatusSet()[0]; + if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())) { + smsSendRecord.setSendStatus( SMSStatusEnum.SENDING.getCode()); + } else { + smsSendRecord.setSendStatus(SMSStatusEnum.FAIL.getCode()); + smsSendRecord.setReason(sendStatus.getMessage()); + } + smsSendRecord.setSid(sendStatus.getSerialNo()); + } catch (TencentCloudSDKException e) { + smsSendRecord.setSendStatus(SMSStatusEnum.FAIL.getCode()); + smsSendRecord.setReason(e.getMessage()); + } + int i = recordMapper.saveSmsSendRecord(smsSendRecord); + if(i>0){ + List recordParams=new ArrayList<>(); + for (String paramValue : templateParamSet) { + // 新增参数 + MsSmsSendRecordParam recordParam = new MsSmsSendRecordParam(); + recordParam.setSmsRecordId(smsSendRecord.getId()); + recordParam.setParamValue(paramValue); + recordParams.add(recordParam); + } +// recordParamMapper.batchInsert(recordParams); +// shortMessageService.insertShortMessageHistoryRecord(smsSendRecord,recordParams); + ExecutorService executor = ThreadUtil.createThreadPool(); + CompletableFuture.runAsync(() -> { + recordParamMapper.batchInsert(recordParams); + + }, executor); + // 新增历史记录表 + CompletableFuture.runAsync(() -> { + shortMessageService.insertShortMessageHistoryRecord(smsSendRecord,recordParams); + + }, executor); + + } + } + + /** + * 参数对象 + */ + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class SendSmsRequest { + /** + * 电话 + */ + private String phone; + + /** + * 模板 ID: 必须填写已审核通过的模板 ID + */ + private String templateId; + + /** + * 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 + */ + private String[] templateParamSet; + private Long caseId; + + } +} diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.xml new file mode 100644 index 0000000..d365a87 --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/flow/MsCaseFlowRoleSmsRelatedMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file 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..ab7b82f --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/log/MsRequestLogMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml new file mode 100644 index 0000000..d3bdf9e --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MeetingInfoMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.xml new file mode 100644 index 0000000..f6d79c1 --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSendMailHistoryRecordMapper.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.xml new file mode 100644 index 0000000..03b13cb --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/shortmessage/MsSmsSendHistoryRecordMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.xml new file mode 100644 index 0000000..22fbc51 --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendHistoryRecordParamMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.xml new file mode 100644 index 0000000..17649f5 --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsSendRecordParamMapper.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.xml new file mode 100644 index 0000000..5d8893a --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.xml b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.xml new file mode 100644 index 0000000..05c56c8 --- /dev/null +++ b/ruoyi-system/src/main/resources/com/ruoyi/system/mapper/sms/MsSmsTemplateParamMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ 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..5aa6050 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,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email, status, create_by, + code, + comp_legal_person, + home, + address, + nationality, create_time )values( #{deptId}, @@ -124,6 +131,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{email}, #{status}, #{createBy}, + #{code}, + #{compLegalPerson}, + #{home}, + #{address}, + #{nationality}, sysdate() ); @@ -140,6 +152,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email, status, create_by, + code, + comp_legal_person, + nationality, + home, + address, create_time )values @@ -155,6 +172,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.email}, #{item.status}, #{item.createBy}, + #{item.code}, + #{item.compLegalPerson}, + #{item.nationality}, + #{item.home}, + #{item.address}, sysdate() ) ; @@ -174,6 +196,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" email = #{email}, status = #{status}, update_by = #{updateBy}, + code = #{code}, + comp_legal_person = #{compLegalPerson}, + home = #{home}, + address = #{address}, + nationality = #{nationality}, update_time = sysdate() where dept_id = #{deptId} @@ -203,4 +230,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update ms_sys_dept set del_flag = '2' where dept_id = #{deptId} - \ No newline at end of file + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index 635e6c9..5c51f22 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -108,7 +108,7 @@ left join ms_sys_role_menu rm on m.menu_id = rm.menu_id left join ms_sys_user_role ur on rm.role_id = ur.role_id left join ms_sys_role r on r.role_id = ur.role_id - where m.status = '0' and r.status = '0' and ur.user_id = #{userId} + where m.status = '0' and r.status = '0' and ur.user_id = #{userId} and m.perms is not null and m.perms!='' - where u.user_name = #{userName} and u.del_flag = '0' + where u.user_name = #{userName} and u.del_flag = '0' limit 1 - 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.email = #{email} 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..53d3d2e 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,83 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + \ 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..1d5192b 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,59 @@ + + 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.id = #{req.caseId} + + + + 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..25f5bcb 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/mscase/MsCaseAttachMapper.xml @@ -14,18 +14,20 @@ + + - 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) - VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{useId},#{useAccount},#{sealStatus},#{onlyOfficeFileId}) + 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,suffix) + VALUES (#{caseAppliId}, #{annexName}, #{annexPath},#{annexType},#{note},#{useId},#{useAccount},#{sealStatus},#{onlyOfficeFileId},#{suffix}) - 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) + 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,suffix) VALUES - (#{item.caseAppliId}, #{item.annexName}, #{item.annexPath},#{item.annexType},#{item.note},#{item.useId},#{item.useAccount},#{item.sealStatus},#{item.onlyOfficeFileId}) + (#{item.caseAppliId}, #{item.annexName}, #{item.annexPath},#{item.annexType},#{item.note},#{item.useId},#{item.useAccount},#{item.sealStatus},#{item.onlyOfficeFileId},#{item.suffix}) @@ -59,6 +61,21 @@ + delete from ms_case_attach @@ -109,7 +126,9 @@ update ms_case_attach set + other_sys_file_id=#{otherSysFileId}, case_appli_id= #{caseAppliId} + where annex_id = #{annexId} @@ -125,6 +144,7 @@ update ms_case_attach annex_name = #{annexName}, + other_sys_file_id=#{otherSysFileId}, annex_path = #{annexPath} diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SendMailRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SendMailRecordMapper.xml index 0b38049..db15513 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SendMailRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SendMailRecordMapper.xml @@ -5,22 +5,26 @@ - - - - - - - - + + + + + + + + + + + - SELECT s.id ,s.mail_name ,s.mail_content ,s.mail_address ,s.send_time ,s.case_id ,s.create_time ,s.create_by , - s.update_by ,s.update_time , s.send_status ,c.case_num + s.update_by ,s.update_time , s.send_status ,s.file_ids ,s.mail_subject ,s.mail_from_address ,c.case_num from ms_send_mail_record s left join ms_case_application c - on s.case_id = c.id + on s.case_id = c.id AND c.case_num = #{caseNum} @@ -38,6 +42,9 @@ case_id, send_status, create_by, + file_ids, + mail_subject, + mail_from_address, create_time )values( #{mailName}, @@ -47,15 +54,24 @@ #{caseId}, #{sendStatus}, #{createBy}, + #{fileIds}, + #{mailSubject}, + #{mailFromAddress}, sysdate() ) - - - - - - - - + + update ms_send_mail_record + set + mail_content= #{mailContent} + ,update_time=#{updateTime} + ,send_time=#{sendTime} + ,send_status=#{sendStatus} + where id = #{id} + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SmsRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SmsRecordMapper.xml index cd86434..ec7c6c7 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SmsRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/sendrecord/SmsRecordMapper.xml @@ -7,15 +7,16 @@ + - + @@ -24,18 +25,22 @@ case_num, phone, send_time, - send_content, + ms_sms_template_id, create_by, send_status, + sid, + reason, create_time )values( #{caseId}, #{caseNum}, #{phone}, #{sendTime}, - #{sendContent}, + #{msSmsTemplateId}, #{createBy}, #{sendStatus}, + #{sid}, + #{reason}, sysdate() ) @@ -46,10 +51,11 @@ case_num, phone, send_time, - send_content, + ms_sms_template_id, create_by, send_status, - create_time + create_time, + sid,reason )values ( @@ -57,17 +63,18 @@ #{item.caseNum}, #{item.phone}, #{item.sendTime}, - #{item.sendContent}, + #{item.msSmsTemplateId}, #{item.createBy}, #{item.sendStatus}, - sysdate() + sysdate(),#{sid},#{reason} ) - - select id ,case_appli_id ,case_num ,phone ,send_time ,send_content,send_status + select * from ms_sms_send_record @@ -76,5 +83,40 @@ order by send_time desc + + + + + update ms_sms_send_record + set send_status= #{sendStatus}, + reason=#{reason} + where sid = #{sid} + + + update ms_sms_send_record + + case_appli_id = #{caseId}, + case_num = #{caseNum}, + phone = #{phone}, + + send_time = #{sendTime}, + ms_sms_template_id = #{msSmsTemplateId}, + + send_status = #{sendStatus}, + sid = #{sid}, + reason = #{reason} + + where id = #{id} + + + diff --git a/tkgenerator/src/main/resources/generator/config.properties b/tkgenerator/src/main/resources/generator/config.properties index c0281fb..66e8621 100644 --- a/tkgenerator/src/main/resources/generator/config.properties +++ b/tkgenerator/src/main/resources/generator/config.properties @@ -3,10 +3,10 @@ jdbc.url=jdbc:mysql://121.40.189.20:3306/mediation_system?serverTimezone=Asia/Sh jdbc.user=root jdbc.password=YMzc157# #目标模块项目路径 -targetprojectpath=E:/WorkCode/SH/Mediation-Backend/ruoyi-system +targetprojectpath=D:/WorkCode/TJ/Mediation-Backend/ruoyi-system #模块名称 -moduleName=flow +moduleName=shortmessage #表名 -tableName=ms_case_flow +tableName=encryptend_info #主键 premaryId=id