|
@@ -17,15 +17,15 @@ import (
|
|
// 模板
|
|
// 模板
|
|
type Warning struct {
|
|
type Warning struct {
|
|
Id int64 `orm:"column(ID);size(11);auto;pk"`
|
|
Id int64 `orm:"column(ID);size(11);auto;pk"`
|
|
- T_pid int `orm:"index;size(256);null"` // Account.Company 绑定公司
|
|
|
|
- T_tp int `orm:"index;size(200);null"` // 报警类型 ->WarningList
|
|
|
|
- T_sn string `orm:"index;size(256);null"` // 设备序列号
|
|
|
|
- T_D_name string `orm:"size(256);null"` // 设备名称
|
|
|
|
- T_id int `orm:"index;size(200);null"` // 传感器 ID
|
|
|
|
- T_DS_name string `orm:"size(256);null"` // 传感器名称
|
|
|
|
- T_Remark string `orm:"type(text);null"` // 采集内容
|
|
|
|
- T_Ut time.Time `orm:"index;type(timestamp);null;"` // 采集时间
|
|
|
|
- T_fUt time.Time `orm:"type(timestamp);null;"` // 首次采集时间
|
|
|
|
|
|
+ T_pid int `orm:"size(256);null"` // Account.Company 绑定公司
|
|
|
|
+ T_tp int `orm:"size(200);null"` // 报警类型 ->WarningList
|
|
|
|
+ T_sn string `orm:"index;size(256);null"` // 设备序列号
|
|
|
|
+ T_D_name string `orm:"size(256);null"` // 设备名称
|
|
|
|
+ T_id int `orm:"size(200);null"` // 传感器 ID
|
|
|
|
+ T_DS_name string `orm:"size(256);null"` // 传感器名称
|
|
|
|
+ T_Remark string `orm:"type(text);null"` // 采集内容
|
|
|
|
+ T_Ut time.Time `orm:"type(timestamp);null;"` // 采集时间
|
|
|
|
+ T_fUt time.Time `orm:"type(timestamp);null;"` // 首次采集时间
|
|
|
|
|
|
T_Text string `orm:"type(text);null"` // 处理备注
|
|
T_Text string `orm:"type(text);null"` // 处理备注
|
|
T_Log string `orm:"type(text);null"` // 通知日志
|
|
T_Log string `orm:"type(text);null"` // 通知日志
|
|
@@ -36,6 +36,13 @@ type Warning struct {
|
|
UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"` //auto_now 每次 model 保存时都会对时间自动更新
|
|
UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"` //auto_now 每次 model 保存时都会对时间自动更新
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 多字段索引
|
|
|
|
+func (u *Warning) TableIndex() [][]string {
|
|
|
|
+ return [][]string{
|
|
|
|
+ []string{"T_pid", "T_tp", "T_State"},
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
分表机制
|
|
分表机制
|
|
|--------30天--------|
|
|
|--------30天--------|
|
|
@@ -239,7 +246,7 @@ func Read_Warning_List(T_pid int, tpList []string, T_name string, T_handle int,
|
|
|
|
|
|
cond := orm.NewCondition()
|
|
cond := orm.NewCondition()
|
|
|
|
|
|
- cond1 := cond.And("T_State__gt", 0)
|
|
|
|
|
|
+ cond1 := orm.NewCondition()
|
|
|
|
|
|
if T_pid > 0 {
|
|
if T_pid > 0 {
|
|
cond1 = cond1.And("T_pid", T_pid)
|
|
cond1 = cond1.And("T_pid", T_pid)
|
|
@@ -248,7 +255,15 @@ func Read_Warning_List(T_pid int, tpList []string, T_name string, T_handle int,
|
|
cond1 = cond1.And("T_tp__in", tpList)
|
|
cond1 = cond1.And("T_tp__in", tpList)
|
|
}
|
|
}
|
|
if len(T_name) > 0 {
|
|
if len(T_name) > 0 {
|
|
- cond1 = cond1.AndCond(cond.Or("T_sn__icontains", T_name).Or("T_D_name__icontains", T_name).Or("T_id__icontains", T_name).Or("T_DS_name", T_name))
|
|
|
|
|
|
+ if len(T_name) == 16 {
|
|
|
|
+ cond1 = cond1.And("T_sn", T_name)
|
|
|
|
+ } else {
|
|
|
|
+ cond1 = cond1.AndCond(cond.Or("T_sn__icontains", T_name).
|
|
|
|
+ Or("T_D_name__icontains", T_name).
|
|
|
|
+ Or("T_id__icontains", T_name).
|
|
|
|
+ Or("T_DS_name__icontains", T_name))
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
if len(Time_start_) > 0 {
|
|
if len(Time_start_) > 0 {
|
|
@@ -262,6 +277,9 @@ func Read_Warning_List(T_pid int, tpList []string, T_name string, T_handle int,
|
|
if T_handle == 1 {
|
|
if T_handle == 1 {
|
|
cond1 = cond1.And("T_State__gt", 1)
|
|
cond1 = cond1.And("T_State__gt", 1)
|
|
}
|
|
}
|
|
|
|
+ if T_handle == 2 {
|
|
|
|
+ cond1 = cond1.And("T_State__gt", 0)
|
|
|
|
+ }
|
|
if T_handle == 3 {
|
|
if T_handle == 3 {
|
|
cond1 = cond1.And("T_State", 3)
|
|
cond1 = cond1.And("T_State", 3)
|
|
}
|
|
}
|
|
@@ -314,8 +332,7 @@ func Read_Admin_Warning_List(T_pids string, T_tp []string, T_name string, T_hand
|
|
}
|
|
}
|
|
|
|
|
|
cond := orm.NewCondition()
|
|
cond := orm.NewCondition()
|
|
-
|
|
|
|
- cond1 := cond.And("T_State__gt", 0)
|
|
|
|
|
|
+ cond1 := orm.NewCondition()
|
|
|
|
|
|
if T_pids != "*" && len(T_pids) > 0 {
|
|
if T_pids != "*" && len(T_pids) > 0 {
|
|
list := lib.SplitStringIds(T_pids, "P")
|
|
list := lib.SplitStringIds(T_pids, "P")
|
|
@@ -326,7 +343,14 @@ func Read_Admin_Warning_List(T_pids string, T_tp []string, T_name string, T_hand
|
|
|
|
|
|
}
|
|
}
|
|
if len(T_name) > 0 {
|
|
if len(T_name) > 0 {
|
|
- cond1 = cond1.AndCond(cond.Or("T_sn__icontains", T_name).Or("T_D_name__icontains", T_name).Or("T_id__icontains", T_name).Or("T_DS_name", T_name))
|
|
|
|
|
|
+ if len(T_name) == 16 {
|
|
|
|
+ cond1 = cond1.And("T_sn", T_name)
|
|
|
|
+ } else {
|
|
|
|
+ cond1 = cond1.AndCond(cond.Or("T_sn__icontains", T_name).
|
|
|
|
+ Or("T_D_name__icontains", T_name).
|
|
|
|
+ Or("T_id__icontains", T_name).
|
|
|
|
+ Or("T_DS_name__icontains", T_name))
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if len(Time_start_) > 0 {
|
|
if len(Time_start_) > 0 {
|
|
@@ -339,6 +363,9 @@ func Read_Admin_Warning_List(T_pids string, T_tp []string, T_name string, T_hand
|
|
if T_handle == 1 {
|
|
if T_handle == 1 {
|
|
cond1 = cond1.And("T_State__gt", 1)
|
|
cond1 = cond1.And("T_State__gt", 1)
|
|
}
|
|
}
|
|
|
|
+ if T_handle == 2 {
|
|
|
|
+ cond1 = cond1.And("T_State__gt", 0)
|
|
|
|
+ }
|
|
if T_handle == 3 {
|
|
if T_handle == 3 {
|
|
cond1 = cond1.And("T_State", 3)
|
|
cond1 = cond1.And("T_State", 3)
|
|
}
|
|
}
|
|
@@ -411,7 +438,7 @@ func Read_Warning_Backups(T_pid int, T_year string, T_month string, tpList []str
|
|
//不填或0:所有 1:已处理 2:未处理
|
|
//不填或0:所有 1:已处理 2:未处理
|
|
if T_handle == 1 {
|
|
if T_handle == 1 {
|
|
//cond1 = cond1.And("T_Text__isnull", true)
|
|
//cond1 = cond1.And("T_Text__isnull", true)
|
|
- sql_WHERE += " AND t__tstate > 1"
|
|
|
|
|
|
+ sql_WHERE += " AND t__state > 1"
|
|
}
|
|
}
|
|
if T_handle == 3 {
|
|
if T_handle == 3 {
|
|
//cond1 = cond1.And("T_Text__isnull", false).And("T_State", 2)
|
|
//cond1 = cond1.And("T_Text__isnull", false).And("T_State", 2)
|