Pārlūkot izejas kodu

设备状态和设备状态列表首页开发

gao.qiang 2 mēneši atpakaļ
vecāks
revīzija
41e7e0bf58

+ 13 - 0
business-service/src/main/java/com/ozs/service/entity/vo/AlarmCountSortVo.java

@@ -0,0 +1,13 @@
+package com.ozs.service.entity.vo;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class AlarmCountSortVo {
+    private Integer cameraCount;
+    private String cameraCode;
+    private String measurePointName;
+}

+ 13 - 0
business-service/src/main/java/com/ozs/service/entity/vo/CameraStateList.java

@@ -0,0 +1,13 @@
+package com.ozs.service.entity.vo;
+
+import lombok.Data;
+
+/**
+ * @author Administrator
+ */
+@Data
+public class CameraStateList {
+    private String deptName;
+    private Integer totalCameraCount;
+    private Integer filteredCameraCount;
+}

+ 4 - 4
business-service/src/main/java/com/ozs/service/mapper/BaseCameraManagementMapper.java

@@ -3,10 +3,8 @@ package com.ozs.service.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.entity.MsgAlarm;
-import com.ozs.service.entity.vo.BaseCameraManagementHomeVo;
-import com.ozs.service.entity.vo.BaseCameraManagementVo;
-import com.ozs.service.entity.vo.DeviceStateResp;
-import com.ozs.service.entity.vo.MsgAlarmVo;
+import com.ozs.service.entity.vo.*;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -31,4 +29,6 @@ public interface BaseCameraManagementMapper extends BaseMapper<BaseCameraManagem
     Map<String, Object> getCameraChannelByAlarmId(@Param("alarmId") String alarmId);
 
     List<DeviceStateResp> deviceStatePage(DeviceStateResp deviceStateResp);
+
+    List<AlarmCountSortVo> alarmCountSort();
 }

+ 3 - 0
business-service/src/main/java/com/ozs/service/mapper/BaseRailwayManagementMapper.java

@@ -2,6 +2,7 @@ package com.ozs.service.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ozs.service.entity.BaseRailwayManagement;
+import com.ozs.service.entity.vo.CameraStateList;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -21,4 +22,6 @@ public interface BaseRailwayManagementMapper extends BaseMapper<BaseRailwayManag
     String getCameraNameByCameraCode(@Param("cameraCode") String cameraCode);
 
     List<BaseRailwayManagement> listRailway();
+
+    List<CameraStateList> cameraStateList();
 }

+ 4 - 0
business-service/src/main/java/com/ozs/service/service/BaseCameraManagementService.java

@@ -47,4 +47,8 @@ public interface BaseCameraManagementService extends IService<BaseCameraManageme
     IPage<DeviceStateResp> deviceStatePage(DeviceStateResp deviceStateResp);
 
     List<DeviceStateResp> deviceStateRespList(DeviceStateResp deviceStateResp);
+
+    AjaxResult cameraStateTotal();
+
+    AjaxResult cameraStateList();
 }

+ 6 - 0
business-service/src/main/java/com/ozs/service/service/MsgAlarmService.java

@@ -1,6 +1,7 @@
 package com.ozs.service.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.entity.MsgAlarm;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -9,6 +10,7 @@ import com.ozs.service.entity.vo.*;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -59,4 +61,8 @@ public interface MsgAlarmService extends IService<MsgAlarm> {
     void initializationCameraCache();
 
     BaseCameraManagement getBaseCameraManagementByCamereCode(String camereCode);
+
+    AjaxResult alarmStatistics();
+
+    AjaxResult alarmCountSort();
 }

+ 52 - 0
business-service/src/main/java/com/ozs/service/service/impl/BaseCameraManagementServiceImpl.java

@@ -59,6 +59,8 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
     private CameraLogDetailMapper cameraLogDetailMapper;
     @Autowired
     private CameraUpdateLogMapper cameraUpdateLogMapper;
