ICLogger.i("Query1 cmdRecords " + where);
Cursor cmdrecords = pcr.query(table, null, where.toString(), null, null);
StringMessage msg = null;
- if (cmdrecords != null) {
- int score = 0;
- if (cmdrecords.getCount() > 0) { //有警报则先发送警报
+ if (cmdrecords != null && cmdrecords.getCount() > 0) { //有警报则先发送警报
+ if (cmdrecords.moveToFirst()) {
+ String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
+ String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
+ String date = cmdrecords.getString(cmdrecords.getColumnIndex("DATE"));
+ String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
+ int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
+ int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
+
+ msg = new StringMessage(new String[]{topic});
+ msg.refresh(cmd);
+ msg.setDate(date, time);
+ msg.setSentFlag(flag);
+ msg.setIndex(index);
+ ICLogger.i("get cmd Record not sent _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
+ }
+ cmdrecords.close();
+ } else { //没有警报,就查询 UD 消息发送 //当前数据优先于 UD2数据
+ if (cmdrecords != null) {
+ cmdrecords.close();
+ }
+ where = new StringBuilder("FLAG=0 and ( TOPIC='AP01' or TOPIC='UD' ) ");
+ cmdrecords = pcr.query(table, null, where.toString(), null, null);
+ ICLogger.i("Query2 cmdRecords " + where);
+ msg = null;
+ if (cmdrecords != null && cmdrecords.getCount() > 0) {
if (cmdrecords.moveToFirst()) {
String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
-
msg = new StringMessage(new String[]{topic});
msg.refresh(cmd);
msg.setDate(date, time);
ICLogger.i("get cmd Record not sent _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
}
cmdrecords.close();
- } else { //没有警报,就查询 UD 消息发送 //当前数据优先于 UD2数据
- cmdrecords.close();
- where = new StringBuilder("FLAG=0 and ( TOPIC='AP01' or TOPIC='UD' ) ");
+ } else {
+ if (cmdrecords != null) {
+ cmdrecords.close();
+ }
+ where = new StringBuilder("FLAG=0 and ( TOPIC='APH1' or TOPIC='UD2' )");
cmdrecords = pcr.query(table, null, where.toString(), null, null);
- ICLogger.i("Query2 cmdRecords " + where);
+ ICLogger.i("Query3 cmdRecords " + where);
msg = null;
if (cmdrecords != null && cmdrecords.getCount() > 0) {
if (cmdrecords.moveToFirst()) {
}
cmdrecords.close();
} else {
- cmdrecords.close();
- where = new StringBuilder("FLAG=0 and ( TOPIC='APH1' or TOPIC='UD2' )");
+ if (cmdrecords != null) {
+ cmdrecords.close();
+ }
+ where = new StringBuilder("FLAG=0");
cmdrecords = pcr.query(table, null, where.toString(), null, null);
- ICLogger.i("Query3 cmdRecords " + where);
+ ICLogger.i("Query4 cmdRecords " + where);
msg = null;
if (cmdrecords != null && cmdrecords.getCount() > 0) {
if (cmdrecords.moveToFirst()) {
ICLogger.i("get cmd Record not sent _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
}
cmdrecords.close();
- } else {
- cmdrecords.close();
- where = new StringBuilder("FLAG=0");
- cmdrecords = pcr.query(table, null, where.toString(), null, null);
- ICLogger.i("Query4 cmdRecords " + where);
- msg = null;
- if (cmdrecords != null && cmdrecords.getCount() > 0) {
- if (cmdrecords.moveToFirst()) {
- String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
- String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
- String date = cmdrecords.getString(cmdrecords.getColumnIndex("DATE"));
- String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
- int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
- int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
- msg = new StringMessage(new String[]{topic});
- msg.refresh(cmd);
- msg.setDate(date, time);
- msg.setSentFlag(flag);
- msg.setIndex(index);
- ICLogger.i("get cmd Record not sent _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
- }
- cmdrecords.close();
- }
}
}
}