From efec12bd4827ddefd9b19ccc0eee3ca1c62908f3 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期五, 12 一月 2024 19:09:01 +0800 Subject: [PATCH] 添加手动推送粮情接口,以便第三方接口调用 --- src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java | 57 ++++++++++++++++++++++++++------------------------------- 1 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java b/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java index f8b3c0a..c85f7c6 100644 --- a/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java +++ b/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewayRemoteServiceImpl.java @@ -6,6 +6,7 @@ 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; @@ -47,6 +48,8 @@ private GatewayConfService gatewayConfService; @Resource private KafkaDeviceReportService kafkaDeviceReportService; + @Resource + private ConfigData configData; @Override @@ -135,50 +138,31 @@ String messageInfo = JSONObject.toJSONString(heartBeatData); - log.info("---缃戝叧蹇冭烦鎺ㄩ��--{}-{}", topic, messageInfo); + //濡傛灉鏄祴璇曟ā寮忎笉鎵ц鎺ㄩ�� + if (configData.getActive().indexOf("dev") >= 0) { + + log.info("----------------------------鎺ㄩ�並AFKA淇℃伅锛屾敞锛氳皟璇曟ā寮忎笉鎺ㄩ��---------------------------"); + 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 } @@ -217,6 +201,17 @@ } messageInfo = JSONObject.toJSONString(statusData); + + //濡傛灉鏄祴璇曟ā寮忎笉鎵ц鎺ㄩ�� + if (configData.getActive().indexOf("dev") >= 0) { + + log.info("----------------------------鎺ㄩ�並AFKA淇℃伅锛屾敞锛氳皟璇曟ā寮忎笉鎺ㄩ��---------------------------"); + log.info("-----TOPIC-----{}", topic); + log.info("-----Message-----{}", messageInfo); + + return; + } + //鎺ㄩ�佽澶囩姸鎬� kafkaDeviceReportService.publishWithTopic(messageInfo, topic); -- Gitblit v1.9.3