utiltag.go 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. package util
  2. import (
  3. "JySEPlatform/models"
  4. sql "JySEPlatform/sqlmodel"
  5. "app.yhyue.com/moapp/jybase/mongodb"
  6. "context"
  7. "encoding/json"
  8. "errors"
  9. "fmt"
  10. "log"
  11. "strings"
  12. "sync"
  13. "time"
  14. qu "app.yhyue.com/moapp/jybase/common"
  15. "app.yhyue.com/moapp/jybase/encrypt"
  16. elastic "app.yhyue.com/moapp/jybase/es"
  17. es "github.com/olivere/elastic/v7"
  18. "go.mongodb.org/mongo-driver/bson"
  19. )
  20. const (
  21. TitleMatchType = "1" //标题匹配
  22. DetailMatchType = "2" //全文匹配
  23. PurchasingMatchType = "3" //标的物匹配
  24. AttachmentsMatchType = "4" //附件匹配
  25. ProjectnameMatchType = "5" //项目名称匹配
  26. BuyerMatchType = "6" //采购单位匹配
  27. SWinnerMatchType = "7" //中标单位匹配
  28. BuyerMatchType1 = "8" //采购单位(正则)匹配
  29. SWinnerMatchType1 = "9" //中标单位(正则)匹配
  30. TitleMatchTypeStr = "title" //标题匹配
  31. DetailMatchTypeStr = "detail" //全文匹配
  32. PurchasingMatchTypeStr = "purchasing" //标的物匹配
  33. AttachmentsMatchTypeStr = "filetext" //附件匹配
  34. ProjectnameMatchTypeStr = "projectname.pname" //项目名称匹配
  35. BuyerMatchTypeStr = "buyer" //项目名称匹配
  36. BuyerRegexpMatchTypeStr = "buyer.mbuyer" //采购单位正则匹配
  37. SWinnerMatchTypeStr = "s_winner" //项目名称匹配
  38. SWinnerRegexpMatchTypeStr = "s_winner.mwinner" //中标单位正则匹配
  39. TitleMatchTypeField = "title" //标题匹配
  40. DetailMatchTypeField = "detail" //全文匹配
  41. PurchasingMatchTypeField = "purchasing" //标的物匹配
  42. AttachmentsMatchTypeField = "filetext" //附件匹配
  43. ProjectnameMatchTypeField = "projectname.pname" //项目名称匹配
  44. BuyerMatchTypeField = "buyer" //项目名称匹配
  45. SWinnerMatchTypeField = "s_winner" //项目名称匹配
  46. MultiMatchType = "phrase"
  47. Standard = 1 //1:标准字段包,
  48. Advanced = 2 //2:高级字段包
  49. Standardstr = "standard" //1:标准字段包
  50. Advancedstr = "advanced" //2:高级字段包
  51. Url = "https://www.jianyu360.com/article/content/%s.html"
  52. )
  53. func UtilEsSaveData(sdataid string, datas *[]map[string]interface{}) error {
  54. defer qu.Catch()
  55. if !Mgo.Del("tagsdata", bson.M{"s_dataid": sdataid}) {
  56. return errors.New("mongo del err")
  57. }
  58. for _, v := range *datas {
  59. Mgo.Save("tagsdata", v)
  60. }
  61. // if Mgo.SaveBulk("tagsdata", *datas...) {
  62. // return nil
  63. // } else {
  64. // return errors.New("mongo save err")
  65. // }
  66. return nil
  67. }
  68. type MySource struct {
  69. Querys string
  70. }
  71. func (m *MySource) Source() (interface{}, error) {
  72. mp := make(map[string]interface{})
  73. json.Unmarshal([]byte(m.Querys), &mp)
  74. return mp["query"], nil
  75. }
  76. // 客户规则
  77. func UtilEsFind1(tags map[string]interface{}) (error, int64) {
  78. defer qu.Catch()
  79. ch := make(chan bool, 20)
  80. wg := &sync.WaitGroup{}
  81. arrsync := &sync.RWMutex{}
  82. sdataid := qu.ObjToString(tags["s_dataid"])
  83. esquery := qu.ObjToString(tags["s_esquery"])
  84. if IsNewSql != 0 {
  85. esquery = qu.ObjToString(tags["s_esquery_search"])
  86. }
  87. clearKey := qu.ObjToString(tags["s_globalclearkey"])
  88. clearKeyMatch := qu.ObjToString(tags["s_globalclearkeymatch"])
  89. if len(esquery) < 1 || len(sdataid) < 1 {
  90. return errors.New("s_esquery or s_dataid no found"), 0
  91. }
  92. i_maxnum := qu.Int64All(tags["i_maxnum"])
  93. if i_maxnum <= 0 {
  94. i_maxnum = 100
  95. }
  96. //
  97. maths := make([]map[string]string, 0)
  98. if orules, ok := tags["o_rules"].([]interface{}); ok {
  99. for _, v := range orules {
  100. orule, _ := v.(map[string]interface{})
  101. maths = append(maths, map[string]string{
  102. "s_matchkey": qu.ObjToString(orule["s_matchkey"]),
  103. "s_keymatch": qu.ObjToString(orule["s_keymatch"]),
  104. })
  105. }
  106. } else if orules, ok := tags["o_rules"].([]map[string]interface{}); ok {
  107. for _, v := range orules {
  108. maths = append(maths, map[string]string{
  109. "s_matchkey": qu.ObjToString(v["s_matchkey"]),
  110. "s_keymatch": qu.ObjToString(v["s_keymatch"]),
  111. })
  112. }
  113. } else {
  114. return errors.New("o_rules no found"), 0
  115. }
  116. ctx, _ := context.WithTimeout(context.Background(), 1*time.Hour)
  117. esCon := elastic.VarEs.(*elastic.EsV7)
  118. client := esCon.GetEsConn()
  119. defer esCon.DestoryEsConn(client)
  120. // esquery = esquery[:len(esquery)-1] + `,"size":` + fmt.Sprintf("%d", i_maxnum) + `}`
  121. cc := &MySource{
  122. Querys: esquery,
  123. }
  124. searchResult, err := client.Search(EsIndex).Query(cc).Size(int(i_maxnum)).Do(ctx)
  125. if err == nil && searchResult.Hits != nil {
  126. datas := make([]map[string]interface{}, 0)
  127. log.Println("es查询到的数量:", searchResult.Hits.TotalHits.Value)
  128. log.Println("es查询到的数量(实际):", len(searchResult.Hits.Hits))
  129. for _, v := range searchResult.Hits.Hits {
  130. wg.Add(1)
  131. ch <- true
  132. go func(tmpHit *es.SearchHit) {
  133. defer func() {
  134. <-ch
  135. arrsync.Unlock()
  136. wg.Done()
  137. }()
  138. arrsync.Lock()
  139. item := make(map[string]interface{})
  140. if json.Unmarshal(tmpHit.Source, &item) == nil {
  141. item["appid"] = tags["appid"]
  142. item["rulename"] = tags["s_name"]
  143. info_id := qu.ObjToString(item["id"])
  144. item["info_id"] = info_id
  145. item["s_dataid"] = sdataid
  146. // item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", info_id))
  147. //
  148. subType := qu.ObjToString(item["subtype"])
  149. subTypeStr := "拟建,采购意向,预告,预审,预审结果,论证意见,需求公示"
  150. if strings.Contains(subTypeStr, subType) {
  151. item["s_jyhref"] = `https://www.jianyu360.cn/article/bdprivate/` + encrypt.CommonEncodeArticle("bdprivate", info_id) + `.html`
  152. } else {
  153. // item["s_jyhref"] = `https://www.jianyu360.cn/article/content/` + qu.CommonEncodeArticle("content", info_id) + `.html`
  154. item["s_jyhref"] = `https://www.jianyu360.cn/article/entservice/` + encrypt.SE3.EncodeString(info_id) + `.html?appid`
  155. }
  156. //
  157. item["i_createtime"] = time.Now().Unix()
  158. delete(item, "_id")
  159. //清理词清空
  160. for _, v := range strings.Split(clearKey, ",") {
  161. ClearKeys(clearKeyMatch, v, item)
  162. }
  163. //二次匹配关键词
  164. matchKeys := GetMactchKey(maths, item)
  165. if len(maths) > 0 {
  166. if matchKeys != "" {
  167. item["s_matchkey"] = matchKeys
  168. }
  169. }
  170. findwinner := strings.TrimSpace(qu.ObjToString(item["winner"]))
  171. if findwinner != "" {
  172. finddata, _ := MgoEnps.FindOne(EnpsColl, bson.M{"company_name": findwinner})
  173. if finddata != nil {
  174. if legal_person := qu.ObjToString((*finddata)["legal_person"]); legal_person != "" {
  175. item["legal_person"] = legal_person
  176. }
  177. if email := qu.ObjToString((*finddata)["company_email"]); email != "" {
  178. item["company_email"] = email
  179. }
  180. if phone := qu.ObjToString((*finddata)["company_phone"]); phone != "" {
  181. item["company_phone"] = phone
  182. }
  183. item["qyk"] = finddata
  184. if company_area := qu.ObjToString((*finddata)["company_area"]); company_area != "" {
  185. item["company_area"] = company_area
  186. }
  187. if company_city := qu.ObjToString((*finddata)["company_city"]); company_city != "" {
  188. item["company_city"] = company_city
  189. }
  190. if company_district := qu.ObjToString((*finddata)["company_district"]); company_district != "" {
  191. item["company_district"] = company_district
  192. }
  193. //中标单位的社会征信代码
  194. if credit_no := qu.ObjToString((*finddata)["credit_no"]); credit_no != "" {
  195. item["winner_credit_no"] = credit_no
  196. }
  197. }
  198. }
  199. agency := strings.TrimSpace(qu.ObjToString(item["agency"]))
  200. if agency != "" {
  201. finddata, _ := MgoEnps.FindOne(EnpsColl, bson.M{"company_name": agency})
  202. if finddata != nil {
  203. //社会征信代码
  204. if credit_no := qu.ObjToString((*finddata)["credit_no"]); credit_no != "" {
  205. item["agency_credit_no"] = credit_no
  206. }
  207. }
  208. }
  209. buyer := strings.TrimSpace(qu.ObjToString(item["buyer"]))
  210. if buyer != "" {
  211. finddata, _ := MgoBuyer.FindOne(BuyerEntColl, bson.M{"company_name": buyer})
  212. if finddata != nil {
  213. //社会征信代码
  214. if credit_no := qu.ObjToString((*finddata)["credit_no"]); credit_no != "" {
  215. item["buyer_credit_no"] = credit_no
  216. }
  217. }
  218. }
  219. //匹配公告附件
  220. info, _ := MgoBidding.FindOne("bidding", bson.M{"_id": mongodb.StringTOBsonId(info_id)})
  221. if info != nil {
  222. log.Println("匹配附件, id-", item["info_id"])
  223. if (*info)["projectinfo"] != nil {
  224. projectInfo := qu.ObjToMap((*info)["projectinfo"])
  225. if projectInfo != nil && len(*projectInfo) > 0 {
  226. if (*projectInfo)["attachments"] != nil {
  227. filesArr := []map[string]interface{}{}
  228. fileUrl := qu.ObjToString(Sysconfig["file_downloadurl"])
  229. if attachments, oks := (*projectInfo)["attachments"].(map[string]interface{}); oks {
  230. for _, v := range attachments {
  231. if atta, ok := v.(map[string]interface{}); ok {
  232. if atta["fid"] != nil && qu.ObjToString(atta["fid"]) != "" {
  233. fileMap := map[string]interface{}{
  234. "filename": atta["filename"],
  235. "url": fileUrl + qu.ObjToString(atta["fid"]),
  236. }
  237. filesArr = append(filesArr, fileMap)
  238. } else {
  239. if atta["org_url"] != nil {
  240. fileMap := map[string]interface{}{
  241. "filename": atta["filename"],
  242. "url": qu.ObjToString(atta["org_url"]),
  243. }
  244. filesArr = append(filesArr, fileMap)
  245. }
  246. }
  247. }
  248. }
  249. }
  250. log.Println("查询附件结果:", info_id, "附件数量:", len(filesArr))
  251. if len(filesArr) > 0 {
  252. item["filehref"] = filesArr
  253. }
  254. }
  255. }
  256. }
  257. } else {
  258. log.Println("id", item["info_id"], "bidding为空")
  259. }
  260. //项目id
  261. //projectId := GetProjectId(info_id)
  262. //if projectId != "" {
  263. // item["projectId"] = SE2.EncodeString(projectId)
  264. //}
  265. datas = append(datas, item)
  266. } else {
  267. log.Println("id", item["_id"], "信息为空")
  268. }
  269. }(v)
  270. }
  271. wg.Wait()
  272. GetProjectId(&datas)
  273. count := Es.Count(EsIndex, EsType, esquery)
  274. Mgo.Update("entniche_rule", bson.M{"_id": tags["_id"]}, bson.M{
  275. "$set": bson.M{
  276. "i_estotal": count,
  277. }}, false, false)
  278. return UtilEsSaveData(sdataid, &datas), count
  279. } else {
  280. log.Println(err)
  281. return err, 0
  282. }
  283. }
  284. func ClearKeys(types, key string, data map[string]interface{}) {
  285. if strings.Contains(types, "1") {
  286. title := qu.ObjToString(data["title"])
  287. data["title"] = strings.ReplaceAll(title, key, "")
  288. }
  289. if strings.Contains(types, "2") {
  290. detail := qu.ObjToString(data["detail"])
  291. data["detail"] = strings.ReplaceAll(detail, key, "")
  292. }
  293. if strings.Contains(types, "3") {
  294. purchasing := qu.ObjToString(data["purchasing"])
  295. data["purchasing"] = strings.ReplaceAll(purchasing, key, "")
  296. }
  297. if strings.Contains(types, "4") {
  298. filetext := qu.ObjToString(data["filetext"])
  299. data["filetext"] = strings.ReplaceAll(filetext, key, "")
  300. }
  301. if strings.Contains(types, "5") {
  302. projectname := qu.ObjToString(data["projectname"])
  303. data["projectname"] = strings.ReplaceAll(projectname, key, "")
  304. }
  305. if strings.Contains(types, "6") || strings.Contains(types, "8") {
  306. buyer := qu.ObjToString(data["buyer"])
  307. data["buyer"] = strings.ReplaceAll(buyer, key, "")
  308. }
  309. if strings.Contains(types, "7") || strings.Contains(types, "9") {
  310. winner := qu.ObjToString(data["s_winner"])
  311. data["s_winner"] = strings.ReplaceAll(winner, key, "")
  312. }
  313. }
  314. func GetTimeInterval(startTime, entTime time.Time, n int) []map[string]interface{} {
  315. timeList := []map[string]interface{}{}
  316. endTimeTmp := startTime
  317. for endTimeTmp.Unix() < entTime.Unix() {
  318. var endTime_ time.Time
  319. startTime = endTimeTmp
  320. endTimeTmp = startTime.AddDate(0, n, 0)
  321. if endTimeTmp.Unix() > entTime.Unix() {
  322. endTime_ = entTime
  323. timeList = append(timeList, map[string]interface{}{"startTime": startTime.Unix(), "endTime": endTime_.Unix()})
  324. break
  325. } else {
  326. endTime_ = endTimeTmp
  327. timeList = append(timeList, map[string]interface{}{"startTime": startTime.Unix(), "endTime": endTime_.Unix()})
  328. }
  329. }
  330. //log.Println(timeList)
  331. return timeList
  332. }
  333. func Utiltags(tag map[string]interface{}) string {
  334. defer qu.Catch()
  335. tmpbyte, _ := json.Marshal(tag)
  336. tab := models.Tag{}
  337. err := json.Unmarshal(tmpbyte, &tab)
  338. if err != nil {
  339. return "json err:" + err.Error()
  340. }
  341. //log.Println("前端数据", tab)
  342. QueryObjecct := sql.QueryObjecct{}
  343. ffBoolObject := sql.BoolObject{}
  344. adsBoolObect := sql.NewEsObject{}
  345. if tab.Sarea != "" {
  346. adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{Area: strings.Split(tab.Sarea, ",")}})
  347. }
  348. if tab.Scity != "" {
  349. adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{City: strings.Split(tab.Scity, ",")}})
  350. }
  351. if tab.Sdistrict != "" {
  352. //城市——区县
  353. cityds := strings.Split(tab.Sdistrict, ",")
  354. var ds []string
  355. for _, v := range cityds {
  356. ds = append(ds, strings.Split(v, "-")[1])
  357. }
  358. adsBoolObect.Bool.Should = append(adsBoolObect.Bool.Should, sql.AreaCityDistrictMust{AreaCityDistrict: &sql.AreaCityDistrict{District: ds}})
  359. }
  360. if len(adsBoolObect.Bool.Should) > 0 {
  361. ffBoolObject.Must = append(ffBoolObject.Must, adsBoolObect)
  362. }
  363. if tab.Stoptype != "" || tab.Ssubtype != "" {
  364. if len(tab.Stoptype) > 0 {
  365. toptypeSubtype := sql.ToptypeSubtype{}
  366. toptypeSubtype.Toptype = strings.Split(tab.Stoptype, ",")
  367. ffBoolObject.Must = append(ffBoolObject.Must, sql.ToptypeSubtypeMust{&toptypeSubtype})
  368. }
  369. if len(tab.Ssubtype) > 0 {
  370. toptypeSubtype := sql.ToptypeSubtype{}
  371. toptypeSubtype.Subtype = strings.Split(tab.Ssubtype, ",")
  372. ffBoolObject.Must = append(ffBoolObject.Must, sql.ToptypeSubtypeMust{&toptypeSubtype})
  373. }
  374. }
  375. if tab.Istarttime > 0 && tab.Iendtime > 0 {
  376. ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime: &sql.Publishtime{
  377. Gte: tab.Istarttime,
  378. Lt: tab.Iendtime,
  379. }}})
  380. } else if tab.Istarttime > 0 {
  381. ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime1: &sql.Publishtime1{
  382. Gte: tab.Istarttime,
  383. }}})
  384. } else if tab.Iendtime > 0 {
  385. ffBoolObject.Must = append(ffBoolObject.Must, sql.PublishtimeMust{PublishtimeObject: &sql.PublishtimeObject{Publishtime2: &sql.Publishtime2{
  386. Lt: tab.Iendtime,
  387. }}})
  388. }
  389. if tab.Sglobalbuyerclass != "" {
  390. if len(tab.Sglobalbuyerclass) > 0 {
  391. buyerclass := sql.BuyerclassObject{
  392. Terms: struct {
  393. Buyerclass []string `json:"buyerclass,omitempty"`
  394. }{
  395. Buyerclass: strings.Split(tab.Sglobalbuyerclass, ","),
  396. },
  397. }
  398. ffBoolObject.Must = append(ffBoolObject.Must, buyerclass)
  399. }
  400. }
  401. if tab.Sglobaltopscopeclass != "" || tab.Sglobalsubscopeclass != "" {
  402. if len(tab.Sglobaltopscopeclass) > 0 {
  403. topScopeclass := sql.Scopeclass{}
  404. topScopeclass.Globaltopscopeclass = strings.Split(tab.Sglobaltopscopeclass, ",")
  405. ffBoolObject.Must = append(ffBoolObject.Must, sql.ScopeclassMust{&topScopeclass})
  406. } else if len(tab.Sglobalsubscopeclass) > 0 {
  407. subScopeclass := sql.Scopeclass{}
  408. subScopeclass.Globalsubscopeclass = strings.Split(tab.Sglobalsubscopeclass, ",")
  409. ffBoolObject.Must = append(ffBoolObject.Must, sql.ScopeclassMust{&subScopeclass})
  410. }
  411. }
  412. fqBoolObject := sql.BoolObject{}
  413. if len(tab.Sexistfields) > 0 {
  414. tmpsfields := strings.Split(tab.Sexistfields, ",")
  415. for _, v := range tmpsfields {
  416. ffBoolObject.Must = append(ffBoolObject.Must, sql.ExistfieldsObjectMust{
  417. ExistfieldsObject: &sql.ExistfieldsObject{Filter: struct {
  418. Exists struct {
  419. Field string `json:"field,omitempty"`
  420. } `json:"exists,omitempty"`
  421. }{
  422. Exists: struct {
  423. Field string `json:"field,omitempty"`
  424. }{Field: v},
  425. },
  426. },
  427. })
  428. }
  429. }
  430. newEsObject := sql.NewEsObject{}
  431. if tab.Sglobaladdkey != "" && tab.Sglobaladdkeymatch != "" {
  432. if tmps := strsToArr(tab.Sglobaladdkeymatch, "str"); tmps != nil {
  433. newEsObject = method1(newEsObject, tab.Sglobaladdkey, tab.Sglobaladdkeymatch, tmps)
  434. }
  435. }
  436. if len(newEsObject.Bool.Should) > 0 || len(newEsObject.Bool.MustNot) > 0 || len(newEsObject.Bool.Must) > 0 {
  437. fqBoolObject.Must = append(fqBoolObject.Must, newEsObject)
  438. }
  439. nots := sql.NewEsObject{}
  440. if tab.Sglobalnotkey != "" && tab.Sglobalnotkeymatch != "" {
  441. if tmps := strsToArr(tab.Sglobalnotkeymatch, "str"); tmps != nil {
  442. nots = method1(nots, tab.Sglobalnotkey, tab.Sglobalnotkeymatch, tmps)
  443. }
  444. }
  445. if len(nots.Bool.Should) > 0 {
  446. fqBoolObject.MustNot = append(fqBoolObject.MustNot, nots)
  447. }
  448. torules := sql.BoolObject{}
  449. for _, v := range tab.Orules {
  450. tmpses := sql.NewEsObject{}
  451. if skeymatchs := strsToArr(v.Skeymatch, "str"); skeymatchs != nil {
  452. tmpnewEsObject := sql.NewEsObject{}
  453. tmpnewEsObject = method1(tmpnewEsObject, v.Smatchkey, v.Skeymatch, skeymatchs)
  454. if len(tmpnewEsObject.Bool.Should) > 0 || len(tmpnewEsObject.Bool.Must) > 0 || len(tmpnewEsObject.Bool.MustNot) > 0 {
  455. tmpses.Bool.Must = append(tmpses.Bool.Must, tmpnewEsObject)
  456. }
  457. }
  458. if saddkeymatchs := strsToArr(v.Saddkeymatch, "str"); saddkeymatchs != nil {
  459. addkeyarr := sql.NewEsObject{}
  460. addkeyarr = method1(addkeyarr, v.Saddkey, v.Saddkeymatch, saddkeymatchs)
  461. if len(addkeyarr.Bool.Should) > 0 {
  462. tmpses.Bool.Must = append(tmpses.Bool.Must, addkeyarr)
  463. }
  464. }
  465. if snotkeymatchs := strsToArr(v.Snotkeymatch, "str"); snotkeymatchs != nil {
  466. tmpses = method2(tmpses, v.Snotkey, v.Snotkeymatch, snotkeymatchs)
  467. }
  468. if len(v.Stopscopeclass) > 0 {
  469. sArr := strings.Split(v.Stopscopeclass, ",")
  470. tmpses.Bool.Must = append(tmpses.Bool.Must, sql.TopscopeclassObject{
  471. Terms: struct {
  472. Topscopeclass []string `json:"s_topscopeclass,omitempty"`
  473. }{
  474. Topscopeclass: sArr,
  475. },
  476. })
  477. } else if len(v.Ssubscopeclass) > 0 {
  478. tmpses.Bool.Must = append(tmpses.Bool.Must, sql.SubscopeclassObject{
  479. Terms: struct {
  480. Subscopeclass []string `json:"s_subscopeclass,omitempty"`
  481. }{
  482. Subscopeclass: strings.Split(v.Ssubscopeclass, ","),
  483. },
  484. })
  485. }
  486. if len(v.Sbuyerclass) > 0 {
  487. tmpses.Bool.Must = append(tmpses.Bool.Must, sql.BuyerclassObject{
  488. Terms: struct {
  489. Buyerclass []string `json:"buyerclass,omitempty"`
  490. }{
  491. Buyerclass: strings.Split(v.Sbuyerclass, ","),
  492. },
  493. })
  494. }
  495. torules.Should = append(torules.Should, tmpses)
  496. }
  497. bidamountSql := sql.NewEsObject{}
  498. if tab.Sbidamount != "" {
  499. if strings.Contains(tab.Sbidamount, "大于") && strings.Contains(tab.Sbidamount, "小于") {
  500. arr := strings.Split(tab.Sbidamount, ",")
  501. limit := &sql.BudgetOrBidamount{
  502. Gte: qu.Float64All(strings.Replace(arr[0], "大于", "", -1)),
  503. Lt: qu.Float64All(strings.Replace(arr[1], "小于", "", -1)),
  504. }
  505. bidamountSql.Bool.Should = append(bidamountSql.Bool.Should, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
  506. } else if strings.Contains(tab.Sbidamount, "大于") {
  507. limit := &sql.BudgetOrBidamount{
  508. Gte: qu.Float64All(strings.Replace(tab.Sbidamount, "大于", "", -1)),
  509. }
  510. bidamountSql.Bool.Should = append(bidamountSql.Bool.Should, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
  511. } else if strings.Contains(tab.Sbidamount, "小于") {
  512. limit := &sql.BudgetOrBidamount{
  513. Lt: qu.Float64All(strings.Replace(tab.Sbidamount, "小于", "", -1)),
  514. }
  515. bidamountSql.Bool.Should = append(bidamountSql.Bool.Should, sql.BidamountMust{BidamountObj: &sql.BidamountObj{Bidamount: limit}})
  516. }
  517. if tab.SbidamountFieldExist == 1 {
  518. SbidamountFieldExistBool := sql.NewEsObject{}
  519. SbidamountFieldExistBool.Bool.MustNot = append(SbidamountFieldExistBool.Bool.MustNot, sql.ExistfieldsObjectMust{
  520. ExistfieldsObject: &sql.ExistfieldsObject{Filter: struct {
  521. Exists struct {
  522. Field string `json:"field,omitempty"`
  523. } `json:"exists,omitempty"`
  524. }{
  525. Exists: struct {
  526. Field string `json:"field,omitempty"`
  527. }{Field: "bidamount"},
  528. },
  529. },
  530. })
  531. bidamountSql.Bool.Should = append(bidamountSql.Bool.Should, SbidamountFieldExistBool)
  532. }
  533. }
  534. budgetSql := sql.NewEsObject{}
  535. if tab.Sbudget != "" {
  536. if strings.Contains(tab.Sbudget, "大于") && strings.Contains(tab.Sbudget, "小于") {
  537. arr := strings.Split(tab.Sbudget, ",")
  538. limit := &sql.BudgetOrBidamount{
  539. Gte: qu.Float64All(strings.Replace(arr[0], "大于", "", -1)),
  540. Lt: qu.Float64All(strings.Replace(arr[1], "小于", "", -1)),
  541. }
  542. budgetSql.Bool.Should = append(budgetSql.Bool.Should, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
  543. } else if strings.Contains(tab.Sbudget, "大于") {
  544. limit := &sql.BudgetOrBidamount{
  545. Gte: qu.Float64All(strings.Replace(tab.Sbudget, "大于", "", -1)),
  546. }
  547. budgetSql.Bool.Should = append(budgetSql.Bool.Should, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
  548. } else if strings.Contains(tab.Sbudget, "小于") {
  549. limit := &sql.BudgetOrBidamount{
  550. Lt: qu.Float64All(strings.Replace(tab.Sbudget, "小于", "", -1)),
  551. }
  552. budgetSql.Bool.Should = append(budgetSql.Bool.Should, sql.BudgetMust{BudgetObj: &sql.BudgetObj{Budget: limit}})
  553. }
  554. if tab.SbudgetFieldExist == 1 {
  555. SbudgetFieldExistBool := sql.NewEsObject{}
  556. SbudgetFieldExistBool.Bool.MustNot = append(SbudgetFieldExistBool.Bool.MustNot, sql.ExistfieldsObjectMust{
  557. ExistfieldsObject: &sql.ExistfieldsObject{Filter: struct {
  558. Exists struct {
  559. Field string `json:"field,omitempty"`
  560. } `json:"exists,omitempty"`
  561. }{
  562. Exists: struct {
  563. Field string `json:"field,omitempty"`
  564. }{Field: "budget"},
  565. },
  566. },
  567. })
  568. budgetSql.Bool.Should = append(budgetSql.Bool.Should, SbudgetFieldExistBool)
  569. }
  570. }
  571. if len(ffBoolObject.Must) > 0 || len(ffBoolObject.MustNot) > 0 || len(ffBoolObject.Should) > 0 {
  572. QueryObjecct.Bool = &ffBoolObject
  573. }
  574. if len(fqBoolObject.Must) > 0 || len(fqBoolObject.MustNot) > 0 || len(fqBoolObject.Should) > 0 {
  575. if QueryObjecct.Bool == nil {
  576. QueryObjecct.Bool = &fqBoolObject
  577. } else {
  578. if fqBoolObject.Must != nil {
  579. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, fqBoolObject.Must...)
  580. }
  581. if fqBoolObject.Should != nil {
  582. QueryObjecct.Bool.Should = append(QueryObjecct.Bool.Should, fqBoolObject.Should...)
  583. }
  584. if fqBoolObject.MustNot != nil {
  585. QueryObjecct.Bool.MustNot = append(QueryObjecct.Bool.MustNot, fqBoolObject.MustNot...)
  586. }
  587. }
  588. if len(torules.Should) > 0 {
  589. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, map[string]interface{}{
  590. "bool": torules,
  591. })
  592. }
  593. } else if len(torules.Should) > 0 {
  594. if QueryObjecct.Bool == nil {
  595. QueryObjecct.Bool = &sql.BoolObject{}
  596. }
  597. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, map[string]interface{}{
  598. "bool": torules,
  599. })
  600. }
  601. if (len(budgetSql.Bool.Should) > 0 || len(bidamountSql.Bool.Should) > 0) && (len(fqBoolObject.Must) > 0 || len(fqBoolObject.MustNot) > 0 || len(fqBoolObject.Should) > 0) {
  602. if QueryObjecct.Bool == nil {
  603. QueryObjecct.Bool = &sql.BoolObject{}
  604. }
  605. if len(budgetSql.Bool.Should) > 0 {
  606. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, budgetSql)
  607. }
  608. if len(bidamountSql.Bool.Should) > 0 {
  609. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, bidamountSql)
  610. }
  611. } else {
  612. if QueryObjecct.Bool == nil {
  613. QueryObjecct.Bool = &sql.BoolObject{}
  614. }
  615. if len(budgetSql.Bool.Should) > 0 {
  616. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, budgetSql)
  617. }
  618. if len(bidamountSql.Bool.Should) > 0 {
  619. QueryObjecct.Bool.Must = append(QueryObjecct.Bool.Must, bidamountSql)
  620. }
  621. }
  622. rdata := make(map[string]interface{})
  623. rdata["query"] = QueryObjecct
  624. esbytes, _ := json.Marshal(rdata)
  625. esStr := strings.Replace(string(esbytes), "regexp1", "regexp", -1)
  626. esStr = strings.Replace(esStr, "publishtime1", "publishtime", -1)
  627. esStr = strings.Replace(esStr, "publishtime2", "publishtime", -1)
  628. return strings.Replace(esStr, "regexp2", "regexp", -1)
  629. }
  630. func strsToArr(strs string, typestr string) []string {
  631. if len(strs) > 0 {
  632. tmps := strings.Split(strs, ",")
  633. switch typestr {
  634. case "str":
  635. for index, vint := range tmps {
  636. switch vint {
  637. case TitleMatchType:
  638. tmps[index] = TitleMatchTypeStr
  639. case DetailMatchType:
  640. tmps[index] = DetailMatchTypeStr
  641. case PurchasingMatchType:
  642. tmps[index] = PurchasingMatchTypeStr
  643. case AttachmentsMatchType:
  644. tmps[index] = AttachmentsMatchTypeStr
  645. case ProjectnameMatchType:
  646. tmps[index] = ProjectnameMatchTypeStr
  647. case BuyerMatchType:
  648. tmps[index] = BuyerMatchTypeStr
  649. case SWinnerMatchType:
  650. tmps[index] = SWinnerMatchTypeStr
  651. case BuyerMatchType1:
  652. tmps[index] = BuyerRegexpMatchTypeStr
  653. case SWinnerMatchType1:
  654. tmps[index] = SWinnerRegexpMatchTypeStr
  655. }
  656. }
  657. return tmps
  658. case "field":
  659. for index, vint := range tmps {
  660. switch vint {
  661. case TitleMatchType:
  662. tmps[index] = TitleMatchTypeField
  663. case DetailMatchType:
  664. tmps[index] = DetailMatchTypeField
  665. case PurchasingMatchType:
  666. tmps[index] = PurchasingMatchTypeField
  667. case AttachmentsMatchType:
  668. tmps[index] = AttachmentsMatchTypeField
  669. case ProjectnameMatchType:
  670. tmps[index] = ProjectnameMatchTypeField
  671. case BuyerMatchType:
  672. tmps[index] = BuyerMatchTypeField
  673. case SWinnerMatchType:
  674. tmps[index] = SWinnerMatchTypeField
  675. case BuyerMatchType1:
  676. tmps[index] = BuyerMatchTypeField
  677. case SWinnerMatchType1:
  678. tmps[index] = SWinnerMatchTypeField
  679. }
  680. }
  681. return tmps
  682. }
  683. }
  684. return nil
  685. }
  686. func init() {
  687. EsIndex = qu.ObjToString(Sysconfig["elasticsearch_index"])
  688. EsType = qu.ObjToString(Sysconfig["elasticsearch_type"])
  689. }
  690. func method1(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
  691. keywordArr := []string{}
  692. for _, vv := range strings.Split(keyword, ",") {
  693. if vv == "" {
  694. continue
  695. }
  696. //log.Println(vv, tmps, keymatch)
  697. if len(tmps) == 1 && (strings.Contains(keymatch, "8") || strings.Contains(keymatch, "9")) {
  698. //中标单位、采购单位、中标单位(正则)、采购单位(正则) 单选
  699. strs := ""
  700. if strings.Contains(vv, "&&") {
  701. //strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
  702. strs = strings.Replace(vv, "&&", ".*", -1)
  703. } else {
  704. strs = vv
  705. }
  706. if tmps[0] == "buyer.mbuyer" {
  707. newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
  708. MultiMatch: &sql.MultiMatch{
  709. Query: strs,
  710. Type: MultiMatchType,
  711. Fields: tmps,
  712. },
  713. })
  714. } else if tmps[0] == "s_winner.mwinner" {
  715. newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
  716. MultiMatch: &sql.MultiMatch{
  717. Query: strs,
  718. Type: MultiMatchType,
  719. Fields: tmps,
  720. },
  721. })
  722. }
  723. } else if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
  724. addkeylines := strings.Split(vv, "&&")
  725. keywordArr = append(keywordArr, addkeylines[0])
  726. } else {
  727. addkeylines := strings.Split(vv, "&&")
  728. //log.Println(addkeylines, "addkeylines")
  729. if len(addkeylines) > 1 {
  730. addkeyline := sql.NewEsObject{}
  731. for _, vvv := range addkeylines {
  732. if vvv == "" {
  733. continue
  734. }
  735. addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.ShouldObj{
  736. MultiMatch: &sql.MultiMatch{
  737. Query: vvv,
  738. Type: MultiMatchType,
  739. Fields: tmps,
  740. },
  741. })
  742. }
  743. if len(addkeyline.Bool.Must) > 0 {
  744. newEsObject.Bool.Should = append(newEsObject.Bool.Should, addkeyline)
  745. }
  746. } else {
  747. newEsObject.Bool.Should = append(newEsObject.Bool.Should, sql.ShouldObj{
  748. MultiMatch: &sql.MultiMatch{
  749. Query: vv,
  750. Type: MultiMatchType,
  751. Fields: tmps,
  752. },
  753. })
  754. }
  755. }
  756. }
  757. if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
  758. addkeyline := sql.NewEsObject{}
  759. if tmps[0] == "buyer" {
  760. addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.BuyerMatch{
  761. Buyer: &sql.Buyer{Buyer: keywordArr},
  762. })
  763. } else if tmps[0] == "s_winner" {
  764. addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.WinnerMatch{
  765. Winner: &sql.Winner{Winner: keywordArr},
  766. })
  767. }
  768. if len(addkeyline.Bool.Must) > 0 {
  769. newEsObject.Bool.Should = append(newEsObject.Bool.Should, addkeyline)
  770. }
  771. }
  772. return newEsObject
  773. }
  774. func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
  775. notKeyWordArr := []string{}
  776. for _, vv := range strings.Split(keyword, ",") {
  777. if vv == "" {
  778. continue
  779. }
  780. if len(tmps) == 1 && (strings.Contains(keymatch, "8") || strings.Contains(keymatch, "9")) {
  781. //中标单位、采购单位、中标单位(正则)、采购单位(正则) 单选
  782. //strs := ""
  783. //if strings.Contains(vv, "&&") {
  784. // strs = ".*" + strings.Replace(vv, "&&", ".*", -1) + ".*"
  785. //} else {
  786. // strs = ".*" + vv + ".*"
  787. //}
  788. if tmps[0] == "buyer.mbuyer" {
  789. newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
  790. MultiMatch: &sql.MultiMatch{
  791. Query: vv,
  792. Type: MultiMatchType,
  793. Fields: tmps,
  794. },
  795. })
  796. } else if tmps[0] == "s_winner.mwinner" {
  797. newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
  798. MultiMatch: &sql.MultiMatch{
  799. Query: vv,
  800. Type: MultiMatchType,
  801. Fields: tmps,
  802. },
  803. })
  804. }
  805. } else if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
  806. notkeylines := strings.Split(vv, "&&")
  807. notKeyWordArr = append(notKeyWordArr, notkeylines[0])
  808. } else {
  809. notkeylines := strings.Split(vv, "&&")
  810. if len(notkeylines) > 1 {
  811. notkeyline := sql.NewEsObject{}
  812. for _, vvv := range notkeylines {
  813. if vvv == "" {
  814. continue
  815. }
  816. notkeyline.Bool.Must = append(notkeyline.Bool.Must, sql.ShouldObj{
  817. MultiMatch: &sql.MultiMatch{
  818. Query: vvv,
  819. Type: MultiMatchType,
  820. Fields: tmps,
  821. },
  822. })
  823. }
  824. if len(notkeyline.Bool.Must) > 0 {
  825. newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, notkeyline)
  826. }
  827. } else {
  828. newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
  829. MultiMatch: &sql.MultiMatch{
  830. Query: vv,
  831. Type: MultiMatchType,
  832. Fields: tmps,
  833. },
  834. })
  835. }
  836. }
  837. }
  838. if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
  839. var notkeyline interface{}
  840. if tmps[0] == "buyer" {
  841. notkeyline = sql.BuyerMatch{
  842. Buyer: &sql.Buyer{Buyer: notKeyWordArr},
  843. }
  844. } else if tmps[0] == "s_winner" {
  845. notkeyline = sql.WinnerMatch{
  846. Winner: &sql.Winner{Winner: notKeyWordArr},
  847. }
  848. }
  849. if notkeyline != nil {
  850. newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, notkeyline)
  851. }
  852. }
  853. return newEsObject
  854. }
  855. /**
  856. * 一级公告行业处理 d、t、p
  857. */
  858. func method3(arr []string) []string {
  859. var sArr []string
  860. for _, v := range arr {
  861. sArr = append(sArr, v+"d")
  862. sArr = append(sArr, v+"t")
  863. sArr = append(sArr, v+"p")
  864. }
  865. return sArr
  866. }
  867. func GetMactchKey(match []map[string]string, data map[string]interface{}) string {
  868. keyWord := []string{}
  869. for _, keys := range match {
  870. types := keys["s_keymatch"]
  871. key := keys["s_matchkey"]
  872. if strings.Contains(types, "1") {
  873. title := qu.ObjToString(data["title"])
  874. keyWord = KeyWordToData(types, title, key, keyWord)
  875. }
  876. if strings.Contains(types, "2") {
  877. detail := qu.ObjToString(data["detail"])
  878. keyWord = KeyWordToData(types, detail, key, keyWord)
  879. }
  880. if strings.Contains(types, "3") {
  881. purchasing := qu.ObjToString(data["purchasing"])
  882. keyWord = KeyWordToData(types, purchasing, key, keyWord)
  883. }
  884. if strings.Contains(types, "4") {
  885. filetext := qu.ObjToString(data["filetext"])
  886. keyWord = KeyWordToData(types, filetext, key, keyWord)
  887. }
  888. if strings.Contains(types, "5") {
  889. projectname := qu.ObjToString(data["projectname"])
  890. keyWord = KeyWordToData(types, projectname, key, keyWord)
  891. }
  892. if strings.Contains(types, "6") || strings.Contains(types, "8") {
  893. buyer := qu.ObjToString(data["buyer"])
  894. keyWord = KeyWordToData(types, buyer, key, keyWord)
  895. }
  896. if strings.Contains(types, "7") || strings.Contains(types, "9") {
  897. winner := qu.ObjToString(data["s_winner"])
  898. keyWord = KeyWordToData(types, winner, key, keyWord)
  899. }
  900. }
  901. keyMap := map[string]bool{}
  902. keyArr := []string{}
  903. for _, key := range keyWord {
  904. keyMap[key] = true
  905. }
  906. for k, _ := range keyMap {
  907. keyArr = append(keyArr, k)
  908. }
  909. return strings.Join(keyArr, ",")
  910. }
  911. func KeyWordToData(types, item, key string, keyWord []string) []string {
  912. for _, mk := range strings.Split(key, ",") {
  913. if strings.Contains(mk, "&&") {
  914. arr := strings.Split(mk, "&&")
  915. isok := true
  916. for _, s := range arr {
  917. if s != "" {
  918. if !strings.Contains(strings.ToUpper(item), strings.ToUpper(s)) {
  919. isok = false
  920. }
  921. }
  922. }
  923. if isok {
  924. keyWord = append(keyWord, mk)
  925. }
  926. } else {
  927. if strings.Contains(strings.ToUpper(item), strings.ToUpper(mk)) {
  928. keyWord = append(keyWord, mk)
  929. }
  930. }
  931. }
  932. return keyWord
  933. }
  934. func GetProjectId_1(id string) string {
  935. query := `{"query": {"bool": {"must": [{"term": {"ids": "%s"}}],"must_not": [],"should": []}}}`
  936. querys := fmt.Sprintf(query, id)
  937. projectId := ""
  938. projectIdArr := []string{}
  939. data := Es.Get("projectset", "projectset", querys)
  940. if data != nil && *data != nil && len(*data) > 0 {
  941. for _, v := range *data {
  942. projectIdArr = append(projectIdArr, qu.ObjToString(v["_id"]))
  943. }
  944. projectId = strings.Join(projectIdArr, ",")
  945. log.Println("projectId", projectId)
  946. } else {
  947. log.Println("ES未查到项目id", id)
  948. }
  949. return projectId
  950. }
  951. func chunkArray(arr []string, size int) [][]string {
  952. var chunks [][]string
  953. for i := 0; i < len(arr); i += size {
  954. end := i + size
  955. if end > len(arr) {
  956. end = len(arr)
  957. }
  958. chunks = append(chunks, arr[i:end])
  959. }
  960. return chunks
  961. }
  962. func GetProjectId(datas *[]map[string]interface{}) (pidMap map[string]interface{}) {
  963. var ids []string
  964. pidMap = make(map[string]interface{})
  965. for _, d1 := range *datas {
  966. id := qu.ObjToString(d1["info_id"])
  967. ids = append(ids, id)
  968. pidMap[id] = ""
  969. }
  970. query := `{"query": {"bool": {"must": [{"terms": {"ids": ["%s"]}}]}},"_source": ["ids","id"]}`
  971. for _, array := range chunkArray(ids, 200) {
  972. query = fmt.Sprintf(query, strings.Join(array, "\",\""))
  973. data := Es.Get("projectset", "projectset", query)
  974. if data != nil && *data != nil && len(*data) > 0 {
  975. for _, v := range *data {
  976. pid := qu.ObjToString(v["id"])
  977. for _, id := range strings.Split(qu.ObjToString(v["ids"]), ",") {
  978. if pidMap[id] != nil {
  979. pidMap[id] = pid
  980. }
  981. }
  982. }
  983. } else {
  984. log.Println("ES未查到项目id", query)
  985. }
  986. }
  987. for _, m := range *datas {
  988. id := qu.ObjToString(m["info_id"])
  989. if pid := qu.ObjToString(pidMap[id]); pid != "" {
  990. log.Println("id: ", id, "pid: ", pid)
  991. m["projectId"] = SE2.EncodeString(pid)
  992. } else {
  993. log.Println("id: ", id, "pid: -")
  994. }
  995. }
  996. return
  997. }