فهرست منبع

soc-modules-host模块-诊断绑定摄像机功能提交

humingshi-7@163.com 11 ماه پیش
والد
کامیت
01ad8be5d8
20فایلهای تغییر یافته به همراه612 افزوده شده و 0 حذف شده
  1. 59 0
      project_data/sql/1.0.11/soc.sql
  2. 5 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/util/LogUtils.java
  3. 62 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseMission.java
  4. 52 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseMissionCh.java
  5. 98 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseThreshold.java
  6. 52 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseThresholdCh.java
  7. 12 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/dto/IotDeviceDiagnoseMissionReq.java
  8. 11 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/dto/IotDeviceDiagnoseThresholdReq.java
  9. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseMissionChMapper.java
  10. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseMissionMapper.java
  11. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseThresholdChMapper.java
  12. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseThresholdMapper.java
  13. 4 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/IotCameraMissionRuleService.java
  14. 146 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotCameraMissionRuleServiceImpl.java
  15. 5 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/constant/WebSocketConstants.java
  16. 22 0
      soc-modules/soc-modules-host/src/main/resources/logback.xml
  17. 5 0
      soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseMissionChMapper.xml
  18. 5 0
      soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseMissionMapper.xml
  19. 5 0
      soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseThresholdChMapper.xml
  20. 5 0
      soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseThresholdMapper.xml

+ 59 - 0
project_data/sql/1.0.11/soc.sql

