_class of entities is updated

parent d28e55d1
...@@ -16,7 +16,7 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -16,7 +16,7 @@ class SplitRoute(plugin.InputPreparationPlugin):
ROUTE_STEPS_SET=set(["ENG", "CAD","CAM","MILL", "MILL-SET","TURN", "DRILL", "QUAL","EDM", "EDM-SET","ASSM", "MAN","INJM", "INJM-MAN", "INJM-SET"]) ROUTE_STEPS_SET=set(["ENG", "CAD","CAM","MILL", "MILL-SET","TURN", "DRILL", "QUAL","EDM", "EDM-SET","ASSM", "MAN","INJM", "INJM-MAN", "INJM-SET"])
DESIGN_ROUTE_STEPS_SET=set(["ENG", "CAD"]) DESIGN_ROUTE_STEPS_SET=set(["ENG", "CAD"])
def preprocess(self, data): def preprocess(self, data):
""" splits the routes of mould parts (design + mould) """ splits the routes of mould parts (design + mould) and update the _class attribute of the entities
""" """
orders = data["input"]["BOM"]["productionOrders"] orders = data["input"]["BOM"]["productionOrders"]
for order in orders: for order in orders:
...@@ -28,6 +28,7 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -28,6 +28,7 @@ class SplitRoute(plugin.InputPreparationPlugin):
# for each step of the components route find out if it is of a design route (ENG - CAD) or of mould route (ASSM-INJM). If the route contains none of these technology-types steps then the component is normal # for each step of the components route find out if it is of a design route (ENG - CAD) or of mould route (ASSM-INJM). If the route contains none of these technology-types steps then the component is normal
routeList = copy.deepcopy(route) routeList = copy.deepcopy(route)
i = 0 i = 0
# figure out which steps are design steps
for step in routeList: for step in routeList:
stepTechnology = step.get('technology',[]) stepTechnology = step.get('technology',[])
assert stepTechnology in self.ROUTE_STEPS_SET, 'the technology provided does not exist' assert stepTechnology in self.ROUTE_STEPS_SET, 'the technology provided does not exist'
...@@ -36,12 +37,19 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -36,12 +37,19 @@ class SplitRoute(plugin.InputPreparationPlugin):
route.pop(i) route.pop(i)
else: else:
i+=1 i+=1
# if the current entity is a mold-design then create the design and update the _class attribute of the mold
if design_step_list: if design_step_list:
design = {"name": component.get("name","")+"_Design", design = {"name": component.get("name","")+"_Design",
"id": component.get("id","")+"_D", "id": component.get("id","")+"_D",
"quantity": component.get("quantity", 1), "quantity": component.get("quantity", 1),
"route": design_step_list} "route": design_step_list,
"_class": "Dream.OrderDesign"}
componentsToAdd.append(design) componentsToAdd.append(design)
"""the current component is a mold"""
component["_class"] = "Dream.Mould" # XXX hard-coded value
# otherwise we have a normal component, update the _class attribute accordingly
else:
component["class"] = "Dream.OrderComponent" # XXX hard-coded value
for design in componentsToAdd: for design in componentsToAdd:
orderComponents.append(design) orderComponents.append(design)
return data return data
......
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