ItEr40S17CUInformeListaAvancesTrabajoItEr39S20: Add Work progress list report

* Adds report summarizing planned and estimated worked hours for every Task, too
   * Refactored code for generating reports
This commit is contained in:
Diego Pino Garcia 2009-12-24 16:58:47 +01:00 committed by Javier Moran Rua
parent 9fdb63d469
commit e1ce429fed
22 changed files with 1728 additions and 79 deletions

View file

@ -35,6 +35,7 @@ import org.navalplanner.business.resources.daos.IMachineDAO;
import org.navalplanner.business.resources.daos.IWorkerDAO;
import org.navalplanner.business.users.daos.IProfileDAO;
import org.navalplanner.business.users.daos.IUserDAO;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.daos.IWorkReportTypeDAO;
import org.springframework.beans.factory.annotation.Autowired;
@ -44,7 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* to access DAOs. For the rest of classes (e.g. services, tests, etc.), Spring
* DI is a more convenient option. The DAOs or services are added to the
* registry as needed.
*
*
* @author Óscar González Fernández <ogonzalez@igalia.com>
* @author Fernando Bellas Permuy <fbellas@udc.es>
* @author Javier Moran Rua <jmoran@igalia.com>
@ -103,6 +104,9 @@ public class Registry {
@Autowired
private IWorkerDAO workerDAO;
@Autowired
private IWorkReportLineDAO workReportLineDAO;
private Registry() {
}
@ -174,5 +178,7 @@ public class Registry {
public static IWorkerDAO getWorkerDAO() {
return getInstance().workerDAO;
}
}
public static IWorkReportLineDAO getWorkReportLineDAO() {
return getInstance().workReportLineDAO;
}
}

View file

@ -22,10 +22,14 @@ package org.navalplanner.business.planner.daos;
import java.util.List;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.daos.IGenericDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskGroup;
import org.navalplanner.business.reports.dtos.CompletedEstimatedHoursPerTaskDTO;
import org.navalplanner.business.reports.dtos.WorkingProgressPerTaskDTO;
/**
* @author Óscar González Fernández <ogonzalez@igalia.com>
@ -39,4 +43,10 @@ public interface ITaskElementDAO extends IGenericDAO<TaskElement, Long> {
List<TaskElement> findChildrenOf(TaskGroup each);
List<WorkingProgressPerTaskDTO> getWorkingProgressPerTaskReport(
Order order, LocalDate deadline);
List<CompletedEstimatedHoursPerTaskDTO> getCompletedEstimatedHoursPerTaskReport(
Order order, LocalDate deadline);
}

View file

@ -23,13 +23,20 @@ package org.navalplanner.business.planner.daos;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.daos.GenericDAOHibernate;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.GenericDayAssignment;
import org.navalplanner.business.planner.entities.SpecificDayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.TaskGroup;
import org.navalplanner.business.reports.dtos.CompletedEstimatedHoursPerTaskDTO;
import org.navalplanner.business.reports.dtos.WorkingProgressPerTaskDTO;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
@ -80,4 +87,69 @@ public class TaskElementDAO extends GenericDAOHibernate<TaskElement, Long>
return getSession().createCriteria(TaskElement.class).add(
Restrictions.eq("parent", each)).list();
}
/**
* Returns a list of dtos with calculations for Working progress per task report
*
* @param orders filter by orders
* @param deadline deadline for task
*/
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public List<WorkingProgressPerTaskDTO> getWorkingProgressPerTaskReport(
Order order, LocalDate deadline) {
List<WorkingProgressPerTaskDTO> result = new ArrayList<WorkingProgressPerTaskDTO>();
final List<Task> tasks = getTasksByOrderAndDate(order, deadline);
for (Task task: tasks) {
result.add(new WorkingProgressPerTaskDTO(task, deadline));
}
return result;
}
private List<Task> getTasksByOrderAndDate(Order order, LocalDate deadline) {
if (deadline == null) {
deadline = new LocalDate();
}
final List<OrderElement> orders = (order != null) ? order
.getOrderElements() : new ArrayList<OrderElement>();
String strQuery =
"SELECT task "
+ "FROM TaskSource taskSource "
+ "LEFT OUTER JOIN taskSource.task task "
+ "LEFT OUTER JOIN taskSource.orderElement orderElement "
+ "WHERE task IN (SELECT task FROM Task task) "
+ "AND task.deadline <= :deadline ";
if (orders != null && !orders.isEmpty()) {
strQuery += "AND orderElement IN (:orders) ";
}
// Execute query
Query query = getSession().createQuery(strQuery);
query.setParameter("deadline", deadline);
if (orders != null && !orders.isEmpty()) {
query.setParameterList("orders", orders);
}
return query.list();
}
@Override
public List<CompletedEstimatedHoursPerTaskDTO> getCompletedEstimatedHoursPerTaskReport(
Order order, LocalDate deadline) {
List<CompletedEstimatedHoursPerTaskDTO> result = new ArrayList<CompletedEstimatedHoursPerTaskDTO>();
final List<Task> tasks = getTasksByOrderAndDate(order, deadline);
for (Task task: tasks) {
result.add(new CompletedEstimatedHoursPerTaskDTO(task, deadline));
}
return result;
}
}

