score.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from pymongo import MongoClient
  2. from bson import ObjectId
  3. from docs.config import abnormal_config
  4. import csv
  5. def bid_score():
  6. db = MongoClient('192.168.3.167', 27080, unicode_decode_error_handler="ignore").jyqyfw_historyData2024
  7. coll_user = db["20240624Hbgd_yanzheng"]
  8. # db = MongoClient('192.168.3.206', 27080, unicode_decode_error_handler="ignore").data_quality
  9. # coll_user = db["bidding_20231122"]
  10. score=100
  11. max_id = ObjectId("0" * 24)
  12. for item in coll_user.find({"_id":{"$gte":max_id}}).sort("_id",1).limit(200):
  13. # for item in coll_user.find({"_id":ObjectId("655ec5319aed6eb2ffa5d77f")}):
  14. # for item in coll_user.find().sort("_id",1):
  15. title= item.get('title_qa')
  16. projectname = item.get('projectname_qa')
  17. area= item.get('area_qa')
  18. projectcode= item.get('projectcode_qa')
  19. #bidopentime= item.get('bidopentime_qa')
  20. buyer= item.get('buyer_qa')
  21. winner= item.get('winner_qa')
  22. budget= item.get('budget_qa')
  23. bidamount= item.get('bidamount_qa')
  24. multipackage= item.get("multipackage_qa")
  25. site=item.get("site")
  26. toptype =item.get("toptype")
  27. subtype = item.get("subtype")
  28. flag=0
  29. with open(abnormal_config["table_field_config"]["path7"], "r") as f:
  30. reads = csv.reader(f)
  31. for w in reads:
  32. result=w[0].split("\t")
  33. if result[0]==site and result[1]==toptype and result[2]==subtype:
  34. flag = 1
  35. if title:
  36. score -= 1
  37. if projectname:
  38. score -= 1
  39. if area:
  40. score -= 1
  41. if projectcode:
  42. score -= 1
  43. # if bidopentime:
  44. # score-=1
  45. if buyer:
  46. score -= 1
  47. if winner:
  48. score -= 1
  49. if budget:
  50. score -= 1
  51. if bidamount:
  52. score -= 1
  53. if multipackage:
  54. score -= 1
  55. coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}})
  56. print(score)
  57. score = 100
  58. if flag == 0:
  59. if title:
  60. score-=10
  61. if projectname:
  62. score-=10
  63. if area:
  64. score-=10
  65. if projectcode:
  66. score-=10
  67. # if bidopentime:
  68. # score-=10
  69. if buyer:
  70. score-=10
  71. if winner:
  72. score-=10
  73. if budget:
  74. score-=10
  75. if bidamount:
  76. score-=10
  77. if multipackage:
  78. score -= 10
  79. coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}})
  80. print(score)
  81. score = 100
  82. bid_score()