|
@@ -83,12 +83,12 @@ func (c *DeviceController) Device_Get() {
|
|
|
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: 303, Msg: "查询失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if Device_r.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 303, Msg: "无权查看!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权查看!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -112,14 +112,14 @@ func (c *DeviceController) Device_Add() {
|
|
|
T_ish: 1, // 湿度 1开启
|
|
|
}
|
|
|
if len(T_sn) < 8 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 303, Msg: "SN 太短 必须8个字符以上"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "SN 太短 必须8个字符以上"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
_, err = Device.Read_Device_ByT_sn(T_sn)
|
|
|
if err == nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 303, Msg: "重复SN!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "重复SN!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -152,7 +152,7 @@ func (c *DeviceController) Device_Edit() {
|
|
|
|
|
|
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.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -208,7 +208,7 @@ func (c *DeviceController) Device_Edit() {
|
|
|
}
|
|
|
|
|
|
if is := Device.Update_Device(Device_r, clos...); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "修改失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -352,7 +352,7 @@ func (c *DeviceController) Device_Parameter_Get() {
|
|
|
DeviceParameter_lite := Device.Read_DeviceParameter_SN(Sn)
|
|
|
if len(DeviceParameter_lite) == 0 {
|
|
|
NatsServer.Read_DeviceParameter(Sn)
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -385,7 +385,7 @@ func (c *DeviceController) Device_Parameter_Pu() {
|
|
|
//
|
|
|
//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.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
|
|
|
// c.ServeJSON()
|
|
|
// return
|
|
|
//}
|
|
@@ -410,7 +410,7 @@ func (c *DeviceController) Device_Parameter_Pu() {
|
|
|
//}
|
|
|
//Deviceparameter, is := Device.Add_DeviceParameter(Deviceparameter)
|
|
|
//if !is {
|
|
|
- // c.Data["json"] = lib.JSONS{Code: 203, Msg: "Add_DeviceParameter ERR"}
|
|
|
+ // c.Data["json"] = lib.JSONS{Code: 202, Msg: "Add_DeviceParameter ERR"}
|
|
|
// c.ServeJSON()
|
|
|
// return
|
|
|
//}
|
|
@@ -426,13 +426,13 @@ func (c *DeviceController) Device_Parameter_Pu() {
|
|
|
|
|
|
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.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
DeviceParameter_lite := Device.Read_DeviceParameter_SN(T_SN)
|
|
|
if len(DeviceParameter_lite) == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -490,7 +490,7 @@ func (c *DeviceController) Device_Parameter_Pu() {
|
|
|
|
|
|
Deviceparameter, is := Device.Add_DeviceParameter(DeviceParameter)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "Add_DeviceParameter ERR"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "Add_DeviceParameter ERR"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -554,8 +554,8 @@ func (c *DeviceController) DeviceSensor_List() {
|
|
|
}
|
|
|
|
|
|
T_sn := c.GetString("T_sn")
|
|
|
- Name := c.GetString("T_name") // 包含 T_name、T_sn
|
|
|
- T_calss_id, _ := c.GetInt("T_calssid")
|
|
|
+ T_name := c.GetString("T_name") // 包含 T_name、T_sn
|
|
|
+ T_class_id, _ := c.GetInt("T_calssid")
|
|
|
T_type, T_type_err := c.GetInt("T_type")
|
|
|
if T_type_err != nil {
|
|
|
T_type = -1
|
|
@@ -568,21 +568,21 @@ func (c *DeviceController) DeviceSensor_List() {
|
|
|
if T_datashow_err != nil {
|
|
|
T_datashow = -1
|
|
|
}
|
|
|
- if T_calss_id > 0 {
|
|
|
- R_DeviceClass, err := Company.Read_CompanyClass_ById(T_calss_id)
|
|
|
+ if T_class_id > 0 {
|
|
|
+ R_DeviceClass, err := Company.Read_CompanyClass_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "R_DeviceClass.T_pid != T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "R_DeviceClass.T_pid != T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
Device.Read_DeviceSensorParameter_All_Map(T_sn, 0)
|
|
|
- r_jsons.Data, r_jsons.Num = Device.Read_DeviceSensorList(c.Admin_r, c.T_pid, T_sn, Name, T_calss_id, T_datashow, T_type, T_State, page, page_z)
|
|
|
+ r_jsons.Data, r_jsons.Num = Device.Read_DeviceSensorList(c.Admin_r, c.T_pid, T_sn, T_name, T_class_id, T_datashow, T_type, T_State, page, page_z)
|
|
|
r_jsons.Page = page
|
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
|
@@ -599,13 +599,18 @@ func (c *DeviceController) DeviceSensor_Edit() {
|
|
|
|
|
|
DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "信息错误!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 数据视图3D视图订阅
|
|
|
if v, err := c.GetInt("T_type"); err == nil {
|
|
|
+ if v == 0 {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "类型错误!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
DeviceSensor.T_type = v
|
|
|
Device.Update_DeviceSensor(DeviceSensor, "T_type")
|
|
|
System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "传感器 类型", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(v))
|
|
@@ -644,7 +649,7 @@ func (c *DeviceController) DeviceSensor_Del() {
|
|
|
|
|
|
_, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "信息错误!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -678,7 +683,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Get() {
|
|
|
DeviceSensorParameter_lite := Device.Read_DeviceSensorParameter_T_sn_T_id(Sn, Id)
|
|
|
if len(DeviceSensorParameter_lite) == 0 {
|
|
|
NatsServer.Read_DeviceSensorParameter(Sn)
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "未同步参数,请检查设备是否正常!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -715,21 +720,21 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
|
|
|
T_id, _ := c.GetInt("T_id")
|
|
|
_, err := Device.Read_Device_ByT_sn(T_SN)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_sn Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(T_SN, T_id)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 208, Msg: "T_sn T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
DeviceSensorParameter, is := Device.Read_DeviceSensorParameter(T_SN, T_id)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 208, Msg: "T_sn T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -814,7 +819,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
|
|
|
|
|
|
Devicesensorparameter, is = Device.Add_DeviceSensorParameter(Devicesensorparameter)
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 209, Msg: "Add_DeviceSensorParameter Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "Add_DeviceSensorParameter Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -824,7 +829,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
|
|
|
if len(T_name) > 0 {
|
|
|
DeviceSensor.T_name = T_name
|
|
|
if is = Device.Update_DeviceSensor(DeviceSensor, "T_name"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 209, Msg: "Update_DeviceSensor Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "Update_DeviceSensor Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -848,7 +853,7 @@ func (c *DeviceController) UpDeviceSensor_Tsort() {
|
|
|
|
|
|
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: 202, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -871,7 +876,7 @@ func (c *DeviceController) UpDeviceSensor_T3dview() {
|
|
|
|
|
|
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: 202, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -893,7 +898,7 @@ func (c *DeviceController) UpDeviceSensor_T_datashow() {
|
|
|
|
|
|
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: 202, Msg: "信息错误!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -933,12 +938,12 @@ func (c *DeviceController) DeviceSensor_Manage_List() {
|
|
|
if T_calss_id > 0 {
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(T_calss_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "CompanyClass.T_pid != T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "CompanyClass.T_pid != T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -998,7 +1003,7 @@ func (c *DeviceController) DeviceTask_List() {
|
|
|
Time_end := c.GetString("Time_end")
|
|
|
|
|
|
if len(T_sn) < 6 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_sn!!!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn!!!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1065,7 +1070,7 @@ func (c *DeviceController) DeviceWarning_List() {
|
|
|
if T_history == 1 {
|
|
|
date, err := time.Parse("2006-01-02 15:04:05", Time_start)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "时间格式错误"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1125,7 +1130,7 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
if T_history == 1 {
|
|
|
date, err := time.Parse("2006-01-02 15:04:05", T_time)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "时间格式错误"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1133,14 +1138,14 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
|
warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
warning.T_Text = T_Text
|
|
|
warning.T_State = 2
|
|
|
if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "修改失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1148,14 +1153,14 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
|
} else {
|
|
|
warning = Warning.Read_Warning_ById(int64(id))
|
|
|
if warning.Id == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
warning.T_Text = T_Text
|
|
|
warning.T_State = 2
|
|
|
if is := Warning.Update_Warning(warning, "T_Text", "T_State"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "修改失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1179,7 +1184,7 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
if T_history == 1 {
|
|
|
date, err := time.Parse("2006-01-02 15:04:05", T_time)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "时间格式错误"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1188,13 +1193,13 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
|
|
|
warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
warning.T_State = 0
|
|
|
if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "删除失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1202,13 +1207,13 @@ func (c *DeviceController) DeviceWarning_Del() {
|
|
|
} else {
|
|
|
warning = Warning.Read_Warning_ById(int64(id))
|
|
|
if warning.Id == 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
warning.T_State = 0
|
|
|
if is := Warning.Update_Warning(warning, "T_Text", "T_State"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 206, Msg: "删除失败!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1233,7 +1238,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
|
|
|
if T_history == 1 {
|
|
|
date, err := time.Parse("2006-01-02 15:04:05", Time_start)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 200, Msg: "时间格式错误"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1293,7 +1298,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
|
|
|
|
|
|
url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
|
|
|
if !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1391,12 +1396,12 @@ func (c *DeviceController) CompanyClass_Get() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1414,7 +1419,7 @@ func (c *DeviceController) CompanyClass_Add() {
|
|
|
|
|
|
Id, err := Company.Add_CompanyClass(t_c)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1429,12 +1434,12 @@ func (c *DeviceController) CompanyClass_Edit() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1444,7 +1449,7 @@ func (c *DeviceController) CompanyClass_Edit() {
|
|
|
}
|
|
|
|
|
|
if is := Company.Update_CompanyClass(R_DeviceClass, "T_name"); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1459,17 +1464,17 @@ func (c *DeviceController) CompanyClass_Del() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if is := Company.Delete_CompanyClass_ById(id); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "删除失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1511,12 +1516,12 @@ func (c *DeviceController) DeviceClassBind_List() {
|
|
|
T_type, _ := c.GetInt("T_type")
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1547,25 +1552,25 @@ func (c *DeviceController) ClassBind_Add() {
|
|
|
return
|
|
|
}
|
|
|
if _, err := Device.Read_Device_ByT_sn(T_sn); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
DeviceSensor_class_list := Device.Read_DeviceSensor_ALL_T_sn_T_id_T_Class(T_sn, T_id, T_class_id)
|
|
|
if len(DeviceSensor_class_list) > 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "重复绑定!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "重复绑定!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1591,18 +1596,18 @@ func (c *DeviceController) ClassBind_Del() {
|
|
|
return
|
|
|
}
|
|
|
if _, err := Device.Read_Device_ByT_sn(T_sn); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
R_DeviceClass, err := Company.Read_CompanyClass_ById(T_class_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1680,12 +1685,12 @@ func (c *DeviceController) CompanyNotice_Get() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
R_DeviceNotice, err := Company.Read_CompanyNotice_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1704,7 +1709,7 @@ func (c *DeviceController) CompanyNotice_Add() {
|
|
|
|
|
|
Id, err := Company.Add_CompanyNotice(t_c)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1726,12 +1731,12 @@ func (c *DeviceController) CompanyNotice_Edit() {
|
|
|
|
|
|
R_DeviceNotice, err := Company.Read_CompanyNotice_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1775,7 +1780,7 @@ func (c *DeviceController) CompanyNotice_Edit() {
|
|
|
}
|
|
|
|
|
|
if err = Company.Update_CompanyNotice(R_DeviceNotice, "T_name", "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism"); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1791,12 +1796,12 @@ func (c *DeviceController) CompanyNotice_Reset_Mechanism() {
|
|
|
|
|
|
R_DeviceNotice, err := Company.Read_CompanyNotice_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1804,7 +1809,7 @@ func (c *DeviceController) CompanyNotice_Reset_Mechanism() {
|
|
|
R_DeviceNotice.T_Notice_mechanism = Warning.Read_WarningType_All_T_Notice_mechanism()
|
|
|
|
|
|
if err = Company.Update_CompanyNotice(R_DeviceNotice, "T_Notice_mechanism"); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1819,17 +1824,17 @@ func (c *DeviceController) CompanyNotice_Del() {
|
|
|
id, _ := c.GetInt("T_id")
|
|
|
R_DeviceNotice, err := Company.Read_CompanyNotice_ById(id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if is := Company.Delete_CompanyNotice_ById(id); !is {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "删除失败"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1870,12 +1875,12 @@ func (c *DeviceController) DeviceNoticeBind_List() {
|
|
|
|
|
|
R_DeviceNotice, err := Company.Read_CompanyNotice_ById(T_notice_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1906,25 +1911,25 @@ func (c *DeviceController) NoticeBind_Add() {
|
|
|
return
|
|
|
}
|
|
|
if _, err := Device.Read_Device_ByT_sn(T_sn); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
R_CompanyNotice, err := Company.Read_CompanyNotice_ById(T_notice_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_CompanyNotice.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
DeviceSensor_Notice_list := Device.Read_DeviceSensor_ALL_T_sn_T_id_T_Notice(T_sn, T_id, T_notice_id)
|
|
|
if len(DeviceSensor_Notice_list) > 0 {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "重复绑定!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "重复绑定!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1957,18 +1962,18 @@ func (c *DeviceController) NoticeBind_Del() {
|
|
|
return
|
|
|
}
|
|
|
if _, err := Device.Read_Device_ByT_sn(T_sn); err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 204, Msg: "T_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
R_DeviceClass, err := Company.Read_CompanyNotice_ById(T_notice_id)
|
|
|
if err != nil {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class_id Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
if R_DeviceClass.T_pid != c.T_pid {
|
|
|
- c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_pid Err!"}
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_pid Err!"}
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
@@ -1998,8 +2003,8 @@ func (c *DeviceController) NoticeBind_Del() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 设备类型
|
|
|
-func (c *DeviceController) DeviceType_List_All() {
|
|
|
+// 传感器类型
|
|
|
+func (c *DeviceController) DeviceSensorType_List_All() {
|
|
|
type R_JSONS struct {
|
|
|
//必须的大写开头
|
|
|
Data []Device.DeviceSensorType
|
|
@@ -2016,3 +2021,131 @@ func (c *DeviceController) DeviceType_List_All() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 传感器类型 - 小程序
|
|
|
+func (c *DeviceController) DeviceSensorType_List() {
|
|
|
+
|
|
|
+ var r_jsons lib.R_JSONS
|
|
|
+
|
|
|
+ list, err := Device.Read_DeviceSensor_T_type(c.T_pid)
|
|
|
+ if err != nil {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var ids []int
|
|
|
+ for _, v := range list {
|
|
|
+ id, _ := strconv.Atoi(v.(string))
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ r_jsons.Data = Device.Read_DeviceSensorType_List_By_Ids(ids)
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 传感器统计 - 小程序
|
|
|
+func (c *DeviceController) DeviceSensor_Stat() {
|
|
|
+
|
|
|
+ type Monitor struct {
|
|
|
+ Count int64
|
|
|
+ Monitor int64
|
|
|
+ Unmonitored int64
|
|
|
+ NoNetwork int64
|
|
|
+ }
|
|
|
+
|
|
|
+ type R_JSONS struct {
|
|
|
+ //必须的大写开头
|
|
|
+ Data interface{}
|
|
|
+ Monitor Monitor
|
|
|
+ Num int64
|
|
|
+ Page int
|
|
|
+ Page_size int
|
|
|
+ }
|
|
|
+
|
|
|
+ var monitor Monitor
|
|
|
+ var monitorList, unmonitoredList, noNetworkList []Device.DeviceSensor_R
|
|
|
+ var r_jsons R_JSONS
|
|
|
+
|
|
|
+ page, _ := c.GetInt("page")
|
|
|
+ if page < 1 {
|
|
|
+ page = 1
|
|
|
+ }
|
|
|
+ page_z, _ := c.GetInt("page_z")
|
|
|
+ if page_z < 1 {
|
|
|
+ page_z = conf.Page_size
|
|
|
+ }
|
|
|
+
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
+ T_monitor, _ := c.GetInt("T_monitor")
|
|
|
+
|
|
|
+ T_type, T_type_err := c.GetInt("T_type")
|
|
|
+ if T_type_err != nil {
|
|
|
+ T_type = -1
|
|
|
+ }
|
|
|
+
|
|
|
+ list, num := Device.Read_DeviceSensor_List_For_Stat(c.T_pid, T_name, T_type)
|
|
|
+ monitor.Count = num
|
|
|
+ for _, v := range list {
|
|
|
+ // 0 未监控 1 监控 2 无网络
|
|
|
+ switch v.T_monitor {
|
|
|
+ case 0:
|
|
|
+ monitor.Unmonitored += 1
|
|
|
+ unmonitoredList = append(unmonitoredList, v)
|
|
|
+ case 1:
|
|
|
+ monitor.Monitor += 1
|
|
|
+ monitorList = append(monitorList, v)
|
|
|
+ case 2:
|
|
|
+ monitor.NoNetwork += 1
|
|
|
+ noNetworkList = append(noNetworkList, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var offset_z int
|
|
|
+ offset := conf.Page_size
|
|
|
+ if page <= 1 {
|
|
|
+ offset = 0
|
|
|
+ } else {
|
|
|
+ page -= 1
|
|
|
+ offset = page * page_z
|
|
|
+ }
|
|
|
+
|
|
|
+ offset_z = offset + page_z
|
|
|
+
|
|
|
+ // 0 未监控 1 监控 2 无网络
|
|
|
+ switch T_monitor {
|
|
|
+ case 0:
|
|
|
+ r_jsons.Num = monitor.Unmonitored
|
|
|
+ if r_jsons.Num < int64(offset_z) {
|
|
|
+ offset_z = int(r_jsons.Num)
|
|
|
+ }
|
|
|
+ r_jsons.Data = unmonitoredList[offset:offset_z]
|
|
|
+ case 1:
|
|
|
+ r_jsons.Num = monitor.Monitor
|
|
|
+ if r_jsons.Num < int64(offset_z) {
|
|
|
+ offset_z = int(r_jsons.Num)
|
|
|
+ }
|
|
|
+ r_jsons.Data = monitorList[offset:offset_z]
|
|
|
+ case 2:
|
|
|
+ r_jsons.Num = monitor.NoNetwork
|
|
|
+ if r_jsons.Num < int64(offset_z) {
|
|
|
+ offset_z = int(r_jsons.Num)
|
|
|
+ }
|
|
|
+ r_jsons.Data = noNetworkList[offset:offset_z]
|
|
|
+ case 3:
|
|
|
+ r_jsons.Num = monitor.Count
|
|
|
+ if r_jsons.Num < int64(offset_z) {
|
|
|
+ offset_z = int(r_jsons.Num)
|
|
|
+ }
|
|
|
+ r_jsons.Data = list[offset:offset_z]
|
|
|
+ }
|
|
|
+
|
|
|
+ r_jsons.Monitor = monitor
|
|
|
+ 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
|
|
|
+}
|