@ -58,7 +58,6 @@ public class NulmAPIController {
this . nulmJdbcTemplate = new JdbcTemplate ( dataSource ) ;
}
@GetMapping ( "/getYear" )
public ResponseEntity < List < Map < String , Object > > > getYear ( ) {
List < Map < String , Object > > yearList = nulmService . getYearList ( ) ;
@ -85,7 +84,6 @@ public class NulmAPIController {
return ResponseEntity . ok ( divisionList ) ;
}
@PostMapping ( "/saveGroup" )
public ResponseEntity < String > saveSchemeGroup ( @RequestBody Map < String , Object > payload ) {
try {
@ -96,19 +94,22 @@ public class NulmAPIController {
return ResponseEntity . status ( 500 ) . body ( "Error saving Scheme Group: " + e . getMessage ( ) ) ;
}
}
/ *
@PostMapping ( "/saveOrder" )
public ResponseEntity < String > saveOrderDetails ( @RequestBody Map < String , Object > payload ) {
try {
Map < String , Object > orderData = new HashMap < > ( payload ) ;
nulmService . saveOrderDetails ( orderData ) ;
return ResponseEntity . ok ( "Order saved successfully." ) ;
} catch ( IllegalArgumentException e ) {
return ResponseEntity . badRequest ( ) . body ( "Invalid data: " + e . getMessage ( ) ) ;
} catch ( Exception e ) {
return ResponseEntity . status ( 500 ) . body ( "Error saving order: " + e . getMessage ( ) ) ;
}
}
* @PostMapping ( "/saveOrder" )
* public ResponseEntity < String > saveOrderDetails ( @RequestBody Map < String ,
* Object > payload ) {
* try {
* Map < String , Object > orderData = new HashMap < > ( payload ) ;
* nulmService . saveOrderDetails ( orderData ) ;
* return ResponseEntity . ok ( "Order saved successfully." ) ;
* } catch ( IllegalArgumentException e ) {
* return ResponseEntity . badRequest ( ) . body ( "Invalid data: " + e . getMessage ( ) ) ;
* } catch ( Exception e ) {
* return ResponseEntity . status ( 500 ) . body ( "Error saving order: " +
* e . getMessage ( ) ) ;
* }
* }
* /
@PostMapping ( "/saveStaff" )
public ResponseEntity < String > saveStaffDetails ( @RequestBody Map < String , Object > payload ) {
@ -142,9 +143,11 @@ public class NulmAPIController {
if ( orderDetails ! = null ) {
/ / Step 2 : Build the SQL for updating enrollments with dynamic IN clause
StringBuilder updateSql = new StringBuilder ( "UPDATE enrollment_table SET order_id = ?, appointed = 'Yes', facial_attendance = 'No', incharge_phoneno = ?, designation = ?, appointed_date = CURRENT_DATE WHERE enrollment_id IN (" ) ;
StringBuilder updateSql = new StringBuilder (
"UPDATE enrollment_table SET order_id = ?, appointed = 'Yes', facial_attendance = 'No', incharge_phoneno = ?, designation = ?, appointed_date = CURRENT_DATE WHERE enrollment_id IN (" ) ;
/ / Add placeholders for the IN clause based on the size of the enrollmentIds list
/ / Add placeholders for the IN clause based on the size of the enrollmentIds
/ / list
for ( int i = 0 ; i < enrollmentIds . size ( ) ; i + + ) {
updateSql . append ( "?" ) ;
if ( i < enrollmentIds . size ( ) - 1 ) {
@ -153,7 +156,8 @@ public class NulmAPIController {
}
updateSql . append ( ")" ) ;
/ / Combine the orderId , inchargePhoneno , designation , and the list of enrollmentIds
/ / Combine the orderId , inchargePhoneno , designation , and the list of
/ / enrollmentIds
List < Object > parameters = new ArrayList < > ( ) ;
parameters . add ( orderId ) ;
parameters . add ( inchargePhoneno ) ;
@ -166,7 +170,8 @@ public class NulmAPIController {
return new ResponseEntity < > ( "Order assigned to enrollments and appointed successfully." , HttpStatus . OK ) ;
} catch ( DataAccessException e ) {
/ / Handle any data access exceptions
return new ResponseEntity < > ( "Error updating enrollments: " + e . getMessage ( ) , HttpStatus . INTERNAL_SERVER_ERROR ) ;
return new ResponseEntity < > ( "Error updating enrollments: " + e . getMessage ( ) ,
HttpStatus . INTERNAL_SERVER_ERROR ) ;
}
}
@ -191,9 +196,11 @@ public class NulmAPIController {
if ( orderDetails ! = null ) {
/ / Step 2 : Build the SQL for updating enrollments with dynamic IN clause
StringBuilder updateSql = new StringBuilder ( "UPDATE enrollment_table SET appointed = 'Drop', dropout = 'Yes', dropout_date = CURRENT_DATE WHERE enrollment_id IN (" ) ;
StringBuilder updateSql = new StringBuilder (
"UPDATE enrollment_table SET appointed = 'Drop', dropout = 'Yes', dropout_date = CURRENT_DATE WHERE enrollment_id IN (" ) ;
/ / Add placeholders for the IN clause based on the size of the enrollmentIds list
/ / Add placeholders for the IN clause based on the size of the enrollmentIds
/ / list
for ( int i = 0 ; i < enrollmentIds . size ( ) ; i + + ) {
updateSql . append ( "?" ) ;
if ( i < enrollmentIds . size ( ) - 1 ) {
@ -210,13 +217,15 @@ public class NulmAPIController {
try {
int rowsAffected = nulmJdbcTemplate . update ( updateSql . toString ( ) , parameters . toArray ( ) ) ;
if ( rowsAffected > 0 ) {
return new ResponseEntity < > ( "Order assigned to enrollments has been Dropout successfully." , HttpStatus . OK ) ;
return new ResponseEntity < > ( "Order assigned to enrollments has been Dropout successfully." ,
HttpStatus . OK ) ;
} else {
return new ResponseEntity < > ( "No matching records found to update." , HttpStatus . NOT_FOUND ) ;
}
} catch ( DataAccessException e ) {
/ / Handle any data access exceptions
return new ResponseEntity < > ( "Error updating enrollments: " + e . getMessage ( ) , HttpStatus . INTERNAL_SERVER_ERROR ) ;
return new ResponseEntity < > ( "Error updating enrollments: " + e . getMessage ( ) ,
HttpStatus . INTERNAL_SERVER_ERROR ) ;
}
}
@ -292,7 +301,8 @@ public class NulmAPIController {
return ResponseEntity . ok ( counts ) ;
} catch ( Exception e ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( null ) ; / / You can also return the error message
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( null ) ; / / You can also return the error
/ / message
}
}
@ -303,7 +313,8 @@ public class NulmAPIController {
if ( result > 0 ) {
return ResponseEntity . ok ( "Employee marked as absent successfully." ) ;
} else {
return ResponseEntity . status ( 304 ) . body ( "No update made. Employee may already be marked as absent or has attended." ) ;
return ResponseEntity . status ( 304 )
. body ( "No update made. Employee may already be marked as absent or has attended." ) ;
}
}
@ -334,7 +345,6 @@ public class NulmAPIController {
}
}
@GetMapping ( "/getAllOrderDetails" )
public ResponseEntity < List < Map < String , Object > > > getAllOrderDetails ( ) {
try {
@ -351,7 +361,6 @@ public class NulmAPIController {
return ResponseEntity . ok ( counts ) ;
}
@GetMapping ( "/dropOutCounts" )
public ResponseEntity < Map < String , Integer > > getDropCounts ( @RequestParam int orderId ) {
Map < String , Integer > counts = nulmService . getDropCounts ( orderId ) ;
@ -377,7 +386,8 @@ public class NulmAPIController {
}
@GetMapping ( "/getEnrollmentdeatilsByID/{enrollmentId}" )
public ResponseEntity < List < Map < String , Object > > > getEnrollmentsById ( @PathVariable ( "enrollmentId" ) int enrollmentId ) {
public ResponseEntity < List < Map < String , Object > > > getEnrollmentsById (
@PathVariable ( "enrollmentId" ) int enrollmentId ) {
List < Map < String , Object > > enrollments = nulmService . getEnrollmentsById ( enrollmentId ) ;
if ( enrollments . isEmpty ( ) ) {
@ -454,8 +464,7 @@ public class NulmAPIController {
order_copy_url ,
order_generated_by ,
category ,
validity_date
) ;
validity_date ) ;
return ResponseEntity . ok ( "Order saved successfully with order number: " + savedOrderNumber ) ;
@ -465,23 +474,34 @@ public class NulmAPIController {
}
}
/ *
@GetMapping ( "/staffInititeadList" )
public ResponseEntity < List < Map < String , Object > > > getAttendanceWithInitiatedSalaryByGroupId ( @RequestParam ( "inchargeName" ) String inchargeName ,
@RequestParam ( "month" ) String month ) {
List < Map < String , Object > > staffList = nulmService . getAttendanceWithInitiatedSalary ( inchargeName , month ) ;
return ResponseEntity . ok ( staffList ) ;
}
@GetMapping ( "/staffInititeadList" )
public ResponseEntity < List < Map < String , Object > > > getAttendanceWithInitiatedSalaryByGroupId (
@RequestParam ( value = "inchargeId" , required = false ) String inchargeId ,
@RequestParam ( value = "month" , required = false ) String month ,
@RequestParam ( value = "inchargeName" , required = false ) String inchargeName ,
@RequestParam ( value = "zone" , required = false ) Integer zone ) {
List < Map < String , Object > > staffList = nulmService . getAttendanceWithInitiatedSalary ( inchargeId , month , inchargeName , zone ) ;
return ResponseEntity . ok ( staffList ) ;
}
* @GetMapping ( "/staffInititeadList" )
* public ResponseEntity < List < Map < String , Object > > >
* getAttendanceWithInitiatedSalaryByGroupId ( @RequestParam ( "inchargeName" )
* String inchargeName ,
*
* @RequestParam ( "month" ) String month ) {
* List < Map < String , Object > > staffList =
* nulmService . getAttendanceWithInitiatedSalary ( inchargeName , month ) ;
* return ResponseEntity . ok ( staffList ) ;
* }
*
* @GetMapping ( "/staffInititeadList" )
* public ResponseEntity < List < Map < String , Object > > >
* getAttendanceWithInitiatedSalaryByGroupId (
*
* @RequestParam ( value = "inchargeId" , required = false ) String inchargeId ,
*
* @RequestParam ( value = "month" , required = false ) String month ,
*
* @RequestParam ( value = "inchargeName" , required = false ) String inchargeName ,
*
* @RequestParam ( value = "zone" , required = false ) Integer zone ) {
*
* List < Map < String , Object > > staffList =
* nulmService . getAttendanceWithInitiatedSalary ( inchargeId , month , inchargeName ,
* zone ) ;
* return ResponseEntity . ok ( staffList ) ;
* }
* /
@GetMapping ( "/staffInititeadList" )
@ -492,50 +512,59 @@ public class NulmAPIController {
@RequestParam ( value = "incharge_name" , required = false ) String inchargeName ,
@RequestParam ( value = "enrollmentIds" , required = false ) List < Integer > enrollmentIds ) {
List < Map < String , Object > > staffList = nulmService . getAttendanceWithInitiatedSalary ( inchargeId , month , year , inchargeName , enrollmentIds ) ;
List < Map < String , Object > > staffList = nulmService . getAttendanceWithInitiatedSalary ( inchargeId , month , year ,
inchargeName , enrollmentIds ) ;
return ResponseEntity . ok ( staffList ) ;
}
/ *
@PostMapping ( "/salaryDetailUpdate" )
public ResponseEntity < String > addSalaryDetails ( @RequestBody List < Map < String , Object > > requestList ) {
System . out . println ( "Received POST request with data: " + requestList ) ;
try {
for ( Map < String , Object > request : requestList ) {
int totalDaysPresent = Integer . parseInt ( request . get ( "total_days_present" ) . toString ( ) ) ;
int totalDaysOd = Integer . parseInt ( request . get ( "total_days_od" ) . toString ( ) ) ;
int totalDaysSalary = Integer . parseInt ( request . get ( "total_days_salary" ) . toString ( ) ) ;
int totalDaysAbsent = Integer . parseInt ( request . get ( "total_days_absent" ) . toString ( ) ) ;
String month = request . get ( "month" ) . toString ( ) ;
int year = Integer . parseInt ( request . get ( "year" ) . toString ( ) ) ;
int salaryAmount = Integer . parseInt ( request . get ( "salary_amount" ) . toString ( ) ) ;
int enrollmentId = Integer . parseInt ( request . get ( "enrollment_id" ) . toString ( ) ) ;
int groupId = Integer . parseInt ( request . get ( "group_id" ) . toString ( ) ) ;
int wageId = Integer . parseInt ( request . get ( "wage_id" ) . toString ( ) ) ;
/ / Check if the month and year are valid for salary initiation ( past month )
if ( isFutureOrCurrentMonth ( month , year ) ) {
return ResponseEntity . status ( HttpStatus . BAD_REQUEST )
. body ( "Salary cannot be initiated for the current or future months. Please select a past month." ) ;
}
String salaryStatus = "Initiated" ;
/ / Call the service method to insert the salary details
int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ) ;
if ( rowsAffected < = 0 ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
}
}
return ResponseEntity . status ( HttpStatus . CREATED )
. body ( "Salary details added successfully for all selected entries." ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ; / / Log the exception for debugging
return ResponseEntity . status ( HttpStatus . BAD_REQUEST )
. body ( "Invalid request data: " + e . getMessage ( ) ) ;
}
}
/ *
* @PostMapping ( "/salaryDetailUpdate" )
* public ResponseEntity < String > addSalaryDetails ( @RequestBody List < Map < String ,
* Object > > requestList ) {
* System . out . println ( "Received POST request with data: " + requestList ) ;
* try {
* for ( Map < String , Object > request : requestList ) {
* int totalDaysPresent =
* Integer . parseInt ( request . get ( "total_days_present" ) . toString ( ) ) ;
* int totalDaysOd = Integer . parseInt ( request . get ( "total_days_od" ) . toString ( ) ) ;
* int totalDaysSalary =
* Integer . parseInt ( request . get ( "total_days_salary" ) . toString ( ) ) ;
* int totalDaysAbsent =
* Integer . parseInt ( request . get ( "total_days_absent" ) . toString ( ) ) ;
* String month = request . get ( "month" ) . toString ( ) ;
* int year = Integer . parseInt ( request . get ( "year" ) . toString ( ) ) ;
* int salaryAmount = Integer . parseInt ( request . get ( "salary_amount" ) . toString ( ) ) ;
* int enrollmentId = Integer . parseInt ( request . get ( "enrollment_id" ) . toString ( ) ) ;
* int groupId = Integer . parseInt ( request . get ( "group_id" ) . toString ( ) ) ;
* int wageId = Integer . parseInt ( request . get ( "wage_id" ) . toString ( ) ) ;
*
* / / Check if the month and year are valid for salary initiation ( past month )
* if ( isFutureOrCurrentMonth ( month , year ) ) {
* return ResponseEntity . status ( HttpStatus . BAD_REQUEST )
* . body ( "Salary cannot be initiated for the current or future months. Please select a past month."
* ) ;
* }
*
* String salaryStatus = "Initiated" ;
*
* / / Call the service method to insert the salary details
* int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent ,
* totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount ,
* salaryStatus , enrollmentId , groupId , wageId ) ;
*
* if ( rowsAffected < = 0 ) {
* return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
* . body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
* }
* }
* return ResponseEntity . status ( HttpStatus . CREATED )
* . body ( "Salary details added successfully for all selected entries." ) ;
* } catch ( Exception e ) {
* e . printStackTrace ( ) ; / / Log the exception for debugging
* return ResponseEntity . status ( HttpStatus . BAD_REQUEST )
* . body ( "Invalid request data: " + e . getMessage ( ) ) ;
* }
* }
* /
@PostMapping ( "/salaryDetailUpdate" )
public ResponseEntity < String > addSalaryDetails ( @RequestBody List < Map < String , Object > > requestList ) {
@ -555,7 +584,6 @@ public class NulmAPIController {
int wageId = Integer . parseInt ( request . get ( "wage_id" ) . toString ( ) ) ;
int inchargeID = 0 ; / / Integer . parseInt ( "" + request . get ( "incharge_id" ) ) ;
/ / Check if the month and year are valid for salary initiation ( past month )
if ( isFutureOrCurrentMonth ( month , year ) ) {
return ResponseEntity . status ( HttpStatus . BAD_REQUEST )
@ -570,13 +598,17 @@ public class NulmAPIController {
if ( ! checkexist ) {
/ / Call the service method to insert the salary details
int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId , inchargeID ) ;
int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary ,
totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ,
inchargeID ) ;
if ( rowsAffected < = 0 ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
}
} else {
int rowsAffected = nulmService . updateSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId , inchargeID ) ;
int rowsAffected = nulmService . updateSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary ,
totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ,
inchargeID ) ;
if ( rowsAffected < = 0 ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "Failed to update salary details for enrollment ID: " + enrollmentId ) ;
@ -600,7 +632,8 @@ public class NulmAPIController {
int currentYear = currentDate . getYear ( ) ;
/ / Convert the string month from the request to Month enum
Month requestMonth = Month . valueOf ( month . toUpperCase ( ) ) ; / / Ensure that month is passed in capitalized format like "JANUARY" , "FEBRUARY" , etc .
Month requestMonth = Month . valueOf ( month . toUpperCase ( ) ) ; / / Ensure that month is passed in capitalized format
/ / like "JANUARY" , "FEBRUARY" , etc .
/ / Compare the request month and year with the current date
if ( year > currentYear ) {
@ -612,14 +645,18 @@ public class NulmAPIController {
}
/ / @PostMapping ( "/salaryDetailUpdate" )
/ / public ResponseEntity < String > addSalaryDetails ( @RequestBody List < Map < String , Object > > requestList ) {
/ / public ResponseEntity < String > addSalaryDetails ( @RequestBody List < Map < String ,
/ / Object > > requestList ) {
/ / System . out . println ( "Received POST request with data: " + requestList ) ;
/ / try {
/ / for ( Map < String , Object > request : requestList ) {
/ / int totalDaysPresent = Integer . parseInt ( request . get ( "total_days_present" ) . toString ( ) ) ;
/ / int totalDaysPresent =
/ / Integer . parseInt ( request . get ( "total_days_present" ) . toString ( ) ) ;
/ / int totalDaysOd = Integer . parseInt ( request . get ( "total_days_od" ) . toString ( ) ) ;
/ / int totalDaysSalary = Integer . parseInt ( request . get ( "total_days_salary" ) . toString ( ) ) ;
/ / int totalDaysAbsent = Integer . parseInt ( request . get ( "total_days_absent" ) . toString ( ) ) ;
/ / int totalDaysSalary =
/ / Integer . parseInt ( request . get ( "total_days_salary" ) . toString ( ) ) ;
/ / int totalDaysAbsent =
/ / Integer . parseInt ( request . get ( "total_days_absent" ) . toString ( ) ) ;
/ / String month = request . get ( "month" ) . toString ( ) ;
/ / int year = Integer . parseInt ( request . get ( "year" ) . toString ( ) ) ;
/ / int salaryAmount = Integer . parseInt ( request . get ( "salary_amount" ) . toString ( ) ) ;
@ -630,16 +667,21 @@ public class NulmAPIController {
/ / String salaryStatus = "Initiated" ;
/ /
/ / / / Call the service method to insert the salary details
/ / int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ) ;
/ / int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent ,
/ / totalDaysOd , totalDaysSalary , totalDaysAbsent , month , year , salaryAmount ,
/ / salaryStatus , enrollmentId , groupId , wageId ) ;
/ /
/ / if ( rowsAffected < = 0 ) {
/ / return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
/ / return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( " Failed
/ / to add salary details for enrollment ID : " + enrollmentId ) ;
/ / }
/ / }
/ / return ResponseEntity . status ( HttpStatus . CREATED ) . body ( "Salary details added successfully for all selected entries." ) ;
/ / return ResponseEntity . status ( HttpStatus . CREATED ) . body ( " Salary details added
/ / successfully for all selected entries . " ) ;
/ / } catch ( Exception e ) {
/ / e . printStackTrace ( ) ; / / Log the exception for debugging
/ / return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "Invalid request data: " + e . getMessage ( ) ) ;
/ / return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( " Invalid request
/ / data : " + e . getMessage ( ) ) ;
/ / }
/ / }
@ -657,28 +699,35 @@ public class NulmAPIController {
/*************** API For Mobile Application *********************************/
/ *
@GetMapping ( "/attendanceWithSalary" )
public ResponseEntity < List < Map < String , Object > > > getAttendanceWithSalaryByInchargeId (
@RequestParam ( value = "month" , required = false ) String month ,
@RequestParam ( value = "year" , required = false ) Integer year ,
@RequestParam ( value = "incharge_id" , required = false ) Integer inchargeId ) {
try {
/ / Call the service method to fetch the data
List < Map < String , Object > > attendanceWithSalary = nulmService . getAttendanceWithSalaryByInchargeId ( month , year , inchargeId ) ;
/ / If no data is found , return a NOT FOUND response
if ( attendanceWithSalary . isEmpty ( ) ) {
return ResponseEntity . status ( 404 ) . body ( List . of ( Map . of ( "error" , "No attendance records found for the specified parameters." ) ) ) ;
}
/ / Return the data in the response
return ResponseEntity . ok ( attendanceWithSalary ) ;
} catch ( Exception ex ) {
/ / Return a 500 Internal Server Error with the error message
return ResponseEntity . status ( 500 ) . body ( List . of ( Map . of ( "error" , "An error occurred while fetching attendance data: " + ex . getMessage ( ) ) ) ) ;
}
}
* @GetMapping ( "/attendanceWithSalary" )
* public ResponseEntity < List < Map < String , Object > > >
* getAttendanceWithSalaryByInchargeId (
*
* @RequestParam ( value = "month" , required = false ) String month ,
*
* @RequestParam ( value = "year" , required = false ) Integer year ,
*
* @RequestParam ( value = "incharge_id" , required = false ) Integer inchargeId ) {
*
* try {
* / / Call the service method to fetch the data
* List < Map < String , Object > > attendanceWithSalary =
* nulmService . getAttendanceWithSalaryByInchargeId ( month , year , inchargeId ) ;
*
* / / If no data is found , return a NOT FOUND response
* if ( attendanceWithSalary . isEmpty ( ) ) {
* return ResponseEntity . status ( 404 ) . body ( List . of ( Map . of ( "error" ,
* "No attendance records found for the specified parameters." ) ) ) ;
* }
*
* / / Return the data in the response
* return ResponseEntity . ok ( attendanceWithSalary ) ;
* } catch ( Exception ex ) {
* / / Return a 500 Internal Server Error with the error message
* return ResponseEntity . status ( 500 ) . body ( List . of ( Map . of ( "error" ,
* "An error occurred while fetching attendance data: " + ex . getMessage ( ) ) ) ) ;
* }
* }
* /
@GetMapping ( "/attendanceWithSalary" )
@ -688,14 +737,20 @@ public class NulmAPIController {
@RequestParam ( value = "incharge_id" , required = false ) Integer inchargeId ) {
try {
/ / List < Map < String , Object > > attendanceWithSalary = new ArrayList < > ( ) ;
/ / Integer check = nulmService . checkInchargeID ( inchargeId ) ;
/ / if ( check = = 1 ) {
/ / Call the service method to fetch the data
List < Map < String , Object > > attendanceWithSalary = nulmService . getAttendanceWithSalaryByInchargeId ( month , year , inchargeId ) ;
/ / If no data is found , return a NOT FOUND response total_days_salary , total_salary and total_days_absent
/ / }
/ / If no data is found , return a NOT FOUND response total_days_salary ,
/ / total_salary and total_days_absent
if ( attendanceWithSalary . isEmpty ( ) ) {
return ResponseEntity . status ( 404 ) . body ( List . of ( Map . of ( "error" , "No attendance records found for the specified parameters." ) ) ) ;
return ResponseEntity . status ( 404 )
. body ( List . of ( Map . of ( "error" , "No attendance records found for the specified parameters." ) ) ) ;
}
for ( Map < String , Object > aa : attendanceWithSalary ) {
long days = ( ( Number ) aa . get ( "total_days" ) ) . longValue ( ) ;
long present = ( ( Number ) aa . get ( "total_days_present" ) ) . longValue ( ) ;
@ -711,12 +766,12 @@ public class NulmAPIController {
aa . put ( "total_days_salary" , totalPresent ) ;
}
/ / Return the data in the response
return ResponseEntity . ok ( attendanceWithSalary ) ;
} catch ( Exception ex ) {
/ / Return a 500 Internal Server Error with the error message
return ResponseEntity . status ( 500 ) . body ( List . of ( Map . of ( "error" , "An error occurred while fetching attendance data: " + ex . getMessage ( ) ) ) ) ;
return ResponseEntity . status ( 500 ) . body (
List . of ( Map . of ( "error" , "An error occurred while fetching attendance data: " + ex . getMessage ( ) ) ) ) ;
}
}
@ -731,8 +786,7 @@ public class NulmAPIController {
@RequestParam ( "salary_amount" ) List < Integer > salaryAmountList ,
@RequestParam ( "enrollment_id" ) List < Integer > enrollmentIdList ,
@RequestParam ( "group_id" ) List < Integer > groupIdList ,
@RequestParam ( "wage_id" ) List < Integer > wageIdList
) {
@RequestParam ( "wage_id" ) List < Integer > wageIdList ) {
/ / System . out . println ( "Received POST request with form-data" ) ;
try {
@ -752,20 +806,22 @@ public class NulmAPIController {
String salaryStatus = "Initiated" ;
/ / Call the service method to insert the salary details
int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , total_days_salary , totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ) ;
int rowsAffected = nulmService . addSalaryDetails ( totalDaysPresent , totalDaysOd , total_days_salary ,
totalDaysAbsent , month , year , salaryAmount , salaryStatus , enrollmentId , groupId , wageId ) ;
if ( rowsAffected < = 0 ) {
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR )
. body ( "Failed to add salary details for enrollment ID: " + enrollmentId ) ;
}
}
return ResponseEntity . status ( HttpStatus . CREATED ) . body ( "Salary details added successfully for all selected entries." ) ;
return ResponseEntity . status ( HttpStatus . CREATED )
. body ( "Salary details added successfully for all selected entries." ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ; / / Log the exception for debugging
return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "Invalid request data: " + e . getMessage ( ) ) ;
}
}
/ / @GetMapping ( "/filtered-details" )
/ / public List < Map < String , Object > > getFilteredSalaryDetails (
/ / @RequestParam ( required = false ) String month ,