Browse Source

行程上报、隔离防疫、疫苗接种关注3个界面发送通知调用sendNoticeV2

dev
yinzuomei 3 years ago
parent
commit
9622de0615
  1. 50
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SendNoticeV2FormDTO.java
  2. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java
  3. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java
  4. 101
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java

50
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<String> bdIds;
/**
* 通知渠道通知渠道 0小程序通知1短信通知
*/
@NotEmpty(message = "请选择通知渠道", groups = CustomerClientShowGroup.class)
private List<String> 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;
}

16
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();
}
}

7
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<IcNoticeEntity> {
* @return
*/
Map<String, Date> getUserLatestNoticeTime(String customerId,List<String> idCardSet);
/**
* 行程上报重点人群关注名单疫苗接种关注名单这几个页面的发送通知
* @param formDTO
*/
void sendNoticeV2(SendNoticeV2FormDTO formDTO);
}

101
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<IcNoticeDao, IcNoticeEn
private MessageFeignClient messageFeignClient;
@Resource
private UserBaseInfoService userBaseInfoService;
@Autowired
private IcTripReportRecordDao icTripReportRecordDao;
@Autowired
private IcEpidemicSpecialAttentionDao icEpidemicSpecialAttentionDao;
@Override
public PageData<IcNoticeDTO> page(IcNoticeFormDTO formDTO) {
@ -333,4 +342,96 @@ public class IcNoticeServiceImpl extends BaseServiceImpl<IcNoticeDao, IcNoticeEn
return map;
}
/**
* 行程上报重点人群关注名单疫苗接种关注名单这几个页面的发送通知
*
* @param formDTO
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void sendNoticeV2(SendNoticeV2FormDTO formDTO) {
String orgName = "";
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
if (null != staffInfo) {
orgName = staffInfo.getAgencyName();
}
// 保存消息
String channel = StringUtils.join(formDTO.getChannel(), StrConstant.COMMA);
String finalOrgName = orgName;
List<SendNoticeFormDTO.UserListBean> userBeanList = null;
List<IcNoticeEntity> 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<UserMessageFormDTO> msgList = new ArrayList<>();
entityList.forEach(item -> {
// 根据身份证获取居民ID 如果一个客户下,存在多个身份证号相同的而用户,该接口只返回一个
List<UserBaseInfoDTO> 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
}
}
}
}

Loading…
Cancel
Save