From f59f1401ea6d6527c34787fa3bd4f7f00ac54b13 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 26 Aug 2024 18:10:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=BD=AE=E6=B5=81?= =?UTF-8?q?=E7=A8=8Bwebsocket=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/websocket/constant/WebSocketEvent.java | 2 ++ .../business/controller/CodeScanningAlarmController.java | 5 ++++- .../business/service/impl/DcEventProcessServiceImpl.java | 9 ++++++++- .../zc/business/service/impl/DcWarningServiceImpl.java | 3 +++ .../resources/mapper/business/DcEventProcessMapper.xml | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java b/ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java index 85a10ec6..3b2e1080 100644 --- a/ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java +++ b/ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java @@ -16,5 +16,7 @@ public class WebSocketEvent { //设备状态 public static final String DEVICE_STATE = "deviceState"; + //处置记录 + public static final String EVENT_PROCESS = "eventProcess"; } diff --git a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java b/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java index c1074bce..c6efb42d 100644 --- a/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java +++ b/zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java @@ -10,6 +10,8 @@ import com.zc.business.domain.DcWarning; import com.zc.business.enums.UniversalEnum; import com.zc.business.mapper.DcEventProcessMapper; import com.zc.business.service.IDcWarningService; +import com.zc.common.core.websocket.WebSocketService; +import com.zc.common.core.websocket.constant.WebSocketEvent; import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -156,7 +158,8 @@ public class CodeScanningAlarmController extends BaseController { dcEventProcess.setOperationTime(new Date()); dcEventProcessMapper.insertDcEventProcess(dcEventProcess); - + //websocket推送 + WebSocketService.broadcast(WebSocketEvent.EVENT_PROCESS, dcEventProcess); return AjaxResult.success("添加成功"); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java index bddefec7..41c09e26 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java @@ -10,6 +10,8 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.MimeTypeUtils; import com.zc.business.domain.DcEvent; +import com.zc.common.core.websocket.WebSocketService; +import com.zc.common.core.websocket.constant.WebSocketEvent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zc.business.mapper.DcEventProcessMapper; @@ -84,7 +86,12 @@ public class DcEventProcessServiceImpl implements IDcEventProcessService dcEventProcess.setOperationTime(new Date()); dcEventProcess.setOperator(SecurityUtils.getUserId().toString()); dcEventProcess.setOperatorName(SecurityUtils.getLoginUser().getUser().getNickName()); - return dcEventProcessMapper.insertDcEventProcess(dcEventProcess); + int i = dcEventProcessMapper.insertDcEventProcess(dcEventProcess); + + //websocket推送 + WebSocketService.broadcast(WebSocketEvent.EVENT_PROCESS, dcEventProcess); + + return i; } /** diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index 9acd6326..6177fa35 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -295,6 +295,9 @@ public class DcWarningServiceImpl implements IDcWarningService { dcEventProcess.setOperationTime(new Date()); dcEventProcessMapper.insertDcEventProcess(dcEventProcess); + //websocket推送 + WebSocketService.broadcast(WebSocketEvent.EVENT_PROCESS, dcEventProcess); + } extracted(dcWarning); diff --git a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml index a36f18d7..af2b218e 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml @@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into dc_event_process id,