main.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. // main
  2. package main
  3. import (
  4. "flag"
  5. "fmt"
  6. "log"
  7. "mongodb"
  8. "os"
  9. qu "qfw/util"
  10. "regexp"
  11. "strings"
  12. //"time"
  13. )
  14. var zhb_key_list = []string{"budget", "buyer", "agency", "s_winner", "bidamount", "projectcode", "contractcode"}
  15. var packreg *regexp.Regexp
  16. var Mgo *mongodb.MongodbSim
  17. var listSource []*dataSource
  18. type dataSource struct {
  19. _id, id, title string
  20. projectname, projectcode, contractcode string
  21. buyer, agency, s_winner string
  22. budget, bidamount float64
  23. budget_isnull,bidamount_isnull bool
  24. isrepeat bool
  25. repeat_id_source string
  26. repeat_id map[string]string
  27. repeatText string
  28. publishtime int64
  29. }
  30. //var addr, dbname, table, startTime, endTime, sortType *string
  31. var addr, dbname, table, sortType *string
  32. func init() {
  33. //addr = flag.String("addr", "192.168.3.167:27080", "数据库名称")
  34. addr = flag.String("addr", "192.168.3.166:27082", "数据库名称")
  35. //addr = flag.String("addr", "127.0.0.1:27167", "数据库名称")
  36. //dbname = flag.String("dbname", "qfw", "数据库名称")
  37. dbname = flag.String("dbname", "zhaolongyue", "数据库名称")
  38. //table = flag.String("table", "0210test", "表名称")
  39. table = flag.String("table", "Htgx0425_data", "表名称")
  40. sortType = flag.String("sort", "1", "sort--请输入排序方式,1正序、-1倒序")
  41. flag.Parse()
  42. Mgo = &mongodb.MongodbSim{
  43. MongodbAddr: *addr,
  44. Size: 3,
  45. DbName: *dbname,
  46. }
  47. Mgo.InitPool()
  48. packreg, _ = regexp.Compile(`([a-zA-Z0-9①②ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ一二三四五六七八九十][包标段])`)
  49. //packreg, _ = regexp.Compile(`([包标段][::]?[a-zA-Z0-9①②ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ一二三四五六七八九十]|[a-zA-Z0-9①②ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ一二三四五六七八九十][包标段]){1,}`)
  50. //packreg, _ = regexp.MustCompile("([a-zA-Z0-9①②ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ一二三四五六七八九十](包|标|段)[::]?)")
  51. }
  52. //创建mgo索引
  53. //func createMgoIndex(){
  54. // mongoDBDialInfo := &mgo.DialInfo{
  55. // Addrs: []string{addr},
  56. // Timeout: 60 * time.Second,
  57. // Database: dbname,
  58. // }
  59. // session, err := mgo.DialWithInfo(mongoDBDialInfo)
  60. // if err != nil {
  61. // log.Fatalf("CreateSession failed:%\n", err)
  62. // }
  63. // coll := session.DB(dbname).C(table)
  64. // err = coll.EnsureIndexKey("publishtime")
  65. // fmt.Println("创建索引~publishtime",err)
  66. //
  67. // //查询所有的已存在索引
  68. // //indexs, err := coll.Indexes()
  69. // //fmt.Println("indexs--------------:", indexs)
  70. //}
  71. func main() {
  72. log.Printf("表名:%s,排序方式:%s", *table, *sortType)
  73. if *addr == "" || *dbname == "" || *table == "" || *sortType == "" {
  74. log.Println("参数输入有误")
  75. fmt.Printf("数据库地址:%s\n数据库名称:%s\n表名:%s\n排序方式:%s\n", *addr, *dbname, *table, *sortType)
  76. os.Exit(0)
  77. }
  78. //stime, _ := time.Parse(qu.Date_Short_Layout, *startTime)
  79. //etime, _ := time.Parse(qu.Date_Short_Layout, *endTime)
  80. //query := map[string]interface{}{}
  81. //query["$and"] = []interface{}{
  82. // map[string]interface{}{
  83. // "publishtime":map[string]interface{}{
  84. // "$gte":stime.Unix(),
  85. // },
  86. // },
  87. // map[string]interface{}{
  88. // "publishtime":map[string]interface{}{
  89. // "$lte":etime.Unix(),
  90. // },
  91. // },
  92. // //bson.M{"publishtime": bson.M{"$gte": stime.Unix()}},
  93. // //bson.M{"publishtime": bson.M{"$lte": etime.Unix()}},
  94. //}
  95. sort := "publishtime"
  96. if *sortType == "-1" {
  97. sort = "-publishtime"
  98. }
  99. //log.Println(sort)
  100. sess := Mgo.GetMgoConn()
  101. defer Mgo.DestoryMongoConn(sess)
  102. //it := sess.DB(Mgo.DbName).C(*table).Find(query).Sort(sort).Iter()
  103. it := sess.DB(Mgo.DbName).C(*table).Find(nil).Sort(sort).Iter()
  104. //对标题、项目名称等中英文符号、空格等进行处理
  105. var filterReg = regexp.MustCompile("[`~!@#$^&*()=|{}':;,\\[\\].<>/?!¥…()—【】‘;:”“。,、?%+_-]")
  106. //var filterReg = regexp.MustCompile("[`~!@#$^&*()=|{}':;,\\[\\].<>/?!¥…()—【】‘;:”“。,、?%+_--]")
  107. index := 0
  108. for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
  109. d := &dataSource{
  110. _id: mongodb.BsonIdToSId(tmp["_id"]),
  111. id: qu.ObjToString(tmp["id"]),
  112. title: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["title"])), ""),
  113. projectname: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["projectname"])), ""),
  114. projectcode: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["projectcode"])), ""),
  115. contractcode: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["contractcode"])), ""),
  116. buyer: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["buyer"])), ""),
  117. agency: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["agency"])), ""),
  118. s_winner: filterReg.ReplaceAllString(strings.ToLower(qu.ObjToString(tmp["s_winner"])), ""),
  119. budget: qu.Float64All(tmp["budget"]),
  120. bidamount: qu.Float64All(tmp["bidamount"]),
  121. publishtime: qu.Int64All(tmp["publishtime"]),
  122. repeat_id: map[string]string{},
  123. }
  124. if tmp["budget"]==nil{
  125. d.budget_isnull=true
  126. }
  127. if tmp["bidamount"]==nil{
  128. d.bidamount_isnull=true
  129. }
  130. //log.Println(tmp["_id"],tmp["title"],tmp["projectname"])
  131. if index%10000 == 0 {
  132. log.Println("加载数据:", index)
  133. }
  134. listSource = append(listSource, d)
  135. tmp = map[string]interface{}{}
  136. }
  137. log.Println("数据加载完成",len(listSource))
  138. dataItem()
  139. dd := 0
  140. for i := 0; i < len(listSource); i++ {
  141. a := listSource[i]
  142. if a.isrepeat {
  143. dd++
  144. }
  145. //更新数据
  146. if len(a.repeat_id) ==0{
  147. Mgo.UpdateById(*table, a._id,
  148. map[string]interface{}{"$set": map[string]interface{}{
  149. //重复数据看repeatid
  150. "repeatid": a.repeat_id_source, //和哪条数据重复id
  151. "repeat": a.isrepeat, //本条数据是否重复数据
  152. "repeattext": a.repeatText, //本数据被判重的原因
  153. }})
  154. }else {
  155. if len(a.repeat_id) > 0{
  156. arr:=[]string{}
  157. for k,_:=range a.repeat_id{
  158. arr = append(arr,k)
  159. }
  160. Mgo.UpdateById(*table, a._id,
  161. map[string]interface{}{"$set": map[string]interface{}{
  162. //原始数据看repeatid_ids_str
  163. "repeatid": a.repeat_id_source, //和哪条数据重复id
  164. "repeat": a.isrepeat, //本条数据是否重复数据
  165. //"repeatid_ids": a.repeat_id, //和我重复的数据都有哪些
  166. "repeatid_ids_str": strings.Join(arr,","),
  167. "repeattext": a.repeatText, //本数据被判重的原因
  168. }})}
  169. }
  170. if i%1000 == 0 {
  171. log.Println("已更新:", i)
  172. }
  173. }
  174. log.Println("重复数据量:",dd)
  175. }
  176. var listSize = 20000
  177. func dataItem() {
  178. for i := 0; i < len(listSource); i++ {
  179. a := listSource[i]
  180. // if a.isrepeat {
  181. // continue
  182. // }
  183. b := &dataSource{}
  184. for j := i + 1; j < len(listSource); j++ {
  185. b = listSource[j]
  186. if *sortType == "1" {
  187. if publishtime_b_a(*a,*b){
  188. // if b.isrepeat {
  189. // continue
  190. // }
  191. a, b = panchong(*a, *b)
  192. listSource[j] = b
  193. listSource[i] = a
  194. // if b.isrepeat {
  195. // log.Println("sss", a.id, b.isrepeat, b.repeat_id)
  196. // }
  197. }
  198. }else{
  199. if publishtime_a_b(*a,*b){
  200. // if b.isrepeat {
  201. // continue
  202. // }
  203. a, b = panchong(*a, *b)
  204. listSource[j] = b
  205. listSource[i] = a
  206. // if b.isrepeat {
  207. // log.Println("sss", a.id, b.isrepeat, b.repeat_id)
  208. // }
  209. }
  210. }
  211. }
  212. if i%500 == 0 {
  213. log.Println("已处理:", i)
  214. }
  215. }
  216. }
  217. func panchong(a, b dataSource) (c, d *dataSource) {
  218. switch {
  219. case a.title == b.title: //标题相等
  220. if pankong(a.contractcode) && pankong(b.contractcode) && a.contractcode != b.contractcode {
  221. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  222. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  223. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  224. b.repeat_id_source = a.id
  225. a.repeat_id[b.id] = ""
  226. b.isrepeat = true
  227. b.repeatText = "标题相等 && bidamount && buyer && s_winner"
  228. }else{
  229. r := key_list(a, b)
  230. if r {
  231. b.repeat_id_source = a.id
  232. a.repeat_id[b.id] = ""
  233. b.isrepeat = true
  234. b.repeatText = "标题相等 && bidamount && buyer && key_list"
  235. }
  236. }
  237. } else if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  238. b.repeat_id_source = a.id
  239. a.repeat_id[b.id] = ""
  240. b.isrepeat = true
  241. b.repeatText = "标题相等 && bidamount && s_winner"
  242. }else {
  243. r := key_list(a, b)
  244. if r {
  245. b.repeat_id_source = a.id
  246. a.repeat_id[b.id] = ""
  247. b.isrepeat = true
  248. b.repeatText = "标题相等 && bidamount && key_list"
  249. }
  250. }
  251. }else if pankong(a.projectcode) && pankong(b.projectcode) && a.projectcode == b.projectcode {
  252. r := key_list(a, b)
  253. if r {
  254. b.repeat_id_source = a.id
  255. a.repeat_id[b.id] = ""
  256. b.isrepeat = true
  257. b.repeatText = "标题相等 && projectcode && key_list"
  258. }
  259. }else if !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  260. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  261. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  262. if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  263. b.repeat_id_source = a.id
  264. a.repeat_id[b.id] = ""
  265. b.isrepeat = true
  266. b.repeatText = "标题相等 && budget && buyer && s_winner && bidamount"
  267. //log.Println("1111", a.id, b.id, b.isrepeat)
  268. }
  269. }
  270. } else {
  271. r := key_list(a, b)
  272. if r {
  273. b.repeat_id_source = a.id
  274. a.repeat_id[b.id] = ""
  275. b.isrepeat = true
  276. b.repeatText = "标题相等 && budget && key_list"
  277. }
  278. }
  279. } else {
  280. //
  281. }
  282. case a.title != b.title: //标题不相等
  283. //项目名称包含及相等
  284. if strings.Contains(a.projectname, b.projectname) || strings.Contains(b.projectname, a.projectname) {
  285. isp := packreg.MatchString(a.title)
  286. //有分包
  287. if isp {
  288. //项目名称相等
  289. if a.projectname == b.projectname {
  290. if pankong(a.contractcode) && pankong(b.contractcode) && a.contractcode != b.contractcode {
  291. //
  292. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  293. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner != b.s_winner{
  294. }else{
  295. b.repeat_id_source = a.id
  296. a.repeat_id[b.id] = ""
  297. b.isrepeat = true
  298. b.repeatText = "标题不相等-->有分包 && projectname && bidamount"
  299. }
  300. //b.repeat_id_source = a.id
  301. //a.repeat_id[b.id] = ""
  302. //b.isrepeat = true
  303. //b.repeatText = "标题不相等-->有分包 && projectname && bidamount"
  304. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount != b.bidamount {
  305. //
  306. } else {
  307. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner && !a.budget_isnull && !b.budget_isnull && a.budget == b.budget && (a.budget >=0 || b.budget >= 0) {
  308. b.repeat_id_source = a.id
  309. a.repeat_id[b.id] = ""
  310. b.isrepeat = true
  311. b.repeatText = "标题不相等-->有分包 && projectname && s_winner && budget"
  312. }
  313. }
  314. } else { //项目名称包含
  315. if pankong(a.contractcode) && pankong(b.contractcode) && a.contractcode != b.contractcode {
  316. //
  317. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  318. if pankong(a.projectcode) && pankong(b.projectcode) && a.projectcode == b.projectcode {
  319. b.repeat_id_source = a.id
  320. a.repeat_id[b.id] = ""
  321. b.isrepeat = true
  322. b.repeatText = "标题不相等-->有分包 && projectname包含 && bidamount && projectcode"
  323. } else if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  324. b.repeat_id_source = a.id
  325. a.repeat_id[b.id] = ""
  326. b.isrepeat = true
  327. b.repeatText = "标题不相等-->有分包 && projectname包含 && bidamount && s_winner"
  328. } else if !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  329. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  330. b.repeat_id_source = a.id
  331. a.repeat_id[b.id] = ""
  332. b.isrepeat = true
  333. b.repeatText = "标题不相等-->有分包 && projectname包含 && bidamount && budget && buyer"
  334. } else if strings.Contains(a.agency, b.agency) || strings.Contains(b.agency, a.agency) && pankong(a.agency) && pankong(b.agency) {
  335. b.repeat_id_source = a.id
  336. a.repeat_id[b.id] = ""
  337. b.isrepeat = true
  338. b.repeatText = "标题不相等-->有分包 && projectname包含 && bidamount && budget && agency"
  339. } else {
  340. //
  341. }
  342. }
  343. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount != b.bidamount {
  344. //
  345. } else {
  346. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner && !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  347. b.repeat_id_source = a.id
  348. a.repeat_id[b.id] = ""
  349. b.isrepeat = true
  350. b.repeatText = "标题不相等-->有分包 && projectname包含 && s_winner && budget"
  351. } else {
  352. //
  353. }
  354. }
  355. }
  356. } else { //无分包
  357. //项目名称相等
  358. if a.projectname == b.projectname {
  359. if pankong(a.contractcode) && pankong(b.contractcode) && a.contractcode != b.contractcode {
  360. //
  361. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  362. b.repeat_id_source = a.id
  363. a.repeat_id[b.id] = ""
  364. b.isrepeat = true
  365. b.repeatText = "标题不相等-->无分包 && projectname && bidamount"
  366. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount != b.bidamount {
  367. //
  368. } else {
  369. if pankong(a.projectcode) && pankong(b.projectcode) && a.projectcode == b.projectcode {
  370. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner != b.s_winner {
  371. }else if !a.budget_isnull && !b.budget_isnull && a.budget != b.budget{
  372. }else{
  373. b.repeat_id_source = a.id
  374. a.repeat_id[b.id] = ""
  375. b.isrepeat = true
  376. b.repeatText = "标题不相等-->无分包 && projectname && projectcode"
  377. }
  378. //if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  379. // b.repeat_id_source = a.id
  380. // a.repeat_id[b.id] = ""
  381. // b.isrepeat = true
  382. // b.repeatText = "标题不相等-->无分包 && projectname && projectcode && s_winner"
  383. //} else if !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  384. // b.repeat_id_source = a.id
  385. // a.repeat_id[b.id] = ""
  386. // b.isrepeat = true
  387. // b.repeatText = "标题不相等-->无分包 && projectname && projectcode && budget"
  388. //}
  389. } else if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  390. b.repeat_id_source = a.id
  391. a.repeat_id[b.id] = ""
  392. b.isrepeat = true
  393. b.repeatText = "标题不相等-->无分包 && projectname && s_winner"
  394. //r := key_list(a, b)
  395. //if r {
  396. // b.repeat_id_source = a.id
  397. // a.repeat_id[b.id] = ""
  398. // b.isrepeat = true
  399. // b.repeatText = "标题不相等-->无分包 && projectname && s_winner && key_list"
  400. //}
  401. } else if !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  402. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  403. b.repeat_id_source = a.id
  404. a.repeat_id[b.id] = ""
  405. b.isrepeat = true
  406. b.repeatText = "标题不相等-->无分包 && projectname && budget && buyer"
  407. } else if strings.Contains(a.agency, b.agency) || strings.Contains(b.agency, a.agency) && pankong(a.agency) && pankong(b.agency) {
  408. b.repeat_id_source = a.id
  409. a.repeat_id[b.id] = ""
  410. b.isrepeat = true
  411. b.repeatText = "标题不相等-->无分包 && projectname && budget && agency"
  412. } else {
  413. //
  414. }
  415. }
  416. }
  417. } else { //项目名称包含
  418. if pankong(a.contractcode) && pankong(b.contractcode) && a.contractcode != b.contractcode {
  419. //
  420. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount == b.bidamount {
  421. if pankong(a.projectcode) && pankong(b.projectcode) && a.projectcode == b.projectcode {
  422. b.repeat_id_source = a.id
  423. a.repeat_id[b.id] = ""
  424. b.isrepeat = true
  425. b.repeatText = "标题不相等-->无分包 && projectname包含 && bidamount && projectcode"
  426. } else if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner {
  427. b.repeat_id_source = a.id
  428. a.repeat_id[b.id] = ""
  429. b.isrepeat = true
  430. b.repeatText = "标题不相等-->无分包 && projectname包含 && bidamount && s_winner"
  431. } else if !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  432. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  433. b.repeat_id_source = a.id
  434. a.repeat_id[b.id] = ""
  435. b.isrepeat = true
  436. b.repeatText = "标题不相等-->无分包 && projectname包含 && budget && buyer"
  437. } else if strings.Contains(a.agency, b.agency) || strings.Contains(b.agency, a.agency) && pankong(a.agency) && pankong(b.agency) {
  438. b.repeat_id_source = a.id
  439. a.repeat_id[b.id] = ""
  440. b.isrepeat = true
  441. b.repeatText = "标题不相等-->无分包 && projectname包含 && budget && agency"
  442. } else {
  443. //
  444. }
  445. } else {
  446. //
  447. }
  448. } else if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount != b.bidamount {
  449. //
  450. } else {
  451. if pankong(a.s_winner) && pankong(b.s_winner) && a.s_winner == b.s_winner && !a.budget_isnull && !b.budget_isnull && a.budget == b.budget {
  452. b.repeat_id_source = a.id
  453. a.repeat_id[b.id] = ""
  454. b.isrepeat = true
  455. b.repeatText = "标题不相等-->无分包 && projectname包含 && s_winner && budget"
  456. }
  457. }
  458. }
  459. }
  460. }
  461. default:
  462. }
  463. return &a, &b
  464. }
  465. //zhb_key_list 判断
  466. //"budget", "buyer", "agency", "s_winner", "bidamount", "projectcode", "contractcode"
  467. func key_list(a, b dataSource) bool {
  468. for i := 0; i < len(zhb_key_list); i++ {
  469. key := zhb_key_list[i]
  470. switch key {
  471. case "budget":
  472. if !a.budget_isnull && !b.budget_isnull && a.budget != b.budget {
  473. return false
  474. } else {
  475. continue
  476. }
  477. case "buyer":
  478. if strings.Contains(a.buyer, b.buyer) || strings.Contains(b.buyer, a.buyer) && pankong(a.buyer) && pankong(b.buyer) {
  479. continue
  480. } else {
  481. return false
  482. }
  483. case "agency":
  484. if strings.Contains(a.agency, b.agency) || strings.Contains(b.agency, a.agency) && pankong(a.agency) && pankong(b.agency) {
  485. continue
  486. } else {
  487. return false
  488. }
  489. case "s_winner":
  490. if a.s_winner != b.s_winner && pankong(a.s_winner) && pankong(b.s_winner) {
  491. return false
  492. } else {
  493. continue
  494. }
  495. case "bidamount":
  496. if !a.bidamount_isnull && !b.bidamount_isnull && a.bidamount != b.bidamount {
  497. return false
  498. } else {
  499. continue
  500. }
  501. case "projectcode":
  502. if a.projectcode != b.projectcode && pankong(a.projectcode) && pankong(b.projectcode) {
  503. return false
  504. } else {
  505. continue
  506. }
  507. case "contractcode":
  508. if a.contractcode != b.contractcode && pankong(a.contractcode) && pankong(b.contractcode) {
  509. return false
  510. } else {
  511. continue
  512. }
  513. }
  514. }
  515. return true
  516. }
  517. //发布时间判断
  518. //正序
  519. func publishtime_b_a(a,b dataSource) bool{
  520. return b.publishtime-a.publishtime < 86400 * 31 * 12
  521. }
  522. //倒序
  523. func publishtime_a_b(a,b dataSource) bool {
  524. return a.publishtime-b.publishtime < 86400 * 31 * 12
  525. }
  526. //
  527. func pankong(a string) bool {
  528. if a != "" {
  529. return true
  530. } else {
  531. return false
  532. }
  533. }