Procházet zdrojové kódy

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

jingyuanchao před 11 měsíci
rodič
revize
d094a07686
48 změnil soubory, kde provedl 1599 přidání a 3 odebrání
  1. 6 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/util/LogUtils.java
  2. 61 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsPlantime.java
  3. 73 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsPlantype.java
  4. 46 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsTemplate.java
  5. 48 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsTemplateChannel.java
  6. 21 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsPlanTimeDto.java
  7. 30 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsPlanTypeDto.java
  8. 15 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsTemplateChannelDto.java
  9. 21 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsTemplateDto.java
  10. 8 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsPlanTimeMapper.java
  11. 8 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsPlanTypeMapper.java
  12. 8 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsTemplateChannelMapper.java
  13. 8 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsTemplateMapper.java
  14. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsPlanTimeService.java
  15. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsPlanTypeService.java
  16. 4 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateAndPlanService.java
  17. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateChannelService.java
  18. 16 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateService.java
  19. 20 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsPlantimeServiceImpl.java
  20. 20 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsPlantypeServiceImpl.java
  21. 177 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateAndPlanServiceImpl.java
  22. 20 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateChannelServiceImpl.java
  23. 20 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateServiceImpl.java
  24. 6 0
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/constant/WebSocketConstants.java
  25. 22 0
      soc-modules/soc-modules-host/src/main/resources/logback.xml
  26. 31 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/CameraDiagnoseMissionController.java
  27. 30 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/CameraDiagnoseThresholdController.java
  28. 39 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/VideoTemplateAndPlanController.java
  29. 2 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/cameraDiagnose/DiagnoseMissionPageDto.java
  30. 4 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/cameraDiagnose/DiagnoseThresholdPageDto.java
  31. 18 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/videoTemplateAndPlan/VideoChannelPlanPageDto.java
  32. 18 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/videoTemplateAndPlan/VideoChannelPlanTimeDto.java
  33. 16 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/DiagnoseMissionChMapper.java
  34. 16 2
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/DiagnoseThresholdChMapper.java
  35. 21 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotDvsTemplateChannelMapper.java
  36. 4 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/DiagnoseMissionService.java
  37. 4 1
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/DiagnoseThresholdService.java
  38. 26 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotDvsTemplateChannelService.java
  39. 114 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseMissionServiceImpl.java
  40. 104 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseThresholdServiceImpl.java
  41. 57 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotDvsTemplateChannelServiceImpl.java
  42. 13 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/DiagnoseMissionBindVo.java
  43. 14 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/DiagnoseThresholdBindVo.java
  44. 20 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/videoTemplateAndPlan/VideoChannelPlanTimeVo.java
  45. 49 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/videoTemplateAndPlan/VideoChannelPlanVo.java
  46. 123 0
      soc-modules/soc-modules-iot/src/main/resources/mapper/DiagnoseMissionChMapper.xml
  47. 108 0
      soc-modules/soc-modules-iot/src/main/resources/mapper/DiagnoseThresholdChMapper.xml
  48. 62 0
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotDvsTemplateChannelMapper.xml

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

@@ -194,4 +194,10 @@ public class LogUtils {
      * 同步设备到主机
      */
     public  static  final Logger SYNC_DEVICE_TO_HOST=LoggerFactory.getLogger("syncDeviceToHost");
+
+
+    /**
+     * websocket dvs录像计划和录像模板
+     */
+    public  static  final Logger SOCKET_DVS_TEMPLATE_INFO=LoggerFactory.getLogger("socketDvsTemplateLog");
 }

+ 61 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsPlantime.java

@@ -0,0 +1,61 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_dvs_plantime")
+@ApiModel(value="IotDvsPlantime对象", description="")
+public class IotDvsPlantime implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @ApiModelProperty(value = "iot_device_info表device_code")
+    @TableField("dvs_code")
+    private String dvsCode;
+
+    @ApiModelProperty(value = "iot_device_info表device_code")
+    @TableField("channel_code")
+    private String channelCode;
+
+    @ApiModelProperty(value = "当前时间片段录像计划类型(0-定时录像,1-移动侦测录像,2-报警录像,3-移动侦测或报警录像,4-移动侦测和报警录像)")
+    @TableField("type")
+    private Integer type;
+
+    @ApiModelProperty(value = "星期标识(星期0-6,0为星期天)")
+    @TableField("week")
+    private Integer week;
+
+    @ApiModelProperty(value = "录像片段开始时间")
+    @TableField("start_time")
+    private Date startTime;
+
+    @ApiModelProperty(value = "录像片段结束时间")
+    @TableField("end_time")
+    private Date endTime;
+
+    @TableField("iot_token")
+    private String iotToken;
+
+
+}

+ 73 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsPlantype.java

@@ -0,0 +1,73 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_dvs_plantype")
+@ApiModel(value="IotDvsPlantype对象", description="")
+public class IotDvsPlantype implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @ApiModelProperty(value = "iot_device_info表device_code")
+    @TableField("dvs_code")
+    private String dvsCode;
+
+    @ApiModelProperty(value = "iot_device_info表device_code")
+    @TableField("channel_code")
+    private String channelCode;
+
+    @ApiModelProperty(value = "录像计划类型(0:全天定时录像;1:分时段定时录像;2:全天移动侦测;3:混合录像计划)")
+    @TableField("plan_type")
+    private Integer planType;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("create_time")
+    private Date createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField("update_time")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "录像时间段最小时间")
+    @TableField("min_time")
+    private Date minTime;
+
+    @ApiModelProperty(value = "录像时间段最大时间")
+    @TableField("max_time")
+    private Date maxTime;
+
+    @ApiModelProperty(value = "是否启动录像(0,启动;1:未启动)")
+    @TableField("isstart")
+    private Integer isstart;
+
+    @ApiModelProperty(value = "失败原因")
+    @TableField("fail_remark")
+    private String failRemark;
+
+    @TableField("iot_token")
+    private String iotToken;
+
+
+}

+ 46 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsTemplate.java

@@ -0,0 +1,46 @@
+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 xujie
+ * @since 2024-11-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_dvs_template")
+@ApiModel(value="IotDvsTemplate对象", description="")
+public class IotDvsTemplate implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @TableField("name")
+    private String name;
+
+    @ApiModelProperty(value = "生成类型:0.系统 1.手动")
+    @TableField("type")
+    private Integer type;
+
+    @ApiModelProperty(value = "name生成的MD5")
+    @TableField("template_md5")
+    private String templateMd5;
+
+    @TableField("iot_token")
+    private String iotToken;
+
+
+}

+ 48 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotDvsTemplateChannel.java

@@ -0,0 +1,48 @@
+package com.xunmei.common.core.domain.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("iot_dvs_template_channel")
+@ApiModel(value="IotDvsTemplateChannel对象", description="")
+public class IotDvsTemplateChannel implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId("id")
+    private Long id;
+
+    @TableField("template_md5")
+    private String templateMd5;
+
+    @TableField("dvs_code")
+    private String dvsCode;
+
+    @TableField("channel_code")
+    private String channelCode;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("iot_token")
+    private String iotToken;
+
+
+}

+ 21 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsPlanTimeDto.java