+    @Autowired
+    private BaseRailwayManagementMapper baseRailwayManagementMapper;
 
     /**
      * 相机台账管理表导入
@@ -347,4 +349,54 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
     public List<DeviceStateResp> deviceStateRespList(DeviceStateResp deviceStateResp) {
         return baseCameraManagementMapper.deviceStatePage(deviceStateResp);
     }
+
+    @Override
+    public AjaxResult cameraStateTotal() {
+        int count;
+        int unresolvedCount;
+        //找出所有相机数据
+        List<BaseCameraManagement> list = this.list();
+        //异常的相机
+        List<BaseDeviceDynamicManagement> alarmList = baseDeviceDynamicManagementMapper.selectList(new LambdaQueryWrapper<BaseDeviceDynamicManagement>()
+                .eq(BaseDeviceDynamicManagement::getIsDisable, 2)
+                .or().le(BaseDeviceDynamicManagement::getElectricity,10));
+        HashMap<String, Integer> map = new HashMap<>();
+        if (!ObjectUtils.isEmpty(list)) {
+            //找出所有相机数据
+            //找出所有相机数据 1=高铁的数量
+            count = (int) list.stream()
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int pu = list.size() - count;
+            map.put("highCount", count);
+            map.put("puCount", pu);
+        }
+        if (!ObjectUtils.isEmpty(alarmList)) {
+            //获取所有异常的相机
+            //找出所有异常的相机 1=高铁的数量
+            unresolvedCount = (int) alarmList.stream()
+                    .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                            .eq(BaseCameraManagement::getCameraCode, base)))
+                    .filter(Objects::nonNull)
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int puUnresolvedCount = alarmList.size() - unresolvedCount;
+            map.put("highStateCount", unresolvedCount);
+            map.put("puStateCount", puUnresolvedCount);
+        }
+        return AjaxResult.success(map);
+    }
+
+    @Override
+    public AjaxResult cameraStateList() {
+        return AjaxResult.success(baseRailwayManagementMapper.cameraStateList());
+    }
 }

+ 60 - 0
business-service/src/main/java/com/ozs/service/service/impl/MsgAlarmServiceImpl.java

@@ -1,14 +1,18 @@
 package com.ozs.service.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.ozs.common.constant.Constants;
+import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.BaseRailwayManagement;
 import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.*;
 import com.ozs.service.mapper.BaseCameraManagementMapper;
+import com.ozs.service.mapper.BaseRailwayManagementMapper;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.MsgAlarmService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -17,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -38,6 +43,9 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
     private BaseCameraManagementMapper baseCameraManagementMapper;
     @Autowired
     private RedisService redisService;
+    @Autowired
+    private BaseRailwayManagementMapper baseRailwayManagementMapper;
+
 
     public IPage listToPage(List list, int pageNum, int pageSize) {
         List pageList = new ArrayList<>();
@@ -225,4 +233,56 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i
         BaseCameraManagement baseCameraManagement = baseCameraManagementMapper.selectOne(queryWrapper);
         return baseCameraManagement;
     }
+
+    @Override
+    public AjaxResult alarmStatistics() {
+        int count;
+        int unresolvedCount;
+        //找出所有报警数据
+        List<MsgAlarm> list = this.list();
+        //未解除的报警
+        List<MsgAlarm> alarmList = this.list(new LambdaQueryWrapper<MsgAlarm>()
+                .eq(MsgAlarm::getIsLock, 1));
+        HashMap<String, Integer> map = new HashMap<>();
+        if (!ObjectUtils.isEmpty(list)) {
+            //获取所有报警的相机编码
+            //找出所有报警数据 1=高铁的数量
+            count = (int) list.stream()
+                    .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                            .eq(BaseCameraManagement::getCameraCode, base)))
+                    .filter(Objects::nonNull)  // 确保 management 不是 null
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int pu = list.size() - count;
+            map.put("highAlarmCount", count);
+            map.put("puAlarmCount", pu);
+        }
+        if (!ObjectUtils.isEmpty(alarmList)) {
+            //获取所有报警的相机编码
+            //找出所有已解除报警数据 1=高铁的数量
+            unresolvedCount = (int) alarmList.stream()
+                    .map(base -> baseCameraManagementMapper.selectOne(new LambdaQueryWrapper<BaseCameraManagement>()
+                            .eq(BaseCameraManagement::getCameraCode, base)))
+                    .filter(Objects::nonNull)
+                    .map(management -> baseRailwayManagementMapper.selectOne(new LambdaQueryWrapper<BaseRailwayManagement>()
+                            .eq(BaseRailwayManagement::getRailwayCode, management.getRailwayCode()))) // 确保管理信息不是空的
+                    .filter(Objects::nonNull) // 确保 baseRailwayManagement 不是 null
+                    .filter(baseRailwayManagement -> baseRailwayManagement.getRailwayType() == 1)
+                    .count();
+            //普铁的数量
+            int puUnresolvedCount = alarmList.size() - unresolvedCount;
+            map.put("highUnresolvedCount", unresolvedCount);
+            map.put("puUnresolvedCount", puUnresolvedCount);
+        }
+        return AjaxResult.success(map);
+    }
+
+    @Override
+    public AjaxResult alarmCountSort() {
+        return AjaxResult.success(baseCameraManagementMapper.alarmCountSort());
+    }
 }

+ 0 - 1
business-service/src/main/java/com/ozs/service/utils/PublishClient.java

@@ -183,7 +183,6 @@ public class PublishClient {
                 res.put("sign", "rate" + IdUtils.fastSimpleUUID());
                 map.put("codec",codec);
                 res.put("data", map);
-                res.put("sign", "cien" + IdUtils.fastSimpleUUID());
                 String s = JSONObject.toJSONString(res);
 
                 MqttMessage message = new MqttMessage();

+ 6 - 0
business-service/src/main/resources/mapper/service/BaseCameraManagementMapper.xml

@@ -197,4 +197,10 @@
         ORDER BY man.is_disable DESC,
         man.electricity
     </select>
+    <select id="alarmCountSort" resultType="com.ozs.service.entity.vo.AlarmCountSortVo">
+        SELECT COUNT(m.camera_code) AS cameraCount,c.camera_code AS cameraCode,c.measure_point_name AS measurePointName
+        FROM msg_alarm  m JOIN base_camera_management  c ON m.camera_code=c.camera_code
+        GROUP BY m.camera_code
+        ORDER BY cameraCount DESC
+    </select>
 </mapper>

+ 16 - 0
business-service/src/main/resources/mapper/service/BaseRailwayManagementMapper.xml

@@ -13,4 +13,20 @@
             (select * from base_railway_management) c on b.railway_code = c.railway_code
         group by c.railway_code, a.dept_id
     </select>
+    <select id="cameraStateList" resultType="com.ozs.service.entity.vo.CameraStateList">
+    SELECT
+    s.dept_name AS deptName,
+    COUNT(c.dept_id) AS totalCameraCount,
+    COUNT(CASE
+    WHEN b.is_disable = 2 OR b.electricity &lt;= 10 THEN 1
+    END) AS filteredCameraCount
+    FROM
+    base_camera_management c
+    JOIN
+    sys_dept s ON c.dept_id = s.dept_id
+    LEFT JOIN
+    base_device_dynamic_management b ON c.camera_code = b.camera_code
+    GROUP BY
+    c.dept_id, s.dept_name;
+    </select>
 </mapper>

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

@@ -49,9 +49,12 @@ import javax.validation.constraints.NotNull;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static net.sf.jsqlparser.parser.feature.Feature.update;
+
 /**
  * <p>
  * 相机台账管理表 前端控制器
@@ -1127,5 +1130,26 @@ public class BaseCameraManagementController extends BaseController {
             return AjaxResult.error();
         }
     }
+
+
+
+
+    /**
+     * 首页设备状态
+     * @return
+     */
+    @GetMapping("cameraStateTotal")
+    public AjaxResult cameraStateTotal() {
+     return baseCameraManagementService.cameraStateTotal();
+    }
+
+    /**
+     * 首页设备状态列表
+     * @return
+     */
+    @GetMapping("cameraStateList")
+    public AjaxResult cameraStateList() {
+        return baseCameraManagementService.cameraStateList();
+    }
 }
 

+ 15 - 0
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -13,6 +13,7 @@ import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.common.core.domain.entity.SysDictType;
 import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.common.core.domain.model.LoginUser;
+import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.enums.BusinessType;
 import com.ozs.common.utils.AppendUtils;
 import com.ozs.common.utils.StringUtils;
@@ -827,5 +828,19 @@ public class MsgAlarmController extends BaseController {
         ExcelUtil<AlarmStatisticMonthDto> util = new ExcelUtil<>(AlarmStatisticMonthDto.class);
         util.exportExcel(response, list, sheetName);
     }
+
+
+    @GetMapping(value = "/alarmStatistics")
+    @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
+    public AjaxResult alarmStatistics() {
+      return   msgAlarmService.alarmStatistics();
+    }
+
+    @GetMapping(value = "/alarmCountSort")
+    @Log(title = "报警信息管理", businessType = BusinessType.SELECT)
+    public AjaxResult alarmCountSort() {
+        return   msgAlarmService.alarmCountSort();
+    }
+
 }