package controllers import ( "encoding/binary" "encoding/json" "fmt" "strconv" "strings" "time" "dashoo.cn/base_common/labsop" "dashoo.cn/base_common/utils" "dashoo.cn/mcs_api/business/device" "dashoo.cn/mcs_api/business/ledscreenmessage" "dashoo.cn/mcs_api/business/logsinfo" "dashoo.cn/mcs_common/business/actions" "dashoo.cn/mcs_common/business/equipment" "dashoo.cn/mcs_common/business/userchannels" ) // 报警器接口说明 type AlertsController struct { BaseController } type AlertModel struct { Title string `json:"title"` Serial string `json:"serial"` TagCode string `json:"tagCode"` BindDevices []string `json:"binddevices"` } type LedInfoModel struct { TimeRange []time.Time `json:"timerange"` Message string `json:"message"` Serial string `json:"serial"` Id int `json:"id"` } type LedMessageList struct { CurrentItemCount int64 `json:"currentItemCount,omitempty"` //结果集中的条目数目 ItemsPerPage int64 `json:"itemsPerPage,omitempty"` //每页记录数目 PageIndex int64 `json:"pageIndex,omitempty"` //条目的当前页索引 Items []ledscreenmessage.LED_ScreenMessage `json:"items"` //数据列表 } // @Title 报警器列表 // @Description 设备列表 // @Success 200 {object} business.device.DeviceChannels // @router /list [get] func (this *AlertsController) List() { page := this.GetPageInfoForm() svc := device.GetDeviceService(utils.DBE) svcuc := userchannels.GetUserChannelService(utils.DBE) channelid := svcuc.GetChannelids(utils.ToStr(this.User.Id)) Uid := utils.ToStr(this.User.Id) where := " (a.CreateUserId=" + utils.ToStr(this.User.Id) + " or a.Id in (" + strings.Join(channelid, ",") + ")) and a.DataItem in (" + Alertor_Alarm + ") " keyword := this.GetString("keyword") if keyword != "" { where = where + " and (a.Title like '%" + keyword + "%' or a.TagCode like '%" + keyword + "%' or a.Serial like '%" + keyword + "%')" } total, devices := svc.GetChannelsListOrder(page.CurrentPage, page.Size, "c.sortcode, a.CreateOn desc", where, Uid) var datainfo DataInfo datainfo.Items = devices datainfo.CurrentItemCount = total this.Data["json"] = &datainfo this.ServeJSON() } // @Title 验证序列号 // @Description 验证序列号 // @Param code path string true "设备SN" // @Success 200 {object} ErrorInfo // @Failure 403 :code 为空 // @router /validcode/:code [get] func (this *AlertsController) ValidCode() { code := this.Ctx.Input.Param(":code") var errinfo ErrorInfo var entity device.Device strUrl := utils.Cfg.MustValue("server", "apiurl") + "/devices/serial?serial=" + code fmt.Println("--------strUrlstrUrl------------", strUrl) json.Unmarshal(Apiget(strUrl), &entity) if entity.Id != 0 && DeviceItemContainint(Device_Alertor, entity.DataItem) { errinfo.Message = "验证通过!" errinfo.Code = 0 } else { errinfo.Message = "报警器序列号不存在!" errinfo.Code = -1 } this.Data["json"] = &errinfo this.ServeJSON() } // @Title 创建报警器 // @Description 创建报警器 // @Param body body business.device.DeviceChannels "报警器信息" // @Success 200 {object} controllers.Request // @router / [post] func (this *AlertsController) AddPost() { var model AlertModel var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &model) var errinfo ErrorInfo u, p := this.GetuAndp() var devices device.Device devices.Serial = model.Serial devices.Code = model.TagCode devices.Title = model.Title svc := device.GetDeviceService(utils.DBE) var entity device.Device strUrl := utils.Cfg.MustValue("server", "apiurl") + "/devices/serial?serial=" + devices.Serial json.Unmarshal(Apiget(strUrl), &entity) if svc.VerifyDevice(entity.Id) { errinfo.Message = "报警器已存在!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() return } else { if devices.Title == "" { devices.Title = entity.Title } if devices.About == "" { devices.About = entity.About } if devices.Tags == "" { devices.Tags = entity.Tags } if devices.Local == "" { devices.Local = entity.Local } if devices.Latitude == 0 { devices.Latitude = entity.Latitude devices.Longitude = entity.Longitude } devices.Wdid = entity.Id devices.Dtype = 1 devices.CreateUserId, _ = utils.StrTo(this.User.Id).Int() devices.CreateBy = this.User.Realname devices.DataItem = entity.DataItem //添加device表 _, err := svc.InsertEntity(&devices) fmt.Println("----------------------") //添加device成功则添加channel表 if err == nil { strUrl = utils.Cfg.MustValue("server", "apiurl") + "/devices/" + utils.ToStr(entity.Id) + "?u=" + u + "&p=" + p Apipost(strUrl, "PUT", devices) strUrl = utils.Cfg.MustValue("server", "apiurl") + "/devices/sourse/" + utils.ToStr(entity.Id) + "?u=" + u + "&p=" + p + "&sourse=coldchain&account=" + this.GetAccode() + "&accountname=" + this.User.Realname Apipost(strUrl, "PUT", devices) if entity.Id != 0 { var channels []device.Channels strUrl = utils.Cfg.MustValue("server", "apiurl") + "/devices/" + utils.ToStr(entity.Id) + "/channelsallclos?u=" + u + "&p=" + p json.Unmarshal(Apiget(strUrl), &channels) //默认添加动作 isaddaction := true for _, v := range channels { if DeviceItemContainint(Alertor_AlarmBindData, v.DataItem) || DeviceItemContainint(Alertor_Alarm, v.DataItem) { v.Title = devices.Title v.TagCode = devices.Code v.DId = devices.Id v.CreateUserId, _ = utils.StrTo(this.User.Id).Int() v.CreateBy = this.User.Realname svc.InsertEntity(&v) } //绑定设备 if DeviceItemContainint(Alertor_AlarmBindData, v.DataItem) { if len(model.BindDevices) > 0 { // bindchannels := "c" + strings.Join(model.BindDevices, ",c") // WriteAlertBindValue("alert"+model.Serial, bindchannels) //查询绑定设备 bindchannels := "'" + strings.Join(model.BindDevices, "','") + "'" svdevc := device.GetDeviceService(utils.DBE) svceq := equipment.GetEquipmentService(utils.DBE) eids := svceq.GetEquipmentidsByUid(this.User.Id) where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_HomeList + ") " where += " and a.Serial in (" + bindchannels + ")" _, devices := svdevc.GetChannelsList(-1, -1, where, this.User.Id) //报警器网关一体机下发数据 var downdatas labsop.AlarmGatewayBindings downdatadetail := make([]labsop.AlarmGatewayBinding, 0) //报警器绑定数据 bindchannelcodes := make([]string, 0) for _, v := range devices { if v.Code != "" { //报警器绑定数据 bindchannelcodes = append(bindchannelcodes, v.Code) //网关一体机下发数据 if len(v.Serial) == 8 { mac1, _ := strconv.ParseUint(v.Serial[0:2], 16, 0) mac2, _ := strconv.ParseUint(v.Serial[2:4], 16, 0) mac3, _ := strconv.ParseUint(v.Serial[4:6], 16, 0) mac4, _ := strconv.ParseUint(v.Serial[6:], 16, 0) max := strconv.FormatFloat(v.MaxValue, 'E', -1, 64) //Cmd和需绑定的无线记录仪编号 sendbyte := []byte{0x00, byte(mac1), byte(mac2), byte(mac3), byte(mac4)} name := utils.Substr(v.Title, 0, 10) namebyte := []byte(CodertoGBK(name)) fuzai := []byte{0x73, byte(len(namebyte))} fuzai = append(fuzai, namebyte...) //yuzhi := []byte{0x65, 0x01, 0x4E, 0x20, 0x65, 0x00, 0x4E, 0x20, 0x66, 0x01, 0x4E, 0x20, 0x66, 0x00, 0xB1, 0xE0} //fuzai = append(yuzhi, fuzai...) fuzailen := byte(len(fuzai)) //拼接负载长度 if v.MaxValue != 0 && max != "" { v.MaxValue = v.MaxValue * 100 data := v.MaxValue i := uint16(data) c := make([]byte, 2) binary.BigEndian.PutUint16(c, i) v.MinValue = v.MinValue * 100 data1 := v.MinValue i1 := uint16(data1) c1 := make([]byte, 2) binary.BigEndian.PutUint16(c1, i1) sendms := []byte{0x65, 0x00, c1[0], c1[1], 0x65, 0x01, c[0], c[1], 0x66, 0x00, 0x00, 0x00, 0x66, 0x01, 0x26, 0xAC} changdu1 := append(sendms, fuzai...) changdu := byte(len(changdu1)) sendms = []byte{changdu, 0x65, 0x00, c1[0], c1[1], 0x65, 0x01, c[0], c[1], 0x66, 0x00, 0x00, 0x00, 0x66, 0x01, 0x26, 0xAC} sendbyte = append(sendbyte, sendms...) } else { sendbyte = append(sendbyte, fuzailen) } //拼接负载数据 sendbyte = append(sendbyte, fuzai...) downdatadetail = append(downdatadetail, labsop.AlarmGatewayBinding{v.Serial, sendbyte}) } } } // 写入绑定缓存 for i, _ := range model.BindDevices { model.BindDevices[i] = "c" + model.BindDevices[i] } WriteAlertBindValue("alert"+model.Serial, strings.Join(model.BindDevices, ",")) // 写入网关报警一体机下发数据 downdatas.AlarmBinds = downdatadetail labsop.UpdateAlarmbinddata(model.Serial, downdatas) } } //不需要添加动作 if DeviceItemContainint(Alertor_NotNeedAction, v.DataItem) { isaddaction = false } } //添加一条动作 if isaddaction { var action actions.Actions action.AItem = 4 action.AName = devices.Title action.SPara4 = devices.Serial action.Enabled = 1 var status Status strUrl = utils.Cfg.MustValue("server", "apiurl") + "/actions/?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "POST", action), &status) if status.Status == 0 { action.AccCode = this.GetAccode() action.Wdid = status.Id action.Id, _ = utils.StrTo(status.Id).Int() action.CreateUserId, _ = utils.StrTo(this.User.Id).Int() action.CreateBy = this.User.Realname svc.InsertEntity(&action) //插入数据库 } } } errinfo.Message = "保存成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() return } else { errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } } } // @Title 获取绑定设备 // @Description 获取绑定设备 // @Param code path string true "设备SN" // @Success 200 {object} []string // @Failure 403 :code 为空 // @router /binddevices/:code [get] func (this *AlertsController) GetBindDevices() { code := this.Ctx.Input.Param(":code") var bddevices []string = []string{} selectstr := "" lastdata, err := GetChannelLast("alert" + code) if err == nil && lastdata.Time.Unix() > 0 { selectstr = strings.Replace(lastdata.RequestData, "c", "", -1) } if selectstr != "" { bddevices = strings.Split(selectstr, ",") } this.Data["json"] = bddevices this.ServeJSON() } // @Title 编辑报警器 // @Description 编辑报警器 // @Param code path string true "需要修改的报警器编号" // @Param body body business.device.DeviceChannels "报警器信息" // @Success 200 {object} ErrorInfo // @router /:code [put] func (this *AlertsController) EditPost() { code := this.Ctx.Input.Param(":code") var errinfo ErrorInfo if code == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() return } code = "c" + code var model AlertModel var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &model) u, p := this.GetuAndp() var devices logsinfo.AlertorLog svc := device.GetDeviceService(utils.DBE) has := svc.GetEntity(&devices, "Serial='"+model.Serial+"' and DataItem=4") if !has { errinfo.Message = "操作失败!请求数据有误" errinfo.Code = -3 this.Data["json"] = &errinfo this.ServeJSON() return } deviceLog_Log := Logcompare{Value1: DeviceLog_Log{devices.Id, devices.Serial, devices.Code, devices.Title, devices.Local, devices.About}, Value2: DeviceLog_Log{devices.Id, devices.Serial, model.TagCode, model.Title, devices.Local, devices.About}} svc.InsertUpdateLog(0, &deviceLog_Log, utils.ToStr(this.User.Id), this.User.Realname, AlertorLogTName) devices.Code = model.TagCode devices.Title = model.Title devices.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int() devices.ModifiedBy = this.User.Realname var cols []string = []string{"Title", "Code", "ModifiedUserId", "ModifiedBy"} _, err := svc.UpdateEntityByIdCols(devices.Id, &devices, cols) if err == nil { strUrl := utils.Cfg.MustValue("server", "apiurl") + "/devices/" + utils.ToStr(devices.Wdid) + "?u=" + u + "&p=" + p Apipost(strUrl, "PUT", devices) //绑定设备 if len(model.BindDevices) > 0 { //查询绑定设备 bindchannels := "'" + strings.Join(model.BindDevices, "','") + "'" svdevc := device.GetDeviceService(utils.DBE) svceq := equipment.GetEquipmentService(utils.DBE) eids := svceq.GetEquipmentidsByUid(this.User.Id) where := " (a.CreateUserId=" + this.User.Id + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + ChannelItem_HomeList + ") " where += " and a.Serial in (" + bindchannels + ")" _, devices := svdevc.GetChannelsList(-1, -1, where, this.User.Id) //报警器网关一体机下发数据 var downdatas labsop.AlarmGatewayBindings downdatadetail := make([]labsop.AlarmGatewayBinding, 0) //报警器绑定数据 bindchannelcodes := make([]string, 0) for _, v := range devices { if v.Code != "" { //报警器绑定数据 bindchannelcodes = append(bindchannelcodes, v.Code) //网关一体机下发数据 if len(v.Serial) == 8 { mac1, _ := strconv.ParseUint(v.Serial[0:2], 16, 0) mac2, _ := strconv.ParseUint(v.Serial[2:4], 16, 0) mac3, _ := strconv.ParseUint(v.Serial[4:6], 16, 0) mac4, _ := strconv.ParseUint(v.Serial[6:], 16, 0) //Cmd和需绑定的无线记录仪编号 sendbyte := []byte{0x00, byte(mac1), byte(mac2), byte(mac3), byte(mac4)} name := utils.Substr(v.Title, 0, 10) namebyte := []byte(CodertoGBK(name)) fuzai := []byte{0x73, byte(len(namebyte))} fuzai = append(fuzai, namebyte...) //yuzhi := []byte{0x65, 0x01, 0x4E, 0x20, 0x65, 0x00, 0x4E, 0x20, 0x66, 0x01, 0x4E, 0x20, 0x66, 0x00, 0xB1, 0xE0} //fuzai = append(yuzhi, fuzai...) fuzailen := byte(len(fuzai)) //如果有温度阀值则 给服务器下发增加温度阀值 max := strconv.FormatFloat(v.MaxValue, 'E', -1, 64) //拼接负载长度 if v.MaxValue != 0 && max != "" { v.MaxValue = v.MaxValue * 100 data := v.MaxValue i := uint16(data) c := make([]byte, 2) binary.BigEndian.PutUint16(c, i) v.MinValue = v.MinValue * 100 data1 := v.MinValue i1 := uint16(data1) c1 := make([]byte, 2) binary.BigEndian.PutUint16(c1, i1) sendms := []byte{0x65, 0x00, c1[0], c1[1], 0x65, 0x01, c[0], c[1], 0x66, 0x00, 0x00, 0x00, 0x66, 0x01, 0x26, 0xAC} changdu1 := append(sendms, fuzai...) changdu := byte(len(changdu1)) sendms = []byte{changdu, 0x65, 0x00, c1[0], c1[1], 0x65, 0x01, c[0], c[1], 0x66, 0x00, 0x00, 0x00, 0x66, 0x01, 0x26, 0xAC} sendbyte = append(sendbyte, sendms...) } else { sendbyte = append(sendbyte, fuzailen) } //拼接负载数据 sendbyte = append(sendbyte, fuzai...) downdatadetail = append(downdatadetail, labsop.AlarmGatewayBinding{v.Serial, sendbyte}) } } } fmt.Println("-------downdatadetail-------", model.Serial, downdatadetail) // 写入绑定缓存 for i, _ := range model.BindDevices { model.BindDevices[i] = "c" + model.BindDevices[i] } WriteAlertBindValue("alert"+model.Serial, strings.Join(model.BindDevices, ",")) // 写入网关报警一体机下发数据 downdatas.AlarmBinds = downdatadetail labsop.UpdateAlarmbinddata(model.Serial, downdatas) } //修改动作 svcaction := actions.GetActionsService(utils.DBE) action := svcaction.GetAlertor(devices.Serial) if action.Id > 0 { action.AName = devices.Title var status Status strUrl = utils.Cfg.MustValue("server", "apiurl") + "/actions/" + utils.ToStr(action.Id) + "?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "PUT", action), &status) if status.Status == 0 { var cols []string = []string{"AName"} svcaction.UpdateEntityByIdCols(action.Id, &action, cols) } } errinfo.Message = "保存成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "保存失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 删除报警器 // @Description 删除报警器 // @Param code path string true "需要删除的报警器编号" // @Success 200 {object} ErrorInfo // @Failure 403 :code 为空 // @router /:code [delete] func (this *AlertsController) Delete() { code := this.Ctx.Input.Param(":code") var errinfo ErrorInfo if code == "" { errinfo.Message = "操作失败!请求信息不完整" errinfo.Code = -3 this.Data["json"] = &errinfo this.ServeJSON() return } code = "c" + code var entity device.Channels var devices device.Device var devicesempty device.Device var entityempty device.Channels svc := device.GetDeviceService(utils.DBE) has := svc.GetEntity(&entity, "Code='"+code+"'") if has { dataitem := entity.DataItem err := svc.DeleteEntityAndBackup(entity.Id, &entity, &entityempty, utils.ToStr(this.User.Id), this.User.Username) if err == nil { //取消waterdrop绑定状态 u, p := this.GetuAndp() strUrl := utils.Cfg.MustValue("server", "apiurl") + "/channels/unbingding/" + code + "?u=" + u + "&p=" + p Apipost(strUrl, "PUT", nil) //删除设备 //取消waterdrop绑定状态 wdid := svc.GetWDidByDid(entity.DId) strUrldevice := utils.Cfg.MustValue("server", "apiurl") + "/devices/unbingding/" + utils.ToStr(wdid) + "?u=" + u + "&p=" + p Apipost(strUrldevice, "PUT", nil) svc.DeleteEntityAndBackup(entity.DId, &devices, &devicesempty, utils.ToStr(this.User.Id), this.User.Username) var channeldevice device.Channels haschannel := svc.GetEntity(&channeldevice, " DataItem=3 and DId="+utils.ToStr(entity.DId)) if haschannel { svc.DeleteEntityAndBackup(channeldevice.Id, &channeldevice, &entityempty, utils.ToStr(this.User.Id), this.User.Username) cstrUrl := utils.Cfg.MustValue("server", "apiurl") + "/channels/unbingding/" + channeldevice.Code + "?u=" + u + "&p=" + p Apipost(cstrUrl, "PUT", nil) } //无动作不需要删除 if DeviceItemContain(Alertor_NotNeedAction, utils.ToStr(dataitem)) { //删除屏显内容 strUrldeletemsg := utils.Cfg.MustValue("server", "apiurl") + "/ledscreenmessage/clear?u=" + u + "&p=" + p + "&code=" + entity.Serial + "&sourse=" + ProjectSourse + "&account=" + this.GetAccode() + "&dataitem=1" Apipost(strUrldeletemsg, "DELETE", nil) } else { //删除动作 svcaction := actions.GetActionsService(utils.DBE) action := svcaction.GetAlertor(entity.Serial) if action.Id > 0 { var status Status //删除报警动作 strUrl = utils.Cfg.MustValue("server", "apiurl") + "/triggers/deletebyaid/" + utils.ToStr(action.Id) + "?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "DELETE", nil), &status) //删除动作 strUrl = utils.Cfg.MustValue("server", "apiurl") + "/actions/" + utils.ToStr(action.Id) + "?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "DELETE", nil), &status) if status.Status == 0 { var actionempty actions.Actions svc.DeleteEntityById(action.Id, actionempty) } } } //删除绑定设备 WriteAlertBindValue("alert"+strings.Replace(code, "c", "", 1), "") errinfo.Message = "删除成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error()) errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } else { errinfo.Message = "删除失败!" errinfo.Code = -2 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 创建屏显信息 // @Description 创建屏显信息 // @Param body body business.ledscreenmessage.LED_ScreenMessage "屏显信息" // @Success 200 {object} controllers.Request // @router /ledinfo/add [put] func (this *AlertsController) LedInfoAdd() { var model LedInfoModel var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &model) var entity ledscreenmessage.LED_ScreenMessage var status Status var errinfo ErrorInfo entity.StartTime = model.TimeRange[0] entity.EndTime = model.TimeRange[1] entity.Message = model.Message entity.Code = model.Serial entity.DataItem = 1 entity.ProjectSourse = ProjectSourse entity.ProjectAccount = this.GetAccode() entity.ProjectAccountName = this.User.Realname u, p := this.GetuAndp() strUrl := utils.Cfg.MustValue("server", "apiurl") + "/ledscreenmessage?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "POST", entity), &status) if status.Status == 0 { errinfo.Message = "屏显信息保存成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "屏显信息保存失败!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 屏显信息列表 // @Description 屏显信息列表 // @Success 200 {object} business.ledscreenmessage.LED_ScreenMessage // @router /ledinfo/list [get] func (this *AlertsController) LedInfoList() { var entity LedMessageList u, p := this.GetuAndp() code := this.GetString("serial") strUrl := utils.Cfg.MustValue("server", "apiurl") + "/ledscreenmessage?u=" + u + "&p=" + p + "&page=1&itemsPerPage=-1&code=" + code + "&sourse=" + ProjectSourse + "&account=" + this.GetAccode() + "&dataitem=1" json.Unmarshal(Apiget(strUrl), &entity) fmt.Println(entity, strUrl) this.Data["json"] = entity this.ServeJSON() } // @Title 创建屏显信息 // @Description 创建屏显信息 // @Param body body business.ledscreenmessage.LED_ScreenMessage "屏显信息" // @Success 200 {object} controllers.Request // @router /ledinfo/update [put] func (this *AlertsController) LedInfoUpdate() { var model LedInfoModel var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &model) var entity ledscreenmessage.LED_ScreenMessage var status Status var errinfo ErrorInfo entity.StartTime = model.TimeRange[0] entity.EndTime = model.TimeRange[1] entity.Message = model.Message entity.DataState = 0 u, p := this.GetuAndp() strUrl := utils.Cfg.MustValue("server", "apiurl") + "/ledscreenmessage/" + utils.ToStr(model.Id) + "?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "PUT", entity), &status) if status.Status == 0 { errinfo.Message = "屏显信息保存成功!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "屏显信息保存失败!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } } // @Title 删除屏显信息 // @Description 删除屏显信息 // @Param body body business.ledscreenmessage.LED_ScreenMessage "屏显信息" // @Success 200 {object} controllers.Request // @router /ledinfo/delete [put] func (this *AlertsController) LedInfoDelete() { var model LedInfoModel var jsonblob = this.Ctx.Input.RequestBody json.Unmarshal(jsonblob, &model) var status Status var errinfo ErrorInfo u, p := this.GetuAndp() strUrl := utils.Cfg.MustValue("server", "apiurl") + "/ledscreenmessage/" + utils.ToStr(model.Id) + "?u=" + u + "&p=" + p json.Unmarshal(Apipost(strUrl, "DELETE", nil), &status) if status.Status == 0 { errinfo.Message = "屏显信息已删除!" errinfo.Code = 0 this.Data["json"] = &errinfo this.ServeJSON() } else { errinfo.Message = "屏显信息删除失败!" errinfo.Code = -1 this.Data["json"] = &errinfo this.ServeJSON() } }