-
Notifications
You must be signed in to change notification settings - Fork 32
Bulk registration #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sushant-bizbrolly
merged 3 commits into
PSMRI:enhancement
from
toarunmishra:bulk_registration
Mar 13, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/com/iemr/admin/controller/bulkRegistration/BulkRegistrationController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package com.iemr.admin.controller.bulkRegistration; | ||
|
|
||
| import com.iemr.admin.repo.employeemaster.EmployeeMasterRepoo; | ||
| import com.iemr.admin.service.bulkRegistration.BulkRegistrationService; | ||
| import com.iemr.admin.service.bulkRegistration.BulkRegistrationServiceImpl; | ||
| import com.iemr.admin.service.bulkRegistration.EmployeeXmlService; | ||
| import com.iemr.admin.service.locationmaster.LocationMasterServiceInter; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.core.io.ClassPathResource; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| @RestController | ||
|
|
||
| public class BulkRegistrationController { | ||
| @Autowired | ||
| private EmployeeXmlService employeeXmlService; | ||
| @Autowired | ||
| BulkRegistrationServiceImpl bulkRegistrationServiceimpl; | ||
| private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); | ||
|
|
||
|
|
||
| @Autowired | ||
| BulkRegistrationService bulkRegistrationService; | ||
|
|
||
| @Autowired | ||
| private EmployeeMasterRepoo employeeMasterRepoo; | ||
| private Map<String, Object> errorResponse = new HashMap<>(); | ||
| @Autowired | ||
| private LocationMasterServiceInter locationMasterServiceInter; | ||
| private Map<String, Object> response = new HashMap<>(); | ||
|
|
||
|
|
||
| @RequestMapping(value = "/bulkRegistration",method = RequestMethod.POST,headers = "Authorization") | ||
| public ResponseEntity<Map<String, Object>> registerBulkUser(@RequestBody String m_user,@RequestHeader String authorization) throws Exception { | ||
| logger.info("Bulk registration request received. Request payload is omitted from logs."); | ||
| try { | ||
| bulkRegistrationService.registerBulkUser(m_user,authorization); | ||
| response.put("status","Success"); | ||
| response.put("statusCode",200); | ||
| response.put("totalUser",bulkRegistrationServiceimpl.totalEmployeeListSize); | ||
| response.put("registeredUser",bulkRegistrationServiceimpl.m_bulkUser.size()); | ||
| response.put("error",bulkRegistrationServiceimpl.errorLogs.toString()); | ||
|
|
||
| bulkRegistrationServiceimpl.m_bulkUser.clear(); | ||
| bulkRegistrationServiceimpl.m_UserDemographics.clear(); | ||
| bulkRegistrationServiceimpl.errorLogs.clear(); | ||
| bulkRegistrationServiceimpl.validationErrors.clear(); | ||
|
|
||
| } catch (Exception e) { | ||
| response.put("status","Fail"); | ||
| response.put("statusCode",500); | ||
| throw new RuntimeException(e); | ||
| } | ||
| return ResponseEntity.ok(response); | ||
|
|
||
| } | ||
| @Operation(description = "Download formatted Excel sheet") | ||
| @RequestMapping(value = {"/downloadExcelSheet"},method = {RequestMethod.GET},consumes = {"application/octet-stream"}) | ||
| public ResponseEntity<?> exportIntoExcelFile(){ | ||
|
|
||
| // Load the Excel file from resources | ||
| ClassPathResource excelFile = new ClassPathResource("xlsxfile/bulkuser_excel_sheet.xlsx"); | ||
|
|
||
| // Return the Excel file as a response with proper headers | ||
| return ResponseEntity.ok() | ||
| .contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) | ||
| .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + excelFile.getFilename() + "\"") | ||
| .body(excelFile); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package com.iemr.admin.data.bulkuser; | ||
|
|
||
| import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
| import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| @JacksonXmlRootElement(localName = "Employee") | ||
| public class Employee { | ||
|
|
||
| @JacksonXmlProperty(localName = "Title") | ||
| private String title; | ||
|
|
||
| @JacksonXmlProperty(localName = "FirstName") | ||
| private String firstName; | ||
|
|
||
| @JacksonXmlProperty(localName = "MiddleName") | ||
| private String middleName; | ||
|
|
||
| @JacksonXmlProperty(localName = "LastName") | ||
| private String lastName; | ||
|
|
||
| @JacksonXmlProperty(localName = "Gender") | ||
| private String gender; | ||
|
|
||
| @JacksonXmlProperty(localName = "ContactNo") | ||
| private String contactNo; | ||
|
|
||
| @JacksonXmlProperty(localName = "Designation") | ||
| private String designation; | ||
|
|
||
| @JacksonXmlProperty(localName = "EmergencyContactNo") | ||
| private String emergencyContactNo; | ||
|
|
||
| @JacksonXmlProperty(localName = "DOB") | ||
| private String dob; | ||
|
|
||
| @JacksonXmlProperty(localName = "Age") | ||
| private int age; | ||
|
|
||
| @JacksonXmlProperty(localName = "Email") | ||
| private String email; | ||
|
|
||
| @JacksonXmlProperty(localName = "MaritalStatus") | ||
| private String maritalStatus; | ||
|
|
||
| @JacksonXmlProperty(localName = "AadhaarNo") | ||
| private String aadhaarNo; | ||
|
|
||
| @JacksonXmlProperty(localName = "PAN") | ||
| private String pan; | ||
|
|
||
| @JacksonXmlProperty(localName = "Qualification") | ||
| private String qualification; | ||
|
|
||
| @JacksonXmlProperty(localName = "FatherName") | ||
| private String fatherName; | ||
|
|
||
| @JacksonXmlProperty(localName = "MotherName") | ||
| private String motherName; | ||
|
|
||
| @JacksonXmlProperty(localName = "Community") | ||
| private String community; | ||
|
|
||
| @JacksonXmlProperty(localName = "Religion") | ||
| private String religion; | ||
|
|
||
| @JacksonXmlProperty(localName = "AddressLine1") | ||
| private String addressLine1; | ||
|
|
||
| @JacksonXmlProperty(localName = "State") | ||
| private String state; | ||
|
|
||
| @JacksonXmlProperty(localName = "District") | ||
| private String district; | ||
|
|
||
| @JacksonXmlProperty(localName = "Pincode") | ||
| private String pincode; | ||
|
|
||
| @JacksonXmlProperty(localName = "PermanentAddressLine1") | ||
| private String permanentAddressLine1; | ||
|
|
||
| @JacksonXmlProperty(localName = "PermanentState") | ||
| private String permanentState; | ||
|
|
||
| @JacksonXmlProperty(localName = "PermanentDistrict") | ||
| private String permanentDistrict; | ||
|
|
||
| @JacksonXmlProperty(localName = "PermanentPincode") | ||
| private String permanentPincode; | ||
|
|
||
| @JacksonXmlProperty(localName = "DateOfJoining") | ||
| private String dateOfJoining; | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/iemr/admin/data/bulkuser/EmployeeList.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.iemr.admin.data.bulkuser; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | ||
| import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Data | ||
| @JacksonXmlRootElement(localName = "Employees") | ||
| public class EmployeeList { | ||
|
|
||
| @JsonProperty("Employee") | ||
| @JacksonXmlElementWrapper(useWrapping = false) // To avoid extra nested array in XML | ||
| private List<Employee> employees; | ||
| } |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/iemr/admin/service/bulkRegistration/BulkRegistrationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.iemr.admin.service.bulkRegistration; | ||
|
|
||
| public interface BulkRegistrationService { | ||
| void registerBulkUser(String user,String authorization); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
Avoid injecting both interface and implementation directly.
Having both
bulkRegistrationServiceandbulkRegistrationServiceimplfields may lead to confusion or inconsistent usage. Typically, you should stick to injecting the interface for a cleaner design.๐ Committable suggestion