|
@ -52,6 +52,8 @@ import org.dromara.workflow.mapper.FlwCategoryMapper; |
|
|
import org.dromara.workflow.mapper.FlwTaskMapper; |
|
|
import org.dromara.workflow.mapper.FlwTaskMapper; |
|
|
import org.dromara.workflow.service.IFlwTaskService; |
|
|
import org.dromara.workflow.service.IFlwTaskService; |
|
|
import org.dromara.workflow.utils.WorkflowUtils; |
|
|
import org.dromara.workflow.utils.WorkflowUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -93,6 +95,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
@DubboReference(stub = "true") |
|
|
@DubboReference(stub = "true") |
|
|
private final RemoteMessageService remoteMessageService; |
|
|
private final RemoteMessageService remoteMessageService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ApplicationContext applicationContext; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 启动任务 |
|
|
* 启动任务 |
|
|
* |
|
|
* |
|
@ -139,6 +144,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn(); |
|
|
RemoteStartProcessReturn dto = new RemoteStartProcessReturn(); |
|
|
dto.setProcessInstanceId(instance.getId()); |
|
|
dto.setProcessInstanceId(instance.getId()); |
|
|
dto.setTaskId(taskList.get(0).getId()); |
|
|
dto.setTaskId(taskList.get(0).getId()); |
|
|
|
|
|
|
|
|
|
|
|
//创建任务
|
|
|
|
|
|
executeTask(taskList.get(0).getId()); |
|
|
return dto; |
|
|
return dto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -188,46 +196,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void sendMessage(String flowName, Long instId, List<String> messageType, String message) { |
|
|
|
|
|
List<RemoteUserVo> userList = new ArrayList<>(); |
|
|
|
|
|
List<FlowTask> list = this.selectByInstId(instId); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(message)) { |
|
|
|
|
|
message = "有新的【" + flowName + "】单据已经提交至您,请您及时处理。"; |
|
|
|
|
|
} |
|
|
|
|
|
for (Task task : list) { |
|
|
|
|
|
List<RemoteUserVo> users = this.currentTaskAllUser(task.getId()); |
|
|
|
|
|
if (CollUtil.isNotEmpty(users)) { |
|
|
|
|
|
userList.addAll(users); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(userList)) { |
|
|
|
|
|
for (String code : messageType) { |
|
|
|
|
|
MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(messageTypeEnum)) { |
|
|
|
|
|
switch (messageTypeEnum) { |
|
|
|
|
|
case SYSTEM_MESSAGE: |
|
|
|
|
|
SseMessageDto dto = new SseMessageDto(); |
|
|
|
|
|
dto.setUserIds(StreamUtils.toList(userList, RemoteUserVo::getUserId).stream().distinct().collect(Collectors.toList())); |
|
|
|
|
|
dto.setMessage(message); |
|
|
|
|
|
dto.getUserIds().forEach(userId -> { |
|
|
|
|
|
remoteMessageService.publishMessage(userId,dto.getMessage()); |
|
|
|
|
|
}); |
|
|
|
|
|
break; |
|
|
|
|
|
case EMAIL_MESSAGE: |
|
|
|
|
|
MailUtils.sendText(StreamUtils.join(userList, RemoteUserVo::getEmail), "单据审批提醒", message); |
|
|
|
|
|
break; |
|
|
|
|
|
case SMS_MESSAGE: |
|
|
|
|
|
//todo 短信发送
|
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new IllegalStateException("Unexpected value: " + messageTypeEnum); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 设置办理人 |
|
|
* 设置办理人 |
|
|
* |
|
|
* |
|
@ -319,12 +287,23 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
public TableDataInfo<FlowTaskVo> pageByTaskWait(FlowTaskBo flowTaskBo, PageQuery pageQuery) { |
|
|
public TableDataInfo<FlowTaskVo> pageByTaskWait(FlowTaskBo flowTaskBo, PageQuery pageQuery) { |
|
|
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo); |
|
|
QueryWrapper<FlowTaskBo> queryWrapper = buildQueryWrapper(flowTaskBo); |
|
|
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey()); |
|
|
queryWrapper.eq("t.node_type", NodeType.BETWEEN.getKey()); |
|
|
queryWrapper.in("t.processed_by", SpringUtils.getBean(WorkflowPermissionHandler.class).permissions()); |
|
|
queryWrapper.in("t.processed_by", this.getPermissions()); |
|
|
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); |
|
|
queryWrapper.in("t.flow_status", BusinessStatusEnum.WAITING.getStatus()); |
|
|
Page<FlowTaskVo> page = this.getFlowTaskVoPage(pageQuery, queryWrapper); |
|
|
Page<FlowTaskVo> page = this.getFlowTaskVoPage(pageQuery, queryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TableDataInfo.build(page); |
|
|
return TableDataInfo.build(page); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 审批前获取当前办理人,办理时会校验的该权限集合 |
|
|
|
|
|
* 返回当前用户权限集合 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<String> getPermissions() { |
|
|
|
|
|
return SpringUtils.getBean(WorkflowPermissionHandler.class).permissions(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询当前用户的已办任务 |
|
|
* 查询当前用户的已办任务 |
|
|
* |
|
|
* |
|
@ -341,6 +320,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
return TableDataInfo.build(page); |
|
|
return TableDataInfo.build(page); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询待办任务 |
|
|
* 查询待办任务 |
|
|
* |
|
|
* |
|
@ -405,6 +385,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
wrapper.like(StringUtils.isNotBlank(flowTaskBo.getFlowName()), "t.flow_name", flowTaskBo.getFlowName()); |
|
|
wrapper.like(StringUtils.isNotBlank(flowTaskBo.getFlowName()), "t.flow_name", flowTaskBo.getFlowName()); |
|
|
wrapper.like(StringUtils.isNotBlank(flowTaskBo.getFlowCode()), "t.flow_code", flowTaskBo.getFlowCode()); |
|
|
wrapper.like(StringUtils.isNotBlank(flowTaskBo.getFlowCode()), "t.flow_code", flowTaskBo.getFlowCode()); |
|
|
wrapper.in(CollUtil.isNotEmpty(flowTaskBo.getCreateByIds()), "t.create_by", flowTaskBo.getCreateByIds()); |
|
|
wrapper.in(CollUtil.isNotEmpty(flowTaskBo.getCreateByIds()), "t.create_by", flowTaskBo.getCreateByIds()); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(flowTaskBo.getBusinessId())){ |
|
|
|
|
|
wrapper.eq("i.business_id", flowTaskBo.getBusinessId()); |
|
|
|
|
|
} |
|
|
if (StringUtils.isNotBlank(flowTaskBo.getCategory())) { |
|
|
if (StringUtils.isNotBlank(flowTaskBo.getCategory())) { |
|
|
List<Long> categoryIds = flwCategoryMapper.selectCategoryIdsByParentId(Convert.toLong(flowTaskBo.getCategory())); |
|
|
List<Long> categoryIds = flwCategoryMapper.selectCategoryIdsByParentId(Convert.toLong(flowTaskBo.getCategory())); |
|
|
wrapper.in("t.category", StreamUtils.toList(categoryIds, Convert::toStr)); |
|
|
wrapper.in("t.category", StreamUtils.toList(categoryIds, Convert::toStr)); |
|
@ -737,4 +720,64 @@ public class FlwTaskServiceImpl implements IFlwTaskService { |
|
|
} |
|
|
} |
|
|
return remoteUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy()))); |
|
|
return remoteUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy()))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 初始化流程任务 |
|
|
|
|
|
* @param taskId |
|
|
|
|
|
*/ |
|
|
|
|
|
public void executeTask(Long taskId) { |
|
|
|
|
|
CompleteTaskBo completeTaskBo = new CompleteTaskBo(); |
|
|
|
|
|
completeTaskBo.setTaskId(taskId); |
|
|
|
|
|
completeTaskBo.setMessageType(List.of(MessageTypeEnum.SYSTEM_MESSAGE.getCode())); |
|
|
|
|
|
IFlwTaskService service = applicationContext.getBean(IFlwTaskService.class); |
|
|
|
|
|
service.completeTask(completeTaskBo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 发送消息 |
|
|
|
|
|
* @param flowName |
|
|
|
|
|
* @param instId |
|
|
|
|
|
* @param messageType |
|
|
|
|
|
* @param message |
|
|
|
|
|
*/ |
|
|
|
|
|
private void sendMessage(String flowName, Long instId, List<String> messageType, String message) { |
|
|
|
|
|
List<RemoteUserVo> userList = new ArrayList<>(); |
|
|
|
|
|
List<FlowTask> list = this.selectByInstId(instId); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(message)) { |
|
|
|
|
|
message = "有新的【" + flowName + "】单据已经提交至您,请您及时处理。"; |
|
|
|
|
|
} |
|
|
|
|
|
for (Task task : list) { |
|
|
|
|
|
List<RemoteUserVo> users = this.currentTaskAllUser(task.getId()); |
|
|
|
|
|
if (CollUtil.isNotEmpty(users)) { |
|
|
|
|
|
userList.addAll(users); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(userList)) { |
|
|
|
|
|
for (String code : messageType) { |
|
|
|
|
|
MessageTypeEnum messageTypeEnum = MessageTypeEnum.getByCode(code); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(messageTypeEnum)) { |
|
|
|
|
|
switch (messageTypeEnum) { |
|
|
|
|
|
case SYSTEM_MESSAGE: |
|
|
|
|
|
SseMessageDto dto = new SseMessageDto(); |
|
|
|
|
|
dto.setUserIds(StreamUtils.toList(userList, RemoteUserVo::getUserId).stream().distinct().collect(Collectors.toList())); |
|
|
|
|
|
dto.setMessage(message); |
|
|
|
|
|
dto.getUserIds().forEach(userId -> { |
|
|
|
|
|
remoteMessageService.publishMessage(userId,dto.getMessage()); |
|
|
|
|
|
}); |
|
|
|
|
|
break; |
|
|
|
|
|
case EMAIL_MESSAGE: |
|
|
|
|
|
MailUtils.sendText(StreamUtils.join(userList, RemoteUserVo::getEmail), "单据审批提醒", message); |
|
|
|
|
|
break; |
|
|
|
|
|
case SMS_MESSAGE: |
|
|
|
|
|
//todo 短信发送
|
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new IllegalStateException("Unexpected value: " + messageTypeEnum); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|