Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
a374dd32
Commit
a374dd32
authored
Feb 23, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gantt of stations also added in capacity instance
parent
074486df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
51 deletions
+55
-51
dream/plugins/CapacityStationGantt.py
dream/plugins/CapacityStationGantt.py
+55
-51
No files found.
dream/plugins/CapacityStationGantt.py
View file @
a374dd32
...
@@ -7,57 +7,61 @@ from dream.plugins.TimeSupport import TimeSupportMixin
...
@@ -7,57 +7,61 @@ from dream.plugins.TimeSupport import TimeSupportMixin
class
CapacityStationGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
class
CapacityStationGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
def
_generateRandomTaskList
(
self
):
"""Generate some random tasks for the example.
Take care of not using reserved id '0'
"""
for
order_id
in
range
(
3
):
for
order_line_id
in
range
(
random
.
randint
(
1
,
6
)):
start_time
=
random
.
random
()
*
10
duration
=
random
.
random
()
*
10
yield
dict
(
id
=
'%s_%s'
%
(
order_id
,
order_line_id
),
order_id
=
"O%s"
%
order_id
,
start_time
=
start_time
,
duration
=
duration
)
def
postprocess
(
self
,
data
):
def
postprocess
(
self
,
data
):
print
2
"""Post process the data for Gantt gadget
"""Post process the data for Gantt gadget
"""
"""
return
data
# in this instance there is not need to define start time
# self.initializeTimeSupport(data)
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
#
self
.
initializeTimeSupport
(
data
)
# date_format = '%d-%m-%Y %H:%M'
date_format
=
'%d-%m-%Y %H:%M'
#
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
# task_dict = {}
task_dict
=
{}
# for task in self._generateRandomTaskList():
# loop in the results to find CapacityProjects
#
for
element
in
resultElements
:
# # Add the order if not already present
if
element
[
'_class'
]
==
"Dream.CapacityStation"
:
# if task['order_id'] not in task_dict:
# add the project in the task_dict
# task_dict[task['order_id']] = dict(
task_dict
[
element
[
'id'
]]
=
dict
(
# id=task['order_id'],
id
=
element
[
'id'
],
# text='Order %s' % task['order_id'],
text
=
'Station %s'
%
element
[
'id'
],
# type='project',
type
=
'station'
,
# open=True)
open
=
False
)
#
# task_dict[task['id']] = dict(
# loop in the project schedule to create the sub-tasks
# id=task['id'],
detailedWorkPlan
=
element
[
'results'
].
get
(
'detailedWorkPlan'
,{})
# parent=task['order_id'],
# text='Task %s' % task['id'],
projectIds
=
[]
# start_date=self.convertToRealWorldTime(
for
record
in
detailedWorkPlan
:
# task['start_time']).strftime(date_format),
if
record
[
'project'
]
not
in
projectIds
:
# stop_date=self.convertToRealWorldTime(
projectIds
.
append
(
record
[
'project'
])
# task['start_time'] + task['duration']).strftime(date_format),
for
projectId
in
projectIds
:
# open=True,
timesInStation
=
[]
# duration=task['duration'])
for
record
in
detailedWorkPlan
:
#
if
record
[
'project'
]
==
projectId
:
# result = data['result']['result_list'][-1]
timesInStation
.
append
(
float
(
record
[
'time'
]))
# result[self.configuration_dict['output_id']] = dict(
entranceTime
=
int
(
min
(
timesInStation
))
# time_unit=self.getTimeUnitText(),
exitTime
=
int
(
max
(
timesInStation
)
+
1
)
# task_list=sorted(task_dict.values(),
task_dict
[
element
[
'id'
]
+
projectId
]
=
dict
(
# key=lambda task: (task.get('order_id'),
id
=
element
[
'id'
]
+
projectId
,
# task.get('type') == 'project',
parent
=
element
[
'id'
],
# task.get('start_date'))))
text
=
projectId
,
#
start_date
=
self
.
convertToRealWorldTime
(
entranceTime
).
strftime
(
date_format
),
# return data
stop_date
=
self
.
convertToRealWorldTime
(
exitTime
).
strftime
(
date_format
),
open
=
False
,
duration
=
exitTime
-
entranceTime
,
entranceTime
=
entranceTime
)
import
json
outputJSONString
=
json
.
dumps
(
task_dict
,
indent
=
5
)
outputJSONFile
=
open
(
'taskDict.json'
,
mode
=
'w'
)
outputJSONFile
.
write
(
outputJSONString
)
# return the result to the gadget
result
=
data
[
'result'
][
'result_list'
][
-
1
]
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
time_unit
=
self
.
getTimeUnitText
(),
task_list
=
sorted
(
task_dict
.
values
(),
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task
.
get
(
'type'
)
==
'station'
,
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
return
data
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment