From f1540038cf3bb9fccedd9010fb4c3e2005ab9720 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 16 十二月 2019 10:49:48 +0800
Subject: [PATCH] 编译追踪

---
 cache/cache.go |   82 ++++++++++++++++++++++++++++++++---------
 1 files changed, 64 insertions(+), 18 deletions(-)

diff --git a/cache/cache.go b/cache/cache.go
index 4906057..53fcea2 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -6,6 +6,7 @@
 	"basic.com/pubsub/protomsg.git"
 	"basic.com/valib/gopherdiscovery.git"
 	"basic.com/valib/logger.git"
+	"encoding/json"
 	"errors"
 	"fmt"
 	"github.com/gogo/protobuf/proto"
@@ -49,7 +50,9 @@
 
 	initTimeRules() //鍒濆鍖栨椂闂磋鍒欑紦瀛�
 
-	initCameraTaskRules() //鍒濆鍖栨憚鍍忔満浠诲姟瑙勫垯缂撳瓨
+	initCameraTaskRules() //鍒濆鍖栨憚鍍忔満浠诲姟瑙勫垯缂撳瓨鎸夋憚鍍忔満
+
+	initCameraTaskRulesAll() // 鍒濆鍖栨憚鍍忔満浠诲姟瑙勫垯缂撳瓨鍏ㄩ儴
 
 	initCamera() //鍒濆鍖栨憚鍍忔満淇℃伅
 
@@ -57,10 +60,11 @@
 
 	initSdks() //鍒濆鍖杝dk鍒楄〃淇℃伅
 
-	initSoData()
+	initSoData() // sopath
 
-	//initDictionary() // 鍒濆鍖栧瓧鍏�
+	initDictionary() // 鍒濆鍖栧瓧鍏�
 
+	initTaskSdkArgs()
 	initChan <- true
 }
 
@@ -84,6 +88,7 @@
 		initCameraTaskRules()
 	case protomsg.TableChanged_T_CameraTaskArgs: //鏇存柊鎽勫儚鏈鸿鍒欓厤缃弬鏁�
 		initCameraTaskRules()
+		initCameraTaskRulesAll()
 	case protomsg.TableChanged_T_Sdk: //鏇存柊sdk閰嶇疆
 		initSdks()
 	default:
@@ -126,6 +131,16 @@
 		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
@@ -141,14 +156,22 @@
 	var api dbapi.DicApi
 	flag, dics := api.FindByType("")
 	if flag {
-		for key, dics1 := range dics.(map[string]interface{}) {
-			for _,dic := range dics1.([]interface{}) {
-				cMap.Set(PREFIX_DIC+key+dic.(Dic).value, dic)
+		var dicss map[string][]Dic
+		b, _ := json.Marshal(dics)
+		if err := json.Unmarshal(b, &dicss); err == nil {
+			for key, dics1 := range dicss {
+				for _, dic := range dics1 {
+					cMap.Set(PREFIX_DIC + key + dic.Value, dic)
+				}
 			}
 		}
 	}
 }
-
+func initTaskSdkArgs() {
+	var api dbapi.TaskApi
+	all := api.FindAllTaskDefaultArgs("TASKRULE")
+	fmt.Println(all)
+}
 func initCameraTaskRules() {
 	var api dbapi.CameraTaskArgsApi
 	all := api.FindAll()
@@ -158,6 +181,11 @@
 	}
 }
 
+func initCameraTaskRulesAll() {
+	var api dbapi.CameraTaskArgsApi
+	all := api.FindAll()
+	cMap.Set(PREFIX_RULE, all)
+}
 func initSdks() {
 	var api dbapi.SdkApi
 	sdks := api.FindAll("")
@@ -194,6 +222,15 @@
 	}
 }
 
+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)
@@ -213,6 +250,15 @@
 		return nil
 	}
 }
+//鏍规嵁鎽勫儚鏈篿d浠庣紦瀛樹腑鑾峰彇鎽勫儚鏈虹殑浠诲姟瑙勫垯璁剧疆
+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)
@@ -222,16 +268,16 @@
 		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
@@ -253,11 +299,11 @@
 }
 
 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"`
 }

--
Gitblit v1.8.0