Commit 727ab731 authored by Jérome Perrin's avatar Jérome Perrin

update job schedule widget to support capacity project

reapply 9cae3eb4
parent d3751537
......@@ -5,6 +5,7 @@
function job_schedule_spreadsheet_widget(all_data) {
var now = new Date(),
name,
input_data = all_data.input,
output_data = all_data.result,
spreadsheet_data = [],
......@@ -49,11 +50,13 @@
for (i = 0; i < output_data.elementList.length; i += 1) {
obj = output_data.elementList[i];
if (obj._class === 'Dream.Job') {
if (obj._class === 'Dream.Job' ||
obj._class === 'Dream.CapacityProject') {
input_job = null;
input_order = null;
// find the input order and order component for this job
// XXX this has no real meaning with capacity project
for (node_id in input_data.nodes) {
if (input_data.nodes.hasOwnProperty(node_id)) {
node = input_data.nodes[node_id];
......@@ -63,7 +66,7 @@
if (order.id === obj.id) {
input_job = input_order = order;
}
if (input_job === null) {
if (input_job === null && order.componentsList) {
for (k = 0; k < order.componentsList.length; k += 1) {
component = order.componentsList[k];
if (component.id === obj.id) {
......@@ -77,6 +80,7 @@
}
}
// XXX does not make sense in the case of capacity project
due_date = new Date(simulation_start_date.getTime() +
input_order.dueDate * 1000 * 3600);
for (j = 0; j < obj.results.schedule.length; j += 1) {
......@@ -85,6 +89,27 @@
// XXX: time unit
schedule.entranceTime * 1000 * 3600);
duration = 0;
if (schedule.exitTime) {
duration = (schedule.exitTime - schedule.entranceTime);
} else {
// When duration is not returned by ManPy, it is calculated by
// difference of entranceTime of this step and entranceTime of the
// next step, or completionTime when this is the last step
if (i + 1 === obj.results.schedule.length) {
duration = obj.results.completionTime - schedule.entranceTime;
} else {
duration = obj.results.schedule[i + 1]
.entranceTime - schedule.entranceTime;
}
}
name = "";
if (obj._class === 'Dream.CapacityProject') {
name = input_order.name + '-' + schedule.stationId;
} else {
name = input_order.name + "-" + input_job.name;
}
// Duration is calculated by difference of entranceTime of this
// step and entranceTime of the next step, or completionTime when
// this is the last step
......@@ -98,7 +123,7 @@
spreadsheet_data.push([
// XXX this label is incorrect for design step, during design
// phase we still have an order and not an order component.
input_order.name + "-" + input_job.name,
name,
obj.id,
input_order.manager,
moment(due_date).format("YYYY/MM/DD"),
......
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