Merge branch 'feature/REQ-3201'
This commit is contained in:
commit
8c085da1fb
@ -1,10 +1,13 @@
|
||||
package cn.axzo.msg.center.message.service.todo;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.msg.center.api.mq.CardInfo;
|
||||
import cn.axzo.msg.center.dal.TodoDao;
|
||||
import cn.axzo.msg.center.domain.entity.Todo;
|
||||
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
||||
import cn.axzo.msg.center.message.domain.param.PendingMessagePushParam;
|
||||
import cn.axzo.msg.center.message.service.card.CardManager;
|
||||
import cn.axzo.msg.center.message.service.impl.v3.ModelV3Service;
|
||||
import cn.axzo.msg.center.message.service.todo.manage.TodoLogger;
|
||||
import cn.axzo.msg.center.message.service.todo.manage.TodoManager;
|
||||
import cn.axzo.msg.center.message.service.todo.manage.TodoRequestContext;
|
||||
@ -27,10 +30,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -49,6 +55,8 @@ public class TodoWithCardWrapper {
|
||||
|
||||
private final TodoDao todoDao;
|
||||
|
||||
private final ModelV3Service modelV3Service;
|
||||
|
||||
/**
|
||||
* 卡片预设按钮,同步待办
|
||||
* 注:卡片预设同步待办状态
|
||||
@ -62,6 +70,7 @@ public class TodoWithCardWrapper {
|
||||
if (StringUtils.isBlank(cardInfo.getTemplateCode()) || StringUtils.isBlank(cardInfo.getBizCode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("TodoWithCardWrapper#fireTodoWhenPresetButtonPressedByCard start,presetButtonType:{},cardInfo:{}", presetButtonType, JSON.toJSONString(cardInfo));
|
||||
TodoRequestContext ctx = TodoRequestContext.create("cardPresetTodo", cardInfo);
|
||||
ctx.addLogContent("presetButtonType", presetButtonType);
|
||||
@ -109,6 +118,13 @@ public class TodoWithCardWrapper {
|
||||
}
|
||||
log.info("TodoWithCardWrapper#fireCardWhenPresetButtonPressedByTodo start,request:{},todo:{}", JSON.toJSONString(request), JSON.toJSONString(todo));
|
||||
TodoRequestContext ctx = TodoRequestContext.create("todoPresetCard", request);
|
||||
|
||||
|
||||
if (!this.isContainImChannel(todo.getTemplateCode())) {
|
||||
log.info("fireCardWhenPresetButtonPressedByTodo#notContainImChannel,templateCode:{}", todo.getTemplateCode());
|
||||
return;
|
||||
}
|
||||
log.info("fireCardWhenPresetButtonPressedByTodo#isContainImChannel,templateCode:{}", todo.getTemplateCode());
|
||||
try {
|
||||
//1 构建对象
|
||||
CardUpdatePresetButtonRequest cardRequest = this.buildCardUpdatePresetButtonRequest(request, todo);
|
||||
@ -149,6 +165,11 @@ public class TodoWithCardWrapper {
|
||||
public void send(PendingMessagePushParam param,List<Todo> todos) {
|
||||
log.info("TodoWithCardWrapper#send start,param:{}", JSON.toJSONString(param));
|
||||
TodoRequestContext ctx = TodoRequestContext.create("todoSyncCardSend", param);
|
||||
if (!this.isContainImChannel(param.getTemplateCode())) {
|
||||
log.info("send#notContainImChannel,templateCode:{}", param.getTemplateCode());
|
||||
return;
|
||||
}
|
||||
log.info("send#isContainImChannel,templateCode:{}", param.getTemplateCode());
|
||||
try {
|
||||
//1 构建对象
|
||||
CardSendRequest cardSendRequest = this.buildCardSendRequest(param);
|
||||
@ -165,6 +186,16 @@ public class TodoWithCardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含IM通道
|
||||
*/
|
||||
private boolean isContainImChannel(String templateCode) {
|
||||
TemplateModelV3 templateModel = modelV3Service.findEnabledByCode(templateCode)
|
||||
.orElseThrow(() -> new ServiceException(
|
||||
String.format("Can't find template. templateCode=%s", templateCode)));
|
||||
return templateModel.getTemplate().isContainImChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片更新状态-完成
|
||||
*/
|
||||
@ -206,8 +237,20 @@ public class TodoWithCardWrapper {
|
||||
ctx.addLogContent("bizState", bizState);
|
||||
ctx.addLogContent("cardState", bizState);
|
||||
ctx.addLogContent("setCardCompleted", setCardCompleted);
|
||||
|
||||
try {
|
||||
Set<String> codes = todoList.stream().map(Todo::getTemplateCode).collect(Collectors.toSet());
|
||||
List<TemplateModelV3> byCodes = modelV3Service.getByCodes(new ArrayList<>(codes));
|
||||
Map<String, TemplateModelV3> modelV3Map = byCodes.stream().collect(Collectors.toMap(TemplateModelV3::getTemplateCode, Function.identity()));
|
||||
|
||||
for (Todo todo : todoList) {
|
||||
TemplateModelV3 templateModelV3 = modelV3Map.get(todo.getTemplateCode());
|
||||
if (Objects.isNull(templateModelV3) || Objects.isNull(templateModelV3.getTemplate())
|
||||
|| StringUtils.isBlank(templateModelV3.getTemplate().getCode()) ||!templateModelV3.getTemplate().isContainImChannel()) {
|
||||
log.info("cardUpdateStateByTodoList#notContainImChannel,templateModelV3:{}", JSON.toJSONString(templateModelV3));
|
||||
continue;
|
||||
}
|
||||
log.info("cardUpdateStateByTodoList#isContainImChannel,templateModelV3:{}", JSON.toJSONString(templateModelV3));
|
||||
//1 构建对象
|
||||
CardUpdateStateRequest updateStateRequest = this.buildCardUpdateStateRequest(todo, bizState, setCardCompleted);
|
||||
//2 更新状态
|
||||
|
||||
@ -152,6 +152,13 @@ public class MessageTemplateV3 extends BaseEntityWithOperator<MessageTemplateV3>
|
||||
return channels == null ? Collections.emptyList() : channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含IM通道
|
||||
*/
|
||||
public boolean isContainImChannel() {
|
||||
return this.determineChannels().contains(MessageChannel.IM);
|
||||
}
|
||||
|
||||
public PushData parsePushData() {
|
||||
JSONObject pushData = this.pushData;
|
||||
if (pushData == null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user