From dfddbbf858b4f24f515746d74d2a6830d8835f1d Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期二, 19 十一月 2019 15:57:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 /dev/null               |  176 --------------------------------------------
 controllers/esSearch.go |    2 
 controllers/tasklist.go |    2 
 extend/config/config.go |    6 +
 4 files changed, 7 insertions(+), 179 deletions(-)

diff --git a/controllers/esSearch.go b/controllers/esSearch.go
index 84dc7d8..ffad124 100644
--- a/controllers/esSearch.go
+++ b/controllers/esSearch.go
@@ -204,7 +204,7 @@
 		"\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," +
 		"\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}" +
 		"}"
-	//logger.Debug("findEsData.param:",prama)
+	logger.Debug("findEsData.param:",prama)
 	//鏁版嵁瑙f瀽
 	tokenRes := esutil.GetEsDataReq(url, prama, true)
 	//fmt.Println(tokenRes)
diff --git a/controllers/tasklist.go b/controllers/tasklist.go
index 13653a6..a59b93d 100644
--- a/controllers/tasklist.go
+++ b/controllers/tasklist.go
@@ -21,7 +21,7 @@
 // @Tags es
 // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
 // @Failure 500 {string} json "{"code":500,  msg:"杩斿洖閿欒淇℃伅", success:false}"
