From 2c9e82adc057f330d7c56be04c4333dae92cfd5c Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期五, 26 七月 2019 19:08:47 +0800
Subject: [PATCH] add Videopersonsinfosbyid

---
 /dev/null   |  187 --------------------------
 EsClient.go |  151 +++++++++++++++++++++
 EsApi.go    |   35 ++++
 3 files changed, 185 insertions(+), 188 deletions(-)

diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 84b050c..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,187 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ChangeListManager">
-    <list default="true" id="e1f05817-985c-458c-b947-3716306448a1" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/EsApi.go" beforeDir="false" afterPath="$PROJECT_DIR$/EsApi.go" afterDir="false" />
-    </list>
-    <ignored path="$PROJECT_DIR$/out/" />
-    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
-    <option name="SHOW_DIALOG" value="false" />
-    <option name="HIGHLIGHT_CONFLICTS" value="true" />
-    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
-    <option name="LAST_RESOLUTION" value="IGNORE" />
-  </component>
-  <component name="FileEditorManager">
-    <leaf>
-      <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/EsApi.go">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="312">
-              <caret line="319" column="45" selection-start-line="319" selection-start-column="38" selection-end-line="319" selection-end-column="45" />
-              <folding>
-                <element signature="e#16#126#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/EsClient_test.go">
-          <provider selected="true" editor-type-id="text-editor" />
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/EsClient.go">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="-1843">
-              <caret line="60" column="39" selection-start-line="60" selection-start-column="32" selection-end-line="60" selection-end-column="39" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-    </leaf>
-  </component>
-  <component name="GOROOT" path="D:\Go" />
-  <component name="Git.Settings">
-    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
-  </component>
-  <component name="IdeDocumentHistory">
-    <option name="CHANGED_PATHS">
-      <list>
-        <option value="$PROJECT_DIR$/EsApi.go" />
-      </list>
-    </option>
-  </component>
-  <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="953" />
-    <option name="width" value="974" />
-    <option name="height" value="1167" />
-  </component>
-  <component name="ProjectView">
-    <navigator proportions="" version="1">
-      <foldersAlwaysOnTop value="true" />
-    </navigator>
-    <panes>
-      <pane id="PackagesPane" />
-      <pane id="Scope" />
-      <pane id="ProjectPane" />
-    </panes>
-  </component>
-  <component name="PropertiesComponent">
-    <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="aspect.path.notification.shown" value="true" />
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1564119272205" />
-    <property name="go.gopath.indexing.explicitly.defined" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../esutiltest" />
-    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
-    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
-    <property name="settings.editor.selected.configurable" value="go.vgo" />
-  </component>
-  <component name="RunDashboard">
-    <option name="ruleStates">
-      <list>
-        <RuleState>
-          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
-        </RuleState>
-        <RuleState>
-          <option name="name" value="StatusDashboardGroupingRule" />
-        </RuleState>
-      </list>
-    </option>
-  </component>
-  <component name="SvnConfiguration">
-    <configuration />
-  </component>
-  <component name="TaskManager">
-    <task active="true" id="Default" summary="Default task">
-      <changelist id="e1f05817-985c-458c-b947-3716306448a1" name="Default Changelist" comment="" />
-      <created>1564037615220</created>
-      <option name="number" value="Default" />
-      <option name="presentableId" value="Default" />
-      <updated>1564037615220</updated>
-      <workItem from="1564037616784" duration="11715000" />
-    </task>
-    <servers />
-  </component>
-  <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="11715000" />
-  </component>
-  <component name="ToolWindowManager">
-    <frame x="-8" y="-8" width="1936" height="1176" extended-state="6" />
-    <editor active="true" />
-    <layout>
-      <window_info id="Image Layers" />
-      <window_info id="Designer" />
-      <window_info id="UI Designer" />
-      <window_info id="Capture Tool" />
-      <window_info id="Favorites" side_tool="true" />
-      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12153518" />
-      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
-      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
-      <window_info anchor="bottom" id="Database Changes" />
-      <window_info anchor="bottom" id="Version Control" />
-      <window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.33877158" />
-      <window_info anchor="bottom" id="Event Log" side_tool="true" />
-      <window_info anchor="bottom" id="Message" order="0" />
-      <window_info anchor="bottom" id="Find" order="1" />
-      <window_info anchor="bottom" id="Run" order="2" />
-      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
-      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
-      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
-      <window_info anchor="bottom" id="TODO" order="6" />
-      <window_info anchor="right" id="Palette" />
-      <window_info anchor="right" id="Theme Preview" />
-      <window_info anchor="right" id="Maven" />
-      <window_info anchor="right" id="Capture Analysis" />
-      <window_info anchor="right" id="Palette&#9;" />
-      <window_info anchor="right" id="Database" />
-      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
-      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
-      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
-    </layout>
-  </component>
-  <component name="TypeScriptGeneratedFilesManager">
-    <option name="version" value="1" />
-  </component>
-  <component name="VgoProject">
-    <integration-enabled>true</integration-enabled>
-  </component>
-  <component name="editorHistoryManager">
-    <entry file="file://$PROJECT_DIR$/EsClient.go">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="-1843">
-          <caret line="60" column="39" selection-start-line="60" selection-start-column="32" selection-end-line="60" selection-end-column="39" />
-        </state>
-      </provider>
-    </entry>
-    <entry file="file://$PROJECT_DIR$/EsClient_test.go">
-      <provider selected="true" editor-type-id="text-editor" />
-    </entry>
-    <entry file="file://$PROJECT_DIR$/EsApi.go">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="312">
-          <caret line="319" column="45" selection-start-line="319" selection-start-column="38" selection-end-line="319" selection-end-column="45" />
-          <folding>
-            <element signature="e#16#126#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
-  </component>
-  <component name="masterDetails">
-    <states>
-      <state key="ProjectJDKs.UI">
-        <settings>
-          <last-edited>1.8</last-edited>
-          <splitter-proportions>
-            <option name="proportions">
-              <list>
-                <option value="0.2" />
-              </list>
-            </option>
-          </splitter-proportions>
-        </settings>
-      </state>
-    </states>
-  </component>
-</project>
\ No newline at end of file
diff --git a/EsApi.go b/EsApi.go
index 246b57a..0baed8f 100644
--- a/EsApi.go
+++ b/EsApi.go
@@ -100,6 +100,40 @@
     return dbtable, nil
 }
 
