Jelajahi Sumber

soc-modules-host模块,优化视频诊断入库

humingshi-7@163.com 11 bulan lalu
induk
melakukan
64abad6479

+ 1 - 1
project_data/sql/1.0.11/soc.sql

@@ -232,7 +232,7 @@ CREATE TABLE `iot_device_diagnose_threshold` (
   PRIMARY KEY (`threshold_id`) USING BTREE
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断阈值表';
 -- 诊断阈值默认
-INSERT INTO `iot_device_diagnose_threshold` VALUES (1858433123521220610,'0cdd75ea0d73056dbd6727b96339f2f6', '默认', '@value==255', '@value>=250', '@value>=150', '@value>=7', '@value>=255', '@value>=225', '@value>=140', '@value>=253', '@value<=0',  '2024-11-18 17:03:54', '0', '1', '00:00:00', '23:59:59',null);
+INSERT INTO `iot_device_diagnose_threshold` VALUES (1,'0cdd75ea0d73056dbd6727b96339f2f6', '默认', '@value==255', '@value>=250', '@value>=150', '@value>=7', '@value>=255', '@value>=225', '@value>=140', '@value>=253', '@value<=0',  '2024-11-18 17:03:54', '0', '1', '00:00:00', '23:59:59',null);
 
 drop table if exists `iot_device_diagnose_threshold_ch`;
 CREATE TABLE `iot_device_diagnose_threshold_ch` (

+ 13 - 2
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotCameraMissionRuleServiceImpl.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xunmei.common.core.domain.iot.domain.*;
+import com.xunmei.common.core.utils.IDHelper;
+import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.host.iot.dto.IotDeviceDiagnoseMissionReq;
 import com.xunmei.host.iot.dto.IotDeviceDiagnoseThresholdReq;
 import com.xunmei.host.iot.mapper.IotDeviceDiagnoseMissionChMapper;
@@ -74,11 +76,14 @@ public class IotCameraMissionRuleServiceImpl implements IotCameraMissionRuleServ
                 //入库任务
                 QueryWrapper<IotDeviceDiagnoseMission> wrapper = new QueryWrapper<>();
                 wrapper.eq("mission_id", mission.getMissionId());
-                wrapper.eq("iot_token", mission.getIotToken());
+                if(StringUtils.isNotEmpty(mission.getIotToken())) {
+                    wrapper.eq("iot_token", mission.getIotToken());
+                }
                 wrapper.last(limitOne);
                 IotDeviceDiagnoseMission bean = missionMapper.selectOne(wrapper);
                 if (bean == null) {
                     missionMapper.insert(mission);
+                }else if(bean.getMissionId().equals("5ed19826-dd47-421e-a632-b00ba9271c45")){//系统默认任务
                 }else{
                     missionMapper.updateById(mission);
                 }
@@ -107,11 +112,17 @@ public class IotCameraMissionRuleServiceImpl implements IotCameraMissionRuleServ
                 //入库状态app附表
                 QueryWrapper<IotDeviceDiagnoseThreshold> wrapper = new QueryWrapper<>();
                 wrapper.eq("threshold_code", threshold.getThresholdCode());
-                wrapper.eq("iot_token", threshold.getIotToken());
+                if(StringUtils.isNotEmpty(threshold.getIotToken())) {
+                    wrapper.eq("iot_token", threshold.getIotToken());
+                }
                 wrapper.last(limitOne);
                 IotDeviceDiagnoseThreshold bean = thresholdMapper.selectOne(wrapper);
                 if (bean == null) {
+                    //新增时,使用平台生成的id,然后下发到主机统一治理
+                    threshold.setThresholdId(IDHelper.id());
+                    threshold.setDiagnoseNumber(0);
                     thresholdMapper.insert(threshold);
+                }else if(bean.getThresholdId()==1){//系统默认阈值
                 }else{
                     threshold.setThresholdId(bean.getThresholdId());
                     thresholdMapper.updateById(threshold);

+ 4 - 4
soc-modules/soc-modules-iot/src/main/resources/mapper/DiagnoseMissionChMapper.xml

@@ -12,7 +12,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>
@@ -54,7 +54,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>
@@ -98,7 +98,7 @@
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
         left join iot_device_diagnose_mission_ch ch on ch.iot_token = s.iot_token
         and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>
@@ -181,7 +181,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>

+ 4 - 4
soc-modules/soc-modules-iot/src/main/resources/mapper/DiagnoseThresholdChMapper.xml

@@ -12,7 +12,7 @@
             inner join iot_device_info dvs on dvs.iot_token = s.iot_token
             and dvs.device_product = s.device_product and dvs.device_code = s.host_code
             and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-            where s.deleted=0 and s.enable=0 and s.device_type = 2
+            where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
             <if test="request.orgId!= null">
                 and s.org_id=#{request.orgId}
             </if>
@@ -55,7 +55,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>
@@ -97,7 +97,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>
@@ -166,7 +166,7 @@
         inner join iot_device_info dvs on dvs.iot_token = s.iot_token
         and dvs.device_product = s.device_product and dvs.device_code = s.host_code
         and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
-        where s.deleted=0 and s.enable=0 and s.device_type = 2
+        where s.deleted=0 and s.enable=0 and (s.device_type = 2 or s.device_type = 3)
         <if test="request.orgId!= null">
             and s.org_id=#{request.orgId}
         </if>