diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java b/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java index cdd8dc6..2f11073 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java @@ -408,7 +408,7 @@ public class DataSourceConfig { return dataSource; } - /////////////// Road War ///////////////////// + /////////////// Road War Web ///////////////////// @Bean(name = "mysqlRoadWarDataSource") public DataSource mysqlRoadWarDataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); @@ -418,6 +418,18 @@ public class DataSourceConfig { dataSource.setPassword(dbpassword); return dataSource; } + + /////////////// Road War Mobile Service ///////////////////// + + @Bean(name = "mysqlGccRoadWarSource") + public DataSource mysqlGccRoadWarSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_roadwar"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } // homeles @Bean(name = "mysqlHomelessSurveyDataSource") diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java index 6ea8d30..0928e6e 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java @@ -216,13 +216,11 @@ public class RegisterApiController { @GetMapping("/getRoadWarDetailsById") - public ResponseEntity getRoadWarDetailsById( - @RequestParam String refid) { + public ResponseEntity getRoadWarDetailsById(@RequestParam String refid) { try { - Map response = - registerService.getRoadWarDetailsById(refid); + Map response = registerService.getRoadWarDetailsById(refid); return ResponseEntity.ok(response); @@ -232,9 +230,7 @@ public class RegisterApiController { error.put("status", false); error.put("message", "Failed to fetch data : " + e.getMessage()); - return ResponseEntity - .status(HttpStatus.INTERNAL_SERVER_ERROR) - .body(error); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); } } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java index 6c44dd2..6aa89be 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java @@ -17,6 +17,7 @@ import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.PreparedStatementCreator; @@ -34,14 +35,34 @@ public class RegisterService { @Autowired private JdbcTemplate jdbcTemplate; + + @Autowired + @Value("${fileBaseUrl}") + + private String fileBaseUrl; @Autowired private Environment environment; + + @Autowired + private JdbcTemplate roadwarjdbcTemplate; @Autowired public void setDataSource(@Qualifier("mysqlRoadWarDataSource") DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } + + @Autowired + public void setDataSource2(@Qualifier("mysqlGccRoadWarSource") DataSource DataSource) { + this.roadwarjdbcTemplate = new JdbcTemplate(DataSource); + } + + public RegisterService(Environment environment) { + + this.environment = environment; + + this.fileBaseUrl = environment.getProperty("fileBaseUrl"); + } public List> ViewZoneDropdown() { String sql = "SELECT zone_name " @@ -397,6 +418,48 @@ public class RegisterService { refid); result.put("relayingDetails", relayingDetails); + + + List> fileDetails =jdbcTemplate.queryForList( + "SELECT *, CONCAT('" + fileBaseUrl + "/gccofficialapp/files',file_path) as file_url " + +" FROM road_master_files " + + " WHERE road_ref_id = ? AND is_active=1 AND is_delete=0 ", + refid); + + for (Map row : fileDetails) { + for (Map.Entry entry : row.entrySet()) { + if (entry.getValue() == null) { + entry.setValue(""); + } + } + } + + result.put("fileDetails", fileDetails); + + String roadId = String.valueOf(road.get("road_id")); + + List> inspectiondetails=roadwarjdbcTemplate.queryForList( + "select ssd.road_id,ssd.start_latitude,ssd.start_longitude, CONCAT('" + fileBaseUrl + "/gccofficialapp/files',ssd.start_img) as start_img, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files',csd.centre_img) as centre_img, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files',esd.end_img) as end_img " + + "from start_street_details ssd " + + "left join centre_street_details csd on ssd.road_id = csd.road_id " + + "left join end_street_details esd on ssd.road_id = esd.road_id " + + "where ssd.road_id = ? and ssd.isactive = 1 and ssd.isdelete = 0 limit 1 ", + roadId + ); + + for (Map row : inspectiondetails) { + for (Map.Entry entry : row.entrySet()) { + if (entry.getValue() == null) { + entry.setValue(""); + } + } + } + + result.put("inspectiondetails", inspectiondetails); + + result.put("status", true); } catch (Exception e) { diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index c188cc6..fb8a940 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -1,4 +1,4 @@ assets.base-url=/assets/ - -fileBaseUrl=http://localhost:8064 +fileBaseUrl=https://gccservices.in +#fileBaseUrl=http://localhost:8064 diff --git a/src/main/resources/templates/modules/roadwar/updateform.html b/src/main/resources/templates/modules/roadwar/updateform.html index 621aa15..55e7faf 100644 --- a/src/main/resources/templates/modules/roadwar/updateform.html +++ b/src/main/resources/templates/modules/roadwar/updateform.html @@ -20,6 +20,27 @@ overflow-y: auto; /* Enable vertical scrolling */ } + .pdf-file-box{ + height:60px; + display:flex; + align-items:center; + justify-content:center; + border:1px solid #ced4da; + border-radius:5px; + background:#f8f9fa; + color:#495057; + font-weight:bold; + cursor:pointer; + transition:all .3s ease; + } + + .pdf-file-box:hover{ + background:#007bff; + color:#fff; + border-color:#007bff; + transform:scale(1.03); + box-shadow:0 4px 10px rgba(0,0,0,.2); + } @@ -180,6 +201,11 @@ + + + + + @@ -856,12 +882,47 @@ Cancel + + + +
+ +
+ + + @@ -2607,8 +2668,64 @@ }); } + + let fileContainer = $("#viewFileContainer"); + fileContainer.empty(); + + if (response.fileDetails && response.fileDetails.length > 0) { + + let html = ` +
Uploaded Files
+
+ `; + + $.each(response.fileDetails, function(index, file) { + + let url = file.file_url; + let extension = url.split('.').pop().toLowerCase(); + + if (extension === "pdf") { + + html += ` +
+ +
+ + PDF File ${index + 1} + +
+ +
+ `; + + } else { + + html += ` +
+ + + +
+ `; + } + + }); + + html += "
"; + + fileContainer.html(html); + } + + renderInspectionDetails(response.inspectiondetails); + $('#titleModalLabel').text(`Road War Details - ${response.ref_id}`); + + + $("#roadWarModal").modal("show"); @@ -2627,6 +2744,116 @@ }); } + + function renderInspectionDetails(data) { + + let container = $("#InspectionFileContainer"); + container.empty(); + + if (data && data.length > 0) { + + let inspection = data[0]; + + let html = ` +
Street Images
+
+ `; + + let url = inspection.start_img; + + // Get latitude and longitude + let latitude = inspection.start_latitude; + let longitude = inspection.start_longitude; + + // Google Maps Embed URL + let mapUrl = ''; + + if (latitude && longitude) { + + + mapUrl = + "https://maps.google.com/maps?q=" + + latitude + "," + longitude + + "&z=18&output=embed"; + } + + + if (url) { + + let extension = url.split('?')[0].split('.').pop().toLowerCase(); + + if (extension === "pdf") { + + html += ` +
+
+ PDF File +
+
+ `; + + } else { + + html += ` +
+ +
+ `; + } + } + + + if (mapUrl) { + + html += ` +
+ + + +
+ `; + } + + html += `
`; + + container.html(html); + } + } + + function showPreview(fileUrl) { + + let extension = fileUrl.split('.').pop().toLowerCase(); + + if (extension === "pdf") { + + $("#previewImage").hide(); + $("#previewPdf").show(); + + $("#previewPdf").attr("src", fileUrl); + + } else { + + $("#previewPdf").hide(); + $("#previewImage").show(); + + $("#previewImage").attr("src", fileUrl); + } + + $("#imagePreviewModal").modal("show"); + } + $(document).on('click', '.removeRelayRow', function () { let totalRows = $('.relay-block').length;