Commit e133362f authored by panos's avatar panos

CapacityStations.outputPreparation set up as method

parent 3da8ae76
...@@ -26,33 +26,27 @@ def getBuffer(data,stationId): ...@@ -26,33 +26,27 @@ def getBuffer(data,stationId):
if edge['destination']==stationId: if edge['destination']==stationId:
return edge['source'] return edge['source']
# configuration=open("PilotCases\CapacityStations\sampleConfiguration.json", "r") def OutputPreparation(data,extractedData):
configuration=open("sampleConfiguration.json", "r") configurationJSON=data
configurationData=configuration.read() dbJSON=extractedData
configurationJSON=json.loads(configurationData) operations=dbJSON.get('operations',{})
stations=configurationJSON['graph']['node']
currentDate=configurationJSON['general']['currentDate']
currentDate=datetime.strptime(currentDate, '%Y/%m/%d')
# db=open("PilotCases\CapacityStations\sampleDBExtraction.json", "r") # set the interval capacity of the stations
db=open("sampleDBExtraction.json", "r") for operationId, operation in operations.iteritems():
dbData=db.read()
dbJSON=json.loads(dbData)
operations=dbJSON.get('operations',{})
stations=configurationJSON['graph']['node']
currentDate=configurationJSON['general']['currentDate']
currentDate=datetime.strptime(currentDate, '%Y/%m/%d')
# set the interval capacity of the stations
for operationId, operation in operations.iteritems():
intervalCapacity=operation.get('intervalCapacity',[]) intervalCapacity=operation.get('intervalCapacity',[])
for stationId, station in stations.iteritems(): for stationId, station in stations.iteritems():
if stationId==operationId: if stationId==operationId:
station['intervalCapacity']=intervalCapacity station['intervalCapacity']=intervalCapacity
orders=dbJSON.get('orders',{}) orders=dbJSON.get('orders',{})
configurationJSON['input']['BOM']['productionOrders']=[] configurationJSON['input']['BOM']['productionOrders']=[]
capacityRequirementDict={} capacityRequirementDict={}
earliestStartDict={} earliestStartDict={}
for order in orders: for order in orders:
for operation in order['sequence']: for operation in order['sequence']:
operationId=operation.keys()[0] operationId=operation.keys()[0]
capacityRequirementDict[operationId]=operation[operationId]['requiredCapacity'] capacityRequirementDict[operationId]=operation[operationId]['requiredCapacity']
...@@ -80,8 +74,8 @@ for order in orders: ...@@ -80,8 +74,8 @@ for order in orders:
"orderDate":orderDate "orderDate":orderDate
}) })
WIP=dbJSON.get('WIP',{}) WIP=dbJSON.get('WIP',{})
if WIP: if WIP:
node=configurationJSON['graph']['node'] node=configurationJSON['graph']['node']
#create an empty wip list in all CapacityStationBuffers #create an empty wip list in all CapacityStationBuffers
for (node_id,node_data) in node.iteritems(): for (node_id,node_data) in node.iteritems():
...@@ -101,11 +95,11 @@ if WIP: ...@@ -101,11 +95,11 @@ if WIP:
"name": orderId+'_'+oper+'_'+str(requiredCapacity) "name": orderId+'_'+oper+'_'+str(requiredCapacity)
}) })
updatedModelJSONString=json.dumps(configurationJSON, indent=5) # updatedModelJSONString=json.dumps(configurationJSON, indent=5)
updatedModel=open('UpdatedModel.json', mode='w') # updatedModel=open('UpdatedModel.json', mode='w')
updatedModel.write(updatedModelJSONString) # updatedModel.write(updatedModelJSONString)
return configurationJSON
......
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