add table validation
parent
40a18eb266
commit
60956b36ba
|
@ -144,7 +144,6 @@ public class JobCardController {
|
|||
@PathVariable long id,
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model ){
|
||||
|
||||
try {
|
||||
jobCard.setStatus(JobCard.Status.POSTED.name() );
|
||||
jobCardService.save( jobCard );
|
||||
|
@ -160,13 +159,18 @@ public class JobCardController {
|
|||
Model model ){
|
||||
List<JobCardItem> jobCardItems = jobCardService.findJobCardItemByJobCardId(id);
|
||||
List<Long> jobCardItemIds = jobCardItems.stream()
|
||||
.map(JobCardItem::getItemId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> itemIds = jobCardItems.stream()
|
||||
.map(JobCardItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
model.addAttribute( "card", jobCardService.findByID(id));
|
||||
model.addAttribute("jobCardItems", jobCardItems);
|
||||
model.addAttribute("cutPiece",jobCardService.findCutPieceByJobCardItemIds(jobCardItemIds));
|
||||
model.addAttribute("cutPiece",jobCardService.findCutPieceByJobCardItemIds(itemIds));
|
||||
model.addAttribute("finishItem",jobCardService.findFinishItemByJobCardId(id));
|
||||
model.addAttribute("stitchingItem",jobCardService.findStitchItemByJobCardId(id));
|
||||
model.addAttribute("totalFinishItem",jobCardService.totalFinishItem(jobCardItemIds, id));
|
||||
model.addAttribute("totalStitchingItem",jobCardService.totalStitchingItem(jobCardItemIds, id));
|
||||
return "job-card-view";
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.jdbc.support.KeyHolder;
|
|||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
|
@ -25,6 +26,7 @@ public class FinishedItemDAO {
|
|||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, stitched_item_id, is_segregated, qa_status) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status) 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), stitched_item_id = VALUES(stitched_item_id), is_segregated = VALUES(is_segregated), qa_status = VALUES(qa_status)", TABLE_NAME );
|
||||
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", 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 SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated ORDER BY ID DESC", TABLE_NAME );
|
||||
private final String SELECT_BY_STITCHED_ITEM_ID = String.format( "SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id", TABLE_NAME );
|
||||
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format( "SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME );
|
||||
|
@ -135,6 +137,20 @@ public class FinishedItemDAO {
|
|||
|
||||
}
|
||||
|
||||
public HashMap<Long, Long> findTotalCount(List<Long> itemIds, long jobCardId) {
|
||||
HashMap<Long, Long> totalCounts = new HashMap<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
for (long id : itemIds) {
|
||||
params.addValue("job_card_id", jobCardId);
|
||||
params.addValue("item_id", id);
|
||||
Long total = namedParameterJdbcTemplate.queryForObject(FIND_TOTAL_COUNT, params, Long.class);
|
||||
if (total != null) {
|
||||
totalCounts.put(id, total);
|
||||
}
|
||||
}
|
||||
return totalCounts;
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByStitchedItemIds( List<Long> stitchedItemIds ){
|
||||
if( stitchedItemIds == null || stitchedItemIds.isEmpty() ) return new ArrayList<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.jdbc.support.KeyHolder;
|
|||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
|
@ -23,6 +24,7 @@ public class StitchingOfflineItemDAO {
|
|||
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) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status) 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)", 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 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 ORDER BY ID DESC", TABLE_NAME );
|
||||
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
||||
|
@ -122,4 +124,20 @@ public class StitchingOfflineItemDAO {
|
|||
params.addValue("job_card_id", masterId );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_MASTER_ID , params, new StitchingOfflineItemRowMapper() );
|
||||
}
|
||||
|
||||
public HashMap<Long, Long> findTotalCount(List<Long> itemIds, long jobCardId) {
|
||||
HashMap<Long, Long> totalCounts = new HashMap<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
for (long id : itemIds) {
|
||||
params.addValue("job_card_id", jobCardId);
|
||||
params.addValue("item_id", id);
|
||||
Long total = namedParameterJdbcTemplate.queryForObject(FIND_TOTAL_COUNT, params, Long.class);
|
||||
|
||||
if (total != null) {
|
||||
totalCounts.put(id, total);
|
||||
}
|
||||
}
|
||||
return totalCounts;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
@ -277,7 +278,16 @@ public class JobCardService {
|
|||
public List<FinishedItem> findFinishItemByJobCardId( long jobCardId ){
|
||||
return finishedItemDAO.findByJobCardId( jobCardId );
|
||||
}
|
||||
|
||||
public List<StitchingOfflineItem> findStitchItemByJobCardId( long jobCardId ){
|
||||
return stitchingOfflineItemDAO.findByJobCardId( jobCardId );
|
||||
}
|
||||
|
||||
public HashMap<Long, Long> totalStitchingItem(List<Long> itemIds, long jobCardId ){
|
||||
return stitchingOfflineItemDAO.findTotalCount( itemIds, jobCardId );
|
||||
}
|
||||
|
||||
public HashMap<Long, Long> totalFinishItem(List<Long> itemIds, long jobCardId ){
|
||||
return finishedItemDAO.findTotalCount( itemIds, jobCardId );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:uind="http://www.w3.org/1999/xhtml">
|
||||
<head th:replace="_fragments :: head('View PO')"></head>
|
||||
<head th:replace="_fragments :: head('Job Card Detail')"></head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
||||
|
@ -69,6 +69,8 @@
|
|||
<th>Expected Production</th>
|
||||
<th>Actual Production</th>
|
||||
<th>Total Production</th>
|
||||
<th>Total Stitching Item</th>
|
||||
<th>Total Finish Item</th>
|
||||
<th class="text-center font-lg">Cut Piece Items</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -80,6 +82,8 @@
|
|||
<td th:text="${cardItem.getExpectedProduction()}"></td>
|
||||
<td th:text="${cardItem.getActualProduction()}"></td>
|
||||
<td th:text="${cardItem.getTotalProduction()}"></td>
|
||||
<td th:text="${totalStitchingItem.get(cardItem.getItemId())}"></td>
|
||||
<td th:text="${totalFinishItem.get(cardItem.getItemId())}"></td>
|
||||
<td class="m-0 p-0">
|
||||
<table class="table m-0 p-0">
|
||||
<tbody>
|
||||
|
@ -97,9 +101,9 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="align-middle"><i>Stitching Offline Items</i> <i ></i></td>
|
||||
<td class="m-0 p-0">
|
||||
<td class="m-0 p-0 text-center">
|
||||
|
||||
<table class="table">
|
||||
<table th:if="${!stitchingItem.isEmpty() }" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
|
@ -118,20 +122,23 @@
|
|||
<td th:text="${cardStitchingItem.getItemId()}">ad</td>
|
||||
<td th:text="${cardStitchingItem.getSku()}"></td>
|
||||
<td th:text="${cardStitchingItem.getBarcode()}"></td>
|
||||
<td th:text="${cardStitchingItem.getQaStatus()}"></td>
|
||||
<td>
|
||||
<span th:if="${cardStitchingItem.getQaStatus() == 'APPROVED'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-APPROVED"></span>
|
||||
<span th:if="${cardStitchingItem.getQaStatus() == 'REJECT'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-warning"></span>
|
||||
</td>
|
||||
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
||||
<td th:text="${cardStitchingItem.getCreatedAt()}"></td>
|
||||
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
||||
<td th:text="${cardStitchingItem.getCreatedBy()}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<span th:if="${stitchingItem.isEmpty() }" class="p-5 text-center font-lg font-weight-bold" > No Data Available</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="align-middle"><i>Finish Items</i></td>
|
||||
<td class="m-0 p-0">
|
||||
|
||||
<table class="table mb-0">
|
||||
<td class="m-0 p-0 text-center">
|
||||
<table th:if="${!finishItem.isEmpty() }" class="table mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
|
@ -149,12 +156,17 @@
|
|||
<td th:text="${cardfinishItem.getItemId()}">ad</td>
|
||||
<td th:text="${cardfinishItem.getSku()}"></td>
|
||||
<td th:text="${cardfinishItem.getBarcode()}"></td>
|
||||
<td th:text="${cardfinishItem.getQaStatus()}"></td>
|
||||
<td th:text="${cardfinishItem.getCreatedAt()}"></td>
|
||||
<td>
|
||||
<span th:if="${cardfinishItem.getQaStatus() == 'APPROVED'}" th:text="${cardfinishItem.getQaStatus()}" class="badge badge-APPROVED"></span>
|
||||
<span th:if="${cardfinishItem.getQaStatus() == 'WASHED'}" th:text="${cardfinishItem.getQaStatus()}" class="badge badge-danger"></span>
|
||||
<span th:if="${cardfinishItem.getQaStatus() == 'ALTER'}" th:text="${cardfinishItem.getQaStatus()}" class="badge badge-warning"></span>
|
||||
</td>
|
||||
<td ctp:formatdatetime="${cardfinishItem.getCreatedAt()}"></td>
|
||||
<td th:text="${cardfinishItem.getCreatedBy()}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<span th:if="${finishItem.isEmpty() }" class="p-5 text-center font-lg font-weight-bold" > No Data Available</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div class="col-sm-3 form-group">
|
||||
<label>Finishing Account</label>
|
||||
<select class="form-control" name="account-id" th:field="*{finishedAccountId}" required>
|
||||
<option value="">PLease select</option>
|
||||
<option value="">Please select</option>
|
||||
<option th:each="account : ${accounts}"
|
||||
th:value="${account.id}"
|
||||
th:text="${account.title}"></option>
|
||||
|
|
Loading…
Reference in New Issue