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