|  |  | 
 |  |  |             device.setKeepaliveIntervalTime(60); | 
 |  |  |         }else { | 
 |  |  |             long lastTime = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(device.getKeepaliveTime()); | 
 |  |  |             device.setKeepaliveIntervalTime(new Long(System.currentTimeMillis()/1000-lastTime).intValue()); | 
 |  |  |             if (System.currentTimeMillis()/1000-lastTime > 10) { | 
 |  |  |                 device.setKeepaliveIntervalTime(new Long(System.currentTimeMillis()/1000-lastTime).intValue()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         device.setKeepaliveTime(DateUtil.getNow()); | 
 |  |  |  | 
 |  |  |         if (device.getOnline() == 1) { | 
 |  |  |         if (device.isOnLine()) { | 
 |  |  |             deviceService.updateDevice(device); | 
 |  |  |         }else { | 
 |  |  |             // 对于已经离线的设备判断他的注册是否已经过期 | 
 |  |  |             if (!deviceService.expire(device)){ | 
 |  |  |                 device.setOnline(0); | 
 |  |  |                 device.setOnLine(false); | 
 |  |  |                 deviceService.online(device, null); | 
 |  |  |             } | 
 |  |  |         } |