ItEr42S16CUInformeListaAvancesPlanificacionItEr41S19: Add report scheduleProgressPerWorker

This commit is contained in:
Diego Pino Garcia 2010-01-05 13:23:53 +01:00 committed by Javier Moran Rua
parent cf2ec63014
commit 7211b5a723
16 changed files with 1519 additions and 22 deletions

View file

@ -20,6 +20,7 @@
package org.navalplanner.business.advance.daos;
import java.util.Collection;
import java.util.List;
import org.hibernate.criterion.Restrictions;
@ -55,4 +56,9 @@ public class AdvanceTypeDAO extends GenericDAOHibernate<AdvanceType, Long>
return getSession().createCriteria(AdvanceType.class).add(
Restrictions.eq("active", Boolean.TRUE)).list();
}
@Override
public Collection<? extends AdvanceType> getAll() {
return list(AdvanceType.class);
}
}

View file

@ -20,6 +20,7 @@
package org.navalplanner.business.advance.daos;
import java.util.Collection;
import java.util.List;
import org.navalplanner.business.advance.entities.AdvanceType;
@ -32,7 +33,11 @@ import org.navalplanner.business.common.daos.IGenericDAO;
public interface IAdvanceTypeDAO extends IGenericDAO<AdvanceType, Long>{
public boolean existsNameAdvanceType(String unitName);
public AdvanceType findByName(String name);
public List<AdvanceType> findActivesAdvanceTypes();
public AdvanceType findByName(String name);
public Collection<? extends AdvanceType> getAll();
}

View file

@ -96,19 +96,6 @@ public class DirectAdvanceAssignment extends AdvanceAssignment {
return advanceMeasurements.first();
}
public BigDecimal getAdvancePercentage() {
if (maxValue.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO;
}
AdvanceMeasurement advanceMeasurement = getLastAdvanceMeasurement();
if (advanceMeasurement == null) {
return BigDecimal.ZERO;
}
return advanceMeasurement.getValue().setScale(2).divide(maxValue,
RoundingMode.DOWN);
}
public AdvanceMeasurement getAdvanceMeasurement(LocalDate date) {
if (advanceMeasurements.isEmpty()) {
return null;
@ -123,12 +110,17 @@ public class DirectAdvanceAssignment extends AdvanceAssignment {
return null;
}
public BigDecimal getAdvancePercentage() {
return getAdvancePercentage(null);
}
public BigDecimal getAdvancePercentage(LocalDate date) {
if (maxValue.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO;
}
AdvanceMeasurement advanceMeasurement = getAdvanceMeasurement(date);
AdvanceMeasurement advanceMeasurement = (date != null) ? getAdvanceMeasurement(date)
: getLastAdvanceMeasurement();
if (advanceMeasurement == null) {
return BigDecimal.ZERO;
}

View file

@ -31,6 +31,7 @@ import org.navalplanner.business.labels.daos.ILabelTypeDAO;
import org.navalplanner.business.materials.daos.IMaterialCategoryDAO;
import org.navalplanner.business.materials.daos.IMaterialDAO;
import org.navalplanner.business.orders.daos.IHoursGroupDAO;
import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.daos.IOrderElementDAO;
import org.navalplanner.business.qualityforms.daos.IQualityFormDAO;
import org.navalplanner.business.resources.daos.ICriterionDAO;
@ -103,6 +104,9 @@ public class Registry {
@Autowired
private IProfileDAO profileDAO;
@Autowired
private IOrderDAO orderDAO;
@Autowired
private IOrderElementDAO orderElementDAO;
@ -214,4 +218,8 @@ public class Registry {
return getInstance().costCategoryDAO;
}
public static IOrderDAO getOrderDAO() {
return getInstance().orderDAO;
}
}

View file

@ -26,11 +26,13 @@ import java.util.List;
import org.navalplanner.business.common.daos.IGenericDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.reports.dtos.OrderCostsPerResourceDTO;
import org.navalplanner.business.planner.entities.Task;
/**
* Contract for {@link OrderDAO}
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
* @author Diego Pino Garcia <dpino@igalia.com>
*/
public interface IOrderDAO extends IGenericDAO<Order, Long> {
@ -43,9 +45,14 @@ public interface IOrderDAO extends IGenericDAO<Order, Long> {
/**
* Builds contents for OrderCostsPerResource report
* @return A {@link List} of {@link OrderCostsPerResourceDTO} objects for
* reporting
* reporting
*/
List<OrderCostsPerResourceDTO> getOrderCostsPerResource(List<Order> orders,
Date startingDate, Date endingDate);
/*
* @param order
* @return
*/
List<Task> getTasksByOrder(Order order);
}

View file

@ -33,9 +33,11 @@ import org.navalplanner.business.costcategories.daos.CostCategoryDAO;
import org.navalplanner.business.costcategories.daos.ITypeOfWorkHoursDAO;
import org.navalplanner.business.costcategories.entities.TypeOfWorkHours;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.orders.entities.TaskSource;
import org.navalplanner.business.planner.daos.ITaskSourceDAO;
import org.navalplanner.business.reports.dtos.OrderCostsPerResourceDTO;
import org.navalplanner.business.planner.entities.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
@ -90,7 +92,6 @@ public class OrderDAO extends GenericDAOHibernate<Order, Long> implements
String orderStrQuery = "FROM Order order ";
Query orderQuery = getSession().createQuery(orderStrQuery);
List<Order> orderList = orderQuery.list();
String strQuery = "SELECT new org.navalplanner.business.reports.dtos.OrderCostsPerResourceDTO(worker, wrl) "
+ "FROM Worker worker, WorkReportLine wrl "
+ "LEFT OUTER JOIN wrl.resource resource "
@ -111,6 +112,7 @@ public class OrderDAO extends GenericDAOHibernate<Order, Long> implements
strQuery += "ORDER BY worker.id, wrl.date";
Query query = getSession().createQuery(strQuery);
if (startingDate != null) {
query.setParameter("startingDate", startingDate);
}
@ -149,11 +151,27 @@ public class OrderDAO extends GenericDAOHibernate<Order, Long> implements
each.setCostPerHour(pricePerHour);
each.setCost(each.getCostPerHour().multiply(
new BigDecimal(each.getNumHours())));
filteredList.add(each);
}
}
return filteredList;
}
@Override
public List<Task> getTasksByOrder(Order order) {
reattach(order);
List<OrderElement> orderElements = order.getAllChildren();
orderElements.add(order);
final String strQuery = "SELECT taskSource.task "
+ "FROM TaskSource taskSource "
+ "WHERE taskSource.orderElement IN (:orderElements) "
+ " AND taskSource.task IN (FROM Task)";
Query query = getSession().createQuery(strQuery);
query.setParameterList("orderElements", orderElements);
return (List<Task>) query.list();
}
}

