|
|
@ -1,7 +1,10 @@ |
|
|
|
package com.hnac.hzims.message.service.impl; |
|
|
|
package com.hnac.hzims.message.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.config.MessageFactory; |
|
|
|
import com.hnac.hzims.message.config.MessageFactory; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.message.entity.MessagePushRecordEntity; |
|
|
|
import com.hnac.hzims.message.enums.PushStatEnum; |
|
|
|
import com.hnac.hzims.message.enums.PushStatEnum; |
|
|
@ -11,12 +14,16 @@ import com.hnac.hzims.message.service.IMessageService; |
|
|
|
import com.hnac.hzims.message.vo.msgpushrecord.*; |
|
|
|
import com.hnac.hzims.message.vo.msgpushrecord.*; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.YearMonth; |
|
|
|
import java.time.YearMonth; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -39,13 +46,50 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
return this.page(Condition.getPage(query), this.getQueryWrapper(request)); |
|
|
|
return this.page(Condition.getPage(query), this.getQueryWrapper(request)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean send(String id) { |
|
|
|
public Boolean send(Long id) { |
|
|
|
MessagePushRecordEntity record = this.getById(id); |
|
|
|
MessagePushRecordEntity record = this.getById(id); |
|
|
|
IMessageService messageSend = MessageFactory.getMessageSend(record.getType()); |
|
|
|
IMessageService messageSend = MessageFactory.getMessageSend(record.getType()); |
|
|
|
return messageSend.send(record); |
|
|
|
Boolean result = messageSend.send(record); |
|
|
|
} |
|
|
|
Assert.isTrue(result , ()-> { |
|
|
|
|
|
|
|
throw new ServiceException("发送消息失败!"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 更新推送状态以及推送时间
|
|
|
|
|
|
|
|
LambdaUpdateWrapper<MessagePushRecordEntity> luw = Wrappers.<MessagePushRecordEntity>lambdaUpdate() |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) |
|
|
|
|
|
|
|
.set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) |
|
|
|
|
|
|
|
.eq(MessagePushRecordEntity::getId, id); |
|
|
|
|
|
|
|
return this.update(luw); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public Boolean saveAndSend(MessagePushRecordEntity request) { |
|
|
|
|
|
|
|
if(Func.isEmpty(request.getPlanTime())) { |
|
|
|
|
|
|
|
request.setPlanTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(this.save(request) && Func.isNotEmpty(request.getId())) { |
|
|
|
|
|
|
|
return this.send(request.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取 QueryWrapper |
|
|
|
|
|
|
|
* @param request 查询条件 |
|
|
|
|
|
|
|
* @return QueryWrapper |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(request).lambda(); |
|
|
|
|
|
|
|
if(Func.isNotEmpty(request.getStartTime())) { |
|
|
|
|
|
|
|
lambda.ge(MessagePushRecordEntity::getPushTime,request.getStartTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(Func.isNotEmpty(request.getEndTime())) { |
|
|
|
|
|
|
|
lambda.le(MessagePushRecordEntity::getPushTime,request.getEndTime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lambda.orderByDesc(MessagePushRecordEntity::getPushTime); |
|
|
|
|
|
|
|
return lambda; |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 短信推送统计 |
|
|
|
* 短信推送统计 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -141,21 +185,6 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取 QueryWrapper |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param request 查询条件 |
|
|
|
|
|
|
|
* @return QueryWrapper |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private LambdaQueryWrapper<MessagePushRecordEntity> getQueryWrapper(MessagePushRecordEntity request) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<MessagePushRecordEntity> lambda = Condition.getQueryWrapper(request).lambda(); |
|
|
|
|
|
|
|
if (Func.isNotEmpty(request.getStatus())) { |
|
|
|
|
|
|
|
lambda.eq(MessagePushRecordEntity::getStatus, request.getStatus()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return lambda; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 状态 ===> 状态名称 |
|
|
|
* 状态 ===> 状态名称 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param key 状态 |
|
|
|
* @param key 状态 |
|
|
|