Commit c7925d8d authored by Georgios Dagkakis's avatar Georgios Dagkakis

cleanup

parent e535e39b
...@@ -20,7 +20,6 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin): ...@@ -20,7 +20,6 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin):
if projectData[row][0] and not (projectData[row][0] in alreadyConsideredProjects): if projectData[row][0] and not (projectData[row][0] in alreadyConsideredProjects):
projectId=projectData[row][0] projectId=projectData[row][0]
alreadyConsideredProjects.append(projectData[row][0]) alreadyConsideredProjects.append(projectData[row][0])
numberOfOperations=1 numberOfOperations=1
i=1 i=1
# if the id changes or is empty it means there is no more data on the project # if the id changes or is empty it means there is no more data on the project
...@@ -30,8 +29,9 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin): ...@@ -30,8 +29,9 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin):
break break
numberOfOperations+=1 numberOfOperations+=1
i+=1 i+=1
# for every operation get the wip and define it # for every project create a dict to keep what is completed
completedCapacityDict={} completedCapacityDict={}
# for every project create a dict to keep what is requested
requiredCapacityDict={} requiredCapacityDict={}
for stationRecord in range(numberOfOperations): for stationRecord in range(numberOfOperations):
stationId=projectData[row+stationRecord][4] stationId=projectData[row+stationRecord][4]
...@@ -39,22 +39,26 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin): ...@@ -39,22 +39,26 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin):
requiredCapacity=float(projectData[row+stationRecord][5]) requiredCapacity=float(projectData[row+stationRecord][5])
completedCapacityDict[stationId]=completedCapacity completedCapacityDict[stationId]=completedCapacity
requiredCapacityDict[stationId]=requiredCapacity requiredCapacityDict[stationId]=requiredCapacity
wipDict=self.calculateWIPDict(data, completedCapacityDict,requiredCapacityDict) # create the wip dictionart
wipDict=self.calculateWIPDict(data, completedCapacityDict,requiredCapacityDict,projectId)
# change the completed data with the wip data in the spreadsheet
for stationRecord in range(numberOfOperations): for stationRecord in range(numberOfOperations):
stationId=projectData[row+stationRecord][4] stationId=projectData[row+stationRecord][4]
projectData[row+stationRecord][wipColumn]=wipDict[stationId] projectData[row+stationRecord][wipColumn]=wipDict[stationId]
return data return data
# gets the dict that shows the completed capacities and returns the one with the actual wip # gets the dict that shows the completed capacities and returns the one with the actual wip
def calculateWIPDict(self,data,completedCapacityDict,requiredCapacityDict): def calculateWIPDict(self,data,completedCapacityDict,requiredCapacityDict,projectId):
wipDict={} wipDict={}
for stationId, completedCapacity in completedCapacityDict.iteritems(): for stationId, completedCapacity in completedCapacityDict.iteritems():
previous=self.getPredecessors(data, stationId) previous=self.getPredecessors(data, stationId)
if previous: if previous:
# if the station is assembly # if the station is assembly
if len(previous)>1: if len(previous)>1:
# if there is capacity completed, then the project was assembled. So set the remaining capacity (if any) as WIP
if completedCapacityDict[stationId]: if completedCapacityDict[stationId]:
wipDict[stationId]=requiredCapacityDict[stationId]-completedCapacityDict[stationId] wipDict[stationId]=requiredCapacityDict[stationId]-completedCapacityDict[stationId]
# else, set wip ONLY if all the pre-decessors have finished this project
else: else:
readyForAssembly=True readyForAssembly=True
for previousId in previous: for previousId in previous:
...@@ -63,6 +67,9 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin): ...@@ -63,6 +67,9 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin):
wipDict[stationId]=0 wipDict[stationId]=0
if readyForAssembly: if readyForAssembly:
wipDict[stationId]=requiredCapacityDict[stationId] wipDict[stationId]=requiredCapacityDict[stationId]
# if the station is not assembly but has predecessor
# check what the predecessor has finished and what workload comes to station.
# if the station has already finished some of the workload reduce it from the wip
else: else:
previousId=previous[0] previousId=previous[0]
completedFromPrevious=completedCapacityDict[previousId] completedFromPrevious=completedCapacityDict[previousId]
...@@ -70,6 +77,7 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin): ...@@ -70,6 +77,7 @@ class ChangeWIPSpreadsheet(plugin.InputPreparationPlugin):
wipDict[stationId]=(transferRate*completedFromPrevious)-completedCapacityDict[stationId] wipDict[stationId]=(transferRate*completedFromPrevious)-completedCapacityDict[stationId]
else: else:
wipDict[stationId]=requiredCapacityDict[stationId]-completedCapacityDict[stationId] wipDict[stationId]=requiredCapacityDict[stationId]-completedCapacityDict[stationId]
assert not (wipDict[stationId]<0), 'invalid WIP definition for '+projectId+' in '+stationId
return wipDict return wipDict
......
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