ItEr18S12CUListaPartesTraballoDendeOrganizacionTraballoItEr17S17: Show the asigned hours to the order elements.
Javier Moran Rua <jmoran@igalia.com>: Several changes to adapt the code to the formatting conventions.
This commit is contained in:
parent
825f533283
commit
664bf0c718
11 changed files with 357 additions and 10 deletions
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.navalplanner.business.resources.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -26,6 +27,7 @@ import org.navalplanner.business.resources.daos.ResourcesDaoRegistry;
|
|||
/**
|
||||
* This class acts as the base class for all resources.
|
||||
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public abstract class Resource {
|
||||
|
||||
|
|
@ -35,6 +37,8 @@ public abstract class Resource {
|
|||
|
||||
private Set<CriterionSatisfaction> criterionSatisfactions = new HashSet<CriterionSatisfaction>();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
private interface Predicate {
|
||||
public boolean accepts(CriterionSatisfaction satisfaction);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.hibernate.validator.NotEmpty;
|
|||
/**
|
||||
* This class models a worker.
|
||||
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class Worker extends Resource {
|
||||
@NotEmpty
|
||||
|
|
@ -30,6 +31,11 @@ public class Worker extends Resource {
|
|||
this.dailyHours = dailyHours;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return getFirstName()+" "+getSurname();
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package org.navalplanner.business.workreports.daos;
|
||||
|
||||
import java.util.List;
|
||||
import org.navalplanner.business.common.daos.IGenericDao;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
|
||||
/**
|
||||
* Dao for {@link WorkReportLine}
|
||||
*
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public interface IWorkReportLineDAO extends IGenericDao<WorkReportLine, Long> {
|
||||
|
||||
public interface IWorkReportLineDAO extends IGenericDao<WorkReportLine, Long>{
|
||||
public List<WorkReportLine> findByOrderElement(OrderElement orderElement);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,33 @@
|
|||
package org.navalplanner.business.workreports.daos;
|
||||
|
||||
import java.util.List;
|
||||
import org.navalplanner.business.common.daos.impl.GenericDaoHibernate;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* Dao for {@link WorkReportLineDAO}
|
||||
*
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
@Service
|
||||
@Repository
|
||||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
public class WorkReportLineDAO extends
|
||||
GenericDaoHibernate<WorkReportLine, Long> implements IWorkReportLineDAO {
|
||||
|
||||
@Override
|
||||
public List<WorkReportLine> findByOrderElement(OrderElement orderElement){
|
||||
Criteria c = getSession().createCriteria(WorkReportLine.class).createCriteria("orderElement");
|
||||
c.add(Restrictions.idEq(orderElement.getId()));
|
||||
return (List<WorkReportLine>)c.list();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.navalplanner.business.resources.entities.Resource;
|
|||
|
||||
/**
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class WorkReportLine {
|
||||
|
||||
|
|
@ -74,11 +75,11 @@ public class WorkReportLine {
|
|||
return criterions;
|
||||
}
|
||||
|
||||
public void setCriterions(Set<Criterion> criterions) {
|
||||
public void setCriterions(Set<Criterion> criterions){
|
||||
this.criterions = criterions;
|
||||
}
|
||||
|
||||
public WorkReport getWorkReport() {
|
||||
public WorkReport getWorkReport(){
|
||||
return workReport;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package org.navalplanner.web.orders;
|
||||
|
||||
import java.util.List;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.zkoss.zul.Window;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
||||
/**
|
||||
* Controller for show the asigned hours of the selected order element<br />
|
||||
*
|
||||
* @author Susana Montes Pedreria <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class AsignedHoursToOrderElementController extends
|
||||
GenericForwardComposer {
|
||||
|
||||
private Window window;
|
||||
|
||||
IAsignedHoursToOrderElementModel asignedHoursToOrderElementModel;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp.getFellow("listOrderElementHours"));
|
||||
comp.setVariable("asignedHoursToOrderElementController", this, true);
|
||||
window = (Window) comp;
|
||||
}
|
||||
|
||||
public List<WorkReportLine> getWorkReportLines() {
|
||||
return asignedHoursToOrderElementModel.getWorkReportLines();
|
||||
}
|
||||
|
||||
public int getTotalAsignedDirectHours() {
|
||||
return asignedHoursToOrderElementModel.getAsignedDirectHours();
|
||||
}
|
||||
|
||||
public int getTotalAsignedHours() {
|
||||
return asignedHoursToOrderElementModel.getTotalAsignedHours();
|
||||
}
|
||||
|
||||
public void back() {
|
||||
window.setVisible(false);
|
||||
Util.reloadBindings(window.getParent());
|
||||
}
|
||||
|
||||
public int getHoursChildren() {
|
||||
return asignedHoursToOrderElementModel.getAsignedDirectHoursChildren();
|
||||
}
|
||||
|
||||
public int getEstimatedHours() {
|
||||
return asignedHoursToOrderElementModel.getEstimatedHours();
|
||||
}
|
||||
|
||||
public int getProgressWork() {
|
||||
return asignedHoursToOrderElementModel.getProgressWork();
|
||||
}
|
||||
|
||||
public void openWindow(IOrderElementModel orderElementModel) {
|
||||
this.asignedHoursToOrderElementModel.initOrderElement(orderElementModel
|
||||
.getOrderElement());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package org.navalplanner.web.orders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Service to show the asigned hours of a selected order element
|
||||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
@Service
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class AsignedHoursToOrderElementModel implements
|
||||
IAsignedHoursToOrderElementModel {
|
||||
|
||||
@Autowired
|
||||
private final IWorkReportLineDAO workReportLineDAO;
|
||||
|
||||
private int asignedDirectHours;
|
||||
|
||||
private OrderElement orderElement;
|
||||
|
||||
private List<WorkReportLine> listWRL;
|
||||
|
||||
@Autowired
|
||||
public AsignedHoursToOrderElementModel(IWorkReportLineDAO workReportLineDAO) {
|
||||
Validate.notNull(workReportLineDAO);
|
||||
this.workReportLineDAO = workReportLineDAO;
|
||||
this.asignedDirectHours = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WorkReportLine> getWorkReportLines() {
|
||||
if (orderElement == null) {
|
||||
return new ArrayList<WorkReportLine>();
|
||||
}
|
||||
this.asignedDirectHours = 0;
|
||||
this.listWRL = workReportLineDAO.findByOrderElement(orderElement);
|
||||
Iterator<WorkReportLine> iterador = listWRL.iterator();
|
||||
while (iterador.hasNext()) {
|
||||
WorkReportLine w = iterador.next();
|
||||
w.getResource().getDailyCapacity();
|
||||
w.getOrderElement().getWorkHours();
|
||||
w.getWorkReport().getDate();
|
||||
this.asignedDirectHours = this.asignedDirectHours + w.getNumHours();
|
||||
}
|
||||
return listWRL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAsignedDirectHours() {
|
||||
if (orderElement == null) {
|
||||
return 0;
|
||||
}
|
||||
return this.asignedDirectHours;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int getTotalAsignedHours() {
|
||||
if (orderElement == null) {
|
||||
return 0;
|
||||
}
|
||||
return getAddAsignedHours(this.orderElement);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
private int getAddAsignedHours(OrderElement orderElement) {
|
||||
int addAsignedHoursChildren = 0;
|
||||
if (!orderElement.getChildren().isEmpty()) {
|
||||
List<OrderElement> children = orderElement.getChildren();
|
||||
Iterator<OrderElement> iterador = children.iterator();
|
||||
while (iterador.hasNext()) {
|
||||
OrderElement w = iterador.next();
|
||||
addAsignedHoursChildren = addAsignedHoursChildren
|
||||
+ getAddAsignedHours(w);
|
||||
}
|
||||
}
|
||||
List<WorkReportLine> listWRL = this.workReportLineDAO
|
||||
.findByOrderElement(orderElement);
|
||||
return (getAsignedDirectHours_(listWRL) + addAsignedHoursChildren);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
private int getAsignedDirectHours_(List<WorkReportLine> listWRL) {
|
||||
int asignedDirectHours = 0;
|
||||
Iterator<WorkReportLine> iterator = listWRL.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
asignedDirectHours = asignedDirectHours
|
||||
+ iterator.next().getNumHours();
|
||||
}
|
||||
return asignedDirectHours;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int getAsignedDirectHoursChildren() {
|
||||
if (orderElement == null) {
|
||||
return 0;
|
||||
}
|
||||
if (orderElement.getChildren().isEmpty())
|
||||
return 0;
|
||||
int asignedDirectChildren = getTotalAsignedHours()
|
||||
- this.asignedDirectHours;
|
||||
return asignedDirectChildren;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void initOrderElement(OrderElement orderElement) {
|
||||
this.orderElement = orderElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int getEstimatedHours() {
|
||||
if (orderElement == null) {
|
||||
return 0;
|
||||
}
|
||||
return orderElement.getWorkHours();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int getProgressWork() {
|
||||
if (orderElement == null) {
|
||||
return 0;
|
||||
}
|
||||
double addAsignedHours = getTotalAsignedHours();
|
||||
double estimatedHours = getEstimatedHours();
|
||||
if (estimatedHours < 1)
|
||||
return 0;
|
||||
return (int) (((double) (addAsignedHours / estimatedHours)) * 100);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package org.navalplanner.web.orders;
|
||||
|
||||
import java.util.List;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
|
||||
/**
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public interface IAsignedHoursToOrderElementModel{
|
||||
public List<WorkReportLine> getWorkReportLines();
|
||||
public int getAsignedDirectHours();
|
||||
public int getTotalAsignedHours();
|
||||
public int getAsignedDirectHoursChildren();
|
||||
public void initOrderElement(OrderElement orderElement);
|
||||
public int getEstimatedHours();
|
||||
public int getProgressWork();
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ import org.zkoss.zul.api.Listhead;
|
|||
* Controller for {@link OrderElement} view of {@link Order} entities <br />
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class OrderElementController extends GenericForwardComposer {
|
||||
|
||||
|
|
@ -70,6 +71,8 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
*/
|
||||
private Set<CriterionType> selectedCriterionTypes = new LinkedHashSet<CriterionType>();
|
||||
|
||||
private AsignedHoursToOrderElementController asignedHoursController;
|
||||
|
||||
public OrderElement getOrderElement() {
|
||||
if (model == null) {
|
||||
return new OrderLine();
|
||||
|
|
@ -154,10 +157,17 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
comp.setVariable("orderElementController", this, true);
|
||||
|
||||
window = (Window) comp;
|
||||
setupAsignedHoursToOrderElementController(comp);
|
||||
}
|
||||
|
||||
|
||||
private void setupAsignedHoursToOrderElementController(Component comp)throws Exception{
|
||||
asignedHoursController = new AsignedHoursToOrderElementController();
|
||||
asignedHoursController.doAfterCompose(comp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the window to edit a {@link OrderElement}. If it's a
|
||||
* {@link OrderLineGroup} less fields will be enabled.
|
||||
|
|
@ -165,12 +175,14 @@ public class OrderElementController extends GenericForwardComposer {
|
|||
* @param orderElement
|
||||
* The {@link OrderElement} to be edited
|
||||
*/
|
||||
public void openWindow(IOrderElementModel model) {
|
||||
public void openWindow(IOrderElementModel model){
|
||||
|
||||
this.model = model;
|
||||
|
||||
final OrderElement orderElement = model.getOrderElement();
|
||||
|
||||
asignedHoursController.openWindow(model);
|
||||
|
||||
// If is a container
|
||||
if (orderElement instanceof OrderLineGroup) {
|
||||
// Disable fields just used in the OrderLine
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
<window visible="false" id="${arg.top_id}" title="Edit Order Element"
|
||||
width="600px" left="100px" top="100px">
|
||||
|
||||
<?component name="listOrderElementHours" inline="true" macroURI="_listOrderElementHours.zul"?>
|
||||
<window visible="false" id="${arg.top_id}" title="Edit Order Element" width="600px" left="100px" top="100px">
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="Detalles"></tab>
|
||||
<tab label="Horas Imputadas"></tab>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<vbox>
|
||||
|
||||
<label value="${arg.title}" />
|
||||
|
|
@ -92,5 +98,12 @@
|
|||
</hbox>
|
||||
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
<tabpanel>
|
||||
<listOrderElementHours/>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
|
||||
</window>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<vbox id="listOrderElementHours">
|
||||
<vbox>
|
||||
<label value="Imputacion directa" />
|
||||
<separator spacing="3px" orient="horizontal"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<grid id="listingWRL" style="border:0px" height="100%" model="@{asignedHoursToOrderElementController.workReportLines}" mold="paging"
|
||||
pageSize="5">
|
||||
<columns>
|
||||
<column label="Data" />
|
||||
<column label="Recurso" />
|
||||
<column label="Horas" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row self="@{each='workReportLine'}">
|
||||
<label value="@{workReportLine.workReport.date}" />
|
||||
<label value="@{workReportLine.resource.description}"/>
|
||||
<label value="@{workReportLine.numHours}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<grid id="total" style="border:0px">
|
||||
<rows>
|
||||
<row>
|
||||
<label value="Total" />
|
||||
<label id="totalID" value="@{asignedHoursToOrderElementController.totalAsignedDirectHours}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<separator spacing="5px" orient="horizontal"/>
|
||||
<hbox>
|
||||
<label value="Imputación lineas hijas: "/> <label id="totalIDC" value="@{asignedHoursToOrderElementController.hoursChildren}"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="Total:"/><label id="addtotal" value="@{asignedHoursToOrderElementController.totalAsignedHours}"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<separator bar="true" spacing="12px" orient="horizontal"/>
|
||||
<vbox>
|
||||
<label value="Porcentaje de consumo horas presupuestadas/horas consumidas."/>
|
||||
<grid style="border:0px" height="100%">
|
||||
<rows>
|
||||
<row>
|
||||
<vbox>
|
||||
<hbox>
|
||||
<label value="Horas presupuestadas:"/>
|
||||
<label id="estimatedHours" value="@{asignedHoursToOrderElementController.estimatedHours}"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="Horas imputadas:"/>
|
||||
<label id="addAsignedHours" value="@{asignedHoursToOrderElementController.totalAsignedHours}"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<hbox>
|
||||
<label value="@{asignedHoursToOrderElementController.progressWork}"/>
|
||||
<label value="% "/>
|
||||
<progressmeter value="@{asignedHoursToOrderElementController.progressWork}"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<button id="backButton2" onClick="asignedHoursToOrderElementController.back();" label="back" />
|
||||
</hbox>
|
||||
</vbox>
|
||||
</vbox>
|
||||
Loading…
Add table
Reference in a new issue