Browse Source

消息订阅

dev
liushaowen 5 years ago
parent
commit
cee6f67841
  1. 86
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxmpMessageConstant.java
  2. 111
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendDataDTO.java
  3. 131
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpUpdateSendRecordDTO.java
  4. 20
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/TemplateListV2FormDTO.java
  5. 86
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeUpdateFormDTO.java
  6. 21
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/TemplateListV2ResultDTO.java
  7. 10
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java
  8. 6
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java
  9. 63
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java
  10. 40
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java
  11. 94
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendDataController.java
  12. 94
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendRecordController.java
  13. 33
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendDataDao.java
  14. 33
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpUpdateSendRecordDao.java
  15. 81
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendDataEntity.java
  16. 101
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpUpdateSendRecordEntity.java
  17. 80
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendDataExcel.java
  18. 92
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpUpdateSendRecordExcel.java
  19. 47
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendDataRedis.java
  20. 47
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpUpdateSendRecordRedis.java
  21. 26
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java
  22. 95
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendDataService.java
  23. 95
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpUpdateSendRecordService.java
  24. 296
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java
  25. 104
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendDataServiceImpl.java
  26. 104
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpUpdateSendRecordServiceImpl.java
  27. 41
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.6__add_subscribe_update.sql
  28. 25
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendDataDao.xml
  29. 29
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendRecordDao.xml
  30. 6
      epmet-module/epmet-third/epmet-third-server/pom.xml
  31. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PersonalTemplateController.java
  32. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java
  33. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java
  34. 11
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java
  35. 19
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml
  36. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/WxmpSubscribeConstant.java
  37. 16
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java
  38. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java
  39. 89
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java

86
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxmpMessageConstant.java

@ -0,0 +1,86 @@
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 = "date6";
/**关注更新提醒模板end**/
/**内容更新消息通知模板start**/
String CONTENT_UPDATE_TEMPLATE_TYPE = "2092";
String CONTENT_UPDATE_TITLE = "thing4";
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 PAGE_URL = "/subpages/mine/pages/message/skip";
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";
}

111
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

131
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

20
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/TemplateListV2FormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @description:
* @author: liushaowen
* @date: 2020/12/29 13:20
*/
@Data
public class TemplateListV2FormDTO implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank(message = "customerId不能为空")
private String customerId;
@NotBlank(message = "app不能为空")
private String app;
}

86
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;
}

21
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/TemplateListV2ResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @description:
* @author: liushaowen
* @date: 2020/12/29 13:19
*/
@Data
public class TemplateListV2ResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
//类型id
private String tid;
//类型名称
private String type;
private String templateId;
}

10
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java

@ -7,6 +7,7 @@ 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;
@ -86,4 +87,13 @@ public interface EpmetMessageOpenFeignClient {
**/
@PostMapping(value = "message/sms/projectsendmsg", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result projectSendMsg(List<ProjectSendMsgFormDTO> 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<WxSubscribeUpdateFormDTO> msgList);
}

6
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java

@ -8,6 +8,7 @@ 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;
@ -57,4 +58,9 @@ public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeig
public Result projectSendMsg(List<ProjectSendMsgFormDTO> formDTOList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "projectSendMsg", formDTOList);
}
@Override
public Result sendWxSubscribeUpdate(List<WxSubscribeUpdateFormDTO> msgList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendWxSubscribeUpdate", msgList);
}
}

63
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java

@ -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";
}

