specialdetection.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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["Djcs"]
  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": '68a44e464966105da88382d4'}):##total 006
  28. ##print(post)
  29. if not "__children" in post:
  30. continue
  31. for entry in (post['__children']):
  32. ##print(entry['清单编码'])
  33. cleaned = clean(entry['清单编码'])
  34. if cleaned.startswith("D"):
  35. continue
  36. dercj = (entry['dercj'])
  37. A1, A2, rg, jx, cl, A6, A7, zhuanye = await dbservice.getSingleDeXilie_(model, client2, 10, cleaned, entry['名称'])
  38. if A1 == None:
  39. if '-F' in cleaned :
  40. pass
  41. else:
  42. print("DE not found")
  43. print(cleaned)
  44. print(post)
  45. else:
  46. mongo_cl = cl
  47. mongo_jx = jx
  48. mongo_rg = rg
  49. for item in dercj:
  50. bm = item[1]
  51. if bm == '人材机编码':
  52. continue
  53. if "商品砼" in item[2]:
  54. continue
  55. hit = False
  56. for rg in mongo_rg:
  57. if rg['CLBH'] == bm:
  58. hit = True
  59. for cl in mongo_cl:
  60. if cl['CLBH'] == bm:
  61. hit = True
  62. for jx in mongo_jx:
  63. if jx['jxbh'] == bm:
  64. hit = True
  65. #and item[1] != '01270100'
  66. #and cleaned !='5-28'
  67. #and cleaned != '4-3'
  68. 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]) \
  69. and (not '砂浆' in item[2]) and item[1] != '99090513' and item[1] != '99090509' and item[1] != '4F0000':
  70. print(cleaned)
  71. print("special case found for" + str(item))
  72. print("来自清单")
  73. print(post['bt'])
  74. print(post)
  75. break
  76. asyncio.run(main())