瀏覽代碼

北向设备同步代码修改,动环诊断导出接口代码提交

jingyuanchao 1 年之前
父節點
當前提交
2d2d9f390b

+ 17 - 5
project_data/sql/0.0.6-iot/soc/soc.sql

@@ -453,7 +453,6 @@ CREATE TABLE `iot_sensor` (
           `host_code` varchar(64) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '视频物联网检测主机唯一标识,(此字段暂不可用)',
           `device_name` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备名称',
           `device_code` varchar(64) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备code',
-          `category_id` bigint DEFAULT NULL COMMENT '传感器类型编码',
           `device_type` varchar(10) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备类型编码',
           `device_id` bigint DEFAULT NULL COMMENT '资产设备id',
           `infos` varchar(2000) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '属性信息数组',
@@ -466,7 +465,7 @@ CREATE TABLE `iot_sensor` (
           `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
           `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
           PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci  COMMENT=' 录像机硬盘检测日志表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci  COMMENT='动环传感器表';
 
 drop table if exists iot_sensor_log;
 CREATE TABLE `iot_sensor_log` (
@@ -478,7 +477,6 @@ CREATE TABLE `iot_sensor_log` (
           `host_code` varchar(64) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '视频物联网检测主机唯一标识',
           `device_name` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备名称',
           `device_code` varchar(64) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备code',
-          `category_id` bigint DEFAULT NULL COMMENT '传感器类型编码',
           `device_id` bigint DEFAULT NULL COMMENT '资产设备id',
           `device_type` varchar(10) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '设备类型编码',
           `infos` varchar(2000) CHARACTER SET gbk COLLATE gbk_chinese_ci DEFAULT NULL COMMENT '属性信息数组',
@@ -490,7 +488,7 @@ CREATE TABLE `iot_sensor_log` (
           `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
           `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
           PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=gbk;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci  COMMENT='动环传感器日志表';
 
 
 
@@ -1094,4 +1092,18 @@ INSERT INTO `sys_menu` (`id`, `menu_name`, `parent_id`, `order_num`, `path`, `co
 
 
 update sys_menu set component ='iot/subSystem/index' WHERE menu_name='布撤防情况跟踪' and platform_type=1;
-UPDATE sys_menu set path='/iot/subsystem' WHERE path='/protection' and platform_type=0;
+UPDATE sys_menu set path='/iot/subsystem' WHERE path='/protection' and platform_type=0;
+
+delete from sys_dict_type where dict_type in ('sensor_alarm_status','sensor_device_type');
+delete from sys_dict_data where dict_type in ('sensor_alarm_status','sensor_device_type');
+INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('动环传感器告警状态', 'sensor_alarm_status', '0', '超级管理员', '2024-03-01 09:12:16', '', NULL, NULL);
+INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('动环传感器设备类型', 'sensor_device_type', '0', '超级管理员', '2024-03-01 09:31:11', '', NULL, NULL);
+
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '正常', '0', 'sensor_alarm_status', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '告警', '1', 'sensor_alarm_status', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (100, '温湿度采集器', '4183', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (200, '红外传感器', '4181', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (300, '烟雾传感器', '4182', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (400, '水浸传感器', '4184', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (500, '门磁、窗磁传感器', '4188', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);
+INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (600, '燃气报警器', '41885', 'sensor_device_type', NULL, 'default', 'N', '0', NULL, now(), NULL, NULL, NULL);

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

@@ -41,7 +41,7 @@ public class IotAlarmData extends BaseEntity {
 
     @ApiModelProperty(value = "设备id")
     @TableField("device_id")
-    private Long deviceId;
+    private String deviceId;
 
     @ApiModelProperty(value = "设备id")
     @TableField("device_name")
@@ -94,8 +94,8 @@ public class IotAlarmData extends BaseEntity {
     private String alarmValue;
 
     @ApiModelProperty(value = "0未处理1已处理")
-    @TableField("isdo")
-    private Integer isdo;
+    @TableField("is_do")
+    private Integer isDo;
 
     @ApiModelProperty(value = "处理时间")
     @TableField("do_time")

+ 16 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/controller/IotSensorController.java

@@ -1,6 +1,9 @@
 package com.xunmei.iot.controller;
 
+import com.xunmei.common.core.domain.drill.dto.CoreDrillTaskPageDto;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.log.annotation.Log;
+import com.xunmei.common.log.enums.BusinessType;
 import com.xunmei.iot.dto.dvrDisk.DvrDiskPageDto;
 import com.xunmei.iot.dto.sensor.SensorPageDto;
 import com.xunmei.iot.service.IIotCommonSensorService;
@@ -13,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * @author jingyuanchao
@@ -38,4 +43,15 @@ public class IotSensorController {
         TableDataInfo<SensorPageVo> page = this.sensorService.selectSensorLogDataPage(request);
         return page;
     }
+
+    /**
+     * 导出excel
+     */
+    @ApiOperation(value = "导出动环设备")
+    //@RequiresPermissions("core:eduTask:export")
+    @Log(title = "导出动环设备", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(@RequestBody final SensorPageDto request, HttpServletResponse response) throws IOException {
+        sensorService.export(request, response);
+    }
 }

+ 2 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/mapper/IotCommonSensorMapper.java

@@ -5,6 +5,7 @@ import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.sensor.SensorPageDto;
+import com.xunmei.iot.vo.sensor.SensorExportVo;
 import com.xunmei.iot.vo.sensor.SensorPageVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Mapper;
@@ -30,4 +31,5 @@ public interface IotCommonSensorMapper extends BaseMapper<IotSensor> {
     List<IotSensor> selectByIds(@Param("deviceIds") List<String> deviceIds);
 
 
+    List<SensorExportVo> selectListData(@Param("request") SensorPageDto request);
 }

+ 3 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/IIotCommonSensorService.java

@@ -6,6 +6,8 @@ import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.iot.dto.sensor.SensorPageDto;
 import com.xunmei.iot.vo.sensor.SensorPageVo;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * <p>
  *  服务类
@@ -20,4 +22,5 @@ public interface IIotCommonSensorService extends IService<IotSensor> {
 
     TableDataInfo<SensorPageVo> selectSensorLogDataPage(SensorPageDto request);
 
+    void export(SensorPageDto request, HttpServletResponse response);
 }

+ 28 - 2
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -2,11 +2,14 @@ package com.xunmei.iot.service.impl;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.constant.DictConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.drill.vo.CoreDrillTaskExportVo;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.MediatorCategory;
 import com.xunmei.common.core.web.page.TableDataInfo;
@@ -17,6 +20,7 @@ import com.xunmei.iot.mapper.IotCommonSensorMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xunmei.iot.mapper.MediatorCategoryMapper;
 import com.xunmei.iot.service.IIotCommonSensorService;
+import com.xunmei.iot.vo.sensor.SensorExportVo;
 import com.xunmei.iot.vo.sensor.SensorPageVo;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
@@ -24,6 +28,8 @@ import io.netty.util.internal.StringUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -57,8 +63,8 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         for (SensorPageVo record : page.getRecords()) {
             final String info = record.getInfo();
             record.setInfo(dealInfoData(info));
-            record.setDeviceType(DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE,Integer.parseInt(record.getDeviceType())));
-            record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS,record.getState()));
+            record.setDeviceType(DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE, Integer.parseInt(record.getDeviceType())));
+            record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS, record.getState()));
         }
         return TableDataInfo.build(page);
     }
@@ -78,6 +84,26 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         return TableDataInfo.build(page);
     }
 
+    @Override
+    public void export(SensorPageDto request, HttpServletResponse response) {
+        dealPageParam(request);
+        List<SensorExportVo> data = sensorMapper.selectListData(request);
+
+        try {
+            // 设置响应头
+            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("动环诊断", "utf-8"));
+            response.setContentType("application/octet-stream;charset=UTF-8");
+            response.setCharacterEncoding("utf-8");
+            // 数据导出
+            EasyExcel.write(response.getOutputStream(), SensorExportVo.class)
+                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).sheet("演练任务").doWrite(data);
+        } catch (Exception e) {
+            // 重置response
+            response.reset();
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+        }
+    }
 
     private void dealPageParam(SensorPageDto request) {
         final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);

+ 60 - 0
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/SensorExportVo.java

@@ -0,0 +1,60 @@
+package com.xunmei.iot.vo.sensor;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.xunmei.common.core.constant.Constants;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/2/26 14:37
+ */
+@Data
+@ColumnWidth(15) //列宽,最大值为255
+@HeadRowHeight(16) //表头行高
+@ContentRowHeight(16) //数据行高
+public class SensorExportVo {
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 0)
+    @ApiModelProperty("设备名称")
+    private String deviceName;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 1)
+    @ApiModelProperty("设备类型")
+    private String deviceType;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 2)
+    @ApiModelProperty("所属机构")
+    private String orgName;
+
+    @ExcelIgnore
+    @ApiModelProperty(value = "告警状态,0:正常,1:告警")
+    private Integer state;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 3)
+    @ApiModelProperty(value = "告警状态")
+    private String stateText;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 4)
+    @JsonFormat(pattern = Constants.HMS_FORMAT)
+    @ApiModelProperty("上报时间")
+    private String updateTime;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "序号", index = 5)
+    @ApiModelProperty("上报内容")
+    private String info;
+
+}

+ 15 - 16
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/SensorPageVo.java

@@ -17,33 +17,32 @@ public class SensorPageVo {
 
     private Long id;
 
-    @ApiModelProperty("机构id")
-    private Long orgId;
-
-    private Long categoryId;
-
-    @ApiModelProperty("所属机构")
-    private String orgName;
-
     @ApiModelProperty("设备名称")
     private String deviceName;
 
     @ApiModelProperty("设备类型")
     private String deviceType;
 
-    @ApiModelProperty("设备code")
-    private String deviceCode;
-
-    @ApiModelProperty("上报内容")
-    private String info;
+    @ApiModelProperty("机构id")
+    private Long orgId;
 
-    @JsonFormat(pattern = Constants.HMS_FORMAT)
-    @ApiModelProperty("上报时间")
-    private LocalDateTime updateTime;
+    @ApiModelProperty("所属机构")
+    private String orgName;
 
     @ApiModelProperty(value = "告警状态,0:正常,1:告警")
     private Integer state;
 
     @ApiModelProperty(value = "告警状态")
     private String stateText;
+
+    @JsonFormat(pattern = Constants.HMS_FORMAT)
+    @ApiModelProperty("上报时间")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty("上报内容")
+    private String info;
+
+    @ApiModelProperty("设备code")
+    private String deviceCode;
+
 }

+ 29 - 2
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

@@ -29,7 +29,7 @@
     </select>
 
     <select id="selectSensorLogDataPage" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
-        select s.id, org_id, org_name, device_name, category_id, infos as info,device_code, update_time from
+        select s.id, org_id, org_name, device_name, infos as info,device_code, update_time from
         iot_sensor_log s
         <where>
             <if test="request.orgId!= null">
@@ -51,7 +51,7 @@
                 and s.state_update_time <![CDATA[<=]]>  #{request.endTime}
             </if>
         </where>
-        order by s.state_update_time desc
+        order by s.create_time desc
     </select>
     <select id="selectByIds" resultType="com.xunmei.common.core.domain.iot.domain.IotSensor">
         SELECT
@@ -68,4 +68,31 @@
             #{item}
         </foreach>
     </select>
+
+    <select id="selectListData" resultType="com.xunmei.iot.vo.sensor.SensorExportVo">
+        select org_name, device_name, device_type, infos as info,update_time,state
+        from iot_sensor s
+        where s.deleted=0
+        <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>
+        <if test="request.state!= null">
+            and s.state = #{request.state}
+        </if>
+        <if test="request.deviceType!= null">
+            and s.device_type = #{request.deviceType}
+        </if>
+        <if test="request.startTime!= null">
+            and s.state_update_time >=#{request.startTime}
+        </if>
+        <if test="request.endTime!= null">
+            and s.state_update_time <![CDATA[<=]]>  #{request.endTime}
+        </if>
+    </select>
 </mapper>

+ 2 - 2
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/EquipmentSyncService.java

@@ -288,8 +288,8 @@ public class EquipmentSyncService {
         alarm.setValueText(ruleExpress.getValueText());
         alarm.setTime(DateUtils.toLocalDateTime(deviceData.getUpdateTime()));//此处时间设置为和外部列表的检测时间一致
         alarm.setAlarmValue(value);
-        alarm.setDeviceId(deviceData.getDeviceId());
-        alarm.setIsdo(0);
+        //alarm.setDeviceId(deviceData.getDeviceId());
+        alarm.setIsDo(0);
         return alarm;
     }
 

+ 1 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/IotSensorService.java

@@ -20,4 +20,5 @@ public interface IotSensorService extends IService<IotSensor> {
     ReceiveErrorDto saveDirectHost(DataPageDto<SensorDto> sensors, String msgId);
 
     ReceiveErrorDto saveDirectHostStatus(DataPageDto<SensorStatusDto> statuses, String msgId);
+     void saveStatusAsync(DataPageDto<SensorStatusDto> request, String msgId);
 }

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

@@ -153,50 +153,43 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         }
 
         if(AlarmRuleExpressOperateEnum.GT.getText().equals(operator)){
-            if(Integer.parseInt(value) > Integer.parseInt(sensorValue)){
+            if(Integer.parseInt(sensorValue) > Integer.parseInt(value)){
                 //对上了
                 iotAlarmData = builderAlarm(sensorValue,field,express,iotSensor);
             }
         }
 
         if(AlarmRuleExpressOperateEnum.GTE.getText().equals(operator)){
-            if(Integer.parseInt(value) >= Integer.parseInt(sensorValue)){
+            if(Integer.parseInt(sensorValue) >= Integer.parseInt(value)){
                 //对上了
                 iotAlarmData = builderAlarm(sensorValue,field,express,iotSensor);
             }
         }
 
         if(AlarmRuleExpressOperateEnum.LT.getText().equals(operator)){
-            if(Integer.parseInt(value) < Integer.parseInt(sensorValue)){
+            if(Integer.parseInt(sensorValue) < Integer.parseInt(value)){
                 //对上了
                 iotAlarmData = builderAlarm(sensorValue,field,express,iotSensor);
             }
         }
 
         if(AlarmRuleExpressOperateEnum.LTE.getText().equals(operator)){
-            if(Integer.parseInt(value) <= Integer.parseInt(sensorValue)){
+            if(Integer.parseInt(sensorValue) <= Integer.parseInt(value)){
                 //对上了
                 iotAlarmData = builderAlarm(sensorValue,field,express,iotSensor);
             }
         }
 
-        if(AlarmRuleExpressOperateEnum.LTE.getText().equals(operator)){
-            if(Integer.parseInt(value) <= Integer.parseInt(sensorValue)){
-                //对上了
-                iotAlarmData = builderAlarm(sensorValue,field,express,iotSensor);
-            }
-        }
         return iotAlarmData;
     }
 
 
     private IotAlarmData builderAlarm(String sensorValue,IotAlarmSystemField field,IotAlarmRuleExpress express,IotSensor iotSensor){
         IotAlarmData iotAlarmData = new IotAlarmData();
-        iotAlarmData.setAlarmValue(sensorValue + field.getUnit());
+        iotAlarmData.setAlarmValue(sensorValue + field.getUnit() == null ? "" : field.getUnit());
         iotAlarmData.setTime(LocalDateTime.now());
         iotAlarmData.setDeviceName(iotSensor.getDeviceName());
         iotAlarmData.setRuleId(express.getRuleId());
-        iotAlarmData.setDeviceId(iotSensor.getDeviceId());
         iotAlarmData.setSourceType(field.getSourceType());
         iotAlarmData.setSourceTypeDes(field.getSourceTypeDes());
         iotAlarmData.setFieldCode(field.getSysFieldCode());
@@ -204,6 +197,8 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         iotAlarmData.setValue(express.getValue());
         iotAlarmData.setValueText(express.getValueText());
         iotAlarmData.setContent(iotSensor.getDeviceName() + "触发" + field.getName());
+        iotAlarmData.setOrgId(iotSensor.getOrgId());
+        iotAlarmData.setDeviceId(iotSensor.getDeviceCode());
         return iotAlarmData;
     }
 

+ 6 - 8
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotSensorServiceImpl.java

@@ -31,7 +31,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.support.TransactionSynchronization;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -69,19 +71,14 @@ public class IotSensorServiceImpl extends ServiceImpl<IotSensorMapper, IotSensor
         ReceiveErrorDto dto = CheckDataUtil.checkObjFieldIsNull(request);
 
         if (dto.getSuccess() && ObjectUtil.isNotEmpty(request.getData())) {
-            new Thread(() -> {
-                try {
-                    saveStatusAsync(request, msgId);
-                } catch (ParseException e) {
-                    throw new RuntimeException(e);
-                }
-            }).start();
+            saveStatusAsync(request, msgId);
         }
 
         return dto;
     }
 
-    private void saveStatusAsync(DataPageDto<SensorStatusDto> request, String msgId) throws ParseException {
+    @Override
+    public void saveStatusAsync(DataPageDto<SensorStatusDto> request, String msgId){
         String path = "/api/status/sensorCommon";
         List<NorthError> errors = new ArrayList<>();
         Map<String, List<IotSensor>> productDeviceMap = getAllDevice();
@@ -115,6 +112,7 @@ public class IotSensorServiceImpl extends ServiceImpl<IotSensorMapper, IotSensor
             iotSensor.setInfos(dealInfoData(infoStr));
             final IotSensorLog iotSensorLog = new IotSensorLog();
             BeanUtils.copyProperties(iotSensor, iotSensorLog, "id");
+            iotSensorLog.setCreateTime(LocalDateTime.now());
             iotSensorLog.setIotSensorId(iotSensor.getId());
             iotSensorLog.setSource(1);
             iotSensorLog.setDeviceType(iotSensor.getDeviceType());