Browse Source

Added dashboard menu in roadwar register

master
Hariprasath S 6 days ago
parent
commit
9f4f6bf85e
  1. 7
      src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java
  2. 40
      src/main/java/in/gov/chennaicorporation/gccoffice/works/controller/APIContoller.java
  3. 77
      src/main/java/in/gov/chennaicorporation/gccoffice/works/service/EstimateService.java
  4. 32
      src/main/resources/templates/modules/roadwar/dashboard.html

7
src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java

@ -54,4 +54,11 @@ public class Maincontroller {
return "modules/roadwar/updateform"; return "modules/roadwar/updateform";
} }
@GetMapping("/dashboard")
public String roadWarDashboard(Model model) {
String externalUrl = "https://gccservices.in/commissionerreview/roadwarRegisterDashboard";
model.addAttribute("externalUrl", externalUrl);
return "modules/roadwar/dashboard";
}
} }

40
src/main/java/in/gov/chennaicorporation/gccoffice/works/controller/APIContoller.java

@ -987,6 +987,24 @@ public class APIContoller {
return response; return response;
} }
Map<String, Object> relayResult =estimateService.checkRelayCondition(textDetails);
boolean relayCondition = (Boolean) relayResult.get("condition");
if (relayCondition) {
List<String> roadNames = (List<String>) relayResult.get("roadNames");
String roads = String.join(", ", roadNames);
response.put("status", false);
response.put("message",
"The following road(s) have been relayed within six months, so cannot be saved: "
+ roads+".So remove them And Click Save");
return response;
}
} }
estimateService.saveAllWorkDetails(createdBy, estid,estimateNo,subCatId , details, textDetails); estimateService.saveAllWorkDetails(createdBy, estid,estimateNo,subCatId , details, textDetails);
@ -1066,9 +1084,7 @@ public class APIContoller {
List<Map<String, Object>> textDetails = (List<Map<String, Object>>) request.get("textDetails"); List<Map<String, Object>> textDetails = (List<Map<String, Object>>) request.get("textDetails");
/*
* Duplicate ROAD validation
*/
/* Duplicate ROAD validation */
if (subcategoryId == 4) { if (subcategoryId == 4) {
String duplicateRoad = estimateService.checkDuplicateRoadForUpdate(estid, refId, textDetails); String duplicateRoad = estimateService.checkDuplicateRoadForUpdate(estid, refId, textDetails);
@ -1082,6 +1098,24 @@ public class APIContoller {
return response; return response;
} }
Map<String, Object> relayResult =estimateService.checkRelayCondition(textDetails);
boolean relayCondition = (Boolean) relayResult.get("condition");
if (relayCondition) {
Map<String, Object> response = new HashMap<>();
List<String> roadNames = (List<String>) relayResult.get("roadNames");
String roads = String.join(", ", roadNames);
response.put("status", false);
response.put("message","This road have been relayed within six months, so cannot be updated: "+ roads);
return response;
}
} }
return estimateService.updateSavedWorkDetails(createdBy, estid, refId, estimateNo, subcategoryId, details,textDetails); return estimateService.updateSavedWorkDetails(createdBy, estid, refId, estimateNo, subcategoryId, details,textDetails);

77
src/main/java/in/gov/chennaicorporation/gccoffice/works/service/EstimateService.java

@ -53,6 +53,9 @@ public class EstimateService {
@Autowired @Autowired
private JdbcTemplate oraclejdbcTemplate; private JdbcTemplate oraclejdbcTemplate;
@Autowired
private JdbcTemplate roadwarWebTemplate;
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static final int STRING_LENGTH = 15; private static final int STRING_LENGTH = 15;
@ -61,10 +64,12 @@ public class EstimateService {
@Autowired @Autowired
public void setDataSource( public void setDataSource(
@Qualifier("mysqlWorksDataSource") DataSource dataSource, @Qualifier("mysqlWorksDataSource") DataSource dataSource,
@Qualifier("oracleDataSource") DataSource oracleDataSource) {
@Qualifier("oracleDataSource") DataSource oracleDataSource,
@Qualifier("mysqlRoadWarDataSource") DataSource roadWarDataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
this.oraclejdbcTemplate = new JdbcTemplate(oracleDataSource); this.oraclejdbcTemplate = new JdbcTemplate(oracleDataSource);
this.roadwarWebTemplate= new JdbcTemplate(roadWarDataSource);
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); this.fileBaseUrl=environment.getProperty("fileBaseUrl");
} }
@ -3489,4 +3494,74 @@ private Map<String, Object> getExistingNonErpEstimate(String estimateNo) {
return count != null && count > 0; return count != null && count > 0;
} }
public Map<String, Object> checkRelayCondition(List<Map<String, Object>> textDetails) {
Map<String, Object> result = new HashMap<>();
List<String> roadNames = new ArrayList<>();
if (textDetails == null || textDetails.isEmpty()) {
result.put("condition", false);
result.put("roadNames", roadNames);
return result;
}
for (Map<String, Object> item : textDetails) {
String answer = item.get("answer") != null ? String.valueOf(item.get("answer")) : "";
if (answer.trim().isEmpty()) {
continue;
}
String[] parts = answer.split(",", -1);
String roadId = parts[0].trim();
String roadName = parts.length > 1 ? parts[1].trim() : roadId;
String sql =
" SELECT " +
" SUM(CASE " +
" WHEN STR_TO_DATE(" +
" CONCAT(ym.year_name, '-', " +
" LPAD(rd.relay_month, 2, '0'), '-28'), " +
" '%Y-%m-%d') >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) " +
" THEN 1 " +
" ELSE 0 " +
" END) AS within_six_months " +
" FROM road_details_master r " +
" LEFT JOIN relaying_details rd " +
" ON r.ref_id = rd.road_ref_id " +
" AND rd.is_active = 1 " +
" AND rd.is_delete = 0 " +
" LEFT JOIN month_master mm " +
" ON mm.id = rd.relay_month " +
" AND mm.is_active = 1 " +
" AND mm.is_delete = 0 " +
" LEFT JOIN year_master ym " +
" ON ym.id = rd.relay_year " +
" AND ym.is_active = 1 " +
" AND ym.is_delete = 0 " +
" WHERE r.is_active = 1 " +
" AND r.is_delete = 0 " +
" AND r.road_id = ?";
Integer count = roadwarWebTemplate.queryForObject(
sql,
Integer.class,
roadId
);
if (count != null && count > 0) {
roadNames.add(roadId + " - " + roadName);
}
}
result.put("condition", !roadNames.isEmpty());
result.put("roadNames", roadNames);
return result;
}
} }

32
src/main/resources/templates/modules/roadwar/dashboard.html

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/modules/base/head :: head}"></head>
<body>
<div class="wrapper">
<!-- Header -->
<header th:replace="~{fragments/modules/base/header :: header}"></header>
<div class="page-wrap">
<!-- Sidebar Menu -->
<div th:replace="~{fragments/modules/base/menu :: menu}"></div>
<!-- Main Content Area with Iframe -->
<div class="main-content">
<div class="container-fluid">
<iframe th:src="${externalUrl}"
style="width: 100%; height: calc(100vh - 65px); border: none; display: block;" allowfullscreen>
</iframe>
</div>
</div>
<!-- Footer -->
<footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
</div>
</div>
<script th:replace="~{fragments/modules/base/script :: script}"></script>
</body>
</html>
Loading…
Cancel
Save