|
|
@@ -1,5 +1,7 @@
|
|
|
package com.yunfeiyun.agmp.iots.warn.service;
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.enums.RedisCacheKey;
|
|
|
+import com.yunfeiyun.agmp.common.framework.manager.RedisCacheManager;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.uuid.IdUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotWarncount;
|
|
|
@@ -10,6 +12,7 @@ import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -21,6 +24,9 @@ public class IotWarnBussinessService {
|
|
|
@Autowired
|
|
|
private IotWarnBussinessMapper iotWarncountMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedisCacheManager redisCacheManager;
|
|
|
+
|
|
|
/**
|
|
|
* 查询设备+配置的重复次数
|
|
|
* 注意:如果没数据会返回Null
|
|
|
@@ -30,6 +36,13 @@ public class IotWarnBussinessService {
|
|
|
* @return
|
|
|
*/
|
|
|
public Long selectIotWarnCountByDevAndConfig(String devId, String configId) {
|
|
|
+
|
|
|
+ Long count = redisCacheManager.getCacheObject(RedisCacheKey.IOT_WARN_RE_COUNTS, configId + ":" + devId);
|
|
|
+// if (false) {
|
|
|
+// redisCacheManager.setCacheObject(RedisCacheKey.IOT_WARN_RE_COUNTS, configId + ":" + devId, 0);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
IotWarncount iotWarncount = iotWarncountMapper.selectIotWarnCountByDevAndConfig(devId, configId);
|
|
|
// 如果为Null,说明还没触发过
|
|
|
if (iotWarncount == null) {
|
|
|
@@ -97,18 +110,17 @@ public class IotWarnBussinessService {
|
|
|
* 查询预警配置信息
|
|
|
*
|
|
|
* @return
|
|
|
- *
|
|
|
*/
|
|
|
List<WarnConfigInfo> selectIotWarnConfigInfoList(WarnConfigInfo warnConfigInfo) {
|
|
|
return iotWarncountMapper.selectIotWarnConfigInfoList(warnConfigInfo);
|
|
|
}
|
|
|
|
|
|
- Map<String, List<WarnConfigInfo>> selectIotWarnConfigInfoMap(WarnConfigInfo warnConfigInfo){
|
|
|
+ Map<String, List<WarnConfigInfo>> selectIotWarnConfigInfoMap(WarnConfigInfo warnConfigInfo) {
|
|
|
List<WarnConfigInfo> warnConfigInfoList = selectIotWarnConfigInfoList(warnConfigInfo);
|
|
|
Map<String, List<WarnConfigInfo>> warnConfigInfoMap = new HashMap<>();
|
|
|
for (WarnConfigInfo info : warnConfigInfoList) {
|
|
|
String wcBid = info.getWcBid();
|
|
|
- if(!warnConfigInfoMap.containsKey(wcBid)){
|
|
|
+ if (!warnConfigInfoMap.containsKey(wcBid)) {
|
|
|
warnConfigInfoMap.put(wcBid, new ArrayList<>());
|
|
|
}
|
|
|
warnConfigInfoMap.get(wcBid).add(info);
|