40
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<WxSubscribeUpdateFormDTO> 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<List<GetTemplateListResultDTO>>().ok(wxmpMessageService.templateList(formDTO));
}
/**
* @Description 居民端工作端-获取客户小程序模板列表(除了站内信模板)
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<TemplateListV2ResultDTO>
* @Author liushaowen
* @Date 2020/12/29 13:18
*/
@PostMapping("templatelistv2")
public Result<List<TemplateListV2ResultDTO>> templateListV2(@RequestBody TemplateListV2FormDTO formDTO){
ValidatorUtils.validateEntity(formDTO);
return new Result<List<TemplateListV2ResultDTO>>().ok(wxmpMessageService.templateListV2(formDTO));
}
/**
* @Description 查询用户授权信息
@ -159,4 +187,4 @@ public class WxmpMessageController {
return new Result();
}
}
}

94
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpUpdateSendDataController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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.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<PageData<WxmpUpdateSendDataDTO>> page(@RequestParam Map<String, Object> params){
PageData<WxmpUpdateSendDataDTO> page = wxmpUpdateSendDataService.page(params);
return new Result<PageData<WxmpUpdateSendDataDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<WxmpUpdateSendDataDTO> get(@PathVariable("id") String id){
WxmpUpdateSendDataDTO data = wxmpUpdateSendDataService.get(id);
return new Result<WxmpUpdateSendDataDTO>().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<String, Object> params, HttpServletResponse response) throws Exception {
List<WxmpUpdateSendDataDTO> list = wxmpUpdateSendDataService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, WxmpUpdateSendDataExcel.class);
}
}

94
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<WxmpUpdateSendRecordDTO>> page(@RequestParam Map<String, Object> params){
PageData<WxmpUpdateSendRecordDTO> page = wxmpUpdateSendRecordService.page(params);
return new Result<PageData<WxmpUpdateSendRecordDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<WxmpUpdateSendRecordDTO> get(@PathVariable("id") String id){
WxmpUpdateSendRecordDTO data = wxmpUpdateSendRecordService.get(id);
return new Result<WxmpUpdateSendRecordDTO>().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<String, Object> params, HttpServletResponse response) throws Exception {
List<WxmpUpdateSendRecordDTO> list = wxmpUpdateSendRecordService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, WxmpUpdateSendRecordExcel.class);
}
}

33
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendDataEntity> {
}

33
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendRecordEntity> {
}

81
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

101
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

80
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

92
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

47
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}

26
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<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO);
@ -62,4 +61,21 @@ public interface WxmpMessageService {
* @author sun
*/
void activationSubscribe(ActivationSubscribeFormDTO formDTO);
/**
* @Description 居民端工作端-获取客户小程序模板列表不包括站内信消息模板
* @param formDTO
* @return java.util.List<com.epmet.dto.result.TemplateListV2ResultDTO>
* @Author liushaowen
* @Date 2020/12/29 13:26
*/
List<TemplateListV2ResultDTO> templateListV2(TemplateListV2FormDTO formDTO);
/**
* @Description 发送(内容更新消息提醒关注更新提醒)订阅消息
* @param msgList
* @return void
* @Author liushaowen
* @Date 2020/12/30 13:36
*/
void sendWxSubscribeUpdate(List<WxSubscribeUpdateFormDTO> msgList);
}

95
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendDataEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<WxmpUpdateSendDataDTO>
* @author generator
* @date 2021-01-04
*/
PageData<WxmpUpdateSendDataDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<WxmpUpdateSendDataDTO>
* @author generator
* @date 2021-01-04
*/
List<WxmpUpdateSendDataDTO> list(Map<String, Object> 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);
}

95
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendRecordEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<WxmpUpdateSendRecordDTO>
* @author generator
* @date 2020-12-30
*/
PageData<WxmpUpdateSendRecordDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<WxmpUpdateSendRecordDTO>
* @author generator
* @date 2020-12-30
*/
List<WxmpUpdateSendRecordDTO> list(Map<String, Object> 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);
}

296
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<CustomerTemplateListResultDTO> customerTemplateListResultDTOS = customerTemplateList(customerTemplateListFormDTO);
// 获取AccessToken
Map<String,String> 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> 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> 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());
@ -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<WxSubscribeUpdateFormDTO> msgList) {
if (msgList.size() == 0){
return;
}
// 获取templateId
TemplateListV2FormDTO templateListV2FormDTO = new TemplateListV2FormDTO();
templateListV2FormDTO.setCustomerId(msgList.get(0).getCustomerId());
//获取工作端的
templateListV2FormDTO.setApp(WxmpMessageConstant.GOV_REDIS);
List<TemplateListV2ResultDTO> workTemplates = templateListV2(templateListV2FormDTO);
//获取居民端的
templateListV2FormDTO.setApp(WxmpMessageConstant.RESI);
List<TemplateListV2ResultDTO> resiTemplates = templateListV2(templateListV2FormDTO);
//获取AccessToken
Map<String,String> 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.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);
govPage.append("?customerId=").append(customerId).append("&staffId=").append(userId);
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<String, Object> 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> 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> 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<String,String> 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<com.epmet.dto.result.TemplateListV2ResultDTO>
* @Description 居民端工作端-获取客户小程序模板列表不包括站内信消息模板
* @Author liushaowen
* @Date 2020/12/29 13:26
*/
@Override
public List<TemplateListV2ResultDTO> 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<Object> resultList = (List<Object>) mapToResult.getData();
List<TemplateListV2ResultDTO> 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

