From 3898fd838546c35f70eb533d4cbc340e41b553d2 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期一, 05 八月 2019 19:38:09 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.14:10010/r/webserver

---
 controllers/dbtablesCon.go   |    5 +++++
 controllers/monitoring.go    |    5 +++--
 controllers/dbtableperson.go |   40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/controllers/dbtableperson.go b/controllers/dbtableperson.go
index bad1888..9c362a7 100644
--- a/controllers/dbtableperson.go
+++ b/controllers/dbtableperson.go
@@ -132,6 +132,46 @@
 	}
 }
 
+func UpdateDbPersonsOfDbTable(id string) (message string) {
+	url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
+		"/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh"
+	jsonDSL := `
+			{
+	"script": {
+		"lang": "painless",
+		"inline": "ctx._source.enable = 0"
+	},
+	"query": {
+		"term": {
+			"tableId": "` + id + `"
+		}
+	}
+}
+`
+	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("淇敼鎴愬姛")
+		message = "淇敼鎴愬姛,鏇存柊鐘舵�佹潯鏁颁负" + strconv.Itoa(int(middle))
+	}
+	return message
+}
+
 // @Summary 鍒犻櫎搴曞簱浜哄憳
 // @Description 鍒犻櫎搴撲汉鍛�
 // @Accept  x-www-form-urlencoded
diff --git a/controllers/dbtablesCon.go b/controllers/dbtablesCon.go
index cb21510..82daabe 100644
--- a/controllers/dbtablesCon.go
+++ b/controllers/dbtablesCon.go
@@ -98,6 +98,11 @@
 	data := esutil.GetEsDataReq(url, params, false)
 	//c.JSON(200, changeEsRespData(data, "淇敼鎴愬姛"))
 	result := changeEsRespData(data, "淇敼鎴愬姛")
+	if dbtable.Enable == 0 {
+		res := UpdateDbPersonsOfDbTable(dbtable.Id)
+		//fmt.Println("鍚屾淇敼浜哄憳鐘舵�佹垚鍔�----",res)
+		logger.Debug("鍚屾淇敼浜哄憳鐘舵�佹垚鍔�----", res)
+	}
 	if result["success"].(bool) {
 		//code.Success.Message = "淇敼搴曞簱鎴愬姛"
 		//if dbtable.Enable ==1 {
diff --git a/controllers/monitoring.go b/controllers/monitoring.go
index b78788d..209f66f 100644
--- a/controllers/monitoring.go
+++ b/controllers/monitoring.go
@@ -26,7 +26,7 @@
 	searchBody := make(map[string]interface{}, 0)
 
 	c.BindJSON(&searchBody)
-	index := config.EsInfo.EsIndex.VideoPersons.IndexName
+	index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName
 	cameraIdStr := ""
 	cameraId := searchBody["treeNodes"].([]interface{})
 	if cameraId != nil && len(cameraId) > 0 {
@@ -56,7 +56,8 @@
 		"\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
 		"\"size\":\"1000\"," +
 		"\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}"
-	//fmt.Println(prama)
+	fmt.Println(prama)
+	fmt.Println(url)
 	tokenRes := esutil.GetEsDataReq(url, prama, true)
 	/*	for _, value := range tokenRes["datalist"].([]interface{}) {
 		if value.(map[string]interface{})["personId"] != nil {

--
Gitblit v1.8.0