|
@@ -3,9 +3,11 @@ package controllers
|
|
|
import (
|
|
|
"Cold_Api/Nats/NatsServer"
|
|
|
"Cold_Api/conf"
|
|
|
+ "Cold_Api/models/Account"
|
|
|
+ "Cold_Api/models/Company"
|
|
|
+ "Cold_Api/models/Warning"
|
|
|
|
|
|
"Cold_Api/controllers/lib"
|
|
|
- "Cold_Api/models/Admin"
|
|
|
"Cold_Api/models/Device"
|
|
|
"Cold_Api/models/System"
|
|
|
"fmt"
|
|
@@ -32,7 +34,7 @@ func (c *DeviceController) Device_html() {
|
|
|
return
|
|
|
}
|
|
|
c.Data["Admin_r"] = admin_r
|
|
|
- c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ c.Data["Admin_Power"], _ = Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
|
|
|
var Device_lite_r []Device.R_Device
|
|
|
|
|
@@ -98,7 +100,7 @@ func (c *DeviceController) Device_Parameter_html() {
|
|
|
c.Ctx.Redirect(302, "Login")
|
|
|
return
|
|
|
}
|
|
|
- c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ c.Data["Admin_Power"], _ = Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
c.Data["Admin"] = admin_r
|
|
|
|
|
|
Sn := c.GetString("Sn")
|
|
@@ -152,7 +154,7 @@ func (c *DeviceController) DeviceSensor_List_html() {
|
|
|
c.Ctx.Redirect(302, "Login")
|
|
|
return
|
|
|
}
|
|
|
- c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ c.Data["Admin_Power"], _ = Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
|
|
|
Sn := c.GetString("Sn")
|
|
|
Id, _ := c.GetInt("Id")
|
|
@@ -187,7 +189,7 @@ func (c *DeviceController) DeviceSensor_v2_Parameter_List() {
|
|
|
Id, _ := c.GetInt("T_id")
|
|
|
|
|
|
//c.Data["DeviceSensor"], _ = Device.Read_DeviceSensor_ByTsn_Tid(Sn, Id)
|
|
|
- DeviceSensorParameter_lite := Device.Read_DeviceSensorParameter_List(Sn, Id)
|
|
|
+ DeviceSensorParameter_lite := Device.Read_V2DeviceSensorParameter_List(Sn, Id, 2, 10)
|
|
|
if len(DeviceSensorParameter_lite) == 0 {
|
|
|
NatsServer.Read_DeviceSensorParameter(Sn)
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "未同步参数,请检查设备是否正常!"}
|
|
@@ -323,7 +325,8 @@ func (c *DeviceController) DeviceSensor_Edit() {
|
|
|
// 验证登录
|
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
|
if !b_ {
|
|
|
- c.Ctx.Redirect(302, "Login")
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey!"}
|
|
|
+ c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -332,7 +335,7 @@ func (c *DeviceController) DeviceSensor_Edit() {
|
|
|
|
|
|
DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 201, Msg: "信息错误!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -673,7 +676,7 @@ func (c *DeviceController) Device_v2_List() {
|
|
|
}
|
|
|
|
|
|
if len(c.GetString("User_uuid")) > 1 {
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("User_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("User_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -879,7 +882,7 @@ func (c *DeviceController) Pu_DeviceParameter() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ Admin_Power_, _ := Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
if Admin_Power_.Power_Device_Parameter_e == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
|
|
|
c.ServeJSON()
|
|
@@ -965,7 +968,7 @@ func (c *DeviceController) Device_v2_Parameter_Pu() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ Admin_Power_, _ := Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
if Admin_Power_.Power_Device_Parameter_e == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
|
|
|
c.ServeJSON()
|
|
@@ -1084,7 +1087,36 @@ func (c *DeviceController) Device_Edit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 222, Msg: "ok!"}
|
|
|
+ T_VerifyTime := c.GetString("T_VerifyTime")
|
|
|
+ if len(T_VerifyTime) > 5 {
|
|
|
+ stamp, err := time.ParseInLocation("2006-01-02 15:04:05", T_VerifyTime, time.Local)
|
|
|
+ if err == nil {
|
|
|
+ Device_r.T_VerifyTime = stamp
|
|
|
+ Device.Update_Device(Device_r, "T_VerifyTime")
|
|
|
+ System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "验证时间操作", "验证时间:"+T_VerifyTime)
|
|
|
+ } else {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "时间解析错误!" + T_VerifyTime}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ T_CalibrationTime := c.GetString("T_CalibrationTime")
|
|
|
+ if len(T_CalibrationTime) > 5 {
|
|
|
+ stamp, err := time.ParseInLocation("2006-01-02 15:04:05", T_CalibrationTime, time.Local)
|
|
|
+ if err == nil {
|
|
|
+ Device_r.T_CalibrationTime = stamp
|
|
|
+ Device.Update_Device(Device_r, "T_CalibrationTime")
|
|
|
+ System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "校准时间操作", "校准时间:"+T_CalibrationTime)
|
|
|
+ } else {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 204, Msg: "时间解析错误!" + T_CalibrationTime}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
|
|
@@ -1195,7 +1227,7 @@ func (c *DeviceController) Pu_DeviceParameter_Sensor() {
|
|
|
T_free, _ := c.GetInt("T_free")
|
|
|
|
|
|
// 权限 过滤
|
|
|
- Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ Admin_Power_, _ := Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
if Admin_Power_.Power_DeviceSensor_Parameter_e == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
|
|
|
c.ServeJSON()
|
|
@@ -1278,7 +1310,7 @@ func (c *DeviceController) DeviceSensor_v2_Parameter_Pu() {
|
|
|
T_hpreu, _ := c.GetFloat("T_hpreu")
|
|
|
|
|
|
// 权限 过滤
|
|
|
- Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ Admin_Power_, _ := Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
if Admin_Power_.Power_DeviceSensor_Parameter_e == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
|
|
|
c.ServeJSON()
|
|
@@ -1432,7 +1464,7 @@ func (c *DeviceController) DeviceWarning_List_html() {
|
|
|
//}
|
|
|
|
|
|
var cnt int64
|
|
|
- DeviceWarning_List, cnt := Device.Read_DeviceWarning_1(admin_r, page, "", T_Name, Time_start, Time_end)
|
|
|
+ DeviceWarning_List, cnt := Warning.Read_DeviceWarning_1(admin_r, page, "", T_Name, Time_start, Time_end)
|
|
|
|
|
|
//for i, v := range DeviceWarning_List {
|
|
|
// DeviceWarning_List[i].T_State = 0
|
|
@@ -1463,7 +1495,7 @@ func (c *DeviceController) DeviceWarning_List() {
|
|
|
|
|
|
type R_JSONS struct {
|
|
|
//必须的大写开头
|
|
|
- DeviceWarning []Device.DeviceWarning
|
|
|
+ DeviceWarning []Warning.DeviceWarning
|
|
|
//DeviceWarningclass []Device.DeviceWarningList
|
|
|
Num int
|
|
|
Page int
|
|
@@ -1491,7 +1523,7 @@ func (c *DeviceController) DeviceWarning_List() {
|
|
|
//}
|
|
|
|
|
|
var cnt int64
|
|
|
- r_jsons.DeviceWarning, cnt = Device.Read_DeviceWarning_1(admin_r, page, T_sn, T_Name, Time_start, Time_end)
|
|
|
+ r_jsons.DeviceWarning, cnt = Warning.Read_DeviceWarning_1(admin_r, page, T_sn, T_Name, Time_start, Time_end)
|
|
|
|
|
|
page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
|
|
|
r_jsons.Page = int(page)
|
|
@@ -1516,7 +1548,7 @@ func (c *DeviceController) V2_DeviceWarning_List() {
|
|
|
|
|
|
type R_JSONS struct {
|
|
|
//必须的大写开头
|
|
|
- Data []Device.DeviceWarning
|
|
|
+ Data []Warning.DeviceWarning_R
|
|
|
Num int64
|
|
|
Page int
|
|
|
Page_size int
|
|
@@ -1540,13 +1572,17 @@ func (c *DeviceController) V2_DeviceWarning_List() {
|
|
|
Time_end := c.GetString("Time_end")
|
|
|
T_handle, _ := c.GetInt("T_handle")
|
|
|
|
|
|
- //r_jsons.DeviceWarningclass = Device.Read_DeviceWarningList_All_1()
|
|
|
- //T_Title := ""
|
|
|
- //if Class_1 > 0 {
|
|
|
- // T_Title = Device.Read_DeviceWarningList_ById(Class_1).T_name
|
|
|
- //}
|
|
|
+ T_year, _ := c.GetInt("T_year")
|
|
|
+ T_month, _ := c.GetInt("T_month")
|
|
|
+
|
|
|
+ if T_year > 0 && T_month > 0 {
|
|
|
+ // 获取备份
|
|
|
+ r_jsons.Data, r_jsons.Num = Warning.Read_DeviceWarning_Backups(admin_r, strconv.Itoa(T_year), strconv.Itoa(T_month), T_sn, T_id, T_title, T_handle, Time_start, Time_end, page, page_z)
|
|
|
+ } else {
|
|
|
+ // 获取最新
|
|
|
+ r_jsons.Data, r_jsons.Num = Warning.Read_DeviceWarning(admin_r, T_sn, T_id, T_title, T_handle, Time_start, Time_end, page, page_z)
|
|
|
+ }
|
|
|
|
|
|
- r_jsons.Data, r_jsons.Num = Device.Read_DeviceWarning(admin_r, T_sn, T_id, T_title, T_handle, 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)))
|
|
|
|
|
@@ -1583,7 +1619,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
|
|
|
// T_Title = Device.Read_DeviceWarningList_ById(Class_1).T_name
|
|
|
//}
|
|
|
|
|
|
- Device_data, _ := Device.Read_DeviceWarning_1(admin_r, 9999, "", T_Name, Time_start, Time_end)
|
|
|
+ Device_data, _ := Warning.Read_DeviceWarning_1(admin_r, 9999, "", T_Name, Time_start, Time_end)
|
|
|
|
|
|
f := excelize.NewFile() // 设置单元格的值
|
|
|
// 这里设置表头
|
|
@@ -1667,7 +1703,7 @@ func (c *DeviceController) V2_DeviceWarning_Data_Excel() {
|
|
|
Time_end := c.GetString("Time_end")
|
|
|
T_handle, _ := c.GetInt("T_handle")
|
|
|
|
|
|
- Device_data, _ := Device.Read_DeviceWarning(admin_r, T_sn, T_id, T_title, T_handle, Time_start, Time_end, 0, 9999)
|
|
|
+ Device_data, _ := Warning.Read_DeviceWarning(admin_r, T_sn, T_id, T_title, T_handle, Time_start, Time_end, 0, 9999)
|
|
|
|
|
|
f := excelize.NewFile() // 设置单元格的值
|
|
|
// 这里设置表头
|
|
@@ -1707,7 +1743,7 @@ func (c *DeviceController) V2_DeviceWarning_Data_Excel() {
|
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_Remark)
|
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.T_Ut)
|
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), v.T_Text)
|
|
|
- f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.UpdateTime)
|
|
|
+ f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.CreateTime)
|
|
|
|
|
|
}
|
|
|
timeStr := time.Now().Format("20060102150405")
|
|
@@ -1735,7 +1771,7 @@ func (c *DeviceController) V2_DeviceWarning_Data_Excel() {
|
|
|
|
|
|
func (c *DeviceController) DeviceWarning_() {
|
|
|
id, _ := c.GetInt("id")
|
|
|
- c.Data["T"] = Device.Read_DeviceWarning_ById(id)
|
|
|
+ c.Data["T"] = Warning.Read_DeviceWarning_ById(id)
|
|
|
c.Data["id"] = id
|
|
|
|
|
|
c.TplName = "Device/DeviceWarning-.html"
|
|
@@ -1743,7 +1779,7 @@ func (c *DeviceController) DeviceWarning_() {
|
|
|
func (c *DeviceController) DeviceWarning_log() {
|
|
|
id, _ := c.GetInt("id")
|
|
|
|
|
|
- T_Log := Device.Read_DeviceWarning_ById(id).T_Log
|
|
|
+ T_Log := Warning.Read_DeviceWarning_ById(id).T_Log
|
|
|
|
|
|
T_Log = strings.Replace(T_Log, "\n", "<hr>", -1)
|
|
|
|
|
@@ -1760,9 +1796,9 @@ func (c *DeviceController) V2_DeviceWarning_Get() {
|
|
|
}
|
|
|
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
- T := Device.Read_DeviceWarning_ById(id)
|
|
|
+ T := Warning.Read_DeviceWarning_ById(id)
|
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.DeviceWarningToDeviceWarning_R(T)}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.DeviceWarningToDeviceWarning_R(T)}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1782,12 +1818,12 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
|
|
|
Id, _ := c.GetInt("Id")
|
|
|
T_Text := c.GetString("T_Text")
|
|
|
- t_c := Device.DeviceWarning{
|
|
|
+ t_c := Warning.DeviceWarning{
|
|
|
Id: Id,
|
|
|
T_Text: T_Text,
|
|
|
}
|
|
|
|
|
|
- Device.Update_DeviceWarning_ById(t_c)
|
|
|
+ Warning.Update_DeviceWarning_ById(t_c)
|
|
|
|
|
|
System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警处理操作", strconv.Itoa(Id)+"->"+T_Text)
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
@@ -1806,16 +1842,16 @@ func (c *DeviceController) V2_DeviceWarning_Post() {
|
|
|
Id, _ := c.GetInt("T_id")
|
|
|
T_Text := c.GetString("T_Text")
|
|
|
|
|
|
- T := Device.Read_DeviceWarning_ById(Id)
|
|
|
+ T := Warning.Read_DeviceWarning_ById(Id)
|
|
|
if T.Id == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
T.T_Text = T_Text
|
|
|
- T.T_State = 2
|
|
|
+ T.T_State = 1
|
|
|
|
|
|
- Device.Update_DeviceWarning(T, "T_Text", "T_State")
|
|
|
+ Warning.Update_DeviceWarning(T, "T_Text", "T_State")
|
|
|
|
|
|
System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警处理操作", strconv.Itoa(Id)+"->"+T_Text)
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
@@ -1831,11 +1867,11 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
}
|
|
|
|
|
|
Id, _ := c.GetInt("Id")
|
|
|
- t_c := Device.DeviceWarning{
|
|
|
+ t_c := Warning.DeviceWarning{
|
|
|
Id: Id,
|
|
|
}
|
|
|
|
|
|
- Device.Update_DeviceWarning_Delete(t_c)
|
|
|
+ Warning.Update_DeviceWarning_Delete(t_c)
|
|
|
|
|
|
System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警删除操作", strconv.Itoa(Id))
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
@@ -1852,7 +1888,7 @@ func (c *DeviceController) V2_DeviceWarning_Del() {
|
|
|
|
|
|
Id, _ := c.GetInt("T_id")
|
|
|
|
|
|
- T := Device.Read_DeviceWarning_ById(Id)
|
|
|
+ T := Warning.Read_DeviceWarning_ById(Id)
|
|
|
if T.Id == 0 {
|
|
|
c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -1860,7 +1896,7 @@ func (c *DeviceController) V2_DeviceWarning_Del() {
|
|
|
}
|
|
|
|
|
|
T.T_State = 0
|
|
|
- Device.Update_DeviceWarning(T, "T_State")
|
|
|
+ Warning.Update_DeviceWarning(T, "T_State")
|
|
|
|
|
|
System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警删除操作", strconv.Itoa(Id))
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
@@ -1876,7 +1912,7 @@ func (c *DeviceController) DeviceBind_html() {
|
|
|
c.Ctx.Redirect(302, "Login")
|
|
|
return
|
|
|
}
|
|
|
- c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ c.Data["Admin_Power"], _ = Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
page, _ := c.GetInt("page")
|
|
|
println(page)
|
|
|
if page < 1 {
|
|
@@ -1886,14 +1922,14 @@ func (c *DeviceController) DeviceBind_html() {
|
|
|
Name := c.GetString("Name")
|
|
|
c.Data["Name"] = Name
|
|
|
|
|
|
- c.Data["Power_List"] = Admin.Read_Power_List_ALL_Power_Administration(0)
|
|
|
- Adminpower, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
+ c.Data["Power_List"] = Account.Read_Power_List_ALL_Power_Administration(0)
|
|
|
+ Adminpower, _ := Account.Read_AdminPower_ById(admin_r.Admin_power)
|
|
|
var cnt int64
|
|
|
if Adminpower.Power_User_r != 1 {
|
|
|
c.Ctx.Redirect(302, "Login")
|
|
|
return
|
|
|
}
|
|
|
- c.Data["List"], cnt = Admin.Read_Admin_List_ALL_User(page, Name, admin_r.Id)
|
|
|
+ c.Data["List"], cnt = Account.Read_Admin_List_ALL_User(page, Name, admin_r.Id)
|
|
|
|
|
|
fmt.Println("cnt:", cnt)
|
|
|
page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
|
|
@@ -1914,7 +1950,7 @@ func (c *DeviceController) DeviceBind_List() {
|
|
|
return
|
|
|
}
|
|
|
if len(c.GetString("Admin_uuid")) > 1 {
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -1983,7 +2019,7 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
|
|
|
return
|
|
|
}
|
|
|
if len(c.GetString("Admin_uuid")) > 1 {
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2075,7 +2111,7 @@ func (c *DeviceController) DeviceBind_Add_All() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2114,7 +2150,7 @@ func (c *DeviceController) DeviceBind_Add() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2158,7 +2194,7 @@ func (c *DeviceController) V2_DeviceBind_Add() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("T_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("T_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2202,7 +2238,7 @@ func (c *DeviceController) DeviceBind_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2246,7 +2282,7 @@ func (c *DeviceController) V2_DeviceBind_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("T_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("T_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2360,7 +2396,7 @@ func (c *DeviceController) DeviceClass_() {
|
|
|
return
|
|
|
}
|
|
|
id, _ := c.GetInt("id")
|
|
|
- c.Data["T"], _ = Device.Read_Class_ById(id)
|
|
|
+ c.Data["T"], _ = Company.Read_Class_ById(id)
|
|
|
c.Data["id"] = id
|
|
|
c.Data["Admin_r"] = admin_r
|
|
|
c.TplName = "Device/DeviceClass-.html"
|
|
@@ -2376,7 +2412,7 @@ func (c *DeviceController) V2_Class_Get() {
|
|
|
}
|
|
|
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
- T, err := Device.Read_Class_ById(id)
|
|
|
+ T, err := Company.Read_Class_ById(id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2413,16 +2449,15 @@ func (c *DeviceController) V2_Class_Get() {
|
|
|
r_jsons.T_Notice_mailbox = T.T_Notice_mailbox
|
|
|
r_jsons.T_Notice_mechanism = T.T_Notice_mechanism
|
|
|
|
|
|
- // 测试环境!!!!!!!!!!!!!!!!!!!
|
|
|
- //T_calss_id_str, _ := NatsServer.Wx_GenerateQRCode("-|" + lib.AesEncryptCBC(strconv.Itoa(T.Id), "0123456789012345") + "|- @宝智达 微信公众号通知")
|
|
|
- //if len(T_calss_id_str) > 0 {
|
|
|
- // r_jsons.T_QRCode = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
|
|
|
- //}
|
|
|
- //
|
|
|
- //T_calss_id_str, _ = NatsServer.Wx_GenerateQRCode2("-|" + lib.AesEncryptCBC(strconv.Itoa(T.Id), "0123456789012345") + "|- @宝智达 微信公众号通知")
|
|
|
- //if len(T_calss_id_str) > 0 {
|
|
|
- // r_jsons.T_QRCode2 = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
|
|
|
- //}
|
|
|
+ T_calss_id_str, _ := NatsServer.Wx_GenerateQRCode("-|" + lib.AesEncryptCBC(strconv.Itoa(T.Id), "0123456789012345") + "|- @宝智达 微信公众号通知")
|
|
|
+ if len(T_calss_id_str) > 0 {
|
|
|
+ r_jsons.T_QRCode = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
|
|
|
+ }
|
|
|
+
|
|
|
+ T_calss_id_str, _ = NatsServer.Wx_GenerateQRCode2("-|" + lib.AesEncryptCBC(strconv.Itoa(T.Id), "0123456789012345") + "|- @宝智达 微信公众号通知")
|
|
|
+ if len(T_calss_id_str) > 0 {
|
|
|
+ r_jsons.T_QRCode2 = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
|
|
|
+ }
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
c.ServeJSON()
|
|
@@ -2463,11 +2498,11 @@ func (c *DeviceController) DeviceClass_Post() {
|
|
|
t_c.T_Notice_phone = ""
|
|
|
t_c.T_Notice_message = ""
|
|
|
t_c.T_Notice_mailbox = ""
|
|
|
- t_c.T_Notice_mechanism = Device.Read_DeviceWarningList_All_T_Notice_mechanism()
|
|
|
- Device.Add_Class(t_c)
|
|
|
+ t_c.T_Notice_mechanism = Warning.Read_DeviceWarningList_All_T_Notice_mechanism()
|
|
|
+ Company.Add_Class(t_c)
|
|
|
} else {
|
|
|
t_c.T_uuid = admin_r.Admin_uuid
|
|
|
- Device.Update_Class_ById(t_c)
|
|
|
+ Company.Update_Class_ById(t_c)
|
|
|
}
|
|
|
System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "分类操作", t_c)
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
@@ -2488,16 +2523,16 @@ func (c *DeviceController) V2_Class_Add() {
|
|
|
t_c := Device.DeviceClass{
|
|
|
T_uuid: admin_r.Admin_uuid,
|
|
|
T_name: T_name,
|
|
|
- T_Notice_mechanism: Device.Read_DeviceWarningList_All_T_Notice_mechanism(),
|
|
|
+ T_Notice_mechanism: Warning.Read_DeviceWarningList_All_T_Notice_mechanism(),
|
|
|
T_State: 1,
|
|
|
}
|
|
|
|
|
|
- Device.Add_Class(t_c)
|
|
|
+ Company.Add_Class(t_c)
|
|
|
System.Add_UserLogs_T(admin_r.Admin_uuid, "分类管理", "分类添加", t_c)
|
|
|
|
|
|
// 同步分类
|
|
|
go func() {
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
if v.Admin_power > 6 {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
@@ -2529,7 +2564,7 @@ func (c *DeviceController) V2_Class_Edit() {
|
|
|
T_Notice_mailbox := c.GetString("T_Notice_mailbox")
|
|
|
T_Notice_mechanism := c.GetString("T_Notice_mechanism")
|
|
|
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(Id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(Id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2564,13 +2599,13 @@ func (c *DeviceController) V2_Class_Edit() {
|
|
|
R_DeviceClass.T_Notice_mechanism = T_Notice_mechanism
|
|
|
}
|
|
|
|
|
|
- Device.Update_Class(R_DeviceClass, "T_name", "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism")
|
|
|
+ Company.Update_Class(R_DeviceClass, "T_name", "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism")
|
|
|
|
|
|
System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "分类操作", R_DeviceClass)
|
|
|
|
|
|
// 同步分类
|
|
|
go func() {
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
if v.Admin_power > 6 {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
@@ -2593,7 +2628,7 @@ func (c *DeviceController) DeviceWarningList_T_Tips() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.Read_DeviceWarningList_All_T_Notice_mechanism()}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.Read_DeviceWarningList_All_T_Notice_mechanism()}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -2609,7 +2644,7 @@ func (c *DeviceController) DeviceClass_Del() {
|
|
|
|
|
|
id, _ := c.GetInt("Id")
|
|
|
|
|
|
- class_r, err := Device.Read_Class_ById(id)
|
|
|
+ class_r, err := Company.Read_Class_ById(id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2620,7 +2655,7 @@ func (c *DeviceController) DeviceClass_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- Device.Delete_Class_ById(id)
|
|
|
+ Company.Delete_Class_ById(id)
|
|
|
|
|
|
DeviceSensor_class_list := Device.Read_DeviceSensor_ALL_class_1(id)
|
|
|
for _, v := range DeviceSensor_class_list {
|
|
@@ -2643,7 +2678,7 @@ func (c *DeviceController) V2_Class_Del() {
|
|
|
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
|
|
|
- class_r, err := Device.Read_Class_ById(id)
|
|
|
+ class_r, err := Company.Read_Class_ById(id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2654,7 +2689,7 @@ func (c *DeviceController) V2_Class_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- Device.Delete_Class_ById(id)
|
|
|
+ Company.Delete_Class_ById(id)
|
|
|
|
|
|
DeviceSensor_class_list := Device.Read_DeviceSensor_ALL_class_1(id)
|
|
|
for _, v := range DeviceSensor_class_list {
|
|
@@ -2664,7 +2699,7 @@ func (c *DeviceController) V2_Class_Del() {
|
|
|
|
|
|
// 同步分类
|
|
|
go func() {
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
if v.Admin_power > 6 {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
@@ -2686,7 +2721,7 @@ func (c *DeviceController) DeviceClass_Syn() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("Admin_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2698,7 +2733,7 @@ func (c *DeviceController) DeviceClass_Syn() {
|
|
|
for _, v := range class_r {
|
|
|
fmt.Println("清掉:", v.Id)
|
|
|
// 删除分类
|
|
|
- Device.Delete_Class_ById(v.Id)
|
|
|
+ Company.Delete_Class_ById(v.Id)
|
|
|
// 删除 传感器分类
|
|
|
Device.DeviceSensor_T_Calss_ALL_Del(v.Id)
|
|
|
//Device.DeviceSensor_T_Bind_ALL_Del(user_r)
|
|
@@ -2720,7 +2755,7 @@ func (c *DeviceController) DeviceClass_Syn() {
|
|
|
}
|
|
|
num_x = num_x + 1
|
|
|
// 添加分类
|
|
|
- cid, err := Device.Add_Class(t_c)
|
|
|
+ cid, err := Company.Add_Class(t_c)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "Add_Class E!"}
|
|
|
c.ServeJSON()
|
|
@@ -2747,7 +2782,7 @@ func (c *DeviceController) DeviceClass_Syn() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func V2_Class_Syn(admin_r Admin.Admin, user_r Admin.Admin) {
|
|
|
+func V2_Class_Syn(admin_r Account.Admin, user_r Account.Admin) {
|
|
|
|
|
|
// 先全部 清掉
|
|
|
Device.Device_Bind_ALL_Del(user_r)
|
|
@@ -2755,7 +2790,7 @@ func V2_Class_Syn(admin_r Admin.Admin, user_r Admin.Admin) {
|
|
|
for _, v := range class_r {
|
|
|
fmt.Println("清掉:", v.Id)
|
|
|
// 删除分类
|
|
|
- Device.Delete_Class_ById(v.Id)
|
|
|
+ Company.Delete_Class_ById(v.Id)
|
|
|
// 删除 传感器分类
|
|
|
Device.DeviceSensor_T_Calss_ALL_Del(v.Id)
|
|
|
//Device.DeviceSensor_T_Bind_ALL_Del(user_r)
|
|
@@ -2777,7 +2812,7 @@ func V2_Class_Syn(admin_r Admin.Admin, user_r Admin.Admin) {
|
|
|
}
|
|
|
num_x = num_x + 1
|
|
|
// 添加分类
|
|
|
- cid, err := Device.Add_Class(t_c)
|
|
|
+ cid, err := Company.Add_Class(t_c)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -2849,7 +2884,7 @@ func (c *DeviceController) DeviceClassBind_List() {
|
|
|
//c.Data["Class_1"] = Class_1
|
|
|
////c.Data["Name"] = Name
|
|
|
//c.Data["T_sn"] = T_sn
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_calss_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_calss_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2917,7 +2952,7 @@ func (c *DeviceController) DeviceSensor_v2_List() {
|
|
|
}
|
|
|
|
|
|
if len(c.GetString("User_uuid")) > 1 {
|
|
|
- s_, user_r := Admin.Read_Admin_ByAdmin_uuid(c.GetString("User_uuid"))
|
|
|
+ s_, user_r := Account.Read_Admin_ByAdmin_uuid(c.GetString("User_uuid"))
|
|
|
if s_ != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "Admin_uuid Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2927,7 +2962,7 @@ func (c *DeviceController) DeviceSensor_v2_List() {
|
|
|
}
|
|
|
|
|
|
if T_calss_id > 0 {
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_calss_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_calss_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -2972,7 +3007,7 @@ func (c *DeviceController) DeviceClassBind_Add() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_class_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -3019,7 +3054,7 @@ func (c *DeviceController) V2_ClassBind_Add() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_class_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -3033,13 +3068,13 @@ func (c *DeviceController) V2_ClassBind_Add() {
|
|
|
|
|
|
DeviceSensor_class_list := Device.Read_DeviceSensor_ALL_T_sn_T_id_class_1(T_sn, T_id, T_class_id)
|
|
|
if len(DeviceSensor_class_list) > 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "ok!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "重复绑定!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
// 同步分类
|
|
|
go func() {
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
if v.Admin_power > 6 {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
@@ -3078,7 +3113,7 @@ func (c *DeviceController) DeviceClassBind_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_class_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -3101,7 +3136,7 @@ func (c *DeviceController) DeviceClassBind_Del() {
|
|
|
System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "分类删除绑定操作", strconv.Itoa(T_class_id)+"->"+T_sn+"-"+strconv.Itoa(T_id))
|
|
|
|
|
|
// 同步分类
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
|
}
|
|
@@ -3133,7 +3168,7 @@ func (c *DeviceController) V2_ClassBind_Del() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_class_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -3147,7 +3182,7 @@ func (c *DeviceController) V2_ClassBind_Del() {
|
|
|
|
|
|
DeviceSensor_class_list := Device.Read_DeviceSensor_ALL_T_sn_T_id_class_1(T_sn, T_id, T_class_id)
|
|
|
if len(DeviceSensor_class_list) == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "ok!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -3157,7 +3192,7 @@ func (c *DeviceController) V2_ClassBind_Del() {
|
|
|
|
|
|
// 同步分类
|
|
|
go func() {
|
|
|
- DataList, _ := Admin.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
+ DataList, _ := Account.Read_v2_Admin_List(admin_r.Id, "", 0, 9999)
|
|
|
for _, v := range DataList {
|
|
|
if v.Admin_power > 6 {
|
|
|
V2_Class_Syn(admin_r, v)
|
|
@@ -3182,7 +3217,7 @@ func (c *DeviceController) Get_DeviceClassId() {
|
|
|
|
|
|
T_class_id, _ := c.GetInt("T_class_id")
|
|
|
|
|
|
- R_DeviceClass, err := Device.Read_Class_ById(T_class_id)
|
|
|
+ R_DeviceClass, err := Company.Read_Class_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
c.Data["json"] = lib.JSONS{Code: 201, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
@@ -3222,6 +3257,54 @@ func (c *DeviceController) DeviceTask_List() {
|
|
|
}
|
|
|
|
|
|
// 任务列表
|
|
|
+func (c *DeviceController) V2_DeviceTask_List() {
|
|
|
+ // 验证登录
|
|
|
+ b_, _ := 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 []Device.DeviceTask
|
|
|
+ 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")
|
|
|
+ Time_start := c.GetString("Time_start")
|
|
|
+ Time_end := c.GetString("Time_end")
|
|
|
+
|
|
|
+ if len(T_sn) < 6 {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_sn!!!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ r_jsons.Data, r_jsons.Num = Device.Read_V2_DeviceTask_All(T_sn, 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)))
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 任务列表
|
|
|
func (c *DeviceController) DeviceTask_Post() {
|
|
|
// 验证登录
|
|
|
b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
|
|
@@ -3384,7 +3467,7 @@ func (c *DeviceController) DeviceLogs() {
|
|
|
c.Data["T_sn"] = T_sn
|
|
|
|
|
|
var cnt int64
|
|
|
- c.Data["List"], cnt = System.Read_DeviceLogs_ALL(page, T_sn)
|
|
|
+ c.Data["List"], cnt = Device.Read_DeviceLogs_ALL(page, T_sn)
|
|
|
page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
|
|
|
c.Data["Page"] = page
|
|
|
c.Data["Page_size"] = page_size
|
|
@@ -3393,3 +3476,35 @@ func (c *DeviceController) DeviceLogs() {
|
|
|
|
|
|
c.TplName = "Device/DeviceLogs.html"
|
|
|
}
|
|
|
+
|
|
|
+// 列表 - 设备日志
|
|
|
+func (c *DeviceController) V2DeviceLogs() {
|
|
|
+ type R_JSONS struct {
|
|
|
+ //必须的大写开头
|
|
|
+ Data []Device.DeviceLogs
|
|
|
+ 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")
|
|
|
+
|
|
|
+ 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)))
|
|
|
+
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|