@@ -160,3 +160,62 @@ INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`,
 INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 1, '下发中', '1', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:22:18', '', NULL, NULL);
 INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 2, '下发成功', '2', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:22:52', '', NULL, NULL);
 INSERT INTO sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ( 3, '下发失败', '3', 'sync_status', NULL, 'default', 'N', '0', '超级管理员', '2024-11-13 16:23:01', '', NULL, NULL);
+
+
+
+-- 诊断绑定摄像机相关表
+drop table if exists `iot_device_diagnose_mission`;
+CREATE TABLE `iot_device_diagnose_mission` (
+  `mission_id` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务ID',
+  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称',
+  `begin_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '开始时间',
+  `end_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '结束时间',
+  `enabled` int NOT NULL COMMENT '是否启用:0-未启用,1-已启用',
+  `cycle` char(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '诊断周期(小时)',
+  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+  `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
+  PRIMARY KEY (`mission_id`) USING BTREE
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断任务表';
+
+drop table if exists `iot_device_diagnose_mission_ch`;
+CREATE TABLE `iot_device_diagnose_mission_ch` (
+  `id` bigint NOT NULL,
+  `mission_id` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '诊断任务id',
+  `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
+  `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '产品名称',
+  `dvs` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  COMMENT 'dvs的设备编码',
+  `channel` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  COMMENT '摄像机的编码',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断任务绑定关系表';
+
+drop table if exists `iot_device_diagnose_threshold`;
+CREATE TABLE `iot_device_diagnose_threshold` (
+  `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 '信号丢失',
+  `freeze` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '冻结',
+  `color` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '偏色',
+  `snow` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '雪花',
+  `covered` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '遮挡',
+  `luminance` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '亮度',
+  `roll` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '条纹',
+  `fuzzy` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模糊',
+  `contrast` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '对比度',
+  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+  `dignose_number` int DEFAULT NULL COMMENT '绑定通道数量',
+  `type` bigint DEFAULT NULL COMMENT '是否默认标识,1为默认,0为其他',
+  `validityBeginTime` time DEFAULT NULL COMMENT '有效开始时间',
+  `validityEndTime` time DEFAULT NULL COMMENT '有效结束时间',
+  PRIMARY KEY (`threshold_code`) USING BTREE
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断阈值表';
+
+drop table if exists `iot_device_diagnose_threshold_ch`;
+CREATE TABLE `iot_device_diagnose_threshold_ch` (
+  `id` bigint NOT NULL,
+  `threshold_code` varchar(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '诊断阈值id',
+  `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
+  `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备品牌',
+  `dvs` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  COMMENT 'dvs的设备编码',
+  `channel` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  COMMENT '摄像机的编码',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='摄像机诊断阈值绑定关系表';

+ 5 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/util/LogUtils.java

@@ -181,6 +181,11 @@ public class LogUtils {
     public  static  final Logger ALARM_RULE_LOG=LoggerFactory.getLogger("alarmRuleLog");
 
     /**
+     * 诊断绑定摄像机
+     */
+    public static final Logger SOCKET_CAMERA_MISSION_AND_THRESHOLD_LOG = LoggerFactory.getLogger("cameraMissionAndThresholdLog");
+
+    /**
      * websocket消息重试日志
      */
     public  static  final Logger WS_MSG_RETRY_LOG=LoggerFactory.getLogger("wsMsgRetryLog");

+ 62 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseMission.java

@@ -0,0 +1,62 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 摄像机诊断任务表
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_device_diagnose_mission")
+@ApiModel(value="IotDeviceDiagnoseMission对象", description="摄像机诊断任务表")
+public class IotDeviceDiagnoseMission implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "任务ID")
+    @TableId("mission_id")
+    private String missionId;
+
+    @ApiModelProperty(value = "任务名称")
+    @TableField("name")
+    private String name;
+
+    @ApiModelProperty(value = "开始时间")
+    @TableField("begin_time")
+    private String beginTime;
+
+    @ApiModelProperty(value = "结束时间")
+    @TableField("end_time")
+    private String endTime;
+
+    @ApiModelProperty(value = "是否启用:0-未启用,1-已启用")
+    @TableField("enabled")
+    private Integer enabled;
+
+    @ApiModelProperty(value = "诊断周期(小时)")
+    @TableField("cycle")
+    private String cycle;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("create_time")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "iot服务唯一编码")
+    @TableField("iot_token")
+    private String iotToken;
+
+
+}

+ 52 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseMissionCh.java

@@ -0,0 +1,52 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 摄像机诊断任务绑定关系表
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_device_diagnose_mission_ch")
+@ApiModel(value="IotDeviceDiagnoseMissionCh对象", description="摄像机诊断任务绑定关系表")
+public class IotDeviceDiagnoseMissionCh implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @ApiModelProperty(value = "诊断任务id")
+    @TableField("mission_id")
+    private String missionId;
+
+    @ApiModelProperty(value = "iot服务唯一编码")
+    @TableField("iot_token")
+    private String iotToken;
+
+    @ApiModelProperty(value = "产品名称")
+    @TableField("device_product")
+    private String deviceProduct;
+
+    @ApiModelProperty(value = "dvs的设备编码")
+    @TableField("dvs")
+    private String dvs;
+
+    @ApiModelProperty(value = "摄像机的编码")
+    @TableField("channel")
+    private String channel;
+
+
+}

+ 98 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseThreshold.java

@@ -0,0 +1,98 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 摄像机诊断阈值表
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_device_diagnose_threshold")
+@ApiModel(value="IotDeviceDiagnoseThreshold对象", description="摄像机诊断阈值表")
+public class IotDeviceDiagnoseThreshold implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "MD5生成唯一码")
+    @TableId("threshold_code")
+    private String thresholdCode;
+
+    @ApiModelProperty(value = "阈值名称")
+    @TableField("threshold_name")
+    private String thresholdName;
+
+    @ApiModelProperty(value = "信号丢失")
+    @TableField("nosignal")
+    private String nosignal;
+
+    @ApiModelProperty(value = "冻结")
+    @TableField("freeze")
+    private String freeze;
+
+    @ApiModelProperty(value = "偏色")
+    @TableField("color")
+    private String color;
+
+    @ApiModelProperty(value = "雪花")
+    @TableField("snow")
+    private String snow;
+
+    @ApiModelProperty(value = "遮挡")
+    @TableField("covered")
+    private String covered;
+
+    @ApiModelProperty(value = "亮度")
+    @TableField("luminance")
+    private String luminance;
+
+    @ApiModelProperty(value = "条纹")
+    @TableField("roll")
+    private String roll;
+
+    @ApiModelProperty(value = "模糊")
+    @TableField("fuzzy")
+    private String fuzzy;
+
+    @ApiModelProperty(value = "对比度")
+    @TableField("contrast")
+    private String contrast;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("create_time")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "绑定通道数量")
+    @TableField("dignose_number")
+    private Integer dignoseNumber;
+
+    @ApiModelProperty(value = "是否默认标识,1为默认,0为其他")
+    @TableField("type")
+    private Long type;
+
+    @ApiModelProperty(value = "有效开始时间")
+    @TableField("validityBeginTime")
+    private LocalTime validitybegintime;
+
+    @ApiModelProperty(value = "有效结束时间")
+    @TableField("validityEndTime")
+    private LocalTime validityendtime;
+
+    @ApiModelProperty(value = "iot服务唯一编码")
+    @TableField("iot_token")
+    private String iotToken;
+
+}

+ 52 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDeviceDiagnoseThresholdCh.java

@@ -0,0 +1,52 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 摄像机诊断阈值绑定关系表
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_device_diagnose_threshold_ch")
+@ApiModel(value="IotDeviceDiagnoseThresholdCh对象", description="摄像机诊断阈值绑定关系表")
+public class IotDeviceDiagnoseThresholdCh implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @ApiModelProperty(value = "诊断阈值id")
+    @TableField("threshold_code")
+    private String thresholdCode;
+
+    @ApiModelProperty(value = "iot服务唯一编码")
+    @TableField("iot_token")
+    private String iotToken;
+
+    @ApiModelProperty(value = "设备品牌")
+    @TableField("device_product")
+    private String deviceProduct;
+
+    @ApiModelProperty(value = "dvs的设备编码")
+    @TableField("dvs")
+    private String dvs;
+
+    @ApiModelProperty(value = "摄像机的编码")
+    @TableField("channel")
+    private String channel;
+
+
+}

+ 12 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/dto/IotDeviceDiagnoseMissionReq.java

@@ -0,0 +1,12 @@
+package com.xunmei.host.iot.dto;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMissionCh;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class IotDeviceDiagnoseMissionReq extends IotDeviceDiagnoseMission {
+    private List<IotDeviceDiagnoseMissionCh> chns;
+}

+ 11 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/dto/IotDeviceDiagnoseThresholdReq.java

@@ -0,0 +1,11 @@
+package com.xunmei.host.iot.dto;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class IotDeviceDiagnoseThresholdReq extends IotDeviceDiagnoseThreshold {
+    private List<IotDeviceDiagnoseThresholdCh> chns;
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseMissionChMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.iot.mapper;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMissionCh;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 摄像机诊断任务绑定关系表 Mapper 接口
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+public interface IotDeviceDiagnoseMissionChMapper extends BaseMapper<IotDeviceDiagnoseMissionCh> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseMissionMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.iot.mapper;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 摄像机诊断任务表 Mapper 接口
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+public interface IotDeviceDiagnoseMissionMapper extends BaseMapper<IotDeviceDiagnoseMission> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseThresholdChMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.iot.mapper;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 摄像机诊断阈值绑定关系表 Mapper 接口
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+public interface IotDeviceDiagnoseThresholdChMapper extends BaseMapper<IotDeviceDiagnoseThresholdCh> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceDiagnoseThresholdMapper.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.iot.mapper;
+
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 摄像机诊断阈值表 Mapper 接口
+ * </p>
+ *
+ * @author jingYuanChao
+ * @since 2024-11-18
+ */
+public interface IotDeviceDiagnoseThresholdMapper extends BaseMapper<IotDeviceDiagnoseThreshold> {
+
+}

+ 4 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/IotCameraMissionRuleService.java

@@ -0,0 +1,4 @@
+package com.xunmei.host.iot.service;
+
+public interface IotCameraMissionRuleService {
+}

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

@@ -0,0 +1,146 @@
+package com.xunmei.host.iot.service.impl;
+
+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.host.iot.dto.IotDeviceDiagnoseMissionReq;
+import com.xunmei.host.iot.dto.IotDeviceDiagnoseThresholdReq;
+import com.xunmei.host.iot.mapper.IotDeviceDiagnoseMissionChMapper;
+import com.xunmei.host.iot.mapper.IotDeviceDiagnoseMissionMapper;
+import com.xunmei.host.iot.mapper.IotDeviceDiagnoseThresholdChMapper;
+import com.xunmei.host.iot.mapper.IotDeviceDiagnoseThresholdMapper;
+import com.xunmei.host.iot.service.IotCameraMissionRuleService;
+import com.xunmei.host.websocket.constant.WebSocketConstants;
+import com.xunmei.host.websocket.dto.WebsocketExecuteReq;
+import com.xunmei.host.websocket.dto.WebsocketResult;
+import com.xunmei.host.websocket.enums.ProductEnums;
+import com.xunmei.host.websocket.service.RouterService;
+import com.xunmei.system.api.util.LogUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+import java.util.StringJoiner;
+
+@Service
+public class IotCameraMissionRuleServiceImpl implements IotCameraMissionRuleService,RouterService {
+
+    @Autowired
+    private IotDeviceDiagnoseMissionMapper missionMapper;
+    @Autowired
+    private IotDeviceDiagnoseMissionChMapper missionChMapper;
+    @Autowired
+    private IotDeviceDiagnoseThresholdMapper thresholdMapper;
+    @Autowired
+    private IotDeviceDiagnoseThresholdChMapper thresholdChMapper;
+
+    @Override
+    public ProductEnums product() {
+        return ProductEnums.DETECTION_HOST;
+    }
+
+    @Override
+    public String routerKey() {
+
+        StringJoiner result = new StringJoiner(",");
+        //诊断绑定数据
+        result.add(WebSocketConstants.CAMERA_MISSION_AND_THRESHOLD_EVENT);
+        return result.toString();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
+    public WebsocketResult execute(WebsocketExecuteReq req) {
+        final JSONObject jsb = receiveAndUpdateMissionCamera(req);
+        return WebsocketResult.reply(req, jsb);
+    }
+
+    private JSONObject receiveAndUpdateMissionCamera(WebsocketExecuteReq req) {
+        try {
+            String limitOne = "limit 1";
+
+            final Object data = req.getData();
+            final String iotToken = req.getServerInfo().getIotCode();
+            final JSONObject jsb = JSON.parseObject(data.toString(), JSONObject.class);
+
+
+            final List<IotDeviceDiagnoseMissionReq> missions = JSON.parseArray(jsb.getString("missions"),IotDeviceDiagnoseMissionReq.class);
+            final List<IotDeviceDiagnoseThresholdReq> thresholds = JSON.parseArray(jsb.getString("thresholds"),IotDeviceDiagnoseThresholdReq.class);
+
+
+            for(IotDeviceDiagnoseMissionReq mission: missions){
+                //入库任务
+                QueryWrapper<IotDeviceDiagnoseMission> wrapper = new QueryWrapper<>();
+                wrapper.eq("mission_id", mission.getMissionId());
+                wrapper.eq("iot_token", mission.getIotToken());
+                wrapper.last(limitOne);
+                IotDeviceDiagnoseMission bean = missionMapper.selectOne(wrapper);
+                if (bean == null) {
+                    missionMapper.insert(mission);
+                }else{
+                    missionMapper.updateById(mission);
+                }
+
+                List<IotDeviceDiagnoseMissionCh> chns = mission.getChns();
+                if(chns != null && !chns.isEmpty()){
+                    for(IotDeviceDiagnoseMissionCh missionCh:chns){
+                        QueryWrapper<IotDeviceDiagnoseMissionCh> wrapperCh = new QueryWrapper<>();
+                        wrapperCh.eq("iot_token", iotToken);
+                        wrapperCh.eq("device_product", missionCh.getDeviceProduct());
+                        wrapperCh.eq("dvs", missionCh.getDvs());
+                        wrapperCh.eq("channel", missionCh.getChannel());
+                        wrapperCh.last(limitOne);
+                        IotDeviceDiagnoseMissionCh beanCh = missionChMapper.selectOne(wrapperCh);
+                        if(beanCh == null){
+                            missionCh.setIotToken(iotToken);
+                            missionChMapper.insert(missionCh);
+                        }else{
+                            missionChMapper.update(missionCh,wrapperCh);
+                        }
+                    }
+                }
+            }
+
+            for(IotDeviceDiagnoseThresholdReq threshold: thresholds){
+                //入库状态app附表
+                QueryWrapper<IotDeviceDiagnoseThreshold> wrapper = new QueryWrapper<>();
+                wrapper.eq("threshold_code", threshold.getThresholdCode());
+                wrapper.eq("iot_token", threshold.getIotToken());
+                wrapper.last(limitOne);
+                IotDeviceDiagnoseThreshold bean = thresholdMapper.selectOne(wrapper);
+                if (bean == null) {
+                    thresholdMapper.insert(threshold);
+                }else{
+                    thresholdMapper.updateById(threshold);
+                }
+
+                List<IotDeviceDiagnoseThresholdCh> chns = threshold.getChns();
+                if(chns != null && !chns.isEmpty()){
+                    for(IotDeviceDiagnoseThresholdCh thresholdCh:chns){
+                        QueryWrapper<IotDeviceDiagnoseThresholdCh> wrapperCh = new QueryWrapper<>();
+                        wrapperCh.eq("iot_token", iotToken);
+                        wrapperCh.eq("device_product", thresholdCh.getDeviceProduct());
+                        wrapperCh.eq("dvs", thresholdCh.getDvs());
+                        wrapperCh.eq("channel", thresholdCh.getChannel());
+                        wrapperCh.last(limitOne);
+                        IotDeviceDiagnoseThresholdCh beanCh = thresholdChMapper.selectOne(wrapperCh);
+                        if(beanCh == null){
+                            thresholdCh.setIotToken(iotToken);
+                            thresholdChMapper.insert(thresholdCh);
+                        }else{
+                            thresholdChMapper.update(thresholdCh,wrapperCh);
+                        }
+                    }
+                }
+            }
+
+
+        } catch (Exception e) {
+            LogUtils.STATUS_INFO_STATUS_SENSOR.info("诊断绑定摄像机: 处理出现异常{}", e);
+            throw new RuntimeException(e);
+        }
+        return WebsocketResult.getSuccessPayload();
+    }
+}

+ 5 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/constant/WebSocketConstants.java

@@ -195,6 +195,11 @@ public interface WebSocketConstants {
      */
     String DELETE_WORK_RULE = "deleteWorkRule";
 
+    /**
+     * 全量诊断任务绑定关系
+     */
+    String CAMERA_MISSION_AND_THRESHOLD_EVENT = "cameraMissionAndThreshold";
+
     // ------------------ IOT提供的服务能力结束 ------------------
 
     /**

+ 22 - 0
soc-modules/soc-modules-host/src/main/resources/logback.xml

@@ -235,6 +235,23 @@
         </encoder>
     </appender>
 
+    <appender name="cameraMissionAndThresholdLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <maxFileSize>${max.file.size}</maxFileSize>
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>${LOG_HOME}/camera_mission_threshold/%d{yyyy-MM-dd}-%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <maxHistory>${max.history}</maxHistory>
+            <totalSizeCap>${total.size.cap}</totalSizeCap>
+            <cleanHistoryOnStart>true</cleanHistoryOnStart>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+
     <logger name="websocketMsgLog" additivity="false" level="info">
         <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
         <appender-ref ref="websocketMsgLog"/>
@@ -278,6 +295,11 @@
         <appender-ref ref="statusSensorLog"/>
     </logger>
 
+    <logger name="cameraMissionAndThresholdLog" additivity="false" level="info">
+        <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
+        <appender-ref ref="cameraMissionAndThresholdLog"/>
+    </logger>
+
     <logger name="alarmRuleLog" additivity="false" level="info">
         <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
         <appender-ref ref="alarmRuleLog"/>

+ 5 - 0
soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseMissionChMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xunmei.host.iot.mapper.IotDeviceDiagnoseMissionChMapper">
+
+</mapper>

+ 5 - 0
soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseMissionMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xunmei.host.iot.mapper.IotDeviceDiagnoseMissionMapper">
+
+</mapper>

+ 5 - 0
soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseThresholdChMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xunmei.host.iot.mapper.IotDeviceDiagnoseThresholdChMapper">
+
+</mapper>

+ 5 - 0
soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceDiagnoseThresholdMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xunmei.host.iot.mapper.IotDeviceDiagnoseThresholdMapper">
+
+</mapper>