diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SmsTemplateConstant.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SmsTemplateConstant.java index 3bfac0e8f7..c5647e5edf 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SmsTemplateConstant.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SmsTemplateConstant.java @@ -27,4 +27,14 @@ public interface SmsTemplateConstant { * 修改密码验证码 */ String CHANGE_PASSWORD = "SMS_150731393"; + + /** + * 项目被吹哨提醒 + */ + String PROJECT_TRANSFER = "SMS_200187239"; + + /** + * 项目滞留提醒 + */ + String PROJECT_OVERDUE = "SMS_206885207"; } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java new file mode 100644 index 0000000000..32be48a287 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SysSmsConstant.java @@ -0,0 +1,19 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2021/1/4 下午1:42 + */ +public interface SysSmsConstant { + + String IS_NULL_PARAM_LIST = "项目流转或滞留推送短信提醒入参集合为空......"; + + String SELECT_PARAMETER_INFO_FAILURE = "查询客户配置参数失败......"; + + String PARAMETER_INFO_IS_ZERO = "未查到客户配置参数......"; + + String NOT_ENOUGH_BALANCE = "客户:%s ,当前余额为:%s"; + + String NOT_ON_SWITCH = "客户:%s ,【%s】开关未开启"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxmpMessageConstant.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxmpMessageConstant.java new file mode 100644 index 0000000000..5c8b364e1f --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxmpMessageConstant.java @@ -0,0 +1,88 @@ +package com.epmet.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * @description: 微信订阅消息常量 + * @author: liushaowen + * @date: 2020/10/21 17:45 + */ + +public interface WxmpMessageConstant { + String SEND_MESSAGE = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="; + + String ERR_CODE = "errcode"; + + String ERR_MSG = "errmsg"; + + int USER_REFUSED = 43101; + + String AUTHORIZER_ACCESS_TOKEN = "authorizerAccessToken"; + + String RESI = "resi"; + + String GOV_REDIS = "work"; + + String GOV_DB = "gov"; + + String ACCESS_TOKEN = "access_token"; + + String TOUSER = "touser"; + + String TEMPLATE_ID = "template_id"; + /*站内信模板start*/ + String MESSAGE_TEMPLATE_TYPE = "1832"; + String MESSAGE_TITLE = "thing5"; + String MESSAGE_CONTENT = "thing4"; + String MESSAGE_TIME = "date2"; + /*站内信模板end*/ + + /**关注更新提醒模板start**/ + String CONCERN_UPDATE_TEMPLATE_TYPE = "8171"; + String CONCERN_UPDATE_TITLE = "thing5"; + String CONCERN_UPDATE_TITLE_TEXT = "话题状态提醒"; + String CONCERN_UPDATE_CONTENT = "thing7"; + String CONCERN_UPDATE_CONTENT_TEXT = "你关注的话题已被转为议题,请点击查看。"; + String CONCERN_UPDATE_TIME = "time6"; + /**关注更新提醒模板end**/ + + /**内容更新消息通知模板start**/ + String CONTENT_UPDATE_TEMPLATE_TYPE = "2092"; + String CONTENT_UPDATE_TITLE = "name4"; + String CONTENT_UPDATE_TITLE_TEXT = "新评论提醒"; + String CONTENT_UPDATE_CONTENT = "thing9"; + String CONTENT_UPDATE_CONTENT_TEXT = "你关注的话题收到新评论,请点击查看。"; + String CONTENT_UPDATE_TIME = "date3"; + /**内容更新消息通知模板end**/ + + /** 消息来源start**/ + //话题 + String SOURCE_TYPE_TOPIC = "topic"; + //议题 + String SOURCE_TYPE_ISSUE = "issue"; + /** 消息来源end**/ + + String PAGE = "page"; + + String MESSAGE_PAGE_URL = "/subpages/mine/pages/message/skip"; + + String UPDATE_PAGE_URL = "/pages/index/subscribe?id="; + + int TITLE_LIMIT = 20; + + int MESSAGE_CONTENT_LIMIT = 20; + + String DATA = "data"; + + String MINIPROGRAM_STATE = "miniprogram_state"; + + String SUCCESS = "success"; + + String ERROR = "error"; + + String STATE_DEV = "developer"; + + String STATE_TEST = "trial"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendDataDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendDataDTO.java new file mode 100644 index 0000000000..75696d1a4e --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendDataDTO.java @@ -0,0 +1,111 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Data +public class WxmpUpdateSendDataDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 来源类型 (话题:topic 议题:issue 项目project 爱心互助heart 党建声音voice) + */ + private String sourceType; + + /** + * 来源对应ID + */ + private String sourceId; + + /** + * 客户ID + */ + private String customerId; + + /** + * 组织ID agencyId + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 工作人员Id + */ + private String staffId; + + /** + * 消息接收者 + */ + private String msgUserId; + + /** + * 删除标识 0未删除、1已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendRecordDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendRecordDTO.java new file mode 100644 index 0000000000..a1e8a23d8e --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendRecordDTO.java @@ -0,0 +1,131 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Data +public class WxmpUpdateSendRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格Id (居民端跟网格有关的则有值,工作端以及一些居民端和网格没关的存*) + */ + private String gridId; + + /** + * 所属端类型 居民端:resi 工作端:gov + */ + private String clientType; + + /** + * 消息模板Id + */ + private String templateId; + + /** + * 用户Id + */ + private String userId; + + /** + * openId + */ + private String wxOpenId; + + /** + * 行为类型: 关注更新提醒、内容更新消息通知 + */ + private String behaviorType; + + /** + * 消息标题 + */ + private String title; + + /** + * 消息内容 + */ + private String content; + + /** + * 消息时间 + */ + private Date time; + + /** + * 发送结果(成功:success 失败:error) + */ + private String result; + + /** + * 发送失败的原因,成功可以不记录 + */ + private String reason; + + /** + * 删除标识 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java new file mode 100644 index 0000000000..cd1e10f820 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ProjectSendMsgFormDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 项目提醒--根据手机号、短信模板编码,发送短信 验证码 + * + * @author sun + */ +@Data +public class ProjectSendMsgFormDTO implements Serializable { + private static final long serialVersionUID = 8894395590639206399L; + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class}) + private String mobile; + /** + * 场景: + */ + @NotBlank(message = "短信模板编码不能为空", groups = {AddUserInternalGroup.class}) + private String aliyunTemplateCode; + + /** + * 客户ID + */ + @NotBlank(message = "客户ID不能为空", groups = {AddUserInternalGroup.class}) + private String customerId; + + /** + * 参数KEY(发短信:send_msg;) + */ + @NotBlank(message = "参数KEY不能为空", groups = {AddUserInternalGroup.class}) + private String parameterKey; + + public interface AddUserInternalGroup {} + + public interface AddUserShowGroup extends CustomerClientShowGroup {} +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeUpdateFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeUpdateFormDTO.java new file mode 100644 index 0000000000..3361ed6295 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeUpdateFormDTO.java @@ -0,0 +1,86 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * @description: 微信订阅消息FormDTO + * @author: liushaowen + * @date: 2020/10/21 14:29 + */ +@Data +public class WxSubscribeUpdateFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + /** + * 客户端类型 居民端:resi 工作端:work + */ + @NotBlank(message = "客户端类型不能为空") + private String clientType; + + /** + * 接收者(用户)的 userId + */ + @NotBlank(message = "接收用户id不能为空") + private String userId; + + /** + * 来源类型 (话题:topic 议题:issue 项目project 爱心互助heart 党建声音voice)等 + */ + @NotBlank(message = "来源类型不能为空") + private String sourceType; + /** + * 来源对应id + */ + @NotBlank(message = "来源id不能为空") + private String sourceId; + + /** + * 行为类型 传模板的tid + */ + @NotBlank(message = "行为类型不能为空") + private String behaviorType; + + @NotBlank(message = "消息标题不能为空") + private String messageTitle; + + /** + * 消息内容 + */ + @NotBlank(message = "消息内容不能为空") + private String messageContent; + + /** + * 消息时间 + */ + @NotNull(message = "消息时间不能为空") + private Date messageTime; + + /** + * 网格id + */ + private String gridId; + /** + * 工作人员id + */ + private String staffId; + + /** + * 群id + */ + private String groupId; + /** + * 组织id + */ + private String agencyId; + + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index 1035ab1552..39f6d76f21 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -3,9 +3,11 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; +import com.epmet.dto.form.WxSubscribeUpdateFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.feign.fallback.EpmetMessageOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; @@ -77,4 +79,21 @@ public interface EpmetMessageOpenFeignClient { **/ @PostMapping(value = "message/wxmpmessage/sendwxsubscribemessage", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result sendWxSubscribeMessage(List msgList); + + /** + * @param formDTOList + * @author sun + * @description 项目流转或滞留推送短信提醒 + **/ + @PostMapping(value = "message/sms/projectsendmsg", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result projectSendMsg(List formDTOList); + + /** + * @param msgList + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Description 发送微信订阅消息 + **/ + @PostMapping(value = "message/wxmpmessage/sendwxsubscribeupdate", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result sendWxSubscribeUpdate(List msgList); } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java index 889569147f..9f1ae0083f 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java @@ -4,9 +4,11 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; +import com.epmet.dto.form.WxSubscribeUpdateFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.feign.EpmetMessageOpenFeignClient; import org.springframework.stereotype.Component; @@ -51,4 +53,14 @@ public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeig public Result sendWxSubscribeMessage(List msgList) { return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendWxSubscribeMessage", msgList); } + + @Override + public Result projectSendMsg(List formDTOList) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "projectSendMsg", formDTOList); + } + + @Override + public Result sendWxSubscribeUpdate(List msgList) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendWxSubscribeUpdate", msgList); + } } diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index 6a10b4724d..778985212f 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -112,6 +112,12 @@ 2.0.0 compile + + + com.epmet + oper-crm-client + 2.0.0 + diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java deleted file mode 100644 index 62c9e16dcb..0000000000 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.epmet.constant; - -import java.util.HashMap; -import java.util.Map; - -/** - * @description: 微信订阅消息常量 - * @author: liushaowen - * @date: 2020/10/21 17:45 - */ - -public interface WxmpMessageConstant { - String SEND_MESSAGE = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="; - - String ERR_CODE = "errcode"; - - String ERR_MSG = "errmsg"; - - int USER_REFUSED = 43101; - - String AUTHORIZER_ACCESS_TOKEN = "authorizerAccessToken"; - - String RESI = "resi"; - - String GOV_REDIS = "work"; - - String GOV_DB = "gov"; - - String ACCESS_TOKEN = "access_token"; - - String TOUSER = "touser"; - - String TEMPLATE_ID = "template_id"; - - String TEMPLATE_TYPE = "1832"; - - String PAGE = "page"; - - String PAGE_URL = "/subpages/mine/pages/message/skip"; - - String TITLE = "thing5"; - - int TITLE_LIMIT = 20; - - String MESSAGE_CONTENT = "thing4"; - - int MESSAGE_CONTENT_LIMIT = 20; - - String MESSAGE_TIME = "date2"; - - String DATA = "data"; - - String MINIPROGRAM_STATE = "miniprogram_state"; - - String SUCCESS = "success"; - - String ERROR = "error"; - - String STATE_DEV = "developer"; - - String STATE_TEST = "trial"; - -} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SmsController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SmsController.java index 0a0f534a0a..8f3ced6845 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SmsController.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SmsController.java @@ -16,6 +16,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AliyunGroup; import com.epmet.commons.tools.validator.group.QcloudGroup; import com.epmet.dto.SysSmsDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.enums.PlatformEnum; @@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import java.util.Arrays; +import java.util.List; import java.util.Map; /** @@ -139,4 +141,19 @@ public class SmsController { SendVerificationCodeResultDTO resultDTO=sysSmsService.sendVerificationCode(formDTO); return new Result().ok(resultDTO); } + + /** + * @param formDTOList + * @author sun + * @description 项目流转或滞留推送短信提醒 + **/ + @PostMapping("projectsendmsg") + public Result projectSendMsg(@RequestBody List formDTOList) { + for (ProjectSendMsgFormDTO formDTO : formDTOList) { + ValidatorUtils.validateEntity(formDTO, ProjectSendMsgFormDTO.AddUserShowGroup.class, ProjectSendMsgFormDTO.AddUserInternalGroup.class); + } + sysSmsService.projectSendMsg(formDTOList); + return new Result(); + } + } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java index b600285971..1847afb396 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java @@ -21,11 +21,9 @@ import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.ActivationSubscribeFormDTO; -import com.epmet.dto.form.GetTemplateListFormDTO; -import com.epmet.dto.form.WxMsgAuthInfoFormDTO; -import com.epmet.dto.form.WxSubscribeMessageFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.GetTemplateListResultDTO; +import com.epmet.dto.result.TemplateListV2ResultDTO; import com.epmet.dto.result.WxMsgAuthInfoResultDTO; import com.epmet.service.WxmpMessageService; import org.slf4j.Logger; @@ -100,9 +98,27 @@ public class WxmpMessageController { return new Result(); } + @PostMapping("sendwxsubscribeupdate") + public Result sendWxSubscribeUpdate(@RequestBody List msgList){ + for (WxSubscribeUpdateFormDTO wxSubscribeUpdateFormDTO : msgList) { + ValidatorUtils.validateEntity(wxSubscribeUpdateFormDTO); + } + executorService.execute(() -> { + try { + long startTs = System.currentTimeMillis(); + wxmpMessageService.sendWxSubscribeUpdate(msgList); + long endTs = System.currentTimeMillis(); + logger.info("异步发送消息成功,执行时长:{}", endTs - startTs); + } catch (Exception e) { + logger.error("异步发送消息失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); + } + }); + return new Result(); + } + /** * @return - * @Description 居民端、工作端-获取客户小程序模板列表 + * @Description 居民端、工作端-获取客户小程序模板列表(只有站内信模板) * @author sun */ @PostMapping("templatelist") @@ -110,6 +126,18 @@ public class WxmpMessageController { ValidatorUtils.validateEntity(formDTO, GetTemplateListFormDTO.AddUserInternalGroup.class); return new Result>().ok(wxmpMessageService.templateList(formDTO)); } + /** + * @Description 居民端、工作端-获取客户小程序模板列表(除了站内信模板) + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/12/29 13:18 + */ + @PostMapping("templatelistv2") + public Result> templateListV2(@RequestBody TemplateListV2FormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return new Result>().ok(wxmpMessageService.templateListV2(formDTO)); + } /** * @Description 查询用户授权信息 @@ -159,4 +187,4 @@ public class WxmpMessageController { return new Result(); } -} \ No newline at end of file +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendDataController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendDataController.java new file mode 100644 index 0000000000..0704f912c6 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendDataController.java @@ -0,0 +1,98 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.WxmpUpdateSendDataDTO; +import com.epmet.excel.WxmpUpdateSendDataExcel; +import com.epmet.service.WxmpUpdateSendDataService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@RestController +@RequestMapping("wxmpupdatesenddata") +public class WxmpUpdateSendDataController { + + @Autowired + private WxmpUpdateSendDataService wxmpUpdateSendDataService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = wxmpUpdateSendDataService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + if (StringUtils.isBlank(id) || "undefined".equals(id)){ + return new Result().error(8000,"id不能为空"); + } + WxmpUpdateSendDataDTO data = wxmpUpdateSendDataService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody WxmpUpdateSendDataDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + wxmpUpdateSendDataService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody WxmpUpdateSendDataDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + wxmpUpdateSendDataService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + wxmpUpdateSendDataService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = wxmpUpdateSendDataService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, WxmpUpdateSendDataExcel.class); + } + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendRecordController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendRecordController.java new file mode 100644 index 0000000000..42daed9b09 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendRecordController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.WxmpUpdateSendRecordDTO; +import com.epmet.excel.WxmpUpdateSendRecordExcel; +import com.epmet.service.WxmpUpdateSendRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@RestController +@RequestMapping("wxmpupdatesendrecord") +public class WxmpUpdateSendRecordController { + + @Autowired + private WxmpUpdateSendRecordService wxmpUpdateSendRecordService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = wxmpUpdateSendRecordService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + WxmpUpdateSendRecordDTO data = wxmpUpdateSendRecordService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody WxmpUpdateSendRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + wxmpUpdateSendRecordService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody WxmpUpdateSendRecordDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + wxmpUpdateSendRecordService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + wxmpUpdateSendRecordService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = wxmpUpdateSendRecordService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, WxmpUpdateSendRecordExcel.class); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendDataDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendDataDao.java new file mode 100644 index 0000000000..89af78b681 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendDataDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.WxmpUpdateSendDataEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Mapper +public interface WxmpUpdateSendDataDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendRecordDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendRecordDao.java new file mode 100644 index 0000000000..63b8812bb0 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendRecordDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.WxmpUpdateSendRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Mapper +public interface WxmpUpdateSendRecordDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendDataEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendDataEntity.java new file mode 100644 index 0000000000..a4395a1bf9 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendDataEntity.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("wxmp_update_send_data") +public class WxmpUpdateSendDataEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 来源类型 (话题:topic 议题:issue 项目project 爱心互助heart 党建声音voice) + */ + private String sourceType; + + /** + * 来源对应ID + */ + private String sourceId; + + /** + * 客户ID + */ + private String customerId; + + /** + * 组织ID agencyId + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 工作人员Id + */ + private String staffId; + + /** + * 消息接收者 + */ + private String msgUserId; + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendRecordEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendRecordEntity.java new file mode 100644 index 0000000000..9497a3475e --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendRecordEntity.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("wxmp_update_send_record") +public class WxmpUpdateSendRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格Id (居民端跟网格有关的则有值,工作端以及一些居民端和网格没关的存*) + */ + private String gridId; + + /** + * 所属端类型 居民端:resi 工作端:gov + */ + private String clientType; + + /** + * 消息模板Id + */ + private String templateId; + + /** + * 用户Id + */ + private String userId; + + /** + * openId + */ + private String wxOpenId; + + /** + * 行为类型: 关注更新提醒、内容更新消息通知 + */ + private String behaviorType; + + /** + * 消息标题 + */ + private String title; + + /** + * 消息内容 + */ + private String content; + + /** + * 消息时间 + */ + private Date time; + + /** + * 发送结果(成功:success 失败:error) + */ + private String result; + + /** + * 发送失败的原因,成功可以不记录 + */ + private String reason; + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendDataExcel.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendDataExcel.java new file mode 100644 index 0000000000..5c1c3f07f3 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendDataExcel.java @@ -0,0 +1,80 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Data +public class WxmpUpdateSendDataExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "来源类型 (话题:topic 议题:issue 项目project 爱心互助heart 党建声音voice)") + private String sourceType; + + @Excel(name = "来源对应ID") + private String sourceId; + + @Excel(name = "客户ID") + private String customerId; + + @Excel(name = "组织ID agencyId") + private String agencyId; + + @Excel(name = "网格ID ") + private String gridId; + + @Excel(name = "小组Id") + private String groupId; + + @Excel(name = "工作人员Id") + private String staffId; + + @Excel(name = "消息接收者") + private String msgUserId; + + @Excel(name = "删除标识 0未删除、1已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendRecordExcel.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendRecordExcel.java new file mode 100644 index 0000000000..bec6cbe551 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendRecordExcel.java @@ -0,0 +1,92 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Data +public class WxmpUpdateSendRecordExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "客户Id ") + private String customerId; + + @Excel(name = "网格Id (居民端跟网格有关的则有值,工作端以及一些居民端和网格没关的存*)") + private String gridId; + + @Excel(name = "所属端类型 居民端:resi 工作端:gov") + private String clientType; + + @Excel(name = "消息模板Id ") + private String templateId; + + @Excel(name = "用户Id") + private String userId; + + @Excel(name = "openId ") + private String wxOpenId; + + @Excel(name = "行为类型: 关注更新提醒、内容更新消息通知") + private String behaviorType; + + @Excel(name = "消息标题 ") + private String title; + + @Excel(name = "消息内容 ") + private String content; + + @Excel(name = "消息时间 ") + private Date time; + + @Excel(name = "发送结果(成功:success 失败:error)") + private String result; + + @Excel(name = "发送失败的原因,成功可以不记录") + private String reason; + + @Excel(name = "删除标识") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendDataRedis.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendDataRedis.java new file mode 100644 index 0000000000..48cc7ac397 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendDataRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Component +public class WxmpUpdateSendDataRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendRecordRedis.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendRecordRedis.java new file mode 100644 index 0000000000..05235661a1 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendRecordRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Component +public class WxmpUpdateSendRecordRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SysSmsService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SysSmsService.java index 1e67125423..8bb9cb2a8e 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SysSmsService.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SysSmsService.java @@ -12,11 +12,13 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.entity.SysSmsEntity; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** @@ -58,5 +60,13 @@ public interface SysSmsService extends BaseService { * @Date 2020/6/23 21:07 **/ SendVerificationCodeResultDTO sendVerificationCode(SendVerificationCodeFormDTO formDTO); + + /** + * @param formDTOList + * @author sun + * @description 项目流转或滞留推送短信提醒 + **/ + void projectSendMsg(List formDTOList); + } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java index 315bf5c6d6..c2e3439bc2 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java @@ -17,10 +17,9 @@ package com.epmet.service; -import com.epmet.dto.form.ActivationSubscribeFormDTO; -import com.epmet.dto.form.GetTemplateListFormDTO; -import com.epmet.dto.form.WxSubscribeMessageFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.GetTemplateListResultDTO; +import com.epmet.dto.result.TemplateListV2ResultDTO; import com.epmet.dto.result.WxMsgAuthInfoResultDTO; import java.util.List; @@ -41,7 +40,7 @@ public interface WxmpMessageService { String behaviorType, String userId); /** - * @Description 发送订阅消息 + * @Description 发送站内信订阅消息 * @param msgList * @return void * @Author liushaowen @@ -51,7 +50,7 @@ public interface WxmpMessageService { /** * @return - * @Description 居民端、工作端-获取客户小程序模板列表 + * @Description 居民端、工作端-获取客户小程序模板列表(只有站内信消息模板) * @author sun */ List templateList(GetTemplateListFormDTO formDTO); @@ -62,4 +61,21 @@ public interface WxmpMessageService { * @author sun */ void activationSubscribe(ActivationSubscribeFormDTO formDTO); + /** + * @Description 居民端、工作端-获取客户小程序模板列表(不包括站内信消息模板) + * @param formDTO + * @return java.util.List + * @Author liushaowen + * @Date 2020/12/29 13:26 + */ + List templateListV2(TemplateListV2FormDTO formDTO); + + /** + * @Description 发送(内容更新消息提醒、关注更新提醒)订阅消息 + * @param msgList + * @return void + * @Author liushaowen + * @Date 2020/12/30 13:36 + */ + void sendWxSubscribeUpdate(List msgList); } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendDataService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendDataService.java new file mode 100644 index 0000000000..5d21093d61 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendDataService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.WxmpUpdateSendDataDTO; +import com.epmet.entity.WxmpUpdateSendDataEntity; + +import java.util.List; +import java.util.Map; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +public interface WxmpUpdateSendDataService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-01-04 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-01-04 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return WxmpUpdateSendDataDTO + * @author generator + * @date 2021-01-04 + */ + WxmpUpdateSendDataDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-01-04 + */ + void save(WxmpUpdateSendDataDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-01-04 + */ + void update(WxmpUpdateSendDataDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-01-04 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendRecordService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendRecordService.java new file mode 100644 index 0000000000..cf67d914fe --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendRecordService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.WxmpUpdateSendRecordDTO; +import com.epmet.entity.WxmpUpdateSendRecordEntity; + +import java.util.List; +import java.util.Map; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +public interface WxmpUpdateSendRecordService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-12-30 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-12-30 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return WxmpUpdateSendRecordDTO + * @author generator + * @date 2020-12-30 + */ + WxmpUpdateSendRecordDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-12-30 + */ + void save(WxmpUpdateSendRecordDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-12-30 + */ + void update(WxmpUpdateSendRecordDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-12-30 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java index 2c254701d2..f5c741a212 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SysSmsServiceImpl.java @@ -17,14 +17,20 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.SysSmsConstant; import com.epmet.dao.SysSmsDao; import com.epmet.dto.SysSmsDTO; +import com.epmet.dto.form.CrmParameterFormDTO; +import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.entity.SysSmsEntity; import com.epmet.exception.ModuleErrorCode; import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.service.SysSmsService; import com.epmet.sms.AbstractSmsService; import com.epmet.sms.SmsFactory; @@ -35,10 +41,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service public class SysSmsServiceImpl extends BaseServiceImpl implements SysSmsService { @@ -47,6 +56,8 @@ public class SysSmsServiceImpl extends BaseServiceImpl @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; @Override public PageData page(Map params) { @@ -181,4 +192,97 @@ public class SysSmsServiceImpl extends BaseServiceImpl } return data; } + + /** + * @param formDTOList + * @author sun + * @description 项目流转或滞留推送短信提醒 + **/ + @Override + public void projectSendMsg(List formDTOList) { + if (CollectionUtils.isEmpty(formDTOList)){ + logger.error(SysSmsConstant.IS_NULL_PARAM_LIST); + return; + } + Map> groupByCustomer = formDTOList.stream().collect(Collectors.groupingBy(ProjectSendMsgFormDTO::getCustomerId)); + List formDTOS = ConvertUtils.sourceToTarget(formDTOList, CrmParameterFormDTO.class); + List parameterFormDTOS = formDTOS.stream().distinct().collect(Collectors.toList()); + Result> listResult = operCrmOpenFeignClient.selectParamInfo(parameterFormDTOS); + if (!listResult.success()){ + throw new RenException(SysSmsConstant.SELECT_PARAMETER_INFO_FAILURE); + } + List parameterResult = listResult.getData(); + if (CollectionUtils.isEmpty(parameterResult)){ + logger.error(SysSmsConstant.PARAMETER_INFO_IS_ZERO); + return; + } + groupByCustomer.forEach((customerId,v) -> { + parameterResult.forEach(p -> { + if (customerId.equals(p.getCustomerId())){ + p.setBalanceStatus(Integer.valueOf(p.getParameterValue()) >= v.size() ? true : false); + p.setSubtractParameterValue(String.valueOf(Integer.valueOf(p.getParameterValue()) - v.size())); + } + }); + }); + try { + groupByCustomer.forEach((customerId,v) -> { + parameterResult.forEach(p -> { + if (customerId.equals(p.getCustomerId())){ + // 判断参数开关是否打开,false:未打开 + if (p.getSwitchStatus() == false){ + logger.error(String.format(SysSmsConstant.NOT_ON_SWITCH,customerId,p.getParameterKey())); + }else { + // 判断余额状态 false:余额不足 + if (p.getBalanceStatus() == false){ + logger.error(String.format(SysSmsConstant.NOT_ENOUGH_BALANCE,customerId,p.getParameterValue())); + }else { + v.forEach(dto->{ + SysSmsDTO sysSmsDTO = new SysSmsDTO(); + sysSmsDTO.setMobile(dto.getMobile()); + sysSmsDTO.setAliyunTemplateCode(dto.getAliyunTemplateCode()); + //推送短信 + this.sendMsg(sysSmsDTO); + }); + } + } + } + }); + }); + }catch (RenException e){ + logger.error(e.getInternalMsg()); + } + Map> groupBySwitch = parameterResult.stream().collect(Collectors.groupingBy(CrmParameterResultDTO::getSwitchStatus)); + List crmParameterTrue = groupBySwitch.get(true); + Map> groupByStatus = crmParameterTrue.stream().collect(Collectors.groupingBy(CrmParameterResultDTO::getBalanceStatus)); + List crmParameterResultDTOS = groupByStatus.get(true); + // 把参数开关打开的,已发送短信的客户更新余额 + if (!CollectionUtils.isEmpty(crmParameterResultDTOS)){ + operCrmOpenFeignClient.updateParamInfo(crmParameterResultDTOS); + } + } + + /** + * @author sun + * @description 推送短信信箱,出错不中断 + **/ + private void sendMsg(SysSmsDTO sysSmsDTO) { + logger.info(String.format("固定短信模板推送短信信息接口入参:%s", JSON.toJSONString(sysSmsDTO))); + LinkedHashMap map = null; + try { + //短信服务 + AbstractSmsService service = SmsFactory.build(); + if (service == null) { + logger.error("发送短信异常,ErrorCode:%s,异常AbstractSmsService is null", ModuleErrorCode.SMS_CONFIG); + } + //发送短信 + if (StringUtils.isNotBlank(sysSmsDTO.getAliyunTemplateCode())) { + service.sendSmsByAliyunTemplateCode(sysSmsDTO.getMobile(), map, sysSmsDTO.getAliyunTemplateCode()); + } else { + service.sendSms(sysSmsDTO.getMobile(), map); + } + } catch (Exception e) { + logger.error(String.format("项目提醒发送短信失败,失败手机号:%s,ErrorCode:%s", sysSmsDTO.getMobile(), e.getMessage())); + } + } + } diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java index 0d390bfc31..c5e1bf1ec6 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java @@ -40,6 +40,8 @@ import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.WxmpMessageRedis; import com.epmet.service.WxmpMessageService; import com.epmet.service.WxmpMsgSendRecordService; +import com.epmet.service.WxmpUpdateSendDataService; +import com.epmet.service.WxmpUpdateSendRecordService; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,10 +51,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 微信消息订阅Service @@ -82,9 +81,15 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { @Autowired private WxmpMsgSendRecordService wxmpMsgSendRecordService; + @Autowired + private WxmpUpdateSendRecordService wxmpUpdateSendRecordService; + @Autowired private WxmpUserSubscribeRecordDao subscribeRecordDao; + @Autowired + private WxmpUpdateSendDataService wxmpUpdateSendDataService; + /** * @return void * @Description 保存系统授权信息 @@ -125,7 +130,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { /** * @param msgList * @return void - * @Description 发送订阅消息 + * @Description 发送站内信订阅消息 * @Author liushaowen * @Date 2020/10/21 15:34 */ @@ -139,7 +144,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { // 获取templateId CustomerTemplateListFormDTO customerTemplateListFormDTO = new CustomerTemplateListFormDTO(); customerTemplateListFormDTO.setCustomerId(msgList.get(0).getCustomerId()); - customerTemplateListFormDTO.setPublicId(WxmpMessageConstant.TEMPLATE_TYPE); + customerTemplateListFormDTO.setPublicId(WxmpMessageConstant.MESSAGE_TEMPLATE_TYPE); List customerTemplateListResultDTOS = customerTemplateList(customerTemplateListFormDTO); // 获取AccessToken Map accessTokenMap = getAccessToken(msgList.get(0).getCustomerId()); @@ -151,32 +156,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { String templateId = null; String openId = null; //通过userId获取openId - try { - if (WxmpMessageConstant.RESI.equals(clientType)) { - UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO(); - userBasicInfoFormDTO.setUserId(userId); - Result userBasicInfo = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO); - if (userBasicInfo.getCode() != 0){ - throw new Exception(userBasicInfo.getInternalMsg()); - }else { - openId = userBasicInfo.getData().getOpenId(); - } - } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { - StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO(); - staffBasicInfoFormDTO.setStaffId(userId); - Result staffBasicInfo = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO);; - if (staffBasicInfo.getCode() != 0){ - throw new Exception(staffBasicInfo.getInternalMsg()); - }else { - openId = staffBasicInfo.getData().getOpenId(); - } - } else { - throw new WxSubscribeException("clientType有误", "", openId); - } - } catch (Exception e) { - e.printStackTrace(); - throw new WxSubscribeException("获取openId失败:" + e.getMessage(), "", ""); - } + openId = getUserOpenId(userId, clientType, openId); if (StringUtils.isBlank(openId)) { throw new WxSubscribeException("该userId未查询到关联的openId", "", ""); @@ -234,7 +214,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { String title = "您有一条" + msg.getBehaviorType(); JSONObject titleJson = new JSONObject(); titleJson.put("value", title.length() > WxmpMessageConstant.TITLE_LIMIT ? title.substring(0, WxmpMessageConstant.TITLE_LIMIT) : title); - data.put(WxmpMessageConstant.TITLE, titleJson); + data.put(WxmpMessageConstant.MESSAGE_TITLE, titleJson); //内容 JSONObject contentJson = new JSONObject(); contentJson.put("value", msg.getMessageContent().length() > WxmpMessageConstant.MESSAGE_CONTENT_LIMIT ? msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT) : msg.getMessageContent()); @@ -247,11 +227,11 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { EnvEnum envEnum = EnvEnum.getCurrentEnv(); //选填项 if (WxmpMessageConstant.RESI.equals(clientType)) { - StringBuilder resiPage = new StringBuilder(WxmpMessageConstant.PAGE_URL); + StringBuilder resiPage = new StringBuilder(WxmpMessageConstant.MESSAGE_PAGE_URL); resiPage.append("?customerId=").append(customerId).append("&gridId=").append(msg.getGridId()); jsonObject.put(WxmpMessageConstant.PAGE, resiPage.toString()); } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { - StringBuilder govPage = new StringBuilder(WxmpMessageConstant.PAGE_URL); + StringBuilder govPage = new StringBuilder(WxmpMessageConstant.MESSAGE_PAGE_URL); govPage.append("?customerId=").append(customerId).append("&staffId=").append(userId); jsonObject.put(WxmpMessageConstant.PAGE, govPage.toString()); } @@ -281,7 +261,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { logger.warn("消息{}发送成功但订阅条数-1失败", JSON.toJSONString(msg)); } //存表 - int saveRes = wxmpMsgSendRecordService.saveRecord(initRecord(msg, templateId, openId, WxmpMessageConstant.SUCCESS)); + int saveRes = wxmpMsgSendRecordService.saveRecord(initWxmpMsgSendRecord(msg, templateId, openId, WxmpMessageConstant.SUCCESS)); if (saveRes == 0) { logger.warn("消息{}发送成功但存入记录表失败", JSON.toJSONString(msg)); } @@ -312,7 +292,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { // } if (e instanceof WxSubscribeException) { //存表 - WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = initRecord(msg, ((WxSubscribeException) e).getTemplateId(), ((WxSubscribeException) e).getOpenId(), WxmpMessageConstant.ERROR); + WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = initWxmpMsgSendRecord(msg, ((WxSubscribeException) e).getTemplateId(), ((WxSubscribeException) e).getOpenId(), WxmpMessageConstant.ERROR); wxmpMsgSendRecordEntity.setReason(errMsg); int saveRes = wxmpMsgSendRecordService.saveRecord(wxmpMsgSendRecordEntity); if (saveRes == 0) { @@ -328,7 +308,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { } //初始化记录对象 - private WxmpMsgSendRecordEntity initRecord(WxSubscribeMessageFormDTO msg, String templateId, String openId, String status) { + private WxmpMsgSendRecordEntity initWxmpMsgSendRecord(WxSubscribeMessageFormDTO msg, String templateId, String openId, String status) { WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = new WxmpMsgSendRecordEntity(); wxmpMsgSendRecordEntity.setCustomerId(msg.getCustomerId()); wxmpMsgSendRecordEntity.setClientType(msg.getClientType()); @@ -345,6 +325,215 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { return wxmpMsgSendRecordEntity; } + /** + * @param msgList + * @return void + * @Description 发送(内容更新消息提醒、关注更新提醒)订阅消息 + * @Author liushaowen + * @Date 2020/12/30 13:36 + */ + @Override + public void sendWxSubscribeUpdate(List msgList) { + if (msgList.size() == 0){ + return; + } + // 获取templateId + TemplateListV2FormDTO templateListV2FormDTO = new TemplateListV2FormDTO(); + templateListV2FormDTO.setCustomerId(msgList.get(0).getCustomerId()); + //获取工作端的 + templateListV2FormDTO.setApp(WxmpMessageConstant.GOV_REDIS); + List workTemplates = templateListV2(templateListV2FormDTO); + //获取居民端的 + templateListV2FormDTO.setApp(WxmpMessageConstant.RESI); + List resiTemplates = templateListV2(templateListV2FormDTO); + + //获取AccessToken + Map accessTokenMap = getAccessToken(msgList.get(0).getCustomerId()); + + for (WxSubscribeUpdateFormDTO msg : msgList) { + //生成属性表id + String dataId = UUID.randomUUID().toString().replace("-",""); + try { + String userId = msg.getUserId(); + String clientType = msg.getClientType(); + String customerId = msg.getCustomerId(); + String templateId = null; + String openId = null; + //通过userId获取openId + openId = getUserOpenId(userId, clientType, openId); + if (StringUtils.isBlank(openId)) { + throw new WxSubscribeException("该userId未查询到关联的openId", "", ""); + } + + //获取模板id + if (WxmpMessageConstant.GOV_DB.equals(msg.getClientType())&& workTemplates.size() > NumConstant.ZERO) { + for (TemplateListV2ResultDTO workTemplate : workTemplates) { + if (workTemplate.getTid().equals(msg.getBehaviorType())){ + templateId = workTemplate.getTemplateId(); + break; + }; + } + } else if (WxmpMessageConstant.RESI.equals(msg.getClientType())&& resiTemplates.size() > NumConstant.ZERO) { + for (TemplateListV2ResultDTO resiTemplate : resiTemplates) { + if (resiTemplate.getTid().equals(msg.getBehaviorType())){ + templateId = resiTemplate.getTemplateId(); + break; + }; + } + }else { + throw new WxSubscribeException("获取模板id失败", "", openId); + } + if (StringUtils.isBlank(templateId)) { + throw new WxSubscribeException("获取模板id失败", "", openId); + } + + //获取accessToken + String accessToken = null; + if (WxmpMessageConstant.RESI.equals(clientType)) { + accessToken = accessTokenMap.get("resiToken"); + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { + accessToken = accessTokenMap.get("govToken"); + } + if (StringUtils.isBlank(accessToken)) { + throw new WxSubscribeException("accessToken获取失败"+accessTokenMap.get("errorMsg"), "", openId); + } + //发送消息 + JSONObject jsonObject = new JSONObject(); + JSONObject data = new JSONObject(); + //必填项 + jsonObject.put(WxmpMessageConstant.ACCESS_TOKEN, accessToken); + jsonObject.put(WxmpMessageConstant.TOUSER, openId); + jsonObject.put(WxmpMessageConstant.TEMPLATE_ID, templateId); + //标题 + JSONObject titleJson = new JSONObject(); + titleJson.put("value", msg.getMessageTitle().length() > WxmpMessageConstant.TITLE_LIMIT ? msg.getMessageTitle().substring(0, WxmpMessageConstant.TITLE_LIMIT) : msg.getMessageTitle()); + //内容 + JSONObject contentJson = new JSONObject(); + contentJson.put("value", msg.getMessageContent().length() > WxmpMessageConstant.MESSAGE_CONTENT_LIMIT ? msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT) : msg.getMessageContent()); + //时间 + JSONObject timeJson = new JSONObject(); + timeJson.put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(msg.getMessageTime())); + + if (WxmpMessageConstant.CONCERN_UPDATE_TEMPLATE_TYPE.equals(msg.getBehaviorType())){ + data.put(WxmpMessageConstant.CONCERN_UPDATE_TITLE, titleJson); + data.put(WxmpMessageConstant.CONCERN_UPDATE_CONTENT, contentJson); + data.put(WxmpMessageConstant.CONCERN_UPDATE_TIME ,timeJson); + } + if (WxmpMessageConstant.CONTENT_UPDATE_TEMPLATE_TYPE.equals(msg.getBehaviorType())){ + data.put(WxmpMessageConstant.CONTENT_UPDATE_TITLE, titleJson); + data.put(WxmpMessageConstant.CONTENT_UPDATE_CONTENT, contentJson); + data.put(WxmpMessageConstant.CONTENT_UPDATE_TIME, timeJson); + } + // + jsonObject.put(WxmpMessageConstant.DATA, data); + EnvEnum envEnum = EnvEnum.getCurrentEnv(); + //选填项 + if (WxmpMessageConstant.RESI.equals(clientType)) { + StringBuilder resiPage = new StringBuilder(WxmpMessageConstant.UPDATE_PAGE_URL); + resiPage.append(dataId); + jsonObject.put(WxmpMessageConstant.PAGE, resiPage.toString()); + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { + StringBuilder govPage = new StringBuilder(WxmpMessageConstant.UPDATE_PAGE_URL); + govPage.append(dataId); + jsonObject.put(WxmpMessageConstant.PAGE, govPage.toString()); + } + //开发环境 + if ("dev".equals(envEnum.getCode())) { + jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_DEV); + } + //测试环境 + if ("test".equals(envEnum.getCode())) { + jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_TEST); + } + + String resultStr = HttpClientManager.getInstance().sendPostByJSON(WxmpMessageConstant.SEND_MESSAGE + accessToken, JSON.toJSONString(jsonObject)).getData(); + Map resultMap = JSON.parseObject(resultStr, Map.class); + Object errcode = resultMap.get(WxmpMessageConstant.ERR_CODE); + if (errcode.equals(NumConstant.ZERO)) { + //发送成功 + //存数据表 + WxmpUpdateSendDataEntity wxmpUpdateSendDataEntity = new WxmpUpdateSendDataEntity(); + wxmpUpdateSendDataEntity.setId(dataId); + wxmpUpdateSendDataEntity.setMsgUserId(userId); + wxmpUpdateSendDataEntity.setAgencyId(msg.getAgencyId()); + wxmpUpdateSendDataEntity.setCustomerId(customerId); + wxmpUpdateSendDataEntity.setGridId(msg.getGridId()); + wxmpUpdateSendDataEntity.setGroupId(msg.getGroupId()); + wxmpUpdateSendDataEntity.setSourceId(msg.getSourceId()); + wxmpUpdateSendDataEntity.setSourceType(msg.getSourceType()); + wxmpUpdateSendDataEntity.setStaffId(msg.getStaffId()); + wxmpUpdateSendDataService.insert(wxmpUpdateSendDataEntity); + //存记录表 + wxmpUpdateSendRecordService.insert(initWxmpUpdateSendRecord(msg, templateId, openId, WxmpMessageConstant.SUCCESS)); + + } else { + //发送失败 + //抛出错误 + throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)), templateId, openId); + } + }catch (Exception e){ + String errMsg = e.getMessage(); + if (e instanceof WxSubscribeException) { + //存表 + WxmpUpdateSendRecordEntity wxmpUpdateSendRecordEntity = initWxmpUpdateSendRecord(msg, ((WxSubscribeException) e).getTemplateId(), ((WxSubscribeException) e).getOpenId(), WxmpMessageConstant.ERROR); + wxmpUpdateSendRecordEntity.setReason(errMsg); + wxmpUpdateSendRecordService.insert(wxmpUpdateSendRecordEntity); + } + logger.warn("消息:{}发送失败,原因是:{}", JSON.toJSONString(msg), errMsg); + continue; + } + } + } + + private WxmpUpdateSendRecordEntity initWxmpUpdateSendRecord(WxSubscribeUpdateFormDTO msg, String templateId, String openId, String status) { + WxmpUpdateSendRecordEntity wxmpUpdateSendRecordEntity = new WxmpUpdateSendRecordEntity(); + wxmpUpdateSendRecordEntity.setCustomerId(msg.getCustomerId()); + wxmpUpdateSendRecordEntity.setClientType(msg.getClientType()); + wxmpUpdateSendRecordEntity.setTemplateId(templateId); + wxmpUpdateSendRecordEntity.setGridId(msg.getGridId() == null ? "" : msg.getGridId()); + wxmpUpdateSendRecordEntity.setUserId(msg.getUserId()); + wxmpUpdateSendRecordEntity.setWxOpenId(openId); + wxmpUpdateSendRecordEntity.setBehaviorType(msg.getBehaviorType()); + wxmpUpdateSendRecordEntity.setTitle(msg.getMessageTitle()); + wxmpUpdateSendRecordEntity.setContent(msg.getMessageContent()); + wxmpUpdateSendRecordEntity.setTime(msg.getMessageTime()); + wxmpUpdateSendRecordEntity.setResult(status); + return wxmpUpdateSendRecordEntity; + } + + + private String getUserOpenId(String userId, String clientType, String openId) throws WxSubscribeException { + try { + if (WxmpMessageConstant.RESI.equals(clientType)) { + UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO(); + userBasicInfoFormDTO.setUserId(userId); + Result userBasicInfo = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO); + if (userBasicInfo.getCode() != 0){ + throw new Exception(userBasicInfo.getInternalMsg()); + }else { + openId = userBasicInfo.getData().getOpenId(); + } + } else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { + StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO(); + staffBasicInfoFormDTO.setStaffId(userId); + Result staffBasicInfo = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO);; + if (staffBasicInfo.getCode() != 0){ + throw new Exception(staffBasicInfo.getInternalMsg()); + }else { + openId = staffBasicInfo.getData().getOpenId(); + } + } else { + throw new WxSubscribeException("clientType有误", "", openId); + } + } catch (Exception e) { + e.printStackTrace(); + throw new WxSubscribeException("获取openId失败:" + e.getMessage(), "", ""); + } + return openId; + } + + + //获取AccessToken private Map getAccessToken(String customerId) { EnvEnum envEnum = EnvEnum.getCurrentEnv(); @@ -398,7 +587,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { /** * @return - * @Description 居民端、工作端-获取客户小程序模板列表 + * @Description 居民端、工作端-获取客户小程序模板列表(只包含站内信消息模板) * @author sun */ @Override @@ -430,6 +619,39 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { return list;*/ } + /** + * @param formDTO + * @return java.util.List + * @Description 居民端、工作端-获取客户小程序模板列表(不包括站内信消息模板) + * @Author liushaowen + * @Date 2020/12/29 13:26 + */ + @Override + public List templateListV2(TemplateListV2FormDTO formDTO) { + String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelistv2"; +// String url = "http://localhost:8110/third/personaltemplate/templatelistv2"; + String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(formDTO)).getData(); + logger.info("ThirdLoginServiceImpl.templatelistv2:httpclient->url:" + url + ",结果->" + data); + JSONObject toResult = JSON.parseObject(data); + Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + mapToResult.setCode(((Integer) toResult.get("code")).intValue()); + } + if (!mapToResult.success()) { + logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败"); + throw new RenException(mapToResult.getCode()); + } + List resultList = (List) mapToResult.getData(); + List list = new ArrayList<>(); + //必须转换 + for(Object f:resultList){ + JSONObject json = JSON.parseObject(f.toString()); + TemplateListV2ResultDTO ff = ConvertUtils.mapToEntity(json, TemplateListV2ResultDTO.class); + list.add(ff); + } + return list; + } + /** * @return * @Description 查询客户两个端小程序对应的站内信模板Id diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendDataServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendDataServiceImpl.java new file mode 100644 index 0000000000..a3e1718233 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendDataServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.WxmpUpdateSendDataDao; +import com.epmet.dto.WxmpUpdateSendDataDTO; +import com.epmet.entity.WxmpUpdateSendDataEntity; +import com.epmet.redis.WxmpUpdateSendDataRedis; +import com.epmet.service.WxmpUpdateSendDataService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 订阅消息发送数据表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-01-04 + */ +@Service +public class WxmpUpdateSendDataServiceImpl extends BaseServiceImpl implements WxmpUpdateSendDataService { + + @Autowired + private WxmpUpdateSendDataRedis wxmpUpdateSendDataRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, WxmpUpdateSendDataDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, WxmpUpdateSendDataDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public WxmpUpdateSendDataDTO get(String id) { + WxmpUpdateSendDataEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, WxmpUpdateSendDataDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(WxmpUpdateSendDataDTO dto) { + WxmpUpdateSendDataEntity entity = ConvertUtils.sourceToTarget(dto, WxmpUpdateSendDataEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(WxmpUpdateSendDataDTO dto) { + WxmpUpdateSendDataEntity entity = ConvertUtils.sourceToTarget(dto, WxmpUpdateSendDataEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendRecordServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendRecordServiceImpl.java new file mode 100644 index 0000000000..98b61d4444 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendRecordServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.WxmpUpdateSendRecordDao; +import com.epmet.dto.WxmpUpdateSendRecordDTO; +import com.epmet.entity.WxmpUpdateSendRecordEntity; +import com.epmet.redis.WxmpUpdateSendRecordRedis; +import com.epmet.service.WxmpUpdateSendRecordService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 订阅消息发送记录表(内容更新消息提醒、关注更新提醒) + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-12-30 + */ +@Service +public class WxmpUpdateSendRecordServiceImpl extends BaseServiceImpl implements WxmpUpdateSendRecordService { + + @Autowired + private WxmpUpdateSendRecordRedis wxmpUpdateSendRecordRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, WxmpUpdateSendRecordDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, WxmpUpdateSendRecordDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public WxmpUpdateSendRecordDTO get(String id) { + WxmpUpdateSendRecordEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, WxmpUpdateSendRecordDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(WxmpUpdateSendRecordDTO dto) { + WxmpUpdateSendRecordEntity entity = ConvertUtils.sourceToTarget(dto, WxmpUpdateSendRecordEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(WxmpUpdateSendRecordDTO dto) { + WxmpUpdateSendRecordEntity entity = ConvertUtils.sourceToTarget(dto, WxmpUpdateSendRecordEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.6__add_subscribe_update.sql b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.6__add_subscribe_update.sql new file mode 100644 index 0000000000..a14887a385 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.6__add_subscribe_update.sql @@ -0,0 +1,41 @@ +CREATE TABLE `wxmp_update_send_record` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ', + `GRID_ID` varchar(64) DEFAULT NULL COMMENT '网格Id (居民端跟网格有关的则有值,工作端以及一些居民端和网格没关的存*)', + `CLIENT_TYPE` varchar(64) NOT NULL COMMENT '所属端类型 居民端:resi 工作端:gov', + `TEMPLATE_ID` varchar(64) NOT NULL COMMENT '消息模板Id ', + `USER_ID` varchar(64) NOT NULL COMMENT '用户Id', + `WX_OPEN_ID` varchar(64) DEFAULT NULL COMMENT 'openId ', + `BEHAVIOR_TYPE` varchar(128) NOT NULL COMMENT '行为类型: 关注更新提醒、内容更新消息通知', + `TITLE` varchar(128) NOT NULL COMMENT '消息标题 ', + `CONTENT` varchar(1024) NOT NULL COMMENT '消息内容 ', + `TIME` datetime NOT NULL COMMENT '消息时间 ', + `RESULT` varchar(32) NOT NULL COMMENT '发送结果(成功:success 失败:error)', + `REASON` varchar(1024) DEFAULT NULL COMMENT '发送失败的原因,成功可以不记录', + `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订阅消息发送记录表(内容更新消息提醒、关注更新提醒)'; + +CREATE TABLE `wxmp_update_send_data` ( + `ID` varchar(32) NOT NULL COMMENT '主键', + `SOURCE_TYPE` varchar(32) NOT NULL COMMENT '来源类型 (话题:topic 议题:issue 项目project 爱心互助heart 党建声音voice)', + `SOURCE_ID` varchar(32) NOT NULL COMMENT '来源对应ID', + `CUSTOMER_ID` varchar(32) NOT NULL COMMENT '客户ID', + `AGENCY_ID` varchar(32) DEFAULT NULL COMMENT '组织ID agencyId', + `GRID_ID` varchar(32) DEFAULT NULL COMMENT '网格ID ', + `GROUP_ID` varchar(32) DEFAULT NULL COMMENT '小组Id', + `STAFF_ID` varchar(32) DEFAULT NULL COMMENT '工作人员Id', + `MSG_USER_ID` varchar(1024) DEFAULT NULL COMMENT '消息接收者', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订阅消息发送数据表(内容更新消息提醒、关注更新提醒)'; diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendDataDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendDataDao.xml new file mode 100644 index 0000000000..3067841eaf --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendDataDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendRecordDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendRecordDao.xml new file mode 100644 index 0000000000..481ec4beea --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendRecordDao.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/ResiAroundPartyPointRankFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/ResiAroundPartyPointRankFormDTO.java new file mode 100644 index 0000000000..ea20744f4c --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/ResiAroundPartyPointRankFormDTO.java @@ -0,0 +1,49 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 身边党员 积分排行接口 入参 + * @Auth zy + */ +@Data +public class ResiAroundPartyPointRankFormDTO implements Serializable { + private static final long serialVersionUID = 1534061512200591149L; + + /** + * 页码 + * */ + @Min(value = 1) + private Integer pageNo = 1; + + /** + * 每页数据条数 + * */ + private Integer pageSize = 10; + + /** + * 身边党员 grid 社区党员community + * */ + private String scope; + + /** + * 本月 monthly 总排行 all; + * */ + private String type; + + /** + * 当前网格id + * */ + private String gridId; + + /** + * 通过网格id,获取到的 网格下的 认证成功的党员 的用户id + * */ + private List userIds; +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/ResiAroundPartyPointRankResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/ResiAroundPartyPointRankResultDTO.java new file mode 100644 index 0000000000..33c9ba5ffb --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/ResiAroundPartyPointRankResultDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 身边党员 积分排行接口返参DTO + * @Auth zy + */ +@Data +public class ResiAroundPartyPointRankResultDTO implements Serializable { + private static final long serialVersionUID = 685408245193506541L; + + /** + * 排序 + * */ + private Integer ranking; + + /** + * 积分 + * */ + private Integer point; + + /** + * 头像 + * */ + private String userHeadPhoto; + + /** + * 名称 + * */ + private String realName; + + /** + * 用户id + * */ + private String userId; +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/AroundPartyConstant.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/AroundPartyConstant.java new file mode 100644 index 0000000000..43a1a8498a --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/AroundPartyConstant.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.common.enu; + +import com.epmet.commons.tools.constant.Constant; + +/** + * 身边党员-积分排行 入参常量 + * + * @author Mark sunlightcs@gmail.com + * @since 1.1.0 + */ +public interface AroundPartyConstant extends Constant { + + String ALL = "all"; + + String MONTHLY = "monthly"; + + String GRID = "grid"; + + String COMMUNITY = "community"; +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/AdjustmentController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/AdjustmentController.java index 535b717e0c..f610a25df6 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/AdjustmentController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/AdjustmentController.java @@ -97,4 +97,3 @@ public class AdjustmentController { return new Result(); } } - diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java index f4e5ce6bb4..5c3b666fa1 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java @@ -6,11 +6,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.CommonPageUserFormDTO; import com.epmet.dto.form.CommonUserFormDTO; +import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; -import com.epmet.dto.result.PointExchangeResponseResultDTO; -import com.epmet.dto.result.ResiPointDetailResultDTO; -import com.epmet.dto.result.ResiPointLogListResultDTO; -import com.epmet.dto.result.ResiPointRankListResultDTO; +import com.epmet.dto.result.*; import com.epmet.service.PointVerificationLogService; import com.epmet.service.UserPointActionLogService; import com.epmet.service.UserPointStatisticalDailyService; @@ -141,4 +139,21 @@ public class ResiPointController { public Result exchangeCallback(@LoginUser TokenDto tokenDto){ return new Result().ok(pointVerificationLogService.resiExchangeCallback(tokenDto.getUserId())); } + + /** + * 身边党员-积分排行 + * 查询规则: scope : grid && type :monthly 表示:按网格统计,对本月党员增加的积分 进行排序 + * scope : grid && type :all 表示:按网格统计,对党员累计可用积分 排序 + * scope : community && type :monthly 表示:按社区统计,对本月党员增加的积分 进行排序 + * scope : community && type :all 表示:按社区统计,对党员累计可用积分 排序 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 16:17 2020-12-28 + **/ + @PostMapping("aroundparty") + public Result> aroundPartyPointRank( @RequestBody ResiAroundPartyPointRankFormDTO formDTO){ + List resultDTOS = userPointStatisticalDailyService.listAroundPartyPointRank(formDTO); + return new Result>().ok(resultDTOS); + } } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java index 9f9783797d..63a3e68c1c 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java @@ -18,6 +18,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; +import com.epmet.dto.result.ResiAroundPartyPointRankResultDTO; import com.epmet.dto.result.ResiPointRankResultDTO; import com.epmet.entity.UserPointStatisticalDailyEntity; import org.apache.ibatis.annotations.Mapper; @@ -62,4 +64,22 @@ public interface UserPointStatisticalDailyDao extends BaseDao + * @Author zhangyong + * @Date 09:24 2020-12-29 + **/ + List selectListGridPartyRankByUsablePoint(ResiAroundPartyPointRankFormDTO formDTO); + + /** + * 身边党员-积分排行 :按网格统计,对本月党员增加的积分 进行排序 + * @param formDTO + * @return java.util.List + * @Author zhangyong + * @Date 09:24 2020-12-29 + **/ + List selectListGridPartyRankByMonth(ResiAroundPartyPointRankFormDTO formDTO); +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java index 9d3f2d3ecf..6630a87891 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java @@ -20,7 +20,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.UserPointStatisticalDailyDTO; +import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; +import com.epmet.dto.result.ResiAroundPartyPointRankResultDTO; import com.epmet.dto.result.ResiPointRankListResultDTO; import com.epmet.entity.UserPointStatisticalDailyEntity; @@ -114,4 +116,13 @@ public interface UserPointStatisticalDailyService extends BaseService> + * @Author zhangyong + * @Date 16:17 2020-12-28 + **/ + List listAroundPartyPointRank(ResiAroundPartyPointRankFormDTO formDTO); +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java index a36a0c39d9..8b0b408d8a 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java @@ -19,21 +19,23 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.common.enu.AroundPartyConstant; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.UserPointStatisticalDailyDao; import com.epmet.dto.UserPointStatisticalDailyDTO; +import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; -import com.epmet.dto.result.ResiPointRankListResultDTO; -import com.epmet.dto.result.ResiPointRankResultDTO; -import com.epmet.dto.result.ResiPointRankingResultDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.UserPointStatisticalDailyEntity; import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; +import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; import com.epmet.service.UserPointStatisticalDailyService; import com.epmet.utils.DimIdGenerator; import com.epmet.utils.ModuleConstant; @@ -59,6 +61,10 @@ public class UserPointStatisticalDailyServiceImpl extends BaseServiceImpl page(Map params) { @@ -230,5 +236,104 @@ public class UserPointStatisticalDailyServiceImpl extends BaseServiceImpl listAroundPartyPointRank(ResiAroundPartyPointRankFormDTO formDTO) { + // 0、查询条件 + formDTO.setPageNo((formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize()); + List resultDTOS = new ArrayList<>(); + + // 增加边界条件 + if (StringUtils.isBlank(formDTO.getGridId()) || StringUtils.isBlank(formDTO.getScope()) || StringUtils.isBlank(formDTO.getType())){ + log.warn("入参错误 gridId:{} ; scope:{} ; type:{} ;", formDTO.getGridId(), formDTO.getScope(), formDTO.getType()); + return resultDTOS; + } + + List gridList = new ArrayList<>(); + // 1-1、获取参数中的网格id + if (AroundPartyConstant.GRID.equals(formDTO.getScope())){ + gridList.add(formDTO.getGridId()); + } + + // 1-2、获取社区(下的所有网格) 的网格id + if (AroundPartyConstant.COMMUNITY.equals(formDTO.getScope())){ + Result> gridInCommunity = govOrgOpenFeignClient.getGridIdsInCommunity(formDTO.getGridId()); + if (gridInCommunity.success() && null != gridInCommunity.getData() && gridInCommunity.getData().isEmpty()){ + log.warn("根据" + formDTO.getGridId() + "网格id, 查询不到同属于一个社区下的所有网格id"); + return resultDTOS; + } + gridList = gridInCommunity.getData(); + } + + // 2.根据网格id,获取网格下的所有党员(认证通过) + Result> partymemberInfo = resiPartyMemberOpenFeignClient.getPartymemberInfoByGridId(gridList); + if (partymemberInfo.success() && null != partymemberInfo.getData() && partymemberInfo.getData().isEmpty()){ + log.warn("根据" + formDTO.getGridId() + "网格id, 查询不到党员信息"); + return resultDTOS; + } + + // 2.1.获取认证通过党员的 用户id + List userIds = getUserIds(partymemberInfo.getData()); + formDTO.setUserIds(userIds); + + // 3.根据用户id(所有),查询积分信息,进行排名 + if (AroundPartyConstant.ALL.equals(formDTO.getType())){ + // type :all 表示:按网格(一个网格 或 社区下的所有网格)统计,对党员累计可用积分 排序 + resultDTOS = baseDao.selectListGridPartyRankByUsablePoint(formDTO); + + } else if (AroundPartyConstant.MONTHLY.equals(formDTO.getType())){ + // type :monthly 表示:按网格(一个网格 或 社区下的所有网格)统计,对本月党员增加的积分 进行排序 + resultDTOS = baseDao.selectListGridPartyRankByMonth(formDTO); + } -} \ No newline at end of file + // 4.给排好序的 身边党员-积分排行, 赋值 【头像、真实姓名】 + resultDTOS = getPartyBaseInfo(resultDTOS); + return resultDTOS; + } + + /** + * 获取认证通过的党员的 用户id + * + * @param partymemberInfo + * @return java.util.List + * @Author zhangyong + * @Date 14:11 2020-12-29 + **/ + private List getUserIds(List partymemberInfo){ + List userIds = new ArrayList<>(); + for (PartymemberInfoDTO dto : partymemberInfo){ + userIds.add(dto.getUserId()); + } + return userIds; + } + + /** + * 给排好序的 身边党员-积分排行, 赋值 【头像、真实姓名】 + * @param rankResultDTOS + * @return java.util.List + * @Author zhangyong + * @Date 10:14 2020-12-29 + **/ + private List getPartyBaseInfo(List rankResultDTOS){ + // 1.获取当前党员Id + List userIdParam = new LinkedList<>(); + for (ResiAroundPartyPointRankResultDTO formDTO : rankResultDTOS){ + userIdParam.add(formDTO.getUserId()); + } + if (userIdParam.size() == NumConstant.ZERO){ + return rankResultDTOS; + } + // 2.获取用户基本信息 + Result> myResiInfoResult = epmetUserOpenFeignClient.queryUserBaseInfo(userIdParam); + if(myResiInfoResult.success() && null != myResiInfoResult.getData() && !myResiInfoResult.getData().isEmpty()){ + for (UserBaseInfoResultDTO resiInfo : myResiInfoResult.getData()){ + for (ResiAroundPartyPointRankResultDTO formDTO : rankResultDTOS){ + if (formDTO.getUserId().equals(resiInfo.getUserId())){ + formDTO.setUserHeadPhoto(resiInfo.getHeadImgUrl()); + formDTO.setRealName(resiInfo.getRealName()); + } + } + } + } + return rankResultDTOS; + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml index 9bb759ed72..983301e016 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml @@ -130,4 +130,53 @@ - \ No newline at end of file + + + + + + diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index 933906f4ad..3b724521a5 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -114,6 +114,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Value("${openapi.scan.server.url}") private String scanApiUrl; @Value("${openapi.scan.method.textSyncScan}") @@ -505,17 +506,26 @@ public class IssueServiceImpl extends BaseServiceImpl imp //发送站内信 - UserMessageFormDTO msgObj = new UserMessageFormDTO(); - msgObj.setApp(ModuleConstants.APP_RESI); - msgObj.setCustomerId(application.getCustomerId()); - msgObj.setGridId(application.getGridId()); - msgObj.setMessageContent(String.format(ModuleConstants.ISSUE_AUDIT_RESULT_MSG_CONTENT_TEMPLATE,application.getIssueTitle(),StringUtils.equals(ModuleConstants.AUDITION_TYPE_REJECT,param.getActionType()) ? ModuleConstants.ISSUE_ACTION_REJECT : ModuleConstants.ISSUE_ACTION_SHIFT)); - msgObj.setReadFlag(ReadFlagConstant.UN_READ); - msgObj.setTitle(ModuleConstants.ISSUE_AUDIT_RESULT_MSG_TITLE_TEMPLATE); - msgObj.setUserId(application.getCreatedBy()); - List msgList = new LinkedList<>();msgList.add(msgObj); - epmetMessageOpenFeignClient.saveUserMessageList(msgList); - +// UserMessageFormDTO msgObj = new UserMessageFormDTO(); +// msgObj.setApp(ModuleConstants.APP_RESI); +// msgObj.setCustomerId(application.getCustomerId()); +// msgObj.setGridId(application.getGridId()); +// msgObj.setMessageContent(String.format(ModuleConstants.ISSUE_AUDIT_RESULT_MSG_CONTENT_TEMPLATE,application.getIssueTitle(),StringUtils.equals(ModuleConstants.AUDITION_TYPE_REJECT,param.getActionType()) ? ModuleConstants.ISSUE_ACTION_REJECT : ModuleConstants.ISSUE_ACTION_SHIFT)); +// msgObj.setReadFlag(ReadFlagConstant.UN_READ); +// msgObj.setTitle(ModuleConstants.ISSUE_AUDIT_RESULT_MSG_TITLE_TEMPLATE); +// msgObj.setUserId(application.getCreatedBy()); +// List msgList = new LinkedList<>();msgList.add(msgObj); +// epmetMessageOpenFeignClient.saveUserMessageList(msgList); + //对关注此话题的用户推送订阅 + try { + SendWxmpUpdateSubscribeFormDTO formDTO = new SendWxmpUpdateSubscribeFormDTO(); + formDTO.setTokenDto(token); + formDTO.setSourceId(app2update.getIssueId()); + formDTO.setSourceType("shiftIssue"); + resiGroupOpenFeignClient.sendWxmpUpdateSubscribe(formDTO); + }catch (Exception e){ + logger.warn("话题转议题-发送订阅消息失败 错误信息:"+e.getMessage()); + } //} //applicationService.update(app2update); diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInCommunityDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInCommunityDTO.java new file mode 100644 index 0000000000..52cfa389da --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInCommunityDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据网格id查询,它的父级 社区id + 最后返回 社区id 下的所有网格信息 + * @Author zy + * @Date 2020/12/28 23:16 + */ +@Data +public class GridInCommunityDTO implements Serializable { + private static final long serialVersionUID = 4360690752084258055L; + + /** + * 网格ID + */ + private String gridId; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 客户ID + */ + private String customerId; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 2dab8452b3..fe67bef009 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -314,4 +314,14 @@ public interface GovOrgOpenFeignClient { **/ @PostMapping("/gov/org/customergrid/griddatafilter") Result gridDataFilter(CommonGridIdFormDTO gridForm); + + /** + * 根据 网格id,查询同属于一个社区下的所有网格id + * @param gridId + * @return com.epmet.commons.tools.utils.Result> + * @Author zhangyong + * @Date 17:44 2020-12-28 + **/ + @GetMapping("/gov/org/customergrid/getGridIdsInCommunity/{gridId}") + Result> getGridIdsInCommunity(@PathVariable("gridId") String gridId); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 4776dec9b6..d9d5be0a84 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -181,6 +181,10 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { @Override public Result gridDataFilter(CommonGridIdFormDTO gridForm) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "gridDataFilter", gridForm); + } + @Override + public Result> getGridIdsInCommunity(String gridId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridIdsInCommunity", gridId); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index b86bb7df20..5068d6187f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -228,4 +228,16 @@ public class CustomerGridController { return new Result().ok(customerGridService.selectGridCount(customerIdFormDTO)); } + /** + * @param gridId + * @return com.epmet.commons.tools.utils.Result> + * @Author zy + * @Description 根据 网格id,查询同属于一个社区下的所有网格id + * @Date 2020/12/28 23:16 + **/ + @GetMapping("getGridIdsInCommunity/{gridId}") + public Result> getGridIdsInCommunity(@PathVariable("gridId") String gridId) { + List resultDTOS = customerGridService.listGridIdsInCommunity(gridId); + return new Result>().ok(resultDTOS); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 64274d1b69..a6c519d1ce 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -246,4 +246,13 @@ public interface CustomerGridDao extends BaseDao { List selectOrgInfoByAgency(@Param("orgIds")List orgIds); List selectOrgInfoByGrid(@Param("orgIds")List orgIds); List selectOrgInfoByDept(@Param("orgIds")List orgIds); -} \ No newline at end of file + + /** + * @param gridId + * @return com.epmet.commons.tools.utils.Result> + * @Author zy + * @Description 根据 网格id,查询同属于一个社区下的所有网格id + * @Date 2020/12/28 23:16 + **/ + List selectListGridIdsInCommunity(@Param("gridId") String gridId); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index f9e8610778..adb1d3c1e0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -39,7 +39,7 @@ import java.util.List; import java.util.Map; /** - * 客户网格表 + * 客户网格表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-16 @@ -277,4 +277,13 @@ public interface CustomerGridService extends BaseService { * @date 2020/11/10 2:55 下午 */ List selectOrgInfo(OrgInfoFormDTO orgInfoFormDTO); -} \ No newline at end of file + + /** + * @param gridId + * @return com.epmet.commons.tools.utils.Result> + * @Author zy + * @Description 根据 网格id,查询同属于一个社区下的所有网格id + * @Date 2020/12/28 23:16 + **/ + List listGridIdsInCommunity(String gridId); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index df895b4f11..8302b1252f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -692,4 +692,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl listGridIdsInCommunity(String gridId) { + return baseDao.selectListGridIdsInCommunity(gridId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index b3e93a2fc3..df3a9fc938 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -545,4 +545,20 @@ ID = #{orgId} + + + diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java index 549b58fdbe..8575f2d4a8 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java @@ -35,11 +35,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ProjectConstant; import com.epmet.constant.ReadFlagConstant; +import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserMessageConstant; import com.epmet.dao.ProjectOrgRelationDao; import com.epmet.dao.ProjectDao; import com.epmet.dao.ProjectProcessDao; import com.epmet.dao.ProjectStaffDao; +import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.ProjectDTO; import com.epmet.dto.ProjectProcessDTO; import com.epmet.dto.ProjectStaffDTO; @@ -305,6 +307,7 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl smsList = new ArrayList<>(); + staffList.forEach(staff -> { + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(staff.getStaffId()); + Result staffResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffResult.success() && null != staffResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffResult.getData().getCustomerId()); + sms.setMobile(staffResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + }); + Result result = epmetMessageOpenFeignClient.projectSendMsg(smsList); + if (!result.success()) { + logger.error("项目流转,发送手机短信失败" + JSON.toJSONString(result)); + } + } /** @@ -684,6 +708,26 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl smsList = new ArrayList<>(); + staffList.forEach(staff -> { + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(staff.getStaffId()); + Result staffResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffResult.success() && null != staffResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffResult.getData().getCustomerId()); + sms.setMobile(staffResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + }); + Result result = epmetMessageOpenFeignClient.projectSendMsg(smsList); + if (!result.success()) { + logger.error("项目流转,发送手机短信失败" + JSON.toJSONString(result)); + } } } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 1a93868918..a72ad4c6f2 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -33,6 +33,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ParameterKeyConstant; import com.epmet.constant.ProjectConstant; +import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserMessageConstant; import com.epmet.dao.ProjectDao; import com.epmet.dao.ProjectOrgRelationDao; @@ -767,6 +768,24 @@ public class ProjectServiceImpl extends BaseServiceImpl smsList = new ArrayList<>(); + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(projectStaffDTO.getStaffId()); + Result staffResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffResult.success() && null != staffResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffResult.getData().getCustomerId()); + sms.setMobile(staffResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + result = epmetMessageOpenFeignClient.projectSendMsg(smsList); + if (!result.success()) { + logger.error("项目退回,发送手机短信失败" + JSON.toJSONString(result)); + } } @Override @@ -993,6 +1012,25 @@ public class ProjectServiceImpl extends BaseServiceImpl smsList = new ArrayList<>(); + staffList.forEach(staff -> { + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(staff.getStaffId()); + Result staffDTOResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffDTOResult.success() && null != staffDTOResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffDTOResult.getData().getCustomerId()); + sms.setMobile(staffDTOResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + }); + Result result = epmetMessageOpenFeignClient.projectSendMsg(smsList); + if (!result.success()) { + logger.error("项目吹哨,发送手机短信失败" + JSON.toJSONString(result)); + } return issueProjectResultDTO; } @@ -1380,6 +1418,8 @@ public class ProjectServiceImpl extends BaseServiceImpl msgList = new ArrayList<>(); //10.29 项目滞留提醒添加推送微信消息 sun List wxmpMsgList = new ArrayList<>(); + //短信消息 + List smsList = new ArrayList<>(); list.forEach(dto -> { String title; String msg; @@ -1429,6 +1469,19 @@ public class ProjectServiceImpl extends BaseServiceImpl staffDTOResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffDTOResult.success() && null != staffDTOResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffDTOResult.getData().getCustomerId()); + sms.setMobile(staffDTOResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_OVERDUE); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } }); messageFeignClient.saveUserMessageList(msgList); logger.info("项目滞留提醒,开始推送微信订阅消息"); @@ -1436,6 +1489,10 @@ public class ProjectServiceImpl extends BaseServiceImpl smsList = new ArrayList<>(); + CustomerStaffDTO staffDTO = new CustomerStaffDTO(); + staffDTO.setUserId(projectStaffDTO.getStaffId()); + Result staffResult = epmetUserFeignClient.getCustomerStaffInfoByUserId(staffDTO); + if (staffResult.success() && null != staffResult.getData()) { + ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); + sms.setCustomerId(staffResult.getData().getCustomerId()); + sms.setMobile(staffResult.getData().getMobile()); + sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); + sms.setParameterKey("send_msg"); + smsList.add(sms); + } + result = epmetMessageOpenFeignClient.projectSendMsg(smsList); + if (!result.success()) { + logger.error("项目退回,发送手机短信失败" + JSON.toJSONString(result)); + } } /** diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java new file mode 100644 index 0000000000..187553f93a --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerParameterDTO.java @@ -0,0 +1,82 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:59 + */ +@Data +public class CustomerParameterDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 唯一标识 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 参数KEY值 + */ + private String parameterKey; + + /** + * 参数名称 + */ + private String parameterName; + + /** + * 参数VALUE值 + */ + private String parameterValue; + + /** + * 参数开关:开启:on,关闭:off + */ + private String parameterSwitch; + + /** + * 说明 + */ + private String description; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java new file mode 100644 index 0000000000..ab31d56ae7 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CrmParameterFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:44 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CrmParameterFormDTO implements Serializable { + + private static final long serialVersionUID = -1892384189805073724L; + + public interface CrmParameterForm{} + + @NotBlank(message = "客户ID不能为空",groups = {CrmParameterForm.class}) + private String customerId; + + @NotBlank(message = "参数KEY值不能为空",groups = {CrmParameterForm.class}) + private String parameterKey; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java new file mode 100644 index 0000000000..23cca7c0d9 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CrmParameterResultDTO.java @@ -0,0 +1,49 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:46 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CrmParameterResultDTO implements Serializable { + + private static final long serialVersionUID = 8082721392714934568L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 参数KEY值 + */ + private String parameterKey; + + /** + * 参数VALUE值 + */ + private String parameterValue; + + /** + * 余额状态【parameterValue】true:充足,false:不足 + */ + private Boolean balanceStatus = true; + + /** + * 新的参数VALUE值 + */ + private String subtractParameterValue; + + /** + * 参数开关状态 true:开启,false:关闭 + */ + private Boolean switchStatus; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 27d5c239d4..496dcd636a 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -4,9 +4,11 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CrmParameterFormDTO; import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; @@ -22,7 +24,7 @@ import java.util.List; * @date 2020/6/4 13:25 */ @FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "118.190.150.119:48080/api") +//@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "localhost:8090") public interface OperCrmOpenFeignClient { /** * 获取客户信息 @@ -74,4 +76,22 @@ public interface OperCrmOpenFeignClient { */ @PostMapping("/oper/crm/customer/getgridcount") Result getGridCount(@RequestBody GridCountFormDTO formDTO); + + /** + * @Description 查询客户配置信息 + * @Param formDTO + * @author zxc + * @date 2021/1/4 上午11:20 + */ + @PostMapping("/oper/crm/parameter/parameterinfo") + Result> selectParamInfo(@RequestBody List formDTOs); + + /** + * @Description 更新客户配置信息 + * @Param formDTOS + * @author zxc + * @date 2021/1/4 下午4:23 + */ + @PostMapping("/oper/crm/parameter/parameterupdate") + Result updateParamInfo(@RequestBody List formDTOS); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index f4ad95f4ca..d18f98065a 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -5,9 +5,11 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CrmParameterFormDTO; import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.OperCrmOpenFeignClient; import org.springframework.stereotype.Component; @@ -57,4 +59,14 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { public Result getGridCount(GridCountFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getGridCount", formDTO); } + + @Override + public Result> selectParamInfo(List formDTOs) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "selectParamInfo", formDTOs); + } + + @Override + public Result updateParamInfo(List formDTOS) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java new file mode 100644 index 0000000000..006080bd6b --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerParameterController.java @@ -0,0 +1,53 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.CrmParameterFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; +import com.epmet.service.CustomerParameterService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:51 + */ +@RestController +@RequestMapping("parameter") +public class CustomerParameterController { + + @Autowired + private CustomerParameterService parameterService; + + /** + * @Description 查询客户配置信息 + * @Param formDTO + * @author zxc + * @date 2021/1/4 上午11:20 + */ + @PostMapping("parameterinfo") + public Result> selectParamInfo(@RequestBody List formDTOs){ + formDTOs.forEach(formDTO -> { + ValidatorUtils.validateEntity(formDTO, CrmParameterFormDTO.CrmParameterForm.class); + }); + return new Result>().ok(parameterService.selectParamInfo(formDTOs)); + } + + /** + * @Description 更新客户配置信息 + * @Param formDTOS + * @author zxc + * @date 2021/1/4 下午4:23 + */ + @PostMapping("parameterupdate") + public Result updateParamInfo(@RequestBody List formDTOS){ + parameterService.updateParamInfo(formDTOS); + return new Result(); + } + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java new file mode 100644 index 0000000000..5d11da7f96 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerParameterDao.java @@ -0,0 +1,34 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.CrmParameterFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; +import com.epmet.entity.CustomerParameterEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午11:01 + */ +@Mapper +public interface CustomerParameterDao extends BaseDao { + + /** + * @Description 查询客户的配置信息 + * @Param customerIds + * @author zxc + * @date 2021/1/4 上午11:07 + */ + List selectParamInfo(@Param("formDTOS")List formDTOS); + + /** + * @Description 更新客户配置信息 + * @Param formDTOS + * @author zxc + * @date 2021/1/4 下午4:12 + */ + void updateParamInfo(@Param("formDTOS")List formDTOS); +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java new file mode 100644 index 0000000000..9ed4ae997a --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerParameterEntity.java @@ -0,0 +1,49 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午11:03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_parameter") +public class CustomerParameterEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 参数KEY值 + */ + private String parameterKey; + + /** + * 参数名称 + */ + private String parameterName; + + /** + * 参数VALUE值 + */ + private String parameterValue; + + /** + * 参数开关:开启:on,关闭:off + */ + private String parameterSwitch; + + /** + * 说明 + */ + private String description; + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java new file mode 100644 index 0000000000..4ab868a9c1 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerParameterService.java @@ -0,0 +1,30 @@ +package com.epmet.service; + +import com.epmet.dto.form.CrmParameterFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:52 + */ +public interface CustomerParameterService { + + /** + * @Description 查询客户配置信息 + * @Param formDTO + * @author zxc + * @date 2021/1/4 上午11:20 + */ + List selectParamInfo(List formDTOs); + + /** + * @Description 更新客户配置信息 + * @Param formDTOS + * @author zxc + * @date 2021/1/4 下午4:10 + */ + void updateParamInfo(List formDTOS); + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java new file mode 100644 index 0000000000..001fab6aff --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerParameterServiceImpl.java @@ -0,0 +1,57 @@ +package com.epmet.service.impl; + +import com.epmet.dao.CustomerParameterDao; +import com.epmet.dto.form.CrmParameterFormDTO; +import com.epmet.dto.result.CrmParameterResultDTO; +import com.epmet.service.CustomerParameterService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/1/4 上午10:53 + */ +@Service +@Slf4j +public class CustomerParameterServiceImpl implements CustomerParameterService { + + @Autowired + private CustomerParameterDao parameterDao; + + /** + * @Description 查询客户配置信息 + * @Param formDTO + * @author zxc + * @date 2021/1/4 上午11:20 + */ + @Override + public List selectParamInfo(List formDTOs) { + if (CollectionUtils.isEmpty(formDTOs)){ + return new ArrayList<>(); + } + List result = parameterDao.selectParamInfo(formDTOs); + if (CollectionUtils.isEmpty(result)){ + return new ArrayList<>(); + } + return result; + } + + /** + * @Description 更新客户配置信息 + * @Param formDTOS + * @author zxc + * @date 2021/1/4 下午4:11 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateParamInfo(List formDTOS) { + if (CollectionUtils.isEmpty(formDTOS))return; + parameterDao.updateParamInfo(formDTOS); + } +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.3__customer_parameter.sql b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.3__customer_parameter.sql new file mode 100644 index 0000000000..1eda6e2cdf --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.3__customer_parameter.sql @@ -0,0 +1,52 @@ +CREATE TABLE `customer_parameter` +( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(32) NOT NULL COMMENT '客户ID', + `PARAMETER_KEY` varchar(32) NOT NULL COMMENT '参数KEY值(发短信:send_msg;)', + `PARAMETER_NAME` varchar(32) DEFAULT NULL COMMENT '参数名称(短信)', + `PARAMETER_VALUE` varchar(32) DEFAULT NULL COMMENT '参数VALUE值', + `DESCRIPTION` varchar(32) DEFAULT NULL COMMENT '说明', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + ROW_FORMAT = COMPACT COMMENT ='客户配置表'; + + +#=================== 数据初始化 ============================ +INSERT INTO customer_parameter ( + ID, + CUSTOMER_ID, + PARAMETER_KEY, + PARAMETER_NAME, + PARAMETER_VALUE, + DESCRIPTION, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME +) +SELECT + MD5(uuid() + FLOOR(RAND() * 999999)), + id, + 'send_msg', + '短信', + '5000', + '客户短信可发送次数配置', + '0', + '0', + 'app_user', + NOW(), + 'app_user', + NOW() +FROM + customer +WHERE + DEL_FLAG = '0' \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.4__new_customer_parameter.sql b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.4__new_customer_parameter.sql new file mode 100644 index 0000000000..96754ce4d2 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.4__new_customer_parameter.sql @@ -0,0 +1,49 @@ +DROP TABLE IF EXISTS `customer_parameter`; +CREATE TABLE `customer_parameter` +( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(32) NOT NULL COMMENT '客户ID', + `PARAMETER_KEY` varchar(32) NOT NULL COMMENT '参数KEY值(发短信:send_msg;)', + `PARAMETER_NAME` varchar(32) DEFAULT NULL COMMENT '参数名称(短信)', + `PARAMETER_SWITCH` varchar(255) DEFAULT NULL COMMENT '参数开关:开启:on,关闭:off', + `PARAMETER_VALUE` varchar(32) DEFAULT NULL COMMENT '参数VALUE值', + `DESCRIPTION` varchar(32) DEFAULT NULL COMMENT '说明', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + ROW_FORMAT = COMPACT COMMENT ='客户配置表'; + + +#=================== 数据初始化 ============================ +INSERT INTO customer_parameter (ID, + CUSTOMER_ID, + PARAMETER_KEY, + PARAMETER_NAME, + PARAMETER_VALUE, + DESCRIPTION, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME) +SELECT MD5(uuid() + FLOOR(RAND() * 999999)), + id, + 'send_msg', + '短信', + '5000', + '客户短信可发送次数配置', + '0', + '0', + 'app_user', + NOW(), + 'app_user', + NOW() +FROM customer +WHERE DEL_FLAG = '0' \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.5__insert_customer_parameter.sql b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.5__insert_customer_parameter.sql new file mode 100644 index 0000000000..6aa4f84bba --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.5__insert_customer_parameter.sql @@ -0,0 +1,32 @@ +DELETE FROM customer_parameter; + + +#=================== 数据初始化 ============================ +INSERT INTO customer_parameter (ID, + CUSTOMER_ID, + PARAMETER_KEY, + PARAMETER_NAME, + PARAMETER_SWITCH, + PARAMETER_VALUE, + DESCRIPTION, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME) +SELECT MD5(uuid() + FLOOR(RAND() * 999999)), + id, + 'send_msg', + '短信', + 'off', + '5000', + '客户短信可发送次数配置', + '0', + '0', + 'app_user', + NOW(), + 'app_user', + NOW() +FROM customer +WHERE DEL_FLAG = '0' \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml new file mode 100644 index 0000000000..2a5c38a13d --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerParameterDao.xml @@ -0,0 +1,33 @@ + + + + + + + + UPDATE customer_parameter + SET PARAMETER_VALUE = #{f.subtractParameterValue} + + DEL_FLAG = 0 + AND CUSTOMER_ID = #{f.customerId} + AND PARAMETER_KEY = #{f.parameterKey} + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/SendWxmpUpdateSubscribeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/SendWxmpUpdateSubscribeFormDTO.java new file mode 100644 index 0000000000..4247d7c266 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/SendWxmpUpdateSubscribeFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.resi.group.dto.topic.form; + +import com.epmet.commons.tools.security.dto.TokenDto; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2021/1/12 13:44 + */ +@Data +public class SendWxmpUpdateSubscribeFormDTO implements Serializable { + @NotNull + private TokenDto tokenDto; + @NotBlank + private String sourceId; + @NotBlank + private String sourceType; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java index fcb56f25ba..c8b884b664 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java @@ -14,6 +14,7 @@ import com.epmet.resi.group.dto.topic.form.*; import com.epmet.resi.group.dto.topic.result.*; import com.epmet.resi.group.feign.fallback.ResiGroupOpenFeignClientFallback; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; @@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.HashMap; import java.util.List; +import org.springframework.http.MediaType; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -142,6 +144,15 @@ public interface ResiGroupOpenFeignClient { @PostMapping("resi/group/topic/fetchtopicinfowhenauditissue") Result fetchTopicInfoWhenAuditIssue(@RequestBody ResiTopicTurnIssueFromDTO param); + /** + * @Description 发送内容更新类的微信订阅 + * @return void + * @Author liushaowen + * @Date 2021/1/12 11:22 + */ + @PostMapping("resi/group/topic/sendwxmpupdatesubscribe") + Result sendWxmpUpdateSubscribe(@RequestBody SendWxmpUpdateSubscribeFormDTO fromDTO); + /** * @Description 查询话题所属小组 * @Param formDTO diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java index b8f7f9e2d7..9a14845822 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java @@ -1,6 +1,7 @@ package com.epmet.resi.group.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.resi.group.dto.group.ResiGroupDTO; @@ -101,6 +102,12 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "fetchTopicInfoWhenAuditIssue",param); } + @Override + public Result sendWxmpUpdateSubscribe(SendWxmpUpdateSubscribeFormDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "sendWxmpUpdateSubscribe",fromDTO); + } + + @Override public Result selectTopicBelongGroup(TopicBelongGroupFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "selectTopicBelongGroup",formDTO); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/WxmpSubscribeConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/WxmpSubscribeConstant.java new file mode 100644 index 0000000000..0c9c5f28b9 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/WxmpSubscribeConstant.java @@ -0,0 +1,6 @@ +package com.epmet.modules.constant; + +public interface WxmpSubscribeConstant { + String TYPE_COMMENT = "comment"; + String TYPE_SHIFT_ISSUE = "shiftIssue"; +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java index ebd0bf7b0d..564e43b98e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java @@ -1,5 +1,6 @@ package com.epmet.modules.topic.controller; +import com.baomidou.mybatisplus.extension.api.R; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.epmet.commons.tools.annotation.LoginUser; @@ -258,7 +259,7 @@ public class ResiTopicController { ValidatorUtils.validateEntity(topicTurnIssueFromDTO); return new Result().ok(topicService.shiftIssueV2(topicTurnIssueFromDTO)); } - + /** * @Description 话题转议题-重新编辑提交 * @param tokenDto @@ -357,6 +358,18 @@ public class ResiTopicController { return new Result().ok(topicService.selectMyPartTopic(myPartIssueFormDTO)); } + /** + * @Description 发送内容更新类的微信订阅 + * @return void + * @Author liushaowen + * @Date 2021/1/12 11:21 + */ + @PostMapping("sendwxmpupdatesubscribe") + public Result sendWxmpUpdateSubscribe(@RequestBody SendWxmpUpdateSubscribeFormDTO fromDTO){ + topicService.sendWxmpUpdateSubscribe(fromDTO.getTokenDto(),fromDTO.getSourceId(),fromDTO.getSourceType()); + return new Result(); + } + /** * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java index e73a3f8c4e..6e8769177d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java @@ -258,7 +258,7 @@ public interface ResiTopicService extends BaseService { * @date 2020.11.20 10:26 */ FirstTopicShiftedToIssueApplicationResultDTO shiftIssueV2(ResiTopicTurnIssueFromDTO param); - + /** * @Description 工作端审核议题通过时获取一些议题相关信息 * @param param @@ -267,7 +267,7 @@ public interface ResiTopicService extends BaseService { * @date 2020.11.20 18:09 */ IssueShiftedFromTopicFormDTO getIssueInfoWhenAudit(ResiTopicTurnIssueFromDTO param); - + /** * @Description 政府端查看议题详情时的话题相关信息 * @param govTopicIssueInfoFormDTO @@ -331,6 +331,16 @@ public interface ResiTopicService extends BaseService { * @Description 获取话题附件信息 **/ TopicAttachmentResultDTO topicAttachmentList(TopicAttachmentFormDTO formDTO); + /** + * @Description 向关注话题的人发送微信订阅 + * @param tokenDto + * @param id + * @param type 订阅类型 comment / shiftIssue + * @return void + * @Author liushaowen + * @Date 2020/12/31 10:28 + */ + void sendWxmpUpdateSubscribe(TokenDto tokenDto, String id, String type); /** * @Description 根据事件枚举发送积分事件 @@ -340,4 +350,4 @@ public interface ResiTopicService extends BaseService { * @date 2021.01.04 16:41 */ void sendTopicPointEventByEventType(TopicEventFormDTO param); -} \ No newline at end of file +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java index 1fc645d6b6..ed76255ad1 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java @@ -42,6 +42,7 @@ import com.epmet.dto.form.UserResiInfoListFormDTO; import com.epmet.dto.result.UserResiInfoResultDTO; import com.epmet.modules.comment.entity.ResiTopicCommentEntity; import com.epmet.modules.constant.ResiGroupRedisKeys; +import com.epmet.modules.constant.WxmpSubscribeConstant; import com.epmet.modules.feign.EpmetUserFeignClient; import com.epmet.modules.group.redis.ResiGroupRedis; import com.epmet.modules.member.dao.ResiGroupMemberDao; @@ -231,7 +232,6 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl() + .eq("del_flag",0) + .eq("issue_id",sourceId)); + } + if (resiTopicEntity == null){ + log.warn("sendWxmpUpdateSubscribe根据topicid获取议题详情为空"); + return; + } + String groupId = resiTopicEntity.getGroupId(); + String createdBy = resiTopicEntity.getCreatedBy(); + //获取对应的customerId,gridId + ResiGroupEntity resiGroupEntity = resiGroupDao.selectById(groupId); + String customerId = resiGroupEntity.getCustomerId(); + String gridId = resiGroupEntity.getGridId(); + //获取所有关心这个话题的userId列表(发布者+评论者) + ResiQueryCommentFormDTO resiQueryCommentFormDTO = new ResiQueryCommentFormDTO(); + resiQueryCommentFormDTO.setTopicId(resiTopicEntity.getId()); + resiQueryCommentFormDTO.setPageNo(1); + resiQueryCommentFormDTO.setPageSize(10000); + List commentList = resiTopicCommentService.getCommentList(tokenDto, resiQueryCommentFormDTO).getData(); + Set toUsers = commentList.stream().map(item -> item.getUserId()).collect(Collectors.toSet()); + toUsers.add(createdBy); + //不给发起操作的人推送 + toUsers.remove(tokenDto.getUserId()); + logger.info("推送的userid列表:"+JSON.toJSONString(toUsers)); + List msgList = new ArrayList<>(); + Date now = new Date(); + for (String toUser : toUsers) { + WxSubscribeUpdateFormDTO subscribeUpdateFormDTO = new WxSubscribeUpdateFormDTO(); + if (WxmpSubscribeConstant.TYPE_COMMENT.equals(type)){ + subscribeUpdateFormDTO.setSourceType(WxmpMessageConstant.SOURCE_TYPE_TOPIC); + subscribeUpdateFormDTO.setBehaviorType(WxmpMessageConstant.CONTENT_UPDATE_TEMPLATE_TYPE); + subscribeUpdateFormDTO.setMessageTitle(WxmpMessageConstant.CONTENT_UPDATE_TITLE_TEXT); + subscribeUpdateFormDTO.setMessageContent(WxmpMessageConstant.CONTENT_UPDATE_CONTENT_TEXT); + } + if (WxmpSubscribeConstant.TYPE_SHIFT_ISSUE.equals(type)){ + subscribeUpdateFormDTO.setSourceType(WxmpMessageConstant.SOURCE_TYPE_ISSUE); + subscribeUpdateFormDTO.setBehaviorType(WxmpMessageConstant.CONCERN_UPDATE_TEMPLATE_TYPE); + subscribeUpdateFormDTO.setMessageTitle(WxmpMessageConstant.CONCERN_UPDATE_TITLE_TEXT); + subscribeUpdateFormDTO.setMessageContent(WxmpMessageConstant.CONCERN_UPDATE_CONTENT_TEXT); + } + subscribeUpdateFormDTO.setGroupId(groupId); + subscribeUpdateFormDTO.setClientType(WxmpMessageConstant.RESI); + subscribeUpdateFormDTO.setCustomerId(customerId); + subscribeUpdateFormDTO.setGridId(gridId); + subscribeUpdateFormDTO.setSourceId(sourceId); + subscribeUpdateFormDTO.setMessageTime(now); + subscribeUpdateFormDTO.setUserId(toUser); + msgList.add(subscribeUpdateFormDTO); + } + if(msgList.size()>0){ + epmetMessageOpenFeignClient.sendWxSubscribeUpdate(msgList); + } + }catch (Exception e){ + logger.warn("话题相关 发送微信订阅失败,"+e.getMessage()+",sourceId="+sourceId+" 类型="+type); + } + } /** * @param formDTO * @return diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java index bd54ec1604..f823096f15 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java @@ -84,4 +84,14 @@ public interface ResiPartyMemberOpenFeignClient { **/ @PostMapping(value = "/resi/partymember/partymemberinfo/queryPartymemberInfoByUserId", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result> queryPartymemberInfoByUserId(@RequestBody List userIdList); + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param gridIdList + * @author zy + * @description 根据网格id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + @PostMapping(value = "/resi/partymember/partymemberinfo/getPartymemberInfoByGridId", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result> getPartymemberInfoByGridId(@RequestBody List gridIdList); } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java index df60a30abc..3f3ebb8c97 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java @@ -60,5 +60,8 @@ public class ResiPartyMemberOpenFeignClientFallback implements ResiPartyMemberOp return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "queryPartymemberInfoByUserId", userIdList); } - + @Override + public Result> getPartymemberInfoByGridId(List gridIdList) { + return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "getPartymemberInfoByGridId", gridIdList); + } } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java index 89b9d7c135..5d7d081e13 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java @@ -42,7 +42,7 @@ import java.util.Map; /** - * 党员认证信息表 + * 党员认证信息表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-30 @@ -50,7 +50,7 @@ import java.util.Map; @RestController @RequestMapping("partymemberinfo") public class PartymemberInfoController { - + @Autowired private PartymemberInfoService partymemberInfoService; @@ -144,4 +144,17 @@ public class PartymemberInfoController { List list = partymemberInfoService.queryPartymemberInfoByUserId(userIdList); return new Result>().ok(list); } -} \ No newline at end of file + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param gridIdList + * @author zy + * @description 根据网格id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + @PostMapping(value = "getPartymemberInfoByGridId") + Result> getPartymemberInfoByGridId(@RequestBody List gridIdList) { + List list = partymemberInfoService.listPartymemberInfoByGridId(gridIdList); + return new Result>().ok(list); + } +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java index 660cbfa957..f395beac8b 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java @@ -86,4 +86,13 @@ public interface PartymemberInfoDao extends BaseDao { * @Date 2020/12/25 14:02 **/ List selectCountAuditting(@Param("gridIdList") List gridIdList); -} \ No newline at end of file + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param gridIdList + * @author zy + * @description 根据网格id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + List selectListPartymemberInfoByGridId(@Param("gridIdList") List gridIdList); +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java index b8b0b39694..3290cb084f 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; /** - * 党员认证信息表 + * 党员认证信息表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-03-30 @@ -153,4 +153,13 @@ public interface PartymemberInfoService extends BaseService queryPartymemberInfoByUserId(List userIdList); -} \ No newline at end of file + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param gridIdList + * @author zy + * @description 根据网格id查询认证通过的党员信息 + * @Date 2020/7/22 12:14 + **/ + List listPartymemberInfoByGridId(List gridIdList); +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java index ddc22a04b1..c6ce32113b 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java @@ -230,5 +230,9 @@ public class PartymemberInfoServiceImpl extends BaseServiceImpl listPartymemberInfoByGridId(List gridIdList) { + List list = baseDao.selectListPartymemberInfoByGridId(gridIdList); + return list; + } +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml index e47b1a142d..876e1102f0 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml @@ -135,4 +135,38 @@ group by pi.GRID_ID - \ No newline at end of file + + + +