update - 抄送模板兜底与自定义配置的逻辑调整

This commit is contained in:
wangli 2024-03-22 17:44:18 +08:00
parent 03679ef523
commit c0133c055c
3 changed files with 43 additions and 21 deletions

View File

@ -344,6 +344,7 @@ public final class BpmnJsonConverterUtil {
noticeConfigElement.addChildElement(pendingMessage);
}
// 抄送模板配置
if (Objects.nonNull(noticeConf.getCarbonCopy()) && Objects.nonNull(noticeConf.getCarbonCopy().getCarbonCopyMessageId())) {
ExtensionElement carbonCopyMessage = new ExtensionElement();
carbonCopyMessage.setName(TEMPLATE_CARBON_COPY_MESSAGE_ID);

View File

@ -19,9 +19,11 @@ import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -42,7 +44,8 @@ import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCarbonC
@RefreshScope
@Slf4j
public class EngineCarbonCopyEventListener implements JavaDelegate {
@Value("${workflow.carbonCopyTemplateCode}")
private String carbonCopyTemplateCode;
@Resource
private EngineExecutionStartListener engineExecutionStartListener;
@Resource
@ -76,7 +79,7 @@ public class EngineCarbonCopyEventListener implements JavaDelegate {
}
private static void invokeCarbonCopy(List<BpmnTaskDelegateAssigner> carbonUsers,
private void invokeCarbonCopy(List<BpmnTaskDelegateAssigner> carbonUsers,
Optional<BpmnNoticeConf> noticeConf,
DelegateExecution execution) {
if (CollectionUtils.isEmpty(carbonUsers)) {
@ -86,8 +89,15 @@ public class EngineCarbonCopyEventListener implements JavaDelegate {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
BpmnNoticeConf bpmnNoticeConf = noticeConf.map(conf -> {
if (!StringUtils.hasText(conf.getCarbonCopy().getCarbonCopyMessageId())) {
conf.getCarbonCopy().setCarbonCopyMessageId(carbonCopyTemplateCode);
}
return conf;
}).orElse(null);
MessagePushEventImpl event = MessagePushEventBuilder.createEvent(MessagePushEventType.CARBON_COPY,
carbonUsers, noticeConf.orElse(null), execution.getProcessInstanceId(),
carbonUsers, bpmnNoticeConf, execution.getProcessInstanceId(),
execution.getTenantId(), null);
eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey());
}

View File

@ -17,7 +17,6 @@ import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -78,10 +77,7 @@ import static cn.axzo.workflow.common.enums.ProcessMessagePushEventEnum.PROCESS_
*/
@Slf4j
@Component
@RefreshScope
public class RocketMqMessagePushEventListener implements BpmnMessagePushEventListener, Ordered {
@Value("${workflow.carbonCopyTemplateCode:123}")
private String carbonCopyTemplateCode;
@Resource
private EventProducer<?> eventProducer;
@Resource
@ -123,9 +119,11 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
log.debug("RocketMqMessagePushEventListener#onNotice...msgTemplateId: {}, receivePerson: {}",
event.getNoticeConfig().getNotice().getNoticeMessageId(), JSON.toJSONString(event.getAssigners()));
}
MessagePushDTO dto = build(event.getNoticeConfig().getNotice().getNoticeMessageId(),
PROCESS_PUSH_NOTICE, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_NOTICE);
if (Objects.nonNull(event.getNoticeConfig().getNotice())) {
MessagePushDTO dto = build(event.getNoticeConfig().getNotice().getNoticeMessageId(),
PROCESS_PUSH_NOTICE, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_NOTICE);
}
if (log.isDebugEnabled()) {
log.debug("RocketMqMessagePushEventListener#onNotice...end, msgTemplateId: {}, receivePerson: {}",
event.getNoticeConfig().getNotice().getNoticeMessageId(), JSON.toJSONString(event.getAssigners()));
@ -171,9 +169,11 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
event.getNoticeConfig().getPending().getPendingMessageId(),
JSON.toJSONString(event.getAssigners()));
}
MessagePushDTO dto = build(event.getNoticeConfig().getPending().getPendingMessageId(),
PROCESS_PUSH_PENDING_COMPLETE, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_PENDING_COMPLETE);
if (Objects.nonNull(event.getNoticeConfig().getPending())) {
MessagePushDTO dto = build(event.getNoticeConfig().getPending().getPendingMessageId(),
PROCESS_PUSH_PENDING_COMPLETE, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_PENDING_COMPLETE);
}
if (log.isDebugEnabled()) {
log.debug("RocketMqMessagePushEventListener#onPendingComplete...end, msgTemplateId: {}, receivePerson: " +
"{}", event.getNoticeConfig().getPending().getPendingMessageId(),
@ -183,16 +183,25 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
@Override
public void onCarbonCopy(MessagePushEvent event) {
if (Objects.isNull(event.getNoticeConfig())
|| Objects.isNull(event.getNoticeConfig().getCarbonCopy())
|| !StringUtils.hasLength(event.getNoticeConfig().getCarbonCopy().getCarbonCopyMessageId())) {
return;
}
if (log.isDebugEnabled()) {
log.debug("RocketMqMessagePushEventListener#onCarbonCopy... cc' templateId: {}, receivePerson: {}",
carbonCopyTemplateCode, JSON.toJSONString(event.getAssigners()));
event.getNoticeConfig().getCarbonCopy().getCarbonCopyMessageId(),
JSON.toJSONString(event.getAssigners()));
}
if (Objects.nonNull(event.getNoticeConfig().getCarbonCopy())) {
MessagePushDTO dto = build(event.getNoticeConfig().getCarbonCopy().getCarbonCopyMessageId(),
PROCESS_CARBON_COPY, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_CARBON_COPY);
}
MessagePushDTO dto = build(carbonCopyTemplateCode,
PROCESS_CARBON_COPY, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_CARBON_COPY);
if (log.isDebugEnabled()) {
log.debug("RocketMqMessagePushEventListener#onCarbonCopy...end, cc' templateId: {}, receivePerson: {}",
carbonCopyTemplateCode, JSON.toJSONString(event.getAssigners()));
event.getNoticeConfig().getCarbonCopy().getCarbonCopyMessageId(),
JSON.toJSONString(event.getAssigners()));
}
}
@ -208,9 +217,11 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
log.debug("RocketMqMessagePushEventListener#onSms...msgTemplateId: {}, receivePerson: {}",
event.getNoticeConfig().getSms().getSmsId(), JSON.toJSONString(event.getAssigners()));
}
MessagePushDTO dto = build(event.getNoticeConfig().getSms().getSmsId(),
PROCESS_PUSH_SMS, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_SMS);
if (Objects.nonNull(event.getNoticeConfig().getCarbonCopy())) {
MessagePushDTO dto = build(event.getNoticeConfig().getSms().getSmsId(),
PROCESS_PUSH_SMS, event, collectionVariable(event));
sendMessageQueue(dto, PROCESS_PUSH_SMS);
}
if (log.isDebugEnabled()) {
log.debug("RocketMqMessagePushEventListener#onSms...end, msgTemplateId: {}, receivePerson: {}",
event.getNoticeConfig().getSms().getSmsId(), JSON.toJSONString(event.getAssigners()));