View file

@ -348,6 +348,8 @@ public abstract class OrderElement extends BaseEntity implements
public abstract DirectAdvanceAssignment getReportGlobalAdvanceAssignment();
public abstract DirectAdvanceAssignment getAdvanceAssignmentByType(AdvanceType type);
public Set<DirectAdvanceAssignment> getDirectAdvanceAssignments() {
return Collections.unmodifiableSet(directAdvanceAssignments);
}
@ -942,4 +944,4 @@ public abstract class OrderElement extends BaseEntity implements
return this;
}
}
}

View file

@ -501,6 +501,16 @@ public class OrderLine extends OrderElement {
return null;
}
@Override
public DirectAdvanceAssignment getAdvanceAssignmentByType(AdvanceType type) {
for (DirectAdvanceAssignment directAdvanceAssignment : getDirectAdvanceAssignments()) {
if (directAdvanceAssignment.getAdvanceType().equals(type)) {
return directAdvanceAssignment;
}
}
return null;
}
public void incrementLastHoursGroupSequenceCode() {
if(lastHoursGroupSequenceCode==null){
lastHoursGroupSequenceCode = 0;
@ -524,7 +534,6 @@ public class OrderLine extends OrderElement {
}
codes.add(code);
}
return true;
}
@ -533,4 +542,4 @@ public class OrderLine extends OrderElement {
return OrderLineTemplate.create(this);
}
}
}

View file

