diff --git a/business-services/egov-hrms/src/main/java/org/egov/hrms/service/EmployeeService.java b/business-services/egov-hrms/src/main/java/org/egov/hrms/service/EmployeeService.java index 2282fa671..b8d5bbb0d 100644 --- a/business-services/egov-hrms/src/main/java/org/egov/hrms/service/EmployeeService.java +++ b/business-services/egov-hrms/src/main/java/org/egov/hrms/service/EmployeeService.java @@ -222,7 +222,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ * @param criteria * @return */ - public List plainsearch(EmployeePlainSearchCriteria criteria) { + public List plainsearch(EmployeePlainSearchCriteria criteria,RequestInfo requestInfo) { if (criteria.getLimit() != null && criteria.getLimit() > propertiesManager.getHrmsMaxLimit()) criteria.setLimit(propertiesManager.getHrmsMaxLimit()); @@ -233,12 +233,31 @@ public List plainsearch(EmployeePlainSearchCriteria criteria) { else employeeIds = criteria.getUuids(); + EmployeePlainSearchCriteria employeePlainSearchCriteria = EmployeePlainSearchCriteria.builder().uuids(employeeIds).build(); + List employees=repository.fetchPlainSearchEmployees(employeePlainSearchCriteria); + + Map mapOfUsers = new HashMap(); + + if(!CollectionUtils.isEmpty(employeeIds)){ + Map UserSearchCriteria = new HashMap<>(); + UserSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_UUID,employeeIds); + if(mapOfUsers.isEmpty()){ + UserResponse userResponse = userService.getUser(requestInfo, UserSearchCriteria); + if(!CollectionUtils.isEmpty(userResponse.getUser())) { + mapOfUsers = userResponse.getUser().stream() + .collect(Collectors.toMap(User :: getUuid, Function.identity())); + } + } + for(Employee employee: employees){ + employee.setUser(mapOfUsers.get(employee.getUuid())); + } + } if(employeeIds.isEmpty()) return Collections.emptyList(); - EmployeePlainSearchCriteria employeePlainSearchCriteria = EmployeePlainSearchCriteria.builder().uuids(employeeIds).build(); - return repository.fetchPlainSearchEmployees(employeePlainSearchCriteria); + + return employees; } /** diff --git a/business-services/egov-hrms/src/main/java/org/egov/hrms/web/controller/EmployeeController.java b/business-services/egov-hrms/src/main/java/org/egov/hrms/web/controller/EmployeeController.java index e0a0ec2b7..8676b3878 100644 --- a/business-services/egov-hrms/src/main/java/org/egov/hrms/web/controller/EmployeeController.java +++ b/business-services/egov-hrms/src/main/java/org/egov/hrms/web/controller/EmployeeController.java @@ -151,10 +151,10 @@ private ResponseEntity countV1(@RequestParam("tenantId") String tenantId, @Re @PostMapping("/_plainsearch") @ResponseBody - private ResponseEntity plainsearch(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid EmployeePlainSearchCriteria criteria) { + private ResponseEntity plainsearch(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid EmployeePlainSearchCriteria criteria,@RequestBody RequestInfo requestInfo) { EmployeeResponse employeeResponse = EmployeeResponse.builder().responseInfo(factory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true)) - .employees(employeeService.plainsearch(criteria)).build(); + .employees(employeeService.plainsearch(criteria,requestInfo)).build(); return new ResponseEntity<>(employeeResponse,HttpStatus.OK); }