| | |
| | | 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) |
| | | } |
| | |
| | | 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) |
| | |
| | | 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() |