1. 111
This commit is contained in:
		
							parent
							
								
									36dabe0e30
								
							
						
					
					
						commit
						ecd98bd977
					
				|  | @ -324,11 +324,13 @@ public class ReceiveController { | |||
|         AsDevice device = asDeviceService.selectAsDeviceByMac(mac); | ||||
|         //开异步线程保存回调参数 | ||||
|         scheduledExecutorService.schedule(() -> { | ||||
|             log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device)); | ||||
|             device.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE); | ||||
|             int i = asDeviceService.updateAsDevice(device); | ||||
|             if(i>0){ | ||||
|                 log.info("【接收onenet推送】异步保存在线状态成功"); | ||||
|             if(device.getOnlineStatus().equals(ServiceConstants.VEHICLE_STATUS_OFFLINE)){ | ||||
|                 log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device)); | ||||
|                 device.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE); | ||||
|                 int i = asDeviceService.updateAsDevice(device); | ||||
|                 if(i>0){ | ||||
|                     log.info("【接收onenet推送】异步保存在线状态成功"); | ||||
|                 } | ||||
|             } | ||||
|         }, 0, TimeUnit.SECONDS); | ||||
|     } | ||||
|  |  | |||
|  | @ -242,6 +242,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|             if(ObjectUtil.isNotNull(status)){ | ||||
|                 String typeName = sysDictDataService.selectDictLabel("as_device_status", status); | ||||
|                 asDevice1.setStatusStr(typeName); | ||||
|                 if(status.equals(ServiceConstants.VEHICLE_STATUS_NOT_BAND) && ObjectUtil.isNotNull(asDevice1.getAreaId())){ | ||||
|                     asDevice1.setStatus(ServiceConstants.VEHICLE_STATUS_IN_OFFLINE); | ||||
|                 } | ||||
|             } | ||||
|             if(ObjectUtil.isNotNull(areaId)){ | ||||
|                 SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId); | ||||
|  | @ -468,6 +471,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|         /** 2.发送命令*/ | ||||
|         ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁"); | ||||
|         if(responseVo.getCode() != 0){ | ||||
|             asynchronousUpdateOnlineStatus(asDevice.getMac()); | ||||
|             throw new ServiceException("【扫码/编号开锁骑行】更新车辆状态失败"); | ||||
|         } | ||||
|         /** 3.更新车辆状态*/ | ||||
|  | @ -665,10 +669,28 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|         //记录命令 | ||||
|         if (!HttpStatus.IOT_SUCCESS.equals(code)) | ||||
|         { | ||||
|             // 异步更新在线状态 | ||||
|             asynchronousUpdateOnlineStatus(mac); | ||||
|             throw new ServiceException(code+"-----"+ IotUtil.formatMsg(code)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void asynchronousUpdateOnlineStatus(String mac) { | ||||
|         AsDevice device = asDeviceMapper.selectAsDeviceByMac(mac); | ||||
|         //异步更新在线状态 | ||||
|         scheduledExecutorService.schedule(() -> { | ||||
|             if(device.getOnlineStatus().equals(ServiceConstants.VEHICLE_STATUS_ONLINE)){ | ||||
|                 log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device)); | ||||
|                 device.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_OFFLINE); | ||||
|                 int i = asDeviceMapper.updateAsDevice(device); | ||||
|                 if(i>0){ | ||||
|                     log.info("【接收onenet推送】异步保存在线状态成功"); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         }, 0, TimeUnit.SECONDS); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     /** 发送命令*/ | ||||
|     public ResponseVo sendCommandWithResp(String mac, String token,String command,String type) { | ||||
|  | @ -1403,10 +1425,12 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|     @SneakyThrows | ||||
|     @Override | ||||
|     public boolean isOnline(String sn) { | ||||
|         ResponseVo responseVo = sendCommandWithResp(asDeviceMapper.selectAsDeviceBySn(sn).getMac(), Token.getToken(), "111", "是否在线"); | ||||
|         AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); | ||||
|         ResponseVo responseVo = sendCommandWithResp(device.getMac(), Token.getToken(), "111", "是否在线"); | ||||
|         if(responseVo.getCode() == 0){ | ||||
|             return true; | ||||
|         } | ||||
|         asynchronousUpdateOnlineStatus(device.getMac()); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user