|
@@ -1,4 +1,7 @@
|
|
|
|
|
|
|
|
+import sys
|
|
|
|
+import os
|
|
|
|
+sys.path.append(os.path.dirname(__file__)+"/../..")
|
|
|
|
|
|
from BaseDataMaintenance.maintenance.dataflow import Dataflow_dumplicate,log
|
|
from BaseDataMaintenance.maintenance.dataflow import Dataflow_dumplicate,log
|
|
|
|
|
|
@@ -10,6 +13,7 @@ flow = Dataflow_dumplicate(start_delete_listener=False)
|
|
from BaseDataMaintenance.common.Utils import uniform_package_name
|
|
from BaseDataMaintenance.common.Utils import uniform_package_name
|
|
import json
|
|
import json
|
|
import re
|
|
import re
|
|
|
|
+import traceback
|
|
|
|
|
|
|
|
|
|
def merge_document_interface(item,b_log=False):
|
|
def merge_document_interface(item,b_log=False):
|
|
@@ -21,54 +25,67 @@ def merge_document_interface(item,b_log=False):
|
|
:return:
|
|
:return:
|
|
'''
|
|
'''
|
|
try:
|
|
try:
|
|
-
|
|
|
|
- _proj = {
|
|
|
|
- "page_time":item.get("page_time"),
|
|
|
|
- "project_codes":item.get("project_codes"),
|
|
|
|
- "project_name":item.get("project_name"),
|
|
|
|
- "tenderee":item.get("tenderee"),
|
|
|
|
- "agency":item.get("agency"),
|
|
|
|
- "product":item.get("product"),
|
|
|
|
- "sub_project_name":item.get("sub_project_name"),
|
|
|
|
- "bidding_budget":item.get("bidding_budget"),
|
|
|
|
- "win_tenderer":item.get("win_tenderer"),
|
|
|
|
- "win_bid_price":item.get("win_bid_price"),
|
|
|
|
- "province":item.get("province"),
|
|
|
|
- "city":item.get("city"),
|
|
|
|
- "district":item.get("district"),
|
|
|
|
- "zhao_biao_page_time":item.get("zhao_biao_page_time"),
|
|
|
|
- "zhong_biao_page_time":item.get("zhong_biao_page_time"),
|
|
|
|
- "enterprise":item.get("enterprise"),
|
|
|
|
- "detail_link":item.get("detail_link"),
|
|
|
|
- "doctitle":item.get("doctitle"),
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if _proj.get("province"):
|
|
|
|
- _proj["province"] = re.sub("省","",str(_proj["province"]))
|
|
|
|
- if _proj.get("city"):
|
|
|
|
- if len(str(_proj["city"]))>2:
|
|
|
|
- _proj["city"] = re.sub("市","",str(_proj["city"]))
|
|
|
|
- if _proj.get("district"):
|
|
|
|
- if len(str(_proj["district"]))>2:
|
|
|
|
- _proj["district"] = re.sub("区|县|镇","",str(_proj["district"]))
|
|
|
|
-
|
|
|
|
- _proj["sub_project_name"] = uniform_package_name(_proj["sub_project_name"])
|
|
|
|
-
|
|
|
|
- enterprise = _proj.get("enterprise","")
|
|
|
|
- list_enterprise = enterprise.split(",") if enterprise else []
|
|
|
|
- enterprise = {"nlp_enterprise":list_enterprise}
|
|
|
|
- _proj["enterprise"] = json.dumps(enterprise,ensure_ascii= False)
|
|
|
|
-
|
|
|
|
- list_projects = flow.merge_projects([_proj],b_log=b_log)
|
|
|
|
- if len(list_projects)>0:
|
|
|
|
- uuids = list_projects[0].get("uuid","")
|
|
|
|
- if uuids:
|
|
|
|
- l_uuid = uuids.split(",")
|
|
|
|
- if l_uuid:
|
|
|
|
- return l_uuid[0]
|
|
|
|
|
|
+ if isinstance(item,dict):
|
|
|
|
+ log("merge_document_interface %s"%json.dumps(item,ensure_ascii=False))
|
|
|
|
+ _proj = {
|
|
|
|
+ "page_time":item.get("page_time",""),
|
|
|
|
+ "project_codes":item.get("project_codes",""),
|
|
|
|
+ "project_name":item.get("project_name",""),
|
|
|
|
+ "tenderee":item.get("tenderee",""),
|
|
|
|
+ "agency":item.get("agency",""),
|
|
|
|
+ "product":item.get("product",""),
|
|
|
|
+ "sub_project_name":item.get("sub_project_name",""),
|
|
|
|
+ "bidding_budget":item.get("bidding_budget","0"),
|
|
|
|
+ "win_tenderer":item.get("win_tenderer",""),
|
|
|
|
+ "win_bid_price":item.get("win_bid_price","0"),
|
|
|
|
+ "province":item.get("province",""),
|
|
|
|
+ "city":item.get("city",""),
|
|
|
|
+ "district":item.get("district",""),
|
|
|
|
+ "zhao_biao_page_time":item.get("zhao_biao_page_time",""),
|
|
|
|
+ "zhong_biao_page_time":item.get("zhong_biao_page_time",""),
|
|
|
|
+ "enterprise":item.get("enterprise",""),
|
|
|
|
+ "detail_link":item.get("detail_link",""),
|
|
|
|
+ "doctitle":item.get("doctitle",""),
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if _proj.get("page_time")=="":
|
|
|
|
+ raise RuntimeError("page_time参数不能为空")
|
|
|
|
+
|
|
|
|
+ if _proj.get("province"):
|
|
|
|
+ _proj["province"] = re.sub("省","",str(_proj["province"]))
|
|
|
|
+ if _proj.get("city"):
|
|
|
|
+ if len(str(_proj["city"]))>2:
|
|
|
|
+ _proj["city"] = re.sub("市","",str(_proj["city"]))
|
|
|
|
+ if _proj.get("district"):
|
|
|
|
+ if len(str(_proj["district"]))>2:
|
|
|
|
+ _proj["district"] = re.sub("区|县|镇","",str(_proj["district"]))
|
|
|
|
+
|
|
|
|
+ if _proj.get("bidding_budget"):
|
|
|
|
+ _proj["bidding_budget"] = float(_proj["bidding_budget"])
|
|
|
|
+
|
|
|
|
+ if _proj.get("win_bid_price"):
|
|
|
|
+ _proj["win_bid_price"] = float(_proj["win_bid_price"])
|
|
|
|
+
|
|
|
|
+ _proj["sub_project_name"] = uniform_package_name(_proj["sub_project_name"])
|
|
|
|
+
|
|
|
|
+ enterprise = _proj.get("enterprise","")
|
|
|
|
+ list_enterprise = enterprise.split(",") if enterprise else []
|
|
|
|
+ enterprise = {"nlp_enterprise":list_enterprise}
|
|
|
|
+ _proj["enterprise"] = json.dumps(enterprise,ensure_ascii= False)
|
|
|
|
+
|
|
|
|
+ list_projects = flow.merge_projects([_proj],b_log=b_log)
|
|
|
|
+ if len(list_projects)>0:
|
|
|
|
+ uuids = list_projects[0].get("uuid","")
|
|
|
|
+ if uuids:
|
|
|
|
+ l_uuid = uuids.split(",")
|
|
|
|
+ if l_uuid:
|
|
|
|
+ return l_uuid[0]
|
|
|
|
+ else:
|
|
|
|
+ raise RuntimeError("参数应该以字典方式传递")
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- raise RuntimeError("error on dumplicate")
|
|
|
|
|
|
+ traceback.print_exc()
|
|
|
|
+ raise RuntimeError("error: %s"%(str(e)))
|
|
|
|
|
|
|
|
|
|
import os
|
|
import os
|
|
@@ -89,6 +106,7 @@ def embedding():
|
|
project_uuid = ""
|
|
project_uuid = ""
|
|
_r["project_uuid"] = project_uuid
|
|
_r["project_uuid"] = project_uuid
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
|
+ traceback.print_exc()
|
|
_r["success"] = False
|
|
_r["success"] = False
|
|
_r["msg"] = str(e)
|
|
_r["msg"] = str(e)
|
|
|
|
|
|
@@ -97,10 +115,7 @@ def embedding():
|
|
def start_project_merge_server():
|
|
def start_project_merge_server():
|
|
app.run(host="0.0.0.0",port="15010",debug=False)
|
|
app.run(host="0.0.0.0",port="15010",debug=False)
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
-
|
|
|
|
- # start_project_merge_server()
|
|
|
|
-
|
|
|
|
|
|
+def test():
|
|
_proj = {
|
|
_proj = {
|
|
"page_time":"2025-01-14",
|
|
"page_time":"2025-01-14",
|
|
"project_codes":"SHX-ZB-2024-01013-07",
|
|
"project_codes":"SHX-ZB-2024-01013-07",
|
|
@@ -130,3 +145,10 @@ if __name__ == '__main__':
|
|
# print(merge_document_interface(_proj,b_log=True))
|
|
# print(merge_document_interface(_proj,b_log=True))
|
|
|
|
|
|
|
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+
|
|
|
|
+ # start_project_merge_server()
|
|
|
|
+ test()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|