specialdetection.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import pymongo
  2. import pandas
  3. import json
  4. import asyncio
  5. from subdir import db as dbservice
  6. from sentence_transformers import SentenceTransformer
  7. model = SentenceTransformer("BAAI/bge-small-zh-v1.5")
  8. from pymongo import MongoClient
  9. client = MongoClient()
  10. client2 = MongoClient()
  11. db = client["baojia"]
  12. collection = db["qdxm"]
  13. def clean(debh):
  14. if "附注" in debh:
  15. position = debh.find("附注")
  16. debh = debh[:position]
  17. if "*" in debh:
  18. position = debh.find("*")
  19. debh = debh[:position]
  20. if debh.endswith("换"):
  21. debh = debh[:-1]
  22. if "[" in debh:
  23. position = debh.find("[")
  24. debh = debh[:position-1]
  25. return debh
  26. async def main():
  27. for post in collection.find({"biao_id": '688990c88230558391ff533c', 'Dwgcbh': '001'}):
  28. for entry in (post['__children']):
  29. ##print(entry['清单编码'])
  30. cleaned = clean(entry['清单编码'])
  31. if cleaned.startswith("D"):
  32. continue
  33. dercj = (entry['dercj'])
  34. A1, A2, rg, jx, cl, A6, A7, zhuanye = await dbservice.getSingleDeXilie_(model, client2, 10, cleaned, entry['名称'])
  35. if A1 == None:
  36. if '-F' in cleaned :
  37. pass
  38. else:
  39. print("DE not found")
  40. print(cleaned)
  41. print(post)
  42. else:
  43. mongo_cl = cl
  44. mongo_jx = jx
  45. mongo_rg = rg
  46. for item in dercj:
  47. bm = item[1]
  48. if bm == '人材机编码':
  49. continue
  50. if "商品砼" in item[2]:
  51. continue
  52. hit = False
  53. for rg in mongo_rg:
  54. if rg['CLBH'] == bm:
  55. hit = True
  56. for cl in mongo_cl:
  57. if cl['CLBH'] == bm:
  58. hit = True
  59. for jx in mongo_jx:
  60. if jx['jxbh'] == bm:
  61. hit = True
  62. #and item[1] != '01270100'
  63. #and cleaned !='5-28'
  64. #and cleaned != '4-3'
  65. 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]) \
  66. and (not '砂浆' in item[2]):
  67. print(cleaned)
  68. print("special case found for" + str(item))
  69. print("来自清单")
  70. print(post['bt'])
  71. print(post)
  72. break
  73. asyncio.run(main())