+// 鏍规嵁鎶撴媿浜哄憳id鏌ヨ鎶撴媿浜哄憳淇℃伅
+func Videopersonsinfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Videopersons, error) {
+	var videopersonsInfo []protomsg.Videopersons
+	videopersonsPersonId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1)
+	var dbinfoRequest = `
+            {
+            	"query": {
+            		"bool": {
+            			"filter": [{
+            				"terms": {
+            					"id": [
+            						"`+ videopersonsPersonId +`"
+            					]
+            				}
+            			}]
+            		}
+            	}
+            }
+        `
+	buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest))
+	if err != nil {
+		return videopersonsInfo,  err
+	}
+
+	sources, err := Sourcelist(buf)
+	if err != nil {
+		return videopersonsInfo , err
+	}
+
+	videoperson := Videopersonsbyid(sources)
+	println(videoperson)
+	return videoperson,nil
+}
+
 // 鏍规嵁搴曞簱浜哄憳id鏌ヨ搴曞簱浜哄憳淇℃伅
 func Dbpersoninfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Dbperson, error) {
     var dbinfo []protomsg.Dbperson
@@ -161,7 +195,6 @@
     if err != nil {
           return "",err 
     }
-
     for _, source := range sources {
         if name, ok := source["tableName"].(string); ok {
             tablename = name
diff --git a/EsClient.go b/EsClient.go
index 9972c13..851c42c 100644
--- a/EsClient.go
+++ b/EsClient.go
@@ -53,6 +53,157 @@
     }
     return 
 }
+
+//瑙f瀽鎶撴媿搴撲汉鍛樼粨鏋�
+func Videopersonsbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Videopersons) {
+    var ok bool
+
+    var tmpinfo protomsg.Videopersons
+    for _, source := range  sources{
+        tmpinfo.Id, ok =   source["id"].(string)
+        if !ok {
+            continue
+        }
+
+        tmpinfo.CameraId, ok    =   source["cameraId"].(string)
+        if !ok {
+            continue
+        }
+
+        tmpinfo.CameraAddr, ok     =   source["cameraAddr"].(string)
+        if !ok {
+            continue
+        }
+
+        tmpinfo.PicDate,ok  =   source["picDate"].(string)
+        Isnil("picDate", ok)
+        tmpinfo.PicMaxUrl,ok =  source["picMaxUrl"].(string)
+        Isnil("picMaxUrl", ok)
+        tmpinfo.TaskId,ok     =  source["taskId"].(string)
+        Isnil("taskId", ok)
+        tmpinfo.TaskName,ok          =  source["taskName"].(string)
+        Isnil("taskName", ok)
+        tmpinfo.SdkName,ok       =  source["sdkName"].(string)
+        Isnil("sdkName", ok)
+        tmpinfo.Content,ok =  source["content"].(string)
+        Isnil("content",ok)
+        tmpinfo.LikeDate,ok = source["likeDate"].(string)
+        Isnil("likeDate",ok)
+        tmpinfo.DetectScore,ok =  source["detectScore"].(string)
+        Isnil("detectScore", ok)
+        tmpinfo.Sex,ok = source["sex"].(string)
+        Isnil("sex",ok)
+
+        age,ok  :=   source["age"].(float64)
+        if ok {
+            tmpinfo.Age= int32(age)
+        }
+        Isnil("age", ok)
+
+        tmpinfo.AgeDescription,ok = source["ageDescription"].(string)
+        Isnil("ageDescription",ok)
+        tmpinfo.Race,ok = source["race"].(string)
+        Isnil("race",ok)
+        tmpinfo.SmileLevel,ok = source["smileLevel"].(string)
+        Isnil("smileLevel",ok)
+        tmpinfo.BeautyLevel,ok = source["beautyLevel"].(string)
+        Isnil("beautyLevel",ok)
+        tmpinfo.PicSmUrl,ok = source["picSmUrl"].(string)
+        Isnil("picSmUrl",ok)
+        tmpinfo.VideoUrl,ok = source["videoUrl"].(string)
+        Isnil("videoUrl",ok)
+        tmpinfo.AnalyServerId,ok = source["analyServerId"].(string)
+        Isnil("analyServerId",ok)
+        tmpinfo.AnalyServerName,ok = source["analyServerName"].(string)
+        Isnil("analyServerName",ok)
+        tmpinfo.AnalyServerIp,ok = source["analyServerIp"].(string)
+        Isnil("analyServerIp",ok)
+        tmpinfo.ClusterId,ok = source["clusterId"].(string)
+        Isnil("clusterId",ok)
+        tmpinfo.IsAlarm,ok = source["isAlarm"].(string)
+        Isnil("isAlarm",ok)
+        tmpinfo.IsAckAlarm,ok = source["isAckAlarm"].(string)
+        Isnil("isAckAlarm",ok)
+
+        isCollect,ok  :=   source["isCollect"].(float64)
+        if ok {
+            tmpinfo.IsDelete= int32(isCollect)
+        }
+        Isnil("isDelete", ok)
+        isDelete,ok  :=   source["isDelete"].(float64)
+        if ok {
+            tmpinfo.IsDelete= int32(isDelete)
+        }
+        Isnil("isDelete", ok)
+        if source["alarmRules"] != nil {
+            fmt.Println(source["alarmRules"])
+            for _,v := range source["alarmRules"].([]interface{}) {
+                m := v.(map[string]interface{})
+                ar := protomsg.AlarmRules{}
+                ar.GroupId,ok = m["groupId"].(string)
+                Isnil("groupId",ok)
+                ar.AlarmLevel,ok = m["alarmLevel"].(string)
+                Isnil("alarmLevel",ok)
+                ar.RuleText,ok = m["ruleText"].(string)
+                Isnil("ruleText",ok)
+                ar.DefenceState,ok = m["defenceState"].(bool)
+                Isnil("DefenceState",ok)
+                tmpinfo.AlarmRules = append( tmpinfo.AlarmRules, &ar)
+            }
+
+        }
+        if source["baseInfo"] != nil {
+            fmt.Println(source["baseInfo"])
+            for _,v := range source["baseInfo"].([]interface{}) {
+                m := v.(map[string]interface{})
+                fmt.Println("m:",m)
+                bi := protomsg.BaseInfo{}
+                bi.TableId,ok = m["tableId"].(string)
+                Isnil("tableId",ok)
+                bi.TableName,ok = m["tableName"].(string)
+                Isnil("tableName",ok)
+                compareScore,ok := m["compareScore"].(float64)
+                if ok {
+                    bi.CompareScore= float32(compareScore)
+                }
+                Isnil("compareScore", ok)
+
+                bi.PersonId,ok = m["personId"].(string)
+                Isnil("personId",ok)
+                bi.PersonName,ok = m["personName"].(string)
+                Isnil("personName",ok)
+                bi.PersonPicUrl,ok = m["personPicUrl"].(string)
+                Isnil("personPicUrl",ok)
+                bi.PhoneNum,ok = m["phoneNum"].(string)
+                Isnil("phoneNum",ok)
+                bi.Sex,ok = m["sex"].(string)
+                Isnil("sex",ok)
+                bi.IdCard,ok = m["idCard"].(string)
+                Isnil("idCard",ok)
+                bi.MonitorLevel,ok = m["monitorLevel"].(string)
+                Isnil("monitorLevel",ok)
+                bi.Content,ok = m["content"].(string)
+                Isnil("content",ok)
+                bwType,ok := m["bwType"].(float64)
+                if ok {
+                    bi.BwType= int32(bwType)
+                }
+                Isnil("bwType", ok)
+
+                tmpinfo.BaseInfo = append(tmpinfo.BaseInfo, &bi)
+            }
+
+        }
+
+        //鏍规嵁 tableid 鑾峰彇 tablename
+        //name, _:= Dbtablename(tmpinfo.TableId)
+        //tmpinfo.TableName= name
+        tmpinfos = append(tmpinfos, tmpinfo)
+    }
+
+    return tmpinfos
+}
+
 //瑙f瀽搴曞簱浜哄憳缁撴瀯
 func Dbpersonbyid(sources []map[string]interface{}) (tmpinfos []protomsg.Dbperson) {
         var ok bool

--
Gitblit v1.8.0