From 11d4be720620abf502d35000e2ed40d30c4023bf Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期一, 24 十一月 2025 16:33:34 +0800
Subject: [PATCH] 修复离线时间展示
---
collect/src/main/java/com/qianwen/mdc/collect/service/IOTMqttReceiveService.java | 41 ++++++++++++-----------------------------
1 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/collect/src/main/java/com/qianwen/mdc/collect/service/IOTMqttReceiveService.java b/collect/src/main/java/com/qianwen/mdc/collect/service/IOTMqttReceiveService.java
index 3246a2f..a8a67b7 100644
--- a/collect/src/main/java/com/qianwen/mdc/collect/service/IOTMqttReceiveService.java
+++ b/collect/src/main/java/com/qianwen/mdc/collect/service/IOTMqttReceiveService.java
@@ -19,6 +19,7 @@
@Service
public class IOTMqttReceiveService {
+ public static final String NEWDP_SUFFIX = "_n";//璁$畻瑙勫垯浣跨敤涔嬪悗鏂版暟鎹偣鐨勭粨灏�
private static final Logger log = LoggerFactory.getLogger(IOTMqttReceiveService.class);
@Autowired
private CollectDataService collectDataService;
@@ -26,12 +27,11 @@
@Autowired
private PackedDataService packedDataService;
@Autowired
- private RedisUtil redisUtil;
- @Autowired
private WorkstationDatapointsService dpService;
+
/**
* 澶勭悊鏀跺埌鐨勬秷鎭�,瀵瑰簲TelemetryDataPostingConsumer
- * @param payload
+ * @param payload 鏁版嵁锛宩son鏍煎紡
*/
public void handle(String payload) {
//瑙f瀽娑堟伅
@@ -56,15 +56,13 @@
Set<String> keySet = jsonObj.keySet();
String[] keys = keySet.toArray(new String[] {});
- //WorkstationDatapointsVO dpVo;
- final String NEWDP_SUFFIX = "_n";//璁$畻瑙勫垯浣跨敤涔嬪悗鏂版暟鎹偣鐨勭粨灏�
for(String key : keys) {
String appId = key;//iot绯荤粺涓殑搴旂敤id锛屾湰搴旂敤涓簲璇ョ敤琛ㄥ幓瀵瑰簲
-
- //TODO 鑾峰彇宸ヤ綅鏁版嵁鐐归厤缃�,鍙繚瀛橀厤缃ソ鐨勬暟鎹偣锛屾病鏈夐厤缃殑閲囬泦鏁版嵁鎶涘純銆�
+ //鑾峰彇宸ヤ綅鏁版嵁鐐归厤缃�,鍙繚瀛橀厤缃ソ鐨勬暟鎹偣锛屾病鏈夐厤缃殑閲囬泦鏁版嵁鎶涘純銆�
final WorkstationDatapointsVO dpVo = dpService.getDatapointsByAppIdFromCache(appId);
+ //final WorkstationDatapointsVO dpVo = dpService.getDataPointByAppId(appId);
if(dpVo == null) {
//宸ヤ綅娌℃湁瀹氫箟杩囨暟鎹偣鎴栬�卆ppId涓嶅尮閰�
log.warn("appId={}鏈壘鍒版暟鎹偣瀹氫箟璁板綍锛屼涪寮冩暟鎹�",appId);
@@ -88,14 +86,16 @@
Set<String> valueKeySet = values.keySet();
valueKeySet.forEach(valueKey ->{
- String oriValueKey = valueKey;;//鐢变簬浣跨敤璁$畻瑙勫垯鐨勯噰闆嗙偣鍚嶇О浼氬悗闈㈠鍔犱竴涓�"_n",鎵�浠ヨ繖涓猳riValueKey浠h〃娌℃湁澧炲姞"_n"鐨�
- if(StringUtils.endsWith(valueKey, NEWDP_SUFFIX)) {
- oriValueKey = StringUtils.removeEnd(valueKey, NEWDP_SUFFIX);
- }
- if(!dpVo.containsDataPoint(oriValueKey)) {
+ if(!dpVo.containsDataPoint(valueKey)) {
//濡傛灉涓嶅瓨鍦ㄨ鏁版嵁鐐归厤缃紝璇ユ暟鎹洿鎺ュ拷鐣�
return;
}
+
+ String oriValueKey = valueKey;//鐢变簬浣跨敤璁$畻瑙勫垯鐨勯噰闆嗙偣鍚嶇О浼氬悗闈㈠鍔犱竴涓�"_n",鎵�浠ヨ繖涓猳riValueKey浠h〃娌℃湁澧炲姞"_n"鐨�
+ if(StringUtils.endsWith(valueKey, NEWDP_SUFFIX)) {
+ oriValueKey = StringUtils.removeEnd(valueKey, NEWDP_SUFFIX);
+ }
+
tdataItem.addPoint(oriValueKey,values.getString(valueKey));//浣跨敤鍘熷閰嶇疆鐐逛繚鎸佷繚瀛樻暟鎹�
});
@@ -108,21 +108,4 @@
return dtList;
}
- /**
- * 鏍规嵁瀵瑰簲琛ㄧ紦瀛橈紝鑾峰彇appId瀵瑰簲鐨刬d
- * @param appId
- * @return
- */
- /*
- public Long getWorkstationIdByAppId(String appId) {
-
- Object wid = redisUtil.hget("workstation-appid-map", appId);
-
- String workstationId = String.valueOf(Optional.ofNullable(wid).orElse(StringUtils.EMPTY));
- if(ObjectUtil.isEmpty(workstationId)) {
- return null;
- }
- return Long.parseLong(workstationId);
- }
- */
}
--
Gitblit v1.9.3