@@ -0,0 +1,21 @@
+package com.xunmei.host.video.dto.templateAndPlan;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DvsPlanTimeDto {
+
+    private String dvsCode;
+
+    private String channelCode;
+
+    private Integer type;
+
+    private Integer week;
+
+    private Date startTime;
+
+    private Date stopTime;
+}

+ 30 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsPlanTypeDto.java

@@ -0,0 +1,30 @@
+package com.xunmei.host.video.dto.templateAndPlan;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DvsPlanTypeDto {
+
+    private String dvsCode;
+
+    private String channelCode;
+
+    private Integer planType;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    private Date minTime;
+
+    private Date maxTime;
+
+    private Integer isstart;
+
+    private String failRemark;
+
+
+
+}

+ 15 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsTemplateChannelDto.java

@@ -0,0 +1,15 @@
+package com.xunmei.host.video.dto.templateAndPlan;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DvsTemplateChannelDto {
+
+    private String dvsCode;
+
+    private String channelCode;
+
+    private Date createTime;
+}

+ 21 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/dto/templateAndPlan/DvsTemplateDto.java

@@ -0,0 +1,21 @@
+package com.xunmei.host.video.dto.templateAndPlan;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DvsTemplateDto {
+
+    private String name;
+
+    private Integer type;
+
+    private String templateMd5;
+
+    private List<DvsTemplateChannelDto> channelList;
+
+    private List<DvsPlanTypeDto> planTypeList;
+
+    private List<DvsPlanTimeDto> planTimeList;
+}

+ 8 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsPlanTimeMapper.java

@@ -0,0 +1,8 @@
+package com.xunmei.host.video.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantime;
+
+public interface IotDvsPlanTimeMapper extends BaseMapper<IotDvsPlantime> {
+
+}

+ 8 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsPlanTypeMapper.java

@@ -0,0 +1,8 @@
+package com.xunmei.host.video.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantype;
+
+public interface IotDvsPlanTypeMapper extends BaseMapper<IotDvsPlantype> {
+
+}

+ 8 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsTemplateChannelMapper.java

@@ -0,0 +1,8 @@
+package com.xunmei.host.video.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+
+public interface IotDvsTemplateChannelMapper extends BaseMapper<IotDvsTemplateChannel> {
+
+}

+ 8 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/mapper/IotDvsTemplateMapper.java

@@ -0,0 +1,8 @@
+package com.xunmei.host.video.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplate;
+
+public interface IotDvsTemplateMapper extends BaseMapper<IotDvsTemplate> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsPlanTimeService.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.video.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantime;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+public interface IotDvsPlanTimeService extends IService<IotDvsPlantime> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsPlanTypeService.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.video.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantype;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+public interface IotDvsPlanTypeService extends IService<IotDvsPlantype> {
+
+}

+ 4 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateAndPlanService.java

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

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateChannelService.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.video.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+public interface IotDvsTemplateChannelService extends IService<IotDvsTemplateChannel> {
+
+}

+ 16 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/IotDvsTemplateService.java

@@ -0,0 +1,16 @@
+package com.xunmei.host.video.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplate;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+public interface IotDvsTemplateService extends IService<IotDvsTemplate> {
+
+}

+ 20 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsPlantimeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.xunmei.host.video.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantime;
+import com.xunmei.host.video.mapper.IotDvsPlanTimeMapper;
+import com.xunmei.host.video.service.IotDvsPlanTimeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Service
+public class IotDvsPlantimeServiceImpl extends ServiceImpl<IotDvsPlanTimeMapper, IotDvsPlantime> implements IotDvsPlanTimeService {
+
+}

+ 20 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsPlantypeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.xunmei.host.video.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.iot.domain.IotDvsPlantype;
+import com.xunmei.host.video.mapper.IotDvsPlanTypeMapper;
+import com.xunmei.host.video.service.IotDvsPlanTypeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Service
+public class IotDvsPlantypeServiceImpl extends ServiceImpl<IotDvsPlanTypeMapper, IotDvsPlantype> implements IotDvsPlanTypeService {
+
+}

+ 177 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateAndPlanServiceImpl.java

