From e8da0a956dc02f581d5395be375d2cda076ff925 Mon Sep 17 00:00:00 2001 From: zcl <1850427625@qq.com> Date: Sun, 15 Jan 2023 10:39:54 +0800 Subject: [PATCH] =?UTF-8?q?V1.20.0=E7=89=88=E6=9C=AC=E8=BF=AD=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easyink-admin/pom.xml | 16 +- .../com/easyink/EasyWeComApplication.java | 6 +- .../controller/common/CaptchaController.java | 4 +- .../controller/common/CommonController.java | 3 +- .../monitor/SysUserOnlineController.java | 26 ++- .../controller/openapi/UnionIdController.java | 34 ++++ .../system/SysNoticeController.java | 35 ---- .../controller/system/SysUserController.java | 7 +- .../wecom/UpdateIDSecurityController.java | 2 - .../web/controller/wecom/WeAppController.java | 16 -- .../wecom/WeChatContactMappingController.java | 10 - .../wecom/WeChatSideController.java | 1 + .../wecom/WeCommunityGroupSopController.java | 36 ---- .../wecom/WeCommunityH5Controller.java | 14 -- .../WeConversationArchiveController.java | 20 +- .../wecom/WeCustomerController.java | 40 +--- .../wecom/WeCustomerPortraitController.java | 22 +- .../wecom/WeEmpleCodeController.java | 5 +- .../wecom/WeGroupCodeController.java | 6 +- .../controller/wecom/WeGroupController.java | 13 -- .../wecom/WeMaterialController.java | 11 +- .../wecom/WeSensitiveActController.java | 5 +- .../controller/wecom/WeUserController.java | 96 --------- .../wecom/radar/WeRadarChannelController.java | 4 +- .../radar/WeRadarClickRecordController.java | 2 +- .../wecom/radar/WeRadarController.java | 9 +- .../WeRedeemCodeActivityController.java | 5 +- .../src/main/resources/application.yml | 7 +- .../src/main/resources/logback-console.xml | 29 +++ .../src/main/resources/logback-file.xml | 38 ++++ .../src/main/resources/logback-spring.xml | 121 ++--------- .../easyink/common/config/RuoYiConfig.java | 2 +- .../easyink/common/constant/Constants.java | 12 +- .../easyink/common/constant/GenConstants.java | 189 +----------------- .../common/constant/GroupCodeConstants.java | 16 +- .../common/constant/GroupConstants.java | 4 +- .../common/constant/UserConstants.java | 15 +- .../easyink/common/constant/WeConstans.java | 52 +++-- .../constant/WeCorpUpdateIdConstants.java | 27 +-- .../common/constant/radar/RadarConstants.java | 32 +-- .../redeemcode/RedeemCodeConstants.java | 10 +- .../common/core/domain/entity/SysUser.java | 17 +- .../common/core/domain/model/LoginUser.java | 16 +- .../com/easyink/common/enums/ChatType.java | 2 +- .../common/enums/CustomerTrajectoryEnums.java | 34 +--- .../easyink/common/enums/DataScopeEnum.java | 4 + .../com/easyink/common/enums/ResultTip.java | 2 + .../easyink/common/enums/WeExceptionTip.java | 13 -- .../com/easyink/common/filter/XssFilter.java | 4 +- .../com/easyink/common/lock/LockUtil.java | 86 ++------ .../java/com/easyink/common/lock/Locker.java | 10 +- .../easyink/common/lock/RedisLockConfig.java | 7 +- .../service/impl/SysRoleServiceImpl.java | 2 +- .../common/token/SysPermissionService.java | 6 +- .../easyink/common/token/TokenService.java | 16 +- .../com/easyink/common/utils/DateUtils.java | 2 +- .../com/easyink/common/utils/Threads.java | 1 + .../com/easyink/common/utils/XmlUtil.java | 10 +- .../common/utils/file/FileUploadUtils.java | 14 +- .../easyink/common/utils/file/FileUtils.java | 47 ++--- .../common/utils/file/MimeTypeUtils.java | 47 ++++- .../easyink/common/utils/http/HttpUtils.java | 66 +----- .../com/easyink/common/utils/ip/IpUtils.java | 13 +- .../com/easyink/common/utils/sign/Base64.java | 30 +-- .../easyink/common/utils/sign/Md5Utils.java | 10 +- .../utils/wecom/CorpSecretDecryptUtil.java | 109 ++++++++++ .../common/utils/wecom/TicketUtils.java | 17 +- .../quartz/task/GroupChatStatisticTask.java | 115 +---------- .../java/com/easyink/quartz/task/RyTask.java | 28 +-- .../quartz/task/UserBehaviorDataTak.java | 84 +------- .../task/WeOperationsCenterSopTask.java | 10 +- .../easyink/wecom/client/WeUnionIdClient.java | 31 +++ .../wecom/domain/dto/FindWeMaterialDTO.java | 3 + .../dto/customer/resp/GetByUserResp.java | 4 +- .../wecom/domain/dto/message/VideoDTO.java | 1 - .../transfer/TransferResignedCustomerReq.java | 26 ++- .../TransferResignedGroupChatReq.java | 23 ++- .../TransferResignedGroupChatResp.java | 3 +- .../domain/dto/unionid/GetUnionIdDTO.java | 25 +++ .../wecom/domain/req/WePageBaseReq.java | 32 ++- .../wecom/domain/vo/unionid/GetUnionIdVO.java | 44 ++++ .../WeCallBackAddExternalContactImpl.java | 65 ++++-- .../customer/WeCallBackDelFollowUserImpl.java | 5 +- .../interceptor/WeUnionIdInterceptor.java | 106 ++++++++++ .../interceptor/WechatOpenInterceptor.java | 2 +- .../wecom/login/util/LoginTokenService.java | 12 +- .../com/easyink/wecom/mapper/WeTagMapper.java | 3 +- .../moment/WeMomentTaskResultMapper.java | 13 ++ .../mapper/radar/WeRadarChannelMapper.java | 5 +- .../wecom/mapper/radar/WeRadarMapper.java | 3 +- .../service/WeCustomerMessagePushService.java | 7 - .../wecom/service/WeCustomerService.java | 14 +- .../service/WeCustomerTrajectoryService.java | 3 +- .../easyink/wecom/service/WeGroupService.java | 7 + .../easyink/wecom/service/WeUserService.java | 7 + ...tendPropertyMultipleOptionServiceImpl.java | 10 +- .../service/impl/WeAutoConfigServiceImpl.java | 3 + .../impl/WeCorpAccountServiceImpl.java | 2 +- .../WeCustomerExtendPropertyServiceImpl.java | 15 +- .../WeCustomerMessagePushServiceImpl.java | 11 - .../service/impl/WeCustomerServiceImpl.java | 40 +++- .../impl/WeCustomerTrajectoryServiceImpl.java | 23 ++- .../impl/WeGroupCodeActualServiceImpl.java | 19 +- .../service/impl/WeGroupServiceImpl.java | 103 +++++++++- .../service/impl/WeGroupSopV2ServiceImpl.java | 2 +- .../service/impl/WeMaterialServiceImpl.java | 2 +- .../WeOperationsCenterSopServiceImpl.java | 4 +- .../impl/WePresTagGroupTaskServiceImpl.java | 9 +- .../service/impl/WeUserRoleServiceImpl.java | 4 +- .../wecom/service/impl/WeUserServiceImpl.java | 82 +++++++- ...toTagRuleHitCustomerRecordServiceImpl.java | 2 +- ...eAutoTagRuleHitGroupRecordServiceImpl.java | 2 +- ...utoTagRuleHitKeywordRecordServiceImpl.java | 2 +- ...RuleHitKeywordRecordTagRelServiceImpl.java | 4 +- .../moment/WeMomentTaskResultServiceImpl.java | 11 + .../impl/moment/WeMomentTaskServiceImpl.java | 14 +- .../impl/radar/WeRadarChannelServiceImpl.java | 9 +- .../impl/radar/WeRadarServiceImpl.java | 19 +- .../redeemcode/WeRedeemCodeServiceImpl.java | 19 +- .../moment/WeMomentTaskResultService.java | 11 + .../wecom/service/radar/RadarUrlHandler.java | 4 +- .../wecom/utils/AttachmentService.java | 4 +- .../java/com/tencent/wework/FinanceUtils.java | 10 +- .../wecom/WeCustomerExtendPropertyMapper.xml | 2 +- .../mapper/wecom/WeMaterialMapper.xml | 6 +- .../resources/mapper/wecom/WeUserMapper.xml | 4 +- .../wecom/moment/WeMomentTaskResultMapper.xml | 15 ++ .../wecom/radar/WeRadarChannelMapper.xml | 10 +- .../mapper/wecom/radar/WeRadarMapper.xml | 5 +- pom.xml | 22 +- sql/init/easyink.sql | 8 +- sql/update/update-V1.20.0.sql | 7 + 132 files changed, 1381 insertions(+), 1406 deletions(-) create mode 100644 easyink-admin/src/main/java/com/easyink/web/controller/openapi/UnionIdController.java create mode 100644 easyink-admin/src/main/resources/logback-console.xml create mode 100644 easyink-admin/src/main/resources/logback-file.xml create mode 100644 easyink-common/src/main/java/com/easyink/common/utils/wecom/CorpSecretDecryptUtil.java create mode 100644 easyink-wecom/src/main/java/com/easyink/wecom/client/WeUnionIdClient.java create mode 100644 easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/unionid/GetUnionIdDTO.java create mode 100644 easyink-wecom/src/main/java/com/easyink/wecom/domain/vo/unionid/GetUnionIdVO.java create mode 100644 easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WeUnionIdInterceptor.java create mode 100644 easyink-wecom/src/main/resources/mapper/wecom/moment/WeMomentTaskResultMapper.xml create mode 100644 sql/update/update-V1.20.0.sql diff --git a/easyink-admin/pom.xml b/easyink-admin/pom.xml index af90881..4b12edb 100644 --- a/easyink-admin/pom.xml +++ b/easyink-admin/pom.xml @@ -15,8 +15,22 @@ web服务入口 - + + + com.alibaba + transmittable-thread-local + + + + com.ofpay + logback-mdc-ttl + + + + net.logstash.logback + logstash-logback-encoder + org.springframework.boot diff --git a/easyink-admin/src/main/java/com/easyink/EasyWeComApplication.java b/easyink-admin/src/main/java/com/easyink/EasyWeComApplication.java index 07330ca..cce2021 100644 --- a/easyink-admin/src/main/java/com/easyink/EasyWeComApplication.java +++ b/easyink-admin/src/main/java/com/easyink/EasyWeComApplication.java @@ -7,6 +7,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.scheduling.annotation.EnableAsync; /** @@ -18,11 +19,12 @@ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class}) @MapperScan("com.easyink.*.mapper") @ForestScan(basePackages = {"com.easyink.wecom.client", "com.easyink.wecom.wxclient"}) -@EnableAsync +@EnableAsync(proxyTargetClass = true) +@EnableAspectJAutoProxy(exposeProxy = true) public class EasyWeComApplication { public static void main(String[] args) { SpringApplication.run(EasyWeComApplication.class, args); - log.info("\n" + + System.out.println("\n" + " ,----, ,----, \n" + " ,/ .`| ,/ .`| \n" + " .--.--. ,` .' : ,---, ,-.----. ,` .' : .--.--. ,----.. ,----.. ,---,. .--.--. .--.--. \n" + diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/common/CaptchaController.java b/easyink-admin/src/main/java/com/easyink/web/controller/common/CaptchaController.java index 0e05a8a..caa6997 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/common/CaptchaController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/common/CaptchaController.java @@ -64,8 +64,8 @@ public AjaxResult getCode(HttpServletResponse response) { // 生成验证码 if (MATH.equals(captchaType)) { String capText = captchaProducerMath.createText(); - capStr = capText.substring(0, capText.lastIndexOf("@")); - code = capText.substring(capText.lastIndexOf("@") + 1); + capStr = capText.substring(0, capText.lastIndexOf('@')); + code = capText.substring(capText.lastIndexOf('@') + 1); image = captchaProducerMath.createImage(capStr); } else { capStr = code = captchaProducer.createText(); diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/common/CommonController.java b/easyink-admin/src/main/java/com/easyink/web/controller/common/CommonController.java index c1a2bba..717ab98 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/common/CommonController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/common/CommonController.java @@ -5,6 +5,7 @@ import com.easyink.common.constant.Constants; import com.easyink.common.core.domain.AjaxResult; import com.easyink.common.core.domain.FileVo; +import com.easyink.common.exception.CustomException; import com.easyink.common.utils.StringUtils; import com.easyink.common.utils.file.FileUploadUtils; import com.easyink.common.utils.file.FileUtils; @@ -54,7 +55,7 @@ public class CommonController { public void fileDownload(@ApiParam("文件名") String fileName, @ApiParam("是否删除本地文件") Boolean delete, @ApiParam("是否带时间戳") Boolean needTimeStamp, HttpServletResponse response, HttpServletRequest request) { try { if (!FileUtils.isValidFilename(fileName)) { - throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); + throw new CustomException(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); } // 文件名分隔符 uuid_fileName.xlsx -> fileName.xlsx String splitSign = "_"; diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/monitor/SysUserOnlineController.java b/easyink-admin/src/main/java/com/easyink/web/controller/monitor/SysUserOnlineController.java index c9229bf..eb3c087 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/monitor/SysUserOnlineController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/monitor/SysUserOnlineController.java @@ -12,12 +12,12 @@ import com.easyink.common.enums.BusinessType; import com.easyink.common.enums.LogoutReasonEnum; import com.easyink.common.service.ISysUserOnlineService; -import com.easyink.common.utils.StringUtils; import com.easyink.wecom.login.util.LoginTokenService; import com.github.xiaoymin.knife4j.annotations.ApiSupport; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -53,20 +53,18 @@ public TableDataInfo list(@ApiParam("Ip地址") String ipaddr, @A List userOnlineList = new ArrayList<>(); for (String key : keys) { LoginUser user = redisCache.getCacheObject(key); - if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { - if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) { - userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); - } - } else if (StringUtils.isNotEmpty(ipaddr)) { - if (StringUtils.equals(ipaddr, user.getIpaddr())) { - userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); - } - } else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) { - if (StringUtils.equals(userName, user.getUsername())) { - userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); - } + SysUserOnline sysUserOnline = null; + if (StringUtils.isNotBlank(ipaddr) && StringUtils.isNotBlank(userName)) { + sysUserOnline = userOnlineService.selectOnlineByInfo(ipaddr, userName, user); + } else if (StringUtils.isNotBlank(ipaddr)){ + sysUserOnline = userOnlineService.selectOnlineByIpaddr(ipaddr, user); + } else if (StringUtils.isNotBlank(userName)) { + sysUserOnline = userOnlineService.selectOnlineByUserName(userName, user); } else { - userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); + sysUserOnline = userOnlineService.loginUserToUserOnline(user); + } + if (sysUserOnline != null) { + userOnlineList.add(sysUserOnline); } } // 根据登录用户名+ip地址 按登录时间倒序排序后 去重,保留最新登录的信息(同一ip如果没有通过后台登出而是直接关闭浏览器,下次打开浏览器登录后redis若token还没过期,则会有该ip的两个同样登录用户) diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/openapi/UnionIdController.java b/easyink-admin/src/main/java/com/easyink/web/controller/openapi/UnionIdController.java new file mode 100644 index 0000000..0a23a3f --- /dev/null +++ b/easyink-admin/src/main/java/com/easyink/web/controller/openapi/UnionIdController.java @@ -0,0 +1,34 @@ +package com.easyink.web.controller.openapi; + +import com.easyink.common.core.controller.BaseController; +import com.easyink.common.core.domain.AjaxResult; +import com.easyink.common.utils.wecom.CorpSecretDecryptUtil; +import com.easyink.wecom.domain.dto.unionid.GetUnionIdDTO; +import com.easyink.wecom.domain.vo.unionid.GetUnionIdVO; +import com.easyink.wecom.service.WeCustomerService; +import lombok.AllArgsConstructor; +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; + +/** + * 类名: easyink获取unionId 接口 + * + * @author : silver_chariot + * @date : 2023/1/4 14:19 + **/ +@RestController +@RequestMapping("/unionId") +@AllArgsConstructor +public class UnionIdController extends BaseController { + + private final WeCustomerService weCustomerService; + + @PostMapping("/getByExternalUserId") + public AjaxResult getByExternalUserId(@RequestBody GetUnionIdDTO getUnionIdDTO) { + return AjaxResult.success( weCustomerService.getDetailByExternalUserId(getUnionIdDTO) ); + } + + +} diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/system/SysNoticeController.java b/easyink-admin/src/main/java/com/easyink/web/controller/system/SysNoticeController.java index e453160..9f26c17 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/system/SysNoticeController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/system/SysNoticeController.java @@ -25,41 +25,6 @@ @Deprecated public class SysNoticeController extends BaseController { - @PreAuthorize("@ss.hasPermi('system:notice:list')") - @GetMapping("/list") - @ApiOperation("获取通知公告列表") - @Deprecated - public TableDataInfo list(SysNotice notice) { - return getDataTable(new ArrayList<>()); - } - - @PreAuthorize("@ss.hasPermi('system:notice:query')") - @GetMapping(value = "/{noticeId}") - @ApiOperation("根据通知公告编号获取详细信息") - @Deprecated - public AjaxResult getInfo(@PathVariable Long noticeId) { - return AjaxResult.success(); - } - - - @PreAuthorize("@ss.hasPermi('system:notice:add')") - @Log(title = "通知公告", businessType = BusinessType.INSERT) - @PostMapping - @ApiOperation("新增通知公告") - @Deprecated - public AjaxResult add(@Validated @RequestBody SysNotice notice) { - return AjaxResult.success(); - } - - @PreAuthorize("@ss.hasPermi('system:notice:edit')") - @Log(title = "通知公告", businessType = BusinessType.UPDATE) - @PutMapping - @ApiOperation("修改通知公告") - @Deprecated - public AjaxResult edit(@Validated @RequestBody SysNotice notice) { - return AjaxResult.success(); - } - @PreAuthorize("@ss.hasPermi('system:notice:remove')") @Log(title = "通知公告", businessType = BusinessType.DELETE) diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/system/SysUserController.java b/easyink-admin/src/main/java/com/easyink/web/controller/system/SysUserController.java index 8046ead..6a4a1d4 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/system/SysUserController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/system/SysUserController.java @@ -134,12 +134,13 @@ public AjaxResult getInfo(@PathVariable(value = "userId") Long userId) { @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysUser user) { + final String msgPrefix = "新增用户"; if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); + return AjaxResult.error(msgPrefix + user.getUserName() + "'失败,登录账号已存在"); } else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + return AjaxResult.error(msgPrefix+ user.getUserName() + "'失败,手机号码已存在"); } else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { - return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); + return AjaxResult.error(msgPrefix + user.getUserName() + "'失败,邮箱账号已存在"); } user.setCreateBy(LoginTokenService.getUsername()); user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/UpdateIDSecurityController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/UpdateIDSecurityController.java index c9c23ca..2df74e6 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/UpdateIDSecurityController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/UpdateIDSecurityController.java @@ -1,9 +1,7 @@ package com.easyink.web.controller.wecom; import com.easyink.common.core.domain.AjaxResult; -import com.easyink.common.enums.BusinessType; import com.easyink.wecom.service.UpdateIDSecurityService; -import com.sun.org.apache.xpath.internal.operations.Bool; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeAppController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeAppController.java index ebf0007..b2ba7ca 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeAppController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeAppController.java @@ -31,20 +31,4 @@ public AjaxResult list() { return AjaxResult.success(); } - @ApiOperation("添加应用") - @ApiOperationSupport(ignoreParameters = {"id"}) - @PostMapping("/addWeapp") - @Deprecated - public AjaxResult addWeApp(@RequestBody WeApp weApp) { - return AjaxResult.success(); - } - - @ApiOperation("更新应用") - @PutMapping("/updateWeApp") - @Deprecated - public AjaxResult updateWeApp(@RequestBody WeApp weApp) { - return AjaxResult.success(); - } - - } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatContactMappingController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatContactMappingController.java index 9354486..7129b30 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatContactMappingController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatContactMappingController.java @@ -50,16 +50,6 @@ public TableDataInfo list(WeChatContactMapping weChatConta return getDataTable(list); } - /** - * 按客户查询关系映射列表 - */ -// @PreAuthorize("@ss.hasPermi('chat:mapping:listByCustomer')") - @Deprecated - @ApiOperation(value = "按客户查询关系映射列表", httpMethod = "GET") - @GetMapping("/listByCustomer") - public TableDataInfo> listByCustomer() { - return getDataTable(new ArrayList<>()); - } /** * 导出聊天关系映射列表 diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatSideController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatSideController.java index 4597e0f..6b5a2e6 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatSideController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeChatSideController.java @@ -107,6 +107,7 @@ public TableDataInfo materialList(@Validated FindWeMaterialDTO findWeMaterialDTO String corpId = LoginTokenService.getLoginUser().getCorpId(); findWeMaterialDTO.setCorpId(corpId); findWeMaterialDTO.setShowMaterial(WeConstans.DEFAULT_WE_MATERIAL_USING); + findWeMaterialDTO.setUsingFlag(WeConstans.DEFAULT_WE_MATERIAL_USING); findWeMaterialDTO.setIsExpire(WeConstans.MATERIAL_UN_EXPIRE); List weMaterials = weMaterialService.findWeMaterials(findWeMaterialDTO); return getDataTable(weMaterials); diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityGroupSopController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityGroupSopController.java index d7b937f..c587df8 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityGroupSopController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityGroupSopController.java @@ -20,42 +20,6 @@ @Deprecated public class WeCommunityGroupSopController extends BaseController { - /** - * 通过过滤条件获取群sop列表 - * - * @param ruleName 规则名称 - * @param createBy 创建者 - * @param beginTime 创建区间 - 开始时间 - * @param endTime 创建区间 - 结束时间 - * @return 群sop规则列表 - */ - @ApiOperation(value = "通过过滤条件获取群sop列表", httpMethod = "GET") -// @PreAuthorize("@ss.hasPermi('wecom:communityGroupSop:list')") - @GetMapping(path = "/list") - @Deprecated - public TableDataInfo getSopList( - @RequestParam(value = "ruleName") String ruleName, - @RequestParam(value = "createBy") String createBy, - @RequestParam(value = "beginTime") String beginTime, - @RequestParam(value = "endTime") String endTime - ) { - return getDataTable(new ArrayList<>()); - } - - /** - * 新增SOP规则 - * - * @param groupSopDto 更新数据 - * @return 结果 - */ - @ApiOperation(value = "新增SOP规则", httpMethod = "POST") -// @PreAuthorize("@ss.hasPermi('wecom:communityGroupSop:add')") - @PostMapping(path = "/") - @Deprecated - public AjaxResult addGroupSop(@Validated @RequestBody WeGroupSopDTO groupSopDto) { - return AjaxResult.success(); - } - /** * 通过规则id获取sop规则 * diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityH5Controller.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityH5Controller.java index b94f4c8..f822196 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityH5Controller.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCommunityH5Controller.java @@ -106,20 +106,6 @@ public AjaxResult changeStatus(@RequestParam("taskId") Long taskId, @RequestPara return AjaxResult.success(); } - /** - * 用于支持H5页面的名称和关键字检索 - * - * @param word 过滤字符 - * @return 结果 - */ - @GetMapping(path = "/filter") - @ApiOperation("H5页面的名称和关键字检索") - @Deprecated - public TableDataInfo filter(@RequestParam("word") String word) { - return getDataTable(new ArrayList<>()); - } - - @GetMapping("/sopTaskDetail/{emplId}") @ApiOperation("获取员工的SOP任务详情") public TableDataInfo sopTaskDetail(@PathVariable("emplId") String emplId, GetSopTaskDetailDTO getSopTaskDetailDTO) { diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeConversationArchiveController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeConversationArchiveController.java index 17e3b6c..bcfdca3 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeConversationArchiveController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeConversationArchiveController.java @@ -1,8 +1,8 @@ package com.easyink.web.controller.wecom; import com.easyink.common.core.controller.BaseController; +import com.easyink.common.core.domain.AjaxResult; import com.easyink.common.core.domain.ConversationArchiveQuery; -import com.easyink.common.core.page.TableDataInfo; import com.easyink.common.token.TokenService; import com.easyink.common.utils.ServletUtils; import com.easyink.common.utils.StringUtils; @@ -42,12 +42,12 @@ public class WeConversationArchiveController extends BaseController { */ @ApiOperation(value = "获取单聊会话数据接口", httpMethod = "GET") @GetMapping("/getChatContactList") - public TableDataInfo> getChatContactList(ConversationArchiveQuery query) { + public AjaxResult> getChatContactList(ConversationArchiveQuery query) { if (StringUtils.isEmpty(LoginTokenService.getLoginUser().getCorpId())){ - return getDataTable(new ArrayList<>()); + return AjaxResult.success(new ArrayList<>()); } query.setCorpId(LoginTokenService.getLoginUser().getCorpId()); - return getDataTable(weConversationArchiveService.getChatContactList(query)); + return AjaxResult.success(weConversationArchiveService.getChatContactList(query)); } @@ -61,12 +61,12 @@ public TableDataInfo> getChatContactList(Convers */ @ApiOperation(value = "获取群聊会话数据接口", httpMethod = "GET") @GetMapping("/getChatRoomContactList") - public TableDataInfo> getChatRoomContactList(ConversationArchiveQuery query) { + public AjaxResult> getChatRoomContactList(ConversationArchiveQuery query) { if (StringUtils.isEmpty(LoginTokenService.getLoginUser().getCorpId())){ - return getDataTable(new ArrayList<>()); + return AjaxResult.success(new ArrayList<>()); } query.setCorpId(LoginTokenService.getLoginUser().getCorpId()); - return getDataTable(weConversationArchiveService.getChatRoomContactList(query)); + return AjaxResult.success(weConversationArchiveService.getChatRoomContactList(query)); } @@ -78,12 +78,12 @@ public TableDataInfo> getChatRoomContactList(Con */ @ApiOperation(value = "获取全局会话数据接口", httpMethod = "GET") @GetMapping("/getChatAllList") - public TableDataInfo> getChatAllList(ConversationArchiveQuery query) { + public AjaxResult> getChatAllList(ConversationArchiveQuery query) { if (StringUtils.isEmpty(LoginTokenService.getLoginUser().getCorpId())){ - return getDataTable(new ArrayList<>()); + return AjaxResult.success(new ArrayList<>()); } query.setCorpId(LoginTokenService.getLoginUser().getCorpId()); - return getDataTable(weConversationArchiveService.getChatAllList(query, tokenService.getLoginUser(ServletUtils.getRequest()))); + return AjaxResult.success(weConversationArchiveService.getChatAllList(query, tokenService.getLoginUser(ServletUtils.getRequest()))); } } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerController.java index 983a5d2..1a111e9 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerController.java @@ -93,20 +93,6 @@ public AjaxResult sum(WeCustomer weCustomer) { return AjaxResult.success(weCustomerService.weCustomerCount(weCustomer)); } - - /** - * 根据客户ID获取客户 - * - * @return - */ - @PreAuthorize("@ss.hasPermi('customerManage:lossRemind:view') || @ss.hasPermi('customerManage:customer:view')") - @GetMapping("/getCustomersByUserId/{externalUserid}/{userId}") - @ApiOperation("根据客户ID和员工ID获取客户详情") - @Deprecated - public AjaxResult> getCustomersByUserId(@PathVariable String externalUserid, @PathVariable String userId, @ApiParam("对应离职员工的离职时间,不传则获取在职员工客户") Date dimissionTime) { - return AjaxResult.success(); - } - @PreAuthorize("@ss.hasPermi('customerManage:lossRemind:view') || @ss.hasPermi('customerManage:customer:view')") @GetMapping("/getCustomersByUserIdV2/{externalUserid}/{userId}") @ApiOperation("根据客户ID和员工ID获取客户详情V2") @@ -153,19 +139,6 @@ public AjaxResult edit(@Validated @RequestBody EditCustomerDTO dto) { return AjaxResult.success(); } - /** - * 离职分配单个客户 - * - * @param weLeaveAllocateVO - * @return - */ - @PostMapping({"/allocateSingleCustomer"}) - @ApiOperation("离职继承分配") - @Deprecated - public AjaxResult allocateSingleCustomer(@RequestBody WeLeaveAllocateVO weLeaveAllocateVO) { - return AjaxResult.success(); - } - /** * 客户同步接口 * @@ -213,7 +186,7 @@ public AjaxResult makeLabel(@Validated @RequestBody WeMakeCustomerTagVO w public AjaxResult makeLabelbatch(@Validated @RequestBody List weMakeCustomerTag) { LoginUser loginUser = LoginTokenService.getLoginUser(); weMakeCustomerTag.forEach(weMakeCustomerTagVO -> weMakeCustomerTagVO.setCorpId(loginUser.getCorpId())); - weCustomerService.makeLabelbatch(weMakeCustomerTag, loginUser.getUsername()); + weCustomerService.batchMakeLabel(weMakeCustomerTag, loginUser.getUsername()); return AjaxResult.success(); } @@ -234,17 +207,6 @@ public AjaxResult removeLabel(@RequestBody RemoveWeCustomerTagDTO removeW } - /** - * 查询企业微信客户列表(六感) - */ - @Deprecated - @GetMapping("/listConcise") - @ApiOperation("查询企业微信客户列表(六感)") - public TableDataInfo listConcise(WeCustomer weCustomer) { - return getDataTable(new ArrayList<>()); - } - - @ApiOperation("查询客户所属的员工列表") @GetMapping("/listUserByCustomerId/{customerId}") public AjaxResult getCustomerUserList(@PathVariable(value = "customerId") String customerId) { diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerPortraitController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerPortraitController.java index 5614a2a..e43eef9 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerPortraitController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeCustomerPortraitController.java @@ -63,21 +63,6 @@ public AjaxResult findWeCustomerInfo(@NotBlank(message = "外部联系人ID不 return AjaxResult.success(weCustomerService.findCustomerByOperUseridAndCustomerId(externalUserid, userId, LoginTokenService.getLoginUser().getCorpId())); } - - /** - * 客户画像资料更新 - * - * @param weCustomerPortrait - * @return - */ - @ApiOperation("客户画像资料更新") - @PostMapping(value = "/updateWeCustomerInfo") - @Deprecated - public AjaxResult updateWeCustomerInfo(@RequestBody WeCustomerPortrait weCustomerPortrait) { - return AjaxResult.success(); - } - - /** * 获取当前系统所有可用标签 * @@ -169,17 +154,12 @@ public AjaxResult getUnFinishedCount(@ApiParam("跟进人userId") @NotB .eq(WeCustomerTrajectory::getCorpId, loginUser.getCorpId()) .ne(WeCustomerTrajectory::getStatus, CustomerTrajectoryEnums.TodoTaskStatusEnum.DEL.getCode()) .eq(WeCustomerTrajectory::getExternalUserid, externalUserid) - .eq(WeCustomerTrajectory::getTrajectoryType, CustomerTrajectoryEnums.Type.TO_DO.getType()) + .eq(WeCustomerTrajectory::getTrajectoryType, CustomerTrajectoryEnums.Type.TO_DO.getDesc()) .eq(WeCustomerTrajectory::getUserId, userId) .in(WeCustomerTrajectory::getStatus, new String[]{CustomerTrajectoryEnums.TodoTaskStatusEnum.NORMAL.getCode(), CustomerTrajectoryEnums.TodoTaskStatusEnum.INFORMED.getCode()}) )); } - @Override - protected TableDataInfo getDataTable(PageInfo pageInfo) { - return super.getDataTable(pageInfo); - } - /** * 添加或编辑轨迹 * diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeEmpleCodeController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeEmpleCodeController.java index b25c026..6f5d5fc 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeEmpleCodeController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeEmpleCodeController.java @@ -22,7 +22,6 @@ import com.easyink.wecom.service.WeEmpleCodeAnalyseService; import com.easyink.wecom.service.WeEmpleCodeService; import com.easyink.wecom.service.WeEmpleCodeUseScopService; -import com.easyink.wecom.service.WeFlowerCustomerRelService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -51,14 +50,12 @@ public class WeEmpleCodeController extends BaseController { private final WeEmpleCodeService weEmpleCodeService; - private final WeFlowerCustomerRelService weFlowerCustomerRelService; private final WeEmpleCodeUseScopService weEmpleCodeUseScopService; private final WeEmpleCodeAnalyseService weEmpleCodeAnalyseService; @Autowired - public WeEmpleCodeController(WeEmpleCodeService weEmpleCodeService, WeFlowerCustomerRelService weFlowerCustomerRelService, WeEmpleCodeUseScopService weEmpleCodeUseScopService, WeEmpleCodeAnalyseService weEmpleCodeAnalyseService) { + public WeEmpleCodeController(WeEmpleCodeService weEmpleCodeService, WeEmpleCodeUseScopService weEmpleCodeUseScopService, WeEmpleCodeAnalyseService weEmpleCodeAnalyseService) { this.weEmpleCodeService = weEmpleCodeService; - this.weFlowerCustomerRelService = weFlowerCustomerRelService; this.weEmpleCodeUseScopService = weEmpleCodeUseScopService; this.weEmpleCodeAnalyseService = weEmpleCodeAnalyseService; } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupCodeController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupCodeController.java index da7b1ce..d9bd765 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupCodeController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupCodeController.java @@ -10,7 +10,6 @@ import com.easyink.common.utils.DateUtils; import com.easyink.common.utils.StringUtils; import com.easyink.common.utils.file.FileUtils; -import com.easyink.framework.web.service.FileService; import com.easyink.wecom.domain.WeGroupCode; import com.easyink.wecom.domain.WeGroupCodeActual; import com.easyink.wecom.domain.dto.FindWeGroupCodeDTO; @@ -51,13 +50,11 @@ public class WeGroupCodeController extends BaseController { private final WeGroupCodeService groupCodeService; - private final FileService fileService; private final WeCorpAccountService weCorpAccountService; @Autowired - public WeGroupCodeController(WeGroupCodeService groupCodeService, FileService fileService, WeCorpAccountService weCorpAccountService) { + public WeGroupCodeController(WeGroupCodeService groupCodeService, WeCorpAccountService weCorpAccountService) { this.groupCodeService = groupCodeService; - this.fileService = fileService; this.weCorpAccountService = weCorpAccountService; } @@ -164,7 +161,6 @@ public AjaxResult edit(@PathVariable("id") Long id, @RequestBody WeGroupCode weG //员工则保存userId weGroupCode.setUpdateBy(LoginTokenService.getLoginUser().getWeUser().getUserId()); } - ; return toAjax(groupCodeService.edit(weGroupCode)); } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupController.java index c2e8c30..3a2226d 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeGroupController.java @@ -90,19 +90,6 @@ public AjaxResult synchWeGroup() { return AjaxResult.success(WeConstans.SYNCH_TIP); } - /** - * 离职分配单个客户群 - * - * @param weLeaveAllocateVO - * @return - */ - @PostMapping({"/allocateSingleGroup"}) - @ApiOperation("客户离职继承分配") - @Deprecated - public AjaxResult allocateSingleGroup(@RequestBody WeLeaveAllocateVO weLeaveAllocateVO) { - return AjaxResult.success(); - } - /** * 根据员工id获取员工相关群 * diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeMaterialController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeMaterialController.java index 18dc7c3..dc26b2a 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeMaterialController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeMaterialController.java @@ -6,6 +6,8 @@ import com.easyink.common.core.page.TableDataInfo; import com.easyink.common.enums.BusinessType; import com.easyink.common.enums.MediaType; +import com.easyink.common.enums.ResultTip; +import com.easyink.common.exception.CustomException; import com.easyink.wecom.domain.WeMaterial; import com.easyink.wecom.domain.WeMaterialTagEntity; import com.easyink.wecom.domain.dto.*; @@ -16,6 +18,8 @@ import com.easyink.wecom.service.WeMaterialTagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jodd.util.StringUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,6 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.validation.constraints.NotNull; import java.util.List; +import java.util.Optional; /** * 企业微信素材Controller @@ -134,8 +139,12 @@ public AjaxResult temporaryMaterialMediaId(String url, String type, String name) @ApiOperation("web端发送获取素材media_id") public AjaxResult temporaryMaterialMediaIdForWeb(@RequestBody TemporaryMaterialDTO temporaryMaterialDTO) { String corpId = LoginTokenService.getLoginUser().getCorpId(); + Optional mediaType = MediaType.of(temporaryMaterialDTO.getType()); + if(!mediaType.isPresent()){ + throw new CustomException(ResultTip.TIP_MEDIA_TYPE_ERROR); + } WeMediaDTO weMediaDto = materialService.uploadTemporaryMaterial(temporaryMaterialDTO.getUrl(), - MediaType.of(temporaryMaterialDTO.getType()).get().getMediaType() + mediaType.get().getMediaType() , temporaryMaterialDTO.getName(), corpId); return AjaxResult.success(weMediaDto); } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeSensitiveActController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeSensitiveActController.java index 4600821..6266bc1 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeSensitiveActController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeSensitiveActController.java @@ -7,7 +7,6 @@ import com.easyink.common.core.page.TableDataInfo; import com.easyink.common.enums.BusinessType; import com.easyink.common.enums.ResultTip; -import com.easyink.common.token.TokenService; import com.easyink.common.utils.poi.ExcelUtil; import com.easyink.wecom.domain.WeSensitiveAct; import com.easyink.wecom.domain.WeSensitiveActHit; @@ -39,13 +38,11 @@ @Api(tags = "敏感行为管理接口") public class WeSensitiveActController extends BaseController { private final WeSensitiveActService weSensitiveActService; - private final TokenService tokenService; private final WeSensitiveActHitService weSensitiveActHitService; @Autowired - public WeSensitiveActController(@NotNull WeSensitiveActService weSensitiveActService, @NotNull TokenService tokenService, @NotNull WeSensitiveActHitService weSensitiveActHitService) { + public WeSensitiveActController(@NotNull WeSensitiveActService weSensitiveActService, @NotNull WeSensitiveActHitService weSensitiveActHitService) { this.weSensitiveActHitService = weSensitiveActHitService; - this.tokenService = tokenService; this.weSensitiveActService = weSensitiveActService; } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeUserController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeUserController.java index 213ffee..fdff920 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeUserController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/WeUserController.java @@ -195,21 +195,6 @@ public AjaxResult startOrStop(@RequestBody WeUser weUser) { return AjaxResult.success(); } - - /** - * 离职已分配,新接口 - * - * @param weLeaveUserV2VO - * @return - */ - @GetMapping({"/v2/leaveUserAllocateList"}) - @ApiOperation("获取离职已分配离职员工") - @Deprecated - public TableDataInfo leaveUserAllocateListV2(WeLeaveUserV2VO weLeaveUserV2VO) { - startPage(); - return getDataTable(new ArrayList<>()); - } - /** * 离职已分配 V3 * @@ -225,20 +210,6 @@ public TableDataInfo leaveUserAllocateListV3(TransferRes } - /** - * 离职未分配,新接口 - * - * @param weLeaveUserV2VO - * @return - */ - @GetMapping({"/v2/leaveUserNoAllocateList"}) - @ApiOperation("获取离职未分配离职员工") - @Deprecated - public TableDataInfo leaveUserNoAllocateListV2(WeLeaveUserV2VO weLeaveUserV2VO) { - startPage(); - return getDataTable(new ArrayList<>()); - } - @GetMapping("/v3/leaveUserNoAllocateList") @ApiOperation("获取离职未分配离职员工V3") public TableDataInfo leaveUserListV3(@Validated TransferResignedUserListDTO dto) { @@ -247,19 +218,6 @@ public TableDataInfo leaveUserListV3(@Validated Transfer return getDataTable(weUserService.leaveUserListV3(dto)); } - /** - * 离职分配,新接口 - * - * @param weLeaveUserInfoAllocateVo - * @return - */ - @PutMapping({"/v2/allocateLeaveUserAboutData"}) - @ApiOperation("离职继承分配") - @Deprecated - public AjaxResult allocateLeaveUserAboutDataV2(@RequestBody WeLeaveUserInfoAllocateVO weLeaveUserInfoAllocateVo) { - return AjaxResult.success(); - } - /** * 同步成员 * @@ -293,60 +251,6 @@ public AjaxResult deleteUser(@PathVariable String[] ids) { } - /** - * 获取历史分配记录的成员 - * - * @param weAllocateCustomersVo - * @return - */ - @GetMapping({"/getAllocateCustomers"}) - @ApiOperation("获取历史分配记录的成员") - @Deprecated - public TableDataInfo getAllocateCustomers(WeAllocateCustomersVO weAllocateCustomersVo) { - startPage(); - return getDataTable(new ArrayList<>()); - } - - /** - * 获取历史分配记录的成员,新接口 - * - * @param weAllocateCustomersVo - * @return - */ - @GetMapping({"/v2/getAllocateCustomers"}) - @ApiOperation("获取历史分配记录的成员") - @Deprecated - public TableDataInfo getAllocateCustomersV2(WeAllocateCustomersVO weAllocateCustomersVo) { - return getDataTable(new ArrayList<>()); - } - - - /** - * 获取历史分配记录的群 - * @deprecated 已废弃 - * @param weAllocateGroupsVo - * @return - */ - @GetMapping({"/getAllocateGroups"}) - @Deprecated - public TableDataInfo getAllocateGroups(WeAllocateGroupsVO weAllocateGroupsVo) { - return getDataTable(new ArrayList<>()); - } - - /** - * 获取历史分配记录的群,新接口 - * - * @param weAllocateGroupsVo - * @return - */ - @ApiOperation("获取历史分配记录的群") - @GetMapping({"/v2/getAllocateGroups"}) - @Deprecated - public TableDataInfo getAllocateGroupsV2(WeAllocateGroupsVO weAllocateGroupsVo) { - return getDataTable(new ArrayList<>()); - } - - /** * 内部应用获取用户userId * diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarChannelController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarChannelController.java index 3b630c1..1ce2058 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarChannelController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarChannelController.java @@ -42,7 +42,7 @@ public WeRadarChannelController(WeRadarChannelService radarChannelService) { @PostMapping("/add") @ApiOperation("新增雷达渠道") // @PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") - public AjaxResult add(@RequestBody @Validated RadarChannelDTO radarChannelDTO) { + public AjaxResult add(@RequestBody @Validated RadarChannelDTO radarChannelDTO) { radarChannelService.saveRadarChannel(radarChannelDTO); return AjaxResult.success(); } @@ -59,7 +59,7 @@ public TableDataInfo list(SearchRadarChannelDTO radarChannelDT @Log(title = "删除雷达渠道", businessType = BusinessType.DELETE) @DeleteMapping("/remove") @ApiOperation("删除雷达渠道") - public AjaxResult remove(@Validated @RequestBody DeleteRadarChannelDTO deleteDTO) { + public AjaxResult remove(@Validated @RequestBody DeleteRadarChannelDTO deleteDTO) { radarChannelService.batchRemoveRadarChannel(deleteDTO); return AjaxResult.success(); } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarClickRecordController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarClickRecordController.java index c4ea67d..b3c7ef3 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarClickRecordController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarClickRecordController.java @@ -37,7 +37,7 @@ public WeRadarClickRecordController(WeRadarClickRecordService radarClickRecordSe @PostMapping("/add") @ApiOperation("新增雷达点击记录") // @PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") - public AjaxResult add(@RequestBody @Validated RadarClickRecordDTO clickRecordDTO) { + public AjaxResult add(@RequestBody @Validated RadarClickRecordDTO clickRecordDTO) { radarClickRecordService.saveClickRecord(clickRecordDTO); return AjaxResult.success(); } diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarController.java index d6a925f..70e01b3 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/radar/WeRadarController.java @@ -14,7 +14,6 @@ import com.easyink.wecom.domain.dto.radar.SearchRadarDTO; import com.easyink.wecom.domain.vo.radar.WeRadarVO; import com.easyink.wecom.login.util.LoginTokenService; -import com.easyink.wecom.service.radar.WeRadarChannelService; import com.easyink.wecom.service.radar.WeRadarService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -37,19 +36,17 @@ public class WeRadarController extends BaseController { private final WeRadarService weRadarService; - private final WeRadarChannelService radarChannelService; @Autowired - public WeRadarController(WeRadarService weRadarService, WeRadarChannelService radarChannelService) { + public WeRadarController(WeRadarService weRadarService) { this.weRadarService = weRadarService; - this.radarChannelService = radarChannelService; } @Log(title = "新增雷达", businessType = BusinessType.INSERT) @PostMapping("/add") @ApiOperation("新增雷达") //@PreAuthorize("@ss.hasPermi('redeeomCode:activity:add')") - public AjaxResult add(@RequestBody @Validated RadarDTO radarDTO) { + public AjaxResult add(@RequestBody @Validated RadarDTO radarDTO) { radarDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); weRadarService.saveRadar(radarDTO); return AjaxResult.success(); @@ -75,7 +72,7 @@ public AjaxResult get(@RequestParam("id") Long id) { @PutMapping("/update") @ApiOperation("修改雷达") //@PreAuthorize("@ss.hasPermi('redeeomCode:activity:edit')") - public AjaxResult edit(@RequestBody @Validated RadarDTO radarDTO) { + public AjaxResult edit(@RequestBody @Validated RadarDTO radarDTO) { radarDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); weRadarService.updateRadar(radarDTO); return AjaxResult.success(); diff --git a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/redeemcode/WeRedeemCodeActivityController.java b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/redeemcode/WeRedeemCodeActivityController.java index c55ef7d..a60ad0c 100644 --- a/easyink-admin/src/main/java/com/easyink/web/controller/wecom/redeemcode/WeRedeemCodeActivityController.java +++ b/easyink-admin/src/main/java/com/easyink/web/controller/wecom/redeemcode/WeRedeemCodeActivityController.java @@ -10,7 +10,6 @@ import com.easyink.wecom.domain.vo.redeemcode.WeRedeemCodeActivityVO; import com.easyink.wecom.login.util.LoginTokenService; import com.easyink.wecom.service.redeemcode.WeRedeemCodeActivityService; -import com.easyink.wecom.service.redeemcode.WeRedeemCodeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -33,12 +32,10 @@ public class WeRedeemCodeActivityController extends BaseController { private final WeRedeemCodeActivityService weRedeemCodeActivityService; - private final WeRedeemCodeService weRedeemCodeService; @Autowired - public WeRedeemCodeActivityController(WeRedeemCodeActivityService weRedeemCodeActivityService, WeRedeemCodeService weRedeemCodeService) { + public WeRedeemCodeActivityController(WeRedeemCodeActivityService weRedeemCodeActivityService) { this.weRedeemCodeActivityService = weRedeemCodeActivityService; - this.weRedeemCodeService = weRedeemCodeService; } //@PreAuthorize("@ss.hasPermi('wecom:redeemcode:add')") diff --git a/easyink-admin/src/main/resources/application.yml b/easyink-admin/src/main/resources/application.yml index 41896cb..1571cf6 100644 --- a/easyink-admin/src/main/resources/application.yml +++ b/easyink-admin/src/main/resources/application.yml @@ -97,6 +97,7 @@ ruoyi: - /url/** - /wechatopen/appId - /wechatopen/openId + - /unionId/getByExternalUserId - /test/** @@ -119,7 +120,7 @@ logging: file: path: ${LOG_PATH:./logs} max-history: ${LOG_MAX_HISTORY:15} - name: ${LOG_NAME:/wecom.log} + name: ${LOG_NAME:/wecom} # Spring配置 spring: @@ -428,7 +429,9 @@ wechatopen: needTokenUrl: - /cgi-bin/user/info - /wxa/generate_urllink - - /sns/oauth2/access_token + +decrypt: + unionIdKey: ${DECRYPT_UNIONID_KEY:} diff --git a/easyink-admin/src/main/resources/logback-console.xml b/easyink-admin/src/main/resources/logback-console.xml new file mode 100644 index 0000000..10d366d --- /dev/null +++ b/easyink-admin/src/main/resources/logback-console.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + { + "date": "%date{yyyy-MM-dd HH:mm:ss.SSS}", + "level": "%level", + "thread": "%thread", + "fileLine": "%file:%line", + "msg": "%msg" + } + + + + + + + + \ No newline at end of file diff --git a/easyink-admin/src/main/resources/logback-file.xml b/easyink-admin/src/main/resources/logback-file.xml new file mode 100644 index 0000000..472b49a --- /dev/null +++ b/easyink-admin/src/main/resources/logback-file.xml @@ -0,0 +1,38 @@ + + + + ${LOG_PATH}/${LOG_NAME}.log + + + + + + { + "date": "%date{yyyy-MM-dd HH:mm:ss.SSS}", + "level": "%level", + "thread": "%thread", + "fileLine": "%file:%line", + "msg": "%msg" + } + + + + + + ${LOG_PATH:-/log}${LOG_NAME:-/wecom.log}.%d{yyyy-MM-dd}(%i)%d{HH.mm.ss}.gz + ${LOG_MAX_HISTORY:-15} + ${LOG_MAX_SIZE:-100MB} + + + + + 256 + 2048 + true + 3000 + true + + + + \ No newline at end of file diff --git a/easyink-admin/src/main/resources/logback-spring.xml b/easyink-admin/src/main/resources/logback-spring.xml index 4ba876a..48abe1c 100644 --- a/easyink-admin/src/main/resources/logback-spring.xml +++ b/easyink-admin/src/main/resources/logback-spring.xml @@ -1,120 +1,25 @@ - - + logback-spring + + - - - - - - - - ${LOG_PATH}/${LOG_NAME}_Info.log - - ${log.pattern} - - - - INFO - - ACCEPT - - DENY - - - - ${LOG_PATH:-/log}${LOG_NAME:-/Scrm.log}_Info.%d{yyyy-MM-dd}.%i.gz - ${LOG_MAX_HISTORY:-15} - ${LOG_MAX_SIZE:-100MB} - - - - - ${LOG_PATH}/${LOG_NAME}_ERROR.log - - ${log.pattern} - - - - ERROR - - ACCEPT - - DENY - - - - ${LOG_PATH:-/log}${LOG_NAME:-/Scrm.log}_Error.%d{yyyy-MM-dd}.%i.gz - ${LOG_MAX_HISTORY:-15} - ${LOG_MAX_SIZE:-100MB} - - - - - - ${LOG_PATH}/${LOG_NAME}_USER.log - - ${log.pattern} - - - - ${LOG_PATH:-/log}${LOG_NAME:-/Scrm.log}_User.%d{yyyy-MM-dd}.%i.gz - ${LOG_MAX_HISTORY:-15} - ${LOG_MAX_SIZE:-100MB} - - - - - 512 - 4096 - true - true - - + + + - - 512 - 4096 - true - true - - - - 512 - 4096 - true - true - - - - - ${log.pattern} - - UTF-8 - - - - - - - - + + + + - - - - + + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/easyink-common/src/main/java/com/easyink/common/config/RuoYiConfig.java b/easyink-common/src/main/java/com/easyink/common/config/RuoYiConfig.java index 2816a7c..6a41cf0 100644 --- a/easyink-common/src/main/java/com/easyink/common/config/RuoYiConfig.java +++ b/easyink-common/src/main/java/com/easyink/common/config/RuoYiConfig.java @@ -46,7 +46,7 @@ public class RuoYiConfig { /** * 企业微信账号登录系统默认密码 */ - private String weUserDefaultPwd = "123456"; + private String weUserDefaultPwd; private FileConfig file; diff --git a/easyink-common/src/main/java/com/easyink/common/constant/Constants.java b/easyink-common/src/main/java/com/easyink/common/constant/Constants.java index 59eb4c4..ec339e6 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/Constants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/Constants.java @@ -240,7 +240,17 @@ private Constants(){} /** * 初始化的菜单权限的菜单ID */ - public static final Long[] INIT_MENU_LIST = {2016L, 2014L, 2015L, 2022L, 2074L, 2020L, 2021L, 2002L, 2003L, 2001L, 2079L, 2080L}; + protected static final Long[] INIT_MENU_LIST = new Long[]{2016L, 2014L, 2015L, 2022L, 2074L, 2020L, 2021L, 2002L, 2003L, 2001L, 2079L, 2080L}; + + /** + * 获取初始化菜单权限的菜单ID + * + * @return INIT_MENU_LIST + */ + public static Long[] getInitMenuList(){ + return INIT_MENU_LIST; + } + /** * 默认排序 */ diff --git a/easyink-common/src/main/java/com/easyink/common/constant/GenConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/GenConstants.java index 255446d..cf0bb78 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/GenConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/GenConstants.java @@ -1,191 +1,21 @@ package com.easyink.common.constant; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * 代码生成通用常量 * * @author admin */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class GenConstants { - /** - * 单表(增删改查) - */ - public static final String TPL_CRUD = "crud"; - - /** - * 树表(增删改查) - */ - public static final String TPL_TREE = "tree"; - - /** - * 主子表(增删改查) - */ - public static final String TPL_SUB = "sub"; - - /** - * 树编码字段 - */ - public static final String TREE_CODE = "treeCode"; - - /** - * 树父编码字段 - */ - public static final String TREE_PARENT_CODE = "treeParentCode"; - - /** - * 树名称字段 - */ - public static final String TREE_NAME = "treeName"; - - /** - * 上级菜单ID字段 - */ - public static final String PARENT_MENU_ID = "parentMenuId"; - - /** - * 上级菜单名称字段 - */ - public static final String PARENT_MENU_NAME = "parentMenuName"; - - /** - * 数据库字符串类型 - */ - public static final String[] COLUMNTYPE_STR = {"char", "varchar", "narchar", "varchar2", "tinytext", "text", - "mediumtext", "longtext"}; - - /** - * 数据库文本类型 - */ - public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; - /** - * 数据库时间类型 - */ - public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; - - /** - * 数据库数字类型 - */ - public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", - "bigint", "float", "float", "double", "decimal"}; - - /** - * 页面不需要编辑字段 - */ - public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"}; - - /** - * 页面不需要显示的列表字段 - */ - public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by", - "update_time"}; - - /** - * 页面不需要查询字段 - */ - public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", - "update_time", "remark"}; - - /** - * Entity基类字段 - */ - public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"}; - - /** - * Tree基类字段 - */ - public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"}; - - /** - * 文本框 - */ - public static final String HTML_INPUT = "input"; - - /** - * 文本域 - */ - public static final String HTML_TEXTAREA = "textarea"; - - /** - * 下拉框 - */ - public static final String HTML_SELECT = "select"; - - /** - * 单选框 - */ - public static final String HTML_RADIO = "radio"; - - /** - * 复选框 - */ - public static final String HTML_CHECKBOX = "checkbox"; - - /** - * 日期控件 - */ - public static final String HTML_DATETIME = "datetime"; - - /** - * 图片上传控件 - */ - public static final String HTML_IMAGE_UPLOAD = "imageUpload"; - - /** - * 文件上传控件 - */ - public static final String HTML_FILE_UPLOAD = "fileUpload"; - - /** - * 富文本控件 - */ - public static final String HTML_EDITOR = "editor"; - - /** - * 字符串类型 - */ - public static final String TYPE_STRING = "String"; - - /** - * 整型 - */ - public static final String TYPE_INTEGER = "Integer"; - - /** - * 长整型 - */ - public static final String TYPE_LONG = "Long"; - - /** - * 浮点型 - */ - public static final String TYPE_DOUBLE = "Double"; - - /** - * 高精度计算类型 - */ - public static final String TYPE_BIGDECIMAL = "BigDecimal"; - - /** - * 时间类型 - */ - public static final String TYPE_DATE = "Date"; - /** - * 模糊查询 - */ - public static final String QUERY_LIKE = "LIKE"; - - /** - * 需要 - */ - public static final String REQUIRE = "1"; /** * limit 1 */ public static final String LIMIT_1 = "LIMIT 1"; - /** - * 操作人占位符 - */ - public static final String OPERATOR = "${operator}"; + /** * 群聊名称占位符 */ @@ -202,14 +32,7 @@ public class GenConstants { * 员工名称占位符 */ public static final String USER_NAME = "${userName}"; - /** - * 图片url占位符 - */ - public static final String PIC_URL = "${picUrl}"; - /** - * 属性值占位符 - */ - public static final String PROPERTY_VALUE = "${propertyValue}"; + /** * 雷达标题占位符 */ diff --git a/easyink-common/src/main/java/com/easyink/common/constant/GroupCodeConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/GroupCodeConstants.java index 16465dc..2f4e14a 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/GroupCodeConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/GroupCodeConstants.java @@ -1,37 +1,41 @@ package com.easyink.common.constant; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * 群活码常量 * * @author tigger * 2022/2/10 10:34 **/ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class GroupCodeConstants { /** * 群二维码人数上限 */ - public final static int ACTUAL_GROUP_NUM_LIMIT = 200; + public static final int ACTUAL_GROUP_NUM_LIMIT = 200; /** * 群二维码人数默认值 */ - public final static int DEFAULT_GROUP_NUM = 100; + public static final int DEFAULT_GROUP_NUM = 100; /** * 企业微信群活码人数上限 */ - public final static int CORP_ACTUAL_GROUP_NUM_LIMIT = 1000; + public static final int CORP_ACTUAL_GROUP_NUM_LIMIT = 1000; /** * 企业微信活码人数默认值 */ - public final static int DEFAULT_CORP_GROUP_NUM = CORP_ACTUAL_GROUP_NUM_LIMIT; + public static final int DEFAULT_CORP_GROUP_NUM = CORP_ACTUAL_GROUP_NUM_LIMIT; /** * com.easyink.wecom.domain.WeGroupCodeCorpActual#scene */ - public final static int MINIPROGRAM_SCENE = 1; - public final static int GROUP_SCENE = 2; + public static final int MINIPROGRAM_SCENE = 1; + public static final int GROUP_SCENE = 2; /** diff --git a/easyink-common/src/main/java/com/easyink/common/constant/GroupConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/GroupConstants.java index 42154e7..c714b7c 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/GroupConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/GroupConstants.java @@ -14,8 +14,8 @@ public class GroupConstants { /** * 1-代表群聊成员是员工 2-代码群聊成员是客户 */ - private static final Integer ID_TYPE_USER = 1; - private static final Integer ID_TYPE_CUSTOMER = 2; + public static final Integer ID_TYPE_USER = 1; + public static final Integer ID_TYPE_CUSTOMER = 2; public static final Integer MAX_ALLOCATE_GROUP = 300; diff --git a/easyink-common/src/main/java/com/easyink/common/constant/UserConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/UserConstants.java index 284a80f..ddb049e 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/UserConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/UserConstants.java @@ -1,10 +1,14 @@ package com.easyink.common.constant; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * 用户常量信息 * * @author admin */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class UserConstants { /** * 平台内系统用户的唯一标志 @@ -150,6 +154,15 @@ public class UserConstants { /** * 系统默认字段 */ - public static final String[] SYS_DEFAULT_PROPERTIES = {"客户", "备注", "来源", "添加时间", "所属员工", "标签", "所属部门", "客户状态", "出生日期", "电话", "邮箱", "地址", "描述"}; + protected static final String[] SYS_DEFAULT_PROPERTIES = {"客户", "备注", "来源", "添加时间", "所属员工", "标签", "所属部门", "客户状态", "出生日期", "电话", "邮箱", "地址", "描述"}; + + /** + * 获取系统默认字段 + * + * @return SYS_DEFAULT_PROPERTIES + */ + public static String[] getSysDefaultProperties(){ + return SYS_DEFAULT_PROPERTIES; + } } diff --git a/easyink-common/src/main/java/com/easyink/common/constant/WeConstans.java b/easyink-common/src/main/java/com/easyink/common/constant/WeConstans.java index 6d64295..3fa973c 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/WeConstans.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/WeConstans.java @@ -398,8 +398,8 @@ public enum corpUserEnum { ACTIVE_STATE_FOUR(4, "未激活"), ACTIVE_STATE_FIVE(5, "成员退出"); - private Integer key; - private String value; + private final Integer key; + private final String value; /** * 构造方法 @@ -408,25 +408,18 @@ public enum corpUserEnum { * @param value */ corpUserEnum(int key, String value) { - this.setKey(key); - this.setValue(value); + this.key = key; + this.value = value; } public Integer getKey() { return key; } - public void setKey(Integer key) { - this.key = key; - } - public String getValue() { return value; } - public void setValue(String value) { - this.value = value; - } } @@ -438,8 +431,8 @@ public enum sendMessageStatusEnum { RECEIVE_OTHER_MESSAGE("3", "-因客户已经收到其他群发消息导致发送失败"), ; - private String status; - private String desc; + private final String status; + private final String desc; /** * 构造方法 @@ -811,30 +804,45 @@ public static String getWeActualGroupCodeKey(String actualId) { */ public static final Long SUBSCRIBE_EXPIRE_TIME = 60L; + /** + * 朋友圈 + */ + public static final String MOMENTS = "【朋友圈】"; + + /** + * 提醒内容:您有一条发送朋友圈的任务 + */ + public static final String REMIND_SEND_MOMENTS = "提醒内容:您有一条发送朋友圈的任务"; + + /** + * 创建时间:{0} + */ + public static final String CREATE_TIME = "创建时间:{0}"; + /** * 个人朋友圈消息模板 */ - public static final String PERSONAL_MOMENT_MSG = "【朋友圈】\n" + + public static final String PERSONAL_MOMENT_MSG = MOMENTS + "\n" + "\n" + - "提醒内容:您有一条发送朋友圈的任务\n" + + REMIND_SEND_MOMENTS + "\n" + "\n" + - "创建时间:{0}\n" + + CREATE_TIME + "\n" + "\n" + "{1}"; - public static final String ENTERPRISE_MOMENT_USER_MSG = "【朋友圈】\n" + + public static final String ENTERPRISE_MOMENT_USER_MSG = MOMENTS + "\n" + "\n" + - "提醒内容:您有一条发送朋友圈的任务\n" + + REMIND_SEND_MOMENTS + "\n" + "\n" + - "创建时间:{0}\n" + + CREATE_TIME + "\n" + "\n" + "请从企业微信APP前往【客户朋友圈】确认发送,记得及时完成喔!"; - public static final String PERSONAL_MOMENT_USER_MSG = "【朋友圈】\n" + + public static final String PERSONAL_MOMENT_USER_MSG = MOMENTS + "\n" + "\n" + - "提醒内容:您有一条发送朋友圈的任务\n" + + REMIND_SEND_MOMENTS + "\n" + "\n" + - "创建时间:{0}\n" + + CREATE_TIME + "\n" + "\n" + "{1}"; public static final String MOMENT_NO_CUSTOMER ="该员工没有需触达客户"; diff --git a/easyink-common/src/main/java/com/easyink/common/constant/WeCorpUpdateIdConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/WeCorpUpdateIdConstants.java index efc1a32..a77d16b 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/WeCorpUpdateIdConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/WeCorpUpdateIdConstants.java @@ -1,7 +1,9 @@ package com.easyink.common.constant; import io.swagger.annotations.ApiModel; +import lombok.AccessLevel; import lombok.Data; +import lombok.NoArgsConstructor; /** @@ -12,13 +14,14 @@ */ @Data @ApiModel("企业微信帐号ID安全性全面升级常量") +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class WeCorpUpdateIdConstants { /** * 存储corpId的表 * */ - public static String CORP_ID_LIST = + public static final String CORP_ID_LIST = " - we_corp_account\n" + " - order_group_to_order_customer\n" + " - order_user_to_order_account\n" + @@ -97,7 +100,7 @@ public class WeCorpUpdateIdConstants { * 要更新的表|修改的列名 * 要更新的表|修改的列名|条件 */ - public static String USER_ID_LIST = + public static final String USER_ID_LIST = " - we_group,owner\n" + " - order_user_to_order_account,user_id\n" + " - we_auto_tag_rule_hit_customer_record_tag_rel,we_auto_tag_rule_hit_customer_record,rule_id,rule_id,user_id\n" + @@ -157,7 +160,7 @@ public class WeCorpUpdateIdConstants { * 要更新的表|修改的列名|条件 * */ - public static String EXTERNAL_USER_ID_LIST = + public static final String EXTERNAL_USER_ID_LIST = " - we_operations_center_sop_detail,target_id\n" + " - we_redeem_code,we_redeem_code_activity,activity_id,id,receive_user_id\n" + " - we_auto_tag_rule_hit_customer_record,customer_id\n" + @@ -183,46 +186,46 @@ public class WeCorpUpdateIdConstants { * 代开发应用设置迁移完成openid_type参数 * 为1时升级userid与corpid 只能同时设置为升级模式 */ - public static Integer MIGRATION_USER_ID_AND_CORP_ID = 1; + public static final Integer MIGRATION_USER_ID_AND_CORP_ID = 1; /** * 代开发应用设置迁移完成openid_type参数 * 为2时升级external_userid 可以单独升级 */ - public static Integer MIGRATION_EXTERNAL_USER_ID = 3; + public static final Integer MIGRATION_EXTERNAL_USER_ID = 3; /** * 空时间 */ - public static String EMPTY_TIME = "0000-00-00 00:00:00"; + public static final String EMPTY_TIME = "0000-00-00 00:00:00"; /** * 数字0 */ - public static Integer ZERO_NUM = 0; + public static final Integer ZERO_NUM = 0; /** * corpId以wpI开头 */ - public static String CORP_START_WITH = "wpI"; + public static final String CORP_START_WITH = "wpI"; /** * 更新企业失败 */ - public static String UPDATE_CORP_FAIL = "更新企业失败: "; + public static final String UPDATE_CORP_FAIL = "更新企业失败: "; /** * 获取corpIdList */ - public static String GET_CORP_ID_LIST = "corpIdList"; + public static final String GET_CORP_ID_LIST = "corpIdList"; /** * 获取corpIdList */ - public static String GET_USER_ID_LIST = "userIdList"; + public static final String GET_USER_ID_LIST = "userIdList"; /** * 获取corpIdList */ - public static String GET_EXTERNAL_USER_ID_LIST = "externalUserIdList"; + public static final String GET_EXTERNAL_USER_ID_LIST = "externalUserIdList"; } diff --git a/easyink-common/src/main/java/com/easyink/common/constant/radar/RadarConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/radar/RadarConstants.java index e573e46..6f3aa30 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/radar/RadarConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/radar/RadarConstants.java @@ -1,7 +1,9 @@ package com.easyink.common.constant.radar; import com.easyink.common.enums.radar.RadarChannelEnum; -import com.easyink.common.utils.StringUtils; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; /** * ClassName: RadarConstants @@ -9,12 +11,14 @@ * @author wx * @date 2022/7/18 17:30 */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class RadarConstants { /** * 参数校验异常 */ + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class ParamVerify { /** * 传输参数为空 @@ -25,6 +29,7 @@ public static class ParamVerify { /** * 提示客户,自定义抛出异常给前端使用 */ + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class PromptCus { /** * 未选择标签 @@ -43,6 +48,7 @@ public static class PromptCus { /** * 新增/更新通知员工 */ + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class UpdateNoticeToUser { /** * 发送消息,企业雷达库已更新 @@ -54,14 +60,15 @@ public static class UpdateNoticeToUser { */ public static final String DEPARTMENT_RADAR_UPDATE = "部门雷达库已更新"; - // “{雷达标题}” - public static final String getUpdateMessage(String title) { - return "“{" + title + "}”"; + // “雷达标题” + public static String getUpdateMessage(String title) { + return "“" + title + "”"; } public static final String SEND_ALL = "@all"; } + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class RadarAnalyseCount { /** * 如果不传日期默认为7天的数据 @@ -77,30 +84,29 @@ public static class RadarAnalyseCount { /** * 客户点击记录 */ + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class RadarCustomerClickRecord { - public static String COMMON_MSG = "普通欢迎语"; + public static final String COMMON_MSG = "普通欢迎语"; - public static String EMPTY_USERID = StringUtils.EMPTY; - - public static String EMPTY_SCENARIO = StringUtils.EMPTY; + public static final String EMPTY_SCENARIO = ""; /** * 替换渠道来源内容 */ - public static String REPlACR_WORD = "【替换内容】"; + public static final String REPlACE_WORD = "【替换内容】"; public static String getRecordText(String customerName, String userName, String detail, int type, String channelName) { - String msg = "客户“" + customerName + "”" + "点击了员工“" + userName + "”" + "在【" + RadarChannelEnum.getChannelByType(type) + REPlACR_WORD + "】发出的雷达链接"; + String msg = "客户“" + customerName + "”" + "点击了员工“" + userName + "”" + "在【" + RadarChannelEnum.getChannelByType(type) + REPlACE_WORD + "】发出的雷达链接"; if (RadarChannelEnum.CUSTOMIZE.getTYPE().equals(type)) { - return msg.replace(REPlACR_WORD, "-{" + channelName + "}"); + return msg.replace(REPlACE_WORD, "-{" + channelName + "}"); } if (StringUtils.isNotBlank(detail) && !RadarChannelEnum.MOMENT.getTYPE().equals(type) && !RadarChannelEnum.SIDE_BAR.getTYPE().equals(type) && !RadarChannelEnum.WELCOME_MSG.getTYPE().equals(type)) { - return msg.replace(REPlACR_WORD, "-{" + detail + "}"); + return msg.replace(REPlACE_WORD, "-{" + detail + "}"); } else { - return msg.replace(REPlACR_WORD, StringUtils.EMPTY); + return msg.replace(REPlACE_WORD, StringUtils.EMPTY); } } } diff --git a/easyink-common/src/main/java/com/easyink/common/constant/redeemcode/RedeemCodeConstants.java b/easyink-common/src/main/java/com/easyink/common/constant/redeemcode/RedeemCodeConstants.java index d27eb0b..3e64ea9 100644 --- a/easyink-common/src/main/java/com/easyink/common/constant/redeemcode/RedeemCodeConstants.java +++ b/easyink-common/src/main/java/com/easyink/common/constant/redeemcode/RedeemCodeConstants.java @@ -1,21 +1,25 @@ package com.easyink.common.constant.redeemcode; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * ClassName: Constants * * @author wx * @date 2022/7/12 9:41 */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class RedeemCodeConstants { /** * 兑换码锁 */ - public static String REDEEM_CODE_KEY = "redeemCode"; + public static final String REDEEM_CODE_KEY = "redeemCode"; - public static long CODE_WAIT_TIME = 5L; + public static final long CODE_WAIT_TIME = 5L; - public static long CODE_LEASE_TIME = 5L; + public static final long CODE_LEASE_TIME = 5L; /** * 获取兑换码活动锁,用来处理分配兑换码所引发的并发操作 diff --git a/easyink-common/src/main/java/com/easyink/common/core/domain/entity/SysUser.java b/easyink-common/src/main/java/com/easyink/common/core/domain/entity/SysUser.java index 4f6b626..7109dce 100644 --- a/easyink-common/src/main/java/com/easyink/common/core/domain/entity/SysUser.java +++ b/easyink-common/src/main/java/com/easyink/common/core/domain/entity/SysUser.java @@ -13,6 +13,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -31,6 +32,7 @@ @Builder @AllArgsConstructor @ApiModel +@EqualsAndHashCode(of = {"userId", "corpId"}, callSuper = false) public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; @@ -396,19 +398,4 @@ public String toString() { .toString(); } - /** - * 重写eq方法,若两个user corpId和userId相同,则相等 - * - * @param obj sysUser - * @return corpId和userId相等则返回true - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof SysUser) { - SysUser sysUser = (SysUser) obj; - return this.corpId.equals(sysUser.getCorpId()) && this.userId.equals(sysUser.getUserId()); - } - return false; - } - } diff --git a/easyink-common/src/main/java/com/easyink/common/core/domain/model/LoginUser.java b/easyink-common/src/main/java/com/easyink/common/core/domain/model/LoginUser.java index 81cccb1..d7acf1c 100644 --- a/easyink-common/src/main/java/com/easyink/common/core/domain/model/LoginUser.java +++ b/easyink-common/src/main/java/com/easyink/common/core/domain/model/LoginUser.java @@ -17,6 +17,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Objects; import java.util.Set; /** @@ -354,14 +355,23 @@ public boolean equals(Object obj) { // 账密登录用户 比较corpId 和 userId return this.user.equals(loginUser.user); } else if (!isSuperAdmin() && !loginUser.isSuperAdmin()) { - if (this.weUser != null && loginUser.weUser != null) { - // 扫码登录用户比较corpId 和 userId - return this.weUser.equals(loginUser.getWeUser()); + if (this.weUser == null || loginUser.weUser == null) { + return false; } + // 扫码登录用户比较corpId 和 userId + return this.weUser.equals(loginUser.getWeUser()); } return false; } + @Override + public int hashCode() { + if(isSuperAdmin()){ + return Objects.hash(user.getUserId(), user.getCorpId()); + } + return Objects.hash(weUser.getUserId()); + } + /** * 获取当前登录用户所设置的主题颜色 * diff --git a/easyink-common/src/main/java/com/easyink/common/enums/ChatType.java b/easyink-common/src/main/java/com/easyink/common/enums/ChatType.java index 814e800..64576d4 100644 --- a/easyink-common/src/main/java/com/easyink/common/enums/ChatType.java +++ b/easyink-common/src/main/java/com/easyink/common/enums/ChatType.java @@ -31,7 +31,7 @@ public enum ChatType { } public static ChatType of(String type) { - return Stream.of(values()).filter(s -> type.equals(s.getType())).findFirst().orElseGet(null); + return Stream.of(values()).filter(s -> s.getType().equals(type)).findFirst().orElse(null); } } diff --git a/easyink-common/src/main/java/com/easyink/common/enums/CustomerTrajectoryEnums.java b/easyink-common/src/main/java/com/easyink/common/enums/CustomerTrajectoryEnums.java index 3506d03..453331a 100644 --- a/easyink-common/src/main/java/com/easyink/common/enums/CustomerTrajectoryEnums.java +++ b/easyink-common/src/main/java/com/easyink/common/enums/CustomerTrajectoryEnums.java @@ -84,12 +84,12 @@ public enum Type { private String name; - private Integer type; + private Integer desc; - Type(Integer type, String name) { + Type(Integer desc, String name) { this.name = name; - this.type = type; + this.desc = desc; } @@ -97,30 +97,21 @@ public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; + public Integer getDesc() { + return desc; } - } public enum SceneType { /** * 编辑资料 */ - EDIT_INFO(Type.INFO.getType(), "信息动态-补充资料", 1), + EDIT_INFO(Type.INFO.getDesc(), "信息动态-补充资料", 1), /** * 信息动态,打标签 */ - MAKE_TAGS(Type.INFO.getType(), "信息动态-设置标签", 2); + MAKE_TAGS(Type.INFO.getDesc(), "信息动态-设置标签", 2); private String name; @@ -142,25 +133,14 @@ public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - public Integer getType() { return type; } - public void setType(Integer type) { - this.type = type; - } - public Integer getKey() { return key; } - public void setKey(Integer key) { - this.key = key; - } } /** diff --git a/easyink-common/src/main/java/com/easyink/common/enums/DataScopeEnum.java b/easyink-common/src/main/java/com/easyink/common/enums/DataScopeEnum.java index 0073af6..11f6bd7 100644 --- a/easyink-common/src/main/java/com/easyink/common/enums/DataScopeEnum.java +++ b/easyink-common/src/main/java/com/easyink/common/enums/DataScopeEnum.java @@ -2,6 +2,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import reactor.util.annotation.Nullable; import java.util.Arrays; /** @@ -47,6 +48,9 @@ public enum DataScopeEnum { * @return */ public static DataScopeEnum getDataScope(String code) { + if (code == null){ + return null; + } return Arrays.stream(values()).filter(value -> value.getCode().equals(code)).findFirst().orElse(null); } } diff --git a/easyink-common/src/main/java/com/easyink/common/enums/ResultTip.java b/easyink-common/src/main/java/com/easyink/common/enums/ResultTip.java index dfd6c3b..3f6b056 100644 --- a/easyink-common/src/main/java/com/easyink/common/enums/ResultTip.java +++ b/easyink-common/src/main/java/com/easyink/common/enums/ResultTip.java @@ -152,6 +152,7 @@ public enum ResultTip { TIP_REDEEM_CODE_FILE_DATA_IS_EMPTY(2081, "文件中数据为空"), TIP_REDEEM_CODE_ACTIVITY_LIMIT_ADD_USER(2082, "活动已开启参与限制,同一客户不能多次领取"), TIP_IMAGE_FORMAT_ERROR(2083, "图片格式异常,请重新保存后上传"), + TIP_MEDIA_TYPE_ERROR(2084,"媒体类型出错"), //员工模块错误码 TIP_PARAM_MISSING(3001, "请填写完整的员工信息"), @@ -196,6 +197,7 @@ public enum ResultTip { TIP_MISSING_LOGIN_INFO(7000, "所在企业未开通「壹鸽快递工单助手」,请联系管理员"), TIP_UN_USE_AI_SYSTEM(7001, "您没有访问权限,请联系管理员"), TIP_UN_BIND_NETWORK(7002, "所在企业未开通「壹鸽快递工单助手」,请联系管理员"), + TIP_GET_UNION_ID_FAIL(7003,"获取unionId失败 "), //应用中心 diff --git a/easyink-common/src/main/java/com/easyink/common/enums/WeExceptionTip.java b/easyink-common/src/main/java/com/easyink/common/enums/WeExceptionTip.java index a856553..8d7f038 100644 --- a/easyink-common/src/main/java/com/easyink/common/enums/WeExceptionTip.java +++ b/easyink-common/src/main/java/com/easyink/common/enums/WeExceptionTip.java @@ -590,27 +590,14 @@ public Integer getCode() { return code; } - public void setCode(Integer code) { - this.code = code; - } - public String getTipMsg() { return tipMsg; } - public void setTipMsg(String tipMsg) { - this.tipMsg = tipMsg; - } - public String getSolveTipMsg() { return solveTipMsg; } - public void setSolveTipMsg(String solveTipMsg) { - this.solveTipMsg = solveTipMsg; - } - - public static String getTipMsg(Integer code) { WeExceptionTip[] values = WeExceptionTip.values(); diff --git a/easyink-common/src/main/java/com/easyink/common/filter/XssFilter.java b/easyink-common/src/main/java/com/easyink/common/filter/XssFilter.java index 0510eeb..3208422 100644 --- a/easyink-common/src/main/java/com/easyink/common/filter/XssFilter.java +++ b/easyink-common/src/main/java/com/easyink/common/filter/XssFilter.java @@ -20,12 +20,12 @@ public class XssFilter implements Filter { /** * 排除链接 */ - public List excludes = new ArrayList<>(); + private List excludes = new ArrayList<>(); /** * xss过滤开关 */ - public boolean enabled = false; + private boolean enabled = false; @Override public void init(FilterConfig filterConfig) { diff --git a/easyink-common/src/main/java/com/easyink/common/lock/LockUtil.java b/easyink-common/src/main/java/com/easyink/common/lock/LockUtil.java index 66cad88..e7acbe5 100644 --- a/easyink-common/src/main/java/com/easyink/common/lock/LockUtil.java +++ b/easyink-common/src/main/java/com/easyink/common/lock/LockUtil.java @@ -1,26 +1,29 @@ package com.easyink.common.lock; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.stereotype.Component; -import java.util.concurrent.TimeUnit; - /** * redis分布式锁工具类 * @author jie.zhao */ @Component +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class LockUtil { - private static Locker locker; + private static RedissonClient redissonClient; /** - * 设置工具类使用的locker + * 设置工具类使用的redissonClient * - * @param locker + * @param redissonClient */ - public static void setLocker(Locker locker) { - LockUtil.locker = locker; + public static void setLocker(RedissonClient redissonClient) { + LockUtil.redissonClient = redissonClient; } /** @@ -28,73 +31,8 @@ public static void setLocker(Locker locker) { * * @param lockKey */ - public static void lock(String lockKey) { - locker.lock(lockKey); - } - - /** - * 释放锁 - * - * @param lockKey - */ - public static void unlock(String lockKey) { - locker.unlock(lockKey); - } - - /** - * 获取锁,超时释放 - * - * @param lockKey - * @param timeout - */ - public static void lock(String lockKey, int timeout) { - locker.lock(lockKey, timeout); - } - - /** - * 获取锁,超时释放,指定时间单位 - * - * @param lockKey - * @param unit - * @param timeout - */ - public static void lock(String lockKey, TimeUnit unit, int timeout) { - locker.lock(lockKey, unit, timeout); + public static RLock getLock(String lockKey) { + return redissonClient.getLock(lockKey); } - - /** - * 尝试获取锁,获取到立即返回true,获取失败立即返回false - * - * @param lockKey - * @return - */ - public static boolean tryLock(String lockKey) { - return locker.tryLock(lockKey); - } - - /** - * 尝试获取锁,在给定的waitTime时间内尝试,获取到返回true,获取失败返回false,获取到后再给定的leaseTime时间超时释放 - * - * @param lockKey - * @param waitTime - * @param leaseTime - * @param unit - * @return - * @throws InterruptedException - */ - public static boolean tryLock(String lockKey, long waitTime, long leaseTime, - TimeUnit unit) throws InterruptedException { - return locker.tryLock(lockKey, waitTime, leaseTime, unit); - } - - /** - * 锁释放被任意一个线程持有 - * - * @param lockKey - * @return - */ - public static boolean isLocked(String lockKey) { - return locker.isLocked(lockKey); - } } \ No newline at end of file diff --git a/easyink-common/src/main/java/com/easyink/common/lock/Locker.java b/easyink-common/src/main/java/com/easyink/common/lock/Locker.java index 6b01a33..61468f8 100644 --- a/easyink-common/src/main/java/com/easyink/common/lock/Locker.java +++ b/easyink-common/src/main/java/com/easyink/common/lock/Locker.java @@ -1,4 +1,6 @@ package com.easyink.common.lock; +import org.redisson.api.RLock; + import java.util.concurrent.TimeUnit; /** @@ -15,7 +17,7 @@ public interface Locker { void lock(String lockKey); /** - * 释放锁 + * 释放锁当前线程的锁 * * @param lockKey */ @@ -47,16 +49,16 @@ public interface Locker { boolean tryLock(String lockKey); /** - * 尝试获取锁,在等待时间内获取到锁则返回true,否则返回false,如果获取到锁,则要么执行完后程序释放锁, + * 尝试获取锁,在等待时间内获取到锁则返回锁实体,否则返回null,如果获取到锁,则要么执行完后程序释放锁, * 要么在给定的超时时间leaseTime后释放锁 * * @param lockKey * @param waitTime * @param leaseTime * @param unit - * @return + * @return 返回锁 */ - boolean tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit unit) + RLock tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException; /** diff --git a/easyink-common/src/main/java/com/easyink/common/lock/RedisLockConfig.java b/easyink-common/src/main/java/com/easyink/common/lock/RedisLockConfig.java index 2a3cf3b..a58005d 100644 --- a/easyink-common/src/main/java/com/easyink/common/lock/RedisLockConfig.java +++ b/easyink-common/src/main/java/com/easyink/common/lock/RedisLockConfig.java @@ -54,10 +54,9 @@ public RedissonClient redisson() { } @Bean - public RedissonLocker redissonLocker(RedissonClient redissonClient) { - RedissonLocker locker = new RedissonLocker(redissonClient); + public RedissonClient redissonLocker(RedissonClient redissonClient) { //设置LockUtil的锁处理对象 - LockUtil.setLocker(locker); - return locker; + LockUtil.setLocker(redissonClient); + return redissonClient; } } diff --git a/easyink-common/src/main/java/com/easyink/common/service/impl/SysRoleServiceImpl.java b/easyink-common/src/main/java/com/easyink/common/service/impl/SysRoleServiceImpl.java index 40a18d7..30ab4c3 100644 --- a/easyink-common/src/main/java/com/easyink/common/service/impl/SysRoleServiceImpl.java +++ b/easyink-common/src/main/java/com/easyink/common/service/impl/SysRoleServiceImpl.java @@ -201,7 +201,7 @@ public int countUserRoleByRoleId(Long roleId) { public int insertRole(SysRole role) { // 新增角色信息 role.setStatus(BaseStatusEnum.CLOSE.getCode().toString()); - role.setMenuIds(Constants.INIT_MENU_LIST); + role.setMenuIds(Constants.getInitMenuList()); roleMapper.insertRole(role); // 如果自定义数据范围则插入 insertRoleDeptRelation(role); diff --git a/easyink-common/src/main/java/com/easyink/common/token/SysPermissionService.java b/easyink-common/src/main/java/com/easyink/common/token/SysPermissionService.java index 7d5bcb1..2f92775 100644 --- a/easyink-common/src/main/java/com/easyink/common/token/SysPermissionService.java +++ b/easyink-common/src/main/java/com/easyink/common/token/SysPermissionService.java @@ -11,9 +11,9 @@ import com.easyink.common.mapper.SysRoleMapper; import com.easyink.common.service.ISysMenuService; import com.easyink.common.service.ISysRoleService; -import com.easyink.common.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -84,10 +84,10 @@ public void setRoleAndDepartmentDataScope(LoginUser user) { } //设置权限 SysRole role = sysRoleMapper.selectRoleByWeUserId(corpId, user.getWeUser().getUserId()); - if (role == null && org.apache.commons.lang3.StringUtils.isNotBlank(user.getWeUser().getExternalCorpId())) { + if (role == null && StringUtils.isNotBlank(user.getWeUser().getExternalCorpId())) { role = sysRoleMapper.selectRoleByWeUserId(user.getWeUser().getExternalCorpId(), user.getWeUser().getUserId()); } - if(ObjectUtil.isNull(role)) { + if(role == null || null == role.getDataScope()) { return; } user.setRole(role); diff --git a/easyink-common/src/main/java/com/easyink/common/token/TokenService.java b/easyink-common/src/main/java/com/easyink/common/token/TokenService.java index 252f001..26f1a75 100644 --- a/easyink-common/src/main/java/com/easyink/common/token/TokenService.java +++ b/easyink-common/src/main/java/com/easyink/common/token/TokenService.java @@ -5,7 +5,6 @@ import com.easyink.common.core.domain.model.LoginUser; import com.easyink.common.core.redis.RedisCache; import com.easyink.common.utils.ServletUtils; -import com.easyink.common.utils.StringUtils; import com.easyink.common.utils.ip.AddressUtils; import com.easyink.common.utils.ip.IpUtils; import com.easyink.common.utils.uuid.IdUtils; @@ -13,7 +12,9 @@ import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -43,7 +44,9 @@ public class TokenService { private String secret; // 令牌有效期(默认30分钟) - public static int expireTime; + @Value("${token.expireTime}") + @Getter + private int expireTime; @Autowired private RuoYiConfig ruoYiConfig; @@ -109,8 +112,7 @@ public String getTokenId(HttpServletRequest request) { // 从令牌中获取声明 Claims claims = parseToken(token); // 从声明中获取登录的uuid - String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); - return uuid; + return (String) claims.get(Constants.LOGIN_USER_KEY); } return StringUtils.EMPTY; } @@ -119,7 +121,7 @@ public String getTokenId(HttpServletRequest request) { * 设置用户身份信息 */ public void setLoginUser(LoginUser loginUser) { - if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) { + if (null != loginUser && StringUtils.isNotEmpty(loginUser.getToken())) { refreshToken(loginUser); } } @@ -281,9 +283,5 @@ public String getUserKey(String token) { return Constants.LOGIN_TOKEN_KEY + token; } - @Value("${token.expireTime}") - public void setExpireTime(int expireTime) { - TokenService.expireTime = expireTime; - } } diff --git a/easyink-common/src/main/java/com/easyink/common/utils/DateUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/DateUtils.java index 2b39425..6ceb773 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/DateUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/DateUtils.java @@ -468,7 +468,7 @@ public static boolean isConformTime(Date nowDate, Date createTime, Integer alert break; case TYPE_1:{ - LocalDateTime localDateTime = createLocalTime.plusDays(alertData1 - 1); + LocalDateTime localDateTime = createLocalTime.plusDays(alertData1 - 1L); int alertHH = Integer.parseInt(alertData2.split(":")[0]); int alertMM = Integer.parseInt(alertData2.split(":")[1]); diff --git a/easyink-common/src/main/java/com/easyink/common/utils/Threads.java b/easyink-common/src/main/java/com/easyink/common/utils/Threads.java index ead44f4..017354c 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/Threads.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/Threads.java @@ -31,6 +31,7 @@ public class Threads { executor.getQueue().put(r); } catch (InterruptedException e) { log.error("InterruptedException e:{}", ExceptionUtils.getStackTrace(e)); + Thread.currentThread().interrupt(); } }); diff --git a/easyink-common/src/main/java/com/easyink/common/utils/XmlUtil.java b/easyink-common/src/main/java/com/easyink/common/utils/XmlUtil.java index be0efb0..8c74166 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/XmlUtil.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/XmlUtil.java @@ -2,6 +2,9 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.dom4j.*; import java.util.List; @@ -12,6 +15,8 @@ * @author: 1*+ * @date: 2021-11-19 15:11 */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@Slf4j public class XmlUtil { @@ -38,10 +43,9 @@ public static JSONObject documentToJSONObject(String xml) { try { jsonObject = elementToJSONObject(strToDocument(xml).getRootElement()); } catch (DocumentException e) { - e.printStackTrace(); - } finally { - return jsonObject; + log.error("[xml转com.alibaba.fastjson.JSONObject], e{}",ExceptionUtil.getExceptionMessage(e)); } + return jsonObject; } diff --git a/easyink-common/src/main/java/com/easyink/common/utils/file/FileUploadUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/file/FileUploadUtils.java index 38348a7..ea5f2c9 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/file/FileUploadUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/file/FileUploadUtils.java @@ -65,7 +65,7 @@ private static String getDefaultBaseDir() { */ public static String upload(MultipartFile file) throws IOException { try { - return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + return upload(getDefaultBaseDir(), file, MimeTypeUtils.getDefaultAllowedExtension()); } catch (Exception e) { throw new IOException(e.getMessage(), e); } @@ -81,7 +81,7 @@ public static String upload(MultipartFile file) throws IOException { */ public static String upload(String baseDir, MultipartFile file) throws IOException { try { - return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + return upload(baseDir, file, MimeTypeUtils.getDefaultAllowedExtension()); } catch (Exception e) { throw new IOException(e.getMessage(), e); } @@ -110,7 +110,7 @@ public static String uploadCert(String baseDir, MultipartFile file) throws IOExc if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); } - assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + assertAllowed(file, MimeTypeUtils.getDefaultAllowedExtension()); return getPathFileName(baseDir, fileName); } @@ -177,7 +177,7 @@ private static void checkFile(MultipartFile file, int fileNamelength) { */ public static String upload2Cos(InputStream in,String fileName, String fileExtension, CosConfig cosConfig) throws IOException { try { - return upload2Cos(in,fileName, fileExtension, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, cosConfig); + return upload2Cos(in,fileName, fileExtension, MimeTypeUtils.getDefaultAllowedExtension(), cosConfig); } catch (Exception e) { throw new IOException(e.getMessage(), e); } @@ -354,13 +354,13 @@ public static void assertAllowed(MultipartFile file, String[] allowedExtension) String extension = getExtension(file); if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { - if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { + if (allowedExtension == MimeTypeUtils.getImageExtension()) { throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, fileName); - } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { + } else if (allowedExtension == MimeTypeUtils.getFlashExtension()) { throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, fileName); - } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { + } else if (allowedExtension == MimeTypeUtils.getMediaExtension()) { throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, fileName); } else { diff --git a/easyink-common/src/main/java/com/easyink/common/utils/file/FileUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/file/FileUtils.java index ffd4636..2a13a5e 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/file/FileUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/file/FileUtils.java @@ -8,6 +8,10 @@ import javax.servlet.http.HttpServletRequest; import java.io.*; import java.net.*; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Paths; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; @@ -30,19 +34,20 @@ public class FileUtils extends org.apache.commons.io.FileUtils { * @return */ public static void writeBytes(String filePath, OutputStream os) throws IOException { - FileInputStream fis = null; try { File file = new File(filePath); if (!file.exists()) { throw new FileNotFoundException(filePath); } - fis = new FileInputStream(file); - byte[] b = new byte[1024]; - int length; - while ((length = fis.read(b)) > 0) { - os.write(b, 0, length); + try (FileInputStream fis = new FileInputStream(file)) { + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) { + os.write(b, 0, length); + } } } catch (IOException e) { + log.error("[输出指定文件的byte数组失败] e:{}", ExceptionUtils.getStackTrace(e)); throw e; } finally { if (os != null) { @@ -52,13 +57,6 @@ public static void writeBytes(String filePath, OutputStream os) throws IOExcepti log.error("异常信息 e:{}", e1.getMessage()); } } - if (fis != null) { - try { - fis.close(); - } catch (IOException e1) { - log.error("异常信息 e:{}", e1.getMessage()); - } - } } } @@ -156,15 +154,8 @@ public static void downloadFile(String urlPath, OutputStream os) { * @param filePath 文件 * @return */ - public static boolean deleteFile(String filePath) { - boolean flag = false; - File file = new File(filePath); - // 路径为文件且不为空则进行删除 - if (file.isFile() && file.exists()) { - file.delete(); - flag = true; - } - return flag; + public static void deleteFile(String filePath) throws IOException { + Files.delete(Paths.get(filePath)); } /** @@ -218,7 +209,7 @@ public static String setFileDownloadHeader(HttpServletRequest request, String fi * @throws UnknownHostException * @throws IOException */ - public static File getFileByUrl(String url) throws UnknownHostException, IOException { + public static File getFileByUrl(String url) throws IOException { //创建临时文件 File tmpFile = File.createTempFile("temp", ".tmp"); toLocalFile(url, tmpFile.getCanonicalPath()); @@ -233,11 +224,13 @@ public static File getFileByUrl(String url) throws UnknownHostException, IOExcep * @throws IOException * @throws UnknownHostException */ - private static void toLocalFile(String urlStr, String localUrl) throws IOException, UnknownHostException { + private static void toLocalFile(String urlStr, String localUrl) throws IOException { byte[] data = toByteArray(urlStr); - FileOutputStream out = new FileOutputStream(localUrl); - out.write(data); - out.close(); + try (FileOutputStream out = new FileOutputStream(localUrl)) { + out.write(data); + }catch (FileNotFoundException e){ + log.error("[网络文件转换为本地文件] e:{}",ExceptionUtils.getStackTrace(e)); + } } /** diff --git a/easyink-common/src/main/java/com/easyink/common/utils/file/MimeTypeUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/file/MimeTypeUtils.java index a0e7494..6f75ea3 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/file/MimeTypeUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/file/MimeTypeUtils.java @@ -20,14 +20,44 @@ public class MimeTypeUtils { public static final String XLS = "xls"; - public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; + protected static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"}; - public static final String[] FLASH_EXTENSION = {"swf", "flv"}; + private MimeTypeUtils() { + } + + /** + * 获取IMAGE_EXTENSION + * + * @return IMAGE_EXTENSION + */ + public static String[] getImageExtension(){ + return IMAGE_EXTENSION; + } + + protected static final String[] FLASH_EXTENSION = {"swf", "flv"}; + + /** + * 获取FLASH_EXTENSION + * + * @return FLASH_EXTENSION + */ + public static String[] getFlashExtension(){ + return FLASH_EXTENSION; + } - public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", + protected static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg", "asf", "rm", "rmvb"}; - public static final String[] DEFAULT_ALLOWED_EXTENSION = { + /** + * 获取MEDIA_EXTENSION + * + * @return MEDIA_EXTENSION + */ + public static String[] getMediaExtension(){ + return MEDIA_EXTENSION; + } + + protected static final String[] DEFAULT_ALLOWED_EXTENSION = { // 图片 "bmp", "gif", "jpg", "jpeg", "png", // word excel powerpoint @@ -37,6 +67,15 @@ public class MimeTypeUtils { // pdf "pdf", "wav", "amr", "mp4", "mp3"}; + /** + * 获取DEFAULT_ALLOWED_EXTENSION + * + * @return DEFAULT_ALLOWED_EXTENSION + */ + public static String[] getDefaultAllowedExtension(){ + return DEFAULT_ALLOWED_EXTENSION; + } + public static String getExtension(String prefix) { switch (prefix) { case IMAGE_PNG: diff --git a/easyink-common/src/main/java/com/easyink/common/utils/http/HttpUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/http/HttpUtils.java index 28d53a8..06f130c 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/http/HttpUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/http/HttpUtils.java @@ -11,6 +11,7 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; +import java.security.cert.CertificateException; import java.security.cert.X509Certificate; /** @@ -143,69 +144,4 @@ public static String sendPost(String url, String param) { } return result.toString(); } - - public static String sendSSLPost(String url, String param) { - StringBuilder result = new StringBuilder(); - String urlNameString = url + "?" + param; - try { - log.info("sendSSLPost - {}", urlNameString); - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom()); - URL console = new URL(urlNameString); - HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); - conn.setRequestProperty(ACCEPT, "*/*"); - conn.setRequestProperty(CONNECTION, KEEP); - conn.setRequestProperty(AGENT, MOZILLA); - conn.setRequestProperty("Accept-Charset", CHARSET); - conn.setRequestProperty("contentType", CHARSET); - conn.setDoOutput(true); - conn.setDoInput(true); - - conn.setSSLSocketFactory(sc.getSocketFactory()); - conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); - conn.connect(); - InputStream is = conn.getInputStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String ret = ""; - while ((ret = br.readLine()) != null) { - if (!"".equals(ret.trim())) { - result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8)); - } - } - log.info(RECV, result); - conn.disconnect(); - br.close(); - } catch (ConnectException e) { - log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + PARAM + param, e); - } catch (SocketTimeoutException e) { - log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + PARAM + param, e); - } catch (IOException e) { - log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + PARAM + param, e); - } catch (Exception e) { - log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + PARAM + param, e); - } - return result.toString(); - } - - private static class TrustAnyTrustManager implements X509TrustManager { - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[]{}; - } - } - - private static class TrustAnyHostnameVerifier implements HostnameVerifier { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - } } \ No newline at end of file diff --git a/easyink-common/src/main/java/com/easyink/common/utils/ip/IpUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/ip/IpUtils.java index fbeacb3..579e816 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/ip/IpUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/ip/IpUtils.java @@ -1,7 +1,10 @@ package com.easyink.common.utils.ip; +import com.easyink.common.utils.ExceptionUtil; import com.easyink.common.utils.StringUtils; import com.easyink.common.utils.html.EscapeUtil; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang3.ObjectUtils; @@ -29,6 +32,7 @@ * @author admin */ @Slf4j +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class IpUtils { private static final String LOCAL_HOST = "127.0.0.1"; public static String getIpAddr(HttpServletRequest request) { @@ -184,17 +188,18 @@ public static String getHostName() { } return "未知"; } - public static String getOutIp() { + public static String getOutIp() throws IOException { Document document = null; try { document = Jsoup.connect("https://ip.chinaz.com/").get(); } catch (IOException e) { - e.printStackTrace(); + log.error("[获取服务器ip异常] e:{}", ExceptionUtil.getExceptionMessage(e)); + throw new IOException(e); } Elements select = document.select("#leftinfo > div.IcpMain02.bor-t1s02 > div.WhoIpWrap.jspu > div.WhwtdWrap.bor-b1s.col-gray03 > span:nth-child(1)"); String s = select.toString(); - String ip = s.substring(s.indexOf(">") + 1, s.lastIndexOf("<")); - return ip; + //返回ip + return s.substring(s.indexOf(">") + 1, s.lastIndexOf("<")); } diff --git a/easyink-common/src/main/java/com/easyink/common/utils/sign/Base64.java b/easyink-common/src/main/java/com/easyink/common/utils/sign/Base64.java index f29f64c..9761035 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/sign/Base64.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/sign/Base64.java @@ -121,8 +121,8 @@ public static String encode(byte[] binaryData) { byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc); encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[(val2 & 0xff) | (k << 4)]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | (val3 & 0xff)]; encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f]; } @@ -134,7 +134,7 @@ public static String encode(byte[] binaryData) { encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; encodedData[encodedIndex++] = PAD; - encodedData[encodedIndex++] = PAD; + encodedData[encodedIndex] = PAD; } else if (fewerThan24bits == SIXTEENBIT) { b1 = binaryData[dataIndex]; b2 = binaryData[dataIndex + 1]; @@ -145,9 +145,9 @@ public static String encode(byte[] binaryData) { byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; + encodedData[encodedIndex++] = lookUpBase64Alphabet[(val2 & 0xff) | (k << 4)]; encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2]; - encodedData[encodedIndex++] = PAD; + encodedData[encodedIndex] = PAD; } return new String(encodedData); } @@ -191,8 +191,12 @@ public static byte[] decode(String encoded) { int dataIndex = 0; for (; i < numberQuadruple - 1; i++) { - if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) - || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) { + d1 = base64Data[dataIndex++]; + d2 = base64Data[dataIndex++]; + d3 = base64Data[dataIndex++]; + d4 = base64Data[dataIndex++]; + if (!isData(d1) || !isData(d2) + || !isData(d3) || !isData(d4)) { return ArrayUtils.EMPTY_BYTE_ARRAY; } // if found "no data" just return null @@ -203,10 +207,11 @@ public static byte[] decode(String encoded) { decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); decodedData[encodedIndex++] = (byte) (((b2 & XF0) << 4) | ((b3 >> 2) & XF0)); - decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); + decodedData[encodedIndex++] = (byte) (b3 << 6 | (b4 & 0xff)); } - - if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) { + d1 = base64Data[dataIndex++]; + d2 = base64Data[dataIndex++]; + if (!isData(d1) || !isData(d2)) { return ArrayUtils.EMPTY_BYTE_ARRAY;// if found "no data" just return null } @@ -214,7 +219,7 @@ public static byte[] decode(String encoded) { b2 = base64Alphabet[d2]; d3 = base64Data[dataIndex++]; - d4 = base64Data[dataIndex++]; + d4 = base64Data[dataIndex]; if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters if (isPad(d3) && isPad(d4)) { if ((b2 & XF0) != 0)// last 4 bits should be zero @@ -244,8 +249,7 @@ public static byte[] decode(String encoded) { b4 = base64Alphabet[d4]; decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); decodedData[encodedIndex++] = (byte) (((b2 & XF0) << 4) | ((b3 >> 2) & XF0)); - decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); - + decodedData[encodedIndex] = (byte) (b3 << 6 | (b4 & 0xff)); } return decodedData; } diff --git a/easyink-common/src/main/java/com/easyink/common/utils/sign/Md5Utils.java b/easyink-common/src/main/java/com/easyink/common/utils/sign/Md5Utils.java index feec6a3..8b50286 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/sign/Md5Utils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/sign/Md5Utils.java @@ -1,5 +1,8 @@ package com.easyink.common.utils.sign; +import com.easyink.common.exception.CustomException; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -12,6 +15,7 @@ * * @author admin */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class Md5Utils { private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); @@ -25,12 +29,12 @@ private static byte[] md5(String s) { } catch (Exception e) { log.error("MD5 Error...", e); } - return null; + return new byte[0]; } private static final String toHex(byte[] hash) { - if (hash == null) { - return null; + if (hash == null || hash.length == 0) { + throw new CustomException("[工单系统接口] md5转化失败"); } StringBuffer buf = new StringBuffer(hash.length * 2); int i; diff --git a/easyink-common/src/main/java/com/easyink/common/utils/wecom/CorpSecretDecryptUtil.java b/easyink-common/src/main/java/com/easyink/common/utils/wecom/CorpSecretDecryptUtil.java new file mode 100644 index 0000000..090a9c3 --- /dev/null +++ b/easyink-common/src/main/java/com/easyink/common/utils/wecom/CorpSecretDecryptUtil.java @@ -0,0 +1,109 @@ +package com.easyink.common.utils.wecom; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.util.Base64Utils; + +import javax.crypto.Cipher; +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.interfaces.RSAPrivateKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; + +/** + * 类名: 企业秘钥解密工具 + * + * @author : silver_chariot + * @date : 2023/1/9 14:55 + **/ +@Component +@ConfigurationProperties(prefix = "decrypt") +public class CorpSecretDecryptUtil { + + @Setter + @Getter + private String unionIdKey; + private static final String RSA = "RSA"; + + /** + * 解密unionId + * + * @param encryptUnionId 加密的unionId + * @return unionId + */ + public String decryptUnionId(String encryptUnionId) { + return privateKeyDecrypt(encryptUnionId, unionIdKey); + } + + /** + * 根据私钥解密 + * + * @param ciphertext 密文 + * @param privateKeyBase64 私钥 + * @return 明文 + */ + public static String privateKeyDecrypt(String ciphertext, String privateKeyBase64) { + try { + // 密文base64解码字节数组 + byte[] bytes = Base64Utils.decode(ciphertext.getBytes("UTF-8")); + Cipher cipher = Cipher.getInstance(RSA); + PrivateKey privateKey = getPrivateKey(privateKeyBase64); + cipher.init(Cipher.DECRYPT_MODE, privateKey); + int keyBit = getKeySize(privateKey); + int inputLen = bytes.length; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int offSet = 0; + int step = keyBit / 8; + + for (int i = 0; inputLen - offSet > 0; offSet = i * step) { + byte[] cache; + if (inputLen - offSet > step) { + cache = cipher.doFinal(bytes, offSet, step); + } else { + cache = cipher.doFinal(bytes, offSet, inputLen - offSet); + } + out.write(cache, 0, cache.length); + ++i; + } + // 明文字节数组 + byte[] plaintextBytes = out.toByteArray(); + out.close(); + return new String(plaintextBytes, StandardCharsets.UTF_8); + } catch (Exception e) { + return null; + } + } + + /** + * 将Base64编码后的私钥转换成PrivateKey对象 + * + * @param privateKeyBase64 私钥base64 + * @return + * @throws Exception + */ + public static PrivateKey getPrivateKey(String privateKeyBase64) throws NoSuchAlgorithmException, InvalidKeySpecException { + byte[] keyBytes = Base64Utils.decode(privateKeyBase64.getBytes(StandardCharsets.UTF_8)); + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); + KeyFactory keyFactory = KeyFactory.getInstance(RSA); + return keyFactory.generatePrivate(keySpec); + } + + /** + * 获取私钥长度 + * + * @param privateKey 私钥 + * @return key size + */ + public static int getKeySize(PrivateKey privateKey) { + RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) privateKey; + return rsaPrivateKey.getModulus() + .bitLength(); + } + +} diff --git a/easyink-common/src/main/java/com/easyink/common/utils/wecom/TicketUtils.java b/easyink-common/src/main/java/com/easyink/common/utils/wecom/TicketUtils.java index a8bb2eb..264b704 100644 --- a/easyink-common/src/main/java/com/easyink/common/utils/wecom/TicketUtils.java +++ b/easyink-common/src/main/java/com/easyink/common/utils/wecom/TicketUtils.java @@ -1,10 +1,14 @@ package com.easyink.common.utils.wecom; +import com.github.mustachejava.ObjectHandler; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.RandomStringUtils; import java.util.HashMap; +import java.util.Map; /** * @author admin @@ -12,9 +16,10 @@ * @date 2021/1/6 12:00 **/ @Slf4j +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class TicketUtils { - public static HashMap getSignatureMap(String ticketVaule, String url) { + public static Map getSignatureMap(String ticketVaule, String url) { String nonceStr = RandomStringUtils.randomAlphanumeric(10); Long timestamp = System.currentTimeMillis() / 1000; StringBuilder strBuild = new StringBuilder(); @@ -24,11 +29,11 @@ public static HashMap getSignatureMap(String ticketVaule, String url) { .append("&url=").append(url); log.info("H5加密串:{}", strBuild.toString()); String signature = DigestUtils.sha1Hex(strBuild.toString()); - return new HashMap(16) {{ - put("nonceStr", nonceStr); - put("timestamp", timestamp); - put("signature", signature); - }}; + Map result = new HashMap(16); + result.put("nonceStr", nonceStr); + result.put("timestamp", timestamp); + result.put("signature", signature); + return result; } } diff --git a/easyink-quartz/src/main/java/com/easyink/quartz/task/GroupChatStatisticTask.java b/easyink-quartz/src/main/java/com/easyink/quartz/task/GroupChatStatisticTask.java index 084293b..fba5b73 100644 --- a/easyink-quartz/src/main/java/com/easyink/quartz/task/GroupChatStatisticTask.java +++ b/easyink-quartz/src/main/java/com/easyink/quartz/task/GroupChatStatisticTask.java @@ -1,30 +1,13 @@ package com.easyink.quartz.task; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.easyink.common.constant.GroupConstants; import com.easyink.common.core.domain.entity.WeCorpAccount; -import com.easyink.common.utils.MyDateUtil; -import com.easyink.common.utils.bean.BeanUtils; -import com.easyink.wecom.client.WeCustomerClient; -import com.easyink.wecom.domain.WeGroup; -import com.easyink.wecom.domain.WeGroupStatistic; -import com.easyink.wecom.domain.dto.GroupChatStatisticDTO; -import com.easyink.wecom.domain.query.GroupChatStatisticQuery; import com.easyink.wecom.service.WeCorpAccountService; import com.easyink.wecom.service.WeGroupService; -import com.easyink.wecom.service.WeGroupStatisticService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; /** @@ -36,117 +19,23 @@ @Component("GroupChatStatisticTask") public class GroupChatStatisticTask { - private final WeCustomerClient weCustomerClient; - private final WeGroupService weGroupService; - private final WeGroupStatisticService weGroupStatisticService; - private final WeCorpAccountService weCorpAccountService; @Autowired - public GroupChatStatisticTask(WeCustomerClient weCustomerClient, WeGroupService weGroupService, WeGroupStatisticService weGroupStatisticService, WeCorpAccountService weCorpAccountService) { - this.weCustomerClient = weCustomerClient; + public GroupChatStatisticTask(WeGroupService weGroupService, WeCorpAccountService weCorpAccountService) { this.weGroupService = weGroupService; - this.weGroupStatisticService = weGroupStatisticService; this.weCorpAccountService = weCorpAccountService; } - private static final int OFFSET = 500; - - public void getGroupChatData() { List weCorpAccountList = weCorpAccountService.listOfAuthCorpInternalWeCorpAccount(); weCorpAccountList.forEach(weCorpAccount -> { if (weCorpAccount != null && StringUtils.isNotBlank(weCorpAccount.getCorpId())) { - processGroupChatData(weCorpAccount.getCorpId()); + weGroupService.processGroupChatData(weCorpAccount.getCorpId()); } }); - - } - - @Transactional(rollbackFor = Exception.class) - void processGroupChatData(String corpId) { - if (StringUtils.isBlank(corpId)) { - return; - } - - //删除本日原先的数据 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - Long startTime = MyDateUtil.strToDate(-1, 0); - Long endTime = MyDateUtil.strToDate(-1, 1); - wrapper.eq(WeGroupStatistic::getCorpId, corpId); - wrapper.between(WeGroupStatistic::getStatTime, DateUtil.date(startTime * 1000), DateUtil.date(endTime * 1000)); - int count = weGroupStatisticService.count(wrapper); - //删除所有数据 - if (count > 0) { - weGroupStatisticService.remove(wrapper); - } - - //判断是否大于500,判断是否分批处理 - int weGroupCount = weGroupService.count( - new LambdaQueryWrapper() - .eq(WeGroup::getCorpId, corpId) - ); - //定义批量操作 - double num = 1; - if (weGroupCount > OFFSET) { - num = Math.ceil((double) weGroupCount / OFFSET); - } - int temp = 0; - List list = new ArrayList<>(2); - list.add(GroupConstants.OWNER_LEAVE); - list.add(GroupConstants.OWNER_LEAVE_EXTEND); - for (int i = 0; i < num; i++) { - QueryWrapper wrapper1 = new QueryWrapper<>(); - wrapper1.select("DISTINCT owner"); - wrapper1.eq("corp_id", corpId); - wrapper1.notIn("status", list); - wrapper1.last("limit " + temp + "," + OFFSET); - List weGroupList = weGroupService.list(wrapper1); - - if (CollUtil.isNotEmpty(weGroupList)) { - List weGroupStatisticList = new ArrayList<>(); - GroupChatStatisticQuery query = new GroupChatStatisticQuery(); - //前一天的数据 - query.setDay_begin_time(startTime); - query.setDay_end_time(endTime); - - weGroupList.forEach(weGroup -> { - - GroupChatStatisticQuery.OwnerFilter ownerFilter = new GroupChatStatisticQuery.OwnerFilter(); - List idList = new ArrayList<>(); - idList.add(weGroup.getOwner()); - ownerFilter.setUserid_list(idList); - query.setOwner_filter(ownerFilter); - try { - //状态不是离职继承中的,离职继承中的群聊无法查询 - //根据群主获取群聊概述 - GroupChatStatisticDTO groupChatStatistic = weCustomerClient.getGroupChatStatistic(query, corpId); - List items = groupChatStatistic.getItems(); - if (CollUtil.isNotEmpty(items)) { - items.forEach(groupChatStatisticData -> { - WeGroupStatistic weGroupStatistic = new WeGroupStatistic(); - GroupChatStatisticDTO.StatisticData data = groupChatStatisticData.getData(); - BeanUtils.copyPropertiesignoreOther(data, weGroupStatistic); - weGroupStatistic.setChatId(groupChatStatisticData.getOwner()); - //返回数据不包含时间,所以使用开始时间做stat_time - weGroupStatistic.setStatTime(DateUtil.date(startTime * 1000)); - weGroupStatistic.setCorpId(corpId); - weGroupStatisticList.add(weGroupStatistic); - }); - } - } catch (Exception e) { - log.error("群聊数据拉取失败: ownerFilter:【{}】,ex:【{}】", JSON.toJSONString(ownerFilter), ExceptionUtils.getStackTrace(e)); - } - }); - - - weGroupStatisticService.saveBatch(weGroupStatisticList); - } - - temp += OFFSET; - } } } diff --git a/easyink-quartz/src/main/java/com/easyink/quartz/task/RyTask.java b/easyink-quartz/src/main/java/com/easyink/quartz/task/RyTask.java index c56a8da..bde26e4 100644 --- a/easyink-quartz/src/main/java/com/easyink/quartz/task/RyTask.java +++ b/easyink-quartz/src/main/java/com/easyink/quartz/task/RyTask.java @@ -136,27 +136,6 @@ private void setRevokeInfo1(List chatDataList, String corpId) { }); } -// private void setRevokeInfo(List msgList, Map idMap, String corpId) { -// msgList.forEach(jsonObject -> { -// //撤回标识 -// String msgtype = jsonObject.getString("msgtype"); -// if ("revoke".equals(msgtype)) { -// String revokeMsgId = jsonObject.getJSONObject("revoke").getString("pre_msgid"); -// if (idMap.containsKey(revokeMsgId)) { -// idMap.get(revokeMsgId).put("isRevoke", Boolean.TRUE); -// } else { -// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery(WeConstans.MSG_ID, revokeMsgId)); -// SearchSourceBuilder builder = new SearchSourceBuilder(); -// builder.query(boolQueryBuilder); -// List search = elasticSearch.search(WeConstans.getChatDataIndex(corpId), builder, JSONObject.class); -// if (org.apache.commons.collections.CollectionUtils.isNotEmpty(search)) { -// search.get(0).put("isRevoke", Boolean.TRUE); -// elasticSearch.updateBatchByJson(WeConstans.getChatDataIndex(corpId), search); -// } -// } -// } -// }); -// } /** * 设置redis中的seq @@ -206,9 +185,12 @@ public void messageTask() { log.warn("群发定时任务传入参数错误 messageId:{} , messageInfo:{}, customerInfo:{},groupsInfo:{}", task.getMessageId(), task.getMessageInfo(), task.getCustomersInfo(), task.getGroupsInfo()); } - } catch (JsonProcessingException | InterruptedException | ForestRuntimeException e) { + } catch (JsonProcessingException | ForestRuntimeException e) { log.error("定时群发消息处理异常:ex:{}", ExceptionUtils.getStackTrace(e)); - } finally { + } catch (InterruptedException e){ + log.error("定时群发消息处理异常:ex:{}", ExceptionUtils.getStackTrace(e)); + Thread.currentThread().interrupt(); + }finally { //更新消息处理状态 customerMessageTimeTaskMapper.updateTaskSolvedById(task.getTaskId()); semaphore.release(); diff --git a/easyink-quartz/src/main/java/com/easyink/quartz/task/UserBehaviorDataTak.java b/easyink-quartz/src/main/java/com/easyink/quartz/task/UserBehaviorDataTak.java index 2e5813d..b8a21b9 100644 --- a/easyink-quartz/src/main/java/com/easyink/quartz/task/UserBehaviorDataTak.java +++ b/easyink-quartz/src/main/java/com/easyink/quartz/task/UserBehaviorDataTak.java @@ -1,31 +1,14 @@ package com.easyink.quartz.task; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.dtflys.forest.exceptions.ForestRuntimeException; import com.easyink.common.core.domain.entity.WeCorpAccount; -import com.easyink.common.core.domain.wecom.WeUser; -import com.easyink.common.utils.MyDateUtil; -import com.easyink.common.utils.bean.BeanUtils; -import com.easyink.wecom.client.WeCustomerClient; -import com.easyink.wecom.client.WeUserClient; -import com.easyink.wecom.domain.WeUserBehaviorData; -import com.easyink.wecom.domain.dto.UserBehaviorDataDTO; -import com.easyink.wecom.domain.query.UserBehaviorDataQuery; import com.easyink.wecom.service.WeCorpAccountService; -import com.easyink.wecom.service.WeDepartmentService; -import com.easyink.wecom.service.WeUserBehaviorDataService; import com.easyink.wecom.service.WeUserService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; /** @@ -37,24 +20,12 @@ @Component("UserBehaviorDataTak") public class UserBehaviorDataTak { - private final WeCustomerClient weCustomerClient; - - private final WeUserBehaviorDataService weUserBehaviorDataService; - - private final WeUserClient weUserClient; - private final WeCorpAccountService weCorpAccountService; - private final WeDepartmentService weDepartmentService; - private final WeUserService weUserService; @Autowired - public UserBehaviorDataTak(WeCustomerClient weCustomerClient, WeUserBehaviorDataService weUserBehaviorDataService, WeUserClient weUserClient, WeCorpAccountService weCorpAccountService, WeDepartmentService weDepartmentService, WeUserService weUserService) { - this.weCustomerClient = weCustomerClient; - this.weUserBehaviorDataService = weUserBehaviorDataService; - this.weUserClient = weUserClient; + public UserBehaviorDataTak(WeCorpAccountService weCorpAccountService, WeUserService weUserService) { this.weCorpAccountService = weCorpAccountService; - this.weDepartmentService = weDepartmentService; this.weUserService = weUserService; } @@ -64,7 +35,7 @@ public void getUserBehaviorData() { weCorpAccountList.forEach(weCorpAccount -> { try { if (weCorpAccount != null && StringUtils.isNotBlank(weCorpAccount.getCorpId())) { - getUserBehaviorDataByCorpId(weCorpAccount.getCorpId()); + weUserService.getUserBehaviorDataByCorpId(weCorpAccount.getCorpId()); } } catch (Exception e) { log.error("[获取用户数据]统计客户任务异常,corpid:{},e:{}", weCorpAccount.getCorpId(), ExceptionUtils.getStackTrace(e)); @@ -73,55 +44,4 @@ public void getUserBehaviorData() { log.info("定时任务执行完成------>"); } - @Transactional(rollbackFor = Exception.class) - void getUserBehaviorDataByCorpId(String corpId) { - if (StringUtils.isBlank(corpId)) { - log.error("corpId不允许为空。"); - return; - } - // 获取根员工 - List visibleUser = weUserService.getVisibleUser(corpId); - if (CollectionUtils.isEmpty(visibleUser)) { - log.info("[UserBehaviorDataTak] 该企业不存在可见的部门和员工,停止执行,corpId:{}", corpId); - return; - } - //删除存在的数据 - Long startTime = MyDateUtil.strToDate(-1, 0); - Long endTime = MyDateUtil.strToDate(-1, 1); - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.eq(WeUserBehaviorData::getCorpId, corpId); - wrapper1.between(WeUserBehaviorData::getStatTime, DateUtil.date(startTime * 1000), DateUtil.date(endTime * 1000)); - int count = weUserBehaviorDataService.count(wrapper1); - if (count > 0) { - weUserBehaviorDataService.remove(wrapper1); - } - - List dataList = new ArrayList<>(); - UserBehaviorDataQuery query = new UserBehaviorDataQuery(); - //前一天的数据 - query.setStart_time(startTime); - query.setEnd_time(endTime); - visibleUser.forEach(weUser -> { - List idList = new ArrayList<>(); - idList.add(weUser.getUserId()); - query.setUserid(idList); - try { - //根据员工id获取员工的数据概览 - UserBehaviorDataDTO userBehaviorData = weCustomerClient.getUserBehaviorData(query, corpId); - List behaviorDataList = userBehaviorData.getBehaviorData(); - for (UserBehaviorDataDTO.BehaviorData data : behaviorDataList) { - WeUserBehaviorData weUserBehaviorData = new WeUserBehaviorData(); - BeanUtils.copyPropertiesignoreOther(data, weUserBehaviorData); - weUserBehaviorData.setUserId(weUser.getUserId()); - weUserBehaviorData.setCorpId(corpId); - dataList.add(weUserBehaviorData); - } - } catch (ForestRuntimeException e) { - log.error("员工数据拉取失败: corpId:{},userId:【{}】,ex:【{}】", corpId, weUser.getUserId(), ExceptionUtils.getStackTrace(e)); - } - }); - weUserBehaviorDataService.saveBatch(dataList); - - - } } diff --git a/easyink-quartz/src/main/java/com/easyink/quartz/task/WeOperationsCenterSopTask.java b/easyink-quartz/src/main/java/com/easyink/quartz/task/WeOperationsCenterSopTask.java index 96a6bb2..2a86dbb 100644 --- a/easyink-quartz/src/main/java/com/easyink/quartz/task/WeOperationsCenterSopTask.java +++ b/easyink-quartz/src/main/java/com/easyink/quartz/task/WeOperationsCenterSopTask.java @@ -285,7 +285,12 @@ private void saveSopTask(List detailList, Str for (SopAttachmentVO sopAttachmentVO : sopAttachmentVos) { WeOperationsCenterSopTaskEntity sopTask = new WeOperationsCenterSopTaskEntity(); if (AttachmentTypeEnum.RADAR.getMessageType().equals(sopAttachmentVO.getMediaType())) { - buildRadarAttachment(sopAttachmentVO, channelType, userId, corpId, sopRuleName); + try { + buildRadarAttachment(sopAttachmentVO, channelType, userId, corpId, sopRuleName); + } catch (Exception e) { + log.error("sop处理构建雷达素材失败, corpId: {},sopRuleName: {},userId: {}, sopType: {}, radarInfo: {}, e: {}", corpId, sopRuleName, userId, channelType, sopAttachmentVO, ExceptionUtils.getMessage(e)); + continue; + } } BeanUtils.copyProperties(sopAttachmentVO, sopTask); sopTask.setId(SnowFlakeUtil.nextId()); @@ -295,6 +300,7 @@ private void saveSopTask(List detailList, Str sopTaskService.saveBatch(taskEntityList); //插入客户轨迹待办消息 List taskIds = taskEntityList.stream().filter(task -> task.getId() != null).map(task -> task.getId().toString()).collect(Collectors.toList()); + log.info("[保存sopTask] corpId: {}, userId: {}, targetId: {}, sopDetailId: {}, taskIds:{}", corpId, userId, sopDetailEntity.getTargetId(), sopDetailEntity.getId(), String.join(StrUtil.COMMA, taskIds)); saveCustomerTrajectorySopTask(sopDetailEntity.getAlertTime(), saveRuleNameMap.get(userId + sopDetailEntity.getRuleId()), corpId, sopDetailEntity.getId(), String.join(StrUtil.COMMA, taskIds), userId, sopDetailEntity.getTargetId()); } } @@ -341,7 +347,7 @@ private void saveCustomerTrajectorySopTask(Date alertTime, String ruleName, Stri weCustomerTrajectory.setExternalUserid(targetId); weCustomerTrajectory.setSopTaskIds(taskIds); weCustomerTrajectory.setContent(ruleName); - weCustomerTrajectory.setTrajectoryType(CustomerTrajectoryEnums.Type.TO_DO.getType()); + weCustomerTrajectory.setTrajectoryType(CustomerTrajectoryEnums.Type.TO_DO.getDesc()); weCustomerTrajectory.setCreateDate(alertTime); weCustomerTrajectory.setStartTime(Time.valueOf(DateUtils.parseDateToStr(HH_MM_SS,alertTime))); trajectoryService.save(weCustomerTrajectory); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/client/WeUnionIdClient.java b/easyink-wecom/src/main/java/com/easyink/wecom/client/WeUnionIdClient.java new file mode 100644 index 0000000..d78d4d1 --- /dev/null +++ b/easyink-wecom/src/main/java/com/easyink/wecom/client/WeUnionIdClient.java @@ -0,0 +1,31 @@ +package com.easyink.wecom.client; + +import com.dtflys.forest.annotation.BaseRequest; +import com.dtflys.forest.annotation.Get; +import com.dtflys.forest.annotation.Header; +import com.dtflys.forest.annotation.Query; +import com.easyink.wecom.domain.dto.customer.ExternalUserDetail; +import com.easyink.wecom.interceptor.WeAccessTokenInterceptor; +import com.easyink.wecom.interceptor.WeUnionIdInterceptor; +import org.springframework.stereotype.Component; + +/** + * 类名: 获取unionid的http客户端 + * + * @author : silver_chariot + * @date : 2023/1/5 14:03 + **/ +@Component +@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeUnionIdInterceptor.class) +public interface WeUnionIdClient { + /** + * 根据外部联系人userId 获取unionId详情 + * + * @param externalUserId 外部联系人userid + * @return {@link ExternalUserDetail } + */ + @Get(url = "/externalcontact/get") + ExternalUserDetail getByExternalUserId(@Query("external_userid") String externalUserId, + @Header("corpId") String corpId, + @Header("corpSecret") String corpSecret); +} diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/FindWeMaterialDTO.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/FindWeMaterialDTO.java index 5cba44f..5deaed3 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/FindWeMaterialDTO.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/FindWeMaterialDTO.java @@ -31,4 +31,7 @@ public class FindWeMaterialDTO { @ApiModelProperty(value = "标签ID,多个逗号隔开") private String tagIds; + + @ApiModelProperty(value = "是否展示侧边栏展示海报素材标识 true: 展示 false: 不展示") + private Boolean usingFlag; } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/customer/resp/GetByUserResp.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/customer/resp/GetByUserResp.java index 4e0f3a7..394f23b 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/customer/resp/GetByUserResp.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/customer/resp/GetByUserResp.java @@ -51,11 +51,11 @@ public class ExternalContactDetail { /** * 外部联系人 */ - public ExternalContact external_contact; + private ExternalContact external_contact; /** * 跟进人信息 */ - public FollowInfo follow_info; + private FollowInfo follow_info; } @Override diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/message/VideoDTO.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/message/VideoDTO.java index 22157d3..e383186 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/message/VideoDTO.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/message/VideoDTO.java @@ -28,7 +28,6 @@ public class VideoDTO { private String videoUrl; @ApiModelProperty(value = "视频大小", required = true) - @NotNull(message = "视频大小不能为空") private Long size; @ApiModelProperty("封面") diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedCustomerReq.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedCustomerReq.java index 6c15d73..635304f 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedCustomerReq.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedCustomerReq.java @@ -1,5 +1,6 @@ package com.easyink.wecom.domain.dto.transfer; +import com.easyink.common.utils.bean.BeanUtils; import com.easyink.common.utils.spring.SpringUtils; import com.easyink.wecom.client.WeExternalContactClient; import com.google.common.collect.Lists; @@ -8,6 +9,7 @@ import org.apache.commons.collections4.CollectionUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -49,21 +51,33 @@ public TransferResignedCustomerResp execute(String corpId) { WeExternalContactClient client = SpringUtils.getBean(WeExternalContactClient.class); // 由于一次最多可转接100个客户 这里分隔客户列表后再分批请求 List> partitionList = Lists.partition(external_userid, MAX_TRANSFER_NUM); + // 保存全部的结果 + TransferResignedCustomerResp respAll = TransferResignedCustomerResp.emptyResult(); List totalList = new ArrayList<>(); - TransferResignedCustomerResp resp = TransferResignedCustomerResp.emptyResult(); + // 每批次返回数据 + TransferResignedCustomerResp onceResp; + // 至少有一次正确返回 + boolean resultSuccessFlag = false; for (List subList : partitionList) { if (CollectionUtils.isEmpty(subList)) { continue; } this.external_userid = subList; - resp = client.transferResignedCustomer(this, corpId); - if (resp != null && CollectionUtils.isNotEmpty(resp.getCustomer())) { - totalList.addAll(resp.getCustomer()); + onceResp = client.transferResignedCustomer(this, corpId); + if (onceResp != null && CollectionUtils.isNotEmpty(onceResp.getCustomer())) { + // 其他参数只复制一次 + if(!resultSuccessFlag){ + BeanUtils.copyBeanProp(respAll, onceResp); + resultSuccessFlag = true; + } + totalList.addAll(onceResp.getCustomer()); } } - resp.setCustomer(totalList); - return resp; + respAll.setCustomer(totalList); + return respAll; } + + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatReq.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatReq.java index aa57ef7..9e0e627 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatReq.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatReq.java @@ -1,5 +1,6 @@ package com.easyink.wecom.domain.dto.transfer; +import com.easyink.common.utils.bean.BeanUtils; import com.easyink.common.utils.spring.SpringUtils; import com.easyink.wecom.client.WeExternalContactClient; import com.google.common.collect.Lists; @@ -44,19 +45,29 @@ public TransferResignedGroupChatResp execute(String corpId) { // 一次最懂分配100个客户群,此处分批请求 List> partitionList = Lists.partition(chat_id_list, MAX_TRANSFER_NUM); List totalList = new ArrayList<>(); - TransferResignedGroupChatResp resp = new TransferResignedGroupChatResp(); + // 每批次返回数据 + TransferResignedGroupChatResp onceResp; + // 保存全部的结果 + TransferResignedGroupChatResp respAll = new TransferResignedGroupChatResp(); + // 至少有一次正确返回 + boolean resultSuccessFlag = false; for (List subList : partitionList) { if (CollectionUtils.isEmpty(subList)) { continue; } this.chat_id_list = subList; - resp = client.transferResignedGroup(this, corpId); - if (resp != null && CollectionUtils.isNotEmpty(resp.getFailed_chat_list())) { - totalList.addAll(resp.getFailed_chat_list()); + onceResp = client.transferResignedGroup(this, corpId); + if (onceResp != null && CollectionUtils.isNotEmpty(onceResp.getFailed_chat_list())) { + // 其他参数只复制一次 + if(!resultSuccessFlag){ + BeanUtils.copyBeanProp(respAll, onceResp); + resultSuccessFlag = true; + } + totalList.addAll(onceResp.getFailed_chat_list()); } } - resp.setFailed_chat_list(totalList); - return resp; + respAll.setFailed_chat_list(totalList); + return respAll; } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatResp.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatResp.java index 84a7ad0..221f1ce 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatResp.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/transfer/TransferResignedGroupChatResp.java @@ -9,6 +9,7 @@ import lombok.Data; import org.apache.commons.collections4.CollectionUtils; +import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; @@ -19,7 +20,7 @@ * @date : 2021/12/6 19:45 */ @Data -public class TransferResignedGroupChatResp extends WeResultDTO { +public class TransferResignedGroupChatResp extends WeResultDTO{ /** * 没继承成功的群详情 */ diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/unionid/GetUnionIdDTO.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/unionid/GetUnionIdDTO.java new file mode 100644 index 0000000..06cecad --- /dev/null +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/dto/unionid/GetUnionIdDTO.java @@ -0,0 +1,25 @@ +package com.easyink.wecom.domain.dto.unionid; + +import lombok.Data; + +/** + * 类名: 根据external_user_id获取unionId的请求参数 + * + * @author : silver_chariot + * @date : 2023/1/5 9:26 + **/ +@Data +public class GetUnionIdDTO { + /** + * 企微外部联系人userid + */ + private String externalUserId; + /** + * 企业corpId + */ + private String corpId; + /** + * 企业corpSecret + */ + private String corpSecret; +} diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/req/WePageBaseReq.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/req/WePageBaseReq.java index e2fe3f6..0808c9e 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/domain/req/WePageBaseReq.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/req/WePageBaseReq.java @@ -1,5 +1,7 @@ package com.easyink.wecom.domain.req; +import com.easyink.common.utils.bean.BeanUtils; +import com.easyink.wecom.domain.dto.transfer.TransferResignedGroupChatResp; import com.easyink.wecom.domain.resp.WePageBaseResp; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; @@ -39,21 +41,33 @@ protected WePageBaseReq() { * @param corpId 企业ID * @return {@link WePageBaseResp} 接口响应 */ - public WePageBaseResp executeTillNoNextPage(String corpId) { + public WePageBaseResp executeTillNoNextPage(String corpId) { // 待返回的分页列表 List totalList = new ArrayList<>(); // 接口单次的响应数据 - WePageBaseResp resp = null; + WePageBaseResp onceResp = null; + // 保存全部数据 + WePageBaseResp respAll = null; + // 至少有一次正确返回 + boolean resultSuccessFlag = false; do { - setCursorIfExist(resp); - resp = this.execute(corpId); - if (resp == null || CollectionUtils.isEmpty(resp.getPageList())) { + setCursorIfExist(onceResp); + onceResp = this.execute(corpId); + if (onceResp == null || CollectionUtils.isEmpty(onceResp.getPageList())) { break; } - totalList.addAll(resp.getPageList()); - } while (StringUtils.isNotBlank(resp.getNext_cursor())); - resp.setTotalList(totalList); - return resp; + // 其他参数只复制一次 + if(!resultSuccessFlag){ + respAll = onceResp; + resultSuccessFlag = true; + } + totalList.addAll(onceResp.getPageList()); + } while (StringUtils.isNotBlank(onceResp.getNext_cursor())); + if(respAll == null){ + return null; + } + respAll.setTotalList(totalList); + return respAll; } /** diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/domain/vo/unionid/GetUnionIdVO.java b/easyink-wecom/src/main/java/com/easyink/wecom/domain/vo/unionid/GetUnionIdVO.java new file mode 100644 index 0000000..6a0ce4e --- /dev/null +++ b/easyink-wecom/src/main/java/com/easyink/wecom/domain/vo/unionid/GetUnionIdVO.java @@ -0,0 +1,44 @@ +package com.easyink.wecom.domain.vo.unionid; + +import com.alibaba.fastjson.annotation.JSONField; +import com.easyink.wecom.domain.dto.customer.ExternalContact; +import lombok.Data; + +/** + * 类名: 根据external_user_id获取unionId的返回结果 + * + * @author : silver_chariot + * @date : 2023/1/5 9:28 + **/ +@Data +public class GetUnionIdVO { + + /** + * 外部联系人userid + */ + private String externalUserId; + /** + * 名称 + */ + private String name ; + /** + * 头像url + */ + private String avatar ; + /** + * 公众平台unionId + */ + private String unionId; + /** + * 外部联系人性别 0-未知 1-男性 2-女性性别 1 为男 + */ + private Integer gender ; + + public GetUnionIdVO(ExternalContact externalContact) { + this.externalUserId = externalContact.getExternalUserid(); + this.avatar = externalContact.getAvatar(); + this.name = externalContact.getName() ; + this.gender = externalContact.getGender(); + this.unionId = externalContact.getUnionid() ; + } +} diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java index 152b5b4..78bbb15 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackAddExternalContactImpl.java @@ -15,7 +15,6 @@ import com.easyink.common.exception.CustomException; import com.easyink.common.lock.LockUtil; import com.easyink.common.utils.ExceptionUtil; -import com.easyink.common.utils.StringUtils; import com.easyink.wecom.domain.*; import com.easyink.wecom.domain.dto.AddWeMaterialDTO; import com.easyink.wecom.domain.dto.WeMediaDTO; @@ -34,7 +33,9 @@ import com.easyink.wecom.utils.AttachmentService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -124,7 +125,7 @@ private boolean checkParams(WxCpXmlMessageVO message) { log.error("[add_external_contact]:回调数据不完整,message:{}", message); return false; } - if (!redisCache.addLock(message.getUniqueKey(message.getExternalUserId()), "", Constants.CALLBACK_HANDLE_LOCK_TIME)) { + if (Boolean.FALSE.equals(redisCache.addLock(message.getUniqueKey(message.getExternalUserId()), "", Constants.CALLBACK_HANDLE_LOCK_TIME))) { log.info("[{}]添加客户事件回调,该回调已处理,不重复处理,message:{}", message.getChangeType(), message); // 不重复处理 return false; @@ -192,7 +193,7 @@ private void empleCodeHandle(String state, String welcomeCode, String userId, St WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(welcomeCode); SelectWeEmplyCodeWelcomeMsgVO messageMap = weEmpleCodeService.selectWelcomeMsgByState(state, corpId, externalUserId); - if (StringUtils.isNotNull(messageMap) && org.apache.commons.lang3.StringUtils.isNotBlank(messageMap.getEmpleCodeId())) { + if (null != messageMap && org.apache.commons.lang3.StringUtils.isNotBlank(messageMap.getEmpleCodeId())) { String empleCodeId = messageMap.getEmpleCodeId(); //更新活码数据统计 weEmpleCodeAnalyseService.saveWeEmpleCodeAnalyse(corpId, userId, externalUserId, empleCodeId, true); @@ -218,23 +219,7 @@ private void empleCodeHandle(String state, String welcomeCode, String userId, St } }); } else if (WelcomeMsgTypeEnum.REDEEM_CODE_WELCOME_MSG_TYPE.getType().equals(messageMap.getWelcomeMsgType())) { - try { - final String redeemCodeKey = RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId()); - if (LockUtil.tryLock(redeemCodeKey, RedeemCodeConstants.CODE_WAIT_TIME, RedeemCodeConstants.CODE_LEASE_TIME, TimeUnit.SECONDS)) { - weEmpleCodeService.buildRedeemCodeActivityWelcomeMsg(messageMap, corpId, externalUserId); - //同步发送消息 - sendMessageToNewExternalUserId(weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel.getRemark(), corpId, userId, externalUserId, state); - log.info("[欢迎语回调]活动欢迎语处理完成,活动id:{},corpId:{}}", messageMap.getCodeActivityId(), corpId); - //发送欢迎语且更新兑换码信息后,释放锁 - LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId())); - } - } catch (InterruptedException e) { - log.error("[欢迎语回调]活动欢迎语获取锁失败,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); - } catch (Exception e) { - log.error("[欢迎语回调]拼装活动欢迎语 或 同步发送欢迎语消息异常,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); - //内部处理逻辑报错,释放锁 - LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId())); - } + handleRedeemCodeWelcomeMsg(state, userId, externalUserId, corpId, weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel); } //为外部联系人添加员工活码标签 setEmplyCodeTag(weFlowerCustomerRel, empleCodeId, messageMap.getTagFlag()); @@ -247,6 +232,42 @@ private void empleCodeHandle(String state, String welcomeCode, String userId, St } } + /** + * 处理兑换码欢迎语 + * + * @param state 渠道 + * @param userId 员工id + * @param externalUserId 外部联系人id + * @param corpId 企业id + * @param weWelcomeMsgBuilder {@link WeWelcomeMsg.WeWelcomeMsgBuilder} + * @param messageMap {@link SelectWeEmplyCodeWelcomeMsgVO} + * @param weFlowerCustomerRel {@link WeFlowerCustomerRel} + */ + private void handleRedeemCodeWelcomeMsg(String state, String userId, String externalUserId, String corpId, WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder, SelectWeEmplyCodeWelcomeMsgVO messageMap, WeFlowerCustomerRel weFlowerCustomerRel) { + RLock rLock = null; + boolean isHaveLock = false; + try { + final String redeemCodeKey = RedeemCodeConstants.getRedeemCodeKey(corpId, messageMap.getCodeActivityId()); + rLock = LockUtil.getLock(redeemCodeKey); + isHaveLock = rLock.tryLock(RedeemCodeConstants.CODE_WAIT_TIME, RedeemCodeConstants.CODE_LEASE_TIME, TimeUnit.SECONDS); + if (isHaveLock) { + weEmpleCodeService.buildRedeemCodeActivityWelcomeMsg(messageMap, corpId, externalUserId); + //同步发送消息 + sendMessageToNewExternalUserId(weWelcomeMsgBuilder, messageMap, weFlowerCustomerRel.getRemark(), corpId, userId, externalUserId, state); + log.info("[欢迎语回调]活动欢迎语处理完成,活动id:{},corpId:{}}", messageMap.getCodeActivityId(), corpId); + } + } catch (InterruptedException e) { + log.error("[欢迎语回调]活动欢迎语获取锁失败,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); + Thread.currentThread().interrupt(); + } catch (Exception e) { + log.error("[欢迎语回调]拼装活动欢迎语 或 同步发送欢迎语消息异常,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), messageMap.getCodeActivityId(), corpId); + } finally { + if(rLock != null){ + rLock.unlock(); + } + } + } + /** * 给员工活码加入的客户设置备注 @@ -331,7 +352,7 @@ private void setEmplyCodeTag(WeFlowerCustomerRel weFlowerCustomerRel, String emp List weMakeCustomerTagList = new ArrayList<>(); weMakeCustomerTagList.add(weMakeCustomerTag); - weCustomerService.makeLabelbatch(weMakeCustomerTagList); + weCustomerService.batchMakeLabel(weMakeCustomerTagList); } } catch (Exception e) { log.error("setEmplyCodeTag error!! empleCodeId={},e={}", empleCodeId, ExceptionUtils.getStackTrace(e)); @@ -356,7 +377,7 @@ private void sendMessageToNewExternalUserId(WeWelcomeMsg.WeWelcomeMsgBuilder weW if (EmployCodeSourceEnum.NEW_GROUP.getSource().equals(messageMap.getSource())) { // 新客拉群创建的员工活码欢迎语图片(群活码图片) String codeUrl = messageMap.getGroupCodeUrl(); - if (StringUtils.isNotNull(codeUrl)) { + if (StringUtils.isNotBlank(codeUrl)) { String cosImgUrlPrefix = ruoYiConfig.getFile().getCos().getCosImgUrlPrefix(); buildWelcomeMsgImg(corpId, codeUrl, codeUrl.replaceAll(cosImgUrlPrefix, ""), attachmentList); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java index 5c1fb66..eeff855 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java @@ -87,7 +87,10 @@ public void eventHandle(WxCpXmlMessageVO message) { .eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId()) .last(GenConstants.LIMIT_1) ); - weEmpleCodeAnalyseService.saveWeEmpleCodeAnalyse(corpId, message.getUserId(), message.getExternalUserId(), weFlowerCustomerRel.getState(), false); + // state 为空表示不是从活码加的外部联系人 + if(weFlowerCustomerRel != null && StringUtils.isNotBlank(weFlowerCustomerRel.getState())) { + weEmpleCodeAnalyseService.saveWeEmpleCodeAnalyse(corpId, message.getUserId(), message.getExternalUserId(), weFlowerCustomerRel.getState(), false); + } // 客户轨迹:记录删除跟进成员事件 weCustomerTrajectoryService.saveActivityRecord(corpId, message.getUserId(), message.getExternalUserId(), CustomerTrajectoryEnums.SubType.DEL_USER.getType()); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WeUnionIdInterceptor.java b/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WeUnionIdInterceptor.java new file mode 100644 index 0000000..4528602 --- /dev/null +++ b/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WeUnionIdInterceptor.java @@ -0,0 +1,106 @@ +package com.easyink.wecom.interceptor; + + +import com.dtflys.forest.exceptions.ForestRuntimeException; +import com.dtflys.forest.http.ForestRequest; +import com.dtflys.forest.http.ForestResponse; +import com.dtflys.forest.interceptor.Interceptor; +import com.easyink.common.core.redis.RedisCache; +import com.easyink.wecom.client.WeAccessTokenClient; +import com.easyink.wecom.domain.dto.WeAccessTokenDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +import static com.easyink.common.constant.WeConstans.WE_COMMON_ACCESS_TOKEN; + +/** + * 类名: 获取unionId的拦截器 + * + * @author : silver_chariot + * @date : 2023/1/5 14:04 + **/ +@Slf4j +@Component +@AllArgsConstructor +public class WeUnionIdInterceptor implements Interceptor { + private final WeAccessTokenClient accessTokenClient; + private final RedisCache redisCache; + /** + * 请求头上的corpId 和 corpSecret + */ + private static final String HEADER_CORP_ID = "corpId"; + private static final String HEADER_CORP_SECRET = "corpSecret"; + /** + * 请求参数的access_token + */ + private static final String ACCESS_TOKEN = "access_token"; + + @Override + public boolean beforeExecute(ForestRequest request) { + // 获取corpId + String corpId = request.getHeaderValue(HEADER_CORP_ID); + if (corpId == null) { + log.error("[getUnionId]请求头的corpId为空,停止请求"); + return false; + } + // 先获取缓存中的access_token + String accessToken = redisCache.getCacheObject(getAccessTokenKey(corpId)); + if (StringUtils.isBlank(accessToken)) { + // 若缓存不存在, 调用企微接口获取access_token + String corpSecret = request.getHeaderValue(HEADER_CORP_SECRET); + accessToken = getAndCacheToken(corpId, corpSecret); + } + if (StringUtils.isNotBlank(accessToken)) { + // 添加access_token 参数 + request.addQuery(ACCESS_TOKEN, accessToken); + } + return Interceptor.super.beforeExecute(request); + } + + @Override + public void onSuccess(Object data, ForestRequest request, ForestResponse response) { + log.error("请求成功url:【{}】,result:【{}】", request.getUrl(), response.getContent()); + } + + @Override + public void onError(ForestRuntimeException ex, ForestRequest request, ForestResponse response) { + log.error("请求失败url:【{}】,result:【{}】", request.getUrl(), response.getContent()); + + } + + /** + * 获取access_token 并缓存 + * + * @param corpId 企业id + * @param corpSecret 企业秘钥 + * @return access_token + */ + private String getAndCacheToken(String corpId, String corpSecret) { + if (StringUtils.isAnyBlank(corpId, corpSecret)) { + return StringUtils.EMPTY; + } + WeAccessTokenDTO accessTokenDTO = accessTokenClient.getToken(corpId, corpSecret); + if (accessTokenDTO == null || accessTokenDTO.getExpires_in() == null + || StringUtils.isBlank(accessTokenDTO.getAccess_token())) { + return StringUtils.EMPTY; + } + // 缓存token + redisCache.setCacheObject(getAccessTokenKey(corpId), accessTokenDTO.getAccess_token(), accessTokenDTO.getExpires_in() + .intValue(), TimeUnit.SECONDS); + return accessTokenDTO.getAccess_token(); + } + + /** + * 获取access_token缓存的redis key + * + * @param corpId 企业id + * @return redis key + */ + private String getAccessTokenKey(String corpId) { + return WE_COMMON_ACCESS_TOKEN + ":" + corpId; + } +} diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WechatOpenInterceptor.java b/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WechatOpenInterceptor.java index 7d03a47..a5ad160 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WechatOpenInterceptor.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/interceptor/WechatOpenInterceptor.java @@ -25,7 +25,7 @@ public class WechatOpenInterceptor implements Interceptor { private final WechatOpenService wechatOpenService; private final WechatOpenConfig wechatOpenConfig; - private final static String API_PREFIX = "https://api.weixin.qq.com"; + private static final String API_PREFIX = "https://api.weixin.qq.com"; @Lazy public WechatOpenInterceptor(WechatOpenService wechatOpenService, WechatOpenConfig wechatOpenConfig) { diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/login/util/LoginTokenService.java b/easyink-wecom/src/main/java/com/easyink/wecom/login/util/LoginTokenService.java index dda4e19..a0ef78a 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/login/util/LoginTokenService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/login/util/LoginTokenService.java @@ -110,10 +110,11 @@ public static void refreshDataScope(LoginUser loginUser) { */ public static void refreshDataScope(String userKey) { RedisCache redisCache = SpringUtils.getBean(RedisCache.class); - LoginUser loginUser = redisCache.getCacheObject(userKey); + TokenService tokenService = SpringUtils.getBean(TokenService.class); + LoginUser loginUser = tokenService.getLoginUserByUserKey(userKey); if (null != loginUser) { SpringUtils.getBean(SysPermissionService.class).setRoleAndDepartmentDataScope(loginUser); - redisCache.setCacheObject(userKey, loginUser, TokenService.expireTime, TimeUnit.MINUTES); + redisCache.setCacheObject(userKey, loginUser, tokenService.getExpireTime(), TimeUnit.MINUTES); } } @@ -184,11 +185,12 @@ public static void refreshWeUser(LoginUser loginUser) { return; } loginUser.setLoginTime(System.currentTimeMillis()); - loginUser.setExpireTime(loginUser.getLoginTime() + TokenService.expireTime * TokenService.MILLIS_MINUTE); + TokenService tokenService = SpringUtils.getBean(TokenService.class); + String currentUserKey = tokenService.getUserKey(loginUser.getToken()); + loginUser.setExpireTime(loginUser.getLoginTime() + tokenService.getExpireTime() * TokenService.MILLIS_MINUTE); // 获取当前登录用户 RedisCache redisCache = SpringUtils.getBean(RedisCache.class); - String currentUserKey = SpringUtils.getBean(TokenService.class).getUserKey(loginUser.getToken()); - redisCache.setCacheObject(currentUserKey, loginUser, TokenService.expireTime, TimeUnit.MINUTES); + redisCache.setCacheObject(currentUserKey, loginUser, tokenService.getExpireTime(), TimeUnit.MINUTES); } /** diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/WeTagMapper.java b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/WeTagMapper.java index 4e593be..dc5ddf8 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/WeTagMapper.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/WeTagMapper.java @@ -33,11 +33,10 @@ public interface WeTagMapper extends BaseMapper { /** * 删除企业微信标签 - * @deprecated 调用方法已弃用 + * * @param groupIds 企业微信标签组Id * @return 结果 */ - @Deprecated int deleteWeTagByGroupId(String[] groupIds); /** diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/moment/WeMomentTaskResultMapper.java b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/moment/WeMomentTaskResultMapper.java index f1d04b6..f21ac1d 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/moment/WeMomentTaskResultMapper.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/moment/WeMomentTaskResultMapper.java @@ -2,8 +2,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.easyink.wecom.domain.entity.moment.WeMomentTaskResultEntity; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; import org.springframework.stereotype.Repository; +import java.util.Date; + /** * @author 佚名 * @date 2022-01-07 18:01:50 @@ -11,4 +15,13 @@ @Repository public interface WeMomentTaskResultMapper extends BaseMapper { + /** + * 更新发布信息 + * @param momentTaskId 任务id + * @param userId 用户id + * @param publishStatus 发布状态 + * @param publishTime 发布时间 + */ + void updatePublishInfo(@Param("momentTaskId") Long momentTaskId, @Param("userId") String userId, @Param("publishStatus") Integer publishStatus, @Param("publishTime") Date publishTime); + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarChannelMapper.java b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarChannelMapper.java index 61ee394..004561e 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarChannelMapper.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarChannelMapper.java @@ -20,9 +20,8 @@ public interface WeRadarChannelMapper extends BaseMapper { /** * 查询渠道列表 * - * @param radarChannelDTO - * @param isSuperAdmin + * @param radarChannelDTO {@link com.easyink.wecom.domain.dto.radar.RadarChannelDTO} * @return */ - List list(@Param("channel") SearchRadarChannelDTO radarChannelDTO, @Param("isSuperAdmin") boolean isSuperAdmin); + List list(@Param("channel") SearchRadarChannelDTO radarChannelDTO); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarMapper.java b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarMapper.java index 66c1eee..49cc496 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarMapper.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/mapper/radar/WeRadarMapper.java @@ -24,10 +24,9 @@ public interface WeRadarMapper extends BaseMapper { * 查询雷达列表 * * @param radarDTO - * @param isSuperAdmin * @return */ - List list(@Param("radar") SearchRadarDTO radarDTO, @Param("isSuperAdmin") boolean isSuperAdmin); + List list(@Param("radar") SearchRadarDTO radarDTO); /** diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerMessagePushService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerMessagePushService.java index 6170e3d..10267e3 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerMessagePushService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerMessagePushService.java @@ -72,13 +72,6 @@ public interface WeCustomerMessagePushService { */ void updateTimeTask(CustomerMessagePushDTO customerMessagePushDTO, LoginUser loginUser) throws ParseException; - /** - * 获取定时任务信息 - * @param messageId 消息 - * @return {@link CustomerMessagePushDTO} - */ - CustomerMessagePushDTO getMessageInfo(Long messageId); - /** * 获取需要复制的信息 * diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerService.java index 31b57fa..2bdbe28 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerService.java @@ -11,6 +11,7 @@ import com.easyink.wecom.domain.dto.customer.EditCustomerDTO; import com.easyink.wecom.domain.dto.pro.EditCustomerFromPlusDTO; import com.easyink.wecom.domain.dto.tag.RemoveWeCustomerTagDTO; +import com.easyink.wecom.domain.dto.unionid.GetUnionIdDTO; import com.easyink.wecom.domain.entity.WeCustomerExportDTO; import com.easyink.wecom.domain.vo.QueryCustomerFromPlusVO; import com.easyink.wecom.domain.vo.WeMakeCustomerTagVO; @@ -18,6 +19,7 @@ import com.easyink.wecom.domain.vo.customer.WeCustomerUserListVO; import com.easyink.wecom.domain.vo.customer.WeCustomerVO; import com.easyink.wecom.domain.vo.sop.CustomerSopVO; +import com.easyink.wecom.domain.vo.unionid.GetUnionIdVO; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotBlank; @@ -104,14 +106,14 @@ public interface WeCustomerService extends IService { * @param weMakeCustomerTagVOS * @param updateBy 操作人 */ - void makeLabelbatch(List weMakeCustomerTagVOS, String updateBy); + void batchMakeLabel(List weMakeCustomerTagVOS, String updateBy); /** * 客户批量打标签 * * @param weMakeCustomerTagVOS */ - void makeLabelbatch(List weMakeCustomerTagVOS); + void batchMakeLabel(List weMakeCustomerTagVOS); /** * 移除客户标签(单个客户) @@ -294,4 +296,12 @@ public interface WeCustomerService extends IService { * @return */ List getCustomer(String corpId, String customerName); + + /** + * 根据external_user_id获取用户的unionId + * + * @param getUnionIdDTO 客户id和企业secret等参数 {@link GetUnionIdDTO } + * @return {@link GetUnionIdVO} + */ + GetUnionIdVO getDetailByExternalUserId(GetUnionIdDTO getUnionIdDTO); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerTrajectoryService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerTrajectoryService.java index 3c79f4d..459c194 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerTrajectoryService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeCustomerTrajectoryService.java @@ -9,9 +9,10 @@ import com.easyink.wecom.domain.WeTag; import com.easyink.wecom.domain.dto.customer.EditCustomerDTO; import com.easyink.wecom.domain.entity.radar.WeRadar; +import io.swagger.annotations.ApiModel; import java.util.List; - +@ApiModel("活动轨迹相关Service") public interface WeCustomerTrajectoryService extends IService { void waitHandleMsg(String url); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeGroupService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeGroupService.java index 92229f1..cced9a2 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeGroupService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeGroupService.java @@ -142,4 +142,11 @@ public interface WeGroupService extends IService { * @return */ AjaxResult export(FindWeGroupDTO weGroupDTO); + + /** + * 定时任务处理客户群聊统计 + * + * @param corpId 企业id + */ + void processGroupChatData(String corpId); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeUserService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeUserService.java index 9cace5f..8bd1974 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/WeUserService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/WeUserService.java @@ -303,4 +303,11 @@ public interface WeUserService extends IService { */ WeUser getWeUserByExternalMapping(String externalUserId, String externalCorpId); + /** + * 联系客户统计 + * + * @param corpId 企业id + */ + void getUserBehaviorDataByCorpId(String corpId); + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/ExtendPropertyMultipleOptionServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/ExtendPropertyMultipleOptionServiceImpl.java index 171bab6..ebd4ec8 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/ExtendPropertyMultipleOptionServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/ExtendPropertyMultipleOptionServiceImpl.java @@ -11,10 +11,8 @@ import com.easyink.wecom.service.ExtendPropertyMultipleOptionService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.validation.constraints.NotNull; import java.util.Collections; import java.util.List; import java.util.Map; @@ -30,12 +28,6 @@ @Slf4j public class ExtendPropertyMultipleOptionServiceImpl extends ServiceImpl implements ExtendPropertyMultipleOptionService { - private final ExtendPropertyMultipleOptionMapper extendPropertyMultipleOptionMapper; - - @Autowired - public ExtendPropertyMultipleOptionServiceImpl(@NotNull ExtendPropertyMultipleOptionMapper extendPropertyMultipleOptionMapper) { - this.extendPropertyMultipleOptionMapper = extendPropertyMultipleOptionMapper; - } @Override public void edit(List list, Long propId) { @@ -65,7 +57,7 @@ public void edit(WeCustomerExtendProperty property) { for (ExtendPropertyMultipleOption option : property.getOptionList()) { if (option.getId() == null && propId != null) { option.setExtendPropertyId(propId); - }else if (!propId.equals(option.getExtendPropertyId())) { + }else if (propId == null || !propId.equals(option.getExtendPropertyId())) { log.warn("自定义参数:编辑多选值的自定义参数id与自定义参数实体id不一致"); throw new CustomException(ResultTip.TIP_GENERAL_PARAM_ERROR); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeAutoConfigServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeAutoConfigServiceImpl.java index ea59160..393fb26 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeAutoConfigServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeAutoConfigServiceImpl.java @@ -149,6 +149,9 @@ public WeCheckQrcodeVO check(String qrcodeKey, String status, LoginUser loginUse // 先判断是否需要短信验证 if (needMobileConfirm(weLoginRespStr)) { WeConfirmMobileRsp mobileRsp = filterConfirmMobile(weLoginRespStr); + if(mobileRsp == null || StringUtils.isBlank(mobileRsp.getTlKey())){ + return new WeCheckQrcodeVO(qrcodeStatus); + } log.info("[checkQrCode]需要短信验证,截取到的tlKEy:{}", mobileRsp); // 根据该qrcodeKey锁720s,不再处理前端发起的其他check请求 redisCache.addLock(confirmRedisKey(qrcodeKey), mobileRsp.getTlKey(), 720L); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCorpAccountServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCorpAccountServiceImpl.java index 881a688..79761ea 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCorpAccountServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCorpAccountServiceImpl.java @@ -529,7 +529,7 @@ public WeCorpAccount findValidWeCorpAccount(String corpId) { .and(i -> i.eq(WeCorpAccount::getStatus, Constants.NORMAL_CODE).or().eq(WeCorpAccount::getStatus, Constants.NOT_START_CODE)) .last(GenConstants.LIMIT_1)); } - if (ObjectUtils.isNotEmpty(weCorpAccount) + if (null != weCorpAccount && Constants.NORMAL_CODE.equals(weCorpAccount.getStatus()) && StringUtils.isNoneBlank(weCorpAccount.getCorpId(), weCorpAccount.getCustomSecret(), diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerExtendPropertyServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerExtendPropertyServiceImpl.java index e053f82..d79ed13 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerExtendPropertyServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerExtendPropertyServiceImpl.java @@ -107,7 +107,7 @@ public void validate(WeCustomerExtendProperty property) { throw new CustomException(ResultTip.TIP_GENERAL_PARAM_ERROR); } // 不允许与系统默认字段重复名字 - if (ListUtil.toList(UserConstants.SYS_DEFAULT_PROPERTIES).contains(property.getName())) { + if (ListUtil.toList(UserConstants.getSysDefaultProperties()).contains(property.getName())) { throw new CustomException(ResultTip.TIP_IS_SYS_PROP_NAME); } if (!isUnique(property)) { @@ -231,6 +231,17 @@ public void editBatch(BatchSaveCustomerExtendPropertyDTO dto) { property.setCorpId(corpId); list.add(property); } + // 删除property中的多选框选项重新插入,这样可以不用排序,直接用传过来的顺序排序 + List removeExtendPropertyIds = new ArrayList<>(); + list.forEach(it -> { + // 记录extendPropertyId + removeExtendPropertyIds.add(it.getId()); + // 将多选框id置为空,重新插入 + it.getOptionList().forEach(option -> option.setId(null)); + }); + if (CollectionUtils.isNotEmpty(removeExtendPropertyIds)) { + extendPropertyMultipleOptionService.remove(new LambdaQueryWrapper().in(ExtendPropertyMultipleOption::getExtendPropertyId, removeExtendPropertyIds)); + } this.editBatch(list, corpId); } @@ -264,7 +275,7 @@ public void setKeyValueMapper(String corpId, List customerLi return; } // 过滤系统默认字段 - selectedProperties = selectedProperties.stream().filter(a -> !ListUtil.toList(UserConstants.SYS_DEFAULT_PROPERTIES).contains(a)).collect(Collectors.toList()); + selectedProperties = selectedProperties.stream().filter(a -> !ListUtil.toList(UserConstants.getSysDefaultProperties()).contains(a)).collect(Collectors.toList()); // 查询该企业所有的扩展属性详情 List extendPropList = this.getList( WeCustomerExtendProperty.builder() diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerMessagePushServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerMessagePushServiceImpl.java index b7d943a..eb873ba 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerMessagePushServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerMessagePushServiceImpl.java @@ -280,17 +280,6 @@ public void updateTimeTask(CustomerMessagePushDTO customerMessagePushDTO, LoginU } } - @Override - @Deprecated - public CustomerMessagePushDTO getMessageInfo(Long messageId) { - if (messageId == null) { - return new CustomerMessagePushDTO(); - } - WeCustomerMessageTimeTask timeTask = getTimeTask(messageId); - buildUserAndDepartmentInfo(timeTask.getMessageInfo().getCorpId(), timeTask.getMessageInfo().getDepartment(), timeTask.getMessageInfo().getStaffId(), timeTask.getMessageInfo()); - return timeTask.getMessageInfo(); - } - /** * 获取定时任务信息 * diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerServiceImpl.java index d31bcae..7369239 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerServiceImpl.java @@ -19,18 +19,22 @@ import com.easyink.common.utils.bean.BeanUtils; import com.easyink.common.utils.poi.ExcelUtil; import com.easyink.common.utils.sql.BatchInsertUtil; +import com.easyink.common.utils.wecom.CorpSecretDecryptUtil; import com.easyink.wecom.client.WeCustomerClient; +import com.easyink.wecom.client.WeUnionIdClient; import com.easyink.wecom.client.WeUserClient; import com.easyink.wecom.domain.*; import com.easyink.wecom.domain.dto.*; import com.easyink.wecom.domain.dto.customer.CustomerTagEdit; import com.easyink.wecom.domain.dto.customer.EditCustomerDTO; +import com.easyink.wecom.domain.dto.customer.ExternalUserDetail; import com.easyink.wecom.domain.dto.customer.GetExternalDetailResp; import com.easyink.wecom.domain.dto.customer.req.GetByUserReq; import com.easyink.wecom.domain.dto.customer.resp.GetByUserResp; import com.easyink.wecom.domain.dto.customersop.Column; import com.easyink.wecom.domain.dto.pro.EditCustomerFromPlusDTO; import com.easyink.wecom.domain.dto.tag.RemoveWeCustomerTagDTO; +import com.easyink.wecom.domain.dto.unionid.GetUnionIdDTO; import com.easyink.wecom.domain.entity.WeCustomerExportDTO; import com.easyink.wecom.domain.vo.QueryCustomerFromPlusVO; import com.easyink.wecom.domain.vo.WeCustomerExportVO; @@ -39,12 +43,14 @@ import com.easyink.wecom.domain.vo.customer.WeCustomerUserListVO; import com.easyink.wecom.domain.vo.customer.WeCustomerVO; import com.easyink.wecom.domain.vo.sop.CustomerSopVO; +import com.easyink.wecom.domain.vo.unionid.GetUnionIdVO; import com.easyink.wecom.mapper.WeCustomerMapper; import com.easyink.wecom.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; @@ -93,6 +99,10 @@ public class WeCustomerServiceImpl extends ServiceImpl list, String updateBy) { + public void batchMakeLabel(List list, String updateBy) { if (CollUtil.isEmpty(list)) { return; } @@ -454,8 +468,9 @@ public void makeLabelbatch(List list, String updateBy) { } @Override - public void makeLabelbatch(List weMakeCustomerTagVOS) { - this.makeLabelbatch(weMakeCustomerTagVOS, null); + @Transactional(rollbackFor = Exception.class) + public void batchMakeLabel(List weMakeCustomerTagVOS) { + ((WeCustomerService)AopContext.currentProxy()).batchMakeLabel(weMakeCustomerTagVOS, null); } /** @@ -519,7 +534,7 @@ public List getCustomerTagEdits(WeMakeCustomerTagVO weMakeCusto * @param weMakeCustomerTag * @return */ - private void batchMarkCustomTag(WeMakeCustomerTagVO weMakeCustomerTag) { + public void batchMarkCustomTag(WeMakeCustomerTagVO weMakeCustomerTag) { if (StringUtils.isAnyBlank(weMakeCustomerTag.getUserId(), weMakeCustomerTag.getExternalUserid(), weMakeCustomerTag.getCorpId())) { log.error("员工id,客户id,公司id不能为空,userId:{},externalUserId:{},corpId:{}", weMakeCustomerTag.getUserId(), weMakeCustomerTag.getExternalUserid(), weMakeCustomerTag.getCorpId()); throw new CustomException("增量式打标签错误"); @@ -615,6 +630,7 @@ public void removeAllLabel(WeFlowerCustomerRel flowerCustomerRel) { } @Override + @Transactional(rollbackFor = Exception.class) public void removeLabel(String corpId, String externalUserid, String userid, List delIdList) { RemoveWeCustomerTagDTO dto = new RemoveWeCustomerTagDTO(); List list = new ArrayList<>(); @@ -828,6 +844,7 @@ public QueryCustomerFromPlusVO getDetailByUserIdAndCustomerAvatar(String corpId, } @Override + @Transactional(rollbackFor = Exception.class) public void editByUserIdAndCustomerAvatar(EditCustomerFromPlusDTO dto) { if (org.apache.commons.lang3.StringUtils.isAnyBlank(dto.getCorpId(), dto.getAvatar(), dto.getUserId())) { return; @@ -890,4 +907,17 @@ public List getCustomer(String corpId, String customerName) { return this.baseMapper.listCustomers(customerName, corpId); } + @Override + public GetUnionIdVO getDetailByExternalUserId(GetUnionIdDTO getUnionIdDTO) { + if(getUnionIdDTO == null || StringUtils.isAnyBlank(getUnionIdDTO.getCorpId(),getUnionIdDTO.getExternalUserId(), getUnionIdDTO.getCorpSecret())) { + throw new CustomException(ResultTip.TIP_PARAM_MISSING); + } + String corpSecret = corpSecretDecryptUtil.decryptUnionId(getUnionIdDTO.getCorpSecret()) ; + ExternalUserDetail userDetail = weUnionIdClient.getByExternalUserId(getUnionIdDTO.getExternalUserId(), getUnionIdDTO.getCorpId(), corpSecret); + if(userDetail == null || userDetail.getExternal_contact() == null ) { + throw new CustomException(ResultTip.TIP_GET_UNION_ID_FAIL); + } + return new GetUnionIdVO(userDetail.getExternal_contact()); + } + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerTrajectoryServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerTrajectoryServiceImpl.java index d611157..6737aac 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerTrajectoryServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeCustomerTrajectoryServiceImpl.java @@ -14,7 +14,6 @@ import com.easyink.common.enums.CustomerTrajectoryEnums; import com.easyink.common.enums.ExternalGroupMemberTypeEnum; import com.easyink.common.enums.MessageType; -import com.easyink.common.utils.StringUtils; import com.easyink.wecom.client.WeMessagePushClient; import com.easyink.wecom.domain.*; import com.easyink.wecom.domain.dto.WeMessagePushDTO; @@ -28,10 +27,12 @@ import com.easyink.wecom.mapper.WeCustomerTrajectoryMapper; import com.easyink.wecom.mapper.WeUserMapper; import com.easyink.wecom.service.*; +import io.swagger.annotations.ApiModel; import joptsimple.internal.Strings; import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +46,7 @@ @Service @Slf4j +@ApiModel("活动轨迹相关Service") public class WeCustomerTrajectoryServiceImpl extends ServiceImpl implements WeCustomerTrajectoryService { @@ -130,7 +132,7 @@ public void recordEditCustomerOperation(String corpId, String userId, String ext .corpId(corpId) .userId(userId) .externalUserid(externalUserId) - .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getDesc()) .createDate(new Date()) .detail(value) .content(content) @@ -173,7 +175,7 @@ public void recordEditExtendPropOperation(String corpId, String userId, String e .userId(userId) .externalUserid(externalUserId) .createDate(new Date()) - .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getDesc()) .content(buildContent(updateBy, prop.getKey().getName())) .subType(CustomerExtendPropertyEnum.getByType(prop.getKey().getType()).getOprSubType().getType()) .detail(prop.getValue()) @@ -213,7 +215,7 @@ public void recordEditTagOperation(String corpId, String userId, String external .userId(userId) .externalUserid(externalUserId) .createDate(new Date()) - .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.INFO.getDesc()) .content(buildContent(updateBy, GenConstants.CUSTOMER_TAG)) .subType(CustomerTrajectoryEnums.SubType.EDIT_TAG.getType()) .detail(editTagStr) @@ -281,15 +283,16 @@ public void saveActivityRecord(List list, String subType) { continue; } WeGroup group = weGroupService.getById(member.getChatId()); - if (group == null) { + if (group == null || StringUtils.isBlank(group.getGroupName())) { log.info("[活动轨迹]记录客户加入/退出群聊,群聊详情获取失败,member:{}", member); + continue; } // 组装文本 content = model.replace(GenConstants.CUSTOMER, member.getMemberName()) .replace(GenConstants.GROUP_NAME, group.getGroupName()); WeCustomerTrajectory trajectory = WeCustomerTrajectory.builder() .externalUserid(member.getUserId()) - .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getDesc()) .content(content) .createDate(new Date()) .detail(group.getGroupName()) @@ -333,7 +336,7 @@ public void saveActivityRecord(String corpId, String userId, String externalUser WeCustomerTrajectory trajectory = WeCustomerTrajectory.builder() .userId(userId) .externalUserid(externalUserId) - .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getDesc()) .content(content) .createDate(new Date()) .detail(user.getAvatarMediaid()) @@ -352,7 +355,7 @@ public List listOfTrajectory(String corpId, String externa .ne(WeCustomerTrajectory::getStatus, CustomerTrajectoryEnums.TodoTaskStatusEnum.DEL.getCode()) .eq(WeCustomerTrajectory::getExternalUserid, externalUserid) .eq(WeCustomerTrajectory::getTrajectoryType, trajectoryType); - if (CustomerTrajectoryEnums.Type.TO_DO.getType().equals(trajectoryType)) { + if (CustomerTrajectoryEnums.Type.TO_DO.getDesc().equals(trajectoryType)) { wrapper.eq(WeCustomerTrajectory::getUserId, userId); isTodo = true; } @@ -371,7 +374,7 @@ public List listOfTrajectory(String corpId, String externa } } // 如果是信息动态,则 过滤掉非当前操作人操作的记录 - if (CustomerTrajectoryEnums.Type.INFO.getType().equals(trajectoryType)) { + if (CustomerTrajectoryEnums.Type.INFO.getDesc().equals(trajectoryType)) { LoginUser loginUser = LoginTokenService.getLoginUser(); return trajectoryList.stream().filter(a -> loginUser.getUserId().equals(a.getUserId())).collect(Collectors.toList()); } @@ -392,7 +395,7 @@ public void recordRadarClickOperation(WeRadar radar, WeUser user, WeCustomer cus WeCustomerTrajectory trajectory = WeCustomerTrajectory.builder() .userId(user.getUserId()) .externalUserid(customer.getExternalUserid()) - .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getType()) + .trajectoryType(CustomerTrajectoryEnums.Type.ACTIVITY.getDesc()) .content(content) .createDate(new Date()) .detail(user.getAvatarMediaid()) diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupCodeActualServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupCodeActualServiceImpl.java index 56a3feb..001baba 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupCodeActualServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupCodeActualServiceImpl.java @@ -17,6 +17,7 @@ import com.easyink.wecom.service.We3rdAppService; import com.easyink.wecom.service.WeGroupCodeActualService; import org.apache.commons.collections4.CollectionUtils; +import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -164,16 +165,18 @@ public List selectByGroupCodeId(Long groupCodeId) { * @return */ @Override + @Transactional(rollbackFor = Exception.class) public List addBatch(List weGroupCodeActualList, Long groupCodeId, String corpId) { checkBatch(weGroupCodeActualList, corpId); // 判断应用类型 String serverType = we3rdAppService.getServerType().getServerType(); // 保存 + WeGroupCodeActualService weGroupCodeActualService = (WeGroupCodeActualService) AopContext.currentProxy(); if (ServerTypeEnum.THIRD.getType().equals(serverType)) { - this.addThirdWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId); + weGroupCodeActualService.addThirdWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId); } if (ServerTypeEnum.INTERNAL.getType().equals(serverType)) { - this.addInnerWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId, Boolean.TRUE, corpId); + weGroupCodeActualService.addInnerWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId, Boolean.TRUE, corpId); } return weGroupCodeActualList; } @@ -325,17 +328,19 @@ private void checkParams(List weGroupCodeActualList) { * @return */ @Override + @Transactional(rollbackFor = Exception.class) public int editBatch(List weGroupCodeActualList, Long groupCodeId, String corpId) { checkBatch(weGroupCodeActualList, corpId); // 判断应用类型 String serverType = we3rdAppService.getServerType().getServerType(); // 保存 int result = 0; + WeGroupCodeActualService weGroupCodeActualService = (WeGroupCodeActualService) AopContext.currentProxy(); if (ServerTypeEnum.THIRD.getType().equals(serverType)) { - result = this.editThirdWeGroupCodeCorpActualBatch(weGroupCodeActualList); + result = weGroupCodeActualService.editThirdWeGroupCodeCorpActualBatch(weGroupCodeActualList); } if (ServerTypeEnum.INTERNAL.getType().equals(serverType)) { - result = this.editInnerWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId, Boolean.TRUE, corpId); + result = weGroupCodeActualService.editInnerWeGroupCodeCorpActualBatch(weGroupCodeActualList, groupCodeId, Boolean.TRUE, corpId); } return result; } @@ -428,17 +433,19 @@ private void checkThirdParamsEdit(List weGroupCodeActualList) * @return */ @Override + @Transactional(rollbackFor = Exception.class) public int removeBatch(List removeIds, String corpId) { checkRemoveBatch(removeIds, corpId); // 判断应用类型 String serverType = we3rdAppService.getServerType().getServerType(); // 保存 + WeGroupCodeActualService weGroupCodeActualService = (WeGroupCodeActualService) AopContext.currentProxy(); int result = 0; if (ServerTypeEnum.THIRD.getType().equals(serverType)) { - result = this.removeThirdWeGroupCodeActualByIds(removeIds); + result = weGroupCodeActualService.removeThirdWeGroupCodeActualByIds(removeIds); } if (ServerTypeEnum.INTERNAL.getType().equals(serverType)) { - result = this.removeInnerWeGroupCodeActualByIds(removeIds, corpId); + result = weGroupCodeActualService.removeInnerWeGroupCodeActualByIds(removeIds, corpId); } return result; } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupServiceImpl.java index 27fe60d..d8016fc 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupServiceImpl.java @@ -2,9 +2,12 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.easyink.common.annotation.DataScope; +import com.easyink.common.constant.GroupConstants; import com.easyink.common.constant.WeConstans; import com.easyink.common.core.domain.AjaxResult; import com.easyink.common.enums.CustomerTrajectoryEnums; @@ -12,18 +15,24 @@ import com.easyink.common.exception.BaseException; import com.easyink.common.exception.CustomException; import com.easyink.common.utils.DateUtils; +import com.easyink.common.utils.MyDateUtil; import com.easyink.common.utils.SnowFlakeUtil; import com.easyink.common.utils.StringUtils; +import com.easyink.common.utils.bean.BeanUtils; import com.easyink.common.utils.poi.ExcelUtil; +import com.easyink.wecom.client.WeCustomerClient; import com.easyink.wecom.client.WeCustomerGroupClient; import com.easyink.wecom.domain.WeCustomerAddGroup; import com.easyink.wecom.domain.WeGroup; import com.easyink.wecom.domain.WeGroupMember; +import com.easyink.wecom.domain.WeGroupStatistic; import com.easyink.wecom.domain.dto.FindWeGroupDTO; +import com.easyink.wecom.domain.dto.GroupChatStatisticDTO; import com.easyink.wecom.domain.dto.WeGroupMemberDTO; import com.easyink.wecom.domain.dto.customer.CustomerGroupDetail; import com.easyink.wecom.domain.dto.customer.CustomerGroupList; import com.easyink.wecom.domain.dto.customer.CustomerGroupMember; +import com.easyink.wecom.domain.query.GroupChatStatisticQuery; import com.easyink.wecom.domain.vo.WeGroupExportVO; import com.easyink.wecom.domain.vo.sop.GroupSopVO; import com.easyink.wecom.domain.vo.wegrouptag.WeGroupTagRelDetail; @@ -32,6 +41,7 @@ import com.easyink.wecom.service.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -61,15 +71,19 @@ public class WeGroupServiceImpl extends ServiceImpl impl private final PageHomeService pageHomeService; private final WeGroupTagRelService weGroupTagRelService; private final WeCustomerTrajectoryService weCustomerTrajectoryService; + private final WeGroupStatisticService weGroupStatisticService; + private final WeCustomerClient weCustomerClient; @Autowired @Lazy - public WeGroupServiceImpl(WeCustomerGroupClient weCustomerGroupClient, WeGroupMemberService weGroupMemberService, PageHomeService pageHomeService, WeGroupTagRelService weGroupTagRelService, WeCustomerTrajectoryService weCustomerTrajectoryService) { + public WeGroupServiceImpl(WeCustomerGroupClient weCustomerGroupClient, WeGroupMemberService weGroupMemberService, PageHomeService pageHomeService, WeGroupTagRelService weGroupTagRelService, WeCustomerTrajectoryService weCustomerTrajectoryService, WeGroupStatisticService weGroupStatisticService, WeCustomerClient weCustomerClient) { this.weCustomerGroupClient = weCustomerGroupClient; this.weGroupMemberService = weGroupMemberService; this.pageHomeService = pageHomeService; this.weGroupTagRelService = weGroupTagRelService; this.weCustomerTrajectoryService = weCustomerTrajectoryService; + this.weGroupStatisticService = weGroupStatisticService; + this.weCustomerClient = weCustomerClient; } private static final int LENGTH = 3; @@ -584,4 +598,91 @@ public AjaxResult export(FindWeGroupDTO weGroup) { ExcelUtil util = new ExcelUtil<>(WeGroupExportVO.class); return util.exportExcel(exportList, sheetName); } + + @Override + @Transactional(rollbackFor = Exception.class) + public void processGroupChatData(String corpId) { + // 偏移量 大于500则分批处理 + final int OFFSET = 500; + if (org.apache.commons.lang3.StringUtils.isBlank(corpId)) { + return; + } + + //删除本日原先的数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + Long startTime = MyDateUtil.strToDate(-1, 0); + Long endTime = MyDateUtil.strToDate(-1, 1); + wrapper.eq(WeGroupStatistic::getCorpId, corpId); + wrapper.between(WeGroupStatistic::getStatTime, DateUtil.date(startTime * 1000), DateUtil.date(endTime * 1000)); + int count = weGroupStatisticService.count(wrapper); + //删除所有数据 + if (count > 0) { + weGroupStatisticService.remove(wrapper); + } + + //判断是否大于500,判断是否分批处理 + int weGroupCount = this.count( + new LambdaQueryWrapper() + .eq(WeGroup::getCorpId, corpId) + ); + //定义批量操作 + double num = 1; + if (weGroupCount > OFFSET) { + num = Math.ceil((double) weGroupCount / OFFSET); + } + int temp = 0; + List list = new ArrayList<>(2); + list.add(GroupConstants.OWNER_LEAVE); + list.add(GroupConstants.OWNER_LEAVE_EXTEND); + for (int i = 0; i < num; i++) { + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.select("DISTINCT owner"); + wrapper1.eq("corp_id", corpId); + wrapper1.notIn("status", list); + wrapper1.last("limit " + temp + "," + OFFSET); + List weGroupList = this.list(wrapper1); + + if (CollUtil.isNotEmpty(weGroupList)) { + List weGroupStatisticList = new ArrayList<>(); + GroupChatStatisticQuery query = new GroupChatStatisticQuery(); + //前一天的数据 + query.setDay_begin_time(startTime); + query.setDay_end_time(endTime); + + weGroupList.forEach(weGroup -> { + + GroupChatStatisticQuery.OwnerFilter ownerFilter = new GroupChatStatisticQuery.OwnerFilter(); + List idList = new ArrayList<>(); + idList.add(weGroup.getOwner()); + ownerFilter.setUserid_list(idList); + query.setOwner_filter(ownerFilter); + try { + //状态不是离职继承中的,离职继承中的群聊无法查询 + //根据群主获取群聊概述 + GroupChatStatisticDTO groupChatStatistic = weCustomerClient.getGroupChatStatistic(query, corpId); + List items = groupChatStatistic.getItems(); + if (CollUtil.isNotEmpty(items)) { + items.forEach(groupChatStatisticData -> { + WeGroupStatistic weGroupStatistic = new WeGroupStatistic(); + GroupChatStatisticDTO.StatisticData data = groupChatStatisticData.getData(); + BeanUtils.copyPropertiesignoreOther(data, weGroupStatistic); + weGroupStatistic.setChatId(groupChatStatisticData.getOwner()); + //返回数据不包含时间,所以使用开始时间做stat_time + weGroupStatistic.setStatTime(DateUtil.date(startTime * 1000)); + weGroupStatistic.setCorpId(corpId); + weGroupStatisticList.add(weGroupStatistic); + }); + } + } catch (Exception e) { + log.error("群聊数据拉取失败: ownerFilter:【{}】,ex:【{}】", JSON.toJSONString(ownerFilter), ExceptionUtils.getStackTrace(e)); + } + }); + + + weGroupStatisticService.saveBatch(weGroupStatisticList); + } + + temp += OFFSET; + } + } } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupSopV2ServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupSopV2ServiceImpl.java index e693fc5..cedfa2f 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupSopV2ServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeGroupSopV2ServiceImpl.java @@ -184,7 +184,7 @@ private void updateCustomerFilter(Date createTime,String corpId, Long sopId, Int * @param chatIdList 作用范围 */ private void updateSopFilter(String corpId, Long sopId, Integer sopType, Integer filterType, AddGroupSopFilterDTO sopFilter, List chatIdList) { - if (StringUtils.isBlank(corpId) || sopId == null || filterType == null) { + if (StringUtils.isBlank(corpId) || sopId == null || filterType == null || sopFilter == null) { throw new CustomException(ResultTip.TIP_GENERAL_BAD_REQUEST); } //筛选条件 diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeMaterialServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeMaterialServiceImpl.java index 802d004..a6218a2 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeMaterialServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeMaterialServiceImpl.java @@ -75,7 +75,7 @@ public WeMaterialFileVO uploadWeMaterialFile(MultipartFile file, String type) { //上传临时素材 Optional mediaType = com.easyink.common.enums.MediaType.of(type); if (!mediaType.isPresent()) { - throw new WeComException("媒体类型出错!"); + throw new WeComException(ResultTip.TIP_MEDIA_TYPE_ERROR.getTipMsg()); } //构造返回结果 String cosImgUrlPrefix = ruoYiConfig.getFile().getCos().getCosImgUrlPrefix(); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeOperationsCenterSopServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeOperationsCenterSopServiceImpl.java index 9e39600..1277e23 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeOperationsCenterSopServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeOperationsCenterSopServiceImpl.java @@ -319,7 +319,7 @@ public void editUser(EditUserDTO updateWeSopDTO) { */ private List buildScope(List userIdList, List departmentIdList, Long sopId, String corpId) { List scopeEntityList = new ArrayList<>(); - Optional.ofNullable(userIdList).orElseGet(Lists::newArrayList); + userIdList = Optional.ofNullable(userIdList).orElseGet(Lists::newArrayList); for (String userId : userIdList) { WeOperationsCenterSopScopeEntity scopeEntity = new WeOperationsCenterSopScopeEntity(); scopeEntity.setTargetId(userId); @@ -328,7 +328,7 @@ private List buildScope(List userIdLis scopeEntity.setSopId(sopId); scopeEntityList.add(scopeEntity); } - Optional.ofNullable(departmentIdList).orElseGet(Lists::newArrayList); + departmentIdList = Optional.ofNullable(departmentIdList).orElseGet(Lists::newArrayList); for (String departmentId : departmentIdList) { WeOperationsCenterSopScopeEntity scopeEntity = new WeOperationsCenterSopScopeEntity(); scopeEntity.setTargetId(departmentId); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WePresTagGroupTaskServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WePresTagGroupTaskServiceImpl.java index 6cd8f1b..0da8c33 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WePresTagGroupTaskServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WePresTagGroupTaskServiceImpl.java @@ -38,6 +38,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.aop.framework.AopContext; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -133,6 +134,7 @@ public int add(WePresTagGroupTask task, List tagIdList, List emp } @Override + @Transactional(rollbackFor = Exception.class) public int addTask(WePresTagGroupTaskDTO taskDTO, WePresTagGroupTask task, LoginUser loginUser) { if (taskDTO == null || task == null || loginUser == null) { throw new CustomException("请求参数不能为空"); @@ -141,6 +143,7 @@ public int addTask(WePresTagGroupTaskDTO taskDTO, WePresTagGroupTask task, Login Integer sendType = taskDTO.getSendType(); List tagList = taskDTO.getTagList(); Integer sendScope = taskDTO.getSendScope(); + WePresTagGroupTaskService wePresTagGroupTaskService = (WePresTagGroupTaskService) AopContext.currentProxy(); //Society my sister Li 个人群发需要scopeList数据(成员userId) if (CustomerTrajectoryEnums.TaskSendType.SINGLE.getType().equals(sendType)) { //选择所有客户,则需要获取当前账号下的数据权限范围的成员userId @@ -157,16 +160,16 @@ public int addTask(WePresTagGroupTaskDTO taskDTO, WePresTagGroupTask task, Login } } //个人群发,客户数据需要保存到WePresTagGroupStat表 - this.saveWePresTagGroupStat(task.getTaskId(), scopeList); + wePresTagGroupTaskService.saveWePresTagGroupStat(task.getTaskId(), scopeList); } //保存任务记录 - int affectedRows = this.add(task, tagList, scopeList); + int affectedRows = wePresTagGroupTaskService.add(task, tagList, scopeList); if (affectedRows > 0) { boolean hasScope = CollectionUtils.isNotEmpty(scopeList); boolean hasTag = CollectionUtils.isNotEmpty(tagList); //符合筛选条件的外部客户数据 List externalIds = this.selectExternalUserIds(task.getTaskId(), hasScope, hasTag, sendScope, taskDTO.getCusBeginTime(), taskDTO.getCusEndTime()); - this.sendMessage(task, externalIds); + wePresTagGroupTaskService.sendMessage(task, externalIds); } return affectedRows; } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserRoleServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserRoleServiceImpl.java index efb7809..72c804c 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserRoleServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserRoleServiceImpl.java @@ -7,11 +7,11 @@ import com.easyink.common.core.domain.entity.SysRole; import com.easyink.common.enums.DataScopeEnum; import com.easyink.common.enums.RoleTypeEnum; -import com.easyink.common.utils.StringUtils; import com.easyink.wecom.domain.WeUserRole; import com.easyink.wecom.mapper.WeUserRoleMapper; import com.easyink.wecom.service.WeUserRoleService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -74,7 +74,7 @@ public Boolean insertRoleIfNotExist(SysRole role) { @Override public Integer insertDefaultRoleAndInitMenus(SysRole role) { Integer res = weUserRoleMapper.insertRole(role); - String menuIds = null; + String menuIds = StringUtils.defaultString(null); if (UserConstants.INIT_ADMIN_ROLE_KEY.equals(role.getRoleKey())) { menuIds = UserConstants.ADMIN_DEFAULT_MENU_IDS; } else if (UserConstants.INIT_DEPARTMENT_ADMIN_ROLE_KEY.equals(role.getRoleKey())) { diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserServiceImpl.java index ef086c5..ffb5920 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/WeUserServiceImpl.java @@ -1,6 +1,7 @@ package com.easyink.wecom.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.dtflys.forest.exceptions.ForestRuntimeException; import com.easyink.common.annotation.DataScope; import com.easyink.common.config.RuoYiConfig; import com.easyink.common.constant.*; @@ -19,9 +21,11 @@ import com.easyink.common.core.redis.RedisCache; import com.easyink.common.enums.*; import com.easyink.common.exception.CustomException; +import com.easyink.common.utils.MyDateUtil; +import com.easyink.common.utils.bean.BeanUtils; import com.easyink.common.utils.file.FileUploadUtils; -import com.easyink.common.utils.spring.SpringUtils; import com.easyink.wecom.client.WeAgentClient; +import com.easyink.wecom.client.WeCustomerClient; import com.easyink.wecom.client.WeUserClient; import com.easyink.wecom.domain.*; import com.easyink.wecom.domain.dto.*; @@ -30,6 +34,7 @@ import com.easyink.wecom.domain.dto.transfer.GetUnassignedListReq; import com.easyink.wecom.domain.dto.transfer.GetUnassignedListResp; import com.easyink.wecom.domain.dto.transfer.TransferResignedUserListDTO; +import com.easyink.wecom.domain.query.UserBehaviorDataQuery; import com.easyink.wecom.domain.resp.GetAgentResp; import com.easyink.wecom.domain.vo.*; import com.easyink.wecom.domain.vo.transfer.TransferResignedUserVO; @@ -80,6 +85,11 @@ public class WeUserServiceImpl extends ServiceImpl impleme private final WeExternalUserMappingUserService weExternalUserMappingUserService; private final WeCorpAccountService weCorpAccountService; private final WeAgentClient weAgentClient; + private final WeUserBehaviorDataService weUserBehaviorDataService; + private final WeCustomerClient weCustomerClient; + @Lazy + @Autowired + private WeUserService weUserService; @Autowired private WeAuthCorpInfoService weAuthCorpInfoService; @@ -87,7 +97,7 @@ public class WeUserServiceImpl extends ServiceImpl impleme @Lazy @Autowired - public WeUserServiceImpl(WeDepartmentService weDepartmentService, WeUserMapper weUserMapper, RedisCache redisCache, We3rdAppService we3rdAppService, WeUserClient weUserClient, WeCustomerService weCustomerService, WeUserRoleMapper weUserRoleMapper, WeFlowerCustomerRelService weFlowerCustomerRelService, WeUserRoleService weUserRoleService, PageHomeService pageHomeService, WeGroupService weGroupService, WeMaterialService weMaterialService, WeExternalUserMappingUserService weExternalUserMappingUserService, RuoYiConfig ruoYiConfig, WeCorpAccountService weCorpAccountService, WeAgentClient weAgentClient) { + public WeUserServiceImpl(WeDepartmentService weDepartmentService, WeUserMapper weUserMapper, RedisCache redisCache, We3rdAppService we3rdAppService, WeUserClient weUserClient, WeCustomerService weCustomerService, WeUserRoleMapper weUserRoleMapper, WeFlowerCustomerRelService weFlowerCustomerRelService, WeUserRoleService weUserRoleService, PageHomeService pageHomeService, WeGroupService weGroupService, WeMaterialService weMaterialService, WeExternalUserMappingUserService weExternalUserMappingUserService, RuoYiConfig ruoYiConfig, WeCorpAccountService weCorpAccountService, WeAgentClient weAgentClient, WeUserBehaviorDataService weUserBehaviorDataService, WeCustomerClient weCustomerClient) { this.weDepartmentService = weDepartmentService; this.weUserMapper = weUserMapper; this.redisCache = redisCache; @@ -103,6 +113,8 @@ public WeUserServiceImpl(WeDepartmentService weDepartmentService, WeUserMapper w this.ruoYiConfig = ruoYiConfig; this.weCorpAccountService = weCorpAccountService; this.weAgentClient = weAgentClient; + this.weUserBehaviorDataService = weUserBehaviorDataService; + this.weCustomerClient = weCustomerClient; } /** @@ -128,9 +140,6 @@ public void updateUserRole(WeUserRole weUserRole) { @Override @DataScope public List listOfUser(QueryUserDTO queryUserDTO) { - if (StringUtils.isEmpty(queryUserDTO.getDepartments())) { - return Collections.emptyList(); - } return weUserMapper.listOfUser(queryUserDTO); } @@ -452,7 +461,7 @@ public void syncWeUser(String corpId) { } // 先同步离职成员(由于如果成员离职后再进入企业,并且存在待分配的离职客户时,拉取离职员工的时候会拉取到该成员并修改状态为离职,所以此处先同步离职员工后,再同步在职成员) try { - SpringUtils.getBean(WeUserService.class).syncWeLeaveUserV2(corpId); + weUserService.syncWeLeaveUserV2(corpId); } catch (Exception e) { log.error("同步离职员工异常corpId:{},E:{}", corpId, ExceptionUtils.getStackTrace(e)); } @@ -479,7 +488,7 @@ public void syncWeUser(String corpId) { //添加或更新员工 for (WeUser weUser : visibleUser) { weUser.setCorpId(corpId); - insertWeUserNoToWeCom(weUser); + weUserService.insertWeUserNoToWeCom(weUser); } log.info("同步成员完成,corpId:{},本次同步成员数:{}", corpId, visibleUser.size()); // 同步员工后刷新数据概览页数据 @@ -541,6 +550,10 @@ public void syncWeLeaveUserV2(String corpId) { // 3. 获取所有离职员工的待分配客户和员工详情 GetUnassignedListReq req = new GetUnassignedListReq(); GetUnassignedListResp resp = (GetUnassignedListResp) req.executeTillNoNextPage(corpId); + if (resp == null) { + log.info("[同步离职员工]本次没有同步到离职待分配员工 corpId:{}", corpId); + return; + } resp.handleData(corpId); if (CollectionUtils.isEmpty(resp.getTotalList())) { log.info("[同步离职员工]本次没有同步到离职待分配员工corpId:{},resp:{}", corpId, resp); @@ -992,7 +1005,7 @@ public WeUser getWeUserByExternalMapping(String externalUserId, String externalC weUser.setExternalCorpId(externalCorpId); weUser.setExternalUserId(externalUserId); weUser.setCorpId(weExternalUserMappingUser.getCorpId()); - this.insertWeUserNoToWeCom(weUser); + weUserService.insertWeUserNoToWeCom(weUser); weUser.setDepartmentName(weDepartmentService.selectNameByUserId(weExternalUserMappingUser.getCorpId(), weExternalUserMappingUser.getUserId())); return weUser; } else { @@ -1000,4 +1013,57 @@ public WeUser getWeUserByExternalMapping(String externalUserId, String externalC } } + @Transactional(rollbackFor = Exception.class) + @Override + public void getUserBehaviorDataByCorpId(String corpId) { + if (StringUtils.isBlank(corpId)) { + log.error("corpId不允许为空。"); + return; + } + // 获取根员工 + List visibleUser = this.getVisibleUser(corpId); + if (CollectionUtils.isEmpty(visibleUser)) { + log.info("[UserBehaviorDataTak] 该企业不存在可见的部门和员工,停止执行,corpId:{}", corpId); + return; + } + //删除存在的数据 + Long startTime = MyDateUtil.strToDate(-1, 0); + Long endTime = MyDateUtil.strToDate(-1, 1); + LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); + wrapper1.eq(WeUserBehaviorData::getCorpId, corpId); + wrapper1.between(WeUserBehaviorData::getStatTime, DateUtil.date(startTime * 1000), DateUtil.date(endTime * 1000)); + int count = weUserBehaviorDataService.count(wrapper1); + if (count > 0) { + weUserBehaviorDataService.remove(wrapper1); + } + + List dataList = new ArrayList<>(); + UserBehaviorDataQuery query = new UserBehaviorDataQuery(); + //前一天的数据 + query.setStart_time(startTime); + query.setEnd_time(endTime); + visibleUser.forEach(weUser -> { + List idList = new ArrayList<>(); + idList.add(weUser.getUserId()); + query.setUserid(idList); + try { + //根据员工id获取员工的数据概览 + UserBehaviorDataDTO userBehaviorData = weCustomerClient.getUserBehaviorData(query, corpId); + List behaviorDataList = userBehaviorData.getBehaviorData(); + for (UserBehaviorDataDTO.BehaviorData data : behaviorDataList) { + WeUserBehaviorData weUserBehaviorData = new WeUserBehaviorData(); + BeanUtils.copyPropertiesignoreOther(data, weUserBehaviorData); + weUserBehaviorData.setUserId(weUser.getUserId()); + weUserBehaviorData.setCorpId(corpId); + dataList.add(weUserBehaviorData); + } + } catch (ForestRuntimeException e) { + log.error("员工数据拉取失败: corpId:{},userId:【{}】,ex:【{}】", corpId, weUser.getUserId(), ExceptionUtils.getStackTrace(e)); + } + }); + weUserBehaviorDataService.saveBatch(dataList); + + + } + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitCustomerRecordServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitCustomerRecordServiceImpl.java index a0d5579..878cddb 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitCustomerRecordServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitCustomerRecordServiceImpl.java @@ -130,7 +130,7 @@ public void makeTagToNewCustomer(String customerId, String userId, String corpId if (CollectionUtils.isNotEmpty(allTagList)) { log.info(">>>>>>>>>>>>>>>准备进行打标签,标签列表: {}", allTagList.stream().map(WeTag::getTagId).collect(Collectors.toList())); WeMakeCustomerTagVO weMakeCustomerTagVO = new WeMakeCustomerTagVO(customerId, userId, allTagList, corpId); - weCustomerService.makeLabelbatch(Collections.singletonList(weMakeCustomerTagVO), userId); + weCustomerService.batchMakeLabel(Collections.singletonList(weMakeCustomerTagVO), userId); } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitGroupRecordServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitGroupRecordServiceImpl.java index b81f692..a00ec47 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitGroupRecordServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitGroupRecordServiceImpl.java @@ -129,7 +129,7 @@ public void makeTagToNewCustomer(String chatId, List newJoinCustomerIdLi List userIdList = weFlowerCustomerRelService.listUpUserIdListByCustomerId(customerId, corpId); for (String userId : userIdList) { log.info("入群打标签: 员工: {}, 客户: {}", userId, customerId); - weCustomerService.makeLabelbatch(Collections.singletonList(new WeMakeCustomerTagVO(customerId, userId, allTagList, corpId)), userId); + weCustomerService.batchMakeLabel(Collections.singletonList(new WeMakeCustomerTagVO(customerId, userId, allTagList, corpId)), userId); } } } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordServiceImpl.java index d23a78f..74b0f0b 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordServiceImpl.java @@ -184,7 +184,7 @@ public void makeTagToNewCustomer(List dataList, String corpId) { List weTagList = new ArrayList<>(userCustomerTagEntry.getValue()); log.info("关键词打标签: 员工: {}, 客户: {}, 标签列表: {}", userId, customerId, weTagList.stream() .map(WeTag::getName).collect(Collectors.toList())); - weCustomerService.makeLabelbatch(Collections.singletonList(new WeMakeCustomerTagVO(customerId, userId, weTagList, corpId)), userId); + weCustomerService.batchMakeLabel(Collections.singletonList(new WeMakeCustomerTagVO(customerId, userId, weTagList, corpId)), userId); } } } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordTagRelServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordTagRelServiceImpl.java index 6f759b7..f9a9495 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordTagRelServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/autotag/WeAutoTagRuleHitKeywordRecordTagRelServiceImpl.java @@ -1,7 +1,6 @@ package com.easyink.wecom.service.impl.autotag; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.easyink.common.utils.StringUtils; import com.easyink.wecom.domain.WeTag; import com.easyink.wecom.domain.entity.autotag.WeAutoTagRuleHitKeywordRecordTagRel; import com.easyink.wecom.mapper.autotag.WeAutoTagRuleHitKeywordRecordTagRelMapper; @@ -9,6 +8,7 @@ import com.easyink.wecom.service.autotag.WeAutoTagRuleHitKeywordRecordTagRelService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,7 +42,7 @@ public class WeAutoTagRuleHitKeywordRecordTagRelServiceImpl extends ServiceImpl< @Override public List buildTagRecord(String corpId, String userId, String customerId, Set matchedRuleIdSet) { List batchList = new ArrayList<>(); - if (StringUtils.isBlank(corpId) || StringUtils.isBlank(corpId) || StringUtils.isBlank(corpId)) { + if (StringUtils.isBlank(corpId)) { log.error("参数异常,取消构建关键词标签记录数据"); return batchList; } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskResultServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskResultServiceImpl.java index 3e94825..d0cfa77 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskResultServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskResultServiceImpl.java @@ -4,10 +4,21 @@ import com.easyink.wecom.domain.entity.moment.WeMomentTaskResultEntity; import com.easyink.wecom.mapper.moment.WeMomentTaskResultMapper; import com.easyink.wecom.service.moment.WeMomentTaskResultService; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.Date; + @Service public class WeMomentTaskResultServiceImpl extends ServiceImpl implements WeMomentTaskResultService { + @Override + public void updatePublishInfo(Long momentTaskId, String userId, Integer publishStatus, Date publishTime) { + if (momentTaskId == null || StringUtils.isBlank(userId) || publishStatus == null) { + log.warn("[更新朋友圈任务结果发布信息] 参数错误,不执行更新"); + return; + } + this.baseMapper.updatePublishInfo(momentTaskId, userId, publishStatus, publishTime); + } } \ No newline at end of file diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskServiceImpl.java index 4e55584..2fa2600 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/moment/WeMomentTaskServiceImpl.java @@ -377,15 +377,13 @@ public void updatePublishStatus(String momentId, Long taskId, String corpId) { for (MomentTask momentTask : taskPublishList) { taskUserList.add(momentTask.getUserid()); //更新执行状态 - LambdaUpdateWrapper resultEntityLambdaUpdateWrapper = new LambdaUpdateWrapper() - .eq(WeMomentTaskResultEntity::getUserId, momentTask.getUserid()) - .eq(WeMomentTaskResultEntity::getMomentTaskId, taskId) - .set(WeMomentTaskResultEntity::getPublishStatus, momentTask.getPublish_status()); - //设置发布时间 - if (MomentPublishStatusEnum.PUBLISH.getType().equals(momentTask.getPublish_status())){ - resultEntityLambdaUpdateWrapper.set(WeMomentTaskResultEntity::getPublishTime,new Date()); + Date publishTime = null; + if (MomentPublishStatusEnum.PUBLISH.getType().equals(momentTask.getPublish_status())) { + //设置发布时间 + publishTime = new Date(); } - weMomentTaskResultService.update(resultEntityLambdaUpdateWrapper); + // 如果发布时间不为空,这里不会再次更新发布时间 + weMomentTaskResultService.updatePublishInfo(taskId, momentTask.getUserid(), momentTask.getPublish_status(), publishTime); log.info("朋友圈执行状态已更新 corpId:{},userId:{},taskId:{}", corpId, momentTask.getUserid(), taskId); this.update(new LambdaUpdateWrapper().eq(WeMomentTaskEntity::getId, taskId).set(WeMomentTaskEntity::getUpdateTime, new Date())); //朋友圈触达客户(已执行产生触达) diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarChannelServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarChannelServiceImpl.java index 1c15041..f942b39 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarChannelServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarChannelServiceImpl.java @@ -102,15 +102,8 @@ public void saveRadarChannel(RadarChannelDTO radarChannelDTO) { */ @Override public List getRadarChannelList(SearchRadarChannelDTO radarChannelDTO) { - final boolean isSuperAdmin = LoginTokenService.getLoginUser().isSuperAdmin(); radarChannelDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId()); - List list = this.baseMapper.list(radarChannelDTO, isSuperAdmin); - list.forEach(item -> { - if (Constants.SUPER_ADMIN.equals(item.getCreateId())) { - item.setCreateName(Constants.SUPER_ADMIN); - } - }); - return list; + return this.baseMapper.list(radarChannelDTO); } /** diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarServiceImpl.java index 60cc1f0..2666667 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/radar/WeRadarServiceImpl.java @@ -157,9 +157,6 @@ public List getRadarList(SearchRadarDTO radarDTO) { if (RadarTypeEnum.DEPARTMENT.getType().equals(radarDTO.getType())) { return Collections.emptyList(); } - if (RadarTypeEnum.CORP.getType().equals(radarDTO.getType())) { - radarDTO.setType(null); - } } if (!isSuperAdmin) { if (RadarTypeEnum.DEPARTMENT.getType().equals(radarDTO.getType())) { @@ -172,16 +169,7 @@ public List getRadarList(SearchRadarDTO radarDTO) { } } startPage(); - List list = this.baseMapper.list(radarDTO, isSuperAdmin); - if (CollectionUtils.isEmpty(list)) { - return Collections.emptyList(); - } - list.forEach(item -> { - if (Constants.SUPER_ADMIN.equals(item.getCreateId())) { - item.setCreateName(Constants.SUPER_ADMIN); - } - }); - return list; + return this.baseMapper.list(radarDTO); } /** @@ -239,7 +227,10 @@ public void updateRadar(RadarDTO radarDTO) { this.baseMapper.saveRadarTags(weRadarTagList); } this.baseMapper.updateById(weRadar); - sendToUser(radarDTO.getCorpId(), radarDTO.getRadarTitle(), radarDTO.getType()); + //发消息通知员工 + if (Boolean.TRUE.equals(radarDTO.getEnableUpdateNotice())) { + sendToUser(radarDTO.getCorpId(), radarDTO.getRadarTitle(), radarDTO.getType()); + } } @Override diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/redeemcode/WeRedeemCodeServiceImpl.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/redeemcode/WeRedeemCodeServiceImpl.java index 3858088..b52969b 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/redeemcode/WeRedeemCodeServiceImpl.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/impl/redeemcode/WeRedeemCodeServiceImpl.java @@ -45,6 +45,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -269,21 +270,26 @@ public void updateRedeemCode(WeRedeemCodeDTO weRedeemCodeDTO) { throw new CustomException(ResultTip.TIP_REDEEM_CODE_ACTIVITY_LIMIT_ADD_USER); } //该客户符合分配兑换码条件 + RLock rLock = null; + boolean isHaveLock = false; try { final String redeemCodeKey = RedeemCodeConstants.getRedeemCodeKey(corpId, weRedeemCode.getActivityId()); - if (LockUtil.tryLock(redeemCodeKey, RedeemCodeConstants.CODE_WAIT_TIME, RedeemCodeConstants.CODE_LEASE_TIME, TimeUnit.SECONDS)) { + rLock = LockUtil.getLock(redeemCodeKey); + isHaveLock = rLock.tryLock(RedeemCodeConstants.CODE_WAIT_TIME, RedeemCodeConstants.CODE_LEASE_TIME, TimeUnit.SECONDS); + if (isHaveLock) { weRedeemCode.setStatus(RedeemCodeConstants.REDEEM_CODE_RECEIVED); weRedeemCode.setRedeemTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date())); this.baseMapper.updateWeRedeemCode(weRedeemCode); - //更新兑换码信息后,释放锁 - LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, String.valueOf(weRedeemCodeDTO.getActivityId()))); } } catch (InterruptedException e) { log.error("[兑换码更新]兑换码更新兑换人获取锁失败,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), weRedeemCodeDTO.getActivityId(), corpId); + Thread.currentThread().interrupt(); } catch (Exception e) { log.error("[兑换码更新]兑换码分配兑换人失败,e:{},活动id:{},corpId:{}", ExceptionUtils.getStackTrace(e), weRedeemCodeDTO.getActivityId(), corpId); - //内部处理逻辑报错,释放锁 - LockUtil.unlock(RedeemCodeConstants.getRedeemCodeKey(corpId, String.valueOf(weRedeemCodeDTO.getActivityId()))); + }finally { + if(rLock != null){ + rLock.unlock(); + } } //告警员工 alarmUser(corpId, weRedeemCodeDTO.getActivityId()); @@ -389,6 +395,9 @@ public List getReemCodeList(WeRedeemCodeDTO weRedeemCodeDTO) { if (StringUtils.isNotBlank(weRedeemCodeDTO.getReceiveName())) { List customers = weCustomerService.getCustomer(weRedeemCodeDTO.getCorpId(), weRedeemCodeDTO.getReceiveName()); List externalUsers = customers.stream().map(WeCustomerVO::getExternalUserid).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(externalUsers)) { + return Collections.emptyList(); + } weRedeemCodeDTO.setExternalUserIdList(externalUsers); } startPage(); diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/moment/WeMomentTaskResultService.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/moment/WeMomentTaskResultService.java index 2c1e0b8..957d57e 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/moment/WeMomentTaskResultService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/moment/WeMomentTaskResultService.java @@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.easyink.wecom.domain.entity.moment.WeMomentTaskResultEntity; +import java.util.Date; + /** * 类名: 接口 * @@ -11,5 +13,14 @@ */ public interface WeMomentTaskResultService extends IService { + /** + * 更新发布信息 + * @param taskId 任务id + * @param userId 用户id + * @param publishStatus 发布状态 + * @param publishTime 发布时间 + */ + void updatePublishInfo(Long taskId, String userId, Integer publishStatus, Date publishTime); + } diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/service/radar/RadarUrlHandler.java b/easyink-wecom/src/main/java/com/easyink/wecom/service/radar/RadarUrlHandler.java index 0549221..d729561 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/service/radar/RadarUrlHandler.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/service/radar/RadarUrlHandler.java @@ -232,7 +232,7 @@ private void setTagForRadarClick(Long id, WeUser user, WeCustomer customer) { .build(); List list = new ArrayList<>(); list.add(makeCustomerTagVO); - weCustomerService.makeLabelbatch(list,user.getUserId()); + weCustomerService.batchMakeLabel(list,user.getUserId()); } @@ -290,7 +290,7 @@ public WeCustomer getCustomerInfoByOpenId(String openId) { // 2. 先根据union_id去客户表查询是否有数据 WeCustomer customer = weCustomerService.getOne(new LambdaQueryWrapper().eq(WeCustomer::getUnionid, unionId).last(GenConstants.LIMIT_1)); if (customer == null) { - log.info("[获取雷达原链接] 获取客户详情,根据union_id在数据库中未匹配到客户,openId:{},unionId:{},customer:{}", openId, unionId); + log.info("[获取雷达原链接] 获取客户详情,根据union_id在数据库中未匹配到客户,openId:{},unionId:{}", openId, unionId); throw new CustomException(ResultTip.TIP_CANNOT_FIND_USER_BY_UNION_ID); } return customer; diff --git a/easyink-wecom/src/main/java/com/easyink/wecom/utils/AttachmentService.java b/easyink-wecom/src/main/java/com/easyink/wecom/utils/AttachmentService.java index a71165d..29ea9d3 100644 --- a/easyink-wecom/src/main/java/com/easyink/wecom/utils/AttachmentService.java +++ b/easyink-wecom/src/main/java/com/easyink/wecom/utils/AttachmentService.java @@ -84,12 +84,12 @@ private Attachments buildVideo(String content, String picUrl, String fileSize, S // 标题 content = StringUtils.isNotEmpty(content) ? content : FileUtil.getName(picUrl); // 链接地址 - url = picUrl; + String useUrl = picUrl; // 封面图片 picUrl = WeConstans.DEFAULT_VIDEO_COVER_URL; // 描述信息 String desc = WeConstans.CLICK_SEE_VIDEO; - attachments = buildLink(content, picUrl, desc, url, AttachmentTypeEnum.LINK); + attachments = buildLink(content, picUrl, desc, useUrl, AttachmentTypeEnum.LINK); return attachments; } attachments = new Attachments(); diff --git a/easyink-wecom/src/main/java/com/tencent/wework/FinanceUtils.java b/easyink-wecom/src/main/java/com/tencent/wework/FinanceUtils.java index 285a5d5..0fd2476 100644 --- a/easyink-wecom/src/main/java/com/tencent/wework/FinanceUtils.java +++ b/easyink-wecom/src/main/java/com/tencent/wework/FinanceUtils.java @@ -14,6 +14,7 @@ import com.easyink.common.core.domain.wecom.WeUser; import com.easyink.common.core.redis.RedisCache; import com.easyink.common.exception.BaseException; +import com.easyink.common.exception.CustomException; import com.easyink.common.utils.DateUtils; import com.easyink.common.utils.StringUtils; import com.easyink.common.utils.file.FileUploadUtils; @@ -28,10 +29,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.exception.ExceptionUtils; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; +import java.io.*; import java.security.PrivateKey; import java.util.ArrayList; import java.util.List; @@ -512,8 +510,8 @@ private static void getMediaData(String sdkFileid, String proxy, String passwd, f.mkdirs(); } File file = new File(filePath, fileName); - if (!file.isDirectory()) { - file.createNewFile(); + if (!file.isDirectory() && !file.createNewFile()) { + throw new CustomException("getMediaData 文件不存在,创建文件失败"); } outputStream = new FileOutputStream(file, true); outputStream.write(Finance.GetData(mediaData)); diff --git a/easyink-wecom/src/main/resources/mapper/wecom/WeCustomerExtendPropertyMapper.xml b/easyink-wecom/src/main/resources/mapper/wecom/WeCustomerExtendPropertyMapper.xml index 4d5766a..776f714 100644 --- a/easyink-wecom/src/main/resources/mapper/wecom/WeCustomerExtendPropertyMapper.xml +++ b/easyink-wecom/src/main/resources/mapper/wecom/WeCustomerExtendPropertyMapper.xml @@ -168,6 +168,6 @@ AND wcep.name LIKE CONCAT('%',#{name},'%') AND wcep.status = #{status} AND wcep.required = #{required} - ORDER BY wcep.property_sort + ORDER BY wcep.property_sort, epmo.id \ No newline at end of file diff --git a/easyink-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml b/easyink-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml index b9bc458..5ba1025 100644 --- a/easyink-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml +++ b/easyink-wecom/src/main/resources/mapper/wecom/WeMaterialMapper.xml @@ -314,9 +314,11 @@ AND wm.material_name LIKE CONCAT('%',#{search},'%') - + AND show_material = #{showMaterial} - AND wc.using = #{showMaterial} + + + AND wc.using = #{usingFlag} diff --git a/easyink-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml b/easyink-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml index 05e306f..28e4cf8 100644 --- a/easyink-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml +++ b/easyink-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml @@ -100,7 +100,9 @@ AND wu.is_allocate = #{isAllocate} - AND CONCAT(',',wu.main_department,',') REGEXP CONCAT(',(',REPLACE(#{departments},',','|'),'),') + + AND CONCAT(',',wu.main_department,',') REGEXP CONCAT(',(',REPLACE(#{departments},',','|'),'),') + diff --git a/easyink-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml b/easyink-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml index 7cde2cc..e899233 100644 --- a/easyink-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml +++ b/easyink-wecom/src/main/resources/mapper/wecom/radar/WeRadarMapper.xml @@ -101,7 +101,7 @@ wr.enable_customer_tag, wr.enable_update_notice, wr.create_by user_id, - wu.user_name, + IFNULL(wu.user_name, wr.create_by) AS user_name, wu.main_department, wd.name, (SELECT COUNT(distinct external_user_id) @@ -125,9 +125,6 @@ AND wr.type = #{radar.type} - - and wr.create_by = '${@com.easyink.common.constant.Constants@SUPER_ADMIN}' - ORDER BY clickNum asc, wr.create_time desc diff --git a/pom.xml b/pom.xml index fd45b57..dc55526 100755 --- a/pom.xml +++ b/pom.xml @@ -41,12 +41,32 @@ 4.0 3.0.2 1.5.22 + 1.0.2 + 6.4 + + 2.14.0 - + + com.alibaba + transmittable-thread-local + ${ttl.version} + + + + com.ofpay + logback-mdc-ttl + ${com.ofpay.logback-mdc-ttl.version} + + + + net.logstash.logback + logstash-logback-encoder + ${net.logstash.logback.logstash-logback-encoder.version} + io.netty netty-bom diff --git a/sql/init/easyink.sql b/sql/init/easyink.sql index ddc7ebb..aae3074 100644 --- a/sql/init/easyink.sql +++ b/sql/init/easyink.sql @@ -1600,7 +1600,8 @@ CREATE TABLE `we_flower_customer_rel` `delete_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '删除时间', `wechat_channel` varchar(64) NOT NULL DEFAULT '' COMMENT '该成员添加此客户的来源add_way为10时,对应的视频号信息', PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `un_user_external_userid_corpid` (`external_userid`, `user_id`, `corp_id`) USING BTREE + UNIQUE INDEX `un_user_external_userid_corpid` (`external_userid`, `user_id`, `corp_id`) USING BTREE, + KEY `idx_corp_user_id` (`corp_id`,`user_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业员工与客户的关系表' ROW_FORMAT = Dynamic; -- ---------------------------- @@ -1715,7 +1716,8 @@ CREATE TABLE `we_group_member` `name` varchar(32) NOT NULL DEFAULT '' COMMENT '成员名称', `invitor` varchar(64) NOT NULL DEFAULT '' COMMENT '邀请者userId', PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `un_member`(`user_id`, `chat_id`, `corp_id`) USING BTREE + UNIQUE INDEX `un_member`(`user_id`, `chat_id`, `corp_id`) USING BTREE, + KEY `idx_chat_id` (`chat_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业微信群成员' ROW_FORMAT = Dynamic; @@ -3201,7 +3203,7 @@ CREATE TABLE `we_auto_tag_rule` `rule_name` varchar(32) NOT NULL DEFAULT '' COMMENT '规则名称', `label_type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '规则类型 1:关键词 2:入群 3:新客', `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '启用禁用状态 0:禁用1:启用', - `create_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', + `create_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', `create_by` varchar(32) NOT NULL DEFAULT '' COMMENT '创建人', PRIMARY KEY (`id`) USING BTREE, KEY `idx_corp_id` (`corp_id`) USING BTREE diff --git a/sql/update/update-V1.20.0.sql b/sql/update/update-V1.20.0.sql new file mode 100644 index 0000000..66c3c20 --- /dev/null +++ b/sql/update/update-V1.20.0.sql @@ -0,0 +1,7 @@ +-- 2023-01-06 silver_chariot 修改群员表的索引 Tower 任务: 线上环境部分接口响应过慢 ( https://tower.im/teams/636204/todos/55908 ) +ALTER TABLE `we_group_member` +ADD INDEX `idx_chat_id` (`chat_id`) USING BTREE ; + +-- 2023-01-06 silver_chariot 修改客户员工关系表的索引 Tower 任务: 线上环境部分接口响应过慢 ( https://tower.im/teams/636204/todos/55908 ) +ALTER TABLE `we_flower_customer_rel` +ADD INDEX `idx_corp_user_id` (`corp_id`, `user_id`) USING BTREE ; \ No newline at end of file