consolidator
/
neuroDebuger.py
51 строка · 2.1 Кб
1import os
2import requests
3import json
4import pandas as pd
5from MyConfig import MyConfig
6from NeuroConsolidator import NeuroConsolidator
7from OraWorker import OraWorker
8
9cur_path = os.path.dirname(os.path.realpath(__file__))
10conf = MyConfig(f"{cur_path}\\config.json")
11api_url_method= conf.get("NeuroApiUrl",None)
12neuro = NeuroConsolidator(api_url_method)
13ora = OraWorker("manage_dw","ufyjwhb","172.17.80.116/scpora",".\\ora")
14
15def handler(rec:pd.Series)->pd.Series:
16try:
17result = neuro.send_single_request(rec,"Вид материала в SAP ERP","Полное наименование материала",n_predictions=2)
18product= result[0][0]
19probability = result[0][1]
20product2= result[1][0]
21probability2 = result[1][1]
22print(f"{rec['Полное наименование материала']} -> {product} : {probability}%")
23# print(result)
24rec["Продукт УП 1"]=product
25rec["Вероятность 1"]=probability
26rec["Продукт УП 2"]=product2
27rec["Вероятность 2"]=probability2
28check = ora.product_check(product,str(rec["ID в SAP ERP VMZ"]))
29rec["Есть в УП"] = check[1]
30rec["Уже укрупнено в"] = check[0]
31rec["Совпадение"] = check[0]==product
32return rec
33except Exception as exp:
34rec["Продукт УП"]=f"error: {exp}"
35rec["Вероятность"]=100
36return rec
37
38
39if __name__=="__main__":
40try:
41input_file = f"{cur_path}\\output\\input_data.xlsx"
42input_file = "D:\\work\\Укрупнение\\current\\debug_data\\neuro_dump.xlsx"
43print(f"work with file: {input_file}")
44df = pd.read_excel(input_file)
45df = df[["Вид материала в SAP ERP","Полное наименование материала","ID в SAP ERP VMZ"]]
46df = df.apply(handler,axis=1)
47df.to_excel(f"{cur_path}\\output\\neuro_data.xlsx",index=False)
48ora.close()
49
50except Exception as exp:
51print(f"general exception: {exp}")