Răsfoiți Sursa

数据导出新增字段调整

wangkaiyue 1 an în urmă
părinte
comite
8318f1ea1b
1 a modificat fișierele cu 58 adăugiri și 44 ștergeri
  1. 58 44
      common/src/qfw/util/dataexport/dataexport.go

+ 58 - 44
common/src/qfw/util/dataexport/dataexport.go

@@ -15,8 +15,6 @@ import (
 	"time"
 	"time"
 
 
 	qutil "app.yhyue.com/moapp/jybase/common"
 	qutil "app.yhyue.com/moapp/jybase/common"
-	. "app.yhyue.com/moapp/jybase/date"
-	. "app.yhyue.com/moapp/jybase/encrypt"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	mg "app.yhyue.com/moapp/jybase/mongodb"
 	mg "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
@@ -665,7 +663,7 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
 	//	"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
 	//	"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
 	//}
 	//}
 	if dataType == "2" {
 	if dataType == "2" {
-		bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr"`
+		bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr","buyerclass","s_topscopeclass"`
 		//for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext"} {
 		//for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext"} {
 		//	selectMap[key] = 1
 		//	selectMap[key] = 1
 		//}
 		//}
@@ -965,57 +963,73 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
 	if len(encry) > 0 {
 	if len(encry) > 0 {
 		isEncry = true
 		isEncry = true
 	}
 	}
-	for _, v := range *data {
+	var entCacheMap = map[string]map[string]interface{}{}
+	for index := 0; index < len(*data); index++ {
+		v := (*data)[index]
 		//有中标企业 且 高级字段查询
 		//有中标企业 且 高级字段查询
 		if dataType == "2" {
 		if dataType == "2" {
 			//查询企业公示 法人 公司电话 公司邮箱地址
 			//查询企业公示 法人 公司电话 公司邮箱地址
-			s_winner, ok := v["s_winner"].(string) //改为entidlistxx?
-			if ok && s_winner != "" {
-				if entData, ok := entmg.Find("winner_enterprise", map[string]interface{}{"company_name": s_winner}, nil, `{"company_name":1,"company_email":1,"legal_person":1,"company_phone":1}`, false, -1, -1); ok {
-					if entData != nil && *entData != nil && len(*entData) > 0 {
-						for _, ev := range *entData {
-							if v["s_winner"] == ev["company_name"] {
-								legal_person := ""
-								if ev["legal_person"] != nil {
-									legal_person = ev["legal_person"].(string)
-									if isEncry {
-										var xx = "*"
-										switch len([]rune(legal_person)) {
-										case 3:
-											xx = "**"
-										case 4:
-											xx = "***"
-										}
-										legal_person = string([]rune(legal_person)[:1]) + xx
-									}
+			entidlist, ok := v["entidlist"].([]interface{})
+			if ok && len(entidlist) > 0 {
+				var winnerMaps []map[string]interface{}
+				for _, entIdObj := range entidlist {
+					entId := qutil.ObjToString(entIdObj)
+					if entId == "" {
+						continue
+					}
+					if entCacheMap[entId] != nil {
+						winnerMaps = append(winnerMaps, entCacheMap[entId])
+					} else if entDetail := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"id":"%s"}}]}},"size":1,"_source":["company_name","company_email","company_phone","legal_person"]}`, entId)); entDetail != nil && len(*entDetail) > 0 {
+						thisEntMap := map[string]interface{}{}
+						legal_person := ""
+						if (*entDetail)[0]["legal_person"] != nil {
+							legal_person = (*entDetail)[0]["legal_person"].(string)
+							if isEncry {
+								var xx = "*"
+								switch len([]rune(legal_person)) {
+								case 3:
+									xx = "**"
+								case 4:
+									xx = "***"
 								}
 								}
-								company_phone := ""
-								if ev["company_phone"] != nil {
-									company_phone = ev["company_phone"].(string)
-									if isEncry {
-										if len([]rune(company_phone)) > 7 {
-											company_phone = company_phone[:7] + "****"
-										} else {
-											company_phone = "****"
-										}
-									}
+								legal_person = string([]rune(legal_person)[:1]) + xx
+							}
+						}
+						company_phone := ""
+						if (*entDetail)[0]["company_phone"] != nil {
+							company_phone = (*entDetail)[0]["company_phone"].(string)
+							if isEncry {
+								if len([]rune(company_phone)) > 7 {
+									company_phone = company_phone[:7] + "****"
+								} else {
+									company_phone = "****"
 								}
 								}
-								company_email := ""
-								if ev["company_email"] != nil && ev["company_email"] != "无" {
-									company_email = ev["company_email"].(string)
-									if isEncry {
-										if len(strings.Split(company_email, "@")) > 1 {
-											company_email = "******" + "@" + strings.Split(company_email, "@")[1]
-										}
-									}
+							}
+						}
+						company_email := ""
+						if (*entDetail)[0]["company_email"] != nil && (*entDetail)[0]["company_email"] != "无" {
+							company_email = (*entDetail)[0]["company_email"].(string)
+							if isEncry {
+								if len(strings.Split(company_email, "@")) > 1 {
+									company_email = "******" + "@" + strings.Split(company_email, "@")[1]
 								}
 								}
-								v["legal_person"] = legal_person
-								v["company_phone"] = company_phone
-								v["company_email"] = company_email
 							}
 							}
 						}
 						}
+						company_name := ""
+						if (*entDetail)[0]["company_name"] != nil {
+							company_name = (*entDetail)[0]["company_name"].(string)
+						}
+						thisEntMap["legal_person"] = legal_person
+						thisEntMap["company_phone"] = company_phone
+						thisEntMap["company_email"] = company_email
+						thisEntMap["company_name"] = company_name
+						entCacheMap[entId] = thisEntMap
+						winnerMaps = append(winnerMaps, thisEntMap)
 					}
 					}
 				}
 				}
+				if len(winnerMaps) > 0 {
+					v["winnerMaps"] = winnerMaps
+				}
 			}
 			}
 		}
 		}
 		//====================字段补漏=========================
 		//====================字段补漏=========================