|
|
@@ -3,6 +3,7 @@ from subdir import service, util
|
|
|
from bson.objectid import ObjectId
|
|
|
import uuid
|
|
|
from datetime import datetime
|
|
|
+import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1385,9 +1386,124 @@ async def getJiagongcai(client, id):
|
|
|
|
|
|
|
|
|
|
|
|
+async def getSingleDeXilie(model, client, zhuanye, debh, mc):
|
|
|
+ db = client["dinge"]
|
|
|
+ collection = db["de-collection"]
|
|
|
+ count = 0
|
|
|
+ actual_zhuanye = []
|
|
|
+ mcs = []
|
|
|
+ if "附注" in debh:
|
|
|
+ position = debh.find("附注")
|
|
|
+ debh = debh[:position]
|
|
|
+ if "*" in debh:
|
|
|
+ position = debh.find("*")
|
|
|
+ debh = debh[:position]
|
|
|
+ if debh.endswith("换"):
|
|
|
+ debh = debh[:-1]
|
|
|
+ if "[" in debh:
|
|
|
+ position = debh.find("[")
|
|
|
+ debh = debh[:position-1]
|
|
|
+ async for post in collection.find({'DEBH': debh}):
|
|
|
+ print(post)
|
|
|
+ actual_zhuanye.append(post['zhuanye'])
|
|
|
+ mcs.append(post['GCLMC'])
|
|
|
+ count = count + 1
|
|
|
+ if count == 0:
|
|
|
+ return None, None, None, None, None, None, None, zhuanye
|
|
|
+ elif count == 1:
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
+ else:
|
|
|
+ hit = False
|
|
|
+ for i in range(0, count):
|
|
|
+ if mcs[i] == mc:
|
|
|
+ hit = True
|
|
|
+ actual_zhuanye[0] = actual_zhuanye[i]
|
|
|
+ if hit:
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
+ else:
|
|
|
+ mcs.append(mc)
|
|
|
+ embeddings = model.encode(mcs)
|
|
|
+ similarities = model.similarity( embeddings[-1], embeddings)
|
|
|
+ ##array([1.0000002, 0.7662151, 1.0000002], dtype=float32)
|
|
|
+ print(similarities)
|
|
|
+ sim = similarities[0].numpy()[:-1]
|
|
|
+ print(sim)
|
|
|
+ index = np.argmax(sim).item()
|
|
|
+ print(index)
|
|
|
+ print(actual_zhuanye)
|
|
|
+
|
|
|
+ actual_zhuanye[0] = actual_zhuanye[index]
|
|
|
+ if actual_zhuanye[0] == '土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_tj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 10
|
|
|
+ elif actual_zhuanye[0] == '市政':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_sz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 20
|
|
|
+ elif actual_zhuanye[0] == '安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_az(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 30
|
|
|
+ elif actual_zhuanye[0] == '园林':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_yl(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 40
|
|
|
+ elif actual_zhuanye[0] == '修缮工程土建':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xstj(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 50
|
|
|
+ elif actual_zhuanye[0] == '修缮工程安装':
|
|
|
+ A1, A2, A3, A4, A5, A6, A7 = service.getSingleDeXilie_xsaz(debh)
|
|
|
+ return A1, A2, A3, A4, A5, A6, A7, 60
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
##################################editor_code##########################
|
|
|
def bjhz_template():
|
|
|
result = []
|