Fix ResourceWorkedHoursDTO that was not working properly

FEA: ItEr76S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-06-04 15:27:28 +02:00
parent 8cafa2ffde
commit 36e6952a80
3 changed files with 6 additions and 4 deletions

View file

@ -148,7 +148,7 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
@Transactional(readOnly = true)
public List<Object[]> getWorkingHoursGroupedPerWorker(
List<String> workerNifs, Date startingDate, Date endingDate) {
String strQuery = "SELECT worker.nif, SUM(wrl.numHours) "
String strQuery = "SELECT worker.nif, SUM(wrl.effort) "
+ "FROM Worker worker, WorkReportLine wrl "
+ "LEFT OUTER JOIN wrl.resource resource "
+ "WHERE resource.id = worker.id ";

View file

@ -36,12 +36,12 @@ public class ResourceWorkedHoursDTO {
public String resource;
@XmlAttribute
public Integer hours;
public String hours;
public ResourceWorkedHoursDTO() {
}
public ResourceWorkedHoursDTO(String resource, Integer hours) {
public ResourceWorkedHoursDTO(String resource, String hours) {
this.resource = resource;
this.hours = hours;
}

View file

@ -34,6 +34,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.libreplan.business.resources.daos.IWorkerDAO;
import org.libreplan.business.workingday.EffortDuration;
import org.libreplan.ws.resources.api.IResourceHoursService;
import org.libreplan.ws.resources.api.ResourceWorkedHoursDTO;
import org.libreplan.ws.resources.api.ResourceWorkedHoursListDTO;
@ -97,7 +98,8 @@ public class ResourceHoursServiceREST implements IResourceHoursService {
for (Object[] pair : hoursPerWorker) {
ResourceWorkedHoursDTO resourceWorkedHoursDTO = new ResourceWorkedHoursDTO(
(String) pair[0], ((Long) pair[1]).intValue());
(String) pair[0], EffortDuration.seconds(
((Long) pair[1]).intValue()).toFormattedString());
result.add(resourceWorkedHoursDTO);
}