Răsfoiți Sursa

add: 修改用户,删除用户,解除内部用户公司绑定时同步报警策略通知显示

zoie 2 ani în urmă
părinte
comite
ff8e869a2a

+ 47 - 13
controllers/Device.go

@@ -417,6 +417,9 @@ func (c *DeviceController) Device_Parameter_Pu() {
 	if v, err := c.GetInt("T_warnD"); err == nil {
 		DeviceParameter.T_warnD = v
 	}
+	if v, err := c.GetInt("T_speed"); err == nil {
+		DeviceParameter.T_speed = v
+	}
 	if v := c.GetString("T_btname"); len(v) > 0 {
 		DeviceParameter.T_btname = v
 	}
@@ -429,13 +432,11 @@ func (c *DeviceController) Device_Parameter_Pu() {
 	if v, err := c.GetInt("T_Msid"); err == nil {
 		DeviceParameter.T_Msid = int64(v)
 	}
-	if v, err := c.GetInt("T_State"); err == nil {
-		DeviceParameter.T_State = v
-	}
 
 	if v := c.GetString("T_name"); len(v) > 0 {
 		DeviceParameter.T_name = v
 	}
+	DeviceParameter.T_State = 2
 	DeviceParameter.T_uuid = c.Admin_r.T_uuid
 	DeviceParameter.T_SendState = 0
 
@@ -687,15 +688,6 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
 		T_RHupper = float32(v)
 	}
 
-	T_en := DeviceSensorParameter.T_en
-	if v, T_en_err := c.GetInt("T_en"); T_en_err == nil {
-		T_en = v
-	}
-
-	T_free := DeviceSensorParameter.T_free
-	if v, T_free_err := c.GetInt("T_free"); T_free_err == nil {
-		T_free = v
-	}
 	T_enprel := DeviceSensorParameter.T_enprel
 	if v, T_enprel_err := c.GetInt("T_enprel"); T_enprel_err == nil {
 		T_enprel = v
@@ -717,6 +709,18 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
 		T_hpreu = float32(v)
 	}
 
+	T_speed := DeviceSensorParameter.T_speed
+	if v, T_speed_err := c.GetInt("T_speed"); T_speed_err == nil {
+		T_speed = v
+	}
+	T_en := DeviceSensorParameter.T_en
+	if v, T_en_err := c.GetInt("T_en"); T_en_err == nil {
+		T_en = v
+	}
+	T_free := DeviceSensorParameter.T_free
+	if v, T_free_err := c.GetInt("T_free"); T_free_err == nil {
+		T_free = v
+	}
 	Devicesensorparameter := Device.DeviceSensorParameter{
 		T_sn:      T_SN,
 		T_id:      T_id,
@@ -725,6 +729,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
 		T_Tupper:  T_Tupper,
 		T_RHlower: T_RHlower,
 		T_RHupper: T_RHupper,
+		T_speed:   T_speed,
 		T_en:      T_en,
 		T_free:    T_free,
 
@@ -1600,7 +1605,7 @@ func (c *DeviceController) CompanyNotice_Edit() {
 		R_DeviceNotice.T_Notice_mechanism = T_Notice_mechanism
 	}
 
-	if is := Company.Update_CompanyNotice(R_DeviceNotice, "T_name"); !is {
+	if is := 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"); !is {
 		c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
 		c.ServeJSON()
 		return
@@ -1612,6 +1617,35 @@ func (c *DeviceController) CompanyNotice_Edit() {
 	c.ServeJSON()
 	return
 }
+func (c *DeviceController) CompanyNotice_Reset_Mechanism() {
+	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.ServeJSON()
+		return
+	}
+	if R_DeviceNotice.T_pid != c.T_pid {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "T_pid Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	R_DeviceNotice.T_Notice_mechanism = Warning.Read_WarningType_All_T_Notice_mechanism()
+
+	if is := Company.Update_CompanyNotice(R_DeviceNotice, "T_Notice_mechanism"); !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
+		c.ServeJSON()
+		return
+	}
+
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "报警策略", R_DeviceNotice)
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+	c.ServeJSON()
+	return
+}
 func (c *DeviceController) CompanyNotice_Del() {
 	id, _ := c.GetInt("T_id")
 	R_DeviceNotice, err := Company.Read_CompanyNotice_ById(id)

+ 41 - 7
controllers/User.go

@@ -7,6 +7,7 @@ import (
 	"Cold_Api/logs"
 	"Cold_Api/models"
 	"Cold_Api/models/Account"
+	"Cold_Api/models/Company"
 	"Cold_Api/models/System"
 	"Cold_Api/models/Warning"
 	"github.com/beego/beego/v2/adapter/orm"
@@ -100,6 +101,15 @@ func (c *UserController) Company_Add() {
 		return
 	}
 
+	if c.Admin_r.T_pids != "*" {
+		T_pids := []int{int(id)}
+		if err = Account.Add_Company_bind(c.Admin_r, T_pids); err != nil {
+			c.Data["json"] = lib.JSONS{Code: 200, Msg: "公司绑定失败"}
+			c.ServeJSON()
+			return
+		}
+	}
+
 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "公司管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
 	c.ServeJSON()
@@ -413,6 +423,13 @@ func (c *UserController) User_Edit() {
 		c.ServeJSON()
 		return
 	}
+
+	if len(T_name) > 0 {
+		if is = Company.Update_CompanyNotice_Bind_By_T_uuid(T_uuid, T_name); !is {
+			logs.Println("修改用户 => 修改用户关联报警通知失败", T_uuid, T_name)
+		}
+	}
+
 	r.T_pass = "******"
 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "编辑", r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
@@ -439,6 +456,10 @@ func (c *UserController) User_Del() {
 		return
 	}
 
+	if is := Company.Delete_CompanyNotice_Bind_By_T_uuid(T_uuid); !is {
+		logs.Println("删除用户 => 删除用户关联报警通知失败", T_uuid)
+	}
+
 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "删除", T_uuid)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -501,10 +522,9 @@ func (c *UserController) Admin_List() {
 	}
 
 	T_name := c.GetString("T_name")
-	T_pid := 0
 
 	Account.Read_Power_All_Map()
-	r_jsons.Data, r_jsons.Num = Account.Read_Admin_List(T_pid, T_name, page, page_z)
+	r_jsons.Data, r_jsons.Num = Account.Read_Admin_List(0, T_name, page, page_z)
 	r_jsons.Page = page
 	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
 
@@ -575,7 +595,7 @@ func (c *UserController) Admin_Add() {
 	}
 
 	var_.T_pass = "******"
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "添加", var_)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "内部用户管理", "添加", var_)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -633,8 +653,15 @@ func (c *UserController) Admin_Edit() {
 		c.ServeJSON()
 		return
 	}
