|
@@ -1,8 +1,6 @@
|
|
package com.huimv.eartag2.process2.service.impl;
|
|
package com.huimv.eartag2.process2.service.impl;
|
|
|
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartagDeviceOnlineEntity;
|
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartagDeviceRegisterEntity;
|
|
|
|
-import com.huimv.eartag2.common.dao.entity.EartarFarmAllStatusEntity;
|
|
|
|
|
|
+import com.huimv.eartag2.common.dao.entity.*;
|
|
import com.huimv.eartag2.common.dao.repo.EartagDeviceRegisterRepo;
|
|
import com.huimv.eartag2.common.dao.repo.EartagDeviceRegisterRepo;
|
|
import com.huimv.eartag2.common.utils.BizConst;
|
|
import com.huimv.eartag2.common.utils.BizConst;
|
|
import com.huimv.eartag2.common.utils.DateUtil;
|
|
import com.huimv.eartag2.common.utils.DateUtil;
|
|
@@ -16,7 +14,6 @@ import org.springframework.stereotype.Service;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.Set;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -127,7 +124,7 @@ public class CacheServiceImpl implements ICacheService {
|
|
@Override
|
|
@Override
|
|
public void flashAllStatusCache(String farmId, EartarFarmAllStatusEntity farmAllStatusEntity) {
|
|
public void flashAllStatusCache(String farmId, EartarFarmAllStatusEntity farmAllStatusEntity) {
|
|
Map allStatusMap = new HashMap();
|
|
Map allStatusMap = new HashMap();
|
|
- allStatusMap.put("id",farmAllStatusEntity.getId());
|
|
|
|
|
|
+// allStatusMap.put("id",farmAllStatusEntity.getId());
|
|
allStatusMap.put("deviceTotal",farmAllStatusEntity.getDeviceTotal());
|
|
allStatusMap.put("deviceTotal",farmAllStatusEntity.getDeviceTotal());
|
|
allStatusMap.put("deviceOnline",farmAllStatusEntity.getDeviceOnline());
|
|
allStatusMap.put("deviceOnline",farmAllStatusEntity.getDeviceOnline());
|
|
allStatusMap.put("deviceOffline",farmAllStatusEntity.getDeviceOffline());
|
|
allStatusMap.put("deviceOffline",farmAllStatusEntity.getDeviceOffline());
|
|
@@ -162,7 +159,7 @@ public class CacheServiceImpl implements ICacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void putDeviceToOnline(String farmId, String deviceCode, String todayDateText) {
|
|
public void putDeviceToOnline(String farmId, String deviceCode, String todayDateText) {
|
|
-// System.out.println("## (D)");
|
|
|
|
|
|
+ System.out.println("## 心跳 2.4");
|
|
String setKey = BizConst.SET_FARM_DEVICE_ONLINE_PREFIX + farmId+"_"+todayDateText;
|
|
String setKey = BizConst.SET_FARM_DEVICE_ONLINE_PREFIX + farmId+"_"+todayDateText;
|
|
redisTemplate.opsForSet().add(setKey, deviceCode);
|
|
redisTemplate.opsForSet().add(setKey, deviceCode);
|
|
redisTemplate.expire(setKey,eartagOnlineSetExpire , TimeUnit.HOURS);
|
|
redisTemplate.expire(setKey,eartagOnlineSetExpire , TimeUnit.HOURS);
|
|
@@ -188,9 +185,9 @@ public class CacheServiceImpl implements ICacheService {
|
|
* @Time : 16:07
|
|
* @Time : 16:07
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void putDeviceInOnline(String deviceOnlineHashKey, EartagDeviceOnlineEntity eartagDeviceOnlineEntity) {
|
|
|
|
|
|
+ public void putDeviceInOnline(String deviceCode, EartagDeviceOnlineEntity eartagDeviceOnlineEntity) {
|
|
Map map = new HashMap();
|
|
Map map = new HashMap();
|
|
- map.put("id", eartagDeviceOnlineEntity.getId());
|
|
|
|
|
|
+// map.put("id", eartagDeviceOnlineEntity.getId());
|
|
map.put("deviceCode", eartagDeviceOnlineEntity.getDeviceCode());
|
|
map.put("deviceCode", eartagDeviceOnlineEntity.getDeviceCode());
|
|
map.put("alias", eartagDeviceOnlineEntity.getAlias());
|
|
map.put("alias", eartagDeviceOnlineEntity.getAlias());
|
|
map.put("heartbeatTotal", eartagDeviceOnlineEntity.getHeartbeatTotal());
|
|
map.put("heartbeatTotal", eartagDeviceOnlineEntity.getHeartbeatTotal());
|
|
@@ -203,7 +200,10 @@ public class CacheServiceImpl implements ICacheService {
|
|
map.put("addDate", eartagDeviceOnlineEntity.getAddDate());
|
|
map.put("addDate", eartagDeviceOnlineEntity.getAddDate());
|
|
map.put("farmId", eartagDeviceOnlineEntity.getFarmId());
|
|
map.put("farmId", eartagDeviceOnlineEntity.getFarmId());
|
|
//更新缓存
|
|
//更新缓存
|
|
- redisTemplate.opsForHash().putAll(deviceOnlineHashKey, map);
|
|
|
|
|
|
+ String deviceOnlineKey = BizConst.DEVICE_ONLINE_PREFIX + deviceCode;
|
|
|
|
+ redisTemplate.opsForHash().putAll(deviceOnlineKey, map);
|
|
|
|
+// Map onlineMap = fromOnlineEntityToMap(newDeviceOnlineEntity);
|
|
|
|
+// redisTemplate.opsForHash().putAll(deviceOnlineHashKey, onlineMap);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -230,8 +230,83 @@ public class CacheServiceImpl implements ICacheService {
|
|
System.out.println("## eartag.setKey .putEartagToOnlineInSet>>"+setKey+",earmark>>"+earmark);
|
|
System.out.println("## eartag.setKey .putEartagToOnlineInSet>>"+setKey+",earmark>>"+earmark);
|
|
redisTemplate.opsForSet().add(setKey, earmark);
|
|
redisTemplate.opsForSet().add(setKey, earmark);
|
|
redisTemplate.expire(setKey,eartagOnlineSetExpire , TimeUnit.HOURS);
|
|
redisTemplate.expire(setKey,eartagOnlineSetExpire , TimeUnit.HOURS);
|
|
- Set<String> resultSet = redisTemplate.opsForSet().members(setKey);
|
|
|
|
- System.out.println("## "+setKey+">>"+resultSet.size()+" >>"+resultSet);
|
|
|
|
|
|
+// Set<String> resultSet = redisTemplate.opsForSet().members(setKey);
|
|
|
|
+// System.out.println("## "+setKey+">>"+resultSet.size()+" >>"+resultSet);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Method : getEartagOnlineTotalFromCache
|
|
|
|
+ * @Description : 返回集合缓存的数量;
|
|
|
|
+ * @Params : [farmId, todayDateText]
|
|
|
|
+ * @Return : void
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/3/3
|
|
|
|
+ * @Time : 10:55
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void getEartagOnlineTotalFromCache(String farmId, String todayDateText) {
|
|
|
|
+ String setKey = BizConst.SET_FARM_EARMARK_ONLINE_PREFIX + farmId+"_"+todayDateText;
|
|
|
|
+ redisTemplate.opsForSet().members(setKey).size();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Method : putEartagRegister
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [earmark, eartagRegisterEntity]
|
|
|
|
+ * @Return : void
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/3/3
|
|
|
|
+ * @Time : 15:29
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void putEartagRegister(String earmark, EartagEartagRegisterEntity eartagRegisterEntity) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+// map.put("id", eartagRegisterEntity.getId());
|
|
|
|
+ map.put("earmark",eartagRegisterEntity.getEarmark());
|
|
|
|
+ map.put("firstTime",eartagRegisterEntity.getFirstTime());
|
|
|
|
+ map.put("lastTime",eartagRegisterEntity.getLastTime());
|
|
|
|
+ map.put("firstDevice",eartagRegisterEntity.getFirstDevice());
|
|
|
|
+ map.put("belongDevice",eartagRegisterEntity.getBelongDevice());
|
|
|
|
+ map.put("lastDevice",eartagRegisterEntity.getLastDevice());
|
|
|
|
+ map.put("registerTime",eartagRegisterEntity.getRegisterTime());
|
|
|
|
+ map.put("registerType",eartagRegisterEntity.getRegisterType());
|
|
|
|
+ map.put("remark",eartagRegisterEntity.getRemark());
|
|
|
|
+ map.put("farmId",eartagRegisterEntity.getFarmId());
|
|
|
|
+ map.put("activeStatus",eartagRegisterEntity.getActiveStatus());
|
|
|
|
+ map.put("activeTime",eartagRegisterEntity.getActiveTime());
|
|
|
|
+ map.put("liveStatus",eartagRegisterEntity.getLiveStatus());
|
|
|
|
+ //更新缓存
|
|
|
|
+ String earmarkOnlineKey = BizConst.EARTAG_REGISTER_PREFIX + earmark;
|
|
|
|
+ redisTemplate.opsForHash().putAll(earmarkOnlineKey, map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Method : putEartagOnlineCount
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [earmark, eartagOnlineEntity]
|
|
|
|
+ * @Return : void
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/3/3
|
|
|
|
+ * @Time : 15:29
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void putEartagOnlineCount(String earmark, EartagEartagOnlineEntity eartagOnlineEntity) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+// map.put("id", eartagRegisterEntity.getId());
|
|
|
|
+ map.put("earmark",eartagOnlineEntity.getEarmark());
|
|
|
|
+ map.put("total",eartagOnlineEntity.getTotal());
|
|
|
|
+ map.put("firstTime",eartagOnlineEntity.getFirstTime());
|
|
|
|
+ map.put("lastTime",eartagOnlineEntity.getLastTime());
|
|
|
|
+ map.put("envTemp",eartagOnlineEntity.getEnvTemp());
|
|
|
|
+ map.put("eartagTemp",eartagOnlineEntity.getEartagTemp());
|
|
|
|
+ map.put("addDate",eartagOnlineEntity.getAddDate());
|
|
|
|
+ map.put("farmId",eartagOnlineEntity.getFarmId());
|
|
|
|
+ //更新缓存
|
|
|
|
+ String earmarkOnlineKey = BizConst.EARTAG_ONLINE_PREFIX + earmark;
|
|
|
|
+ redisTemplate.opsForHash().putAll(earmarkOnlineKey, map);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|