Ver Fonte

告警规则代码修改

jingyuanchao há 1 ano atrás
pai
commit
bd2ed68895
29 ficheiros alterados com 315 adições e 258 exclusões
  1. 5 9
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmData.java
  2. 18 13
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRule.java
  3. 22 36
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRuleExpress.java
  4. 23 18
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRuleSource.java
  5. 17 36
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmSystemField.java
  6. 2 2
      soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/util/CodeGenerators.java
  7. 10 18
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/alarm/service/impl/IotAlarmDataServiceImpl.java
  8. 9 9
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceStatusServiceImpl.java
  9. 8 10
      soc-modules/soc-modules-host/src/main/java/com/xunmei/host/protection/service/impl/IotAlarmHostServiceImpl.java
  10. 13 7
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotAlarmRuleController.java
  11. 6 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleDto.java
  12. 1 1
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleExpressDto.java
  13. 2 2
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleQueryDto.java
  14. 1 1
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleSourceDeviceDto.java
  15. 5 2
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotAlarmRuleMapper.java
  16. 5 1
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotAlarmRuleService.java
  17. 58 36
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleServiceImpl.java
  18. 20 17
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleSourceServiceImpl.java
  19. 1 2
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleExpressEditVo.java
  20. 9 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleSourceDeviceVo.java
  21. 12 12
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmSystemFieldVo.java
  22. 6 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotInitAlarmRuleVo.java
  23. 9 0
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/ProductDeviceTempVo.java
  24. 2 1
      soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/ProductTypeDataVo.java
  25. 22 0
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmRuleMapper.xml
  26. 14 10
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmRuleSourceMapper.xml
  27. 1 1
      soc-modules/soc-modules-iot/src/main/resources/mapper/IotServerInfoMapper.xml
  28. 11 11
      soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/alarm/service/impl/IotAlarmDataServiceImpl.java
  29. 3 3
      soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/iot/service/impl/IotDeviceStatusServiceImpl.java

+ 5 - 9
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmData.java

@@ -1,14 +1,8 @@
 package com.xunmei.common.core.domain.mediator.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 com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.xunmei.common.core.web.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
@@ -16,6 +10,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.time.LocalDateTime;
+
 /**
  * <p>
  * 告警数据表
@@ -58,7 +54,7 @@ public class IotAlarmData extends BaseEntity {
 
     @ApiModelProperty(value = "报警源类型(设备类型):4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;50:报警防区")
     @TableField("source_type")
-    private Integer sourceType;
+    private String sourceType;
 
     @ApiModelProperty(value = "报警源类型(设备类型) 中文")
     @TableField("source_type_des")

+ 18 - 13
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRule.java

@@ -1,31 +1,28 @@
 package com.xunmei.common.core.domain.mediator.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 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.time.LocalDateTime;
+
 /**
  * <p>
  * 告警规则表
  * </p>
  *
- * @author oygj
- * @since 2024-01-26
+ * @author jingYuanChao
+ * @since 2024-09-13
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("iot_alarm_rule")
-@ApiModel(value = "IotAlarmRule对象", description = "告警规则表")
+@ApiModel(value="IotAlarmRule对象", description="告警规则表")
 public class IotAlarmRule implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -33,6 +30,14 @@ public class IotAlarmRule implements Serializable {
     @TableId("id")
     private Long id;
 
+    @ApiModelProperty(value = "机构id")
+    @TableField("org_id")
+    private Long orgId;
+
+    @ApiModelProperty(value = "主机code")
+    @TableField("iot_code")
+    private String iotCode;
+
     @ApiModelProperty(value = "规则名称")
     @TableField("name")
     private String name;
@@ -45,9 +50,9 @@ public class IotAlarmRule implements Serializable {
     @TableField("isdeleted")
     private Integer isdeleted;
 
-    @ApiModelProperty(value = "alarm:告警,inspection:一键巡检;默认值为告警")
+    @ApiModelProperty(value = "alarm:告警,inspection:一键巡检")
     @TableField("type")
-    private String type = "alarm";
+    private String type;
 
     @ApiModelProperty(value = "备注信息")
     @TableField("remark")

+ 22 - 36
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRuleExpress.java

@@ -1,31 +1,28 @@
 package com.xunmei.common.core.domain.mediator.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 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.time.LocalDateTime;
+
 /**
  * <p>
  * 告警规则表达式表
  * </p>
  *
- * @author oygj
- * @since 2024-01-26
+ * @author jingYuanChao
+ * @since 2024-09-13
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("iot_alarm_rule_express")
-@ApiModel(value = "IotAlarmRuleExpress对象", description = "告警规则表达式表")
+@ApiModel(value="IotAlarmRuleExpress对象", description="告警规则表达式表")
 public class IotAlarmRuleExpress implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -37,11 +34,15 @@ public class IotAlarmRuleExpress implements Serializable {
     @TableField("rule_id")
     private Long ruleId;
 
-    @ApiModelProperty(value = "属性code")
-    @TableField("fieldCode")
-    private String fieldcode;
+    @ApiModelProperty(value = "产品类型")
+    @TableField("product_type")
+    private String productType;
+
+    @ApiModelProperty(value = "产品属性")
+    @TableField("product_property")
+    private String productProperty;
 
-    @ApiModelProperty(value = "操作符,GT(大于)、GTE(大于等于)、LT(小于)、LTE(小于等于)、EQUALS(等于)、STARTS_WITH(以什么开始)、	ENDS_WITH(以什么结束)、CONTAIN(包含)")
+    @ApiModelProperty(value = "操作符,GT(大于)、GTE(大于等于)、LT(小于)、LTE(小于等	于)、EQUALS(等于)、STARTS_WITH(以什么开始)、	ENDS_WITH(以什么结束)、CONTAIN(包含)")
     @TableField("operator")
     private String operator;
 
@@ -53,37 +54,22 @@ public class IotAlarmRuleExpress implements Serializable {
     @TableField("value_text")
     private String valueText;
 
-    @ApiModelProperty(value = "报警源类型:4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;50:报警防区")
-    @TableField("source_type")
-    private Integer sourceType;
-
-    @ApiModelProperty(value = "是否需要发送短信:0.不需要发送短信;1.需要发送短信")
-    @TableField("sms_type")
-    private Boolean smsType = false;
-
-    /**
-     * 采用时间段方式,农信版本不使用时间模板,不撤防不加入报警列表
-     */
-/*    @ApiModelProperty(value = "时间模板编码")
-    @TableField("time_template_id")
-    private Integer timeTemplateId;
-
-    @ApiModelProperty(value = "是否使用作息时间模板(0否1是)")
-    @TableField("is_use_work_template")
-    private Integer isUseWorkTemplate;*/
-
     @ApiModelProperty(value = "规则使用周期:1.周一,2.周二,3.周三,4.周四,5.周五,6.周六,7.周日")
     @TableField("week_day")
     private Integer weekDay;
 
-    @ApiModelProperty(value = "开始时间")
+    @ApiModelProperty(value = "开始时间如:07:30")
     @TableField("start_time")
     private String startTime;
 
-    @ApiModelProperty(value = "结束时间")
+    @ApiModelProperty(value = "结束时间如:16:00")
     @TableField("end_time")
     private String endTime;
 
+    @ApiModelProperty(value = "是否需要发送短信:0不需要,1需要")
+    @TableField("sms_type")
+    private Integer smsType;
+
     @ApiModelProperty(value = "创建人")
     @TableField("create_by")
     private String createBy;

+ 23 - 18
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmRuleSource.java

@@ -1,31 +1,28 @@
 package com.xunmei.common.core.domain.mediator.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 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.time.LocalDateTime;