+
+	if len(T_name) > 0 {
+		if is = Company.Update_CompanyNotice_Bind_By_T_uuid(T_uuid, "内管-"+T_name); !is {
+			logs.Println("修改内部用户 => 修改内部用户关联报警通知失败", T_uuid, T_name)
+		}
+	}
+
 	r.T_pass = "********"
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "编辑", r)
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "内部用户管理", "修改", r)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -654,7 +681,7 @@ func (c *UserController) Admin_Del() {
 		return
 	}
 	if admin_r_lod.Id == 1 {
-		c.Data["json"] = lib.JSONS{Code: 200, Msg: "无权删除!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权删除!"}
 		c.ServeJSON()
 		return
 	}
@@ -664,7 +691,11 @@ func (c *UserController) Admin_Del() {
 		return
 	}
 
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "用户管理", "删除", T_uuid)
+	if is := Company.Delete_CompanyNotice_Bind_By_T_uuid(T_uuid); !is {
+		logs.Println("删除内部用户 => 删除内部用户关联报警通知失败", T_uuid)
+	}
+
+	System.Add_UserLogs_T(c.Admin_r.T_uuid, "内部用户管理", "删除", T_uuid)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -786,6 +817,9 @@ func (c *UserController) AdminCompanyBind_Del() {
 		c.ServeJSON()
 		return
 	}
+	if is := Company.Delete_CompanyNotice_Bind_By_T_uuid_T_pid(T_uuid, T_pids); !is {
+		logs.Println("删除内部用户公司绑定 => 删除内部用户绑定的公司关联报警通知失败", T_uuid)
+	}
 
 	System.Add_UserLogs(c.Admin_r.T_uuid, "内部用户管理", "公司绑定删除", T_uuid+"-"+strconv.Itoa(T_pid))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
@@ -817,7 +851,7 @@ func (c *UserController) Power_List() {
 	return
 }
 
