Quellcode durchsuchen

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

gao.qiang vor 2 Monaten
Ursprung
Commit
ac3f0c3acf

+ 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;
+}

+ 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();
 }

+ 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());
+    }
 }

+ 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>

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

@@ -1139,5 +1139,24 @@ public class BaseCameraManagementController extends BaseController {
     public void getDuration() {
         cameraUtil.getDuration("1");
     }
+
+
+    /**
+     * 首页设备状态
+     * @return
+     */
+    @GetMapping("cameraStateTotal")
+    public AjaxResult cameraStateTotal() {
+     return baseCameraManagementService.cameraStateTotal();
+    }
+
+    /**
+     * 首页设备状态列表
+     * @return
+     */
+    @GetMapping("cameraStateList")
+    public AjaxResult cameraStateList() {
+        return baseCameraManagementService.cameraStateList();
+    }
 }