MergeSteps plugin updated and corrected

parent 43cd2083
...@@ -17,60 +17,70 @@ class MergeSteps(plugin.InputPreparationPlugin): ...@@ -17,60 +17,70 @@ class MergeSteps(plugin.InputPreparationPlugin):
""" merge the steps that constitute one single technology step """ merge the steps that constitute one single technology step
""" """
orders = data["input"]["BOM"]['orders'] orders = data["input"]["BOM"]['orders']
# for all the orders
for order in orders: for order in orders:
orderComponents = order.get("componentsList", []) orderComponents = order.get("componentsList", [])
for component in orderComponents: # for each component of the order
route = component.get("route", []) for component in orderComponents:
updatedRoute = [] route = component.get("route", [])
technologySequence = [] updatedRoute = []
idxToMerge = None technologySequence = []
for index, step in enumerate(route): idxToMerge = None
technology = step["technology"] for index, step in enumerate(route):
technology = technology.split("-")[0] technology = step["technology"]
# loadType is always manual for this pilot technology = technology.split("-")[0]
step["operationType"] = {"load" : "Manual"} # XXX loadType is always manual for this pilot
step["operator"] = {} step["operationType"] = {"load" : "Manual"}
# processingType + operator for processing # processingType + operator for processing
if step["operator"] == "Automatic" if step["operator"] == "Automatic":
step["operationType"]["processing"] = "Automatic" step["operationType"]["processing"] = "Automatic"
else: step.pop("operator")
step["operationType"]["processing"] = "Manual" else:
tempOperator = copy.deepcopy(step["operator"]) step["operationType"]["processing"] = "Manual"
step["operator"]["processing"] = [tempOperator], tempOperator = copy.deepcopy(step["operator"])
step["operator"]["load"] = [tempOperator]} step["operator"] = {}
# find out if there is there is any previous step to merge with step["operator"]["processing"] = [tempOperator]
if technology == technologySequence[-1]: step["operator"]["load"] = [tempOperator]
if len(route[index-1]["technology"].split("-")): # find out if there is there is any previous step to merge with
if route[index-1]["technology"].split("-")[-1]=="SET": if technologySequence:
idxToMerge = index-1 if technology == technologySequence[-1]:
else: if len(route[index-1]["technology"].split("-")):
idxToMerge = None if route[index-1]["technology"].split("-")[-1]=="SET":
# if we must merge two steps idxToMerge = index-1
if idxToMerge != None: else:
# remove the previous step from the updatedRoute and technologySequence idxToMerge = None
updatedRoute.pop(-1) # if we must merge two steps
technologySequence.pop(-1) if idxToMerge != None:
stepToMerge = route[idxToMerge] # remove the previous step from the updatedRoute and technologySequence
# parts needed updatedRoute.pop(-1)
step["parts_needed"] = route[idxToMerge]["parts_needed"] technologySequence.pop(-1)
# technology stepToMerge = route[idxToMerge]
step["technology"] = technology # parts needed
# setupTime step["parts_needed"] = stepToMerge["parts_needed"]
if route[idxToMerge]["processingTime"]: # technology
step["setupTime"] = route[idxToMerge]["processingTime"] step["technology"] = technology
# setupType + operator for setup # setupTime
if route[idxToMerge]["operator"] == "Automatic" if stepToMerge["processingTime"]:
step["operationType"]["setup"] = "Automatic" step["setupTime"] = stepToMerge["processingTime"]
else: # setupType + operator for setup
step["operationType"]["setup"] = "Manual" if stepToMerge["operator"] == "Automatic"
step["operator"]["setup"] = route[idxToMerge]["operator"] step["operationType"]["setup"] = "Automatic"
step["operator"]["load"] = route[idxToMerge]["operator"] else:
technologySequence.append(techonology) step["operationType"]["setup"] = "Manual"
# append the (updated) step to the temporary route try:
updatedRoute.append(step) tempOperator = copy.deepcopy(step["operator"])
# update the route of the step except:
component["route"] = updatedRoute tempOperator = None
step["operator"] = {}
step["operator"]["setup"] = route[idxToMerge]["operator"]["processing"]
step["operator"]["load"] = route[idxToMerge]["operator"]["load"]
if tempOperator:
step["operator"]["processing"] = tempOperator["processing"]
technologySequence.append(technology)
# append the (updated) step to the temporary route
updatedRoute.append(step)
# update the route of the step
component["route"] = updatedRoute
return data return data
if __name__ == '__main__': if __name__ == '__main__':
......
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