Commit bf44645329332d04fdbb81f7458111584c8229ee

Authored by 杨鸣坤
1 parent 2a391e39

报错修复v2

@@ -254,7 +254,7 @@ public class ShzzDevicePullService { @@ -254,7 +254,7 @@ public class ShzzDevicePullService {
254 String deviceName = result.get(1).toString(); 254 String deviceName = result.get(1).toString();
255 255
256 // 查询该设备最近两条key='531'的数据 256 // 查询该设备最近两条key='531'的数据
257 - String tsKvSql = "SELECT str_v FROM ts_kv " + 257 + String tsKvSql = "SELECT long_v FROM ts_kv " +
258 "WHERE entity_id = ? AND key = '531' " + 258 "WHERE entity_id = ? AND key = '531' " +
259 "ORDER BY ts DESC LIMIT 2"; 259 "ORDER BY ts DESC LIMIT 2";
260 260
@@ -265,7 +265,11 @@ public class ShzzDevicePullService { @@ -265,7 +265,11 @@ public class ShzzDevicePullService {
265 265
266 List<String> strVValues = new ArrayList<>(2); 266 List<String> strVValues = new ArrayList<>(2);
267 while (tsKvResultSet.next()) { 267 while (tsKvResultSet.next()) {
268 - strVValues.add(tsKvResultSet.getString("long_v")); 268 + long value = tsKvResultSet.getLong("long_v");
  269 + // 注意:getLong() 如果数据库值为NULL会返回0,这里需要判断是否真的为NULL
  270 + if (!tsKvResultSet.wasNull()) {
  271 + strVValues.add(String.valueOf(value));
  272 + }
269 } 273 }
270 274
271 // 如果查询到两条数据且值不同,才认为是真正的RUN状态 275 // 如果查询到两条数据且值不同,才认为是真正的RUN状态