commit
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.budwk.app.flow.listenter;
|
package com.budwk.app.flow.listenter;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import com.budwk.app.flow.constant.FlowConst;
|
import com.budwk.app.flow.constant.FlowConst;
|
||||||
import com.budwk.app.flow.engine.event.ProcessEvent;
|
import com.budwk.app.flow.engine.event.ProcessEvent;
|
||||||
import com.budwk.app.flow.engine.event.ProcessEventListener;
|
import com.budwk.app.flow.engine.event.ProcessEventListener;
|
||||||
@@ -9,6 +10,7 @@ import com.budwk.app.flow.entity.ProcessTask;
|
|||||||
import com.budwk.app.flow.entity.ProcessTaskActor;
|
import com.budwk.app.flow.entity.ProcessTaskActor;
|
||||||
import com.budwk.app.flow.enums.ProcessEventTypeEnum;
|
import com.budwk.app.flow.enums.ProcessEventTypeEnum;
|
||||||
import com.budwk.app.todo.service.TodoService;
|
import com.budwk.app.todo.service.TodoService;
|
||||||
|
import com.budwk.app.web.commons.base.Globals;
|
||||||
import com.budwk.app.zhgh.dayofficework.message.service.GlobalMessageSendService;
|
import com.budwk.app.zhgh.dayofficework.message.service.GlobalMessageSendService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
@@ -61,9 +63,21 @@ public class ProcessTaskStartEventListener implements ProcessEventListener {
|
|||||||
List<ProcessTaskActor> taskActors = dao.query(ProcessTaskActor.class, Cnd.where(ProcessTaskActor::getProcessTaskId, "=", task.getId()));
|
List<ProcessTaskActor> taskActors = dao.query(ProcessTaskActor.class, Cnd.where(ProcessTaskActor::getProcessTaskId, "=", task.getId()));
|
||||||
|
|
||||||
for (ProcessTaskActor taskActor : taskActors) {
|
for (ProcessTaskActor taskActor : taskActors) {
|
||||||
|
|
||||||
|
JSONObject config = new JSONObject();
|
||||||
|
config.set("pcUrl", Globals.AppDomain + task.getFormKey());
|
||||||
|
|
||||||
// 模拟发送消息
|
// 模拟发送消息
|
||||||
String message = StrUtil.format("您有一条待办任务,实例:{},处理环节:{}", taskActor.getActorName(), instanceName, taskDisplayName);
|
String message = "";
|
||||||
log.info(message);
|
if(StrUtil.isNotBlank(task.getH5FormKey())) {
|
||||||
|
config.set("mobileUrl", Globals.AppDomain + task.getH5FormKey());
|
||||||
|
message = StrUtil.format("您有一条待办任务,实例:{},处理环节:{}。", instanceName, taskDisplayName);
|
||||||
|
} else {
|
||||||
|
config.set("mobileUrl", Globals.AppDomain + "/platform/tooltip/h5");
|
||||||
|
message = StrUtil.format("您有一条待办任务,实例:{},处理环节:{},请到电脑端智慧工会系统审核。", instanceName, taskDisplayName);
|
||||||
|
}
|
||||||
|
log.info(message);
|
||||||
|
|
||||||
globalMessageSendService.sendMessage(taskDisplayName, message, 2, List.of(taskActor.getActorId()), null);
|
globalMessageSendService.sendMessage(taskDisplayName, message, 2, List.of(taskActor.getActorId()), null);
|
||||||
}
|
}
|
||||||
todoService.addTransaction(task);
|
todoService.addTransaction(task);
|
||||||
|
|||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
package com.budwk.app.zhgh.dayofficework.message.strategy.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.budwk.app.base.sms.SmsService;
|
||||||
|
import com.budwk.app.sys.models.Sys_user;
|
||||||
|
import com.budwk.app.zhgh.dayofficework.message.enums.GlobalMessageChannel;
|
||||||
|
import com.budwk.app.zhgh.dayofficework.message.strategy.GlobalMessageSendStrategy;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
|
import org.nutz.dao.Dao;
|
||||||
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
|
import org.nutz.lang.Lang;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName WechatEnterpriseMessageSendStrategy
|
||||||
|
* @Author JyuHsin
|
||||||
|
* @Date 2026/2/27 15:42
|
||||||
|
* @Version 1.0
|
||||||
|
* @Description TODO
|
||||||
|
*/
|
||||||
|
@IocBean
|
||||||
|
@Slf4j
|
||||||
|
public class WechatEnterpriseMessageSendStrategy implements GlobalMessageSendStrategy {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Dao dao;
|
||||||
|
@Inject
|
||||||
|
private SmsService smsService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GlobalMessageChannel getChannel() {
|
||||||
|
return GlobalMessageChannel.WECHAT_ENTERPRISE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportAsync() {
|
||||||
|
return GlobalMessageSendStrategy.super.supportAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(String title, String content, Integer type, List<String> receiverIds, JSONObject config) {
|
||||||
|
try {
|
||||||
|
log.info("开始发送企业微信消息,标题:{},接收人数量:{}", title, receiverIds.size());
|
||||||
|
|
||||||
|
// 查询用户手机号
|
||||||
|
List<Sys_user> users = dao.query(Sys_user.class, Cnd.where(Sys_user::getId, "in", receiverIds));
|
||||||
|
sendMessage(title, content, type, users, config);
|
||||||
|
|
||||||
|
log.info("企业微信消息发送完成,标题:{},接收人数量:{}", title, users.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("企业微信消息发送失败,标题:{},错误:{}", title, e.getMessage(), e);
|
||||||
|
throw new RuntimeException("企业微信消息发送失败:" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendByLoginName(String title, String content, Integer type, List<String> receiverLoginNames, JSONObject config) {
|
||||||
|
try {
|
||||||
|
log.info("开始发送企业微信消息(按登录名),标题:{},接收人数量:{}", title, receiverLoginNames.size());
|
||||||
|
|
||||||
|
// 查询用户手机号
|
||||||
|
List<Sys_user> users = dao.query(Sys_user.class, Cnd.where(Sys_user::getLoginname, "in", receiverLoginNames));
|
||||||
|
sendMessage(title, content, type, users, config);
|
||||||
|
|
||||||
|
log.info("企业微信消息发送完成(按登录名),标题:{},接收人数量:{}", title, users.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("企业微信消息发送失败(按登录名),标题:{},错误:{}", title, e.getMessage(), e);
|
||||||
|
throw new RuntimeException("企业微信消息发送失败:" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(String title, String content, Integer type, List<Sys_user> users, JSONObject config) {
|
||||||
|
if(Lang.isEmpty(users)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> list = users.stream().map(Sys_user::getLoginname).toList();
|
||||||
|
smsService.massSendTextCard(list, "智慧工会", content, config.getStr("pcUrl"), config.getStr("mobileUrl"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user