From a230c790107e4be5743473849bbc9aeb93583ddd Mon Sep 17 00:00:00 2001
From: vince <757871790@qq.com>
Date: 星期五, 14 六月 2024 09:33:01 +0800
Subject: [PATCH] 修改地磅报文
---
src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java | 67 ++++++++++++++++++++++++++-------
1 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java b/src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
index 2010ea8..05b6b64 100644
--- a/src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
+++ b/src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
@@ -125,7 +125,7 @@
//鑾峰彇璇锋眰淇℃伅
- BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDepotIdSys());
+ BaseReqData reqData = ProtocolUtils.getSyncReq(gatewayDevice.getDeviceSn());
if (null == reqData) {
replayGrain(message);
log.error("涓绘満-------->>骞冲彴锛岃В鏋愮伯鎯呭け璐ワ紝鏈幏鍙栧埌绮儏璇锋眰淇℃伅锛�" + message.getAddr());
@@ -201,13 +201,13 @@
int sumNum = cableData.getSumNum();
// 鏍规嵁灞傝鍒楄幏鍙栨寚瀹氶暱搴�
- int start = 0;
+ int start = (Integer.valueOf(device.getCableStart()) - 1) * cableData.getCableZ() * 4;
int len = 4 * sumNum;
log.info("鍒嗘満------>>>骞冲彴锛氳繑鍥炵伯鎯呭畬鏁翠俊鎭紝鍒嗘満={}", device.getDeviceName());
String strPoints = grainStr.substring(start, start + len);
-
+ log.info("strPoints = "+ strPoints);
// 灏嗙伯鎯呰В鏋愭垚鏁扮粍
List<Double> temps = new ArrayList<>();
double tempValue;
@@ -278,7 +278,7 @@
int cableY = cableData.getCableY();
int sumNum = temps.size();
-
+ log.info("temps:" + temps.toString());
//鏁版嵁灏佽
GrainData grain = new GrainData();
grain.setMessageId(ScConstant.getMessageId());
@@ -346,25 +346,53 @@
outPut.setTemperature(temperature);
outPut.setAvgTemperature(NumberUtil.keepPrecision((sumT / sumNum), 1) + "");
outPut.setMinTemperature(min + "");
- outPut.setMaxTemperature(min + "");
+ outPut.setMaxTemperature(max + "");
JSONObject properties = new JSONObject();
- properties.put("data", outPut);
- properties.put("timestamp", grain.getTimestamp());
+ properties.put("timestamp", grain.getTimestamp());
+ outPut.setDetectTime( grain.getTimestamp());
String height = this.getCacheHeight(device);
if (StringUtils.isEmpty(height)) height = "0.0";
properties.put("liquidHeight", height);
- grain.setProperties(properties);
+ outPut.setLiquidHeight(height);
+ grain.setOutput(JSONObject.toJSONString(outPut));
+ properties.put("output", outPut);
+ GatewayDevice gatewayDeviceWeather = GatewayUtils.getCacheByDeviceTypeOne(GatewayDeviceType.TYPE_09.getCode());
+
+ //绯荤粺姘旇薄绔欎俊鎭�
+ WeatherWebDto weather = WeatherWebDto.contextMap.get("default");
+
+ //姘旇薄淇℃伅
+ GrainWeather weatherStation = new GrainWeather();
+ weatherStation.setMessageId(ScConstant.getMessageId());
+ weatherStation.setMessgeId(weatherStation.getMessageId());
+
+ if (null != gatewayDeviceWeather) {
+ weatherStation.setId(gatewayDeviceWeather.getDeviceId());
+ } else {
+ weatherStation.setId(device.getDeviceId());
+ }
+ weatherStation.setAirPressure(weather.getPressure());
+ weatherStation.setHumidity(weather.getHumidity());
+ weatherStation.setPm(weather.getAir_pm25());
+ weatherStation.setRadiation("0");
+ weatherStation.setRainfallAmount(weather.getWea());
+ weatherStation.setTemperature(weather.getTem());
+ weatherStation.setWindDirection(weather.getWin());
+ weatherStation.setWindPower(weather.getWin_meter());
+ weatherStation.setWindSpeed(weather.getWin_speed());
+
+ grain.setWeatherStation(JSONObject.toJSONString(weatherStation));
//灏佽濂界殑鏁版嵁
log.info("---娌圭綈浠撲俊鎭皝瑁呭畬鎴�----寮�濮嬫墽琛屾帹閫�");
-
+ grain.setProperties(properties);
reqData.setData(JSONObject.toJSONString(grain));
- doPushGrain(reqData);
+ doPushGrain(reqData,grain);
}
/**
@@ -375,8 +403,17 @@
*/
private String getCacheHeight(GatewayDevice device) {
//缁欏叾浠栬蒋浣跨敤
- String key = RedisConst.KEY_DEPOT_HEIGHT + ":" + configData.getCompanyId() + "_" + device.getDepotIdSys();
- return (String) redisUtil.get(key);
+ //igds:5012:DEPOT_HEIGHT:0134
+ String key = "igds:"+ device.getOrgId() + ":" + RedisConst.KEY_DEPOT_HEIGHT+ ":" + device.getDepotIdSys();
+ com.ld.igds.grain.dto.GrainData ht = (com.ld.igds.grain.dto.GrainData) redisUtil.get(key);
+ log.info("KEY="+key);
+ if(ht!=null){
+ log.info("VALUE="+ht.getOilHeight());
+ return ht.getOilHeight() ;
+ }else {
+ return "0.0";
+ }
+
}
@@ -500,10 +537,10 @@
reqData.setData(JSONObject.toJSONString(grain));
- doPushGrain(reqData);
+ doPushGrain(reqData,grain);
}
- private void doPushGrain(BaseReqData reqData) {
+ private void doPushGrain(BaseReqData reqData,GrainData grainData) {
GatewayDeviceReportService reportService = gatewayRemoteManager.getDeviceReportService(reqData.getDevice().getPushProtocol());
if (null == reportService) {
@@ -511,6 +548,8 @@
return;
}
reportService.reportGrainData(reqData);
+ reqData.setData(reportService.grainData2GatewayApiInfoKafka(grainData,reqData.getDevice()).getData());
+ reportService.reportGrainDataByKafka(reqData);
}
--
Gitblit v1.9.3