+
 /**
  * <p>
  * 告警规则与设备源关系表
  * </p>
  *
- * @author oygj
- * @since 2024-01-26
+ * @author jingYuanChao
+ * @since 2024-09-13
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("iot_alarm_rule_source")
-@ApiModel(value = "IotAlarmRuleSource对象", description = "告警规则与设备源关系表")
+@ApiModel(value="IotAlarmRuleSource对象", description="告警规则与设备源关系表")
 public class IotAlarmRuleSource implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -33,23 +30,31 @@ public class IotAlarmRuleSource implements Serializable {
     @TableId("id")
     private Long id;
 
-    @ApiModelProperty(value = "value_type=Device时有值为设备所属机构Id,否则为空")
+    @ApiModelProperty(value = "机构id")
     @TableField("org_id")
     private Long orgId;
 
-    @ApiModelProperty(value = "报警规则编码")
+    @ApiModelProperty(value = "iotCode")
+    @TableField("iot_code")
+    private String iotCode;
+
+    @ApiModelProperty(value = "报警规则id")
     @TableField("rule_id")
     private Long ruleId;
 
-    @ApiModelProperty(value = "报警源类型:4:烟雾传感器;5:温湿度采集器;6:水浸,7:门磁:窗磁,8:卷帘门门磁;9:地磁,10:燃气报警器,50:报警防区")
-    @TableField("source_type")
-    private Integer sourceType;
+    @ApiModelProperty(value = "产品类型")
+    @TableField("product_type")
+    private String productType;
+
+    @ApiModelProperty(value = "source_type=Device时有值为设备Id,否则为空")
+    @TableField("device_code")
+    private String deviceCode;
 
-    @ApiModelProperty(value = "value_type=Device时有值为设备Id,否则为空")
+    @ApiModelProperty(value = "绑定设备值")
     @TableField("value")
     private String value;
 
-    @ApiModelProperty(value = "AllDevice:所有设备,Device:单个设备")
+    @ApiModelProperty(value = "设备源: AllDevice:所有设备,Device:单个设备")
     @TableField("value_type")
     private String valueType;
 

+ 17 - 36
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/mediator/domain/IotAlarmSystemField.java

@@ -10,20 +10,19 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.io.Serializable;
-import java.time.LocalDateTime;
 
 /**
  * <p>
  * 系统报警属性字段表
  * </p>
  *
- * @author oygj
- * @since 2024-01-26
+ * @author jingYuanChao
+ * @since 2024-09-13
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("iot_alarm_system_field")
-@ApiModel(value = "IotAlarmSystemField对象", description = "系统报警属性字段表")
+@ApiModel(value="IotAlarmSystemField对象", description="系统报警属性字段表")
 public class IotAlarmSystemField implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -32,39 +31,33 @@ public class IotAlarmSystemField implements Serializable {
     @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
-    @ApiModelProperty(value = "报警源类型(设备类型):4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;50:报警防区")
-    @TableField("source_type")
-    private Integer sourceType;
+    @ApiModelProperty(value = "产品类型")
+    @TableField("product_type")
+    private String productType;
 
     @ApiModelProperty(value = "报警源类型(设备类型) 中文")
-    @TableField("source_type_des")
-    private String sourceTypeDes;
+    @TableField("product_name")
+    private String productName;
 
     @ApiModelProperty(value = "系统属性code(报警类型编码,全表唯一)")
-    @TableField("sys_field_code")
-    private String sysFieldCode;
+    @TableField("product_property")
+    private String productProperty;
 
     @ApiModelProperty(value = "系统属性名称")
-    @TableField("name")
-    private String name;
+    @TableField("product_property_display_name")
+    private String productPropertyDisplayName;
 
-    @ApiModelProperty(value = "属性名称")
-    @TableField("property_name")
-    private String propertyName;
-
-    @ApiModelProperty(value = "属性规格信息,eg:{'0': '门已关闭','1': '门已打开'}")
     @TableField("specs")
     private String specs;
 
-    @ApiModelProperty(value = "该属性拥有哪些操作符eg:{ 'GT': '大于', 'LT': '小于' }GT(大于)、GTE(大于等于)、LT(小于)、LTE(小于等于)、EQUALS(等于)、STARTS_WITH(以什么开始)、	ENDS_WITH(以什么结束)、CONTAIN(包含)")
     @TableField("operators")
     private String operators;
 
-    @ApiModelProperty(value = "数据值类型,eg:'FLOAT'、'ENUM')")
+    @ApiModelProperty(value = "数据值类型,eg:”FLOAT“、'ENUM'")
     @TableField("type")
     private String type;
 
-    @ApiModelProperty(value = "数据值类型中午描述,eg:'浮点型'、'枚举')")
+    @ApiModelProperty(value = "数据值类型字段描述,eg:”浮点型“、'枚举'")
     @TableField("type_des")
     private String typeDes;
 
@@ -80,21 +73,9 @@ public class IotAlarmSystemField implements Serializable {
     @TableField("alarm_rule_property")
     private Integer alarmRuleProperty;
 
-    @ApiModelProperty(value = "创建人")
-    @TableField("create_by")
-    private String createBy;
-
-    @ApiModelProperty(value = "创建人名称")
-    @TableField("create_time")
-    private LocalDateTime createTime;
-
-    @ApiModelProperty(value = "修改人名称")
-    @TableField("update_by")
-    private String updateBy;
-
-    @ApiModelProperty(value = "修改时间")
-    @TableField("update_time")
-    private LocalDateTime updateTime;
+    @ApiModelProperty(value = "排序值")
+    @TableField("`order`")
+    private Integer order;
 
 
 }

+ 2 - 2
soc-modules/soc-modules-gen/src/main/java/com/xunmei/gen/util/CodeGenerators.java

@@ -29,8 +29,8 @@ public class CodeGenerators {
         throw new MybatisPlusException("请输入正确的" + tip + "!");
     }*/
 
