HaLim commited on
Commit
08284a1
·
1 Parent(s): a344829

finalize etl / optimization configuration

Browse files
src/config/optimization_config.py CHANGED
@@ -23,13 +23,14 @@ DATE_SPAN, start_date, end_date = get_date_span()
23
 
24
  # COOIS_Released_Prod_Orders.csv
25
  PRODUCT_LIST = transformed_data.get_released_product_list(start_date, end_date)
26
- print(PRODUCT_LIST)
27
 
28
 
29
  def get_employee_type_list():
30
  try:
31
- streamlit_employee_type_list = dashboard.employee_type_list
32
- return streamlit_employee_type_list
 
33
  except Exception as e:
34
  print(f"using default value for employee type list")
35
  employee_type_list = extract.read_employee_data()
@@ -37,7 +38,7 @@ def get_employee_type_list():
37
  return emp_type_list
38
 
39
  EMPLOYEE_TYPE_LIST = get_employee_type_list()
40
- print(EMPLOYEE_TYPE_LIST)
41
 
42
  def get_shift_list():
43
  try:
@@ -86,7 +87,6 @@ def get_demand_dictionary():
86
  except Exception as e:
87
  print(f"using default value for demand dictionary")
88
  demand_df = extract.read_demand_data()
89
- print(demand_df)
90
  demand_dictionary = demand_df.groupby('Material Number')["Order quantity (GMEIN)"].sum().to_dict()
91
  return demand_dictionary
92
 
@@ -114,38 +114,67 @@ print(COST_LIST_PER_EMP_SHIFT)
114
  # "Humanizer": {1: 10, 2: 10, 3: 10},
115
  # }
116
 
117
- def get_productivity_list_per_emp_product():
 
 
118
  try:
119
- streamlit_productivity_list_per_emp_product = dashboard.productivity_list_per_emp_product
120
- return streamlit_productivity_list_per_emp_product
121
  except Exception as e:
122
- print(f"using default value for productivity list per emp product")
123
- emp_product_df = extract.read_employee_productivity_data()
124
- print(emp_product_df)
125
- productivity_list_per_emp_product = emp_product_df.groupby("employment_type_id")["productivity"].sum().to_dict()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  print(productivity_list_per_emp_product)
127
- return
128
-
129
 
130
- PRODUCTIVITY_LIST_PER_EMP_PRODUCT = get_productivity_list_per_emp_product()
131
  print(PRODUCTIVITY_LIST_PER_EMP_PRODUCT)
132
 
133
- PRODUCTIVITY_LIST_PER_EMP_PRODUCT = { # Kits_Calculation
134
- "Fixed": {
135
- 1: {"a": 1000, "b": 1000, "c": 1000},
136
- 2: {"a": 1000, "b": 1000, "c": 1000},
137
- 3: {"a": 1000, "b": 1000, "c": 1000},
138
- },
139
- "Humanizer": {
140
- 1: {"a": 10, "b": 6, "c": 5},
141
- 2: {"a": 1000, "b": 1000, "c": 1000},
142
- 3: {"a": 1000, "b": 1000, "c": 1000},
143
- },
144
- } # Kits_Calculation.csv
 
145
 
146
 
