| | |
| | | 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 { |
| | |
| | | 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, |
| | |
| | | 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()) |
| | | } |
| | |
| | | document_number_list = []string{} |
| | | for _, i := range labelFilter { |
| | | document_number_list = append(document_number_list, i.Id) |
| | | document_number_list = append(document_number_list, i.Id) |
| | | } |
| | | } |
| | | if len(m.KeyTypes) > 0 { |
| | |
| | | person.PersonType = i.PersonType |
| | | document_number_map[i.DocumentNumber] = person |
| | | } |
| | | logger.Debugf("document_number_list %s last result %s", m.Task.Name, document_number_list) |
| | | records, err := queryEsLocation(db.GetEsClient(), m, document_number_list) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | logger.Debugf("records %s last result %s", m.Task.Name, records) |
| | | domains, err := domainToLocation(records) |
| | | if err != nil { |
| | | return err |
| | |
| | | if orgBuckets, ok := aggs["orgs"].(map[string]interface{})["buckets"].([]interface{}); ok { |
| | | for _, orgBucket := range orgBuckets { |
| | | orgId := orgBucket.(map[string]interface{})["key"].(string) |
| | | |
| | | logger.Debugf("orgId--------------------------------------- %s", orgId) |
| | | // 解析按communityId的聚合结果 |
| | | if communityBuckets, ok := orgBucket.(map[string]interface{})["community"].(map[string]interface{})["buckets"].([]interface{}); ok { |
| | | for _, communityBucket := range communityBuckets { |
| | | communityId := communityBucket.(map[string]interface{})["key"].(string) |
| | | |
| | | logger.Debugf("communityId--------------------------------------- %s", communityId) |
| | | // 解析按building的聚合结果 |
| | | if locationBuckets, ok := communityBucket.(map[string]interface{})["location"].(map[string]interface{})["buckets"].([]interface{}); ok { |
| | | for _, locationBucket := range locationBuckets { |
| | | building := locationBucket.(map[string]interface{})["key"].(string) |
| | | |
| | | logger.Debugf("building--------------------------------------- %s", building) |
| | | // 解析按floor的聚合结果 |
| | | if floorBuckets, ok := locationBucket.(map[string]interface{})["floor"].(map[string]interface{})["buckets"].([]interface{}); ok { |
| | | for _, floorBucket := range floorBuckets { |
| | |
| | | persons = append(persons, docNumBucket.(map[string]interface{})["key"].(string)) |
| | | } |
| | | } |
| | | |
| | | logger.Debugf("floor--------------------------------------- %s-- %s --", floor, appearCount) |
| | | record := &LocationRecord{ |
| | | //PicDate: timestamp, |
| | | DocumentNumbers: persons, |