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

报警主机传感器相关功能代码修改

jingyuanchao 1 жил өмнө
parent
commit
0fa0205906

+ 5 - 1
project_data/sql/0.1.1/soc/soc.sql

@@ -1059,7 +1059,11 @@ INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `s
 INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (158, 408, 'UPS', '408_4', '电池容量', 'batteryCapacity', '{}', '{}', 'FLOAT', '浮点型', '%', 1, NULL, NULL, NULL, NULL);
 INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (159, 408, 'UPS', '408_5', '电池剩余备用时间', 'batteryRemainingStandbyTime', '{}', '{}', 'FLOAT', '浮点型', 's', 1, NULL, NULL, NULL, NULL);
 INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (160, 408, 'UPS', '408_6', '电池电压低告警', 'lowBatteryVoltageAlarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
-INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (161, 4186, '8小时回路', '4186', '8小时回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
+INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (161, 4186, '回路', '4186', '回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
+INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (162, 41861, 'DO8小时控电箱按钮', '41861', 'DO8小时控电箱按钮', 'status', '{\"0\": \"弹起\",\"1\": \"按下\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
+INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (163, 41860001, '8小时回路通电状态', '41860001', '8小时回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
+INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (164, 41860002, '24小时回路缺相状态', '41860002', '24小时回路缺相状态', 'status', '{\"0\": \"缺相\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
+
 -- 报警主机传感器 --
 INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (500, '湿度(报警主机)', 'AlarmHostInput_Humidity', '湿度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
 INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (500, '温度(报警主机)', 'AlarmHostInput_Temperature', '温度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);

+ 2 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/iot/SensorType.java

@@ -35,6 +35,8 @@ public enum SensorType {
 
     DO_POWER_CONTROL(41861, "DO8小时控电", "FSU_DoPowerControl"),
     DO_POWER_COLLECTION(4186, "DO8小时采集", "FSU_DoPowerCollection"),
+    DO_POWER_COLLECTION8(41860001, "8小时回路通电状态", "FSU_DoPowerCollection"),
+    DO_POWER_COLLECTION24(41860002, "24小时回路缺相状态", "FSU_DoPowerCollection"),
     DO_POWER_BOX_BUTTON(4185, "DO8小时电箱按钮", "FSU_DoPowerControlBoxButton"),
 
     //待确认

+ 5 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/sensor/SensorAppPageDto.java

@@ -4,7 +4,7 @@ import com.xunmei.common.core.web.domain.PageRequest;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.util.Date;
+import java.util.List;
 
 /**
  * @author jingyuanchao
@@ -17,4 +17,8 @@ public class SensorAppPageDto extends PageRequest {
 
     @ApiModelProperty(value = "告警状态,0:正常,1:告警")
     private Integer state;
+
+    @ApiModelProperty(value = "报警主机传感器设备类型")
+    private List<String> defenceAreaType;
+
 }

+ 18 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotAlarmDefenceAreaMapper.java

@@ -0,0 +1,18 @@
+package com.xunmei.iot.mapper;
+
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author oygj
+ * @since 2024-01-29
+ */
+@InterceptorIgnore(blockAttack = "true")
+public interface IotAlarmDefenceAreaMapper extends BaseMapper<IotAlarmDefenceArea> {
+
+}

+ 3 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IIotCommonSensorService.java

@@ -40,4 +40,7 @@ public interface IIotCommonSensorService extends IService<IotSensor> {
     List<IotSensor> selectSensorListByOrgPath(String path);
 
     List<Map<String, String>> getDeviceTypeList(String type);
+
+
+    List<String> sensorTurnToDefenceArea(String deviceType);
 }

+ 79 - 21
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xunmei.iot.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
@@ -12,9 +13,12 @@ import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.constant.DictConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.enums.OrgTypeEnum;
 import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
+import com.xunmei.common.core.enums.iot.DefenceAreaType;
+import com.xunmei.common.core.enums.iot.SensorType;
 import com.xunmei.common.core.exception.ServiceException;
 import com.xunmei.common.core.utils.bean.BeanUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
@@ -24,10 +28,7 @@ import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.iot.dto.sensor.SensorAppPageDto;
 import com.xunmei.iot.dto.sensor.SensorLogPageDto;
 import com.xunmei.iot.dto.sensor.SensorPageDto;
-import com.xunmei.iot.mapper.IotCommonSensorMapper;
-import com.xunmei.iot.mapper.IotDeviceInfoMapper;
-import com.xunmei.iot.mapper.IotDeviceStatusLogMapper;
-import com.xunmei.iot.mapper.IotDeviceStatusMapper;
+import com.xunmei.iot.mapper.*;
 import com.xunmei.iot.service.IIotCommonSensorService;
 import com.xunmei.iot.vo.sensor.*;
 import com.xunmei.system.api.RemoteOrgService;
@@ -67,6 +68,8 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
     private IotDeviceInfoMapper deviceInfoMapper;
     @Resource
     private IotDeviceStatusLogMapper deviceStatusLogMapper;
+    @Resource
+    private IotAlarmDefenceAreaMapper defenceAreaMapper;
 
     @Override
     public TableDataInfo<SensorPageVo> selectSensorDataPage(SensorPageDto request) {
@@ -175,9 +178,17 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         Page<SensorAppPageVo> page = sensorMapper.selectAppPageData(request.getPageRequest(), request);
         for (SensorAppPageVo record : page.getRecords()) {
             final String info = record.getInfo();
-            record.setInfo(dealInfoData(info));
-            record.setDeviceType(DictUtils.getDictLabel(DictConstants.APP_SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
-            record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, record.getState()));
+            if (NumberUtil.isNumber(record.getDeviceType())) {
+                //通用传感器
+                record.setInfo(dealInfoData(info));
+                record.setDeviceType(DictUtils.getDictLabel(DictConstants.APP_SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
+                record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, record.getState()));
+            } else {
+                record.setDeviceName(record.getDeviceName() + "(报警主机)");
+                //报警主机传感器
+                record.setStateText(record.getInfo());
+            }
+
             if (SecurityUtils.isApp()) {
                 record.setOrgName(orgService.concatOrgName(record.getOrgId(), SecurityConstants.INNER));
             }
@@ -197,23 +208,33 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
     @Override
     public SensorAppVo appDetail(Long id) {
         IotDeviceInfo deviceInfo = deviceInfoMapper.selectById(id);
-        if (deviceInfo == null) {
-            throw new ServiceException("不存在该设备");
-        }
-        IotDeviceStatus deviceStatus = deviceStatusMapper.selectByDeviceId(deviceInfo.getId());
-        if (ObjectUtil.isNull(deviceStatus)) {
-            throw new ServiceException("未获取到设备状态");
-        }
+        if (deviceInfo != null) {
+            IotDeviceStatus deviceStatus = deviceStatusMapper.selectByDeviceId(deviceInfo.getId());
+            if (ObjectUtil.isNull(deviceStatus)) {
+                throw new ServiceException("未获取到设备状态");
+            }
 
 
+            SensorAppVo vo = new SensorAppVo();
+            BeanUtils.copyProperties(deviceInfo, vo);
+            BeanUtils.copyProperties(deviceStatus, vo);
+            vo.setDeviceType(deviceStatus.getDeviceType());
+            vo.setInfos(deviceStatus.getInfo());
+            vo.setDeviceTypeText(DictUtils.getDictLabel(DictConstants.APP_SENSOR_DEVICE_TYPE, Integer.parseInt(vo.getDeviceType())));
+            vo.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, vo.getState()));
+            vo.setOrgName(orgService.concatOrgName(deviceInfo.getOrgId(), SecurityConstants.INNER));
+            return vo;
+        }
+        final IotAlarmDefenceArea defenceArea = defenceAreaMapper.selectById(id);
+        if (defenceArea == null) {
+            throw new ServiceException("该传感器数据不存在!");
+        }
         SensorAppVo vo = new SensorAppVo();
-        BeanUtils.copyProperties(deviceInfo, vo);
-        BeanUtils.copyProperties(deviceStatus, vo);
-        vo.setDeviceType(deviceStatus.getDeviceType());
-        vo.setInfos(deviceStatus.getInfo());
-        vo.setDeviceTypeText(DictUtils.getDictLabel(DictConstants.APP_SENSOR_DEVICE_TYPE, Integer.parseInt(vo.getDeviceType())));
-        vo.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, vo.getState()));
-        vo.setOrgName(orgService.concatOrgName(deviceInfo.getOrgId(), SecurityConstants.INNER));
+        BeanUtils.copyProperties(defenceArea, vo);
+        vo.setState("alarm".equals(defenceArea.getState()) ? 1 : 0);
+        vo.setDeviceType(defenceArea.getSensorType());
+        vo.setDeviceTypeText(defenceArea.getSensorTypeName());
+        vo.setDeviceName(defenceArea.getDefenceAreaName());
         return vo;
     }
 
@@ -237,6 +258,10 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
             request.setOrgPath(sysOrg.getPath());
             request.setOrgId(null);
         }
+        final List<String> list = sensorTurnToDefenceArea(request.getDeviceType());
+        if (ObjectUtil.isNotEmpty(list)) {
+            request.setDefenceAreaType(list);
+        }
     }
 
     private void dealPageParam(SensorPageDto request) {
@@ -270,6 +295,39 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
     }
 
     @Override
+    public List<String> sensorTurnToDefenceArea(String deviceType) {
+        List<String> list = new ArrayList<>();
+        if (ObjectUtil.isEmpty(deviceType)) {
+            return list;
+        }
+
+        final SensorType sensorType = SensorType.getSensorTypeEnum(Integer.parseInt(deviceType));
+
+        if (ObjectUtil.isEmpty(sensorType)) {
+            return list;
+        }
+        switch (sensorType) {
+            case SMOKE_SENSOR:
+                list.add(DefenceAreaType.SMOKE.getCode());
+                break;
+            case HUMIDITY_TEMPERATURE_SENSOR:
+                list.add(DefenceAreaType.HUMIDITY.getCode());
+                list.add(DefenceAreaType.TEMPERATURE.getCode());
+                break;
+            case INFRARED_SENSOR:
+                list.add(DefenceAreaType.INFRARED.getCode());
+                break;
+            case DOOR_MAGNETIC_SENSOR:
+                list.add(DefenceAreaType.DOOR_SENSOR.getCode());
+                break;
+            case WATER_INTRUSION:
+                list.add(DefenceAreaType.SOAKING.getCode());
+                break;
+        }
+        return list;
+    }
+
+    @Override
     public List<Map<String, String>> getDeviceTypeList(String type) {
         List<Map<String, String>> list = new ArrayList<Map<String, String>>();
         if (ObjectUtil.isEmpty(type)) {

+ 0 - 0
soc-modules/soc-modules-iot/src/main/resources/IotDayWorkFieldMapper.xml → soc-modules/soc-modules-iot/src/main/resources/mapper/IotDayWorkFieldMapper.xml


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

@@ -73,7 +73,33 @@
         <if test="request.deviceType!= null and request.deviceType!= ''">
             and ds.device_type = #{request.deviceType}
         </if>
-        order by ds.state desc
+        <if test="request.defenceAreaType != null and request.defenceAreaType.size()>0">
+            UNION ALL
+            SELECT a.id,
+            a.org_id,
+            a.org_name,
+            a.defence_area_name,
+            a.sensor_type,
+            a.state_text as info,
+            a.state_update_time,
+            if(a.state='alarm',1,0) as state
+            FROM `iot_alarm_defence_area` a
+            where a.deleted=0
+            <if test="request.orgId!= null">
+                and a.org_id=#{request.orgId}
+            </if>
+            <if test="request.orgPath!= null">
+                and a.org_path like CONCAT(#{request.orgPath}, '%')
+            </if>
+            <if test="request.state!= null">
+                and a.state = #{request.state}
+            </if>
+
+            and a.sensor_type in
+            <foreach collection="request.defenceAreaType" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
     </select>
     <select id="stateStatistic" resultType="com.xunmei.iot.vo.sensor.SensorAppStateVo">
         SELECT sum(state=0) as normal,