View file

@ -0,0 +1,134 @@
/*
* 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.util.List;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.Registry;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class CompletedEstimatedHoursPerTaskDTO {
private IWorkReportLineDAO workReportLineDAO;
private String taskName;
private Integer estimatedHours;
private Integer totalPlannedHours;
private Integer partialPlannedHours;
private Integer realHours;
private CompletedEstimatedHoursPerTaskDTO() {
workReportLineDAO = Registry.getWorkReportLineDAO();
}
public CompletedEstimatedHoursPerTaskDTO(Task task, LocalDate date) {
this();
this.taskName = task.getName();
this.estimatedHours = task.getHoursSpecifiedAtOrder();
this.totalPlannedHours = calculatePlannedHours(task, null);
this.partialPlannedHours = calculatePlannedHours(task, date);
this.realHours = calculateRealHours(task, date);
}
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(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 void setEstimatedHours(Integer estimatedHours) {
this.estimatedHours = estimatedHours;
}
public Integer getTotalPlannedHours() {
return totalPlannedHours;
}
public void setTotalPlannedHours(Integer totalPlannedHours) {
this.totalPlannedHours = totalPlannedHours;
}
public Integer getPartialPlannedHours() {
return partialPlannedHours;
}
public void setPartialPlannedHours(Integer partialPlannedHours) {
this.partialPlannedHours = partialPlannedHours;
}
public Integer getRealHours() {
return realHours;
}
public void setRealHours(Integer realHours) {
this.realHours = realHours;
}
public String getTaskName() {
return taskName;
}
}

View file

@ -0,0 +1,234 @@
/*
* 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.List;
import org.joda.time.LocalDate;
import org.navalplanner.business.common.Registry;
import org.navalplanner.business.planner.entities.DayAssignment;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
import org.navalplanner.business.workreports.entities.WorkReportLine;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class WorkingProgressPerTaskDTO {
private IWorkReportLineDAO workReportLineDAO;
private String taskName;
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 WorkingProgressPerTaskDTO() {
workReportLineDAO = Registry.getWorkReportLineDAO();
}
public WorkingProgressPerTaskDTO(Task task, LocalDate date) {
this();
this.taskName = task.getName();
this.estimatedHours = task.getHoursSpecifiedAtOrder();
this.totalPlannedHours = calculatePlannedHours(task, null);
this.partialPlannedHours = calculatePlannedHours(task, date);
this.realHours = calculateRealHours(task, date);
this.averageProgress = task.getOrderElement().getAdvancePercentage();
this.imputedProgress = (totalPlannedHours != 0) ? new Double(realHours / totalPlannedHours.doubleValue()) : new Double(0);
this.plannedProgress = (totalPlannedHours != 0) ? new Double(partialPlannedHours / totalPlannedHours.doubleValue()) : new Double(0);
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);
}
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(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 void setEstimatedHours(Integer estimatedHours) {
this.estimatedHours = estimatedHours;
}
public Integer getTotalPlannedHours() {
return totalPlannedHours;
}
public void setTotalPlannedHours(Integer totalPlannedHours) {
this.totalPlannedHours = totalPlannedHours;
}
public Integer getPartialPlannedHours() {
return partialPlannedHours;
}
public void setPartialPlannedHours(Integer partialPlannedHours) {
this.partialPlannedHours = partialPlannedHours;
}
public Integer getRealHours() {
return realHours;
}
public void setRealHours(Integer realHours) {
this.realHours = realHours;
}
public BigDecimal getAverageProgress() {
return averageProgress;
}
public void setAverageProgress(BigDecimal averageProgress) {
this.averageProgress = averageProgress;
}
public Double getImputedProgress() {
return imputedProgress;
}
public void setImputedProgress(Double imputedProgress) {
this.imputedProgress = imputedProgress;
}
public Double getPlannedProgress() {
return plannedProgress;
}
public void setPlannedProgress(Double plannedProgress) {
this.plannedProgress = plannedProgress;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
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;
}
}

View file

@ -0,0 +1,192 @@
<?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="deadlineDate" class="java.util.Date"/>
<field name="taskName" 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"/>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="167" splitType="Stretch">
<staticText>
<reportElement style="Title" x="0" y="13" width="263" height="33"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Hours report]]></text>
</staticText>
<staticText>
<reportElement style="SubTitle" x="34" y="46" width="240" height="22">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{deadlineDate} != null)]]></printWhenExpression>
</reportElement>
<textElement/>
<text><![CDATA[Completed estimated hours]]></text>
</staticText>
<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 x="0" y="76" width="78" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Deadline date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="78" y="76" width="100" height="20"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$P{deadlineDate}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement mode="Opaque" x="64" y="132" width="382" height="20" forecolor="#000000" backcolor="#E0E4FB"/>
</rectangle>
<staticText>
<reportElement style="Column header" x="130" y="137" width="158" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Total hours]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="288" y="137" width="158" height="15"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Hours on time]]></text>
</staticText>
<staticText>
<reportElement style="Column header" mode="Opaque" x="130" y="152" width="79" 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="209" y="152" width="79" 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="288" y="152" width="79" 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="367" y="152" width="79" 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="64" y="152" width="66" 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="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="16" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="64" y="0" width="66" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{taskName}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="209" y="0" width="79" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{totalPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="130" y="0" width="79" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{estimatedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="288" y="0" width="79" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{partialPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="367" y="0" width="79" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{realHours}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" 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>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>

View file

@ -0,0 +1,311 @@
<?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="deadlineDate" class="java.util.Date"/>
<field name="taskName" 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"/>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="167" splitType="Stretch">
<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="240" height="22">
<printWhenExpression><![CDATA[new java.lang.Boolean($P{deadlineDate} != null)]]></printWhenExpression>
</reportElement>
<textElement/>
<text><![CDATA[Working progress per task]]></text>
</staticText>
<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 x="0" y="76" width="78" height="20"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Deadline date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="78" y="76" width="100" height="20"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$P{deadlineDate}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement mode="Opaque" x="0" y="132" width="555" height="20" forecolor="#000000" backcolor="#E0E4FB"/>
</rectangle>
<staticText>
<reportElement style="Column header" x="39" y="137" width="62" height="15"/>
<textElement verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Total hours]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="315" y="137" width="56" height="15"/>
<textElement verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Difference]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="188" y="137" width="46" height="15"/>
<textElement verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Progress]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="119" y="137" width="70" height="15"/>
<textElement verticalAlignment="Top">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Hours on time]]></text>
</staticText>
<staticText>
<reportElement style="Column header" mode="Opaque" x="39" y="152" width="30" 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[Est. hr]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="68" y="152" width="52" 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[Tot Plan. hr]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="119" y="152" width="35" 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[Plan. hr]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="154" y="152" width="35" 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. hr]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="189" y="152" width="39" 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[Av. prog]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="228" y="152" width="43" 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[Imp. prog]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="270" y="152" width="45" 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[Plan. prog]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="315" y="152" width="39" 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. dif]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="353" y="152" width="37" 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[Plan. dif]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="389" y="152" width="60" 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 dif. ratio]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="448" y="152" width="59" 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[Plan dif. ratio]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="16" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="1" y="0" width="39" height="16"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{taskName}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="69" y="0" width="52" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{totalPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="39" y="0" width="28" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{estimatedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="122" y="0" width="34" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{partialPlannedHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="156" y="0" width="34" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{realHours}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="190" y="0" width="39" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{averageProgress}]]></textFieldExpression>
</textField>
<textField pattern="###0.00" isBlankWhenNull="true">
<reportElement x="230" y="0" width="42" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{imputedProgress}]]></textFieldExpression>
</textField>
<textField pattern="###0.00;-###0.00" isBlankWhenNull="true">
<reportElement x="272" y="0" width="43" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{plannedProgress}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="315" y="0" width="38" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{costDifference}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="353" y="0" width="36" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{planningDifference}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="389" y="0" width="58" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ratioCostDifference}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="447" y="0" width="58" height="16"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{ratioPlanningDifference}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="9" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" 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>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>

View file

@ -222,7 +222,12 @@ public class CustomMenuController extends Div implements IMenuItemsRegister {
subItem(_("Manage user accounts"), "/users/users.zul",""));
}
topItem(_("Reports"), "", "",
subItem(_("Worker report"),"/reports/worker_report.zul", ""));
subItem(_("Hours worked per worker"),
"/reports/hoursWorkedPerWorkerReport.zul", ""),
subItem(_("Completed estimated hours"),
"/reports/completedEstimatedHoursPerTask.zul", ""),
subItem(_("Working progress per task"),
"/reports/workingProgressPerTaskReport.zul", ""));
}
private Vbox getRegisteredItemsInsertionPoint() {

View file

@ -0,0 +1,95 @@
/*
* 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.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.business.orders.entities.Order;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class CompletedEstimatedHoursPerTaskController extends NavalplannerReportController {
private static final String REPORT_NAME = "completedEstimatedHours";
private ICompletedEstimatedHoursPerTaskModel completedEstimatedHoursPerTaskModel;
private Listbox lbOrders;
private Datebox deadlineDate;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
}
public List<Order> getOrders() {
return completedEstimatedHoursPerTaskModel.getOrders();
}
@Override
protected String getReportName() {
return REPORT_NAME;
}
@Override
protected JRDataSource getDataSource() {
return completedEstimatedHoursPerTaskModel
.getCompletedEstimatedHoursReportPerTask(getSelectedOrder(),
getDeadlineDate());
}
private Order getSelectedOrder() {
final Listitem item = lbOrders.getSelectedItem();
return (item != null) ? (Order) item.getValue() : null;
}
private Date getDeadlineDate() {
Date result = deadlineDate.getValue();
if (result == null) {
deadlineDate.setValue(new Date());
}
return deadlineDate.getValue();
}
@Override
protected Map<String, Object> getParameters() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("deadlineDate", getDeadlineDate());
return result;
}
}

View file

@ -0,0 +1,90 @@
/*
* 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 net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.joda.time.LocalDate;
import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.daos.ITaskElementDAO;
import org.navalplanner.business.reports.dtos.CompletedEstimatedHoursPerTaskDTO;
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 CompletedEstimatedHoursPerTaskModel implements ICompletedEstimatedHoursPerTaskModel {
@Autowired
IOrderDAO orderDAO;
@Autowired
ITaskElementDAO taskDAO;
@Override
@Transactional(readOnly = true)
public List<Order> getOrders() {
List<Order> result = orderDAO.getOrders();
for (Order each: result) {
initializeOrderElements(each.getOrderElements());
}
return result;
}
private void initializeOrderElements(List<OrderElement> orderElements) {
for (OrderElement each: orderElements) {
initializeOrderElement(each);
}
}
private void initializeOrderElement(OrderElement orderElement) {
orderElement.getName();
}
@Override
@Transactional(readOnly = true)
public JRDataSource getCompletedEstimatedHoursReportPerTask(
Order order, Date deadline) {
final List<CompletedEstimatedHoursPerTaskDTO> completedEstimatedHoursPerTaskList =
taskDAO.getCompletedEstimatedHoursPerTaskReport(order, new LocalDate(deadline));
if (completedEstimatedHoursPerTaskList != null && !completedEstimatedHoursPerTaskList.isEmpty()) {
return new JRBeanCollectionDataSource(completedEstimatedHoursPerTaskList);
} else {
return new JREmptyDataSource();
}
}
}

View file

@ -30,41 +30,28 @@ import java.util.Set;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.business.resources.entities.Worker;
import org.navalplanner.web.common.components.ExtendedJasperreport;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Toolbarbutton;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class HoursWorkedPerWorkerController extends GenericForwardComposer {
public class HoursWorkedPerWorkerController extends NavalplannerReportController {
private static final String REPORT_NAME = "hoursWorkedPerWorkerReport";
private IHoursWorkedPerWorkerModel hoursWorkedPerWorkerModel;
private HoursWorkedPerWorkerReport workerReport;
private Listbox lbWorkers;
private Datebox startingDate;
private Datebox endingDate;
private ComboboxOutputFormat outputFormat;
private Hbox URItext;
private Toolbarbutton URIlink;
private static final String HTML = "html";
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
@ -75,36 +62,16 @@ public class HoursWorkedPerWorkerController extends GenericForwardComposer {
return hoursWorkedPerWorkerModel.getWorkers();
}
public void showReport(ExtendedJasperreport report) {
final String type = outputFormat.getOutputFormat();
workerReport = new HoursWorkedPerWorkerReport(report);
workerReport.setDatasource(getDataSource());
workerReport.setParameters(getParameters());
String URI = workerReport.show(type);
if (type.equals(HTML)) {
URItext.setStyle("display: none");
Executions.getCurrent().sendRedirect(URI, "_blank");
} else {
URItext.setStyle("display: inline");
URIlink.setHref(URI);
}
@Override
protected String getReportName() {
return REPORT_NAME;
}
private JRDataSource getDataSource() {
@Override
protected JRDataSource getDataSource() {
return hoursWorkedPerWorkerModel.getWorkerReport(getSelectedWorkers(), getStartingDate(), getEndingDate());
}
private Map<String, Object> getParameters() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("startingDate", getStartingDate());
result.put("endingDate", getEndingDate());
return result;
}
private List<Worker> getSelectedWorkers() {
List<Worker> result = new ArrayList<Worker>();
@ -123,4 +90,14 @@ public class HoursWorkedPerWorkerController extends GenericForwardComposer {
return endingDate.getValue();
}
@Override
protected Map<String, Object> getParameters() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("startingDate", getStartingDate());
result.put("endingDate", getEndingDate());
return result;
}
}

View file

@ -1,33 +0,0 @@
/*
* 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 org.navalplanner.web.common.components.ExtendedJasperreport;
public class HoursWorkedPerWorkerReport extends NavalplannerReport {
public HoursWorkedPerWorkerReport(ExtendedJasperreport report) {
report.setSrc("worker_report.jasper");
setReport(report);
}
}

View file

@ -0,0 +1,21 @@
package org.navalplanner.web.reports;
import java.util.Date;
import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.business.orders.entities.Order;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public interface ICompletedEstimatedHoursPerTaskModel {
JRDataSource getCompletedEstimatedHoursReportPerTask(Order order, Date deadlineDate);
List<Order> getOrders();
}

View file

@ -0,0 +1,22 @@
package org.navalplanner.web.reports;
import java.util.Date;
import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.resources.entities.Worker;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public interface IWorkingProgressPerTaskModel {
JRDataSource getWorkingProgressPerTaskReport(Order order, Date deadlineDate);
List<Order> getOrders();
}

View file

@ -27,10 +27,22 @@ import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.web.common.components.ExtendedJasperreport;
import org.zkoss.zk.ui.Executions;
public abstract class NavalplannerReport implements INavalplannerReport {
public class NavalplannerReport implements INavalplannerReport {
private ExtendedJasperreport report;
public NavalplannerReport() {
}
public NavalplannerReport(ExtendedJasperreport report, String reportName) {
if (!reportName.endsWith(".jasper")) {
reportName += ".jasper";
}
report.setSrc(reportName);
setReport(report);
}
public ExtendedJasperreport getReport() {
return report;
}

View file

@ -0,0 +1,78 @@
/*
* 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.Map;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.web.common.components.ExtendedJasperreport;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Toolbarbutton;
/**
*
* Handles the basic behaviour of a Controller for showing reports
*
* All reports consists of several input components and a show button which retrieves the necessary data to
* build resulting report. The method showReport takes care of this behaviour. In addition, when a new report
* is shown, a link to the report shows up as well.
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public abstract class NavalplannerReportController extends GenericForwardComposer {
private static final String HTML = "html";
protected ComboboxOutputFormat outputFormat;
protected Hbox URItext;
protected Toolbarbutton URIlink;
public void showReport(ExtendedJasperreport jasperreport) {
final String type = outputFormat.getOutputFormat();
NavalplannerReport report = new NavalplannerReport(jasperreport,
getReportName());
report.setDatasource(getDataSource());
report.setParameters(getParameters());
report.show(type);
String URI = report.show(type);
if (type.equals(HTML)) {
URItext.setStyle("display: none");
Executions.getCurrent().sendRedirect(URI, "_blank");
} else {
URItext.setStyle("display: inline");
URIlink.setHref(URI);
}
}
protected abstract JRDataSource getDataSource();
protected abstract Map<String, Object> getParameters();
protected abstract String getReportName();
}

View file

@ -0,0 +1,93 @@
/*
* 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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.jasperreports.engine.JRDataSource;
import org.navalplanner.business.orders.entities.Order;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
/**
*
* @author Diego Pino Garcia <dpino@igalia.com>
*
*/
public class WorkingProgressPerTaskController extends NavalplannerReportController {
private static final String REPORT_NAME = "workingProgressPerTaskReport";
private IWorkingProgressPerTaskModel workingProgressPerTaskModel;
private Listbox lbOrders;
private Datebox deadlineDate;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
}
public List<Order> getOrders() {
return workingProgressPerTaskModel.getOrders();
}
protected String getReportName() {
return REPORT_NAME;
}
protected JRDataSource getDataSource() {
return workingProgressPerTaskModel.getWorkingProgressPerTaskReport(
getSelectedOrder(), getDeadlineDate());
}
private Order getSelectedOrder() {
final Listitem item = lbOrders.getSelectedItem();
return (item != null) ? (Order) item.getValue() : null;
}
private Date getDeadlineDate() {
Date result = deadlineDate.getValue();
if (result == null) {
deadlineDate.setValue(new Date());
}
return deadlineDate.getValue();
}
protected Map<String, Object> getParameters() {
Map<String, Object> result = new HashMap<String, Object>();
result.put("deadlineDate", getDeadlineDate());
return result;
}
}

