score.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_historyData2023_1
  7. # coll_user = db["20230921Ssk_endo"]
  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. # for item in coll_user.find({"_id":ObjectId("655ec5319aed6eb2ffa5d77f")}):
  12. for item in coll_user.find().sort("_id",1):
  13. title= item.get('title_qa')
  14. projectname = item.get('projectname_qa')
  15. area= item.get('area_qa')
  16. projectcode= item.get('projectcode_qa')
  17. #bidopentime= item.get('bidopentime_qa')
  18. buyer= item.get('buyer_qa')
  19. winner= item.get('winner_qa')
  20. budget= item.get('budget_qa')
  21. bidamount= item.get('bidamount_qa')
  22. multipackage= item.get("multipackage_qa")
  23. site=item.get("site")
  24. toptype =item.get("toptype")
  25. subtype = item.get("subtype")
  26. flag=0
  27. with open(abnormal_config["table_field_config"]["path7"], "r") as f:
  28. reads = csv.reader(f)
  29. for w in reads:
  30. result=w[0].split("\t")
  31. if result[0]==site and result[1]==toptype and result[2]==subtype:
  32. flag = 1
  33. if title:
  34. score -= 1
  35. if projectname:
  36. score -= 1
  37. if area:
  38. score -= 1
  39. if projectcode:
  40. score -= 1
  41. # if bidopentime:
  42. # score-=1
  43. if buyer:
  44. score -= 1
  45. if winner:
  46. score -= 1
  47. if budget:
  48. score -= 1
  49. if bidamount:
  50. score -= 1
  51. if multipackage:
  52. score -= 1
  53. coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}})
  54. print(score)
  55. score = 100
  56. if flag == 0:
  57. if title:
  58. score-=10
  59. if projectname:
  60. score-=10
  61. if area:
  62. score-=10
  63. if projectcode:
  64. score-=10
  65. # if bidopentime:
  66. # score-=10
  67. if buyer:
  68. score-=10
  69. if winner:
  70. score-=10
  71. if budget:
  72. score-=10
  73. if bidamount:
  74. score-=10
  75. if multipackage:
  76. score -= 10
  77. coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}})
  78. print(score)
  79. score = 100
  80. bid_score()