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