瀏覽代碼

传感器导出bug

liyi 10 月之前
父節點
當前提交
2b87c3f7ba
共有 1 個文件被更改,包括 8 次插入 和 7 次删除
  1. 8 7
      pro/src/sqlite_handle.c

+ 8 - 7
pro/src/sqlite_handle.c

@@ -5635,7 +5635,7 @@ static int db_exec(sqlite3 *db, int tab_id, int type, time_t from, time_t to, ha
         {
             GlobalSensorInfo tmp;
 
-            snprintf(temp,sizeof(temp),"SELECT * FROM Table_sensorInfo where (sensor_samp_time BETWEEN '%s' and '%s' ) and sensor_id in (SELECT a.sensor_type from Table_SensorManage a where (a.sensor_type=%d));",time_s, time_e,type);
+            snprintf(temp,sizeof(temp),"SELECT * FROM Table_sensorInfo where (sensor_samp_time BETWEEN '%s' and '%s' ) and sensor_id in (SELECT a.sensor_id from Table_SensorManage a where (a.sensor_type=%d));",time_s, time_e,type);
             //snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (sensor_samp_time BETWEEN '%s' AND '%s') ORDER BY sensor_samp_time DESC;", tabNamePool[tab_id], time_s, time_e);
             r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
             if (r != SQLITE_OK) {
@@ -5644,14 +5644,14 @@ static int db_exec(sqlite3 *db, int tab_id, int type, time_t from, time_t to, ha
             }
 
             while (sqlite3_step(stmt) == SQLITE_ROW) {
-                p = (char*)sqlite3_column_text(stmt, 2);
+                p = (char*)sqlite3_column_text(stmt, 1);
                 tmp.samp_time[0] = 0;
                 if(p) strcpy(tmp.samp_time, p);
 
-                tmp.product_id = sqlite3_column_int(stmt, 3);
-                tmp.sensor_id = sqlite3_column_int(stmt, 4);
-                tmp.val1 = sqlite3_column_double(stmt, 5);
-                tmp.val2 = sqlite3_column_double(stmt, 6);
+                tmp.product_id = sqlite3_column_int(stmt, 2);
+                tmp.sensor_id = sqlite3_column_int(stmt, 3);
+                tmp.val1 = sqlite3_column_double(stmt, 4);
+                tmp.val2 = sqlite3_column_double(stmt, 5);
 
                 xlist_append(l, tab_id, &tmp, sizeof(tmp));
                 cnt++;
@@ -6003,8 +6003,9 @@ static int sensor_iterator_fn(handle_t l, node_t *node, node_t *xd, void *arg, i
     fprintf(parg->fp, "%d,", tmp->sensor_id);
     fprintf(parg->fp, "%0.2f,", tmp->val1);
     fprintf(parg->fp, "%0.2f,", tmp->val2);
-    fprintf(parg->fp, "%s,", tmp->samp_time);
+    
     replace_chr(tmp->samp_time, '-', '.');
+    fprintf(parg->fp, "%s,", tmp->samp_time);
     fprintf(parg->fp, "\n");
     parg->id++;
     return 0;