Use code instead of id for ResourceHoursService
Using code from now on in order to make it coherent with the rest of services. FEA: ItEr77S04BugFixing
This commit is contained in:
parent
237369faf9
commit
a8e57499af
3 changed files with 12 additions and 12 deletions
|
|
@ -111,7 +111,7 @@ public interface IWorkerDAO extends IIntegrationEntityDAO<Worker> {
|
||||||
List<Worker> findByFirstNameSecondNameAndNifAnotherTransaction(
|
List<Worker> findByFirstNameSecondNameAndNifAnotherTransaction(
|
||||||
String firstname, String surname, String nif);
|
String firstname, String surname, String nif);
|
||||||
|
|
||||||
List<Object[]> getWorkingHoursGroupedPerWorker(List<String> workerNifs,
|
List<Object[]> getWorkingHoursGroupedPerWorker(List<String> workerCodes,
|
||||||
Date startingDate, Date endingDate);
|
Date startingDate, Date endingDate);
|
||||||
|
|
||||||
Worker findByNifAnotherTransaction(String nif)
|
Worker findByNifAnotherTransaction(String nif)
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Object[]> getWorkingHoursGroupedPerWorker(
|
public List<Object[]> getWorkingHoursGroupedPerWorker(
|
||||||
List<String> workerNifs, Date startingDate, Date endingDate) {
|
List<String> workerCodes, Date startingDate, Date endingDate) {
|
||||||
String strQuery = "SELECT worker.nif, SUM(wrl.effort) "
|
String strQuery = "SELECT worker.code, SUM(wrl.effort) "
|
||||||
+ "FROM Worker worker, WorkReportLine wrl "
|
+ "FROM Worker worker, WorkReportLine wrl "
|
||||||
+ "LEFT OUTER JOIN wrl.resource resource "
|
+ "LEFT OUTER JOIN wrl.resource resource "
|
||||||
+ "WHERE resource.id = worker.id ";
|
+ "WHERE resource.id = worker.id ";
|
||||||
|
|
@ -165,15 +165,15 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set workers
|
// Set workers
|
||||||
if (workerNifs != null && !workerNifs.isEmpty()) {
|
if (workerCodes != null && !workerCodes.isEmpty()) {
|
||||||
strQuery += "AND worker.nif IN (:workerNifs) ";
|
strQuery += "AND worker.code IN (:workerCodes) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group by
|
// Group by
|
||||||
strQuery += "GROUP BY worker.nif ";
|
strQuery += "GROUP BY worker.code ";
|
||||||
|
|
||||||
// Order by
|
// Order by
|
||||||
strQuery += "ORDER BY worker.nif";
|
strQuery += "ORDER BY worker.code";
|
||||||
|
|
||||||
// Set parameters
|
// Set parameters
|
||||||
Query query = getSession().createQuery(strQuery);
|
Query query = getSession().createQuery(strQuery);
|
||||||
|
|
@ -183,8 +183,8 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
||||||
if (endingDate != null) {
|
if (endingDate != null) {
|
||||||
query.setParameter("endingDate", endingDate);
|
query.setParameter("endingDate", endingDate);
|
||||||
}
|
}
|
||||||
if (workerNifs != null && !workerNifs.isEmpty()) {
|
if (workerCodes != null && !workerCodes.isEmpty()) {
|
||||||
query.setParameterList("workerNifs", workerNifs);
|
query.setParameterList("workerCodes", workerCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get result
|
// Get result
|
||||||
|
|
|
||||||
|
|
@ -87,13 +87,13 @@ public class ResourceHoursServiceREST implements IResourceHoursService {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> workerNifs = null;
|
List<String> workerCodes = null;
|
||||||
if (resourceCode != null) {
|
if (resourceCode != null) {
|
||||||
workerNifs = Arrays.asList(resourceCode);
|
workerCodes = Arrays.asList(resourceCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object[]> hoursPerWorker = workerDAO
|
List<Object[]> hoursPerWorker = workerDAO
|
||||||
.getWorkingHoursGroupedPerWorker(workerNifs, startingDate,
|
.getWorkingHoursGroupedPerWorker(workerCodes, startingDate,
|
||||||
endingDate);
|
endingDate);
|
||||||
|
|
||||||
for (Object[] pair : hoursPerWorker) {
|
for (Object[] pair : hoursPerWorker) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue