Browse Source

Merge remote-tracking branch 'origin/V1.0.11' into V1.0.11

jingyuanchao 11 tháng trước cách đây
mục cha
commit
478f9cfa97

+ 3 - 2
project_data/sql/1.0.11/soc.sql

@@ -211,6 +211,7 @@ CREATE TABLE `iot_device_diagnose_mission_ch` (
 
 drop table if exists `iot_device_diagnose_threshold`;
 CREATE TABLE `iot_device_diagnose_threshold` (
+  `threshold_id` bigint NOT NULL,
   `threshold_code` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT 'MD5生成唯一码',
   `threshold_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '阈值名称',
   `nosignal` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '信号丢失',
@@ -228,10 +229,10 @@ CREATE TABLE `iot_device_diagnose_threshold` (
   `begin_time` time DEFAULT NULL COMMENT '有效开始时间',
   `end_time` time DEFAULT NULL COMMENT '有效结束时间',
   `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
-  PRIMARY KEY (`threshold_code`) USING BTREE
+  PRIMARY KEY (`threshold_id`) USING BTREE
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断阈值表';
 -- 诊断阈值默认
-INSERT INTO `iot_device_diagnose_threshold` VALUES ('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` (

+ 5 - 1
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseThreshold.java

@@ -25,8 +25,12 @@ public class IotDeviceDiagnoseThreshold implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    @ApiModelProperty(value = "主键id")
+    @TableId("threshold_id")
+    private Long thresholdId;
+
     @ApiModelProperty(value = "MD5生成唯一码")
-    @TableId("threshold_code")
+    @TableField("threshold_code")
     private String thresholdCode;
 
     @ApiModelProperty(value = "阈值名称")

+ 14 - 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,12 +112,19 @@ 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);
                 }
 

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

@@ -207,7 +207,9 @@ public class DiagnoseMissionServiceImpl implements DiagnoseMissionService {
 
     @Override
     public List<IotDeviceDiagnoseMission> selectMissionPage(){
-        return diagnoseMissionChMapper.selectList(Wrappers.emptyWrapper());
+        QueryWrapper<IotDeviceDiagnoseMission> queryWrapper = new QueryWrapper();
+        queryWrapper.orderByAsc("create_time");
+        return diagnoseMissionChMapper.selectList(queryWrapper);
     }
 
     @Override

+ 21 - 11
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseThresholdServiceImpl.java

@@ -200,13 +200,18 @@ public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
 
     @Override
     public List<IotDeviceDiagnoseThreshold> selectThresholdPage(){
-        return diagnoseThresholdChMapper.selectList(Wrappers.emptyWrapper());
+        QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
+        queryWrapper.orderByAsc("create_time");
+        return diagnoseThresholdChMapper.selectList(queryWrapper);
     }
 
     @Override
     @Transactional
     public void deleteThreshold(String thresholdCode){
-        IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectById(thresholdCode);
+        QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("threshold_code",thresholdCode);
+        queryWrapper.last("limit 1");
+        IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectOne(queryWrapper);
         if (system == null) {
             String errorMsg = "当前阈值不存在!";
             throw  new ServiceException(errorMsg);
@@ -216,7 +221,7 @@ public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
             throw  new ServiceException(errorMsg);
         }
         //删除阈值
-        diagnoseThresholdChMapper.deleteById(thresholdCode);
+        diagnoseThresholdChMapper.delete(queryWrapper);
         //删除关联视频通道
         diagnoseThresholdChMapper.deleteCamerasByThresholdCode(thresholdCode);
     }
@@ -252,6 +257,7 @@ public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
         threshold.setBeginTime(request.getTimeRange()[0]);
         threshold.setEndTime(request.getTimeRange()[1]);
 
+        threshold.setThresholdId(IDHelper.id());
         threshold.setThresholdCode(thresholdCode);
         threshold.setCreateTime(DateUtils.getTime());
         threshold.setDiagnoseNumber(0);
@@ -262,19 +268,23 @@ public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
 
     @Override
     public void editThreshold(DiagnoseThresholdAddVo request){
-        //todo:
+        String nosignal=request.getNosignal().replace("&gt;",">").replace("&lt;","<");
+        String covered=request.getCovered().replace("&gt;",">").replace("&lt;","<");
+        request.setNosignal(nosignal);
+        request.setCovered(covered);
+
         String thresholdCode = DigestUtils.md5DigestAsHex(getThresholdGuid(request).getBytes());
 
         QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
-//        queryWrapper.eq("threshold_code", thresholdCode);
-//        List<IotDeviceDiagnoseThreshold> list = diagnoseThresholdChMapper.selectList(queryWrapper);
-//        if (!list.isEmpty()) {
-//            String errorMsg = "已存在相同参数的阈值配置'" + list.get(0).getThresholdName() + "'!";
-//            throw  new ServiceException(errorMsg);
-//        }
+        queryWrapper.eq("threshold_code", thresholdCode).ne("threshold_id", request.getThresholdId());
+        List<IotDeviceDiagnoseThreshold> list = diagnoseThresholdChMapper.selectList(queryWrapper);
+        if (!list.isEmpty()) {
+            String errorMsg = "已存在相同参数的阈值配置'" + list.get(0).getThresholdName() + "'!";
+            throw  new ServiceException(errorMsg);
+        }
 
         queryWrapper = new QueryWrapper();
-        queryWrapper.eq("threshold_name", request.getThresholdName()).ne("threshold_code", thresholdCode);
+        queryWrapper.eq("threshold_name", request.getThresholdName()).ne("threshold_id", request.getThresholdId());
         long nameCount = diagnoseThresholdChMapper.selectCount(queryWrapper);
         if (nameCount > 0) {
             String errorMsg = "已存在相同名称的阈值配置";

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