Browse Source

Changes in Roadwar mis report

master
Hariprasath S 1 month ago
parent
commit
21acaa100b
  1. 11
      src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java
  2. 30
      src/main/java/com/gcc/commissionerreview/service/RoadWarService.java
  3. 81
      src/main/resources/templates/modules/roadwarweb/misreport.html

11
src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java

@ -234,6 +234,17 @@ public class DataSourceConfig {
return dataSource; return dataSource;
} }
//////////RoadWar //////////////////////
@Bean(name = "mysqlRoadWarDataSource")
public DataSource mysqlRoadWarDataSource() {
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;
}
@Bean(name = "mysqlcowrspaceDataSource") @Bean(name = "mysqlcowrspaceDataSource")
public DataSource mysqlCoworkspacebDataSource() { public DataSource mysqlCoworkspacebDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource(); DriverManagerDataSource dataSource = new DriverManagerDataSource();

30
src/main/java/com/gcc/commissionerreview/service/RoadWarService.java

@ -57,6 +57,10 @@ public class RoadWarService {
private String fileBaseUrl; private String fileBaseUrl;
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private JdbcTemplate roadwarjdbcTemplate;
@Autowired @Autowired
private Environment environment; private Environment environment;
@ -65,6 +69,11 @@ public class RoadWarService {
this.jdbcTemplate = new JdbcTemplate(DataSource); this.jdbcTemplate = new JdbcTemplate(DataSource);
} }
@Autowired
public void setDataSource2(@Qualifier("mysqlRoadWarDataSource") DataSource DataSource) {
this.roadwarjdbcTemplate = new JdbcTemplate(DataSource);
}
public RoadWarService(Environment environment) { public RoadWarService(Environment environment) {
this.environment = environment; this.environment = environment;
@ -931,6 +940,27 @@ public class RoadWarService {
result.put("fileDetails", fileDetails); result.put("fileDetails", fileDetails);
String roadId = String.valueOf(road.get("road_id"));
//System.out.println("========Road id========="+roadId);
List<Map<String, Object>> geolocdetails = roadwarjdbcTemplate.queryForList(
"SELECT *, " +
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', centre_img) AS centre_img_url " +
"FROM centre_street_details " +
"WHERE road_id = ? AND isactive = 1 AND isdelete = 0",
roadId
);
// Replace null values with empty string
for (Map<String, Object> row : geolocdetails) {
for (Map.Entry<String, Object> entry : row.entrySet()) {
if (entry.getValue() == null) {
entry.setValue("");
}
}
}
result.put("geolocdetails", geolocdetails);
result.put("message", "Fetched Details Successfully"); result.put("message", "Fetched Details Successfully");
result.put("status", true); result.put("status", true);

81
src/main/resources/templates/modules/roadwarweb/misreport.html

@ -1058,6 +1058,8 @@
<div id="viewFileContainer"></div> <div id="viewFileContainer"></div>
<div id="viewGeoLocContainer"></div>
<div class="text-center mt-3"> <div class="text-center mt-3">
<button type="button" <button type="button"
id="btnDownloadPdf" id="btnDownloadPdf"
@ -2715,6 +2717,85 @@ function fetchRoadWarDetails(refId) {
fileContainer.html(html); fileContainer.html(html);
} }
let GeoContainer = $("#viewGeoLocContainer");
GeoContainer.empty();
if (response.geolocdetails && response.geolocdetails.length > 0) {
let html = `
<h5 class="mt-4">GeoLocation Details</h5>
<div class="row">
`;
$.each(response.geolocdetails, function(index, file) {
let url = file.centre_img_url;
let latitude = file.start_latitude || "";
let longitude = file.start_longitude || "";
html+=`<div class="mb-2">
<strong>Latitude:</strong> ${latitude}
</div>
<div class="mb-3">
<strong>Longitude:</strong> ${longitude}
</div>`;
if (url.trim() === "") {
// Image Not Available
html += `
<div class="col-md-2 col-4 mb-3 text-center">
<div class="border rounded d-flex align-items-center justify-content-center"
style="height:120px; width:100%; background:#f5f5f5;">
<span class="text-muted">
Image Not Available
</span>
</div>
</div>
`;
} else {
let extension = url.split('.').pop().split('?')[0].toLowerCase();
// image/pdf
if (extension === "pdf") {
html += `
<div class="col-md-2 col-4 mb-3 text-center">
<div class="pdf-file-box" onclick="showPreview('${url}')">
PDF File ${index + 1}
</div>
</div>
`;
} else {
html += `
<div class="col-md-2 col-4 mb-3 text-center">
<img src="${url}"
class="img-thumbnail"
style="height:120px;width:100%;object-fit:cover;cursor:pointer;"
onclick="showPreview('${url}')">
</div>
`;
}
}
});
html += "</div>";
GeoContainer.html(html);
}
$('#titleModalLabel').text(`Road War Details - ${response.ref_id}`); $('#titleModalLabel').text(`Road War Details - ${response.ref_id}`);

Loading…
Cancel
Save