| | |
| | | "errors" |
| | | "fmt" |
| | | "encoding/json" |
| | | "log" |
| | | "net" |
| | | "time" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/dbapi.git" |
| | | "github.com/golang/protobuf/proto" |
| | | "ruleprocess/ruleserver" |
| | | "ruleprocess/util" |
| | | "github.com/golang/protobuf/proto" |
| | | "github.com/satori/go.uuid" |
| | | ) |
| | | |
| | | var weedfsUrl = "http://192.168.1.182:6333/submit" |
| | | // 人脸的数据结构 |
| | | type PerVideoPicture struct { |
| | | Id string `json:"id"` |
| | |
| | | |
| | | type AlarmRule struct { |
| | | GroupId string `json:"groupId"` |
| | | AlarmLevel int32 `json:"alarmLevel"` |
| | | AlarmLevel int32 `json:"alarmLevel"` |
| | | RuleText string `json:"ruleText"` |
| | | } |
| | | |
| | | // 往ES插数据 |
| | | func InsertToEs(msg ruleserver.ResultMsg) { |
| | | fmt.Println("往ES插数据") |
| | | |
| | |
| | | alarmRules = append(alarmRules,AlarmRule{result.RuleGroupId,result.AlarmLevel,result.RuleText}) |
| | | } |
| | | isAlarm := "" |
| | | resp := make(map[string]interface{}) |
| | | if len(alarmRules) > 0 { |
| | | isAlarm = "1" |
| | | // 解压缩并上传图片 |
| | | bdata, err := util.UnCompress(msg.Data) |
| | | if err != nil { |
| | | panic("解压缩图片时出现错误") |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | resp,err = util.PostFormBufferData(weedfsUrl,i.Data,uuid.NewV4().String()) |
| | | }else { |
| | | isAlarm = "0" |
| | | continue |
| | | //continue |
| | | } |
| | | log.Println("图片上传返回值:",resp) |
| | | // 查询本机信息 |
| | | flag,localConfig := dbapi.SysSetApi{}.GetServerInfo() |
| | | if !flag { |
| | |
| | | localConfig.ServerName, |
| | | serverIp, |
| | | "", |
| | | "", |
| | | resp["fileUrl"].(string), |
| | | time.Now().Format("2006-01-02 15:04:05"), |
| | | "", |
| | | isAlarm, |