[Bug #1178] Fixed calculation of sum hours with EffortDuration in report HoursWorkedPerResource
FEA: ItEr75S04BugFixing
This commit is contained in:
parent
549d02265b
commit
598cc0393a
3 changed files with 25 additions and 3 deletions
|
|
@ -52,6 +52,8 @@ public class HoursWorkedPerResourceDTO implements Comparable {
|
|||
|
||||
private String labels;
|
||||
|
||||
private HoursWorkedPerResourceDTO self;
|
||||
|
||||
public HoursWorkedPerResourceDTO(Resource resource,
|
||||
WorkReportLine workReportLine) {
|
||||
|
||||
|
|
@ -69,6 +71,7 @@ public class HoursWorkedPerResourceDTO implements Comparable {
|
|||
labels.addAll(workReportLine.getOrderElement().getLabels());
|
||||
}
|
||||
this.labels = labelsAsString(labels);
|
||||
this.self = this;
|
||||
}
|
||||
|
||||
private String labelsAsString(Set<Label> labels) {
|
||||
|
|
@ -165,4 +168,19 @@ public class HoursWorkedPerResourceDTO implements Comparable {
|
|||
.compareTo(((HoursWorkedPerResourceDTO) o).workerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the self
|
||||
*/
|
||||
public HoursWorkedPerResourceDTO getSelf() {
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param self
|
||||
* the self to set
|
||||
*/
|
||||
public void setSelf(HoursWorkedPerResourceDTO self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
<field name="date" class="java.util.Date"/>
|
||||
<field name="clockStart" class="java.util.Date"/>
|
||||
<field name="clockFinish" class="java.util.Date"/>
|
||||
<field name="self" class="org.navalplanner.business.reports.dtos.HoursWorkedPerResourceDTO"/>
|
||||
<field name="effort" class="org.navalplanner.business.workingday.EffortDuration"/>
|
||||
<field name="orderElementCode" class="java.lang.String"/>
|
||||
<field name="orderElementName" class="java.lang.String"/>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
|||
import net.sf.jasperreports.engine.JRAbstractScriptlet;
|
||||
import net.sf.jasperreports.engine.JRScriptletException;
|
||||
|
||||
import org.navalplanner.business.reports.dtos.HoursWorkedPerResourceDTO;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
|
||||
/**
|
||||
|
|
@ -36,7 +37,7 @@ import org.navalplanner.business.workingday.EffortDuration;
|
|||
*/
|
||||
public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet {
|
||||
|
||||
private Set<EffortDuration> efforts = new HashSet<EffortDuration>();
|
||||
private Set<HoursWorkedPerResourceDTO> dtos = new HashSet<HoursWorkedPerResourceDTO>();
|
||||
|
||||
public String getEffort() throws JRScriptletException {
|
||||
EffortDuration effort = (EffortDuration) this.getFieldValue("effort");
|
||||
|
|
@ -56,7 +57,9 @@ public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet {
|
|||
// We use the set because elements could be processed twice depending on
|
||||
// the report
|
||||
EffortDuration current = (EffortDuration) this.getFieldValue("effort");
|
||||
if (!efforts.contains(current)) {
|
||||
HoursWorkedPerResourceDTO dto = (HoursWorkedPerResourceDTO) this
|
||||
.getFieldValue("self");
|
||||
if (!dtos.contains(dto)) {
|
||||
// The effort of the worker is the sum of all efforts.
|
||||
EffortDuration effortWorker = EffortDuration.sum(current,
|
||||
EffortDuration.parseFromFormattedString((String) this
|
||||
|
|
@ -68,7 +71,7 @@ public class HoursWorkedPerWorkerScriptlet extends JRAbstractScriptlet {
|
|||
.parseFromFormattedString((String) this
|
||||
.getVariableValue("sumHoursPerDay")));
|
||||
this.setVariableValue("sumHoursPerDay", effort.toFormattedString());
|
||||
efforts.add(current);
|
||||
dtos.add(dto);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue