Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6012397
added the total number of employee in search call
himanshukeshari-eGov Dec 20, 2024
ce97932
Added one preparedSTmList
himanshukeshari-eGov Dec 23, 2024
88cccd1
payment module changes
himanshukeshari-eGov Jan 30, 2025
7e73fe8
Added skills in hrms-create
himanshukeshari-eGov Feb 3, 2025
2498232
Mobile number validation changed to accept 8 digits
saiprakash-eGov Feb 14, 2025
89e6a62
Mobile number validation changed to accept 8 digits
saiprakash-eGov Feb 14, 2025
db2470d
Mobile number validation changed to accept 8 digits
saiprakash-eGov Feb 14, 2025
685703a
fix the code for adding the National Id in the family name column
himanshukeshari-eGov Mar 4, 2025
b4477d6
Merge pull request #1430 from egovernments/HDDF-2617
saiprakash-eGov Mar 4, 2025
073ada3
Added the userType in the additional fields
himanshukeshari-eGov Mar 12, 2025
986f2a6
Merge pull request #1446 from egovernments/HDDF-2724
saiprakash-eGov Mar 12, 2025
558bdde
Fix the userType in the additional fields
himanshukeshari-eGov Mar 13, 2025
128eba8
Merge pull request #1448 from egovernments/HDDF-2724-2
himanshukeshari-eGov Mar 13, 2025
77e07aa
Fix the userType in the additional fields
himanshukeshari-eGov Mar 13, 2025
43e311a
Merge pull request #1449 from egovernments/HDDF-2724-2
himanshukeshari-eGov Mar 13, 2025
f6415ba
Merge branch 'HCMPRE-2656-HCM-Services' into HDDF-2588-impl
arnob93 May 20, 2025
bfe44a9
Update model version in hrms
arnob93 May 20, 2025
c45f52a
fix bad import
arnob93 May 20, 2025
11d5f4c
Cleanup merge issue
arnob93 May 20, 2025
abb72dc
fix tenant replacement on search query
arnob93 May 21, 2025
f006ce9
additnal field null fix
vishal-egov May 23, 2025
cfc1dac
additnal field null fix
vishal-egov May 23, 2025
e04deaa
add tenantid in address for individual writes
arnob93 May 23, 2025
d4dd478
Capture bank details during HRMS create/update
arnob93 May 25, 2025
84144a7
handle mobile number as long
arnob93 May 26, 2025
5e8f769
Merge branch 'HCMPRE-2656-HCM-Services' into HDDF-2588-impl
arnob93 May 27, 2025
edf3903
resolve merge conflicts issues
arnob93 May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public String getEmployeeSearchQuery(EmployeeSearchCriteria criteria,List <Objec
addWhereClause(criteria, builder, preparedStmtList);
return paginationClause(criteria, builder, addPagination);
}
public String getEmployeeSearchQueryWithoutPagination(EmployeeSearchCriteria criteria,List <Object> preparedStmtList ) {
StringBuilder builder = new StringBuilder(EmployeeQueries.HRMS_GET_EMPLOYEES);
builder = new StringBuilder(String.format(String.valueOf(builder), SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING ,SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING,
SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING, SCHEMA_REPLACE_STRING));
addWhereClause(criteria, builder, preparedStmtList);
return builder.toString();
}

