|
|
@ -1,23 +1,36 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
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.constant.*; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.SmsTemplateConstant; |
|
|
|
import com.epmet.constant.UserMessageTypeConstant; |
|
|
|
import com.epmet.dao.IcNoticeDao; |
|
|
|
import com.epmet.dto.IcNoticeDTO; |
|
|
|
import com.epmet.dto.form.ProjectSendMsgFormDTO; |
|
|
|
import com.epmet.dto.form.SendNoticeFormDTO; |
|
|
|
import com.epmet.dto.form.UserMessageFormDTO; |
|
|
|
import com.epmet.entity.IcNoticeEntity; |
|
|
|
import com.epmet.feign.MessageFeignClient; |
|
|
|
import com.epmet.service.IcNoticeService; |
|
|
|
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; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 防疫通知 |
|
|
@ -25,9 +38,13 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2022-03-28 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class IcNoticeServiceImpl extends BaseServiceImpl<IcNoticeDao, IcNoticeEntity> implements IcNoticeService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private MessageFeignClient messageFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcNoticeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<IcNoticeEntity> page = baseDao.selectPage( |
|
|
@ -80,4 +97,91 @@ public class IcNoticeServiceImpl extends BaseServiceImpl<IcNoticeDao, IcNoticeEn |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发送通知 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/3/28 14:19 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void sendNotice(SendNoticeFormDTO formDTO) { |
|
|
|
//保存消息
|
|
|
|
String channel = StringUtils.join(formDTO.getChannel(), StrConstant.COMMA); |
|
|
|
List<IcNoticeEntity> entityList = formDTO.getUserList().stream().map(item -> { |
|
|
|
IcNoticeEntity entity = new IcNoticeEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setChannel(channel); |
|
|
|
entity.setContent(formDTO.getContent()); |
|
|
|
entity.setOrigin(entity.getOrigin()); |
|
|
|
entity.setUserId(item.getUserId()); |
|
|
|
entity.setMobile(entity.getMobile()); |
|
|
|
entity.setIdCard(item.getIdCard()); |
|
|
|
entity.setOrgName(formDTO.getOrgName()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
insertBatch(entityList); |
|
|
|
|
|
|
|
//通知
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
//短信消息
|
|
|
|
List<ProjectSendMsgFormDTO> smsList = new ArrayList<>(); |
|
|
|
|
|
|
|
entityList.forEach(item -> { |
|
|
|
if (StringUtils.isNotBlank(item.getUserId())) { |
|
|
|
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); |
|
|
|
messageFormDTO.setCustomerId(item.getCustomerId()); |
|
|
|
messageFormDTO.setApp(AppClientConstant.APP_GOV); |
|
|
|
messageFormDTO.setGridId(StrConstant.STAR); |
|
|
|
messageFormDTO.setUserId(item.getUserId()); |
|
|
|
messageFormDTO.setTitle("您有一条通知消息!"); |
|
|
|
messageFormDTO.setMessageContent(item.getContent()); |
|
|
|
messageFormDTO.setReadFlag(Constant.UNREAD); |
|
|
|
messageFormDTO.setMessageType(UserMessageTypeConstant.ANTIEPIDEMIC); |
|
|
|
messageFormDTO.setTargetId(item.getId()); |
|
|
|
msgList.add(messageFormDTO); |
|
|
|
} |
|
|
|
//TODO
|
|
|
|
if (StringUtils.isNotBlank(item.getMobile())) { |
|
|
|
ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); |
|
|
|
sms.setCustomerId(item.getCustomerId()); |
|
|
|
sms.setMobile(item.getMobile()); |
|
|
|
sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_OVERDUE); |
|
|
|
sms.setParameterKey("send_msg"); |
|
|
|
smsList.add(sms); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
Result result = messageFeignClient.saveUserMessageList(msgList); |
|
|
|
if (!result.success()) { |
|
|
|
log.error("发送小程序消息失败" + JSON.toJSONString(result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取人员最新一条通知 |
|
|
|
* |
|
|
|
* @param idCard |
|
|
|
* @Param idCard |
|
|
|
* @Return {@link IcNoticeDTO} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/3/28 15:43 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public IcNoticeDTO getNotice(String customerId, String idCard) { |
|
|
|
IcNoticeDTO result = new IcNoticeDTO(); |
|
|
|
LambdaQueryWrapper<IcNoticeEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcNoticeEntity::getCustomerId, customerId); |
|
|
|
wrapper.eq(IcNoticeEntity::getIdCard, idCard); |
|
|
|
wrapper.orderByDesc(IcNoticeEntity::getCreatedTime); |
|
|
|
List<IcNoticeEntity> list = baseDao.selectList(wrapper); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
result = ConvertUtils.sourceToTarget(list.get(NumConstant.ZERO), IcNoticeDTO.class); |
|
|
|
result.setChannelList(Arrays.asList(result.getChannel().split(StrConstant.COMMA))); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
} |