|
|
@@ -9,9 +9,11 @@ import com.tmzn.devicelinkykc.entity.DeviceStatus;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.HeartFrameSend;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
|
|
|
import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
+import com.tmzn.devicelinkykc.service.DeviceControlerService;
|
|
|
import com.tmzn.devicelinkykc.service.DeviceService;
|
|
|
import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
|
import com.tmzn.devicelinkykc.socket.SocketHandle;
|
|
|
+import com.tmzn.devicelinkykc.transdata.entity.DeviceParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
@@ -42,6 +44,8 @@ public class MsgHeartRunner {
|
|
|
@Autowired
|
|
|
private SocketHandle socketHandle;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceControlerService deviceControlerService;
|
|
|
|
|
|
|
|
|
// 使用AtomicBoolean替代基本的boolean
|
|
|
@@ -106,6 +110,14 @@ public class MsgHeartRunner {
|
|
|
// log.info("not found ones:{}",devicePileCode);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ //检查多久没有心跳时间了
|
|
|
+ if (oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 120 * 1000L) {
|
|
|
+ log.info("heart_over..{},{}" ,devicePileCode, (System.currentTimeMillis() - heartTime));
|
|
|
+ socketHandle.removeDeviceConnection(devicePileCode);
|
|
|
+ deviceControlerService.sendImeiDetail(oneDs.getDeviceImei());
|
|
|
+ return;
|
|
|
+ }
|
|
|
boolean res = heartFrameSend.heartSend(deviceConnectionMsg, oneDs);
|
|
|
if(res){
|
|
|
return;
|
|
|
@@ -124,30 +136,7 @@ public class MsgHeartRunner {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- if (oneDs.getOnlineStatus() == DeviceOnlineStatus.ONLINE && (System.currentTimeMillis() - heartTime) > 50 * 1000L) {
|
|
|
- log.info("pileCode:" + devicePileCode + " loging... ..." + (System.currentTimeMillis() - heartTime));
|
|
|
- int a = 0;
|
|
|
- if (redisCache.hasKey(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode)) {
|
|
|
- //如果登录次数30秒内登三次就算断开
|
|
|
- a = redisCache.getCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode);
|
|
|
- if (a > 3) {
|
|
|
- log.info("30s no heart {} reset",devicePileCode);
|
|
|
- socketHandle.removeDeviceConnection(devicePileCode);
|
|
|
- } else {
|
|
|
-// QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
-// deviceQueryWrapper.eq("pile_code", devicePileCode).eq("disabled", DeviceOnlineStatus.NORMAL);
|
|
|
-// Device device = deviceService.getOne(deviceQueryWrapper);
|
|
|
-// if(device!=null){
|
|
|
-//// loginFrame.loginMsgSend(deviceConnectionMsg, device);
|
|
|
-// socketHandle.removeDeviceConnection(devicePileCode);
|
|
|
-// }
|
|
|
- }
|
|
|
- a++;
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a,32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
- } else {
|
|
|
- redisCache.setCacheObject(RedisConstant.DEVICE_LOGIN_YKC + devicePileCode, a, 32 * 1000, TimeUnit.MILLISECONDS);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|