From 378445b97b115be44b25957ef71e01caae598593 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 12 十二月 2024 21:34:29 +0800 Subject: [PATCH] 模型任务处理结果保存时间 --- models/gather_model.go | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/models/gather_model.go b/models/gather_model.go index 909c01f..375526b 100644 --- a/models/gather_model.go +++ b/models/gather_model.go @@ -89,18 +89,19 @@ return err } event := strings.Join(typeNames, ",") - for location, persons := range aggregation { + for lt, persons := range aggregation { result := &db.ModelTaskResults{ Title: m.Task.Name, Event: fmt.Sprintf("%s/%d浜�", event, len(persons)), ModelID: m.Task.ModelID, ModelTaskID: m.Task.ID, - CommunityId: location.CommunityId, - OrgID: location.OrgId, + CommunityId: lt.CommunityId, + OrgID: lt.OrgId, ObjectIds: strings.Join(persons.Elements(), ","), - Location: location.Location, - Building: location.Building, - Floor: location.Floor, + Location: lt.Location, + Building: lt.Building, + Floor: lt.Floor, + PicDate: lt.Time, } results = append(results, result) } @@ -344,16 +345,17 @@ return records, nil } -type GatherLocation struct { +type GatherLocationTime struct { CommunityId string OrgId string Building string Floor string Location string + Time string } -func analyzeAndAggregate(records []GatherRecord) (map[GatherLocation]set.StringSet, error) { - aggregation := make(map[GatherLocation]set.StringSet) +func analyzeAndAggregate(records []GatherRecord) (map[GatherLocationTime]set.StringSet, error) { + aggregation := make(map[GatherLocationTime]set.StringSet) domainIds := set.NewStringSet() for _, record := range records { domainIds.Add(record.CommunityId) @@ -369,12 +371,13 @@ continue } - location := GatherLocation{ + location := GatherLocationTime{ CommunityId: record.CommunityId, OrgId: record.OrgId, Building: record.Building, Floor: record.Floor, Location: fmt.Sprintf("%s%s%s", domains[record.CommunityId].Name, record.Building, record.Floor), + Time: record.PicDate, } if aggregation[location] == nil { aggregation[location] = set.NewStringSet() -- Gitblit v1.8.0