Sfoglia il codice sorgente

values2 ausgelagert

robert 1 anno fa
parent
commit
dac2619dbd
3 ha cambiato i file con 78 aggiunte e 70 eliminazioni
  1. 9 36
      webservice/plan_export.py
  2. 65 0
      webservice/plan_values2.py
  3. 4 34
      webservice/planner_load.py

+ 9 - 36
webservice/plan_export.py

@@ -1,46 +1,19 @@
+from plan_values2 import VALUES2_HEADER
+
 import pandas as pd
 import numpy as np
 
+
 base_dir = "/home/robert/projekte/planner/export"
 
 id_header = ["Ebene" + str(i) for i in range(1, 11)]
-# values2_header = ['VJ', 'AJ', 'FC', 'Plan_ori', 'Plan_Prozent', 'Stk', 'VAK', 'BE_Prozent', 'Plan_VJ', 'Plan_Stk_VJ', 'Plan',
-#                   'Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez', 'Periode13']
-values2_header = [
-    "Plan",
-    "Jan",
-    "Feb",
-    "Mar",
-    "Apr",
-    "Mai",
-    "Jun",
-    "Jul",
-    "Aug",
-    "Sep",
-    "Okt",
-    "Nov",
-    "Dez",
-    "Periode13",
-    "Plan_ori",
-    "Plan_Prozent",
-    "Stk",
-    "VAK",
-    "BE_Prozent",
-    "frei",
-    "VJ",
-    "VJ_Stk",
-    "AJ",
-    "AJ_Stk",
-    "AJ_Okt",
-    "AJ_Okt_Stk",
-    "FC",
-    "FC_Stk",
-    "Plan_VJ",
-    "Plan_VJ_Stk",
-]
+# values2_header = ['VJ', 'AJ', 'FC', 'Plan_ori', 'Plan_Prozent', 'Stk', 'VAK', 'BE_Prozent', 'Plan_VJ',
+# 'Plan_Stk_VJ', 'Plan', 'Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt',
+# 'Nov', 'Dez', 'Periode13']
+
 season_header = ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
 info_header = ["text", "costcenter", "department"]
-header = info_header + id_header + values2_header
+header = info_header + id_header + VALUES2_HEADER
 season_export_header = info_header + season_header
 
 source_header = ["department", "text", "costcenter", "Ebene1", "Plan", "Periode13"]
@@ -80,7 +53,7 @@ def data_cleansing(filename):
 
     df["id"] = df["id"].str.split(";")
     df = expand(df, id_header, "id")
-    df = expand(df, values2_header, "values2")
+    df = expand(df, VALUES2_HEADER, "values2")
     return df
 
 

+ 65 - 0
webservice/plan_values2.py

@@ -0,0 +1,65 @@
+VALUES2_HEADER = [
+    "Plan",
+    "Jan",
+    "Feb",
+    "Mar",
+    "Apr",
+    "Mai",
+    "Jun",
+    "Jul",
+    "Aug",
+    "Sep",
+    "Okt",
+    "Nov",
+    "Dez",
+    "Periode13",
+    "Plan_ori",
+    "Plan_Prozent",
+    "Stk",
+    "VAK",
+    "BE_Prozent",
+    "frei",
+    "VJ",
+    "VJ_Stk",
+    "AJ",
+    "AJ_Stk",
+    "AJ_Okt",
+    "AJ_Okt_Stk",
+    "FC",
+    "FC_Stk",
+    "Plan_VJ",
+    "Plan_VJ_Stk",
+]
+
+VALUES2_MAPPING = [
+    10,
+    11,
+    12,
+    13,
+    14,
+    15,
+    16,
+    17,
+    18,
+    19,
+    20,
+    21,
+    22,
+    23,
+    3,
+    4,
+    5,
+    6,
+    7,
+    4,
+    0,
+    4,
+    4,
+    4,
+    1,
+    4,
+    2,
+    4,
+    8,
+    9,
+]

+ 4 - 34
webservice/planner_load.py

@@ -1,3 +1,5 @@
+from plan_values2 import VALUES2_MAPPING
+
 import json
 from pathlib import Path
 
@@ -12,38 +14,6 @@ class PlannerLoad:
     structure: list
     config = {
         "department": [1, 2, 3, 10, 30, 40, 50, 55, 81, 82],
-        "translation": [
-            10,
-            11,
-            12,
-            13,
-            14,
-            15,
-            16,
-            17,
-            18,
-            19,
-            20,
-            21,
-            22,
-            23,
-            3,
-            4,
-            5,
-            6,
-            7,
-            4,
-            0,
-            4,
-            4,
-            4,
-            1,
-            4,
-            2,
-            4,
-            8,
-            9,
-        ],
     }
 
     def __init__(self, base_dir: str):
@@ -129,7 +99,7 @@ class PlannerLoad:
             for d in s["values2"].keys():
                 if len(s["values2"][d]) < 30:
                     s["values2"][d] = [
-                        s["values2"][d][i] if 0 <= i < len(s["values2"][d]) else 0 for i in self.config["translation"]
+                        s["values2"][d][i] if 0 <= i < len(s["values2"][d]) else 0 for i in VALUES2_MAPPING
                     ]
 
         self.update_account_values(s)
@@ -214,7 +184,7 @@ class PlannerLoad:
                 if len(s["values2"][d]) == 30:
                     values[d] = s["values2"][d]
                 else:
-                    values[d] = [s["values2"][d].get(i, 0) for i in self.config["translation"]]
+                    values[d] = [s["values2"][d].get(i, 0) for i in VALUES2_MAPPING]
             if d in p_values:
                 for i, v in enumerate(p_values[d], 28):
                     values[d][i] = v