project.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. package main
  2. import (
  3. "context"
  4. "github.com/google/uuid"
  5. "go.mongodb.org/mongo-driver/bson"
  6. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  7. "math"
  8. "sort"
  9. "strings"
  10. "sync"
  11. "tieta_data/config"
  12. )
  13. var (
  14. wg sync.WaitGroup
  15. )
  16. // 从对应map中获取对比的项目id
  17. func getCompareIds(pn, pc, pb string) (bpn, bpc, bpb int, res []*Key, idArr []string, IDArr []*ID) {
  18. // p.ConCurrentLock(n1, n2, n3, n4)
  19. // defer p.ConCurrentUnLock(n1, n2, n3, n4)
  20. wg.Add(1)
  21. //查找到id数组
  22. res = []*Key{}
  23. //是否查找到,并标识位置。-1代表值为空或已经存在。
  24. bpn, bpc, bpb = -1, -1, -1
  25. if pn != "" {
  26. ids := mapPn[pn]
  27. if ids == nil {
  28. ids = &Key{Arr: []string{}}
  29. mapPn[pn] = ids
  30. bpn = 0
  31. }
  32. ids.Lock.Lock()
  33. res = append(res, ids)
  34. }
  35. if pc != "" {
  36. ids := mapPc[pc]
  37. if ids == nil {
  38. ids = &Key{Arr: []string{}}
  39. mapPc[pc] = ids
  40. bpc = len(res)
  41. }
  42. ids.Lock.Lock()
  43. res = append(res, ids)
  44. }
  45. if pb != "" {
  46. ids := mapPb[pb]
  47. if ids == nil {
  48. ids = &Key{Arr: []string{}}
  49. mapPb[pb] = ids
  50. bpb = len(res)
  51. }
  52. ids.Lock.Lock()
  53. res = append(res, ids)
  54. }
  55. repeatId := map[string]bool{}
  56. idArr = []string{} //项目id
  57. IDArr = []*ID{} //项目信息
  58. for _, m := range res {
  59. for _, id := range m.Arr {
  60. if !repeatId[id] {
  61. repeatId[id] = true
  62. //_, _ = strconv.ParseInt(id[0:8], 16, 64)
  63. AllIdsMapLock.Lock()
  64. Id := AllIdsMap[id]
  65. AllIdsMapLock.Unlock()
  66. if Id != nil {
  67. Id.Lock.Lock()
  68. idArr = append(idArr, id)
  69. IDArr = append(IDArr, Id)
  70. }
  71. }
  72. }
  73. }
  74. return
  75. }
  76. func startProjectMerge(info *Info, tmp map[string]interface{}) {
  77. findLock.Lock()
  78. defer findLock.Unlock()
  79. //bpn, bpc, bptc, bpb 是否查找到,并标识位置。-1代表未查找到。
  80. //pids 是项目id数组集合
  81. //IDArr,是单个项目ID对象集合
  82. bpn, bpc, bpb, pids, _, IDArr := getCompareIds(info.ProjectName, info.ProjectCode, info.Buyer) //, info.LenPN, info.LenPC, info.LenPTC, len([]rune(info.Buyer)))
  83. defer wg.Done()
  84. //map--k为pn,ptn,pc,ptc,buyer值 v为Id数组和lock
  85. for _, m := range pids {
  86. defer m.Lock.Unlock()
  87. }
  88. for _, id := range IDArr {
  89. defer id.Lock.Unlock()
  90. }
  91. bFindProject := false
  92. findPid := ""
  93. //获取完id,进行计算
  94. //定义两组
  95. comRes1 := []*Project{} //优先级最高的对比结果数组
  96. comRes2 := []*Project{} //优化级其次
  97. comRes3 := []*Project{}
  98. for _, v := range IDArr {
  99. comStr := ""
  100. compareProject := v.P
  101. compareProject.score = 0
  102. diffTime := int64(math.Abs(float64(info.Publishtime - compareProject.LastTime)))
  103. //代理机构完全不相同,直接新建项目
  104. if CheckContain(compareProject.Agency, info.Agency) == 3 {
  105. continue
  106. }
  107. //地区(省、市、区)不同,直接新建项目
  108. if ComparePlace(compareProject, info) {
  109. continue
  110. }
  111. // 多包 处理
  112. if ComparePkg(compareProject, info) {
  113. continue
  114. }
  115. compareStr, score := comparePNC(info, compareProject)
  116. resVal, pjVal := Select(compareStr, info, compareProject)
  117. //---------------------------------------
  118. if resVal > 0 {
  119. compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount, score2 := compareBCTABB(info, compareProject, diffTime, score)
  120. //项目名称、项目编号、标题项目编号、采购单位、省、市、发布时间、代理机构
  121. comStr = compareStr + compareBuyer + compareCity + compareTime + compareAgency + compareBudget + compareBidmount
  122. compareProject.comStr = comStr
  123. compareProject.pjVal = pjVal
  124. compareProject.resVal = resVal
  125. //log.Println(compareProject.comStr)
  126. eqV := compareResult(resVal, pjVal, score2, comStr, compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount)
  127. if eqV == 1 {
  128. comRes1 = append(comRes1, compareProject)
  129. } else if eqV == 2 {
  130. comRes2 = append(comRes2, compareProject)
  131. } else if eqV == 3 {
  132. comRes3 = append(comRes3, compareProject)
  133. }
  134. }
  135. }
  136. //--------------------------------对比完成-----------------------
  137. //更新数组、更新项目
  138. for kv, resN := range [][]*Project{comRes1, comRes2, comRes3} {
  139. if len(resN) > 0 {
  140. if len(resN) > 1 {
  141. sort.Slice(resN, func(i, j int) bool {
  142. return resN[i].score > resN[j].score
  143. })
  144. }
  145. resArr := []*Project{}
  146. for _, res := range resN {
  147. resArr = append(resArr, res)
  148. }
  149. if len(resArr) > 0 {
  150. bFindProject = true
  151. findPid = resArr[0].ProjectId
  152. UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr)
  153. for k2, bv := range []int{bpn, bpc, bpb} {
  154. if bv > -1 {
  155. pids[bv].Arr = append(pids[bv].Arr, findPid)
  156. if k2 == 0 {
  157. if resArr[0].ProjectName == "" {
  158. resArr[0].ProjectName = info.ProjectName
  159. }
  160. } else if k2 < 3 {
  161. if resArr[0].ProjectCode == "" {
  162. resArr[0].ProjectCode = info.ProjectCode
  163. }
  164. } else {
  165. if resArr[0].Buyer == "" {
  166. resArr[0].Buyer = info.Buyer
  167. }
  168. }
  169. }
  170. }
  171. } else {
  172. bFindProject = false
  173. findPid = ""
  174. }
  175. break
  176. }
  177. }
  178. if !bFindProject {
  179. id, p1 := NewProject(tmp, info)
  180. AllIdsMapLock.Lock()
  181. AllIdsMap[id] = &ID{Id: id, P: p1}
  182. AllIdsMapLock.Unlock()
  183. for _, m := range pids {
  184. m.Arr = append(m.Arr, id)
  185. }
  186. }
  187. }
  188. func compareBCTABB(info *Info, cp *Project, diffTime int64, score int) (compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount string, score2 int) {
  189. compareBuyer = "D"
  190. if len([]rune(info.Buyer)) > 3 && len([]rune(cp.Buyer)) > 3 {
  191. v := CheckContain(info.Buyer, cp.Buyer)
  192. if v == 1 {
  193. compareBuyer = "A"
  194. score += 3
  195. } else {
  196. //v1 := CosineSimilar(info.Buyer, cp.Buyer)
  197. if v == 2 {
  198. compareBuyer = "B"
  199. score += 1
  200. } else {
  201. compareBuyer = "C"
  202. }
  203. }
  204. }
  205. //---------------------------------------
  206. compareCity = ""
  207. if info.Area != "全国" && info.Area != "" && info.Area == cp.Area {
  208. compareCity += "A"
  209. score += 2
  210. } else if info.Area == "全国" || cp.Area == "全国" {
  211. compareCity += "B"
  212. score += 1
  213. } else {
  214. compareCity += "C"
  215. }
  216. if compareCity != "C" {
  217. if info.City != "" && info.City == cp.City {
  218. compareCity += "A"
  219. score += 2
  220. } else {
  221. if info.Area == "全国" || cp.Area == "全国" {
  222. compareCity += "B"
  223. } else if info.City == compareCity {
  224. compareCity += "B"
  225. } else {
  226. compareCity += "C"
  227. }
  228. }
  229. } else {
  230. compareCity += "C"
  231. }
  232. score2 = 0
  233. if compareCity == "AA" {
  234. if info.District != "" && info.District == cp.District {
  235. score2 = 1
  236. }
  237. }
  238. compareTime = "D"
  239. if diffTime < 45*86400 {
  240. compareTime = "A"
  241. score += 2
  242. } else if diffTime < 90*86400 {
  243. compareTime = "B"
  244. score += 1
  245. }
  246. compareAgency = "D"
  247. if info.Agency != "" {
  248. if info.Agency == cp.Agency {
  249. compareAgency = "A"
  250. score += 2
  251. score2 += 1
  252. } else if cp.Agency != "" {
  253. if strings.Contains(info.Agency, cp.Agency) || strings.Contains(cp.Agency, info.Agency) {
  254. compareAgency = "B"
  255. score += 1
  256. score2 += 1
  257. } else {
  258. compareAgency = "C"
  259. }
  260. }
  261. }
  262. compareBudget = "C"
  263. if info.Budget > 0 && (info.Budget == cp.Budget || (cp.Bidamount > 0 && info.Budget > cp.Bidamount && (info.Budget-cp.Bidamount) < (0.15*info.Budget))) {
  264. compareBudget = "A"
  265. score += 1
  266. score2 += 1
  267. }
  268. // else if info.Budget == 0 && cp.Budget == 0 {
  269. // compareBudget = "B"
  270. // }
  271. compareBidmount = "C"
  272. if info.Bidamount > 0 && (info.Bidamount == cp.Bidamount || (cp.Budget > 0 && cp.Budget > info.Bidamount && (cp.Budget-info.Bidamount) < 0.15*cp.Budget)) {
  273. compareBidmount = "A"
  274. score += 1
  275. score2 += 1
  276. }
  277. // else if info.Bidamount == 0 && cp.Bidamount == 0 {
  278. // compareBidmount = "B"
  279. // }
  280. cp.score = score
  281. return
  282. }
  283. func compareResult(resVal, pjVal, score2 int, comStr, compareBuyer, compareCity, compareTime, compareAgency, compareBudget, compareBidmount string) int {
  284. eqV := 0
  285. switch resVal {
  286. case 3:
  287. if pjVal == 3 && comStr[3:] != "CCCDCCC" {
  288. eqV = 1
  289. } else if compareBuyer < "C" {
  290. if pjVal > 1 {
  291. eqV = 1
  292. } else { //if (compareCity[1:1] != "C" || compareTime != "D") && score2 > 0
  293. eqV = 2
  294. }
  295. } else if compareBuyer == "D" {
  296. if pjVal > 1 && (compareCity[1:1] != "C" || score2 > 0) {
  297. eqV = 2
  298. } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
  299. eqV = 3
  300. }
  301. } else {
  302. if pjVal == 3 && (score2 > 0 || compareCity[1:1] != "C") {
  303. eqV = 2
  304. } else if pjVal == 2 && compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
  305. eqV = 3
  306. } else if compareCity == "AA" && compareTime == "A" && score2 > 0 {
  307. eqV = 3
  308. }
  309. }
  310. case 2:
  311. if compareBuyer < "C" {
  312. if pjVal > 1 {
  313. eqV = 2
  314. } else if compareCity[1:1] != "C" && compareTime == "A" || score2 > 0 {
  315. eqV = 3
  316. }
  317. } else if compareBuyer == "D" {
  318. if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
  319. eqV = 2
  320. } else if compareCity[1:1] != "C" && compareTime == "A" && score2 > 0 {
  321. eqV = 3
  322. }
  323. } else {
  324. if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
  325. eqV = 2
  326. } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
  327. eqV = 3
  328. }
  329. }
  330. case 1:
  331. if compareBuyer < "C" {
  332. if pjVal > 1 && (score2 > 0 || compareCity[1:1] != "C") {
  333. eqV = 2
  334. } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
  335. eqV = 3
  336. }
  337. } else if compareBuyer == "D" {
  338. if pjVal > 1 && compareTime == "A" && (score2 > 0 || compareCity[1:1] != "C") {
  339. eqV = 2
  340. } else if compareCity[1:1] != "C" && compareTime == "A" && (compareAgency == "A" || score2 > 0) && (compareBudget == "A" || compareBidmount == "A") {
  341. eqV = 3
  342. }
  343. } else {
  344. if pjVal > 1 && compareTime == "A" && score2 > 0 && (compareBudget == "A" || compareBidmount == "A") && compareCity[1:1] != "C" {
  345. eqV = 3
  346. }
  347. }
  348. }
  349. return eqV
  350. }
  351. func ComparePlace(project *Project, info *Info) bool {
  352. if info.Area == "全国" || info.Area == "" {
  353. return false
  354. }
  355. if project.Area == "全国" || project.Area == "" {
  356. return false
  357. }
  358. if info.Area == project.Area {
  359. if info.City == "" || project.City == "" {
  360. return false
  361. } else if info.City == project.City {
  362. return false
  363. }
  364. } else {
  365. return true
  366. }
  367. return true
  368. }
  369. func ComparePkg(project *Project, info *Info) bool {
  370. if project.MultiPackage == 1 && project.MultiPackageId == info.MultiPackageId {
  371. return false
  372. }
  373. return true
  374. }
  375. func NewCachePinfo(thisinfo *Info, pid string) Project {
  376. p1 := Project{
  377. ProjectId: pid,
  378. ProjectName: thisinfo.ProjectName,
  379. ProjectCode: thisinfo.ProjectCode,
  380. Buyer: thisinfo.Buyer,
  381. Agency: thisinfo.Agency,
  382. Area: thisinfo.Area,
  383. City: thisinfo.City,
  384. District: thisinfo.District,
  385. FirstTime: thisinfo.Publishtime,
  386. LastTime: thisinfo.Publishtime,
  387. Budget: thisinfo.Budget,
  388. Bidamount: thisinfo.Bidamount,
  389. MultiPackage: thisinfo.MultiPackage,
  390. MultiPackageId: thisinfo.MultiPackageId,
  391. }
  392. return p1
  393. }
  394. func NewProject(tmp map[string]interface{}, thisinfo *Info) (string, *Project) {
  395. pId := uuid.New().String()
  396. pId = strings.ReplaceAll(pId, "-", "")
  397. set := map[string]interface{}{}
  398. set["projectId"] = pId
  399. set["sourceinfoid"] = thisinfo.Id
  400. for _, f := range FIELDS {
  401. if tmp[f] != nil && tmp[f] != "" {
  402. set[f] = tmp[f]
  403. }
  404. }
  405. if util.ObjToString(tmp["projectname"]) == "" {
  406. set["projectname"] = thisinfo.ProjectName
  407. }
  408. p1 := NewCachePinfo(thisinfo, pId)
  409. if thisinfo.TopType == "招标" {
  410. p1.Zbtime = util.Int64All(tmp["publishtime"])
  411. set["zb_href"] = thisinfo.Href
  412. set["zb_jybxhref"] = thisinfo.JybxHref
  413. set["zb_updatetime"] = tmp["publishtime"]
  414. set["zb_infoid"] = thisinfo.Id
  415. set["zb_toptype"] = thisinfo.TopType
  416. set["zb_subtype"] = thisinfo.SubType
  417. } else if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "合同" || thisinfo.SubType == "验收" ||
  418. thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
  419. p1.Jgtime = thisinfo.Publishtime
  420. set["href"] = thisinfo.Href
  421. set["jybxhref"] = thisinfo.JybxHref
  422. set["updatetime"] = tmp["publishtime"]
  423. set["infoid"] = thisinfo.Id
  424. set["toptype"] = thisinfo.TopType
  425. set["subtype"] = thisinfo.SubType
  426. }
  427. if len(thisinfo.Winners) > 0 {
  428. set["s_winner"] = strings.Join(thisinfo.Winners, ",")
  429. p1.Winners = strings.Join(thisinfo.Winners, ",")
  430. if util.ObjToString(tmp["winnertel"]) != "" {
  431. set["winnertel"] = tmp["winnertel"]
  432. }
  433. if util.ObjToString(tmp["winnerperson"]) != "" {
  434. set["winnerperson"] = tmp["winnerperson"]
  435. }
  436. }
  437. if util.ObjToString(tmp["tagname"]) != "" {
  438. p1.TagName = util.ObjToString(tmp["tagname"])
  439. set["tagname"] = util.ObjToString(tmp["tagname"])
  440. }
  441. if util.ObjToString(tmp["tagname2"]) != "" {
  442. p1.TagName2 = util.ObjToString(tmp["tagname2"])
  443. set["tagname2"] = util.ObjToString(tmp["tagname2"])
  444. }
  445. if util.ObjToString(tmp["tagname3"]) != "" {
  446. p1.TagName3 = util.ObjToString(tmp["tagname3"])
  447. set["tagname3"] = util.ObjToString(tmp["tagname3"])
  448. }
  449. if thisinfo.MultiPackage == 0 {
  450. set["multipackage"] = 0
  451. } else {
  452. set["multipackage"] = 1
  453. set["multipackageid"] = thisinfo.MultiPackageId
  454. }
  455. id := MysqlTool.Insert(config.Conf.DB.Mysql.Pcoll, set)
  456. if id > 0 {
  457. MysqlTool.Update(config.Conf.DB.Mysql.Coll, bson.M{"msg_id": thisinfo.MsgId}, bson.M{"projectId": pId})
  458. client := Es.GetEsConn()
  459. defer Es.DestoryEsConn(client)
  460. client.Update().Index(config.Conf.DB.Es.Index).Id(thisinfo.Nid).
  461. Doc(map[string]interface{}{"projectId": pId}).Refresh("true").Do(context.TODO())
  462. }
  463. return pId, &p1
  464. }
  465. func UpdateProject(tmp map[string]interface{}, thisinfo *Info, pInfo *Project, weight int, comStr string) {
  466. set := map[string]interface{}{}
  467. //相同城市的公告才会合并到一起(全国列外)
  468. if thisinfo.Area != "全国" {
  469. pInfo.Area = thisinfo.Area
  470. set["area"] = thisinfo.Area
  471. if thisinfo.City != "" {
  472. pInfo.City = thisinfo.City
  473. set["city"] = thisinfo.City
  474. }
  475. if thisinfo.District != "" {
  476. pInfo.District = thisinfo.District
  477. set["district"] = thisinfo.District
  478. }
  479. }
  480. //项目名称
  481. if pInfo.ProjectName == "" && thisinfo.ProjectName != "" {
  482. pInfo.ProjectName = thisinfo.ProjectName
  483. set["projectname"] = thisinfo.ProjectName
  484. }
  485. if pInfo.ProjectCode == "" && thisinfo.ProjectCode != "" {
  486. pInfo.ProjectCode = thisinfo.ProjectCode
  487. set["projectcode"] = thisinfo.ProjectCode
  488. }
  489. //7--采购单位
  490. if (pInfo.Buyer == "" && thisinfo.Buyer != "") || (len([]rune(pInfo.Buyer)) < 5 && len([]rune(thisinfo.Buyer)) > 5) {
  491. pInfo.Buyer = thisinfo.Buyer
  492. set["buyer"] = thisinfo.Buyer
  493. pInfo.Buyerclass = thisinfo.Buyerclass
  494. set["buyerclass"] = thisinfo.Buyerclass
  495. }
  496. //采购单位联系人
  497. if thisinfo.Buyerperson != "" {
  498. pInfo.Buyerperson = thisinfo.Buyerperson
  499. set["buyerperson"] = thisinfo.Buyerperson
  500. }
  501. //采购单位電話
  502. if thisinfo.Buyertel != "" {
  503. pInfo.Buyertel = thisinfo.Buyertel
  504. set["buyertel"] = pInfo.Buyertel
  505. }
  506. //8--代理机构
  507. if (pInfo.Agency == "" && thisinfo.Agency != "") || (len([]rune(pInfo.Agency)) < 5 && len([]rune(thisinfo.Agency)) > 5) {
  508. pInfo.Agency = thisinfo.Agency
  509. set["agency"] = thisinfo.Agency
  510. }
  511. if util.ObjToString(tmp["agencyperson"]) != "" {
  512. set["agencyperson"] = tmp["agencyperson"]
  513. }
  514. if util.ObjToString(tmp["agencytel"]) != "" {
  515. set["agencytel"] = tmp["agencytel"]
  516. }
  517. if len(thisinfo.Winners) > 0 {
  518. var winners []string
  519. if pInfo.Winners == "" {
  520. for _, k := range thisinfo.Winners {
  521. if k == "" {
  522. continue
  523. }
  524. if BinarySearch(winners, k) == -1 {
  525. winners = append(winners, k)
  526. }
  527. }
  528. } else {
  529. winners = strings.Split(pInfo.Winners, ",")
  530. for _, k := range thisinfo.Winners {
  531. if k == "" {
  532. continue
  533. }
  534. if thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
  535. if BinarySearch(winners, k) != -1 {
  536. deleteSlice(winners, k, "")
  537. }
  538. } else {
  539. if BinarySearch(winners, k) == -1 {
  540. winners = append(winners, k)
  541. }
  542. }
  543. }
  544. }
  545. set["s_winner"] = strings.Join(util.ObjArrToStringArr(Duplicate(winners)), ",")
  546. if util.ObjToString(tmp["winnertel"]) != "" {
  547. set["winnertel"] = tmp["winnertel"]
  548. }
  549. if util.ObjToString(tmp["winnerperson"]) != "" {
  550. set["winnerperson"] = tmp["winnerperson"]
  551. }
  552. }
  553. if thisinfo.TopType == "招标" {
  554. set["zb_href"] = thisinfo.Href
  555. set["zb_jybxhref"] = thisinfo.JybxHref
  556. set["zb_infoid"] = thisinfo.Id
  557. set["zb_updatetime"] = tmp["publishtime"]
  558. set["zb_toptype"] = thisinfo.TopType
  559. set["zb_subtype"] = thisinfo.SubType
  560. } else if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "合同" || thisinfo.SubType == "验收" ||
  561. thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
  562. set["href"] = thisinfo.Href
  563. set["jybxhref"] = thisinfo.JybxHref
  564. set["updatetime"] = tmp["publishtime"]
  565. set["infoid"] = thisinfo.Id
  566. set["toptype"] = thisinfo.TopType
  567. set["subtype"] = thisinfo.SubType
  568. }
  569. if util.ObjToString(tmp["tagname"]) != "" && pInfo.TagName != "" {
  570. pInfo.TagName = util.ObjToString(tmp["tagname"])
  571. set["tagname"] = util.ObjToString(tmp["tagname"])
  572. }
  573. if util.ObjToString(tmp["tagname2"]) != "" && pInfo.TagName2 != "" {
  574. pInfo.TagName2 = util.ObjToString(tmp["tagname2"])
  575. set["tagname2"] = util.ObjToString(tmp["tagname2"])
  576. }
  577. if util.ObjToString(tmp["tagname3"]) != "" && pInfo.TagName3 != "" {
  578. pInfo.TagName3 = util.ObjToString(tmp["tagname3"])
  579. set["tagname3"] = util.ObjToString(tmp["tagname3"])
  580. }
  581. if thisinfo.Budget > 0 {
  582. set["budget"] = thisinfo.Budget
  583. pInfo.Budget = thisinfo.Budget
  584. }
  585. if thisinfo.Bidamount > 0 {
  586. set["bidamount"] = thisinfo.Bidamount
  587. pInfo.Bidamount = thisinfo.Bidamount
  588. }
  589. b := MysqlTool.Update(config.Conf.DB.Mysql.Pcoll, bson.M{"projectId": pInfo.ProjectId}, set)
  590. if b {
  591. MysqlTool.Update(config.Conf.DB.Mysql.Coll, bson.M{"msg_id": thisinfo.MsgId}, bson.M{"projectId": pInfo.ProjectId})
  592. client := Es.GetEsConn()
  593. defer Es.DestoryEsConn(client)
  594. client.Update().Index(config.Conf.DB.Es.Index).Id(thisinfo.Nid).
  595. Doc(map[string]interface{}{"projectId": pInfo.ProjectId}).Refresh("true").Do(context.TODO())
  596. }
  597. }