From 8789a02b646c47446b4b65ef2f64b58488eee68e Mon Sep 17 00:00:00 2001 From: Hariprasath S <113695067+Hariprasath4022@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:11:48 +0530 Subject: [PATCH] Changes in roadwar register and update form --- .../configuration/DataSourceConfig.java | 15 +- .../roadwar/controller/Maincontroller.java | 15 + .../controller/RegisterApiController.java | 53 +- .../roadwar/service/LoginMappingService.java | 51 + .../roadwar/service/RegisterService.java | 440 +++- .../src/main/resources/application.properties | 4 +- .../templates/modules/roadwar/regform.html | 921 +++++-- .../templates/modules/roadwar/updateform.html | 2206 +++++++++++++---- 8 files changed, 2997 insertions(+), 708 deletions(-) create mode 100644 gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java index c0fee04e..43f55a13 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java @@ -24,8 +24,8 @@ import java.util.Properties; @EnableTransactionManagement public class DataSourceConfig { - // private static String host = "localhost:3306"; - // private static String dbpassword = "root"; +// private static String host = "localhost:3306"; +// private static String dbpassword = "root"; // private static String dbpassword = "gccroot"; @@ -430,6 +430,17 @@ public class DataSourceConfig { dataSource.setPassword(dbpassword); return dataSource; } + + //////////////////////////////(For GCC USER) //////////////////////// + @Bean(name = "mysqlGCCUserDataSource") + public DataSource mysqlGCCUserDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_users"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } ////////////////////////////// ORACLE //////////////////////// @Bean(name = "oracleDataSource") diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java index 31664053..a00ecb62 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java @@ -6,6 +6,7 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import in.gov.chennaicorporation.gccoffice.roadwar.service.LoginMappingService; import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; @RequestMapping("/gcc/roadwarweb") @@ -15,11 +16,19 @@ public class Maincontroller { @Autowired private LoginUserInfo loginUserInfo; + @Autowired + private LoginMappingService loginMappingService; @GetMapping("/regform") public String viewdashboard(Model model) { String LoginUserId = LoginUserInfo.getLoginUserId(); model.addAttribute("LoginUserId", LoginUserId); + + String zone=loginMappingService.getZoneByUserId(LoginUserId); + String ward=loginMappingService.getWardByUserId(LoginUserId); + + model.addAttribute("Loginzone", zone); + model.addAttribute("Loginward", ward); String UserRole = LoginUserInfo.getUserRole(); model.addAttribute("UserRole", UserRole); @@ -32,6 +41,12 @@ public class Maincontroller { public String updateForm(Model model) { String LoginUserId = LoginUserInfo.getLoginUserId(); model.addAttribute("LoginUserId", LoginUserId); + + String zone=loginMappingService.getZoneByUserId(LoginUserId); + String ward=loginMappingService.getWardByUserId(LoginUserId); + + model.addAttribute("Loginzone", zone); + model.addAttribute("Loginward", ward); String UserRole = LoginUserInfo.getUserRole(); model.addAttribute("UserRole", UserRole); diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java index 9c224199..817e8a2f 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java @@ -102,6 +102,37 @@ public class RegisterApiController { } + @GetMapping("/getRoadTypeMaterial") + public Map getRoadTypeMaterial() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getRoadTypeMaterial(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Roadtype Material fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No roadtype material found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + @GetMapping("/getFootpathType") + public Map getFootpathType() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getFootpathType(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Footpath Types fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No Footpath Types found"); + response.put("data", Collections.emptyList()); + } + return response; + } @GetMapping("/getMonthList") public Map getMonthList() { @@ -146,14 +177,15 @@ public class RegisterApiController { @GetMapping("/getAllRoadWarDetails") public ResponseEntity getAllRoadWarDetails( + @RequestParam(required = false) String userid, @RequestParam(required = false) String zone, @RequestParam(required = false) String ward, - @RequestParam(required = false) String roadName) { + @RequestParam(required = false) String roadId) { try { List> response = - registerService.getAllRoadWarDetails(zone, ward, roadName); + registerService.getAllRoadWarDetails(userid,zone, ward, roadId); return ResponseEntity.ok(response); @@ -190,4 +222,21 @@ public class RegisterApiController { } } + @GetMapping("/checkRoadExists") + public Map checkRoadExists(@RequestParam("roadId") Integer roadId) { + return registerService.checkRoadExists(roadId); + } + + @PostMapping("/updateRoadWarDetails") + public Map updateRoadWarDetails(@RequestBody Map payload) { + return registerService.updateRoadWarDetails(payload); + } + + @PostMapping("/deleteRoadWarDetails") + public Map deleteRoadWarDetails( + @RequestParam String refId,@RequestParam String updatedby) { + + return registerService.deleteRoadWarDetails(refId,updatedby); + } + } diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java new file mode 100644 index 00000000..d8d97b8a --- /dev/null +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java @@ -0,0 +1,51 @@ +package in.gov.chennaicorporation.gccoffice.roadwar.service; + +import java.util.Collections; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class LoginMappingService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("mysqlGCCUserDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public String getZoneByUserId(String userid) { + + String sql = "SELECT zone FROM user_mapping_details WHERE userid=?"; + + try { + return jdbcTemplate.queryForObject(sql, String.class, userid); + }catch (EmptyResultDataAccessException e) { + return ""; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + public String getWardByUserId(String userid) { + + String sql = "SELECT ward FROM user_mapping_details WHERE userid=?"; + + try { + return jdbcTemplate.queryForObject(sql, String.class, userid); + } catch (EmptyResultDataAccessException e) { + return ""; + }catch (Exception e) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java index de2705f5..3354e4a5 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java @@ -22,6 +22,7 @@ import org.springframework.jdbc.support.GeneratedKeyHolder; import org.springframework.jdbc.support.KeyHolder; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -34,9 +35,7 @@ public class RegisterService { @Autowired private Environment environment; - - - + @Autowired public void setDataSource(@Qualifier("mysqlRoadWarDataSource") DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); @@ -117,6 +116,27 @@ public class RegisterService { } + public List> getRoadTypeMaterial() { + String sql = "Select id,roadtype_material from roadtype_material_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getFootpathType() { + String sql = "Select id,footpath_type_name from footpath_type_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getMonthList() { String sql = "SELECT id, month_name FROM month_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id"; try { @@ -151,8 +171,9 @@ public class RegisterService { + " is_cpipe, cpipe_count, is_rwh, rwh_count, " + " sewer_length, sewer_size, " + " is_electric_poles, ep_count, is_hml, culvert_bridge_count, details, " - + " is_busshelter, busshelter_count, is_centermedian, erp_asset_code, cby,road_id) " - + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + " is_busshelter, busshelter_count, is_centermedian, erp_asset_code, cby,road_id,road_type_material,road_min_width,road_max_width, " + + " hml_count,is_streetlight_poles,streetlight_poles_count,is_mml,mml_count,road_from,road_to,is_footpath,footpath_at) " + + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; KeyHolder keyHolder = new GeneratedKeyHolder(); @@ -198,6 +219,18 @@ public class RegisterService { ps.setObject(37, payload.get("erp_asset_code")); ps.setObject(38, payload.get("cby")); ps.setObject(39, payload.get("road_id")); + ps.setObject(40, payload.get("road_type_material")); + ps.setObject(41, payload.get("road_min_width")); + ps.setObject(42, payload.get("road_max_width")); + ps.setObject(43, payload.get("hml_count")); + ps.setObject(44, payload.get("is_streetlight_poles")); + ps.setObject(45, payload.get("streetlight_poles_count")); + ps.setObject(46, payload.get("is_mml")); + ps.setObject(47, payload.get("mml_count")); + ps.setObject(48, payload.get("roadfrom")); + ps.setObject(49, payload.get("roadto")); + ps.setObject(50, payload.get("is_footpath")); + ps.setObject(51, payload.get("footpathat")); return ps; }, keyHolder); @@ -213,14 +246,15 @@ public class RegisterService { if (relayingList != null && !relayingList.isEmpty()) { String insertRelay = "INSERT INTO relaying_details " - + "(road_ref_id, relay_month, relay_year, cr_value, road_type, remarks, cby) " - + "VALUES (?,?,?,?,?,?,?)"; + + "(road_ref_id, relay_month, relay_year,road_type_material ,cr_value, road_type, remarks, cby) " + + "VALUES (?,?,?,?,?,?,?,?)"; for (Map relay : relayingList) { 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"), @@ -243,16 +277,25 @@ public class RegisterService { public List> getAllRoadWarDetails( + String userid, String zone, String ward, - String roadName) { + String roadId) { - StringBuilder sql = new StringBuilder(" SELECT rdm.*,rtm.road_type as road_type_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 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 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); @@ -263,11 +306,11 @@ public class RegisterService { params.add(ward); } - if (roadName != null && !roadName.isEmpty()) { - sql.append(" AND rdm.road_name = ?"); - params.add(roadName); + 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(" ORDER BY rdm.id DESC"); @@ -283,9 +326,11 @@ public class RegisterService { try { String sql = - "SELECT rdm.*, rtm.road_type As road_type_name " + + "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 road = @@ -295,10 +340,11 @@ public class RegisterService { List> relayingDetails = jdbcTemplate.queryForList( - " SELECT rd.*,mm.month_name,ym.year_name " + " 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); @@ -315,4 +361,368 @@ public class RegisterService { return result; } + public Map checkRoadExists(Integer roadId) { + + Map response = new HashMap<>(); + + try { + + String sql = " SELECT COUNT(*) FROM road_details_master " + + + " WHERE road_id = ? AND is_active=1 AND is_delete = 0 "; + + Integer count = jdbcTemplate.queryForObject( + sql, + Integer.class, + roadId + ); + + response.put("status", true); + response.put("exists", count != null && count > 0); + + } catch (Exception e) { + + e.printStackTrace(); + + response.put("status", false); + response.put("message", "Error while checking road"); + + } + + return response; + } + + @Transactional + public Map updateRoadWarDetails(Map payload) { + + Map 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, road_type,road_type_material, highway_ans, " + + "road_length, 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, " + + "footpath_from_location, footpath_to_location, " + + "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, road_type,road_type_material, highway_ans, " + + "road_length, 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, " + + "footpath_from_location, footpath_to_location, " + + "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); + + + // 2. IF SWD = NO CLEAR DEPENDENT VALUES + + + String isSwd = (String) payload.get("is_swd"); + + if ("no".equalsIgnoreCase(isSwd)) { + + payload.put("swd_from", null); + payload.put("swd_to", null); + payload.put("swd_length", null); + payload.put("swd_size", null); + + payload.put("is_scp", null); + payload.put("scp_count", null); + + payload.put("is_manhole", null); + payload.put("manhole_count", null); + payload.put("manhole_location", null); + + payload.put("is_cpipe", null); + payload.put("cpipe_count", null); + + payload.put("is_rwh", null); + payload.put("rwh_count", null); + } + + // 3. UPDATE ROAD MASTER + + String updateSql = + "UPDATE road_details_master SET " + + "zone=?, " + + "ward=?, " + + "road_id=?, " + + "road_name=?, " + + "road_type=?, " + + "road_type_material=?, " + + "road_length=?, " + + "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=?, " + + "footpath_from_location=?, " + + "footpath_to_location=?, " + + "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=?, " + + "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_type"), + payload.get("road_type_material"), + + payload.get("road_length"), + 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("footpath_from_location"), + payload.get("footpath_to_location"), + + payload.get("is_swd"), + payload.get("swd_from"), + payload.get("swd_to"), + payload.get("swd_length"), + payload.get("swd_size"), + + payload.get("is_scp"), + payload.get("scp_count"), + + payload.get("is_manhole"), + payload.get("manhole_count"), + payload.get("manhole_location"), + + payload.get("is_cpipe"), + payload.get("cpipe_count"), + + payload.get("is_rwh"), + payload.get("rwh_count"), + + 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> relays = + (List>) 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 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 deleteRoadWarDetails(String refId, String updatedby) { + Map 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; + } + } diff --git a/gcc_officer_portal/src/main/resources/application.properties b/gcc_officer_portal/src/main/resources/application.properties index ad06f8ad..376e518b 100644 --- a/gcc_officer_portal/src/main/resources/application.properties +++ b/gcc_officer_portal/src/main/resources/application.properties @@ -1,5 +1,5 @@ -spring.profiles.active=local -#spring.profiles.active=production +#spring.profiles.active=local +spring.profiles.active=production #For Server production #assets.base-url=/gcc/assets/ #For local test diff --git a/gcc_officer_portal/src/main/resources/templates/modules/roadwar/regform.html b/gcc_officer_portal/src/main/resources/templates/modules/roadwar/regform.html index d1320add..ca2a112d 100644 --- a/gcc_officer_portal/src/main/resources/templates/modules/roadwar/regform.html +++ b/gcc_officer_portal/src/main/resources/templates/modules/roadwar/regform.html @@ -52,6 +52,9 @@
Road Details
+ + +
@@ -59,7 +62,7 @@ -
+
+ +
+ -
-
+ +
+
- - - -
-
- - -
-
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + + +
+ + +
+ +
+
+ + + +
+ +
-
+
@@ -223,13 +299,13 @@
- - + +
- - + +
@@ -254,14 +330,14 @@
- + +
-
+
+
+ + +
+ +
+ + +
+
-
+ +
+ +
+ + +
+ +
+ +
@@ -364,27 +479,34 @@ No
+
- -
+ + +
- -
+ + +
@@ -396,33 +518,30 @@ No
- -
+ +
-
+
+ + name="sewerLength" placeholder="e.g. 190.5">
-
- +
+ + name="sewerSize" placeholder="e.g. 300.0">
-
+
- +
@@ -465,27 +584,37 @@
+ + +
+ + +
- +
-
+
@@ -553,43 +682,58 @@ diff --git a/gcc_officer_portal/src/main/resources/templates/modules/roadwar/updateform.html b/gcc_officer_portal/src/main/resources/templates/modules/roadwar/updateform.html index 30fafa2a..a71f071c 100644 --- a/gcc_officer_portal/src/main/resources/templates/modules/roadwar/updateform.html +++ b/gcc_officer_portal/src/main/resources/templates/modules/roadwar/updateform.html @@ -7,6 +7,9 @@ .custom-width1 { width: 30%; /* Adjust the width as needed */ } +.custom-width2 { + width: 15%; /* Adjust the width as needed */ +} #roadWarModal .modal-body { max-height: 80vh; /* Limit the height to 70% of the viewport */ overflow-y: auto; /* Enable vertical scrolling */ @@ -56,14 +59,15 @@
- Reports Filters + Filters +
@@ -84,7 +88,7 @@
+
- - + +
- - + +
- - + + +
+ +
+ +
- + + class="form-control decimal-only">
- +
- + + class="form-control decimal-only" >
- -
- + +
+ + class="form-control decimal-only" > +
+ + + +
+ + +
+ +
+ +
-
+
+ +
+
+ + +
+ +
+ + +
+
+
+ +
+ + + +
+ + + +
+ +
+ +
+ +