From 167dbfefe9a0b8ace3e433e9797be515da7cc6d7 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期六, 08 二月 2025 18:16:41 +0800
Subject: [PATCH] 测试 场景问题群

---
 models/locationAnalysis.go |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/models/locationAnalysis.go b/models/locationAnalysis.go
index 2a6ddcf..e3ff6ba 100644
--- a/models/locationAnalysis.go
+++ b/models/locationAnalysis.go
@@ -129,41 +129,36 @@
 
 	results := make([]*db.ModelTaskResults, 0)
 	var baseFilter, labelFilter, keyFilter, lastFilter []LocationPersonInfo
-	var document_number_map map[string]LocationPersonInfo
+	var document_number_map = make(map[string]LocationPersonInfo)
 	var document_number_list []string
 	err := db.GetDB().Raw(`
 		SELECT
+		    p.id,
 			s.document_number,
--- 			s.community_id,
--- 			s.org_id,
--- 			p.person_name,
--- 			p.id_card,
-			s.last_appearance_time,
--- 			s.last_direction,
--- 			s.last_location 
+			s.last_appearance_time
 		FROM
 			snapshot_count_summary AS s
 			JOIN person AS p ON p.id = s.document_number
 		WHERE
 			p.id_card != "" 
-			AND (p.community_id IN ?
-			OR p.org_id IN ?)
-			AND p.status IN ?
+			AND (s.community_id IN ? OR s.org_id IN ?)
+			AND s.status IN ?
 		`, m.AreaIds, m.OrgIds, m.PersonIdentity).Scan(&baseFilter).Error
 	if err != nil {
 		logger.Warnf(err.Error())
 	}
 
 	if len(baseFilter) == 0 {
-		return fmt.Errorf("no results found that match the age condition %s - %s ", m.AreaIds, m.OrgIds)
+		return fmt.Errorf("no results found that match the age condition %s - %s - %s ", m.AreaIds, m.OrgIds, m.PersonIdentity)
 	}
 
 	logger.Debugf("task %s match age result %d", m.Task.Name, len(baseFilter))
 	for _, i := range baseFilter {
 		if _, ok := document_number_map[i.DocumentNumber]; !ok {
 			document_number_list = append(document_number_list, i.DocumentNumber)
+			tmp := i
+			document_number_map[i.DocumentNumber] = tmp
 		}
-		document_number_map[i.DocumentNumber] = i
 	}
 	if m.PersonLabel != "" {
 		labels := strings.Split(m.PersonLabel, ",")

--
Gitblit v1.8.0