Browse Source

Implemented staff update module

main
AJITHKUMAR12 7 months ago
parent
commit
a0dc38c70a
  1. 214
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmAPIController.java
  2. 118
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmController.java
  3. 706
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java
  4. 1509
      gcc_officer_portal/src/main/resources/templates/modules/nulm/staffupdate.html
  5. 63
      gcc_officer_portal/src/main/resources/templates/modules/nulm/staffupdatenoacess.html

214
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmAPIController.java

@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -514,7 +515,7 @@ public class NulmAPIController {
@RequestParam(value = "inchargeName", required = false) String inchargeName, @RequestParam(value = "inchargeName", required = false) String inchargeName,
@RequestParam(value = "enrollmentIds", required = false) List<Integer> enrollmentIds) { @RequestParam(value = "enrollmentIds", required = false) List<Integer> enrollmentIds) {
System.out.println("inchargeName="+inchargeName);
System.out.println("inchargeName=" + inchargeName);
List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, year, List<Map<String, Object>> staffList = nulmService.getAttendanceWithInitiatedSalary(inchargeId, month, year,
inchargeName, enrollmentIds); inchargeName, enrollmentIds);
@ -523,7 +524,6 @@ public class NulmAPIController {
///// /////
@GetMapping("/staffInititeadList-park") @GetMapping("/staffInititeadList-park")
public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId_Park( public ResponseEntity<List<Map<String, Object>>> getAttendanceWithInitiatedSalaryByGroupId_Park(
@RequestParam(value = "inchargeId", required = false) Integer inchargeId, @RequestParam(value = "inchargeId", required = false) Integer inchargeId,
@ -537,7 +537,6 @@ public class NulmAPIController {
return ResponseEntity.ok(staffList); return ResponseEntity.ok(staffList);
} }
///// /////
/* /*
* @PostMapping("/salaryDetailUpdate") * @PostMapping("/salaryDetailUpdate")
@ -646,7 +645,6 @@ public class NulmAPIController {
} }
} }
/// ///
@PostMapping("/salaryDetailUpdate_Park") @PostMapping("/salaryDetailUpdate_Park")
@ -655,7 +653,6 @@ public class NulmAPIController {
try { try {
for (Map<String, Object> request : requestList) { for (Map<String, Object> request : requestList) {
System.out.println("enrollment_id = " + request.get("enrollment_id").toString()); System.out.println("enrollment_id = " + request.get("enrollment_id").toString());
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 totalDaysOd = Integer.parseInt(request.get("total_days_od").toString());
@ -691,7 +688,8 @@ public class NulmAPIController {
.body("Failed to add salary details for enrollment ID: " + enrollmentId); .body("Failed to add salary details for enrollment ID: " + enrollmentId);
} }
} else { } else {
int rowsAffected = nulmService.updateSalaryDetails_park(totalDaysPresent, totalDaysOd, totalDaysSalary,
int rowsAffected = nulmService.updateSalaryDetails_park(totalDaysPresent, totalDaysOd,
totalDaysSalary,
totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId, totalDaysAbsent, month, year, salaryAmount, salaryStatus, enrollmentId, groupId, wageId,
inchargeID); inchargeID);
if (rowsAffected <= 0) { if (rowsAffected <= 0) {
@ -709,12 +707,8 @@ public class NulmAPIController {
} }
} }
/// ///
// Helper method to check if the month is future or current // Helper method to check if the month is future or current
private boolean isFutureOrCurrentMonth(String month, int year) { private boolean isFutureOrCurrentMonth(String month, int year) {
// Get the current month and year // Get the current month and year
@ -788,27 +782,31 @@ public class NulmAPIController {
return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments."); return ResponseEntity.ok("Salary status updated to 'Approved' for the provided enrollments.");
} }
//// ////
@GetMapping("/salary-approve-park-testdata") @GetMapping("/salary-approve-park-testdata")
public List<Map<String, Object>> getsalaryInitiatedCounts(@RequestParam(required = false) String month, public List<Map<String, Object>> getsalaryInitiatedCounts(@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year, @RequestParam(required = false) Integer year,
@RequestParam(required = false) String salaryStatus, @RequestParam(required = false) String salaryStatus,
@RequestParam (required = false) String LoginUserId){
@RequestParam(required = false) String LoginUserId) {
List<Map<String, Object>> salaryInitiatedCounts; List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list
// Fetch data if both month and year are provided, otherwise return an empty
// list
if (month != null && year != null) { if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus,LoginUserId); // Pass department to the service method
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus, LoginUserId); // Pass
// department
// to
// the
// service
// method
} else { } else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
} }
return salaryInitiatedCounts; return salaryInitiatedCounts;
} }
@PostMapping("/update-salary-status-park") @PostMapping("/update-salary-status-park")
public ResponseEntity<String> updateSalaryStatus_Park( public ResponseEntity<String> updateSalaryStatus_Park(
@RequestParam List<Integer> enrollmentIds, @RequestParam List<Integer> enrollmentIds,
@ -864,12 +862,13 @@ public class NulmAPIController {
try { try {
//List<Map<String, Object>> attendanceWithSalary = new ArrayList<>();
//Integer check = nulmService.checkInchargeID(inchargeId);
// List<Map<String, Object>> attendanceWithSalary = new ArrayList<>();
// Integer check = nulmService.checkInchargeID(inchargeId);
// if (check == 1) { // if (check == 1) {
// Call the service method to fetch the data // Call the service method to fetch the data
List<Map<String, Object>> attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId(month, year, inchargeId);
//}
List<Map<String, Object>> attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId(month,
year, inchargeId);
// }
// If no data is found, return a NOT FOUND response total_days_salary, // If no data is found, return a NOT FOUND response total_days_salary,
// total_salary and total_days_absent // total_salary and total_days_absent
if (attendanceWithSalary.isEmpty()) { if (attendanceWithSalary.isEmpty()) {
@ -901,7 +900,6 @@ public class NulmAPIController {
} }
} }
//// ////
@GetMapping("/attendanceWithSalary_New") @GetMapping("/attendanceWithSalary_New")
@ -915,10 +913,11 @@ public class NulmAPIController {
List<Map<String, Object>> attendanceWithSalary = new ArrayList<>(); List<Map<String, Object>> attendanceWithSalary = new ArrayList<>();
String ids = nulmService.checkInchargeID(inchargeId); String ids = nulmService.checkInchargeID(inchargeId);
System.out.println("IDS = "+ids);
System.out.println("IDS = " + ids);
if (ids != null || !ids.trim().isEmpty()) { if (ids != null || !ids.trim().isEmpty()) {
// Call the service method to fetch the data // Call the service method to fetch the data
attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId_New(month, year, inchargeId, type, ids);
attendanceWithSalary = nulmService.getAttendanceWithSalaryByInchargeId_New(month, year, inchargeId,
type, ids);
} }
// If no data is found, return a NOT FOUND response total_days_salary, // If no data is found, return a NOT FOUND response total_days_salary,
// total_salary and total_days_absent // total_salary and total_days_absent
@ -951,7 +950,6 @@ public class NulmAPIController {
} }
} }
//// ////
@PostMapping("/salaryDetailInitiate") @PostMapping("/salaryDetailInitiate")
@ -1003,60 +1001,58 @@ public class NulmAPIController {
//// ////
// @PostMapping("/salaryDetailInitiate_park")
// public ResponseEntity<String> addInitiatedSalaryDetails_park(
// @RequestParam("total_days_present") List<Integer> totalDaysPresentList,
// @RequestParam("total_days_od") List<Integer> totalDaysOdList,
// @RequestParam("total_days_salary") List<Integer> totalDaysSalaryList,
// @RequestParam("total_days_absent") List<Integer> totalDaysAbsentList,
// @RequestParam("month") List<String> monthList,
// @RequestParam("year") List<Integer> yearList,
// @RequestParam("salary_amount") List<Integer> salaryAmountList,
// @RequestParam("enrollment_id") List<Integer> enrollmentIdList,
// @RequestParam("group_id") List<Integer> groupIdList,
// @RequestParam("wage_id") List<Integer> wageIdList) {
// // System.out.println("Received POST request with form-data");
//
// try {
// // Iterate through each list to process the form data
// for (int i = 0; i < totalDaysPresentList.size(); i++) {
// int totalDaysPresent = totalDaysPresentList.get(i);
// int totalDaysOd = totalDaysOdList.get(i);
// int total_days_salary = totalDaysSalaryList.get(i);
// int totalDaysAbsent = totalDaysAbsentList.get(i);
// String month = monthList.get(i);
// int year = yearList.get(i);
// int salaryAmount = salaryAmountList.get(i);
// int enrollmentId = enrollmentIdList.get(i);
// int groupId = groupIdList.get(i);
// int wageId = wageIdList.get(i);
//
// String salaryStatus = "Initiated";
//
// // Call the service method to insert the salary details
// int rowsAffected = nulmService.addSalaryDetails_park(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.CREATED)
// .body("Salary details added successfully for all selected entries in park.");
// } catch (Exception e) {
// e.printStackTrace(); // Log the exception for debugging
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid request data: " + e.getMessage());
// }
// }
// @PostMapping("/salaryDetailInitiate_park")
// public ResponseEntity<String> addInitiatedSalaryDetails_park(
// @RequestParam("total_days_present") List<Integer> totalDaysPresentList,
// @RequestParam("total_days_od") List<Integer> totalDaysOdList,
// @RequestParam("total_days_salary") List<Integer> totalDaysSalaryList,
// @RequestParam("total_days_absent") List<Integer> totalDaysAbsentList,
// @RequestParam("month") List<String> monthList,
// @RequestParam("year") List<Integer> yearList,
// @RequestParam("salary_amount") List<Integer> salaryAmountList,
// @RequestParam("enrollment_id") List<Integer> enrollmentIdList,
// @RequestParam("group_id") List<Integer> groupIdList,
// @RequestParam("wage_id") List<Integer> wageIdList) {
// // System.out.println("Received POST request with form-data");
//
// try {
// // Iterate through each list to process the form data
// for (int i = 0; i < totalDaysPresentList.size(); i++) {
// int totalDaysPresent = totalDaysPresentList.get(i);
// int totalDaysOd = totalDaysOdList.get(i);
// int total_days_salary = totalDaysSalaryList.get(i);
// int totalDaysAbsent = totalDaysAbsentList.get(i);
// String month = monthList.get(i);
// int year = yearList.get(i);
// int salaryAmount = salaryAmountList.get(i);
// int enrollmentId = enrollmentIdList.get(i);
// int groupId = groupIdList.get(i);
// int wageId = wageIdList.get(i);
//
// String salaryStatus = "Initiated";
//
// // Call the service method to insert the salary details
// int rowsAffected = nulmService.addSalaryDetails_park(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.CREATED)
// .body("Salary details added successfully for all selected entries in park.");
// } 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") // @GetMapping("/filtered-details")
// public List<Map<String, Object>> getFilteredSalaryDetails( // public List<Map<String, Object>> getFilteredSalaryDetails(
// @RequestParam(required = false) String month, // @RequestParam(required = false) String month,
@ -1066,4 +1062,74 @@ public class NulmAPIController {
// // Call the service method to get the filtered salary details // // Call the service method to get the filtered salary details
// return nulmService.getFilteredSalaryDetails(month, year, salaryStatus); // return nulmService.getFilteredSalaryDetails(month, year, salaryStatus);
// } // }
// ak
// 1. Get Zones
@GetMapping("/zones")
public List<Integer> getZones() {
return nulmService.getZones();
}
// 2. Get Divisions by Zone
@GetMapping("/divisions")
public List<Integer> getDivisions(@RequestParam int zone) {
return nulmService.getDivisions(zone);
}
// 3. Get Parks by Zone and Division
@GetMapping("/list")
public List<Map<String, Object>> getParks(
@RequestParam int zone,
// @RequestParam int division) {
@RequestParam(required = false) Integer division) {
return nulmService.getParks(zone, division);
}
@GetMapping("/staff")
public List<Map<String, Object>> getStaffByPark(@RequestParam int parkId) {
return nulmService.getStaffByPark(parkId);
}
@GetMapping("/staff-details")
public Map<String, Object> getStaffDetails(@RequestParam int enrollmentId) {
return nulmService.getStaffDetails(enrollmentId);
}
@PostMapping("/update-staff")
public ResponseEntity<?> updateStaff(
@RequestParam int enrollmentId,
@RequestParam(required = false) String fhName,
@RequestParam(required = false) String designation,
@RequestParam(required = false) Integer designationId,
@RequestParam(required = false) String aadharNo,
@RequestParam(required = false) String bankAccNo,
@RequestParam(required = false) String phoneNumber,
@RequestParam(required = false) String address,
// ak
@RequestParam(required = false) String bankName,
@RequestParam(required = false) String ifscCode,
@RequestParam(required = false) String branch,
@RequestParam(required = false) String branchAddress,
@RequestParam(required = false) Integer notFound,
@RequestParam(required = false) Integer error,
@RequestParam(required = false) String remarks,
@RequestParam(required = false) MultipartFile uploadform,
@RequestParam(required = false) MultipartFile aadharcard,
@RequestParam(required = false) MultipartFile bankpassbook, @RequestParam String createdBy) {
return ResponseEntity.ok(nulmService.updateStaff(
enrollmentId, fhName, designation, designationId,
aadharNo, bankAccNo, bankName, ifscCode, branch, branchAddress, phoneNumber, address,
uploadform, aadharcard, bankpassbook, notFound, error, remarks, createdBy));
}
@GetMapping("/designations")
@ResponseBody
public List<Map<String, Object>> getDesignations() {
return nulmService.getDesignations();
}
} }

118
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/controller/NulmController.java

@ -92,24 +92,31 @@ public class NulmController {
System.out.println("salarydetails for month: " + month + ", year: " + year); System.out.println("salarydetails for month: " + month + ", year: " + year);
return "modules/nulm/salary-details"; return "modules/nulm/salary-details";
} }
/*
@GetMapping("/salary-approve")
public String viewSalaryApproveScreen(@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year,
@RequestParam(required = false) String salaryStatus,
Model model) {
List<Map<String, Object>> salaryInitiatedCounts;
// If both month and year are provided, fetch the data; otherwise, return an empty list
if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year, salaryStatus);
} else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
}
model.addAttribute("salaryInitiatedCounts", salaryInitiatedCounts);
return "modules/nulm/salary-approve";
}
/*
* @GetMapping("/salary-approve")
* public String viewSalaryApproveScreen(@RequestParam(required = false) String
* month,
*
* @RequestParam(required = false) Integer year,
*
* @RequestParam(required = false) String salaryStatus,
* Model model) {
* List<Map<String, Object>> salaryInitiatedCounts;
*
* // If both month and year are provided, fetch the data; otherwise, return an
* empty list
* if (month != null && year != null) {
* salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year,
* salaryStatus);
* } else {
* salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month
* and year are provided
* }
*
* model.addAttribute("salaryInitiatedCounts", salaryInitiatedCounts);
* return "modules/nulm/salary-approve";
* }
*/ */
@GetMapping("/salary-approve") @GetMapping("/salary-approve")
public String viewSalaryApproveScreen(@RequestParam(required = false) String month, public String viewSalaryApproveScreen(@RequestParam(required = false) String month,
@ -118,15 +125,21 @@ public class NulmController {
Model model) { Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId(); String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
model.addAttribute("LoginUserId", LoginUserId);
System.out.println("LoginUserId=="+LoginUserId);
System.out.println("LoginUserId==" + LoginUserId);
List<Map<String, Object>> salaryInitiatedCounts; List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list
// Fetch data if both month and year are provided, otherwise return an empty
// list
if (month != null && year != null) { if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year, salaryStatus,LoginUserId); // Pass department to the service method
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails(month, year, salaryStatus, LoginUserId); // Pass
// department
// to
// the
// service
// method
} else { } else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
} }
@ -136,10 +149,8 @@ public class NulmController {
return "modules/nulm/salary-approve"; return "modules/nulm/salary-approve";
} }
//// ////
@GetMapping("/salary-approve-park") @GetMapping("/salary-approve-park")
public String viewSalaryApproveScreen_park(@RequestParam(required = false) String month, public String viewSalaryApproveScreen_park(@RequestParam(required = false) String month,
@RequestParam(required = false) Integer year, @RequestParam(required = false) Integer year,
@ -147,13 +158,19 @@ public class NulmController {
Model model) { Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId(); String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
model.addAttribute("LoginUserId", LoginUserId);
List<Map<String, Object>> salaryInitiatedCounts; List<Map<String, Object>> salaryInitiatedCounts;
// Fetch data if both month and year are provided, otherwise return an empty list
// Fetch data if both month and year are provided, otherwise return an empty
// list
if (month != null && year != null) { if (month != null && year != null) {
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus,LoginUserId); // Pass department to the service method
salaryInitiatedCounts = nulmService.getFilteredSalaryDetails_park(month, year, salaryStatus, LoginUserId); // Pass
// department
// to
// the
// service
// method
} else { } else {
salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided salaryInitiatedCounts = Collections.emptyList(); // Empty list if no month and year are provided
} }
@ -163,11 +180,8 @@ public class NulmController {
return "modules/nulm/salary-approve-park"; return "modules/nulm/salary-approve-park";
} }
//// ////
@GetMapping("/salary-report") @GetMapping("/salary-report")
public String viewSalaryReport( public String viewSalaryReport(
@RequestParam(required = false) String month, @RequestParam(required = false) String month,
@ -177,7 +191,7 @@ public class NulmController {
Model model) { Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId(); String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
model.addAttribute("LoginUserId", LoginUserId);
// Initialize an empty salaryReport list // Initialize an empty salaryReport list
List<Map<String, Object>> salaryReport = new ArrayList<>(); List<Map<String, Object>> salaryReport = new ArrayList<>();
@ -204,7 +218,7 @@ public class NulmController {
Model model) { Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId(); String LoginUserId = LoginUserInfo.getLoginUserId();
model.addAttribute("LoginUserId",LoginUserId);
model.addAttribute("LoginUserId", LoginUserId);
// Initialize an empty salaryReport list // Initialize an empty salaryReport list
List<Map<String, Object>> salaryReport = new ArrayList<>(); List<Map<String, Object>> salaryReport = new ArrayList<>();
@ -231,14 +245,14 @@ public class NulmController {
@RequestParam(required = false) String zone, @RequestParam(required = false) String zone,
@RequestParam(required = false) String division, @RequestParam(required = false) String division,
Model model) { Model model) {
//System.out.println("Zone: "+zone);
// System.out.println("Zone: "+zone);
// Initialize an empty salaryReport list // Initialize an empty salaryReport list
List<Map<String, Object>> zoneWiseReport = new ArrayList<>(); List<Map<String, Object>> zoneWiseReport = new ArrayList<>();
// Only fetch the report if month, year and zone are provided // Only fetch the report if month, year and zone are provided
if (month != null && year != null && zone!= null) {
zoneWiseReport = nulmService.getZoneWiseReport(month, year, salaryStatus ,groupName, zone, division);
if (month != null && year != null && zone != null) {
zoneWiseReport = nulmService.getZoneWiseReport(month, year, salaryStatus, groupName, zone, division);
} }
// Add the fetched data to the model // Add the fetched data to the model
@ -260,8 +274,8 @@ public class NulmController {
List<Map<String, Object>> attendanceReport = new ArrayList<>(); List<Map<String, Object>> attendanceReport = new ArrayList<>();
// Only fetch the report if month, year and zone are provided // Only fetch the report if month, year and zone are provided
if (division != null && zone!= null) {
attendanceReport = nulmService.getAttendanceReport(fromdate ,todate ,groupName, zone, division);
if (division != null && zone != null) {
attendanceReport = nulmService.getAttendanceReport(fromdate, todate, groupName, zone, division);
} }
// Add the fetched data to the model // Add the fetched data to the model
@ -284,7 +298,8 @@ public class NulmController {
// Only fetch the report if month, year and zone are provided // Only fetch the report if month, year and zone are provided
if (division != null && zone != null) { if (division != null && zone != null) {
consolidatedAttendanceReport = nulmService.getConsolidatedAttendanceReport(fromdate, todate, groupName, zone, division);
consolidatedAttendanceReport = nulmService.getConsolidatedAttendanceReport(fromdate, todate, groupName,
zone, division);
} }
// Add the fetched data to the model // Add the fetched data to the model
@ -295,7 +310,7 @@ public class NulmController {
return "modules/nulm/attendance-report"; return "modules/nulm/attendance-report";
} }
@GetMapping("/attendance-dates") //need to add
@GetMapping("/attendance-dates") // need to add
public ResponseEntity<Map<String, List<String>>> getAttendanceDates( public ResponseEntity<Map<String, List<String>>> getAttendanceDates(
@RequestParam(required = false) String enrollmentId, @RequestParam(required = false) String enrollmentId,
@RequestParam(required = false) String fromdate, @RequestParam(required = false) String fromdate,
@ -307,8 +322,7 @@ public class NulmController {
} }
@GetMapping("/self-help-group") // need to add
@GetMapping("/self-help-group") // need to add
public String viewSelfHelpGroup(Model model) { public String viewSelfHelpGroup(Model model) {
// Fetch the full list or filtered list based on parameters // Fetch the full list or filtered list based on parameters
@ -321,8 +335,7 @@ public class NulmController {
return "modules/nulm/selfHelpGroup"; return "modules/nulm/selfHelpGroup";
} }
@GetMapping("/salary-nonInitiated")
@GetMapping("/salary-nonInitiated")
public String viewSalaryNotInitiatedReport( public String viewSalaryNotInitiatedReport(
@RequestParam(required = false) String month, @RequestParam(required = false) String month,
@RequestParam(required = false) Integer year, @RequestParam(required = false) Integer year,
@ -343,4 +356,25 @@ public class NulmController {
return "modules/nulm/salary-nonInitiatedreport"; return "modules/nulm/salary-nonInitiatedreport";
} }
@GetMapping("/staffupdate")
public String viewSalaryReport(Model model) {
String LoginUserId = LoginUserInfo.getLoginUserId();
System.out.println("===" + LoginUserId);
model.addAttribute("LoginUserId", LoginUserId);
boolean hasAccess = nulmService.hasStaffUpdateAccess(LoginUserId);
if (hasAccess) {
model.addAttribute("LoginUserId", LoginUserId);
return "modules/nulm/staffupdate";
} else {
return "modules/nulm/staffupdatenoacess";
}
}
} }

706
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/nulm/service/NulmService.java

@ -1,5 +1,6 @@
package in.gov.chennaicorporation.gccoffice.nulm.service; package in.gov.chennaicorporation.gccoffice.nulm.service;
import java.nio.file.Path;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
@ -11,17 +12,30 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.nio.file.Files;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.nio.file.Paths;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.ByteArrayInputStream;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import in.gov.chennaicorporation.gccoffice.controller.DateTimeUtil;
import in.gov.chennaicorporation.gccoffice.nulm.repository.NulmRepository; import in.gov.chennaicorporation.gccoffice.nulm.repository.NulmRepository;
@Service @Service
@ -29,16 +43,30 @@ public class NulmService {
@Autowired @Autowired
private NulmRepository nulmRepository; private NulmRepository nulmRepository;
@Autowired
private Environment environment;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Value("${fileBaseUrl}")
private String fileBaseUrl;
@Autowired @Autowired
public NulmService(NulmRepository nulmRepository, JdbcTemplate jdbcTemplate) { public NulmService(NulmRepository nulmRepository, JdbcTemplate jdbcTemplate) {
this.nulmRepository = nulmRepository; this.nulmRepository = nulmRepository;
this.jdbcTemplate = jdbcTemplate; this.jdbcTemplate = jdbcTemplate;
} }
/*
* public NulmService(Environment environment) {
* this.environment = environment;
* this.fileBaseUrl = environment.getProperty("fileBaseUrl");
* }
*/
@Autowired @Autowired
public void setDataSource(@Qualifier("mysqlNulmDataSource") DataSource dataSource) { public void setDataSource(@Qualifier("mysqlNulmDataSource") DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
@ -479,21 +507,23 @@ public class NulmService {
salaryAmount, salaryStatus, enrollmentId, groupId, wageId); salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
} }
//// ////
// public int addSalaryDetails_park(int totalDaysPresent, int totalDaysOd, int totalDaysSalary, int totalDaysAbsent,
// String month, int year, int salaryAmount,
// String salaryStatus, int enrollmentId, int groupId, int wageId)
// {
// String sql = "INSERT INTO salary_details_park (total_days_present, total_days_od, total_days_salary, total_days_absent, month, year, salary_amount, salary_status, enrollment_id, group_id, wage_id) "
// +
// "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//
// return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd, totalDaysSalary, totalDaysAbsent, month, year,
// salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
// }
// public int addSalaryDetails_park(int totalDaysPresent, int totalDaysOd, int
// totalDaysSalary, int totalDaysAbsent,
// String month, int year, int salaryAmount,
// String salaryStatus, int enrollmentId, int groupId, int wageId)
// {
// String sql = "INSERT INTO salary_details_park (total_days_present,
// total_days_od, total_days_salary, total_days_absent, month, year,
// salary_amount, salary_status, enrollment_id, group_id, wage_id) "
// +
// "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//
// return jdbcTemplate.update(sql, totalDaysPresent, totalDaysOd,
// totalDaysSalary, totalDaysAbsent, month, year,
// salaryAmount, salaryStatus, enrollmentId, groupId, wageId);
// }
//// ////
@ -908,8 +938,8 @@ public class NulmService {
/// ///
public List<Map<String, Object>> getSalaryReport_park(String month, Integer year, String salaryStatus, String groupName,
public List<Map<String, Object>> getSalaryReport_park(String month, Integer year, String salaryStatus,
String groupName,
String loginId) { String loginId) {
// Retrieve zone access for the user // Retrieve zone access for the user
@ -988,11 +1018,8 @@ public class NulmService {
return results; return results;
} }
/// ///
/* /*
* public List<Map<String, Object>> getSalaryReport(String month, Integer year, * public List<Map<String, Object>> getSalaryReport(String month, Integer year,
* String salaryStatus, String groupName) { * String salaryStatus, String groupName) {
@ -1441,8 +1468,6 @@ public class NulmService {
* } * }
*/ */
///// /////
public boolean checkSalaryDetails_park(int enrollmentId, String month, int year) { public boolean checkSalaryDetails_park(int enrollmentId, String month, int year) {
@ -1477,10 +1502,8 @@ public class NulmService {
salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year); salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year);
} }
///// /////
public List<Map<String, Object>> getAttendanceWithInitiatedSalary( public List<Map<String, Object>> getAttendanceWithInitiatedSalary(
int inchargeId, String month, String year, String inchargeName, List<Integer> enrollmentIds) { int inchargeId, String month, String year, String inchargeName, List<Integer> enrollmentIds) {
@ -1514,7 +1537,7 @@ public class NulmService {
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " + "WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " +
"AND (? IS NULL OR e.incharge_id = ?) " + "AND (? IS NULL OR e.incharge_id = ?) " +
"AND (? IS NULL OR e.incharge_name = ?) "+
"AND (? IS NULL OR e.incharge_name = ?) " +
"AND e.emp_type = 'NULM' "; "AND e.emp_type = 'NULM' ";
if (month != null && !month.isEmpty()) { if (month != null && !month.isEmpty()) {
@ -1567,7 +1590,6 @@ public class NulmService {
return jdbcTemplate.queryForList(sql, params.toArray()); return jdbcTemplate.queryForList(sql, params.toArray());
} }
/// ///
public List<Map<String, Object>> getAttendanceWithInitiatedSalary_Park( public List<Map<String, Object>> getAttendanceWithInitiatedSalary_Park(
@ -1580,7 +1602,8 @@ public class NulmService {
"a.enrollment_id, e.emp_id, e.name, e.incharge_id, " + "a.enrollment_id, e.emp_id, e.name, e.incharge_id, " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, " "(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, "
+ +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, "
+
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " + "YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " + "MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " + "DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " +
@ -1603,8 +1626,8 @@ public class NulmService {
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " + "WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) " +
"AND (? IS NULL OR e.incharge_id = ?) " + "AND (? IS NULL OR e.incharge_id = ?) " +
"AND (? IS NULL OR e.incharge_name = ?) "+
"AND e.emp_type = 'Park' " ;
"AND (? IS NULL OR e.incharge_name = ?) " +
"AND e.emp_type = 'Park' ";
if (month != null && !month.isEmpty()) { if (month != null && !month.isEmpty()) {
sql += "AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? "; sql += "AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ";
@ -1629,8 +1652,10 @@ public class NulmService {
"GROUP BY a.enrollment_id, e.group_id, " + "GROUP BY a.enrollment_id, e.group_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " + "YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " + "MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), "
+
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), "
+
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " + "(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " + "DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " +
"s.salary_status"; "s.salary_status";
@ -1682,7 +1707,6 @@ public class NulmService {
//// ////
/* /*
* public List<Map<String, Object>> getFilteredSalaryDetails(String month, * public List<Map<String, Object>> getFilteredSalaryDetails(String month,
* Integer year, String salaryStatus) { * Integer year, String salaryStatus) {
@ -1955,10 +1979,8 @@ public class NulmService {
} }
//// ////
public List<Map<String, Object>> getFilteredSalaryDetails_park(String month, Integer year, String salaryStatus, public List<Map<String, Object>> getFilteredSalaryDetails_park(String month, Integer year, String salaryStatus,
String loginId) { String loginId) {
StringBuilder sql = new StringBuilder("SELECT " + StringBuilder sql = new StringBuilder("SELECT " +
@ -2090,19 +2112,18 @@ public class NulmService {
} }
//// ////
// public Integer checkInchargeID(Integer inchargeId) {
//
// String sql = "SELECT EXISTS( " +
// "SELECT 1 FROM additional_incharge " +
// "WHERE incharge_id = ? AND is_active = 1 AND is_delete = 0)";
//
// Integer result = jdbcTemplate.queryForObject(sql, Integer.class, inchargeId);
//
// return result;
// }
// public Integer checkInchargeID(Integer inchargeId) {
//
// String sql = "SELECT EXISTS( " +
// "SELECT 1 FROM additional_incharge " +
// "WHERE incharge_id = ? AND is_active = 1 AND is_delete = 0)";
//
// Integer result = jdbcTemplate.queryForObject(sql, Integer.class, inchargeId);
//
// return result;
// }
public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId(String month, Integer year, public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId(String month, Integer year,
Integer incharge_id) { Integer incharge_id) {
@ -2141,7 +2162,7 @@ public class NulmService {
"LEFT JOIN salary_details AS s ON a.enrollment_id = s.enrollment_id " + "LEFT JOIN salary_details AS s ON a.enrollment_id = s.enrollment_id " +
"AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " + "AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) AND e.emp_type = 'NULM' ");
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) ");
// Append condition for incharge_id // Append condition for incharge_id
sql.append("AND (? IS NULL OR e.incharge_id = ?) "); sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
@ -2190,19 +2211,14 @@ public class NulmService {
return results; return results;
} }
/// ///
public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId_New(String month, Integer year, public List<Map<String, Object>> getAttendanceWithSalaryByInchargeId_New(String month, Integer year,
Integer incharge_id, String type, String ids)
{
Integer incharge_id, String type, String ids) {
List<Map<String, Object>> results = new ArrayList<>(); List<Map<String, Object>> results = new ArrayList<>();
if(type.equalsIgnoreCase("1")){
results = getAttendanceWithSalaryByInchargeId(month,year, incharge_id);
}
else
{
if (type.equalsIgnoreCase("1")) {
results = getAttendanceWithSalaryByInchargeId_Nulm(month, year, incharge_id);
} else {
StringBuilder sql = new StringBuilder("SELECT " + StringBuilder sql = new StringBuilder("SELECT " +
"e.group_id, " + "e.group_id, " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1) AS group_name, " "(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1) AS group_name, "
@ -2214,7 +2230,8 @@ public class NulmService {
"e.incharge_name, " + "e.incharge_name, " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, " "(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS salary_per_day, "
+ +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id) AS wage_id, "
+
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " + "YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " + "MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " + "DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " +
@ -2246,9 +2263,8 @@ public class NulmService {
params.add(month); // Add month for the inner subquery params.add(month); // Add month for the inner subquery
params.add(year); // Add year for the inner subquery params.add(year); // Add year for the inner subquery
// Append condition for incharge_id // Append condition for incharge_id
//sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
// sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
if (ids != null && !ids.trim().isEmpty()) { if (ids != null && !ids.trim().isEmpty()) {
List<Integer> idList = Arrays.stream(ids.split(",")) List<Integer> idList = Arrays.stream(ids.split(","))
@ -2259,15 +2275,14 @@ public class NulmService {
String placeholders = idList.stream() String placeholders = idList.stream()
.map(i -> "?") .map(i -> "?")
.collect(Collectors.joining(",")); .collect(Collectors.joining(","));
System.out.println("placeholders = "+placeholders);
System.out.println("placeholders = " + placeholders);
sql.append(" AND e.incharge_id IN (").append(placeholders).append(") "); sql.append(" AND e.incharge_id IN (").append(placeholders).append(") ");
System.out.println("idList = "+idList);
System.out.println("idList = " + idList);
params.addAll(idList); params.addAll(idList);
} }
// Append condition for month if provided // Append condition for month if provided
if (month != null && !month.isEmpty()) { if (month != null && !month.isEmpty()) {
sql.append("AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? "); sql.append("AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ");
@ -2284,8 +2299,10 @@ public class NulmService {
sql.append("GROUP BY a.enrollment_id, e.group_id, " + sql.append("GROUP BY a.enrollment_id, e.group_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " + "YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " + "MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), " +
"(SELECT salary_per_day FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), "
+
"(SELECT wage_id FROM staff_wages_park WHERE isactive = 1 AND e.designation_id = staff_wages_park.designation_id), "
+
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " + "(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " + "DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " +
"s.salary_status"); "s.salary_status");
@ -2294,15 +2311,14 @@ public class NulmService {
// Create a list of parameters // Create a list of parameters
//params.add(incharge_id);
//params.add(incharge_id); // Added twice for the conditional check in the SQL
//if (month != null && !month.isEmpty()) {
//params.add(month);
//}
//if (year != null) {
//params.add(year);
//}
// params.add(incharge_id);
// params.add(incharge_id); // Added twice for the conditional check in the SQL
// if (month != null && !month.isEmpty()) {
// params.add(month);
// }
// if (year != null) {
// params.add(year);
// }
// Log the SQL and parameters (optional for debugging) // Log the SQL and parameters (optional for debugging)
System.out.println("Generated SQL: " + sql.toString()); System.out.println("Generated SQL: " + sql.toString());
@ -2314,10 +2330,93 @@ public class NulmService {
return results; return results;
} }
private List<Map<String, Object>> getAttendanceWithSalaryByInchargeId_Nulm(String month, Integer year,
Integer incharge_id) {
StringBuilder sql = new StringBuilder("SELECT " +
"e.group_id, " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1) AS group_name, "
+
"a.enrollment_id, " +
"e.emp_id, " +
"e.name, " +
"e.incharge_id, " +
"e.incharge_name, " +
"(SELECT salary_per_day FROM staff_wages WHERE isactive = 1 ORDER BY wage_id DESC LIMIT 1) AS salary_per_day, "
+
"(SELECT wage_id FROM staff_wages WHERE isactive = 1 ORDER BY wage_id DESC LIMIT 1) AS wage_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS year, " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) AS month, " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))) AS total_days, " +
"COUNT(DISTINCT DATE(a.indatetime)) AS total_days_present, " +
// Subquery to get total_days_od
"(SELECT COUNT(DISTINCT DATE(a2.oddatetime)) " +
" FROM attendance AS a2 " +
" WHERE MONTHNAME(a2.oddatetime) = ? " + // Use placeholder for month
" AND YEAR(a2.oddatetime) = ? " + // Use placeholder for year
" AND a2.enrollment_id = a.enrollment_id " +
" AND DATE(a2.oddatetime) NOT IN ( " +
" SELECT DISTINCT DATE(a3.indatetime) " +
" FROM attendance AS a3 " +
" WHERE MONTHNAME(a3.indatetime) = ? " + // Use placeholder for month
" AND YEAR(a3.indatetime) = ? " + // Use placeholder for year
" AND a3.enrollment_id = a.enrollment_id " +
")) AS total_days_od, " +
"IFNULL(s.salary_status, '') AS salary_status " +
"FROM attendance AS a " +
"INNER JOIN enrollment_table AS e ON a.enrollment_id = e.enrollment_id " +
"LEFT JOIN salary_details AS s ON a.enrollment_id = s.enrollment_id " +
"AND s.month = MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"AND s.year = YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) " +
"WHERE (a.inby IS NOT NULL OR a.leaveby IS NOT NULL OR a.odby IS NOT NULL) AND e.emp_type = 'NULM' ");
////
// Append condition for incharge_id
sql.append("AND (? IS NULL OR e.incharge_id = ?) ");
// Append condition for month if provided
if (month != null && !month.isEmpty()) {
sql.append("AND MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ");
}
// Append condition for year if provided
if (year != null) {
sql.append("AND YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)) = ? ");
}
// Group by necessary columns
sql.append("GROUP BY a.enrollment_id, e.group_id, " +
"YEAR(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"MONTHNAME(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime)), " +
"(SELECT salary_per_day FROM staff_wages WHERE isactive = 1 ORDER BY wage_id DESC LIMIT 1), " +
"(SELECT wage_id FROM staff_wages WHERE isactive = 1 ORDER BY wage_id DESC LIMIT 1), " +
"(SELECT group_name FROM suyaudavi_kuzhu WHERE suyaudavi_kuzhu.group_id = e.group_id LIMIT 1), " +
"DAY(LAST_DAY(COALESCE(a.indatetime, a.leavedatetime, a.oddatetime))), " +
"s.salary_status");
// Create a list of parameters
List<Object> params = new ArrayList<>();
params.add(month); // Add month for total_days_od
params.add(year); // Add year for total_days_od
params.add(month); // Add month for the inner subquery
params.add(year); // Add year for the inner subquery
params.add(incharge_id);
params.add(incharge_id); // Added twice for the conditional check in the SQL
if (month != null && !month.isEmpty()) {
params.add(month);
}
if (year != null) {
params.add(year);
}
// Log the SQL and parameters (optional for debugging)
System.out.println("Generated SQL: " + sql.toString());
System.out.println("Parameters: " + params);
// Execute the query using JdbcTemplate
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql.toString(), params.toArray());
return results;
}
////
public List<Map<String, Object>> getZoneWiseReport(String month, Integer year, String salaryStatus, public List<Map<String, Object>> getZoneWiseReport(String month, Integer year, String salaryStatus,
String groupName, String zone, String division) { String groupName, String zone, String division) {
@ -2778,7 +2877,6 @@ public class NulmService {
salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year); salaryAmount, salaryStatus, enrollmentId, groupId, wageId, inchargeID, enrollmentId, month, year);
} }
public String checkInchargeID(Integer inchargeId) { public String checkInchargeID(Integer inchargeId) {
String sql = "SELECT " + String sql = "SELECT " +
@ -2799,4 +2897,464 @@ public class NulmService {
return result; return result;
} }
// ak
public List<Integer> getZones() {
String sql = "select distinct zone from park_details " +
"where is_active = 1 and is_delete = 0 order by zone";
return jdbcTemplate.queryForList(sql, Integer.class);
}
// 2. Get Divisions by Zone
public List<Integer> getDivisions(int zone) {
String sql = "select distinct division from park_details " +
"where is_active = 1 and is_delete = 0 and zone = ? " +
"order by division";
return jdbcTemplate.queryForList(sql, Integer.class, zone);
}
// 3. Get Parks by Zone and Division
/*
* public List<Map<String, Object>> getParks(int zone, int division) {
*
* String sql = "select park_id, park_name from park_details " +
* "where is_active = 1 and is_delete = 0 " +
* "and zone = ? and division = ? " +
* "order by park_name";
*
* return jdbcTemplate.queryForList(sql, zone, division);
* }
*/
public List<Map<String, Object>> getParks(int zone, Integer division) {
String sql = "select park_id, park_name from park_details " +
"where is_active = 1 and is_delete = 0 and zone = ? ";
List<Object> params = new ArrayList<>();
params.add(zone);
if (division != null) {
sql += " and division = ? ";
params.add(division);
}
sql += " order by park_name";
return jdbcTemplate.queryForList(sql, params.toArray());
}
public List<Map<String, Object>> getStaffByPark(int parkId) {
String sql = "select et.emp_id, et.enrollment_id, pd.park_name, "
+ "et.name as empname, et.phone_number, "
+ "et.designation, et.incharge_name "
+ "from enrollment_table et "
+ "left join park_details pd on et.park_id = pd.park_id "
+ "where pd.park_id = ? "
+ "and et.isactive = 1 "
+ "and et.isdelete = 0 "
+ "and pd.is_active = 1 "
+ "and et.emp_type = 'Park'";
return jdbcTemplate.queryForList(sql, parkId);
}
public Map<String, Object> getStaffDetails(int enrollmentId) {
String sql = "select pd.park_name, et.incharge_name, et.name as name, et.designation,et.designation_id, " +
"ifnull(sk.group_name,'-') as groupname, et.aadhar_no, ifnull(et.f_h_name,'') as f_h_name, " +
"ifnull(et.bank_acc_no,'-') as bankaccNo, et.phone_number,et.not_found,et.error,et.remarks, " +
"ifnull(et.address,'-') as address, " +
"ifnull(et.bank_name,'') as bank_name, " +
"ifnull(et.ifsc_code,'') as ifsc_code, " +
"ifnull(et.branch,'') as branch, " +
"ifnull(et.branch_address,'') as branch_address, " +
"IFNULL(CONCAT('" + fileBaseUrl + "/gcc/files', et.form_url),'') AS formUrl, " +
"IFNULL(CONCAT('" + fileBaseUrl + "/gcc/files', et.bank_passbook_url),'') AS bankpassbookUrl, " +
"IFNULL(CONCAT('" + fileBaseUrl + "/gcc/files', et.aadhar_card_url),'') AS aadharUrl " +
"from enrollment_table et " +
"left join park_details pd on et.park_id = pd.park_id " +
"left join suyaudavi_kuzhu sk on et.group_id = sk.group_id " +
"where et.isactive = 1 and et.enrollment_id = ?";
return jdbcTemplate.queryForMap(sql, enrollmentId);
}
/*
* public String updateStaff(
* int enrollmentId,
* String fhName,
* String designation,
* Integer designationId,
* String aadharNo,
* String bankAccNo,
* String phoneNumber,
* String address,
* MultipartFile uploadform,
* MultipartFile aadharcard,
* MultipartFile bankpassbook,String createdBy) {
*
* StringBuilder sql = new StringBuilder("UPDATE enrollment_table SET ");
* List<Object> params = new ArrayList<>();
*
* if (fhName != null && !fhName.isEmpty()) {
* sql.append("f_h_name=?, ");
* params.add(fhName);
* }
*
* if (designation != null && !designation.isEmpty()) {
* sql.append("designation=?, ");
* params.add(designation);
* }
*
* if (designationId != null) {
* sql.append("designation_id=?, ");
* params.add(designationId);
* }
*
* if (aadharNo != null && !aadharNo.isEmpty()) {
* sql.append("aadhar_no=?, ");
* params.add(aadharNo);
* }
*
* if (bankAccNo != null && !bankAccNo.isEmpty()) {
* sql.append("bank_acc_no=?, ");
* params.add(bankAccNo);
* }
*
* if (phoneNumber != null && !phoneNumber.isEmpty()) {
* sql.append("phone_number=?, ");
* params.add(phoneNumber);
* }
*
* if (address != null && !address.isEmpty()) {
* sql.append("res_adress=?, ");
* params.add(address);
* }
*
* // File uploads
* if (uploadform != null && !uploadform.isEmpty()) {
* String path = fileUpload("uploadform", String.valueOf(enrollmentId),
* uploadform);
* sql.append("form_url=?, ");
* params.add(path);
* }
*
* if (aadharcard != null && !aadharcard.isEmpty()) {
* String path = fileUpload("aadharcard", String.valueOf(enrollmentId),
* aadharcard);
* sql.append("aadhar_card_url=?, ");
* params.add(path);
* }
*
* if (bankpassbook != null && !bankpassbook.isEmpty()) {
* String path = fileUpload("bankpassbook", String.valueOf(enrollmentId),
* bankpassbook);
* sql.append("bank_passbook_url=?, ");
* params.add(path);
* }
*
* // Remove last comma
* sql.setLength(sql.length() - 2);
*
* sql.append(" WHERE enrollment_id=?");
* params.add(enrollmentId);
*
* jdbcTemplate.update(sql.toString(), params.toArray());
*
* return "Updated Successfully";
* }
*/
@Transactional
public String updateStaff(
int enrollmentId,
String fhName,
String designation,
Integer designationId,
String aadharNo,
String bankAccNo,
String bankName,
String ifscCode,
String branch,
String branchAddress,
String phoneNumber,
String address,
MultipartFile uploadform,
MultipartFile aadharcard,
MultipartFile bankpassbook,
Integer notFound,
Integer error,
String remarks,
String createdBy) {
// 1️⃣ Fetch existing record
String fetchSql = "SELECT * FROM enrollment_table WHERE enrollment_id = ?";
Map<String, Object> existing = jdbcTemplate.queryForMap(fetchSql, enrollmentId);
// 2️⃣ Insert existing record into log table
String logSql = "INSERT INTO enrollment_table_log("
+ "enrollment_id,name,department,division,incharge_id,incharge_name,incharge_designation,RFID_CARD_NO,"
+ "designation,incharge_phoneno,emp_id,isactive,isdelete,created_date,appointed,facial_attendance,"
+ "staff_photo_url,order_id,group_id,dropout_date,dropout,registered_date,appointed_date,res_adress,"
+ "f_h_name,form_url,bank_passbook_url,bank_acc_no,ration_card_url,aadhar_no,aadhar_card_url,"
+ "additional_skills,education_qualification,address,phone_number,gender,date_of_birth,zone,"
+ "remarks,emp_type,park_name,park_id,designation_id,not_found,error,updatedby,bank_name,ifsc_code,branch,branch_address)"
+ " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
jdbcTemplate.update(logSql,
existing.get("enrollment_id"),
existing.get("name"),
existing.get("department"),
existing.get("division"),
existing.get("incharge_id"),
existing.get("incharge_name"),
existing.get("incharge_designation"),
existing.get("RFID_CARD_NO"),
existing.get("designation"),
existing.get("incharge_phoneno"),
existing.get("emp_id"),
existing.get("isactive"),
existing.get("isdelete"),
existing.get("created_date"),
existing.get("appointed"),
existing.get("facial_attendance"),
existing.get("staff_photo_url"),
existing.get("order_id"),
existing.get("group_id"),
existing.get("dropout_date"),
existing.get("dropout"),
existing.get("registered_date"),
existing.get("appointed_date"),
existing.get("res_adress"),
existing.get("f_h_name"),
existing.get("form_url"),
existing.get("bank_passbook_url"),
existing.get("bank_acc_no"),
existing.get("ration_card_url"),
existing.get("aadhar_no"),
existing.get("aadhar_card_url"),
existing.get("additional_skills"),
existing.get("education_qualification"),
existing.get("address"),
existing.get("phone_number"),
existing.get("gender"),
existing.get("date_of_birth"),
existing.get("zone"),
existing.get("remarks"),
existing.get("emp_type"),
existing.get("park_name"),
existing.get("park_id"),
// existing.get("designation_id"),
existing.get("designation_id") == null ? 0 : existing.get("designation_id"),
existing.get("not_found"),
existing.get("error"),
createdBy,
existing.get("bank_name"),
existing.get("ifsc_code"),
existing.get("branch"),
existing.get("branch_address"));
// 3️⃣ Build dynamic update query
StringBuilder sql = new StringBuilder("UPDATE enrollment_table SET ");
List<Object> params = new ArrayList<>();
if (fhName != null && !fhName.isEmpty()) {
sql.append("f_h_name=?, ");
params.add(fhName);
}
if (designation != null && !designation.isEmpty()) {
sql.append("designation=?, ");
params.add(designation);
}
if (designationId != null) {
sql.append("designation_id=?, ");
params.add(designationId);
}
if (aadharNo != null && !aadharNo.isEmpty()) {
sql.append("aadhar_no=?, ");
params.add(aadharNo);
}
if (bankAccNo != null && !bankAccNo.isEmpty()) {
sql.append("bank_acc_no=?, ");
params.add(bankAccNo);
}
// ak
if (bankName != null && !bankName.isEmpty()) {
sql.append("bank_name=?, ");
params.add(bankName);
}
if (ifscCode != null && !ifscCode.isEmpty()) {
sql.append("ifsc_code=?, ");
params.add(ifscCode);
}
if (branch != null && !branch.isEmpty()) {
sql.append("branch=?, ");
params.add(branch);
}
if (branchAddress != null && !branchAddress.isEmpty()) {
sql.append("branch_address=?, ");
params.add(branchAddress);
}
if (phoneNumber != null && !phoneNumber.isEmpty()) {
sql.append("phone_number=?, ");
params.add(phoneNumber);
}
if (address != null && !address.isEmpty()) {
sql.append("address=?, ");
params.add(address);
}
// 4️⃣ File Upload Handling
if (uploadform != null && !uploadform.isEmpty()) {
String path = fileUpload("uploadform", String.valueOf(enrollmentId), uploadform);
sql.append("form_url=?, ");
params.add(path);
}
if (aadharcard != null && !aadharcard.isEmpty()) {
String path = fileUpload("aadharcard", String.valueOf(enrollmentId), aadharcard);
sql.append("aadhar_card_url=?, ");
params.add(path);
}
if (bankpassbook != null && !bankpassbook.isEmpty()) {
String path = fileUpload("bankpassbook", String.valueOf(enrollmentId), bankpassbook);
sql.append("bank_passbook_url=?, ");
params.add(path);
}
if (notFound != null) {
sql.append("not_found=?, ");
params.add(notFound);
}
if (error != null) {
sql.append("error=?, ");
params.add(error);
}
if (remarks != null) {
sql.append("remarks=?, ");
params.add(remarks);
}
// Remove last comma
sql.setLength(sql.length() - 2);
sql.append(" WHERE enrollment_id=?");
params.add(enrollmentId);
jdbcTemplate.update(sql.toString(), params.toArray());
return "Staff updated successfully";
}
public String fileUpload(String name, String id, MultipartFile file) {
int lastInsertId = 0;
// Set the file path where you want to save it
String uploadDirectory = environment.getProperty("file.upload.directory");
String serviceFolderName = environment.getProperty("nulm_foldername");
var year = DateTimeUtil.getCurrentYear();
var month = DateTimeUtil.getCurrentMonth();
var date = DateTimeUtil.getCurrentDay();
uploadDirectory = uploadDirectory + serviceFolderName + year + "/" + month + "/" + date;
try {
// Create directory if it doesn't exist
Path directoryPath = Paths.get(uploadDirectory);
if (!Files.exists(directoryPath)) {
Files.createDirectories(directoryPath);
}
// Datetime string
String datetimetxt = DateTimeUtil.getCurrentDateTime();
// File name
System.out.println(file.getOriginalFilename());
String fileName = name + "_" + id + "_" + datetimetxt + "_"
+ file.getOriginalFilename();
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename
String filePath = uploadDirectory + "/" + fileName;
String filepath_txt = "/" + serviceFolderName + year + "/" + month + "/" + date + "/" + fileName;
// Create a new Path object
Path path = Paths.get(filePath);
// Get the bytes of the file
byte[] bytes = file.getBytes();
// Compress the image
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality
// Write the bytes to the file
Files.write(path, bytes);
System.out.println(filePath);
return filepath_txt;
} catch (IOException e) {
e.printStackTrace();
return "Failed to save file " + file.getOriginalFilename();
}
}
private byte[] compressImage(BufferedImage image, float quality) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream);
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
writer.setOutput(imageOutputStream);
ImageWriteParam param = writer.getDefaultWriteParam();
if (param.canWriteCompressed()) {
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(quality);
}
writer.write(null, new javax.imageio.IIOImage(image, null, null), param);
writer.dispose();
imageOutputStream.close();
return byteArrayOutputStream.toByteArray();
}
public boolean hasStaffUpdateAccess(String LoginUserId) {
String sql = "SELECT COUNT(*) FROM login_mapping_1913 " +
"WHERE appuser_id = ? AND isactive = 1 AND isdelete = 0";
Integer count = jdbcTemplate.queryForObject(sql, Integer.class, LoginUserId);
return count != null && count > 0;
}
public List<Map<String, Object>> getDesignations() {
String sql = "SELECT designation_id, designation " +
"FROM designation_master " +
"WHERE is_active = 1 AND is_delete = 0";
return jdbcTemplate.queryForList(sql);
}
} }

1509
gcc_officer_portal/src/main/resources/templates/modules/nulm/staffupdate.html
File diff suppressed because it is too large
View File

63
gcc_officer_portal/src/main/resources/templates/modules/nulm/staffupdatenoacess.html

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en" dir="">
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}"></head>
<body>
<div class="wrapper">
<header th:replace="~{fragments/modules/base/header :: header}"></header>
<div class="page-wrap">
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
<div class="main-content">
<div class="container-fluid">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-6">
<div class="page-header-title">
<i class="ik ik-thumbs-up bg-blue"></i>
<div class="d-inline">
<h5>NULM STAFF</h5>
<span>Salary Report</span>
</div>
</div>
</div>
<div class="col-lg-6">
<nav class="breadcrumb-container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/index"><i class="ik ik-home"></i></a>
</li>
<li class="breadcrumb-item active" aria-current="page">Salary Report</li>
</ol>
</nav>
</div>
</div>
</div>
<hr>
<div class="card-block mt-3">
<div class="text-center text-danger" style="font-size:20px; font-weight:bold;">
You Have No access for staff Update, Please contact admin...
</div>
</div>
</div>
</div>
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<div th:replace="~{fragments/modules/base/script :: script}"></div>
</body>
</html>
Loading…
Cancel
Save