Răsfoiți Sursa

Merge branch 'V0.1.1_alarm' of http://10.87.21.221:8000/jzyd_yyds/soc into V0.1.1_alarm

zhulu 1 an în urmă
părinte
comite
45943aad42

+ 28 - 2
project_data/sql/0.1.1/soc/soc.sql

@@ -126,7 +126,7 @@ BEGIN
                   WHERE table_schema = DATABASE()
                     AND table_name = 'iot_alarm_defence_area'
                     AND column_name = 'category_id') THEN
-        ALTER TABLE `soc`.`iot_alarm_defence_area`
+        ALTER TABLE iot_alarm_defence_area
             DROP COLUMN `category_id`;
     END IF;
 
@@ -1180,7 +1180,7 @@ INSERT INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES (120, 1839945558511747
 
 
 DELETE FROM `sys_menu` WHERE `id`=01840267252212912129;
-INSERT INTO `soc`.`sys_menu` (`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01840267252212912129, '多层字典', 1, 0, 'multilayerdict', 'system/multilayerdict/index', NULL, 1, 0, 'C', '0', '0', '', '1', 'dict', NULL, '超级管理员', '2024-09-29 13:50:03', '超级管理员', '2024-09-29 13:50:46', '');
+INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01840267252212912129, '多层字典', 1, 0, 'multilayerdict', 'system/multilayerdict/index', NULL, 1, 0, 'C', '0', '0', '', '1', 'dict', NULL, '超级管理员', '2024-09-29 13:50:03', '超级管理员', '2024-09-29 13:50:46', '');
 
 drop table if exists core_notice_rule;
 CREATE TABLE `core_notice_rule` (
@@ -1344,6 +1344,32 @@ BEGIN
             ADD COLUMN `iot_code` varchar(225)  DEFAULT null COMMENT '主机token';
     END IF;
 
+    IF NOT EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_source'
+                     AND column_name = 'product_type') THEN
+        ALTER TABLE `iot_alarm_rule_source`
+            CHANGE COLUMN `source_type` `product_type` varchar(225) NULL DEFAULT NULL COMMENT '报警源类型:4:烟雾传感器;5:温湿度采集器;6:水浸,7:门磁:窗磁,8:卷帘门门磁;9:地磁,10:燃气报警器,50:报警防区' AFTER `rule_id`;
+    END IF;
+
+
+    IF NOT EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_source'
+                     AND column_name = 'device_code') THEN
+        ALTER TABLE `iot_alarm_rule_source`
+            ADD COLUMN `device_code` varchar(255) NULL COMMENT '设备code' AFTER `product_type`;
+    END IF;
+
+    IF EXISTS (SELECT * FROM information_schema.columns
+                   WHERE table_schema = DATABASE()
+                     AND table_name = 'iot_alarm_rule_express'
+                     AND column_name = 'source_type') THEN
+        ALTER TABLE `iot_alarm_rule_express`
+            DROP COLUMN `source_type`;
+    END IF;
+
+
 
     IF NOT EXISTS (SELECT * FROM information_schema.columns
                    WHERE table_schema = DATABASE()

+ 1 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/ProtectionServiceImpl.java

@@ -94,6 +94,7 @@ public class ProtectionServiceImpl extends ServiceImpl<ProtectionMapper, IotAlar
         }
 
 
+
         //按规则分页
         page = this.baseMapper.pageList(page, request);
 

+ 1 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/device/ProtectionMapper.xml

@@ -29,7 +29,7 @@
         a.alarm_host_code as deviceCode,
         a.iot_token as iotToken,
         a.source
-        from iot_alarm_subsystem a
+        from iot_alarm_subsystem a inner join sys_device d on d.business_device_id=a.id and d.device_status = 1
         inner join sys_org c on a.org_id = c.id and c.deleted=0
         <if test="request.checkSub==true">
             and c.path like concat((select path from sys_org where id=#{request.orgId}), '%')

+ 17 - 12
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/alarm/service/impl/IotAlarmRuleServiceImpl.java

@@ -19,6 +19,7 @@ import com.xunmei.host.websocket.enums.TopicTypeEnums;
 import com.xunmei.host.websocket.service.RouterService;
 import com.xunmei.host.websocket.utils.IotServerUtils;
 import com.xunmei.host.websocket.utils.WebSocketUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -80,14 +81,16 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
         final IotAlarmRule alarmRule = jsb.toJavaObject(IotAlarmRule.class);
 
         final IotAlarmRule iotAlarmRule = JSON.parseObject(JSON.toJSONString(jsb), IotAlarmRule.class);
-        iotAlarmRule.setIotCode(serverInfo.getIotCode());
-        iotAlarmRule.setOrgId(serverInfo.getOrgId());
-        iotAlarmRule.setOrgName(serverInfo.getOrgName());
-        iotAlarmRule.setServerName(serverInfo.getIotName());
+        final IotAlarmRule rule = new IotAlarmRule();
+        BeanUtils.copyProperties(iotAlarmRule, rule);
+        rule.setIotCode(serverInfo.getIotCode());
+        rule.setOrgId(serverInfo.getOrgId());
+        rule.setOrgName(serverInfo.getOrgName());
+        rule.setServerName(serverInfo.getIotName());
         final Object deleted = jsb.get("deleted");
-        iotAlarmRule.setIsdeleted(deleted == null ? null : Integer.parseInt(deleted.toString()));
-        iotAlarmRule.setType("alarm");
-        saveOrUpdate(alarmRule);
+        rule.setIsdeleted(deleted == null ? null : Integer.parseInt(deleted.toString()));
+        rule.setType("alarm");
+        saveOrUpdate(rule);
 
         final Object rs = jsb.get("ruleSourceList");
         final Object re = jsb.get("ruleExpresses");
@@ -95,11 +98,13 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
             final List<JSONObject> list = JSON.parseArray(rs.toString(), JSONObject.class);
             for (JSONObject j : list) {
                 final IotAlarmRuleSource ruleSource = j.toJavaObject(IotAlarmRuleSource.class);
-                ruleSource.setOrgId(serverInfo.getOrgId());
-                ruleSource.setIotCode(serverInfo.getIotCode());
-                ruleSource.setValue(serverInfo.getIotCode() + "_" + ruleSource.getProductType() + "_" + ruleSource.getDeviceCode());
-                ruleSource.setValueType(j.get("sourceType") == null ? "" : j.get("sourceType").toString());
-                ruleSourceService.saveOrUpdate(ruleSource);
+                final IotAlarmRuleSource source = new IotAlarmRuleSource();
+                BeanUtils.copyProperties(ruleSource, source);
+                source.setOrgId(serverInfo.getOrgId());
+                source.setIotCode(serverInfo.getIotCode());
+                source.setValue(serverInfo.getIotCode() + "_" + ruleSource.getProductType() + "_" + ruleSource.getDeviceCode());
+                source.setValueType(j.get("sourceType") == null ? "" : j.get("sourceType").toString());
+                ruleSourceService.saveOrUpdate(source);
             }
         }
         if (re != null) {

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

@@ -2,6 +2,7 @@ package com.xunmei.host.iot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
+import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
 import com.xunmei.system.api.domain.SysDevice;
 import com.xunmei.system.api.domain.iot.IotDeviceInfo;
 
@@ -16,4 +17,5 @@ public interface SysDeviceService extends IService<SysDevice> {
 
     void addDevice(List<IotDeviceInfo> deviceInfoList);
     void addDefenceArea(IotAlarmDefenceArea defenceArea);
+    void addSubSystem(IotAlarmSubsystem subsystem);
 }

+ 1 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceInfoServiceImpl.java

@@ -435,6 +435,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
                     dealAlarmSubSystem(subSystemInfo, info, serverInfo);
                     updateSubSystemList.add(info);
                 }
+                sysDeviceService.addSubSystem(info);
                 List<SubDeviceInfo> childDefenceAreaList = defenceAreaList.stream().filter(r -> ObjectUtil.equal(r.getParentCode(), subSystemInfo.getDeviceCode())).collect(Collectors.toList());
                 for (SubDeviceInfo defenceAreaInfo : childDefenceAreaList) {
                     IotAlarmDefenceArea defenceArea = iotAlarmDefenceAreaService.getBySubSystemCodeAndDeviceName(token, dvsBaseInfo.getDeviceCode(), subSystemInfo.getDeviceCode(), defenceAreaInfo.getDeviceCode());

+ 40 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/SysDeviceServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
+import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
 import com.xunmei.host.iot.mapper.SysDeviceMapper;
 import com.xunmei.host.iot.service.SysDeviceService;
 import com.xunmei.system.api.domain.SysDevice;
@@ -43,15 +44,53 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
         final SysDevice sysDevice = getByBusinessDeviceId(defenceArea.getId());
         if (sysDevice == null) {
             final SysDevice device = buildByDefenceArea(defenceArea);
+            device.setCreateBy("system");
+            device.setUpdateBy("system");
             save(device);
         } else {
             sysDevice.setDeviceName(defenceArea.getDefenceAreaName());
             sysDevice.setUpdateTime(new Date());
+            sysDevice.setUpdateBy("system");
             updateById(sysDevice);
         }
 
     }
 
+    @Override
+    public void addSubSystem(IotAlarmSubsystem subsystem) {
+        final SysDevice sysDevice = getByBusinessDeviceId(subsystem.getId());
+
+        if (sysDevice == null) {
+            final SysDevice device = buildSubSystem(subsystem);
+            device.setCreateBy("system");
+            device.setUpdateBy("system");
+            save(device);
+        } else {
+            sysDevice.setDeviceName(subsystem.getName());
+            sysDevice.setUpdateTime(new Date());
+            sysDevice.setUpdateBy("system");
+            updateById(sysDevice);
+        }
+
+    }
+
+    private SysDevice buildSubSystem(IotAlarmSubsystem subsystem) {
+        final Date now = new Date();
+        final SysDevice sysDevice = new SysDevice();
+        sysDevice.setDeviceName(subsystem.getName());
+        sysDevice.setUseTime(now);
+        sysDevice.setDeviceStatus(1);
+        sysDevice.setDelFlag("0");
+        sysDevice.setOrgId(subsystem.getOrgId());
+        sysDevice.setOrgName(subsystem.getOrgName());
+        sysDevice.setOrgPath(subsystem.getOrgPath());
+        sysDevice.setCreateTime(now);
+        sysDevice.setUpdateTime(now);
+        sysDevice.setBusinessDeviceId(subsystem.getId());
+        return sysDevice;
+
+    }
+
     public SysDevice getByBusinessDeviceId(Long businessDeviceId) {
         LambdaQueryWrapper<SysDevice> lambdaQuery = new LambdaQueryWrapper<>();
         lambdaQuery.eq(SysDevice::getBusinessDeviceId, businessDeviceId);
@@ -82,7 +121,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
         SysDevice sysDevice = new SysDevice();
         sysDevice.setDeviceName(deviceInfo.getDefenceAreaName());
         sysDevice.setUseTime(now);
-        sysDevice.setDeviceStatus(0);
+        sysDevice.setDeviceStatus(1);
         sysDevice.setDelFlag("0");
         sysDevice.setOrgId(deviceInfo.getOrgId());
         sysDevice.setOrgName(deviceInfo.getOrgName());

+ 1 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/init/ProductEnumInit.java

@@ -47,6 +47,7 @@ public class ProductEnumInit implements ApplicationRunner {
                     case DETECTION_HOST:
                         final List<String> detectionHost = productList.stream().filter(r -> r.getCategories().contains("DetectionHost")).map(IotServerProduct::getName).collect(Collectors.toList());
                         productEnum.getProductName().addAll(detectionHost);
+                        productEnum.getProductName().add("DetectionHostDevice");
                         break;
                 }
             }

+ 2 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleServiceImpl.java

@@ -257,7 +257,8 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
 
     @Override
     public List<Pair<String, String>> getConnectHostOrg(Long orgId) {
-        final List<IotServerInfo> connectOrg = serverInfoService.selectConnectOrg(false, orgId, null);
+        final SysOrg sysOrg = orgService.selectSysOrgById(orgId, SecurityConstants.INNER);
+        final List<IotServerInfo> connectOrg = serverInfoService.selectConnectOrg(true, orgId, sysOrg.getPath());
         if (CollectionUtils.isEmpty(connectOrg)) {
             return new ArrayList<>();
         }

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotBoardServiceImpl.java

@@ -181,7 +181,7 @@ public class IotBoardServiceImpl implements IotBoardService {
     public Map<String, Object> iotOverview(Long orgId) {
         List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
 
-        List<String> alarmTypeList = Lists.newArrayList("水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "盗告警");
+        List<String> alarmTypeList = Lists.newArrayList("水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "盗告警");
         List<String> productTypeList = Lists.newArrayList("FSU_Water", "FSU_TemperatureAndHumidity", "FSU_Smoke", "FSU_Gas", "FSU_DoorMagnetic", "FSU_Theft");
 
         Map<String, Object> map = new HashMap<>();

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

@@ -275,7 +275,7 @@
     </select>
     <select id="selectDiskBadge" resultType="java.lang.Integer">
         select  sum( d.`state` = 1 ) AS count
-        from iot_dvr_disk d
+        from iot_dvr_disk d inner join iot_server_info i on i.iot_code=d.iot_token
         <if test="orgPath!=null and orgPath != ''">
                  inner join sys_org o on o.id = d.org_id
         </if>