@ -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 " +
"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 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.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 "