fix redirect and null exceptioin on dashboard screen

add-reporting-dashboard
Usama Khan 2025-04-10 12:19:54 -07:00
parent 2cd71d3828
commit 9a541b8389
2 changed files with 11 additions and 6 deletions

View File

@ -11,6 +11,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
@ -45,7 +46,11 @@ public class ReportingController {
@GetMapping( "/job-card-report") @GetMapping( "/job-card-report")
public String jobCardReport(@RequestParam( value = "job-card-id", required = false ) String jobCardId, public String jobCardReport(@RequestParam( value = "job-card-id", required = false ) String jobCardId,
Model model ){ Model model, RedirectAttributes redirectAttributes ){
if( jobCardId == null || jobCardId.isEmpty()) {
redirectAttributes.addFlashAttribute("error", "Please Re-Select Job Card" );
return "/reporting/job-card-report";
}
model.addAttribute("totalProduction", reportingService.getTotalProduction(jobCardId)); model.addAttribute("totalProduction", reportingService.getTotalProduction(jobCardId));
model.addAttribute("phasesTimes", reportingService.getEachPhaseTotalTime(jobCardId)); model.addAttribute("phasesTimes", reportingService.getEachPhaseTotalTime(jobCardId));
model.addAttribute("segregateItems", reportingService.getSegregateItems(jobCardId)); model.addAttribute("segregateItems", reportingService.getSegregateItems(jobCardId));

View File

@ -12,7 +12,7 @@
<div class="col-sm"> <div class="col-sm">
<table class="table " > <table class="table " >
<tbody> <tbody>
<tr> <tr th:if="${jobCardProgress != null }">
<td style="padding:0px;"> <td style="padding:0px;">
<div style="border: 2px solid #d5d8dc; padding: 10px; border-radius: 10px; height: 370px;"> <div style="border: 2px solid #d5d8dc; padding: 10px; border-radius: 10px; height: 370px;">
<h1 style="text-align: center;">Job Card Report</h1> <h1 style="text-align: center;">Job Card Report</h1>
@ -54,7 +54,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr th:if="${phasesTimes != null }">
<td style="display: flex; flex-direction: column; align-items: center; border: none !important; outline: none;"> <td style="display: flex; flex-direction: column; align-items: center; border: none !important; outline: none;">
<div style="display: flex; gap: 10px;"> <div style="display: flex; gap: 10px;">
<div th:each="phase, index : ${phasesTimes.keySet()}" style="border: 2px solid #d5d8dc; border-radius: 10px; text-align: center; padding:20px;"> <div th:each="phase, index : ${phasesTimes.keySet()}" style="border: 2px solid #d5d8dc; border-radius: 10px; text-align: center; padding:20px;">
@ -65,7 +65,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr th:if="${cuttingDetails != null and cuttingDetails.get('accounts') != null}"> <tr th:if="${cuttingDetails != null && cuttingDetails.get('accounts') != null}">
<td style="padding: 0px; text-align: center;"> <td style="padding: 0px; text-align: center;">
<div style="background-color: black; color: white; padding: 10px; font-size: 18px; font-weight: bold; text-align: center;"> <div style="background-color: black; color: white; padding: 10px; font-size: 18px; font-weight: bold; text-align: center;">
Cutting Detail Cutting Detail
@ -96,7 +96,7 @@
</td> </td>
</tr> </tr>
<tr th:if="${stitchingDetails != null and stitchingDetails.get('accounts') != null}"> <tr th:if="${stitchingDetails != null && stitchingDetails.get('accounts') != null}">
<td style="padding: 0px; text-align: center; "> <td style="padding: 0px; text-align: center; ">
<div style="background-color: black; color: white; padding: 10px; font-size: 18px; font-weight: bold; text-align: center;"> <div style="background-color: black; color: white; padding: 10px; font-size: 18px; font-weight: bold; text-align: center;">
Stitching Detail Stitching Detail
@ -127,7 +127,7 @@
</table> </table>
</td> </td>
</tr> </tr>
<tr th:if="${dailyProgress.get('dates') != null}"> <tr th:if="${dailyProgress != null}">
<td style="padding-left: 150px;"> <td style="padding-left: 150px;">
<div style="border: 2px solid #d5d8dc; padding-top: 10px; border-radius: 10px; height: 560px; width: 80%; overflow-x: auto;"> <div style="border: 2px solid #d5d8dc; padding-top: 10px; border-radius: 10px; height: 560px; width: 80%; overflow-x: auto;">
<div id="barChart" class="barChart" style="height: 500px; width: 1600px;" <div id="barChart" class="barChart" style="height: 500px; width: 1600px;"