-// @Router /data/api-v/es/tagList [POST]
+// @Router /data/api-v/es/taskList [POST]
 func (sc *EsSearchController) PostEsTaskList(c *gin.Context) {
 	localConf, err2 := cache.GetServerInfo()
 	if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
diff --git a/extend/config/config.go b/extend/config/config.go
index a62cdfa..61e5126 100644
--- a/extend/config/config.go
+++ b/extend/config/config.go
@@ -40,6 +40,10 @@
 }
 
 type esindexlist struct {
+	VideoPersons   index `mapstructure:"videopersons"`
+	DbTables       index `mapstructure:"dbtables"`
+	Dbtablepersons index `mapstructure:"dbtablepersons"`
+	Personaction   index `mapstructure:"personaction"`
 	AiOcean   index `mapstructure:"aiOcean"`
 }
 type index struct {
@@ -86,7 +90,7 @@
 	viper.AddConfigPath("/opt/vasystem/config/")
 	err = viper.ReadInConfig()
 	if err != nil {
-		log.Fatal("error on parsing configuration file")
+		log.Fatal("error on parsing configuration file",err)
 	}
 	viper.UnmarshalKey("es", EsInfo)
 	viper.UnmarshalKey("server", Server)
diff --git a/service/CameraVideoService.go b/service/CameraVideoService.go
deleted file mode 100644
index 8a158f2..0000000
--- a/service/CameraVideoService.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package service
-
-import (
-	"basic.com/valib/logger.git"
-	"encoding/json"
-	"fmt"
-	"strconv"
-	"webserver/cache"
-	"webserver/extend/config"
-	"webserver/extend/esutil"
-	"webserver/models"
-)
-
-// 鍦板簱浜哄憳鏁版嵁 涓� 姣斿鍋氬噯澶�
-func QueryDbPersonsForCompare(reqBody models.EsSearch) map[string]interface{} {
-	localConf, err2 := cache.GetServerInfo()
-	if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
-		logger.Debug("localConfig is wrong!!!")
-		return nil
-	}
-	url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
-		"/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_search"
-	tableIds := make([]string, 20)
-	if reqBody.DataBases != nil {
-		tableIds = reqBody.DataBases
-	}
-	startDate := ""
-	endDate := ""
-	if reqBody.SearchTime != nil && len(reqBody.SearchTime) >= 2 {
-		dates := reqBody.SearchTime
-		startDate = dates[0]
-		endDate = dates[1] // 璧峰缁撴潫鏃堕棿
-	}
-	contentValue := reqBody.InputValue //杈撳叆妗嗗唴瀹�
-	/*page := 1 ;if reqBody["page"] != nil { page = int(reqBody["page"].(float64))       } // 椤电爜
-	size := 8 ;if reqBody["size"] != nil { size = int(reqBody["size"].(float64))       }// 鏉℃暟
-	from := (page - 1) * size
-	*/
-	syncTerm := ""
-	contentParam := ""
-	if len(tableIds) < 1 {
-		// / 鎵�鏈変汉鍛�
-	} else {
-		bytes, _ := json.Marshal(tableIds)
-		syncTerm += ",{\"terms\":{\"tableId\":" + string(bytes) + "}}" // 搴曞簱浜哄憳
-	}
-	if startDate != "" && endDate != "" {
-		syncTerm += ",{\"range\":{\"createTime\":{\"from\":\"" + startDate + "\"," +
-			"\"to\":\"" + endDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}" // 搴曞簱浜哄憳
-	}
-	if contentValue != "" {
-		contentParam = ",\"must\":[{\"multi_match\":{\"query\":\"" + contentValue + "\",\"type\":\"best_fields\"," +
-			"\"fields\":[\"personName\",\"sex\",\"idcard\",\"phoneNum\",\"reserved\"],\"boost\":1}}]"
-	}
-	params := "{\"query\":{\"bool\":{\"filter\":[" +
-		"{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":0,\"size\":10000,\"sort\":{\"uuid\":{\"order\":\"desc\"}}}"
-	fmt.Print("鏌ヨ鍏ㄩ儴搴曞簱浜哄憳 璇锋眰url:%s;\n 璇锋眰鍙傛暟params:%s", url, params)
-	data := esutil.GetEsDataReq(url, params, true)
-	return data
-}
diff --git a/service/EnableStatusControlService.go b/service/EnableStatusControlService.go
deleted file mode 100644
index a0439b1..0000000
--- a/service/EnableStatusControlService.go
+++ /dev/null
@@ -1,176 +0,0 @@
-package service
-
-import (
-	"basic.com/valib/logger.git"
-	"encoding/json"
-	"fmt"
-	"strconv"
-	"strings"
-	"time"
-	"webserver/cache"
-	"webserver/extend/config"
-	"webserver/extend/esutil"
-)
-
-func GetVerificationData() []map[string]interface{} {
-	localConf, err2 := cache.GetServerInfo()
-	if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
-		logger.Debug("localConfig is wrong!!!")
-		return nil
-	}
-	url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
-		"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_search"
-
-	jsonDSL := `{
-	"query": {
-		"bool": {
-			"filter": [{
-					"term": {
-						"isDelete": "0"
-					}
-				},
-				{
-					"terms": {
-						"analyServerId": ["` + localConf.ServerId + `",""]
-					}
-				}
-			]
-		}
-	},
-	"size": 10000
-}
-`
-	buf, err := esutil.EsReq("POST", url, []byte(jsonDSL))
-	if err != nil {
-		logger.Debug(err)
-	}
-
-	sources, err := esutil.Sourcelist(buf)
-	if err != nil {
-		logger.Debug(err)
-	}
-	return sources
-}
-
-func VerificationTime(source []map[string]interface{}) map[string][]string {
-	resultInfo := make(map[string][]string, 0)
-	currentTime := time.Now()
-	for _, v := range source {
-		id := v["id"].(string)
-		startTime := v["startTime"].(string)
-		endTime := ""
-		if v["endTime"] != nil {
-			endTime = v["endTime"].(string)
-		}
-		st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
-		if endTime != "" {
-			et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
-			if et.After(currentTime) && st.Before(currentTime) {
-				resultInfo["effective"] = append(resultInfo["effective"], id)
-			} else {
-				resultInfo["invalid"] = append(resultInfo["invalid"], id)
-			}
-		} else if st.Before(currentTime) && endTime == "" {
-			resultInfo["effective"] = append(resultInfo["effective"], id)
-		} else {
-			resultInfo["invalid"] = append(resultInfo["invalid"], id)
-		}
-	}
-	//fmt.Println(resultInfo)
-	return resultInfo
-}
-
-func UpdateEnableStatus(id []string, flag bool) (message string) {
-	ids := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1)
-	status := 0
-	if flag == true {
-		status = 1
-	}
-	enable := strconv.Itoa(status)
-	localConf, err2 := cache.GetServerInfo()
-	if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
-		logger.Debug("localConfig is wrong!!!")
-		return "localConf wrong"
-	}
-	url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
-		"/" + config.EsInfo.EsIndex.DbTables.IndexName + "/_update_by_query?refresh"
-	jsonDsl := `
-			{
-	"script": {
-		"lang": "painless",
-		"inline": "ctx._source.enable = ` + enable + `"
-	},
-	"query": {
-		"terms": {
-			"id": ["` + ids + `"]
-		}
-	}
-}
-`
-	buf, err := esutil.EsReq("POST", url, []byte(jsonDsl))
-	if err != nil {
-		logger.Debug("http request info is err!")
-		message = "淇敼澶辫触"
-	}
-	var info interface{}
-	json.Unmarshal(buf, &info)
-	out, ok := info.(map[string]interface{})
-	if !ok {
-		logger.Debug("http response interface can not change map[string]interface{}")
-		message = "淇敼澶辫触"
-	}
-	middle, ok := out["updated"].(float64)
-	if !ok {
-		logger.Debug("first result change error!")
-		message = "淇敼澶辫触"
-	}
-	if middle > 0 {
-		logger.Debug("淇敼鎴愬姛")
-		//if flag {//鐢熸晥鐨�
-		//	discovery.AddDbMessage(&protomsg.EsPersonCacheChange{
-		//		Type: protomsg.EsCacheChanged_T_DbTable,
-		//		PersonId: "",
-		//		TableId: id,
-		//		Feature: "",
-		//		Action: protomsg.DbAction_Insert,
-		//	})
-		//} else {//澶辨晥鐨�
-		//	discovery.AddDbMessage(&protomsg.EsPersonCacheChange{
-		//		Type: protomsg.EsCacheChanged_T_DbTable,
-		//		PersonId: "",
-		//		TableId: id,
-		//		Feature: "",
-		//		Action: protomsg.DbAction_Insert,
-		//	})
-		//}
-		message = "淇敼鎴愬姛"
-	}
-	return message
-}
-
-func InitEnableStatus() (messageInfo string) {
-	verificationData := GetVerificationData()
-	verificationTime := VerificationTime(verificationData)
-	idOfEffective := verificationTime["effective"]
-	idOfinvalid := verificationTime["invalid"]
-	mesInfo := false
-	effectiveMesInfo := ""
-	invalidMesInfo := ""
-	if len(idOfEffective) > 0 {
-		effectiveMesInfo = UpdateEnableStatus(idOfEffective, true)
-	} else {
-		effectiveMesInfo = "淇敼鎴愬姛"
-	}
-	if len(idOfinvalid) > 0 {
-		invalidMesInfo = UpdateEnableStatus(idOfinvalid, false)
-	} else {
-		invalidMesInfo = "淇敼鎴愬姛"
-	}
-	if effectiveMesInfo == "淇敼鎴愬姛" && invalidMesInfo == "淇敼鎴愬姛" {
-		mesInfo = true
-	}
-	if mesInfo == true {
-		messageInfo = "淇敼鎴愬姛"
-	}
-	return messageInfo
-}

--
Gitblit v1.8.0