View file

@ -0,0 +1,90 @@
/*
* 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 net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.joda.time.LocalDate;
import org.navalplanner.business.orders.daos.IOrderDAO;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.planner.daos.ITaskElementDAO;
import org.navalplanner.business.reports.dtos.WorkingProgressPerTaskDTO;
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 WorkingProgressPerTaskModel implements IWorkingProgressPerTaskModel {
@Autowired
IOrderDAO orderDAO;
@Autowired
ITaskElementDAO taskDAO;
@Override
@Transactional(readOnly = true)
public List<Order> getOrders() {
List<Order> result = orderDAO.getOrders();
for (Order each: result) {
initializeOrderElements(each.getOrderElements());
}
return result;
}
private void initializeOrderElements(List<OrderElement> orderElements) {
for (OrderElement each: orderElements) {
initializeOrderElement(each);
}
}
private void initializeOrderElement(OrderElement orderElement) {
orderElement.getName();
}
@Override
public JRDataSource getWorkingProgressPerTaskReport(Order order,
Date deadlineDate) {
final List<WorkingProgressPerTaskDTO> workingHoursPerWorkerList =
taskDAO.getWorkingProgressPerTaskReport(order, new LocalDate(deadlineDate));
if (workingHoursPerWorkerList != null && !workingHoursPerWorkerList.isEmpty()) {
return new JRBeanCollectionDataSource(workingHoursPerWorkerList);
} else {
return new JREmptyDataSource();
}
}
}

View file

@ -0,0 +1,120 @@
<!--
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.CompletedEstimatedHoursPerTaskController"
title="${i18n:_('Completed estimated hours per task')}"
border="normal" >
<!-- Select deadline date -->
<panel title="${i18n:_('Date')}" border="normal"
style="overflow:auto">
<panelchildren>
<grid width="600px">
<columns>
<column width="200px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Deadline date:')}" />
<datebox id="deadlineDate" />
</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="false"
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>

View file

@ -0,0 +1,120 @@
<!--
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.WorkingProgressPerTaskController"
title="${i18n:_('Working progress per task')}"
border="normal" >
<!-- Select deadline date -->
<panel title="${i18n:_('Date')}" border="normal"
style="overflow:auto">
<panelchildren>
<grid width="600px">
<columns>
<column width="200px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Deadline date:')}" />
<datebox id="deadlineDate" />
</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="false"
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>