public String getEmployeeCountQuery(String tenantId, List <Object> preparedStmtList ) {
StringBuilder builder = new StringBuilder(EmployeeQueries.HRMS_COUNT_EMP_QUERY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.egov.common.utils.MultiStateInstanceUtil;
import org.egov.hrms.utils.ErrorConstants;
import org.egov.hrms.utils.HRMSUtils;
import org.egov.hrms.web.contract.EmployeeCountResponse;
import org.egov.hrms.web.contract.EmployeeSearchCriteria;
import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -27,10 +28,10 @@
public class EmployeeRepository {
@Autowired
private EmployeeQueryBuilder queryBuilder;

@Autowired
private JdbcTemplate jdbcTemplate;

@Autowired
private EmployeeRowMapper rowMapper;

Expand All @@ -42,32 +43,29 @@ public class EmployeeRepository {

@Autowired
private MultiStateInstanceUtil multiStateInstanceUtil;

/**
* DB Repository that makes jdbc calls to the db and fetches employees.
*
* @param criteria
* @param requestInfo
* @return
*/
public Map<String, Object> fetchEmployees(EmployeeSearchCriteria criteria, RequestInfo requestInfo){
Long totalCount = 0L;
public EmployeeCountResponse fetchEmployees(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
// Get the tenantId from the criteria
String tenantId = criteria.getTenantId();
Long totalCount = 0L;
List<Employee> employees = new ArrayList<>();
List<Object> preparedStmtList = new ArrayList<>();
List<Object> preparedStmtListWithOutLimitAndOffset = new ArrayList<>();
Map<String, Object> response = new HashMap<>();
if(hrmsUtils.isAssignmentSearchReqd(criteria)) {
if (hrmsUtils.isAssignmentSearchReqd(criteria)) {
List<String> empUuids = fetchEmployeesforAssignment(criteria, requestInfo);
if (CollectionUtils.isEmpty(empUuids)) {
response.put("employees", employees);
response.put("totalCount", totalCount);
return response;
}
if (CollectionUtils.isEmpty(empUuids))
return new EmployeeCountResponse(employees, 0);
else {
if(!CollectionUtils.isEmpty(criteria.getUuids()))
criteria.setUuids(criteria.getUuids().stream().filter(empUuids::contains).collect(Collectors.toList()));
if (!CollectionUtils.isEmpty(criteria.getUuids()))
criteria.setUuids(
criteria.getUuids().stream().filter(empUuids::contains).collect(Collectors.toList()));
else
criteria.setUuids(empUuids);
}
Expand All @@ -76,55 +74,62 @@ public Map<String, Object> fetchEmployees(EmployeeSearchCriteria criteria, Reque
List<String> empUuids = fetchUnassignedEmployees(criteria, requestInfo);
criteria.setUuids(empUuids);
}

// Build queries for employee search
String query = queryBuilder.getEmployeeSearchQuery(criteria, preparedStmtList, true);
String queryWithOutLimitAndOffset = queryBuilder.getEmployeeSearchQuery(criteria, preparedStmtListWithOutLimitAndOffset , false);
String queryWithOutLimitAndOffset = queryBuilder.getEmployeeSearchQuery(criteria,
preparedStmtListWithOutLimitAndOffset, false);
// Wrap query construction in try-catch to handle invalid tenant scenarios gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query, tenantId);
queryWithOutLimitAndOffset = multiStateInstanceUtil.replaceSchemaPlaceholder(queryWithOutLimitAndOffset, tenantId);
queryWithOutLimitAndOffset = multiStateInstanceUtil.replaceSchemaPlaceholder(queryWithOutLimitAndOffset,
tenantId);
} catch (InvalidTenantIdException e) {
throw new CustomException(ErrorConstants.TENANT_ID_EXCEPTION, e.getMessage());
}

// Excecute query
try {
employees = jdbcTemplate.query(query, preparedStmtList.toArray(),rowMapper);
totalCount = jdbcTemplate.query(queryWithOutLimitAndOffset, preparedStmtList.toArray(),rowMapper).spliterator().getExactSizeIfKnown();
}catch(Exception e) {
log.error("Exception while making the db call: ",e);
log.error("query; "+query);
employees = jdbcTemplate.query(query, preparedStmtList.toArray(), rowMapper);
totalCount = jdbcTemplate.query(queryWithOutLimitAndOffset, preparedStmtList.toArray(), rowMapper)
.spliterator().getExactSizeIfKnown();
} catch (Exception e) {
log.error("Exception while making the db call: ", e);
log.error("query; " + query);
}
response.put("employees", employees);
response.put("totalCount", totalCount);
return response;
return new EmployeeCountResponse(employees, totalCount.intValue());
}

private List<String> fetchUnassignedEmployees(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
List<String> employeesIds = new ArrayList<>();
List <Object> preparedStmtList = new ArrayList<>();
List<Object> preparedStmtList = new ArrayList<>();
// Get the tenantId from the criteria
String tenantId = criteria.getTenantId();
String query = queryBuilder.getUnassignedEmployeesSearchQuery(criteria, preparedStmtList);
// Wrap query construction in try-catch to handle invalid tenant scenarios gracefully
// Wrap query construction in try-catch to handle invalid tenant scenarios
// gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query,tenantId);
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query, tenantId);
} catch (InvalidTenantIdException e) {
throw new CustomException(ErrorConstants.TENANT_ID_EXCEPTION, e.getMessage());
}
try {
employeesIds = jdbcTemplate.queryForList(query, preparedStmtList.toArray(),String.class);
}catch(Exception e) {
log.error("Exception while making the db call: ",e);
log.error("query; "+query);
employeesIds = jdbcTemplate.queryForList(query, preparedStmtList.toArray(), String.class);
} catch (Exception e) {
log.error("Exception while making the db call: ", e);
log.error("query; " + query);
}
return employeesIds;
}

private List<String> fetchEmployeesforAssignment(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
List<String> employeesIds = new ArrayList<>();
List <Object> preparedStmtList = new ArrayList<>();
List<Object> preparedStmtList = new ArrayList<>();
// Get the tenantId from the criteria
String tenantId = criteria.getTenantId();
String query = queryBuilder.getAssignmentSearchQuery(criteria, preparedStmtList);
// Wrap query construction in try-catch to handle invalid tenant scenarios gracefully
// Wrap query construction in try-catch to handle invalid tenant scenarios
// gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query, tenantId);
} catch (InvalidTenantIdException e) {
Expand All @@ -133,10 +138,10 @@ private List<String> fetchEmployeesforAssignment(EmployeeSearchCriteria criteria

try {

employeesIds = jdbcTemplate.queryForList(query, preparedStmtList.toArray(),String.class);
}catch(Exception e) {
log.error("Exception while making the db call: ",e);
log.error("query; "+query);
employeesIds = jdbcTemplate.queryForList(query, preparedStmtList.toArray(), String.class);
} catch (Exception e) {
log.error("Exception while making the db call: ", e);
log.error("query; " + query);
}
return employeesIds;

Expand All @@ -148,20 +153,21 @@ private List<String> fetchEmployeesforAssignment(EmployeeSearchCriteria criteria
* @param tenantId
* @return
*/
public Long fetchPosition(String tenantId){
public Long fetchPosition(String tenantId) {
String query = queryBuilder.getPositionSeqQuery();
Long id = null;
// Wrap query construction in try-catch to handle invalid tenant scenarios gracefully
// Wrap query construction in try-catch to handle invalid tenant scenarios
// gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder( query, tenantId);
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query, tenantId);
} catch (InvalidTenantIdException e) {
throw new CustomException(ErrorConstants.TENANT_ID_EXCEPTION, e.getMessage());
}
try {
id = jdbcTemplate.queryForObject(query, Long.class);
}catch(Exception e) {
log.error("Exception while making the db call: ",e);
log.error("query; "+query);
} catch (Exception e) {
log.error("Exception while making the db call: ", e);
log.error("query; " + query);
}
return id;
}
Expand All @@ -172,23 +178,24 @@ public Long fetchPosition(String tenantId){
* @param tenantId
* @return
*/
public Map<String,String> fetchEmployeeCount(String tenantId){
Map<String,String> response = new HashMap<>();
public Map<String, String> fetchEmployeeCount(String tenantId) {
Map<String, String> response = new HashMap<>();
List<Object> preparedStmtList = new ArrayList<>();

String query = queryBuilder.getEmployeeCountQuery(tenantId, preparedStmtList);
log.info("query; "+query);
// Wrap query construction in try-catch to handle invalid tenant scenarios gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder( query, tenantId);
} catch (InvalidTenantIdException e) {
throw new CustomException(ErrorConstants.TENANT_ID_EXCEPTION, e.getMessage());
}
try {
response=jdbcTemplate.query(query, preparedStmtList.toArray(),countRowMapper);
}catch(Exception e) {
log.error("Exception while making the db call: ",e);
log.error("query; "+query);
log.info("query; " + query);
// Wrap query construction in try-catch to handle invalid tenant scenarios
// gracefully
try {
query = multiStateInstanceUtil.replaceSchemaPlaceholder(query, tenantId);
} catch (InvalidTenantIdException e) {
throw new CustomException(ErrorConstants.TENANT_ID_EXCEPTION, e.getMessage());
}
try {
response = jdbcTemplate.query(query, preparedStmtList.toArray(), countRowMapper);
} catch (Exception e) {
log.error("Exception while making the db call: ", e);
log.error("query; " + query);
}
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,10 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
}
}
List <Employee> employees = new ArrayList<>();
if(!((!CollectionUtils.isEmpty(criteria.getRoles()) || !CollectionUtils.isEmpty(criteria.getNames()) || !StringUtils.isEmpty(criteria.getPhone())) && CollectionUtils.isEmpty(criteria.getUuids()))) {
Map<String, Object> response = repository.fetchEmployees(criteria, requestInfo);
// Extract the List<Employee> and total count from the map
employees = (List<Employee>) response.get("employees");
totalCount = (Long) response.get("totalCount");
}
EmployeeCountResponse employeeCountResponse=new EmployeeCountResponse();
if(!((!CollectionUtils.isEmpty(criteria.getRoles()) || !CollectionUtils.isEmpty(criteria.getNames()) || !StringUtils.isEmpty(criteria.getPhone())) && CollectionUtils.isEmpty(criteria.getUuids())))
employeeCountResponse = repository.fetchEmployees(criteria, requestInfo);
employees=employeeCountResponse.getEmployees();
List<String> uuids = employees.stream().map(Employee :: getUuid).collect(Collectors.toList());
// If the uuids list is not empty, filter the employees list to include only those with matching UUIDs
if(userChecked && !propertiesManager.isCentralInstance) {
Expand All @@ -262,8 +260,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
}
}
return EmployeeResponse.builder().responseInfo(factory.createResponseInfoFromRequestInfo(requestInfo, true))
.employees(employees)
.totalCount(totalCount).build();
.employees(employees).count(employeeCountResponse.getCount()).build();
}


Expand Down
Loading
Loading