add filter fields sku, status in master bundles sidebar #39
|
@ -130,6 +130,8 @@ public class CuttingController {
|
|||
@GetMapping( "/master-bundles")
|
||||
public String showMasterBundles( @RequestParam(value = "id" , required = false) String id,
|
||||
@RequestParam(value = "jc-id", required = false ) String jobCardId,
|
||||
@RequestParam(value = "sku", required = false ) String sku,
|
||||
@RequestParam(value = "status", required = false ) String status,
|
||||
@RequestParam(value = "start-date", required = false) String startDate,
|
||||
@RequestParam(value = "end-date", required = false) String endDate,
|
||||
@RequestParam(value = "count", required = false) Long count,
|
||||
|
@ -138,7 +140,7 @@ public class CuttingController {
|
|||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
||||
model.addAttribute("startDate", startDate1);
|
||||
model.addAttribute("endDate", endDate1);
|
||||
model.addAttribute("masterBundles", bundleService.getMasterBundles( id, jobCardId, startDate1.toString(), endDate1.toString(), count ) );
|
||||
model.addAttribute("masterBundles", bundleService.getMasterBundles( id, sku, status, jobCardId, startDate1.toString(), endDate1.toString(), count ) );
|
||||
return "/cutting/master-bundles";
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.time.LocalDate;
|
|||
public class MasterBundleQueryBuilder {
|
||||
|
||||
|
||||
public static String buildQuery( String id, String jobCardId, String startDate, String endDate, Long count ){
|
||||
public static String buildQuery( String id, String sku, String status, String jobCardId, String startDate, String endDate, Long count ){
|
||||
// format date
|
||||
String formattedDate;
|
||||
String formattedEndDate;
|
||||
|
@ -26,8 +26,7 @@ public class MasterBundleQueryBuilder {
|
|||
endDate1 = String.format("'%s 23:59:59'", LocalDate.now() );
|
||||
}
|
||||
}
|
||||
|
||||
return ( new QueryBuilder() )
|
||||
QueryBuilder queryBuilder = new QueryBuilder()
|
||||
.setTable( "cut_to_pack.master_bundle" )
|
||||
.setColumns( "*" )
|
||||
.where()
|
||||
|
@ -35,10 +34,24 @@ public class MasterBundleQueryBuilder {
|
|||
.and()
|
||||
.columnEquals( "job_card_id", jobCardId )
|
||||
.and()
|
||||
.columnEquals( "sku", sku )
|
||||
.and()
|
||||
.columnEqualToOrGreaterThan("created_at" , startDate1 )
|
||||
.and()
|
||||
.columnEqualToOrLessThan( "created_at", endDate1 )
|
||||
.limit( count.intValue() )
|
||||
.build();
|
||||
.columnEqualToOrLessThan( "created_at", endDate1 );
|
||||
|
||||
|
||||
if (! StringUtils.isNullOrEmpty( status ) ) {
|
||||
if (status.equalsIgnoreCase("1")) {
|
||||
queryBuilder.and()
|
||||
.columnGreaterThan("is_received", "0");
|
||||
} else {
|
||||
queryBuilder.and()
|
||||
.columnEquals("is_received", "0");
|
||||
}
|
||||
}
|
||||
queryBuilder.limit( count.intValue() );
|
||||
|
||||
return queryBuilder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,13 +88,13 @@ public class BundleService {
|
|||
/*
|
||||
* find master bundles by params
|
||||
* */
|
||||
public List<MasterBundle> getMasterBundles( String id, String jobCardId, String startDate, String endDate, Long count ){
|
||||
List<MasterBundle> bundles = new ArrayList<>();
|
||||
public List<MasterBundle> getMasterBundles( String id, String sku, String status, String jobCardId, String startDate, String endDate, Long count ){
|
||||
List<MasterBundle> bundles;
|
||||
if( count == null ){
|
||||
count = 100L;
|
||||
}
|
||||
if( StringUtils.isAnyNotNullOrEmpty(id, jobCardId, startDate, endDate ) ){
|
||||
String query = MasterBundleQueryBuilder.buildQuery( id, jobCardId, startDate, endDate , count );
|
||||
if( StringUtils.isAnyNotNullOrEmpty(id, jobCardId, startDate, endDate, sku, status) ){
|
||||
String query = MasterBundleQueryBuilder.buildQuery( id, sku, status, jobCardId, startDate, endDate , count );
|
||||
System.out.println( query );
|
||||
bundles = masterBundleDAO.findByQuery( query );
|
||||
} else {
|
||||
|
|
|
@ -11,20 +11,23 @@
|
|||
<label>ID</label>
|
||||
<input type="text" class="form-control" name="id" maxlength="100" th:value="${param['id']}">
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label>Item ID</label>-->
|
||||
<!-- <input type="text" class="form-control" name="item-id" maxlength="100"-->
|
||||
<!-- th:value="${param['item-id']}">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label>Sku</label>-->
|
||||
<!-- <input type="text" class="form-control" name="sku" maxlength="100" th:value="${param['sku']}">-->
|
||||
<!-- </div>-->
|
||||
<div class="form-group">
|
||||
<label>Sku</label>
|
||||
<input type="text" class="form-control" name="sku" maxlength="100" th:value="${param['sku']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Job Card ID</label>
|
||||
<input type="text" class="form-control" name="jc-id" maxlength="100"
|
||||
th:value="${param['jc-id']}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Status</label>
|
||||
<select name="status" class="form-control">
|
||||
<option value="">All</option>
|
||||
<option value="1" th:selected="${#strings.equals(param['status'], #strings.toString(1))}">Received</option>
|
||||
<option value="0" th:selected="${#strings.equals(param['status'], #strings.toString(0))}">Not Received</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<label>Start Date</label>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<th>Sku</th>
|
||||
<th>Created By</th>
|
||||
<th>Created At</th>
|
||||
<th>Received</th>
|
||||
<th>Status</th>
|
||||
<th>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-sm btn-outline-primary" type="submit">Generate Master
|
||||
|
@ -52,7 +52,12 @@
|
|||
<td th:text="*{sku}"></td>
|
||||
<td th:text="*{createdBy}"></td>
|
||||
<td ctp:formatdatetime="*{createdAt}"></td>
|
||||
<td th:text="${bundle.isReceived ? 'YES' : 'NO'}"></td>
|
||||
<td>
|
||||
<span th:if="${!bundle.isReceived}" class="badge badge-UN_TAGGED">NOT RECEIVED</span>
|
||||
<div th:if="${bundle.isReceived}">
|
||||
<span class="badge badge-TAGGED"> RECEIVED</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="form-group form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
|
|
Loading…
Reference in New Issue