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(
|
||||
String firstname, String surname, String nif);
|
||||
|
||||
List<Object[]> getWorkingHoursGroupedPerWorker(List<String> workerNifs,
|
||||
List<Object[]> getWorkingHoursGroupedPerWorker(List<String> workerCodes,
|
||||
Date startingDate, Date endingDate);
|
||||
|
||||
Worker findByNifAnotherTransaction(String nif)
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Object[]> getWorkingHoursGroupedPerWorker(
|
||||
List<String> workerNifs, Date startingDate, Date endingDate) {
|
||||
String strQuery = "SELECT worker.nif, SUM(wrl.effort) "
|
||||
List<String> workerCodes, Date startingDate, Date endingDate) {
|
||||
String strQuery = "SELECT worker.code, SUM(wrl.effort) "
|
||||
+ "FROM Worker worker, WorkReportLine wrl "
|
||||
+ "LEFT OUTER JOIN wrl.resource resource "
|
||||
+ "WHERE resource.id = worker.id ";
|
||||
|
|
@ -165,15 +165,15 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
|||
}
|
||||
|
||||
// Set workers
|
||||
if (workerNifs != null && !workerNifs.isEmpty()) {
|
||||
strQuery += "AND worker.nif IN (:workerNifs) ";
|
||||
if (workerCodes != null && !workerCodes.isEmpty()) {
|
||||
strQuery += "AND worker.code IN (:workerCodes) ";
|
||||
}
|
||||
|
||||
// Group by
|
||||
strQuery += "GROUP BY worker.nif ";
|
||||
strQuery += "GROUP BY worker.code ";
|
||||
|
||||
// Order by
|
||||
strQuery += "ORDER BY worker.nif";
|
||||
strQuery += "ORDER BY worker.code";
|
||||
|
||||
// Set parameters
|
||||
Query query = getSession().createQuery(strQuery);
|
||||
|
|
@ -183,8 +183,8 @@ public class WorkerDAO extends IntegrationEntityDAO<Worker>
|
|||
if (endingDate != null) {
|
||||
query.setParameter("endingDate", endingDate);
|
||||
}
|
||||
if (workerNifs != null && !workerNifs.isEmpty()) {
|
||||
query.setParameterList("workerNifs", workerNifs);
|
||||
if (workerCodes != null && !workerCodes.isEmpty()) {
|
||||
query.setParameterList("workerCodes", workerCodes);
|
||||
}
|
||||
|
||||
// Get result
|
||||
|
|
|
|||
|
|
@ -87,13 +87,13 @@ public class ResourceHoursServiceREST implements IResourceHoursService {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
List<String> workerNifs = null;
|
||||
List<String> workerCodes = null;
|
||||
if (resourceCode != null) {
|
||||
workerNifs = Arrays.asList(resourceCode);
|
||||
workerCodes = Arrays.asList(resourceCode);
|
||||
}
|
||||
|
||||
List<Object[]> hoursPerWorker = workerDAO
|
||||
.getWorkingHoursGroupedPerWorker(workerNifs, startingDate,
|
||||
.getWorkingHoursGroupedPerWorker(workerCodes, startingDate,
|
||||
endingDate);
|
||||
|
||||
for (Object[] pair : hoursPerWorker) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue