|
@@ -141,6 +141,7 @@ func (c *DeviceController) DeviceWarning_List2() {
|
|
|
|
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
T_history, _ := c.GetInt("T_history")
|
|
T_history, _ := c.GetInt("T_history")
|
|
|
|
+ T_abandon, _ := c.GetInt("T_abandon") // 1 弃用设备
|
|
if len(Time_start) == 0 {
|
|
if len(Time_start) == 0 {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间不能为空!"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间不能为空!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -165,24 +166,29 @@ func (c *DeviceController) DeviceWarning_List2() {
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, T_admin, T_history)
|
|
|
|
|
|
+ countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, T_admin, T_history, T_abandon)
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // 查询弃用设备
|
|
|
|
+ abandonDeviceList, _ := Device.Read_Device_List_ByT_State(bindSN, c.T_pid, 0)
|
|
|
|
+ abandonSN := make([]string, 0)
|
|
|
|
+ for _, r := range abandonDeviceList {
|
|
|
|
+ abandonSN = append(abandonSN, r.T_sn)
|
|
|
|
+ }
|
|
// 管理员界面
|
|
// 管理员界面
|
|
if T_admin == 1 {
|
|
if T_admin == 1 {
|
|
- // 获取最新
|
|
|
|
- r_jsons.Data, r_jsons.Num = Warning.Gorm_Read_Admin_Warning_List(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, page, page_z, countRedisKey)
|
|
|
|
|
|
+ // 获取最新 获取绑定的sn 如果未绑定则获取全部
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Warning.Gorm_Read_Admin_Warning_List(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN, page, page_z, countRedisKey)
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- r_jsons.Data, r_jsons.Num = Warning.Gorm_Read_Warning_List(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, page, page_z, countRedisKey)
|
|
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Warning.Gorm_Read_Warning_List(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN, page, page_z, countRedisKey)
|
|
|
|
|
|
r_jsons.Page = page
|
|
r_jsons.Page = page
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
@@ -207,6 +213,7 @@ func (c *DeviceController) DeviceWarning_List_Sse() {
|
|
T_handle, _ := c.GetInt("T_handle")
|
|
T_handle, _ := c.GetInt("T_handle")
|
|
|
|
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
|
|
+ T_abandon, _ := c.GetInt("T_abandon") // 1 弃用设备
|
|
tpCount := Warning.Read_WarningType_Count()
|
|
tpCount := Warning.Read_WarningType_Count()
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -214,6 +221,12 @@ func (c *DeviceController) DeviceWarning_List_Sse() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 查询弃用设备
|
|
|
|
+ abandonDeviceList, _ := Device.Read_Device_List_ByT_State(bindSN, c.T_pid, 0)
|
|
|
|
+ abandonSN := make([]string, 0)
|
|
|
|
+ for _, r := range abandonDeviceList {
|
|
|
|
+ abandonSN = append(abandonSN, r.T_sn)
|
|
|
|
+ }
|
|
var tpList []string
|
|
var tpList []string
|
|
if len(T_tp) > 0 {
|
|
if len(T_tp) > 0 {
|
|
tpList = lib.SplitStringIds(T_tp, "T")
|
|
tpList = lib.SplitStringIds(T_tp, "T")
|
|
@@ -227,7 +240,7 @@ func (c *DeviceController) DeviceWarning_List_Sse() {
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, T_admin, 0)
|
|
|
|
|
|
+ countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, T_admin, 0, T_abandon)
|
|
tableNames := Warning.GenerateWarningTableNames(Time_start, Time_end)
|
|
tableNames := Warning.GenerateWarningTableNames(Time_start, Time_end)
|
|
|
|
|
|
// 设置响应头
|
|
// 设置响应头
|
|
@@ -239,7 +252,7 @@ func (c *DeviceController) DeviceWarning_List_Sse() {
|
|
tableCount := make(map[string]int64)
|
|
tableCount := make(map[string]int64)
|
|
// 管理员界面
|
|
// 管理员界面
|
|
if T_admin == 1 {
|
|
if T_admin == 1 {
|
|
- gormReadWarningListScopes := Warning.GormReadAdminWarningListScopes(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end)
|
|
|
|
|
|
+ gormReadWarningListScopes := Warning.GormReadAdminWarningListScopes(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN)
|
|
cnt, tableCount, err = Warning.Redis_WarningCount_GetOne(c.Admin_r.Id, countRedisKey)
|
|
cnt, tableCount, err = Warning.Redis_WarningCount_GetOne(c.Admin_r.Id, countRedisKey)
|
|
|
|
|
|
offset := (page - 1) * page_z
|
|
offset := (page - 1) * page_z
|
|
@@ -298,7 +311,7 @@ func (c *DeviceController) DeviceWarning_List_Sse() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
//从redis获取报警统计数量
|
|
//从redis获取报警统计数量
|
|
- gormReadWarningListScopes := Warning.GormReadWarningListScopes(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end)
|
|
|
|
|
|
+ gormReadWarningListScopes := Warning.GormReadWarningListScopes(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN)
|
|
cnt, tableCount, err = Warning.Redis_WarningCount_GetOne(c.T_pid, countRedisKey)
|
|
cnt, tableCount, err = Warning.Redis_WarningCount_GetOne(c.T_pid, countRedisKey)
|
|
|
|
|
|
offset := (page - 1) * page_z
|
|
offset := (page - 1) * page_z
|
|
@@ -547,7 +560,7 @@ func (c *DeviceController) DeviceWarning_Post() {
|
|
T_year, T_month = date.Format("2006"), date.Format("01")
|
|
T_year, T_month = date.Format("2006"), date.Format("01")
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
Wtab += "_" + T_year + "_" + T_month
|
|
warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month)
|
|
- if err != nil {
|
|
|
|
|
|
+ if err != nil && err.Error() != "<QuerySeter> no row found" {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
@@ -853,6 +866,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
T_admin, _ := c.GetInt("T_admin")
|
|
|
|
+ T_abandon, _ := c.GetInt("T_abandon") // 1 弃用设备
|
|
tpCount := Warning.Read_WarningType_Count()
|
|
tpCount := Warning.Read_WarningType_Count()
|
|
var tpList []string
|
|
var tpList []string
|
|
if len(T_tp) > 0 {
|
|
if len(T_tp) > 0 {
|
|
@@ -867,7 +881,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
tpList = lib.SplitStringIds(power.T_warning, "W")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, 0)
|
|
|
|
|
|
+ countRedisKey := fmt.Sprintf("Warning_Count_%d_%s_%s_%s_%s_%d_%d_%d", c.T_pid, T_name, T_tp, Time_start, Time_end, T_handle, 0, T_abandon)
|
|
|
|
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
bindSN, err := Account.Read_UserDevice_List(*c.Admin_r)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -875,6 +889,12 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 查询弃用设备
|
|
|
|
+ abandonDeviceList, _ := Device.Read_Device_List_ByT_State(bindSN, c.T_pid, 0)
|
|
|
|
+ abandonSN := make([]string, 0)
|
|
|
|
+ for _, r := range abandonDeviceList {
|
|
|
|
+ abandonSN = append(abandonSN, r.T_sn)
|
|
|
|
+ }
|
|
|
|
|
|
var Device_data []Warning.Warning_R
|
|
var Device_data []Warning.Warning_R
|
|
|
|
|
|
@@ -882,11 +902,11 @@ func (c *DeviceController) DeviceWarning_Data_Excel2() {
|
|
if T_admin == 1 {
|
|
if T_admin == 1 {
|
|
// 获取最新
|
|
// 获取最新
|
|
//Device_data, _ = Warning.Gorm_Read_Admin_Warning_List(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
//Device_data, _ = Warning.Gorm_Read_Admin_Warning_List(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
- Device_data, _ = Warning.Gorm_Read_Admin_Warning_List_Excel(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
|
|
|
|
+ Device_data, _ = Warning.Gorm_Read_Admin_Warning_List_Excel(*c.Admin_r, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN, 0, 9999, countRedisKey)
|
|
} else {
|
|
} else {
|
|
// 获取最新
|
|
// 获取最新
|
|
//Device_data, _ = Warning.Gorm_Read_Warning_List(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
//Device_data, _ = Warning.Gorm_Read_Warning_List(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
- Device_data, _ = Warning.Gorm_Read_Warning_List_Excel(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, 0, 9999, countRedisKey)
|
|
|
|
|
|
+ Device_data, _ = Warning.Gorm_Read_Warning_List_Excel(c.T_pid, bindSN, tpList, T_name, T_handle, Time_start, Time_end, T_abandon, abandonSN, 0, 9999, countRedisKey)
|
|
}
|
|
}
|
|
|
|
|
|
f := excelize.NewFile() // 设置单元格的值
|
|
f := excelize.NewFile() // 设置单元格的值
|