ReadJSWorkPlan plugin corrected

parent 87375166
...@@ -5,7 +5,6 @@ import random ...@@ -5,7 +5,6 @@ import random
import operator import operator
from datetime import datetime from datetime import datetime
import copy import copy
import routeQuery
from dream.plugins import plugin from dream.plugins import plugin
...@@ -31,36 +30,44 @@ class ReadJSWorkPlan(plugin.InputPreparationPlugin): ...@@ -31,36 +30,44 @@ class ReadJSWorkPlan(plugin.InputPreparationPlugin):
""" inserts the retrieved order components and the related information (routing) to the BOM echelon """ inserts the retrieved order components and the related information (routing) to the BOM echelon
""" """
self.data=data self.data=data
WPdata = data["input"]["workplan_spreadsheet"] WPdata = data["input"].get("workplan_spreadsheet",[])
orders = data["input"]["BOM"].get("orders",{}) orders = data["input"]["BOM"].get("orders",{})
if WPdata: if WPdata:
WPdata.pop(0) # pop the column names WPdata.pop(0) # pop the column names
for line in WPdata: for line in WPdata:
orderID = WPdata[1] orderID = line[1]
order = self.findEntityByID(orderID) order = self.findEntityByID(orderID)
# if the order is not defined then skip this part # if the order is not defined then skip this part
if not order: if not order:
continue continue
partID = WPdata[0] partID = line[0]
part = self.findEntityByID(partID) part = self.findEntityByID(partID)
# if there is no such part in the BOM then create it # if there is no such part in the BOM then create it
if not part: if not part:
partName = WPdata[2] partName = line[2]
components = order.get("componentsList",[]) components = order.get("componentsList",[])
components.append({ # the part is brand new
part = {
"componentID": partID, "componentID": partID,
"componentName": partName "componentName": partName
}) }
components.append(part)
order["componentsList"] = components order["componentsList"] = components
# update the route of the component # update the route of the component
route = part.get("route", []) route = part.get("route", [])
task_id = WPdata[-1] task_id = line[-1]
sequence = WPdata[4] sequence = line[4]
processingTime = WPdata[-4] processingTime = line[-4]
operator = WPdata[5] operator = line[5]
partsneeded = WPdata[-2].replace(" ","").split(',') partsneeded = line[-3]
technology = WPdata[3] # if there are requested parts then split them
quantity = WPdata[6] if partsneeded:
partsneeded = partsneeded.replace(" ","").split(',')
else:
partsneeded = [""]
technology = line[3]
quantity = line[6]
# append the current step to the route of the part
route.append({ route.append({
"task_id": task_id, "task_id": task_id,
"sequence": sequence, "sequence": sequence,
......
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