| | |
| | | import com.fzzy.api.utils.DateUtil; |
| | | import com.fzzy.data.ConfigData; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.api.GatewayRemoteService; |
| | | import com.fzzy.gateway.api.GatewaySyncGranService; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.BaseResp; |
| | | import com.fzzy.gateway.data.WeatherWebDto; |
| | |
| | | gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportGrainDataByHand(reqData); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * <p> |
| | | * 粮情每天8点采集粮情 |
| | | * |
| | | */ |
| | | // @Scheduled(cron = "0 32 11 ? * *") |
| | | @Scheduled(cron = "0 32 11 ? * 2,5 *") |
| | | public void scheduledGrain2() { |
| | | //获取设备配置,只针对粮情设备进行执行 |
| | | log.info("定时粮情采集kafka推送"); |
| | | List<GatewayDevice> list = gatewayDeviceTestPR.listAll(); |
| | | |
| | | if (null == list || list.isEmpty()) { |
| | | log.error("为获取到系统中设备配置,取消执行\""); |
| | | return ; |
| | | } |
| | | BaseReqData reqData = new BaseReqData(); |
| | | BaseResp resp; |
| | | for (GatewayDevice device : list) { |
| | | try{ |
| | | //如果不是粮情分机跳过 |
| | | if (!GatewayDeviceType.TYPE_07.getCode().equals(device.getType())) { |
| | | continue; |
| | | } |
| | | reqData.setDeviceId(device.getDeviceId()); |
| | | reqData.setProductId(device.getProductId()); |
| | | reqData.setDeviceName(device.getDeviceName()); |
| | | reqData.setDevice(device); |
| | | reqData.setAutoReplay(true); |
| | | GatewaySyncGranService syncGrainService = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()); |
| | | resp = syncGrainService.syncGrain(reqData); |
| | | log.info("命令发送结果:"+resp.toString()); |
| | | Thread.sleep(30000); |
| | | }catch (Exception e){ |
| | | log.error(e.getMessage(),e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * 每间隔3秒执行一次事件 |