From e6dee5bf270329ddf7d1123f8ad0d5f33b99d2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B9=B3?= Date: Thu, 30 Nov 2023 16:25:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E6=95=B0=E6=8D=AE=E6=AE=B5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/drht/datamanage/protocols/Cn2011.java | 2 +- .../drht/datamanage/util/AnalysisUtil.java | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/drht/datamanage/protocols/Cn2011.java b/src/main/java/com/drht/datamanage/protocols/Cn2011.java index df7754d..dc6952e 100644 --- a/src/main/java/com/drht/datamanage/protocols/Cn2011.java +++ b/src/main/java/com/drht/datamanage/protocols/Cn2011.java @@ -63,7 +63,7 @@ public class Cn2011 implements Reply { realTimeData.setF_turbidity(v); else if(ckey.equals("DataTime")) realTimeData.setF_time(v); - else if(ckey.equals("f_raw_data")) + else if(ckey.equals("rawData")) realTimeData.setF_raw_data(v); } BaseResult result=realTimeDataService.insert(realTimeData); diff --git a/src/main/java/com/drht/datamanage/util/AnalysisUtil.java b/src/main/java/com/drht/datamanage/util/AnalysisUtil.java index 94d58b1..6a55100 100644 --- a/src/main/java/com/drht/datamanage/util/AnalysisUtil.java +++ b/src/main/java/com/drht/datamanage/util/AnalysisUtil.java @@ -80,23 +80,29 @@ public class AnalysisUtil { String[] cpArry = s.split(";"); for (String ss:cpArry){ //以逗号分隔 - String[] c = ss.split(","); - for (String s1:c){ - //此处已经是单值 xxx=xxx - String[] split = s1.split("="); - String key=""; - String value=""; - key=split[0]; - if (split.length==2){ - //不是key=value的格式 + if(!ss.startsWith("rawData")){ + String[] c = ss.split(","); + for (String s1:c){ + //此处已经是单值 xxx=xxx + String[] split = s1.split("="); + String key=""; + String value=""; + key=split[0]; + if (split.length==2){ + //不是key=value的格式 // throw new AnalysisException(2701,"解析报文出错,报文cp段的值不是key=value形式"); - value=split[1]; + value=split[1]; + } + //特殊处理 ##1234QN=20180210154956000 + if(key.endsWith("QN")&&!"QN".equals(key.split("QN")[0])) + key="QN"; + resultMap.put(key,value); } - //特殊处理 ##1234QN=20180210154956000 - if(key.endsWith("QN")&&!"QN".equals(key.split("QN")[0])) - key="QN"; - resultMap.put(key,value); + }else { + String[] split = ss.split("="); + resultMap.put(split[0],split[1]); } + } return resultMap; }