瀏覽代碼

增加日志打印

LiXiangFei 1 周之前
父節點
當前提交
aa0dabc7e9
共有 2 個文件被更改,包括 11 次插入5 次删除
  1. 4 3
      Cold_server.go
  2. 7 2
      controllers/DeviceController.go

+ 4 - 3
Cold_server.go

@@ -6,13 +6,14 @@ import (
 	"ColdP_server/middleware"
 	_ "ColdP_server/routers"
 	"fmt"
+	"runtime"
+	"strconv"
+
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
 	beego "github.com/beego/beego/v2/server/web"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	_ "github.com/go-sql-driver/mysql"
-	"runtime"
-	"strconv"
 )
 
 func init() {
@@ -51,7 +52,7 @@ func main() {
 	s, _ := beego.AppConfig.String("isRun")
 	if s == "true" {
 		go MqttServer.MqttConntMqttjxit()
-		//go MqttServer.MqttConntMqttlodr()
+		go MqttServer.MqttConntMqttlodr()
 		//go MqttServer.MqttConntMqttyuht()
 		go MqttServer.Cron()
 	}

+ 7 - 2
controllers/DeviceController.go

@@ -10,7 +10,6 @@ import (
 	"ColdP_server/models/Warning"
 	"encoding/json"
 	"fmt"
-	beego "github.com/beego/beego/v2/server/web"
 	"io"
 	"log"
 	"math"
@@ -18,6 +17,8 @@ import (
 	"strings"
 	"sync"
 	"time"
+
+	beego "github.com/beego/beego/v2/server/web"
 )
 
 // DeviceController  设备管理页面
@@ -253,7 +254,9 @@ func (c *DeviceController) ReadDeviation() {
 
 // WriteDeviation 设置偏差值
 func (c *DeviceController) WriteDeviation() {
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	// 账号(T_name) 和 用户ID(T_id)。
+	logs.Println("WriteDeviation1 日志 - 账号: %s, 用户ID: %v", admin_r.T_name, admin_r.Id)
 	if !b_ {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
 		c.ServeJSON()
@@ -282,6 +285,8 @@ func (c *DeviceController) WriteDeviation() {
 	}
 	// 处理每个设备的数据
 	for _, v := range data {
+		// 输出 账号 和 目标设备 SN
+		logs.Println("WriteDeviation2 日志 - 账号: %s,用户ID: %v 目标设备SN: %s", admin_r.T_name, admin_r.Id, v.Sn)
 		wg.Add(1)
 		go func(v MqttServer.Deviation_Sub) {
 			defer wg.Done()