add 增加催办接口,调整消息发送

This commit is contained in:
songgaoshuai 2025-07-22 11:46:04 +08:00
parent 9375578925
commit 0dce571270
6 changed files with 108 additions and 2 deletions

View File

@ -209,4 +209,16 @@ public class FlwTaskController extends BaseController {
return R.ok(flwTaskService.currentTaskAllUser(List.of(taskId))); return R.ok(flwTaskService.currentTaskAllUser(List.of(taskId)));
} }
/**
* 催办任务
*
* @param bo 参数
* @return 结果
*/
@PostMapping("/urgeTask")
public R<Void> urgeTask(@RequestBody FlowUrgeTaskBo bo) {
return toAjax(flwTaskService.urgeTask(bo));
}
} }

View File

@ -0,0 +1,38 @@
package org.dromara.workflow.domain.bo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.dromara.common.core.validate.AddGroup;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
/**
* 流程变量参数
*
* @author may
*/
@Data
public class FlowUrgeTaskBo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 任务id
*/
@NotNull(message = "任务id为空", groups = AddGroup.class)
private List<Long> taskIdList;
/**
* 消息类型
*/
private List<String> messageType;
/**
* 催办内容
*/
@NotNull(message = "催办内容为空", groups = AddGroup.class)
private String message;
}

View File

@ -1,5 +1,7 @@
package org.dromara.workflow.service; package org.dromara.workflow.service;
import org.dromara.common.core.domain.dto.UserDTO;
import java.util.List; import java.util.List;
/** /**
@ -19,6 +21,16 @@ public interface IFlwCommonService {
*/ */
void sendMessage(String flowName, Long instId, List<String> messageType, String message); void sendMessage(String flowName, Long instId, List<String> messageType, String message);
/**
* 发送消息
*
* @param messageType 消息类型
* @param message 消息内容
* @param subject 邮件标题
* @param userList 接收用户
*/
void sendMessage(List<String> messageType, String message, String subject, List<UserDTO> userList);
/** /**
* 申请人节点编码 * 申请人节点编码
* *

View File

@ -198,4 +198,12 @@ public interface IFlwTaskService {
* @return 节点 * @return 节点
*/ */
FlowNode getByNodeCode(String nodeCode, Long definitionId); FlowNode getByNodeCode(String nodeCode, Long definitionId);
/**
* 催办任务
*
* @param bo 参数
* @return 结果
*/
boolean urgeTask(FlowUrgeTaskBo bo);
} }

View File

@ -55,6 +55,19 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
if (CollUtil.isEmpty(userList)) { if (CollUtil.isEmpty(userList)) {
return; return;
} }
sendMessage(messageType, message, "单据审批提醒", userList);
}
/**
* 发送消息
*
* @param messageType 消息类型
* @param message 消息内容
* @param subject 邮件标题
* @param userList 接收用户
*/
@Override
public void sendMessage(List<String> messageType, String message, String subject, List<UserDTO> userList) {
for (String code : messageType) { for (String code : messageType) {
MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code); MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code);
if (ObjectUtil.isEmpty(messageTypeEnum)) { if (ObjectUtil.isEmpty(messageTypeEnum)) {
@ -68,7 +81,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
SseMessageUtils.publishMessage(dto); SseMessageUtils.publishMessage(dto);
} }
case EMAIL_MESSAGE -> { case EMAIL_MESSAGE -> {
MailUtils.sendText(StreamUtils.join(userList, UserDTO::getEmail), "单据审批提醒", message); MailUtils.sendText(StreamUtils.join(userList, UserDTO::getEmail), subject, message);
} }
case SMS_MESSAGE -> { case SMS_MESSAGE -> {
//todo 短信发送 //todo 短信发送
@ -76,7 +89,6 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
default -> throw new IllegalStateException("Unexpected value: " + messageTypeEnum); default -> throw new IllegalStateException("Unexpected value: " + messageTypeEnum);
} }
} }
} }

View File

@ -721,4 +721,28 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
.eq(FlowNode::getDefinitionId, definitionId)); .eq(FlowNode::getDefinitionId, definitionId));
} }
/**
* 催办任务
*
* @param bo 参数
*/
@Override
public boolean urgeTask(FlowUrgeTaskBo bo) {
try {
if (CollUtil.isEmpty(bo.getTaskIdList())) {
return false;
}
List<UserDTO> userList = this.currentTaskAllUser(bo.getTaskIdList());
if (CollUtil.isEmpty(userList)) {
return false;
}
List<String> messageType = bo.getMessageType();
String message = bo.getMessage();
flwCommonService.sendMessage(messageType, message, "单据审批提醒", userList);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
return true;
}
} }