|
@@ -43,19 +43,19 @@ func init() {
|
|
|
|
|
|
configJPG := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
|
|
configJPG := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
|
|
"redis_DeviceDataJPG", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
|
|
"redis_DeviceDataJPG", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
|
|
- fmt.Println(config)
|
|
|
|
|
|
+ logs.Println(config)
|
|
var err error
|
|
var err error
|
|
redisCache_DeviceData, err = cache.NewCache("redis", config)
|
|
redisCache_DeviceData, err = cache.NewCache("redis", config)
|
|
if err != nil || redisCache_DeviceData == nil {
|
|
if err != nil || redisCache_DeviceData == nil {
|
|
errMsg := "failed to init redis"
|
|
errMsg := "failed to init redis"
|
|
- fmt.Println(errMsg, err)
|
|
|
|
|
|
+ logs.Println(errMsg, err)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
redisCache_DeviceDataJPG, err = cache.NewCache("redis", configJPG)
|
|
redisCache_DeviceDataJPG, err = cache.NewCache("redis", configJPG)
|
|
if err != nil || redisCache_DeviceDataJPG == nil {
|
|
if err != nil || redisCache_DeviceDataJPG == nil {
|
|
errMsg := "failed to init redis"
|
|
errMsg := "failed to init redis"
|
|
- fmt.Println(errMsg, err)
|
|
|
|
|
|
+ logs.Println(errMsg, err)
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -64,7 +64,7 @@ func DeviceData_Set(key string) (err error) {
|
|
|
|
|
|
err = redisCache_DeviceData.Put(key, "", 2*time.Hour)
|
|
err = redisCache_DeviceData.Put(key, "", 2*time.Hour)
|
|
if err != nil {
|
|
if err != nil {
|
|
- fmt.Println("set key:", key, err)
|
|
|
|
|
|
+ logs.Println("set key:", key, err)
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -81,7 +81,7 @@ func RedisDeviceData_Set(key string, r DeviceData_New) (err error) {
|
|
|
|
|
|
err = redisCache_DeviceData.Put(key, str, 24*time.Hour)
|
|
err = redisCache_DeviceData.Put(key, str, 24*time.Hour)
|
|
if err != nil {
|
|
if err != nil {
|
|
- fmt.Println("set key:", key, ",value:", str, err)
|
|
|
|
|
|
+ logs.Println("set key:", key, ",value:", str, err)
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -173,7 +173,7 @@ func CREATE_DeviceData(SN string) bool {
|
|
//// 添加
|
|
//// 添加
|
|
//func Add_DeviceData(SN string, t_id string, t_t string, t_rh string, t_time string) bool {
|
|
//func Add_DeviceData(SN string, t_id string, t_t string, t_rh string, t_time string) bool {
|
|
// key := SN + "|" + t_id + "|" + t_time
|
|
// key := SN + "|" + t_id + "|" + t_time
|
|
-// //fmt.Println(key)
|
|
|
|
|
|
+// //logs.Println(key)
|
|
// if redisCache_DeviceData.IsExist(key) {
|
|
// if redisCache_DeviceData.IsExist(key) {
|
|
// //println("找到key:",key)
|
|
// //println("找到key:",key)
|
|
// return true
|
|
// return true
|
|
@@ -185,14 +185,14 @@ func CREATE_DeviceData(SN string) bool {
|
|
// var maps_z []orm2.ParamsList
|
|
// var maps_z []orm2.ParamsList
|
|
//
|
|
//
|
|
// sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " WHERE t_time = '" + t_time + "' AND t_id = " + t_id
|
|
// sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " WHERE t_time = '" + t_time + "' AND t_id = " + t_id
|
|
-// //fmt.Println(sql)
|
|
|
|
|
|
+// //logs.Println(sql)
|
|
// _, err := o.Raw(sql).ValuesList(&maps_z)
|
|
// _, err := o.Raw(sql).ValuesList(&maps_z)
|
|
//
|
|
//
|
|
// if err != nil {
|
|
// if err != nil {
|
|
// logs.Error(lib.FuncName(),err)
|
|
// logs.Error(lib.FuncName(),err)
|
|
// return false
|
|
// return false
|
|
// }
|
|
// }
|
|
-// //fmt.Println("maps_z[0][0]:",maps_z[0][0])
|
|
|
|
|
|
+// //logs.Println("maps_z[0][0]:",maps_z[0][0])
|
|
// if lib.To_int(maps_z[0][0]) > 0 {
|
|
// if lib.To_int(maps_z[0][0]) > 0 {
|
|
// // 存在 写入 redis
|
|
// // 存在 写入 redis
|
|
// DeviceData_Set(key)
|
|
// DeviceData_Set(key)
|
|
@@ -201,7 +201,7 @@ func CREATE_DeviceData(SN string) bool {
|
|
// // 开始插入数据
|
|
// // 开始插入数据
|
|
// sql = "INSERT INTO z_devicedata_" + SN + " (`t_id`, `t_t`, `t_rh`, `t_time`) VALUES (" + t_id + ", " + t_t + ", " + t_rh + ", '" + t_time + "')"
|
|
// sql = "INSERT INTO z_devicedata_" + SN + " (`t_id`, `t_t`, `t_rh`, `t_time`) VALUES (" + t_id + ", " + t_t + ", " + t_rh + ", '" + t_time + "')"
|
|
// // 这里有时间优化 用于一次 prepare 多次 exec,以提高批量执行的速度
|
|
// // 这里有时间优化 用于一次 prepare 多次 exec,以提高批量执行的速度
|
|
-// //fmt.Println(sql)
|
|
|
|
|
|
+// //logs.Println(sql)
|
|
// res, err := o.Raw(sql).Exec()
|
|
// res, err := o.Raw(sql).Exec()
|
|
// if err != nil {
|
|
// if err != nil {
|
|
// logs.Error(lib.FuncName(),err)
|
|
// logs.Error(lib.FuncName(),err)
|
|
@@ -210,7 +210,7 @@ func CREATE_DeviceData(SN string) bool {
|
|
// res.RowsAffected()
|
|
// res.RowsAffected()
|
|
// // 存在 写入 redis
|
|
// // 存在 写入 redis
|
|
// DeviceData_Set(key)
|
|
// DeviceData_Set(key)
|
|
-// //fmt.Println("mysql row affected nums: ", num)
|
|
|
|
|
|
+// //logs.Println("mysql row affected nums: ", num)
|
|
// return true
|
|
// return true
|
|
//}
|
|
//}
|
|
|
|
|
|
@@ -263,7 +263,7 @@ func Read_DeviceSensorData_ById_List(SN string, Time_start_ string, Time_end_ st
|
|
if len(sql_time) > 0 {
|
|
if len(sql_time) > 0 {
|
|
sql += " WHERE " + sql_time
|
|
sql += " WHERE " + sql_time
|
|
}
|
|
}
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
if err != nil {
|
|
if err != nil {
|
|
return maps, 0
|
|
return maps, 0
|
|
@@ -271,7 +271,7 @@ func Read_DeviceSensorData_ById_List(SN string, Time_start_ string, Time_end_ st
|
|
if len(maps_z) == 0 {
|
|
if len(maps_z) == 0 {
|
|
return maps, 0
|
|
return maps, 0
|
|
}
|
|
}
|
|
- //fmt.Println("maps_z;",maps_z[0][0])
|
|
|
|
|
|
+ //logs.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
|
|
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 {
|
|
if len(sql_time) > 0 {
|
|
@@ -282,7 +282,7 @@ func Read_DeviceSensorData_ById_List(SN string, Time_start_ string, Time_end_ st
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(pagez)
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(pagez)
|
|
}
|
|
}
|
|
|
|
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err = o.Raw(sql).QueryRows(&maps)
|
|
_, err = o.Raw(sql).QueryRows(&maps)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Println(lib.FuncName(), err)
|
|
logs.Println(lib.FuncName(), err)
|
|
@@ -315,7 +315,7 @@ func Read_DeviceData_By_snid(SN string, T_id int, Time_start_ string, Time_end_
|
|
//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 := "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)
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(limit)
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err := o.Raw(sql).QueryRows(&maps)
|
|
_, err := o.Raw(sql).QueryRows(&maps)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Println(lib.FuncName(), err)
|
|
logs.Println(lib.FuncName(), err)
|
|
@@ -343,7 +343,7 @@ func Read_DeviceData_Count_By_snid(SN string, T_id int, Time_start_ string, Time
|
|
}
|
|
}
|
|
|
|
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
if err != nil {
|
|
if err != nil {
|
|
return 0
|
|
return 0
|
|
@@ -381,7 +381,7 @@ func Read_DeviceSensorData_List(SN string, Time_start_ string, Time_end_ string,
|
|
}
|
|
}
|
|
|
|
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " " + sql_time
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " " + sql_time
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
if err != nil {
|
|
if err != nil {
|
|
return maps, 0
|
|
return maps, 0
|
|
@@ -389,14 +389,14 @@ func Read_DeviceSensorData_List(SN string, Time_start_ string, Time_end_ string,
|
|
if len(maps_z) == 0 {
|
|
if len(maps_z) == 0 {
|
|
return maps, 0
|
|
return maps, 0
|
|
}
|
|
}
|
|
- //fmt.Println("maps_z;",maps_z[0][0])
|
|
|
|
|
|
+ //logs.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 "
|
|
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 {
|
|
if page_z != 9999 {
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(pagez)
|
|
sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(pagez)
|
|
}
|
|
}
|
|
|
|
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err = o.Raw(sql).QueryRows(&maps)
|
|
_, err = o.Raw(sql).QueryRows(&maps)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Println(lib.FuncName(), err)
|
|
logs.Println(lib.FuncName(), err)
|
|
@@ -423,7 +423,7 @@ func Read_DeviceSensorData_List_z(SN string, Time_start_ string) int {
|
|
}
|
|
}
|
|
|
|
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " " + sql_time
|
|
sql := "SELECT COUNT(ID) FROM z_devicedata_" + SN + " " + sql_time
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
_, err := o.Raw(sql).ValuesList(&maps_z)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Println(lib.FuncName(), err)
|
|
logs.Println(lib.FuncName(), err)
|
|
@@ -450,18 +450,18 @@ func Read_DeviceSensorData_ById_New(SN string, T_id int) (DeviceData_New, bool)
|
|
return r, true
|
|
return r, true
|
|
}
|
|
}
|
|
|
|
|
|
- //fmt.Println("maps_z;",maps_z[0][0])
|
|
|
|
|
|
+ //logs.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 := "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 "
|
|
sql = sql + " LIMIT 0,1 "
|
|
|
|
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
err := o.Raw(sql).QueryRow(&maps)
|
|
err := o.Raw(sql).QueryRow(&maps)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Error(lib.FuncName(), err)
|
|
logs.Error(lib.FuncName(), err)
|
|
return maps, false
|
|
return maps, false
|
|
}
|
|
}
|
|
- fmt.Println("T_time:", maps.T_time)
|
|
|
|
|
|
+ logs.Println("T_time:", maps.T_time)
|
|
RedisDeviceData_Set(key_data, maps)
|
|
RedisDeviceData_Set(key_data, maps)
|
|
return maps, true
|
|
return maps, true
|
|
}
|
|
}
|
|
@@ -479,7 +479,7 @@ func Read_DeviceSensorData_By_T_snid_List(T_snid string, Time_start_ string, Tim
|
|
maps = append(maps, r_maps...)
|
|
maps = append(maps, r_maps...)
|
|
maps_num = maps_num + r_maps_num
|
|
maps_num = maps_num + r_maps_num
|
|
|
|
|
|
- fmt.Println("加载数据:", sn_id[0], sn_id[1], r_maps_num)
|
|
|
|
|
|
+ logs.Println("加载数据:", sn_id[0], sn_id[1], r_maps_num)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if page <= 1 {
|
|
if page <= 1 {
|
|
@@ -495,10 +495,10 @@ func Read_DeviceSensorData_By_T_snid_List(T_snid string, Time_start_ string, Tim
|
|
}
|
|
}
|
|
|
|
|
|
if page_z == 9999 {
|
|
if page_z == 9999 {
|
|
- fmt.Println("总数据:", maps_num, " 导出")
|
|
|
|
|
|
+ logs.Println("总数据:", maps_num, " 导出")
|
|
return maps, maps_num
|
|
return maps, maps_num
|
|
}
|
|
}
|
|
- fmt.Println("总数据:", maps_num, " 截取", offset, offset+page_z)
|
|
|
|
|
|
+ logs.Println("总数据:", maps_num, " 截取", offset, offset+page_z)
|
|
return maps[offset:offset_z], maps_num
|
|
return maps[offset:offset_z], maps_num
|
|
}
|
|
}
|
|
|
|
|
|
@@ -512,10 +512,10 @@ func Read_DeviceData_ById_Year_List(SN string) []orm2.ParamsList {
|
|
|
|
|
|
//sql = "SELECT t_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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 DATE_FORMAT(t_time,\"%m\") AS m ,DATE_FORMAT(t_time,\"%d\") AS d FROM z_devicedata_" + SN + " WHERE t_time > '" + strconv.Itoa(time.Now().Year()) + "-0-0 00:00:00' GROUP BY DATE_FORMAT(t_time,\"%m\");"
|
|
sql := "SELECT DATE_FORMAT(t_time,\"%m\") AS m ,DATE_FORMAT(t_time,\"%d\") AS d FROM z_devicedata_" + SN + " WHERE t_time > '" + strconv.Itoa(time.Now().Year()) + "-0-0 00:00:00' GROUP BY DATE_FORMAT(t_time,\"%m\");"
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
num, err := o.Raw(sql).ValuesList(&maps_z)
|
|
num, err := o.Raw(sql).ValuesList(&maps_z)
|
|
if err == nil && num > 0 {
|
|
if err == nil && num > 0 {
|
|
- fmt.Println(maps_z[0][0]) // slene
|
|
|
|
|
|
+ logs.Println("", maps_z[0][0]) // slene
|
|
}
|
|
}
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
//key,_ := strconv.Atoi(maps_z[0][0].(string))
|
|
//key,_ := strconv.Atoi(maps_z[0][0].(string))
|
|
@@ -534,7 +534,7 @@ func Read_DeviceData_ById_Month_List(SN string) []orm2.ParamsList {
|
|
|
|
|
|
//sql = "SELECT t_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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 DATE_FORMAT(t_time,\"%d\") AS d FROM z_devicedata_" + SN + " WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%d\");"
|
|
sql := "SELECT DATE_FORMAT(t_time,\"%d\") AS d FROM z_devicedata_" + SN + " WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%d\");"
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
|
|
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
@@ -554,7 +554,7 @@ func Read_DeviceSensorData_ById_Day_List(SN string) []orm2.ParamsList {
|
|
|
|
|
|
//sql = "SELECT t_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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_name,t_t,t_rh,t_tl,t_tu,t_rhl,t_rhu,t_site,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 DATE_FORMAT(t_time,\"%H\") AS m FROM z_devicedata_" + SN + " WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%H\");"
|
|
sql := "SELECT DATE_FORMAT(t_time,\"%H\") AS m FROM z_devicedata_" + SN + " WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%H\");"
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
|
|
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
|
|
@@ -576,7 +576,7 @@ func Read_DeviceSensorData_List_GROUP_BY_t_time(SN string, Time_start_ string, T
|
|
}
|
|
}
|
|
|
|
|
|
sql := "SELECT DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " WHERE " + sql_time + " GROUP BY t_time ORDER BY t_time DESC "
|
|
sql := "SELECT DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time FROM z_devicedata_" + SN + " WHERE " + sql_time + " GROUP BY t_time ORDER BY t_time DESC "
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
o.Raw(sql).ValuesList(&maps_z)
|
|
return maps_z
|
|
return maps_z
|
|
}
|
|
}
|
|
@@ -600,10 +600,10 @@ func Read_DeviceData_T_Min_Max_Time_Min_Max(SN string, Time_start_ string, Time_
|
|
if len(sql_condition) > 0 {
|
|
if len(sql_condition) > 0 {
|
|
sql_condition = " WHERE " + strings.TrimLeft(sql_condition, " AND ")
|
|
sql_condition = " WHERE " + strings.TrimLeft(sql_condition, " AND ")
|
|
}
|
|
}
|
|
- //fmt.Println("maps_z;",maps_z[0][0])
|
|
|
|
|
|
+ //logs.Println("maps_z;",maps_z[0][0])
|
|
sql := "SELECT MIN(t_t) AS min_t, MAX(t_t) AS max_t,MIN(t_time) AS min_time, MAX(t_time) AS max_time FROM z_devicedata_" + SN + sql_condition
|
|
sql := "SELECT MIN(t_t) AS min_t, MAX(t_t) AS max_t,MIN(t_time) AS min_time, MAX(t_time) AS max_time FROM z_devicedata_" + SN + sql_condition
|
|
|
|
|
|
- fmt.Println(sql)
|
|
|
|
|
|
+ logs.Println(sql)
|
|
err := o.Raw(sql).QueryRow(&minT, &maxT, &minTime, &maxTime)
|
|
err := o.Raw(sql).QueryRow(&minT, &maxT, &minTime, &maxTime)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Error(lib.FuncName(), err)
|
|
logs.Error(lib.FuncName(), err)
|