From f60d06a3269772904eae05cac266faead0330764 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期六, 08 二月 2025 19:16:46 +0800
Subject: [PATCH] 测试 场景分析 bug

---
 models/locationAnalysis.go |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/models/locationAnalysis.go b/models/locationAnalysis.go
index 1bd1828..b420691 100644
--- a/models/locationAnalysis.go
+++ b/models/locationAnalysis.go
@@ -65,9 +65,9 @@
 		m.KeyTypes = strings.Split(task.PersonType, ",")
 	}
 
-	if len(m.AreaIds) == 0 {
-		m.AreaIds = m.OrgIds
-	}
+	//if len(m.AreaIds) == 0 {
+	//	m.AreaIds = m.OrgIds
+	//}
 	for _, v := range task.Rules {
 		if v.Alias == "appearances" {
 			if val, ok := v.Value.(float64); ok {
@@ -136,6 +136,10 @@
 	var baseFilter, labelFilter, keyFilter []LocationPersonInfo
 	var document_number_map = make(map[string]LocationPersonInfo)
 	var document_number_list []string
+	community_ids := m.AreaIds
+	if len(community_ids) == 0 {
+		community_ids = m.OrgIds
+	}
 	err := db.GetDB().Raw(`
 		SELECT
 		    p.id,
@@ -148,7 +152,7 @@
 			p.id_card != "" 
 			AND (s.community_id IN ? OR s.org_id IN ?)
 			AND s.status IN ?
-		`, m.AreaIds, m.OrgIds, m.PersonIdentity).Scan(&baseFilter).Error
+		`, community_ids, m.OrgIds, m.PersonIdentity).Scan(&baseFilter).Error
 	if err != nil {
 		logger.Warnf(err.Error())
 	}
@@ -352,7 +356,7 @@
 			},
 		})
 	}
-
+	logger.Debugf("filters--------------------------------------- %s", filters)
 	query := map[string]interface{}{
 		"query": map[string]interface{}{
 			"bool": map[string]interface{}{
@@ -415,6 +419,14 @@
 		"size": 0,
 	}
 
+	query = map[string]interface{}{
+		"query": map[string]interface{}{
+			"bool": map[string]interface{}{
+				"filter": filters,
+			},
+		},
+		"size": 10000,
+	}
 	if err := json.NewEncoder(&buf).Encode(query); err != nil {
 		return nil, fmt.Errorf("error encoding query: %s", err)
 	}
@@ -441,7 +453,7 @@
 	if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
 		return nil, fmt.Errorf("error parsing response body: %s", err)
 	}
-
+	logger.Debugf("ressss--------------------------------------- %s", result)
 	// 瑙f瀽鑱氬悎缁撴灉
 	var records []*LocationRecord
 	if aggs, ok := result["aggregations"].(map[string]interface{}); ok {

--
Gitblit v1.8.0