| | |
| | | |
| | | initTimeRules() //初始化时间规则缓存 |
| | | |
| | | initCameraTaskRules() //初始化摄像机任务规则缓存 |
| | | initCameraTaskRules() //初始化摄像机任务规则缓存按摄像机 |
| | | |
| | | initCameraTaskRulesAll() // 初始化摄像机任务规则缓存全部 |
| | | |
| | | initCamera() //初始化摄像机信息 |
| | | |
| | |
| | | initCameraTaskRules() |
| | | case protomsg.TableChanged_T_CameraTaskArgs: //更新摄像机规则配置参数 |
| | | initCameraTaskRules() |
| | | initCameraTaskRulesAll() |
| | | case protomsg.TableChanged_T_Sdk: //更新sdk配置 |
| | | initSdks() |
| | | default: |
| | |
| | | cMap.Set(PREFIX_POLYGON+k, v) |
| | | } |
| | | } |
| | | // 缓存区域并不根据id |
| | | func initPolygonsById() { |
| | | var api dbapi.CameraApi |
| | | data := api.FindAllPolygons() |
| | | for _, item := range data { |
| | | if item.Type != "line" { |
| | | cMap.Set(PREFIX_POLYGON+item.Id, item) |
| | | } |
| | | } |
| | | } |
| | | |
| | | func initTimeRules() { |
| | | var api dbapi.CameraApi |
| | |
| | | if flag { |
| | | var dicss map[string][]Dic |
| | | b, _ := json.Marshal(dics) |
| | | if err := json.Unmarshal(b, &dicss) ; err == nil { |
| | | if err := json.Unmarshal(b, &dicss); err == nil { |
| | | for key, dics1 := range dicss { |
| | | for _,dic := range dics1 { |
| | | logger.Debug("字典缓存初始化",PREFIX_DIC+key+dic.value, dic) |
| | | cMap.Set(PREFIX_DIC+key+dic.value, dic) |
| | | for _, dic := range dics1 { |
| | | cMap.Set(PREFIX_DIC + key + dic.Value, dic) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | func initCameraTaskRulesAll() { |
| | | var api dbapi.CameraTaskArgsApi |
| | | all := api.FindAll() |
| | | cMap.Set(PREFIX_RULE, all) |
| | | } |
| | | func initSdks() { |
| | | var api dbapi.SdkApi |
| | | sdks := api.FindAll("") |
| | |
| | | } |
| | | } |
| | | |
| | | func GetPolygonsById(id string) *protomsg.CameraPolygon { |
| | | obj, b := cMap.Get(PREFIX_POLYGON + id) |
| | | if b { |
| | | return obj.(*protomsg.CameraPolygon) |
| | | } else { |
| | | return nil |
| | | } |
| | | } |
| | | |
| | | //从缓存中获取时间规则 |
| | | func GetTimeRuleById(id string) (exist bool, rule protomsg.CameraTimerule) { |
| | | obj, b := cMap.Get(PREFIX_TIME + id) |
| | |
| | | return nil |
| | | } |
| | | } |
| | | //根据摄像机id从缓存中获取摄像机的任务规则设置 |
| | | func GetCameraTaskRulesAll() []*protomsg.TaskGroupArgs { |
| | | obj, b := cMap.Get(PREFIX_RULE) |
| | | if b { |
| | | return obj.([]*protomsg.TaskGroupArgs) |
| | | } else { |
| | | return nil |
| | | } |
| | | } |
| | | |
| | | func GetSdkById(sdkId string) (sdk protomsg.Sdk, err error) { |
| | | obj, b := cMap.Get(PREFIX_SDK + sdkId) |
| | |
| | | return sdk, errors.New("sdk not found") |
| | | } |
| | | } |
| | | |
| | | // 获取字典值 |
| | | func GetDic(key string) (value string) { |
| | | obj, b := cMap.Get(PREFIX_SDK + key) |
| | | func GetDic(key string) (name string) { |
| | | obj, b := cMap.Get(PREFIX_DIC + key) |
| | | if b { |
| | | return obj.(Dic).value |
| | | return obj.(Dic).Name |
| | | } else { |
| | | return "" |
| | | } |
| | | } |
| | | |
| | | |
| | | func initSoData() { |
| | | var api dbapi.SoApi |
| | |
| | | } |
| | | |
| | | type Dic struct { |
| | | Id string |
| | | value string |
| | | Name string |
| | | Type string |
| | | Description string |
| | | Sort int |
| | | Parent_id string |
| | | Id string `json:"id"` |
| | | Value string `json:"value"` |
| | | Name string `json:"name"` |
| | | Type string `json:"type"` |
| | | Description string `json:"description"` |
| | | Sort int `json:"sort"` |
| | | Parent_id string `json:"parent_id"` |
| | | } |