Merge pull request 'add pagination in cutting report and count in reporting sidebars' (#37) from add-pagination-cutting-report into main

Reviewed-on: #37
main
usama.jameel 2025-06-30 05:01:17 +00:00
commit ffc1a8ac41
12 changed files with 99 additions and 38 deletions

View File

@ -35,13 +35,12 @@ public class POStatusController {
public String poReport(@RequestParam(value = "poName", required = false) String poName,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "color", required = false) String color,
@RequestParam(value = "count", required = false, defaultValue = "100") Long count,
Model model){
model.addAttribute("allSize",jobCardItemService.getAllSizesOFItems());
model.addAttribute("allColor",jobCardItemService.getAllColorOFItems());
model.addAttribute("allPOs", reportingService.getAllPOs(poName, size, color));
model.addAttribute("dw", reportingService.getPoItemsSizeOrColor(4, size, color));
model.addAttribute("allPOs", reportingService.getAllPOs(poName, size, color, count));
return "/reporting/po-report";
}

View File

@ -78,27 +78,27 @@ public class ReportingController {
}
@GetMapping( value = "/cutting-report" )
public String cuttingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
public String cuttingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, @RequestParam(value = "count", required = false) Long count, Model model ){
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
model.addAttribute("startDate", startDate1);
model.addAttribute("endDate", endDate1);
model.addAttribute("accounts", inventoryAccountService.getAllCuttingAccounts() );
model.addAttribute("cutting",reportingService.getCuttingTableDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString()));
model.addAttribute("cutting",reportingService.getCuttingTableDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString(), count));
return "/reporting/cutting-report";
}
@GetMapping( value = "/stitching-report" )
public String stitchingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
public String stitchingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, @RequestParam(value = "count", required = false) Long count, Model model ){
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
model.addAttribute("startDate", startDate1);
model.addAttribute("endDate", endDate1);
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
model.addAttribute("stitching",reportingService.getStitchingDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString()));
model.addAttribute("stitching",reportingService.getStitchingDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString(), count));
return "/reporting/stitching-report";
}
@ -109,13 +109,14 @@ public class ReportingController {
@RequestParam( value = "sku", required = false) String sku,
@RequestParam( value = "startDate", required = false) String startDate,
@RequestParam( value = "endDate", required = false) String endDate,
@RequestParam(value = "count", required = false) Long count,
Model model ){
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
model.addAttribute("startDate", startDate1);
model.addAttribute("endDate", endDate1);
model.addAttribute("transactions", reportingService.stitchingItemsTransactions( jobCardId, accountId, sku, startDate1.toString(), endDate1.toString() ));
model.addAttribute("transactions", reportingService.stitchingItemsTransactions( jobCardId, accountId, sku, startDate1.toString(), endDate1.toString(), count ));
return "/reporting/accounts-transaction-table";
}

View File

@ -205,10 +205,6 @@ public class InventoryTransactionLegDAO {
params.addValue("start_date", startDate );
params.addValue("end_date", endDate );
params.addValue("type", type );
System.out.println("Start Date: " + startDate);
System.out.println("End Date: " + endDate);
System.out.println("Params: " + params.getValues());
return namedParameterJdbcTemplate.query( SELECT_JOB_CARD_DATES , params, new InventoryTransactionLegRowMapper() );
}

View File

