mark 19 KB

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