104
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendDataDao, WxmpUpdateSendDataEntity> implements WxmpUpdateSendDataService {
@Autowired
private WxmpUpdateSendDataRedis wxmpUpdateSendDataRedis;
@Override
public PageData<WxmpUpdateSendDataDTO> page(Map<String, Object> params) {
IPage<WxmpUpdateSendDataEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, WxmpUpdateSendDataDTO.class);
}
@Override
public List<WxmpUpdateSendDataDTO> list(Map<String, Object> params) {
List<WxmpUpdateSendDataEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, WxmpUpdateSendDataDTO.class);
}
private QueryWrapper<WxmpUpdateSendDataEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<WxmpUpdateSendDataEntity> 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));
}
}

104
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<WxmpUpdateSendRecordDao, WxmpUpdateSendRecordEntity> implements WxmpUpdateSendRecordService {
@Autowired
private WxmpUpdateSendRecordRedis wxmpUpdateSendRecordRedis;
@Override
public PageData<WxmpUpdateSendRecordDTO> page(Map<String, Object> params) {
IPage<WxmpUpdateSendRecordEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, WxmpUpdateSendRecordDTO.class);
}
@Override
public List<WxmpUpdateSendRecordDTO> list(Map<String, Object> params) {
List<WxmpUpdateSendRecordEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, WxmpUpdateSendRecordDTO.class);
}
private QueryWrapper<WxmpUpdateSendRecordEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<WxmpUpdateSendRecordEntity> 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));
}
}

41
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='订阅消息发送数据表(内容更新消息提醒、关注更新提醒)';

25
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendDataDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.WxmpUpdateSendDataDao">
<resultMap type="com.epmet.entity.WxmpUpdateSendDataEntity" id="wxmpUpdateSendDataMap">
<result property="id" column="ID"/>
<result property="sourceType" column="SOURCE_TYPE"/>
<result property="sourceId" column="SOURCE_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="groupId" column="GROUP_ID"/>
<result property="staffId" column="STAFF_ID"/>
<result property="msgUserId" column="MSG_USER_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

29
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpUpdateSendRecordDao.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.WxmpUpdateSendRecordDao">
<resultMap type="com.epmet.entity.WxmpUpdateSendRecordEntity" id="wxmpUpdateSendRecordMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="clientType" column="CLIENT_TYPE"/>
<result property="templateId" column="TEMPLATE_ID"/>
<result property="userId" column="USER_ID"/>
<result property="wxOpenId" column="WX_OPEN_ID"/>
<result property="behaviorType" column="BEHAVIOR_TYPE"/>
<result property="title" column="TITLE"/>
<result property="content" column="CONTENT"/>
<result property="time" column="TIME"/>
<result property="result" column="RESULT"/>
<result property="reason" column="REASON"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

6
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -154,6 +154,12 @@
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-message-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PersonalTemplateController.java

@ -4,8 +4,10 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CustomerTemplateListFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.TemplateListV2FormDTO;
import com.epmet.dto.result.CustomerTemplateListResultDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateListV2ResultDTO;
import com.epmet.service.PersonalTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -37,6 +39,12 @@ public class PersonalTemplateController {
return new Result<List<GetTemplateListResultDTO>>().ok(personalTemplateService.templateList(formDTO));
}
@PostMapping("templatelistv2")
public Result<List<TemplateListV2ResultDTO>> templateList(@RequestBody TemplateListV2FormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<TemplateListV2ResultDTO>>().ok(personalTemplateService.templateListV2(formDTO));
}
/**
* @return
* @Description 获取客户两个端站内信模板Id

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java

@ -21,10 +21,8 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.CustomerTemplateListFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.result.CustomerTempResultDTO;
import com.epmet.dto.result.CustomerTemplateListResultDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.dto.form.TemplateListV2FormDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.PersonalTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -105,4 +103,6 @@ public interface PersonalTemplateDao extends BaseDao<PersonalTemplateEntity> {
* @return java.util.List<com.epmet.dto.PersonalTemplateDTO>
*/
List<PersonalTemplateDTO> selectListByKey(@Param("appId") String appId, @Param("tid") String tid, @Param("keyIds") String keyIds);
}
List<TemplateListV2ResultDTO> selectTemplateListV2(TemplateListV2FormDTO formDTO);
}

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java

