gui Aufruf mit einem Assembly holt sich alle nötigen Infos von den DAtenbanken.
This commit is contained in:
+59
-9
@@ -44,6 +44,7 @@ class CadItem():
|
||||
"halbzeugoberflaeche_neu",
|
||||
"halbzeugfarbe_neu",
|
||||
"lebenszyklus_status_neu",
|
||||
"model3d_neu",
|
||||
"bezeichnung1_sivas", "bezeichnung1_neu",
|
||||
"bezeichnung2_sivas", "bezeichnung2_neu",
|
||||
"halbzeugOhneSaege_sivas", "halbzeugOhneSaege_neu",
|
||||
@@ -102,6 +103,38 @@ class CadItem():
|
||||
"cb_zurücksetzen",
|
||||
]
|
||||
|
||||
# dies sind die Excel Headel der SIVAS csv Export Datei
|
||||
# und wie diese in das Datenmodell der Gui integriert werden kann
|
||||
excel_to_gui = {
|
||||
"Teilenummer":"teilenummer",
|
||||
"Bezeichnung1":"bezeichnung1_sivas",
|
||||
"Bezeichnung2":"bezeichnung2_sivas",
|
||||
"Beschaffungsart":"beschaffungsart_sivas",
|
||||
"Mengeneinheit":"mengeneinheit_sivas",
|
||||
"Halbzeug":"halbzeug_sivas",
|
||||
"TOS_Gruppe":"tosgruppe_sivas",
|
||||
"Dispogruppe":"dispolaufgruppe_sivas",
|
||||
"Dispolaufgruppe":"dispolaufgruppe_sivas",
|
||||
"ErsatzFuer":"ersatzfuer_neu",
|
||||
"ErsetztDurch":"ersetztdurch_neu",
|
||||
"AktuellerIndex":"aenderungsindex_sivas",
|
||||
"Hersteller":"hersteller_sivas",
|
||||
"HerstellerTeilenummer":"herstteilenr_sivas",
|
||||
"Version":"version_sivas",
|
||||
"HalbzeugExtern":"halbzeug_sivas",
|
||||
"Werkstoff":"werkstofftyp_sivas",
|
||||
"Oberfläche":"cb_oberflaeche_neu",
|
||||
# "Truemmer":"truemmer",
|
||||
# "HzOhneSaegeliste":"",
|
||||
"Ruestcode":"ruestcode_sivas",
|
||||
"Fertigungsart":"fertigungsart_sivas",
|
||||
"FosGruppe":"fosGruppe_sivas",
|
||||
"Kalkulationsart":"kalkulationsart_sivas",
|
||||
#"Indexerfasser":"",
|
||||
"Aenderungstext":"aenderungstext_sivas",
|
||||
"Freigabevermerk":"freigabevermerk_sivas",
|
||||
# "Indexbearbeiter":"in"
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
""" is initalized with its unique id"""
|
||||
@@ -190,20 +223,29 @@ class CadItem():
|
||||
def get_all_gui_data(self):
|
||||
return self.gui_data
|
||||
|
||||
def csv2guidata(self, data):
|
||||
translated_data = dict()
|
||||
for k,v in data.items():
|
||||
if k in self.excel_to_gui and v is not None:
|
||||
translated_data[self.excel_to_gui[k]] = v
|
||||
|
||||
# Spezial: Befüllung von Änderungstext mit dem Author, falls in der .csv vorhanden
|
||||
if "Indexerfasser" in data and "Aenderungstext" in data:
|
||||
translated_data["aenderungstext_sivas"] = '{aenderungstext} (von {author})'.format(aenderungstext=data["Aenderungstext"], author=data["Indexerfasser"])
|
||||
# Indexerfasser wird nicht in der gui verwaltet. Deshalb Modifikation aus den Rohdaten
|
||||
self.set_gui_dict(translated_data)
|
||||
return translated_data
|
||||
|
||||
|
||||
def sivas_data_from_csv(self, cid):
|
||||
path = os.path.join(self.controller.get_env("data"), cid + '.csv')
|
||||
if os.path.exists(path):
|
||||
data = self.load_csv(path)
|
||||
return data
|
||||
return None
|
||||
def sivas_data_from_json(self, cid):
|
||||
path = os.path.join(self.controller.get_env("out"), cid + '.json')
|
||||
if os.path.exists(path):
|
||||
data = self.load(path)
|
||||
data = self._load_csv(path)
|
||||
return data
|
||||
return None
|
||||
|
||||
|
||||
def load_csv(self, path):
|
||||
def _load_csv(self, path):
|
||||
"""lädt die SIVAS csv Datei in die Felder für die Oberfläche """
|
||||
if not os.path.exists(path):
|
||||
return None
|
||||
@@ -218,7 +260,13 @@ class CadItem():
|
||||
value = None
|
||||
ret[k] = value
|
||||
return ret
|
||||
|
||||
|
||||
def from_json_file(self, subpath, cid):
|
||||
path = os.path.join(subpath, cid + '.json')
|
||||
if os.path.exists(path):
|
||||
self.load(path)
|
||||
return False
|
||||
|
||||
def from_json(self, json_str):
|
||||
jsonobj = json.loads(json_str)
|
||||
|
||||
@@ -236,6 +284,7 @@ class CadItem():
|
||||
if "red_ids" in jsonobj:
|
||||
red_ids = jsonobj["red_ids"]
|
||||
self.set_red_ids(red_ids)
|
||||
return True
|
||||
|
||||
def to_dict(self, tree=False ):
|
||||
jsonobj = dict()
|
||||
@@ -266,6 +315,7 @@ class CadItem():
|
||||
except Exception:
|
||||
raise Exception("guid_data, data, parent_children_mapping or red_ids not found")
|
||||
|
||||
|
||||
def save(self, path, tree=False):
|
||||
"""saves all data of model to a json string"""
|
||||
with open(path, 'w') as f:
|
||||
|
||||
Reference in New Issue
Block a user