Browse Source

回复消息 bug修改

zjs 1 week ago
parent
commit
b899ecd5e0

+ 4 - 1
src/main/java/com/cn/esermis/server/Consumer.java

@@ -38,7 +38,10 @@ public class Consumer {
38
             Object message = redisQueueService.receiveMessage(Constant.SERVER);
38
             Object message = redisQueueService.receiveMessage(Constant.SERVER);
39
             if (message==null || message.equals("")){
39
             if (message==null || message.equals("")){
40
 //                System.out.println("消息队列为空");
40
 //                System.out.println("消息队列为空");
41
-                Thread.sleep(1000*5);
41
+                try {
42
+                    Thread.sleep(1000*5);
43
+                } catch (InterruptedException e) {
44
+                }
42
             }else{
45
             }else{
43
                 tolot++;
46
                 tolot++;
44
                 int finalTolot = tolot;
47
                 int finalTolot = tolot;

+ 7 - 4
src/main/java/com/cn/esermis/utils/HJ212MsgUtils.java

@@ -90,7 +90,6 @@ public class HJ212MsgUtils {
90
                 } else {
90
                 } else {
91
                     String[] ele = getPollutionSource(paramStr);
91
                     String[] ele = getPollutionSource(paramStr);
92
                     JSONObject jsonObject = JSONObject.parseObject("{\"" + ele[1] + "\"}");
92
                     JSONObject jsonObject = JSONObject.parseObject("{\"" + ele[1] + "\"}");
93
-//                    PollutionGas pollutionGas = PollutionGas.valueOf(ele[0]);
94
                     PollutionGas[] values = PollutionGas.values();
93
                     PollutionGas[] values = PollutionGas.values();
95
                     jsonObject.put("factor", ele[0]);
94
                     jsonObject.put("factor", ele[0]);
96
                     if (ele[0].length() < 6){
95
                     if (ele[0].length() < 6){
@@ -105,7 +104,6 @@ public class HJ212MsgUtils {
105
                 }
104
                 }
106
             }
105
             }
107
             data.put("CP", cp);
106
             data.put("CP", cp);
108
-
109
             // 保存消息尾数据,主要是CRC校验和包结束符
107
             // 保存消息尾数据,主要是CRC校验和包结束符
110
             data.put("End", subMsg[2]);
108
             data.put("End", subMsg[2]);
111
 
109
 
@@ -119,6 +117,7 @@ public class HJ212MsgUtils {
119
 
117
 
120
     /**
118
     /**
121
      * 接收数据后做数据格式化,回复数据是否接收成功
119
      * 接收数据后做数据格式化,回复数据是否接收成功
120
+     * 消息回复
122
      */
121
      */
123
     public static String reply(String msg) {
122
     public static String reply(String msg) {
124
         StringBuilder result = new StringBuilder();
123
         StringBuilder result = new StringBuilder();
@@ -133,14 +132,18 @@ public class HJ212MsgUtils {
133
             data.put("SIZE", headStr.substring(0, 4));
132
             data.put("SIZE", headStr.substring(0, 4));
134
             data.putAll(JSONObject.parseObject("{\"" + headStr.substring(4) + "\"}"));
133
             data.putAll(JSONObject.parseObject("{\"" + headStr.substring(4) + "\"}"));
135
             for (Map.Entry<String, Object> stringObjectEntry : data.entrySet()) {
134
             for (Map.Entry<String, Object> stringObjectEntry : data.entrySet()) {
135
+                if (stringObjectEntry.getKey().equals("SIZE"))
136
+                    continue;
136
                 if (stringObjectEntry.getKey().equals("CN")){
137
                 if (stringObjectEntry.getKey().equals("CN")){
137
                     result.append(stringObjectEntry.getKey()).append("=").append("9014").append(";");
138
                     result.append(stringObjectEntry.getKey()).append("=").append("9014").append(";");
138
-                }
139
+                }else
139
                 if (stringObjectEntry.getKey().equals("ST")){
140
                 if (stringObjectEntry.getKey().equals("ST")){
140
                     result.append(stringObjectEntry.getKey()).append("=").append("91").append(";");
141
                     result.append(stringObjectEntry.getKey()).append("=").append("91").append(";");
141
-                }
142
+                }else
142
                 if (stringObjectEntry.getKey().equals("Flag")){
143
                 if (stringObjectEntry.getKey().equals("Flag")){
143
                     result.append(stringObjectEntry.getKey()).append("=").append("4").append(";");
144
                     result.append(stringObjectEntry.getKey()).append("=").append("4").append(";");
145
+                }else{
146
+                    result.append(stringObjectEntry.getKey()).append("=").append(stringObjectEntry.getValue()).append(";");
144
                 }
147
                 }
145
             }
148
             }
146
         } catch (Exception e) {
149
         } catch (Exception e) {