specialdetection.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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": '688990c88230558391ff533c', 'Dwgcbh': '004'}):
  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. if '-F' in cleaned :
  34. pass
  35. else:
  36. print("DE not found")
  37. print(cleaned)
  38. print(post)
  39. else:
  40. mongo_cl = post2['mongo_cl']
  41. mongo_jx = post2['mongo_jx']
  42. mongo_rg = post2['mongo_rg']
  43. for item in dercj:
  44. bm = item[1]
  45. if bm == '人材机编码':
  46. continue
  47. if "商品砼" in item[2]:
  48. continue
  49. hit = False
  50. for rg in mongo_rg:
  51. if rg['CLBH'] == bm:
  52. hit = True
  53. for cl in mongo_cl:
  54. if cl['CLBH'] == bm:
  55. hit = True
  56. for jx in mongo_jx:
  57. if jx['jxbh'] == bm:
  58. hit = True
  59. if (not hit) and item[1] != 'S00001' and item[1] != '410000F' and item[1] != 'JD0001' and (not '二类工' in item[2]) and (not '水泥' in item[2]) and item[1] != '01270100' and cleaned !='5-28' and cleaned != '4-3' and (not '砂浆' in item[2]):
  60. print(cleaned)
  61. print("special case found for" + str(item))
  62. print("来自清单")
  63. print(post['bt'])
  64. print(post)
  65. break