@ -266,6 +266,14 @@ public class OrderLineGroup extends OrderElement implements
return hoursGroups;
}
public BigDecimal getAdvancePercentage(AdvanceType advanceType, LocalDate date) {
final DirectAdvanceAssignment directAdvanceAssignment = this.getAdvanceAssignmentByType(advanceType);
if (directAdvanceAssignment != null) {
return directAdvanceAssignment.getAdvancePercentage(date);
}
return null;
}
@Override
public BigDecimal getAdvancePercentage(LocalDate date) {
for (DirectAdvanceAssignment directAdvanceAssignment : directAdvanceAssignments) {
@ -762,6 +770,21 @@ public class OrderLineGroup extends OrderElement implements
return null;
}
public DirectAdvanceAssignment getAdvanceAssignmentByType(AdvanceType type) {
for (DirectAdvanceAssignment each : getDirectAdvanceAssignments()) {
if (type != null && each.getAdvanceType().getId().equals(type.getId())) {
return each;
}
}
for (IndirectAdvanceAssignment each : getIndirectAdvanceAssignments()) {
if (type != null && each.getAdvanceType().getId().equals(type.getId())) {
return calculateFakeDirectAdvanceAssignment(each);
}
}
return null;
}
@Override
public OrderElementTemplate createTemplate() {
return OrderLineGroupTemplate.create(this);

View file

@ -0,0 +1,285 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.business.reports.dtos;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import org.joda.time.LocalDate;
import org.navalplanner.business.advance.entities.AdvanceType;
import org.navalplanner.business.advance.entities.DirectAdvanceAssignment;
import org.navalplanner.business.common.Registry;
import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class SchedulingProgressPerOrderDTO {
private IOrderDAO orderDAO;
private IWorkReportLineDAO workReportLineDAO;
private String orderName;
private Integer estimatedHours;
private Integer totalPlannedHours;
private Integer partialPlannedHours;
private Integer realHours;
private BigDecimal averageProgress;
private Double imputedProgress;
private Double plannedProgress;
private BigDecimal costDifference;
private BigDecimal planningDifference;
private BigDecimal ratioCostDifference;
private BigDecimal ratioPlanningDifference;
private Boolean advanceTypeDoesNotApply = Boolean.FALSE;
private SchedulingProgressPerOrderDTO() {
workReportLineDAO = Registry.getWorkReportLineDAO();
orderDAO = Registry.getOrderDAO();
}
public SchedulingProgressPerOrderDTO(Order order, AdvanceType advanceType, LocalDate date) {
this();
this.orderName = order.getName();
// Get average progress
if (advanceType != null) {
averageProgress = order.getAdvancePercentage(advanceType, date);
} else {
final DirectAdvanceAssignment directAdvanceAssignment = order.getReportGlobalAdvanceAssignment();
averageProgress = (directAdvanceAssignment != null) ? directAdvanceAssignment.getAdvancePercentage(date) : null;
}
if (averageProgress == null) {
advanceTypeDoesNotApply = true;
averageProgress = new BigDecimal(0);
}
// Fill DTO
// Total hours calculations
final List<Task> tasks = orderDAO.getTasksByOrder(order);
getTasks(order);
this.estimatedHours = getHoursSpecifiedAtOrder(tasks);
this.totalPlannedHours = calculatePlannedHours(tasks, null);
// Hours on time calculations
this.partialPlannedHours = calculatePlannedHours(tasks, date);
this.realHours = calculateRealHours(tasks, date);
// Progress calculations
this.imputedProgress = (totalPlannedHours != 0) ? new Double(realHours
/ totalPlannedHours.doubleValue()) : new Double(0);
this.plannedProgress = (totalPlannedHours != 0) ? new Double(
partialPlannedHours / totalPlannedHours.doubleValue())
: new Double(0);
// Differences calculations
this.costDifference = calculateCostDifference(averageProgress,
new BigDecimal(totalPlannedHours), new BigDecimal(realHours));
this.planningDifference = calculatePlanningDifference(averageProgress,
new BigDecimal(totalPlannedHours), new BigDecimal(
partialPlannedHours));
this.ratioCostDifference = calculateRatioCostDifference(
averageProgress, imputedProgress);
this.ratioPlanningDifference = calculateRatioPlanningDifference(
averageProgress, plannedProgress);
}
private List<Task> getTasks(Order order) {
List<Task> result = new ArrayList<Task>();
final List<TaskElement> taskElements = order
.getAllChildrenAssociatedTaskElements();
for (TaskElement each : taskElements) {
if (each instanceof Task) {
result.add((Task) each);
}
}
return result;
}
private Integer getHoursSpecifiedAtOrder(List<Task> tasks) {
Integer result = new Integer(0);
for (Task each: tasks) {
result += each.getHoursSpecifiedAtOrder();
}
return result;
}
public Integer calculatePlannedHours(List<Task> tasks, LocalDate date) {
Integer result = new Integer(0);
for (Task each: tasks) {
result += calculatePlannedHours(each, date);
}
return result;
}
public Integer calculatePlannedHours(Task task, LocalDate date) {
Integer result = new Integer(0);
final List<DayAssignment> dayAssignments = task.getDayAssignments();
if (dayAssignments.isEmpty()) {
return result;
}
for (DayAssignment dayAssignment : dayAssignments) {
if (date == null || dayAssignment.getDay().compareTo(date) <= 0) {
result += dayAssignment.getHours();
}
}
return result;
}
public Integer calculateRealHours(List<Task> tasks, LocalDate date) {
Integer result = new Integer(0);
for (Task each: tasks) {
result += calculateRealHours(each, date);
}
return result;
}
public Integer calculateRealHours(Task task, LocalDate date) {
Integer result = new Integer(0);
final List<WorkReportLine> workReportLines = workReportLineDAO
.findByOrderElementAndChildren(task.getOrderElement());
if (workReportLines.isEmpty()) {
return result;
}
for (WorkReportLine workReportLine : workReportLines) {
final LocalDate workReportLineDate = new LocalDate(workReportLine.getDate());
if (date == null || workReportLineDate.compareTo(date) <= 0) {
result += workReportLine.getNumHours();
}
}
return result;
}
public Integer getEstimatedHours() {
return estimatedHours;
}
public Integer getTotalPlannedHours() {
return totalPlannedHours;
}
public Integer getPartialPlannedHours() {
return partialPlannedHours;
}
public Integer getRealHours() {
return realHours;
}
public BigDecimal getAverageProgress() {
return averageProgress;
}
public Double getImputedProgress() {
return imputedProgress;
}
public Double getPlannedProgress() {
return plannedProgress;
}
public String getOrderName() {
return orderName;
}
public BigDecimal calculateCostDifference(BigDecimal averageProgress,
BigDecimal totalPlannedHours, BigDecimal realHours) {
BigDecimal result = averageProgress;
result = result.multiply(totalPlannedHours);
return result.subtract(realHours);
}
public BigDecimal calculatePlanningDifference(BigDecimal averageProgress,
BigDecimal totalPlannedHours, BigDecimal partialPlannedHours) {
BigDecimal result = averageProgress;
result = result.multiply(totalPlannedHours);
return result.subtract(partialPlannedHours);
}
public BigDecimal calculateRatioCostDifference(BigDecimal averageProgress, Double imputedProgress) {
if (imputedProgress.doubleValue() == 0) {
return new BigDecimal(0);
}
return averageProgress.divide(new BigDecimal(imputedProgress), 2, RoundingMode.HALF_UP);
}
public BigDecimal calculateRatioPlanningDifference(BigDecimal averageProgress, Double plannedProgress) {
if (plannedProgress.doubleValue() == 0) {
return new BigDecimal(0);
}
return averageProgress.divide(new BigDecimal(plannedProgress), 2, RoundingMode.HALF_UP);
}
public BigDecimal getCostDifference() {
return costDifference;
}
public BigDecimal getPlanningDifference() {
return planningDifference;
}
public BigDecimal getRatioCostDifference() {
return ratioCostDifference;
}
public BigDecimal getRatioPlanningDifference() {
return ratioPlanningDifference;
}
public Boolean getAdvanceTypeDoesNotApply() {
return advanceTypeDoesNotApply;
}
}

View file

@ -0,0 +1,535 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Title" isDefault="false" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
<style name="SubTitle" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="18"/>
<style name="Column header" isDefault="false" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" isDefault="false" fontName="Arial" fontSize="12"/>
<parameter name="referenceDate" class="java.util.Date"/>
<parameter name="orderName" class="java.lang.String"/>
<parameter name="startingDate" class="java.util.Date"/>
<parameter name="endingDate" class="java.util.Date"/>
<parameter name="advanceType" class="java.lang.String"/>
<parameter name="showFootnote" class="java.lang.Boolean"/>
<field name="orderName" class="java.lang.String"/>
<field name="estimatedHours" class="java.lang.Integer"/>
<field name="totalPlannedHours" class="java.lang.Integer"/>
<field name="partialPlannedHours" class="java.lang.Integer"/>
<field name="realHours" class="java.lang.Integer"/>
<field name="averageProgress" class="java.math.BigDecimal"/>
<field name="imputedProgress" class="java.lang.Double"/>
<field name="plannedProgress" class="java.lang.Double"/>
<field name="costDifference" class="java.math.BigDecimal"/>
<field name="planningDifference" class="java.math.BigDecimal"/>
<field name="ratioCostDifference" class="java.math.BigDecimal"/>
<field name="ratioPlanningDifference" class="java.math.BigDecimal"/>
<field name="advanceTypeDoesNotApply" class="java.lang.Boolean"/>
<variable name="advanceTypeDoesNotApply" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE)) ?
new java.lang.Integer(1) :
new java.lang.Integer(0)]]></variableExpression>
<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
</variable>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="176" splitType="Stretch">
<image scaleImage="RealHeight">
<reportElement x="316" y="3" width="239" height="65"/>
<imageExpression class="java.lang.String"><![CDATA["logos/navalpro_logo.gif"]]></imageExpression>
</image>
<staticText>
<reportElement style="Title" x="0" y="13" width="263" height="33"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Progress report]]></text>
</staticText>
<staticText>
<reportElement style="SubTitle" x="34" y="46" width="252" height="22">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{referenceDate} != null)]]></printWhenExpression>
</reportElement>
<textElement/>
<text><![CDATA[Scheduling progress per order]]></text>
</staticText>
<staticText>
<reportElement x="1" y="116" width="85" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Reference date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="86" y="116" width="100" height="20"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$P{referenceDate}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="136" width="85" height="20">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{startingDate} != null)]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Starting date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="86" y="136" width="100" height="20">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{startingDate} != null)]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$P{startingDate}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="186" y="136" width="85" height="20">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{endingDate} != null)]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Ending date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="271" y="136" width="100" height="20">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{endingDate} != null)]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$P{endingDate}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="76" width="85" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Advance type:]]></text>
</staticText>
<textField>
<reportElement x="86" y="76" width="281" height="20"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.String"><![CDATA[$P{advanceType}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="96" width="85" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Orders:]]></text>
</staticText>
<textField>
<reportElement x="86" y="96" width="469" height="20"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.String"><![CDATA[$P{orderName}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="115" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="165" y="21" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{estimatedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="21" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{partialPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="165" y="36" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{totalPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="36" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{realHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="0" y="1" width="123" height="16"/>
<textElement textAlignment="Left" verticalAlignment="Bottom">
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{orderName}]]></textFieldExpression>
</textField>
<textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement x="165" y="91" width="106" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{plannedProgress}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="81" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ratioCostDifference}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="96" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ratioPlanningDifference}]]></textFieldExpression>
</textField>
<textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement x="165" y="71" width="106" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{imputedProgress}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="66" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{planningDifference}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="446" y="51" width="106" height="15"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{costDifference}]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Column header" mode="Opaque" x="0" y="21" width="85" height="30" backcolor="#E0E4FB"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Total hours]]></text>
</staticText>
<staticText>
<reportElement style="Column header" mode="Opaque" x="85" y="21" width="80" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Estimated]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="85" y="36" width="80" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Planned]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="85" y="51" width="80" height="20"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Measured]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="85" y="71" width="80" height="20"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Imputed]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="85" y="91" width="80" height="20"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Planned]]></text>
</staticText>
<staticText>
<reportElement style="Column header" mode="Opaque" x="276" y="21" width="85" height="30" backcolor="#E0E4FB"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Hours up to date]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="21" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Planned]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="36" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Real]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="51" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Cost]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="66" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Planned]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="81" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Cost ratio]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="361" y="96" width="85" height="15"/>
<box>
<pen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<text><![CDATA[Planned ratio]]></text>
</staticText>
<line>
<reportElement x="0" y="17" width="552" height="1">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{orderName} != null)]]></printWhenExpression>
</reportElement>
</line>
<staticText>
<reportElement style="Column header" mode="Opaque" x="0" y="51" width="85" height="60" backcolor="#E0E4FB"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Progress]]></text>
</staticText>
<staticText>
<reportElement style="Column header" mode="Opaque" x="276" y="51" width="85" height="60" backcolor="#E0E4FB"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Difference]]></text>
</staticText>
<textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement x="165" y="51" width="106" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{averageProgress}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="271" y="51" width="5" height="20">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE))]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[*]]></text>
</staticText>
<staticText>
<reportElement x="552" y="51" width="5" height="15">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE))]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[*]]></text>
</staticText>
<staticText>
<reportElement x="553" y="66" width="5" height="15">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE))]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[*]]></text>
</staticText>
<staticText>
<reportElement x="553" y="81" width="5" height="15">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE))]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[*]]></text>
</staticText>
<staticText>
<reportElement x="553" y="96" width="5" height="15">
<printWhenExpression><![CDATA[new java.lang.Boolean($F{advanceTypeDoesNotApply}.equals(java.lang.Boolean.TRUE))]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[*]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="23" splitType="Stretch">
<textField>
<reportElement style="Column header" x="433" y="0" width="80" height="20"/>
<textElement textAlignment="Right">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement style="Column header" x="513" y="0" width="40" height="20"/>
<textElement>
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="0" y="0" width="197" height="20"/>
<textElement>
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<lastPageFooter>
<band height="18">
<staticText>
<reportElement x="0" y="0" width="555" height="16">
<printWhenExpression><![CDATA[new java.lang.Boolean(
!$V{advanceTypeDoesNotApply}.equals(new java.lang.Integer(0))) ]]></printWhenExpression>
</reportElement>
<textElement/>
<text><![CDATA[* Selected advance type is not available for this order]]></text>
</staticText>
</band>
</lastPageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>

View file

@ -233,7 +233,8 @@ public class CustomMenuController extends Div implements IMenuItemsRegister {
subItem(_("Hours worked per worker"),"/reports/hoursWorkedPerWorkerReport.zul","15-informes.html"),
subItem(_("Completed estimated hours"),"/reports/completedEstimatedHoursPerTask.zul", "15-informes.html"),
subItem(_("Working progress per task"),"/reports/workingProgressPerTaskReport.zul", "15-informes.html"),
subItem(_("Order costs per resource"),"/reports/orderCostsPerResource.zul", "15-informes.html"));
subItem(_("Order costs per resource"),"/reports/orderCostsPerResource.zul", "15-informes.html"),
subItem(_("Scheduling progress per order"),"/reports/schedulingProgressPerOrderReport.zul", "15-informes.html"));
}
private Vbox getRegisteredItemsInsertionPoint() {

View file

@ -0,0 +1,47 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import java.util.Date;
import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import org.joda.time.LocalDate;
import org.navalplanner.business.advance.entities.AdvanceType;
import org.navalplanner.business.orders.entities.Order;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public interface ISchedulingProgressPerOrderModel {
JRDataSource getSchedulingProgressPerOrderReport(List<Order> orders,
AdvanceType advanceType, Date startingDate, Date endingDate,
LocalDate referenceDate);
List<Order> getOrders();
List<AdvanceType> getAdvanceTypes();
}

View file

@ -0,0 +1,225 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import static org.navalplanner.web.I18nHelper._;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRDataSource;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.navalplanner.business.advance.entities.AdvanceType;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.web.common.components.ExtendedJasperreport;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class SchedulingProgressPerOrderController extends NavalplannerReportController {
private static final String REPORT_NAME = "schedulingProgressPerOrderReport";
private ISchedulingProgressPerOrderModel schedulingProgressPerOrderModel;
private Listbox lbOrders;
private Listbox lbAdvanceType;
private Datebox referenceDate;
private Datebox startingDate;
private Datebox endingDate;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
lbAdvanceType.setSelectedIndex(0);
}
public List<Order> getOrders() {
return schedulingProgressPerOrderModel.getOrders();
}
protected String getReportName() {
return REPORT_NAME;
}
protected JRDataSource getDataSource() {
List<Order> orders = getSelectedOrders();
return schedulingProgressPerOrderModel
.getSchedulingProgressPerOrderReport(orders, getAdvanceType(),
startingDate.getValue(), endingDate.getValue(),
new LocalDate(getReferenceDate()));
}
/**
* Return selected orders, if none are selected return all orders in listbox
*
* @return
*/
private List<Order> getSelectedOrders() {
List<Order> result = new ArrayList<Order>();
final Set<Listitem> listItems = lbOrders.getSelectedItems();
for (Listitem each: listItems) {
result.add((Order) each.getValue());
}
return (!result.isEmpty()) ? result : getOrders();
}
private Date getReferenceDate() {
Date result = referenceDate.getValue();
if (result == null) {
referenceDate.setValue(new Date());
}
return referenceDate.getValue();
}
private Date getStartingDate() {
return startingDate.getValue();
}
private Date getEndingDate() {
return endingDate.getValue();
}
protected Map<String, Object> getParameters() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("referenceDate", getReferenceDate());
result.put("startingDate", getStartingDate());
result.put("endingDate", getEndingDate());
result.put("orderName", getSelectedOrderNames());
result.put("advanceType", asString(getSelectedAdvanceType()));
return result;
}
private AdvanceTypeDTO getSelectedAdvanceType() {
final Listitem item = lbAdvanceType.getSelectedItem();
return (AdvanceTypeDTO) item.getValue();
}
private String asString(AdvanceTypeDTO advanceTypeDTO) {
return (advanceTypeDTO != null) ? advanceTypeDTO.getName() : _("SPREAD");
}
public AdvanceType getAdvanceType() {
final AdvanceTypeDTO advanceTypeDTO = getSelectedAdvanceType();
return (advanceTypeDTO != null) ? advanceTypeDTO.getAdvanceType() : null;
}
public String getSelectedOrderNames() {
List<String> orderNames = new ArrayList<String>();
final Set<Listitem> listItems = lbOrders.getSelectedItems();
for (Listitem each: listItems) {
final Order order = (Order) each.getValue();
orderNames.add(order.getName());
}
return (!orderNames.isEmpty()) ? StringUtils.join(orderNames, ",") : _("All");
}
public List<AdvanceTypeDTO> getAdvanceTypeDTOs() {
List<AdvanceTypeDTO> result = new ArrayList<AdvanceTypeDTO>();
// Add value Spread
AdvanceTypeDTO advanceTypeDTO = new AdvanceTypeDTO();
advanceTypeDTO.setAdvanceType(null);
advanceTypeDTO.setName(_("SPREAD"));
result.add(advanceTypeDTO);
final List<AdvanceType> advanceTypes = schedulingProgressPerOrderModel.getAdvanceTypes();
for (AdvanceType each: advanceTypes) {
result.add(new AdvanceTypeDTO(each));
}
return result;
}
public void checkCannotBeHigher(Datebox dbStarting, Datebox dbEnding) {
dbStarting.clearErrorMessage(true);
dbEnding.clearErrorMessage(true);
final Date startingDate = (Date) dbStarting.getValue();
final Date endingDate = (Date) dbEnding.getValue();
if (endingDate != null && startingDate != null && startingDate.compareTo(endingDate) > 0) {
throw new WrongValueException(dbStarting, _("Cannot be higher than Ending date"));
}
}
public void showReport(ExtendedJasperreport jasperreport) {
checkCannotBeHigher(startingDate, endingDate);
super.showReport(jasperreport);
}
public class AdvanceTypeDTO {
private String name;
private AdvanceType advanceType;
public AdvanceTypeDTO() {
}
public AdvanceTypeDTO(AdvanceType advanceType) {
this.name = advanceType.getUnitName().toUpperCase();
this.advanceType = advanceType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public AdvanceType getAdvanceType() {
return advanceType;
}
public void setAdvanceType(AdvanceType advanceType) {
this.advanceType = advanceType;
}
}
}

