Browse Source

update: 修改表名

zoie 2 years ago
parent
commit
91e377762b

+ 1 - 0
.gitignore

@@ -33,3 +33,4 @@ _testmain.go
 lastupdate.tmp
 main
 Cold_Api6200
+Makefile

+ 98 - 18
Nats/Nats.go

@@ -6,6 +6,7 @@ import (
 	"Cold_Api/logs"
 	"Cold_Api/models/Account"
 	"Cold_Api/models/Company"
+	"Cold_Api/models/Device"
 	"Cold_Api/models/System"
 	"encoding/xml"
 	"fmt"
@@ -216,19 +217,12 @@ func NatsInit() {
 
 	// 请求-响应 验证登录
 	_, _ = lib.Nats.Subscribe("Cold_User_verification", func(m *nats.Msg) {
-		fmt.Printf("verification message: %s\n", string(m.Data))
-
-		type T_User struct {
-			T_uuid  string `xml:"T_uuid"`
-			T_pid   int    `xml:"T_pid"`
-			T_power int    `xml:"T_power"`
-			T_name  string `xml:"T_name"`
-			T_user  string `xml:"T_user"`
-		}
+		fmt.Printf("Cold_User_verification message: %s\n", string(m.Data))
+
 		type T_R struct {
-			Code int16  `xml:"Code"`
-			Msg  string `xml:"Msg"`
-			Data T_User `xml:"Data"` // 泛型
+			Code int16           `xml:"Code"`
+			Msg  string          `xml:"Msg"`
+			Data Account.Admin_R `xml:"Data"` // 泛型
 		}
 
 		var t_R T_R
@@ -246,11 +240,7 @@ func NatsInit() {
 
 		t_R.Code = 200
 		t_R.Msg = "ok"
-		t_R.Data.T_uuid = admin_r.T_uuid
-		t_R.Data.T_pid = admin_r.T_pid
-		t_R.Data.T_power = admin_r.T_power
-		t_R.Data.T_name = admin_r.T_name
-		t_R.Data.T_user = admin_r.T_user
+		t_R.Data = Account.AdminToAdmin_R(admin_r)
 
 		b, _ := msgpack.Marshal(&t_R)
 		_ = lib.Nats.Publish(m.Reply, b)
@@ -293,7 +283,7 @@ func NatsInit() {
 	})
 	// 请求-响应 检查用户权限
 	_, _ = lib.Nats.Subscribe("Cold_User_CheckUserPermissions", func(m *nats.Msg) {
-		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
+		fmt.Printf("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
@@ -386,4 +376,94 @@ func NatsInit() {
 
 	})
 
+	// 请求-响应 获取设备
+	_, _ = lib.Nats.Subscribe("Cold_ReadDeviceByT_sn", func(m *nats.Msg) {
+		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
+
+		type T_R struct {
+			Code int16         `xml:"Code"`
+			Msg  string        `xml:"Msg"`
+			Data Device.Device `xml:"Data"` // 泛型
+		}
+
+		var t_R T_R
+
+		device, err := Device.Read_Device_ByT_sn(string(m.Data))
+
+		if err != nil {
+			t_R.Code = 202
+			t_R.Msg = "查询失败"
+			b, _ := msgpack.Marshal(&t_R)
+			_ = lib.Nats.Publish(m.Reply, b)
+		}
+
+		t_R.Code = 200
+		t_R.Msg = "ok"
+		t_R.Data = device
+
+		b, _ := msgpack.Marshal(&t_R)
+		_ = lib.Nats.Publish(m.Reply, b)
+	})
+
+	// 请求-响应 获取传感器列表
+	_, _ = lib.Nats.Subscribe("Cold_ReadDeviceSensorALLByT_sn", func(m *nats.Msg) {
+		fmt.Printf("CheckUserPermissions message: %s\n", string(m.Data))
+
+		type T_R struct {
+			Code int16                 `xml:"Code"`
+			Msg  string                `xml:"Msg"`
+			Data []Device.DeviceSensor `xml:"Data"` // 泛型
+		}
+
+		var t_R T_R
+
+		device := Device.Read_DeviceSensor_ALL_List_T_sn(string(m.Data))
+
+		t_R.Code = 200
+		t_R.Msg = "ok"
+		t_R.Data = device
+
+		b, _ := msgpack.Marshal(&t_R)
+		_ = lib.Nats.Publish(m.Reply, b)
+	})
+
+	// 请求-响应 获取设备数据列表
+	_, _ = lib.Nats.Subscribe("Cold_ReadDeviceDataListBy_T_snid", func(m *nats.Msg) {
+		fmt.Printf("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"`
+			Time_end   string `xml:"Time_end"`
+			Page       int    `xml:"Page"`
+			Page_z     int    `xml:"Page_z"`
+		}
+		type T_R struct {
+			Code  int16                 `xml:"Code"`
+			Msg   string                `xml:"Msg"`
+			Count int64                 `xml:"Count"`
+			Data  []Device.DeviceData_R `xml:"Data"` // 泛型
+		}
+		var t_Req T_Req
+		var t_R T_R
+
+		err := msgpack.Unmarshal(m.Data, &t_Req)
+		if err != nil {
+			t_R.Code = 201
+			t_R.Msg = "Unmarshal error"
+			b, _ := msgpack.Marshal(&t_R)
+			_ = lib.Nats.Publish(m.Reply, b)
+			return
+		}
+
+		deviceData, cnt := Device.Read_DeviceData_By_T_snid_List(t_Req.T_snid, t_Req.Time_start, t_Req.Time_end, t_Req.Page, t_Req.Page_z)
+
+		t_R.Code = 200
+		t_R.Msg = "ok"
+		t_R.Count = cnt
+		t_R.Data = deviceData
+
+		b, _ := msgpack.Marshal(&t_R)
+		_ = lib.Nats.Publish(m.Reply, b)
+	})
+
 }

+ 1 - 1
conf/app.conf

@@ -25,7 +25,7 @@ MysqlServer_MaxOpenConnections = 200
 
 # Redis
 # Redis
-Redis_address = "127.0.0.1:41379"
+Redis_address = "127.0.0.1:43379"
 Redis_password = ""
 Redis_dbNum = "1"
 

+ 5 - 5
controllers/Data.go

@@ -186,7 +186,7 @@ func (c *DataController) Device_Sensor_Data_More() {
 	}
 	var r_jsons R_JSONS
 
-	r_jsons.Data, r_jsons.Num = Device.Read_V2_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, page, page_z)
+	r_jsons.Data, r_jsons.Num = Device.Read_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, page, page_z)
 	r_jsons.Page = page
 	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
 
@@ -219,7 +219,7 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 	}
 	var DeviceSensor_data []Device.DeviceData_R
 
-	DeviceSensor_data, _ = Device.Read_V2_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
+	DeviceSensor_data, _ = Device.Read_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
 
 	f := excelize.NewFile() // 设置单元格的值
 	// 这里设置表头
@@ -314,7 +314,7 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 	}
 	var DeviceSensor_data []Device.DeviceData_R
 
-	DeviceSensor_data, _ = Device.Read_V2_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
+	DeviceSensor_data, _ = Device.Read_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
 
 	f := excelize.NewFile() // 设置单元格的值
 	// 这里设置表头
@@ -482,7 +482,7 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 	}
 	var DeviceSensor_data []Device.DeviceData_R
 
-	DeviceSensor_data, _ = Device.Read_V2_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
+	DeviceSensor_data, _ = Device.Read_DeviceData_By_T_snid_List(T_snid, Time_start, Time_end, 0, 9999)
 
 	var err error
 	pdf := &gopdf.GoPdf{}
@@ -660,7 +660,7 @@ func (c *DataController) Raw() {
 		return
 	}
 
-	if //!strings.Contains(T_SQL, "Z_DeviceData_") ||
+	if //!strings.Contains(T_SQL, "z_device_data_") ||
 	!strings.Contains(T_SQL_, "select") {
 		RawSql.Add_SqlLogs(admin_r.T_uuid, "Err:"+admin_r.T_user, T_SQL)
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err SQL!", Data: admin_r.T_name + " :你的行为 也被记录"}

+ 58 - 72
controllers/Device.go

@@ -13,7 +13,6 @@ import (
 	"github.com/xuri/excelize/v2"
 	"math"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -77,7 +76,7 @@ func (c *DeviceController) Device_List() {
 	return
 
 }
-func (c *DeviceController) Device_Post() {
+func (c *DeviceController) Device_Add() {
 	/// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 	if !b_ {
@@ -90,10 +89,16 @@ func (c *DeviceController) Device_Post() {
 
 	T_sn := c.GetString("T_sn")
 	T_MSISDN := c.GetString("T_MSISDN")
-
+	T_type, _ := c.GetInt("T_type")
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
 	var_ := Device.Device{
+		T_pid:     T_pid,
 		T_sn:      T_sn,
 		T_MSISDN:  T_MSISDN,
+		T_type:    T_type,
 		T_give:    1,
 		T_monitor: 1,
 		T_State:   1,
@@ -104,12 +109,6 @@ func (c *DeviceController) Device_Post() {
 		return
 	}
 
-	if !(strings.Contains(T_sn, "KF") || strings.Contains(T_sn, "YD")) {
-		c.Data["json"] = lib.JSONS{Code: 303, Msg: "必须包含 KF或YD!"}
-		c.ServeJSON()
-		return
-	}
-
 	_, err = Device.Read_Device_ByT_sn(T_sn)
 	if err == nil {
 		c.Data["json"] = lib.JSONS{Code: 303, Msg: "重复SN!"}
@@ -140,45 +139,6 @@ func (c *DeviceController) Device_Post() {
 	return
 
 }
-func (c *DeviceController) Device_Del() {
-	// 验证登录
-	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-	if !b_ {
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-	if admin_r.Id != 1 {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
-		c.ServeJSON()
-		return
-	}
-
-	T_sn := c.GetString("T_sn")
-
-	Device_r, err := Device.Read_Device_ByT_sn(T_sn)
-	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
-		c.ServeJSON()
-		return
-	}
-
-	Device.Delete_Device(Device_r)
-	DeviceSensor_list, _ := Device.Read_DeviceSensor_ByTsn(Device_r.T_sn)
-	for _, v := range DeviceSensor_list {
-		Device.Delete_DeviceSensor_ById(Device_r.T_sn, v.T_id)
-	}
-	Device.DELETE_DeviceSensor(Device_r.T_sn)
-	Device.DELETE_DeviceDatar(Device_r.T_sn)
-	Device.DELETE_DeviceParameter(Device_r.T_sn)
-	Device.DELETE_DeviceSensorParameter(Device_r.T_sn)
-
-	System.Add_UserLogs(admin_r.T_uuid, "设备管理", "设备删除", T_sn)
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-	c.ServeJSON()
-	return
-
-}
 func (c *DeviceController) Device_Edit() {
 	// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -230,6 +190,45 @@ func (c *DeviceController) Device_Edit() {
 	return
 
 }
+func (c *DeviceController) Device_Del() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	if admin_r.Id != 1 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_sn := c.GetString("T_sn")
+
+	Device_r, err := Device.Read_Device_ByT_sn(T_sn)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	Device.Delete_Device(Device_r)
+	DeviceSensor_list, _ := Device.Read_DeviceSensor_ByTsn(Device_r.T_sn)
+	for _, v := range DeviceSensor_list {
+		Device.Delete_DeviceSensor_ById(Device_r.T_sn, v.T_id)
+	}
+	Device.DELETE_DeviceSensor(Device_r.T_sn)
+	Device.DELETE_DeviceDatar(Device_r.T_sn)
+	Device.DELETE_DeviceParameter(Device_r.T_sn)
+	Device.DELETE_DeviceSensorParameter(Device_r.T_sn)
+
+	System.Add_UserLogs(admin_r.T_uuid, "设备管理", "设备删除", T_sn)
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
 
 // 设备参数 ------------------------------------------
 
@@ -909,9 +908,9 @@ func (c *DeviceController) DeviceWarning_List() {
 
 	T_year, _ := c.GetInt("T_year")
 	T_month, _ := c.GetInt("T_month")
-	T_pid, _ := c.GetInt("T_pid")
-	if admin_r.T_pid > 0 {
-		T_pid = admin_r.T_pid
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
 	}
 
 	if T_year > 0 && T_month > 0 {
@@ -1022,9 +1021,9 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 	Time_start := c.GetString("Time_start")
 	Time_end := c.GetString("Time_end")
 	T_handle, _ := c.GetInt("T_handle")
-	T_pid, _ := c.GetInt("T_pid")
-	if admin_r.T_pid > 0 {
-		T_pid = admin_r.T_pid
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
 	}
 
 	Device_data, _ := Warning.Read_Warning(T_pid, T_sn, T_id, T_title, T_handle, Time_start, Time_end, 0, 9999)
@@ -2002,32 +2001,19 @@ func (c *DeviceController) NoticeBind_Del() {
 	return
 }
 
-// 设备日志 ------------------------------------------
-func (c *DeviceController) DeviceLogs() {
+// 设备类型
+func (c *DeviceController) DeviceType_All() {
 	type R_JSONS struct {
 		//必须的大写开头
-		Data      []Device.DeviceLogs
+		Data      []Device.DeviceType
 		Num       int64
 		Page      int
 		Page_size int
 	}
-	var r_jsons R_JSONS
-
-	page, _ := c.GetInt("page")
-	println(page)
-	if page < 1 {
-		page = 1
-	}
-	page_z, _ := c.GetInt("page_z")
-	if page_z < 1 {
-		page_z = conf.Page_size
-	}
 
-	T_sn := c.GetString("T_sn")
+	var r_jsons R_JSONS
 
-	r_jsons.Data, r_jsons.Num = Device.Read_V2DeviceLogs_ALL(T_sn, page, page_z)
-	r_jsons.Page = page
-	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
+	r_jsons.Data = Device.Read_DeviceType_List_All()
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()

+ 850 - 1019
controllers/GoodsOrder.go

@@ -1,1029 +1,860 @@
 package controllers
 
 import (
+	"Cold_Api/Nats/NatsServer"
+	"Cold_Api/conf"
+	"Cold_Api/controllers/lib"
+	"Cold_Api/models/Device"
+	"Cold_Api/models/Function"
+	"fmt"
 	beego "github.com/beego/beego/v2/server/web"
+	"github.com/signintech/gopdf"
+	"math"
+	"os"
+	"strconv"
+	"strings"
+	"time"
 )
 
-//Handle
+// Handle
 type GoodsOrderController struct {
 	beego.Controller
 }
 
-//
-//func (c *GoodsOrderController) GoodsOrder_List() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	type R_JSONS struct {
-//		//必须的大写开头
-//		Data      []Function.GoodsOrderR
-//		Num       int64
-//		Page      int
-//		Page_size int
-//	}
-//
-//	var r_jsons R_JSONS
-//
-//	page, _ := c.GetInt("page")
-//	println(page)
-//	if page < 1 {
-//		page = 1
-//	}
-//	page_z, _ := c.GetInt("page_z")
-//	if page_z < 1 {
-//		page_z = conf.Page_size
-//	}
-//
-//	Name := c.GetString("T_name")
-//	c.Data["Name"] = Name
-//
-//	r_jsons.Data, r_jsons.Num = Function.Read_V2_GoodsOrder_List(admin_r.Admin_uuid, page, page_z, Name)
-//	r_jsons.Page = page
-//	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
-//	c.ServeJSON()
-//	return
-//}
-//func (c *GoodsOrderController) GoodsOrder_Get() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Ctx.Redirect(302, "Login")
-//		return
-//	}
-//
-//	id, _ := c.GetInt("T_id")
-//
-//	r := Function.Read_GoodsOrder_ById(id)
-//
-//	if r.Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id !"}
-//		c.ServeJSON()
-//		return
-//	}
-//	if admin_r.Admin_uuid != r.T_uuid {
-//		c.Data["json"] = lib.JSONS{Code: 205, Msg: "你没有权限 !"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Function.GoodsOrderToGoodsOrderR(r)}
-//	c.ServeJSON()
-//	return
-//}
-//
-//func (c *GoodsOrderController) GoodsOrder_html() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Ctx.Redirect(302, "Login")
-//		return
-//	}
-//	c.Data["Device_lite"] = Device.Read_Device_ALL_bind(admin_r)
-//
-//	//c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
-//	Name := c.GetString("Name")
-//	c.Data["Name"] = Name
-//
-//	page, _ := c.GetInt("page")
-//
-//	println(page)
-//	if page < 1 {
-//		page = 1
-//	}
-//
-//	page_z, _ := c.GetInt("Page_size")
-//	if page_z == 0 {
-//		page_z = conf.Page_size
-//	}
-//
-//	List, cnt := Function.Read_GoodsOrder_List(admin_r.Admin_uuid, page, page_z, Name)
-//
-//	page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
-//
-//	c.Data["List"] = List
-//	c.Data["Page"] = page
-//	c.Data["Page_size"] = page_size
-//	c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
-//	c.Data["cnt"] = cnt
-//
-//	c.TplName = "GoodsOrder/GoodsOrder.html"
-//}
-//
-//func (c *GoodsOrderController) GoodsOrder__html() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Ctx.Redirect(302, "Login")
-//		return
-//	}
-//
-//	c.Data["Device_lite"] = Device.Read_Device_ALL_bind(admin_r)
-//
-//	//c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
-//	id, _ := c.GetInt("id")
-//	c.Data["id"] = id
-//	if id > 0 {
-//		c.Data["Date"] = Function.Read_GoodsOrder_ById(id)
-//	}
-//
-//	c.TplName = "GoodsOrder/GoodsOrder-.html"
-//}
-//
-////
-////func (c *GoodsOrderController) GoodsOrder_List() {
-////	// 验证登录
-////	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-////	if !b_ {
-////		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-////		c.ServeJSON()
-////		return
-////	}
-////
-////	type R_JSONS struct {
-////		//必须的大写开头
-////		DeviceSensor_lite []Device.DeviceSensor_R
-////		Num               int
-////		Page              int
-////		Page_size         int
-////		Pages             []lib.Page_T
-////	}
-////	var r_jsons R_JSONS
-////	page, _ := c.GetInt("page")
-////
-////	println(page)
-////	if page < 1 {
-////		page = 1
-////	}
-////
-////	page_z, _ := c.GetInt("page_z")
-////	if page_z == 0 {
-////		page_z = conf.Page_size
-////	}
-////
-////	T_sn := c.GetString("Sn")
-////
-////	Device_r, err := Device.Read_Device_ByT_sn(T_sn)
-////	if err != nil {
-////		c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_sn Err!"}
-////		c.ServeJSON()
-////		return
-////	}
-////	if admin_r.Admin_master > 1 {
-////		if !strings.Contains(Device_r.T_Bind, "U"+strconv.Itoa(admin_r.Id)+"|") && admin_r.Admin_master != 0 {
-////			c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
-////			c.ServeJSON()
-////			return
-////		}
-////	}
-////
-////	//c.Data["Class_List"] = Device.Read_Class_All_1()
-////
-////	var cnt int64
-////	r_jsons.DeviceSensor_lite, cnt = Device.Read_DeviceSensor_ALL_T_sn(T_sn, page, page_z)
-////
-////	page_size := math.Ceil(float64(cnt) / float64(page_z))
-////	r_jsons.Page = int(page)
-////	r_jsons.Page_size = int(page_size)
-////	r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
-////	r_jsons.Num = int(cnt)
-////
-////	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
-////	c.ServeJSON()
-////	return
-////
-////}
-////
-//
-//func (c *GoodsOrderController) List_Post() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Ctx.Redirect(302, "Login")
-//		return
-//	}
-//	var id int64
-//	var err error
-//
-//	id, _ = c.GetInt64("id")
-//	T_orderid := c.GetString("T_orderid")
-//	T_outorderid := c.GetString("T_outorderid")
-//	T_sn := c.GetString("T_sn")
-//	T_receiving := c.GetString("T_receiving")
-//	T_start_Ut := c.GetString("T_start_Ut")
-//	T_end_Ut := c.GetString("T_end_Ut")
-//	T_start_Ut_T, _ := c.GetFloat("T_start_Ut_T")
-//	T_end_Ut_T, _ := c.GetFloat("T_end_Ut_T")
-//	T_text := c.GetString("T_text")
-//
-//	T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_start_Ut, time.Local)
-//	T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_end_Ut, time.Local)
-//	var_ := Function.GoodsOrder{
-//		T_uuid:       admin_r.Admin_uuid,
-//		T_orderid:    T_orderid,
-//		T_outorderid: T_outorderid,
-//		T_sn:         T_sn,
-//		T_receiving:  T_receiving,
-//		T_start_Ut:   T_start_Ut_,
-//		T_end_Ut:     T_end_Ut_,
-//		T_start_Ut_T: float32(T_start_Ut_T),
-//		T_end_Ut_T:   float32(T_end_Ut_T),
-//		T_text:       T_text,
-//		T_State:      1,
-//	}
-//
-//	if id > 0 {
-//		var_.Id = int(id)
-//		is := Function.Update_TGoodsOrder(var_, "T_orderid", "T_outorderid", "T_sn", "T_receiving", "T_start_Ut", "T_end_Ut", "T_start_Ut_T", "T_end_Ut_T", "T_text")
-//		if !is {
-//			c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//	} else {
-//		id, err = Function.Add_GoodsOrder(var_)
-//		if err != nil {
-//			c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-//	c.ServeJSON()
-//	return
-//
-//}
-//func (c *GoodsOrderController) GoodsOrder_Add() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	var id int64
-//	var err error
-//
-//	id, _ = c.GetInt64("T_id")
-//	T_orderid := c.GetString("T_orderid")
-//	T_outorderid := c.GetString("T_outorderid")
-//	T_sn := c.GetString("T_sn")
-//	T_receiving := c.GetString("T_receiving")
-//	T_time := c.GetString("T_time")
-//	T_text := c.GetString("T_text")
-//	T_time_s := strings.Split(T_time, "|")
-//	if len(T_time_s) != 2 {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "时间参数异常!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[0], time.Local)
-//	T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[1], time.Local)
-//	var_ := Function.GoodsOrder{
-//		T_uuid:       admin_r.Admin_uuid,
-//		T_orderid:    T_orderid,
-//		T_outorderid: T_outorderid,
-//		T_sn:         T_sn,
-//		T_receiving:  T_receiving,
-//		T_start_Ut:   T_start_Ut_,
-//		T_end_Ut:     T_end_Ut_,
-//		T_text:       T_text,
-//		T_State:      1,
-//	}
-//
-//	if id > 0 {
-//		var_.Id = int(id)
-//		is := Function.Update_TGoodsOrder(var_, "T_orderid", "T_outorderid", "T_sn", "T_receiving", "T_start_Ut", "T_end_Ut", "T_start_Ut_T", "T_end_Ut_T", "T_text")
-//		if !is {
-//			c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//	} else {
-//		id, err = Function.Add_GoodsOrder(var_)
-//		if err != nil {
-//			c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-//	c.ServeJSON()
-//	return
-//
-//}
-//func (c *GoodsOrderController) GoodsOrder_Edit() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	var id int64
-//	var err error
-//
-//	id, _ = c.GetInt64("T_id")
-//	T_orderid := c.GetString("T_orderid")
-//	T_outorderid := c.GetString("T_outorderid")
-//	T_sn := c.GetString("T_sn")
-//	T_receiving := c.GetString("T_receiving")
-//	T_time := c.GetString("T_time")
-//	T_text := c.GetString("T_text")
-//	T_time_s := strings.Split(T_time, "|")
-//	if len(T_time_s) != 2 {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "时间参数异常!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	println("T_time_s:", T_time_s)
-//	T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[0], time.Local)
-//	T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[1], time.Local)
-//	var_ := Function.GoodsOrder{
-//		T_uuid:       admin_r.Admin_uuid,
-//		T_orderid:    T_orderid,
-//		T_outorderid: T_outorderid,
-//		T_sn:         T_sn,
-//		T_receiving:  T_receiving,
-//		T_start_Ut:   T_start_Ut_,
-//		T_end_Ut:     T_end_Ut_,
-//		T_text:       T_text,
-//		T_State:      1,
-//	}
-//
-//	if id > 0 {
-//		var_.Id = int(id)
-//		is := Function.Update_TGoodsOrder(var_, "T_orderid", "T_outorderid", "T_sn", "T_receiving", "T_start_Ut", "T_end_Ut", "T_start_Ut_T", "T_end_Ut_T", "T_text")
-//		if !is {
-//			c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//	} else {
-//		id, err = Function.Add_GoodsOrder(var_)
-//		if err != nil {
-//			c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
-//			c.ServeJSON()
-//			return
-//		}
-//
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-//	c.ServeJSON()
-//	return
-//
-//}
-//
-//func (c *GoodsOrderController) GoodsOrder_Del() {
-//	// 验证登录
-//	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	Id, _ := c.GetInt("T_id")
-//	r := Function.Read_GoodsOrder_ById(Id)
-//
-//	if r.Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id !"}
-//		c.ServeJSON()
-//		return
-//	}
-//	if admin_r.Admin_uuid != r.T_uuid {
-//		c.Data["json"] = lib.JSONS{Code: 205, Msg: "你没有权限 !"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	r.T_State = 0
-//	Function.Update_TGoodsOrder(r, "T_State")
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-//	c.ServeJSON()
-//	return
-//
-//}
-//
-//func (c *GoodsOrderController) List_Del() {
-//	Id, _ := c.GetInt("Id")
-//	if Id > 0 {
-//		GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
-//		Function.Delete_GoodsOrder_ById(GoodsOrder_r)
-//	} else {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "e!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
-//	c.ServeJSON()
-//	return
-//
-//}
-//
-//// 列表 - 接口
-//func (c *GoodsOrderController) Data_PDF() {
-//	var err error
-//	// 验证登录
-//	b_, user_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	Id, _ := c.GetInt("Id")
-//	if Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id  e!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
-//	if GoodsOrder_r.Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id  e!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	Device_r, err := Device.Read_Device_ByT_sn(GoodsOrder_r.T_sn)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_sn Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	DeviceSensor_r := Device.Read_DeviceSensor_ALL_List_T_sn(GoodsOrder_r.T_sn)
-//	if len(DeviceSensor_r) == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 202, Msg: GoodsOrder_r.T_sn + "设备没有数据!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	var DeviceSensor_data []Device.DeviceData_
-//	DeviceSensor_data, _ = Device.Read_DeviceSensorData_By_T_snid_List(GoodsOrder_r.T_sn+","+strconv.Itoa(DeviceSensor_r[0].T_id), GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05"), GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"), 0, 9999)
-//
-//	pdf := &gopdf.GoPdf{}
-//	pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
-//	//err = GetFont(pdf, "LiberationSerif-Regular.ttf")
-//	//if err != nil {
-//	//	log.Fatalln(err)
-//	//}
-//	//err = pdf.SetFont("Ubuntu-L", "", 14)
-//	//if err != nil {
-//	//	log.Fatalln(err)
-//	//}
-//
-//	err = pdf.AddTTFFont("simsun", "static/fonts/三极行楷简体-粗.ttf")
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	err = pdf.SetFont("simsun", "", 24)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 205, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	pdf.SetGrayFill(0.5)
-//
-//	pdf.SetMargins(0, 20, 0, 20)
-//	pdf.AddPage()
-//
-//	//use path
-//	//pdf.Image("logo.png", 100, 50, &gopdf.Rect{W: 50, H: 50})
-//
-//	textw, _ := pdf.MeasureTextWidth(user_r.Admin_name)
-//	pdf.SetX((595 / 2) - (textw / 2))
-//	pdf.SetY(40)
-//	pdf.Text(user_r.Admin_name)
-//
-//	// 线
-//	pdf.SetLineWidth(2)
-//	pdf.SetLineType("dashed")
-//	pdf.Line(10, 60, 585, 60)
-//
-//	err = pdf.AddTTFFont("wts", "static/fonts/MiSans-Medium.ttf")
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 206, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	err = pdf.SetFont("wts", "", 10)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	//fmt.Sprintf(" %.1f ", v.T_t)
-//	//lib.RectFillColor(pdf, "历史数据["+Time_start+" / "+Time_end+"]", 14, 22, 80, 550, 40, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//
-//	// -------------
-//	x := 22.0
-//	w1 := 80.0
-//	w2 := 195.0
-//
-//	lib.RectFillColor(pdf, "订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, GoodsOrder_r.T_orderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	lib.RectFillColor(pdf, "出库订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, GoodsOrder_r.T_outorderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 195.0
-//
-//	lib.RectFillColor(pdf, "设备名称:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, Device_r.T_devName, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	lib.RectFillColor(pdf, "设备编号:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, Device_r.T_sn, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 240.0
-//	T_time := fmt.Sprintf("%s", GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05")+" - "+GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"))
-//	lib.RectFillColor(pdf, "送货时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_time, 12, x, 120, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_time = fmt.Sprintf("%s", GoodsOrder_r.CreateTime.Format("2006-01-02 15:04:05"))
-//	lib.RectFillColor(pdf, "订单时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_time, 12, x, 120, 150, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 195.0*2 + 80
-//	T_text := fmt.Sprintf("%s", GoodsOrder_r.T_receiving)
-//	lib.RectFillColor(pdf, "收货单位:", 12, x, 140, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_text, 12, x, 140, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	// -----------
-//	textw, _ = pdf.MeasureTextWidth("历史数据")
-//	pdf.SetX(20)
-//	pdf.SetY(210)
-//	pdf.Text("历史数据:")
-//
-//	// 数据展示--------------------------------
-//	var y float64 = 220
-//	x = 22.0
-//	w1 = 94.0
-//	w2 = 43.0
-//
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// 数据展示--------------------------------
-//
-//	y = 240
-//
-//	err = pdf.SetFont("wts", "", 8)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	nln := 0
-//	x = 22.0
-//	var T_t_l float32 = 100.0
-//	var T_t_u float32 = 0.0
-//	var T_t_v float32 = 0.0
-//	for n := 0; len(DeviceSensor_data) > n; n++ {
-//		// -计算温度
-//		if DeviceSensor_data[n].T_t < T_t_l {
-//			T_t_l = DeviceSensor_data[n].T_t
-//		}
-//		if DeviceSensor_data[n].T_t > T_t_u {
-//			T_t_u = DeviceSensor_data[n].T_t
-//		}
-//		T_t_v += DeviceSensor_data[n].T_t
-//
-//		//text := fmt.Sprintf(" %d ", i+1)
-//		var textH float64 = 25 // if text height is 25px.
-//		pdf.SetNewY(y, textH)
-//		y = pdf.GetY()
-//
-//		nln++
-//		if nln > 4 {
-//			nln = 1
-//			x = 22.0
-//			y += 18
-//		}
-//
-//		// ------------------
-//		T_t := fmt.Sprintf(" %.1f ", DeviceSensor_data[n].T_t)
-//		T_time = fmt.Sprintf("%s", DeviceSensor_data[n].T_time)
-//
-//		lib.RectFillColor(pdf, T_time, 10, x, y, w1, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//		x += w1
-//		lib.RectFillColor(pdf, T_t, 10, x, y, w2, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//		x += w2
-//
-//	}
-//
-//	err = pdf.SetFont("wts", "", 10)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	// 数据汇总--------------------------------
-//	y = 160
-//	x = 22.0
-//	w1 = 60.0
-//	w2 = 50.0
-//
-//	T_t := fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[len(DeviceSensor_data)-1].T_t)
-//	lib.RectFillColor(pdf, "起送温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[0].T_t)
-//	lib.RectFillColor(pdf, "送达温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", T_t_l)
-//	lib.RectFillColor(pdf, "最低温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", float32(T_t_v/float32(len(DeviceSensor_data)-1)))
-//	lib.RectFillColor(pdf, "平均温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", T_t_u)
-//	lib.RectFillColor(pdf, "最高温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	//----------------
-//	timeStr := "ofile/" + time.Now().Format("20060102150405") + ".pdf"
-//
-//	err = pdf.WritePdf(timeStr)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	// 上传 OSS
-//	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/"+timeStr, timeStr)
-//	if !is {
-//		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	//删除目录
-//	err = os.Remove(timeStr)
-//	if err != nil {
-//		fmt.Println(err)
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
-//	c.ServeJSON()
-//	return
-//
-//}
-//
-//// 列表 - 接口
-//func (c *GoodsOrderController) GoodsOrder_PDF() {
-//	var err error
-//	// 验证登录
-//	b_, user_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
-//	if !b_ {
-//		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	Id, _ := c.GetInt("T_id")
-//	if Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id  e!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
-//	if GoodsOrder_r.Id == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id  e!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	Device_r, err := Device.Read_Device_ByT_sn(GoodsOrder_r.T_sn)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_sn Err!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	DeviceSensor_r := Device.Read_DeviceSensor_ALL_List_T_sn(GoodsOrder_r.T_sn)
-//	if len(DeviceSensor_r) == 0 {
-//		c.Data["json"] = lib.JSONS{Code: 202, Msg: GoodsOrder_r.T_sn + "设备没有数据!"}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	var DeviceSensor_data []Device.DeviceData_
-//	DeviceSensor_data, _ = Device.Read_DeviceSensorData_By_T_snid_List(GoodsOrder_r.T_sn+","+strconv.Itoa(DeviceSensor_r[0].T_id), GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05"), GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"), 0, 9999)
-//
-//	pdf := &gopdf.GoPdf{}
-//	pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
-//	//err = GetFont(pdf, "LiberationSerif-Regular.ttf")
-//	//if err != nil {
-//	//	log.Fatalln(err)
-//	//}
-//	//err = pdf.SetFont("Ubuntu-L", "", 14)
-//	//if err != nil {
-//	//	log.Fatalln(err)
-//	//}
-//
-//	err = pdf.AddTTFFont("simsun", "static/fonts/三极行楷简体-粗.ttf")
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 204, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	err = pdf.SetFont("simsun", "", 24)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 205, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	pdf.SetGrayFill(0.5)
-//
-//	pdf.SetMargins(0, 20, 0, 20)
-//	pdf.AddPage()
-//
-//	//use path
-//	//pdf.Image("logo.png", 100, 50, &gopdf.Rect{W: 50, H: 50})
-//
-//	textw, _ := pdf.MeasureTextWidth(user_r.Admin_name)
-//	pdf.SetX((595 / 2) - (textw / 2))
-//	pdf.SetY(40)
-//	pdf.Text(user_r.Admin_name)
-//
-//	// 线
-//	pdf.SetLineWidth(2)
-//	pdf.SetLineType("dashed")
-//	pdf.Line(10, 60, 585, 60)
-//
-//	err = pdf.AddTTFFont("wts", "static/fonts/MiSans-Medium.ttf")
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 206, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	err = pdf.SetFont("wts", "", 10)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	//fmt.Sprintf(" %.1f ", v.T_t)
-//	//lib.RectFillColor(pdf, "历史数据["+Time_start+" / "+Time_end+"]", 14, 22, 80, 550, 40, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//
-//	// -------------
-//	x := 22.0
-//	w1 := 80.0
-//	w2 := 195.0
-//
-//	lib.RectFillColor(pdf, "订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, GoodsOrder_r.T_orderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	lib.RectFillColor(pdf, "出库订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, GoodsOrder_r.T_outorderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 195.0
-//
-//	lib.RectFillColor(pdf, "设备名称:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, Device_r.T_devName, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	lib.RectFillColor(pdf, "设备编号:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, Device_r.T_sn, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 240.0
-//	T_time := fmt.Sprintf("%s", GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05")+" - "+GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"))
-//	lib.RectFillColor(pdf, "送货时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_time, 12, x, 120, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_time = fmt.Sprintf("%s", GoodsOrder_r.CreateTime.Format("2006-01-02 15:04:05"))
-//	lib.RectFillColor(pdf, "订单时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_time, 12, x, 120, 150, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//
-//	// -------------
-//	x = 22.0
-//	w1 = 80.0
-//	w2 = 195.0*2 + 80
-//	T_text := fmt.Sprintf("%s", GoodsOrder_r.T_receiving)
-//	lib.RectFillColor(pdf, "收货单位:", 12, x, 140, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_text, 12, x, 140, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	// -----------
-//	textw, _ = pdf.MeasureTextWidth("历史数据")
-//	pdf.SetX(20)
-//	pdf.SetY(210)
-//	pdf.Text("历史数据:")
-//
-//	// 数据展示--------------------------------
-//	var y float64 = 220
-//	x = 22.0
-//	w1 = 94.0
-//	w2 = 43.0
-//
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//	// 数据展示--------------------------------
-//
-//	y = 240
-//
-//	err = pdf.SetFont("wts", "", 8)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	nln := 0
-//	x = 22.0
-//	var T_t_l float32 = 100.0
-//	var T_t_u float32 = 0.0
-//	var T_t_v float32 = 0.0
-//	for n := 0; len(DeviceSensor_data) > n; n++ {
-//		// -计算温度
-//		if DeviceSensor_data[n].T_t < T_t_l {
-//			T_t_l = DeviceSensor_data[n].T_t
-//		}
-//		if DeviceSensor_data[n].T_t > T_t_u {
-//			T_t_u = DeviceSensor_data[n].T_t
-//		}
-//		T_t_v += DeviceSensor_data[n].T_t
-//
-//		//text := fmt.Sprintf(" %d ", i+1)
-//		var textH float64 = 25 // if text height is 25px.
-//		pdf.SetNewY(y, textH)
-//		y = pdf.GetY()
-//
-//		nln++
-//		if nln > 4 {
-//			nln = 1
-//			x = 22.0
-//			y += 18
-//		}
-//
-//		// ------------------
-//		T_t := fmt.Sprintf(" %.1f ", DeviceSensor_data[n].T_t)
-//		T_time = fmt.Sprintf("%s", DeviceSensor_data[n].T_time)
-//
-//		lib.RectFillColor(pdf, T_time, 10, x, y, w1, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//		x += w1
-//		lib.RectFillColor(pdf, T_t, 10, x, y, w2, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//		x += w2
-//
-//	}
-//
-//	err = pdf.SetFont("wts", "", 10)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//	// 数据汇总--------------------------------
-//	y = 160
-//	x = 22.0
-//	w1 = 60.0
-//	w2 = 50.0
-//
-//	T_t := fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[len(DeviceSensor_data)-1].T_t)
-//	lib.RectFillColor(pdf, "起送温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[0].T_t)
-//	lib.RectFillColor(pdf, "送达温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", T_t_l)
-//	lib.RectFillColor(pdf, "最低温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", float32(T_t_v/float32(len(DeviceSensor_data)-1)))
-//	lib.RectFillColor(pdf, "平均温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	T_t = fmt.Sprintf(" %.1f℃ ", T_t_u)
-//	lib.RectFillColor(pdf, "最高温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w1
-//	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
-//	x += w2
-//
-//	//----------------
-//	timeStr := "ofile/" + time.Now().Format("20060102150405") + ".pdf"
-//
-//	err = pdf.WritePdf(timeStr)
-//	if err != nil {
-//		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
-//		c.ServeJSON()
-//		return
-//	}
-//
-//	// 上传 OSS
-//	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/"+timeStr, timeStr)
-//	if !is {
-//		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
-//		c.ServeJSON()
-//		return
-//	}
-//	//删除目录
-//	err = os.Remove(timeStr)
-//	if err != nil {
-//		fmt.Println(err)
-//	}
-//
-//	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
-//	c.ServeJSON()
-//	return
-//
-//}
+func (c *GoodsOrderController) GoodsOrder_List() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	type R_JSONS struct {
+		//必须的大写开头
+		Data      []Function.GoodsOrderR
+		Num       int64
+		Page      int
+		Page_size int
+	}
+
+	var r_jsons R_JSONS
+
+	page, _ := c.GetInt("page")
+	println(page)
+	if page < 1 {
+		page = 1
+	}
+	page_z, _ := c.GetInt("page_z")
+	if page_z < 1 {
+		page_z = conf.Page_size
+	}
+
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
+
+	Name := c.GetString("T_name")
+	c.Data["Name"] = Name
+
+	r_jsons.Data, r_jsons.Num = Function.Read_GoodsOrder_List(T_pid, page, page_z, Name)
+	r_jsons.Page = page
+	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
+	c.ServeJSON()
+	return
+}
+func (c *GoodsOrderController) GoodsOrder_Get() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Ctx.Redirect(302, "Login")
+		return
+	}
+
+	Id, _ := c.GetInt("T_id")
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
+	r := Function.Read_GoodsOrder_ById(Id)
+
+	if r.Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
+		c.ServeJSON()
+		return
+	}
+	if T_pid != r.T_pid {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
+		c.ServeJSON()
+		return
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Function.GoodsOrderToGoodsOrderR(r)}
+	c.ServeJSON()
+	return
+}
+
+func (c *GoodsOrderController) GoodsOrder_Add() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	var id int64
+	var err error
+
+	id, _ = c.GetInt64("T_id")
+	T_orderid := c.GetString("T_orderid")
+	T_outorderid := c.GetString("T_outorderid")
+	T_sn := c.GetString("T_sn")
+	T_receiving := c.GetString("T_receiving")
+	T_time := c.GetString("T_time")
+	T_text := c.GetString("T_text")
+	T_time_s := strings.Split(T_time, "|")
+	if len(T_time_s) != 2 {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "时间参数异常!"}
+		c.ServeJSON()
+		return
+	}
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
+
+	T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[0], time.Local)
+	T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[1], time.Local)
+	var_ := Function.GoodsOrder{
+		T_pid:        T_pid,
+		T_orderid:    T_orderid,
+		T_outorderid: T_outorderid,
+		T_sn:         T_sn,
+		T_receiving:  T_receiving,
+		T_start_Ut:   T_start_Ut_,
+		T_end_Ut:     T_end_Ut_,
+		T_text:       T_text,
+		T_State:      1,
+	}
+
+	if id > 0 {
+		var_.Id = int(id)
+		is := Function.Update_TGoodsOrder(var_, "T_orderid", "T_outorderid", "T_sn", "T_receiving", "T_start_Ut", "T_end_Ut", "T_start_Ut_T", "T_end_Ut_T", "T_text")
+		if !is {
+			c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
+			c.ServeJSON()
+			return
+		}
+	} else {
+		id, err = Function.Add_GoodsOrder(var_)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
+			c.ServeJSON()
+			return
+		}
+
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
+func (c *GoodsOrderController) GoodsOrder_Edit() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	var id int64
+	var err error
+
+	id, _ = c.GetInt64("T_id")
+	T_orderid := c.GetString("T_orderid")
+	T_outorderid := c.GetString("T_outorderid")
+	T_sn := c.GetString("T_sn")
+	T_receiving := c.GetString("T_receiving")
+	T_time := c.GetString("T_time")
+	T_text := c.GetString("T_text")
+	T_time_s := strings.Split(T_time, "|")
+	if len(T_time_s) != 2 {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "时间参数异常!"}
+		c.ServeJSON()
+		return
+	}
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
+	println("T_time_s:", T_time_s)
+	T_start_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[0], time.Local)
+	T_end_Ut_, err := time.ParseInLocation("2006-01-02 15:04:05", T_time_s[1], time.Local)
+	var_ := Function.GoodsOrder{
+		T_pid:        T_pid,
+		T_orderid:    T_orderid,
+		T_outorderid: T_outorderid,
+		T_sn:         T_sn,
+		T_receiving:  T_receiving,
+		T_start_Ut:   T_start_Ut_,
+		T_end_Ut:     T_end_Ut_,
+		T_text:       T_text,
+		T_State:      1,
+	}
+
+	if id > 0 {
+		var_.Id = int(id)
+		is := Function.Update_TGoodsOrder(var_, "T_orderid", "T_outorderid", "T_sn", "T_receiving", "T_start_Ut", "T_end_Ut", "T_start_Ut_T", "T_end_Ut_T", "T_text")
+		if !is {
+			c.Data["json"] = lib.JSONS{Code: 302, Msg: "修改失败!"}
+			c.ServeJSON()
+			return
+		}
+	} else {
+		id, err = Function.Add_GoodsOrder(var_)
+		if err != nil {
+			c.Data["json"] = lib.JSONS{Code: 301, Msg: "添加失败!"}
+			c.ServeJSON()
+			return
+		}
+
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
+
+func (c *GoodsOrderController) GoodsOrder_Del() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	Id, _ := c.GetInt("T_id")
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
+	}
+	r := Function.Read_GoodsOrder_ById(Id)
+
+	if r.Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
+		c.ServeJSON()
+		return
+	}
+	if T_pid != r.T_pid {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "没有权限!"}
+		c.ServeJSON()
+		return
+	}
+
+	r.T_State = 0
+	Function.Update_TGoodsOrder(r, "T_State")
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+
+}
+
+// 数据列表pdf
+func (c *GoodsOrderController) Data_PDF() {
+	var err error
+	// 验证登录
+	b_, user_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	Id, _ := c.GetInt("Id")
+	if Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id  e!"}
+		c.ServeJSON()
+		return
+	}
+
+	GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
+	if GoodsOrder_r.Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id  e!"}
+		c.ServeJSON()
+		return
+	}
+	Device_r, err := Device.Read_Device_ByT_sn(GoodsOrder_r.T_sn)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_sn Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	DeviceSensor_r := Device.Read_DeviceSensor_ALL_List_T_sn(GoodsOrder_r.T_sn)
+	if len(DeviceSensor_r) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: GoodsOrder_r.T_sn + "设备没有数据!"}
+		c.ServeJSON()
+		return
+	}
+
+	var DeviceSensor_data []Device.DeviceData_R
+	DeviceSensor_data, _ = Device.Read_DeviceData_By_T_snid_List(GoodsOrder_r.T_sn+","+strconv.Itoa(DeviceSensor_r[0].T_id), GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05"), GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"), 0, 9999)
+
+	pdf := &gopdf.GoPdf{}
+	pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
+	//err = GetFont(pdf, "LiberationSerif-Regular.ttf")
+	//if err != nil {
+	//	log.Fatalln(err)
+	//}
+	//err = pdf.SetFont("Ubuntu-L", "", 14)
+	//if err != nil {
+	//	log.Fatalln(err)
+	//}
+
+	err = pdf.AddTTFFont("simsun", "static/fonts/三极行楷简体-粗.ttf")
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 204, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	err = pdf.SetFont("simsun", "", 24)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 205, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+
+	pdf.SetGrayFill(0.5)
+
+	pdf.SetMargins(0, 20, 0, 20)
+	pdf.AddPage()
+
+	//use path
+	//pdf.Image("logo.png", 100, 50, &gopdf.Rect{W: 50, H: 50})
+
+	textw, _ := pdf.MeasureTextWidth(user_r.T_name)
+	pdf.SetX((595 / 2) - (textw / 2))
+	pdf.SetY(40)
+	pdf.Text(user_r.T_name)
+
+	// 线
+	pdf.SetLineWidth(2)
+	pdf.SetLineType("dashed")
+	pdf.Line(10, 60, 585, 60)
+
+	err = pdf.AddTTFFont("wts", "static/fonts/MiSans-Medium.ttf")
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 206, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	err = pdf.SetFont("wts", "", 10)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	//fmt.Sprintf(" %.1f ", v.T_t)
+	//lib.RectFillColor(pdf, "历史数据["+Time_start+" / "+Time_end+"]", 14, 22, 80, 550, 40, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+	// -------------
+	x := 22.0
+	w1 := 80.0
+	w2 := 195.0
+
+	lib.RectFillColor(pdf, "订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, GoodsOrder_r.T_orderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	lib.RectFillColor(pdf, "出库订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, GoodsOrder_r.T_outorderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 195.0
+
+	lib.RectFillColor(pdf, "设备名称:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, Device_r.T_devName, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	lib.RectFillColor(pdf, "设备编号:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, Device_r.T_sn, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 240.0
+	T_time := fmt.Sprintf("%s", GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05")+" - "+GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"))
+	lib.RectFillColor(pdf, "送货时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_time, 12, x, 120, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_time = fmt.Sprintf("%s", GoodsOrder_r.CreateTime.Format("2006-01-02 15:04:05"))
+	lib.RectFillColor(pdf, "订单时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_time, 12, x, 120, 150, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 195.0*2 + 80
+	T_text := fmt.Sprintf("%s", GoodsOrder_r.T_receiving)
+	lib.RectFillColor(pdf, "收货单位:", 12, x, 140, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_text, 12, x, 140, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	// -----------
+	textw, _ = pdf.MeasureTextWidth("历史数据")
+	pdf.SetX(20)
+	pdf.SetY(210)
+	pdf.Text("历史数据:")
+
+	// 数据展示--------------------------------
+	var y float64 = 220
+	x = 22.0
+	w1 = 94.0
+	w2 = 43.0
+
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// 数据展示--------------------------------
+
+	y = 240
+
+	err = pdf.SetFont("wts", "", 8)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	nln := 0
+	x = 22.0
+	var T_t_l float32 = 100.0
+	var T_t_u float32 = 0.0
+	var T_t_v float32 = 0.0
+	for n := 0; len(DeviceSensor_data) > n; n++ {
+		// -计算温度
+		if DeviceSensor_data[n].T_t < T_t_l {
+			T_t_l = DeviceSensor_data[n].T_t
+		}
+		if DeviceSensor_data[n].T_t > T_t_u {
+			T_t_u = DeviceSensor_data[n].T_t
+		}
+		T_t_v += DeviceSensor_data[n].T_t
+
+		//text := fmt.Sprintf(" %d ", i+1)
+		var textH float64 = 25 // if text height is 25px.
+		pdf.SetNewY(y, textH)
+		y = pdf.GetY()
+
+		nln++
+		if nln > 4 {
+			nln = 1
+			x = 22.0
+			y += 18
+		}
+
+		// ------------------
+		T_t := fmt.Sprintf(" %.1f ", DeviceSensor_data[n].T_t)
+		T_time = fmt.Sprintf("%s", DeviceSensor_data[n].T_time)
+
+		lib.RectFillColor(pdf, T_time, 10, x, y, w1, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+		x += w1
+		lib.RectFillColor(pdf, T_t, 10, x, y, w2, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+		x += w2
+
+	}
+
+	err = pdf.SetFont("wts", "", 10)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	// 数据汇总--------------------------------
+	y = 160
+	x = 22.0
+	w1 = 60.0
+	w2 = 50.0
+
+	T_t := fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[len(DeviceSensor_data)-1].T_t)
+	lib.RectFillColor(pdf, "起送温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[0].T_t)
+	lib.RectFillColor(pdf, "送达温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", T_t_l)
+	lib.RectFillColor(pdf, "最低温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", float32(T_t_v/float32(len(DeviceSensor_data)-1)))
+	lib.RectFillColor(pdf, "平均温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", T_t_u)
+	lib.RectFillColor(pdf, "最高温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	//----------------
+	timeStr := "ofile/" + time.Now().Format("20060102150405") + ".pdf"
+
+	err = pdf.WritePdf(timeStr)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+
+	// 上传 OSS
+	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/"+timeStr, timeStr)
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
+	//删除目录
+	err = os.Remove(timeStr)
+	if err != nil {
+		fmt.Println(err)
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
+	c.ServeJSON()
+	return
+
+}
+
+// 订单列表pdf
+func (c *GoodsOrderController) GoodsOrder_PDF() {
+	var err error
+	// 验证登录
+	b_, user_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+	Id, _ := c.GetInt("T_id")
+	if Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id  e!"}
+		c.ServeJSON()
+		return
+	}
+
+	GoodsOrder_r := Function.Read_GoodsOrder_ById(Id)
+	if GoodsOrder_r.Id == 0 {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "Id  e!"}
+		c.ServeJSON()
+		return
+	}
+	Device_r, err := Device.Read_Device_ByT_sn(GoodsOrder_r.T_sn)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_sn Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	DeviceSensor_r := Device.Read_DeviceSensor_ALL_List_T_sn(GoodsOrder_r.T_sn)
+	if len(DeviceSensor_r) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: GoodsOrder_r.T_sn + "设备没有数据!"}
+		c.ServeJSON()
+		return
+	}
+
+	var DeviceSensor_data []Device.DeviceData_R
+	DeviceSensor_data, _ = Device.Read_DeviceData_By_T_snid_List(GoodsOrder_r.T_sn+","+strconv.Itoa(DeviceSensor_r[0].T_id), GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05"), GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"), 0, 9999)
+
+	pdf := &gopdf.GoPdf{}
+	pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
+	//err = GetFont(pdf, "LiberationSerif-Regular.ttf")
+	//if err != nil {
+	//	log.Fatalln(err)
+	//}
+	//err = pdf.SetFont("Ubuntu-L", "", 14)
+	//if err != nil {
+	//	log.Fatalln(err)
+	//}
+
+	err = pdf.AddTTFFont("simsun", "static/fonts/三极行楷简体-粗.ttf")
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 204, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	err = pdf.SetFont("simsun", "", 24)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 205, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+
+	pdf.SetGrayFill(0.5)
+
+	pdf.SetMargins(0, 20, 0, 20)
+	pdf.AddPage()
+
+	//use path
+	//pdf.Image("logo.png", 100, 50, &gopdf.Rect{W: 50, H: 50})
+
+	textw, _ := pdf.MeasureTextWidth(user_r.T_name)
+	pdf.SetX((595 / 2) - (textw / 2))
+	pdf.SetY(40)
+	pdf.Text(user_r.T_name)
+
+	// 线
+	pdf.SetLineWidth(2)
+	pdf.SetLineType("dashed")
+	pdf.Line(10, 60, 585, 60)
+
+	err = pdf.AddTTFFont("wts", "static/fonts/MiSans-Medium.ttf")
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 206, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	err = pdf.SetFont("wts", "", 10)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	//fmt.Sprintf(" %.1f ", v.T_t)
+	//lib.RectFillColor(pdf, "历史数据["+Time_start+" / "+Time_end+"]", 14, 22, 80, 550, 40, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+	// -------------
+	x := 22.0
+	w1 := 80.0
+	w2 := 195.0
+
+	lib.RectFillColor(pdf, "订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, GoodsOrder_r.T_orderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	lib.RectFillColor(pdf, "出库订单号:", 12, x, 80, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, GoodsOrder_r.T_outorderid, 12, x, 80, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 195.0
+
+	lib.RectFillColor(pdf, "设备名称:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, Device_r.T_devName, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	lib.RectFillColor(pdf, "设备编号:", 12, x, 100, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, Device_r.T_sn, 12, x, 100, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 240.0
+	T_time := fmt.Sprintf("%s", GoodsOrder_r.T_start_Ut.Format("2006-01-02 15:04:05")+" - "+GoodsOrder_r.T_end_Ut.Format("2006-01-02 15:04:05"))
+	lib.RectFillColor(pdf, "送货时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_time, 12, x, 120, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_time = fmt.Sprintf("%s", GoodsOrder_r.CreateTime.Format("2006-01-02 15:04:05"))
+	lib.RectFillColor(pdf, "订单时间:", 12, x, 120, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_time, 12, x, 120, 150, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+
+	// -------------
+	x = 22.0
+	w1 = 80.0
+	w2 = 195.0*2 + 80
+	T_text := fmt.Sprintf("%s", GoodsOrder_r.T_receiving)
+	lib.RectFillColor(pdf, "收货单位:", 12, x, 140, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_text, 12, x, 140, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	// -----------
+	textw, _ = pdf.MeasureTextWidth("历史数据")
+	pdf.SetX(20)
+	pdf.SetY(210)
+	pdf.Text("历史数据:")
+
+	// 数据展示--------------------------------
+	var y float64 = 220
+	x = 22.0
+	w1 = 94.0
+	w2 = 43.0
+
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	lib.RectFillColor(pdf, "记录时间", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, "温度℃", 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+	// 数据展示--------------------------------
+
+	y = 240
+
+	err = pdf.SetFont("wts", "", 8)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	nln := 0
+	x = 22.0
+	var T_t_l float32 = 100.0
+	var T_t_u float32 = 0.0
+	var T_t_v float32 = 0.0
+	for n := 0; len(DeviceSensor_data) > n; n++ {
+		// -计算温度
+		if DeviceSensor_data[n].T_t < T_t_l {
+			T_t_l = DeviceSensor_data[n].T_t
+		}
+		if DeviceSensor_data[n].T_t > T_t_u {
+			T_t_u = DeviceSensor_data[n].T_t
+		}
+		T_t_v += DeviceSensor_data[n].T_t
+
+		//text := fmt.Sprintf(" %d ", i+1)
+		var textH float64 = 25 // if text height is 25px.
+		pdf.SetNewY(y, textH)
+		y = pdf.GetY()
+
+		nln++
+		if nln > 4 {
+			nln = 1
+			x = 22.0
+			y += 18
+		}
+
+		// ------------------
+		T_t := fmt.Sprintf(" %.1f ", DeviceSensor_data[n].T_t)
+		T_time = fmt.Sprintf("%s", DeviceSensor_data[n].T_time)
+
+		lib.RectFillColor(pdf, T_time, 10, x, y, w1, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+		x += w1
+		lib.RectFillColor(pdf, T_t, 10, x, y, w2, 18, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+		x += w2
+
+	}
+
+	err = pdf.SetFont("wts", "", 10)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+	// 数据汇总--------------------------------
+	y = 160
+	x = 22.0
+	w1 = 60.0
+	w2 = 50.0
+
+	T_t := fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[len(DeviceSensor_data)-1].T_t)
+	lib.RectFillColor(pdf, "起送温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", DeviceSensor_data[0].T_t)
+	lib.RectFillColor(pdf, "送达温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", T_t_l)
+	lib.RectFillColor(pdf, "最低温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", float32(T_t_v/float32(len(DeviceSensor_data)-1)))
+	lib.RectFillColor(pdf, "平均温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	T_t = fmt.Sprintf(" %.1f℃ ", T_t_u)
+	lib.RectFillColor(pdf, "最高温度", 10, x, y, w1, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w1
+	lib.RectFillColor(pdf, T_t, 10, x, y, w2, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
+	x += w2
+
+	//----------------
+	timeStr := "ofile/" + time.Now().Format("20060102150405") + ".pdf"
+
+	err = pdf.WritePdf(timeStr)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 207, Msg: "ok!", Data: err}
+		c.ServeJSON()
+		return
+	}
+
+	// 上传 OSS
+	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/"+timeStr, timeStr)
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
+	//删除目录
+	err = os.Remove(timeStr)
+	if err != nil {
+		fmt.Println(err)
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
+	c.ServeJSON()
+	return
+
+}

+ 3 - 3
controllers/User.go

@@ -226,9 +226,9 @@ func (c *UserController) User_Info() {
 		return
 	}
 
-	T_pid, _ := c.GetInt("T_pid")
-	if admin_r.T_pid > 0 {
-		T_pid = admin_r.T_pid
+	T_pid := admin_r.T_pid
+	if T_pid == 0 {
+		T_pid, _ = c.GetInt("T_pid")
 	}
 	type User_ struct {
 		T_uuid  string

+ 2 - 3
controllers/lib/lib.go

@@ -80,11 +80,10 @@ func Verification(GetCookie string, GetString string) (bool, Account.Admin) {
 	}
 	admin_r, err := Account.Read_Admin_ByUuid(tokey)
 	if err != nil {
-		is = false
 		return false, Account.Admin{}
 	}
 	log.Println("登录 Admin_name 为:", admin_r.T_name)
-	return is, admin_r
+	return true, admin_r
 }
 
 // 登录验证
@@ -356,7 +355,7 @@ func Random(min, max int) int {
 	return rand.Intn(max-min) + min
 }
 
-//取文本(字符串)中间
+// 取文本(字符串)中间
 func GetBetweenStr(str, start, end string) string {
 	n := strings.Index(str, start)
 	if n == -1 {

+ 5 - 5
models/Account/Admin.go

@@ -58,7 +58,7 @@ func AdminToAdmin_R(r Admin) (v Admin_R) {
 }
 
 func (t *Admin) TableName() string {
-	return "Admin" // 数据库名称   // ************** 替换 FormulaList **************
+	return "admin" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_Admin cache.Cache
@@ -80,7 +80,7 @@ func init() {
 }
 
 // ---------------- Redis -------------------
-//Redis_Set(m.T_sn,m) // Redis 更新缓存
+// Redis_Set(m.T_sn,m) // Redis 更新缓存
 func Redis_Admin_Set(r Admin) (err error) {
 	//json序列化
 	str, err := json.Marshal(r)
@@ -96,9 +96,9 @@ func Redis_Admin_Set(r Admin) (err error) {
 	return
 }
 
-//if r,is :=Redis_Get(T_sn);is{
-//return r,nil
-//}
+// if r,is :=Redis_Get(T_sn);is{
+// return r,nil
+// }
 func Redis_Admin_Get(key string) (r Admin, is bool) {
 	if redisCache_Admin.IsExist(key) {
 		//println("找到key:",key)

+ 1 - 1
models/Account/Company.go

@@ -41,7 +41,7 @@ func CompanyToCompany_R(r Company) (v Company_R) {
 }
 
 func (t *Company) TableName() string {
-	return "Company" // 数据库名称   // ************** 替换 FormulaList **************
+	return "company" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_Company cache.Cache

+ 2 - 2
models/Account/Menu.go

@@ -26,7 +26,7 @@ type Menu struct {
 }
 
 func (t *Menu) TableName() string {
-	return "Menu" // 数据库名称   // ************** 替换 FormulaList **************
+	return "menu" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 type API struct {
@@ -50,7 +50,7 @@ type Menu_R struct {
 	Children map[string]Menu_R
 }
 
-//var redisCache_Menu cache.Cache
+// var redisCache_Menu cache.Cache
 var redisCache_API cache.Cache
 
 func init() {

+ 1 - 1
models/Account/Power.go

@@ -27,7 +27,7 @@ type Power struct {
 }
 
 func (t *Power) TableName() string {
-	return "Power" // 数据库名称   // ************** 替换 FormulaList **************
+	return "power" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_Power cache.Cache

+ 1 - 1
models/Account/Tokey.go

@@ -16,7 +16,7 @@ func init() {
 	//orm.RegisterModel(new(Tokey))
 
 	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
-		"redisCache_Cold_User_Tokey", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
+		"redis_Cold_User_Tokey", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
 	fmt.Println(config)
 	var err error
 	redisCache_Tokey, err = cache.NewCache("redis", config)

+ 1 - 1
models/Account/Vpanel.go

@@ -48,7 +48,7 @@ func Vpanel_To_Vpanel_R(r Vpanel) (v Vpanel_R) {
 }
 
 func (t *Vpanel) TableName() string {
-	return "Vpanel" // 数据库名称   // ************** 替换 FormulaList **************
+	return "v_panel" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_Vpanel cache.Cache

+ 5 - 5
models/Company/CompanyClass.go

@@ -30,7 +30,7 @@ type CompanyClass_R struct {
 }
 
 func (t *CompanyClass) TableName() string {
-	return "DeviceClass" // 数据库名称   // ************** 替换 DesignClass **************
+	return "company_class" // 数据库名称   // ************** 替换 DesignClass **************
 }
 
 var redisCache_CompanyClass cache.Cache
@@ -51,7 +51,7 @@ func Redis_CompanyClass_Set(r CompanyClass) (err error) {
 		return
 	}
 
-	err = redisCache_CompanyNotice.Put(key, str, 2*time.Hour)
+	err = redisCache_CompanyClass.Put(key, str, 2*time.Hour)
 	if err != nil {
 		fmt.Println("set key:", key, ",value:", str, err)
 	}
@@ -63,9 +63,9 @@ func Redis_CompanyClass_Set(r CompanyClass) (err error) {
 // }
 func Redis_CompanyClass_Get(key string) (CompanyClass, bool) {
 	println("找到key:", key)
-	if redisCache_CompanyNotice.IsExist(key) {
+	if redisCache_CompanyClass.IsExist(key) {
 		//println("找到key:",key)
-		v := redisCache_CompanyNotice.Get(key)
+		v := redisCache_CompanyClass.Get(key)
 		var r CompanyClass
 		json.Unmarshal(v.([]byte), &r)
 
@@ -75,7 +75,7 @@ func Redis_CompanyClass_Get(key string) (CompanyClass, bool) {
 	return CompanyClass{}, false
 }
 func Redis_CompanyClass_DelK(key string) (err error) {
-	err = redisCache_CompanyNotice.Delete(key)
+	err = redisCache_CompanyClass.Delete(key)
 	return
 }
 

+ 1 - 1
models/Company/CompanyNotice.go

@@ -45,7 +45,7 @@ type CompanyNotice_R struct {
 }
 
 func (t *CompanyNotice) TableName() string {
-	return "CompanyNotice" // 数据库名称   // ************** 替换 DesignClass **************
+	return "company_notice" // 数据库名称   // ************** 替换 DesignClass **************
 }
 
 var redisCache_CompanyNotice cache.Cache

+ 3 - 3
models/Device/Device.go

@@ -21,8 +21,8 @@ type Device struct {
 	T_MSISDN          string    `orm:"size(256);null"`       // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
 	T_devName         string    `orm:"size(256);null"`       // 设备名称
 	T_protocol        int       `orm:"size(2);default(1)"`   // 冷链通讯协议 1 :1.0协议   2 :2.0协议    3 :3.0协议
-	T_VerifyTime      time.Time `orm:"type(timestamp);"`     // 验证时间
-	T_CalibrationTime time.Time `orm:"type(timestamp);"`     // 校准时间
+	T_VerifyTime      time.Time `orm:"type(timestamp);null"` // 验证时间
+	T_CalibrationTime time.Time `orm:"type(timestamp);null"` // 校准时间
 	T_ist             int       `orm:"size(2);default(1)"`   // 温度   1开启   2关闭
 	T_ish             int       `orm:"size(2);default(1)"`   // 湿度   1开启   2关闭
 
@@ -67,7 +67,7 @@ type Device_task struct {
 }
 
 func (t *Device) TableName() string {
-	return "Device" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_Device cache.Cache

+ 16 - 16
models/Device/DeviceData.go

@@ -17,7 +17,7 @@ import (
 )
 
 // 建表
-// var CREATEsql = "CREATE TABLE IF NOT EXISTS `Z_DeviceData_" + SN + " ( " +
+// var CREATEsql = "CREATE TABLE IF NOT EXISTS `z_device_data_" + SN + " ( " +
 var CREATEsql = " ( " +
 	"`t_id` int(6) NOT NULL," +
 	"`t_sp` int(6) NOT NULL," +
@@ -128,7 +128,7 @@ func RedisDeviceData_Get(key string) (r DeviceData_R, is bool) {
 // 创建数据库  Device.CREATE_DeviceData("")
 func CREATE_DeviceData(SN string) bool {
 
-	sql := "CREATE TABLE IF NOT EXISTS `Z_DeviceData_" + SN + "` " + CREATEsql
+	sql := "CREATE TABLE IF NOT EXISTS `z_device_data_" + SN + "` " + CREATEsql
 	o := orm.NewOrm()
 	_, err := o.Raw(sql).Exec()
 	if err != nil {
@@ -139,8 +139,8 @@ func CREATE_DeviceData(SN string) bool {
 
 func DELETE_DeviceDatar(SN string) bool {
 	timeStr := time.Now().Format("2006_01_02_15_04_05")
-	//sql := "DROP TABLE Z_DeviceData_" + SN
-	sql := "ALTER TABLE Z_DeviceData_" + SN + " RENAME TO " + "Z_DeviceData_" + SN + "_dle_" + timeStr + ";"
+	//sql := "DROP TABLE z_device_data_" + SN
+	sql := "ALTER TABLE z_device_data_" + SN + " RENAME TO " + "z_device_data_" + SN + "_dle_" + timeStr + ";"
 	logs.Println("DELETE_DeviceDatar:", sql)
 	o := orm.NewOrm()
 	_, err := o.Raw(sql).Exec()
@@ -180,7 +180,7 @@ func Add_DeviceData(SN string, v DeviceData_T) bool {
 	if time.Now().Unix()-v.T_time.Unix() >= 60*40 {
 		// 查看是否 有记录
 		var maps_z []orm2.ParamsList
-		sql_c := "SELECT COUNT(ID) FROM Z_DeviceData_" + SN + " WHERE t_time = '" + v.T_time.Format("2006-01-02 15:04:05") + "' AND t_id = " + strconv.Itoa(v.T_id)
+		sql_c := "SELECT COUNT(ID) FROM z_device_data_" + SN + " WHERE t_time = '" + v.T_time.Format("2006-01-02 15:04:05") + "' AND t_id = " + strconv.Itoa(v.T_id)
 		logs.Println("检查 超过时间,查询 数据库 SQL:", sql_c)
 		_, err := o.Raw(sql_c).ValuesList(&maps_z)
 		if err != nil {
@@ -195,7 +195,7 @@ func Add_DeviceData(SN string, v DeviceData_T) bool {
 	}
 
 	// 开始插入数据
-	sql := "INSERT INTO Z_DeviceData_" + SN + " ( `t_id`, `t_t`, `t_rh`, `t_site`, `t_time`) " +
+	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)
@@ -257,7 +257,7 @@ func Read_DeviceData_ById_List(SN string, T_id int, Time_start_ string, Time_end
 		sql_time += " t_time <= '" + Time_end_ + "' AND "
 	}
 
-	sql := "SELECT COUNT(ID) FROM Z_DeviceData_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
+	sql := "SELECT COUNT(ID) FROM z_device_data_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id)
 	fmt.Println(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
@@ -268,7 +268,7 @@ func Read_DeviceData_ById_List(SN string, T_id int, Time_start_ string, Time_end
 	}
 	//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_DeviceData_" + SN + " WHERE " + sql_time + " t_id = " + strconv.Itoa(T_id) + " ORDER BY t_time1 DESC "
+	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 "
 	if page_z != 9999 {
 		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
 	}
@@ -309,7 +309,7 @@ func Read_SqlRawL(T_SQL string, T_data []string) (string, []orm2.Params) {
 	return "", lists
 }
 
-func Read_V2_DeviceData_By_T_snid_List(T_snid string, Time_start_ string, Time_end_ string, page int, page_z int) ([]DeviceData_R, int64) {
+func Read_DeviceData_By_T_snid_List(T_snid string, Time_start_ string, Time_end_ string, page int, page_z int) ([]DeviceData_R, int64) {
 	T_snid_list := strings.Split(T_snid, "|")
 	var maps []DeviceData_R
 	var maps_num int64
@@ -355,8 +355,8 @@ func Read_DeviceData_ById_Year_List(SN string) []orm2.ParamsList {
 
 	var maps_z []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_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 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)
 	num, err := o.Raw(sql).ValuesList(&maps_z)
 	if err == nil && num > 0 {
@@ -374,8 +374,8 @@ func Read_DeviceData_ById_Month_List(SN string) []orm2.ParamsList {
 
 	time_x := currentTime.Format("2006-01") + "-00 00:00:00"
 
-	//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_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 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)
 	o.Raw(sql).ValuesList(&maps_z)
 
@@ -391,8 +391,8 @@ func Read_DeviceData_ById_Day_List(SN string) []orm2.ParamsList {
 
 	time_x := currentTime.Format("2006-01-02") + " 00:00:00"
 
-	//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_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 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)
 	o.Raw(sql).ValuesList(&maps_z)
 
@@ -411,7 +411,7 @@ func Read_DeviceData_List_GROUP_BY_t_time(SN string, Time_start_ string, Time_en
 		sql_time += " t_time >= '" + Time_start_ + "' AND " + " t_time <= '" + Time_end_ + "' "
 	}
 
-	sql := "SELECT DATE_FORMAT(t_time,'%Y-%c-%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-%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)
 	o.Raw(sql).ValuesList(&maps_z)
 	return maps_z

+ 0 - 71
models/Device/DeviceLogs.go

@@ -1,71 +0,0 @@
-package Device
-
-import (
-	"Cold_Api/conf"
-	"github.com/beego/beego/v2/adapter/orm"
-	"time"
-)
-
-type DeviceLogs struct {
-	Id       int    `orm:"column(ID);size(11);auto;pk"`
-	T_sn     string `orm:"size(256);null"`  //
-	Logs_Txt string `orm:"type(text);null"` // 详情
-
-	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now 每次 model 保存时都会对时间自动更新
-}
-
-func (t *DeviceLogs) TableName() string {
-	return "DeviceLogs" // 数据库名称   // ************** 替换 FormulaList **************
-}
-
-func init() {
-	//注册模型
-	orm.RegisterModel(new(DeviceLogs))
-}
-
-// 添加  System.Add_DeviceLogs("MqttServer","参数请求 [Rt_Parameter]","base")
-func Add_DeviceLogs(T_sn string, Logs_Txt string) {
-	o := orm.NewOrm()
-	m := DeviceLogs{T_sn: T_sn, Logs_Txt: Logs_Txt}
-	o.Insert(&m)
-}
-
-// 获取列表
-func Read_DeviceLogs_ALL(page int, T_sn string) (r []DeviceLogs, cnt int64) {
-
-	o := orm.NewOrm()
-	// 也可以直接使用 Model 结构体作为表名
-
-	qs := o.QueryTable(new(DeviceLogs))
-	var offset int64
-	if page <= 1 {
-		offset = 0
-	} else {
-		offset = int64((page - 1) * conf.Page_size)
-	}
-
-	qs.Limit(conf.Page_size, offset).Filter("T_sn", T_sn).OrderBy("-Id").All(&r)
-	cnt, _ = qs.Filter("T_sn", T_sn).Count()
-
-	return r, cnt
-}
-
-// 获取列表
-func Read_V2DeviceLogs_ALL(T_sn string, page int, page_z int) (r []DeviceLogs, cnt int64) {
-
-	o := orm.NewOrm()
-	// 也可以直接使用 Model 结构体作为表名
-
-	qs := o.QueryTable(new(DeviceLogs))
-	var offset int64
-	if page <= 1 {
-		offset = 0
-	} else {
-		offset = int64((page - 1) * conf.Page_size)
-	}
-
-	qs.Limit(conf.Page_size, offset).Filter("T_sn", T_sn).OrderBy("-Id").All(&r)
-	cnt, _ = qs.Filter("T_sn", T_sn).Count()
-
-	return r, cnt
-}

+ 3 - 4
models/Device/DeviceParameter.go

@@ -40,13 +40,12 @@ type DeviceParameter struct {
 }
 
 func (t *DeviceParameter) TableName() string {
-	return "DeviceParameter" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device_parameter" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {
 	//注册模型
 	orm.RegisterModel(new(DeviceParameter))
-	orm.Debug = true
 }
 
 // ---------------- 特殊方法 -------------------
@@ -98,7 +97,7 @@ func Update_DeviceParameter_(m DeviceParameter) (err error) {
 }
 func DELETE_DeviceParameter(SN string) bool {
 
-	sql := "DELETE FROM `culd`.`DeviceParameter` WHERE `t_sn` = '" + SN + "' "
+	sql := "DELETE FROM `cold`.`device_parameter` WHERE `t_sn` = '" + SN + "' "
 	o := orm.NewOrm()
 	_, err := o.Raw(sql).Exec()
 	if err != nil {
@@ -168,7 +167,7 @@ func Read_DeviceParameter_SN_T_SendState_0(T_sn string) (r []DeviceParameter) {
 func Read_DeviceParameter_SN_T_SendState_0_sql() (maps []orm2.ParamsList) {
 	o := orm.NewOrm()
 
-	sql := "SELECT DISTINCT t_sn FROM `culd`.`DeviceParameter` WHERE `t__send_state` = '0' AND `t__state` = '2'"
+	sql := "SELECT DISTINCT t_sn FROM `cold`.`device_parameter` WHERE `t__send_state` = '0' AND `t__state` = '2'"
 
 	fmt.Println(sql)
 	o.Raw(sql).ValuesList(&maps)

+ 2 - 2
models/Device/DeviceSensor.go

@@ -47,7 +47,7 @@ type DeviceSensor_Del struct {
 }
 
 func (t *DeviceSensor) TableName() string {
-	return "DeviceSensor" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device_sensor" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 // 模板
@@ -546,7 +546,7 @@ func Read_DeviceSensor_ALL_Class_Id(T_Class_id int) (r []DeviceSensor) {
 }
 func DELETE_DeviceSensor(SN string) bool {
 
-	sql := "DELETE FROM `culd`.`DeviceSensor` WHERE `t_sn` = '" + SN + "' "
+	sql := "DELETE FROM `cold`.`device_sensor` WHERE `t_sn` = '" + SN + "' "
 	o := orm.NewOrm()
 	_, err := o.Raw(sql).Exec()
 	if err != nil {

+ 2 - 2
models/Device/DeviceSensorParameter.go

@@ -92,7 +92,7 @@ func DeviceSensorParameterTo_DeviceSensorParameter_R(r DeviceSensorParameter) (t
 	return t
 }
 func (t *DeviceSensorParameter) TableName() string {
-	return "DeviceSensorParameter" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device_sensor_parameter" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 var redisCache_DeviceSensorParameter cache.Cache
@@ -208,7 +208,7 @@ func Update_DeviceSensorParameter(r DeviceSensorParameter, cols ...string) bool
 
 func DELETE_DeviceSensorParameter(SN string) bool {
 
-	sql := "DELETE FROM `culd`.`DeviceSensorParameter` WHERE `t_sn` = '" + SN + "' "
+	sql := "DELETE FROM `cold`.`device_sensor_parameter` WHERE `t_sn` = '" + SN + "' "
 	o := orm.NewOrm()
 	_, err := o.Raw(sql).Exec()
 	if err != nil {

+ 1 - 1
models/Device/DeviceSnOld.go

@@ -11,7 +11,7 @@ type DeviceSnOld struct {
 }
 
 func (t *DeviceSnOld) TableName() string {
-	return "DeviceSnOld" // 数据库名称   // ************** 替换 DesignClass **************
+	return "device_sn_old" // 数据库名称   // ************** 替换 DesignClass **************
 }
 
 func init() {

+ 1 - 1
models/Device/DeviceTask.go

@@ -23,7 +23,7 @@ type DeviceTask struct {
 }
 
 func (t *DeviceTask) TableName() string {
-	return "DeviceTask" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device_task" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {

+ 10 - 1
models/Device/DeviceType.go

@@ -17,11 +17,20 @@ type DeviceType struct {
 }
 
 func (t *DeviceType) TableName() string {
-	return "DeviceType" // 数据库名称   // ************** 替换 FormulaList **************
+	return "device_type" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {
 	//注册模型
 	orm.RegisterModel(new(DeviceType))
+}
+
+func Read_DeviceType_List_All() (r []DeviceType) {
+
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+	qs := o.QueryTable(new(DeviceType))
+	qs.Filter("T_State", 1).All(&r)
 
+	return r
 }

+ 4 - 34
models/Function/GoodsOrder.go

@@ -14,7 +14,7 @@ import (
 type GoodsOrder struct {
 	Id int `orm:"column(ID);size(11);auto;pk"`
 	//T_id   string `orm:"size(50);null"` // 订单唯一ID
-	T_uuid string `orm:"size(50);null"` // 用户
+	T_pid int `orm:"index;size(256);null"` // Account.Company 绑定公司
 
 	T_orderid    string `orm:"size(256);null"` // 订单号
 	T_outorderid string `orm:"size(256);null"` // 出库订单号
@@ -49,7 +49,7 @@ type GoodsOrderR struct {
 }
 
 func (t *GoodsOrder) TableName() string {
-	return "GoodsOrder" // 数据库名称   // ************** 替换 FormulaList **************
+	return "goods_order" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {
@@ -139,7 +139,7 @@ func Delete_GoodsOrder(m GoodsOrder) (err error) {
 }
 
 // 获取列表
-func Read_V2_GoodsOrder_List(Admin_uuid string, page int, page_z int, Name string) (t []GoodsOrderR, cnt int64) {
+func Read_GoodsOrder_List(T_pid int, page int, page_z int, Name string) (t []GoodsOrderR, cnt int64) {
 	o := orm.NewOrm()
 
 	// 也可以直接使用 Model 结构体作为表名
@@ -156,7 +156,7 @@ func Read_V2_GoodsOrder_List(Admin_uuid string, page int, page_z int, Name strin
 	}
 
 	cond := orm.NewCondition()
-	cond1 := cond.And("T_uuid", Admin_uuid).And("T_State", 1)
+	cond1 := cond.And("T_pid", T_pid).And("T_State", 1)
 
 	if len(Name) > 0 {
 		cond1 = cond.AndCond(cond1).AndCond(cond.Or("T_sn__icontains", Name).Or("T_orderid__icontains", Name).Or("T_outorderid__icontains", Name))
@@ -170,33 +170,3 @@ func Read_V2_GoodsOrder_List(Admin_uuid string, page int, page_z int, Name strin
 	}
 	return t, cnt
 }
-
-// 获取列表
-func Read_GoodsOrder_List(Admin_uuid string, page int, page_z int, Name string) (r []GoodsOrder, cnt int64) {
-	o := orm.NewOrm()
-
-	// 也可以直接使用 Model 结构体作为表名
-	qs := o.QueryTable(new(GoodsOrder))
-	var offset int64
-	if page_z == 0 {
-		page_z = conf.Page_size
-	}
-
-	if page <= 1 {
-		offset = 0
-	} else {
-		offset = int64((page - 1) * page_z)
-	}
-
-	cond := orm.NewCondition()
-	cond1 := cond.And("T_uuid", Admin_uuid).And("T_State", 1)
-
-	if len(Name) > 0 {
-		cond1 = cond.AndCond(cond1).AndCond(cond.Or("T_sn__icontains", Name).Or("T_orderid__icontains", Name).Or("T_outorderid__icontains", Name))
-	}
-
-	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("Id").All(&r)
-	cnt, _ = qs.SetCond((*orm2.Condition)(cond1)).Count()
-
-	return r, cnt
-}

+ 1 - 1
models/RawSql/RawSql.go

@@ -24,7 +24,7 @@ type RawSqlR struct {
 }
 
 func (t *RawSql) TableName() string {
-	return "RawSql" // 数据库名称   // ************** 替换 FormulaList **************
+	return "raw_sql" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {

+ 1 - 1
models/RawSql/SqlLogs.go

@@ -19,7 +19,7 @@ type SqlLogs struct {
 }
 
 func (t *SqlLogs) TableName() string {
-	return "SqlLogs" // 数据库名称   // ************** 替换 FormulaList **************
+	return "sql_logs" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {

+ 1 - 1
models/System/Logs.go

@@ -19,7 +19,7 @@ type Logs struct {
 }
 
 func (t *Logs) TableName() string {
-	return "Logs" // 数据库名称   // ************** 替换 FormulaList **************
+	return "logs" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {

+ 1 - 1
models/System/UserLogs.go

@@ -20,7 +20,7 @@ type UserLogs struct {
 }
 
 func (t *UserLogs) TableName() string {
-	return "UserLogs" // 数据库名称   // ************** 替换 FormulaList **************
+	return "user_logs" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {

+ 3 - 3
models/Warning/Warning.go

@@ -60,7 +60,7 @@ type Warning_R struct {
 }
 
 func (t *Warning) TableName() string {
-	return "Warning" // 数据库名称   // ************** 替换 FormulaList **************
+	return "warning" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {
@@ -286,7 +286,7 @@ func Read_Warning_Backups(T_pid int, T_year string, T_month string, T_sn string,
 	if len(T_month) == 1 {
 		T_month = "0" + T_month
 	}
-	Wtab := "Warning_" + T_year + "_" + T_month
+	Wtab := "warning_" + T_year + "_" + T_month
 
 	var offset int
 	if page_z == 0 {
@@ -390,7 +390,7 @@ func Read_Warning_ALL_T_Bind_TIME_1d_Count(T_pid int, T_sn string) int {
 	timeStr := now.Format("2006-01-02") + " 00:00:00"
 	timeStr1 := now.Format("2006-01-02") + " 23:59:59"
 
-	sql := "SELECT * FROM Warning WHERE t__title NOT LIKE '%恢复%' AND t__title NOT LIKE '%任务%' AND t__ut > '" + timeStr + "' AND t__ut < '" + timeStr1 + "' AND t_pid = '" + strconv.Itoa(T_pid) + "%' AND t_sn  LIKE '%" + T_sn + "%' group by t_sn"
+	sql := "SELECT * FROM warning WHERE t__title NOT LIKE '%恢复%' AND t__title NOT LIKE '%任务%' AND t__ut > '" + timeStr + "' AND t__ut < '" + timeStr1 + "' AND t_pid = '" + strconv.Itoa(T_pid) + "%' AND t_sn  LIKE '%" + T_sn + "%' group by t_sn"
 	fmt.Println(sql)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {

+ 3 - 3
models/Warning/WarningSand.go

@@ -37,7 +37,7 @@ type WarningSand struct {
 }
 
 func (t *WarningSand) TableName() string {
-	return "WarningSand" // 数据库名称   // ************** 替换 FormulaList **************
+	return "warning_sand" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 func init() {
@@ -115,7 +115,7 @@ func Read_WarningSand_ALL_T_sn_TIME_Count(T_sn string) (cnt int) {
 	now := time.Now()
 	timeStr := now.Format("2006-01-02") + " 00:00:00"
 
-	sql := "SELECT COUNT(ID) FROM WarningSand WHERE t__title NOT LIKE '%恢复%' AND t__ut > '" + timeStr + "' AND t_sn LIKE '%" + T_sn + "%' "
+	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)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {
@@ -139,7 +139,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 WarningSand WHERE t__title NOT LIKE '%恢复%' AND t__ut > '" + timeStr + "' AND t__bind LIKE '%" + T_Bind + "%' AND t_sn  LIKE '%" + T_sn + "%'"
+	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)
 	_, err := o.Raw(sql).ValuesList(&maps_z)
 	if err != nil {

+ 1 - 1
models/Warning/WarningType.go

@@ -16,7 +16,7 @@ type WarningType struct {
 }
 
 func (t *WarningType) TableName() string {
-	return "WarningType" // 数据库名称   // ************** 替换 FormulaList **************
+	return "warning_type" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
 //var redisCache_WarningType cache.Cache

+ 1 - 1
routers/filter.go

@@ -41,7 +41,7 @@ func FilterRBAC(ctx *context.Context) {
 		return
 	}
 
-	b_, admin := lib.Verification(ctx.GetCookie("User_tokey"), "")
+	b_, admin := lib.Verification(ctx.GetCookie("User_tokey"), ctx.Input.Query("User_tokey"))
 	if !b_ {
 		ctx.Output.JSON(lib.JSONS{Code: 201, Msg: "请重新登陆!"}, true, false)
 

+ 2 - 0
routers/router.go

@@ -16,6 +16,8 @@ func init() {
 	beego.Router(version+"/System/LogsClass", &controllers.LogsController{}, "*:LogsClass") // 获取未读消息
 	beego.Router(version+"/System/LogsList", &controllers.LogsController{}, "*:LogsList")   // 获取未读消息
 
+	// 字典数据
+	beego.Router(version+"/System/DictData", &controllers.DictDataController{}, "*:DictData_All") // 字典数据
 	//初始化配置 不鉴权的URL和只鉴权登录的URL
 	InitSetFilterUrl()
 	//过滤器,拦截所有请求

+ 2 - 4
routers/v3.go

@@ -10,7 +10,7 @@ func init() {
 	var version = conf.Version
 	//设备
 	beego.Router(version+"/Device/List", &controllers.DeviceController{}, "*:Device_List")                                        // 设备列表
-	beego.Router(version+"/Device/Add", &controllers.DeviceController{}, "*:Device_Post")                                         // 添加设备
+	beego.Router(version+"/Device/Add", &controllers.DeviceController{}, "*:Device_Add")                                          // 添加设备
 	beego.Router(version+"/Device/Del", &controllers.DeviceController{}, "*:Device_Del")                                          // 删除设备
 	beego.Router(version+"/Device/Edit", &controllers.DeviceController{}, "*:Device_Edit")                                        // 修改设备
 	beego.Router(version+"/Device/Parameter_List", &controllers.DeviceController{}, "*:Device_Parameter_List")                    // 设备参数列表
@@ -77,9 +77,6 @@ func init() {
 	// 添加设备数据 由mqtt服务添加
 	//beego.Router(version+"/Device/DeviceData_Add", &controllers.DeviceController{}, "*:DeviceData_Add") // 设置 设备参数
 
-	// 设备日志
-	beego.Router(version+"/Device/Log", &controllers.DeviceController{}, "*:DeviceLogs") // 谁呗日志
-
 	beego.Router(version+"/Data/Device_Sensor", &controllers.DataController{}, "*:Device_Sensor_Get")                       // 获取传感器
 	beego.Router(version+"/Data/Device_Sensor_List", &controllers.DataController{}, "*:Device_Sensor_List")                 // 传感器列表
 	beego.Router(version+"/Data/Device_Sensor_Data", &controllers.DataController{}, "*:Device_Sensor_Data")                 // 传感器数据
@@ -88,4 +85,5 @@ func init() {
 
 	beego.Router(version+"/Data/List", &controllers.DataController{}, "*:Device_Sensor_Data_More") // 传感器设备列表
 
+	beego.Router(version+"/DeviceType/All", &controllers.DeviceController{}, "*:DeviceType_All") // 传感器设备列表
 }