@ -22,9 +22,11 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.CustomerTemplateListFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.TemplateListV2FormDTO;
import com.epmet.dto.result.CustomerTemplateListResultDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.dto.result.TemplateListV2ResultDTO;
import com.epmet.entity.PersonalTemplateEntity;
import java.util.List;
@ -152,4 +154,6 @@ public interface PersonalTemplateService extends BaseService<PersonalTemplateEnt
* @return java.util.List<com.epmet.dto.PersonalTemplateDTO>
*/
List<PersonalTemplateDTO> getListByKey(String appId, String tid, String keyIds);
}
List<TemplateListV2ResultDTO> templateListV2(TemplateListV2FormDTO formDTO);
}

11
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java

@ -27,9 +27,11 @@ import com.epmet.dao.PersonalTemplateDao;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.CustomerTemplateListFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.TemplateListV2FormDTO;
import com.epmet.dto.result.CustomerTemplateListResultDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.dto.result.TemplateListV2ResultDTO;
import com.epmet.entity.PersonalTemplateEntity;
import com.epmet.service.PersonalTemplateService;
import org.apache.commons.lang3.StringUtils;
@ -42,7 +44,7 @@ import java.util.List;
import java.util.Map;
/**
*
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-09
@ -132,6 +134,11 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl<PersonalTemplat
return baseDao.selectTemplateList(formDTO);
}
@Override
public List<TemplateListV2ResultDTO> templateListV2(TemplateListV2FormDTO formDTO) {
return baseDao.selectTemplateListV2(formDTO);
}
/**
* @return
* @Description 获取客户两个端站内信模板Id
@ -158,4 +165,4 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl<PersonalTemplat
return baseDao.selectListByKey(appId, tid, keyIds);
}
}
}

19
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml

@ -90,6 +90,23 @@
ORDER BY created_time ASC
</select>
<select id="selectTemplateListV2" resultType="com.epmet.dto.result.TemplateListV2ResultDTO">
SELECT
tid as "tid",
title AS "type",
pri_tmpl_id AS "templateId"
FROM
personal_template
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND client_type = #{app}
AND (
(KEY_IDS = '5,7,6' and tid = '8171')or
(KEY_IDS = '4,9,3' and tid = '2092'))
ORDER BY created_time ASC
</select>
<select id="selectCustomerTemplateList" resultType="com.epmet.dto.result.CustomerTemplateListResultDTO">
SELECT
pt.title AS "templateType",
@ -115,4 +132,4 @@
AND KEY_IDS = #{keyIds}
</select>
</mapper>
</mapper>

6
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";
}

16
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<ResiTopicEntity> {
* @date 2020.11.20 10:26
*/
FirstTopicShiftedToIssueApplicationResultDTO shiftIssueV2(ResiTopicTurnIssueFromDTO param);
/**
* @Description 工作端审核议题通过时获取一些议题相关信息
* @param param
@ -267,7 +267,7 @@ public interface ResiTopicService extends BaseService<ResiTopicEntity> {
* @date 2020.11.20 18:09
*/
IssueShiftedFromTopicFormDTO getIssueInfoWhenAudit(ResiTopicTurnIssueFromDTO param);
/**
* @Description 政府端查看议题详情时的话题相关信息
* @param govTopicIssueInfoFormDTO
@ -324,4 +324,14 @@ public interface ResiTopicService extends BaseService<ResiTopicEntity> {
*/
List<String> getTopicIdsByGroup(String groupId);
}
/**
* @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);
}

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java

@ -38,6 +38,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.member.dao.ResiGroupMemberDao;
import com.epmet.modules.member.redis.ResiGroupMemberRedis;
@ -224,6 +225,8 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl<ResiTopicCommen
comment.setCreatedBy(tokenDto.getUserId());
baseDao.insertOne(comment);
//对所有关注这个话题的人发送微信订阅
resiTopicService.sendWxmpUpdateSubscribe(tokenDto,topic.getId(), WxmpSubscribeConstant.TYPE_COMMENT);
return new Result();
}
@ -369,4 +372,4 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl<ResiTopicCommen
return resiTopicdDao.selectIssueList(topicList);
}
}
}

89
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java

@ -39,10 +39,12 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.OrgInfoConstant;
import com.epmet.constant.WxmpMessageConstant;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.IssueApplicationDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.dto.result.CommonDataFilterResultDTO;
@ -51,6 +53,7 @@ import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.feign.GovIssueOpenFeignClient;
import com.epmet.modules.constant.GroupMemberConstant;
import com.epmet.modules.constant.ResiGroupRedisKeys;
import com.epmet.modules.constant.WxmpSubscribeConstant;
import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.GovIssueFeignClient;
import com.epmet.modules.feign.GovOrgFeignClient;
@ -69,11 +72,14 @@ import com.epmet.modules.topic.dao.ResiTopicOperationDao;
import com.epmet.modules.topic.entity.ResiTopicAttachmentEntity;
import com.epmet.modules.topic.entity.ResiTopicEntity;
import com.epmet.modules.topic.entity.ResiTopicOperationEntity;
import com.epmet.modules.topic.service.ResiTopicCommentService;
import com.epmet.modules.topic.service.ResiTopicOperationService;
import com.epmet.modules.topic.service.ResiTopicService;
import com.epmet.modules.utils.ModuleConstant;
import com.epmet.resi.group.constant.MemberStateConstant;
import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO;
import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO;
import com.epmet.resi.group.dto.group.ResiGroupInfoRedisDTO;
import com.epmet.resi.group.dto.group.ResiGroupStatisticalInfoRedisDTO;
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO;
@ -164,6 +170,12 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
@Autowired
private GovIssueOpenFeignClient issueOpenFeignClient;
@Autowired
private ResiTopicCommentService resiTopicCommentService;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
@ -1553,6 +1565,14 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
}else throw new RenException(dataFilterResult.getMsg());
//对关注此话题的用户推送订阅
try {
TokenDto tokenDto = new TokenDto();
tokenDto.setUserId(topicTurnIssueFromDTO.getUserId());
sendWxmpUpdateSubscribe(tokenDto,result.getIssueId(),WxmpSubscribeConstant.TYPE_SHIFT_ISSUE);
}catch (Exception e){
logger.warn("话题转议题-发送订阅消息失败 错误信息:"+e.getMessage());
}
return result;
}
@ -1822,6 +1842,75 @@ public class ResiTopicServiceImpl extends BaseServiceImpl<ResiTopicDao, ResiTopi
throw new RenException(reply.getInternalMsg());
}
/**
* @param tokenDto
* @param topicId
* @param type 订阅类型 comment / shiftIssue
* @return void
* @Description 向关注话题的人发送微信订阅
* @Author liushaowen
* @Date 2020/12/31 10:28
*/
@Override
public void sendWxmpUpdateSubscribe(TokenDto tokenDto, String topicId, String type) {
if (StringUtils.isBlank(type) || StringUtils.isBlank(topicId)) {
return;
}
try{
//获取话题的groupId,创建人
ResiTopicEntity resiTopicEntity = baseDao.selectById(topicId);
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(topicId);
resiQueryCommentFormDTO.setPageNo(1);
resiQueryCommentFormDTO.setPageSize(10000);
List<ResiCommentResultDTO> commentList = resiTopicCommentService.getCommentList(tokenDto, resiQueryCommentFormDTO).getData();
Set<String> toUsers = commentList.stream().map(item -> item.getUserId()).collect(Collectors.toSet());
toUsers.add(createdBy);
//不给发起操作的人推送
toUsers.remove(tokenDto.getUserId());
List<WxSubscribeUpdateFormDTO> 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(topicId);
subscribeUpdateFormDTO.setMessageTime(now);
subscribeUpdateFormDTO.setUserId(toUser);
msgList.add(subscribeUpdateFormDTO);
}
if(msgList.size()>0){
epmetMessageOpenFeignClient.sendWxSubscribeUpdate(msgList);
}
}catch (Exception e){
logger.warn("话题相关 发送微信订阅失败,"+e.getMessage()+",topicId="+topicId+" 类型="+type);
}
}
}

Loading…
Cancel
Save