@@ -0,0 +1,177 @@
+package com.xunmei.host.video.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.xunmei.common.core.constant.ErrorMsgConstants;
+import com.xunmei.common.core.domain.iot.domain.*;
+import com.xunmei.common.core.utils.JacksonUtils;
+import com.xunmei.common.core.utils.bean.BeanUtils;
+import com.xunmei.host.video.dto.templateAndPlan.DvsPlanTimeDto;
+import com.xunmei.host.video.dto.templateAndPlan.DvsPlanTypeDto;
+import com.xunmei.host.video.dto.templateAndPlan.DvsTemplateChannelDto;
+import com.xunmei.host.video.dto.templateAndPlan.DvsTemplateDto;
+import com.xunmei.host.video.service.*;
+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.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringJoiner;
+
+
+@Service
+public class IotDvsTemplateAndPlanServiceImpl implements IotDvsTemplateAndPlanService, RouterService {
+
+    @Resource
+    private IotDvsTemplateService dvsTemplateService;
+
+    @Resource
+    private IotDvsTemplateChannelService dvsTemplateChannelService;
+
+    @Resource
+    private IotDvsPlanTypeService dvsPlanTypeService;
+
+    @Resource
+    private IotDvsPlanTimeService dvsPlanTimeService;
+
+    @Transactional
+    public void handDvsTemplateAndPlan(List<DvsTemplateDto> dataList, IotServerInfo serverInfo) {
+        //先删除数据
+        deleteDvsTemplateAndPlanByIotCode(serverInfo.getIotCode());
+        //处理录像模板和录像计划数据
+        for (DvsTemplateDto dvsTemplateDto : dataList) {
+            IotDvsTemplate dvsTemplate = new IotDvsTemplate();
+            BeanUtils.copyProperties(dvsTemplateDto, dvsTemplate);
+            dvsTemplate.setIotToken(serverInfo.getIotCode());
+            dvsTemplate.setId(IdWorker.getId());
+
+            List<IotDvsTemplateChannel> dvsTemplateChannels = handleTemplateChannelList(dvsTemplateDto.getChannelList(), dvsTemplate.getTemplateMd5(), serverInfo.getIotCode());
+            List<IotDvsPlantype> iotDvsPlanTypes = handlePlanTypeList(dvsTemplateDto.getPlanTypeList(), serverInfo.getIotCode());
+            List<IotDvsPlantime> iotDvsPlanTimes = handlePlanTimeList(dvsTemplateDto.getPlanTimeList(), serverInfo.getIotCode());
+
+            dvsTemplateService.save(dvsTemplate);
+            if (dvsTemplateChannels.size() > 0) {
+                dvsTemplateChannelService.saveBatch(dvsTemplateChannels);
+            }
+            if (iotDvsPlanTypes.size() > 0) {
+                dvsPlanTypeService.saveBatch(iotDvsPlanTypes);
+            }
+            if (iotDvsPlanTimes.size() > 0) {
+                dvsPlanTimeService.saveBatch(iotDvsPlanTimes);
+            }
+        }
+    }
+
+
+    private List<IotDvsTemplateChannel> handleTemplateChannelList(List<DvsTemplateChannelDto> channelList,String templateMd5,String iotCode){
+        ArrayList<IotDvsTemplateChannel> list = new ArrayList<>();
+        for (DvsTemplateChannelDto dvsTemplateChannelDto : channelList) {
+            IotDvsTemplateChannel templateChannel = new IotDvsTemplateChannel();
+            BeanUtils.copyProperties(dvsTemplateChannelDto, templateChannel);
+            templateChannel.setTemplateMd5(templateMd5);
+            templateChannel.setIotToken(iotCode);
+            templateChannel.setId(IdWorker.getId());
+            list.add(templateChannel);
+        }
+        return list;
+    }
+
+    private List<IotDvsPlantype> handlePlanTypeList(List<DvsPlanTypeDto> planTypeList, String iotCode){
+        ArrayList<IotDvsPlantype> list = new ArrayList<>();
+        for (DvsPlanTypeDto dvsPlanTypeDto : planTypeList) {
+            IotDvsPlantype plantype = new IotDvsPlantype();
+            BeanUtils.copyProperties(dvsPlanTypeDto, plantype);
+            plantype.setIotToken(iotCode);
+            plantype.setId(IdWorker.getId());
+            list.add(plantype);
+        }
+        return list;
+    }
+
+    private List<IotDvsPlantime> handlePlanTimeList(List<DvsPlanTimeDto> planTimeList, String iotCode){
+        ArrayList<IotDvsPlantime> list = new ArrayList<>();
+        for( DvsPlanTimeDto dvsPlanTimeDto : planTimeList){
+            IotDvsPlantime plantime = new IotDvsPlantime();
+            BeanUtils.copyProperties(dvsPlanTimeDto, plantime);
+            plantime.setEndTime(dvsPlanTimeDto.getStopTime());
+            plantime.setIotToken(iotCode);
+            plantime.setId(IdWorker.getId());
+            list.add(plantime);
+        }
+        return list;
+    }
+
+
+
+    @Transactional
+    public void deleteDvsTemplateAndPlanByIotCode(String iotCode) {
+        //IotDvsTemplate表
+        QueryWrapper<IotDvsTemplate> templateWrapper = new QueryWrapper<>();
+        templateWrapper.lambda().eq(IotDvsTemplate::getIotToken, iotCode);
+        dvsTemplateService.remove(templateWrapper);
+
+        //IotDvsTemplateChannel表
+        QueryWrapper<IotDvsTemplateChannel> templateChannelWrapper = new QueryWrapper<>();
+        templateChannelWrapper.lambda().eq(IotDvsTemplateChannel::getIotToken, iotCode);
+        dvsTemplateChannelService.remove(templateChannelWrapper);
+
+        //IotDvsPlantype表
+        QueryWrapper<IotDvsPlantype> planTypeWrapper = new QueryWrapper<>();
+        planTypeWrapper.lambda().eq(IotDvsPlantype::getIotToken, iotCode);
+        dvsPlanTypeService.remove(planTypeWrapper);
+
+        //IotDvsPlantime表
+        QueryWrapper<IotDvsPlantime> planTimeWrapper = new QueryWrapper<>();
+        planTimeWrapper.lambda().eq(IotDvsPlantime::getIotToken, iotCode);
+        dvsPlanTimeService.remove(planTimeWrapper);
+    }
+
+
+    @Override
+    public ProductEnums product() {
+        return ProductEnums.DETECTION_HOST;
+    }
+
+    @Override
+    public String routerKey() {
+        StringJoiner result = new StringJoiner(",");
+        //全量录像模板和录像计划
+        result.add(WebSocketConstants.DVS_TEMPLATE_AND_PLAN);
+        return result.toString();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
+    public WebsocketResult execute(WebsocketExecuteReq req) {
+        try {
+            LogUtils.SOCKET_DVS_TEMPLATE_INFO.info("收到消息:{}", JacksonUtils.toJSONString(req));
+            Object data = req.getData();
+            JSONArray dataArray = (JSONArray) data;
+            if (ObjectUtil.isEmpty(dataArray)) {
+                return WebsocketResult.replySuccess(req);
+            }
+            IotServerInfo serverInfo = req.getServerInfo();
+            String event = req.getEvent();
+            if (event.equals(WebSocketConstants.DVS_TEMPLATE_AND_PLAN)) {
+                List<DvsTemplateDto> dataList = dataArray.toJavaList(DvsTemplateDto.class);
+                handDvsTemplateAndPlan(dataList, serverInfo);
+            }else {
+                return WebsocketResult.replyError(req, ErrorMsgConstants.ERROR_ROUTE);
+            }
+        }catch (Exception e){
+            LogUtils.SOCKET_DVS_TEMPLATE_INFO.error("dvs录像模板和录像计划,处理失败", e);
+            throw new RuntimeException("dvs录像模板和录像计划,处理失败",e);
+        }
+        return WebsocketResult.replySuccess(req);
+    }
+}

+ 20 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateChannelServiceImpl.java

@@ -0,0 +1,20 @@
+package com.xunmei.host.video.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+import com.xunmei.host.video.mapper.IotDvsTemplateChannelMapper;
+import com.xunmei.host.video.service.IotDvsTemplateChannelService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Service
+public class IotDvsTemplateChannelServiceImpl extends ServiceImpl<IotDvsTemplateChannelMapper, IotDvsTemplateChannel> implements IotDvsTemplateChannelService {
+
+}

+ 20 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/video/service/impl/IotDvsTemplateServiceImpl.java

@@ -0,0 +1,20 @@
+package com.xunmei.host.video.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplate;
+import com.xunmei.host.video.mapper.IotDvsTemplateMapper;
+import com.xunmei.host.video.service.IotDvsTemplateService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Service
+public class IotDvsTemplateServiceImpl extends ServiceImpl<IotDvsTemplateMapper, IotDvsTemplate> implements IotDvsTemplateService {
+
+}

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

@@ -208,6 +208,12 @@ public interface WebSocketConstants {
      */
     String CAMERA_MISSION_AND_THRESHOLD_EVENT = "cameraMissionAndThreshold";
 
+
+    /**
+     * 全量录像模板和录像计划
+     */
+    String DVS_TEMPLATE_AND_PLAN = "dvsTemplateAndPlan";
+
     // ------------------ IOT提供的服务能力结束 ------------------
 
     /**

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

@@ -269,6 +269,23 @@
     </appender>
 
 
+    <!-- 录像模板和录像计划日志 -->
+    <appender name="socketDvsTemplateLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <maxFileSize>${max.file.size}</maxFileSize>
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>${LOG_HOME}/socketDvsTemplateLog/%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"/>
@@ -330,6 +347,11 @@
         <appender-ref ref="wsMsgRetryLog"/>
     </logger>
 
+    <logger name="socketDvsTemplateLog" additivity="false" level="info">
+        <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
+        <appender-ref ref="socketDvsTemplateLog"/>
+    </logger>
+
     <!-- 日志输出级别 -->
     <root level="INFO">
         <appender-ref ref="STDOUT"/>

+ 31 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/CameraDiagnoseMissionController.java

@@ -1,11 +1,15 @@
 package com.xunmei.iot.controller;
 
+import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseMissionPageDto;
 import com.xunmei.iot.service.DiagnoseMissionService;
 import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
 import com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
@@ -13,6 +17,8 @@ import java.util.List;
 @RestController
 @RequestMapping("/diagnoseMission")
 public class CameraDiagnoseMissionController {
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
     @Resource
     private DiagnoseMissionService diagnoseMissionService;
 
@@ -23,6 +29,31 @@ public class CameraDiagnoseMissionController {
         return page;
     }
 
+    @ApiModelProperty("诊断任务绑定操作")
+    @PostMapping({"/bindMission"})
+    public AjaxResult bindMission(@RequestBody final DiagnoseMissionPageDto request) {
+        try {
+            diagnoseMissionService.camerasBind(request);
+        }catch (Exception e){
+            log.error("/diagnoseMission/bindMission,出现异常:{}",e);
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success("操作成功");
+    }
+
+    @ApiModelProperty("诊断任务解绑操作")
+    @PostMapping({"/unbindMission"})
+    public AjaxResult unbindMission(@RequestBody final DiagnoseMissionPageDto request) {
+        try {
+            diagnoseMissionService.camerasUnbind(request);
+        }catch (Exception e){
+            log.error("/diagnoseMission/unbindMission,出现异常:{}",e);
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success("操作成功");
+    }
+
+
     @ApiOperation("获取任务下拉框")
     @GetMapping({"/missionTypeList"})
     public List<AlarmTypeSelectedVO> missionTypeList() {

+ 30 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/CameraDiagnoseThresholdController.java

@@ -1,11 +1,15 @@
 package com.xunmei.iot.controller;
 
+import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
 import com.xunmei.iot.service.DiagnoseThresholdService;
 import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
 import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import java.util.List;
@@ -13,6 +17,7 @@ import java.util.List;
 @RestController
 @RequestMapping("/diagnoseThreshold")
 public class CameraDiagnoseThresholdController {
+    protected Logger log = LoggerFactory.getLogger(getClass());
 
     @Resource
     private DiagnoseThresholdService diagnoseThresholdService;
@@ -24,6 +29,31 @@ public class CameraDiagnoseThresholdController {
         return page;
     }
 
+    @ApiModelProperty("诊断阈值绑定操作")
+    @PostMapping({"/bindThreshold"})
+    public AjaxResult bindThreshold(@RequestBody final DiagnoseThresholdPageDto request) {
+        try {
+            diagnoseThresholdService.camerasBind(request);
+        }catch (Exception e){
+            log.error("/diagnoseThreshold/bindThreshold,出现异常:{}",e);
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success("操作成功");
+    }
+
+    @ApiModelProperty("诊断阈值解绑操作")
+    @PostMapping({"/unbindThreshold"})
+    public AjaxResult unbindThreshold(@RequestBody final DiagnoseThresholdPageDto request) {
+        try {
+            diagnoseThresholdService.camerasUnbind(request);
+        }catch (Exception e){
+            log.error("/diagnoseThreshold/unbindThreshold,出现异常:{}",e);
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success("操作成功");
+    }
+
+
     @ApiOperation("获取阈值下拉框")
     @GetMapping({"/thresholdTypeList"})
     public List<AlarmTypeSelectedVO> thresholdTypeList() {

+ 39 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/VideoTemplateAndPlanController.java

@@ -0,0 +1,39 @@
+package com.xunmei.iot.controller;
+
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanPageDto;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanTimeDto;
+import com.xunmei.iot.service.IotDvsTemplateChannelService;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/video")
+public class VideoTemplateAndPlanController {
+
+    @Resource
+    private IotDvsTemplateChannelService dvsTemplateChannelService;
+
+
+    @ApiOperation("通道录像模板列表分页")
+    @GetMapping({"/channelPlan/page"})
+    TableDataInfo<VideoChannelPlanVo> channelPlanPage(VideoChannelPlanPageDto request) {
+        TableDataInfo<VideoChannelPlanVo> page = dvsTemplateChannelService.getChannelPlanList(request);
+        return page;
+    }
+
+    @ApiOperation("通道录像计划详情")
+    @GetMapping({"/channelPlanTime/detail"})
+    AjaxResult channelPlanTime(@Valid VideoChannelPlanTimeDto dto) {
+        List<VideoChannelPlanTimeVo> list = dvsTemplateChannelService.getChannelPlanTimeList(dto);
+        return AjaxResult.success(list);
+    }
+
+}

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/cameraDiagnose/DiagnoseMissionPageDto.java

@@ -18,4 +18,6 @@ public class DiagnoseMissionPageDto extends PageRequest {
     @ApiModelProperty(value = "任务code")
     private String missionCode;
 
+    @ApiModelProperty(value = "需要绑定的任务id")
+    private String bindMissionId;
 }

+ 4 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/cameraDiagnose/DiagnoseThresholdPageDto.java

@@ -22,4 +22,8 @@ public class DiagnoseThresholdPageDto extends PageRequest {
     @ApiModelProperty(value = "阈值code")
     private String thresholdCode;
 
+
+    @ApiModelProperty(value = "需要绑定或解绑的阈值code数组")
+    private List<String> bindThresholdCodes;
+
 }

+ 18 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/videoTemplateAndPlan/VideoChannelPlanPageDto.java

@@ -0,0 +1,18 @@
+package com.xunmei.iot.dto.videoTemplateAndPlan;
+
+import com.xunmei.common.core.web.domain.PageRequest;
+import lombok.Data;
+
+@Data
+public class VideoChannelPlanPageDto extends PageRequest {
+
+    private Integer planType;
+
+    private Long templateId;
+
+    private String dvsName;
+
+    private String channelName;
+
+    private String templateName;
+}

+ 18 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/videoTemplateAndPlan/VideoChannelPlanTimeDto.java

@@ -0,0 +1,18 @@
+package com.xunmei.iot.dto.videoTemplateAndPlan;
+
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class VideoChannelPlanTimeDto {
+
+    @Min(value = 1, message = "设备id参数值非法")
+    @NotNull( message = "设备id参数值必须传入")
+    private Long deviceId;
+
+    @Min(value = -1, message = "星期参数值非法")
+    @NotNull( message = "星期参数值必须传入")
+    private Integer week;
+}

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

@@ -2,7 +2,10 @@ package com.xunmei.iot.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMissionCh;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseMissionPageDto;
+import com.xunmei.iot.vo.sensor.DiagnoseMissionBindVo;
 import com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -11,5 +14,18 @@ import java.util.List;
 @Repository
 public interface DiagnoseMissionChMapper {
     Page<DiagnoseMissionPageVo> selectPageData(Page<DiagnoseMissionPageVo> pageRequest, @Param("request") DiagnoseMissionPageDto request);
+    Integer selectCamerasCount(@Param("request") DiagnoseMissionPageDto request);
+
+    List<DiagnoseMissionBindVo> selectCamerasBind(@Param("request") DiagnoseMissionPageDto request);
+    //批量插入-任务通道绑定
+
+    int batchInsertMissionCh(@Param("list") List<IotDeviceDiagnoseMissionCh> list);
+    //批量更新-任务通道绑定
+    int batchUpdateMissionCh(@Param("list") List<IotDeviceDiagnoseMissionCh> list);
+    //批量插入-默认阈值通道绑定
+    int batchInsertThresholdCh(@Param("list") List<IotDeviceDiagnoseThresholdCh> list);
+    //批量删除-任务通道
+    int batchDeleteMissionCh(@Param("ids") List<Long> ids);
+
     List<IotDeviceDiagnoseMission> selectAllDiagnoseMission();
 }

+ 16 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/DiagnoseThresholdChMapper.java

@@ -1,16 +1,30 @@
 package com.xunmei.iot.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo;
 import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
-
 import java.util.List;
 
 @Repository
-public interface DiagnoseThresholdChMapper {
+public interface DiagnoseThresholdChMapper  extends BaseMapper<IotDeviceDiagnoseThreshold> {
     Page<DiagnoseThresholdPageVo> selectPageData(Page<DiagnoseThresholdPageVo> pageRequest, @Param("request") DiagnoseThresholdPageDto request);
+
+    Integer selectCamerasCount(@Param("request") DiagnoseThresholdPageDto request);
+
+    List<DiagnoseThresholdBindVo> selectCamerasBind(@Param("request") DiagnoseThresholdPageDto request);
+
+    //批量插入-阈值通道绑定
+    int batchInsertThresholdCh(@Param("list") List<IotDeviceDiagnoseThresholdCh> list);
+    //批量删除-阈值通道
+    int batchDeleteThresholdCh(@Param("ids") List<Long> ids);
+    //修改阈值绑定的设备数量
+    Integer updateDignoseNumber(@Param("thresholdCode")String thresholdCode);
+
     List<IotDeviceDiagnoseThreshold> selectAllDiagnoseThreshold();
 }

+ 21 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotDvsTemplateChannelMapper.java

@@ -0,0 +1,21 @@
+package com.xunmei.iot.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanPageDto;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanTimeDto;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface IotDvsTemplateChannelMapper extends BaseMapper<IotDvsTemplateChannel> {
+
+    Page<VideoChannelPlanVo> getChannelPlanList(Page<VideoChannelPlanPageDto> pageRequest, @Param("req") VideoChannelPlanPageDto req);
+
+    List<VideoChannelPlanTimeVo> getChannelPlanTimeList(@Param("req")VideoChannelPlanTimeDto req);
+}

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

@@ -10,5 +10,9 @@ public interface DiagnoseMissionService {
 
     TableDataInfo<DiagnoseMissionPageVo> selectDiagnoseMissionPage(DiagnoseMissionPageDto request);
 
+    void camerasBind(DiagnoseMissionPageDto request);
+
+    void camerasUnbind(DiagnoseMissionPageDto request);
+
     List<AlarmTypeSelectedVO> missionTypeList();
 }

+ 4 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/DiagnoseThresholdService.java

@@ -4,12 +4,15 @@ import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
 import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
 import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
-
 import java.util.List;
 
 public interface DiagnoseThresholdService {
 
     TableDataInfo<DiagnoseThresholdPageVo> selectDiagnoseThresholdPage(DiagnoseThresholdPageDto request);
 
+    void camerasBind(DiagnoseThresholdPageDto request);
+
+    void camerasUnbind(DiagnoseThresholdPageDto request);
+
     List<AlarmTypeSelectedVO> thresholdTypeList();
 }

+ 26 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotDvsTemplateChannelService.java

@@ -0,0 +1,26 @@
+package com.xunmei.iot.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanPageDto;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanTimeDto;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+public interface IotDvsTemplateChannelService extends IService<IotDvsTemplateChannel> {
+
+    TableDataInfo<VideoChannelPlanVo> getChannelPlanList(VideoChannelPlanPageDto dto);
+
+    List<VideoChannelPlanTimeVo> getChannelPlanTimeList(VideoChannelPlanTimeDto dto);
+}

+ 114 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseMissionServiceImpl.java

@@ -1,25 +1,37 @@
 package com.xunmei.iot.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.CacheConstants;
+import com.xunmei.common.core.constant.Constants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMissionCh;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
 import com.xunmei.common.core.enums.OrgTypeEnum;
+import com.xunmei.common.core.exception.ServiceException;
+import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.redis.utils.RedisUtils;
 import com.xunmei.iot.dto.cameraDiagnose.DiagnoseMissionPageDto;
 import com.xunmei.iot.mapper.DiagnoseMissionChMapper;
+import com.xunmei.iot.mapper.DiagnoseThresholdChMapper;
 import com.xunmei.iot.service.DiagnoseMissionService;
 import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
+import com.xunmei.iot.vo.sensor.DiagnoseMissionBindVo;
 import com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.vo.SysOrgVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.List;
@@ -27,11 +39,15 @@ import java.util.stream.Collectors;
 
 @Service
 public class DiagnoseMissionServiceImpl implements DiagnoseMissionService {
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
     @Resource
     private RemoteOrgService orgService;
 
     @Autowired
     private DiagnoseMissionChMapper diagnoseMissionChMapper;
+    @Autowired
+    private DiagnoseThresholdChMapper diagnoseThresholdChMapper;
 
     @Override
     public TableDataInfo<DiagnoseMissionPageVo> selectDiagnoseMissionPage(DiagnoseMissionPageDto request) {
@@ -83,6 +99,104 @@ public class DiagnoseMissionServiceImpl implements DiagnoseMissionService {
 
 
     @Override
+    @Transactional
+    public void camerasBind(DiagnoseMissionPageDto request){
+        final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
+            request.setOrgPath(sysOrg.getPath());
+            request.setOrgId(null);
+        }
+
+        Integer camerasCount = diagnoseMissionChMapper.selectCamerasCount(request);
+        if (camerasCount == null || camerasCount == 0) {
+            String errorMsg = "绑定任务查询条件筛选结果为空!";
+            throw  new ServiceException(errorMsg);
+        }
+
+        String bindMissionId = request.getBindMissionId();
+        QueryWrapper<IotDeviceDiagnoseThreshold> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("type", 1);
+        queryWrapper.last(Constants.LIMIT1);
+        IotDeviceDiagnoseThreshold system = diagnoseThresholdChMapper.selectOne(queryWrapper);
+        //获取未绑定阈值的通道
+        List<IotDeviceDiagnoseThresholdCh> batchInsertsUnbindThresholdCh = Lists.newArrayList();
+        //获取要绑定的通道
+        List<IotDeviceDiagnoseMissionCh> batchInserts = Lists.newArrayList();
+        List<IotDeviceDiagnoseMissionCh> batchUpdates = Lists.newArrayList();
+
+        List<DiagnoseMissionBindVo> list = diagnoseMissionChMapper.selectCamerasBind(request);
+        for (DiagnoseMissionBindVo info :list) {
+            String beanId = info.getMissionId();
+            IotDeviceDiagnoseMissionCh chn = new IotDeviceDiagnoseMissionCh();
+            chn.setIotToken(info.getIotToken());
+            chn.setDeviceProduct(info.getDeviceProduct());
+            chn.setDvs(info.getDvs());
+            chn.setChannel(info.getChannel());
+            chn.setMissionId(bindMissionId);
+
+            if (StringUtils.isBlank(beanId)) {
+                chn.setId(IDHelper.id());
+                batchInserts.add(chn);
+            } else if (!beanId.equals(bindMissionId)) {
+                batchUpdates.add(chn);
+            }
+            if (StringUtils.isEmpty(info.getThresholdCodes())) {
+                IotDeviceDiagnoseThresholdCh thresholdCh = new IotDeviceDiagnoseThresholdCh();
+                thresholdCh.setThresholdCode(system.getThresholdCode());
+                thresholdCh.setIotToken(info.getIotToken());
+                thresholdCh.setDeviceProduct(info.getDeviceProduct());
+                thresholdCh.setDvs(info.getDvs());
+                thresholdCh.setChannel(info.getChannel());
+                thresholdCh.setId(IDHelper.id());
+                batchInsertsUnbindThresholdCh.add(thresholdCh);
+            }
+        }
+
+        if (batchInserts != null && !batchInserts.isEmpty()) {
+            diagnoseMissionChMapper.batchInsertMissionCh(batchInserts);
+        }
+        if (batchUpdates != null && !batchUpdates.isEmpty()) {
+            diagnoseMissionChMapper.batchUpdateMissionCh(batchUpdates);
+        }
+
+        //查询的通道如果未绑定阈值,绑定它们到默认阈值上
+        if (batchInsertsUnbindThresholdCh != null && !batchInsertsUnbindThresholdCh.isEmpty()) {
+            diagnoseMissionChMapper.batchInsertThresholdCh(batchInsertsUnbindThresholdCh);
+        }
+
+        //更新默认阈值绑定数量
+        diagnoseThresholdChMapper.updateDignoseNumber(system.getThresholdCode());
+    }
+
+    @Override
+    @Transactional
+    public void camerasUnbind(DiagnoseMissionPageDto request){
+        final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
+            request.setOrgPath(sysOrg.getPath());
+            request.setOrgId(null);
+        }
+
+        Integer camerasCount = diagnoseMissionChMapper.selectCamerasCount(request);
+        if (camerasCount == null || camerasCount == 0) {
+            String errorMsg = "绑定任务查询条件筛选结果为空!";
+            throw  new ServiceException(errorMsg);
+        }
+
+
+        List<DiagnoseMissionBindVo> list = diagnoseMissionChMapper.selectCamerasBind(request);
+
+        //需要解除绑定的集合
+        List<Long> unbindIds = Lists.newArrayList();
+        for (DiagnoseMissionBindVo item : list) {
+            if (StringUtils.isNotEmpty(item.getMissionId())) unbindIds.add(item.getId());
+        }
+        //删除绑定的诊断任务
+        if (unbindIds != null && !unbindIds.isEmpty()) diagnoseMissionChMapper.batchDeleteMissionCh(unbindIds);
+
+    }
+
+    @Override
     public List<AlarmTypeSelectedVO> missionTypeList() {
         List<AlarmTypeSelectedVO> list = Lists.newArrayList();
         AlarmTypeSelectedVO bean;

+ 104 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/DiagnoseThresholdServiceImpl.java

@@ -6,7 +6,10 @@ import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
 import com.xunmei.common.core.enums.OrgTypeEnum;
+import com.xunmei.common.core.exception.ServiceException;
+import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.redis.utils.RedisUtils;
@@ -14,12 +17,14 @@ import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
 import com.xunmei.iot.mapper.DiagnoseThresholdChMapper;
 import com.xunmei.iot.service.DiagnoseThresholdService;
 import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo;
 import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.vo.SysOrgVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.List;
@@ -85,6 +90,105 @@ public class DiagnoseThresholdServiceImpl  implements DiagnoseThresholdService {
 
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void camerasBind(DiagnoseThresholdPageDto req) {
+        final SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, req.getCheckSub())) {
+            req.setOrgPath(sysOrg.getPath());
+            req.setOrgId(null);
+        }
+
+        Integer camerasCount = diagnoseThresholdChMapper.selectCamerasCount(req);
+        if (camerasCount == null || camerasCount == 0) {
+            String errorMsg = "绑定阈值查询条件筛选结果为空!";
+            throw  new ServiceException(errorMsg);
+        }
+
+        List<DiagnoseThresholdBindVo> list = diagnoseThresholdChMapper.selectCamerasBind(req);
+        //获取要绑定的通道
+        List<IotDeviceDiagnoseThresholdCh> batchInserts = Lists.newArrayList();
+
+        List<String> bindThresholdCodes = req.getBindThresholdCodes();
+        if (bindThresholdCodes != null && !bindThresholdCodes.isEmpty()) {
+            for (String bindThresholdCode:bindThresholdCodes) {
+                for (DiagnoseThresholdBindVo info : list) {
+                    String beanThresholdCodes = info.getThresholdCodes();
+                    //避免重复绑定
+                    if (StringUtils.isNotEmpty(beanThresholdCodes)
+                            &&beanThresholdCodes.contains(bindThresholdCode)) {continue;}
+
+                    IotDeviceDiagnoseThresholdCh ch = new IotDeviceDiagnoseThresholdCh();
+                    //1.生成绑定数据
+                    ch.setIotToken(info.getIotToken());
+                    ch.setDeviceProduct(info.getDeviceProduct());
+                    ch.setDvs(info.getDvs());
+                    ch.setChannel(info.getChannel());
+                    ch.setThresholdCode(bindThresholdCode);
+                    ch.setId(IDHelper.id());
+                    batchInserts.add(ch);
+                }
+            }
+            if (batchInserts != null && !batchInserts.isEmpty()) {
+                diagnoseThresholdChMapper.batchInsertThresholdCh(batchInserts);
+            }
+            //获取涉及阈值配置,并修改设备数量
+            for (String bindThresholdCode:bindThresholdCodes) {
+                diagnoseThresholdChMapper.updateDignoseNumber(bindThresholdCode);
+            }
+        }
+    }
+
+    @Override
+    public void camerasUnbind(DiagnoseThresholdPageDto req){
+        final SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
+        if (ObjectUtil.equal(Boolean.TRUE, req.getCheckSub())) {
+            req.setOrgPath(sysOrg.getPath());
+            req.setOrgId(null);
+        }
+
+        Integer camerasCount = diagnoseThresholdChMapper.selectCamerasCount(req);
+        if (camerasCount == null || camerasCount == 0) {
+            String errorMsg = "解绑阈值查询条件筛选结果为空!";
+            throw  new ServiceException(errorMsg);
+        }
+
+        List<DiagnoseThresholdBindVo> list = diagnoseThresholdChMapper.selectCamerasBind(req);
+
+        //需要解除绑定的id集合
+        List<Long> unbindIds = Lists.newArrayList();
+
+        List<String> unbindThresholdCodes = req.getBindThresholdCodes();
+        if (unbindThresholdCodes != null && !unbindThresholdCodes.isEmpty()) {
+            for (String unbindThresholdCode:unbindThresholdCodes) {
+                for (DiagnoseThresholdBindVo info : list) {
+                    String beanThresholdCodes = info.getThresholdCodes();
+                    //通道是否有绑定阈值
+                    if(StringUtils.isNotEmpty(beanThresholdCodes)) {
+                        String[] beanThresholdCodeArr = beanThresholdCodes.split(",");
+                        //通道绑定的阈值是否与将要解绑的一致,一致就解绑
+                        for (String beanThresholdCode : beanThresholdCodeArr) {
+                            if (beanThresholdCode.contains(unbindThresholdCode)) {
+                                String id = beanThresholdCode.split("#")[1];
+                                unbindIds.add(Long.parseLong(id));
+                            }
+                        }
+
+                    }
+                }
+            }
+
+            if (unbindIds != null && !unbindIds.isEmpty()) {
+                diagnoseThresholdChMapper.batchDeleteThresholdCh(unbindIds);
+            }
+            //获取涉及阈值配置,并修改设备数量
+            for (String bindThresholdCode:unbindThresholdCodes) {
+                diagnoseThresholdChMapper.updateDignoseNumber(bindThresholdCode);
+            }
+        }
+    }
+
+
+    @Override
     public List<AlarmTypeSelectedVO> thresholdTypeList() {
         List<AlarmTypeSelectedVO> list = Lists.newArrayList();
         AlarmTypeSelectedVO bean;

+ 57 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotDvsTemplateChannelServiceImpl.java

@@ -0,0 +1,57 @@
+package com.xunmei.iot.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.iot.domain.IotDvsTemplateChannel;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanPageDto;
+import com.xunmei.iot.dto.videoTemplateAndPlan.VideoChannelPlanTimeDto;
+import com.xunmei.iot.mapper.IotDvsTemplateChannelMapper;
+import com.xunmei.iot.service.IotDvsTemplateChannelService;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo;
+import com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.SysOrg;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author xujie
+ * @since 2024-11-15
+ */
+@Service
+public class IotDvsTemplateChannelServiceImpl extends ServiceImpl<IotDvsTemplateChannelMapper, IotDvsTemplateChannel> implements IotDvsTemplateChannelService {
+
+    @Resource
+    private IotDvsTemplateChannelMapper iotDvsTemplateChannelMapper;
+
+    @Resource
+    RemoteOrgService orgService;
+
+    @Override
+    public TableDataInfo<VideoChannelPlanVo> getChannelPlanList(VideoChannelPlanPageDto request) {
+        if (request.getCheckSub()) {
+            SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
+            request.setOrgPath(sysOrg.getPath());
+        }
+
+        Page<VideoChannelPlanVo> page = iotDvsTemplateChannelMapper.getChannelPlanList(request.getPageRequest(), request);
+
+        return TableDataInfo.build(page);
+    }
+
+    @Override
+    public List<VideoChannelPlanTimeVo> getChannelPlanTimeList(VideoChannelPlanTimeDto dto) {
+
+        return iotDvsTemplateChannelMapper.getChannelPlanTimeList(dto);
+    }
+
+
+}

+ 13 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/DiagnoseMissionBindVo.java

@@ -0,0 +1,13 @@
+package com.xunmei.iot.vo.sensor;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMissionCh;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class DiagnoseMissionBindVo extends IotDeviceDiagnoseMissionCh {
+    @JsonIgnore
+    @ApiModelProperty("已绑定阈值集合")
+    private String thresholdCodes;
+}

+ 14 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/DiagnoseThresholdBindVo.java

@@ -0,0 +1,14 @@
+package com.xunmei.iot.vo.sensor;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThresholdCh;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class DiagnoseThresholdBindVo extends IotDeviceDiagnoseThresholdCh{
+
+    @JsonIgnore
+    @ApiModelProperty("已绑定阈值集合")
+    private String thresholdCodes;
+}

+ 20 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/videoTemplateAndPlan/VideoChannelPlanTimeVo.java

@@ -0,0 +1,20 @@
+package com.xunmei.iot.vo.videoTemplateAndPlan;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class VideoChannelPlanTimeVo {
+
+    private Integer week;
+
+    private Integer type;
+
+    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+
+    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+}

+ 49 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/videoTemplateAndPlan/VideoChannelPlanVo.java

@@ -0,0 +1,49 @@
+package com.xunmei.iot.vo.videoTemplateAndPlan;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class VideoChannelPlanVo {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long deviceId;
+
+    //通道名称
+    private String channelName;
+
+    private String channelCode;
+
+    //录像机名称
+    private String dvsName;
+
+    private String netAddress;
+
+    private String orgName;
+
+    //录像模板名称
+    private String templateName;
+
+    //录像模板类型
+    private Integer planType;
+
+    //录像模板修改时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date planUpdateTime;
+
+    //录像计划最早时间
+    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
+    private Date minTime;
+
+    //录像计划最晚时间
+    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
+    private Date maxTime;
+
+    //获取录像计划失败原因
+    private String failRemark;
+}

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

@@ -44,6 +44,129 @@
 
     </select>
 
+    <select id="selectCamerasCount" resultType="java.lang.Integer">
+        select count(1) from
+        (
+        select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
+        (select mission_id from iot_device_diagnose_mission_ch ch where 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 limit 1) mission_id
+        from iot_device_info s
+        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
+        <if test="request.orgId!= null">
+            and s.org_id=#{request.orgId}
+        </if>
+        <if test="request.orgPath!= null">
+            and s.org_path like CONCAT(#{request.orgPath}, '%')
+        </if>
+        <if test="request.deviceName != null and request.deviceName!= ''">
+            and s.device_name like CONCAT('%',#{request.deviceName},'%')
+        </if>
+        order by s.host_code ,cast(s.device_code as signed)
+        ) c where 1=1
+        <choose>
+            <when test=" request.state == null">
+            </when>
+            <when test=" request.state == 0">
+                and c.mission_id is null
+            </when>
+            <otherwise>
+                and c.mission_id is not null
+            </otherwise>
+        </choose>
+        <choose>
+            <when test=" request.missionCode != null and request.missionCode != '' ">
+                and c.mission_id = #{request.missionCode}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+
+    </select>
+
+    <select id="selectCamerasBind" resultType="com.xunmei.iot.vo.sensor.DiagnoseMissionBindVo">
+        select c.* from
+        (
+        select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,ch.mission_id,ch.id,
+        (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where 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) threshold_codes
+        from iot_device_info s
+        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
+        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
+        <if test="request.orgId!= null">
+            and s.org_id=#{request.orgId}
+        </if>
+        <if test="request.orgPath!= null">
+            and s.org_path like CONCAT(#{request.orgPath}, '%')
+        </if>
+        <if test="request.deviceName != null and request.deviceName!= ''">
+            and s.device_name like CONCAT('%',#{request.deviceName},'%')
+        </if>
+        order by s.host_code ,cast(s.device_code as signed)
+        ) c where 1=1
+        <choose>
+            <when test=" request.state == null">
+            </when>
+            <when test=" request.state == 0">
+                and c.mission_id is null
+            </when>
+            <otherwise>
+                and c.mission_id is not null
+            </otherwise>
+        </choose>
+        <choose>
+            <when test=" request.missionCode != null and request.missionCode != '' ">
+                and c.mission_id = #{request.missionCode}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+
+    </select>
+
+
+    <insert id="batchInsertMissionCh" parameterType="java.util.List">
+        insert into iot_device_diagnose_mission_ch (id,mission_id,iot_token,device_product,dvs,channel)
+        values
+        <foreach collection="list" item="item" index="index" separator=",">
+            (#{item.id},#{item.missionId},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
+        </foreach>
+    </insert>
+    <update id="batchUpdateMissionCh" parameterType="java.util.List">
+        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
+            update iot_device_diagnose_mission_ch
+            <set>
+                <if test="item.missionId != null">
+                    mission_id = #{item.missionId},
+                </if>
+            </set>
+            where iot_token = #{item.iotToken} and device_product = #{item.deviceProduct}
+            and dvs = #{item.dvs} and channel = #{item.channel}
+        </foreach>
+    </update>
+
+    <insert id="batchInsertThresholdCh" parameterType="java.util.List">
+        insert into iot_device_diagnose_threshold_ch (id,threshold_code, iot_token,device_product,dvs,channel)
+        values
+        <foreach collection="list" item="item" index="index" separator="," >
+            (#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
+        </foreach>
+    </insert>
+
+
+    <delete id="batchDeleteMissionCh" parameterType="java.lang.Long">
+        delete from iot_device_diagnose_mission_ch where id in
+        <foreach collection="ids" item="item" index="index"
+                 open="(" separator="," close=")">#{item}
+        </foreach>
+    </delete>
+
     <select id="selectAllDiagnoseMission" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseMission">
         select * from iot_device_diagnose_mission
     </select>

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

@@ -44,6 +44,114 @@
 
     </select>
 
+
+    <select id="selectCamerasCount" resultType="java.lang.Integer">
+        select count(1) from
+        (
+        select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
+        (select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where 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) threshold_codes
+        from iot_device_info s
+        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
+        <if test="request.orgId!= null">
+            and s.org_id=#{request.orgId}
+        </if>
+        <if test="request.orgPath!= null">
+            and s.org_path like CONCAT(#{request.orgPath}, '%')
+        </if>
+        <if test="request.deviceName != null and request.deviceName!= ''">
+            and s.device_name like CONCAT('%',#{request.deviceName},'%')
+        </if>
+        order by s.host_code ,cast(s.device_code as signed)
+        ) c where 1=1
+        <choose>
+            <when test=" request.state == null">
+            </when>
+            <when test=" request.state == 0">
+                and c.threshold_codes is null
+            </when>
+            <otherwise>
+                and c.threshold_codes is not null
+            </otherwise>
+        </choose>
+        <choose>
+            <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
+                and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+
+    </select>
+
+    <select id="selectCamerasBind" resultType="com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo">
+        select c.* from
+        (
+        select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
+        (select group_concat(concat(threshold_code,'#',id)) from iot_device_diagnose_threshold_ch ch where 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) threshold_codes
+        from iot_device_info s
+        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
+        <if test="request.orgId!= null">
+            and s.org_id=#{request.orgId}
+        </if>
+        <if test="request.orgPath!= null">
+            and s.org_path like CONCAT(#{request.orgPath}, '%')
+        </if>
+        <if test="request.deviceName != null and request.deviceName!= ''">
+            and s.device_name like CONCAT('%',#{request.deviceName},'%')
+        </if>
+        order by s.host_code ,cast(s.device_code as signed)
+        ) c where 1=1
+        <choose>
+            <when test=" request.state == null">
+            </when>
+            <when test=" request.state == 0">
+                and c.threshold_codes is null
+            </when>
+            <otherwise>
+                and c.threshold_codes is not null
+            </otherwise>
+        </choose>
+        <choose>
+            <when test=" request.thresholdCode != null and request.thresholdCode != '' ">
+                and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+
+    </select>
+
+    <insert id="batchInsertThresholdCh" parameterType="java.util.List">
+        insert into iot_device_diagnose_threshold_ch (id,threshold_code,iot_token,device_product,dvs,channel)
+        values
+        <foreach collection="list" item="item" index="index" separator=",">
+            (#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
+        </foreach>
+    </insert>
+
+    <delete id="batchDeleteThresholdCh" parameterType="java.lang.Long">
+        delete from iot_device_diagnose_threshold_ch where id in
+        <foreach collection="ids" item="item" index="index"
+                 open="(" separator="," close=")">#{item}
+        </foreach>
+    </delete>
+
+    <select id="updateDignoseNumber" resultType="java.lang.Integer">
+        update iot_device_diagnose_threshold set dignose_number =
+        (
+           select count(1) from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
+        )
+        where threshold_code =  #{thresholdCode}
+    </select>
+
     <select id="selectAllDiagnoseThreshold" resultType="com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold">
         select * from iot_device_diagnose_threshold
     </select>

+ 62 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/IotDvsTemplateChannelMapper.xml

@@ -0,0 +1,62 @@
+<?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.iot.mapper.IotDvsTemplateChannelMapper">
+
+    <select id="getChannelPlanList" resultType="com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanVo">
+        SELECT
+            d.id as device_id,
+            d.device_name as channel_name,
+            d.device_code as channel_code,
+            i.device_name as dvs_name,
+            e.net_address,
+            d.org_name,
+            a.`name` as template_name,
+            p.plan_type,
+            p.update_time as plan_update_time,
+            p.fail_remark,
+            p.min_time,
+            p.max_time
+        FROM
+            iot_device_info d
+            LEFT JOIN iot_device_info i ON d.host_code = i.device_code
+            LEFT JOIN iot_device_info_extend e ON e.device_id = i.id
+            LEFT JOIN iot_dvs_template_channel t ON d.iot_token = t.iot_token and d.host_code = t.dvs_code and d.device_code = t.channel_code
+            LEFT JOIN iot_dvs_template a ON t.iot_token = a.iot_token and t.template_md5 = a.template_md5
+            LEFT JOIN iot_dvs_plantype p ON d.iot_token = p.iot_token and d.host_code = p.dvs_code and d.device_code = p.channel_code
+        WHERE
+            d.device_type = 3
+            and d.deleted = 0
+            <choose>
+                <when test="req.checkSub == false">
+                    and d.org_id=#{req.orgId}
+                </when>
+                <otherwise>
+                    and d.org_path like concat(#{req.orgPath},'%')
+                </otherwise>
+            </choose>
+            <if test="req.channelName != null and req.channelName != ''">
+                and d.device_name like concat('%',#{req.channelName},'%')
+            </if>
+            <if test="req.dvsName != null and req.dvsName != ''">
+                and i.device_name like concat('%',#{req.dvsName},'%')
+            </if>
+    </select>
+
+    <select id="getChannelPlanTimeList" resultType="com.xunmei.iot.vo.videoTemplateAndPlan.VideoChannelPlanTimeVo">
+        SELECT
+            p.type,
+            p.`week`,
+            p.start_time,
+            p.end_time
+        FROM
+            iot_dvs_plantime p
+            LEFT JOIN iot_device_info d ON p.dvs_code = d.host_code AND p.channel_code = d.device_code AND p.iot_token = d.iot_token
+        WHERE
+            d.id = #{req.deviceId}
+            <if test="req.week != null and req.week != -1">
+                AND p.`week` = #{req.week}
+            </if>
+        ORDER BY
+            p.`week` ASC
+    </select>
+</mapper>