From 2b6dbb4779f3f9faee12be9d3c3622a51fd154d6 Mon Sep 17 00:00:00 2001 From: fengrong Date: Tue, 5 Nov 2024 09:49:54 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/dasadmin/src/views/backend/dashboard.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/dasadmin/src/views/backend/dashboard.vue b/ui/dasadmin/src/views/backend/dashboard.vue index f4d2b888..2cd1b398 100644 --- a/ui/dasadmin/src/views/backend/dashboard.vue +++ b/ui/dasadmin/src/views/backend/dashboard.vue @@ -523,7 +523,7 @@ const initpowerChart = () => { top: 50, right: 23, bottom: 10, - left: 18, + left: 25, containLabel: true, }, tooltip: { From a3fb26a69ccec3f02ce9e2939c03568a1aeaf7b0 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 11:28:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/EventLevelConstant.java | 19 ++++ .../modules/data/domain/DeviceEventInfo.java | 2 + .../modules/data/service/TDEngineService.java | 95 ++++++++++++++++--- .../data/service/impl/DataServiceImpl.java | 2 +- .../event/controller/EventController.java | 52 ++++++++++ .../modules/event/domain/EventQueryParam.java | 33 +++++++ .../modules/event/service/EventService.java | 13 +++ .../event/service/impl/EventServiceImpl.java | 41 ++++++++ .../service/impl/NodeMessageServiceImpl.java | 21 ++-- 9 files changed, 253 insertions(+), 25 deletions(-) create mode 100644 das/src/main/java/com/das/common/constant/EventLevelConstant.java create mode 100644 das/src/main/java/com/das/modules/event/controller/EventController.java create mode 100644 das/src/main/java/com/das/modules/event/domain/EventQueryParam.java create mode 100644 das/src/main/java/com/das/modules/event/service/EventService.java create mode 100644 das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java diff --git a/das/src/main/java/com/das/common/constant/EventLevelConstant.java b/das/src/main/java/com/das/common/constant/EventLevelConstant.java new file mode 100644 index 00000000..e648a268 --- /dev/null +++ b/das/src/main/java/com/das/common/constant/EventLevelConstant.java @@ -0,0 +1,19 @@ +package com.das.common.constant; + +/** + * 事件等级 + * + */ +public interface EventLevelConstant { + + /** + * 告警 + */ + Integer ALARM = 0; + + /** + * 故障 + */ + Integer FAULT = 1; + +} diff --git a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java index 45ec8839..c8b56ba9 100644 --- a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java +++ b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java @@ -8,6 +8,8 @@ public class DeviceEventInfo { private Long eventId; + private Integer eventType; + private Integer eventLevel; private String eventText; diff --git a/das/src/main/java/com/das/modules/data/service/TDEngineService.java b/das/src/main/java/com/das/modules/data/service/TDEngineService.java index 4c26008e..f785cc08 100644 --- a/das/src/main/java/com/das/modules/data/service/TDEngineService.java +++ b/das/src/main/java/com/das/modules/data/service/TDEngineService.java @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.sql.*; @@ -95,7 +96,7 @@ public class TDEngineService { } } - public void createCalStable(String iotmodel, String iotModelField,String dataType) { + public void createCalStable(String iotmodel, String iotModelField, String dataType) { try (Connection conn = hikariDataSource.getConnection(); Statement pstmt = conn.createStatement()) { StringBuilder sb = new StringBuilder(1024 * 1024); @@ -251,9 +252,9 @@ public class TDEngineService { for (IotModelFieldVo info : list) { String iotModelCode = info.getIotModelCode(); Map calFieldMap = calculateIotFieldMap.get(iotModelCode); - if (calFieldMap.keySet().size() != 0){ - for (String key : calFieldMap.keySet()){ - createCalStable(iotModelCode,key,calFieldMap.get(key)); + if (calFieldMap.keySet().size() != 0) { + for (String key : calFieldMap.keySet()) { + createCalStable(iotModelCode, key, calFieldMap.get(key)); } } } @@ -385,7 +386,9 @@ public class TDEngineService { for (DeviceEventInfo dv : list) { sb.append("E_"); sb.append(dv.getDeviceId()); - sb.append(" using event_info tags ('"); + sb.append(" using event_info tags ("); + sb.append(dv.getDeviceId()); + sb.append(",'"); sb.append(dv.getDeviceCode()); sb.append("','"); sb.append(dv.getDeviceName()); @@ -394,6 +397,8 @@ public class TDEngineService { sb.append(","); sb.append(dv.getEventId()); sb.append(","); + sb.append(dv.getEventType()); + sb.append(","); sb.append(dv.getEventLevel()); sb.append(",'"); sb.append(dv.getEventText()); @@ -460,11 +465,11 @@ public class TDEngineService { Map>> result = new HashMap<>(); Map> valueMap = new HashMap<>(); for (String item : fieldList) { - Map timeValueMap = new HashMap<>(); + Map timeValueMap = new HashMap<>(); List times = new ArrayList<>(); List objects = new ArrayList<>(); - timeValueMap.put("times",times); - timeValueMap.put("values",objects); + timeValueMap.put("times", times); + timeValueMap.put("values", objects); valueMap.put(item, timeValueMap); } StringBuffer sb = new StringBuffer(2048); @@ -529,7 +534,6 @@ public class TDEngineService { public Map>> fetchLowHistoryCurve(Long irn, Date startTime, Date endTime, String interval, List fieldList) { SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String tbName = String.format("l%d", irn); Date now = new Date(); if (endTime.after(now)) { @@ -538,11 +542,11 @@ public class TDEngineService { Map>> result = new HashMap<>(); Map> valueMap = new HashMap<>(); for (String item : fieldList) { - Map timeValueMap = new HashMap<>(); + Map timeValueMap = new HashMap<>(); List times = new ArrayList<>(); List objects = new ArrayList<>(); - timeValueMap.put("times",times); - timeValueMap.put("values",objects); + timeValueMap.put("times", times); + timeValueMap.put("values", objects); valueMap.put(item, timeValueMap); } StringBuffer sb = new StringBuffer(2048); @@ -605,6 +609,73 @@ public class TDEngineService { return result; } + public List queryEvent(Integer eventLevel, Long startTime, Long endTime, List deviceCodeList) { + List result = new ArrayList<>(); + StringBuffer sb = new StringBuffer(2048); + sb.append("select t.* from event_info t where "); + sb.append(String.format(" t.event_time >= %d and t.event_time < %d", startTime, endTime)); + if (eventLevel != null) { + sb.append(String.format(" and t.event_level = %d", eventLevel)); + } + if (!CollectionUtils.isEmpty(deviceCodeList)) { + sb.append(" and t.device_code in ("); + for (int i = 0; i < deviceCodeList.size(); i++) { + if (i == deviceCodeList.size() - 1) { + sb.append("'").append(deviceCodeList.get(i)).append("')"); + } else { + sb.append("'").append(deviceCodeList.get(i)).append("',"); + } + } + } + sb.append(" order by t.updatetime"); + log.debug(sb.toString()); + try (Connection conn = hikariDataSource.getConnection(); + Statement smt = conn.createStatement(); + ResultSet rs = smt.executeQuery(sb.toString())) { + while (rs.next()) { + DeviceEventInfo deviceEventInfo = new DeviceEventInfo(); + deviceEventInfo.setUpdateTime(rs.getLong("event_time")); + deviceEventInfo.setDeviceId(rs.getString("event_id")); + deviceEventInfo.setEventLevel(rs.getInt("event_level")); + deviceEventInfo.setEventType(rs.getInt("event_type")); + deviceEventInfo.setEventText(rs.getString("event_text")); + deviceEventInfo.setConfirmed(rs.getInt("confirmed")); + deviceEventInfo.setConfirmAccount(rs.getString("confirm_account")); + deviceEventInfo.setConfirmTime(rs.getLong("confirm_time")); + deviceEventInfo.setDeviceCode(rs.getString("device_code")); + deviceEventInfo.setDeviceId(rs.getString("device_id")); + result.add(deviceEventInfo); + } + } catch (Exception e) { + log.error("获取数据异常", e); + return result; + } + return result; + } + + public void confirmEvent(DeviceEventInfo deviceEventInfo) { + StringBuffer sb = new StringBuffer(2048); + sb.append("insert into e_"); + sb.append(deviceEventInfo.getDeviceId()); + sb.append(" USING event_info (device_id)TAGS (null) (event_time,event_id,confirmed,confirm_account,confirm_time) VALUES ("); + sb.append(deviceEventInfo.getUpdateTime()); + sb.append(","); + sb.append(deviceEventInfo.getEventId()); + sb.append(","); + sb.append(deviceEventInfo.getConfirmed()); + sb.append(",'"); + sb.append(deviceEventInfo.getConfirmAccount()); + sb.append("',"); + sb.append(deviceEventInfo.getConfirmTime()); + sb.append(")"); + try (Connection conn = hikariDataSource.getConnection(); + Statement pstmt = conn.createStatement()) { + pstmt.executeUpdate(sb.toString()); + } catch (Exception e) { + log.error("新增超级表列失败:{},失败原因{}", sb.toString(), e); + } + } + private String convertInterval(String interval) { if (!StringUtils.hasText(interval)) { interval = "1m"; diff --git a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java index 02928b3b..88c3a566 100644 --- a/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java +++ b/das/src/main/java/com/das/modules/data/service/impl/DataServiceImpl.java @@ -51,7 +51,7 @@ public class DataServiceImpl implements DataService { //key:modelId value:modelCode public ConcurrentHashMap iotModelMap = new ConcurrentHashMap<>(10000); - //key:modelId value:fieldCode fieldName + //key:modelCode value:fieldCode fieldName public ConcurrentHashMap> fieldCodeNameMap = new ConcurrentHashMap<>(10000); //key:modelCode value:FiledCode,dataType diff --git a/das/src/main/java/com/das/modules/event/controller/EventController.java b/das/src/main/java/com/das/modules/event/controller/EventController.java new file mode 100644 index 00000000..fc51d0eb --- /dev/null +++ b/das/src/main/java/com/das/modules/event/controller/EventController.java @@ -0,0 +1,52 @@ +package com.das.modules.event.controller; + +import com.das.common.result.R; +import com.das.common.utils.JsonUtils; +import com.das.modules.data.domain.DeviceEventInfo; +import com.das.modules.event.domain.EventQueryParam; +import com.das.modules.event.service.EventService; +import jakarta.validation.Valid; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * 告警event相关controller + */ +@Slf4j +@RequestMapping("/api/event") +@RestController +public class EventController { + + @Autowired + private EventService eventService; + + /** + * 查询设备告警信息列表 + * @param param 查询条件 + * @return TD数据库数据 + */ + @PostMapping("/query") + public R> queryEvent(@RequestBody @Valid EventQueryParam param) { + if (log.isDebugEnabled()){ + log.debug("/api/event/query is calling"); + log.debug(JsonUtils.toJsonString(param)); + } + return R.success(eventService.queryEvent(param)); + } + + /** + * 确认告警信息 + * @param deviceEventInfo 确认信息 + */ + @PostMapping("/confirm") + public void confirmEvent(@RequestBody DeviceEventInfo deviceEventInfo){ + eventService.confirmEvent(deviceEventInfo); + } +} diff --git a/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java b/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java new file mode 100644 index 00000000..c4946328 --- /dev/null +++ b/das/src/main/java/com/das/modules/event/domain/EventQueryParam.java @@ -0,0 +1,33 @@ +package com.das.modules.event.domain; + +import com.das.modules.data.domain.SnapshotValueQueryParam; +import lombok.Data; + +import java.util.List; + +/** + * 时序数据查询实体 + */ +@Data +public class EventQueryParam +{ + /** + * 开始时间 + */ + private String startTime; + + /** + * 结束时间 + */ + private String endTime; + + /** + * 事件等级 + */ + private Integer eventLevel; + + /** + * 设备编码列表 + */ + private List deviceCode; +} diff --git a/das/src/main/java/com/das/modules/event/service/EventService.java b/das/src/main/java/com/das/modules/event/service/EventService.java new file mode 100644 index 00000000..8185cc87 --- /dev/null +++ b/das/src/main/java/com/das/modules/event/service/EventService.java @@ -0,0 +1,13 @@ +package com.das.modules.event.service; + +import com.das.modules.data.domain.DeviceEventInfo; +import com.das.modules.event.domain.EventQueryParam; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +public interface EventService { + List queryEvent(EventQueryParam param); + + void confirmEvent(DeviceEventInfo deviceEventInfo); +} diff --git a/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java new file mode 100644 index 00000000..fcb10d01 --- /dev/null +++ b/das/src/main/java/com/das/modules/event/service/impl/EventServiceImpl.java @@ -0,0 +1,41 @@ +package com.das.modules.event.service.impl; + +import cn.dev33.satoken.stp.StpUtil; +import com.das.common.config.SessionUtil; +import com.das.common.exceptions.ServiceException; +import com.das.modules.auth.domain.vo.SysUserVo; +import com.das.modules.data.domain.DeviceEventInfo; +import com.das.modules.data.service.TDEngineService; +import com.das.modules.event.domain.EventQueryParam; +import com.das.modules.event.service.EventService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +public class EventServiceImpl implements EventService { + + @Autowired + private TDEngineService tdEngineService; + + @Override + public List queryEvent(EventQueryParam param) { + if (param.getStartTime() == null || param.getEndTime() ==null){ + throw new ServiceException("查询时间不能为空"); + } + List deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), Long.valueOf(param.getStartTime()), Long.valueOf(param.getEndTime()), param.getDeviceCode()); + return deviceEventInfos; + } + + @Override + public void confirmEvent(DeviceEventInfo deviceEventInfo) { + Long confirmTime = System.currentTimeMillis(); + deviceEventInfo.setConfirmTime(confirmTime); + SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY); + deviceEventInfo.setConfirmAccount(sysUserVo.getAccount()); + tdEngineService.confirmEvent(deviceEventInfo); + } +} diff --git a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java index 98f4f2ec..0b36e4a5 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java @@ -315,6 +315,7 @@ public class NodeMessageServiceImpl implements NodeMessageService { if (StringUtils.isEmpty(fieldName)){ log.debug("未查询到物模型属性code,设备id:{}",item.getDeviceId()); } + deviceEventInfo.setEventType(item.getEventType()); deviceEventInfo.setEventLevel(0); deviceEventInfo.setConfirmed(0); if (!StringUtils.isEmpty(eventType) && eventType.equals("遥信变位")){ @@ -334,20 +335,16 @@ public class NodeMessageServiceImpl implements NodeMessageService { }catch (Exception e){ log.error("事件信息存入Td失败,失败原因{}",e); } - - } private String getEventType(int eventType) { - switch (eventType) { - case 0: - return "遥信变位"; - case 1: - return "越上限"; - case 2: - return "越下限"; - default: - return null; - } + return switch (eventType) { + case 0 -> "遥信变位"; + case 1 -> "越上限"; + case 2 -> "越下限"; + case 3 -> "越上上限"; + case 4 -> "越下下限"; + default -> null; + }; } } From 5c0f8963800673d4c2108854594832c919799267 Mon Sep 17 00:00:00 2001 From: yu Date: Tue, 5 Nov 2024 13:55:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E4=BC=98=E5=8C=96;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- das/src/main/java/com/das/common/utils/StringUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/das/src/main/java/com/das/common/utils/StringUtils.java b/das/src/main/java/com/das/common/utils/StringUtils.java index 2b9ce2e6..301f5520 100644 --- a/das/src/main/java/com/das/common/utils/StringUtils.java +++ b/das/src/main/java/com/das/common/utils/StringUtils.java @@ -4,9 +4,9 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.springframework.boot.configurationprocessor.json.JSONTokener; import org.springframework.util.AntPathMatcher; import java.util.*; @@ -355,7 +355,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { */ public static boolean isJsonString(String jsonString) { try { - new JSONTokener(jsonString).nextValue(); + JSONObject.parseObject(jsonString); return true; } catch (Exception e) { return false; From 8d262a05912b6cb3a547e1b617be3ea84ec907b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=88=90=E4=BC=9F?= Date: Tue, 5 Nov 2024 14:26:53 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=96=B0=E5=A2=9EeventType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/datacollect/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/datacollect/README.md b/docs/datacollect/README.md index faf72d9e..2f9ffc86 100644 --- a/docs/datacollect/README.md +++ b/docs/datacollect/README.md @@ -315,7 +315,7 @@ PS: 同一节点只允许建立一条连接。 "attrCode": "stop", //属性值 "attrValue": 0, - //事件类型 ( 0-遥信变位 1-越上限 2-越下限) + //事件类型 ( 0-遥信变位 1-越上限 2-越下限 3-越上上限 4-越下下限 5-越限复归) "eventType": 0, //事件发生时刻 "eventTime": 12321351235123, From 04d19d8dfacdc525066b8dc9dc8a52917fc1f926 Mon Sep 17 00:00:00 2001 From: huguanghan Date: Tue, 5 Nov 2024 14:53:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E7=A1=AE=E8=AE=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/das/modules/data/domain/DeviceEventInfo.java | 7 ++++++- .../com/das/modules/data/service/TDEngineService.java | 10 +++++----- .../das/modules/event/controller/EventController.java | 3 ++- .../node/service/impl/NodeMessageServiceImpl.java | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java index c8b56ba9..7f523ced 100644 --- a/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java +++ b/das/src/main/java/com/das/modules/data/domain/DeviceEventInfo.java @@ -1,11 +1,15 @@ package com.das.modules.data.domain; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; @Data public class DeviceEventInfo { - private Long updateTime; + @JsonSerialize(using = ToStringSerializer.class) + private Long eventTime; + @JsonSerialize(using = ToStringSerializer.class) private Long eventId; private Integer eventType; @@ -18,6 +22,7 @@ public class DeviceEventInfo { private String confirmAccount; + @JsonSerialize(using = ToStringSerializer.class) private Long confirmTime; private String deviceId; diff --git a/das/src/main/java/com/das/modules/data/service/TDEngineService.java b/das/src/main/java/com/das/modules/data/service/TDEngineService.java index f785cc08..71386e74 100644 --- a/das/src/main/java/com/das/modules/data/service/TDEngineService.java +++ b/das/src/main/java/com/das/modules/data/service/TDEngineService.java @@ -393,7 +393,7 @@ public class TDEngineService { sb.append("','"); sb.append(dv.getDeviceName()); sb.append("') values ("); - sb.append(dv.getUpdateTime()); + sb.append(dv.getEventTime()); sb.append(","); sb.append(dv.getEventId()); sb.append(","); @@ -627,15 +627,15 @@ public class TDEngineService { } } } - sb.append(" order by t.updatetime"); + sb.append(" order by t.event_time"); log.debug(sb.toString()); try (Connection conn = hikariDataSource.getConnection(); Statement smt = conn.createStatement(); ResultSet rs = smt.executeQuery(sb.toString())) { while (rs.next()) { DeviceEventInfo deviceEventInfo = new DeviceEventInfo(); - deviceEventInfo.setUpdateTime(rs.getLong("event_time")); - deviceEventInfo.setDeviceId(rs.getString("event_id")); + deviceEventInfo.setEventTime(rs.getLong("event_time")); + deviceEventInfo.setEventId(rs.getLong("event_id")); deviceEventInfo.setEventLevel(rs.getInt("event_level")); deviceEventInfo.setEventType(rs.getInt("event_type")); deviceEventInfo.setEventText(rs.getString("event_text")); @@ -658,7 +658,7 @@ public class TDEngineService { sb.append("insert into e_"); sb.append(deviceEventInfo.getDeviceId()); sb.append(" USING event_info (device_id)TAGS (null) (event_time,event_id,confirmed,confirm_account,confirm_time) VALUES ("); - sb.append(deviceEventInfo.getUpdateTime()); + sb.append(deviceEventInfo.getEventTime()); sb.append(","); sb.append(deviceEventInfo.getEventId()); sb.append(","); diff --git a/das/src/main/java/com/das/modules/event/controller/EventController.java b/das/src/main/java/com/das/modules/event/controller/EventController.java index fc51d0eb..2f1345e4 100644 --- a/das/src/main/java/com/das/modules/event/controller/EventController.java +++ b/das/src/main/java/com/das/modules/event/controller/EventController.java @@ -46,7 +46,8 @@ public class EventController { * @param deviceEventInfo 确认信息 */ @PostMapping("/confirm") - public void confirmEvent(@RequestBody DeviceEventInfo deviceEventInfo){ + public R confirmEvent(@RequestBody DeviceEventInfo deviceEventInfo){ eventService.confirmEvent(deviceEventInfo); + return R.success(); } } diff --git a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java index 0b36e4a5..b71c256b 100644 --- a/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java +++ b/das/src/main/java/com/das/modules/node/service/impl/NodeMessageServiceImpl.java @@ -301,7 +301,7 @@ public class NodeMessageServiceImpl implements NodeMessageService { for (DeviceEventVo item : list){ DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId())); DeviceEventInfo deviceEventInfo = new DeviceEventInfo(); - deviceEventInfo.setUpdateTime(item.getEventTime()); + deviceEventInfo.setEventTime(item.getEventTime()); deviceEventInfo.setEventId(IdWorker.getId()); deviceEventInfo.setDeviceId(item.getDeviceId()); deviceEventInfo.setDeviceName(deviceInfoCache.getDeviceName());