fix finishing and Qc phase sidebar issue and add stitching new sidebar file #41

Merged
usama.jameel merged 1 commits from fix/finishing-sidebar into main 2025-07-28 06:43:40 +00:00
11 changed files with 109 additions and 48 deletions

View File

@ -48,6 +48,7 @@ public class FinishingController {
@RequestParam(value = "start-date", required = false) String startDate,
@RequestParam(value = "end-date", required = false) String endDate,
@RequestParam(value = "job-card-id", required = false) String jobCardId,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "count", required = false) Long count,
Model model) {
@ -55,7 +56,7 @@ public class FinishingController {
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
model.addAttribute("startDate", startDate1);
model.addAttribute("endDate", endDate1);
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, count);
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, status, count);
model.addAttribute("items", itemList);
return "finishing/finished-item-list";

View File

@ -64,13 +64,14 @@ public class QualityControlController {
@RequestParam(value = "start-date", required = false) String startDate,
@RequestParam(value = "end-date", required = false) String endDate,
@RequestParam(value = "job-card-id", required = false) String jobCardId,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "count", required = false, defaultValue = "100") Long count,
Model model) {
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(30) : LocalDate.parse(startDate);
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
model.addAttribute("startDate", startDate1);
model.addAttribute("endDate", endDate1);
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, count);
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, status, count);
model.addAttribute("items", itemList);
return "/quality-control/qc-items-list";
}

View File

@ -22,19 +22,19 @@ public class StitchingOfflineItemDAO {
private final String TABLE_NAME = "cut_to_pack.stitching_offline_item";
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 ORDER BY id DESC", TABLE_NAME );
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND inline_received = TRUE", 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, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status,bundle_id, qc_done_at, inline_received) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status, :bundle_id, :qc_done_at, :inline_received) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status), bundle_id = VALUES(bundle_id), qc_done_at = VALUES(qc_done_at), inline_received = VALUES(inline_received)", TABLE_NAME );
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME );
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id AND inline_received = TRUE", TABLE_NAME );
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND inline_received = TRUE ORDER BY ID DESC", TABLE_NAME );
private final String SELECT_BY_BUNDLE_ID = String.format( "SELECT * FROM %s WHERE bundle_id = :bundle_id", TABLE_NAME );
private final String COUNT_TOTAL_QA_ITEMS= String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_qa IS TRUE",TABLE_NAME);
private final String SELECT_BY_TIME_AND_CARD_ID= String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id ORDER BY created_at DESC LIMIT 1;",TABLE_NAME);
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME );
private final String SELECT_BY_DATE_QA_STATUS = String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR qc_done_at >= :start_date) AND qc_done_at <= :end_date AND qa_status = :qa_status AND id IN (:ids)", TABLE_NAME );
private final String SELECT_BY_DATE_QA_STATUS_APPROVED= String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR qc_done_at >= :start_date) AND qc_done_at <= :end_date AND qa_status = :qa_status", TABLE_NAME );
private final String COUNT_TOTAL_QA_ITEMS= String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND inline_received = TRUE AND is_qa IS TRUE",TABLE_NAME);
private final String SELECT_BY_TIME_AND_CARD_ID= String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id AND inline_received = TRUE ORDER BY created_at DESC LIMIT 1;",TABLE_NAME);
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND inline_received = TRUE AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME );
private final String SELECT_BY_DATE_QA_STATUS = String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR qc_done_at >= :start_date) AND inline_received = TRUE AND qc_done_at <= :end_date AND qa_status = :qa_status AND id IN (:ids)", TABLE_NAME );
private final String SELECT_BY_DATE_QA_STATUS_APPROVED= String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR qc_done_at >= :start_date) AND inline_received = TRUE AND qc_done_at <= :end_date AND qa_status = :qa_status", TABLE_NAME );
public StitchingOfflineItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;

View File