147
  MAX_EMPLOYEE_PER_TYPE_ON_DAY = { # Not available information
148
- "Fixed": {
149
  t: 8 for t in DATE_SPAN
150
  }, # EDIT: e.g., {'x': {1:5,2:5,...}, 'y':{1:6,...}}
151
  "Humanizer": {t: 6 for t in DATE_SPAN},
@@ -153,12 +182,12 @@ MAX_EMPLOYEE_PER_TYPE_ON_DAY = { # Not available information
153
  # available employee but for fixed in shift 1, it is mandatory employment
154
 
155
  MAX_HOUR_PER_PERSON_PER_DAY = 14 # legal standard
156
- MAX_HOUR_PER_SHIFT_PER_PERSON = {1: 3, 2: 4, 3: 6} # work_shifts_timing.csv
157
  CAP_PER_LINE_PER_HOUR = {
158
  "long": 2200,
159
  "short": 1600,
160
  }
161
  # number of products that can be produced per hour per line
162
-
163
 
164
  DAILY_WEEKLY_SCHEDULE = "daily" # daily or weekly ,this needs to be implementedin in if F_x1_day is not None... F_x1_week is not None... also need to change x1 to Fixedstaff_first_shift
 
23
 
24
  # COOIS_Released_Prod_Orders.csv
25
  PRODUCT_LIST = transformed_data.get_released_product_list(start_date, end_date)
26
+ print("product list",PRODUCT_LIST)
27
 
28
 
29
  def get_employee_type_list():
30
  try:
31
+ pass
32
+ # streamlit_employee_type_list = dashboard.employee_type_list
33
+ # return streamlit_employee_type_list
34
  except Exception as e:
35
  print(f"using default value for employee type list")
36
  employee_type_list = extract.read_employee_data()
 
38
  return emp_type_list
39
 
40
  EMPLOYEE_TYPE_LIST = get_employee_type_list()
41
+ print("employee type list",EMPLOYEE_TYPE_LIST)
42
 
43
  def get_shift_list():
44
  try:
 
87
  except Exception as e:
88
  print(f"using default value for demand dictionary")
89
  demand_df = extract.read_demand_data()
 
90
  demand_dictionary = demand_df.groupby('Material Number')["Order quantity (GMEIN)"].sum().to_dict()
91
  return demand_dictionary
92
 
 
114
  # "Humanizer": {1: 10, 2: 10, 3: 10},
115
  # }
116
 
117
+
118
+
119
+ def get_productivity(PRODUCT_LIST):
120
  try:
121
+ streamlit_productivity = dashboard.productivity
122
+ return streamlit_productivity
123
  except Exception as e:
124
+ productivity_df = extract.read_productivity_data()
125
+
126
+ productivity_df = productivity_df[["Kit","Humanizer hours","UNICEF hours"]]
127
+
128
+ productivity_dict = {
129
+ "UNICEF Fixed term": {},
130
+ "Humanizer": {}
131
+ }
132
+
133
+ # shift별 딕셔너리 초기화
134
+ for shift in [1, 2, 3]:
135
+ productivity_dict["UNICEF Fixed term"][shift] = {}
136
+ productivity_dict["Humanizer"][shift] = {}
137
+
138
+ # 제품별 데이터 처리
139
+ for product in PRODUCT_LIST:
140
+ print(product)
141
+ productivity_df_product = productivity_df[productivity_df['Kit'] == product]
142
+
143
+ if not productivity_df_product.empty:
144
+ # 올바른 컬럼명 사용
145
+ humanizer_productivity = productivity_df_product["Humanizer hours"].iloc[0]
146
+ unicef_productivity = productivity_df_product["UNICEF hours"].iloc[0]
147
+
148
+ for shift in [1, 2, 3]:
149
+ productivity_dict["UNICEF Fixed term"][shift][product] = float(unicef_productivity) if unicef_productivity else 0
150
+ productivity_dict["Humanizer"][shift][product] = float(humanizer_productivity) if humanizer_productivity else 0
151
+
152
+ return productivity_dict
153
+
154
+
155
  print(productivity_list_per_emp_product)
156
+ return productivity_list_per_emp_product
 
157
 
158
+ PRODUCTIVITY_LIST_PER_EMP_PRODUCT = get_productivity(PRODUCT_LIST)
159
  print(PRODUCTIVITY_LIST_PER_EMP_PRODUCT)
160
 
161
+
162
+ # PRODUCTIVITY_LIST_PER_EMP_PRODUCT = { # Kits_Calculation
163
+ # "UNICEF Fixed term": {
164
+ # 1: {"product name": 1000, "b": 1000, "c": 1000},
165
+ # 2: {"a": 1000, "b": 1000, "c": 1000},
166
+ # 3: {"a": 1000, "b": 1000, "c": 1000},
167
+ # },
168
+ # "Humanizer": {
169
+ # 1: {"a": 10, "b": 6, "c": 5},
170
+ # 2: {"a": 1000, "b": 1000, "c": 1000},
171
+ # 3: {"a": 1000, "b": 1000, "c": 1000},
172
+ # },
173
+ # } # Kits_Calculation.csv
174
 
175
 
176
  MAX_EMPLOYEE_PER_TYPE_ON_DAY = { # Not available information
177
+ "UNICEF Fixed term": {
178
  t: 8 for t in DATE_SPAN
179
  }, # EDIT: e.g., {'x': {1:5,2:5,...}, 'y':{1:6,...}}
180
  "Humanizer": {t: 6 for t in DATE_SPAN},
 
182
  # available employee but for fixed in shift 1, it is mandatory employment
183
 
184
  MAX_HOUR_PER_PERSON_PER_DAY = 14 # legal standard
185
+ MAX_HOUR_PER_SHIFT_PER_PERSON = {1: 7, 2: 7, 3: 3} # work_shifts_timing.csv #Need to be fixed
186
  CAP_PER_LINE_PER_HOUR = {
187
  "long": 2200,
188
  "short": 1600,
189
  }
190
  # number of products that can be produced per hour per line
191
+ #This information is critical and it should not rely on the productivity information
192
 
193
  DAILY_WEEKLY_SCHEDULE = "daily" # daily or weekly ,this needs to be implementedin in if F_x1_day is not None... F_x1_week is not None... also need to change x1 to Fixedstaff_first_shift
src/etl/extract.py CHANGED
@@ -35,7 +35,7 @@ def read_shift_cost_data(
35
  return pd.read_csv(path)
36
 
37
 
38
- def read_kit_data(
39
  path="data/real_data_excel/converted_csv/Kits__Calculation.csv",
40
  ) -> pd.DataFrame:
41
  return pd.read_csv(path)
 
35
  return pd.read_csv(path)
36
 
37
 
38
+ def read_productivity_data(
39
  path="data/real_data_excel/converted_csv/Kits__Calculation.csv",
40
  ) -> pd.DataFrame:
41
  return pd.read_csv(path)