|
@@ -215,7 +215,6 @@ func CREATE_DeviceData(SN string) bool {
|
|
|
//}
|
|
|
|
|
|
type DeviceData_ struct {
|
|
|
- T_id int `orm:"column(t_id);size(10);null"` // ID
|
|
|
T_t float32 `orm:"column(t_t);size(10);null"` // 温度
|
|
|
T_rh float32 `orm:"column(t_rh);size(10);null"` // 湿度
|
|
|
T_time string `orm:"column(t_time);type(timestamp);null;"` // 采集时间
|
|
@@ -273,7 +272,8 @@ func Read_DeviceSensorData_ById_List(SN string, Time_start_ string, Time_end_ st
|
|
|
return maps, 0
|
|
|
}
|
|
|
//fmt.Println("maps_z;",maps_z[0][0])
|
|
|
- sql = "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN
|
|
|
+ //sql = "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN
|
|
|
+ sql = "SELECT t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN
|
|
|
if len(sql_time) > 0 {
|
|
|
sql += " WHERE " + sql_time
|
|
|
}
|
|
@@ -312,7 +312,8 @@ func Read_DeviceData_By_snid(SN string, T_id int, Time_start_ string, Time_end_
|
|
|
sql_time += " t_time <= '" + Time_end_ + "' AND "
|
|
|
}
|
|
|
|
|
|
- sql := "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
+ //sql := "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
+ sql := "SELECT t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(limit)
|
|
|
fmt.Println(sql)
|
|
|
_, err := o.Raw(sql).QueryRows(&maps)
|
|
@@ -389,7 +390,8 @@ func Read_DeviceSensorData_List(SN string, Time_start_ string, Time_end_ string,
|
|
|
return maps, 0
|
|
|
}
|
|
|
//fmt.Println("maps_z;",maps_z[0][0])
|
|
|
- sql = "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " " + sql_time + " ORDER BY t_time DESC "
|
|
|
+ //sql = "SELECT t_id,t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " " + sql_time + " ORDER BY t_time DESC "
|
|
|
+ sql = "SELECT t_t,t_rh,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " " + sql_time + " ORDER BY t_time DESC "
|
|
|
if page_z != 9999 {
|
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(pagez)
|
|
|
}
|
|
@@ -449,7 +451,8 @@ func Read_DeviceSensorData_ById_New(SN string, T_id int) (DeviceData_New, bool)
|
|
|
}
|
|
|
|
|
|
//fmt.Println("maps_z;",maps_z[0][0])
|
|
|
- sql := "SELECT t_id,t_t,t_rh,t_time FROM z_devicedata_" + SN + " WHERE " + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
+ //sql := "SELECT t_id,t_t,t_rh,t_time FROM z_devicedata_" + SN + " WHERE " + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
+ sql := "SELECT t_t,t_rh,t_time FROM z_devicedata_" + SN + " WHERE " + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time DESC "
|
|
|
sql = sql + " LIMIT 0,1 "
|
|
|
|
|
|
fmt.Println(sql)
|