From 1a529c3f8a623eb3e10ff6c7dcb99e79bbd451f0 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Wed, 01 Sep 2021 09:52:11 +0800
Subject: [PATCH] 修改因子更新特殊设备警报信息
---
screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
index 8265b20..9d18e07 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -7,9 +7,11 @@
import com.moral.api.service.HistoryHourlyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.constant.Constants;
+import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -34,14 +36,21 @@
@Autowired
private DeviceService deviceService;
+ @Autowired
+ private RedisTemplate redisTemplate;
+
@Override
@Transactional
public void insertHistoryHourly(Map<String, Object> data) {
- Map<String, Object> dataAdjust = new HashMap<>(data);
String mac = data.remove("mac").toString();
+ //������mac������������
+ Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac);
+ Map<String, Object> versionInfo = (Map<String, Object>) deviceInfo.get("version");
+ Integer version = (Integer) versionInfo.get("id");
+ Map<String, Object> dataAdjust = new HashMap<>(data);
Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN);
- Integer version = (Integer) data.remove("ver");
+
Map<String, Object> result = new HashMap<>();
result.put("mac", mac);
result.put("time", time);
@@ -53,12 +62,14 @@
//������������
dataAdjust = deviceService.adjustDeviceData(dataAdjust);
- dataAdjust.remove("mac");
- dataAdjust.remove("DataTime");
- dataAdjust.remove("ver");
- result.put("timeUnits", Constants.TRANSITION);
- result.put("value", JSONObject.toJSONString(dataAdjust));
- //������������������������insert
- historyHourlyMapper.insertHistoryHourly(result);
+
+ HistoryHourly historyHourly = new HistoryHourly();
+ historyHourly.setMac(mac);
+ historyHourly.setTime(time);
+ historyHourly.setVersion(version);
+ historyHourly.setValue(JSONObject.toJSONString(dataAdjust));
+
+ //������������������insert
+ historyHourlyMapper.insert(historyHourly);
}
}
--
Gitblit v1.8.0