specialdetection.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import pymongo
  2. import pandas
  3. import json
  4. from pymongo import MongoClient
  5. client = MongoClient()
  6. client2 = MongoClient()
  7. db = client["baojia"]
  8. collection = db["qdxm"]
  9. db2 = client2["dinge"]
  10. collection2 = db2["de-collection"]
  11. def clean(debh):
  12. if "附注" in debh:
  13. position = debh.find("附注")
  14. debh = debh[:position]
  15. if "*" in debh:
  16. position = debh.find("*")
  17. debh = debh[:position]
  18. if debh.endswith("换"):
  19. debh = debh[:-1]
  20. if "[" in debh:
  21. position = debh.find("[")
  22. debh = debh[:position-1]
  23. return debh
  24. for post in collection.find({"biao_id": '6879086d5d280edee4b4aa15', 'Dwgcbh': '007'}):
  25. for entry in (post['__children']):
  26. ##print(entry['清单编码'])
  27. cleaned = clean(entry['清单编码'])
  28. if cleaned.startswith("D"):
  29. continue
  30. dercj = (entry['dercj'])
  31. post2 = collection2.find_one({'zhuanye': '安装', 'DEBH' : cleaned })
  32. if post2 == None:
  33. pass##input(cleaned + " not found ")
  34. else:
  35. mongo_cl = post2['mongo_cl']
  36. mongo_jx = post2['mongo_jx']
  37. mongo_rg = post2['mongo_rg']
  38. for item in dercj:
  39. bm = item[1]
  40. if bm == '人材机编码':
  41. continue
  42. if "商品砼" in item[2]:
  43. continue
  44. hit = False
  45. for rg in mongo_rg:
  46. if rg['CLBH'] == bm:
  47. hit = True
  48. for cl in mongo_cl:
  49. if cl['CLBH'] == bm:
  50. hit = True
  51. for jx in mongo_jx:
  52. if jx['jxbh'] == bm:
  53. hit = True
  54. if not hit:
  55. print(cleaned)
  56. print("special case found for" + str(item))
  57. print("来自清单")
  58. print(post['bt'])
  59. print(post)
  60. break