if a WIP component is in DESIGN route steps, the it is renamed to the...

if a WIP component is in DESIGN route steps, the it is renamed to the corresponding orderDesign part
parent 66fec197
from copy import copy from copy import copy
from dream.plugins import plugin from dream.plugins import plugin
from dream.plugins import SplitRoute
import datetime import datetime
# XXX HARDCODED # XXX HARDCODED
MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"]) MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"])
class UpdateWIP(plugin.InputPreparationPlugin): class UpdateWIP(SplitRoute.SplitRoute):
""" Input preparation """ Input preparation
reads the data from external data base and updates the WIP reads the data from external data base and updates the WIP
""" """
...@@ -28,6 +29,7 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -28,6 +29,7 @@ class UpdateWIP(plugin.InputPreparationPlugin):
All the components defined by the corresponding orders should be examined All the components defined by the corresponding orders should be examined
""" """
wipToBeRemoved = [] wipToBeRemoved = []
designsToBeReplaced = [] # list used to hold the designID that are in the WIP and need to change key (id) as the current one correspond to the molds ids
# # check all the orders # # check all the orders
for order in orders: for order in orders:
orderComponents = order.get("componentsList", []) orderComponents = order.get("componentsList", [])
...@@ -47,20 +49,34 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -47,20 +49,34 @@ class UpdateWIP(plugin.InputPreparationPlugin):
assert len(route)>0, "the OrderComponent must have a route defined with length more than 0" assert len(route)>0, "the OrderComponent must have a route defined with length more than 0"
assert task_id, "there must be a task_id defined for the OrderComponent in the WIP" assert task_id, "there must be a task_id defined for the OrderComponent in the WIP"
# # get the step identified by task_id, hold the step_index to see if the entity's route is concluded # # get the step identified by task_id, hold the step_index to see if the entity's route is concluded
last_step = {}
for step_index, step in enumerate(route): for step_index, step in enumerate(route):
if step["task_id"] == task_id: if step["task_id"] == task_id and step.get("technology", None):
last_step = step last_step = step
break break
# # check if the entity has left the station # # check if the entity has left the station
toBeRemoved = False
if remainingProcessingTime: if remainingProcessingTime:
currentStation = workStation currentStation = workStation
current_step = last_step current_step = last_step
# if the current step is part of a design route then the current WIP must be removed and replaced by a similar with the Design name
for tech in self.DESIGN_ROUTE_STEPS_SET:
if work.get("station", None).startswith(tech):
toBeRemoved = True
designsToBeReplaced.append(componentID)
# the entity is in a buffer if the step_index is no larger than the length of the route # the entity is in a buffer if the step_index is no larger than the length of the route
elif len(route)-1>=step_index: elif len(route)-1 > step_index:
'''if the step is OrderDecomposition then the design has concluded its route'''
if any(station.startswith("OD") for station in route[step_index+1]["stationIdsList"]):
toBeRemoved = True
else:
current_step = route[step_index+1] current_step = route[step_index+1]
currentStation = current_step["stationIdsList"][0] currentStation = current_step["stationIdsList"][0]
# the entity has concluded it's route; it should be removed from the WIP # if it has concluded the last step
else: else:
toBeRemoved = True
# the entity has concluded it's route; it should be removed from the WIP
if toBeRemoved:
wipToBeRemoved.append(componentID) wipToBeRemoved.append(componentID)
# # check if this part is a design and update the flag # # check if this part is a design and update the flag
if any(station.startswith("OD") for station in route[-1]["stationIdsList"]): if any(station.startswith("OD") for station in route[-1]["stationIdsList"]):
...@@ -82,31 +98,33 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -82,31 +98,33 @@ class UpdateWIP(plugin.InputPreparationPlugin):
componentID = component["id"] componentID = component["id"]
route = component["route"] route = component["route"]
if not componentID in self.getWIPIds(): if not componentID in self.getWIPIds():
insertWIPitem = False insertWIPitem = [False, None] # first is the flag that shows if the component should be inserted to the WIP, the second one shows which step of it's route should be initiated
# # if the design is complete # # if the design is complete
if designComplete: if designComplete:
# # if the component is not a mould then put in the first step of its route # # if the component is not a mould then put in the second step of its route (the first is OrderDecomposition - it shouldn't be there)
if not any(station.startswith("E") for station in route[-1]["stationIdsList"]): if not any(station.startswith("E") for station in route[-1]["stationIdsList"]):
insertWIPitem = True insertWIPitem = [True, 1]
# # if the design is not complete # # if the design is not complete
else: else:
# # if the component is design then put it at the start of its route # # if the component is design then put it at the start of its route (the start of it's route is QCAD - it should be placed there)
if any(station.startswith("OD") for station in route[-1]["stationIdsList"]): if any(station.startswith("OD") for station in route[-1]["stationIdsList"]):
insertWIPitem = True insertWIPitem = [True, 0]
# # if the completed components include all the components (exclude mould and design) # # if the completed components include all the components (exclude mould and design)
if len(completedComponents) == len(orderComponents)-2: if len(completedComponents) == len(orderComponents)-2:
# # if the component is a mould then put it in the first step of it's route # # if the component is a mould then put it in the first step of it's route (the first step of it's route is Assembly, it should be there)
if any(station.startswith("E") for station in route[-1]["stationIdsList"]): if any(station.startswith("E") for station in route[-1]["stationIdsList"]):
insertWIPitem = True insertWIPitem = True [True, 0]
if insertWIPitem: if insertWIPitem[0]:
if not wip.get(componentID, {}): if not wip.get(componentID, {}):
wip[componentID] = {} wip[componentID] = {}
wip[componentID]["station"] = route[0]["stationIdsList"][0] wip[componentID]["station"] = route[insertWIPitem[1]]["stationIdsList"][0]
wip[componentID]["sequence"] = route[0]["sequence"] wip[componentID]["sequence"] = route[insertWIPitem[1]]["sequence"]
wip[componentID]["task_id"] = route[0]["task_id"] wip[componentID]["task_id"] = route[insertWIPitem[1]]["task_id"]
# remove the idle entities # remove the idle entities
for entityID in wipToBeRemoved: for entityID in wipToBeRemoved:
if entityID in designsToBeReplaced:
wip[entityID+"_D"] = wip[entityID]
assert wip.pop(entityID, None), "while trying to remove WIP that has concluded it's route, nothing is removed" assert wip.pop(entityID, None), "while trying to remove WIP that has concluded it's route, nothing is removed"
......
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