Bläddra i källkod

update:日志优化

zoie 3 månader sedan
förälder
incheckning
f149be35cb

+ 22 - 22
Nats/Nats.go

@@ -25,7 +25,7 @@ func init() {
 	// 连接Nats服务器
 	lib.Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
 	if err != nil {
-		fmt.Println("nats 连接失败!")
+		logs.Error("nats 连接失败!")
 		panic(err)
 	}
 	logs.Info("nats OK!")
@@ -36,11 +36,11 @@ func init() {
 
 	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
 		"redisCache_NatsServer", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
-	fmt.Println(config)
+	logs.Info(config)
 	redisCache_NatsServer, err = cache.NewCache("redis", config)
 	if err != nil || redisCache_NatsServer == nil {
 		errMsg := "failed to init redis"
-		fmt.Println(errMsg, err)
+		logs.Error(errMsg, err)
 		panic(errMsg)
 	}
 
@@ -50,7 +50,7 @@ func NatsInit() {
 
 	// 获取微信二维码 返回结果
 	_, _ = lib.Nats.QueueSubscribe("Wx_BasicMessage_Event_QRCode", "Wx_BasicMessage_Event_QRCode", func(m *nats.Msg) {
-		//fmt.Printf(" => Nats   Wx_BasicMessage_Event_QRCode message: %s\n", string(m.Data))
+		//logs.Debug(fmt.Sprintf(" => Nats   Wx_BasicMessage_Event_QRCode message: %s\n", string(m.Data)))
 
 		type Person_QRCode struct {
 			ToUserName   string `xml:"ToUserName"`   //注意这里有个反引号
@@ -61,13 +61,13 @@ func NatsInit() {
 		var person_QRCode Person_QRCode
 		err1 := xml.Unmarshal(m.Data, &person_QRCode)
 		if err1 != nil {
-			fmt.Println("Unmarshal error")
+			logs.Error("Unmarshal error")
 			_ = lib.Nats.Publish(m.Reply, []byte(""))
 			return
 		}
 		// 进入 二维码配对
-		//fmt.Println("FromUserName-", person_QRCode.FromUserName)
-		//fmt.Println("EventKey-", person_QRCode.EventKey)
+		//logs.Info("FromUserName-", person_QRCode.FromUserName)
+		//logs.Info("EventKey-", person_QRCode.EventKey)
 
 		// 开始  处理消息
 		if strings.Contains(person_QRCode.EventKey, "@宝智达冷链 微信公众号通知") {
@@ -81,7 +81,7 @@ func NatsInit() {
 				name = strings.Split(decryptCode, "/")[1]
 			}
 
-			fmt.Println("解密结果 UUID name:", decryptCode, "  Content_r:", Content_r)
+			logs.Info("解密结果 UUID name:", decryptCode, "  Content_r:", Content_r)
 			Admin_r, err := Account.Read_Admin_ByUuid(uuid)
 			if err != nil {
 				_ = lib.Nats.Publish(m.Reply, []byte(""))
@@ -116,7 +116,7 @@ func NatsInit() {
 
 	// 请求-响应 验证登录
 	_, _ = lib.Nats.QueueSubscribe("Cold_User_verification", "Cold_User_verification", func(m *nats.Msg) {
-		fmt.Printf("Cold_User_verification message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_User_verification message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16           `xml:"Code"`
@@ -129,7 +129,7 @@ func NatsInit() {
 		// 验证登录
 		b_, admin_r := Account.Verification(string(m.Data), "")
 		if !b_ {
-			fmt.Println("Unmarshal error")
+			logs.Error("Unmarshal error")
 			t_R.Code = 201
 			t_R.Msg = "User_tokey Err!"
 			b, _ := msgpack.Marshal(&t_R)
@@ -157,7 +157,7 @@ func NatsInit() {
 
 	// 请求-响应 通过公司名获取所有公司信息
 	_, _ = lib.Nats.QueueSubscribe("Cold_User_CompanyListAllByT_name", "Cold_User_CompanyListAllByT_name", func(m *nats.Msg) {
-		fmt.Printf("CompanyListAll message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("CompanyListAll message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16             `xml:"Code"`
@@ -175,7 +175,7 @@ func NatsInit() {
 	})
 	// 请求-响应 获取公司
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_id", "Cold_ReadCompanyByT_id", func(m *nats.Msg) {
-		fmt.Printf("Cold_ReadCompanyByT_id message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_ReadCompanyByT_id message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16           `xml:"Code"`
@@ -205,7 +205,7 @@ func NatsInit() {
 
 	// 请求-响应 获取公司 通过秘钥
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadCompanyByT_key", "Cold_ReadCompanyByT_key", func(m *nats.Msg) {
-		fmt.Printf("Cold_ReadCompanyByT_key message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_ReadCompanyByT_key message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16           `xml:"Code"`
@@ -251,7 +251,7 @@ func NatsInit() {
 	})
 	// 请求-响应 检查用户权限
 	_, _ = lib.Nats.QueueSubscribe("Cold_User_CheckUserPermissions", "Cold_User_CheckUserPermissions", func(m *nats.Msg) {
-		fmt.Printf("Cold_User_CheckUserPermissions message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_User_CheckUserPermissions message: %s\n", string(m.Data)))
 		type T_Req struct {
 			Power_Id int    `xml:"Power_Id"` // 权限id
 			Req_Url  string `xml:"Req_Url"`  // 请求url
@@ -308,7 +308,7 @@ func NatsInit() {
 
 	// 发布-订阅 模式,异步订阅 AddSysLogs
 	_, _ = lib.Nats.QueueSubscribe("Cold_User_AddSysLogs", "Cold_User_AddSysLogs", func(m *nats.Msg) {
-		fmt.Printf("AddSysLogs message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("AddSysLogs message: %s\n", string(m.Data)))
 
 		type T_S struct {
 			T_class string
@@ -331,7 +331,7 @@ func NatsInit() {
 
 	// 发布-订阅 模式,异步订阅 AddUserLogs
 	_, _ = lib.Nats.QueueSubscribe("Cold_User_AddUserLogs", "Cold_User_AddUserLogs", func(m *nats.Msg) {
-		fmt.Printf("AddUserLogs message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("AddUserLogs message: %s\n", string(m.Data)))
 
 		type T_S struct {
 			T_uuid  string
@@ -353,7 +353,7 @@ func NatsInit() {
 
 	// 请求-响应 获取设备
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceByT_sn", "Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
-		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("CheckUserPermissions message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16         `xml:"Code"`
@@ -382,7 +382,7 @@ func NatsInit() {
 
 	// 请求-响应 获取传感器列表
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceSensorALLByT_sn", "Cold_ReadDeviceSensorALLByT_sn", func(m *nats.Msg) {
-		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("CheckUserPermissions message: %s\n", string(m.Data)))
 
 		type T_R struct {
 			Code int16                 `xml:"Code"`
@@ -404,7 +404,7 @@ func NatsInit() {
 
 	// 请求-响应 获取设备数据列表
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataListBy_T_snid", "Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
-		fmt.Printf("Cold_ReadDeviceDataListBy_T_snid message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_ReadDeviceDataListBy_T_snid message: %s\n", string(m.Data)))
 		type T_Req struct {
 			T_snid     string `xml:"T_snid"`
 			Time_start string `xml:"Time_start"`
@@ -443,7 +443,7 @@ func NatsInit() {
 
 	// 请求-响应 通过key获取传感器列表
 	_, _ = lib.Nats.QueueSubscribe("Cold_CompanyDeviceSensor_List_ByKey", "Cold_CompanyDeviceSensor_List_ByKey", func(m *nats.Msg) {
-		fmt.Printf("Cold_CompanyDeviceSensor_List_ByKey message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_CompanyDeviceSensor_List_ByKey message: %s\n", string(m.Data)))
 		type T_Req struct {
 			T_sn  string `xml:"T_sn"`
 			T_key string `xml:"T_key"`
@@ -492,7 +492,7 @@ func NatsInit() {
 
 	// 请求-响应 根据时间获取设备数据(单条)最新数据
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDeviceDataBy_T_snid_T_time", "Cold_ReadDeviceDataBy_T_snid_T_time", func(m *nats.Msg) {
-		fmt.Printf("Cold_ReadDeviceDataBy_T_snid_T_time message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_ReadDeviceDataBy_T_snid_T_time message: %s\n", string(m.Data)))
 		type T_Req struct {
 			T_sn string `xml:"T_sn"`
 			T_id int    `xml:"T_id"`
@@ -527,7 +527,7 @@ func NatsInit() {
 
 	// 请求-响应 获取设备
 	_, _ = lib.Nats.QueueSubscribe("Cold_ReadDevice_List", "Cold_ReadDevice_List", func(m *nats.Msg) {
-		fmt.Printf("Cold_ReadDevice_List message: %s\n", string(m.Data))
+		logs.Debug(fmt.Sprintf("Cold_ReadDevice_List message: %s\n", string(m.Data)))
 		type T_Req struct {
 			Key    string `xml:"Key"`
 			Name   string `xml:"Name"`

+ 7 - 7
Nats/NatsServer/NatsQiniu.go

@@ -2,9 +2,9 @@ package NatsServer
 
 import (
 	"Cold_Api/controllers/lib"
-	"github.com/beego/beego/v2/core/logs"
 	"context"
 	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"github.com/qiniu/go-sdk/v7/auth/qbox"
 	"github.com/qiniu/go-sdk/v7/storage"
 	"github.com/vmihailenco/msgpack/v5"
@@ -29,9 +29,9 @@ func Qiniu_UploadToken(T_suffix string, T_MimeLimit string) (string, bool) {
 	// 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
 	msg, err := lib.Nats.Request("Qiniu_UploadToken", b, 3*time.Second)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	} else {
-		fmt.Printf("Qiniu_UploadToken : %s\n", string(msg.Data))
+		logs.Debug(fmt.Sprintf("Qiniu_UploadToken : %s\n", string(msg.Data)))
 		return string(msg.Data), true
 	}
 
@@ -54,9 +54,9 @@ func Qiniu_UploadToken(T_suffix string, T_MimeLimit string) (string, bool) {
 //	// 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
 //	msg, err := lib.Nats.Request("Qiniu_UploadFile", b, 3*time.Second)
 //	if err != nil {
-//		fmt.Println(err)
+//		logs.Error(err)
 //	} else {
-//		fmt.Printf("Qiniu_UploadFile : %s\n", string(msg.Data))
+//		logs.Debug(fmt.Sprintf("Qiniu_UploadFile : %s\n", string(msg.Data)))
 //		return string(msg.Data), true
 //	}
 //
@@ -71,7 +71,7 @@ func Qiniu_UploadFile(localFile string, name string) (string, bool) {
 	if err != nil {
 		return string(msg.Data), false
 	}
-	fmt.Printf("Qiniu_Token : %s\n", string(msg.Data))
+	logs.Debug(fmt.Sprintf("Qiniu_Token : %s\n", string(msg.Data)))
 	Qiniu_cs := strings.Split(string(msg.Data), "|")
 	Qiniu_AccessKey := Qiniu_cs[0]
 	Qiniu_SecretKey := Qiniu_cs[1]
@@ -109,7 +109,7 @@ func Qiniu_UploadFile(localFile string, name string) (string, bool) {
 		logs.Info("七牛云", "上传文件失败 "+localFile, err.Error())
 		return "", false
 	}
-	fmt.Println(ret.Bucket, ret.Key, ret.Fsize, ret.Hash, ret.Name)
+	logs.Debug(ret.Bucket, ret.Key, ret.Fsize, ret.Hash, ret.Name)
 	return Qiniu_Url + name, true
 
 }

+ 2 - 1
Nats/NatsServer/NatsWorkOrder.go

@@ -3,6 +3,7 @@ package NatsServer
 import (
 	"Cold_Api/controllers/lib"
 	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"github.com/vmihailenco/msgpack/v5"
 	"time"
 )
@@ -13,7 +14,7 @@ func Read_WorkOrderT_State_Count(T_pids string) (int64, int64) {
 		return 0, 0
 	}
 
-	fmt.Printf("UserListAll: %v\n", string(msg.Data))
+	logs.Debug(fmt.Sprintf("UserListAll: %v\n", string(msg.Data)))
 	type T_R struct {
 		Code                  int16  `xml:"Code"`
 		Msg                   string `xml:"Msg"`

+ 2 - 3
Nats/NatsServer/NatsWx.go

@@ -3,7 +3,6 @@ package NatsServer
 import (
 	"Cold_Api/controllers/lib"
 	"github.com/beego/beego/v2/core/logs"
-	"fmt"
 	"time"
 )
 
@@ -13,10 +12,10 @@ func Wx_GenerateQRCode(T_uuid string) (string, bool) {
 	// 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
 	msg, err := lib.Nats.Request("Wx_GenerateQR", []byte(T_uuid), 3*time.Second)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
-	fmt.Printf("Wx_GenerateQR : %s\n", string(msg.Data))
+	logs.Info("Wx_GenerateQR : %s\n", string(msg.Data))
 	return string(msg.Data), true
 
 }

+ 7 - 7
controllers/Data.go

@@ -413,7 +413,7 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	// 上传 OSS
@@ -426,7 +426,7 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 	//删除目录
 	err := os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -531,7 +531,7 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	// 上传 OSS
@@ -545,7 +545,7 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 	//删除目录
 	//err := os.Remove("ofile/" + timeStr + ".xlsx")
 	//if err != nil {
-	//	fmt.Println(err)
+	//	logs.Error(err)
 	//}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -962,7 +962,7 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 	//删除目录
 	err = os.Remove(timeStr)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -1445,7 +1445,7 @@ func Device_Sensor_Data_ChartShow_PDF1(companyName, T_snid, Time_start, Time_end
 	//删除目录
 	err = os.Remove(timeStr)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	return url, nil
@@ -1920,7 +1920,7 @@ func Device_Sensor_Data_ChartShow_PDF0(companyName, T_snid, Time_start, Time_end
 	//删除目录
 	err = os.Remove(timeStr)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 	return url, nil
 

+ 0 - 1
controllers/DeviceReal.go

@@ -102,7 +102,6 @@ func DeviceRealTime() {
 		//	// 实时数据请求次数达到180次(30分钟*6次/分钟=180)
 		//	// 更新实时请求为2分钟每次(2分钟*6次/分钟=12)
 		//	if num > 180 && (num-180)%12 != 0 {
-		//		fmt.Println("num:", num)
 		//		return true
 		//	}
 		//

+ 2 - 2
controllers/RawSql.go

@@ -5,7 +5,7 @@ import (
 	"Cold_Api/models/Account"
 	"Cold_Api/models/Device"
 	"Cold_Api/models/RawSql"
-	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	beego "github.com/beego/beego/v2/server/web"
 	"strings"
 )
@@ -114,7 +114,7 @@ func (c *RawSqlController) Raw() {
 	}
 
 	T_data := c.GetString("T_data")
-	fmt.Println(" 执行SQL:", T_id, " => [", T_data, "] ", c.Admin_r.T_uuid, c.Admin_r.T_name)
+	logs.Debug(" 执行SQL:", T_id, " => [", T_data, "] ", c.Admin_r.T_uuid, c.Admin_r.T_name)
 	var T_dataL []string
 	for _, v := range strings.Split(T_data, "|") {
 		if len(v) > 0 {

+ 4 - 4
controllers/User.go

@@ -1570,7 +1570,7 @@ func (c *UserController) Menu_Excel() {
 	timeStr := filename + fmt.Sprintf("(%s)", lib.GetRandstring(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 0))
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	var url string
@@ -1584,7 +1584,7 @@ func (c *UserController) Menu_Excel() {
 	////删除目录
 	//err = os.Remove("ofile/" + timeStr + ".xlsx")
 	//if err != nil {
-	//	fmt.Println(err)
+	//	logs.Error(err)
 	//}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -1730,7 +1730,7 @@ func (c *UserController) CompanyBill_Excel() {
 	timeStr := filename + fmt.Sprintf("(%s)", lib.GetRandstring(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 0))
 	// 保存文件
 	if err = f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	var url string
@@ -1744,7 +1744,7 @@ func (c *UserController) CompanyBill_Excel() {
 	//删除目录
 	err = os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}

+ 8 - 8
controllers/Warning.go

@@ -826,7 +826,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
@@ -838,7 +838,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 	// 删除文件
 	err = os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -944,7 +944,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
@@ -956,7 +956,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
 	// 删除文件
 	err = os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -1060,7 +1060,7 @@ func (c *DeviceController) CompanyWarning_Data_Excel() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
@@ -1072,7 +1072,7 @@ func (c *DeviceController) CompanyWarning_Data_Excel() {
 	// 删除文件
 	err = os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
@@ -1168,7 +1168,7 @@ func (c *DeviceController) CompanyWarning_Data_Excel2() {
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
@@ -1180,7 +1180,7 @@ func (c *DeviceController) CompanyWarning_Data_Excel2() {
 	// 删除文件
 	err = os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}

+ 22 - 22
controllers/lib/Onelink.go

@@ -2,7 +2,7 @@ package lib
 
 import (
 	"encoding/json"
-	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"io/ioutil"
 	"net/http"
 )
@@ -16,22 +16,22 @@ func yidong_token() (string, bool) {
 	req, err := http.NewRequest(method, url, nil)
 
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
 	res, err := client.Do(req)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
 	defer res.Body.Close()
 
 	body, err := ioutil.ReadAll(res.Body)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
-	fmt.Println(string(body))
+	logs.Info(string(body))
 
 	type Token struct {
 		Token string `json:"token"`
@@ -43,16 +43,16 @@ func yidong_token() (string, bool) {
 	var c TestJson
 	err = json.Unmarshal(body, c)
 	if err := json.Unmarshal([]byte(body), &c); err != nil {
-		fmt.Println("Error =", err)
+		logs.Error("Error =", err)
 	}
 
-	fmt.Println("bodyjson:", c)
+	logs.Info("bodyjson:", c)
 
 	//dd := c["result"]
 	if len(c.Result) == 0 {
 		return "", false
 	}
-	fmt.Println("Token:", c.Result[0].Token)
+	logs.Info("Token:", c.Result[0].Token)
 
 	return c.Result[0].Token, true
 
@@ -77,22 +77,22 @@ func Yidong_group_data_margin() (FlowPoolSharingInfo, bool) {
 	req, err := http.NewRequest(method, url, nil)
 
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return FlowPoolSharingInfo{}, false
 	}
 	res, err := client.Do(req)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return FlowPoolSharingInfo{}, false
 	}
 	defer res.Body.Close()
 
 	body, err := ioutil.ReadAll(res.Body)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return FlowPoolSharingInfo{}, false
 	}
-	fmt.Println(string(body))
+	logs.Info(string(body))
 
 	type List_data struct {
 		FlowPoolSharingInfo []FlowPoolSharingInfo `json:"flowPoolSharingInfo"`
@@ -104,16 +104,16 @@ func Yidong_group_data_margin() (FlowPoolSharingInfo, bool) {
 	var c TestJson
 	err = json.Unmarshal(body, c)
 	if err := json.Unmarshal([]byte(body), &c); err != nil {
-		fmt.Println("Error =", err)
+		logs.Error("Error =", err)
 	}
 
-	fmt.Println("bodyjson:", c)
+	logs.Info("bodyjson:", c)
 
 	//dd := c["result"]
 	if len(c.Result) == 0 {
 		return FlowPoolSharingInfo{}, false
 	}
-	//fmt.Println("Token:",c.Result[0].UseAmount)
+	//logs.Info("Token:",c.Result[0].UseAmount)
 
 	return c.Result[0].FlowPoolSharingInfo[0], true
 
@@ -132,22 +132,22 @@ func yidong_sim_data_usage(msisdn string) (string, bool) {
 	req, err := http.NewRequest(method, url, nil)
 
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
 	res, err := client.Do(req)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
 	defer res.Body.Close()
 
 	body, err := ioutil.ReadAll(res.Body)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return "", false
 	}
-	fmt.Println(string(body))
+	logs.Info(string(body))
 
 	type List_data struct {
 		DataAmount string `json:"dataAmount"`
@@ -159,16 +159,16 @@ func yidong_sim_data_usage(msisdn string) (string, bool) {
 	var c TestJson
 	err = json.Unmarshal(body, c)
 	if err := json.Unmarshal([]byte(body), &c); err != nil {
-		fmt.Println("Error =", err)
+		logs.Error("Error =", err)
 	}
 
-	fmt.Println("bodyjson:", c)
+	logs.Info("bodyjson:", c)
 
 	//dd := c["result"]
 	if len(c.Result) == 0 {
 		return "", false
 	}
-	//fmt.Println("Token:",c.Result[0].UseAmount)
+	//logs.Info("Token:",c.Result[0].UseAmount)
 
 	return c.Result[0].DataAmount, true
 

+ 1 - 1
controllers/lib/Qiniu.go

@@ -3,8 +3,8 @@ package lib
 // 存储相关功能的引入包只有这两个,后面不再赘述
 import (
 	"Cold_Api/conf"
-	"github.com/beego/beego/v2/core/logs"
 	"context"
+	"github.com/beego/beego/v2/core/logs"
 	"github.com/qiniu/go-sdk/v7/auth/qbox"
 	"github.com/qiniu/go-sdk/v7/storage"
 	uuid "github.com/satori/go.uuid"

+ 7 - 9
models/Account/Admin.go

@@ -170,7 +170,7 @@ func Add_Admin(m Admin) (id int64, err error) {
 //		v.T_State = 0
 //
 //		if num, err = o.Update(&v, "T_State"); err == nil {
-//			fmt.Println("Number of records updated in database:", num)
+//			logs.Info("Number of records updated in database:", num)
 //		}
 //
 //		Redis_Admin_Set(v)
@@ -205,12 +205,12 @@ func Read_AdminLogin_verification(T_user string, T_pass string) (error, Admin) {
 // 修改
 func Update_Admin(m Admin, cols ...string) bool {
 	o := orm.NewOrm()
-	num, err := o.Update(&m, cols...)
+	_, err := o.Update(&m, cols...)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+
 	Redis_Admin_Set(m) // Redis 更新缓存
 	return true
 
@@ -220,12 +220,12 @@ func Update_Admin(m Admin, cols ...string) bool {
 func Delete_Admin(v Admin) bool {
 	o := orm.NewOrm()
 	v.T_State = 0
-	num, err := o.Update(&v, "T_State")
+	_, err := o.Update(&v, "T_State")
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+
 	Redis_Admin_DelK(v.T_uuid) // Redis 更新缓存
 	return true
 }
@@ -454,12 +454,11 @@ func Add_Company_bind(Admin_r Admin, T_pids []int) (err error) {
 		Admin_r.T_pids = Admin_r.T_pids + T_Pid_bind
 	}
 
-	num, err := o.Update(&Admin_r, "T_pids")
+	_, err = o.Update(&Admin_r, "T_pids")
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return err
 	}
-	fmt.Println("Number of records updated in database:", num)
 	Redis_Admin_Set(Admin_r) // Redis 更新缓存
 	return nil
 }
@@ -472,12 +471,11 @@ func Delete_Company_bind(Admin_r Admin, T_pids []int) (err error) {
 		Admin_r.T_pids = strings.Replace(Admin_r.T_pids, T_Pid_bind, "", -1)
 	}
 
-	num, err := o.Update(&Admin_r, "T_pids")
+	_, err = o.Update(&Admin_r, "T_pids")
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return err
 	}
-	fmt.Println("Number of records updated in database:", num)
 	Redis_Admin_Set(Admin_r) // Redis 更新缓存
 	return nil
 

+ 2 - 2
models/Account/Company.go

@@ -192,7 +192,7 @@ func Update_Company(m Company, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_Company_Set(strconv.Itoa(m.Id), m) // Redis 更新缓存
 	return true
 }
@@ -208,7 +208,7 @@ func Delete_Company(orm orm.Ormer, id int) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_Company_DelK(strconv.Itoa(m.Id))
 	return true
 }

+ 9 - 9
models/Account/Menu.go

@@ -131,7 +131,7 @@ func Redis_Munu_Set(Power_Id, T_pid int, r Menu_Permission) (err error) {
 	//json序列化
 	str, err := json.Marshal(r)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 		return
 	}
 	keys := strconv.Itoa(Power_Id) + "-Pid"
@@ -186,7 +186,7 @@ func Add_Menu(m Menu) (id int64, err error) {
 	// 插入菜单信息
 	id, err = o.Insert(&m)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 	return id, err
 }
@@ -195,7 +195,7 @@ func Add_Menu(m Menu) (id int64, err error) {
 func Update_Menu(m Menu, cols ...string) bool {
 	o := orm.NewOrm()
 	if num, err := o.Update(&m, cols...); err == nil {
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 		return true
 	}
 	return false
@@ -205,7 +205,7 @@ func Update_Menu(m Menu, cols ...string) bool {
 func Delete_Menu(m Menu) bool {
 	o := orm.NewOrm()
 	if num, err := o.Delete(&m); err == nil {
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 	} else {
 		return false
 	}
@@ -390,7 +390,7 @@ func Add_API(m API) (id int64, err error) {
 	o := orm.NewOrm()
 	id, err = o.Insert(&m)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 	m.Id = int(id)
 	return id, err
@@ -401,7 +401,7 @@ func Add_Multi_API(m []API) (id int64, err error) {
 	o := orm.NewOrm()
 	id, err = o.InsertMulti(len(m), &m)
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 	return id, err
 }
@@ -410,7 +410,7 @@ func Add_Multi_API(m []API) (id int64, err error) {
 func Update_API(m API, cols ...string) bool {
 	o := orm.NewOrm()
 	if num, err := o.Update(&m, cols...); err == nil {
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 		return true
 	}
 	return false
@@ -420,7 +420,7 @@ func Update_API(m API, cols ...string) bool {
 func Delete_API(m API) bool {
 	o := orm.NewOrm()
 	if num, err := o.Delete(&m); err == nil {
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 	} else {
 		return false
 	}
@@ -431,7 +431,7 @@ func Delete_API(m API) bool {
 func Delete_Multi_API(m []API) bool {
 	o := orm.NewOrm()
 	if num, err := o.Delete(&m); err == nil {
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 	} else {
 		return false
 	}

+ 2 - 3
models/Account/Power.go

@@ -165,7 +165,6 @@ func Read_Power_ById(Id int) (r Power, err error) {
 		logs.Error(lib.FuncName(), err)
 		return
 	}
-	fmt.Println(len("M1|M2|M4|M5|M6|M7|M8|M9|M10|M11|M12|M13|M14|M15|M16|M17|M18|M19|M207|M20|M21|M22|M23|M24|M25|M26|M27|M28|M29|M30|M31|M32|M33|M34|M101|M35|M102|M103|M118|M36|M37|M38|M45|M39|M119|M46|M47|M106|M113|M114|M108|M109|M110|M111|M112|M120|M48|M49|M50|M51|M52|M53|M"))
 	Redis_Power_Set(r)
 
 	return r, err
@@ -253,7 +252,7 @@ func Update_Power(v Power, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_Power_Set(v)                 // Redis 更新缓存
 	Redis_Menu_DelK(v.Id)              // 删除菜单缓存
 	Redis_API_DelK(strconv.Itoa(v.Id)) // 删除API缓存
@@ -269,7 +268,7 @@ func Delete_Power(v Power) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_Menu_DelK(v.Id)                // 删除菜单缓存
 	Redis_API_DelK(strconv.Itoa(v.Id))   // Redis 删除API缓存
 	Redis_Power_DelK(strconv.Itoa(v.Id)) // Redis 删除缓存

+ 1 - 1
models/Account/Tokey.go

@@ -41,7 +41,7 @@ func Add_Tokey_Set(Uuid string) string {
 		if !redisCache_Tokey.IsExist(Tokey) {
 			break
 		}
-		fmt.Print("申请 TOKEY 重复!重新生成。", Tokey)
+		logs.Info("申请 TOKEY 重复!重新生成。", Tokey)
 	}
 	err := redisCache_Tokey.Put(Tokey, Uuid+"|0", 2*time.Hour)
 	if err != nil {

+ 2 - 1
models/Account/Vpanel.go

@@ -6,6 +6,7 @@ import (
 	"github.com/astaxie/beego/cache"
 	_ "github.com/astaxie/beego/cache/redis"
 	"github.com/beego/beego/v2/adapter/orm"
+	"github.com/beego/beego/v2/core/logs"
 	_ "github.com/go-sql-driver/mysql"
 )
 
@@ -64,7 +65,7 @@ func init() {
 	redisCache_Vpanel, err = cache.NewCache("redis", config)
 	if err != nil || redisCache_Vpanel == nil {
 		errMsg := "failed to init redis"
-		fmt.Println(errMsg, err)
+		logs.Debug(errMsg, err)
 	}
 
 }

+ 2 - 2
models/Company/CompanyClass.go

@@ -160,7 +160,7 @@ func Update_CompanyClass(r CompanyClass, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_CompanyClass_Set(r)
 	return true
 }
@@ -177,7 +177,7 @@ func Delete_CompanyClass_ById(id int) bool {
 			logs.Error(lib.FuncName(), err)
 			return false
 		}
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 		key := strconv.Itoa(v.Id)
 		Redis_CompanyClass_DelK(key)
 		return true

+ 2 - 2
models/Company/CompanyNotice.go

@@ -178,7 +178,7 @@ func Delete_CompanyNotice_ById(id int) bool {
 			logs.Error(lib.FuncName(), err)
 			return false
 		}
-		fmt.Println("Number of records updated in database:", num)
+		logs.Info("Number of records updated in database:", num)
 		key := strconv.Itoa(v.Id)
 		Redis_CompanyNotice_DelK(key)
 		return true
@@ -194,7 +194,7 @@ func Update_CompanyNotice(m CompanyNotice, cols ...string) error {
 		logs.Error(lib.FuncName(), err)
 		return err
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_CompanyNotice_Set(m)
 	return nil
 }

+ 1 - 2
models/Company/CompanyPayOrder.go

@@ -2,7 +2,6 @@ package Company
 
 import (
 	"Cold_Api/controllers/lib"
-	"fmt"
 	"github.com/beego/beego/v2/adapter/orm"
 	"github.com/beego/beego/v2/core/logs"
 	"time"
@@ -48,7 +47,7 @@ func Update_CompanyPayOrder(m CompanyPayOrder, cols ...string) error {
 		logs.Error(lib.FuncName(), err)
 		return err
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	return nil
 }
 

+ 1 - 1
models/Device/Device.go

@@ -248,7 +248,7 @@ func Update_Device(r Device, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_Device_Set(r) // Redis 更新缓存
 	return true
 }

+ 26 - 34
models/Device/DeviceData.go

@@ -242,12 +242,11 @@ type DeviceData_T struct {
 // 添加
 func Add_DeviceData(SN string, v DeviceData_T) bool {
 	//if(conf.Test_server){
-	//	fmt.Println("Add_DeviceData:",SN , t_name , t_id , t_t , t_rh , t_tl , t_tu , t_rhl , t_rhu , t_site , t_battery , t_time)
 	//	return true
 	//}
 
 	key_time := SN + "|" + strconv.Itoa(v.T_id) + "|" + v.T_time.Format("2006-01-02 15:04:05")
-	fmt.Println(key_time)
+	logs.Debug(key_time)
 	if redis_DeviceData.IsExist(key_time) {
 		//println("找到key:",key)
 		return true
@@ -267,7 +266,6 @@ func Add_DeviceData(SN string, v DeviceData_T) bool {
 			logs.Info(err)
 			return false
 		}
-		//fmt.Println("maps_z[0][0]:",maps_z[0][0])
 		if lib.To_int(maps_z[0][0]) > 0 {
 			logs.Info("存在记录,跳过!")
 			return true
@@ -278,7 +276,7 @@ func Add_DeviceData(SN string, v DeviceData_T) bool {
 	sql := "INSERT INTO z_device_data_" + SN + " ( `t_id`, `t_t`, `t_rh`, `t_site`, `t_time`) " +
 		"VALUES (" + strconv.Itoa(v.T_id) + ", " + lib.To_string(v.T_t) + ", " + lib.To_string(v.T_rh) + ", '" + v.T_Site + "'," + v.T_time.Format("2006-01-02 15:04:05") + "')"
 	//  这里有时间优化  用于一次 prepare 多次 exec,以提高批量执行的速度
-	fmt.Println(sql)
+	logs.Debug(sql)
 	res, err := o.Raw(sql).Exec()
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -315,7 +313,7 @@ func Read_DeviceData_ById_List(SN string, T_id int, Time_start_ string, Time_end
 	}
 
 	sql := "SELECT COUNT(t_id) FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -324,14 +322,13 @@ func Read_DeviceData_ById_List(SN string, T_id int, Time_start_ string, Time_end
 	if len(maps_z) == 0 {
 		return r, 0
 	}
-	//fmt.Println("maps_z;",maps_z[0][0])
-	//t_tl,t_tu,t_rhl,t_rhu,
+
 	sql = "SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time1 DESC,t_id DESC "
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -376,7 +373,7 @@ func Read_DeviceData_ById_List_OrderByTimeAes(SN string, T_id int, Time_start_ s
 	}
 
 	sql := "SELECT COUNT(t_id) FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -385,14 +382,13 @@ func Read_DeviceData_ById_List_OrderByTimeAes(SN string, T_id int, Time_start_ s
 	if len(maps_z) == 0 {
 		return r, 0
 	}
-	//fmt.Println("maps_z;",maps_z[0][0])
-	//t_tl,t_tu,t_rhl,t_rhu,
+
 	sql = "SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time1,t_id DESC "
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -438,7 +434,7 @@ func Read_DeviceData_ByIds(SN string, ids []int, Time_start_ string, Time_end_ s
 	}
 
 	sql := "SELECT COUNT(t_id) FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id in (" + lib.IntListToDotStr(ids) + ")"
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -447,14 +443,13 @@ func Read_DeviceData_ByIds(SN string, ids []int, Time_start_ string, Time_end_ s
 	if len(maps_z) == 0 {
 		return r, 0
 	}
-	//fmt.Println("maps_z;",maps_z[0][0])
 	//t_tl,t_tu,t_rhl,t_rhu,
 	sql = "SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id in (" + lib.IntListToDotStr(ids) + ") ORDER BY t_time1 DESC,t_id ASC "
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -489,9 +484,6 @@ func Read_DeviceData_ByIds_ForPDF(SN string, ids []int, Time_start_ string, Time
 		sql_time += " t_time <= '" + Time_end_ + "' AND "
 	}
 
-	//fmt.Println("maps_z;",maps_z[0][0])
-	//t_tl,t_tu,t_rhl,t_rhu,
-
 	selectSql := ""
 	for i, v := range ids {
 		selectSql += fmt.Sprintf("MAX(CASE WHEN t_id = %d THEN t_t END) AS t_id%d,", v, i+1)
@@ -500,7 +492,7 @@ func Read_DeviceData_ByIds_ForPDF(SN string, ids []int, Time_start_ string, Time
 
 	sql := "SELECT DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time," + selectSql + " FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id in (" + lib.IntListToDotStr(ids) + ") GROUP BY t_time ORDER BY t_time"
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).QueryRows(&r)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -513,7 +505,7 @@ func Read_DeviceData_ByIds_ForPDF(SN string, ids []int, Time_start_ string, Time
 func Read_SqlRawL(T_SQL string, T_data []string) (string, []orm2.Params) {
 	o := orm.NewOrm()
 	var lists []orm2.Params
-	fmt.Println(T_SQL)
+	logs.Debug(T_SQL)
 	_, err := o.Raw(T_SQL, T_data).Values(&lists)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -541,7 +533,7 @@ func Read_DeviceData_By_T_snid_List(T_snid string, Time_start_ string, Time_end_
 			maps = append(maps, r_maps...)
 			maps_num = maps_num + int64(r_maps_num)
 
-			fmt.Println("加载数据:", sn_id[0], sn_id[1], r_maps_num)
+			logs.Debug("加载数据:", sn_id[0], sn_id[1], r_maps_num)
 		}
 	}
 
@@ -581,10 +573,10 @@ func Read_DeviceData_By_T_snid_List(T_snid string, Time_start_ string, Time_end_
 	}
 
 	if page_z == 9999 {
-		fmt.Println("总数据:", maps_num, " 导出")
+		logs.Debug("总数据:", maps_num, " 导出")
 		return maps, maps_num
 	}
-	fmt.Println("总数据:", maps_num, " 截取", offset, offset+page_z)
+	logs.Debug("总数据:", maps_num, " 截取", offset, offset+page_z)
 	return maps[offset:offset_z], maps_num
 }
 
@@ -595,10 +587,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-%c-%d %H:%i:%s') AS t_time  FROM z_device_data_"+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_device_data_" + 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.Debug(sql)
 	num, err := o.Raw(sql).ValuesList(&maps_z)
 	if err == nil && num > 0 {
-		fmt.Println(maps_z[0][0]) // slene
+		logs.Debug(maps_z[0][0]) // slene
 	}
 	//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
 	//key,_ := strconv.Atoi(maps_z[0][0].(string))
@@ -614,7 +606,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-%c-%d %H:%i:%s') AS t_time  FROM z_device_data_"+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_device_data_" + SN + "  WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%d\");"
-	fmt.Println(sql)
+	logs.Debug(sql)
 	o.Raw(sql).ValuesList(&maps_z)
 
 	//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
@@ -631,7 +623,7 @@ func Read_DeviceData_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-%c-%d %H:%i:%s') AS t_time  FROM z_device_data_"+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_device_data_" + SN + "  WHERE t_time > '" + time_x + "' GROUP BY DATE_FORMAT(t_time,\"%H\");"
-	fmt.Println(sql)
+	logs.Debug(sql)
 	o.Raw(sql).ValuesList(&maps_z)
 
 	//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
@@ -650,7 +642,7 @@ func Read_DeviceData_List_GROUP_BY_t_time(SN string, Time_start_ string, Time_en
 	}
 
 	sql := "SELECT DATE_FORMAT(t_time,'%Y-%c-%d %H:%i:%s') AS t_time FROM z_device_data_" + SN + " WHERE " + sql_time + "   GROUP BY t_time  ORDER BY t_time DESC "
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -668,7 +660,7 @@ func Read_DeviceData(T_sn string, T_id int) (t DeviceData_) {
 	var maps []DeviceData_
 	sql := "SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_" + T_sn + " WHERE" + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time1 DESC LIMIT 0,1"
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).QueryRows(&maps)
 
 	if err != nil {
@@ -703,7 +695,7 @@ func Read_DeviceData_BackUp_List(T_snid string, Time_start_ string, Time_end_ st
 			maps = append(maps, r_maps...)
 			maps_num = maps_num + int64(r_maps_num)
 
-			fmt.Println("加载数据:", sn_id[0], sn_id[1], r_maps_num)
+			logs.Debug("加载数据:", sn_id[0], sn_id[1], r_maps_num)
 		}
 	}
 	if page <= 1 {
@@ -722,10 +714,10 @@ func Read_DeviceData_BackUp_List(T_snid string, Time_start_ string, Time_end_ st
 	}
 
 	if page_z == 9999 {
-		fmt.Println("总数据:", maps_num, " 导出")
+		logs.Debug("总数据:", maps_num, " 导出")
 		return maps, maps_num
 	}
-	fmt.Println("总数据:", maps_num, " 截取", offset, offset+page_z)
+	logs.Debug("总数据:", maps_num, " 截取", offset, offset+page_z)
 	return maps[offset:offset_z], maps_num
 }
 
@@ -745,7 +737,7 @@ func Read_DeviceData_BackUp(T_sn string, T_id int, Time_start_ string, Time_end_
 
 	sql := "SELECT t_id,date_format(t_time, '%Y-%m-%d') t_date, count(*) t_num FROM z_device_data_" + T_sn + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " GROUP BY t_date ORDER BY t_time DESC "
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -768,7 +760,7 @@ func Read_DeviceData_By_Time(T_sn string, T_id int, Time string) (t DeviceData_)
 	var maps DeviceData_
 	sql := "SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_" + T_sn + " WHERE" + " t_id = " + strconv.Itoa(T_id) + " AND t_time <= '" + Time + "'" + " ORDER BY t_time1 DESC LIMIT 0,1"
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	err := o.Raw(sql).QueryRow(&maps)
 
 	if err != nil {

+ 10 - 25
models/Device/DeviceSensor.go

@@ -427,7 +427,6 @@ func Read_DeviceSensorList(admin_r *Account.Admin, bindSN []string, T_pid int, T
 
 	if T_Class_id > 0 {
 		T_Class := "C" + strconv.Itoa(T_Class_id) + "|"
-		fmt.Println("T_Class:", T_Class)
 		cond1 = cond1.And("T_Class__icontains", T_Class)
 	}
 
@@ -501,12 +500,11 @@ func Read_DeviceSensor_ByT_sn(T_sn string, T_id int) (r DeviceSensor, is bool) {
 
 // 删除
 func Delete_DeviceSensor_ById(T_sn string, T_id int) (err error) {
-	fmt.Println("Delete_DeviceSensor  : T_sn", T_sn, "T_id", T_id)
 	o := orm.NewOrm()
 	r := DeviceSensor{T_sn: T_sn, T_id: T_id}
 	err = o.Read(&r, "T_sn", "T_id") // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
 	if err != nil {
-		fmt.Println("Delete_DeviceSensor_ById", err)
+		logs.Error("Delete_DeviceSensor_ById", err)
 		return err
 	}
 	_, err = o.Delete(&DeviceSensor{Id: r.Id})
@@ -526,7 +524,7 @@ func Update_DeviceSensor(r DeviceSensor, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	Redis_DeviceSensor_Set(r)
 	return true
 
@@ -628,8 +626,6 @@ func Read_DeviceSensor_List_T_Class(T_pid int, T_Class_id int, T_sn string, T_na
 		T_Class = "C" + strconv.Itoa(T_Class_id) + "|"
 	}
 
-	fmt.Println("T_Class:", T_Class)
-
 	var r []DeviceSensor
 	cond := orm.NewCondition()
 	cond1 := cond.And("T_pid", T_pid).And("T_State", 1).And("T_Class__icontains", T_Class).And("T_sn__icontains", T_sn).And("T_name__icontains", T_name) // .AndNot("status__in", 1).Or("profile__age__gt", 2000)
@@ -832,8 +828,6 @@ func Read_DeviceSensor_List_T_Notice(T_pid int, T_Notice_id int, page int, page_
 		T_Notice = "N" + strconv.Itoa(T_Notice_id) + "|"
 	}
 
-	fmt.Println("T_Notice:", T_Notice)
-
 	var r []DeviceSensor
 	cond := orm.NewCondition()
 	cond1 := cond.And("T_pid", T_pid).And("T_State", 1).And("T_Notice__icontains", T_Notice).And("T_sn__icontains", T_sn).And("T_name__icontains", T_name) // .AndNot("status__in", 1).Or("profile__age__gt", 2000)
@@ -927,7 +921,7 @@ func Read_DeviceSensorManageList1(admin_r *Account.Admin, bindSN []string, T_pid
 
 	// -------------
 	sql := "SELECT COUNT(ds.ID) FROM " + "device_sensor ds WHERE " + sql_WHERE
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -936,7 +930,6 @@ func Read_DeviceSensorManageList1(admin_r *Account.Admin, bindSN []string, T_pid
 	if len(maps_z) == 0 {
 		return DeviceSensor_p, 0
 	}
-	//fmt.Println("maps_z;",maps_z[0][0])
 	sql = "SELECT * FROM device_sensor ds " +
 		"LEFT JOIN ( SELECT t_sn AS tsn,t_id AS tid,t_en,t_free,t__tlower,t__tupper,t__r_hlower,t__r_hupper,t_enprel,t_tprel,t_tpreu,t_hprel,t_hpreu " +
 		"FROM device_sensor_parameter WHERE id IN (SELECT MAX(id) FROM device_sensor_parameter WHERE t__state=1 GROUP BY t_sn,t_id)) AS dsp " +
@@ -947,7 +940,7 @@ func Read_DeviceSensorManageList1(admin_r *Account.Admin, bindSN []string, T_pid
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1020,7 +1013,7 @@ func Read_DeviceSensorManageList(admin_r *Account.Admin, bindSN []string, T_pid
 		"LEFT JOIN device_sensor_parameter dsp " +
 		"ON ds.t_sp=dsp.id " +
 		"WHERE " + sql_WHERE + sql_ORDER
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1029,7 +1022,6 @@ func Read_DeviceSensorManageList(admin_r *Account.Admin, bindSN []string, T_pid
 	if len(maps_z) == 0 {
 		return DeviceSensor_p, 0
 	}
-	//fmt.Println("maps_z;",maps_z[0][0])
 	//"LEFT JOIN (SELECT id,t_en,t_free,t__tlower,t__tupper,t__r_hlower,t__r_hupper,t_enprel,t_tprel,t_tpreu,t_hprel,t_hpreu " +
 	//"FROM device_sensor_parameter) dsp " +
 	sql = "SELECT ds.t_sn,ds.t_id,ds.t_name,t_type,t_sort,t_datashow,ds.t__state,t_en,t_free,t__tlower,t__tupper,t__r_hlower,t__r_hupper,t_enprel,t_tprel,t_tpreu,t_hprel,t_hpreu FROM device_sensor ds " +
@@ -1041,7 +1033,7 @@ func Read_DeviceSensorManageList(admin_r *Account.Admin, bindSN []string, T_pid
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1210,7 +1202,7 @@ func Read_DeviceSensor_List_For_Data1(bindSN []string, T_pid int, T_name string,
 	}
 	// -------------
 	sql := "SELECT COUNT(*) FROM " + "device_sensor ds WHERE " + sql_WHERE
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1230,7 +1222,7 @@ func Read_DeviceSensor_List_For_Data1(bindSN []string, T_pid int, T_name string,
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&r)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1251,7 +1243,6 @@ func Read_DeviceSensor_List_For_Data1(bindSN []string, T_pid int, T_name string,
 			return
 		}
 		var DeviceSensor_unusual []DeviceSensor_R
-		stime := time.Now()
 		for _, v := range r {
 			v_r := DeviceSensorRealTimeToDeviceSensor_R(v)
 			data := v_r.T_DeviceSensorData
@@ -1263,7 +1254,6 @@ func Read_DeviceSensor_List_For_Data1(bindSN []string, T_pid int, T_name string,
 			}
 		}
 		DeviceSensor_unusual = append(DeviceSensor_unusual, DeviceSensor_r...)
-		fmt.Println("================", time.Now().Sub(stime).Seconds())
 		return DeviceSensor_unusual[offset:offset_z], cnt
 	}
 
@@ -1295,7 +1285,6 @@ func Read_CompanyDeviceSensor_List_For_Data(T_pids []int, T_name string, T_Class
 
 	if T_Class_id > 0 {
 		T_Class := "C" + strconv.Itoa(T_Class_id) + "|"
-		fmt.Println("T_Class:", T_Class)
 		cond1 = cond1.And("T_Class__icontains", T_Class)
 	}
 
@@ -1335,7 +1324,6 @@ func Read_CompanyDeviceSensor_List_For_Data(T_pids []int, T_name string, T_Class
 			return
 		}
 		var DeviceSensor_unusual []DeviceSensor_R
-		stime := time.Now()
 		for _, v := range r {
 			v_r := DeviceSensorToDeviceSensor_R(v)
 			data := v_r.T_DeviceSensorData
@@ -1347,7 +1335,6 @@ func Read_CompanyDeviceSensor_List_For_Data(T_pids []int, T_name string, T_Class
 			}
 		}
 		DeviceSensor_unusual = append(DeviceSensor_unusual, DeviceSensor_r...)
-		fmt.Println("================", time.Now().Sub(stime).Seconds())
 
 		return DeviceSensor_unusual[offset:offset_z], cnt
 	}
@@ -1411,7 +1398,7 @@ func Read_CompanyDeviceSensor_List_For_Data1(T_pids []int, T_name string, T_Clas
 	sql_WHERE = strings.TrimLeft(sql_WHERE, " AND")
 	// -------------
 	sql := "SELECT COUNT(*) FROM " + "device_sensor ds WHERE " + sql_WHERE
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1431,7 +1418,7 @@ func Read_CompanyDeviceSensor_List_For_Data1(T_pids []int, T_name string, T_Clas
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&r)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1452,7 +1439,6 @@ func Read_CompanyDeviceSensor_List_For_Data1(T_pids []int, T_name string, T_Clas
 			return
 		}
 		var DeviceSensor_unusual []DeviceSensor_R
-		stime := time.Now()
 		for _, v := range r {
 			v_r := DeviceSensorRealTimeToDeviceSensor_R(v)
 			data := v_r.T_DeviceSensorData
@@ -1464,7 +1450,6 @@ func Read_CompanyDeviceSensor_List_For_Data1(T_pids []int, T_name string, T_Clas
 			}
 		}
 		DeviceSensor_unusual = append(DeviceSensor_unusual, DeviceSensor_r...)
-		fmt.Println("================", time.Now().Sub(stime).Seconds())
 		return DeviceSensor_unusual[offset:offset_z], cnt
 	}
 

+ 1 - 5
models/Product/ProductUpgrade.go

@@ -3,7 +3,6 @@ package Product
 import (
 	"Cold_Api/controllers/lib"
 	"encoding/json"
-	"fmt"
 	"github.com/astaxie/beego/cache"
 	_ "github.com/astaxie/beego/cache/redis"
 	"github.com/beego/beego/v2/adapter/orm"
@@ -60,7 +59,6 @@ func init() {
 	//redisCache_ProductUpgrade, err = cache.NewCache("redis", config)
 	//if err != nil || redisCache_ProductUpgrade == nil {
 	//	errMsg := "failed to init redis"
-	//	fmt.Println(errMsg, err)
 	//	panic(errMsg)
 	//}
 }
@@ -207,12 +205,10 @@ func Read_ProductUpgrade_List(T_model string, page int, page_z int) (r []Product
 func Read_ProductUpgrade_T_model() (lists orm2.ParamsList) {
 	o := orm.NewOrm()
 	var pl_lists orm2.ParamsList
-	num, err := o.Raw("SELECT DISTINCT t_model FROM product_upgrade LIMIT 0,1000").ValuesFlat(&pl_lists)
+	_, err := o.Raw("SELECT DISTINCT t_model FROM product_upgrade LIMIT 0,1000").ValuesFlat(&pl_lists)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 	}
-	fmt.Println("user nums: ", num)
-	fmt.Println(len(pl_lists))
 
 	return pl_lists
 }

+ 2 - 4
models/RawSql/RawSql.go

@@ -3,7 +3,6 @@ package RawSql
 import (
 	"Cold_Api/conf"
 	"Cold_Api/controllers/lib"
-	"fmt"
 	"github.com/beego/beego/v2/adapter/orm"
 	"github.com/beego/beego/v2/core/logs"
 	_ "github.com/go-sql-driver/mysql"
@@ -96,18 +95,17 @@ func Update_TRawSql(r RawSql, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	return true
 }
 
 // 删除
 func Delete_RawSql(m RawSql) (err error) {
 	o := orm.NewOrm()
-	num, err := o.Delete(&m)
+	_, err = o.Delete(&m)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 	}
-	fmt.Println("Number of records deleted in database:", num)
 	return
 }
 

+ 1 - 2
models/System/UserLogs.go

@@ -3,7 +3,6 @@ package System
 import (
 	"Cold_Api/controllers/lib"
 	"encoding/json"
-	"fmt"
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/core/logs"
@@ -45,7 +44,7 @@ func Add_UserLogs_T(Logs_uuid string, Logs_class string, Logs_Title string, Logs
 	o := orm.NewOrm()
 	jsonStu, err := json.Marshal(Logs_Txt_T)
 	if err != nil {
-		fmt.Println("Add_UserLogs_T JSON ,err=", err)
+		logs.Error("Add_UserLogs_T JSON ,err=", err)
 	}
 	m := UserLogs{Logs_uuid: Logs_uuid, Logs_class: Logs_class, Logs_Title: Logs_Title, Logs_Txt: string(jsonStu)}
 	_, err = o.Insert(&m)

+ 12 - 14
models/Warning/Warning.go

@@ -337,7 +337,7 @@ func Read_Warning_ById_Backups(id int, T_year string, T_month string) (r Warning
 	sql := "SELECT ID,t_pid,t_tp,t_sn,t__d_name,t_id,t__d_s_name,t__remark,t__ut,t__text,t__log,t__msid,t__state,create_time,update_time " +
 		"FROM " + Wtab + " WHERE" + sql_WHERE
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	num, err := o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -369,7 +369,7 @@ func Update_Warning(r Warning, cols ...string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 	return true
 }
 
@@ -384,7 +384,7 @@ func Update_Warning_Backups(r Warning, T_year string, T_month string) bool {
 		logs.Error(lib.FuncName(), err)
 		return false
 	}
-	fmt.Println("Number of records updated in database:", num)
+	logs.Info("Number of records updated in database:", num)
 
 	return true
 }
@@ -628,7 +628,7 @@ func Read_Warning_Backups(T_pid int, bindSN []string, T_year string, T_month str
 	cnt, _, err := Redis_WarningCount_GetOne(T_pid, countRedisKey)
 	if err != nil {
 		sql := "SELECT COUNT(*) FROM " + Wtab + " WHERE " + sql_WHERE
-		fmt.Println(sql)
+		logs.Debug(sql)
 		_, err = o.Raw(sql).ValuesList(&maps_z)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
@@ -645,14 +645,13 @@ func Read_Warning_Backups(T_pid int, bindSN []string, T_year string, T_month str
 		return r, 0
 	}
 
-	//fmt.Println("maps_z;",maps_z[0][0])
 	sql := "SELECT ID,t_pid,t_tp,t_sn,t__d_name,t_id,t__d_s_name,t__remark,t__ut,t__text,t__log,t__msid,t__state,create_time,update_time " +
 		"FROM " + Wtab + " WHERE " + sql_WHERE + " ORDER BY t__ut DESC"
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -732,7 +731,7 @@ func Read_Admin_Warning_Backups(admin Account.Admin, T_year string, T_month stri
 	cnt, _, err := Redis_WarningCount_GetOne(admin.Id, countRedisKey)
 	if err != nil {
 		sql := "SELECT COUNT(*) FROM " + Wtab + " WHERE " + sql_WHERE
-		fmt.Println(sql)
+		logs.Debug(sql)
 		_, err = o.Raw(sql).ValuesList(&maps_z)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
@@ -749,14 +748,13 @@ func Read_Admin_Warning_Backups(admin Account.Admin, T_year string, T_month stri
 		return r, 0
 	}
 
-	//fmt.Println("maps_z;",maps_z[0][0])
 	sql := "SELECT ID,t_pid,t_tp,t_sn,t__d_name,t_id,t__d_s_name,t__remark,t__ut,t__text,t__log,t__msid,t__state,create_time,update_time " +
 		"FROM " + Wtab + " WHERE " + sql_WHERE + " ORDER BY t__ut DESC"
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -959,7 +957,7 @@ func Read_Warning_List_By_DS_T_type(admin *Account.Admin, T_pid int, bindSN []st
 		"WHERE " + sql_WHERE
 	cnt, _, err := Redis_WarningCount_GetOne(T_pid, countRedisKey)
 	if err != nil {
-		fmt.Println(sql)
+		logs.Debug(sql)
 		_, err = o.Raw(sql).ValuesList(&maps_z)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
@@ -986,7 +984,7 @@ func Read_Warning_List_By_DS_T_type(admin *Account.Admin, T_pid int, bindSN []st
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1169,7 +1167,7 @@ func Read_Company_Warning_Backups(T_pids []int, T_year string, T_month string, T
 	cnt, _, err := Redis_WarningCount_GetOne(T_pid, countRedisKey)
 	if err != nil {
 		sql := "SELECT COUNT(*) FROM " + Wtab + " WHERE " + sql_WHERE
-		fmt.Println(sql)
+		logs.Debug(sql)
 		_, err = o.Raw(sql).ValuesList(&maps_z)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
@@ -1191,7 +1189,7 @@ func Read_Company_Warning_Backups(T_pids []int, T_year string, T_month string, T
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
 
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err = o.Raw(sql).QueryRows(&maps)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -1737,7 +1735,7 @@ func checkStringListContinuous(nums []string) (int, int, bool) {
 	for i, num := range nums {
 		parsedNum, err := strconv.Atoi(num)
 		if err != nil {
-			fmt.Println("Error converting string to int:", err)
+			logs.Error("Error converting string to int:", err)
 			return 0, 0, false
 		}
 		intNums[i] = parsedNum

+ 4 - 4
models/Warning/WarningSand.go

@@ -71,7 +71,7 @@ func Read_WarningWx_ById(id int) (r WarningSand) {
 	r = WarningSand{Id: id}
 	err := o.Read(&r) // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
 	if err != nil {
-		fmt.Println(err)
+		logs.Error(err)
 	}
 	return r
 }
@@ -89,7 +89,7 @@ func Add_WarningSand(m WarningSand) (id int64, err error) {
 	o := orm.NewOrm()
 	id, err = o.Insert(&m)
 	//if err != nil {
-	//	fmt.Println(err)
+	//	logs.Error(err)
 	//}
 	return id, err
 }
@@ -133,7 +133,7 @@ func Read_WarningSand_ALL_T_sn_TIME_Count(T_sn string) (cnt int) {
 	timeStr := now.Format("2006-01-02") + " 00:00:00"
 
 	sql := "SELECT COUNT(ID) FROM warning_sand WHERE t__title NOT LIKE '%恢复%' AND t__ut > '" + timeStr + "' AND t_sn LIKE '%" + T_sn + "%' "
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		return 0
@@ -157,7 +157,7 @@ func Read_WarningSand_ALL_T_Bind_TIME_Count(user_ Account.Admin, T_sn string) (c
 	T_Bind := "U" + strconv.Itoa(user_.Id) + "|"
 
 	sql := "SELECT COUNT(ID) FROM warning_sand WHERE t__title NOT LIKE '%恢复%' AND t__ut > '" + timeStr + "' AND t__bind LIKE '%" + T_Bind + "%' AND t_sn  LIKE '%" + T_sn + "%'"
-	fmt.Println(sql)
+	logs.Debug(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
 		return 0

+ 1 - 2
routers/filter.go

@@ -4,7 +4,6 @@ import (
 	"Cold_Api/conf"
 	"Cold_Api/controllers/lib"
 	"Cold_Api/models/Account"
-	"fmt"
 	"github.com/beego/beego/v2/core/logs"
 	"github.com/beego/beego/v2/server/web/context"
 	"strings"
@@ -114,5 +113,5 @@ func T_pidFilter(ctx *context.Context) {
 		data := lib.JSONS{Code: 202, Msg: "T_pid Err!"}
 		ctx.Output.JSON(data, true, false)
 	}
-	fmt.Println("公司 T_pid 为", T_pid)
+	logs.Debug("公司 T_pid 为", T_pid)
 }