View file

@ -0,0 +1,178 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.reports;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.joda.time.LocalDate;
import org.navalplanner.business.advance.daos.IAdvanceTypeDAO;
import org.navalplanner.business.advance.entities.AdvanceMeasurement;
import org.navalplanner.business.advance.entities.AdvanceType;
import org.navalplanner.business.advance.entities.DirectAdvanceAssignment;
import org.navalplanner.business.advance.entities.IndirectAdvanceAssignment;
import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.daos.IOrderElementDAO;
import org.navalplanner.business.orders.entities.HoursGroup;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.orders.entities.TaskSource;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.reports.dtos.SchedulingProgressPerOrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Diego Pino Garcia <dpino@igalia.com>
*
*/
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class SchedulingProgressPerOrderModel implements ISchedulingProgressPerOrderModel {
@Autowired
IOrderDAO orderDAO;
@Autowired
IOrderElementDAO taskDAO;
@Autowired
IAdvanceTypeDAO advanceTypeDAO;
@Override
@Transactional(readOnly = true)
public List<Order> getOrders() {
List<Order> orders = orderDAO.getOrders();
for (Order each: orders) {
initializeTasks(each.getTaskElements());
initializeOrderElements(each.getOrderElements());
initializeDirectAdvanceAssignments(each.getDirectAdvanceAssignments());
initializeIndirectAdvanceAssignments(each.getIndirectAdvanceAssignments());
}
return orders;
}
private void initializeOrderElements(List<OrderElement> orderElements) {
for(OrderElement each: orderElements) {
each.getCode();
initializeDirectAdvanceAssignments(each.getDirectAdvanceAssignments());
initializeTasks(each.getTaskElements());
}
}
private void initializeTasks(Set<TaskElement> tasks) {
for(TaskElement each: tasks) {
each.getName();
initializeTaskSource(each.getTaskSource());
initializeResourceAllocations(each.getResourceAllocations());
}
}
private void initializeResourceAllocations(Set<ResourceAllocation<?>> resourceAllocations) {
for (ResourceAllocation<?> each: resourceAllocations) {
each.getAssignedHours();
}
}
private void initializeTaskSource(TaskSource taskSource) {
taskSource.getTotalHours();
initializeHoursGroups(taskSource.getHoursGroups());
}
private void initializeHoursGroups(Set<HoursGroup> hoursGroups) {
for (HoursGroup each: hoursGroups) {
each.getPercentage();
}
}
private void initializeDirectAdvanceAssignments(Set<DirectAdvanceAssignment> directAdvanceAssingments) {
for (DirectAdvanceAssignment each: directAdvanceAssingments) {
each.getMaxValue();
initializaAdvanceType(each.getAdvanceType());
initializaAdvanceMeasurements(each.getAdvanceMeasurements());
}
}
private void initializeIndirectAdvanceAssignments(Set<IndirectAdvanceAssignment> indirectAdvanceAssingments) {
for (IndirectAdvanceAssignment each: indirectAdvanceAssingments) {
each.getReportGlobalAdvance();
initializaAdvanceType(each.getAdvanceType());
}
}
private void initializaAdvanceType(AdvanceType advanceType) {
advanceType.getUnitName();
}
private void initializaAdvanceMeasurements(Set<AdvanceMeasurement> advanceMeasurements) {
for (AdvanceMeasurement each: advanceMeasurements) {
each.getDate();
}
}
@Override
@Transactional(readOnly = true)
public JRDataSource getSchedulingProgressPerOrderReport(List<Order> orders,
AdvanceType advanceType, Date startingDate, Date endingDate,
LocalDate referenceDate) {
if (orders == null || orders.isEmpty()) {
return new JREmptyDataSource();
}
// Create DTOs for orders
final List<SchedulingProgressPerOrderDTO> schedulingProgressPerOrderList =
new ArrayList<SchedulingProgressPerOrderDTO>();
for (Order each: orders) {
// Filter by date
if (startingDate != null && startingDate.compareTo(each.getInitDate()) > 0) {
continue;
}
if (endingDate != null && endingDate.compareTo(each.getDeadline()) < 0) {
continue;
}
// Add to list
schedulingProgressPerOrderList
.add(new SchedulingProgressPerOrderDTO(each, advanceType, referenceDate));
}
return new JRBeanCollectionDataSource(schedulingProgressPerOrderList);
}
@Override
@Transactional(readOnly = true)
public List<AdvanceType> getAdvanceTypes() {
List<AdvanceType> result = new ArrayList<AdvanceType>();
result.addAll(advanceTypeDAO.getAll());
return result;
}
}

