|
|
@@ -5054,7 +5054,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
case TAB_ID_POWER_INFO:
|
|
|
{
|
|
|
GlobalPowerInfo tmp;
|
|
|
- snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE product_samp_time BETWEEN '%s' AND '%s';", tabNamePool[tab_id], time_s, time_e);
|
|
|
+ snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE product_samp_time BETWEEN '%s' AND '%s' ORDER BY product_samp_time DESC;", tabNamePool[tab_id], time_s, time_e);
|
|
|
|
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
if (r != SQLITE_OK) {
|
|
|
@@ -5062,7 +5062,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- while (sqlite3_step(stmt) == SQLITE_ROW) { //column start from 0
|
|
|
+ while (sqlite3_step(stmt)==SQLITE_ROW) { //column start from 0
|
|
|
tmp.product_id = sqlite3_column_int(stmt, 1);
|
|
|
tmp.product_ch_id = sqlite3_column_int(stmt, 2);
|
|
|
tmp.product_status = sqlite3_column_int(stmt, 3);
|
|
|
@@ -5085,7 +5085,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
{
|
|
|
GlobalTreeACManager tmp;
|
|
|
|
|
|
- snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (product_ph_samp_time BETWEEN '%s' AND '%s') ORDER BY product_index ASC;", tabNamePool[tab_id], time_s, time_e);
|
|
|
+ snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (product_ph_samp_time BETWEEN '%s' AND '%s') ORDER BY product_ph_samp_time DESC;", tabNamePool[tab_id], time_s, time_e);
|
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
if (r != SQLITE_OK) {
|
|
|
log_e("___db_requery TAB_ID_POWER3_INFO, sqlite3_prepare_v2 failed\n");
|
|
|
@@ -5123,7 +5123,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
alarm_data_t tmp;
|
|
|
GlobalDeviceManager *dm=&__globalDeviceManage;
|
|
|
|
|
|
- snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE ((alarmType=%d) OR (alarmType=%d)) AND (alarmDate BETWEEN '%s' AND '%s');",
|
|
|
+ snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE ((alarmType=%d) OR (alarmType=%d)) AND (alarmDate BETWEEN '%s' AND '%s') ORDER BY alarmDate DESC;",
|
|
|
tabNamePool[tab_id], ALARM_TYPE_OPRATION, ALARM_TYPE_RUNNING, time_s, time_e);
|
|
|
|
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
@@ -5555,18 +5555,25 @@ int dev_log_xport(int type, time_t from, time_t to, char *path)
|
|
|
}
|
|
|
|
|
|
l = xlist_init(&lc);
|
|
|
+
|
|
|
+ log_d("___ log export, query db start ...\n");
|
|
|
db_exec(dm->db, TAB_ID_ALARM_INFO, IO_EXPORT, from, to, l);
|
|
|
+ log_d("___ log export, query db end ...\n");
|
|
|
|
|
|
fp = fopen(path, "wt");
|
|
|
if(!fp) {
|
|
|
- printf("__%s open failed\n", path);
|
|
|
+ log_e("__%s open failed\n", path);
|
|
|
xlist_free(l);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
fprintf(fp, "id,date,content\n");
|
|
|
arg.fp = fp; arg.id = 1; arg.type = stype;
|
|
|
+
|
|
|
+ log_d("___ log export, sz: %d, iterator start ...\n", xlist_size(l));
|
|
|
xlist_iterator(l, NULL, log_iterator_fn, &arg);
|
|
|
+ log_d("___ log export, iterator end ...\n");
|
|
|
+
|
|
|
fclose(fp);
|
|
|
xlist_free(l);
|
|
|
|
|
|
@@ -5639,16 +5646,19 @@ int dev_power_xport(time_t from, time_t to, char *path)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- if(dm->_globalDevInfo.product.pwr_type>=SmartPDU_Tree_AC_Tree) {
|
|
|
+ if(dm->_globalDevInfo.product.pwr_type==SmartPDU_Tree_AC_Tree) {
|
|
|
tab_id = TAB_ID_POWER3_INFO;
|
|
|
}
|
|
|
|
|
|
l = xlist_init(&lc);
|
|
|
+
|
|
|
+ log_d("___ power export, query db start ...\n");
|
|
|
db_exec(dm->db, tab_id, IO_EXPORT, from, to, l);
|
|
|
+ log_d("___ power export, query db end ...\n");
|
|
|
|
|
|
fp = fopen(path, "wt");
|
|
|
if(!fp) {
|
|
|
- printf("__%s open failed\n", path);
|
|
|
+ log_e("__%s open failed\n", path);
|
|
|
xlist_free(l);
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -5661,7 +5671,10 @@ int dev_power_xport(time_t from, time_t to, char *path)
|
|
|
}
|
|
|
|
|
|
arg.fp = fp; arg.id = 1;
|
|
|
+ log_d("___ pwr export, sz: %d, iterator start ...\n", xlist_size(l));
|
|
|
xlist_iterator(l, NULL, pwr_iterator_fn, &arg);
|
|
|
+ log_d("___ pwr export, iterator end ...\n");
|
|
|
+
|
|
|
fclose(fp);
|
|
|
xlist_free(l);
|
|
|
|
|
|
@@ -5672,7 +5685,7 @@ int dev_power_xport(time_t from, time_t to, char *path)
|
|
|
int dev_clear_table(sqlite3 *db, int tab_id)
|
|
|
{
|
|
|
int r;
|
|
|
- char temp[1024];
|
|
|
+ char temp[200];
|
|
|
|
|
|
if(!db || tab_id<TAB_ID_NTP || tab_id>=TAB_ID_MAX) {
|
|
|
return -1;
|