@ -34,41 +34,39 @@ public class RegisterService {
private JdbcTemplate jdbcTemplate ;
@Autowired
private Environment environment ;
private Environment environment ;
@Autowired
public void setDataSource ( @Qualifier ( "mysqlRoadWarDataSource" ) DataSource dataSource ) {
this . jdbcTemplate = new JdbcTemplate ( dataSource ) ;
}
public List < Map < String , Object > > ViewZoneDropdown ( ) {
String sql = "SELECT zone_name "
+ "FROM zone_master "
+ "WHERE is_active=1 AND is_delete=0" ;
try {
return jdbcTemplate . queryForList ( sql ) ;
+ "FROM zone_master "
+ "WHERE is_active=1 AND is_delete=0" ;
try {
return jdbcTemplate . queryForList ( sql ) ;
} catch ( Exception e ) {
/ / TODO : handle exception
e . printStackTrace ( ) ;
return Collections . emptyList ( ) ;
e . printStackTrace ( ) ;
return Collections . emptyList ( ) ;
}
}
public List < Map < String , Object > > ViewWardDropdown ( String zone ) {
String sql = "SELECT ward_name "
+ "FROM ward_master "
+ "WHERE is_active=1 AND is_delete=0 AND zone_id=?" ;
try {
return jdbcTemplate . queryForList ( sql , zone ) ;
+ "FROM ward_master "
+ "WHERE is_active=1 AND is_delete=0 AND zone_id=?" ;
try {
return jdbcTemplate . queryForList ( sql , zone ) ;
} catch ( Exception e ) {
/ / TODO : handle exception
e . printStackTrace ( ) ;
return Collections . emptyList ( ) ;
e . printStackTrace ( ) ;
return Collections . emptyList ( ) ;
}
}
public List < Map < String , Object > > getRoadNamesByWard ( String ward ) {
try {
String encodedWard = URLEncoder . encode ( "'" + ward + "'" , StandardCharsets . UTF_8 . toString ( ) ) ;
@ -90,7 +88,7 @@ public class RegisterService {
for ( JsonNode feature : features ) {
JsonNode props = feature . path ( "properties" ) ;
Map < String , Object > roadInfo = new HashMap < > ( ) ;
roadInfo . put ( "road_id" , props . path ( "road_id" ) . asText ( ) ) ;
roadInfo . put ( "road_id" , props . path ( "road_id" ) . asText ( ) ) ;
roadInfo . put ( "road_name" , props . path ( "road_name" ) . asText ( ) ) ;
roadList . add ( roadInfo ) ;
}
@ -103,8 +101,6 @@ public class RegisterService {
}
}
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" ;
try {
@ -115,7 +111,6 @@ public class RegisterService {
}
}
public List < Map < String , Object > > getRoadTypeMaterial ( ) {
String sql = "Select id,roadtype_material from roadtype_material_master where is_active = 1 and is_delete = 0" ;
try {
@ -146,7 +141,6 @@ public class RegisterService {
}
}
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" ;
try {
@ -157,7 +151,6 @@ public class RegisterService {
}
}
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" ;
try {
@ -168,10 +161,28 @@ public class RegisterService {
}
}
public Map < String , Object > saveRoadWarDetails ( Map < String , Object > payload ) {
Map < String , Object > result = new HashMap < > ( ) ;
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 "
+ "(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 ( 3 , payload . get ( "road_name" ) ) ;
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 ( 6 , payload . get ( "road_avg_width" ) ) ;
ps . setObject ( 7 , payload . get ( "road_area" ) ) ;
@ -301,467 +312,452 @@ public class RegisterService {
return result ;
}
public List < Map < String , Object > > getAllRoadWarDetails (
String userid ,
String zone ,
String ward ,
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 " +
" 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 footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
" WHERE 1=1 " ) ;
List < Object > params = new ArrayList < > ( ) ;
if ( userid ! = null & & ! userid . isEmpty ( ) ) {
sql . append ( " AND rdm.cby = ?" ) ;
params . add ( userid ) ;
}
String zone ,
String ward ,
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 "
+
" 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 footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
" WHERE 1=1 " ) ;
List < Object > params = new ArrayList < > ( ) ;
if ( userid ! = null & & ! userid . isEmpty ( ) ) {
sql . append ( " AND rdm.cby = ?" ) ;
params . add ( userid ) ;
}
if ( zone ! = null & & ! zone . isEmpty ( ) ) {
sql . append ( " AND rdm.zone = ?" ) ;
params . add ( zone ) ;
}
if ( zone ! = null & & ! zone . isEmpty ( ) ) {
sql . append ( " AND rdm.zone = ?" ) ;
params . add ( zone ) ;
}
if ( ward ! = null & & ! ward . isEmpty ( ) ) {
sql . append ( " AND rdm.ward = ?" ) ;
params . add ( ward ) ;
}
if ( ward ! = null & & ! ward . isEmpty ( ) ) {
sql . append ( " AND rdm.ward = ?" ) ;
params . add ( ward ) ;
}
if ( roadId ! = null & & ! roadId . isEmpty ( ) ) {
sql . append ( " AND rdm.road_id = ?" ) ;
params . add ( roadId ) ;
}
if ( roadId ! = null & & ! roadId . isEmpty ( ) ) {
sql . append ( " AND rdm.road_id = ?" ) ;
params . add ( roadId ) ;
}
sql . append ( " AND rdm.is_active=1 AND rdm.is_delete=0 " ) ;
sql . append ( " AND rdm.is_active=1 AND rdm.is_delete=0 " ) ;
sql . append ( " ORDER BY rdm.id DESC" ) ;
sql . append ( " ORDER BY rdm.id DESC" ) ;
return jdbcTemplate . queryForList ( sql . toString ( ) , params . toArray ( ) ) ;
return jdbcTemplate . queryForList ( sql . toString ( ) , params . toArray ( ) ) ;
}
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 " +
"FROM road_details_master rdm " +
"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 footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
"WHERE rdm.ref_id = ? AND rdm.is_active=1 AND rdm.is_delete=0 " ;
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 " +
"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 footpath_type_master ftm ON ftm.id= rdm.footpath_material " +
"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 (
" SELECT rd.*,mm.month_name,ym.year_name,rtmm.roadtype_material "
+ " FROM relaying_details rd "
+ " LEFT JOIN month_master mm on mm.id = rd.relay_month "
+ " LEFT JOIN year_master ym on ym.id = rd.relay_year "
+ " LEFT JOIN roadtype_material_master rtmm on rtmm.id = rd.road_type_material "
+ " WHERE rd.road_ref_id = ? AND rd.is_active=1 AND rd.is_delete=0 " ,
refid ) ;
List < Map < String , Object > > relayingDetails = jdbcTemplate . queryForList (
" SELECT rd.*,mm.month_name,ym.year_name,rtmm.roadtype_material "
+ " FROM relaying_details rd "
+ " LEFT JOIN month_master mm on mm.id = rd.relay_month "
+ " LEFT JOIN year_master ym on ym.id = rd.relay_year "
+ " LEFT JOIN roadtype_material_master rtmm on rtmm.id = rd.road_type_material "
+ " WHERE rd.road_ref_id = ? AND rd.is_active=1 AND rd.is_delete=0 " ,
refid ) ;
result . put ( "relayingDetails" , relayingDetails ) ;
result . put ( "status" , true ) ;
result . put ( "relayingDetails" , relayingDetails ) ;
result . put ( "status" , true ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
result . put ( "status" , false ) ;
result . put ( "message" , e . getMessage ( ) ) ;
result . put ( "status" , false ) ;
result . put ( "message" , e . getMessage ( ) ) ;
}
}
return result ;
return result ;
}
public Map < String , Object > checkRoadExists ( Integer roadId ) {
Map < String , Object > response = new HashMap < > ( ) ;
Map < String , Object > response = new HashMap < > ( ) ;
try {
try {
String sql = " SELECT COUNT(*) FROM road_details_master "
String sql = " SELECT COUNT(*) FROM road_details_master "
+ " WHERE road_id = ? AND is_active=1 AND is_delete = 0 " ;
+ " WHERE road_id = ? AND is_active=1 AND is_delete = 0 " ;
Integer count = jdbcTemplate . queryForObject (
sql ,
Integer . class ,
roadId
) ;
Integer count = jdbcTemplate . queryForObject (
sql ,
Integer . class ,
roadId ) ;
response . put ( "status" , true ) ;
response . put ( "exists" , count ! = null & & count > 0 ) ;
response . put ( "status" , true ) ;
response . put ( "exists" , count ! = null & & count > 0 ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
e . printStackTrace ( ) ;
response . put ( "status" , false ) ;
response . put ( "message" , "Error while checking road" ) ;
response . put ( "status" , false ) ;
response . put ( "message" , "Error while checking road" ) ;
}
}
return response ;
return response ;
}
@Transactional
public Map < String , Object > updateRoadWarDetails ( Map < String , Object > payload ) {
Map < String , Object > result = new HashMap < > ( ) ;
try {
String refId = String . valueOf ( payload . get ( "ref_id" ) ) ;
String updatedBy = String . valueOf ( payload . get ( "updated_by" ) ) ;
String roadId = String . valueOf ( payload . get ( "road_id" ) ) ;
Integer count = jdbcTemplate . queryForObject (
"SELECT COUNT(*) " +
"FROM road_details_master " +
"WHERE road_id = ? " +
"AND ref_id <> ? " +
"AND is_active = 1 " +
"AND is_delete = 0" ,
Integer . class ,
roadId ,
refId
) ;
if ( count ! = null & & count > 0 ) {
result . put ( "status" , false ) ;
result . put ( "message" ,
"Selected road is already mapped to another Road War record" ) ;
return result ;
}
/ / 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, " +
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"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, " +
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete) " +
"SELECT " +
"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_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"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, " +
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete " +
"FROM road_details_master " +
"WHERE ref_id=?" ;
jdbcTemplate . update ( logSql , refId ) ;
/ / 3 . UPDATE ROAD MASTER
String updateSql =
"UPDATE road_details_master SET " +
"zone=?, " +
"ward=?, " +
"road_id=?, " +
"road_name=?, " +
"area_name=?, " +
"locality_name=?, " +
"road_type=?, " +
"road_type_material=?, " +
"road_length=?, " +
"road_row_width=?, " +
"road_avg_width=?, " +
"road_min_width=?, " +
"road_max_width=?, " +
"road_area=?, " +
"road_from=?, " +
"road_to=?, " +
"is_footpath=?, " +
"footpath_at=?, " +
"footpath_material=?, " +
"footpath_length=?, " +
"footpath_width=?, " +
"r_footpath_material=?, " +
"r_footpath_length=?, " +
"r_footpath_width=?, " +
"footpath_from_location=?, " +
"footpath_to_location=?, " +
"is_swd=?, " +
"swd_from=?, " +
"swd_to=?, " +
"swd_at=?," +
"swd_length=?, " +
"swd_size=?, " +
"rhs_swdlength=?, " +
"rhs_swdsize=?, " +
"is_scp=?, " +
"scp_at=?, " +
"scp_count=?, " +
"rhs_scpCount=?," +
"is_manhole=?, " +
"manhole_count=?, " +
"manhole_at=?, " +
"r_mhCount=?, " +
"is_cpipe=?, " +
"cpipe_count=?, " +
"cp_at=?, " +
"r_cpCount=?, " +
"is_rwh=?, " +
"rwh_count=?, " +
"rwh_at=?, " +
"r_rwCount=?, " +
"sewer_length=?, " +
"sewer_size=?, " +
"is_electric_poles=?, " +
"ep_count=?, " +
"is_hml=?, " +
"hml_count=?, " +
"is_streetlight_poles=?, " +
"streetlight_poles_count=?, " +
"is_mml=?, " +
"mml_count=?, " +
"culvert_bridge_count=?, " +
"details=?, " +
"is_busshelter=?, " +
"busshelter_count=?, " +
"is_centermedian=?, " +
"updated_date=NOW(), " +
"updated_by=? " +
"WHERE ref_id=?" ;
jdbcTemplate . update ( updateSql ,
payload . get ( "zone" ) ,
payload . get ( "ward" ) ,
payload . get ( "road_id" ) ,
payload . get ( "road_name" ) ,
payload . get ( "road_areaname" ) ,
payload . get ( "road_localityname" ) ,
payload . get ( "road_type" ) ,
payload . get ( "road_type_material" ) ,
payload . get ( "road_length" ) ,
payload . get ( "road_row_width" ) ,
payload . get ( "road_avg_width" ) ,
payload . get ( "road_min_width" ) ,
payload . get ( "road_max_width" ) ,
payload . get ( "road_area" ) ,
payload . get ( "road_from" ) ,
payload . get ( "road_to" ) ,
payload . get ( "is_footpath" ) ,
payload . get ( "footpath_at" ) ,
payload . get ( "footpath_material" ) ,
payload . get ( "footpath_length" ) ,
payload . get ( "footpath_width" ) ,
payload . get ( "rhs_footpathDropdown" ) ,
payload . get ( "rhs_fplength" ) ,
payload . get ( "rhs_fpwidth" ) ,
payload . get ( "footpath_from_location" ) ,
payload . get ( "footpath_to_location" ) ,
payload . get ( "is_swd" ) ,
payload . get ( "swd_from" ) ,
payload . get ( "swd_to" ) ,
payload . get ( "swd_at" ) ,
payload . get ( "swd_length" ) ,
payload . get ( "swd_size" ) ,
payload . get ( "rhs_swdlength" ) ,
payload . get ( "rhs_swdsize" ) ,
payload . get ( "is_scp" ) ,
payload . get ( "scp_at" ) ,
payload . get ( "scp_count" ) ,
payload . get ( "rhs_scpCount" ) ,
payload . get ( "is_manhole" ) ,
payload . get ( "manhole_count" ) ,
payload . get ( "manhole_at" ) ,
payload . get ( "r_mhCount" ) ,
payload . get ( "is_cpipe" ) ,
payload . get ( "cpipe_count" ) ,
payload . get ( "cp_at" ) ,
payload . get ( "r_cpCount" ) ,
payload . get ( "is_rwh" ) ,
payload . get ( "rwh_count" ) ,
payload . get ( "rwh_at" ) ,
payload . get ( "r_rwCount" ) ,
payload . get ( "sewer_length" ) ,
payload . get ( "sewer_size" ) ,
payload . get ( "is_electric_poles" ) ,
payload . get ( "ep_count" ) ,
payload . get ( "is_hml" ) ,
payload . get ( "hml_count" ) ,
payload . get ( "is_streetlight_poles" ) ,
payload . get ( "streetlight_poles_count" ) ,
payload . get ( "is_mml" ) ,
payload . get ( "mml_count" ) ,
payload . get ( "culvert_bridge_count" ) ,
payload . get ( "details" ) ,
payload . get ( "is_busshelter" ) ,
payload . get ( "busshelter_count" ) ,
payload . get ( "is_centermedian" ) ,
updatedBy ,
refId
) ;
/ / 4 . SOFT DELETE OLD RELAYING RECORDS
jdbcTemplate . update (
"UPDATE relaying_details " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_date=NOW(), " +
"updated_by=? " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
updatedBy ,
refId
) ;
/ / 5 . INSERT NEW RELAYING RECORDS
@SuppressWarnings ( "unchecked" )
List < Map < String , Object > > relays =
( List < Map < String , Object > > ) payload . get ( "relaying_details" ) ;
String insertRelay =
"INSERT INTO relaying_details " +
"(road_ref_id, relay_month, relay_year,road_type_material, cr_value, road_type, remarks, cby) " +
"VALUES (?,?,?,?,?,?,?,?)" ;
if ( relays ! = null ) {
for ( Map < String , Object > relay : relays ) {
jdbcTemplate . update (
insertRelay ,
refId ,
relay . get ( "relay_month" ) ,
relay . get ( "relay_year" ) ,
relay . get ( "road_type_material" ) ,
relay . get ( "cr_value" ) ,
relay . get ( "road_type" ) ,
relay . get ( "remarks" ) ,
updatedBy
) ;
}
}
result . put ( "status" , true ) ;
result . put ( "message" , "Road details updated successfully" ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
result . put ( "status" , false ) ;
result . put ( "message" , e . getMessage ( ) ) ;
}
return result ;
}
Map < String , Object > result = new HashMap < > ( ) ;
try {
String refId = String . valueOf ( payload . get ( "ref_id" ) ) ;
String updatedBy = String . valueOf ( payload . get ( "updated_by" ) ) ;
String roadId = String . valueOf ( payload . get ( "road_id" ) ) ;
Integer count = jdbcTemplate . queryForObject (
"SELECT COUNT(*) " +
"FROM road_details_master " +
"WHERE road_id = ? " +
"AND ref_id <> ? " +
"AND is_active = 1 " +
"AND is_delete = 0" ,
Integer . class ,
roadId ,
refId ) ;
if ( count ! = null & & count > 0 ) {
result . put ( "status" , false ) ;
result . put ( "message" ,
"Selected road is already mapped to another Road War record" ) ;
return result ;
}
/ / 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, "
+
"road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " +
"road_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"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, "
+
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete) " +
"SELECT " +
"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_from,road_to,is_footpath,footpath_at, " +
"footpath_material, footpath_length, footpath_width, " +
"r_footpath_material, r_footpath_length, r_footpath_width, " +
"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, "
+
"is_swd, swd_from, swd_to, swd_length, swd_size, " +
"is_scp, scp_count, is_manhole, manhole_count, manhole_location, " +
"is_cpipe, cpipe_count, is_rwh, rwh_count, " +
"sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " +
"is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " +
"culvert_bridge_count, details, is_busshelter, busshelter_count, " +
"is_centermedian, erp_asset_code, ref_id, cdate, cby, " +
"updated_date, updated_by, is_active, is_delete " +
"FROM road_details_master " +
"WHERE ref_id=?" ;
jdbcTemplate . update ( logSql , refId ) ;
/ / 3 . UPDATE ROAD MASTER
String updateSql = "UPDATE road_details_master SET " +
"zone=?, " +
"ward=?, " +
"road_id=?, " +
"road_name=?, " +
"area_name=?, " +
"locality_name=?, " +
"road_type=?, " +
"road_type_material=?, " +
"road_length=?, " +
"road_row_width=?, " +
"road_avg_width=?, " +
"road_min_width=?, " +
"road_max_width=?, " +
"road_area=?, " +
"road_from=?, " +
"road_to=?, " +
"is_footpath=?, " +
"footpath_at=?, " +
"footpath_material=?, " +
"footpath_length=?, " +
"footpath_width=?, " +
"r_footpath_material=?, " +
"r_footpath_length=?, " +
"r_footpath_width=?, " +
"footpath_from_location=?, " +
"footpath_to_location=?, " +
"is_swd=?, " +
"swd_from=?, " +
"swd_to=?, " +
"swd_at=?," +
"swd_length=?, " +
"swd_size=?, " +
"rhs_swdlength=?, " +
"rhs_swdsize=?, " +
"is_scp=?, " +
"scp_at=?, " +
"scp_count=?, " +
"rhs_scpCount=?," +
"is_manhole=?, " +
"manhole_count=?, " +
"manhole_at=?, " +
"r_mhCount=?, " +
"is_cpipe=?, " +
"cpipe_count=?, " +
"cp_at=?, " +
"r_cpCount=?, " +
"is_rwh=?, " +
"rwh_count=?, " +
"rwh_at=?, " +
"r_rwCount=?, " +
"sewer_length=?, " +
"sewer_size=?, " +
"is_electric_poles=?, " +
"ep_count=?, " +
"is_hml=?, " +
"hml_count=?, " +
"is_streetlight_poles=?, " +
"streetlight_poles_count=?, " +
"is_mml=?, " +
"mml_count=?, " +
"culvert_bridge_count=?, " +
"details=?, " +
"is_busshelter=?, " +
"busshelter_count=?, " +
"is_centermedian=?, " +
"updated_date=NOW(), " +
"updated_by=? " +
"WHERE ref_id=?" ;
jdbcTemplate . update ( updateSql ,
payload . get ( "zone" ) ,
payload . get ( "ward" ) ,
payload . get ( "road_id" ) ,
payload . get ( "road_name" ) ,
payload . get ( "road_areaname" ) ,
payload . get ( "road_localityname" ) ,
payload . get ( "road_type" ) ,
payload . get ( "road_type_material" ) ,
payload . get ( "road_length" ) ,
payload . get ( "road_row_width" ) ,
payload . get ( "road_avg_width" ) ,
payload . get ( "road_min_width" ) ,
payload . get ( "road_max_width" ) ,
payload . get ( "road_area" ) ,
payload . get ( "road_from" ) ,
payload . get ( "road_to" ) ,
payload . get ( "is_footpath" ) ,
payload . get ( "footpath_at" ) ,
payload . get ( "footpath_material" ) ,
payload . get ( "footpath_length" ) ,
payload . get ( "footpath_width" ) ,
payload . get ( "rhs_footpathDropdown" ) ,
payload . get ( "rhs_fplength" ) ,
payload . get ( "rhs_fpwidth" ) ,
payload . get ( "footpath_from_location" ) ,
payload . get ( "footpath_to_location" ) ,
payload . get ( "is_swd" ) ,
payload . get ( "swd_from" ) ,
payload . get ( "swd_to" ) ,
payload . get ( "swd_at" ) ,
payload . get ( "swd_length" ) ,
payload . get ( "swd_size" ) ,
payload . get ( "rhs_swdlength" ) ,
payload . get ( "rhs_swdsize" ) ,
payload . get ( "is_scp" ) ,
payload . get ( "scp_at" ) ,
payload . get ( "scp_count" ) ,
payload . get ( "rhs_scpCount" ) ,
payload . get ( "is_manhole" ) ,
payload . get ( "manhole_count" ) ,
payload . get ( "manhole_at" ) ,
payload . get ( "r_mhCount" ) ,
payload . get ( "is_cpipe" ) ,
payload . get ( "cpipe_count" ) ,
payload . get ( "cp_at" ) ,
payload . get ( "r_cpCount" ) ,
payload . get ( "is_rwh" ) ,
payload . get ( "rwh_count" ) ,
payload . get ( "rwh_at" ) ,
payload . get ( "r_rwCount" ) ,
payload . get ( "sewer_length" ) ,
payload . get ( "sewer_size" ) ,
payload . get ( "is_electric_poles" ) ,
payload . get ( "ep_count" ) ,
payload . get ( "is_hml" ) ,
payload . get ( "hml_count" ) ,
payload . get ( "is_streetlight_poles" ) ,
payload . get ( "streetlight_poles_count" ) ,
payload . get ( "is_mml" ) ,
payload . get ( "mml_count" ) ,
payload . get ( "culvert_bridge_count" ) ,
payload . get ( "details" ) ,
payload . get ( "is_busshelter" ) ,
payload . get ( "busshelter_count" ) ,
payload . get ( "is_centermedian" ) ,
updatedBy ,
refId ) ;
/ / 4 . SOFT DELETE OLD RELAYING RECORDS
jdbcTemplate . update (
"UPDATE relaying_details " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_date=NOW(), " +
"updated_by=? " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
updatedBy ,
refId ) ;
/ / 5 . INSERT NEW RELAYING RECORDS
@SuppressWarnings ( "unchecked" )
List < Map < String , Object > > relays = ( List < Map < String , Object > > ) payload . get ( "relaying_details" ) ;
String insertRelay = "INSERT INTO relaying_details " +
"(road_ref_id, relay_month, relay_year,road_type_material, cr_value, road_type, remarks, cby) " +
"VALUES (?,?,?,?,?,?,?,?)" ;
if ( relays ! = null ) {
for ( Map < String , Object > relay : relays ) {
jdbcTemplate . update (
insertRelay ,
refId ,
relay . get ( "relay_month" ) ,
relay . get ( "relay_year" ) ,
relay . get ( "road_type_material" ) ,
relay . get ( "cr_value" ) ,
relay . get ( "road_type" ) ,
relay . get ( "remarks" ) ,
updatedBy ) ;
}
}
result . put ( "status" , true ) ;
result . put ( "message" , "Road details updated successfully" ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
result . put ( "status" , false ) ;
result . put ( "message" , e . getMessage ( ) ) ;
}
return result ;
}
public Map < String , Object > deleteRoadWarDetails ( String refId , String updatedby ) {
Map < String , Object > result = new HashMap < > ( ) ;
try {
int roadUpdated = jdbcTemplate . update (
"UPDATE road_details_master " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_date=NOW() " +
"WHERE ref_id=? " +
"AND is_active=1" ,
updatedby , refId
) ;
jdbcTemplate . update (
"UPDATE relaying_details " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_date=NOW() " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
updatedby , refId
) ;
if ( roadUpdated > 0 ) {
result . put ( "status" , true ) ;
result . put ( "message" ,
"Road War details deleted successfully" ) ;
} else {
result . put ( "status" , false ) ;
result . put ( "message" , "Record not found" ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
result . put ( "status" , false ) ;
result . put ( "message" ,
"Failed to delete Road War details" ) ;
}
return result ;
Map < String , Object > result = new HashMap < > ( ) ;
try {
int roadUpdated = jdbcTemplate . update (
"UPDATE road_details_master " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_date=NOW() " +
"WHERE ref_id=? " +
"AND is_active=1" ,
updatedby , refId ) ;
jdbcTemplate . update (
"UPDATE relaying_details " +
"SET is_active=0, " +
"is_delete=1, " +
"updated_by=?, " +
"updated_date=NOW() " +
"WHERE road_ref_id=? " +
"AND is_active=1" ,
updatedby , refId ) ;
if ( roadUpdated > 0 ) {
result . put ( "status" , true ) ;
result . put ( "message" ,
"Road War details deleted successfully" ) ;
} else {
result . put ( "status" , false ) ;
result . put ( "message" , "Record not found" ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
result . put ( "status" , false ) ;
result . put ( "message" ,
"Failed to delete Road War details" ) ;
}
return result ;
}
}