@ -23,8 +23,8 @@ public class PurchaseOrderCTPDao {
private final String TABLE_NAME = "cut_to_pack.purchase_order";
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ", TABLE_NAME );
private final String SELECT_BY_PO_CODE = String.format( "SELECT * FROM %s WHERE purchase_order_code = :purchase_order_code", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY created_at DESC LIMIT :limit ", TABLE_NAME );
private final String SELECT_BY_PO_CODE = String.format("SELECT * FROM %s WHERE purchase_order_code = :purchase_order_code ORDER BY created_at DESC LIMIT :limit", TABLE_NAME);
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
private final String INSERT_QUERY = String.format(
"INSERT INTO %s (id, purchase_order_code, purchase_order_quantity, purchase_order_quantity_required, article_name, created_by, status, po_status) " +
@ -70,8 +70,10 @@ public class PurchaseOrderCTPDao {
// find all
public List<PurchaseOrderCTP> findAll() {
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new PurchaseOrderCTPRowMapper() );
public List<PurchaseOrderCTP> findAll(Long limit) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("limit", limit);
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, params, new PurchaseOrderCTPRowMapper() );
}
// save
@ -119,9 +121,10 @@ public class PurchaseOrderCTPDao {
/*
* find by po code
* */
public List<PurchaseOrderCTP> findByPoCode(String poCode){
public List<PurchaseOrderCTP> findByPoCode(String poCode, Long limit ){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("purchase_order_code", poCode);
params.addValue("limit", limit);
return namedParameterJdbcTemplate.query( SELECT_BY_PO_CODE, params, new PurchaseOrderCTPRowMapper() );
}

View File

@ -75,7 +75,7 @@ public class SummaryInventoryReportQueryBuilder {
String startDate,
String endDate,
String type,
String parentDocumentType) {
String parentDocumentType, Long count) {
QueryBuilder qb = new QueryBuilder()
.setTable(TABLE_NAME)
@ -98,6 +98,7 @@ public class SummaryInventoryReportQueryBuilder {
qb.and()
.columnEquals("sku", sku );
}
qb.orderBy("transaction_leg_datetime", "DESC").limit(count);
return qb.build();
}
}

View File

@ -440,15 +440,15 @@ public class ReportingService {
/*
* find all po for po-online-status
* */
public List<POsDetails> getAllPOs(String poCode, String size, String color) {
public List<POsDetails> getAllPOs(String poCode, String size, String color, Long count) {
List<POsDetails> pOsDetailsList = new ArrayList<>();
List<PurchaseOrderCTP> purchaseOrderCTPList;
if (poCode != null && !poCode.isEmpty()) {
purchaseOrderCTPList = purchaseOrderCTPDao.findByPoCode(poCode);
purchaseOrderCTPList = purchaseOrderCTPDao.findByPoCode(poCode, count);
}else {
purchaseOrderCTPList = purchaseOrderCTPDao.findAll();
purchaseOrderCTPList = purchaseOrderCTPDao.findAll(count);
}
@ -482,7 +482,7 @@ public class ReportingService {
actualProduction = actualProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
if(!jobCardItems.isEmpty() || (size == null || color == null)) {
if(!jobCardItems.isEmpty() || (StringUtils.isNullOrEmpty(size) || StringUtils.isNullOrEmpty(color))) {
for (JobCardItem jobCardItem : jobCardItems) {
//stitching detail
@ -634,7 +634,7 @@ public class ReportingService {
return poItemsWrapperHashMap;
}
public Map<String, Object> getCuttingTableDetails(String jobCardId, String cuttingTableId, String startDate, String endDate) {
public Map<String, Object> getCuttingTableDetails(String jobCardId, String cuttingTableId, String startDate, String endDate, Long count) {
Map<String, Object> cuttingDetails = new HashMap<>();
long jobCardIdTemp = 0L;
String startDate1 = null;
@ -659,7 +659,7 @@ public class ReportingService {
inventoryAccountIds = List.of(Long.parseLong(cuttingTableId));
}
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds, null, startDate1, endDate1, "IN","BUNDLE");
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds, null, startDate1, endDate1, "IN","BUNDLE", count);
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
Map<String, Integer> dateWiseProduction = new TreeMap<>();
@ -732,7 +732,7 @@ public class ReportingService {
return cuttingDetails;
}
public Map<String, Object> getStitchingDetails(String jobCardId, String stitchingLine, String startDate, String endDate) {
public Map<String, Object> getStitchingDetails(String jobCardId, String stitchingLine, String startDate, String endDate, Long count) {
Map<String, Object> stitchingDetails = new HashMap<>();
long jobCardIdTemp = 0L;
String startDate1 = null;
@ -757,7 +757,7 @@ public class ReportingService {
inventoryAccountIds = List.of(Long.parseLong(stitchingLine));
}
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds,null, startDate1, endDate1, "IN","STITCHING_OFFLINE");
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds,null, startDate1, endDate1, "IN","STITCHING_OFFLINE", count);
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
Map<String, Integer> dateWiseProduction = new TreeMap<>();
@ -831,7 +831,7 @@ public class ReportingService {
return stitchingDetails;
}
public List<StitchingOfflineItem> stitchingItemsTransactions(String jobCardId, String accountId, String sku, String startDate, String endDate) {
public List<StitchingOfflineItem> stitchingItemsTransactions(String jobCardId, String accountId, String sku, String startDate, String endDate, Long count) {
List<Long> accountID = new ArrayList<>();
String startDate1 = null;
String endDate1 = null;
@ -848,7 +848,7 @@ public class ReportingService {
}
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(Long.parseLong(jobCardId), accountID, sku, startDate1, endDate1,"IN","STITCHING_OFFLINE");
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(Long.parseLong(jobCardId), accountID, sku, startDate1, endDate1,"IN","STITCHING_OFFLINE", count);
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
List<Long> stitchingItemsList = inventoryTransactionLegs.stream()
.map(InventoryTransactionLeg::getParentDocumentId)

View File

@ -32,6 +32,10 @@
</option>
</select>
</div>
<div class="form-group">
<label>Count</label>
<input type="number" class="form-control" name="count" maxlength="100" min="0" th:value="${param['count'] ?: 100}">
</div>
<input type="submit" class="btn btn-secondary btn-block" value="Search">
<a th:href="@{${#strings.replace(#httpServletRequest.requestURI, #request.getContextPath(), '')}}"
class="btn btn-secondary btn-block">Reset</a>

View File

@ -3,6 +3,17 @@
xmlns:ctp="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Cutting Report')"></head>
<style>
div.dataTables_wrapper div.dataTables_filter {
text-align: left !important;
}
div.dataTables_wrapper .dt-buttons {
text-align: left !important;
}
div.dataTables_wrapper div.dataTables_info {
text-align: left !important;
}
</style>
<body>
<div class="container-fluid">
@ -33,8 +44,8 @@
class="p-0 text-center">
<div class="bg-dark text-white py-2 px-3 fs-5 fw-bold text-center"
th:text="${cuttingAccount.title}"></div>
<table class="table table-bordered mt-2">
<thead class="">
<table class="table table-bordered mt-2 datatable">
<thead>
<tr>
<th>Job Card</th>
<th>PO Number</th>
@ -77,8 +88,37 @@
</div>
</main>
</div>
<!-- Load JavaScript file -->
<!-- Load chart logic -->
<script th:src="@{/js/charts.js}"></script>
<!-- DataTables Initialization -->
<script>
const dataTableConfig = {
pageLength: 5,
searching: true,
lengthChange: false,
processing: false,
info: true,
paging: true,
dom: `
<'row mb-2 mt-2'<'col-sm-6'f><'col-sm-6'B>>
<'row'<'col-sm-12'tr>>
<'row mt-2'<'col-sm-6'i><'col-sm-6 text-end'p>>`
,
buttons: []
};
$(document).ready(function () {
$('table.datatable').each(function () {
const $table = $(this);
if (!$.fn.DataTable.isDataTable($table)) {
$table.DataTable(dataTableConfig);
}
});
});
</script>
</body>
</html>
</html>

View File

@ -8,7 +8,7 @@
<div class="container">
<div class="row">
<div class="col-sm-8">
<table th:if="${#lists != null && #lists.size(poJobcardItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-dropdown-icon-summary >
<table th:if="${#lists != null && #lists.size(poJobcardItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-order="[[ 0, &quot;desc&quot; ]]" data-dropdown-icon-summary >
<thead>
<tr>
<th>Sku</th>

View File

@ -33,6 +33,10 @@
</option>
</select>
</div>
<div class="form-group">
<label>Count</label>
<input type="number" class="form-control" name="count" maxlength="100" min="0" th:value="${param['count'] ?: 100}">
</div>
<input type="submit" class="btn btn-secondary btn-block" value="Search">
<a th:href="@{${#strings.replace(#httpServletRequest.requestURI, #request.getContextPath(), '')}}"
class="btn btn-secondary btn-block">Reset</a>

View File

@ -11,7 +11,7 @@
<h3>All PO's</h3>
<div class="table-responsive"> <!-- Bootstrap responsive table wrapper -->
<table th:if="${ #lists != null && #lists.size(allPOs) != 0 }"
class="table table-striped font-sm" style="min-width: 1500px;">
class="table table-striped font-sm" data-order="[[ 0, &quot;desc&quot; ]]" style="min-width: 1500px;">
<thead>
<tr>
<th>PO Number</th>
@ -299,8 +299,21 @@
$.ajax({
url: `/ctp/po-status/po-items?poId=${poId}&size=${size}&color=${color}`,
success: function( data ){
// show fetched page
$row.child( data ).show();
if (data.includes('page-login') ||
data.includes('login__form') ||
data.includes('Sign in')) {
// Redirect to login page
window.location.href = '/ctp/login?logout';
} else {
$row.child(data).show();
}
},
error: function(xhr) {
if (xhr.status === 401) {
window.location.href = '/ctp/login?logout';
} else {
$row.child('<span class="text-danger">Error loading data</span>').show();
}
}
});
}

View File

@ -8,7 +8,7 @@
<div class="container">
<div class="row">
<div class="col-sm-8">
<table th:if="${#lists != null && #lists.size(storeItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-account-tables >
<table th:if="${#lists != null && #lists.size(storeItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-order="[[ 0, &quot;desc&quot; ]]" data-account-tables >
<thead>
<tr>
<th th:each="heading : ${storeItems.keySet()}" th:text="${heading}"></th>