Merge branch 'master' of https://axzsource.com/universal/infrastructure/backend/msg-center-plat into feature/REQ-3832
This commit is contained in:
commit
d23b8f8bda
@ -46,6 +46,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.axzo.trade</groupId>
|
<groupId>cn.axzo.trade</groupId>
|
||||||
<artifactId>trade-web-spring-boot-starter</artifactId>
|
<artifactId>trade-web-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis</groupId>
|
<groupId>org.mybatis</groupId>
|
||||||
|
|||||||
@ -1,5 +1,21 @@
|
|||||||
package cn.axzo.msg.center.event.outer;
|
package cn.axzo.msg.center.event.outer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import cn.axzo.framework.rocketmq.Event;
|
import cn.axzo.framework.rocketmq.Event;
|
||||||
import cn.axzo.framework.rocketmq.EventConsumer;
|
import cn.axzo.framework.rocketmq.EventConsumer;
|
||||||
import cn.axzo.framework.rocketmq.EventHandler;
|
import cn.axzo.framework.rocketmq.EventHandler;
|
||||||
@ -19,21 +35,7 @@ import cn.axzo.msg.center.nimpush.device.PushDevice;
|
|||||||
import cn.axzo.msg.center.nimpush.device.PushDeviceService;
|
import cn.axzo.msg.center.nimpush.device.PushDeviceService;
|
||||||
import cn.axzo.msg.center.push.PushData;
|
import cn.axzo.msg.center.push.PushData;
|
||||||
import cn.axzo.msg.center.service.enums.TerminalTypeEnum;
|
import cn.axzo.msg.center.service.enums.TerminalTypeEnum;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ -127,9 +129,8 @@ public class PushYouMengMessageHandler implements EventHandler, InitializingBean
|
|||||||
log.info("push-handler, 模板code:{},appType不合法, event: {}", card.getTemplateCode(), event);
|
log.info("push-handler, 模板code:{},appType不合法, event: {}", card.getTemplateCode(), event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PushDevice device = pushDeviceService
|
long personId = Long.parseLong(newMessageHistory.getReceivePersonId());
|
||||||
.createDeviceSnapshots()
|
PushDevice device = pushDeviceService.getDevice(personId);
|
||||||
.getDevice(Long.parseLong(newMessageHistory.getReceivePersonId()));
|
|
||||||
if(!device.shouldPush(appType, PushChannel.YOU_MENG)) {
|
if(!device.shouldPush(appType, PushChannel.YOU_MENG)) {
|
||||||
log.info("push-handler, 模板code:{}, 友盟push不适用, event: {}", card.getTemplateCode(), event);
|
log.info("push-handler, 模板code:{}, 友盟push不适用, event: {}", card.getTemplateCode(), event);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
package cn.axzo.msg.center.message.service.card;
|
package cn.axzo.msg.center.message.service.card;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import cn.axzo.framework.jackson.utility.JSON;
|
import cn.axzo.framework.jackson.utility.JSON;
|
||||||
import cn.axzo.im.center.api.feign.MessageApi;
|
import cn.axzo.im.center.api.feign.MessageApi;
|
||||||
import cn.axzo.im.center.api.vo.req.SendTemplateMessageParam;
|
import cn.axzo.im.center.api.vo.req.SendTemplateMessageParam;
|
||||||
@ -42,18 +55,6 @@ import cn.axzo.msg.center.utils.BatchController;
|
|||||||
import cn.axzo.msg.center.utils.RecordCursor;
|
import cn.axzo.msg.center.utils.RecordCursor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -106,7 +107,7 @@ public class CardManager {
|
|||||||
cardDao.saveBatch(sendModel.getCards());
|
cardDao.saveBatch(sendModel.getCards());
|
||||||
sendLogger.reloadAndLogCards("send:enqueue");
|
sendLogger.reloadAndLogCards("send:enqueue");
|
||||||
});
|
});
|
||||||
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots();
|
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots(sendModel.receiverPersonIds());
|
||||||
BatchController groupExecutor = new BatchController("sendCard", request, executor);
|
BatchController groupExecutor = new BatchController("sendCard", request, executor);
|
||||||
for (CardGroup group : sendModel.getCardGroups()) {
|
for (CardGroup group : sendModel.getCardGroups()) {
|
||||||
groupExecutor.submit(() -> {
|
groupExecutor.submit(() -> {
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
package cn.axzo.msg.center.message.service.card.domain;
|
package cn.axzo.msg.center.message.service.card.domain;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import cn.axzo.msg.center.domain.entity.Card;
|
import cn.axzo.msg.center.domain.entity.Card;
|
||||||
import cn.axzo.msg.center.message.domain.vo.GeneralMessagePushVO;
|
import cn.axzo.msg.center.message.domain.vo.GeneralMessagePushVO;
|
||||||
import cn.axzo.msg.center.message.service.card.CardRequestContext;
|
import cn.axzo.msg.center.message.service.card.CardRequestContext;
|
||||||
@ -11,12 +20,6 @@ import lombok.Getter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
*/
|
*/
|
||||||
@ -35,6 +38,10 @@ public class CardSendModel {
|
|||||||
cards.add(card);
|
cards.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Long> receiverPersonIds() {
|
||||||
|
return cards.stream().map(Card::getReceiverPersonId).collect(toSet());
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<CardGroup> getCardGroups() {
|
public Collection<CardGroup> getCardGroups() {
|
||||||
HashMap<CardGroupKey, CardGroup> groups = new HashMap<>();
|
HashMap<CardGroupKey, CardGroup> groups = new HashMap<>();
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
package cn.axzo.msg.center.message.service.impl.v3;
|
package cn.axzo.msg.center.message.service.impl.v3;
|
||||||
|
|
||||||
|
import static cn.axzo.msg.center.common.utils.PlaceholderResolver.getDefaultResolver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import cn.axzo.msg.center.domain.entity.MessageTemplateButtonV3;
|
import cn.axzo.msg.center.domain.entity.MessageTemplateButtonV3;
|
||||||
import cn.axzo.msg.center.domain.entity.MessageTemplateGroupV3;
|
import cn.axzo.msg.center.domain.entity.MessageTemplateGroupV3;
|
||||||
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
||||||
@ -20,19 +33,8 @@ import cn.axzo.msg.center.service.pending.response.v3.model.ParsedModelV3;
|
|||||||
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedTemplateV3;
|
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedTemplateV3;
|
||||||
import cn.axzo.msg.center.service.pending.response.v3.model.PhoneInfo;
|
import cn.axzo.msg.center.service.pending.response.v3.model.PhoneInfo;
|
||||||
import cn.axzo.trade.datasecurity.core.util.DataSecurityHelper;
|
import cn.axzo.trade.datasecurity.core.util.DataSecurityHelper;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.math.NumberUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.axzo.msg.center.common.utils.PlaceholderResolver.getDefaultResolver;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -154,7 +156,8 @@ public class ModelV3Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
// 提前排序避免并发问题
|
||||||
|
parsedModel.sortButtons();
|
||||||
return parsedModel;
|
return parsedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,18 @@
|
|||||||
package cn.axzo.msg.center.message.service.todo.manage.event;
|
package cn.axzo.msg.center.message.service.todo.manage.event;
|
||||||
|
|
||||||
import cn.axzo.msg.center.domain.entity.Todo;
|
import static java.util.stream.Collectors.toSet;
|
||||||
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
|
import cn.axzo.msg.center.domain.entity.Todo;
|
||||||
|
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -23,6 +28,10 @@ public class NewTodoEvent extends ApplicationEvent {
|
|||||||
this.todos = todos;
|
this.todos = todos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Long> executorPersonIds() {
|
||||||
|
return todos.stream().map(Todo::getExecutorPersonId).collect(toSet());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
HashMap<String, Object> fields = new HashMap<>();
|
HashMap<String, Object> fields = new HashMap<>();
|
||||||
|
|||||||
@ -1,5 +1,19 @@
|
|||||||
package cn.axzo.msg.center.message.service.todo.manage.event;
|
package cn.axzo.msg.center.message.service.todo.manage.event;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import cn.axzo.msg.center.dal.TodoBusinessDao;
|
import cn.axzo.msg.center.dal.TodoBusinessDao;
|
||||||
import cn.axzo.msg.center.dal.TodoBusinesses;
|
import cn.axzo.msg.center.dal.TodoBusinesses;
|
||||||
import cn.axzo.msg.center.domain.entity.MessageEntity;
|
import cn.axzo.msg.center.domain.entity.MessageEntity;
|
||||||
@ -23,20 +37,8 @@ import cn.axzo.msg.center.service.domain.CardUrlConfig;
|
|||||||
import cn.axzo.msg.center.service.domain.UrlConfig;
|
import cn.axzo.msg.center.service.domain.UrlConfig;
|
||||||
import cn.axzo.msg.center.service.domain.UrlConfigWalker;
|
import cn.axzo.msg.center.service.domain.UrlConfigWalker;
|
||||||
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -64,7 +66,7 @@ class TodoPushSender implements ApplicationListener<NewTodoEvent> {
|
|||||||
if (!pushData.determinePushable(log, event.getTemplateModel().getTemplateCode()))
|
if (!pushData.determinePushable(log, event.getTemplateModel().getTemplateCode()))
|
||||||
return;
|
return;
|
||||||
List<PushTerminalEnum> pushTerminals = template.determinePushTerminals();
|
List<PushTerminalEnum> pushTerminals = template.determinePushTerminals();
|
||||||
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots();
|
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots(event.executorPersonIds());
|
||||||
ArrayList<YoumengPush> pushes = new ArrayList<>();
|
ArrayList<YoumengPush> pushes = new ArrayList<>();
|
||||||
for (Todo todo : event.getTodos()) {
|
for (Todo todo : event.getTodos()) {
|
||||||
PushDevice pushDevice = deviceSnapshots.getDevice(todo.getExecutorPersonId());
|
PushDevice pushDevice = deviceSnapshots.getDevice(todo.getExecutorPersonId());
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class TodoPushSenderNim implements ApplicationListener<NewTodoEvent> {
|
|||||||
if (pushData != null && !pushData.determinePushable(log, parsedModelV3.getTemplateCode())) {
|
if (pushData != null && !pushData.determinePushable(log, parsedModelV3.getTemplateCode())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots();
|
PushDeviceSnapshots deviceSnapshots = pushDeviceService.createDeviceSnapshots(event.executorPersonIds());
|
||||||
for (Todo todo : event.getTodos()) {
|
for (Todo todo : event.getTodos()) {
|
||||||
executor.submit(() -> {
|
executor.submit(() -> {
|
||||||
for (AppTypeEnum appType : appTypes) {
|
for (AppTypeEnum appType : appTypes) {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package cn.axzo.msg.center.nimpush.device;
|
package cn.axzo.msg.center.nimpush.device;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
||||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||||
import cn.axzo.msg.center.nimpush.PushChannel;
|
import cn.axzo.msg.center.nimpush.PushChannel;
|
||||||
@ -7,8 +9,6 @@ import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
*/
|
*/
|
||||||
@ -16,9 +16,7 @@ import java.util.List;
|
|||||||
public class PushDevice {
|
public class PushDevice {
|
||||||
|
|
||||||
private final PushDeviceService pushDeviceService;
|
private final PushDeviceService pushDeviceService;
|
||||||
private final Long personId;
|
private final List<ApkDeviceMaxCodeResp> devices;
|
||||||
|
|
||||||
private volatile List<ApkDeviceMaxCodeResp> cache;
|
|
||||||
|
|
||||||
public boolean shouldPush(AppTypeEnum appType,
|
public boolean shouldPush(AppTypeEnum appType,
|
||||||
PushChannel pushChannel) {
|
PushChannel pushChannel) {
|
||||||
@ -30,20 +28,7 @@ public class PushDevice {
|
|||||||
|
|
||||||
public boolean shouldPush(PushTerminalEnum pushTerminal,
|
public boolean shouldPush(PushTerminalEnum pushTerminal,
|
||||||
PushChannel pushChannel) {
|
PushChannel pushChannel) {
|
||||||
List<ApkDeviceMaxCodeResp> devices = getDevices();
|
|
||||||
return pushDeviceService.shouldPush(pushTerminal, pushChannel, devices);
|
return pushDeviceService.shouldPush(pushTerminal, pushChannel, devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ApkDeviceMaxCodeResp> getDevices() {
|
|
||||||
List<ApkDeviceMaxCodeResp> cache = this.cache;
|
|
||||||
if (cache != null)
|
|
||||||
return cache;
|
|
||||||
synchronized (this) {
|
|
||||||
cache = this.cache;
|
|
||||||
if (cache == null)
|
|
||||||
cache = this.cache = pushDeviceService.getPersonDevices(personId);
|
|
||||||
}
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,8 +1,22 @@
|
|||||||
package cn.axzo.msg.center.nimpush.device;
|
package cn.axzo.msg.center.nimpush.device;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
import cn.axzo.epic.client.common.enums.AppTerminalTypeEnum;
|
import cn.axzo.epic.client.common.enums.AppTerminalTypeEnum;
|
||||||
import cn.axzo.epic.client.feign.AppDeviceApi;
|
import cn.axzo.epic.client.feign.AppDeviceApi;
|
||||||
import cn.axzo.epic.client.vo.request.FetchDeviceByPersonIdAndTerminalReq;
|
import cn.axzo.epic.client.vo.request.BatchFetchDeviceByPersonIdAndTerminalReq;
|
||||||
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
||||||
import cn.axzo.msg.center.common.enums.SystemTypeEnum;
|
import cn.axzo.msg.center.common.enums.SystemTypeEnum;
|
||||||
import cn.axzo.msg.center.common.utils.BizAssertions;
|
import cn.axzo.msg.center.common.utils.BizAssertions;
|
||||||
@ -10,16 +24,8 @@ import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
|
|||||||
import cn.axzo.msg.center.inside.notices.config.push.PushDeviceVersion;
|
import cn.axzo.msg.center.inside.notices.config.push.PushDeviceVersion;
|
||||||
import cn.axzo.msg.center.nimpush.PushChannel;
|
import cn.axzo.msg.center.nimpush.PushChannel;
|
||||||
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -32,18 +38,21 @@ public class PushDeviceService {
|
|||||||
private final AppDeviceApi appDeviceApi;
|
private final AppDeviceApi appDeviceApi;
|
||||||
private final PendingMessageBizConfig cfg;
|
private final PendingMessageBizConfig cfg;
|
||||||
|
|
||||||
public PushDeviceSnapshots createDeviceSnapshots() {
|
public PushDevice getDevice(long personId) {
|
||||||
return new PushDeviceSnapshots(this);
|
return createDeviceSnapshots(Collections.singletonList(personId)).getDevice(personId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ApkDeviceMaxCodeResp> getPersonDevices(Long personId) {
|
public PushDeviceSnapshots createDeviceSnapshots(Collection<Long> personIds) {
|
||||||
FetchDeviceByPersonIdAndTerminalReq request =
|
if (CollectionUtils.isNotEmpty(personIds))
|
||||||
new FetchDeviceByPersonIdAndTerminalReq();
|
return new PushDeviceSnapshots(this, Collections.emptyList());
|
||||||
request.setPersonId(personId);
|
ArrayList<Long> uniquePersonIds = new ArrayList<>(new HashSet<>(personIds));
|
||||||
|
BatchFetchDeviceByPersonIdAndTerminalReq request = new BatchFetchDeviceByPersonIdAndTerminalReq();
|
||||||
|
request.setPersonIds(uniquePersonIds);
|
||||||
request.setTerminals(Arrays.asList(
|
request.setTerminals(Arrays.asList(
|
||||||
AppTerminalTypeEnum.CMP, AppTerminalTypeEnum.CM));
|
AppTerminalTypeEnum.CMP, AppTerminalTypeEnum.CM));
|
||||||
return BizAssertions.assertResponse(
|
List<ApkDeviceMaxCodeResp> devices = BizAssertions.assertResponse(
|
||||||
appDeviceApi.fetchCodeByPersonIdAndTerminal(request));
|
appDeviceApi.batchfetchCodeByPersonIdAndTerminal(request));
|
||||||
|
return new PushDeviceSnapshots(this, devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldPush(PushTerminalEnum pushTerminal,
|
boolean shouldPush(PushTerminalEnum pushTerminal,
|
||||||
@ -104,5 +113,4 @@ public class PushDeviceService {
|
|||||||
return SystemTypeEnum.IOS;
|
return SystemTypeEnum.IOS;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,26 +1,39 @@
|
|||||||
|
|
||||||
package cn.axzo.msg.center.nimpush.device;
|
package cn.axzo.msg.center.nimpush.device;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import static java.util.Collections.emptyList;
|
||||||
import lombok.RequiredArgsConstructor;
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
public class PushDeviceSnapshots {
|
public class PushDeviceSnapshots {
|
||||||
|
|
||||||
private final Map<Long, PushDevice> cache = new ConcurrentHashMap<>();
|
private final Map<Long, PushDevice> cache = new ConcurrentHashMap<>();
|
||||||
private final PushDeviceService pushDeviceService;
|
private final PushDeviceService pushDeviceService;
|
||||||
|
private final List<ApkDeviceMaxCodeResp> devices;
|
||||||
|
|
||||||
public PushDevice getDevice(Long personId) {
|
private Map<Long, List<ApkDeviceMaxCodeResp>> personId2Devices;
|
||||||
return cache.computeIfAbsent(personId, this::createDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PushDevice createDevice(Long personId) {
|
public PushDevice getDevice(Long personId) {
|
||||||
return new PushDevice(pushDeviceService, personId);
|
return cache.computeIfAbsent(personId, this::createDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PushDevice createDevice(Long personId) {
|
||||||
|
if (personId2Devices == null)
|
||||||
|
personId2Devices = devices.stream().collect(groupingBy(ApkDeviceMaxCodeResp::getPersonId));
|
||||||
|
List<ApkDeviceMaxCodeResp> personDevices = personId2Devices.getOrDefault(personId, emptyList());
|
||||||
|
return new PushDevice(pushDeviceService, personDevices);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ public class BatchController {
|
|||||||
|
|
||||||
public BatchController(String operation, Object request,
|
public BatchController(String operation, Object request,
|
||||||
ExecutorService executor) {
|
ExecutorService executor) {
|
||||||
this(operation, request, executor, 4);
|
this(operation, request, executor, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatchController(String operation, Object request,
|
public BatchController(String operation, Object request,
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package cn.axzo.msg.center.service.pending.response.v3;
|
package cn.axzo.msg.center.service.pending.response.v3;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
import cn.axzo.msg.center.service.domain.CardUrlConfig;
|
import cn.axzo.msg.center.service.domain.CardUrlConfig;
|
||||||
import cn.axzo.msg.center.service.domain.card.AppVersionConfig;
|
import cn.axzo.msg.center.service.domain.card.AppVersionConfig;
|
||||||
import cn.axzo.msg.center.service.domain.card.StateImageConfig;
|
import cn.axzo.msg.center.service.domain.card.StateImageConfig;
|
||||||
@ -12,10 +16,6 @@ import cn.axzo.msg.center.service.pending.response.v3.model.ParsedGroupV3;
|
|||||||
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedKV;
|
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedKV;
|
||||||
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedModelV3;
|
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedModelV3;
|
||||||
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedTemplateV3;
|
import cn.axzo.msg.center.service.pending.response.v3.model.ParsedTemplateV3;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -41,9 +41,7 @@ public class ParsedModelV3Walker {
|
|||||||
}
|
}
|
||||||
for (ParsedGroupV3 group : new ArrayList<>(model.determineGroups()))
|
for (ParsedGroupV3 group : new ArrayList<>(model.determineGroups()))
|
||||||
visitGroup(visitor, group);
|
visitGroup(visitor, group);
|
||||||
ArrayList<ParsedButtonV3> buttons = new ArrayList<>(model.determineButtons());
|
for (ParsedButtonV3 button : new ArrayList<>(model.determineButtons()))
|
||||||
buttons.sort(Comparator.comparingInt(ParsedButtonV3::determinePriority));
|
|
||||||
for (ParsedButtonV3 button : buttons)
|
|
||||||
visitButton(visitor, button);
|
visitButton(visitor, button);
|
||||||
if (template != null)
|
if (template != null)
|
||||||
visitor.exitTemplate(template);
|
visitor.exitTemplate(template);
|
||||||
|
|||||||
@ -1,19 +1,7 @@
|
|||||||
package cn.axzo.msg.center.service.pending.response.v3.model;
|
package cn.axzo.msg.center.service.pending.response.v3.model;
|
||||||
|
|
||||||
import cn.axzo.msg.center.push.PushData;
|
import static java.util.stream.Collectors.toList;
|
||||||
import cn.axzo.msg.center.push.PushMessage;
|
|
||||||
import cn.axzo.msg.center.service.domain.CardUrlConfig;
|
|
||||||
import cn.axzo.msg.center.service.domain.UrlConfig;
|
|
||||||
import cn.axzo.msg.center.service.enums.GroupType;
|
|
||||||
import cn.axzo.msg.center.service.pending.response.MessageButtonProvider;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -21,7 +9,21 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import cn.axzo.msg.center.push.PushData;
|
||||||
|
import cn.axzo.msg.center.push.PushMessage;
|
||||||
|
import cn.axzo.msg.center.service.domain.CardUrlConfig;
|
||||||
|
import cn.axzo.msg.center.service.domain.UrlConfig;
|
||||||
|
import cn.axzo.msg.center.service.enums.GroupType;
|
||||||
|
import cn.axzo.msg.center.service.pending.response.MessageButtonProvider;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
@ -94,10 +96,14 @@ public class ParsedModelV3 implements MessageButtonProvider<ParsedButtonV3>, Pus
|
|||||||
return groups == null ? Collections.emptyList() : groups;
|
return groups == null ? Collections.emptyList() : groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ParsedButtonV3> determineButtons() {
|
public void sortButtons() {
|
||||||
List<ParsedButtonV3> buttons = this.buttons == null ? Collections.emptyList() : this.buttons;
|
if (buttons == null) return;
|
||||||
|
this.buttons = new ArrayList<>(buttons);
|
||||||
buttons.sort(Comparator.comparingInt(ParsedButtonV3::determinePriority));
|
buttons.sort(Comparator.comparingInt(ParsedButtonV3::determinePriority));
|
||||||
return buttons;
|
}
|
||||||
|
|
||||||
|
public List<ParsedButtonV3> determineButtons() {
|
||||||
|
return this.buttons == null ? Collections.emptyList() : this.buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEmptyKVGroups() {
|
public void removeEmptyKVGroups() {
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
package cn.axzo.msg.center.notices.integration.client.impl;
|
package cn.axzo.msg.center.notices.integration.client.impl;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import cn.hutool.core.net.URLEncoder;
|
import cn.hutool.core.net.URLEncoder;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息中心短信服务组件
|
* 信息中心短信服务组件
|
||||||
@ -100,7 +102,7 @@ public class RegulatoryGaoxinClient {
|
|||||||
param.put("Pwd", pwd);
|
param.put("Pwd", pwd);
|
||||||
param.put("Mobile", phone);
|
param.put("Mobile", phone);
|
||||||
param.put("Content", encodeContent);
|
param.put("Content", encodeContent);
|
||||||
return HttpUtil.toParams(param);
|
return JSON.toJSONString(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,13 +113,13 @@ public class RegulatoryGaoxinClient {
|
|||||||
private String executeSend(String param) {
|
private String executeSend(String param) {
|
||||||
try {
|
try {
|
||||||
//构建url
|
//构建url
|
||||||
String requestUrl = this.createUrl(param);
|
//String requestUrl = this.createUrl(param);
|
||||||
|
|
||||||
log.info("发送政务短信请求: {}", requestUrl);
|
log.info("发送政务短信请求, url={}, body={}", url, param);
|
||||||
|
|
||||||
//执行请求
|
//执行请求
|
||||||
String result = HttpUtil.post(
|
String result = HttpUtil.post(
|
||||||
requestUrl, StrUtil.EMPTY_JSON
|
url, param
|
||||||
);
|
);
|
||||||
|
|
||||||
//打印发送结果
|
//打印发送结果
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.axzo.trade</groupId>
|
<groupId>cn.axzo.trade</groupId>
|
||||||
<artifactId>trade-web-spring-boot-starter</artifactId>
|
<artifactId>trade-web-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.axzo.msgcenter</groupId>
|
<groupId>cn.axzo.msgcenter</groupId>
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
package cn.axzo.msg.center.nimpush.device;
|
|
||||||
|
|
||||||
import cn.axzo.epic.client.vo.response.ApkDeviceMaxCodeResp;
|
|
||||||
import cn.axzo.msg.center.MsgCenterApplication;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author yanglin
|
|
||||||
*/
|
|
||||||
@SpringBootTest(classes = MsgCenterApplication.class)
|
|
||||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
||||||
class PushDeviceServiceTest {
|
|
||||||
|
|
||||||
private final PushDeviceService pushDeviceService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void exec() {
|
|
||||||
List<ApkDeviceMaxCodeResp> devices = pushDeviceService.getPersonDevices(80792L);
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -61,6 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.axzo.trade</groupId>
|
<groupId>cn.axzo.trade</groupId>
|
||||||
<artifactId>trade-web-spring-boot-starter</artifactId>
|
<artifactId>trade-web-spring-boot-starter</artifactId>
|
||||||
|
<version>2.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
Loading…
Reference in New Issue
Block a user