Browse Source

事件处置流程websocket推送

develop
lau572 3 months ago
parent
commit
f59f1401ea
  1. 2
      ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java
  2. 5
      zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java
  3. 9
      zc-business/src/main/java/com/zc/business/service/impl/DcEventProcessServiceImpl.java
  4. 3
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  5. 2
      zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

2
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";
}

5
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("添加成功");
}

9
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;
}
/**

3
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);

2
zc-business/src/main/resources/mapper/business/DcEventProcessMapper.xml

@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<insert id="insertDcEventProcess" parameterType="DcEventProcess">
<insert id="insertDcEventProcess" parameterType="DcEventProcess" useGeneratedKeys="true" keyProperty="id">
insert into dc_event_process
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>

Loading…
Cancel
Save