dueDate and orderDate transformed to simulation time

parent 6cf8ee24
...@@ -3,12 +3,13 @@ import json ...@@ -3,12 +3,13 @@ import json
import time import time
import random import random
import operator import operator
from datetime import datetime import datetime
import copy import copy
from dream.plugins import plugin from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin
class ReadJSOrders(plugin.InputPreparationPlugin): class ReadJSOrders(plugin.InputPreparationPlugin, TimeSupportMixin):
""" Input preparation """ Input preparation
reads the production orders from the corresponding spreadsheet reads the production orders from the corresponding spreadsheet
""" """
...@@ -16,12 +17,22 @@ class ReadJSOrders(plugin.InputPreparationPlugin): ...@@ -16,12 +17,22 @@ class ReadJSOrders(plugin.InputPreparationPlugin):
def preprocess(self, data): def preprocess(self, data):
""" inserts the retrieved production orders to the BOM echelon """ inserts the retrieved production orders to the BOM echelon
""" """
strptime = datetime.datetime.strptime
# read the current date and define dateFormat from it
try:
now = strptime(data['general']['currentDate'], '%Y/%m/%d %H:%M')
data['general']['dateFormat']='%Y/%m/%d %H:%M'
except ValueError:
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
POdata = data["input"].get("production_orders_spreadsheet",[]) POdata = data["input"].get("production_orders_spreadsheet",[])
productionOrders = [] productionOrders = []
BOM = data["input"].get("BOM",{}) BOM = data["input"].get("BOM",{})
if not BOM: if not BOM:
BOM = data["input"]["BOM"] = {} BOM = data["input"]["BOM"] = {}
data["input"]["BOM"]["orders"] = productionOrders data["input"]["BOM"]["productionOrders"] = productionOrders
if POdata: if POdata:
POdata.pop(0) # pop the column names POdata.pop(0) # pop the column names
for order in POdata: for order in POdata:
...@@ -30,18 +41,22 @@ class ReadJSOrders(plugin.InputPreparationPlugin): ...@@ -30,18 +41,22 @@ class ReadJSOrders(plugin.InputPreparationPlugin):
continue continue
customer = order[1] customer = order[1]
project = order[2] project = order[2]
orderDate = order[3] # orderDate = order[3]
dueDate = order[4] # XXX hardcoded time
orderDate = self.convertToSimulationTime(strptime("%s %s" % (order[3], "00:00"), '%Y/%m/%d %H:%M'))
# dueDate = order[4]
# XXX hardcoded time
dueDate = self.convertToSimulationTime(strptime("%s %s" % (order[4], "00:00"), '%Y/%m/%d %H:%M'))
priority = order[5] priority = order[5]
manager = order[6] manager = order[6]
productionOrders.append({ productionOrders.append({
"orderID": orderID, "_class": "Dream.Order", # hard coded value for the class
"orderName": project, "id": orderID,
"name": project,
"customer": customer, "customer": customer,
"orderDate": orderDate, "orderDate": orderDate,
"dueDate": dueDate, "dueDate": dueDate,
"priority": priority, "priority": priority,
"manager": manager "manager": manager
}) })
return data return data
\ No newline at end of file
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