|
@@ -184,6 +184,7 @@ func (this *HomeController) MainGrid6() {
|
|
|
// this.TplName = "homecontroller/maingrid6.tpl"
|
|
// this.TplName = "homecontroller/maingrid6.tpl"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// V2版大屏报警器获取报警信息(兼容V1版)
|
|
|
func (this *HomeController) TriggerPost() {
|
|
func (this *HomeController) TriggerPost() {
|
|
|
ccode := this.Ctx.Input.Param(":ccode")
|
|
ccode := this.Ctx.Input.Param(":ccode")
|
|
|
list_history := GetHistory(ccode)
|
|
list_history := GetHistory(ccode)
|
|
@@ -199,6 +200,7 @@ func (this *HomeController) TriggerPost() {
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// V2版大屏报警器获取绑定的设备信息(兼容V1版)
|
|
|
func (this *HomeController) ChannelPost() {
|
|
func (this *HomeController) ChannelPost() {
|
|
|
//获取分页信息
|
|
//获取分页信息
|
|
|
currentPage, _ := strconv.ParseInt(this.GetString("_currentPage"), 10, 64)
|
|
currentPage, _ := strconv.ParseInt(this.GetString("_currentPage"), 10, 64)
|
|
@@ -208,33 +210,92 @@ func (this *HomeController) ChannelPost() {
|
|
|
cmodels := make([]ChannelModel, 0)
|
|
cmodels := make([]ChannelModel, 0)
|
|
|
|
|
|
|
|
var list []userchannels.Channels
|
|
var list []userchannels.Channels
|
|
|
- var total int64 = 0
|
|
|
|
|
|
|
+ var total int = 0
|
|
|
if alertorstrs != "" {
|
|
if alertorstrs != "" {
|
|
|
- codes := strings.Replace(alertorstrs, ",", "','", -1)
|
|
|
|
|
|
|
+ // channelstr := strings.Replace(alertorstrs, "c", "", -1)
|
|
|
|
|
+ channels := strings.Split(alertorstrs, ",")
|
|
|
|
|
+
|
|
|
|
|
+ total = len(channels)
|
|
|
|
|
+ // totalPage := int(math.Ceil(float64(total) / float64(size)))
|
|
|
|
|
+ beginIndex := (int(currentPage) - 1) * int(size)
|
|
|
|
|
+ endIndex := int(currentPage)*int(size) - 1
|
|
|
|
|
+
|
|
|
|
|
+ curPageChannels := make([]string, 10)
|
|
|
|
|
+ if total <= endIndex {
|
|
|
|
|
+ curPageChannels = channels[beginIndex:]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ curPageChannels = channels[beginIndex : endIndex+1]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ curPageChannelStr := strings.Join(curPageChannels, ",")
|
|
|
|
|
+ codes := strings.Replace(curPageChannelStr, ",", "','", -1)
|
|
|
svc := userchannels.GetChannelService(MCS_DBE)
|
|
svc := userchannels.GetChannelService(MCS_DBE)
|
|
|
where := "c.Code in ('" + codes + "')"
|
|
where := "c.Code in ('" + codes + "')"
|
|
|
- total, list = svc.GetCnameByCodePage(currentPage, size, "Id", false, where)
|
|
|
|
|
- for _, v := range list {
|
|
|
|
|
- t, h, o2, co2, cjtime, lv, ls, voltage, power := GetTH(v.Code)
|
|
|
|
|
- //字符串分割
|
|
|
|
|
- codde := strings.Replace(v.Code, "c", "", 1)
|
|
|
|
|
- cdss := timeshijian(cjtime.Format("2006-01-02 15:04:05"))
|
|
|
|
|
- online := 1
|
|
|
|
|
- if cdss {
|
|
|
|
|
- online = 1
|
|
|
|
|
- } else {
|
|
|
|
|
- online = 0
|
|
|
|
|
|
|
+ _, list = svc.GetCnameByCodePage(1, size, "Id", false, where)
|
|
|
|
|
+
|
|
|
|
|
+ count := len(list)
|
|
|
|
|
+ for i := 0; i < count; i++ {
|
|
|
|
|
+ code := curPageChannels[i]
|
|
|
|
|
+ for _, v := range list {
|
|
|
|
|
+ if code == v.Code {
|
|
|
|
|
+ t, h, o2, co2, cjtime, lv, ls, voltage, power := GetTH(v.Code)
|
|
|
|
|
+ codde := strings.Replace(v.Code, "c", "", 1)
|
|
|
|
|
+ cdss := timeshijian(cjtime.Format("2006-01-02 15:04:05"))
|
|
|
|
|
+ online := 0
|
|
|
|
|
+ if cdss {
|
|
|
|
|
+ online = 1
|
|
|
|
|
+ }
|
|
|
|
|
+ cmodels = append(cmodels, ChannelModel{t, h, o2, co2, cjtime.Format("2006-01-02 15:04:05"), v.MaxValue, v.MinValue, v.Title, codde, lv, ls, v.DataItem, online, v.EModelType, voltage, power})
|
|
|
|
|
+
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- cmodels = append(cmodels, ChannelModel{t, h, o2, co2, cjtime.Format("2006-01-02 15:04:05"), v.MaxValue, v.MinValue, v.Title, codde, lv, ls, v.DataItem, online, v.EModelType, voltage, power})
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
var datainfo DataInfo
|
|
var datainfo DataInfo
|
|
|
datainfo.Items = cmodels
|
|
datainfo.Items = cmodels
|
|
|
- datainfo.CurrentItemCount = total
|
|
|
|
|
|
|
+ datainfo.CurrentItemCount = int64(total)
|
|
|
this.Data["json"] = datainfo
|
|
this.Data["json"] = datainfo
|
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// func (this *HomeController) ChannelPost() {
|
|
|
|
|
+// //获取分页信息
|
|
|
|
|
+// currentPage, _ := strconv.ParseInt(this.GetString("_currentPage"), 10, 64)
|
|
|
|
|
+// size, _ := strconv.ParseInt(this.GetString("_size"), 10, 64)
|
|
|
|
|
+// ccode := this.Ctx.Input.Param(":ccode")
|
|
|
|
|
+// alertorstrs := GetAlertor(ccode)
|
|
|
|
|
+// cmodels := make([]ChannelModel, 0)
|
|
|
|
|
+
|
|
|
|
|
+// var list []userchannels.Channels
|
|
|
|
|
+// var total int64 = 0
|
|
|
|
|
+// if alertorstrs != "" {
|
|
|
|
|
+// codes := strings.Replace(alertorstrs, ",", "','", -1)
|
|
|
|
|
+// svc := userchannels.GetChannelService(MCS_DBE)
|
|
|
|
|
+// where := "c.Code in ('" + codes + "')"
|
|
|
|
|
+// total, list = svc.GetCnameByCodePage(currentPage, size, "Id", false, where)
|
|
|
|
|
+// for _, v := range list {
|
|
|
|
|
+// t, h, o2, co2, cjtime, lv, ls, voltage, power := GetTH(v.Code)
|
|
|
|
|
+// //字符串分割
|
|
|
|
|
+// codde := strings.Replace(v.Code, "c", "", 1)
|
|
|
|
|
+// cdss := timeshijian(cjtime.Format("2006-01-02 15:04:05"))
|
|
|
|
|
+// online := 1
|
|
|
|
|
+// if cdss {
|
|
|
|
|
+// online = 1
|
|
|
|
|
+// } else {
|
|
|
|
|
+// online = 0
|
|
|
|
|
+// }
|
|
|
|
|
+// cmodels = append(cmodels, ChannelModel{t, h, o2, co2, cjtime.Format("2006-01-02 15:04:05"), v.MaxValue, v.MinValue, v.Title, codde, lv, ls, v.DataItem, online, v.EModelType, voltage, power})
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// var datainfo DataInfo
|
|
|
|
|
+// datainfo.Items = cmodels
|
|
|
|
|
+// datainfo.CurrentItemCount = total
|
|
|
|
|
+// this.Data["json"] = datainfo
|
|
|
|
|
+// this.ServeJSON()
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
func (this *HomeController) ChannelPost5() {
|
|
func (this *HomeController) ChannelPost5() {
|
|
|
ccode := this.Ctx.Input.Param(":ccode")
|
|
ccode := this.Ctx.Input.Param(":ccode")
|
|
|
alertorstrs := GetAlertor(ccode)
|
|
alertorstrs := GetAlertor(ccode)
|
|
@@ -264,6 +325,8 @@ func EditSend(list []triggerhistory.Trigger_History) {
|
|
|
svc.EditSend(list)
|
|
svc.EditSend(list)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取报警器取绑定传感器信息(保存在缓存中) todo 持久化的DB中
|
|
|
|
|
+// RequestData示例数据 "RequestData": "c52021810,c52061395,c52063466,c52063465,c52063463"
|
|
|
func GetAlertor(bbmac string) string {
|
|
func GetAlertor(bbmac string) string {
|
|
|
selectstr := ""
|
|
selectstr := ""
|
|
|
lastdata, err := GetChannelLast("calert" + bbmac)
|
|
lastdata, err := GetChannelLast("calert" + bbmac)
|
|
@@ -273,6 +336,7 @@ func GetAlertor(bbmac string) string {
|
|
|
return selectstr
|
|
return selectstr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取传感器最新数据(从缓存中获取)
|
|
|
func GetTH(code string) (t, h, o2, co2 float32, cjtime time.Time, levelv, levelsignal, v, p int) {
|
|
func GetTH(code string) (t, h, o2, co2 float32, cjtime time.Time, levelv, levelsignal, v, p int) {
|
|
|
lastdata, err := GetChannelLast(code)
|
|
lastdata, err := GetChannelLast(code)
|
|
|
if err == nil && lastdata.Time.Unix() > 0 {
|
|
if err == nil && lastdata.Time.Unix() > 0 {
|