Commit 12dd0bb1 authored by panos's avatar panos

Data Extraction updated to its latest version

parent d2bbb33b
...@@ -136,6 +136,7 @@ def DataExtraction(DBFilePath): ...@@ -136,6 +136,7 @@ def DataExtraction(DBFilePath):
step={} step={}
ind4=d.fetchone() ind4=d.fetchone()
process=ind4.Operation_Name process=ind4.Operation_Name
orderID=ind3.Order_id
task=ind4.WP_id task=ind4.WP_id
#create another dictionary in step dictionary and insert the following attributes #create another dictionary in step dictionary and insert the following attributes
step[process]={} step[process]={}
...@@ -144,6 +145,29 @@ def DataExtraction(DBFilePath): ...@@ -144,6 +145,29 @@ def DataExtraction(DBFilePath):
step[process]['requiredCapacity']=ind4.CapacityRequirement step[process]['requiredCapacity']=ind4.CapacityRequirement
step[process]['earliestStart']=str(ind4.EarliestStart) step[process]['earliestStart']=str(ind4.EarliestStart)
order['sequence'].append(step) order['sequence'].append(step)
if status == 'accepted' or status =='in progress':
if process == 'SMF':
data['WIP']['startBuffered.SMF_id' + orderID]={}
data['WIP']['startBuffered.SMF_id' + orderID]['operation']=process
data['WIP']['startBuffered.SMF_id' + orderID]['buffered']=ind4.CapacityRequirement
data['WIP']['startBuffered.SMF_id' + orderID]['order_id']=ind3.Order_id
elif process == 'CNC':
data['WIP']['startBuffered.CNC_id' + orderID]={}
data['WIP']['startBuffered.CNC_id' + orderID]['operation']=process
data['WIP']['startBuffered.CNC_id' + orderID]['buffered']=ind4.CapacityRequirement
data['WIP']['startBuffered.CNC_id' + orderID]['order_id']=ind3.Order_id
elif process == 'MCH':
data['WIP']['startBuffered.MCH_id' + orderID]={}
data['WIP']['startBuffered.MCH_id' + orderID]['operation']=process
data['WIP']['startBuffered.MCH_id' + orderID]['buffered']=ind4.CapacityRequirement
data['WIP']['startBuffered.MCH_id' + orderID]['order_id']=ind3.Order_id
elif process == 'EEP':
data['WIP']['startBuffered.EEP_id' + orderID]={}
data['WIP']['startBuffered.EEP_id' + orderID]['operation']=process
data['WIP']['startBuffered.EEP_id' + orderID]['buffered']=ind4.CapacityRequirement
data['WIP']['startBuffered.EEP_id' + orderID]['order_id']=ind3.Order_id
else:
continue
#SQL query that extracts data from production_status table, joining the sequence and production_status table in WP_id attribute, in order to retrieve that WIP #SQL query that extracts data from production_status table, joining the sequence and production_status table in WP_id attribute, in order to retrieve that WIP
e= cursor[5].execute(""" e= cursor[5].execute("""
...@@ -202,7 +226,8 @@ def DataExtraction(DBFilePath): ...@@ -202,7 +226,8 @@ def DataExtraction(DBFilePath):
if operation=='SMF' and not ind5.END_DATE: if operation=='SMF' and not ind5.END_DATE:
finishedCap= ind5.CapacityRequirement - ind5.Capacity_left finishedCap= ind5.CapacityRequirement - ind5.Capacity_left
startWELD = float(key) * float(finishedCap) startWELD = float(key) * float(finishedCap)
try: try:
del data['WIP']['startBuffered.SMF_id' + orderID]
data['WIP']['WELD_id' + orderID]['operation']='WELD' data['WIP']['WELD_id' + orderID]['operation']='WELD'
data['WIP']['WELD_id' + orderID]['buffered']=startWELD data['WIP']['WELD_id' + orderID]['buffered']=startWELD
data['WIP']['WELD_id' + orderID]['order_id']=orderID data['WIP']['WELD_id' + orderID]['order_id']=orderID
...@@ -234,6 +259,7 @@ def DataExtraction(DBFilePath): ...@@ -234,6 +259,7 @@ def DataExtraction(DBFilePath):
if operation=='CNC': if operation=='CNC':
try: try:
cncfinishedCap= ind5.CapacityRequirement - ind5.Capacity_left cncfinishedCap= ind5.CapacityRequirement - ind5.Capacity_left
del data['WIP']['startBuffered.CNC_id' + orderID]
data['WIP']['PPASB_id' + orderID ]['operation']='PPASB' data['WIP']['PPASB_id' + orderID ]['operation']='PPASB'
data['WIP']['PPASB_id' + orderID ]['order_id']=orderID data['WIP']['PPASB_id' + orderID ]['order_id']=orderID
if weldfinishedCap or mchfinishedCap: if weldfinishedCap or mchfinishedCap:
...@@ -254,6 +280,7 @@ def DataExtraction(DBFilePath): ...@@ -254,6 +280,7 @@ def DataExtraction(DBFilePath):
if operation=='MCH': if operation=='MCH':
try: try:
mchfinishedCap= ind5.CapacityRequirement - ind5.Capacity_left mchfinishedCap= ind5.CapacityRequirement - ind5.Capacity_left
del data['WIP']['startBuffered.MCH_id' + orderID]
data['WIP']['PPASB_id' + orderID ]['operation']='PPASB' data['WIP']['PPASB_id' + orderID ]['operation']='PPASB'
data['WIP']['PPASB_id' + orderID ]['order_id']=orderID data['WIP']['PPASB_id' + orderID ]['order_id']=orderID
if weldfinishedCap or cncfinishedCap: if weldfinishedCap or cncfinishedCap:
...@@ -269,7 +296,10 @@ def DataExtraction(DBFilePath): ...@@ -269,7 +296,10 @@ def DataExtraction(DBFilePath):
FinishedCap = mchfinishedCap FinishedCap = mchfinishedCap
data['WIP']['PPASB_id' + orderID ]['buffered']=FinishedCap data['WIP']['PPASB_id' + orderID ]['buffered']=FinishedCap
except KeyError: except KeyError:
continue continue
return data if operation=='EEP':
try:
del data['WIP']['startBuffered.EEP_id' + orderID]
except KeyError:
continue
return data
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment