Commit e3ede773 authored by panos's avatar panos

Data Extraction script updated -- running version

parent eb3e6b15
...@@ -84,11 +84,12 @@ def DataExtraction(DBFilePath): ...@@ -84,11 +84,12 @@ def DataExtraction(DBFilePath):
component={} component={}
# and get the next row # and get the next row
ind1=c.fetchone() ind1=c.fetchone()
name=ind1.PartName type=ind1.PartName
component['name']=name component['componentType'] = type
code=ind1.PartCode code=ind1.PartCode
WP=ind1.WP_id WP=ind1.WP_id
component['id']=code component['id']=code
component['name']=code
component['route']=[] component['route']=[]
#SQL query that extracts data from sequence table where PartCode is given #SQL query that extracts data from sequence table where PartCode is given
d=cursor[3].execute(""" d=cursor[3].execute("""
...@@ -115,11 +116,14 @@ def DataExtraction(DBFilePath): ...@@ -115,11 +116,14 @@ def DataExtraction(DBFilePath):
step['quantity']=ind2.Quantity step['quantity']=ind2.Quantity
step['completed']=ind2.Completed step['completed']=ind2.Completed
ind3=f.fetchone() ind3=f.fetchone()
partsNeeded = ind3.PartsNeeded.split(';') partsNeeded = ind3.PartsNeeded.replace(" ","").split(';')
for part in partsNeeded:
if part == '':
partsNeeded.remove(part)
step['requiredParts']=partsNeeded step['requiredParts']=partsNeeded
step['processingTime']={} step['processingTime']={}
step['processingTime']['distribution']='Fixed' step['processingTime']['Fixed']={}
step['processingTime']['mean']=ind2.ProcessingTime step['processingTime']['Fixed']['mean']=ind2.ProcessingTime
component['route'].append(step) component['route'].append(step)
#The following checks if the component ids have been inserted to appended #The following checks if the component ids have been inserted to appended
if not component['id'] in appended: if not component['id'] in appended:
...@@ -136,26 +140,18 @@ def DataExtraction(DBFilePath): ...@@ -136,26 +140,18 @@ def DataExtraction(DBFilePath):
for x in range(e.rowcount): for x in range(e.rowcount):
ind3=e.fetchone() ind3=e.fetchone()
for t in appended: for t in appended:
if ind3.TIMEOUT:
remTime= 0
else:
#calculate the time difference between the TIMEIN and the moment the user wants to run the simulation (e.g. datetime.now())
timeDelta= datetime.now() - ind3.TIMEIN
timeDiff= timeDelta.total_seconds() / 3600
#calculate the remaining time the part needs to be processed
remTime= round((ind3.ProcessingTime - timeDiff),2)
data['WIP'][code]={} data['WIP'][code]={}
data['WIP'][code]['station']=ind3.MachineName data['WIP'][code]['station']=ind3.MachineName
data['WIP'][code]['operator']=ind3.PersonnelCode data['WIP'][code]['operator']=ind3.PersonnelCode
data['WIP'][code]['task_id']=ind3.WP_id data['WIP'][code]['task_id']=ind3.WP_id
data['WIP'][code]['sequence']=ind3.step data['WIP'][code]['sequence']=ind3.step
data['WIP'][code]['remainingProcessingTime']=remTime timeIn=datetime.strptime(str(ind3.TIMEIN), '%Y-%m-%d %H:%M:%S')
data['WIP'][code]['timeIn']=str(timeIn)
timeOut=datetime.strptime(str(ind3.TIMEOUT), '%Y-%m-%d %H:%M:%S')
data['WIP'][code]['timeOut']=str(timeOut)
#in case the status is 'finished' continue to the next order #in case the status is 'finished' continue to the next order
elif status == 'finished': elif status == 'finished':
continue continue
data['productionOrders'].append(productionOrders.copy()) data['productionOrders'].append(productionOrders.copy())
# print data return data
return data \ No newline at end of file
DataExtraction("C:\Users\Panos\Documents\DB_Approach\JobShop")
\ 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