-// 权限管理
+// 添加用户 权限选择列表
 func (c *UserController) Power_List_All() {
 	r, err := Account.Read_Power_ById(c.Admin_r.T_power)
 	if err != nil {

+ 2 - 6
models/Account/Admin.go

@@ -254,17 +254,13 @@ func Read_Admin_List(T_pid int, T_name string, page int, page_z int) (AdminList
 		offset = int64((page - 1) * page_z)
 	}
 	cond := orm.NewCondition()
-	cond1 := cond.And("T_State", 1)
-
-	if T_pid > 0 {
-		cond1 = cond1.AndCond(cond.And("T_pid", T_pid))
-	}
+	cond1 := cond.And("T_State", 1).And("T_pid", T_pid)
 
 	if len(T_name) > 0 {
 		cond1 = cond1.AndCond(cond.Or("T_name__icontains", T_name).Or("T_user__icontains", T_name))
 	}
 
-	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-Id").All(&maps)
+	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("Id").All(&maps)
 	cnt, _ = qs.SetCond((*orm2.Condition)(cond1)).Count()
 
 	for _, v := range maps {

+ 0 - 1
models/Account/Company.go

@@ -51,7 +51,6 @@ var redisCache_Company cache.Cache
 func init() {
 	//注册模型
 	orm.RegisterModel(new(Company))
-	orm.Debug = true
 
 	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
 		"redis_User_Company", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)

+ 2 - 42
models/Account/Menu.go

@@ -188,7 +188,6 @@ func Read_Menu_ById(Id int) (r Menu, e error) {
 
 // 获取列表
 func Read_Menu_Bind_List(Power_Id int, Bind_Menu string, T_pid int) (maps []Menu) {
-
 	if r, is := Redis_Menu_Get(Power_Id, T_pid); is {
 		return r
 	}
@@ -198,6 +197,7 @@ func Read_Menu_Bind_List(Power_Id int, Bind_Menu string, T_pid int) (maps []Menu
 
 	qs := o.QueryTable(new(Menu))
 	cond := orm.NewCondition()
+	cond = cond.And("T_State__gt", 0)
 	if T_pid == 0 {
 		cond = cond.And("T_pid", 0)
 	}
@@ -214,7 +214,7 @@ func Read_Menu_Bind_List(Power_Id int, Bind_Menu string, T_pid int) (maps []Menu
 		return maps
 	}
 
-	cond = cond.AndCond(cond.Or("Id__in", models.IntIdsDistinct(AllIds)).Or("T_State", 2))
+	cond = cond.And("Id__in", models.IntIdsDistinct(AllIds)).Or("T_State", 2)
 
 	qs.SetCond((*orm2.Condition)(cond)).OrderBy("T_sort", "Id").All(&maps)
 
@@ -265,46 +265,6 @@ func Read_Menu_List_All() (maps []Menu, menu_ids []int) {
 	return m, menu_ids
 }
 
-// 获取左侧菜单树
-//func Read_Menu_Tree(Menu_Bind string, T_pid int) (MenuList []Menu) {
-//
-//	o := orm.NewOrm()
-//	// 也可以直接使用 Model 结构体作为表名
-//
-//	qs := o.QueryTable(new(Menu))
-//	cond := orm.NewCondition()
-//	T_pid_list := []int{0}
-//	if T_pid > 0 {
-//		T_pid_list = append(T_pid_list, 1)
-//	}
-//	cond1 := cond.And("T_pid__in", T_pid_list)
-//	var maps []Menu
-//	if Menu_Bind != "*" {
-//		list := models.SplitStringIds(Menu_Bind, "M")
-//		cond1 = cond1.And("Id__in", list)
-//	}
-//	qs.SetCond((*orm2.Condition)(cond1)).OrderBy("-T_sort").All(&maps)
-//
-//	//m := Menu_Tree(maps, 0)
-//	MenuList = Menu_Call(maps, 0)
-//	//parentMap, flag := getMenuParent(maps)
-//	//if flag {
-//	//	for i := 0; i < len(maps); i++ {
-//	//		if parentMap[maps[i].T_mid] {
-//	//			continue
-//	//		}
-//	//		info := MenuCall(maps, maps[i])
-//	//		MenuList = append(MenuList, info)
-//	//	}
-//	//} else {
-//	//	for i := 0; i < len(maps); i++ {
-//	//		info := MenuCall(maps, maps[i])
-//	//		MenuList = append(MenuList, info)
-//	//	}
-//	//}
-//	return MenuList
-//}
-
 // Menu_Call 构建菜单树
 // [{"Id":70,"T_mid":0,"T_name":"工单管理","T_permission":"workorder","T_sort":0,"T_pid":1,"T_bind":false,"Children":[{"Id":71,"T_mid":70,"T_name":"工单列表","T_permission":"workorder:list","T_sort":0,"T_pid":1,"T_bind":false,"Children":[]}]}]
 func Menu_Call(list []Menu, parentId int) []Menu {

+ 133 - 0
models/Company/CompanyNotice.go

@@ -291,3 +291,136 @@ func Delete_T_Notice_bind(T_sn string, T_id int, T_Notice_id int) (err error) {
 	return err
 
 }
+
+// 修改用户同时修改报警策略绑定的用户信息
+func Update_CompanyNotice_Bind_By_T_uuid(T_uuid, T_name string) bool {
+
+	o := orm.NewOrm()
+	o.Begin()
+	// 也可以直接使用 Model 结构体作为表名
+	var map_r []CompanyNotice
+	qs := o.QueryTable(new(CompanyNotice))
+
+	cond := orm.NewCondition()
+
+	cond1 := cond.And("T_State", 1).AndCond(
+		cond.Or("T_Notice_wx__icontains", T_uuid).
+			Or("T_Notice_wx2__icontains", T_uuid).
+			Or("T_Notice_phone__icontains", T_uuid).
+			Or("T_Notice_message__icontains", T_uuid).
+			Or("T_Notice_mailbox__icontains", T_uuid))
+
+	qs.SetCond((*orm2.Condition)(cond1)).All(&map_r)
+	T_uuid_name := fmt.Sprintf("%s/%s|", T_uuid, T_name)
+	for _, v := range map_r {
+		v.T_Notice_wx = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx, T_uuid_name)
+		v.T_Notice_wx2 = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx2, T_uuid_name)
+		v.T_Notice_phone = Replice_T_Notice_Bind(T_uuid, v.T_Notice_phone, T_uuid_name)
+		v.T_Notice_message = Replice_T_Notice_Bind(T_uuid, v.T_Notice_message, T_uuid_name)
+		v.T_Notice_mailbox = Replice_T_Notice_Bind(T_uuid, v.T_Notice_mailbox, T_uuid_name)
+		_, err := o.Update(&v, "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism")
+		if err != nil {
+			o.Rollback()
+			return false
+		}
+		Redis_CompanyNotice_DelK(strconv.Itoa(v.Id))
+	}
+
+	o.Commit()
+	return true
+
+}
+
+// 删除用户同时删除报警策略绑定的用户信息
+func Delete_CompanyNotice_Bind_By_T_uuid(T_uuid string) bool {
+
+	o := orm.NewOrm()
+	o.Begin()
+	// 也可以直接使用 Model 结构体作为表名
+	var map_r []CompanyNotice
+	qs := o.QueryTable(new(CompanyNotice))
+
+	cond := orm.NewCondition()
+
+	cond1 := cond.And("T_State", 1).AndCond(
+		cond.Or("T_Notice_wx__icontains", T_uuid).
+			Or("T_Notice_wx2__icontains", T_uuid).
+			Or("T_Notice_phone__icontains", T_uuid).
+			Or("T_Notice_message__icontains", T_uuid).
+			Or("T_Notice_mailbox__icontains", T_uuid))
+
+	qs.SetCond((*orm2.Condition)(cond1)).All(&map_r)
+
+	for _, v := range map_r {
+		v.T_Notice_wx = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx, "")
+		v.T_Notice_wx2 = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx2, "")
+		v.T_Notice_phone = Replice_T_Notice_Bind(T_uuid, v.T_Notice_phone, "")
+		v.T_Notice_message = Replice_T_Notice_Bind(T_uuid, v.T_Notice_message, "")
+		v.T_Notice_mailbox = Replice_T_Notice_Bind(T_uuid, v.T_Notice_mailbox, "")
+		_, err := o.Update(&v, "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism")
+		if err != nil {
+			o.Rollback()
+			return false
+		}
+		Redis_CompanyNotice_DelK(strconv.Itoa(v.Id))
+
+	}
+
+	o.Commit()
+	return true
+
+}
+
+// 获取全部列表
+func Delete_CompanyNotice_Bind_By_T_uuid_T_pid(T_uuid string, T_pids []int) bool {
+
+	o := orm.NewOrm()
+	o.Begin()
+	// 也可以直接使用 Model 结构体作为表名
+	var map_r []CompanyNotice
+	qs := o.QueryTable(new(CompanyNotice))
+
+	cond := orm.NewCondition()
+
+	cond1 := cond.And("T_State", 1).And("T_pid__in", T_pids).AndCond(
+		cond.Or("T_Notice_wx__icontains", T_uuid).
+			Or("T_Notice_wx2__icontains", T_uuid).
+			Or("T_Notice_phone__icontains", T_uuid).
+			Or("T_Notice_message__icontains", T_uuid).
+			Or("T_Notice_mailbox__icontains", T_uuid))
+
+	qs.SetCond((*orm2.Condition)(cond1)).All(&map_r)
+
+	for _, v := range map_r {
+		v.T_Notice_wx = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx, "")
+		v.T_Notice_wx2 = Replice_T_Notice_Bind(T_uuid, v.T_Notice_wx2, "")
+		v.T_Notice_phone = Replice_T_Notice_Bind(T_uuid, v.T_Notice_phone, "")
+		v.T_Notice_message = Replice_T_Notice_Bind(T_uuid, v.T_Notice_message, "")
+		v.T_Notice_mailbox = Replice_T_Notice_Bind(T_uuid, v.T_Notice_mailbox, "")
+		_, err := o.Update(&v, "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism")
+		if err != nil {
+			o.Rollback()
+			return false
+		}
+		Redis_CompanyNotice_DelK(strconv.Itoa(v.Id))
+
+	}
+
+	o.Commit()
+	return true
+
+}
+
+func Replice_T_Notice_Bind(T_uuid, T_Notice_Bind string, new string) string {
+	if len(T_Notice_Bind) == 0 {
+		return ""
+	}
+	list := strings.Split(T_Notice_Bind, "|")
+	for _, v := range list {
+		if strings.Contains(v, T_uuid) {
+			T_Notice_Bind = strings.Replace(T_Notice_Bind, v+"|", new, -1)
+			break
+		}
+	}
+	return T_Notice_Bind
+}

+ 3 - 1
models/Device/DeviceParameter.go

@@ -20,10 +20,11 @@ type DeviceParameter struct {
 	T_overA int `orm:"size(5);null"` //数据保存间隔 超限报警触发间隔 s(60~600) 默认:60  *
 	T_outA  int `orm:"size(5);null"` //超限报警触发间隔 s(0,60~600)  为0时只触发一次 默认:60 *
 	T_lostA int `orm:"size(5);null"` //传感器掉线报警触发间隔  s(0,60~600) 为0时只触发一次 默认:60  *
-	T_bat   int `orm:"size(5);null"` // 电池电量下限   %(0~30) 默认:20 *
+	T_bat   int `orm:"size(5);null"` //电池电量下限   %(0~30) 默认:20 *
 
 	T_warn  int `orm:"size(5);null"` // 超限预警触发间隔 s(0,60~600)为0时只触发一次 默认:60  *
 	T_warnD int `orm:"size(5);null"` // 超限预警延时   s(0~600) 默认:0 *
+	T_speed int `orm:"size(5);null"` // 传感器采样率   s(1~240) 默认:15 *
 
 	T_btname string `orm:"size(256);''"` //蓝牙打印机名称
 	T_btsid  int    `orm:"size(256);''"` //打印机服务号
@@ -52,6 +53,7 @@ type DeviceParameter_R struct {
 	T_bat    int    // 电池电量下限   %(0~30) 默认:20 *
 	T_warn   int    // 超限预警触发间隔 s(0,60~600)为0时只触发一次 默认:60  *
 	T_warnD  int    // 超限预警延时   s(0~600) 默认:0 *
+	T_speed  int    // 传感器采样率   s(1~240) 默认:15 *
 	T_btname string // 蓝牙打印机名称
 	T_btsid  int    // 打印机服务号
 	T_btchar int    // 蓝牙特征码

+ 7 - 4
models/Device/DeviceSensorParameter.go

@@ -34,8 +34,9 @@ type DeviceSensorParameter struct {
 	T_hprel  float32 `orm:"size(200);null"`     //  湿度预警下限
 	T_hpreu  float32 `orm:"size(200);null"`     //  温度预警上限
 
-	T_en   int `orm:"size(2);default(1)"` // en:是否启用传感器,   0 停用  1 启用
-	T_free int `orm:"size(2);default(1)"` // free:监测点是否为闲置状态(空库,只监测不报警)    0 正常   1 空库
+	T_speed int `orm:"size(5);null"`       // 传感器采样率   s(1~240) 默认:15 *
+	T_en    int `orm:"size(2);default(1)"` // en:是否启用传感器,   0 停用  1 启用
+	T_free  int `orm:"size(2);default(1)"` // free:监测点是否为闲置状态(空库,只监测不报警)    0 正常   1 空库
 
 	// 逻辑字段
 	T_uuid      string `orm:"size(256);null"`      // 处理 人员
@@ -61,8 +62,9 @@ type DeviceSensorParameter_R struct {
 	T_hprel  float32 //  湿度预警下限
 	T_hpreu  float32 //  温度预警上限
 
-	T_en   int // en:是否启用传感器,
-	T_free int // free:监测点是否为闲置状态(空库,只监测不报警)
+	T_speed int // 传感器采样率   s(1~240) 默认:15 *
+	T_en    int // en:是否启用传感器,
+	T_free  int // free:监测点是否为闲置状态(空库,只监测不报警)
 
 	T_time models.JsonTime
 }
@@ -86,6 +88,7 @@ func DeviceSensorParameterToDeviceSensorParameter_R(r DeviceSensorParameter) (t
 	t.T_tpreu = r.T_tpreu
 	t.T_hprel = r.T_hprel
 	t.T_hpreu = r.T_hpreu
+	t.T_speed = r.T_speed
 	t.T_en = r.T_en
 	t.T_free = r.T_free
 	t.T_time.Time = r.CreateTime

+ 0 - 1
models/Warning/Warning.go

@@ -70,7 +70,6 @@ func (t *Warning) TableName() string {
 func init() {
 	//注册模型
 	orm.RegisterModel(new(Warning))
-	orm.Debug = true
 }
 
 // ---------------- 特殊方法 -------------------

+ 0 - 1
models/Warning/WarningSand.go

@@ -31,7 +31,6 @@ func (t *WarningSand) TableName() string {
 func init() {
 	//注册模型
 	orm.RegisterModel(new(WarningSand))
-	orm.Debug = true
 }
 
 // ---------------- 特殊方法 -------------------

+ 6 - 5
models/Warning/WarningType.go

@@ -14,9 +14,10 @@ import (
 
 // 模板
 type WarningType struct {
-	Id     int    `orm:"column(ID);size(11);auto;pk"`
-	T_name string `orm:"size(256);null"`            // 分类
-	T_Tips string `orm:"type(text);size(256);null"` // 提示
+	Id       int    `orm:"column(ID);size(11);auto;pk"`
+	T_name   string `orm:"size(256);null"`            // 分类
+	T_Tips   string `orm:"type(text);size(256);null"` // 提示
+	T_Notice int    `orm:"size(2);default(0)"`        // 是否在报警策略通知机制处展示 0 不展示  1 展示
 }
 
 //3
@@ -104,7 +105,7 @@ func Read_WarningType_All_T_Notice_mechanism() string {
 	o := orm.NewOrm()
 	var r []WarningType
 	qs := o.QueryTable(new(WarningType))
-	qs.All(&r)
+	qs.Filter("T_Notice", 1).All(&r)
 	str := ""
 	for _, v := range r {
 		str += v.T_Tips
@@ -159,7 +160,7 @@ func Read_WarningType_All_Power_T_Warning(T_warning string) (r []WarningType_R)
 
 // 获取全部
 func Read_WarningType_All_Maps() {
-	time.Sleep(time.Second)
+	time.Sleep(2 * time.Second)
 
 	logs.Println("=========== 初始化报警类型 =========")
 

+ 2 - 0
routers/v3.go

@@ -89,6 +89,8 @@ func init() {
 			beego.NSRouter("/Add", &controllers.DeviceController{}, "*:CompanyNotice_Add"),   // 添加报警策略
 			beego.NSRouter("/Edit", &controllers.DeviceController{}, "*:CompanyNotice_Edit"), // 修改报警策略
 			beego.NSRouter("/Del", &controllers.DeviceController{}, "*:CompanyNotice_Del"),   // 删除报警策略
+
+			beego.NSRouter("/Reset_Mechanism", &controllers.DeviceController{}, "*:CompanyNotice_Reset_Mechanism"), // 重置报警机制
 			// 报警策略绑定
 			beego.NSRouter("/Bind_Add", &controllers.DeviceController{}, "*:NoticeBind_Add"), // 添加报警策略绑定
 			beego.NSRouter("/Bind_Del", &controllers.DeviceController{}, "*:NoticeBind_Del"), // 删除报警策略绑定