Commit e133362f authored by panos's avatar panos

CapacityStations.outputPreparation set up as method

parent 3da8ae76
...@@ -25,87 +25,81 @@ def getBuffer(data,stationId): ...@@ -25,87 +25,81 @@ def getBuffer(data,stationId):
for (edge_id, edge) in data['graph']['edge'].iteritems(): for (edge_id, edge) in data['graph']['edge'].iteritems():
if edge['destination']==stationId: if edge['destination']==stationId:
return edge['source'] return edge['source']
# configuration=open("PilotCases\CapacityStations\sampleConfiguration.json", "r")
configuration=open("sampleConfiguration.json", "r")
configurationData=configuration.read()
configurationJSON=json.loads(configurationData)
# db=open("PilotCases\CapacityStations\sampleDBExtraction.json", "r")
db=open("sampleDBExtraction.json", "r")
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',[])
for stationId, station in stations.iteritems():
if stationId==operationId:
station['intervalCapacity']=intervalCapacity
orders=dbJSON.get('orders',{})
configurationJSON['input']['BOM']['productionOrders']=[]
capacityRequirementDict={} def OutputPreparation(data,extractedData):
earliestStartDict={} configurationJSON=data
for order in orders: dbJSON=extractedData
for operation in order['sequence']: operations=dbJSON.get('operations',{})
operationId=operation.keys()[0] stations=configurationJSON['graph']['node']
capacityRequirementDict[operationId]=operation[operationId]['requiredCapacity'] currentDate=configurationJSON['general']['currentDate']
earliestStart=operation[operationId].get('earliestStart',None) currentDate=datetime.strptime(currentDate, '%Y/%m/%d')
if earliestStart:
earliestStart=datetime.strptime(earliestStart, '%Y-%m-%d')
earliestStartDict[operationId]=(earliestStart-currentDate).days
assemblySpaceRequirement=order.get('floorSpaceRequired',100)
orderId=order['orderID']
dueDate=order.get('dueDate',100)
dueDate=datetime.strptime(dueDate, '%Y-%m-%d')
dueDate=(dueDate-currentDate).days
orderDate=order.get('orderDate',0)
orderDate=datetime.strptime(orderDate, '%Y-%m-%d')
orderDate=(orderDate-currentDate).days
name=order.get('orderName',orderId)
configurationJSON['input']['BOM']['productionOrders'].append({
"capacityRequirementDict":capacityRequirementDict,
"assemblySpaceRequirement":assemblySpaceRequirement,
"name":name,
"id":orderId,
"earliestStartDict":earliestStartDict,
"_class": "dream.simulation.applications.CapacityStations.CapacityProject.CapacityProject",
"dueDate":dueDate,
"orderDate":orderDate
})
WIP=dbJSON.get('WIP',{}) # set the interval capacity of the stations
if WIP: for operationId, operation in operations.iteritems():
node=configurationJSON['graph']['node'] intervalCapacity=operation.get('intervalCapacity',[])
#create an empty wip list in all CapacityStationBuffers for stationId, station in stations.iteritems():
for (node_id,node_data) in node.iteritems(): if stationId==operationId:
if node_data['_class']=='dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer': station['intervalCapacity']=intervalCapacity
node_data['wip']=[]
for taskid, wip in WIP.iteritems(): orders=dbJSON.get('orders',{})
oper=wip.get('operation',[]) configurationJSON['input']['BOM']['productionOrders']=[]
requiredCapacity=wip.get('Capacity required', 0)
buffered=wip.get('buffered', 0) capacityRequirementDict={}
orderId=wip.get('order_id',[]) earliestStartDict={}
if requiredCapacity or buffered: for order in orders:
capacityBuffer=getBuffer(configurationJSON,oper) for operation in order['sequence']:
configurationJSON['graph']['node'][capacityBuffer]['wip'].append({ operationId=operation.keys()[0]
"_class": "dream.simulation.applications.CapacityStations.CapacityEntity.CapacityEntity", capacityRequirementDict[operationId]=operation[operationId]['requiredCapacity']
"requiredCapacity": max([requiredCapacity,buffered]), earliestStart=operation[operationId].get('earliestStart',None)
"capacityProjectId": orderId, if earliestStart:
"name": orderId+'_'+oper+'_'+str(requiredCapacity) earliestStart=datetime.strptime(earliestStart, '%Y-%m-%d')
}) earliestStartDict[operationId]=(earliestStart-currentDate).days
assemblySpaceRequirement=order.get('floorSpaceRequired',100)
updatedModelJSONString=json.dumps(configurationJSON, indent=5) orderId=order['orderID']
updatedModel=open('UpdatedModel.json', mode='w') dueDate=order.get('dueDate',100)
updatedModel.write(updatedModelJSONString) dueDate=datetime.strptime(dueDate, '%Y-%m-%d')
dueDate=(dueDate-currentDate).days
orderDate=order.get('orderDate',0)
orderDate=datetime.strptime(orderDate, '%Y-%m-%d')
orderDate=(orderDate-currentDate).days
name=order.get('orderName',orderId)
configurationJSON['input']['BOM']['productionOrders'].append({
"capacityRequirementDict":capacityRequirementDict,
"assemblySpaceRequirement":assemblySpaceRequirement,
"name":name,
"id":orderId,
"earliestStartDict":earliestStartDict,
"_class": "dream.simulation.applications.CapacityStations.CapacityProject.CapacityProject",
"dueDate":dueDate,
"orderDate":orderDate
})
WIP=dbJSON.get('WIP',{})
if WIP:
node=configurationJSON['graph']['node']
#create an empty wip list in all CapacityStationBuffers
for (node_id,node_data) in node.iteritems():
if node_data['_class']=='dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer':
node_data['wip']=[]
for taskid, wip in WIP.iteritems():
oper=wip.get('operation',[])
requiredCapacity=wip.get('Capacity required', 0)
buffered=wip.get('buffered', 0)
orderId=wip.get('order_id',[])
if requiredCapacity or buffered:
capacityBuffer=getBuffer(configurationJSON,oper)
configurationJSON['graph']['node'][capacityBuffer]['wip'].append({
"_class": "dream.simulation.applications.CapacityStations.CapacityEntity.CapacityEntity",
"requiredCapacity": max([requiredCapacity,buffered]),
"capacityProjectId": orderId,
"name": orderId+'_'+oper+'_'+str(requiredCapacity)
})
# updatedModelJSONString=json.dumps(configurationJSON, indent=5)
# updatedModel=open('UpdatedModel.json', mode='w')
# 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