|
|
|
@ -77,28 +77,30 @@ public class MessagePushSchedule {
|
|
|
|
|
* @return void |
|
|
|
|
**/ |
|
|
|
|
private void sendMessage(List<MessagePushRecordEntity> list) { |
|
|
|
|
Map<String, List<MessagePushRecordEntity>> collect = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount)); |
|
|
|
|
String type = list.get(0).getType(); |
|
|
|
|
IMessageService service = MessageFactory.getMessageSend(type); |
|
|
|
|
collect.forEach((account,records) -> { |
|
|
|
|
MessagePushRecordEntity request = records.get(0); |
|
|
|
|
// 完善推送内容
|
|
|
|
|
request.setContent(this.getPushContent(type,records)); |
|
|
|
|
if(MessageConstants.SMS_PUSH.equals(type)) { |
|
|
|
|
request.setSmsParam(request.getContent()); |
|
|
|
|
} |
|
|
|
|
request.setMessageId(IdWorker.getId()); |
|
|
|
|
Boolean flag = service.send(request); |
|
|
|
|
if(!flag) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<Long> ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()); |
|
|
|
|
// 更新消息推送状态
|
|
|
|
|
LambdaUpdateWrapper<MessagePushRecordEntity> lwq = Wrappers.<MessagePushRecordEntity>lambdaUpdate() |
|
|
|
|
.set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED) |
|
|
|
|
.set(MessagePushRecordEntity::getPushTime,LocalDateTime.now()) |
|
|
|
|
.in(MessagePushRecordEntity::getId, ids); |
|
|
|
|
recordService.update(lwq); |
|
|
|
|
Map<String, List<MessagePushRecordEntity>> typeGroup = list.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getType)); |
|
|
|
|
typeGroup.forEach((type,typeList) -> { |
|
|
|
|
Map<String, List<MessagePushRecordEntity>> collect = typeList.stream().collect(Collectors.groupingBy(MessagePushRecordEntity::getAccount)); |
|
|
|
|
IMessageService service = MessageFactory.getMessageSend(type); |
|
|
|
|
collect.forEach((account,records) -> { |
|
|
|
|
MessagePushRecordEntity request = records.get(0); |
|
|
|
|
// 完善推送内容
|
|
|
|
|
request.setContent(this.getPushContent(type,records)); |
|
|
|
|
if(MessageConstants.SMS_PUSH.equals(type)) { |
|
|
|
|
request.setSmsParam(request.getContent()); |
|
|
|
|
} |
|
|
|
|
request.setMessageId(IdWorker.getId()); |
|
|
|
|
Boolean flag = service.send(request); |
|
|
|
|
if(!flag) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<Long> ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()); |
|
|
|
|
// 更新消息推送状态
|
|
|
|
|
LambdaUpdateWrapper<MessagePushRecordEntity> lwq = Wrappers.<MessagePushRecordEntity>lambdaUpdate() |
|
|
|
|
.set(MessagePushRecordEntity::getStatus, flag ? MessageConstants.PUSH_SUCCESS : MessageConstants.PUSH_FAILED) |
|
|
|
|
.set(MessagePushRecordEntity::getPushTime,LocalDateTime.now()) |
|
|
|
|
.in(MessagePushRecordEntity::getId, ids); |
|
|
|
|
recordService.update(lwq); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|