From 9622de06154f6d9d5c5e394628b145d79894e92b Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 21 Sep 2022 17:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E7=A8=8B=E4=B8=8A=E6=8A=A5=E3=80=81?= =?UTF-8?q?=E9=9A=94=E7=A6=BB=E9=98=B2=E7=96=AB=E3=80=81=E7=96=AB=E8=8B=97?= =?UTF-8?q?=E6=8E=A5=E7=A7=8D=E5=85=B3=E6=B3=A83=E4=B8=AA=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8F=91=E9=80=81=E9=80=9A=E7=9F=A5=E8=B0=83=E7=94=A8?= =?UTF-8?q?sendNoticeV2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/SendNoticeV2FormDTO.java | 50 +++++++++ .../epmet/controller/IcNoticeController.java | 16 ++- .../com/epmet/service/IcNoticeService.java | 7 ++ .../service/impl/IcNoticeServiceImpl.java | 101 ++++++++++++++++++ 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java new file mode 100644 index 0000000000..23e77ed29c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java @@ -0,0 +1,50 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Size; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/9/21 17:06 + */ +@Data +public class SendNoticeV2FormDTO { + // token获取 + private String customerId; + private String staffId; + // 前端传入 + /** + * 用户列表 + */ + @NotEmpty(message = "业务数据id不能为空", groups = CustomerClientShowGroup.class) + private List bdIds; + /** + * 通知渠道通知渠道 0小程序通知,1短信通知 + */ + @NotEmpty(message = "请选择通知渠道", groups = CustomerClientShowGroup.class) + private List channel; + /** + * v1:通知来源 0 行程上报,1 疫苗接种,2 核酸检测 + * v2:0行程上报,1疫苗接种关注名单,2重点人群关注名单-隔离防疫(原核酸检测关注名单) + */ + @NotEmpty(message = "通知来源不能为空", groups = CustomerClientShowGroup.class) + private String origin; + /** + * 通知内容 + */ + @Size(min = 1, max = 500, message = "通知内容不超过500字", groups = CustomerClientShowGroup.class) + private String content; + + // 接口内赋值 + /** + * 组织名 + */ + private String orgName; + +} + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java index 325eb71c31..ada0124d86 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java @@ -4,7 +4,6 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -15,6 +14,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; +import com.epmet.dto.form.SendNoticeV2FormDTO; import com.epmet.dto.form.SendPointNoticeFormDTO; import com.epmet.dto.result.CommunityInfoResultDTO; import com.epmet.feign.GovOrgFeignClient; @@ -108,4 +108,18 @@ public class IcNoticeController { return new Result(); } + /** + * 行程上报、重点人群关注名单、疫苗接种关注名单这几个页面的发送通知 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("sendNoticeV2") + public Result sendNoticeV2(@LoginUser TokenDto tokenDto, @RequestBody SendNoticeV2FormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerClientShowGroup.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + icNoticeService.sendNoticeV2(formDTO); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java index 9c65229972..9be6485b37 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; +import com.epmet.dto.form.SendNoticeV2FormDTO; import com.epmet.dto.form.SendPointNoticeFormDTO; import com.epmet.entity.IcNoticeEntity; @@ -115,4 +116,10 @@ public interface IcNoticeService extends BaseService { * @return */ Map getUserLatestNoticeTime(String customerId,List idCardSet); + + /** + * 行程上报、重点人群关注名单、疫苗接种关注名单这几个页面的发送通知 + * @param formDTO + */ + void sendNoticeV2(SendNoticeV2FormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java index 4754780727..710dd05ee9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java @@ -13,11 +13,15 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserMessageTypeConstant; +import com.epmet.dao.IcEpidemicSpecialAttentionDao; import com.epmet.dao.IcNoticeDao; +import com.epmet.dao.IcTripReportRecordDao; import com.epmet.dto.IcNoticeDTO; import com.epmet.dto.UserBaseInfoDTO; import com.epmet.dto.form.*; +import com.epmet.entity.IcEpidemicSpecialAttentionEntity; import com.epmet.entity.IcNoticeEntity; +import com.epmet.entity.IcTripReportRecordEntity; import com.epmet.feign.MessageFeignClient; import com.epmet.service.IcNoticeService; import com.epmet.service.UserBaseInfoService; @@ -26,6 +30,7 @@ import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +52,10 @@ public class IcNoticeServiceImpl extends BaseServiceImpl page(IcNoticeFormDTO formDTO) { @@ -333,4 +342,96 @@ public class IcNoticeServiceImpl extends BaseServiceImpl userBeanList = null; + List entityList = new ArrayList<>(); + for (String bdId : formDTO.getBdIds()) { + IcNoticeEntity entity = new IcNoticeEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setChannel(channel); + entity.setContent(formDTO.getContent()); + entity.setOrigin(formDTO.getOrigin()); + // 这时候还不知道居民端的用户id + entity.setUserId(StrConstant.EPMETY_STR); + entity.setOrgName(finalOrgName); + // 发送结果:1成功,0失败 默认插入发送成功。下面没有找到居民端的用户id,会更新 + entity.setSendRes(NumConstant.ONE_STR); + // v2:0行程上报,1疫苗接种关注名单,2隔离防疫原核酸检测 + // 身份证号手机号 + if (NumConstant.ZERO_STR.equals(formDTO.getOrigin())) { + IcTripReportRecordEntity icTripReportRecordEntity = icTripReportRecordDao.selectById(bdId); + entity.setMobile(icTripReportRecordEntity.getMobile()); + entity.setIdCard(icTripReportRecordEntity.getIdCard()); + } else if (NumConstant.ONE_STR.equals(formDTO.getOrigin()) || NumConstant.TWO_STR.equals(formDTO.getOrigin())) { + IcEpidemicSpecialAttentionEntity icEpidemicSpecialAttentionEntity = icEpidemicSpecialAttentionDao.selectById(bdId); + entity.setMobile(icEpidemicSpecialAttentionEntity.getMobile()); + entity.setIdCard(icEpidemicSpecialAttentionEntity.getIdCard()); + } + entityList.add(entity); + } + if (CollectionUtils.isEmpty(entityList)) { + return; + } + insertBatch(entityList); + + // 通知渠道通知渠道 0小程序通知,1短信通知 + for (String channelValue : formDTO.getChannel()) { + if ("0".equals(channelValue)) { + // 小程序通知 + List msgList = new ArrayList<>(); + entityList.forEach(item -> { + // 根据身份证获取居民ID 如果一个客户下,存在多个身份证号相同的而用户,该接口只返回一个 + List userList = userBaseInfoService.getCommonIdNumUser(item.getCustomerId(), item.getIdCard()); + if (CollectionUtils.isNotEmpty(userList)) { + UserBaseInfoDTO userBaseInfoDTO = userList.get(NumConstant.ZERO); + UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); + messageFormDTO.setCustomerId(item.getCustomerId()); + messageFormDTO.setApp(AppClientConstant.APP_GOV); + messageFormDTO.setGridId(StrConstant.STAR); + messageFormDTO.setUserId(userBaseInfoDTO.getUserId()); + messageFormDTO.setTitle("您有一条通知消息!"); + messageFormDTO.setMessageContent(item.getContent()); + messageFormDTO.setReadFlag(Constant.UNREAD); + messageFormDTO.setMessageType(UserMessageTypeConstant.ANTIEPIDEMIC); + messageFormDTO.setTargetId(item.getId()); + msgList.add(messageFormDTO); + item.setUserId(userBaseInfoDTO.getUserId()); + } else { + // 没有找到居民端的用户id,发送失败 + item.setSendRes(NumConstant.ZERO_STR); + } + baseDao.updateById(item); + }); + // 发送小程序消息-站内信 + Result result = messageFeignClient.saveUserMessageList(msgList); + if (!result.success()) { + log.warn("发送小程序消息失败" + JSON.toJSONString(result)); + } + } else { + // 短信通知再说 todo + } + + + } + + + } + + + }