-    public static final String moduleName="com.xunmei.host";
-    public static final String tableNames="iot_day_work_field";
+    public static final String moduleName="com.xunmei.core";
+    public static final String tableNames="iot_alarm_rule,iot_alarm_rule_source,iot_alarm_rule_express,iot_alarm_system_field";
 
     public static void main(String[] args) {
         // 代码生成器

+ 10 - 18
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/alarm/service/impl/IotAlarmDataServiceImpl.java

@@ -1,7 +1,6 @@
 package com.xunmei.host.alarm.service.impl;
 
 
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -13,7 +12,6 @@ import com.xunmei.common.core.domain.iot.domain.IotDvrHardDiskDetection;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleExpress;
-import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleSource;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmSystemField;
 import com.xunmei.common.core.domain.video.MediatorVideoDiagnosisRecord;
 import com.xunmei.common.core.utils.DateUtils;
@@ -26,13 +24,11 @@ import com.xunmei.host.alarm.service.IotAlarmDataService;
 import com.xunmei.host.enums.AlarmDataTypeEnum;
 import com.xunmei.host.enums.AlarmRuleExpressOperateEnum;
 import com.xunmei.host.enums.AlarmVideoTypeEnum;
-import com.xunmei.host.enums.SmsNotifyType;
 import com.xunmei.host.iot.mapper.IotDeviceStatusMapper;
 import com.xunmei.system.api.RemoteConfigService;
 import com.xunmei.system.api.RemoteSmsService;
 import com.xunmei.system.api.domain.SysConfig;
 import com.xunmei.system.api.domain.iot.IotDeviceStatus;
-import com.xunmei.system.api.util.LogUtils;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -43,11 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -82,7 +74,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void dealDeviceStatusData(IotDeviceStatus deviceStatus) throws Exception {
-        Date now = new Date();
+      /*  Date now = new Date();
         //判断是否有绑定规则
         QueryWrapper<IotAlarmRuleSource> qw = new QueryWrapper<>();
         qw.lambda().eq(IotAlarmRuleSource::getValue, deviceStatus.getUniqueCode())
@@ -102,7 +94,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         System.out.println(weekDay);
         QueryWrapper<IotAlarmRuleExpress> ruleExpress = new QueryWrapper<>();
         ruleExpress.lambda().eq(IotAlarmRuleExpress::getRuleId, iotAlarmRuleSource.getRuleId())
-                .eq(IotAlarmRuleExpress::getSourceType, iotAlarmRuleSource.getSourceType())
+                .eq(IotAlarmRuleExpress::getProductType, iotAlarmRuleSource.getSourceType())
                 .eq(IotAlarmRuleExpress::getWeekDay, weekDay);
         List<IotAlarmRuleExpress> iotAlarmRuleExpresses = iotAlarmRuleExpressMapper.selectList(ruleExpress);
 
@@ -201,7 +193,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
                 }
             }
         }
-    }
+    */}
 
    /* @Transactional(rollbackFor = Exception.class)
     @Override
@@ -473,7 +465,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(equipmentName + "-" + diskName);
         iotAlarmData.setRuleId(1L);
-        iotAlarmData.setSourceType(AlarmVideoTypeEnum.DVRDISK.getValue());
+       // iotAlarmData.setSourceType(AlarmVideoTypeEnum.DVRDISK.getValue());
         iotAlarmData.setSourceTypeDes(AlarmVideoTypeEnum.getTextByValue(AlarmVideoTypeEnum.DVRDISK.getValue()) + "告警");
         iotAlarmData.setFieldCode(AlarmVideoTypeEnum.DVRDISK.getValue() + "");
         iotAlarmData.setOperator("EQUALS");
@@ -520,8 +512,8 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         String settingValue = express.getValue();
         String infos = deviceStatus.getInfo();
         Map<String, String> dataMap = dealInfos(infos);
-        IotAlarmSystemField field = fieldMap.get(express.getFieldcode());
-        String sensorValue = dataMap.get(field.getName());
+        IotAlarmSystemField field = fieldMap.get(express.getProductType());
+        String sensorValue = dataMap.get(field.getProductName());
         if (StringUtils.isEmpty(sensorValue)) {
             return null;
         }
@@ -584,7 +576,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
             iotAlarmData.setDeviceName(deviceName + "-" + channelName);
         }
         iotAlarmData.setRuleId(1L);
-        iotAlarmData.setSourceType(diagnosisType);
+        iotAlarmData.setSourceType(diagnosisType+"");
         iotAlarmData.setSourceTypeDes(AlarmVideoTypeEnum.getTextByValue(diagnosisType) + "告警");
         iotAlarmData.setFieldCode(diagnosisType + "");
         iotAlarmData.setOperator("EQUALS");
@@ -603,9 +595,9 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(deviceStatus.getDeviceName());
         iotAlarmData.setRuleId(express.getRuleId());
-        iotAlarmData.setSourceType(field.getSourceType());
-        iotAlarmData.setSourceTypeDes(field.getSourceTypeDes() + "告警");
-        iotAlarmData.setFieldCode(field.getSysFieldCode());
+        iotAlarmData.setSourceType(field.getProductType());
+        iotAlarmData.setSourceTypeDes(field.getProductPropertyDisplayName() + "告警");
+        iotAlarmData.setFieldCode(field.getProductProperty());
         iotAlarmData.setOperator(express.getOperator());
         iotAlarmData.setValue(express.getValue());
         iotAlarmData.setValueText(express.getValueText());

+ 9 - 9
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceStatusServiceImpl.java

@@ -81,8 +81,8 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
 
             final Optional<IotAlarmSystemField> fieldOptional = fieldList
                     .stream()
-                    .filter(r -> ObjectUtil.equal(r.getPropertyName(), jsb.get("propertyName")))
-                    .filter(r -> ObjectUtil.equal(deviceType, String.valueOf(r.getSourceType())))
+                    .filter(r -> ObjectUtil.equal(r.getProductProperty(), jsb.get("propertyName")))
+                    .filter(r -> ObjectUtil.equal(deviceType, String.valueOf(r.getProductType())))
                     .findFirst();
             if (fieldOptional.isPresent()) {
                 final IotAlarmSystemField systemField = fieldOptional.get();
@@ -91,12 +91,12 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
                 array.add(object);
                 if (ObjectUtil.isNotEmpty(unit)) {
                     //说明不是开关量
-                    object.put("name", systemField.getName());
+                    object.put("name", systemField.getProductPropertyDisplayName());
                     object.put("val", jsb.get("propertyValue"));
                     object.put("res", jsb.get("propertyValue") + unit);
                     object.put("unit", unit);
                 } else {
-                    object.put("name", systemField.getName());
+                    object.put("name", systemField.getProductPropertyDisplayName());
                     object.put("val", jsb.get("propertyValue"));
                     final String specs = systemField.getSpecs();
                     final Map map = JSON.parseObject(specs, Map.class);
@@ -188,13 +188,13 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
             iotAlarmData.setTime(dataReq.getStartTime());
             final String sourceType = SensorType.getCodeByProduct(dataReq.getProductType());
             fieldList.stream()
-                    .filter(r -> ObjectUtil.equal(String.valueOf(r.getSourceType()), sourceType))
-                    .filter(r -> ObjectUtil.equal(r.getPropertyName(), dataReq.getProductProperty()))
+                    .filter(r -> ObjectUtil.equal(String.valueOf(r.getProductType()), sourceType))
+                    .filter(r -> ObjectUtil.equal(r.getProductProperty(), dataReq.getProductProperty()))
                     .findAny()
                     .ifPresent(r -> {
-                        iotAlarmData.setSourceType(r.getSourceType());
-                        iotAlarmData.setSourceTypeDes(r.getSourceTypeDes());
-                        iotAlarmData.setFieldCode(r.getSysFieldCode());
+                        iotAlarmData.setSourceType(r.getProductType());
+                        iotAlarmData.setSourceTypeDes(r.getProductName());
+                        iotAlarmData.setFieldCode(r.getProductType());
                     });
             iotAlarmDataService.saveOrUpdate(iotAlarmData);
             // 发生报警

+ 8 - 10
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/protection/service/impl/IotAlarmHostServiceImpl.java

@@ -10,7 +10,6 @@ import com.xunmei.common.core.domain.iot.domain.*;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmSystemField;
 import com.xunmei.common.core.enums.iot.DeviceTypeEnum;
-import com.xunmei.common.core.enums.iot.SensorType;
 import com.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.utils.JacksonUtils;
@@ -18,7 +17,6 @@ import com.xunmei.common.redis.utils.RedisUtils;
 import com.xunmei.host.alarm.mapper.IotAlarmDataMapper;
 import com.xunmei.host.alarm.mapper.IotAlarmSystemFieldMapper;
 import com.xunmei.host.enums.AlarmDataTypeEnum;
-import com.xunmei.host.enums.IotInputSensorTypeEnum;
 import com.xunmei.host.enums.IotInputStatusEnum;
 import com.xunmei.host.iot.mapper.IotDeviceStatusLogMapper;
 import com.xunmei.host.iot.mapper.IotDeviceStatusMapper;
@@ -421,7 +419,7 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
         String arrInfo = JSON.toJSONString(arr);
         String displayName = input.getDefenceAreaName();
         IotAlarmSystemField field = fieldList.get(0);
-        String deviceType = String.valueOf(field.getSourceType());
+        String deviceType = String.valueOf(field.getProductType());
         //入库状态app附表
         QueryWrapper<IotDeviceStatus> wrapper = new QueryWrapper<>();
         wrapper.eq("device_type", deviceType);
@@ -468,7 +466,7 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
         String infos = status.getInfo();
         Map<String, String> dataMap = dealInfos(infos);
 
-        String sensorValue = dataMap.get(field.getName());
+        String sensorValue = dataMap.get(field.getProductProperty());
         if (StringUtils.isBlank(sensorValue)) {
             return ;
         }
@@ -529,7 +527,7 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
 
         IotAlarmSystemField bean = null;
         for(IotAlarmSystemField field:fieldList){
-            if(datum.getPropertyName().equals(field.getPropertyName())){
+            if(datum.getPropertyName().equals(field.getProductProperty())){
                 bean = field;
             }
         }
@@ -537,7 +535,7 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
             return array;
         }
 
-        String name = bean.getName();
+        String name = bean.getProductPropertyDisplayName();
         object.put("name", name);
         object.put("val", val);
 
@@ -573,7 +571,7 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
     //分析组装alarmData数据
     private IotAlarmData builderAlarm(String sensorValue, IotAlarmSystemField field, IotDeviceStatus iotDeviceStatus) {
         String deviceName = iotDeviceStatus.getDeviceName();
-        String productName = field.getSourceTypeDes();
+        String productName = field.getProductName();
 
         IotAlarmData iotAlarmData = new IotAlarmData();
         iotAlarmData.setId(IDHelper.id());
@@ -581,9 +579,9 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(deviceName);
         iotAlarmData.setRuleId(-1L);//规则id
-        iotAlarmData.setSourceType(field.getSourceType());
-        iotAlarmData.setSourceTypeDes(field.getSourceTypeDes() + "告警");
-        iotAlarmData.setFieldCode(field.getSysFieldCode());
+        iotAlarmData.setSourceType(field.getProductType());
+        iotAlarmData.setSourceTypeDes(field.getProductPropertyDisplayName() + "告警");
+        iotAlarmData.setFieldCode(field.getProductProperty());
         iotAlarmData.setOperator(field.getOperators());//规则操作符
         iotAlarmData.setValue(sensorValue);//规则值
         iotAlarmData.setValueText(IotInputStatusEnum.ALARM.getName());//规则值描述

+ 13 - 7
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotAlarmRuleController.java

@@ -1,5 +1,6 @@
 package com.xunmei.iot.controller;
 
+import cn.hutool.core.lang.Pair;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleDto;
@@ -21,7 +22,7 @@ public class IotAlarmRuleController {
 
     @ApiOperation(value = "新增界面初始化数据;")
     @GetMapping(value = "/getAddAlarmRule")
-    public AjaxResult getAddAlarmRule(){
+    public AjaxResult getAddAlarmRule() {
         try {
             IotInitAlarmRuleVo data = iotAlarmRuleService.getAddInitAlarmRuleData();
             return AjaxResult.success(data);
@@ -33,7 +34,7 @@ public class IotAlarmRuleController {
 
     @ApiOperation(value = "修改界面")
     @GetMapping(value = "/getRuleById/{ruleId}")
-    public AjaxResult getRuleById(@PathVariable Long ruleId){
+    public AjaxResult getRuleById(@PathVariable Long ruleId) {
         try {
             IotInitAlarmRuleVo alarmRuleData = iotAlarmRuleService.getAlarmRuleData(ruleId);
             return AjaxResult.success(alarmRuleData);
@@ -45,11 +46,11 @@ public class IotAlarmRuleController {
 
     @ApiOperation(value = "查询报警规则")
     @PostMapping(value = "/getRules")
-    public TableDataInfo<IotInitAlarmRuleVo> getRules(@RequestBody IotAlarmRuleQueryDto args){
+    public TableDataInfo<IotInitAlarmRuleVo> getRules(@RequestBody IotAlarmRuleQueryDto args) {
         try {
 //            ruleName = ruleName.trim();
 //            if(ruleName.equals("undefined")) ruleName = "";
-            TableDataInfo<IotInitAlarmRuleVo> alarmRuleData = iotAlarmRuleService.getAlarmRuleDatas(args.getRuleType(),args.getRuleName(),args.getPageNum(),args.getPageSize());
+            TableDataInfo<IotInitAlarmRuleVo> alarmRuleData = iotAlarmRuleService.getAlarmRuleData(args);
             return alarmRuleData;
         } catch (Exception e) {
             e.printStackTrace();
@@ -63,7 +64,7 @@ public class IotAlarmRuleController {
 
     @ApiOperation(value = "保存或者更新告警规则")
     @PostMapping(value = "/saveOrUpdateAlarmRule")
-    public AjaxResult saveOrUpdateAlarmRule( @RequestBody IotAlarmRuleDto request) {
+    public AjaxResult saveOrUpdateAlarmRule(@RequestBody IotAlarmRuleDto request) {
         try {
             iotAlarmRuleService.saveOrUpdateAlarmRule(request);
             return AjaxResult.success();
@@ -75,7 +76,7 @@ public class IotAlarmRuleController {
 
     @ApiOperation(value = "修改界面")
     @GetMapping(value = "/deleteRule/{ruleId}")
-    public AjaxResult deleteRuleById(@PathVariable Long ruleId){
+    public AjaxResult deleteRuleById(@PathVariable Long ruleId) {
         try {
             iotAlarmRuleService.deleteAlarmRule(ruleId);
             return AjaxResult.success();
@@ -85,5 +86,10 @@ public class IotAlarmRuleController {
         }
     }
 
-
+    @ApiOperation(value = "获取机构下所有主机信息")
+    @GetMapping(value = "/getConnectHostOrg/{orgId}")
+    public AjaxResult getConnectHostOrg(@PathVariable Long orgId) {
+        List<Pair<String, String>> data = iotAlarmRuleService.getConnectHostOrg(orgId);
+        return AjaxResult.success(data);
+    }
 }

+ 6 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleDto.java

@@ -22,9 +22,15 @@ public class IotAlarmRuleDto implements Serializable {
 
     private Long id;
 
+    @ApiModelProperty(value = "所属机构")
+    private Long orgId;
+
     @ApiModelProperty(value = "规则名称")
     private String name;
 
+    @ApiModelProperty(value = "所属主机")
+    private String iotCode;
+
     @ApiModelProperty(value = "是否启用")
     private Integer enabled;
 

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleExpressDto.java

@@ -38,7 +38,7 @@ public class IotAlarmRuleExpressDto implements Serializable {
     private String valueText;
 
     @ApiModelProperty(value = "报警源类型:4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;20:报警防区")
-    private Integer sourceType;
+    private String sourceType;
 
     @ApiModelProperty(value = "是否需要发送短信:0.不需要发送短信;1.需要发送短信")
     private Boolean smsType = false;

+ 2 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleQueryDto.java

@@ -1,10 +1,10 @@
 package com.xunmei.iot.dto.alarm;
 
-import com.xunmei.common.core.web.domain.PageDto;
+import com.xunmei.common.core.web.domain.PageRequest;
 import lombok.Data;
 
 @Data
-public class IotAlarmRuleQueryDto extends PageDto {
+public class IotAlarmRuleQueryDto extends PageRequest {
 
     private String ruleName;
 

+ 1 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/alarm/IotAlarmRuleSourceDeviceDto.java

@@ -28,7 +28,7 @@ public class IotAlarmRuleSourceDeviceDto {
      */
     @ApiModelProperty(value = "产品类型")
     @NotNull(message = "请选择产品类型进行添加设备!")
-    private Integer type;
+    private String type;
 
     private int page;
 

+ 5 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotAlarmRuleMapper.java

@@ -1,9 +1,12 @@
 package com.xunmei.iot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
-import org.apache.ibatis.annotations.Mapper;
+import com.xunmei.iot.dto.alarm.IotAlarmRuleQueryDto;
+import org.apache.ibatis.annotations.Param;
 
-@Mapper
 public interface IotAlarmRuleMapper extends BaseMapper<IotAlarmRule> {
+    IPage<IotAlarmRule> selectPageData(Page<IotAlarmRule> pageRequest, @Param("req") IotAlarmRuleQueryDto req);
 }

+ 5 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IotAlarmRuleService.java

@@ -1,9 +1,11 @@
 package com.xunmei.iot.service;
 
+import cn.hutool.core.lang.Pair;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleDto;
+import com.xunmei.iot.dto.alarm.IotAlarmRuleQueryDto;
 import com.xunmei.iot.vo.alarm.IotInitAlarmRuleVo;
 
 import java.util.List;
@@ -35,7 +37,7 @@ public interface IotAlarmRuleService extends IService<IotAlarmRule> {
      * @param pageSize
      * @return {@link IotInitAlarmRuleVo}
      */
-    TableDataInfo<IotInitAlarmRuleVo> getAlarmRuleDatas(String alarmType, String ruleName, Long pageIndex, Long pageSize) throws Exception;
+    TableDataInfo<IotInitAlarmRuleVo> getAlarmRuleData(IotAlarmRuleQueryDto args) throws Exception;
 
     /**
      *
@@ -45,4 +47,6 @@ public interface IotAlarmRuleService extends IService<IotAlarmRule> {
     void saveOrUpdateAlarmRule(IotAlarmRuleDto ruleDto)throws Exception;
 
     void deleteAlarmRule(Long ruleId);
+
+    List<Pair<String, String>> getConnectHostOrg(Long orgId);
 }

+ 58 - 36
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleServiceImpl.java

@@ -1,11 +1,13 @@
 package com.xunmei.iot.service.impl;
 
+import cn.hutool.core.lang.Pair;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-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.IotServerInfo;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleExpress;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleSource;
@@ -17,12 +19,17 @@ import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.security.utils.SecurityUtils;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleDto;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleExpressDto;
+import com.xunmei.iot.dto.alarm.IotAlarmRuleQueryDto;
 import com.xunmei.iot.mapper.IotAlarmRuleMapper;
 import com.xunmei.iot.mapper.IotAlarmRuleSourceMapper;
 import com.xunmei.iot.mapper.IotAlarmSystemFieldMapper;
 import com.xunmei.iot.service.IotAlarmRuleExpressService;
 import com.xunmei.iot.service.IotAlarmRuleService;
+import com.xunmei.iot.service.IotServerInfoService;
 import com.xunmei.iot.vo.alarm.*;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.SysOrg;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,12 +49,19 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
 
     @Autowired
     private IotAlarmRuleSourceMapper iotAlarmRuleSourceMapper;
+    @Autowired
+    private RemoteOrgService orgService;
+
+    @Autowired
+    private IotServerInfoService serverInfoService;
 
     @Override
     public IotInitAlarmRuleVo getAddInitAlarmRuleData() throws Exception {
-
         IotInitAlarmRuleVo ruleVo = new IotInitAlarmRuleVo();
-        LambdaQueryWrapper<IotAlarmSystemField> lqw = new LambdaQueryWrapper<IotAlarmSystemField>().eq(IotAlarmSystemField::getEnable, 1).eq(IotAlarmSystemField::getAlarmRuleProperty,1).orderByDesc(IotAlarmSystemField::getId);
+        LambdaQueryWrapper<IotAlarmSystemField> lqw = new LambdaQueryWrapper<IotAlarmSystemField>()
+                .eq(IotAlarmSystemField::getEnable, 1)
+                .eq(IotAlarmSystemField::getAlarmRuleProperty, 1)
+                .orderByDesc(IotAlarmSystemField::getId);
         List<IotAlarmSystemField> systemFieldList = iotAlarmSystemFieldMapper.selectList(lqw);
         //
         List<IotAlarmSystemFieldVo> appAlarmSystemFieldVoList = new ArrayList<>();
@@ -82,19 +96,20 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
             appAlarmSystemFieldVo.setOperatorsList(operatorsList);
             appAlarmSystemFieldVoList.add(appAlarmSystemFieldVo);
         }
-        Map<Integer, List<IotAlarmSystemFieldVo>> appAlarmSystemFieldVoMapList = appAlarmSystemFieldVoList.stream().collect(Collectors.groupingBy(r -> r.getSourceType()));
+        Map<String, List<IotAlarmSystemFieldVo>> appAlarmSystemFieldVoMapList = appAlarmSystemFieldVoList.stream().collect(Collectors.groupingBy(IotAlarmSystemFieldVo::getProductType));
         List<Map<String, Object>> mapList = new ArrayList<>();
-        for (Integer key : appAlarmSystemFieldVoMapList.keySet()) {
+        for (String key : appAlarmSystemFieldVoMapList.keySet()) {
             Map<String, Object> map = new HashMap<>();
             List<IotAlarmSystemFieldVo> systemFieldVos = appAlarmSystemFieldVoMapList.get(key);
-            map.put("sourceTypeDes", systemFieldVos.get(0).getSourceTypeDes());
-            map.put("sourceType", systemFieldVos.get(0).getSourceType());
+            map.put("sourceTypeDes", systemFieldVos.get(0).getProductName());
+            map.put("sourceType", systemFieldVos.get(0).getProductType());
             map.put("smsType", systemFieldVos.get(0).getSmsType());
+            map.put("order", systemFieldVos.get(0).getOrder());
             List<Map<String, Object>> systemFieldsList = new ArrayList<>();
             for (IotAlarmSystemFieldVo vo : systemFieldVos) {
                 Map<String, Object> mapa = new HashMap<>();
-                mapa.put("sysFieldCode", vo.getSysFieldCode());
-                mapa.put("name", vo.getName());
+                mapa.put("sysFieldCode", vo.getProductProperty());
+                mapa.put("name", vo.getProductPropertyDisplayName());
                 mapa.put("specsList", vo.getSpecsList());
                 mapa.put("operatorsList", vo.getOperatorsList());
                 mapa.put("type", vo.getType());
@@ -105,6 +120,8 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
             map.put("systemFields", systemFieldsList);
             mapList.add(map);
         }
+        Comparator<Map<String, Object>> comparator = Comparator.comparing(map -> (Comparable) map.get("order"));
+        mapList = mapList.stream().sorted(comparator).collect(Collectors.toList());
         ruleVo.setSourceTypeList(mapList);
         return ruleVo;
     }
@@ -125,11 +142,13 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
         for (IotAlarmRuleExpress express : appAlarmRuleExpressList) {
             IotAlarmRuleExpressEditVo expressNew = new IotAlarmRuleExpressEditVo();
             BeanHelper.copyProperties(expressNew, express);
+            expressNew.setSourceType(express.getProductType());
+            expressNew.setFieldcode(express.getProductProperty());
             appAlarmRuleExpressEditVos.add(expressNew);
         }
-        Map<Integer, List<IotAlarmRuleExpressEditVo>> appAlarmSystemFieldVoMapList = appAlarmRuleExpressEditVos.stream().collect(Collectors.groupingBy(r -> r.getSourceType()));
+        Map<String, List<IotAlarmRuleExpressEditVo>> appAlarmSystemFieldVoMapList = appAlarmRuleExpressEditVos.stream().collect(Collectors.groupingBy(IotAlarmRuleExpressEditVo::getSourceType));
         List<Map<String, Object>> mapList = new ArrayList<>();
-        for (Integer key : appAlarmSystemFieldVoMapList.keySet()) {
+        for (String key : appAlarmSystemFieldVoMapList.keySet()) {
             Map<String, Object> map = new HashMap();
             map.put("sourceType", key);
             map.put("appAlarmRuleExpressList", appAlarmSystemFieldVoMapList.get(key));
@@ -140,19 +159,12 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
     }
 
     @Override
-    public TableDataInfo<IotInitAlarmRuleVo> getAlarmRuleDatas(String alarmType, String ruleName, Long pageIndex, Long pageSize) throws Exception {
-        LambdaQueryWrapper<IotAlarmRule> queryWrapper = new LambdaQueryWrapper<>();
-        if(alarmType!=null && !alarmType.isEmpty())
-        {
-            queryWrapper.eq(IotAlarmRule::getType,alarmType);
-        }
-        if(ruleName !=null && !ruleName.isEmpty())
-        {
-            queryWrapper.like(IotAlarmRule::getName,ruleName);
+    public TableDataInfo<IotInitAlarmRuleVo> getAlarmRuleData(IotAlarmRuleQueryDto args) throws Exception {
+        if (args.getCheckSub()) {
+            final SysOrg sysOrg = orgService.selectOrgById(args.getOrgId(), SecurityConstants.INNER);
+            args.setOrgPath(sysOrg.getPath());
         }
-        Page<IotAlarmRule> page = new Page<>(pageIndex,pageSize);
-
-        IPage<IotAlarmRule> appAlarmRule= this.baseMapper.selectPage(page,queryWrapper);
+        IPage<IotAlarmRule> appAlarmRule = this.baseMapper.selectPageData(args.getPageRequest(), args);
 
         List<IotInitAlarmRuleVo> datas = new ArrayList<>();
         appAlarmRule.getRecords().stream().forEach(i -> {
@@ -163,7 +175,7 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
             }
         });
 
-        TableDataInfo<IotInitAlarmRuleVo> pageDatas= TableDataInfo.build(datas);
+        TableDataInfo<IotInitAlarmRuleVo> pageDatas = TableDataInfo.build(datas);
         pageDatas.setCode(200);
         pageDatas.setTotal(appAlarmRule.getTotal());
         return pageDatas;
@@ -178,12 +190,12 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
             rule.setId(IDHelper.id());
             rule.setCreateTime(LocalDateTime.now());
             rule.setCreateBy(SecurityUtils.getUsername());
-            rule.setUpdateBy(SecurityUtils.getUsername());
-            rule.setUpdateTime(LocalDateTime.now());
-        } else {//修改
-            rule.setUpdateBy(SecurityUtils.getUsername());
-            rule.setUpdateTime(LocalDateTime.now());
+            rule.setIsdeleted(0);
         }
+        rule.setUpdateBy(SecurityUtils.getUsername());
+        rule.setUpdateTime(LocalDateTime.now());
+        rule.setOrgId(ruleDto.getOrgId());
+        rule.setIotCode(ruleDto.getIotCode());
         List<IotAlarmRuleExpressDto> appAlarmRuleExpressDtos = ruleDto.getIotAlarmRuleExpressDtoList();
         List<IotAlarmRuleExpress> appAlarmRuleExpressesList = new ArrayList<>();
         if (appAlarmRuleExpressDtos != null && appAlarmRuleExpressDtos.size() > 0) {
@@ -191,6 +203,8 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
                 IotAlarmRuleExpress express = new IotAlarmRuleExpress();
                 BeanHelper.copyProperties(express, vo);
                 express.setRuleId(rule.getId());
+                express.setProductType(vo.getSourceType());
+                express.setProductProperty(vo.getFieldcode());
                 express.setId(IDHelper.id());
                 express.setCreateTime(LocalDateTime.now());
                 express.setUpdateBy(SecurityUtils.getUsername());
@@ -198,8 +212,8 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
                 appAlarmRuleExpressesList.add(express);
             }
         }
-        Set<Integer> sourceTypes = new HashSet<>();
-        appAlarmRuleExpressesList.forEach(r -> sourceTypes.add(r.getSourceType()));
+        Set<String> sourceTypes = new HashSet<>();
+        appAlarmRuleExpressesList.forEach(r -> sourceTypes.add(r.getProductType()));
         this.saveOrUpdate(rule);
         //规则先删除原来的然重新插入
         iotAlarmRuleExpressService.remove(new LambdaQueryWrapper<IotAlarmRuleExpress>().eq(IotAlarmRuleExpress::getRuleId, rule.getId()));
@@ -208,18 +222,26 @@ public class IotAlarmRuleServiceImpl extends ServiceImpl<IotAlarmRuleMapper, Iot
 
 
     @Override
-    public void deleteAlarmRule(Long ruleId)
-    {
+    public void deleteAlarmRule(Long ruleId) {
         LambdaQueryWrapper<IotAlarmRule> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(IotAlarmRule::getId,ruleId);
+        queryWrapper.eq(IotAlarmRule::getId, ruleId);
         this.baseMapper.delete(queryWrapper);
         LambdaQueryWrapper<IotAlarmRuleExpress> ruleExpressWrapper = new LambdaQueryWrapper<>();
-        ruleExpressWrapper.eq(IotAlarmRuleExpress::getRuleId,ruleId);
+        ruleExpressWrapper.eq(IotAlarmRuleExpress::getRuleId, ruleId);
         iotAlarmRuleExpressService.remove(ruleExpressWrapper);
 
         //删除绑定设备数据
         LambdaQueryWrapper<IotAlarmRuleSource> iots = new LambdaQueryWrapper<>();
-        iots.eq(IotAlarmRuleSource::getRuleId,ruleId);
+        iots.eq(IotAlarmRuleSource::getRuleId, ruleId);
         iotAlarmRuleSourceMapper.delete(iots);
     }
+
+    @Override
+    public List<Pair<String, String>> getConnectHostOrg(Long orgId) {
+        final List<IotServerInfo> connectOrg = serverInfoService.selectConnectOrg(false, orgId, null);
+        if (CollectionUtils.isEmpty(connectOrg)) {
+            return new ArrayList<>();
+        }
+        return connectOrg.stream().map(serverInfo -> Pair.of(serverInfo.getIotName(), serverInfo.getIotCode())).collect(Collectors.toList());
+    }
 }

+ 20 - 17
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmRuleSourceServiceImpl.java

@@ -10,8 +10,6 @@ import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRuleSource;
 import com.xunmei.common.core.enums.OrgTypeEnum;
-import com.xunmei.common.core.enums.iot.DeviceTypeEnum;
-import com.xunmei.common.core.enums.iot.SensorType;
 import com.xunmei.common.core.utils.IDHelper;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.redis.utils.RedisUtils;
@@ -19,7 +17,10 @@ import com.xunmei.iot.dto.alarm.IotAlarmRuleSourceDetailDto;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleSourceDeviceBatchJoin;
 import com.xunmei.iot.dto.alarm.IotAlarmRuleSourceDeviceDto;
 import com.xunmei.iot.enums.ValueTypeEnum;
-import com.xunmei.iot.mapper.*;
+import com.xunmei.iot.mapper.IotAlarmRuleExpressMapper;
+import com.xunmei.iot.mapper.IotAlarmRuleMapper;
+import com.xunmei.iot.mapper.IotAlarmRuleSourceMapper;
+import com.xunmei.iot.mapper.IotCommonSensorMapper;
 import com.xunmei.iot.service.IotAlarmRuleSourceService;
 import com.xunmei.iot.service.IotDeviceStatusService;
 import com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDetailVo;
@@ -77,16 +78,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
         Page<IotAlarmRuleSourceDeviceVo> page = new Page<>();
         page.setSize(param.getSize());
         page.setCurrent(param.getPage());
-        if (ObjectUtil.isNotEmpty(param.getType())){
-            final SensorType sensorType = SensorType.getSensorTypeEnum(param.getType());
-            if (ObjectUtil.isNotEmpty(sensorType)){
 
-                final String productName = sensorType.getProductName();
-                final DeviceTypeEnum deviceTypeEnum = DeviceTypeEnum.valueOf(productName);
-                param.setType(Integer.parseInt(deviceTypeEnum.getCode()));
-
-            }
-        }
         Page<IotAlarmRuleSourceDeviceVo> result = iotAlarmRuleSourceMapper.selectDeviceList(page, param);
         final List<IotAlarmRuleSourceDeviceVo> records = result.getRecords();
         if (ObjectUtil.isEmpty(records)) {
@@ -133,7 +125,8 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
             if (ValueTypeEnum.AllDevice.getText().equals(productType.getValueType()) && productType.getIsAllDeviceEnable()) {
                 ruleSource.setId(IDHelper.id());
                 ruleSource.setOrgId(null);
-                ruleSource.setSourceType(productType.getType());
+                ruleSource.setIotCode(productType.getIotCode());
+                ruleSource.setProductType(productType.getType());
                 ruleSource.setValue(null);
                 ruleSource.setValueType(ValueTypeEnum.AllDevice.getText());
                 iotAlarmRuleSourceMapper.insert(ruleSource);
@@ -145,11 +138,16 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
                     QueryWrapper<IotAlarmRuleSource> iqw = new QueryWrapper<>();
                     iqw.lambda().eq(IotAlarmRuleSource::getOrgId, deviceTempVo.getOrgId())
                             .eq(IotAlarmRuleSource::getValue, deviceTempVo.getDeviceId())
-                            .eq(IotAlarmRuleSource::getSourceType, productType.getType());
+                            .eq(IotAlarmRuleSource::getIotCode, deviceTempVo.getIotCode())
+                            .eq(IotAlarmRuleSource::getProductType, deviceTempVo.getDeviceProduct())
+                            .eq(IotAlarmRuleSource::getDeviceCode, deviceTempVo.getDeviceCode());
                     iotAlarmRuleSourceMapper.delete(iqw);
                     ruleSource.setId(IDHelper.id());
+                    ruleSource.setIotCode(productType.getIotCode());
+                    ruleSource.setRuleId(detailDto.getRuleId());
                     ruleSource.setOrgId(deviceTempVo.getOrgId());
-                    ruleSource.setSourceType(productType.getType());
+                    ruleSource.setProductType(deviceTempVo.getDeviceProduct());
+                    ruleSource.setDeviceCode(deviceTempVo.getDeviceCode());
                     ruleSource.setValue(deviceTempVo.getDeviceId());
                     ruleSource.setValueType(ValueTypeEnum.Device.getText());
                     iotAlarmRuleSourceMapper.insert(ruleSource);
@@ -180,7 +178,9 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
                 boolean isAllDevice = false;
                 final List<IotAlarmRuleSource> ruleSourceList = iotAlarmRuleSourceMapper.selectList(new LambdaQueryWrapper<IotAlarmRuleSource>()
                         .eq(IotAlarmRuleSource::getRuleId, ruleId)
-                        .eq(IotAlarmRuleSource::getSourceType, Integer.parseInt(code)));
+                        .eq(IotAlarmRuleSource::getProductType, Integer.parseInt(code))
+                        )
+                        ;
                 isAllDevice = ruleSourceList.stream().map(IotAlarmRuleSource::getValueType).anyMatch(ValueTypeEnum.AllDevice.getText()::equals);
                 if (isAllDevice) {
                     //如果此前已经设置了 产品类型=AllDevice的  本次就无需再添加
@@ -192,7 +192,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
                 source.setId(IDHelper.id());
                 source.setOrgId(productDevice.getOrgId());
                 source.setRuleId(ruleId);
-                source.setSourceType(Integer.parseInt(code));
+               // source.setProductType(Integer.parseInt(code));
                 source.setValue(deviceId);
                 source.setValueType(ValueTypeEnum.Device.getText());
                 iotAlarmRuleSourceMapper.insert(source);
@@ -232,6 +232,9 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
                     final IotDeviceStatus deviceStatus = deviceIdAndName.get(ptv.getDeviceId());
                     if (deviceStatus != null) {
                         ptv.setDeviceName(deviceStatus.getDeviceName());
+                        ptv.setIotCode(deviceStatus.getIotToken());
+                        ptv.setDeviceProduct(deviceStatus.getDeviceProduct());
+                        ptv.setDeviceCode(deviceStatus.getDeviceCode());
                         final String orgName = dealOrgName(cacheList, deviceStatus.getOrgPath(), deviceStatus.getOrgName());
                         ptv.setOrgName(orgName);
                     }

+ 1 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleExpressEditVo.java

@@ -1,6 +1,5 @@
 package com.xunmei.iot.vo.alarm;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -36,7 +35,7 @@ public class IotAlarmRuleExpressEditVo implements Serializable {
     private String valueText;
 
     @ApiModelProperty(value = "报警源类型:4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;20:报警防区")
-    private Integer sourceType;
+    private String sourceType;
 
     @ApiModelProperty(value = "是否需要发送短信:0.不需要发送短信;1.需要发送短信")
     private Boolean smsType = false;

+ 9 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmRuleSourceDeviceVo.java

@@ -15,6 +15,15 @@ public class IotAlarmRuleSourceDeviceVo {
     @ApiModelProperty(value = "设备名称")
     private String deviceId;
 
+    @ApiModelProperty(value = "iotCode")
+    private String iotCode;
+
+    @ApiModelProperty(value = "设备产品")
+    private String deviceProduct;
+
+    @ApiModelProperty(value = "设备code")
+    private String deviceCode;
+
     @ApiModelProperty(value = "设备名称")
     private String deviceName;
 

+ 12 - 12
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotAlarmSystemFieldVo.java

@@ -17,26 +17,25 @@ import java.util.List;
  */
 @Data
 public class IotAlarmSystemFieldVo implements Serializable {
-
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty(value = "主键")
     private Long id;
 
-    @ApiModelProperty(value = "报警源类型(设备类型):4:烟雾传感器;5: 温湿度采集器;6:水浸; 7:门磁、窗磁;8:卷帘门门磁;9:地磁;10燃气报警器;50:报警防区")
-    private Integer sourceType;
-
-    @ApiModelProperty(value = "是否需要发送短信:0.不需要发送短信;1.需要发送短信")
-    private Boolean smsType = false;
+    @ApiModelProperty(value = "报警源产品类型")
+    private String productType;
 
     @ApiModelProperty(value = "报警源类型(设备类型) 中文")
-    private String sourceTypeDes;
+    private String productName;
 
-    @ApiModelProperty(value = "系统属性code(报警类型编码,全表唯一)")
-    private String sysFieldCode;
+    @ApiModelProperty(value = "报警源产品报警属性")
+    private String productProperty;
 
-    @ApiModelProperty(value = "系统属性名称")
-    private String name;
+    @ApiModelProperty(value = "报警源产品属性显示名称")
+    private String productPropertyDisplayName;
+
+    @ApiModelProperty(value = "是否需要发送短信:0.不需要发送短信;1.需要发送短信")
+    private Boolean smsType = false;
 
     @ApiModelProperty(value = "属性规格信息,eg:{ 	'0': '门已关闭', 	'1': '门已打开' 	}")
     private List<KeyValue> specsList;
@@ -53,5 +52,6 @@ public class IotAlarmSystemFieldVo implements Serializable {
     @ApiModelProperty(value = "属性单位,非必填")
     private String unit;
 
-
+    @ApiModelProperty(value = "排序值")
+    private Integer order;
 }

+ 6 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/IotInitAlarmRuleVo.java

@@ -1,5 +1,6 @@
 package com.xunmei.iot.vo.alarm;
 
+import com.xunmei.common.core.domain.IdName;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmRule;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
@@ -28,4 +29,9 @@ public class IotInitAlarmRuleVo implements Serializable {
      * 每种规则绑定设备详情
      */
     private List<IotAlarmRuleSourceTotalVo> iotAlarmRuleSourceTotalVos;
+
+    /**
+     * 主机列表
+     */
+    private List<IdName<String,String>> hostList;
 }

+ 9 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/ProductDeviceTempVo.java

@@ -22,6 +22,15 @@ public class ProductDeviceTempVo {
      * 设备名称
      */
     private String deviceName;
+
+    @ApiModelProperty(value = "设备产品")
+    private String deviceProduct;
+
+    @ApiModelProperty(value = "设备code")
+    private String deviceCode;
+
+    @ApiModelProperty(value = "iotCode")
+    private String iotCode;
     /**
      * 机构id
      */

+ 2 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/alarm/ProductTypeDataVo.java

@@ -15,11 +15,12 @@ public class ProductTypeDataVo {
     /**
      * 告警类型
      */
-    private Integer type;
+    private String type;
     /**
      * 告警类型名称
      */
     private String typeText;
+    private String iotCode;
 
     @ApiModelProperty(value = "关联类型",notes = "AllDevice:所有设备,Device:单个设备")
     private String  valueType;

+ 22 - 0
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmRuleMapper.xml

@@ -0,0 +1,22 @@
+<?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.IotAlarmRuleMapper">
+
+    <select id="selectPageData" resultType="com.xunmei.common.core.domain.mediator.domain.IotAlarmRule">
+        select * from iot_alarm_rule r inner join sys_org so on r.org_id=so.id
+        <where>
+            <if test="req.ruleName != null and req.ruleName != ''">
+                and r.name like concat('%', #{req.ruleName}, '%')
+            </if>
+            <if test="req.ruleType != null and req.ruleType != ''">
+                and r.type = #{req.ruleType}
+            </if>
+            <if test="req.checkSub==false">
+                and r.org_id =#{req.orgId}
+            </if>
+            <if test="req.checkSub==true">
+                and  so.path like concat(#{req.orgPath},'%')
+            </if>
+        </where>
+    </select>
+</mapper>

+ 14 - 10
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmRuleSourceMapper.xml

@@ -24,14 +24,15 @@
             <result property="orgId" column="org_id"/>
             <result property="orgName" column="org_name"/>
             <result property="orgPath" column="org_path"/>
+            <result property="iotCode" column="iot_token"/>
         </collection>
     </resultMap>
 
 
     <select id="selectRuleDevice" resultMap="product_type_data">
         SELECT
-            a.source_type AS type,
-            d.source_type_des as type_text,
+            a.product_type AS type,
+            d.product_name as type_text,
             b.value_type,
             b.`value` AS device_id,
             concat(b.org_id,'-',b.value) as strDeviceId,
@@ -39,10 +40,10 @@
             c.`name` AS org_name,
             c.path AS org_path
         FROM
-            ( SELECT rule_id, source_type FROM iot_alarm_rule_express GROUP BY source_type, rule_id ) a
-                LEFT JOIN iot_alarm_rule_source b ON a.rule_id = b.rule_id AND a.source_type = b.source_type
+            ( SELECT rule_id, product_type FROM iot_alarm_rule_express GROUP BY product_type, rule_id ) a
+                LEFT JOIN iot_alarm_rule_source b ON a.rule_id = b.rule_id AND a.product_type = b.product_type
                 LEFT JOIN sys_org c ON b.org_id = c.id
-                LEFT JOIN (select source_type,source_type_des from iot_alarm_system_field GROUP BY source_type,source_type_des) d on a.source_type = d.source_type
+                LEFT JOIN (select product_type,product_name from iot_alarm_system_field GROUP BY product_type,product_name) d on a.product_type = d.product_type
         where a.rule_id = #{ruleId}
     </select>
     <!--<select id="selectDeviceList" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDeviceVo">
@@ -71,7 +72,10 @@
     <select id="selectDeviceList" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDeviceVo">
         SELECT DISTINCT
         concat(d.iot_token,'_',d.device_product,'_',d.device_code) AS deviceId,
+        d.iot_token AS iotCode,
         d.device_name AS deviceName,
+        d.device_product AS deviceProduct,
+        d.device_code AS deviceCode,
         d.org_id AS orgId,
         d.org_path AS orgPath,
         b.short_name as org_name
@@ -85,7 +89,7 @@
         <if test="param.includeSub == true">
             and   b.path like concat((select path from sys_org where id = #{param.orgId} ),'%')
         </if>
-        and d.device_type = #{param.type}
+        and d.device_product = #{param.type}
         <if test="param.deviceName != null and param.deviceName != ''">
             and d.device_name like concat('%',#{param.deviceName},'%')
         </if>
@@ -93,11 +97,11 @@
     </select>
     <select id="getRuleSourceSize" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceTotalVo">
         SELECT
-            a.source_type,
-            a.source_type_des AS source_name,
+            a.product_type as sourceType,
+            a.product_name AS sourceName,
             IFNULL( b.source_size, 0 ) AS source_size
         FROM
-            ( SELECT source_type, source_type_des FROM iot_alarm_system_field where enable = 1 and alarm_rule_property = 1 GROUP BY source_type, source_type_des ) a
-                LEFT JOIN ( SELECT rule_id, source_type, count(*) source_size FROM iot_alarm_rule_source WHERE rule_id = #{ruleId} GROUP BY rule_id, source_type ) b ON a.source_type = b.source_type
+            ( SELECT product_type, product_name FROM iot_alarm_system_field where enable = 1 and alarm_rule_property = 1 GROUP BY product_type, product_name ) a
+                LEFT JOIN ( SELECT rule_id, product_type, count(*) source_size FROM iot_alarm_rule_source WHERE rule_id = #{ruleId} GROUP BY rule_id, product_type ) b ON a.product_type = b.product_type
     </select>
 </mapper>

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

@@ -27,7 +27,7 @@
     </select>
 
     <select id="selectConnectOrg" resultType="com.xunmei.common.core.domain.iot.domain.IotServerInfo">
-        select i.org_id, i.iot_code, i.org_path
+        select i.org_id, i.iot_code, i.org_path,iot_name
         from iot_server_info i
         inner join sys_org o on i.org_id = o.id
         where o.deleted = 0

+ 11 - 11
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/alarm/service/impl/IotAlarmDataServiceImpl.java

@@ -88,7 +88,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         Date now = new Date();
         //判断是否有绑定规则
         QueryWrapper<IotAlarmRuleSource> qw = new QueryWrapper<>();
-        qw.lambda().eq(IotAlarmRuleSource::getValue, deviceStatus.getUniqueCode())
+        qw.lambda().eq(IotAlarmRuleSource::getDeviceCode, deviceStatus.getUniqueCode())
                 .eq(IotAlarmRuleSource::getOrgId, deviceStatus.getOrgId());
         IotAlarmRuleSource iotAlarmRuleSource = iotAlarmRuleSourceMapper.selectOne(qw);
         if (iotAlarmRuleSource == null) {
@@ -105,18 +105,18 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         System.out.println(weekDay);
         QueryWrapper<IotAlarmRuleExpress> ruleExpress = new QueryWrapper<>();
         ruleExpress.lambda().eq(IotAlarmRuleExpress::getRuleId, iotAlarmRuleSource.getRuleId())
-                .eq(IotAlarmRuleExpress::getSourceType, iotAlarmRuleSource.getSourceType())
+                .eq(IotAlarmRuleExpress::getProductType, iotAlarmRuleSource.getProductType())
                 .eq(IotAlarmRuleExpress::getWeekDay, weekDay);
         List<IotAlarmRuleExpress> iotAlarmRuleExpresses = iotAlarmRuleExpressMapper.selectList(ruleExpress);
 
         List<IotAlarmSystemField> fields = iotAlarmSystemFieldMapper.selectList(null);
-        Map<String, IotAlarmSystemField> fieldMap = fields.stream().collect(Collectors.toMap(IotAlarmSystemField::getSysFieldCode, Function.identity()));
+        Map<String, IotAlarmSystemField> fieldMap = fields.stream().collect(Collectors.toMap(IotAlarmSystemField::getProductType, Function.identity()));
         String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd");
         boolean isAlarm = false;
         boolean isExpress = false;
         List<IotAlarmData> list = new ArrayList<>();
         for (IotAlarmRuleExpress express : iotAlarmRuleExpresses) {
-            Boolean smsType = express.getSmsType();
+            Boolean smsType = express.getSmsType()==1;
             boolean isOk = compareTime(express, dateStr, now);
             if (!isOk) {
                 //不在时间段内
@@ -476,7 +476,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(equipmentName + "-" + diskName);
         iotAlarmData.setRuleId(1L);
-        iotAlarmData.setSourceType(AlarmVideoTypeEnum.DVRDISK.getValue());
+        iotAlarmData.setSourceType(AlarmVideoTypeEnum.DVRDISK.getValue()+"");
         iotAlarmData.setSourceTypeDes(AlarmVideoTypeEnum.getTextByValue(AlarmVideoTypeEnum.DVRDISK.getValue()) + "告警");
         iotAlarmData.setFieldCode(AlarmVideoTypeEnum.DVRDISK.getValue() + "");
         iotAlarmData.setOperator("EQUALS");
@@ -523,8 +523,8 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         String settingValue = express.getValue();
         String infos = deviceStatus.getInfo();
         Map<String, String> dataMap = dealInfos(infos);
-        IotAlarmSystemField field = fieldMap.get(express.getFieldcode());
-        String sensorValue = dataMap.get(field.getName());
+        IotAlarmSystemField field = fieldMap.get(express.getProductType());
+        String sensorValue = dataMap.get(field.getProductName());
         if (StringUtils.isEmpty(sensorValue)) {
             return null;
         }
@@ -587,7 +587,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
             iotAlarmData.setDeviceName(deviceName + "-" + channelName);
         }
         iotAlarmData.setRuleId(1L);
-        iotAlarmData.setSourceType(diagnosisType);
+        iotAlarmData.setSourceType(String.valueOf(diagnosisType));
         iotAlarmData.setSourceTypeDes(AlarmVideoTypeEnum.getTextByValue(diagnosisType) + "告警");
         iotAlarmData.setFieldCode(diagnosisType + "");
         iotAlarmData.setOperator("EQUALS");
@@ -606,9 +606,9 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(deviceStatus.getDeviceName());
         iotAlarmData.setRuleId(express.getRuleId());
-        iotAlarmData.setSourceType(field.getSourceType());
-        iotAlarmData.setSourceTypeDes(field.getSourceTypeDes() + "告警");
-        iotAlarmData.setFieldCode(field.getSysFieldCode());
+        iotAlarmData.setSourceType(field.getProductType());
+        iotAlarmData.setSourceTypeDes(field.getProductPropertyDisplayName() + "告警");
+        iotAlarmData.setFieldCode(field.getProductProperty());
         iotAlarmData.setOperator(express.getOperator());
         iotAlarmData.setValue(express.getValue());
         iotAlarmData.setValueText(express.getValueText());

+ 3 - 3
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/iot/service/impl/IotDeviceStatusServiceImpl.java

@@ -161,9 +161,9 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
             array.add(object);
             String name = fieldList
                     .stream()
-                    .filter(r -> ObjectUtil.equal(r.getPropertyName(), jsb.get("propertyName")))
-                    .filter(r -> ObjectUtil.equal(deviceType, String.valueOf(r.getSourceType())))
-                    .map(IotAlarmSystemField::getName)
+                    .filter(r -> ObjectUtil.equal(r.getProductName(), jsb.get("propertyName")))
+                    .filter(r -> ObjectUtil.equal(deviceType, String.valueOf(r.getProductType())))
+                    .map(IotAlarmSystemField::getProductName)
                     .findFirst()
                     .orElse(StringUtil.EMPTY_STRING);
             String val = DeviceTypeEnum.getStatusText(jsb.get("propertyValue"));