View file

@ -0,0 +1,156 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<?page id="reports"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_v01.css"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_zk.css"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?component name="combobox_output_format" macroURI="combobox_output_format.zul"
class="org.navalplanner.web.reports.ComboboxOutputFormat" ?>
<?component name="extendedjasperreport"
class="org.navalplanner.web.common.components.ExtendedJasperreport"
extends="jasperreport" ?>
<zk>
<window self="@{define(content)}"
apply="org.navalplanner.web.reports.SchedulingProgressPerOrderController"
title="${i18n:_('Scheduling progress per order')}"
border="normal" >
<!-- Select dates -->
<panel title="${i18n:_('Date')}" border="normal"
style="overflow:auto">
<panelchildren>
<grid width="600px">
<columns>
<column width="200px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Starting date:')}" />
<datebox id="startingDate"
onChange="controller.checkCannotBeHigher(startingDate, endingDate)"/>
</row>
<row>
<label value="${i18n:_('Ending date:')}" />
<datebox id="endingDate"
onChange="controller.checkCannotBeHigher(startingDate, endingDate)"/>
</row>
<row>
<label value="${i18n:_('Reference date:')}" />
<datebox id="referenceDate" />
</row>
</rows>
</grid>
</panelchildren>
</panel>
<!-- Advance type -->
<panel title="${i18n:_('Advance type')}" border="normal"
style="overflow:auto">
<panelchildren>
<grid width="600px">
<columns>
<column width="200px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Advance type:')}" />
<listbox id="lbAdvanceType"
model="@{controller.advanceTypeDTOs}"
mold="select"
multiple="false" >
<listitem self="@{each='advanceTypeDTO'}" value="@{advanceTypeDTO}">
<listcell label="@{advanceTypeDTO.name}" />
</listitem>
</listbox>
</row>
</rows>
</grid>
</panelchildren>
</panel>
<!-- Select orders -->
<panel title="${i18n:_('Filter by orders')}"
border="normal"
style="overflow:auto">
<panelchildren>
<listbox id="lbOrders"
width="600px"
multiple="true"
model="@{controller.orders}">
<listhead>
<listheader label="${i18n:_('Name')}" sort="auto(name)" />
<listheader label="${i18n:_('Code')}" sort="auto(code)" />
</listhead>
<listitem self="@{each='order'}" value="@{order}">
<listcell label="@{order.name}" />
<listcell label="@{order.code}" />
</listitem>
</listbox>
</panelchildren>
</panel>
<!-- Select output format -->
<panel title="${i18n:_('Format')}" border="normal"
style="overflow:auto">
<panelchildren>
<grid width="600px">
<columns>
<column width="200px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Output format:')}" />
<combobox_output_format id="outputFormat" />
</row>
</rows>
</grid>
</panelchildren>
</panel>
<separator spacing="10px" orient="horizontal"/>
<hbox style="display: none" id="URItext">
<label value="${i18n:_('Click on ')}" />
<toolbarbutton id="URIlink" class="z-label" zclass="z-label"
label="${i18n:_('direct link')}" />
<label value="${i18n:_(' to go to output directly')}" />
</hbox>
<separator spacing="10px" orient="horizontal" />
<button label="Show" onClick="controller.showReport(report)" />
<extendedjasperreport style="display: none" id="report" />
</window>
</zk>