diff --git a/dk-common/common-sse/src/main/java/org/dromara/common/sse/config/SseAutoConfiguration.java b/dk-common/common-sse/src/main/java/org/dromara/common/sse/config/SseAutoConfiguration.java index 0cf8054..81cdda2 100644 --- a/dk-common/common-sse/src/main/java/org/dromara/common/sse/config/SseAutoConfiguration.java +++ b/dk-common/common-sse/src/main/java/org/dromara/common/sse/config/SseAutoConfiguration.java @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Bean; * @author Lion Li */ @AutoConfiguration -@ConditionalOnProperty(value = "sse.enabled", havingValue = "true") +//@ConditionalOnProperty(value = "sse.enabled", havingValue = "true") @EnableConfigurationProperties(SseProperties.class) public class SseAutoConfiguration { diff --git a/dk-common/common-sse/src/main/java/org/dromara/common/sse/controller/SseController.java b/dk-common/common-sse/src/main/java/org/dromara/common/sse/controller/SseController.java index 41832fc..7f99f6f 100644 --- a/dk-common/common-sse/src/main/java/org/dromara/common/sse/controller/SseController.java +++ b/dk-common/common-sse/src/main/java/org/dromara/common/sse/controller/SseController.java @@ -21,7 +21,7 @@ import java.util.List; * @author Lion Li */ @RestController -@ConditionalOnProperty(value = "sse.enabled", havingValue = "true") +//@ConditionalOnProperty(value = "sse.enabled", havingValue = "true") @RequiredArgsConstructor public class SseController implements DisposableBean { @@ -30,7 +30,7 @@ public class SseController implements DisposableBean { /** * 建立 SSE 连接 */ - @GetMapping(value = "${sse.path}", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + @GetMapping(value = "/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE) public SseEmitter connect() { String tokenValue = StpUtil.getTokenValue(); Long userId = LoginHelper.getUserId(); @@ -40,7 +40,7 @@ public class SseController implements DisposableBean { /** * 关闭 SSE 连接 */ - @GetMapping(value = "${sse.path}/close") + @GetMapping(value = "/sse/close") public R close() { String tokenValue = StpUtil.getTokenValue(); Long userId = LoginHelper.getUserId(); @@ -54,7 +54,7 @@ public class SseController implements DisposableBean { * @param userId 目标用户的 ID * @param msg 要发送的消息内容 */ - @GetMapping(value = "${sse.path}/send") + @GetMapping(value = "/sse/send") public R send(Long userId, String msg) { SseMessageDto dto = new SseMessageDto(); dto.setUserIds(List.of(userId)); @@ -68,7 +68,7 @@ public class SseController implements DisposableBean { * * @param msg 要发送的消息内容 */ - @GetMapping(value = "${sse.path}/sendAll") + @GetMapping(value = "/sse/sendAll") public R send(String msg) { sseEmitterManager.publishAll(msg); return R.ok(); diff --git a/dk-common/common-sse/src/main/java/org/dromara/common/sse/listener/SseTopicListener.java b/dk-common/common-sse/src/main/java/org/dromara/common/sse/listener/SseTopicListener.java index 9adf1a1..ed4eeb1 100644 --- a/dk-common/common-sse/src/main/java/org/dromara/common/sse/listener/SseTopicListener.java +++ b/dk-common/common-sse/src/main/java/org/dromara/common/sse/listener/SseTopicListener.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Component; * @author Lion Li */ @Slf4j -@Component public class SseTopicListener implements ApplicationRunner, Ordered { @Autowired diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessPatrolAreasController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessPatrolAreasController.java index 20f6991..1e7107b 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessPatrolAreasController.java +++ b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessPatrolAreasController.java @@ -1,8 +1,6 @@ package org.dromara.business.controller; import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import org.dromara.business.domain.BusinessPatrolAreas; import org.dromara.business.domain.bo.BusinessPatrolAreasBo; @@ -75,11 +73,7 @@ public class BusinessPatrolAreasController extends BaseController { */ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) public R edit(@RequestBody BusinessPatrolAreas patrolAreas) { - boolean flag = patrolAreasService.updatePatrolAreas(patrolAreas); - if(flag){ - return R.ok("添加成功!"); - } - return R.fail("新增失败"); + return patrolAreasService.updatePatrolAreas(patrolAreas)?R.ok("添加成功!"):R.fail("添加失败"); } /** * 巡查区域-禁用/启用 @@ -89,11 +83,7 @@ public class BusinessPatrolAreasController extends BaseController { */ @RequestMapping(value = "/isDisable", method = {RequestMethod.PUT,RequestMethod.POST}) public R isDisable(@RequestBody BusinessPatrolAreas patrolAreas) { - boolean flag = patrolAreasService.updateById(patrolAreas); - if(flag){ - return R.ok("修改成功!"); - } - return R.fail("操作失败"); + return patrolAreasService.updateById(patrolAreas)?R.ok("修改成功!"):R.fail("修改失败"); } /** * 巡查区域-删除 @@ -103,11 +93,7 @@ public class BusinessPatrolAreasController extends BaseController { */ @DeleteMapping(value = "/delete") public R delete(String id) { - boolean flag = patrolAreasService.removeById(id); - if(flag){ - return R.ok("删除成功!"); - } - return R.fail("删除失败!"); + return patrolAreasService.removeById(id)?R.ok("删除成功!"):R.fail("删除失败!"); } /** * 导出excel diff --git a/dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java b/dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java index 251d98a..40414e5 100644 --- a/dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java +++ b/dk-modules/workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java @@ -187,8 +187,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService { // 执行任务跳转,并根据返回的处理人设置下一步处理人 Instance instance = taskService.skip(taskId, flowParams); this.setHandler(instance, flowTask, flowCopyList); - // 消息通知 - sendMessage(definition.getFlowName(), ins.getId(), messageType, notice); + // 待办消息通知 + WorkflowUtils.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice); return true; } catch (Exception e) { log.error(e.getMessage(), e); @@ -430,7 +430,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService { Instance instance = insService.getById(inst.getId()); this.setHandler(instance, task, null); // 消息通知 - sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); + WorkflowUtils.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); return true; } catch (Exception e) { log.error(e.getMessage(), e); @@ -733,51 +733,4 @@ public class FlwTaskServiceImpl implements IFlwTaskService { service.completeTask(completeTaskBo); } - /** - * 发送消息 - * @param flowName - * @param instId - * @param messageType - * @param message - */ - private void sendMessage(String flowName, Long instId, List messageType, String message) { - List userList = new ArrayList<>(); - List list = this.selectByInstId(instId); - - if (StringUtils.isBlank(message)) { - message = "有新的【" + flowName + "】单据已经提交至您,请您及时处理。"; - } - for (Task task : list) { - List 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); - } - } - } - } - } - }