Эх сурвалжийг харах

fix:三级页跳转修改

duxin 1 жил өмнө
parent
commit
55a311ee28

+ 85 - 82
src/jfw/front/nzjProject.go

@@ -75,11 +75,16 @@ func (l *ClaimProject) NzjDetails() {
 }
 
 type RemovalKey struct {
-	nameId string
 	person string
 	phone  string
 }
 
+type ProjectConnection struct {
+	endName string
+	address string
+	data    []map[string]interface{}
+}
+
 func getDetail(pid string, equity int) map[string]interface{} {
 	var codeContent string
 	detail := make(map[string]interface{})
@@ -144,94 +149,89 @@ ORDER BY publishtime DESC `, pid))
 			detail["follRecord"] = follRecord
 		}
 
-		var ids []string
 		//获取企业主题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 {
-			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
 }
@@ -258,6 +258,9 @@ func getNzjList(infoMap map[string]interface{}) (count int64, list *[]map[string
 	musts := esQuery(infoMap)
 	if pageNum == 1 {
 		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))
 	return

+ 3 - 3
src/jfw/front/shorturl.go

@@ -152,9 +152,9 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
 				paramSuffix = ".html?aside=0&"
 			}
 			//p415 首页改版 三级页登录跳转第一版修改
-			urlStr := strings.ReplaceAll(s.Request.URL.String(), "nologin", "article")
-			//return s.Redirect(fmt.Sprintf("%s%s%s", config.Sysconfig["workDesktopUrl"].(string), config.Sysconfig["webdomain"].(string), url.QueryEscape(strings.Replace(s.Request.URL.String(), replaceStr, paramSuffix, 1))))
-			return s.Redirect(strings.Replace(urlStr, replaceStr, paramSuffix, 1), 302)
+			return s.Redirect(fmt.Sprintf("%s%s%s", config.Sysconfig["workDesktopUrl"].(string), config.Sysconfig["webdomain"].(string), url.QueryEscape(strings.Replace(s.Request.URL.String(), replaceStr, paramSuffix, 1))))
+			//urlStr := strings.ReplaceAll(s.Request.URL.String(), "nologin", "article")
+			//return s.Redirect(strings.Replace(urlStr, replaceStr, paramSuffix, 1), 302)
 		}
 	}
 	userId, _ := sess["userId"].(string)