|
@@ -75,11 +75,16 @@ func (l *ClaimProject) NzjDetails() {
|
|
}
|
|
}
|
|
|
|
|
|
type RemovalKey struct {
|
|
type RemovalKey struct {
|
|
- nameId string
|
|
|
|
person string
|
|
person string
|
|
phone string
|
|
phone string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type ProjectConnection struct {
|
|
|
|
+ endName string
|
|
|
|
+ address string
|
|
|
|
+ data []map[string]interface{}
|
|
|
|
+}
|
|
|
|
+
|
|
func getDetail(pid string, equity int) map[string]interface{} {
|
|
func getDetail(pid string, equity int) map[string]interface{} {
|
|
var codeContent string
|
|
var codeContent string
|
|
detail := make(map[string]interface{})
|
|
detail := make(map[string]interface{})
|
|
@@ -144,94 +149,89 @@ ORDER BY publishtime DESC `, pid))
|
|
detail["follRecord"] = follRecord
|
|
detail["follRecord"] = follRecord
|
|
}
|
|
}
|
|
|
|
|
|
- var ids []string
|
|
|
|
//获取企业主题id
|
|
//获取企业主题id
|
|
- entId := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT name_id FROM Jianyu_subjectdb.dwd_f_nzj_ent WHERE proposed_id = '%s' ORDER BY identity_type DESC , createtime ASC`, pid))
|
|
|
|
|
|
+ entId := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT name_id,name,address FROM Jianyu_subjectdb.dwd_f_nzj_ent WHERE proposed_id = '%s' ORDER BY identity_type DESC , createtime ASC`, pid))
|
|
if entId != nil && len(*entId) > 0 {
|
|
if entId != nil && len(*entId) > 0 {
|
|
- for _, v := range *entId {
|
|
|
|
- ids = append(ids, fmt.Sprintf(`"%s"`, common.InterfaceToStr(v["name_id"])))
|
|
|
|
- }
|
|
|
|
- connection := make(map[RemovalKey]map[string]interface{})
|
|
|
|
- var data []map[string]interface{}
|
|
|
|
- nzjContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id in (%s) ORDER BY createtime DESC `, strings.Join(ids, ",")))
|
|
|
|
- if nzjContact != nil && len(*nzjContact) > 0 {
|
|
|
|
- for _, v := range *nzjContact {
|
|
|
|
- v["lasttime"] = v["createtime"]
|
|
|
|
- var key RemovalKey
|
|
|
|
- key.person = common.InterfaceToStr(v["contact_name"])
|
|
|
|
- key.nameId = common.InterfaceToStr(v["name_id"])
|
|
|
|
- key.phone = common.InterfaceToStr(v["contact_tel"])
|
|
|
|
- connection[key] = v
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if equity > 3 {
|
|
|
|
- //企业联系人
|
|
|
|
- entContact := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM dws_f_ent_contact WHERE name_id in (%s)`, strings.Join(ids, ",")))
|
|
|
|
- if entContact != nil && len(*entContact) > 0 {
|
|
|
|
- for _, v := range *entContact {
|
|
|
|
- v["lasttime"] = v["createtime"]
|
|
|
|
- if common.InterfaceToStr(v["createtime"]) < common.InterfaceToStr(v["updatetime"]) {
|
|
|
|
- v["lasttime"] = v["updatetime"]
|
|
|
|
- }
|
|
|
|
- var key RemovalKey
|
|
|
|
- key.person = common.InterfaceToStr(v["contact_name"])
|
|
|
|
- key.nameId = common.InterfaceToStr(v["name_id"])
|
|
|
|
- key.phone = common.InterfaceToStr(v["contact_tel"])
|
|
|
|
- connection[key] = v
|
|
|
|
|
|
+ pool := make(chan bool, 10)
|
|
|
|
+ wait := &sync.WaitGroup{}
|
|
|
|
+ var lock sync.Mutex
|
|
|
|
+ var contact []ProjectConnection
|
|
|
|
+ for _, nameMap := range *entId {
|
|
|
|
+ pool <- true
|
|
|
|
+ wait.Add(1)
|
|
|
|
+ go func(nameId map[string]interface{}) {
|
|
|
|
+ defer func() {
|
|
|
|
+ wait.Done()
|
|
|
|
+ <-pool
|
|
|
|
+ }()
|
|
|
|
+ connection := make(map[RemovalKey]map[string]interface{})
|
|
|
|
+ var data []map[string]interface{}
|
|
|
|
+ person := ProjectConnection{
|
|
|
|
+ endName: common.InterfaceToStr(nameId["name"]),
|
|
|
|
+ address: common.InterfaceToStr(nameId["address"]),
|
|
}
|
|
}
|
|
- }
|
|
|
|
- for _, m := range connection {
|
|
|
|
- data = append(data, m)
|
|
|
|
- }
|
|
|
|
- //私有联系人用户
|
|
|
|
- userContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_user_contact_record WHERE name_id in (%s) `, strings.Join(ids, ",")))
|
|
|
|
- if userContact != nil && len(*userContact) > 0 {
|
|
|
|
- for _, m := range *userContact {
|
|
|
|
- data = append(data, m)
|
|
|
|
|
|
+ nzjContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_nzj_contact WHERE name_id ='%s' ORDER BY createtime DESC `, nameId))
|
|
|
|
+ if nzjContact != nil && len(*nzjContact) > 0 {
|
|
|
|
+ for _, v := range *nzjContact {
|
|
|
|
+ v["lasttime"] = v["createtime"]
|
|
|
|
+ var key RemovalKey
|
|
|
|
+ key.person = common.InterfaceToStr(v["contact_name"])
|
|
|
|
+ key.phone = common.InterfaceToStr(v["contact_tel"])
|
|
|
|
+ connection[key] = v
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ if equity > 3 {
|
|
|
|
+ //企业联系人
|
|
|
|
+ entContact := public.GlobalCommonMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM dws_f_ent_contact WHERE name_id ='%s'`, nameId))
|
|
|
|
+ if entContact != nil && len(*entContact) > 0 {
|
|
|
|
+ for _, v := range *entContact {
|
|
|
|
+ v["lasttime"] = v["createtime"]
|
|
|
|
+ if common.InterfaceToStr(v["createtime"]) < common.InterfaceToStr(v["updatetime"]) {
|
|
|
|
+ v["lasttime"] = v["updatetime"]
|
|
|
|
+ }
|
|
|
|
+ var key RemovalKey
|
|
|
|
+ key.person = common.InterfaceToStr(v["contact_name"])
|
|
|
|
+ key.phone = common.InterfaceToStr(v["contact_tel"])
|
|
|
|
+ connection[key] = v
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for _, m := range connection {
|
|
|
|
+ data = append(data, m)
|
|
|
|
+ }
|
|
|
|
+ //私有联系人用户
|
|
|
|
+ userContact := public.BaseMysql.SelectBySql(fmt.Sprintf(`SELECT * FROM Jianyu_subjectdb.dwd_f_user_contact_record WHERE name_id = '%s' `, nameId))
|
|
|
|
+ if userContact != nil && len(*userContact) > 0 {
|
|
|
|
+ for _, m := range *userContact {
|
|
|
|
+ data = append(data, m)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- for _, m := range connection {
|
|
|
|
- m["name"] = codeContent
|
|
|
|
- data = append(data, m)
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ person.endName = codeContent
|
|
|
|
+ for _, m := range connection {
|
|
|
|
+ data = append(data, m)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 自定义排序函数
|
|
|
|
+ sort.Slice(data, func(i, j int) bool {
|
|
|
|
+ sourceTypeA := data[i]["source_type"].(string)
|
|
|
|
+ sourceTypeB := data[j]["source_type"].(string)
|
|
|
|
+ if sourceTypeA == sourceTypeB {
|
|
|
|
+ lastTimeA := data[i]["lasttime"].(int)
|
|
|
|
+ lastTimeB := data[j]["lasttime"].(int)
|
|
|
|
+ return lastTimeA > lastTimeB // 降序排序
|
|
|
|
+ }
|
|
|
|
+ return sourceTypeA < sourceTypeB // 升序排序
|
|
|
|
+ })
|
|
|
|
+ person.data = data
|
|
|
|
+ lock.Lock()
|
|
|
|
+ contact = append(contact, person)
|
|
|
|
+ lock.Unlock()
|
|
|
|
+ }(nameMap)
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 自定义排序函数
|
|
|
|
- sort.Slice(data, func(i, j int) bool {
|
|
|
|
- // 获取 source_type 字段的整数值,如果不存在,默认为 0
|
|
|
|
- sourceType1, ok1 := data[i]["source_type"].(int)
|
|
|
|
- if !ok1 {
|
|
|
|
- sourceType1 = 0
|
|
|
|
- }
|
|
|
|
- sourceType2, ok2 := data[j]["source_type"].(int)
|
|
|
|
- if !ok2 {
|
|
|
|
- sourceType2 = 0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 首先按照 source_type 进行升序排序
|
|
|
|
- if sourceType1 != sourceType2 {
|
|
|
|
- return sourceType1 < sourceType2
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 如果 source_type 相同,则按照 str 进行降序排序
|
|
|
|
- str1 := common.InterfaceToStr(data[i]["lasttime"])
|
|
|
|
- str2 := common.InterfaceToStr(data[j]["lasttime"])
|
|
|
|
- // 空值放在前面,非空值按照降序排序
|
|
|
|
- if str1 == "" && str2 == "" {
|
|
|
|
- return false
|
|
|
|
- } else if str1 == "" {
|
|
|
|
- return true
|
|
|
|
- } else if str2 == "" {
|
|
|
|
- return false
|
|
|
|
- } else {
|
|
|
|
- return str1 > str2
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- detail["contact"] = data
|
|
|
|
|
|
+ wait.Wait()
|
|
|
|
+ detail["contact"] = contact
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
return detail
|
|
return detail
|
|
}
|
|
}
|
|
@@ -258,6 +258,9 @@ func getNzjList(infoMap map[string]interface{}) (count int64, list *[]map[string
|
|
musts := esQuery(infoMap)
|
|
musts := esQuery(infoMap)
|
|
if pageNum == 1 {
|
|
if pageNum == 1 {
|
|
count = elastic.Count(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}}`, strings.Join(musts, ",")))
|
|
count = elastic.Count(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}}`, strings.Join(musts, ",")))
|
|
|
|
+ if count > common.Int64All(config.Sysconfig["nzjLimit"]) {
|
|
|
|
+ count = common.Int64All(config.Sysconfig["nzjLimit"])
|
|
|
|
+ }
|
|
}
|
|
}
|
|
list = elastic.Get(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}},"_source":["projectname","area_city","lasttime","project_stage","ownerclass","proposed_id","category","project_stage"],"sort":[{"lasttime":{"order":"desc"}}],"from":%d,"size":%d`, strings.Join(musts, ","), (pageNum-1)*pageSize, pageSize))
|
|
list = elastic.Get(proposed, proposed, fmt.Sprintf(`{"query": {"bool": {"must": [%s]}},"_source":["projectname","area_city","lasttime","project_stage","ownerclass","proposed_id","category","project_stage"],"sort":[{"lasttime":{"order":"desc"}}],"from":%d,"size":%d`, strings.Join(musts, ","), (pageNum-1)*pageSize, pageSize))
|
|
return
|
|
return
|