@ -9,7 +9,7 @@ import java.time.LocalDate;
public class FinishedItemQueryBuilder {
public static String buildQuery(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, Long count) {
public static String buildQuery(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, String status, Long count) {
// format date
String formattedDate;
String formattedEndDate;
@ -38,6 +38,8 @@ public class FinishedItemQueryBuilder {
.and()
.columnEquals("job_card_id", jobCardId )
.and()
.columnEquals("qa_status", status )
.and()
.columnEqualToOrGreaterThan("created_at", startDate1)
.and()
.columnEqualToOrLessThan("created_at", endDate1 )

View File

@ -110,13 +110,13 @@ public class BundleService {
/*
* find finished Items by params
* */
public List<FinishedItem> getFinishedItem(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, Long count ){
public List<FinishedItem> getFinishedItem(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, String status ,Long count ){
List<FinishedItem> finishedItems = new ArrayList<>();
if( count == null ){
count = 100L;
}
if( StringUtils.isAnyNotNullOrEmpty(id, itemId, sku, createdStartDate, createdEndDate, jobCardId ) ){
String query = FinishedItemQueryBuilder.buildQuery( id, itemId, sku, createdStartDate, createdEndDate, jobCardId , count );
if( StringUtils.isAnyNotNullOrEmpty(id, itemId, sku, createdStartDate, createdEndDate, jobCardId, status ) ){
String query = FinishedItemQueryBuilder.buildQuery( id, itemId, sku, createdStartDate, createdEndDate, jobCardId, status, count );
System.out.println( query );
finishedItems = finishedItemDAO.findByQuery( query );
} else {

View File

@ -338,35 +338,25 @@ public class InventoryService {
* */
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
public void createStitchingOfflineItemsFromBundle(List<Bundle> bundles) {
List<JobCardItem> updatedItems = new ArrayList<>();
JobCard jobCard = null;
for (Bundle subBundle : bundles) {
for (Bundle subBundle : bundles) {
if (subBundle.getCurrentProduction() != null && subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0) {
Bundle bundle = bundleDAO.find(subBundle.getId());
jobCard = jobCardDAO.find(subBundle.getJobCardId());
long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue();
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(), subBundle.getItemId());
BigDecimal previousTotalProduction = jobCardItem.getTotalProduction() == null ? BigDecimal.ZERO : jobCardItem.getTotalProduction();
// create stitchingOfflineItems items
createStitchingOfflineItems(subBundle.getCurrentProduction(), jobCardItem, subBundle.getId());
//update job card item and then add in list
jobCardItem.setTotalProduction(previousTotalProduction.add(subBundle.getCurrentProduction()));
jobCardItem.setJobCardId(jobCard.getId());
updatedItems.add(jobCardItem);
// update bundle production
BigDecimal pro = BigDecimal.valueOf(production + subBundle.getCurrentProduction().longValue());
BigDecimal pro = BigDecimal.valueOf(subBundle.getCurrentProduction().longValue());
bundle.setProduction(pro);
bundleDAO.save(bundle);
}
}
jobCardItemDAO.saveAll(updatedItems);
}
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
public void createStitchingOfflineItemsTransactionWhenReceivedMasterBundle(BundleWrapper wrapper) {
List<JobCardItem> updatedItems = new ArrayList<>();
//switching table transaction in Transaction Table
InventoryTransaction transaction = createInventoryTransaction("Against Movement from Stitching to Stitched Offline Item");
inventoryTransactionDAO.save(transaction);
@ -381,14 +371,22 @@ public class InventoryService {
// create IN Transactions of Finished Items into account
createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name());
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
List<StitchingOfflineItem> updatedItems = stitchingOfflineItems.stream().map(e-> {
List<StitchingOfflineItem> updatedStitchItems = stitchingOfflineItems.stream().map(e-> {
e.setInlineReceived(true);
e.setCreatedBy(authentication.getName());
return e;
}).collect(Collectors.toList());
stitchingOfflineItemDAO.saveAll(updatedItems);
stitchingOfflineItemDAO.saveAll(updatedStitchItems);
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(), subBundle.getItemId());
BigDecimal previousTotalProduction = jobCardItem.getTotalProduction() == null ? BigDecimal.ZERO : jobCardItem.getTotalProduction();
//update job card item and then add in list
jobCardItem.setTotalProduction(previousTotalProduction.add(subBundle.getWrapQuantity()));
updatedItems.add(jobCardItem);
}
jobCardItemDAO.saveAll(updatedItems);
}
@ -544,6 +542,7 @@ public class InventoryService {
createInventoryTransactionLeg(transaction, preCreatedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
}
stitchingOfflineItem.setIsQa(true);
stitchingOfflineItem.setInlineReceived(true);
preCreatedItem.setIsQa(true);
finishedItemsForUlter.add(preCreatedItem);
// create IN in finishing Account Finished Item
@ -556,6 +555,7 @@ public class InventoryService {
finishedItemsForUlter.add(preCreatedItem);
}
stitchingOfflineItem.setIsQa(false);
stitchingOfflineItem.setInlineReceived(true);
}
stitchingOfflineItem.setQaStatus(qaStatus);
stitchingOfflineItem.setQcDoneAt(LocalDateTime.now());

View File

@ -33,10 +33,13 @@
</div>
<div class="form-group">
<label>Status</label>
<select class="form-control" name="status">
<option value="" th:selected="${param.status == null}">Please Select</option>
<option value="APPROVED" th:selected="${param.status == 'true'}">Approved</option>
<option value="REJECT" th:selected="${param.status == 'false'}">Reject</option>
<select name="status" class="form-control">
<option value="">All</option>
<option value="APPROVED" th:selected="${#strings.equals(param['status'], 'APPROVED')}">APPROVED</option>
<option value="REJECT" th:selected="${#strings.equals(param['status'], 'REJECT')}">REJECT</option>
<option value="WASHED" th:selected="${#strings.equals(param['status'], 'WASHED')}">WASHED</option>
<option value="ALTER" th:selected="${#strings.equals(param['status'], 'ALTER')}">ALTER</option>
<option value="B GRADE" th:selected="${#strings.equals(param['status'], 'B GRADE')}">B GRADE</option>
</select>
</div>

View File

@ -7,7 +7,7 @@
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<!-- sidebar starts -->
<aside class="col-sm-2" th:replace="/stitching/_finished-item-sidebar :: sidebar"></aside>
<aside class="col-sm-2" th:replace="/finishing/_finished-item-sidebar :: sidebar"></aside>
<!-- sidebar ends -->
<!--header starts-->
<div class="col-sm">
@ -26,7 +26,6 @@
<th>Item ID</th>
<th>Sku</th>
<th>Job Card ID</th>
<th>Is QA</th>
<th>Created At</th>
<th>Created By</th>
<th>Segregated</th>
@ -38,23 +37,19 @@
<td th:text="${item.itemId}"></td>
<td th:text="${item.sku}"></td>
<td th:text="${item.jobCardId}"></td>
<td>
<span th:if="${not item.isQa}" class="badge badge-danger">NOT PERFORMED</span>
<div th:if="${item.isQa}">
<span class="badge badge-APPROVED">PERFORMED</span>
</div>
<div th:if="${item.qaStatus != null }">
<span th:text="${item.qaStatus}"></span>
</div>
</td>
<td th:text="${item.createdBy}"></td>
<td ctp:formatdatetime="${item.createdAt}"></td>
<td>
<span th:if="${not item.isSegregated && item.qaStatus != ('ALTER')}" class="badge badge-danger">PENDING</span>
<span th:if="${not item.isSegregated && item.qaStatus == ('ALTER')}" class="badge badge-warning">REVERTED</span>
<div th:if="${not item.isSegregated && item.qaStatus != ('ALTER')}" >
<span class="badge badge-danger">PENDING</span>
</div>
<div th:if="${not item.isSegregated && item.qaStatus == ('ALTER')}">
<span class="badge badge-warning">REVERTED</span>
</div>
<div th:if="${item.isSegregated && item.qaStatus != ('ALTER')}">
<span class="badge badge-APPROVED">DONE</span>
</div>
<span th:text="${item.qaStatus}"></span>
</td>
</tr>
</tbody>

View File

@ -7,7 +7,7 @@
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<!-- sidebar starts -->
<aside class="col-sm-2" th:replace="/stitching/_finished-item-sidebar :: sidebar"></aside>
<aside class="col-sm-2" th:replace="/finishing/_finished-item-sidebar :: sidebar"></aside>
<!-- sidebar ends -->
<!--header starts-->
<div class="col-sm">

View File

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Home Page')"></head>
<body>
<!-- sidebar starts -->
<aside class="col-sm-2" th:fragment="sidebar">
<div class="page-filters-sidebar">
<form th:action="@{${#strings.replace(#httpServletRequest.requestURI, #request.getContextPath(), '')}}">
<h5 class="mb-4">Refine Your Search</h5>
<div class="form-group">
<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>Bundle ID</label>
<input type="number" class="form-control" min="0" name="bundle-id" th:value="${param['bundle-id']}">
</div>
<div class="form-group">
<label>Start Date</label>
<input type="date" class="form-control" name="start-date" th:value="${param['start-date'] ?: startDate}">
</div>
<div class="form-group">
<label>End Date</label>
<input type="date" class="form-control" name="end-date" th:value="${param['end-date'] ?: endDate}">
</div>
<div class="form-group">
<label>Status</label>
<select class="form-control" name="status">
<option value="" th:selected="${param.status == null}">Please Select</option>
<option value="APPROVED" th:selected="${param.status == 'true'}">Approved</option>
<option value="REJECT" th:selected="${param.status == 'false'}">Reject</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>
</form>
</div>
</aside>
<!-- sidebar ends -->
<div th:fragment="page-footer-scripts">
<script th:src="@{/js/vendor/lazyload-db.js}"></script>
<script th:src="@{/js/main.js}"></script>
</div>
</body>
</html>

View File

@ -7,7 +7,7 @@
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<!-- sidebar starts -->
<aside class="col-sm-2" th:replace="/stitching/_finished-item-sidebar :: sidebar"></aside>
<aside class="col-sm-2" th:replace="/stitching/_stitching-sidebar :: sidebar"></aside>
<!-- sidebar ends -->
<!--header starts-->
<div class="col-sm">
@ -62,7 +62,7 @@
</tbody>
</table>
</form>
<h4 th:if="${#lists.size(items) == 0}">No Finished Items found.</h4>
<h4 th:if="${#lists.size(items) == 0}">No Stitching Items found.</h4>
</div>
</main>
</div>