@ -41,7 +41,6 @@ public class RegisterService {
this . jdbcTemplate = new JdbcTemplate ( dataSource ) ;
this . jdbcTemplate = new JdbcTemplate ( dataSource ) ;
}
}
public List < Map < String , Object > > ViewZoneDropdown ( ) {
public List < Map < String , Object > > ViewZoneDropdown ( ) {
String sql = "SELECT zone_name "
String sql = "SELECT zone_name "
+ "FROM zone_master "
+ "FROM zone_master "
@ -60,7 +59,7 @@ public class RegisterService {
+ "FROM ward_master "
+ "FROM ward_master "
+ "WHERE is_active=1 AND is_delete=0 AND zone_id=?" ;
+ "WHERE is_active=1 AND is_delete=0 AND zone_id=?" ;
try {
try {
return jdbcTemplate . queryForList ( sql , zone ) ;
return jdbcTemplate . queryForList ( sql , zone ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
/ / TODO : handle exception
/ / TODO : handle exception
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
@ -68,7 +67,6 @@ public class RegisterService {
}
}
}
}
public List < Map < String , Object > > getRoadNamesByWard ( String ward ) {
public List < Map < String , Object > > getRoadNamesByWard ( String ward ) {
try {
try {
String encodedWard = URLEncoder . encode ( "'" + ward + "'" , StandardCharsets . UTF_8 . toString ( ) ) ;
String encodedWard = URLEncoder . encode ( "'" + ward + "'" , StandardCharsets . UTF_8 . toString ( ) ) ;
@ -103,8 +101,6 @@ public class RegisterService {
}
}
}
}
public List < Map < String , Object > > getRoadType ( ) {
public List < Map < String , Object > > getRoadType ( ) {
String sql = "Select id,road_type as roadType from road_type_master where is_active = 1 and is_delete = 0" ;
String sql = "Select id,road_type as roadType from road_type_master where is_active = 1 and is_delete = 0" ;
try {
try {
@ -115,7 +111,6 @@ public class RegisterService {
}
}
}
}
public List < Map < String , Object > > getRoadTypeMaterial ( ) {
public List < Map < String , Object > > getRoadTypeMaterial ( ) {
String sql = "Select id,roadtype_material from roadtype_material_master where is_active = 1 and is_delete = 0" ;
String sql = "Select id,roadtype_material from roadtype_material_master where is_active = 1 and is_delete = 0" ;
try {
try {
@ -146,7 +141,6 @@ public class RegisterService {
}
}
}
}
public List < Map < String , Object > > getMonthList ( ) {
public List < Map < String , Object > > getMonthList ( ) {
String sql = "SELECT id, month_name FROM month_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id" ;
String sql = "SELECT id, month_name FROM month_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id" ;
try {
try {
@ -157,7 +151,6 @@ public class RegisterService {
}
}
}
}
public List < Map < String , Object > > getYearList ( ) {
public List < Map < String , Object > > getYearList ( ) {
String sql = "SELECT id, year_name FROM year_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id DESC" ;
String sql = "SELECT id, year_name FROM year_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id DESC" ;
try {
try {
@ -168,10 +161,28 @@ public class RegisterService {
}
}
}
}
public Map < String , Object > saveRoadWarDetails ( Map < String , Object > payload ) {
public Map < String , Object > saveRoadWarDetails ( Map < String , Object > payload ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
try {
String roadId = String . valueOf ( payload . get ( "road_id" ) ) ;
Integer count = jdbcTemplate . queryForObject (
"SELECT COUNT(*) " +
"FROM road_details_master " +
"WHERE road_id = ? " +
"AND is_active = 1 " +
"AND is_delete = 0" ,
Integer . class ,
roadId ) ;
if ( count ! = null & & count > 0 ) {
result . put ( "status" , false ) ;
result . put ( "message" ,
"Selected road is already mapped to another Road War record" ) ;
return result ;
}
String insertRoad = "INSERT INTO road_details_master "
String insertRoad = "INSERT INTO road_details_master "
+ "(zone, ward, road_name, road_type, road_length, road_avg_width, road_area, "
+ "(zone, ward, road_name, road_type, road_length, road_avg_width, road_area, "
@ -194,7 +205,7 @@ public class RegisterService {
ps . setObject ( 2 , payload . get ( "ward" ) ) ;
ps . setObject ( 2 , payload . get ( "ward" ) ) ;
ps . setObject ( 3 , payload . get ( "road_name" ) ) ;
ps . setObject ( 3 , payload . get ( "road_name" ) ) ;
ps . setObject ( 4 , payload . get ( "road_type" ) ) ;
ps . setObject ( 4 , payload . get ( "road_type" ) ) ;
/ / ps . setObject ( 5 , payload . get ( "highway_ans" ) ) ;
/ / ps . setObject ( 5 , payload . get ( "highway_ans" ) ) ;
ps . setObject ( 5 , payload . get ( "road_length" ) ) ;
ps . setObject ( 5 , payload . get ( "road_length" ) ) ;
ps . setObject ( 6 , payload . get ( "road_avg_width" ) ) ;
ps . setObject ( 6 , payload . get ( "road_avg_width" ) ) ;
ps . setObject ( 7 , payload . get ( "road_area" ) ) ;
ps . setObject ( 7 , payload . get ( "road_area" ) ) ;
@ -301,15 +312,15 @@ public class RegisterService {
return result ;
return result ;
}
}
public List < Map < String , Object > > getAllRoadWarDetails (
public List < Map < String , Object > > getAllRoadWarDetails (
String userid ,
String userid ,
String zone ,
String zone ,
String ward ,
String ward ,
String roadId ) {
String roadId ) {
StringBuilder sql = new StringBuilder ( " SELECT rdm.*,rtm.road_type as road_type_name,rtmm.roadtype_material as roadtype_material_name,ftm.footpath_type_name as footpath_material_name FROM road_details_master rdm " +
StringBuilder sql = new StringBuilder (
" SELECT rdm.*,rtm.road_type as road_type_name,rtmm.roadtype_material as roadtype_material_name,ftm.footpath_type_name as footpath_material_name FROM road_details_master rdm "
+
" LEFT JOIN road_type_master rtm ON rtm.id= rdm.road_type " +
" LEFT JOIN road_type_master rtm ON rtm.id= rdm.road_type " +
" LEFT JOIN roadtype_material_master rtmm ON rtmm.id= rdm.road_type_material " +
" LEFT JOIN roadtype_material_master rtmm ON rtmm.id= rdm.road_type_material " +
" LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
" LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
@ -317,7 +328,6 @@ public class RegisterService {
List < Object > params = new ArrayList < > ( ) ;
List < Object > params = new ArrayList < > ( ) ;
if ( userid ! = null & & ! userid . isEmpty ( ) ) {
if ( userid ! = null & & ! userid . isEmpty ( ) ) {
sql . append ( " AND rdm.cby = ?" ) ;
sql . append ( " AND rdm.cby = ?" ) ;
params . add ( userid ) ;
params . add ( userid ) ;
@ -345,28 +355,25 @@ public class RegisterService {
return jdbcTemplate . queryForList ( sql . toString ( ) , params . toArray ( ) ) ;
return jdbcTemplate . queryForList ( sql . toString ( ) , params . toArray ( ) ) ;
}
}
public Map < String , Object > getRoadWarDetailsById ( String refid ) {
public Map < String , Object > getRoadWarDetailsById ( String refid ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
try {
String sql =
"SELECT rdm.*, rtm.road_type As road_type_name,rtmm.roadtype_material as roadtype_material,ftm.footpath_type_name as footpath_material_name " +
String sql = "SELECT rdm.*, rtm.road_type As road_type_name,rtmm.roadtype_material as roadtype_material,ftm.footpath_type_name as footpath_material_name "
+
"FROM road_details_master rdm " +
"FROM road_details_master rdm " +
"LEFT JOIN road_type_master rtm ON rtm.id = rdm.road_type " +
"LEFT JOIN road_type_master rtm ON rtm.id = rdm.road_type " +
"LEFT JOIN roadtype_material_master rtmm ON rtmm.id = rdm.road_type_material " +
"LEFT JOIN roadtype_material_master rtmm ON rtmm.id = rdm.road_type_material " +
"LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
"LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
"WHERE rdm.ref_id = ? AND rdm.is_active=1 AND rdm.is_delete=0 " ;
"WHERE rdm.ref_id = ? AND rdm.is_active=1 AND rdm.is_delete=0 " ;
Map < String , Object > road =
jdbcTemplate . queryForMap ( sql , refid ) ;
Map < String , Object > road = jdbcTemplate . queryForMap ( sql , refid ) ;
result . putAll ( road ) ;
result . putAll ( road ) ;
List < Map < String , Object > > relayingDetails =
jdbcTemplate . queryForList (
List < Map < String , Object > > relayingDetails = jdbcTemplate . queryForList (
" SELECT rd.*,mm.month_name,ym.year_name,rtmm.roadtype_material "
" SELECT rd.*,mm.month_name,ym.year_name,rtmm.roadtype_material "
+ " FROM relaying_details rd "
+ " FROM relaying_details rd "
+ " LEFT JOIN month_master mm on mm.id = rd.relay_month "
+ " LEFT JOIN month_master mm on mm.id = rd.relay_month "
@ -401,8 +408,7 @@ public class RegisterService {
Integer count = jdbcTemplate . queryForObject (
Integer count = jdbcTemplate . queryForObject (
sql ,
sql ,
Integer . class ,
Integer . class ,
roadId
) ;
roadId ) ;
response . put ( "status" , true ) ;
response . put ( "status" , true ) ;
response . put ( "exists" , count ! = null & & count > 0 ) ;
response . put ( "exists" , count ! = null & & count > 0 ) ;
@ -440,8 +446,7 @@ public class RegisterService {
"AND is_delete = 0" ,
"AND is_delete = 0" ,
Integer . class ,
Integer . class ,
roadId ,
roadId ,
refId
) ;
refId ) ;
if ( count ! = null & & count > 0 ) {
if ( count ! = null & & count > 0 ) {
@ -452,39 +457,41 @@ public class RegisterService {
return result ;
return result ;
}
}
/ / COPY CURRENT RECORD TO LOG TABLE
/ / COPY CURRENT RECORD TO LOG TABLE
String logSql =
"INSERT INTO road_details_master_log (" +
"id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, " +
String logSql = "INSERT INTO road_details_master_log (" +
"id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, "
+
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_from,road_to,is_footpath,footpath_at, " +
"road_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"footpath_from_location, footpath_to_location, " +
"footpath_from_location, footpath_to_location, " +
"swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, " +
"swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, "
+
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete) " +
"updated_date, updated_by, is_active, is_delete) " +
"SELECT " +
"SELECT " +
"id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, " +
"id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, "
+
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_from,road_to,is_footpath,footpath_at, " +
"road_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"footpath_from_location, footpath_to_location, " +
"footpath_from_location, footpath_to_location, " +
"swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, " +
"swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, "
+
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete " +
"updated_date, updated_by, is_active, is_delete " +
@ -493,12 +500,9 @@ public class RegisterService {
jdbcTemplate . update ( logSql , refId ) ;
jdbcTemplate . update ( logSql , refId ) ;
/ / 3 . UPDATE ROAD MASTER
/ / 3 . UPDATE ROAD MASTER
String updateSql =
"UPDATE road_details_master SET " +
String updateSql = "UPDATE road_details_master SET " +
"zone=?, " +
"zone=?, " +
"ward=?, " +
"ward=?, " +
"road_id=?, " +
"road_id=?, " +
@ -508,15 +512,15 @@ public class RegisterService {
"road_type=?, " +
"road_type=?, " +
"road_type_material=?, " +
"road_type_material=?, " +
"road_length=?, " +
"road_length=?, " +
"road_row_width=?, " +
"road_row_width=?, " +
"road_avg_width=?, " +
"road_avg_width=?, " +
"road_min_width=?, " +
"road_min_width=?, " +
"road_max_width=?, " +
"road_max_width=?, " +
"road_area=?, " +
"road_area=?, " +
"road_from=?, " +
"road_to=?, " +
"is_footpath=?, " +
"footpath_at=?, " +
"road_from=?, " +
"road_to=?, " +
"is_footpath=?, " +
"footpath_at=?, " +
"footpath_material=?, " +
"footpath_material=?, " +
"footpath_length=?, " +
"footpath_length=?, " +
"footpath_width=?, " +
"footpath_width=?, " +
@ -528,7 +532,7 @@ public class RegisterService {
"is_swd=?, " +
"is_swd=?, " +
"swd_from=?, " +
"swd_from=?, " +
"swd_to=?, " +
"swd_to=?, " +
"swd_at=?," +
"swd_at=?," +
"swd_length=?, " +
"swd_length=?, " +
"swd_size=?, " +
"swd_size=?, " +
"rhs_swdlength=?, " +
"rhs_swdlength=?, " +
@ -536,7 +540,7 @@ public class RegisterService {
"is_scp=?, " +
"is_scp=?, " +
"scp_at=?, " +
"scp_at=?, " +
"scp_count=?, " +
"scp_count=?, " +
"rhs_scpCount=?," +
"rhs_scpCount=?," +
"is_manhole=?, " +
"is_manhole=?, " +
"manhole_count=?, " +
"manhole_count=?, " +
"manhole_at=?, " +
"manhole_at=?, " +
@ -652,8 +656,7 @@ public class RegisterService {
payload . get ( "is_centermedian" ) ,
payload . get ( "is_centermedian" ) ,
updatedBy ,
updatedBy ,
refId
) ;
refId ) ;
/ / 4 . SOFT DELETE OLD RELAYING RECORDS
/ / 4 . SOFT DELETE OLD RELAYING RECORDS
@ -666,17 +669,14 @@ public class RegisterService {
"WHERE road_ref_id=? " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
"AND is_active=1" ,
updatedBy ,
updatedBy ,
refId
) ;
refId ) ;
/ / 5 . INSERT NEW RELAYING RECORDS
/ / 5 . INSERT NEW RELAYING RECORDS
@SuppressWarnings ( "unchecked" )
@SuppressWarnings ( "unchecked" )
List < Map < String , Object > > relays =
( List < Map < String , Object > > ) payload . get ( "relaying_details" ) ;
List < Map < String , Object > > relays = ( List < Map < String , Object > > ) payload . get ( "relaying_details" ) ;
String insertRelay =
"INSERT INTO relaying_details " +
String insertRelay = "INSERT INTO relaying_details " +
"(road_ref_id, relay_month, relay_year,road_type_material, cr_value, road_type, remarks, cby) " +
"(road_ref_id, relay_month, relay_year,road_type_material, cr_value, road_type, remarks, cby) " +
"VALUES (?,?,?,?,?,?,?,?)" ;
"VALUES (?,?,?,?,?,?,?,?)" ;
@ -693,8 +693,7 @@ public class RegisterService {
relay . get ( "cr_value" ) ,
relay . get ( "cr_value" ) ,
relay . get ( "road_type" ) ,
relay . get ( "road_type" ) ,
relay . get ( "remarks" ) ,
relay . get ( "remarks" ) ,
updatedBy
) ;
updatedBy ) ;
}
}
}
}
@ -712,7 +711,6 @@ public class RegisterService {
return result ;
return result ;
}
}
public Map < String , Object > deleteRoadWarDetails ( String refId , String updatedby ) {
public Map < String , Object > deleteRoadWarDetails ( String refId , String updatedby ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
@ -722,23 +720,21 @@ public class RegisterService {
"UPDATE road_details_master " +
"UPDATE road_details_master " +
"SET is_active=0, " +
"SET is_active=0, " +
"is_delete=1, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_by=?, " +
"updated_date=NOW() " +
"updated_date=NOW() " +
"WHERE ref_id=? " +
"WHERE ref_id=? " +
"AND is_active=1" ,
"AND is_active=1" ,
updatedby , refId
) ;
updatedby , refId ) ;
jdbcTemplate . update (
jdbcTemplate . update (
"UPDATE relaying_details " +
"UPDATE relaying_details " +
"SET is_active=0, " +
"SET is_active=0, " +
"is_delete=1, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_by=?, " +
"updated_date=NOW() " +
"updated_date=NOW() " +
"WHERE road_ref_id=? " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
"AND is_active=1" ,
updatedby , refId
) ;
updatedby , refId ) ;
if ( roadUpdated > 0 ) {
if ( roadUpdated > 0 ) {
@ -749,7 +745,7 @@ public class RegisterService {
} else {
} else {
result . put ( "status" , false ) ;
result . put ( "status" , false ) ;
result . put ( "message" , "Record not found" ) ;
result . put ( "message" , "Record not found" ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {