浏览代码

web消息推送

gao.qiang 1 年之前
父节点
当前提交
75d06d5445

+ 6 - 0
business-service/src/main/java/com/ozs/service/entity/vo/MsgAlarmResp.java

@@ -79,4 +79,10 @@ public class MsgAlarmResp implements Serializable {
      */
     private String cameraCode;
 
+    /**
+     * 报警时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date alarmTime;
+
 }

+ 28 - 24
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -471,31 +471,35 @@ public class BaseCameraManagementController extends BaseController {
             queryWrapper.orderByDesc(MsgAlarm::getCreateTime);
         }
         List<MsgAlarm> msgAlarmList = msgAlarmService.list(queryWrapper);
-        MsgAlarm msgAlarm = msgAlarmList.get(0);
-        LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
-        if (!ObjectUtils.isEmpty(cameraCode)) {
-            lw.eq(BaseCameraManagement::getCameraCode, cameraCode);
-        }
-        BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(lw);
-        LambdaQueryWrapper<BaseRailwayManagement> wrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
-        if (!ObjectUtils.isEmpty(baseCameraManagement.getRailwayCode())) {
-            wrapper.eq(BaseRailwayManagement::getRailwayCode, baseCameraManagement.getRailwayCode());
+        if (msgAlarmList.size()>0) {
+            MsgAlarm msgAlarm = msgAlarmList.get(0);
+            LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
+            if (!ObjectUtils.isEmpty(cameraCode)) {
+                lw.eq(BaseCameraManagement::getCameraCode, cameraCode);
+            }
+            BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(lw);
+            LambdaQueryWrapper<BaseRailwayManagement> wrapper = new LambdaQueryWrapper<BaseRailwayManagement>();
+            if (!ObjectUtils.isEmpty(baseCameraManagement.getRailwayCode())) {
+                wrapper.eq(BaseRailwayManagement::getRailwayCode, baseCameraManagement.getRailwayCode());
+            }
+            BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(wrapper);
+            MsgAlarmResp msgAlarmResp = new MsgAlarmResp();
+            BeanUtils.copyProperties(msgAlarm, msgAlarmResp);
+            msgAlarmResp.setRailwayName(baseRailwayManagement.getRailwayName());
+            msgAlarmResp.setDeptId(baseCameraManagement.getDeptId());
+            String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
+            String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
+            String endMile = begin + end;
+            msgAlarmResp.setBeginMile(endMile);
+            String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
+            msgAlarmResp.setAlarmMile(mile);
+            msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
+            msgAlarmResp.setLineDir(baseCameraManagement.getLineDir());
+            msgAlarmResp.setAlarmMile(baseCameraManagement.getInstallMile().toString());
+            return AjaxResult.success(msgAlarmResp);
+        }else {
+            return  error("该相机没有报警消息");
         }
-        BaseRailwayManagement baseRailwayManagement = baseRailwayManagementService.getOne(wrapper);
-        MsgAlarmResp msgAlarmResp = new MsgAlarmResp();
-        BeanUtils.copyProperties(msgAlarm, msgAlarmResp);
-        msgAlarmResp.setRailwayName(baseRailwayManagement.getRailwayName());
-        msgAlarmResp.setDeptId(baseCameraManagement.getDeptId());
-        String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
-        String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
-        String endMile = begin + end;
-        msgAlarmResp.setBeginMile(endMile);
-        String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
-        msgAlarmResp.setAlarmMile(mile);
-        msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
-        msgAlarmResp.setLineDir(baseCameraManagement.getLineDir());
-        msgAlarmResp.setAlarmMile(baseCameraManagement.getInstallMile().toString());
-        return AjaxResult.success(msgAlarmResp);
     }
 }
 

+ 14 - 2
hazard-admin/src/main/java/com/ozs/web/controller/websocket/WebSocketConteoller.java

@@ -1,15 +1,19 @@
 package com.ozs.web.controller.websocket;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.utils.AppendUtils;
 import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.MsgAlarmResp;
+import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.service.service.BaseRailwayManagementService;
 import com.ozs.service.service.BaseUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -30,19 +34,27 @@ public class WebSocketConteoller extends BaseController {
     private BaseUserService baseUserService;
     @Resource
     private BaseRailwayManagementService baseRailwayManagementService;
+    @Autowired
+    private BaseCameraManagementService baseCameraManagementService;
 
     @ResponseBody
     @PostMapping("/publish")
-    public Map publish(@RequestBody BaseCameraManagement baseCameraManagement) {
+    public Map publish(@RequestBody MsgAlarm msgAlarm) {
+        LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<BaseCameraManagement>();
+        if (!ObjectUtils.isEmpty(msgAlarm.getCameraCode())) {
+            wrapper.eq(BaseCameraManagement::getCameraCode, msgAlarm.getCameraCode());
+        }
+        BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(wrapper);
         // 获取推送人ID列表
         Set<String> set = baseUserService.getUserIdList(baseCameraManagement.getCreateBy(), baseCameraManagement.getDeptId());
-        // List<String> list = new ArrayList<>(set);
         String[] list = set.toArray(new String[set.size()]);
         MsgAlarmResp msgAlarmResp = new MsgAlarmResp();
         String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
         String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
         String endMile = begin + "-" + end;
         msgAlarmResp.setBeginMile(endMile);
+        msgAlarmResp.setAlarmType(msgAlarm.getAlarmType());
+        msgAlarmResp.setAlarmTime(msgAlarm.getAlarmTime());
         String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
         msgAlarmResp.setAlarmMile(mile);
         String cameraCode = baseCameraManagement.getCameraCode();

二进制
hazard-admin/src/main/resources/template/SysUser.xlsx


+ 8 - 0
hazard-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -8,6 +8,7 @@ import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.common.utils.ApiTokenUtils;
 import com.ozs.common.utils.AppTokenUtils;
 import com.ozs.common.utils.AppendUtils;
+import com.ozs.common.utils.HttpClientUtil;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.stateSecrets.SM4Utils;
 import com.ozs.jpush.JPushUtil;
@@ -202,6 +203,13 @@ public class GeoHazardMonitorTokenController {
                 }
                 respMsgAlarmVo.setCancelTime(null);
             }
+            String url = "http://localhost:18819/hazard/sdk/publish";
+            try {
+                String result = HttpClientUtil.postJson(url, JSON.toJSONString(alarm));
+            } catch (Exception e) {
+                log.info(e.getMessage());
+                e.printStackTrace();
+            }
             jsonObject.put("resultCode", 1);
             jsonObject.put("message", "成功");
             jsonObject.put("data", respMsgAlarmVo);