Browse Source

new changes in adjustemnt project, toner management project, rental management project api's and pages

master
yoganandhank 2 days ago
parent
commit
5bf7d76bc8
  1. 2
      src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java
  2. 8
      src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java
  3. 224
      src/main/java/com/gcc_manpower/gccrentalmanagement/controller/RentalController.java
  4. 326
      src/main/java/com/gcc_manpower/gccrentalmanagement/service/RentalService.java
  5. 172
      src/main/java/com/gcc_manpower/gcctonermanagement/controller/TonerController.java
  6. 144
      src/main/java/com/gcc_manpower/gcctonermanagement/service/TonerService.java
  7. 11
      src/main/resources/templates/gccadjustmentmanagement/dashboard.html
  8. 19
      src/main/resources/templates/gccadjustmentmanagement/details.html
  9. 2666
      src/main/resources/templates/gccrentalmanagement/dashboard.html
  10. 1637
      src/main/resources/templates/gcctonermanagement/details.html
  11. 2
      src/main/resources/templates/gcctonermanagement/login.html
  12. 2484
      src/main/resources/templates/gcctonermanagement/upload.html

2
src/main/java/com/gcc_manpower/gccadjustmentmanagement/controller/AdjustmentController.java

@ -218,6 +218,7 @@ public class AdjustmentController {
@RequestParam(value = "fund_type_id", required = false) String fundTypeId, @RequestParam(value = "fund_type_id", required = false) String fundTypeId,
@RequestParam(value = "bal_amt", required = false) Double balAmt, @RequestParam(value = "bal_amt", required = false) Double balAmt,
@RequestParam(value = "file_remark", required = false) String fileRemark, @RequestParam(value = "file_remark", required = false) String fileRemark,
@RequestParam(value = "review_remark", required = false) String reviewRemark,
@RequestParam(value = "file_data_num", required = false) String fileDataNum, @RequestParam(value = "file_data_num", required = false) String fileDataNum,
@RequestParam(value = "pi_amt", required = false) Double piAmt, @RequestParam(value = "pi_amt", required = false) Double piAmt,
@RequestParam(value = "pi_file_gen_date", required = false) String piFileGenDate, @RequestParam(value = "pi_file_gen_date", required = false) String piFileGenDate,
@ -308,6 +309,7 @@ public class AdjustmentController {
data.put("fund_type_id", fundTypeId); data.put("fund_type_id", fundTypeId);
data.put("bal_amt", balAmt); data.put("bal_amt", balAmt);
data.put("file_remark", fileRemark); data.put("file_remark", fileRemark);
data.put("review_remark", reviewRemark);
data.put("file_data_num", fileDataNum); data.put("file_data_num", fileDataNum);
data.put("pi_amt", piAmt); data.put("pi_amt", piAmt);
data.put("pi_file_gen_date", piFileGenDate); data.put("pi_file_gen_date", piFileGenDate);

8
src/main/java/com/gcc_manpower/gccadjustmentmanagement/service/AdjustmentService.java

@ -219,7 +219,7 @@ public class AdjustmentService {
"as_file_gen_date = ?, as_file_path = ?, as_final_file_gen_date = ?, as_final_file_path = ?, " + "as_file_gen_date = ?, as_file_path = ?, as_final_file_gen_date = ?, as_final_file_path = ?, " +
"bal_amt = ?, dc_file_path = ?, ejv_num = ?, ejv_num_file_gen_date = ?, ejv_num_file_path = ?, " + "bal_amt = ?, dc_file_path = ?, ejv_num = ?, ejv_num_file_gen_date = ?, ejv_num_file_path = ?, " +
"fi_amt = ?, fi_file_gen_date = ?, fi_file_path = ?, file_data_num = ?, file_path = ?, " + "fi_amt = ?, fi_file_gen_date = ?, fi_file_path = ?, file_data_num = ?, file_path = ?, " +
"file_remark = ?, fin_year = ?, subject = ?, ir_file_path = ?, pi_amt = ?, pi_file_gen_date = ?, " +
"file_remark = ?, review_remark = ?, fin_year = ?, subject = ?, ir_file_path = ?, pi_amt = ?, pi_file_gen_date = ?, " +
"pi_file_path = ?, po_file_path = ?, rtgs_file_path = ?, sr_filepath = ?, tc_file_gen_date = ?, " + "pi_file_path = ?, po_file_path = ?, rtgs_file_path = ?, sr_filepath = ?, tc_file_gen_date = ?, " +
"tc_file_path = ?, vend_name = ?, adv_type_id = ?, fund_type_id = ?, ac_code = ?, " + "tc_file_path = ?, vend_name = ?, adv_type_id = ?, fund_type_id = ?, ac_code = ?, " +
"file_available_status = ?, dc_completed_date = ?, rtgs_date = ?, file_status_id = ?, updated_date = ?, updated_by = ? WHERE id = ?"; "file_available_status = ?, dc_completed_date = ?, rtgs_date = ?, file_status_id = ?, updated_date = ?, updated_by = ? WHERE id = ?";
@ -240,6 +240,7 @@ public class AdjustmentService {
data.get("file_data_num"), data.get("file_data_num"),
data.get("file_path"), data.get("file_path"),
data.get("file_remark"), data.get("file_remark"),
data.get("review_remark"),
data.get("fin_year"), data.get("fin_year"),
data.get("subject"), data.get("subject"),
data.get("ir_file_path"), data.get("ir_file_path"),
@ -274,12 +275,12 @@ public class AdjustmentService {
"as_file_gen_date, as_file_path, as_final_file_gen_date, as_final_file_path, " + "as_file_gen_date, as_file_path, as_final_file_gen_date, as_final_file_path, " +
"bal_amt, dc_file_path, ejv_num, ejv_num_file_gen_date, ejv_num_file_path, " + "bal_amt, dc_file_path, ejv_num, ejv_num_file_gen_date, ejv_num_file_path, " +
"fi_amt, fi_file_gen_date, fi_file_path, file_data_num, file_path, " + "fi_amt, fi_file_gen_date, fi_file_path, file_data_num, file_path, " +
"file_remark, fin_year, subject, ir_file_path, pi_amt, pi_file_gen_date, " +
"file_remark, review_remark, fin_year, subject, ir_file_path, pi_amt, pi_file_gen_date, " +
"pi_file_path, po_file_path, rtgs_file_path, sr_filepath, tc_file_gen_date, " + "pi_file_path, po_file_path, rtgs_file_path, sr_filepath, tc_file_gen_date, " +
"tc_file_path, vend_name, adv_type_id, fund_type_id, ac_code, file_available_status, " + "tc_file_path, vend_name, adv_type_id, fund_type_id, ac_code, file_available_status, " +
"dc_completed_date, rtgs_date, file_status_id, cdate, updated_date, updated_by, is_active, is_delete) VALUES " "dc_completed_date, rtgs_date, file_status_id, cdate, updated_date, updated_by, is_active, is_delete) VALUES "
+ +
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)";
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)";
try { try {
int rows = jdbcTemplate.update(sql, int rows = jdbcTemplate.update(sql,
parseDate(data.get("as_file_gen_date")), parseDate(data.get("as_file_gen_date")),
@ -297,6 +298,7 @@ public class AdjustmentService {
data.get("file_data_num"), data.get("file_data_num"),
data.get("file_path"), data.get("file_path"),
data.get("file_remark"), data.get("file_remark"),
data.get("review_remark"),
data.get("fin_year"), data.get("fin_year"),
data.get("subject"), data.get("subject"),
data.get("ir_file_path"), data.get("ir_file_path"),

224
src/main/java/com/gcc_manpower/gccrentalmanagement/controller/RentalController.java

@ -5,6 +5,7 @@ import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -87,7 +88,8 @@ public class RentalController {
Map<String, Object> response = new HashMap<>(); Map<String, Object> response = new HashMap<>();
try { try {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(usrName, usrPass);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(usrName,
usrPass);
Authentication authentication = authenticationManager.authenticate(authenticationToken); Authentication authentication = authenticationManager.authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
@ -146,6 +148,12 @@ public class RentalController {
return rentalService.getActiveZones(); return rentalService.getActiveZones();
} }
@GetMapping("/api/categories")
@ResponseBody
public List<Map<String, Object>> getCategories(HttpSession session) {
return rentalService.getActiveCategories();
}
@GetMapping("/api/vendors") @GetMapping("/api/vendors")
@ResponseBody @ResponseBody
public List<Map<String, Object>> getVendors(HttpSession session) { public List<Map<String, Object>> getVendors(HttpSession session) {
@ -178,12 +186,9 @@ public class RentalController {
@RequestParam("periodFromDate") String periodFromDate, @RequestParam("periodFromDate") String periodFromDate,
@RequestParam("periodToDate") String periodToDate, @RequestParam("periodToDate") String periodToDate,
@RequestParam("vendorName") String vendorName, @RequestParam("vendorName") String vendorName,
@RequestParam(value = "systemsQty", defaultValue = "0") Integer systemsQty,
@RequestParam(value = "systemsModel", defaultValue = "") String systemsModel,
@RequestParam(value = "printersQty", defaultValue = "0") Integer printersQty,
@RequestParam(value = "printersModel", defaultValue = "") String printersModel,
@RequestParam(value = "laptopsQty", defaultValue = "0") Integer laptopsQty,
@RequestParam(value = "laptopsModel", defaultValue = "") String laptopsModel,
@RequestParam(value = "cid", required = false) List<String> cids,
@RequestParam(value = "categoryQty", required = false) List<String> categoryQtys,
@RequestParam(value = "categoryModelName", required = false) List<String> categoryModelNames,
@RequestParam(value = "woCopyFile", required = false) MultipartFile woCopyFile, @RequestParam(value = "woCopyFile", required = false) MultipartFile woCopyFile,
@RequestParam(value = "remarks", defaultValue = "") String remarks, @RequestParam(value = "remarks", defaultValue = "") String remarks,
HttpSession session) { HttpSession session) {
@ -196,23 +201,81 @@ public class RentalController {
return response; return response;
} }
if (cids == null || cids.isEmpty()) {
response.put("success", false);
response.put("error", "Please add at least one Asset Category.");
return response;
}
List<Map<String, Object>> categoryItems = new ArrayList<>();
for (int i = 0; i < cids.size(); i++) {
String cidStr = cids.get(i);
String qtyStr = (categoryQtys != null && i < categoryQtys.size()) ? categoryQtys.get(i) : "0";
String model = (categoryModelNames != null && i < categoryModelNames.size()) ? categoryModelNames.get(i)
: "";
Integer cid = null;
try { try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) uploadDir.mkdirs();
if (cidStr != null && !cidStr.trim().isEmpty()) {
cid = Integer.parseInt(cidStr.trim());
}
} catch (Exception ignored) {
}
Integer qty = null;
try {
if (qtyStr != null && !qtyStr.trim().isEmpty()) {
qty = Integer.parseInt(qtyStr.trim());
}
} catch (Exception ignored) {
}
if (cid == null || cid <= 0) {
response.put("success", false);
response.put("error", "Please select a valid Asset Category for all items.");
return response;
}
if (qty == null || qty <= 0) {
response.put("success", false);
response.put("error", "Category Quantity must be greater than 0 for all items.");
return response;
}
if (model == null || model.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Asset Model Name / Specifications is mandatory for all items.");
return response;
}
String woCopyPath = null;
if (woCopyFile != null && !woCopyFile.isEmpty()) {
woCopyPath = saveUploadedFile(woCopyFile, "wo", uploadDir);
Map<String, Object> item = new HashMap<>();
item.put("cid", cid);
item.put("categoryQty", qty);
item.put("categoryModelName", model.trim());
categoryItems.add(item);
}
if (woCopyFile == null || woCopyFile.isEmpty()) {
response.put("success", false);
response.put("error", "Upload Work Order Copy (PDF / Doc) is mandatory.");
return response;
} }
boolean saved = rentalService.saveWorkOrder(
try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists())
uploadDir.mkdirs();
String woCopyPath = saveUploadedFile(woCopyFile, "wo", uploadDir);
boolean saved = rentalService.saveWorkOrders(
woFileNo, fileSubject, periodFromDate, periodToDate, vendorName, woFileNo, fileSubject, periodFromDate, periodToDate, vendorName,
systemsQty, systemsModel, printersQty, printersModel,
laptopsQty, laptopsModel, woCopyPath, remarks, username);
categoryItems, woCopyPath, remarks, username);
if (saved) { if (saved) {
response.put("success", true); response.put("success", true);
response.put("message", "Work order registered successfully.");
response.put("message",
"Work order registered successfully with " + categoryItems.size() + " category item(s).");
} else { } else {
response.put("success", false); response.put("success", false);
response.put("error", "Failed to save work order to database."); response.put("error", "Failed to save work order to database.");
@ -241,9 +304,9 @@ public class RentalController {
@RequestParam("tapalDate") String tapalDate, @RequestParam("tapalDate") String tapalDate,
@RequestParam("deptId") Integer deptId, @RequestParam("deptId") Integer deptId,
@RequestParam(value = "zoneId", required = false) Integer zoneId, @RequestParam(value = "zoneId", required = false) Integer zoneId,
@RequestParam(value = "reqSystemsQty", defaultValue = "0") Integer reqSystemsQty,
@RequestParam(value = "reqPrintersQty", defaultValue = "0") Integer reqPrintersQty,
@RequestParam(value = "reqLaptopsQty", defaultValue = "0") Integer reqLaptopsQty,
@RequestParam(value = "cid", required = false) List<Integer> cids,
@RequestParam(value = "categoryQty", required = false) List<Integer> categoryQtys,
@RequestParam(value = "categoryModelName", required = false) List<String> categoryModelNames,
@RequestParam("requiredFromDate") String requiredFromDate, @RequestParam("requiredFromDate") String requiredFromDate,
@RequestParam("requiredToDate") String requiredToDate, @RequestParam("requiredToDate") String requiredToDate,
@RequestParam(value = "mailCopyFile", required = false) MultipartFile mailCopyFile, @RequestParam(value = "mailCopyFile", required = false) MultipartFile mailCopyFile,
@ -261,24 +324,65 @@ public class RentalController {
return response; return response;
} }
if (cids == null || cids.isEmpty()) {
response.put("success", false);
response.put("error", "Please add at least one requested asset category.");
return response;
}
List<Map<String, Object>> categoryItems = new ArrayList<>();
for (int i = 0; i < cids.size(); i++) {
Integer cid = cids.get(i);
Integer qty = (categoryQtys != null && i < categoryQtys.size()) ? categoryQtys.get(i) : 1;
String model = (categoryModelNames != null && i < categoryModelNames.size()) ? categoryModelNames.get(i) : "";
if (cid == null || cid <= 0) {
response.put("success", false);
response.put("error", "Please select a valid Requested Asset Category for all items.");
return response;
}
if (qty == null || qty <= 0) {
response.put("success", false);
response.put("error", "Requested Category Quantity must be greater than 0 for all items.");
return response;
}
if (model == null || model.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Requested Model Name / Specifications is mandatory for all items.");
return response;
}
Map<String, Object> item = new HashMap<>();
item.put("cid", cid);
item.put("categoryQty", qty);
item.put("categoryModelName", model.trim());
categoryItems.add(item);
}
if (mailCopyFile == null || mailCopyFile.isEmpty()) {
response.put("success", false);
response.put("error", "Please upload the Mail Copy (PDF / Scan).");
return response;
}
try { try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile(); File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) uploadDir.mkdirs();
if (!uploadDir.exists())
uploadDir.mkdirs();
String mailCopyPath = null;
if (mailCopyFile != null && !mailCopyFile.isEmpty()) {
mailCopyPath = saveUploadedFile(mailCopyFile, "request_mail", uploadDir);
}
String mailCopyPath = saveUploadedFile(mailCopyFile, "request_mail", uploadDir);
boolean saved = rentalService.saveUserRequest(
boolean saved = rentalService.saveUserRequests(
tapalNo, tapalDate, deptId, zoneId, tapalNo, tapalDate, deptId, zoneId,
reqSystemsQty, reqPrintersQty, reqLaptopsQty,
categoryItems,
requiredFromDate, requiredToDate, mailCopyPath, reqStatusId, requiredFromDate, requiredToDate, mailCopyPath, reqStatusId,
requestingOfficer, contactNo, purpose, username); requestingOfficer, contactNo, purpose, username);
if (saved) { if (saved) {
response.put("success", true); response.put("success", true);
response.put("message", "Department request registered successfully.");
response.put("message", "Department request registered successfully with " + categoryItems.size() + " category item(s).");
} else { } else {
response.put("success", false); response.put("success", false);
response.put("error", "Failed to save department request."); response.put("error", "Failed to save department request.");
@ -310,6 +414,8 @@ public class RentalController {
@RequestParam(value = "inSystemsQty", defaultValue = "0") Integer inSystemsQty, @RequestParam(value = "inSystemsQty", defaultValue = "0") Integer inSystemsQty,
@RequestParam(value = "inPrintersQty", defaultValue = "0") Integer inPrintersQty, @RequestParam(value = "inPrintersQty", defaultValue = "0") Integer inPrintersQty,
@RequestParam(value = "inLaptopsQty", defaultValue = "0") Integer inLaptopsQty, @RequestParam(value = "inLaptopsQty", defaultValue = "0") Integer inLaptopsQty,
@RequestParam(value = "inUpsQty", defaultValue = "0") Integer inUpsQty,
@RequestParam(value = "inDongleQty", defaultValue = "0") Integer inDongleQty,
@RequestParam(value = "dcFile", required = false) MultipartFile dcFile, @RequestParam(value = "dcFile", required = false) MultipartFile dcFile,
@RequestParam(value = "vehicleNo", defaultValue = "") String vehicleNo, @RequestParam(value = "vehicleNo", defaultValue = "") String vehicleNo,
@RequestParam(value = "receivedBy", defaultValue = "") String receivedBy, @RequestParam(value = "receivedBy", defaultValue = "") String receivedBy,
@ -326,7 +432,8 @@ public class RentalController {
try { try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile(); File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) uploadDir.mkdirs();
if (!uploadDir.exists())
uploadDir.mkdirs();
String dcFilePath = null; String dcFilePath = null;
if (dcFile != null && !dcFile.isEmpty()) { if (dcFile != null && !dcFile.isEmpty()) {
@ -335,7 +442,7 @@ public class RentalController {
boolean saved = rentalService.saveInwardChallan( boolean saved = rentalService.saveInwardChallan(
woId, dcNo, dcDate, vendorName, woId, dcNo, dcDate, vendorName,
inSystemsQty, inPrintersQty, inLaptopsQty,
inSystemsQty, inPrintersQty, inLaptopsQty, inUpsQty, inDongleQty,
dcFilePath, vehicleNo, receivedBy, remarks, username); dcFilePath, vehicleNo, receivedBy, remarks, username);
if (saved) { if (saved) {
@ -369,6 +476,10 @@ public class RentalController {
@RequestParam(value = "inwardDcId", required = false) Integer inwardDcId, @RequestParam(value = "inwardDcId", required = false) Integer inwardDcId,
@RequestParam(value = "woId", required = false) Integer woId, @RequestParam(value = "woId", required = false) Integer woId,
@RequestParam("issuedDate") String issuedDate, @RequestParam("issuedDate") String issuedDate,
@RequestParam(value = "cid", required = false) List<String> cids,
@RequestParam(value = "categoryModelName", required = false) List<String> categoryModelNames,
@RequestParam(value = "requestedQty", required = false) List<String> requestedQtys,
@RequestParam(value = "issuedQty", required = false) List<String> issuedQtys,
@RequestParam(value = "issuedSystemsQty", defaultValue = "0") Integer issuedSystemsQty, @RequestParam(value = "issuedSystemsQty", defaultValue = "0") Integer issuedSystemsQty,
@RequestParam(value = "issuedPrintersQty", defaultValue = "0") Integer issuedPrintersQty, @RequestParam(value = "issuedPrintersQty", defaultValue = "0") Integer issuedPrintersQty,
@RequestParam(value = "issuedLaptopsQty", defaultValue = "0") Integer issuedLaptopsQty, @RequestParam(value = "issuedLaptopsQty", defaultValue = "0") Integer issuedLaptopsQty,
@ -391,15 +502,57 @@ public class RentalController {
try { try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile(); File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) uploadDir.mkdirs();
if (!uploadDir.exists())
uploadDir.mkdirs();
String stockCopyPath = null;
if (stockCopyFile != null && !stockCopyFile.isEmpty()) {
stockCopyPath = saveUploadedFile(stockCopyFile, "issue_stock", uploadDir);
if (stockCopyFile == null || stockCopyFile.isEmpty()) {
response.put("success", false);
response.put("error", "Upload Stock Issue Copy (Acknowledgment / Handover Slip) is mandatory.");
return response;
}
String stockCopyPath = saveUploadedFile(stockCopyFile, "issue_stock", uploadDir);
List<Map<String, Object>> itemDetails = new ArrayList<>();
if (cids != null && !cids.isEmpty()) {
for (int i = 0; i < cids.size(); i++) {
String cidStr = cids.get(i);
Integer cid = null;
try {
if (cidStr != null && !cidStr.trim().isEmpty()) {
cid = Integer.parseInt(cidStr.trim());
}
} catch (Exception ignored) {
}
Integer reqQty = 0;
try {
if (requestedQtys != null && i < requestedQtys.size() && requestedQtys.get(i) != null) {
reqQty = Integer.parseInt(requestedQtys.get(i).trim());
}
} catch (Exception ignored) {
}
Integer issQty = 0;
try {
if (issuedQtys != null && i < issuedQtys.size() && issuedQtys.get(i) != null) {
issQty = Integer.parseInt(issuedQtys.get(i).trim());
}
} catch (Exception ignored) {
}
String model = (categoryModelNames != null && i < categoryModelNames.size()) ? categoryModelNames.get(i) : "";
Map<String, Object> item = new HashMap<>();
item.put("cid", cid);
item.put("categoryModelName", model != null ? model.trim() : "");
item.put("requestedQty", reqQty);
item.put("issuedQty", issQty);
itemDetails.add(item);
}
} }
boolean saved = rentalService.saveIssuedDetails( boolean saved = rentalService.saveIssuedDetails(
requestId, inwardDcId, woId, issuedDate,
requestId, inwardDcId, woId, itemDetails, issuedDate,
issuedSystemsQty, issuedPrintersQty, issuedLaptopsQty, issuedSystemsQty, issuedPrintersQty, issuedLaptopsQty,
assetSerialDetails, issuedFromDate, issuedToDate, stockCopyPath, assetSerialDetails, issuedFromDate, issuedToDate, stockCopyPath,
custodianOfficer, contactNo, issuedBy, username); custodianOfficer, contactNo, issuedBy, username);
@ -455,7 +608,8 @@ public class RentalController {
try { try {
File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile(); File uploadDir = new File(rentalUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) uploadDir.mkdirs();
if (!uploadDir.exists())
uploadDir.mkdirs();
String stockCopyPath = null; String stockCopyPath = null;
if (stockCopyFile != null && !stockCopyFile.isEmpty()) { if (stockCopyFile != null && !stockCopyFile.isEmpty()) {

326
src/main/java/com/gcc_manpower/gccrentalmanagement/service/RentalService.java

@ -27,16 +27,58 @@ public class RentalService {
@Autowired @Autowired
public void setDataSource(@Qualifier("mysqlItcellManagementDataSource") DataSource dataSource) { public void setDataSource(@Qualifier("mysqlItcellManagementDataSource") DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
}
public JdbcTemplate getJdbcTemplate() {
return this.jdbcTemplate;
} }
// ========================================================================= // =========================================================================
// 1. MASTER LOOKUPS (Departments, Zones, Vendors, Master Statuses)
// 1. MASTER LOOKUPS (Categories, Departments, Zones, Vendors, Master Statuses)
// ========================================================================= // =========================================================================
public List<Map<String, Object>> getActiveCategories() {
String sql = "SELECT id, category_type, category_type AS category_name, order_by, is_active "
+ "FROM rental_category_master "
+ "WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) "
+ "ORDER BY COALESCE(order_by, id) ASC, id ASC";
try {
return jdbcTemplate.queryForList(sql);
} catch (Exception e1) {
try {
return jdbcTemplate.queryForList(
"SELECT id, category_type, category_type AS category_name FROM rental_category_master WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) ORDER BY id ASC");
} catch (Exception e2) {
try {
return jdbcTemplate
.queryForList(
"SELECT id, category_type, category_type AS category_name FROM rental_category_master ORDER BY id ASC");
} catch (Exception e3) {
try {
List<Map<String, Object>> rows = jdbcTemplate
.queryForList("SELECT * FROM rental_category_master");
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> r : rows) {
Map<String, Object> map = new HashMap<>();
map.put("id", r.get("id"));
Object catType = r.get("category_type") != null ? r.get("category_type")
: (r.get("category_name") != null ? r.get("category_name")
: (r.get("name") != null ? r.get("name")
: (r.get("category") != null ? r.get("category")
: (r.get("cat_name") != null ? r.get("cat_name")
: "Category " + r.get("id")))));
String catStr = catType != null ? catType.toString() : "Category " + r.get("id");
map.put("category_type", catStr);
map.put("category_name", catStr);
result.add(map);
}
return result;
} catch (Exception e4) {
e4.printStackTrace();
return new ArrayList<>();
}
}
}
}
}
public List<Map<String, Object>> getActiveDepartments() { public List<Map<String, Object>> getActiveDepartments() {
String sql = "SELECT id, dept_name FROM toner_department_list WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) ORDER BY dept_name ASC"; String sql = "SELECT id, dept_name FROM toner_department_list WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) ORDER BY dept_name ASC";
try { try {
@ -110,43 +152,98 @@ public class RentalService {
// ========================================================================= // =========================================================================
@Transactional @Transactional
public boolean saveWorkOrder(String woFileNo, String fileSubject, String fromDate, String toDate,
String vendorName, Integer systemsQty, String systemsModel,
Integer printersQty, String printersModel, Integer laptopsQty,
String laptopsModel, String woCopyPath, String remarks, String updatedBy) {
public boolean saveWorkOrders(String woFileNo, String fileSubject, String fromDate, String toDate,
String vendorName, List<Map<String, Object>> categoryItems,
String woCopyPath, String remarks, String updatedBy) {
String sql = "INSERT INTO rental_workorder_register " + String sql = "INSERT INTO rental_workorder_register " +
"(wo_file_no, file_subject, period_from_date, period_to_date, vendor_name, " + "(wo_file_no, file_subject, period_from_date, period_to_date, vendor_name, " +
"systems_qty, systems_model_name, printers_qty, printers_model_name, " +
"laptops_qty, laptops_model_name, wo_copy_file, status, remarks, created_by, is_active, is_delete) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Active', ?, ?, 1, 0)";
"cid, category_qty, category_model_name, wo_copy_file, status, remarks, created_by, is_active, is_delete) "
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'Active', ?, ?, 1, 0)";
try { try {
int rows = jdbcTemplate.update(sql,
if (categoryItems == null || categoryItems.isEmpty()) {
return false;
}
for (Map<String, Object> item : categoryItems) {
Integer cid = item.get("cid") != null ? Integer.valueOf(item.get("cid").toString()) : null;
Integer qty = item.get("categoryQty") != null ? Integer.valueOf(item.get("categoryQty").toString()) : 0;
String model = item.get("categoryModelName") != null ? item.get("categoryModelName").toString() : "";
jdbcTemplate.update(sql,
woFileNo != null ? woFileNo.trim() : null, woFileNo != null ? woFileNo.trim() : null,
fileSubject != null ? fileSubject.trim() : null, fileSubject != null ? fileSubject.trim() : null,
fromDate, toDate, fromDate, toDate,
vendorName != null ? vendorName.trim() : null, vendorName != null ? vendorName.trim() : null,
systemsQty != null ? systemsQty : 0,
systemsModel != null ? systemsModel.trim() : "",
printersQty != null ? printersQty : 0,
printersModel != null ? printersModel.trim() : "",
laptopsQty != null ? laptopsQty : 0,
laptopsModel != null ? laptopsModel.trim() : "",
cid,
qty,
model != null ? model.trim() : "",
woCopyPath, remarks, updatedBy); woCopyPath, remarks, updatedBy);
return rows > 0;
}
return true;
} catch (Exception e) { } catch (Exception e) {
String msg = e.getMessage() != null ? e.getMessage().toLowerCase() : "";
if (msg.contains("idx_wo_file_no") || msg.contains("duplicate entry") || msg.contains("constraint")) {
try {
for (Map<String, Object> item : categoryItems) {
Integer cid = item.get("cid") != null ? Integer.valueOf(item.get("cid").toString()) : null;
Integer qty = item.get("categoryQty") != null
? Integer.valueOf(item.get("categoryQty").toString())
: 0;
String model = item.get("categoryModelName") != null ? item.get("categoryModelName").toString()
: "";
jdbcTemplate.update(sql,
woFileNo != null ? woFileNo.trim() : null,
fileSubject != null ? fileSubject.trim() : null,
fromDate, toDate,
vendorName != null ? vendorName.trim() : null,
cid,
qty,
model != null ? model.trim() : "",
woCopyPath, remarks, updatedBy);
}
return true;
} catch (Exception retryEx) {
retryEx.printStackTrace();
}
}
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} }
@Transactional
public boolean saveWorkOrder(String woFileNo, String fileSubject, String fromDate, String toDate,
String vendorName, Integer cid, Integer categoryQty, String categoryModelName,
String woCopyPath, String remarks, String updatedBy) {
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("cid", cid);
map.put("categoryQty", categoryQty);
map.put("categoryModelName", categoryModelName);
list.add(map);
return saveWorkOrders(woFileNo, fileSubject, fromDate, toDate, vendorName, list, woCopyPath, remarks,
updatedBy);
}
public List<Map<String, Object>> getAllWorkOrders() { public List<Map<String, Object>> getAllWorkOrders() {
String sql = "SELECT id, wo_file_no, file_subject, period_from_date, period_to_date, vendor_name, " +
"systems_qty, systems_model_name, printers_qty, printers_model_name, " +
"laptops_qty, laptops_model_name, (systems_qty + printers_qty + laptops_qty) AS total_units, " +
"wo_copy_file, status, remarks, created_by, created_at " +
"FROM rental_workorder_register " +
String sql = "SELECT w.id, w.wo_file_no, w.file_subject, w.period_from_date, w.period_to_date, w.vendor_name, "
+
"w.cid, COALESCE(c.category_type, 'General') AS category_name, c.category_type, " +
"w.category_qty, w.category_model_name, " +
"COALESCE(w.category_qty, 0) AS total_units, " +
"COALESCE(dc.inwarded_qty, 0) AS total_inwarded_qty, " +
"w.wo_copy_file, w.status, w.remarks, w.created_by, w.created_at " +
"FROM rental_workorder_register w " +
"LEFT JOIN rental_category_master c ON w.cid = c.id " +
"LEFT JOIN (" +
" SELECT wo_id, " +
" SUM(COALESCE(inward_systems_qty, 0) + COALESCE(inward_printers_qty, 0) + COALESCE(inward_laptops_qty, 0) + COALESCE(inward_ups_qty, 0) + COALESCE(inward_dongle_qty, 0)) AS inwarded_qty "
+
" FROM rental_inward_delivery_challan " +
" WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) " + " WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) " +
"ORDER BY id DESC";
" GROUP BY wo_id" +
") dc ON w.id = dc.wo_id " +
"WHERE (w.is_active IS NULL OR w.is_active = 1) AND (w.is_delete IS NULL OR w.is_delete = 0) " +
"ORDER BY w.id DESC";
try { try {
return jdbcTemplate.queryForList(sql); return jdbcTemplate.queryForList(sql);
} catch (Exception e) { } catch (Exception e) {
@ -155,7 +252,24 @@ public class RentalService {
} }
public Map<String, Object> getWorkOrderById(int id) { public Map<String, Object> getWorkOrderById(int id) {
String sql = "SELECT * FROM rental_workorder_register WHERE id = ?";
String sql = "SELECT w.id, w.wo_file_no, w.file_subject, w.period_from_date, w.period_to_date, w.vendor_name, "
+
"w.cid, COALESCE(c.category_type, 'General') AS category_name, c.category_type, " +
"w.category_qty, w.category_model_name, " +
"COALESCE(w.category_qty, 0) AS total_units, " +
"COALESCE(dc.inwarded_qty, 0) AS total_inwarded_qty, " +
"w.wo_copy_file, w.status, w.remarks, w.created_by, w.created_at " +
"FROM rental_workorder_register w " +
"LEFT JOIN rental_category_master c ON w.cid = c.id " +
"LEFT JOIN (" +
" SELECT wo_id, " +
" SUM(COALESCE(inward_systems_qty, 0) + COALESCE(inward_printers_qty, 0) + COALESCE(inward_laptops_qty, 0) + COALESCE(inward_ups_qty, 0) + COALESCE(inward_dongle_qty, 0)) AS inwarded_qty "
+
" FROM rental_inward_delivery_challan " +
" WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) " +
" GROUP BY wo_id" +
") dc ON w.id = dc.wo_id " +
"WHERE w.id = ?";
try { try {
return jdbcTemplate.queryForMap(sql, id); return jdbcTemplate.queryForMap(sql, id);
} catch (Exception e) { } catch (Exception e) {
@ -168,8 +282,8 @@ public class RentalService {
// ========================================================================= // =========================================================================
@Transactional @Transactional
public boolean saveUserRequest(String tapalNo, String tapalDate, Integer deptId, Integer zoneId,
Integer reqSystemsQty, Integer reqPrintersQty, Integer reqLaptopsQty,
public boolean saveUserRequests(String tapalNo, String tapalDate, Integer deptId, Integer zoneId,
List<Map<String, Object>> categoryItems,
String fromDate, String toDate, String mailCopyPath, Integer statusId, String fromDate, String toDate, String mailCopyPath, Integer statusId,
String requestingOfficer, String contactNo, String purpose, String updatedBy) { String requestingOfficer, String contactNo, String purpose, String updatedBy) {
@ -178,42 +292,96 @@ public class RentalService {
String sql = "INSERT INTO rental_user_request " + String sql = "INSERT INTO rental_user_request " +
"(tapal_no, tapal_date, department_id, zone_id, " + "(tapal_no, tapal_date, department_id, zone_id, " +
"req_systems_qty, req_printers_qty, req_laptops_qty, " +
"required_from_date, required_to_date, calculated_days, " + "required_from_date, required_to_date, calculated_days, " +
"cid, category_qty, category_model_name, " +
"mail_copy_file, req_status_id, requesting_officer, contact_no, purpose, " + "mail_copy_file, req_status_id, requesting_officer, contact_no, purpose, " +
"created_by, is_active, is_delete) " + "created_by, is_active, is_delete) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)"; "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)";
try { try {
int rows = jdbcTemplate.update(sql,
for (Map<String, Object> item : categoryItems) {
Integer cid = item.get("cid") != null ? Integer.valueOf(item.get("cid").toString()) : null;
Integer qty = item.get("categoryQty") != null ? Integer.valueOf(item.get("categoryQty").toString()) : 0;
String model = item.get("categoryModelName") != null ? item.get("categoryModelName").toString() : "";
jdbcTemplate.update(sql,
tapalNo != null ? tapalNo.trim() : null, tapalNo != null ? tapalNo.trim() : null,
tapalDate, tapalDate,
deptId, zoneId, deptId, zoneId,
reqSystemsQty != null ? reqSystemsQty : 0,
reqPrintersQty != null ? reqPrintersQty : 0,
reqLaptopsQty != null ? reqLaptopsQty : 0,
fromDate, toDate, calculatedDays, fromDate, toDate, calculatedDays,
cid,
qty,
model != null ? model.trim() : "",
mailCopyPath, finalStatusId, mailCopyPath, finalStatusId,
requestingOfficer != null ? requestingOfficer.trim() : null, requestingOfficer != null ? requestingOfficer.trim() : null,
contactNo != null ? contactNo.trim() : null, contactNo != null ? contactNo.trim() : null,
purpose, updatedBy); purpose, updatedBy);
return rows > 0;
}
return true;
} catch (Exception e) { } catch (Exception e) {
String msg = e.getMessage() != null ? e.getMessage().toLowerCase() : "";
if (msg.contains("idx_tapal_no") || msg.contains("duplicate entry") || msg.contains("constraint")) {
try {
for (Map<String, Object> item : categoryItems) {
Integer cid = item.get("cid") != null ? Integer.valueOf(item.get("cid").toString()) : null;
Integer qty = item.get("categoryQty") != null
? Integer.valueOf(item.get("categoryQty").toString())
: 0;
String model = item.get("categoryModelName") != null ? item.get("categoryModelName").toString()
: "";
jdbcTemplate.update(sql,
tapalNo != null ? tapalNo.trim() : null,
tapalDate,
deptId, zoneId,
fromDate, toDate, calculatedDays,
cid,
qty,
model != null ? model.trim() : "",
mailCopyPath, finalStatusId,
requestingOfficer != null ? requestingOfficer.trim() : null,
contactNo != null ? contactNo.trim() : null,
purpose, updatedBy);
}
return true;
} catch (Exception retryEx) {
retryEx.printStackTrace();
}
}
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} }
@Transactional
public boolean saveUserRequest(String tapalNo, String tapalDate, Integer deptId, Integer zoneId,
Integer cid, Integer categoryQty, String categoryModelName,
String fromDate, String toDate, String mailCopyPath, Integer statusId,
String requestingOfficer, String contactNo, String purpose, String updatedBy) {
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("cid", cid);
map.put("categoryQty", categoryQty);
map.put("categoryModelName", categoryModelName);
list.add(map);
return saveUserRequests(tapalNo, tapalDate, deptId, zoneId, list, fromDate, toDate, mailCopyPath, statusId,
requestingOfficer, contactNo, purpose, updatedBy);
}
public List<Map<String, Object>> getAllUserRequests() { public List<Map<String, Object>> getAllUserRequests() {
String sql = "SELECT r.id, r.tapal_no, r.tapal_date, r.department_id, d.dept_name, " + String sql = "SELECT r.id, r.tapal_no, r.tapal_date, r.department_id, d.dept_name, " +
"r.zone_id, z.zone_name, r.req_systems_qty, r.req_printers_qty, r.req_laptops_qty, " +
"(r.req_systems_qty + r.req_printers_qty + r.req_laptops_qty) AS total_req_qty, " +
"r.required_from_date, r.required_to_date, r.calculated_days, r.mail_copy_file, " +
"r.zone_id, z.zone_name, " +
"r.required_from_date, r.required_to_date, r.calculated_days, " +
"r.cid, COALESCE(c.category_type, 'General') AS category_name, c.category_type, " +
"r.category_qty, r.category_model_name, " +
"COALESCE(r.category_qty, 0) AS total_req_qty, " +
"r.mail_copy_file, " +
"r.req_status_id, COALESCE(s.status_name, 'Pending') AS status_name, " + "r.req_status_id, COALESCE(s.status_name, 'Pending') AS status_name, " +
"COALESCE(s.badge_color, 'warning') AS badge_color, " + "COALESCE(s.badge_color, 'warning') AS badge_color, " +
"r.requesting_officer, r.contact_no, r.purpose, r.created_by, r.created_at " + "r.requesting_officer, r.contact_no, r.purpose, r.created_by, r.created_at " +
"FROM rental_user_request r " + "FROM rental_user_request r " +
"LEFT JOIN toner_department_list d ON r.department_id = d.id " + "LEFT JOIN toner_department_list d ON r.department_id = d.id " +
"LEFT JOIN toner_zone_list z ON r.zone_id = z.id " + "LEFT JOIN toner_zone_list z ON r.zone_id = z.id " +
"LEFT JOIN rental_category_master c ON r.cid = c.id " +
"LEFT JOIN rental_master_status_list s ON r.req_status_id = s.id " + "LEFT JOIN rental_master_status_list s ON r.req_status_id = s.id " +
"WHERE (r.is_active IS NULL OR r.is_active = 1) AND (r.is_delete IS NULL OR r.is_delete = 0) " + "WHERE (r.is_active IS NULL OR r.is_active = 1) AND (r.is_delete IS NULL OR r.is_delete = 0) " +
"ORDER BY r.id DESC"; "ORDER BY r.id DESC";
@ -241,13 +409,14 @@ public class RentalService {
@Transactional @Transactional
public boolean saveInwardChallan(Integer woId, String dcNo, String dcDate, String vendorName, public boolean saveInwardChallan(Integer woId, String dcNo, String dcDate, String vendorName,
Integer inSystemsQty, Integer inPrintersQty, Integer inLaptopsQty, Integer inSystemsQty, Integer inPrintersQty, Integer inLaptopsQty,
Integer inUpsQty, Integer inDongleQty,
String dcFilePath, String vehicleNo, String receivedBy, String dcFilePath, String vehicleNo, String receivedBy,
String remarks, String updatedBy) { String remarks, String updatedBy) {
String sql = "INSERT INTO rental_inward_delivery_challan " + String sql = "INSERT INTO rental_inward_delivery_challan " +
"(wo_id, dc_no, dc_date, vendor_name, " + "(wo_id, dc_no, dc_date, vendor_name, " +
"inward_systems_qty, inward_printers_qty, inward_laptops_qty, " +
"inward_systems_qty, inward_printers_qty, inward_laptops_qty, inward_ups_qty, inward_dongle_qty, " +
"dc_file_path, vehicle_no, received_by, remarks, created_by, is_active, is_delete) " + "dc_file_path, vehicle_no, received_by, remarks, created_by, is_active, is_delete) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)";
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, 0)";
try { try {
int rows = jdbcTemplate.update(sql, int rows = jdbcTemplate.update(sql,
woId, woId,
@ -257,6 +426,8 @@ public class RentalService {
inSystemsQty != null ? inSystemsQty : 0, inSystemsQty != null ? inSystemsQty : 0,
inPrintersQty != null ? inPrintersQty : 0, inPrintersQty != null ? inPrintersQty : 0,
inLaptopsQty != null ? inLaptopsQty : 0, inLaptopsQty != null ? inLaptopsQty : 0,
inUpsQty != null ? inUpsQty : 0,
inDongleQty != null ? inDongleQty : 0,
dcFilePath, dcFilePath,
vehicleNo != null ? vehicleNo.trim() : null, vehicleNo != null ? vehicleNo.trim() : null,
receivedBy != null ? receivedBy.trim() : null, receivedBy != null ? receivedBy.trim() : null,
@ -268,11 +439,23 @@ public class RentalService {
} }
} }
public boolean saveInwardChallan(Integer woId, String dcNo, String dcDate, String vendorName,
Integer inSystemsQty, Integer inPrintersQty, Integer inLaptopsQty,
String dcFilePath, String vehicleNo, String receivedBy,
String remarks, String updatedBy) {
return saveInwardChallan(woId, dcNo, dcDate, vendorName, inSystemsQty, inPrintersQty, inLaptopsQty, 0, 0,
dcFilePath, vehicleNo, receivedBy, remarks, updatedBy);
}
public List<Map<String, Object>> getAllInwardChallans() { public List<Map<String, Object>> getAllInwardChallans() {
String sql = "SELECT c.id, c.wo_id, w.wo_file_no, w.file_subject, c.dc_no, c.dc_date, " + String sql = "SELECT c.id, c.wo_id, w.wo_file_no, w.file_subject, c.dc_no, c.dc_date, " +
"COALESCE(c.vendor_name, w.vendor_name) AS vendor_name, " + "COALESCE(c.vendor_name, w.vendor_name) AS vendor_name, " +
"c.inward_systems_qty, c.inward_printers_qty, c.inward_laptops_qty, " +
"(c.inward_systems_qty + c.inward_printers_qty + c.inward_laptops_qty) AS total_inward_qty, " +
"COALESCE(c.inward_systems_qty, 0) AS inward_systems_qty, " +
"COALESCE(c.inward_printers_qty, 0) AS inward_printers_qty, " +
"COALESCE(c.inward_laptops_qty, 0) AS inward_laptops_qty, " +
"COALESCE(c.inward_ups_qty, 0) AS inward_ups_qty, " +
"COALESCE(c.inward_dongle_qty, 0) AS inward_dongle_qty, " +
"(COALESCE(c.inward_systems_qty, 0) + COALESCE(c.inward_printers_qty, 0) + COALESCE(c.inward_laptops_qty, 0) + COALESCE(c.inward_ups_qty, 0) + COALESCE(c.inward_dongle_qty, 0)) AS total_inward_qty, " +
"c.dc_file_path, c.vehicle_no, c.received_by, c.remarks, c.created_by, c.created_at " + "c.dc_file_path, c.vehicle_no, c.received_by, c.remarks, c.created_by, c.created_at " +
"FROM rental_inward_delivery_challan c " + "FROM rental_inward_delivery_challan c " +
"LEFT JOIN rental_workorder_register w ON c.wo_id = w.id " + "LEFT JOIN rental_workorder_register w ON c.wo_id = w.id " +
@ -291,6 +474,7 @@ public class RentalService {
@Transactional @Transactional
public boolean saveIssuedDetails(Integer requestId, Integer inwardDcId, Integer woId, public boolean saveIssuedDetails(Integer requestId, Integer inwardDcId, Integer woId,
List<Map<String, Object>> itemDetails,
String issuedDate, Integer issuedSystemsQty, Integer issuedPrintersQty, String issuedDate, Integer issuedSystemsQty, Integer issuedPrintersQty,
Integer issuedLaptopsQty, String assetSerialDetails, Integer issuedLaptopsQty, String assetSerialDetails,
String issuedFromDate, String issuedToDate, String stockCopyPath, String issuedFromDate, String issuedToDate, String stockCopyPath,
@ -299,15 +483,38 @@ public class RentalService {
int periodDays = calculateDaysBetween(issuedFromDate, issuedToDate); int periodDays = calculateDaysBetween(issuedFromDate, issuedToDate);
String sql = "INSERT INTO rental_issued_details " + String sql = "INSERT INTO rental_issued_details " +
"(request_id, inward_dc_id, wo_id, issued_date, " +
"issued_systems_qty, issued_printers_qty, issued_laptops_qty, " +
"(request_id, inward_dc_id, wo_id, cid, category_model_name, requested_qty, issued_qty, " +
"issued_date, issued_systems_qty, issued_printers_qty, issued_laptops_qty, " +
"asset_serial_details, issued_from_date, issued_to_date, issued_period_days, " + "asset_serial_details, issued_from_date, issued_to_date, issued_period_days, " +
"stock_copy_path, custodian_officer, contact_no, issued_by, status, " + "stock_copy_path, custodian_officer, contact_no, issued_by, status, " +
"created_by, is_active, is_delete) " + "created_by, is_active, is_delete) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Issued', ?, 1, 0)";
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'Issued', ?, 1, 0)";
try { try {
int rows = jdbcTemplate.update(sql,
requestId, inwardDcId, woId, issuedDate,
int rows = 0;
if (itemDetails != null && !itemDetails.isEmpty()) {
for (Map<String, Object> it : itemDetails) {
Integer cid = it.get("cid") != null && !it.get("cid").toString().trim().isEmpty()
? Integer.valueOf(it.get("cid").toString().trim()) : null;
String model = it.get("categoryModelName") != null ? it.get("categoryModelName").toString().trim() : "";
Integer reqQty = it.get("requestedQty") != null ? Integer.valueOf(it.get("requestedQty").toString()) : 0;
Integer issQty = it.get("issuedQty") != null ? Integer.valueOf(it.get("issuedQty").toString()) : 0;
rows += jdbcTemplate.update(sql,
requestId, inwardDcId, woId, cid, model, reqQty, issQty,
issuedDate,
issQty, 0, 0,
assetSerialDetails, issuedFromDate, issuedToDate, periodDays,
stockCopyPath,
custodianOfficer != null ? custodianOfficer.trim() : null,
contactNo != null ? contactNo.trim() : null,
issuedBy != null ? issuedBy.trim() : null,
updatedBy);
}
} else {
rows = jdbcTemplate.update(sql,
requestId, inwardDcId, woId, null, "", 0,
(issuedSystemsQty != null ? issuedSystemsQty : 0) + (issuedPrintersQty != null ? issuedPrintersQty : 0) + (issuedLaptopsQty != null ? issuedLaptopsQty : 0),
issuedDate,
issuedSystemsQty != null ? issuedSystemsQty : 0, issuedSystemsQty != null ? issuedSystemsQty : 0,
issuedPrintersQty != null ? issuedPrintersQty : 0, issuedPrintersQty != null ? issuedPrintersQty : 0,
issuedLaptopsQty != null ? issuedLaptopsQty : 0, issuedLaptopsQty != null ? issuedLaptopsQty : 0,
@ -317,11 +524,18 @@ public class RentalService {
contactNo != null ? contactNo.trim() : null, contactNo != null ? contactNo.trim() : null,
issuedBy != null ? issuedBy.trim() : null, issuedBy != null ? issuedBy.trim() : null,
updatedBy); updatedBy);
}
if (rows > 0 && requestId != null) { if (rows > 0 && requestId != null) {
// Automatically update request status to 'Issued' (status_id = 3)
// Automatically update request status to 'Issued' (status_id = 3) for all items under this tapal_no
try {
jdbcTemplate.update(
"UPDATE rental_user_request SET req_status_id = 3 WHERE tapal_no = (SELECT tapal_no FROM (SELECT tapal_no FROM rental_user_request WHERE id = ?) t) OR id = ?",
requestId, requestId);
} catch (Exception eStatus) {
jdbcTemplate.update("UPDATE rental_user_request SET req_status_id = 3 WHERE id = ?", requestId); jdbcTemplate.update("UPDATE rental_user_request SET req_status_id = 3 WHERE id = ?", requestId);
} }
}
return rows > 0; return rows > 0;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -329,11 +543,26 @@ public class RentalService {
} }
} }
@Transactional
public boolean saveIssuedDetails(Integer requestId, Integer inwardDcId, Integer woId,
String issuedDate, Integer issuedSystemsQty, Integer issuedPrintersQty,
Integer issuedLaptopsQty, String assetSerialDetails,
String issuedFromDate, String issuedToDate, String stockCopyPath,
String custodianOfficer, String contactNo, String issuedBy, String updatedBy) {
return saveIssuedDetails(requestId, inwardDcId, woId, null, issuedDate, issuedSystemsQty, issuedPrintersQty,
issuedLaptopsQty, assetSerialDetails, issuedFromDate, issuedToDate, stockCopyPath,
custodianOfficer, contactNo, issuedBy, updatedBy);
}
public List<Map<String, Object>> getAllIssuedDetails() { public List<Map<String, Object>> getAllIssuedDetails() {
String sql = "SELECT i.id, i.request_id, r.tapal_no, d.dept_name, z.zone_name, " + String sql = "SELECT i.id, i.request_id, r.tapal_no, d.dept_name, z.zone_name, " +
"i.inward_dc_id, dc.dc_no, i.wo_id, w.wo_file_no, i.issued_date, " + "i.inward_dc_id, dc.dc_no, i.wo_id, w.wo_file_no, i.issued_date, " +
"i.cid, COALESCE(cat.category_type, 'General') AS category_name, " +
"COALESCE(i.category_model_name, r.category_model_name, '-') AS category_model_name, " +
"COALESCE(i.requested_qty, r.category_qty, 0) AS requested_qty, " +
"COALESCE(NULLIF(i.issued_qty, 0), (i.issued_systems_qty + i.issued_printers_qty + i.issued_laptops_qty)) AS issued_qty, " +
"i.issued_systems_qty, i.issued_printers_qty, i.issued_laptops_qty, " + "i.issued_systems_qty, i.issued_printers_qty, i.issued_laptops_qty, " +
"(i.issued_systems_qty + i.issued_printers_qty + i.issued_laptops_qty) AS total_issued_qty, " +
"COALESCE(NULLIF(i.issued_qty, 0), (i.issued_systems_qty + i.issued_printers_qty + i.issued_laptops_qty)) AS total_issued_qty, " +
"i.asset_serial_details, i.issued_from_date, i.issued_to_date, i.issued_period_days, " + "i.asset_serial_details, i.issued_from_date, i.issued_to_date, i.issued_period_days, " +
"i.stock_copy_path, i.custodian_officer, i.contact_no, i.issued_by, i.status, " + "i.stock_copy_path, i.custodian_officer, i.contact_no, i.issued_by, i.status, " +
"i.created_by, i.created_at, " + "i.created_by, i.created_at, " +
@ -342,6 +571,7 @@ public class RentalService {
"LEFT JOIN rental_user_request r ON i.request_id = r.id " + "LEFT JOIN rental_user_request r ON i.request_id = r.id " +
"LEFT JOIN toner_department_list d ON r.department_id = d.id " + "LEFT JOIN toner_department_list d ON r.department_id = d.id " +
"LEFT JOIN toner_zone_list z ON r.zone_id = z.id " + "LEFT JOIN toner_zone_list z ON r.zone_id = z.id " +
"LEFT JOIN rental_category_master cat ON (i.cid = cat.id OR (i.cid IS NULL AND r.cid = cat.id)) " +
"LEFT JOIN rental_inward_delivery_challan dc ON i.inward_dc_id = dc.id " + "LEFT JOIN rental_inward_delivery_challan dc ON i.inward_dc_id = dc.id " +
"LEFT JOIN rental_workorder_register w ON i.wo_id = w.id " + "LEFT JOIN rental_workorder_register w ON i.wo_id = w.id " +
"LEFT JOIN (SELECT issue_id, SUM(returned_systems_qty + returned_printers_qty + returned_laptops_qty) AS total_returned_qty " "LEFT JOIN (SELECT issue_id, SUM(returned_systems_qty + returned_printers_qty + returned_laptops_qty) AS total_returned_qty "

172
src/main/java/com/gcc_manpower/gcctonermanagement/controller/TonerController.java

@ -69,6 +69,24 @@ public class TonerController {
return "gcctonermanagement/upload"; return "gcctonermanagement/upload";
} }
@GetMapping("/details")
public String viewDetails(Model model, HttpSession session) {
String username = (String) session.getAttribute("toner_usrName");
if (username == null) {
return "redirect:/gcctonermanagement/login";
}
String usrRole = (String) session.getAttribute("toner_usrRole");
boolean isAdmin = "ADMIN".equalsIgnoreCase(usrRole);
model.addAttribute("isLoggedIn", true);
model.addAttribute("isAdmin", isAdmin);
model.addAttribute("usrName", username);
model.addAttribute("curPage", "gcctonermanagement");
return "gcctonermanagement/details";
}
@GetMapping("/login") @GetMapping("/login")
public String login(HttpSession session) { public String login(HttpSession session) {
return "gcctonermanagement/login"; return "gcctonermanagement/login";
@ -102,6 +120,8 @@ public class TonerController {
session.setMaxInactiveInterval(1800); // 30 minutes session timeout session.setMaxInactiveInterval(1800); // 30 minutes session timeout
response.put("result", true); response.put("result", true);
response.put("usrName", usrName); response.put("usrName", usrName);
response.put("usrRole", role);
response.put("isAdmin", "ADMIN".equalsIgnoreCase(role));
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
response.put("result", false); response.put("result", false);
response.put("error", e.getMessage() != null ? e.getMessage() : "Invalid username or password!"); response.put("error", e.getMessage() != null ? e.getMessage() : "Invalid username or password!");
@ -190,6 +210,18 @@ public class TonerController {
if (updatedBy == null) if (updatedBy == null)
updatedBy = username; updatedBy = username;
if (dcNo == null || dcNo.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Delivery Challan (DC) Number is required.");
return response;
}
if (dcDate == null || dcDate.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Delivery Challan (DC) Date is required.");
return response;
}
if (dcFile == null || dcFile.isEmpty()) { if (dcFile == null || dcFile.isEmpty()) {
response.put("success", false); response.put("success", false);
response.put("error", "Delivery Challan (DC) PDF file is required."); response.put("error", "Delivery Challan (DC) PDF file is required.");
@ -240,6 +272,146 @@ public class TonerController {
return response; return response;
} }
@PostMapping("/api/inward/update-dc")
@ResponseBody
public Map<String, Object> updateInwardDc(
@RequestParam("ids") String idsStr,
@RequestParam("dcNo") String dcNo,
@RequestParam("dcDate") String dcDate,
@RequestParam(value = "dcFile", required = false) MultipartFile dcFile,
HttpSession session) {
Map<String, Object> response = new HashMap<>();
String username = (String) session.getAttribute("toner_usrName");
if (username == null) {
response.put("success", false);
response.put("error", "Unauthorized access. Please log in.");
return response;
}
String updatedBy = appUserService.getUserIdByName(username);
if (updatedBy == null)
updatedBy = username;
if (idsStr == null || idsStr.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Record IDs are required.");
return response;
}
if (dcNo == null || dcNo.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Delivery Challan (DC) Number is required.");
return response;
}
if (dcDate == null || dcDate.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Delivery Challan (DC) Date is required.");
return response;
}
if (dcFile != null && !dcFile.isEmpty() && !isPdfFile(dcFile)) {
response.put("success", false);
response.put("error", "Delivery Challan file must be a PDF.");
return response;
}
try {
List<Integer> ids = java.util.Arrays.stream(idsStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Integer::parseInt)
.collect(java.util.stream.Collectors.toList());
if (ids.isEmpty()) {
response.put("success", false);
response.put("error", "No valid record IDs provided.");
return response;
}
File uploadDir = new File(tonerUploadPathConfig).getAbsoluteFile();
if (!uploadDir.exists()) {
uploadDir.mkdirs();
}
String dcPath = null;
if (dcFile != null && !dcFile.isEmpty()) {
dcPath = saveUploadedFile(dcFile, "dc", uploadDir);
}
boolean updated = tonerService.updateInwardDc(ids, dcNo.trim(), dcDate.trim(), dcPath, updatedBy);
if (updated) {
response.put("success", true);
response.put("message", "Delivery Challan details updated successfully.");
} else {
if (dcPath != null) {
deleteFileIfExists(dcPath, uploadDir);
}
response.put("success", false);
response.put("error", "Failed to update Delivery Challan details in the database.");
}
} catch (Exception e) {
response.put("success", false);
response.put("error", "An error occurred: " + e.getMessage());
e.printStackTrace();
}
return response;
}
@PostMapping("/api/inward/delete-dc")
@ResponseBody
public Map<String, Object> deleteInwardDc(
@RequestParam("ids") String idsStr,
HttpSession session) {
Map<String, Object> response = new HashMap<>();
String username = (String) session.getAttribute("toner_usrName");
if (username == null) {
response.put("success", false);
response.put("error", "Unauthorized access. Please log in.");
return response;
}
String updatedBy = appUserService.getUserIdByName(username);
if (updatedBy == null)
updatedBy = username;
if (idsStr == null || idsStr.trim().isEmpty()) {
response.put("success", false);
response.put("error", "Record IDs are required.");
return response;
}
try {
List<Integer> ids = java.util.Arrays.stream(idsStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Integer::parseInt)
.collect(java.util.stream.Collectors.toList());
if (ids.isEmpty()) {
response.put("success", false);
response.put("error", "No valid record IDs provided.");
return response;
}
boolean deleted = tonerService.deleteInwardDc(ids, updatedBy);
if (deleted) {
response.put("success", true);
response.put("message", "Delivery Challan and inward stock entry deleted successfully.");
} else {
response.put("success", false);
response.put("error", "Failed to delete Delivery Challan details from database.");
}
} catch (Exception e) {
response.put("success", false);
response.put("error", "An error occurred: " + e.getMessage());
e.printStackTrace();
}
return response;
}
@PostMapping("/api/request") @PostMapping("/api/request")
@ResponseBody @ResponseBody
public Map<String, Object> uploadRequest( public Map<String, Object> uploadRequest(

144
src/main/java/com/gcc_manpower/gcctonermanagement/service/TonerService.java

@ -66,10 +66,16 @@ public class TonerService {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
try { try {
List<Map<String, Object>> list = jdbcTemplate.queryForList( List<Map<String, Object>> list = jdbcTemplate.queryForList(
"SELECT id, part_code FROM toner_model_list WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0)");
"SELECT id, model_name, part_code FROM toner_model_list WHERE (is_delete IS NULL OR is_delete = 0)");
for (Map<String, Object> row : list) { for (Map<String, Object> row : list) {
if (row.get("id") != null && row.get("part_code") != null) {
map.put(String.valueOf(row.get("id")).trim(), String.valueOf(row.get("part_code")).trim());
String code = row.get("part_code") != null ? String.valueOf(row.get("part_code")).trim() : "";
if (!code.isEmpty() && !"null".equalsIgnoreCase(code) && !"n/a".equalsIgnoreCase(code)) {
if (row.get("id") != null) {
map.put(String.valueOf(row.get("id")).trim(), code);
}
if (row.get("model_name") != null) {
map.put(String.valueOf(row.get("model_name")).trim().toLowerCase(), code);
}
} }
} }
} catch (Exception ignored) { } catch (Exception ignored) {
@ -179,6 +185,25 @@ public class TonerService {
return map; return map;
} }
private Map<String, Integer> getTotalWorkorderRegisteredMap() {
Map<String, Integer> map = new HashMap<>();
try {
List<Map<String, Object>> list = jdbcTemplate.queryForList(
"SELECT pid, tid, SUM(CAST(qty_registered AS SIGNED)) AS total_qty FROM toner_workorder_printermodel_qty WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) GROUP BY pid, tid");
for (Map<String, Object> row : list) {
if (row.get("pid") != null && row.get("tid") != null) {
String pid = String.valueOf(row.get("pid")).trim();
String tid = String.valueOf(row.get("tid")).trim();
Integer qty = parseIntegerSafely(row.get("total_qty"));
map.put(pid + "_" + tid, qty != null ? qty : 0);
map.put(tid, map.getOrDefault(tid, 0) + (qty != null ? qty : 0));
}
}
} catch (Exception ignored) {
}
return map;
}
private Map<String, Integer> getInwardStockMap() { private Map<String, Integer> getInwardStockMap() {
Map<String, Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
try { try {
@ -620,6 +645,55 @@ public class TonerService {
return saveInwardRegister(refNo, companyName, items, dcUpload, null, null, username); return saveInwardRegister(refNo, companyName, items, dcUpload, null, null, username);
} }
@Transactional
public boolean updateInwardDc(List<Integer> ids, String dcNo, String dcDate, String newDcUpload, String updatedBy) {
if (ids == null || ids.isEmpty()) {
return false;
}
Timestamp now = new Timestamp(System.currentTimeMillis());
String inSql = ids.stream().map(i -> "?").collect(java.util.stream.Collectors.joining(","));
String finalDcNo = (dcNo != null && !dcNo.trim().isEmpty()) ? dcNo.trim() : null;
String finalDcDate = (dcDate != null && !dcDate.trim().isEmpty()) ? dcDate.trim() : null;
if (newDcUpload != null && !newDcUpload.trim().isEmpty()) {
String sql = "UPDATE toner_stock_register_details SET dc_no = ?, dc_date = ?, dc_upload = ?, updated_date = ?, updated_by = ? WHERE id IN (" + inSql + ")";
List<Object> params = new ArrayList<>();
params.add(finalDcNo);
params.add(finalDcDate);
params.add(newDcUpload.trim());
params.add(now);
params.add(updatedBy);
params.addAll(ids);
jdbcTemplate.update(sql, params.toArray());
} else {
String sql = "UPDATE toner_stock_register_details SET dc_no = ?, dc_date = ?, updated_date = ?, updated_by = ? WHERE id IN (" + inSql + ")";
List<Object> params = new ArrayList<>();
params.add(finalDcNo);
params.add(finalDcDate);
params.add(now);
params.add(updatedBy);
params.addAll(ids);
jdbcTemplate.update(sql, params.toArray());
}
return true;
}
@Transactional
public boolean deleteInwardDc(List<Integer> ids, String updatedBy) {
if (ids == null || ids.isEmpty()) {
return false;
}
Timestamp now = new Timestamp(System.currentTimeMillis());
String inSql = ids.stream().map(i -> "?").collect(java.util.stream.Collectors.joining(","));
String sql = "UPDATE toner_stock_register_details SET is_active = 0, is_delete = 1, updated_date = ?, updated_by = ? WHERE id IN (" + inSql + ")";
List<Object> params = new ArrayList<>();
params.add(now);
params.add(updatedBy);
params.addAll(ids);
jdbcTemplate.update(sql, params.toArray());
return true;
}
public List<Map<String, Object>> getInwardHistory() { public List<Map<String, Object>> getInwardHistory() {
try { try {
String sql = "SELECT * FROM toner_stock_register_details WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) ORDER BY id DESC"; String sql = "SELECT * FROM toner_stock_register_details WHERE (is_active IS NULL OR is_active = 1) AND (is_delete IS NULL OR is_delete = 0) ORDER BY id DESC";
@ -630,6 +704,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> userMap = getUserMap(); Map<String, String> userMap = getUserMap();
Map<String, String> vendorMap = getVendorMap(); Map<String, String> vendorMap = getVendorMap();
Map<String, String> fileNumberMap = getWorkorderFileNumberMap(); Map<String, String> fileNumberMap = getWorkorderFileNumberMap();
@ -651,9 +726,16 @@ public class TonerService {
String companyName = raw.get("company_name") != null ? String.valueOf(raw.get("company_name")).trim() String companyName = raw.get("company_name") != null ? String.valueOf(raw.get("company_name")).trim()
: ""; : "";
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
Map<String, Object> row = new HashMap<>(raw); Map<String, Object> row = new HashMap<>(raw);
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("order_by", userMap.getOrDefault(updatedBy, updatedBy)); row.put("order_by", userMap.getOrDefault(updatedBy, updatedBy));
row.put("file_number", fileNumberMap.getOrDefault(refNo, "")); row.put("file_number", fileNumberMap.getOrDefault(refNo, ""));
row.put("vendor_name", vendorMap.getOrDefault(companyName, companyName)); row.put("vendor_name", vendorMap.getOrDefault(companyName, companyName));
@ -837,6 +919,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> deptMap = getDepartmentMap(); Map<String, String> deptMap = getDepartmentMap();
Map<String, String> zoneMap = getZoneMap(); Map<String, String> zoneMap = getZoneMap();
Map<String, String> userMap = getUserMap(); Map<String, String> userMap = getUserMap();
@ -853,8 +936,15 @@ public class TonerService {
String requestDate = raw.get("request_date") != null ? String.valueOf(raw.get("request_date")).trim() String requestDate = raw.get("request_date") != null ? String.valueOf(raw.get("request_date")).trim()
: ""; : "";
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("dept_name", deptMap.getOrDefault(deptId, deptId)); row.put("dept_name", deptMap.getOrDefault(deptId, deptId));
row.put("zone_name", zoneMap.getOrDefault(zoneId, zoneId)); row.put("zone_name", zoneMap.getOrDefault(zoneId, zoneId));
row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy)); row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy));
@ -906,6 +996,7 @@ public class TonerService {
Map<String, String> deptMap = getDepartmentMap(); Map<String, String> deptMap = getDepartmentMap();
Map<String, String> zoneMap = getZoneMap(); Map<String, String> zoneMap = getZoneMap();
Map<String, Integer> availStockMap = getAvailableStockMap(); Map<String, Integer> availStockMap = getAvailableStockMap();
Map<String, Integer> totalWoMap = getTotalWorkorderRegisteredMap();
List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> raw : list) { for (Map<String, Object> raw : list) {
@ -921,6 +1012,7 @@ public class TonerService {
String pid = raw.get("pid") != null ? String.valueOf(raw.get("pid")).trim() : ""; String pid = raw.get("pid") != null ? String.valueOf(raw.get("pid")).trim() : "";
String tid = raw.get("tid") != null ? String.valueOf(raw.get("tid")).trim() : ""; String tid = raw.get("tid") != null ? String.valueOf(raw.get("tid")).trim() : "";
int availStock = availStockMap.getOrDefault(pid + "_" + tid, 0); int availStock = availStockMap.getOrDefault(pid + "_" + tid, 0);
int woQty = totalWoMap.getOrDefault(pid + "_" + tid, totalWoMap.getOrDefault(tid, 0));
Map<String, Object> row = new HashMap<>(raw); Map<String, Object> row = new HashMap<>(raw);
String deptId = raw.get("dept_id") != null ? String.valueOf(raw.get("dept_id")).trim() : ""; String deptId = raw.get("dept_id") != null ? String.valueOf(raw.get("dept_id")).trim() : "";
@ -932,6 +1024,8 @@ public class TonerService {
row.put("dept_name", deptMap.getOrDefault(deptId, deptId)); row.put("dept_name", deptMap.getOrDefault(deptId, deptId));
row.put("zone_name", zoneMap.getOrDefault(zoneId, zoneId)); row.put("zone_name", zoneMap.getOrDefault(zoneId, zoneId));
row.put("available_stock", availStock); row.put("available_stock", availStock);
row.put("qty_workorder_registered", woQty);
row.put("workorder_qty", woQty);
result.add(row); result.add(row);
} }
@ -1256,6 +1350,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> vendorMap = getVendorMap(); Map<String, String> vendorMap = getVendorMap();
Map<String, String> fileNumberMap = getWorkorderFileNumberMap(); Map<String, String> fileNumberMap = getWorkorderFileNumberMap();
Map<String, Integer> inStockMap = getInwardStockMap(); Map<String, Integer> inStockMap = getInwardStockMap();
@ -1275,8 +1370,15 @@ public class TonerService {
String pid = raw.get("pid") != null ? String.valueOf(raw.get("pid")).trim() : ""; String pid = raw.get("pid") != null ? String.valueOf(raw.get("pid")).trim() : "";
String tid = raw.get("tid") != null ? String.valueOf(raw.get("tid")).trim() : ""; String tid = raw.get("tid") != null ? String.valueOf(raw.get("tid")).trim() : "";
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("vendor_name", vendorMap.getOrDefault(vendorId, vendorId)); row.put("vendor_name", vendorMap.getOrDefault(vendorId, vendorId));
row.put("vendor_id", vendorId); row.put("vendor_id", vendorId);
row.put("file_number", fileNumberMap.getOrDefault(cleanRef, "")); row.put("file_number", fileNumberMap.getOrDefault(cleanRef, ""));
@ -1300,6 +1402,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> userMap = getUserMap(); Map<String, String> userMap = getUserMap();
Map<String, String> vendorMap = getVendorMap(); Map<String, String> vendorMap = getVendorMap();
Map<String, String> fileNumberMap = getWorkorderFileNumberMap(); Map<String, String> fileNumberMap = getWorkorderFileNumberMap();
@ -1339,8 +1442,15 @@ public class TonerService {
row.put("file_number", fileNumberMap.getOrDefault(refNo, "")); row.put("file_number", fileNumberMap.getOrDefault(refNo, ""));
} }
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy)); row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy));
row.put("vendor_name", vendorMap.getOrDefault(vendorStr, vendorStr)); row.put("vendor_name", vendorMap.getOrDefault(vendorStr, vendorStr));
row.put("total_qty_registered", raw.get("qty_registered")); row.put("total_qty_registered", raw.get("qty_registered"));
@ -1436,6 +1546,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> userMap = getUserMap(); Map<String, String> userMap = getUserMap();
Map<String, Integer> inByReqMap = getInwardStockByRequestMap(); Map<String, Integer> inByReqMap = getInwardStockByRequestMap();
@ -1449,8 +1560,15 @@ public class TonerService {
String updatedBy = raw.get("updated_by") != null ? String.valueOf(raw.get("updated_by")).trim() : ""; String updatedBy = raw.get("updated_by") != null ? String.valueOf(raw.get("updated_by")).trim() : "";
String mrId = raw.get("id") != null ? String.valueOf(raw.get("id")).trim() : ""; String mrId = raw.get("id") != null ? String.valueOf(raw.get("id")).trim() : "";
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy)); row.put("updated_by", userMap.getOrDefault(updatedBy, updatedBy));
row.put("qty_requested", raw.get("qty_registered")); row.put("qty_requested", raw.get("qty_registered"));
row.put("qty_inward_received", row.put("qty_inward_received",
@ -1474,6 +1592,7 @@ public class TonerService {
Map<String, String> printerMap = getPrinterMap(); Map<String, String> printerMap = getPrinterMap();
Map<String, String> tonerMap = getTonerMap(); Map<String, String> tonerMap = getTonerMap();
Map<String, String> partCodeMap = getTonerPartCodeMap();
Map<String, String> userMap = getUserMap(); Map<String, String> userMap = getUserMap();
Map<String, Integer> woRegisteredQtyMap = getWorkorderRegisteredQtyMap(); Map<String, Integer> woRegisteredQtyMap = getWorkorderRegisteredQtyMap();
@ -1486,8 +1605,15 @@ public class TonerService {
String updatedBy = raw.get("updated_by") != null ? String.valueOf(raw.get("updated_by")).trim() : ""; String updatedBy = raw.get("updated_by") != null ? String.valueOf(raw.get("updated_by")).trim() : "";
String refNo = raw.get("ref_no") != null ? String.valueOf(raw.get("ref_no")).trim() : ""; String refNo = raw.get("ref_no") != null ? String.valueOf(raw.get("ref_no")).trim() : "";
String tonerModelName = tonerMap.getOrDefault(tid, tid);
String partCode = partCodeMap.get(tid);
if (partCode == null || partCode.isEmpty()) {
partCode = partCodeMap.get(tonerModelName != null ? tonerModelName.trim().toLowerCase() : "");
}
row.put("printer_name", printerMap.getOrDefault(pid, pid)); row.put("printer_name", printerMap.getOrDefault(pid, pid));
row.put("model_name", tonerMap.getOrDefault(tid, tid));
row.put("model_name", tonerModelName);
row.put("part_code", partCode != null && !partCode.isEmpty() ? partCode : "-");
row.put("order_by", userMap.getOrDefault(updatedBy, updatedBy)); row.put("order_by", userMap.getOrDefault(updatedBy, updatedBy));
row.put("qty_requested", raw.get("qty_registered")); row.put("qty_requested", raw.get("qty_registered"));

11
src/main/resources/templates/gccadjustmentmanagement/dashboard.html

@ -1979,6 +1979,13 @@
<textarea id="form-file-remark" name="file_remark" class="form-control-custom" <textarea id="form-file-remark" name="file_remark" class="form-control-custom"
style="height: 100px; padding: 12px;" placeholder="Remarks :*" required></textarea> style="height: 100px; padding: 12px;" placeholder="Remarks :*" required></textarea>
</div> </div>
<!-- Review Remarks -->
<div class="col-12">
<label for="form-review-remark" class="form-label">Review Remarks :</label>
<textarea id="form-review-remark" name="review_remark" class="form-control-custom"
style="height: 90px; padding: 12px;" placeholder="Review Remarks :"></textarea>
</div>
</div> </div>
<div class="d-flex justify-content-center gap-3 mt-5"> <div class="d-flex justify-content-center gap-3 mt-5">
@ -4295,6 +4302,9 @@
<div class="col-12 mt-2"> <div class="col-12 mt-2">
<strong>File Remarks:</strong> <span class="text-muted">${escapeHtml(r.file_remark || 'No remarks provided.')}</span> <strong>File Remarks:</strong> <span class="text-muted">${escapeHtml(r.file_remark || 'No remarks provided.')}</span>
</div> </div>
<div class="col-12 mt-2">
<strong>Review Remarks:</strong> <span class="text-muted">${escapeHtml(r.review_remark || 'No review remarks provided.')}</span>
</div>
</div> </div>
<hr> <hr>
<h6 class="fw-bold mb-3"><i class="fa-solid fa-list-check text-success"></i> Document Checklist Lifecycle</h6> <h6 class="fw-bold mb-3"><i class="fa-solid fa-list-check text-success"></i> Document Checklist Lifecycle</h6>
@ -4370,6 +4380,7 @@
document.getElementById('form-file-available-status').value = r.file_available_status || ''; document.getElementById('form-file-available-status').value = r.file_available_status || '';
document.getElementById('form-bal-amt').value = r.bal_amt || ''; document.getElementById('form-bal-amt').value = r.bal_amt || '';
document.getElementById('form-file-remark').value = r.file_remark || ''; document.getElementById('form-file-remark').value = r.file_remark || '';
document.getElementById('form-review-remark').value = r.review_remark || '';
document.getElementById('form-file-data-num').value = r.file_data_num || ''; document.getElementById('form-file-data-num').value = r.file_data_num || '';
document.getElementById('form-pi-amt').value = r.pi_amt || ''; document.getElementById('form-pi-amt').value = r.pi_amt || '';
document.getElementById('form-pi-gen-date').value = r.pi_file_gen_date || ''; document.getElementById('form-pi-gen-date').value = r.pi_file_gen_date || '';

19
src/main/resources/templates/gccadjustmentmanagement/details.html

@ -525,6 +525,7 @@
<th class="text-center">Days Flow</th> <th class="text-center">Days Flow</th>
<!-- <th class="text-center">Documents</th> --> <!-- <th class="text-center">Documents</th> -->
<th>Remarks</th> <th>Remarks</th>
<th>Review Remarks</th>
<th class="text-center">Updated Date</th> <th class="text-center">Updated Date</th>
<th class="text-center">Updated By</th> <th class="text-center">Updated By</th>
<th class="text-center">Actions</th> <th class="text-center">Actions</th>
@ -908,6 +909,13 @@
<textarea id="form-file-remark" name="file_remark" class="form-control-custom" <textarea id="form-file-remark" name="file_remark" class="form-control-custom"
style="height: 100px; padding: 12px;" placeholder="Remarks :*" required></textarea> style="height: 100px; padding: 12px;" placeholder="Remarks :*" required></textarea>
</div> </div>
<!-- Review Remarks -->
<div class="col-12">
<label for="form-review-remark" class="form-label">Review Remarks :</label>
<textarea id="form-review-remark" name="review_remark" class="form-control-custom"
style="height: 90px; padding: 12px;" placeholder="Review Remarks :"></textarea>
</div>
</div> </div>
<div class="d-flex justify-content-center gap-3 mt-5"> <div class="d-flex justify-content-center gap-3 mt-5">
@ -1459,6 +1467,7 @@
document.getElementById('form-file-status').value = r.file_status_id || ''; document.getElementById('form-file-status').value = r.file_status_id || '';
document.getElementById('form-bal-amt').value = r.bal_amt || ''; document.getElementById('form-bal-amt').value = r.bal_amt || '';
document.getElementById('form-file-remark').value = r.file_remark || ''; document.getElementById('form-file-remark').value = r.file_remark || '';
document.getElementById('form-review-remark').value = r.review_remark || '';
document.getElementById('form-file-data-num').value = r.file_data_num || ''; document.getElementById('form-file-data-num').value = r.file_data_num || '';
document.getElementById('form-pi-amt').value = r.pi_amt || ''; document.getElementById('form-pi-amt').value = r.pi_amt || '';
document.getElementById('form-pi-gen-date').value = r.pi_file_gen_date || ''; document.getElementById('form-pi-gen-date').value = r.pi_file_gen_date || '';
@ -1769,7 +1778,7 @@
finalRecords = finalRecords.filter(r => { finalRecords = finalRecords.filter(r => {
const fileNum = String(r.file_num || r.file_data_num || '').toLowerCase(); const fileNum = String(r.file_num || r.file_data_num || '').toLowerCase();
const advType = String(r.adv_type || '').toLowerCase(); const advType = String(r.adv_type || '').toLowerCase();
const remarks = String(r.file_remark || r.remarks || '').toLowerCase();
const remarks = String(r.file_remark || r.review_remark || r.remarks || '').toLowerCase();
const fileStatus = String(r.file_status || '').toLowerCase(); const fileStatus = String(r.file_status || '').toLowerCase();
return fileNum.includes(query) || advType.includes(query) || remarks.includes(query) || fileStatus.includes(query); return fileNum.includes(query) || advType.includes(query) || remarks.includes(query) || fileStatus.includes(query);
}); });
@ -2093,6 +2102,7 @@
<td class="text-center">${daysFlowHtml}</td> <td class="text-center">${daysFlowHtml}</td>
<td class="text-wrap" style="max-width: 250px;">${r.file_remark || '-'}</td> <td class="text-wrap" style="max-width: 250px;">${r.file_remark || '-'}</td>
<td class="text-wrap" style="max-width: 250px;">${r.review_remark || '-'}</td>
<td class="text-center font-monospace">${formatDate(r.updated_date || r.cdate)}</td> <td class="text-center font-monospace">${formatDate(r.updated_date || r.cdate)}</td>
<td class="text-center">${r.updated_by_name || r.updated_by || '-'}</td> <td class="text-center">${r.updated_by_name || r.updated_by || '-'}</td>
@ -2359,10 +2369,14 @@
</div> </div>
</div> </div>
<div class="row mt-3 border-top pt-3"> <div class="row mt-3 border-top pt-3">
<div class="col-12">
<div class="col-md-6">
<p class="mb-1"><strong>Remarks:</strong></p> <p class="mb-1"><strong>Remarks:</strong></p>
<p class="bg-light p-2 rounded text-secondary" style="white-space: pre-wrap;">${fileObj.file_remark || '-'}</p> <p class="bg-light p-2 rounded text-secondary" style="white-space: pre-wrap;">${fileObj.file_remark || '-'}</p>
</div> </div>
<div class="col-md-6">
<p class="mb-1"><strong>Review Remarks:</strong></p>
<p class="bg-light p-2 rounded text-secondary" style="white-space: pre-wrap;">${fileObj.review_remark || '-'}</p>
</div>
</div> </div>
`; `;
} }
@ -2428,6 +2442,7 @@
'TC Date': formatDateForExcel(r.tc_file_gen_date), 'TC Date': formatDateForExcel(r.tc_file_gen_date),
'Status': isAdjusted(r) ? 'Adjusted' : 'Pending', 'Status': isAdjusted(r) ? 'Adjusted' : 'Pending',
'Remarks': r.file_remark || '', 'Remarks': r.file_remark || '',
'Review Remarks': r.review_remark || '',
'Last Updated Date': formatDateForExcel(r.updated_date), 'Last Updated Date': formatDateForExcel(r.updated_date),
'PI File Path': r.pi_file_path || '', 'PI File Path': r.pi_file_path || '',
'AS File Path': r.as_file_path || '', 'AS File Path': r.as_file_path || '',

2666
src/main/resources/templates/gccrentalmanagement/dashboard.html
File diff suppressed because it is too large
View File

1637
src/main/resources/templates/gcctonermanagement/details.html
File diff suppressed because it is too large
View File

2
src/main/resources/templates/gcctonermanagement/login.html

@ -94,6 +94,8 @@
.then(data => { .then(data => {
if (data.result) { if (data.result) {
sessionStorage.setItem("toner_usrName", data.usrName); sessionStorage.setItem("toner_usrName", data.usrName);
sessionStorage.setItem("toner_usrRole", data.usrRole || 'USER');
sessionStorage.setItem("toner_isAdmin", data.isAdmin ? 'true' : 'false');
window.location.href = contextPath + 'gcctonermanagement/upload'; window.location.href = contextPath + 'gcctonermanagement/upload';
} else { } else {
submitBtn.disabled = false; submitBtn.disabled = false;

2484
src/main/resources/templates/gcctonermanagement/upload.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save