Эх сурвалжийг харах

环境监测后端代码提交

xujie 1 жил өмнө
parent
commit
f941bc87fb

+ 7 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotAlarmDataAppController.java

@@ -67,4 +67,11 @@ public class IotAlarmDataAppController {
         TableDataInfo<IotAlarmDataVo> sensorAlarmList = this.iotAlarmDataService.selectSensorAlarmPageList(requestDto);
         return sensorAlarmList;
     }
+
+    @ApiOperation("环境监测角标")
+    @GetMapping({"/getEnvMonitorBadge/{orgId}"})
+    AjaxResult getEnvMonitorBadge(@PathVariable("orgId") Long orgId) {
+        Integer count = this.iotAlarmDataService.getEnvMonitorBadge(orgId);
+        return AjaxResult.success(count);
+    }
 }

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotAlarmDataService.java

@@ -34,5 +34,7 @@ public interface IotAlarmDataService extends IService<IotAlarmData> {
 
     Integer getFireWarningBadge(Long orgId);
 
+    Integer getEnvMonitorBadge(Long orgId);
+
     TableDataInfo<IotAlarmDataVo> selectSensorAlarmPageList(AppAlarmPageDto requestDto);
 }

+ 49 - 9
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java

@@ -140,15 +140,36 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         }
         List<DeviceTypeCountVo> list = baseMapper.selectDeviceTypeCount(requestDto);
         for (DeviceTypeCountVo vo : list) {
-            if (SensorTypeEnum.SMOKE.getType().equals(vo.getDeviceType())){
-                sensorAlarmCountVo.setSmokeCount(vo.getDeviceTypeCount());
-                sensorAlarmCountVo.setSmokeAlarmCount(vo.getDeviceTypeAlarmCount());
-            } else if (SensorTypeEnum.GAS.getType().equals(vo.getDeviceType())) {
-                sensorAlarmCountVo.setGasCount(vo.getDeviceTypeCount());
-                sensorAlarmCountVo.setGasAlarmCount(vo.getDeviceTypeAlarmCount());
-            } else if (SensorTypeEnum.TEMPERATURE_HUMIDITY.getType().equals(vo.getDeviceType())) {
-                sensorAlarmCountVo.setTemperatureAndHumidityCount(vo.getDeviceTypeCount());
-                sensorAlarmCountVo.setTemperatureAndHumidityAlarmCount(vo.getDeviceTypeAlarmCount());
+            String deviceType = vo.getDeviceType();
+            switch (deviceType){
+                case "4181"://红外
+                    sensorAlarmCountVo.setInfraredCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setInfraredAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "4182"://烟感
+                    sensorAlarmCountVo.setSmokeCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setSmokeAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "4183"://温湿度
+                    sensorAlarmCountVo.setTemperatureAndHumidityCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setTemperatureAndHumidityAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "4184"://水浸
+                    sensorAlarmCountVo.setWaterCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setWaterAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "4188"://门磁
+                    sensorAlarmCountVo.setDoorCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setDoorAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "41881"://防盗
+                    sensorAlarmCountVo.setThiefCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setThiefAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
+                case "41885"://燃气
+                    sensorAlarmCountVo.setGasCount(vo.getDeviceTypeCount());
+                    sensorAlarmCountVo.setGasAlarmCount(vo.getDeviceTypeAlarmCount());
+                    break;
             }
         }
         return sensorAlarmCountVo;
@@ -171,6 +192,25 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
     }
 
     @Override
+    public Integer getEnvMonitorBadge(Long orgId) {
+        AppAlarmPageDto pageDto = new AppAlarmPageDto();
+        pageDto.setCheckSub(false);
+        pageDto.setOrgId(orgId);
+        SensorAlarmCountVo alarmCountVo = this.selectDeviceTypeCount(pageDto);
+        if (alarmCountVo != null){
+            Integer thiefAlarmCount = alarmCountVo.getThiefAlarmCount() == null ? 0 : alarmCountVo.getThiefAlarmCount();
+            Integer infraredAlarmCount = alarmCountVo.getInfraredAlarmCount() == null ? 0 : alarmCountVo.getInfraredAlarmCount();
+            Integer doorAlarmCount = alarmCountVo.getDoorAlarmCount() == null ? 0 : alarmCountVo.getDoorAlarmCount();
+            Integer waterAlarmCount = alarmCountVo.getWaterAlarmCount() == null ? 0 : alarmCountVo.getWaterAlarmCount();
+            Integer upsAlarmCount = alarmCountVo.getUpsAlarmCount() == null ? 0 : alarmCountVo.getUpsAlarmCount();
+            Integer airAlarmCount = alarmCountVo.getAirAlarmCount() == null ? 0 : alarmCountVo.getAirAlarmCount();
+            Integer count = thiefAlarmCount + infraredAlarmCount + doorAlarmCount + waterAlarmCount + upsAlarmCount + airAlarmCount;
+            return count;
+        }
+        return 0;
+    }
+
+    @Override
     public TableDataInfo<IotAlarmDataVo> selectSensorAlarmPageList(AppAlarmPageDto requestDto) {
         Page<IotAlarmDataVo> page;
         //分页

+ 1 - 1
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml

@@ -127,7 +127,7 @@
         SELECT
             s.device_type AS deviceType,
             count(*) AS deviceTypeCount,
-            (select count(*) from iot_sensor where id = s.id and state = 1) as deviceTypeAlarmCount
+            (select count(*) from iot_sensor a where a.device_type = s.device_type and a.org_id = s.org_id and a.state = 1 ) as deviceTypeAlarmCount
         FROM
             iot_sensor s
         WHERE

+ 1 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

@@ -43,6 +43,7 @@
         <if test="request.deviceType!= null and request.deviceType!= ''">
             and s.device_type = #{request.deviceType}
         </if>
+        order by s.state desc
     </select>
     <select id="stateStatistic" resultType="com.xunmei.iot.vo.sensor.SensorAppStateVo">
         SELECT sum(state=0) as normal,