| | |
| | | import com.fzzy.api.data.PushProtocol; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.view.repository.ApiLogRep; |
| | | import com.fzzy.data.ConfigData; |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.api.GatewayRemoteService; |
| | | import com.fzzy.gateway.data.BaseResp; |
| | |
| | | private GatewayConfService gatewayConfService; |
| | | @Resource |
| | | private KafkaDeviceReportService kafkaDeviceReportService; |
| | | @Resource |
| | | private ConfigData configData; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | String messageInfo = JSONObject.toJSONString(heartBeatData); |
| | | |
| | | log.info("---网关心跳推送--{}-{}", topic, messageInfo); |
| | | //如果是测试模式不执行推送 |
| | | if (configData.getActive().indexOf("dev") >= 0) { |
| | | |
| | | log.info("----------------------------推送KAFKA信息,注:调试模式不推送---------------------------"); |
| | | log.info("-----TOPIC-----{}", topic); |
| | | log.info("-----Message-----{}", messageInfo); |
| | | |
| | | return; |
| | | } |
| | | |
| | | |
| | | kafkaDeviceReportService.publishWithTopic(messageInfo, topic); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("------网关心跳接口--执行失败-----{}", e); |
| | | } |
| | | |
| | | //执行当前网关的设备状态推送 |
| | | log.info("------------定时设备状态执行---------{}", gatewayConf.getKqmc()); |
| | | pushDeviceStatus(gatewayConf); |
| | | } |
| | | |
| | | @Override |
| | | public void pushInfo(GatewayConf gatewayConf) { |
| | | try { |
| | | |
| | | if (StringUtils.isEmpty(gatewayConf.getApiUrl())) { |
| | | return; |
| | | } |
| | | |
| | | gatewayConf = getCacheConf(gatewayConf.getKqdm()); |
| | | //网关心跳接口 |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("token", gatewayConf.getAccessToken()); |
| | | params.put("gatewayId", gatewayConf.getGatewayId()); |
| | | params.put("gatewayIp", gatewayConf.getGatewayIp()); |
| | | params.put("gatewayMac", null == gatewayConf.getGatewayMac() ? "无" : gatewayConf.getGatewayMac()); |
| | | params.put("gatewayCPU", null == gatewayConf.getGatewayCPU() ? "无" : gatewayConf.getGatewayCPU()); |
| | | params.put("gatewayMem", null == gatewayConf.getGatewayMem() ? "无" : gatewayConf.getGatewayMem()); |
| | | params.put("gatewayHardDisk", null == gatewayConf.getGatewayHardDisk() ? "无" : gatewayConf.getGatewayHardDisk()); |
| | | params.put("timestamp", System.currentTimeMillis() + ""); |
| | | |
| | | String sign = getSign(params, gatewayConf); |
| | | params.put("sign", sign); |
| | | |
| | | String url = gatewayConf.getApiUrl() + "reserver/api/iot/equipment/heartbeat"; |
| | | |
| | | String jsonStr = GatewayHttpUtil.doGet(url, params); |
| | | log.info("---推送网关信息-返回---{}", jsonStr); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("------推送网关信息--执行失败-----{}", e); |
| | | } |
| | | //DO NOTHING |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | messageInfo = JSONObject.toJSONString(statusData); |
| | | |
| | | //如果是测试模式不执行推送 |
| | | if (configData.getActive().indexOf("dev") >= 0) { |
| | | |
| | | log.info("----------------------------推送KAFKA信息,注:调试模式不推送---------------------------"); |
| | | log.info("-----TOPIC-----{}", topic); |
| | | log.info("-----Message-----{}", messageInfo); |
| | | |
| | | return; |
| | | } |
| | | |
| | | //推送设备状态 |
| | | kafkaDeviceReportService.publishWithTopic(messageInfo, topic); |
| | | |