Compare commits
5 Commits
add-qa-rep
...
main
Author | SHA1 | Date |
---|---|---|
|
4d235b2975 | |
|
0353df0924 | |
|
cb01cddeff | |
|
b314d46426 | |
|
75f4d8ef09 |
|
@ -9,6 +9,6 @@ import java.lang.annotation.Target;
|
|||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@PreAuthorize( "hasAnyRole('ROLE_ADMIN')")
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMIN')")
|
||||
public @interface AdminRole {
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
|
||||
@Controller
|
||||
@FinishingRole
|
||||
@RequestMapping( "/finishing" )
|
||||
@RequestMapping("/finishing")
|
||||
public class FinishingController {
|
||||
|
||||
private final FinishedItemDAO finishedItemDAO;
|
||||
|
@ -37,26 +37,26 @@ public class FinishingController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
public String showHome(Model model ){
|
||||
public String showHome(Model model) {
|
||||
return "redirect:/finishing/finished-items";
|
||||
}
|
||||
|
||||
@GetMapping( "/finished-items" )
|
||||
public String showFinishedItems( @RequestParam(value = "id", required = false ) String id,
|
||||
@RequestParam(value = "item-id", required = false ) String itemId,
|
||||
@RequestParam( value = "sku", required = false ) String sku,
|
||||
@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 = "count", required = false ) Long count,
|
||||
Model model ){
|
||||
@GetMapping("/finished-items")
|
||||
public String showFinishedItems(@RequestParam(value = "id", required = false) String id,
|
||||
@RequestParam(value = "item-id", required = false) String itemId,
|
||||
@RequestParam(value = "sku", required = false) String sku,
|
||||
@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 = "count", required = false) 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 );
|
||||
model.addAttribute("items", itemList ) ;
|
||||
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, count);
|
||||
model.addAttribute("items", itemList);
|
||||
|
||||
return "finishing/finished-item-list";
|
||||
}
|
||||
|
@ -65,39 +65,38 @@ public class FinishingController {
|
|||
/*
|
||||
* get finishing inventory accounts
|
||||
* */
|
||||
@GetMapping( "/inventory-accounts" )
|
||||
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||
@RequestParam( value = "title", required = false) String title,
|
||||
@RequestParam( value = "active", required = false ) String active,
|
||||
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||
@RequestParam( value = "count", required = false, defaultValue = "100") Long count,
|
||||
Model model ) {
|
||||
@GetMapping("/inventory-accounts")
|
||||
public String getInventoryAccounts(@RequestParam(value = "id", required = false) String id,
|
||||
@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "active", required = false) String active,
|
||||
@RequestParam(value = "created-by", required = false) String createdBy,
|
||||
@RequestParam(value = "start-date", required = false) String startDate,
|
||||
@RequestParam(value = "end-date", required = false) String endDate,
|
||||
@RequestParam(value = "site-id", required = false) String siteId,
|
||||
@RequestParam(value = "count", required = false, defaultValue = "100") Long count,
|
||||
Model model) {
|
||||
// 5 for Finishing
|
||||
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts( id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "5" , false ));
|
||||
model.addAttribute("locations", locationService.findAll() );
|
||||
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "5", false));
|
||||
model.addAttribute("locations", locationService.findAll());
|
||||
return "/finishing/inventory-accounts";
|
||||
}
|
||||
|
||||
@GetMapping( "segregate-inventory" )
|
||||
public String segregateFinishedItems( Model model ){
|
||||
model.addAttribute("accounts", inventoryAccountService.findInventoryAccountsForFinishedItems() );
|
||||
model.addAttribute("wrapper", new FinishedItemWrapper() );
|
||||
@GetMapping("segregate-inventory")
|
||||
public String segregateFinishedItems(Model model) {
|
||||
model.addAttribute("wrapper", new FinishedItemWrapper());
|
||||
return "/finishing/segregate-inventory";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping( "segregate-inventory" )
|
||||
public String segregateFinishItemsInventory( @ModelAttribute FinishedItemWrapper wrapper,
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model ){
|
||||
@PostMapping("segregate-inventory")
|
||||
public String segregateFinishItemsInventory(@ModelAttribute FinishedItemWrapper wrapper,
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model) {
|
||||
try {
|
||||
inventoryService.segregateFinishedItems( wrapper );
|
||||
redirectAttributes.addFlashAttribute("success", "Items Successfully saved !" );
|
||||
} catch ( Exception e ){
|
||||
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
||||
inventoryService.segregateFinishedItems(wrapper, wrapper.getQaStatus());
|
||||
redirectAttributes.addFlashAttribute("success", "Items Successfully saved !");
|
||||
} catch (Exception e) {
|
||||
redirectAttributes.addFlashAttribute("error", e.getMessage());
|
||||
}
|
||||
return "redirect:/finishing/segregate-inventory";
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
|
||||
@Controller
|
||||
@QCRole
|
||||
@RequestMapping( "/quality-control" )
|
||||
@RequestMapping("/quality-control")
|
||||
public class QualityControlController {
|
||||
|
||||
private final InventoryAccountService inventoryAccountService;
|
||||
|
@ -34,63 +34,63 @@ public class QualityControlController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
public String homePage( Model model ){
|
||||
public String homePage(Model model) {
|
||||
return "redirect:/quality-control/qc-finished-items";
|
||||
}
|
||||
|
||||
/*
|
||||
* get stitching inventory accounts
|
||||
* */
|
||||
@GetMapping( "/inventory-accounts" )
|
||||
public String getInventoryAccounts( @RequestParam( value = "id", required = false ) String id,
|
||||
@RequestParam( value = "title", required = false) String title,
|
||||
@RequestParam( value = "active", required = false ) String active,
|
||||
@RequestParam( value = "created-by", required = false ) String createdBy,
|
||||
@RequestParam( value = "start-date", required = false ) String startDate,
|
||||
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||
@RequestParam( value = "site-id", required = false ) String siteId,
|
||||
@RequestParam( value = "count", required = false ) Long count,
|
||||
Model model ) {
|
||||
@GetMapping("/inventory-accounts")
|
||||
public String getInventoryAccounts(@RequestParam(value = "id", required = false) String id,
|
||||
@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "active", required = false) String active,
|
||||
@RequestParam(value = "created-by", required = false) String createdBy,
|
||||
@RequestParam(value = "start-date", required = false) String startDate,
|
||||
@RequestParam(value = "end-date", required = false) String endDate,
|
||||
@RequestParam(value = "site-id", required = false) String siteId,
|
||||
@RequestParam(value = "count", required = false) Long count,
|
||||
Model model) {
|
||||
// 24 for Packaging
|
||||
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "4", false));
|
||||
model.addAttribute("locations", locationService.findAll() );
|
||||
model.addAttribute("locations", locationService.findAll());
|
||||
return "/quality-control/inventory-accounts";
|
||||
}
|
||||
|
||||
@GetMapping( "/qc-finished-items" )
|
||||
public String getFinishedItems( @RequestParam(value = "id", required = false ) String id,
|
||||
@RequestParam(value = "item-id", required = false ) String itemId,
|
||||
@RequestParam( value = "sku", required = false ) String sku,
|
||||
@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 = "count", required = false, defaultValue = "100") Long count,
|
||||
Model model ){
|
||||
@GetMapping("/qc-finished-items")
|
||||
public String getFinishedItems(@RequestParam(value = "id", required = false) String id,
|
||||
@RequestParam(value = "item-id", required = false) String itemId,
|
||||
@RequestParam(value = "sku", required = false) String sku,
|
||||
@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 = "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 );
|
||||
model.addAttribute("items", itemList ) ;
|
||||
List<FinishedItem> itemList = bundleService.getFinishedItem(id, itemId, sku, startDate1.toString(), endDate1.toString(), jobCardId, count);
|
||||
model.addAttribute("items", itemList);
|
||||
return "/quality-control/qc-items-list";
|
||||
}
|
||||
|
||||
@GetMapping( "/qc-finished-item" )
|
||||
public String getAddFinishedItemForQCForm( Model model ){
|
||||
@GetMapping("/qc-finished-item")
|
||||
public String getAddFinishedItemForQCForm(Model model) {
|
||||
// 4 for packaging
|
||||
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(5L) );
|
||||
model.addAttribute("wrapper", new StitchedItemWrapper() );
|
||||
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(5L));
|
||||
model.addAttribute("wrapper", new StitchedItemWrapper());
|
||||
return "/quality-control/qc-items-form";
|
||||
}
|
||||
|
||||
@PostMapping( "/qc-finished-item" )
|
||||
public String postFinishedItemsAfterQc( @ModelAttribute StitchedItemWrapper wrapper,
|
||||
RedirectAttributes redirectAttributes ){
|
||||
@PostMapping("/qc-finished-item")
|
||||
public String postFinishedItemsAfterQc(@ModelAttribute StitchedItemWrapper wrapper,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
inventoryService.createFinishedItemsAgainstStitchedItems( wrapper );
|
||||
redirectAttributes.addFlashAttribute("success", " Finished Items Are Generated Against Stitched Items" );
|
||||
}catch ( Exception ex ){
|
||||
redirectAttributes.addFlashAttribute("error", ex.getMessage() );
|
||||
inventoryService.createFinishedItemsAgainstStitchedItems(wrapper, wrapper.getQaStatus());
|
||||
redirectAttributes.addFlashAttribute("success", " Finished Items Are Generated Against Stitched Items");
|
||||
} catch (Exception ex) {
|
||||
redirectAttributes.addFlashAttribute("error", ex.getMessage());
|
||||
}
|
||||
return "redirect:/quality-control/qc-finished-item";
|
||||
}
|
||||
|
|
|
@ -17,182 +17,182 @@ import java.util.List;
|
|||
@Repository
|
||||
public class FinishedItemDAO {
|
||||
|
||||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
||||
private final String TABLE_NAME = "cut_to_pack.finished_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_BARCODE_QA_STATUS = String.format( "SELECT case when EXISTS ( SELECT * FROM %s WHERE barcode = :barcode AND (qa_status = 'APPROVED' OR qa_status = 'WASHED') ) then true else false End as Result", 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 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, stitched_item_id, is_segregated, qa_status, is_packed) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status, :is_packed) 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), is_packed = VALUES(is_packed)", 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_TERM_FOR_PACKAGING = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated AND qa_status = 'APPROVED' AND is_packed = FALSE 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 );
|
||||
private final String COUNT_TOTAL_FINISH_ITEM= String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_segregated IS TRUE ",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 TABLE_NAME = "cut_to_pack.finished_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_BARCODE_QA_STATUS = String.format("SELECT case when EXISTS ( SELECT * FROM %s WHERE barcode = :barcode AND (qa_status = 'APPROVED' OR qa_status = 'WASHED') ) then true else false End as Result", 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 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, stitched_item_id, is_segregated, qa_status, is_packed) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status, :is_packed) 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), is_packed = VALUES(is_packed)", 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_qa = :is_qa AND is_packed = FALSE ORDER BY ID DESC", TABLE_NAME);
|
||||
private final String SELECT_BY_TERM_FOR_PACKAGING = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated AND qa_status = 'APPROVED' AND is_packed = FALSE 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 AND is_packed = FALSE", 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);
|
||||
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_segregated IS TRUE ", 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);
|
||||
|
||||
public FinishedItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||
}
|
||||
public FinishedItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||
}
|
||||
|
||||
// prepare query params
|
||||
private MapSqlParameterSource prepareInsertQueryParams( FinishedItem finishedItem ) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "id", finishedItem.getId() )
|
||||
.addValue( "item_id", finishedItem.getItemId() )
|
||||
.addValue( "sku", finishedItem.getSku() )
|
||||
.addValue( "barcode", finishedItem.getBarcode() )
|
||||
.addValue( "created_at", finishedItem.getCreatedAt() )
|
||||
.addValue( "created_by", finishedItem.getCreatedBy() )
|
||||
.addValue("job_card_id", finishedItem.getJobCardId() )
|
||||
.addValue("is_qa", finishedItem.getIsQa() )
|
||||
.addValue("stitched_item_id", finishedItem.getStitchedItemId() )
|
||||
.addValue("is_segregated", finishedItem.getIsSegregated() )
|
||||
.addValue("qa_status", finishedItem.getQaStatus() )
|
||||
.addValue("is_packed",finishedItem.isPackaging());
|
||||
return params;
|
||||
}
|
||||
// prepare query params
|
||||
private MapSqlParameterSource prepareInsertQueryParams(FinishedItem finishedItem) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("id", finishedItem.getId())
|
||||
.addValue("item_id", finishedItem.getItemId())
|
||||
.addValue("sku", finishedItem.getSku())
|
||||
.addValue("barcode", finishedItem.getBarcode())
|
||||
.addValue("created_at", finishedItem.getCreatedAt())
|
||||
.addValue("created_by", finishedItem.getCreatedBy())
|
||||
.addValue("job_card_id", finishedItem.getJobCardId())
|
||||
.addValue("is_qa", finishedItem.getIsQa())
|
||||
.addValue("stitched_item_id", finishedItem.getStitchedItemId())
|
||||
.addValue("is_segregated", finishedItem.getIsSegregated())
|
||||
.addValue("qa_status", finishedItem.getQaStatus())
|
||||
.addValue("is_packed", finishedItem.isPackaging());
|
||||
return params;
|
||||
}
|
||||
|
||||
// find
|
||||
public FinishedItem find( long id ) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "id", id );
|
||||
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new FinishedItemRowMapper() )
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse( new FinishedItem() );
|
||||
}
|
||||
// find
|
||||
public FinishedItem find(long id) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("id", id);
|
||||
return namedParameterJdbcTemplate.query(SELECT_QUERY, params, new FinishedItemRowMapper())
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(new FinishedItem());
|
||||
}
|
||||
|
||||
// find all
|
||||
public List<FinishedItem> findAll() {
|
||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new FinishedItemRowMapper() );
|
||||
}
|
||||
// find all
|
||||
public List<FinishedItem> findAll() {
|
||||
return namedParameterJdbcTemplate.query(SELECT_ALL_QUERY, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
// save
|
||||
public long save( FinishedItem finishedItem ) {
|
||||
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||
MapSqlParameterSource params = prepareInsertQueryParams( finishedItem );
|
||||
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||
return KeyHolderFunctions.getKey( finishedItem.getId(), keyHolder );
|
||||
}
|
||||
// save
|
||||
public long save(FinishedItem finishedItem) {
|
||||
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||
MapSqlParameterSource params = prepareInsertQueryParams(finishedItem);
|
||||
namedParameterJdbcTemplate.update(INSERT_QUERY, params, keyHolder);
|
||||
return KeyHolderFunctions.getKey(finishedItem.getId(), keyHolder);
|
||||
}
|
||||
|
||||
// save all
|
||||
public int[] saveAll( List<FinishedItem> finishedItems ) {
|
||||
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||
for ( FinishedItem finishedItem: finishedItems ) {
|
||||
MapSqlParameterSource params = prepareInsertQueryParams( finishedItem );
|
||||
batchArgs.add( params );
|
||||
}
|
||||
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[finishedItems.size()]) );
|
||||
}
|
||||
// save all
|
||||
public int[] saveAll(List<FinishedItem> finishedItems) {
|
||||
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||
for (FinishedItem finishedItem : finishedItems) {
|
||||
MapSqlParameterSource params = prepareInsertQueryParams(finishedItem);
|
||||
batchArgs.add(params);
|
||||
}
|
||||
return namedParameterJdbcTemplate.batchUpdate(INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[finishedItems.size()]));
|
||||
}
|
||||
|
||||
// delete
|
||||
public boolean delete( long id ) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "id", id );
|
||||
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||
}
|
||||
// delete
|
||||
public boolean delete(long id) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("id", id);
|
||||
return namedParameterJdbcTemplate.update(DELETE_QUERY, params) > 0;
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByLimit(Long count ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "limit",count );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT , params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByLimit(Long count) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("limit", count);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_LIMIT, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByQuery(String query ){
|
||||
return namedParameterJdbcTemplate.query( query, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByQuery(String query) {
|
||||
return namedParameterJdbcTemplate.query(query, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByIds(List<Long> ids ){
|
||||
if( ids == null || ids.isEmpty() ) return new ArrayList<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("ids", ids );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByIds(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) return new ArrayList<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("ids", ids);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_IDS, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByTerm( String term , boolean isSegregated ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("term", "%" + term + "%" );
|
||||
params.addValue("is_segregated", isSegregated );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_TERM , params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByTerm(String term, boolean isQa) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("term", "%" + term + "%");
|
||||
params.addValue("is_qa", isQa);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_TERM, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public List<FinishedItem> findByTermForPackaging( String term , boolean isSegregated ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("term", "%" + term + "%" );
|
||||
params.addValue("is_segregated", isSegregated );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_TERM_FOR_PACKAGING , params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByTermForPackaging(String term, boolean isSegregated) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("term", "%" + term + "%");
|
||||
params.addValue("is_segregated", isSegregated);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_TERM_FOR_PACKAGING, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
// find By job card Id
|
||||
public List<FinishedItem> findByJobCardId(long jobCardId ) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "job_card_id", jobCardId );
|
||||
return namedParameterJdbcTemplate.query(SELECT_QUERY_BY_JOB_CARD, params, new FinishedItemRowMapper() );
|
||||
}
|
||||
// find By job card Id
|
||||
public List<FinishedItem> findByJobCardId(long jobCardId) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("job_card_id", jobCardId);
|
||||
return namedParameterJdbcTemplate.query(SELECT_QUERY_BY_JOB_CARD, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public FinishedItem findByStitchedItem( long stitchedItemId ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("stitched_item_id", stitchedItemId );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_STITCHED_ITEM_ID , params, new FinishedItemRowMapper() )
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse( null );
|
||||
public FinishedItem findByStitchedItem(long stitchedItemId) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("stitched_item_id", stitchedItemId);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_STITCHED_ITEM_ID, params, new FinishedItemRowMapper())
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Long, Long> findTotalFinishedItems(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 HashMap<Long, Long> findTotalFinishedItems(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();
|
||||
params.addValue("stitched_item_ids", stitchedItemIds );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_STITCHED_ITEM_IDS, params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> findByStitchedItemIds(List<Long> stitchedItemIds) {
|
||||
if (stitchedItemIds == null || stitchedItemIds.isEmpty()) return new ArrayList<>();
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("stitched_item_ids", stitchedItemIds);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_STITCHED_ITEM_IDS, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
public List<StitchingOfflineItem> findByBarcodeAndApprovedStatus( List<StitchingOfflineItem> stitchingOfflineItems ){
|
||||
List<StitchingOfflineItem> items = new ArrayList<>();
|
||||
for (StitchingOfflineItem item : stitchingOfflineItems){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("barcode", item.getBarcode() );
|
||||
boolean check =Boolean.TRUE.equals(namedParameterJdbcTemplate.queryForObject( SELECT_QUERY_BY_BARCODE_QA_STATUS, params, Boolean.class ));
|
||||
if(!check){
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
public List<StitchingOfflineItem> findByBarcodeAndApprovedStatus(List<StitchingOfflineItem> stitchingOfflineItems) {
|
||||
List<StitchingOfflineItem> items = new ArrayList<>();
|
||||
for (StitchingOfflineItem item : stitchingOfflineItems) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("barcode", item.getBarcode());
|
||||
boolean check = Boolean.TRUE.equals(namedParameterJdbcTemplate.queryForObject(SELECT_QUERY_BY_BARCODE_QA_STATUS, params, Boolean.class));
|
||||
if (!check) {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public Long calculateTotalFinishItem( long jobCardId ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("job_card_id", jobCardId );
|
||||
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_FINISH_ITEM, params, Long.class);
|
||||
return count != null ? count : 0;
|
||||
}
|
||||
public Long calculateTotalFinishItem(long jobCardId) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("job_card_id", jobCardId);
|
||||
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_FINISH_ITEM, params, Long.class);
|
||||
return count != null ? count : 0;
|
||||
}
|
||||
|
||||
public List<FinishedItem> calculateTotalFinishItem( long jobCardId, String startDate, String endDate ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("job_card_id", jobCardId );
|
||||
params.addValue( "start_date", startDate );
|
||||
params.addValue( "end_date", endDate );
|
||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_DATE, params, new FinishedItemRowMapper() );
|
||||
}
|
||||
public List<FinishedItem> calculateTotalFinishItem(long jobCardId, String startDate, String endDate) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("job_card_id", jobCardId);
|
||||
params.addValue("start_date", startDate);
|
||||
params.addValue("end_date", endDate);
|
||||
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_AND_DATE, params, new FinishedItemRowMapper());
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
|||
|
||||
public class FinishedItemWrapper {
|
||||
|
||||
private String qaStatus;
|
||||
|
||||
private List<FinishedItem> items;
|
||||
|
||||
public List<FinishedItem> getItems() {
|
||||
|
@ -14,6 +16,14 @@ public class FinishedItemWrapper {
|
|||
this.items = items;
|
||||
}
|
||||
|
||||
public String getQaStatus() {
|
||||
return qaStatus;
|
||||
}
|
||||
|
||||
public void setQaStatus(String qaStatus) {
|
||||
this.qaStatus = qaStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishedItemWrapper{" +
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.utopiaindustries.model.ctp;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class StitchedItemWrapper {
|
||||
|
||||
|
||||
private String qaStatus;
|
||||
private List<StitchingOfflineItem> items;
|
||||
private Long finishedAccountId;
|
||||
|
||||
public String getQaStatus() {
|
||||
return qaStatus;
|
||||
}
|
||||
|
||||
public void setQaStatus(String qaStatus) {
|
||||
this.qaStatus = qaStatus;
|
||||
}
|
||||
|
||||
public List<StitchingOfflineItem> getItems() {
|
||||
return items;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping( "/rest/finished-items" )
|
||||
@RequestMapping("/rest/finished-items")
|
||||
public class FinishedItemRestController {
|
||||
|
||||
private final FinishedItemDAO finishedItemDAO;
|
||||
|
@ -19,14 +19,15 @@ public class FinishedItemRestController {
|
|||
this.finishedItemDAO = finishedItemDAO;
|
||||
}
|
||||
|
||||
@GetMapping( "/search" )
|
||||
public List<FinishedItem> searchFinishedItems(@RequestParam( "term") String term,
|
||||
@RequestParam( "is-segregated") boolean isSegregated ){
|
||||
return finishedItemDAO.findByTerm( term, isSegregated );
|
||||
@GetMapping("/search")
|
||||
public List<FinishedItem> searchFinishedItems(@RequestParam("term") String term,
|
||||
@RequestParam("is-segregated") boolean isSegregated) {
|
||||
return finishedItemDAO.findByTerm(term, true);
|
||||
}
|
||||
@GetMapping( "/search-packaging" )
|
||||
public List<FinishedItem> searchFinishedItemsForPackaging(@RequestParam( "term") String term,
|
||||
@RequestParam( "is-segregated") boolean isSegregated ){
|
||||
return finishedItemDAO.findByTermForPackaging( term, true );
|
||||
|
||||
@GetMapping("/search-packaging")
|
||||
public List<FinishedItem> searchFinishedItemsForPackaging(@RequestParam("term") String term,
|
||||
@RequestParam("is-segregated") boolean isSegregated) {
|
||||
return finishedItemDAO.findByTermForPackaging(term, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,55 +44,55 @@ public class InventoryService {
|
|||
this.packagingItemsDAO = packagingItemsDAO;
|
||||
}
|
||||
|
||||
private void updateJobCardInventoryStatus( JobCard card ){
|
||||
List<JobCardItem> items = jobCardItemDAO.findByCardId( card.getId( ) );
|
||||
for( JobCardItem item : items ){
|
||||
private void updateJobCardInventoryStatus(JobCard card) {
|
||||
List<JobCardItem> items = jobCardItemDAO.findByCardId(card.getId());
|
||||
for (JobCardItem item : items) {
|
||||
// check if item is received
|
||||
if( item.getActualProduction( ) == null || item.getActualProduction( ).compareTo( BigDecimal.ZERO ) == 0 ){
|
||||
return;
|
||||
if (item.getActualProduction() == null || item.getActualProduction().compareTo(BigDecimal.ZERO) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
card.setInventoryStatus( JobCard.InventoryStatus.RECEIVED.name( ) );
|
||||
jobCardDAO.save( card );
|
||||
card.setInventoryStatus(JobCard.InventoryStatus.RECEIVED.name());
|
||||
jobCardDAO.save(card);
|
||||
}
|
||||
|
||||
/*
|
||||
* receive inv from job card
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||
public void receiveJobCardInventory( long jobCardId, JobCardWrapper jobCardWrapper ) {
|
||||
if ( jobCardId == 0 || jobCardWrapper.getItems( ) == null || jobCardWrapper.getItems( ).isEmpty( ) ) {
|
||||
throw new RuntimeException( " JobCard can`t be empty");
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
|
||||
public void receiveJobCardInventory(long jobCardId, JobCardWrapper jobCardWrapper) {
|
||||
if (jobCardId == 0 || jobCardWrapper.getItems() == null || jobCardWrapper.getItems().isEmpty()) {
|
||||
throw new RuntimeException(" JobCard can`t be empty");
|
||||
}
|
||||
JobCard jobCard = jobCardDAO.find( jobCardId );
|
||||
JobCard jobCard = jobCardDAO.find(jobCardId);
|
||||
// get job cad items
|
||||
List<JobCardItemWrapper> jobCardItemWrappers = jobCardWrapper.getItems( );
|
||||
List<Long> jobCardItemWrapperIds = jobCardItemWrappers.stream( )
|
||||
.map( JobCardItemWrapper::getJobCardItemId )
|
||||
.collect( Collectors.toList( ) );
|
||||
List<JobCardItemWrapper> jobCardItemWrappers = jobCardWrapper.getItems();
|
||||
List<Long> jobCardItemWrapperIds = jobCardItemWrappers.stream()
|
||||
.map(JobCardItemWrapper::getJobCardItemId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<Long,BigDecimal> jobCardItemIdToActualProdMap = jobCardItemWrappers.stream( )
|
||||
.collect( Collectors.toMap( JobCardItemWrapper::getJobCardItemId, JobCardItemWrapper::getActualProduction ) );
|
||||
Map<Long, BigDecimal> jobCardItemIdToActualProdMap = jobCardItemWrappers.stream()
|
||||
.collect(Collectors.toMap(JobCardItemWrapper::getJobCardItemId, JobCardItemWrapper::getActualProduction));
|
||||
|
||||
List<JobCardItem> items = jobCardItemDAO.findByIds( jobCardItemWrapperIds );
|
||||
List<JobCardItem> items = jobCardItemDAO.findByIds(jobCardItemWrapperIds);
|
||||
|
||||
if ( items != null && !items.isEmpty( ) ) {
|
||||
if (items != null && !items.isEmpty()) {
|
||||
// get job card item ids
|
||||
List<Long> jobCardItemIds = items.stream( )
|
||||
.map( JobCardItem::getId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> jobCardItemIds = items.stream()
|
||||
.map(JobCardItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// save updated cut pieces
|
||||
List<CutPiece> cutPieces = jobCardItemWrappers.stream( )
|
||||
.flatMap( wrapper -> wrapper.getPieces( ).stream( ) )
|
||||
.collect( Collectors.toList( ) );
|
||||
cutPieceDAO.saveAll( cutPieces );
|
||||
List<CutPiece> cutPieces = jobCardItemWrappers.stream()
|
||||
.flatMap(wrapper -> wrapper.getPieces().stream())
|
||||
.collect(Collectors.toList());
|
||||
cutPieceDAO.saveAll(cutPieces);
|
||||
|
||||
Map<Long, List<CutPiece>> piecesMap = cutPieceDAO.findByJobCardItemIds( jobCardItemIds)
|
||||
.stream( )
|
||||
.collect( Collectors.groupingBy( CutPiece::getJobCardItemId));
|
||||
Map<Long, List<CutPiece>> piecesMap = cutPieceDAO.findByJobCardItemIds(jobCardItemIds)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(CutPiece::getJobCardItemId));
|
||||
|
||||
for ( JobCardItem jobCardItem : items) {
|
||||
for (JobCardItem jobCardItem : items) {
|
||||
|
||||
int quantity = jobCardItemWrappers.stream()
|
||||
.filter(e -> e.getJobCardItemId() == jobCardItem.getId())
|
||||
|
@ -112,32 +112,32 @@ public class InventoryService {
|
|||
.findFirst()
|
||||
.orElse(BigDecimal.ZERO);
|
||||
|
||||
List<Bundle> bundles = createBundles( jobCardItem,quantity,jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) );
|
||||
List<Bundle> bundles = createBundles(jobCardItem, quantity, jobCardItemIdToActualProdMap.getOrDefault(jobCardItem.getId(), BigDecimal.ZERO));
|
||||
// create transactions
|
||||
createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( ));
|
||||
jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ), BigDecimal.ZERO ).add(jobCardItem.getActualProduction()) );
|
||||
createTransactions(bundles, jobCardItem.getAccountId(), InventoryArtifactType.BUNDLE.name());
|
||||
jobCardItem.setActualProduction(jobCardItemIdToActualProdMap.getOrDefault(jobCardItem.getId(), BigDecimal.ZERO).add(jobCardItem.getActualProduction()));
|
||||
jobCardItem.setComplete(cuttingComplete);
|
||||
|
||||
}
|
||||
// update items with quantity
|
||||
jobCardItemDAO.saveAll( items );
|
||||
jobCardItemDAO.saveAll(items);
|
||||
// update job card inv status
|
||||
if(jobCardItemDAO.checkAllItemsComplete(jobCardId,jobCardItemIds)) {
|
||||
if (jobCardItemDAO.checkAllItemsComplete(jobCardId, jobCardItemIds)) {
|
||||
updateJobCardInventoryStatus(jobCard);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException( "Items Not found in Job Card");
|
||||
throw new RuntimeException("Items Not found in Job Card");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* t create transactions
|
||||
* */
|
||||
private void createTransactions( List<? extends InventoryArtifact> artifacts, long accountId, String parentDocumentType) {
|
||||
if ( !artifacts.isEmpty( )) {
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Transaction Against " + parentDocumentType);
|
||||
for ( InventoryArtifact artifact : artifacts) {
|
||||
InventoryTransactionLeg leg = createInventoryTransactionLeg( transaction, artifact, accountId, InventoryTransactionLeg.Type.IN.name( ), parentDocumentType );
|
||||
private void createTransactions(List<? extends InventoryArtifact> artifacts, long accountId, String parentDocumentType) {
|
||||
if (!artifacts.isEmpty()) {
|
||||
InventoryTransaction transaction = createInventoryTransaction("Transaction Against " + parentDocumentType);
|
||||
for (InventoryArtifact artifact : artifacts) {
|
||||
InventoryTransactionLeg leg = createInventoryTransactionLeg(transaction, artifact, accountId, InventoryTransactionLeg.Type.IN.name(), parentDocumentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,93 +146,93 @@ public class InventoryService {
|
|||
/*
|
||||
* create and save transaction
|
||||
* */
|
||||
private InventoryTransaction createInventoryTransaction( String notes) {
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
InventoryTransaction transaction = new InventoryTransaction( );
|
||||
transaction.setGeneratedBy( authentication.getName( ));
|
||||
transaction.setTransactionDateTime( LocalDateTime.now( ));
|
||||
transaction.setNotes( notes);
|
||||
transaction.setId( inventoryTransactionDAO.save( transaction));
|
||||
private InventoryTransaction createInventoryTransaction(String notes) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
InventoryTransaction transaction = new InventoryTransaction();
|
||||
transaction.setGeneratedBy(authentication.getName());
|
||||
transaction.setTransactionDateTime(LocalDateTime.now());
|
||||
transaction.setNotes(notes);
|
||||
transaction.setId(inventoryTransactionDAO.save(transaction));
|
||||
return transaction;
|
||||
}
|
||||
|
||||
/*
|
||||
* create and save inventory transaction
|
||||
* */
|
||||
private InventoryTransactionLeg createInventoryTransactionLeg( InventoryTransaction transaction,
|
||||
private InventoryTransactionLeg createInventoryTransactionLeg(InventoryTransaction transaction,
|
||||
InventoryArtifact artifact,
|
||||
long accountId,
|
||||
String transactionType,
|
||||
String parentDocumentType) {
|
||||
|
||||
InventoryTransactionLeg inventoryTransactionLeg = new InventoryTransactionLeg( );
|
||||
inventoryTransactionLeg.setTransactionId( transaction.getId( ));
|
||||
inventoryTransactionLeg.setType( transactionType);
|
||||
inventoryTransactionLeg.setQuantity( BigDecimal.valueOf( 1L));
|
||||
inventoryTransactionLeg.setAccountId( ( int) accountId);
|
||||
inventoryTransactionLeg.setItemId( artifact.getItemId( ));
|
||||
inventoryTransactionLeg.setSku( artifact.getSku( ));
|
||||
inventoryTransactionLeg.setParentDocumentType( parentDocumentType);
|
||||
inventoryTransactionLeg.setParentDocumentId( artifact.getId( ));
|
||||
inventoryTransactionLeg.setParentDocumentPieceType( artifact.getType( ));
|
||||
inventoryTransactionLeg.setTransactionLegDateTime( LocalDateTime.now( ));
|
||||
InventoryTransactionLeg inventoryTransactionLeg = new InventoryTransactionLeg();
|
||||
inventoryTransactionLeg.setTransactionId(transaction.getId());
|
||||
inventoryTransactionLeg.setType(transactionType);
|
||||
inventoryTransactionLeg.setQuantity(BigDecimal.valueOf(1L));
|
||||
inventoryTransactionLeg.setAccountId((int) accountId);
|
||||
inventoryTransactionLeg.setItemId(artifact.getItemId());
|
||||
inventoryTransactionLeg.setSku(artifact.getSku());
|
||||
inventoryTransactionLeg.setParentDocumentType(parentDocumentType);
|
||||
inventoryTransactionLeg.setParentDocumentId(artifact.getId());
|
||||
inventoryTransactionLeg.setParentDocumentPieceType(artifact.getType());
|
||||
inventoryTransactionLeg.setTransactionLegDateTime(LocalDateTime.now());
|
||||
inventoryTransactionLeg.setJobCardId(artifact.getJobCardId());
|
||||
// set balance
|
||||
BigDecimal initialBalance = calculateBalance( accountId, artifact.getItemId( ), parentDocumentType, artifact.getType( ));
|
||||
BigDecimal initialBalance = calculateBalance(accountId, artifact.getItemId(), parentDocumentType, artifact.getType());
|
||||
|
||||
if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) {
|
||||
initialBalance = initialBalance.add( inventoryTransactionLeg.getQuantity( ));
|
||||
}else if(transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.OUT.name( ))) {
|
||||
if (transactionType.equalsIgnoreCase(InventoryTransactionLeg.Type.IN.name())) {
|
||||
initialBalance = initialBalance.add(inventoryTransactionLeg.getQuantity());
|
||||
} else if (transactionType.equalsIgnoreCase(InventoryTransactionLeg.Type.OUT.name())) {
|
||||
if (inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)) {
|
||||
initialBalance = BigDecimal.ZERO;
|
||||
} else {
|
||||
initialBalance = initialBalance.subtract(inventoryTransactionLeg.getQuantity());
|
||||
}
|
||||
}
|
||||
inventoryTransactionLeg.setBalance( initialBalance);
|
||||
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
||||
inventoryTransactionLeg.setBalance(initialBalance);
|
||||
inventoryTransactionLeg.setId(inventoryTransactionLegDAO.save(inventoryTransactionLeg));
|
||||
return inventoryTransactionLeg;
|
||||
}
|
||||
|
||||
|
||||
// calculate balance
|
||||
private BigDecimal calculateBalance( long accountId, long itemId, String parentType, String pieceType) {
|
||||
private BigDecimal calculateBalance(long accountId, long itemId, String parentType, String pieceType) {
|
||||
// find the last transaction leg of the current account Id with itemId
|
||||
InventoryTransactionLeg lastTransactionLeg = inventoryTransactionLegDAO.findLastByAccountIdAndItemIdAndParentType( accountId, itemId, parentType, pieceType);
|
||||
if ( lastTransactionLeg.getBalance( ) != null) {
|
||||
return lastTransactionLeg.getBalance( );
|
||||
InventoryTransactionLeg lastTransactionLeg = inventoryTransactionLegDAO.findLastByAccountIdAndItemIdAndParentType(accountId, itemId, parentType, pieceType);
|
||||
if (lastTransactionLeg.getBalance() != null) {
|
||||
return lastTransactionLeg.getBalance();
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
|
||||
// create bundles from cut pieces
|
||||
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
||||
int perBundleWrap, BigDecimal value ) {
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
if ( value != null && !value.equals(BigDecimal.ZERO)) {
|
||||
List<Bundle> bundles = new ArrayList<>( );
|
||||
int quantity = value.intValue();
|
||||
int batchSize = perBundleWrap;
|
||||
int iterations = (int) Math.ceil((double) quantity / batchSize);
|
||||
private List<Bundle> createBundles(JobCardItem jobCardItem,
|
||||
int perBundleWrap, BigDecimal value) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (value != null && !value.equals(BigDecimal.ZERO)) {
|
||||
List<Bundle> bundles = new ArrayList<>();
|
||||
int quantity = value.intValue();
|
||||
int batchSize = perBundleWrap;
|
||||
int iterations = (int) Math.ceil((double) quantity / batchSize);
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
int start = i * batchSize + 1; // Start index
|
||||
int end = Math.min((i + 1) * batchSize, quantity); // Last index
|
||||
int perBundleQuantity = end - start + 1;
|
||||
Bundle bundle = new Bundle( );
|
||||
bundle.setItemId( jobCardItem.getItemId( ));
|
||||
bundle.setSku( jobCardItem.getSku( ));
|
||||
bundle.setJobCardId( jobCardItem.getJobCardId( ) );
|
||||
bundle.setWrapQuantity( BigDecimal.valueOf(perBundleQuantity));
|
||||
bundle.setType( "BUNDLE");
|
||||
bundle.setCreatedAt( LocalDateTime.now( ));
|
||||
bundle.setCreatedBy( authentication.getName( ));
|
||||
bundles.add( bundle);
|
||||
bundle.setId( bundleDAO.save( bundle));
|
||||
bundle.setBarcode( cryptographyService.generateRandomString( 15));
|
||||
// save again after barcode generation
|
||||
bundle.setId( bundleDAO.save( bundle));
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
int start = i * batchSize + 1; // Start index
|
||||
int end = Math.min((i + 1) * batchSize, quantity); // Last index
|
||||
int perBundleQuantity = end - start + 1;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.setItemId(jobCardItem.getItemId());
|
||||
bundle.setSku(jobCardItem.getSku());
|
||||
bundle.setJobCardId(jobCardItem.getJobCardId());
|
||||
bundle.setWrapQuantity(BigDecimal.valueOf(perBundleQuantity));
|
||||
bundle.setType("BUNDLE");
|
||||
bundle.setCreatedAt(LocalDateTime.now());
|
||||
bundle.setCreatedBy(authentication.getName());
|
||||
bundles.add(bundle);
|
||||
bundle.setId(bundleDAO.save(bundle));
|
||||
bundle.setBarcode(cryptographyService.generateRandomString(15));
|
||||
// save again after barcode generation
|
||||
bundle.setId(bundleDAO.save(bundle));
|
||||
}
|
||||
// for ( Map.Entry<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
||||
// JobCardItem key = entry.getKey( );
|
||||
|
@ -242,87 +242,87 @@ public class InventoryService {
|
|||
// }
|
||||
return bundles;
|
||||
}
|
||||
return new ArrayList<>( );
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* receive inventory from master barcode
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||
public void receiveInventoryFromMasterBarcode( long masterId, long toAccount) {
|
||||
if ( masterId == 0 || toAccount == 0) {
|
||||
throw new RuntimeException( "Master Barcode | Account can`t be empty");
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
|
||||
public void receiveInventoryFromMasterBarcode(long masterId, long toAccount) {
|
||||
if (masterId == 0 || toAccount == 0) {
|
||||
throw new RuntimeException("Master Barcode | Account can`t be empty");
|
||||
}
|
||||
MasterBundle masterBundle = masterBundleDAO.find( masterId);
|
||||
MasterBundle masterBundle = masterBundleDAO.find(masterId);
|
||||
// find bundles from master barcode
|
||||
List<Bundle> bundles = bundleDAO.findByMasterId( masterId);
|
||||
if ( bundles != null && !bundles.isEmpty( )) {
|
||||
List<Bundle> bundles = bundleDAO.findByMasterId(masterId);
|
||||
if (bundles != null && !bundles.isEmpty()) {
|
||||
// bundle ids
|
||||
List<Long> bundleIds = bundles.stream( ).map( Bundle::getId).collect( Collectors.toList( ));
|
||||
List<Long> bundleIds = bundles.stream().map(Bundle::getId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), bundleIds, InventoryArtifactType.BUNDLE.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), bundleIds, InventoryArtifactType.BUNDLE.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// create Transaction
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Against Movement from Cutting to Stitching");
|
||||
inventoryTransactionDAO.save( transaction);
|
||||
InventoryTransaction transaction = createInventoryTransaction("Against Movement from Cutting to Stitching");
|
||||
inventoryTransactionDAO.save(transaction);
|
||||
// create transaction legs
|
||||
for ( Bundle bundle : bundles) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault( bundle.getId( ), null);
|
||||
if ( lastInvTransaction != null) {
|
||||
for (Bundle bundle : bundles) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(bundle.getId(), null);
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.BUNDLE.name());
|
||||
// IN
|
||||
bundle.setType("BUNDLE");
|
||||
createInventoryTransactionLeg( transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.STITCH_BUNDLE.name( ));
|
||||
createInventoryTransactionLeg(transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.STITCH_BUNDLE.name());
|
||||
}
|
||||
}
|
||||
// update status
|
||||
masterBundle.setIsReceived( true);
|
||||
masterBundle.setIsReceived(true);
|
||||
masterBundle.setAccountId(toAccount);
|
||||
masterBundleDAO.save( masterBundle);
|
||||
masterBundleDAO.save(masterBundle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void validateItems( List<JobCardItem> cardItems) {
|
||||
if ( cardItems == null || cardItems.isEmpty( )) {
|
||||
throw new RuntimeException( "Item cant be Empty | null");
|
||||
private void validateItems(List<JobCardItem> cardItems) {
|
||||
if (cardItems == null || cardItems.isEmpty()) {
|
||||
throw new RuntimeException("Item cant be Empty | null");
|
||||
}
|
||||
for ( JobCardItem jobCardItem : cardItems) {
|
||||
if( jobCardItem.getTotalProduction() != null ){
|
||||
int finalQuantity = jobCardItem.getActualProduction( ).compareTo( jobCardItem.getTotalProduction( ).add( jobCardItem.getProduction( )));
|
||||
if ( finalQuantity < 0) {
|
||||
throw new RuntimeException( " Items cant be generated because it exceeds from limit of expected Production");
|
||||
for (JobCardItem jobCardItem : cardItems) {
|
||||
if (jobCardItem.getTotalProduction() != null) {
|
||||
int finalQuantity = jobCardItem.getActualProduction().compareTo(jobCardItem.getTotalProduction().add(jobCardItem.getProduction()));
|
||||
if (finalQuantity < 0) {
|
||||
throw new RuntimeException(" Items cant be generated because it exceeds from limit of expected Production");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAllBundleAreReceived( long jobCardId,
|
||||
private void checkAllBundleAreReceived(long jobCardId,
|
||||
List<JobCardItem> jobCardItems) {
|
||||
|
||||
|
||||
if ( jobCardItems != null && !jobCardItems.isEmpty( ) ) {
|
||||
List<Long> itemIds = jobCardItems.stream( )
|
||||
.filter( JobCardItem::getIsSelected )
|
||||
.map( JobCardItem::getItemId).collect( Collectors.toList( ));
|
||||
List<Bundle> bundles = bundleDAO.findByItemIdsAndCardId( itemIds, jobCardId);
|
||||
List<Long> masterBundleIds = bundles.stream( ).map( Bundle::getMasterBundleId).collect( Collectors.toList( ));
|
||||
if (jobCardItems != null && !jobCardItems.isEmpty()) {
|
||||
List<Long> itemIds = jobCardItems.stream()
|
||||
.filter(JobCardItem::getIsSelected)
|
||||
.map(JobCardItem::getItemId).collect(Collectors.toList());
|
||||
List<Bundle> bundles = bundleDAO.findByItemIdsAndCardId(itemIds, jobCardId);
|
||||
List<Long> masterBundleIds = bundles.stream().map(Bundle::getMasterBundleId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, MasterBundle> idToMasterBundleMap = masterBundleDAO.findByIds( masterBundleIds)
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( MasterBundle::getId, Function.identity( )));
|
||||
Map<Long, MasterBundle> idToMasterBundleMap = masterBundleDAO.findByIds(masterBundleIds)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(MasterBundle::getId, Function.identity()));
|
||||
|
||||
for ( Bundle bundle : bundles) {
|
||||
for (Bundle bundle : bundles) {
|
||||
// check all bundles are received
|
||||
MasterBundle masterBundle = idToMasterBundleMap.getOrDefault( bundle.getMasterBundleId( ), null);
|
||||
if ( masterBundle == null || ! masterBundle.getIsReceived( ) ) {
|
||||
throw new RuntimeException( "Please Receive Bundles Against Master Bundles First to Create Finished Item");
|
||||
MasterBundle masterBundle = idToMasterBundleMap.getOrDefault(bundle.getMasterBundleId(), null);
|
||||
if (masterBundle == null || !masterBundle.getIsReceived()) {
|
||||
throw new RuntimeException("Please Receive Bundles Against Master Bundles First to Create Finished Item");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,8 +331,8 @@ public class InventoryService {
|
|||
/*
|
||||
* create finished items from master bundles
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||
public void createStitchingOfflineItemsFromJobCard( BundleWrapper wrapper) {
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
|
||||
public void createStitchingOfflineItemsFromJobCard(BundleWrapper wrapper) {
|
||||
List<JobCardItem> updatedItems = new ArrayList<>();
|
||||
List<Bundle> updateBundles = new ArrayList<>();
|
||||
JobCard jobCard = null;
|
||||
|
@ -349,17 +349,17 @@ public class InventoryService {
|
|||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
for (Bundle subBundle : wrapper.getBundles()) {
|
||||
long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId();
|
||||
if(subBundle.getCurrentProduction() != null && subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0){
|
||||
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() ;
|
||||
long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue();
|
||||
long wrapQuantity = bundle.getWrapQuantity().longValue();
|
||||
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(),subBundle.getItemId());
|
||||
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(), subBundle.getItemId());
|
||||
BigDecimal previousTotalProduction = jobCardItem.getTotalProduction() == null ? BigDecimal.ZERO : jobCardItem.getTotalProduction();
|
||||
|
||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(subBundle.getId(), null);
|
||||
|
||||
if (lastInvTransaction != null ) {
|
||||
if (lastInvTransaction != null) {
|
||||
if (wrapQuantity == production + subBundle.getCurrentProduction().longValue()) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
|
@ -367,7 +367,7 @@ public class InventoryService {
|
|||
}
|
||||
}
|
||||
// create stitchingOfflineItems items
|
||||
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems(subBundle.getCurrentProduction(),jobCardItem,subBundle.getId());
|
||||
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems(subBundle.getCurrentProduction(), jobCardItem, subBundle.getId());
|
||||
// create IN Transactions of Finished Items into account
|
||||
createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||
|
||||
|
@ -385,24 +385,24 @@ public class InventoryService {
|
|||
/*
|
||||
* create finished items
|
||||
* */
|
||||
public List<StitchingOfflineItem> createStitchingOfflineItems( BigDecimal totalItem, JobCardItem jobCardItem,long bundleId) {
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
List<StitchingOfflineItem> items = new ArrayList<>( );
|
||||
if ( jobCardItem != null) {
|
||||
for ( int i = 1; i <= totalItem.intValue( ); i++) {
|
||||
StitchingOfflineItem stitchingOfflineItem = new StitchingOfflineItem( );
|
||||
stitchingOfflineItem.setCreatedAt( LocalDateTime.now( ));
|
||||
stitchingOfflineItem.setCreatedBy( authentication.getName( ));
|
||||
stitchingOfflineItem.setItemId( jobCardItem.getItemId( ));
|
||||
stitchingOfflineItem.setSku( jobCardItem.getSku( ));
|
||||
public List<StitchingOfflineItem> createStitchingOfflineItems(BigDecimal totalItem, JobCardItem jobCardItem, long bundleId) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
List<StitchingOfflineItem> items = new ArrayList<>();
|
||||
if (jobCardItem != null) {
|
||||
for (int i = 1; i <= totalItem.intValue(); i++) {
|
||||
StitchingOfflineItem stitchingOfflineItem = new StitchingOfflineItem();
|
||||
stitchingOfflineItem.setCreatedAt(LocalDateTime.now());
|
||||
stitchingOfflineItem.setCreatedBy(authentication.getName());
|
||||
stitchingOfflineItem.setItemId(jobCardItem.getItemId());
|
||||
stitchingOfflineItem.setSku(jobCardItem.getSku());
|
||||
stitchingOfflineItem.setBundleId(bundleId);
|
||||
stitchingOfflineItem.setJobCardId( jobCardItem.getJobCardId( ));
|
||||
stitchingOfflineItem.setIsQa( false );
|
||||
long id = stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
||||
stitchingOfflineItem.setId( id);
|
||||
stitchingOfflineItem.setBarcode( cryptographyService.generateRandomString( 15));
|
||||
stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
||||
items.add( stitchingOfflineItem);
|
||||
stitchingOfflineItem.setJobCardId(jobCardItem.getJobCardId());
|
||||
stitchingOfflineItem.setIsQa(false);
|
||||
long id = stitchingOfflineItemDAO.save(stitchingOfflineItem);
|
||||
stitchingOfflineItem.setId(id);
|
||||
stitchingOfflineItem.setBarcode(cryptographyService.generateRandomString(15));
|
||||
stitchingOfflineItemDAO.save(stitchingOfflineItem);
|
||||
items.add(stitchingOfflineItem);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
@ -411,51 +411,51 @@ public class InventoryService {
|
|||
/*
|
||||
* find transactions by account id
|
||||
* */
|
||||
public List<InventoryTransactionLeg> findTransactionByAccountId( long accountId) {
|
||||
List<InventoryTransactionLeg> legs = inventoryTransactionLegDAO.findByAccountId( accountId);
|
||||
public List<InventoryTransactionLeg> findTransactionByAccountId(long accountId) {
|
||||
List<InventoryTransactionLeg> legs = inventoryTransactionLegDAO.findByAccountId(accountId);
|
||||
|
||||
List<Long> tIds = legs.stream( ).map( InventoryTransactionLeg::getTransactionId).collect( Collectors.toList( ));
|
||||
Map<Long, InventoryTransaction> idToTransactioMap = inventoryTransactionDAO.findByIds( tIds).stream( ).collect( Collectors.toMap( InventoryTransaction::getId, Function.identity( )));
|
||||
legs.forEach( leg -> leg.setTransaction( idToTransactioMap.get( leg.getTransactionId( ))));
|
||||
List<Long> tIds = legs.stream().map(InventoryTransactionLeg::getTransactionId).collect(Collectors.toList());
|
||||
Map<Long, InventoryTransaction> idToTransactioMap = inventoryTransactionDAO.findByIds(tIds).stream().collect(Collectors.toMap(InventoryTransaction::getId, Function.identity()));
|
||||
legs.forEach(leg -> leg.setTransaction(idToTransactioMap.get(leg.getTransactionId())));
|
||||
return legs;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class)
|
||||
public void markFinishedItemsApproved( List<Long> fItemIds, long toAccount) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void markFinishedItemsApproved(List<Long> fItemIds, long toAccount) {
|
||||
|
||||
if ( fItemIds.isEmpty( ) || toAccount == 0) {
|
||||
throw new RuntimeException( "Finished Item Ids | Account can`t be empty");
|
||||
if (fItemIds.isEmpty() || toAccount == 0) {
|
||||
throw new RuntimeException("Finished Item Ids | Account can`t be empty");
|
||||
}
|
||||
|
||||
List<FinishedItem> finishedItems = finishedItemDAO.findByIds( fItemIds);
|
||||
if ( finishedItems != null && !finishedItems.isEmpty( )) {
|
||||
List<FinishedItem> finishedItems = finishedItemDAO.findByIds(fItemIds);
|
||||
if (finishedItems != null && !finishedItems.isEmpty()) {
|
||||
// bundle ids
|
||||
List<Long> finishedItemIds = finishedItems.stream( ).map( FinishedItem::getId).collect( Collectors.toList( ));
|
||||
List<Long> finishedItemIds = finishedItems.stream().map(FinishedItem::getId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), finishedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), finishedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// create Transaction
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Against Movement from Stitching to Packaging After QA");
|
||||
inventoryTransactionDAO.save( transaction);
|
||||
InventoryTransaction transaction = createInventoryTransaction("Against Movement from Stitching to Packaging After QA");
|
||||
inventoryTransactionDAO.save(transaction);
|
||||
// create transaction legs
|
||||
for ( FinishedItem finishedItem : finishedItems) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault( finishedItem.getId( ), null);
|
||||
if ( lastInvTransaction != null) {
|
||||
for (FinishedItem finishedItem : finishedItems) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(finishedItem.getId(), null);
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.STITCHING_OFFLINE.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||
// IN
|
||||
createInventoryTransactionLeg( transaction, finishedItem, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.STITCHING_OFFLINE.name( ));
|
||||
createInventoryTransactionLeg(transaction, finishedItem, toAccount, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||
}
|
||||
finishedItem.setIsQa( true);
|
||||
finishedItem.setIsQa(true);
|
||||
}
|
||||
finishedItemDAO.saveAll( finishedItems);
|
||||
finishedItemDAO.saveAll(finishedItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,81 +463,94 @@ public class InventoryService {
|
|||
/*
|
||||
* generate finished items against stitched items
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class)
|
||||
public void createFinishedItemsAgainstStitchedItems( StitchedItemWrapper wrapper ) {
|
||||
if ( wrapper.getItems( ) != null && wrapper.getFinishedAccountId( ) != 0) {
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createFinishedItemsAgainstStitchedItems(StitchedItemWrapper wrapper, String qaStatus) {
|
||||
if (wrapper.getItems() != null && wrapper.getFinishedAccountId() != 0) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
List<StitchingOfflineItem> stitchingOfflineItems = wrapper.getItems( );
|
||||
List<StitchingOfflineItem> updatedStitchedItems = new ArrayList<>( );
|
||||
List<FinishedItem> finishedItems = new ArrayList<>( );
|
||||
List<StitchingOfflineItem> stitchingOfflineItems = wrapper.getItems();
|
||||
List<StitchingOfflineItem> updatedStitchedItems = new ArrayList<>();
|
||||
List<FinishedItem> finishedItems = new ArrayList<>();
|
||||
List<FinishedItem> finishedItemsForUlter = new ArrayList<>();
|
||||
|
||||
List<Long> stitchedItemIds = stitchingOfflineItems.stream( )
|
||||
.map( StitchingOfflineItem::getId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> stitchedItemIds = stitchingOfflineItems.stream()
|
||||
.map(StitchingOfflineItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<Long, InventoryTransactionLeg> lastStitchedIdInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), stitchedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), stitchedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// get finished items from stitched items if exists
|
||||
List<Long> preCreatedFinishedItemIds = finishedItemDAO.findByStitchedItemIds( stitchedItemIds ).stream( ).
|
||||
map( FinishedItem::getId ).collect( Collectors.toList( ));
|
||||
List<Long> preCreatedFinishedItemIds = finishedItemDAO.findByStitchedItemIds(stitchedItemIds).stream().
|
||||
map(FinishedItem::getId).collect(Collectors.toList());
|
||||
|
||||
Map<Long, InventoryTransactionLeg> lastFinishedItemInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), preCreatedFinishedItemIds, InventoryArtifactType.FINISHED_ITEM.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), preCreatedFinishedItemIds, InventoryArtifactType.FINISHED_ITEM.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Against Movement From Stitching Offline to Finished Item");
|
||||
InventoryTransaction transaction = createInventoryTransaction("Against Movement From Stitching Offline to Finished Item");
|
||||
|
||||
// generate FI for SI
|
||||
for ( StitchingOfflineItem stitchingOfflineItem : stitchingOfflineItems) {
|
||||
if ( stitchingOfflineItem.getQaStatus( ).equalsIgnoreCase( "APPROVED" )) {
|
||||
for (StitchingOfflineItem stitchingOfflineItem : stitchingOfflineItems) {
|
||||
if (qaStatus.equalsIgnoreCase("APPROVED")) {
|
||||
// check finished item is already created
|
||||
FinishedItem preCreatedItem = finishedItemDAO.findByStitchedItem( stitchingOfflineItem.getId( ));
|
||||
if ( preCreatedItem == null) {
|
||||
FinishedItem finishedItem = new FinishedItem( );
|
||||
finishedItem.setItemId( stitchingOfflineItem.getItemId( ));
|
||||
finishedItem.setSku( stitchingOfflineItem.getSku( ));
|
||||
finishedItem.setBarcode( stitchingOfflineItem.getBarcode( ));
|
||||
finishedItem.setCreatedBy( authentication.getName( ));
|
||||
finishedItem.setCreatedAt( LocalDateTime.now( ));
|
||||
finishedItem.setStitchedItemId( stitchingOfflineItem.getId( ));
|
||||
finishedItem.setJobCardId( stitchingOfflineItem.getJobCardId( ));
|
||||
finishedItem.setIsQa( false);
|
||||
finishedItem.setId( finishedItemDAO.save( finishedItem));
|
||||
finishedItems.add( finishedItem);
|
||||
InventoryTransactionLeg lastInvTransaction = lastStitchedIdInTransactionMap.getOrDefault( stitchingOfflineItem.getId( ), null);
|
||||
if ( lastInvTransaction != null ) {
|
||||
FinishedItem preCreatedItem = finishedItemDAO.findByStitchedItem(stitchingOfflineItem.getId());
|
||||
if (preCreatedItem == null) {
|
||||
FinishedItem finishedItem = new FinishedItem();
|
||||
finishedItem.setItemId(stitchingOfflineItem.getItemId());
|
||||
finishedItem.setSku(stitchingOfflineItem.getSku());
|
||||
finishedItem.setBarcode(stitchingOfflineItem.getBarcode());
|
||||
finishedItem.setCreatedBy(authentication.getName());
|
||||
finishedItem.setCreatedAt(LocalDateTime.now());
|
||||
finishedItem.setStitchedItemId(stitchingOfflineItem.getId());
|
||||
finishedItem.setJobCardId(stitchingOfflineItem.getJobCardId());
|
||||
finishedItem.setIsQa(true);
|
||||
finishedItem.setId(finishedItemDAO.save(finishedItem));
|
||||
finishedItems.add(finishedItem);
|
||||
InventoryTransactionLeg lastInvTransaction = lastStitchedIdInTransactionMap.getOrDefault(stitchingOfflineItem.getId(), null);
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, stitchingOfflineItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.STITCHING_OFFLINE.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, stitchingOfflineItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||
}
|
||||
// update stitched item
|
||||
stitchingOfflineItem.setIsQa( true);
|
||||
stitchingOfflineItem.setIsQa(true);
|
||||
stitchingOfflineItem.setQaStatus(qaStatus);
|
||||
updatedStitchedItems.add(stitchingOfflineItem);
|
||||
// if FI is already created
|
||||
} else {
|
||||
// create OUT from stitching account Finished Item
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemInTransactionMap.getOrDefault( preCreatedItem.getId( ), null);
|
||||
if ( lastInvTransaction != null ) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemInTransactionMap.getOrDefault(preCreatedItem.getId(), null);
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, stitchingOfflineItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, stitchingOfflineItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
|
||||
}
|
||||
preCreatedItem.setIsQa(true);
|
||||
finishedItemsForUlter.add(preCreatedItem);
|
||||
// create IN in finishing Account Finished Item
|
||||
finishedItems.add( preCreatedItem );
|
||||
finishedItems.add(preCreatedItem);
|
||||
}
|
||||
} else {
|
||||
FinishedItem preCreatedItem = finishedItemDAO.findByStitchedItem(stitchingOfflineItem.getId());
|
||||
preCreatedItem.setIsQa(false);
|
||||
finishedItemsForUlter.add(preCreatedItem);
|
||||
}
|
||||
stitchingOfflineItem.setIsQa(true);
|
||||
stitchingOfflineItem.setQaStatus(qaStatus);
|
||||
updatedStitchedItems.add(stitchingOfflineItem);
|
||||
}
|
||||
for ( FinishedItem finishedItem : finishedItems) {
|
||||
for (FinishedItem finishedItem : finishedItems) {
|
||||
// IN
|
||||
createInventoryTransactionLeg( transaction, finishedItem, wrapper.getFinishedAccountId( ), InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||
createInventoryTransactionLeg(transaction, finishedItem, wrapper.getFinishedAccountId(), InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.FINISHED_ITEM.name());
|
||||
}
|
||||
// save updated stitched items
|
||||
stitchingOfflineItemDAO.saveAll( wrapper.getItems( ));
|
||||
finishedItemDAO.saveAll(finishedItemsForUlter);
|
||||
stitchingOfflineItemDAO.saveAll(updatedStitchedItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,139 +558,163 @@ public class InventoryService {
|
|||
/*
|
||||
* segregate finish items
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||
public void segregateFinishedItems( FinishedItemWrapper wrapper) {
|
||||
if ( wrapper != null && wrapper.getItems( ) != null) {
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
|
||||
public void segregateFinishedItems(FinishedItemWrapper wrapper, String status) {
|
||||
if (wrapper != null && wrapper.getItems() != null) {
|
||||
|
||||
List<FinishedItem> items = wrapper.getItems( );
|
||||
List<FinishedItem> updatedItems = new ArrayList<>( );
|
||||
List<FinishedItem> items = wrapper.getItems();
|
||||
List<FinishedItem> updatedItems = new ArrayList<>();
|
||||
// finished ids
|
||||
List<Long> finishedItemIds = items.stream( ).map( FinishedItem::getId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> finishedItemIds = items.stream().map(FinishedItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
// stitched ids
|
||||
List<Long> stitchedItemIds = items.stream( ).map( FinishedItem::getStitchedItemId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> stitchedItemIds = items.stream().map(FinishedItem::getStitchedItemId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// create parent doc type last IN transaction map
|
||||
Map<Long, InventoryTransactionLeg> lastFinishedItemIdInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), finishedItemIds, InventoryArtifactType.FINISHED_ITEM.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), finishedItemIds, InventoryArtifactType.FINISHED_ITEM.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// create parent doc type last OUT transaction map
|
||||
Map<Long, InventoryTransactionLeg> lastStitchedItemOutTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.OUT.name( ), stitchedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.OUT.name(), stitchedItemIds, InventoryArtifactType.STITCHING_OFFLINE.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// create transaction
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Against Segregation of Finished Items");
|
||||
|
||||
InventoryTransaction transaction = createInventoryTransaction("Against Segregation of Finished Items");
|
||||
|
||||
// create IN and OUT for all approved items
|
||||
for ( FinishedItem finishedItem : items) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemIdInTransactionMap.getOrDefault( finishedItem.getId( ), null);
|
||||
finishedItem.setIsQa( true);
|
||||
/*
|
||||
* item is not approved and washed is selected then item remain in Finishing account
|
||||
* */
|
||||
for (FinishedItem finishedItem : items) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemIdInTransactionMap.getOrDefault(finishedItem.getId(), null);
|
||||
finishedItem.setIsQa(true);
|
||||
|
||||
/*
|
||||
* item is approved and alter is selected then finished item will to stitching account
|
||||
* */
|
||||
if ( finishedItem.getQaStatus( ).equalsIgnoreCase( "ALTER")) {
|
||||
if (status.equalsIgnoreCase("ALTER")) {
|
||||
// create OUT and IN transactions for FI
|
||||
if ( lastInvTransaction != null) {
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
|
||||
// IN
|
||||
// get the stitching account id
|
||||
long stitchedItemId = finishedItem.getStitchedItemId( );
|
||||
InventoryTransactionLeg lastOutTransaction = lastStitchedItemOutTransactionMap.getOrDefault( stitchedItemId, null);
|
||||
createInventoryTransactionLeg( transaction, finishedItem, lastOutTransaction.getAccountId( ), InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||
long stitchedItemId = finishedItem.getStitchedItemId();
|
||||
InventoryTransactionLeg lastOutTransaction = lastStitchedItemOutTransactionMap.getOrDefault(stitchedItemId, null);
|
||||
createInventoryTransactionLeg(transaction, finishedItem, lastOutTransaction.getAccountId(), InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||
finishedItem.setQaStatus("ALTER");
|
||||
finishedItem.setIsSegregated(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* item is not approved and washed is selected then item remain in Finishing account
|
||||
* */
|
||||
if (status.equalsIgnoreCase("WASHED")) {
|
||||
finishedItem.setIsSegregated(false);
|
||||
finishedItem.setQaStatus("WASHED");
|
||||
}
|
||||
|
||||
/*
|
||||
* item is not approved and B grade is selected then item remain in Finishing account because after
|
||||
* alteration item will be moved to A grade account for segregation
|
||||
* */
|
||||
if (status.equalsIgnoreCase("B GRADE")) {
|
||||
finishedItem.setIsSegregated(false);
|
||||
finishedItem.setQaStatus("B GRADE");
|
||||
}
|
||||
|
||||
/*
|
||||
* item is not approved and C grade is selected then item remain in Finishing account because after
|
||||
* alteration item will be moved to A grade account for segregation
|
||||
* */
|
||||
if (status.equalsIgnoreCase("C GRADE")) {
|
||||
finishedItem.setIsSegregated(false);
|
||||
finishedItem.setQaStatus("C GRADE");
|
||||
}
|
||||
|
||||
/*
|
||||
* item is approved and grade is selected then fI is move to grade account
|
||||
*/
|
||||
if ( finishedItem.getQaStatus( ).equalsIgnoreCase( "APPROVED") && finishedItem.getAccountId( ) != 0) {
|
||||
finishedItem.setIsSegregated( true);
|
||||
if (status.equalsIgnoreCase("APPROVED")) {
|
||||
finishedItem.setQaStatus("APPROVED");
|
||||
finishedItem.setIsSegregated(true);
|
||||
}
|
||||
updatedItems.add( finishedItem);
|
||||
updatedItems.add(finishedItem);
|
||||
}
|
||||
// save finish items
|
||||
finishedItemDAO.saveAll( updatedItems);
|
||||
finishedItemDAO.saveAll(updatedItems);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Packaging items
|
||||
* */
|
||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||
public void createPackagingItemAndTransaction( FinishedItemWrapper wrapper) {
|
||||
if ( wrapper != null && wrapper.getItems( ) != null) {
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
|
||||
public void createPackagingItemAndTransaction(FinishedItemWrapper wrapper) {
|
||||
if (wrapper != null && wrapper.getItems() != null) {
|
||||
|
||||
List<FinishedItem> items = wrapper.getItems( );
|
||||
List<FinishedItem> updatedItems = new ArrayList<>( );
|
||||
List<PackagingItems> packagingItems = new ArrayList<>( );
|
||||
List<FinishedItem> items = wrapper.getItems();
|
||||
List<FinishedItem> updatedItems = new ArrayList<>();
|
||||
List<PackagingItems> packagingItems = new ArrayList<>();
|
||||
// finished ids
|
||||
List<Long> finishedItemIds = items.stream( ).map( FinishedItem::getId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> finishedItemIds = items.stream().map(FinishedItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
// stitched ids
|
||||
List<Long> stitchedItemIds = items.stream( ).map( FinishedItem::getStitchedItemId)
|
||||
.collect( Collectors.toList( ));
|
||||
List<Long> stitchedItemIds = items.stream().map(FinishedItem::getStitchedItemId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// find parent doc type last IN transaction map
|
||||
Map<Long, InventoryTransactionLeg> lastFinishedItemIdInTransactionMap = inventoryTransactionLegDAO
|
||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), finishedItemIds, InventoryArtifactType.FINISHED_ITEM.name( ))
|
||||
.stream( )
|
||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), finishedItemIds, InventoryArtifactType.FINISHED_ITEM.name())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||
|
||||
// create transaction
|
||||
InventoryTransaction transaction = createInventoryTransaction( "Against Segregation of Finished Items");
|
||||
InventoryTransaction transaction = createInventoryTransaction("Against Segregation of Finished Items");
|
||||
|
||||
|
||||
// create IN and OUT for all approved items
|
||||
for ( FinishedItem finishedItem : items) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemIdInTransactionMap.getOrDefault( finishedItem.getId( ), null);
|
||||
finishedItem.setIsQa( true);
|
||||
for (FinishedItem finishedItem : items) {
|
||||
InventoryTransactionLeg lastInvTransaction = lastFinishedItemIdInTransactionMap.getOrDefault(finishedItem.getId(), null);
|
||||
finishedItem.setIsQa(true);
|
||||
|
||||
if ( finishedItem.getQaStatus( ).equalsIgnoreCase( "APPROVED") && finishedItem.getIsSegregated( )) {
|
||||
if (finishedItem.getQaStatus().equalsIgnoreCase("APPROVED") && finishedItem.getIsSegregated()) {
|
||||
// create OUT and IN transactions for FI
|
||||
PackagingItems packagingItems1 = (createPackagingItem(finishedItem));
|
||||
packagingItems1.setId(packagingItemsDAO.save(packagingItems1));
|
||||
if ( lastInvTransaction != null) {
|
||||
if (lastInvTransaction != null) {
|
||||
// OUT
|
||||
long fromAccount = lastInvTransaction.getAccountId( );
|
||||
createInventoryTransactionLeg( transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
|
||||
// IN
|
||||
createInventoryTransactionLeg( transaction, packagingItems1, 8, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.PACKAGING.name( ));
|
||||
createInventoryTransactionLeg(transaction, packagingItems1, 8, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.PACKAGING.name());
|
||||
}
|
||||
finishedItem.setIsSegregated( true);
|
||||
finishedItem.setPackaging( true);
|
||||
finishedItem.setIsSegregated(true);
|
||||
finishedItem.setPackaging(true);
|
||||
packagingItems.add(packagingItems1);
|
||||
}
|
||||
updatedItems.add( finishedItem);
|
||||
updatedItems.add(finishedItem);
|
||||
}
|
||||
// save finish items
|
||||
finishedItemDAO.saveAll( updatedItems);
|
||||
finishedItemDAO.saveAll(updatedItems);
|
||||
packagingItemsDAO.saveAll(packagingItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* find item summary by account
|
||||
* */
|
||||
public List<InventorySummary> findItemSummaryByAccountId( long accountId) {
|
||||
return inventoryTransactionLegDAO.findSummaryByAccountId( accountId);
|
||||
public List<InventorySummary> findItemSummaryByAccountId(long accountId) {
|
||||
return inventoryTransactionLegDAO.findSummaryByAccountId(accountId);
|
||||
}
|
||||
|
||||
private PackagingItems createPackagingItem(FinishedItem finishedItem){
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
private PackagingItems createPackagingItem(FinishedItem finishedItem) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
PackagingItems packagingItems = new PackagingItems();
|
||||
packagingItems.setItemId(finishedItem.getItemId());
|
||||
packagingItems.setAccountId(finishedItem.getAccountId());
|
||||
|
@ -687,7 +724,7 @@ public class InventoryService {
|
|||
packagingItems.setSku(finishedItem.getSku());
|
||||
packagingItems.setBarcode(finishedItem.getBarcode());
|
||||
packagingItems.setCreatedAt(LocalDateTime.now());
|
||||
packagingItems.setCreatedBy(authentication.getName( ));
|
||||
packagingItems.setCreatedBy(authentication.getName());
|
||||
packagingItems.setIsQa(finishedItem.getIsQa());
|
||||
packagingItems.setIsSegregated(finishedItem.getIsSegregated());
|
||||
packagingItems.setQaStatus(finishedItem.getQaStatus());
|
||||
|
|
|
@ -213,31 +213,27 @@ public class ReportingService {
|
|||
return new HashMap<>();
|
||||
}else {
|
||||
HashMap<String,Integer> gradingItems = new HashMap<>();
|
||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.getPackagingAccounts();
|
||||
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(Long.parseLong(jobCardID));
|
||||
List<PackagingItems> packagingItems = packagingItemsDAO.findByJobCardId(Long.parseLong(jobCardID));
|
||||
|
||||
List<Long> finishItemsIds = finishedItems.stream()
|
||||
.map(FinishedItem::getId).collect(Collectors.toList());
|
||||
List<FinishedItem> bGradeFinishItemsIds= finishedItems.stream()
|
||||
.filter(item -> "B GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
|
||||
|
||||
List<Long> packagingItemsIds = packagingItems.stream()
|
||||
.map(PackagingItems::getId).collect(Collectors.toList());
|
||||
List<FinishedItem> cGradeFinishItemsIds= finishedItems.stream()
|
||||
.filter(item -> "C GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
|
||||
|
||||
if (finishItemsIds.isEmpty()){
|
||||
List<FinishedItem> aGradeFinishItemsIds= finishedItems.stream()
|
||||
.filter(item -> "APPROVED".equals(item.getQaStatus())).collect(Collectors.toList());
|
||||
|
||||
|
||||
if (finishedItems.isEmpty()){
|
||||
gradingItems.put("A GRADE",0);
|
||||
gradingItems.put("B GRADE",0);
|
||||
gradingItems.put("C GRADE",0);
|
||||
return gradingItems;
|
||||
}else {
|
||||
for (InventoryAccount inventoryAccount : inventoryAccounts){
|
||||
if (inventoryAccount.getIsPackaging()){
|
||||
long totalGradingItems = inventoryTransactionLegDAO.CalculateTotalGradingItems(packagingItemsIds,(int) inventoryAccount.getId());
|
||||
gradingItems.put(inventoryAccount.getTitle(), (int) totalGradingItems);
|
||||
}else {
|
||||
long totalGradingItems = inventoryTransactionLegDAO.CalculateTotalGradingItems(finishItemsIds,(int) inventoryAccount.getId());
|
||||
gradingItems.put(inventoryAccount.getTitle(), (int) totalGradingItems);
|
||||
}
|
||||
}
|
||||
gradingItems.put("B GRADE",bGradeFinishItemsIds.size());
|
||||
gradingItems.put("C GRADE",cGradeFinishItemsIds.size());
|
||||
gradingItems.put("A GRADE",aGradeFinishItemsIds.size());
|
||||
return gradingItems;
|
||||
}
|
||||
}
|
||||
|
@ -386,11 +382,6 @@ public class ReportingService {
|
|||
}
|
||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findByParentEntityTypeAndParentId("PROCESS",6L);
|
||||
|
||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
||||
BigDecimal actualProduction = jobCardItems.stream()
|
||||
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
LocalDateTime startDate = jobCardDAO.find(Long.parseLong(jobCardID)).getCreatedAt();
|
||||
HashMap<String, List<?>> barChartData = new HashMap<>();
|
||||
|
||||
|
@ -437,15 +428,9 @@ public class ReportingService {
|
|||
stitchingList.set(index, stitchingList.get(index) + leg.getQuantity().intValue());
|
||||
}
|
||||
else if ("FINISHED_ITEM".equals(leg.getParentDocumentType()) && (leg.getAccountId().equals(7) || leg.getAccountId().equals(12))) {
|
||||
if (index == 0 || !dateIndexMap.containsKey(dateKey)) {
|
||||
qualityList.set(index, 0);
|
||||
}
|
||||
qualityList.set(index, qualityList.get(index) + leg.getQuantity().intValue());
|
||||
}
|
||||
else if ("PACKAGING".equals(leg.getParentDocumentType()) && inventoryAccounts.stream().anyMatch(e -> e.getId() == leg.getAccountId().longValue())) {
|
||||
if (index == 0 || !dateIndexMap.containsKey(dateKey)) {
|
||||
finishItems.set(index, 0);
|
||||
}
|
||||
finishItems.set(index, finishItems.get(index) + leg.getQuantity().intValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
( async function(){
|
||||
|
||||
(async function () {
|
||||
Vue.prototype.$accounts = window.ctp.accounts;
|
||||
|
||||
Vue.component('finished-item-table',{
|
||||
props : [ 'items' ],
|
||||
Vue.component('finished-item-table', {
|
||||
props: ['items'],
|
||||
methods: {
|
||||
getFormattedDateTime: function (dateTime) {
|
||||
if (!!dateTime) {
|
||||
|
@ -15,8 +14,8 @@
|
|||
this.$emit('remove-item', index)
|
||||
}
|
||||
},
|
||||
template : `
|
||||
<table class="table table-bordered bg-white col-sm-12">
|
||||
template: `
|
||||
<table class="table table-bordered bg-white col-sm-12">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
|
@ -27,68 +26,53 @@
|
|||
<th>Job Card ID</th>
|
||||
<th>Barcode</th>
|
||||
<th>Status</th>
|
||||
<th>Account</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item,index) in items">
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].createdBy'" v-bind:value="item.createdBy">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode" >
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].stitchedItemId'" v-bind:value="item.stitchedItemId">
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isSegregated'" v-bind:value="item.isSegregated">
|
||||
<span> {{item.id}} </span>
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].createdBy'" v-bind:value="item.createdBy">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].stitchedItemId'" v-bind:value="item.stitchedItemId">
|
||||
<input type="hidden" v-bind:name="'items[' + index + '].isSegregated'" v-bind:value="item.isSegregated">
|
||||
<span> {{item.id}} </span>
|
||||
</td>
|
||||
<td> {{item.itemId}} </td>
|
||||
<td> {{item.sku}} </td>
|
||||
<td> {{item.createdBy}} </td>
|
||||
<td> {{ getFormattedDateTime( item.createdAt) }} </td>
|
||||
<td> {{item.jobCardId}}</td>
|
||||
<td> {{ getFormattedDateTime(item.createdAt) }} </td>
|
||||
<td> {{item.jobCardId}} </td>
|
||||
<td> {{item.barcode}} </td>
|
||||
<td>
|
||||
<select class="w-100" required v-bind:name="'items[' + index + '].qaStatus'" v-model="item.qaStatus">
|
||||
<option value="WASHED">WASHED</option>
|
||||
<option value="ALTER">ALTER</option>
|
||||
<option value="APPROVED">APPROVED</option>
|
||||
</select><br>
|
||||
<!-- <textarea class="w-100 mt-1" rows="2" v-model="item.qaRemarks" -->
|
||||
<!-- v-if="item.accountId === '0'" -->
|
||||
<!-- v-bind:name="'items[' + index + '].qaRemarks'"></textarea> -->
|
||||
</td>
|
||||
<span v-if="!item.qaStatus" class="badge badge-danger">NOT PERFORMED</span>
|
||||
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
|
||||
<span v-else-if="item.qaStatus === 'ALTER' || item.qaStatus === 'B GRADE' || item.qaStatus === 'C GRADE' " class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
|
||||
<span v-else-if="item.qaStatus === 'WASHED'" class="font-lg badge badge-APPROVED">{{ item.qaStatus }}</span>
|
||||
<td>
|
||||
<select class="w-100" required v-bind:name="'items[' + index + '].accountId'"
|
||||
v-model="item.accountId"
|
||||
v-bind:disabled="item.qaStatus !== 'APPROVED'"
|
||||
v-bind:required="item.qaStatus === 'APPROVED'">
|
||||
<option v-for="(option,index) in $accounts"
|
||||
v-bind:value="option.id">{{option.title}}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
|
||||
<button type="button" class="btn btn-light" v-on:click="removeItem(index)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
`,
|
||||
|
||||
})
|
||||
`
|
||||
});
|
||||
|
||||
let app = new Vue({
|
||||
el : '#finishedApp',
|
||||
data : {
|
||||
items : []
|
||||
el: '#finishedApp',
|
||||
data: {
|
||||
items: [],
|
||||
QaStatus: 'APPROVED'
|
||||
},
|
||||
methods : {
|
||||
methods: {
|
||||
onItemSelect: function (id, item) {
|
||||
this.items.push(item);
|
||||
},
|
||||
|
@ -100,10 +84,15 @@
|
|||
const uniqueIds = new Set(ids);
|
||||
return ids.length !== uniqueIds.size;
|
||||
},
|
||||
submitWithQaStatus: function (status) {
|
||||
this.QaStatus = status;
|
||||
this.$nextTick(() => {
|
||||
document.getElementById('finishedApp').submit();
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted : function () {
|
||||
console.log( this.$accounts )
|
||||
mounted: function () {
|
||||
console.log(this.$accounts);
|
||||
}
|
||||
})
|
||||
|
||||
})(jQuery)
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
@ -53,7 +53,13 @@
|
|||
<td> {{ getFormattedDateTime( item.createdAt) }} </td>
|
||||
<td> {{item.jobCardId}}</td>
|
||||
<td> {{item.barcode}} </td>
|
||||
<td > {{item.qaStatus}} </td>
|
||||
<td >
|
||||
<span v-if="!item.qaStatus" class="badge badge-danger">NOT PERFORMED</span>
|
||||
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
|
||||
<span v-else-if="item.qaStatus === 'ALTER' || item.qaStatus === 'B GRADE'" class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
|
||||
<span v-else-if="item.qaStatus === 'WASHED'" class="font-lg badge badge-APPROVED">{{ item.qaStatus }}</span>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
|
||||
<i class="bi bi-trash"></i>
|
||||
|
|
|
@ -50,12 +50,10 @@
|
|||
<td> {{item.jobCardId}}</td>
|
||||
<td> {{item.barcode}} </td>
|
||||
<td>
|
||||
<select class="w-100" required v-bind:name="'items[' + index + '].qaStatus'" v-model="item.qaStatus">
|
||||
<option value="APPROVED">APPROVED</option>
|
||||
<option value="REJECT">REJECT</option>
|
||||
</select><br>
|
||||
<textarea class="w-100 mt-1" rows="2" v-model="item.remarks" v-if="item.qaStatus === 'REJECT'" v-bind:name="'items[' + index + '].qaRemarks'"></textarea>
|
||||
</td>
|
||||
<span v-if="!item.qaStatus" class="badge badge-danger">NOT PERFORMED</span>
|
||||
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
|
||||
<span v-else-if="item.qaStatus === 'REJECT'" class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
|
||||
<i class="bi bi-trash"></i>
|
||||
|
@ -72,6 +70,7 @@
|
|||
el: '#qcForm',
|
||||
data: {
|
||||
items: [],
|
||||
QaStatus: 'APPROVED'
|
||||
},
|
||||
methods: {
|
||||
onItemSelect: function (id, item) {
|
||||
|
@ -86,6 +85,12 @@
|
|||
const uniqueIds = new Set(ids);
|
||||
return ids.length !== uniqueIds.size;
|
||||
},
|
||||
submitWithQaStatus: function (status) {
|
||||
this.QaStatus = status;
|
||||
this.$nextTick(() => {
|
||||
document.getElementById('qcForm').submit();
|
||||
});
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
|
||||
|
|
|
@ -1,54 +1,70 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
|
||||
xmlns:v-bind="http://www.w3.org/1999/xhtml">
|
||||
<head th:replace="_fragments :: head('Segregate Finished Items')"></head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
||||
<main class="row page-main">
|
||||
<div class="col-sm">
|
||||
<div class="mb-4 d-flex justify-content-between">
|
||||
<h3>Segregate Finished Items</h3>
|
||||
<head th:replace="_fragments :: head('Segregate Finished Items')"></head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
||||
<main class="row page-main">
|
||||
<div class="col-sm">
|
||||
<div class="mb-4 d-flex justify-content-between">
|
||||
<h3>Segregate Finished Items</h3>
|
||||
</div>
|
||||
<form th:action="'/ctp/finishing/segregate-inventory'" method="post" id="finishedApp">
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-3 form-group">
|
||||
<search-item
|
||||
url="/ctp/rest/finished-items/search"
|
||||
v-on:finished-item-select="onItemSelect">
|
||||
</search-item>
|
||||
</div>
|
||||
<div class="col-sm-3 form-group">
|
||||
<!-- <label>Packaging Account</label>-->
|
||||
<!-- <select class="form-control" name="account-id" th:field="*{finishedAccountId}" required>-->
|
||||
<!-- <option value="">PLease select</option>-->
|
||||
<!-- <option th:each="account : ${accounts}"-->
|
||||
<!-- th:value="${account.id}"-->
|
||||
<!-- th:text="${account.title}"></option>-->
|
||||
<!-- </select>-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<form th:action="'/ctp/finishing/segregate-inventory'" method="post" id="finishedApp">
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-3 form-group">
|
||||
<search-item
|
||||
url="/ctp/rest/finished-items/search"
|
||||
v-on:finished-item-select="onItemSelect">
|
||||
</search-item>
|
||||
</div>
|
||||
<div class="col-sm-3 form-group">
|
||||
<!-- <label>Packaging Account</label>-->
|
||||
<!-- <select class="form-control" name="account-id" th:field="*{finishedAccountId}" required>-->
|
||||
<!-- <option value="">PLease select</option>-->
|
||||
<!-- <option th:each="account : ${accounts}"-->
|
||||
<!-- th:value="${account.id}"-->
|
||||
<!-- th:text="${account.title}"></option>-->
|
||||
<!-- </select>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<h6 class="mb-3">Finished Items</h6>
|
||||
<finished-item-table
|
||||
v-bind:items="items"
|
||||
v-on:remove-item="removeItem"
|
||||
></finished-item-table>
|
||||
</div>
|
||||
<div class="alert alert-danger" v-if="hasDuplicates()" >Duplicate Item Selected</div>
|
||||
<button class="btn btn-primary" type="submit" v-bind:disabled="hasDuplicates()">Submit</button>
|
||||
<a th:href="@{/finishing/finished-items}" class="btn btn-light">Cancel</a>
|
||||
</form>
|
||||
<script th:inline="javascript">
|
||||
window.ctp.accounts = [[${accounts}]];
|
||||
</script>
|
||||
<script th:src="@{/js/vendor/compressor.min.js}"></script>
|
||||
<script th:src="@{/js/finishing/finished-item-segregation-form.js}"></script>
|
||||
<input type="hidden" name="qaStatus" v-model="QaStatus">
|
||||
</div>
|
||||
</main>
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<h6 class="mb-3">Finished Items</h6>
|
||||
<finished-item-table
|
||||
v-bind:items="items"
|
||||
v-on:remove-item="removeItem"
|
||||
></finished-item-table>
|
||||
</div>
|
||||
<div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Item Selected</div>
|
||||
<button class="btn btn-primary mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('APPROVED')">APPROVED
|
||||
</button>
|
||||
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('ALTER')">ALTER
|
||||
</button>
|
||||
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('B GRADE')">B GRADE
|
||||
</button>
|
||||
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('C GRADE')">C GRADE
|
||||
</button>
|
||||
<button class="btn btn-success mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('WASHED')">WASHED
|
||||
</button>
|
||||
<a th:href="@{/finishing/finished-items}" class="btn btn-light">Cancel</a>
|
||||
</form>
|
||||
<script th:inline="javascript">
|
||||
window.ctp.accounts = [[${accounts}]];
|
||||
</script>
|
||||
<script th:src="@{/js/vendor/compressor.min.js}"></script>
|
||||
<script th:src="@{/js/finishing/finished-item-segregation-form.js}"></script>
|
||||
</div>
|
||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
||||
</body>
|
||||
</main>
|
||||
</div>
|
||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,55 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
|
||||
xmlns:v-bind="http://www.w3.org/1999/xhtml">
|
||||
<head th:replace="_fragments :: head('Home Page')"></head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
||||
<main class="row page-main">
|
||||
<div class="col-sm">
|
||||
<div class="mb-4 d-flex justify-content-between">
|
||||
<h3>Add Stitched Offline Items For QC</h3>
|
||||
<head th:replace="_fragments :: head('Home Page')"></head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
||||
<main class="row page-main">
|
||||
<div class="col-sm">
|
||||
<div class="mb-4 d-flex justify-content-between">
|
||||
<h3>Add Stitched Offline Items For QC</h3>
|
||||
</div>
|
||||
<form th:action="'/ctp/quality-control/qc-finished-item'" method="post" id="qcForm"
|
||||
th:object="${wrapper}">
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-3 form-group">
|
||||
<search-item
|
||||
label="Search Stitch Item"
|
||||
url="/ctp/rest/stitching-offline-items/search"
|
||||
v-on:finished-item-select="onItemSelect">
|
||||
</search-item>
|
||||
</div>
|
||||
<input type="hidden" name="qaStatus" v-model="QaStatus">
|
||||
<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 th:each="account : ${accounts}"
|
||||
th:value="${account.id}"
|
||||
th:text="${account.title}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<form th:action="'/ctp/quality-control/qc-finished-item'" method="post" id="qcForm"
|
||||
th:object="${wrapper}">
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-3 form-group">
|
||||
<search-item
|
||||
label="Search Stitch Item"
|
||||
url="/ctp/rest/stitching-offline-items/search"
|
||||
v-on:finished-item-select="onItemSelect">
|
||||
</search-item>
|
||||
</div>
|
||||
<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 th:each="account : ${accounts}"
|
||||
th:value="${account.id}"
|
||||
th:text="${account.title}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<h6 class="mb-3">Stitched Items</h6>
|
||||
<stitched-item-table
|
||||
v-bind:items="items"
|
||||
v-on:remove-item="removeItem">
|
||||
</stitched-item-table>
|
||||
</div>
|
||||
<div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Item Selected</div>
|
||||
<button class="btn btn-primary" type="submit" v-bind:disabled="hasDuplicates()">Submit</button>
|
||||
<a th:href="@{/quality-control/qc-finished-items}" class="btn btn-light">Cancel</a>
|
||||
</form>
|
||||
<script th:inline="javascript">
|
||||
</script>
|
||||
<script th:src="@{/js/vendor/compressor.min.js}"></script>
|
||||
<script th:src="@{/js/qc/finished-items-qc-form.js}"></script>
|
||||
</div>
|
||||
</main>
|
||||
<div class="bg-light p-3 mb-3">
|
||||
<h6 class="mb-3">Stitched Items</h6>
|
||||
<stitched-item-table
|
||||
v-bind:items="items"
|
||||
v-on:remove-item="removeItem">
|
||||
</stitched-item-table>
|
||||
</div>
|
||||
<div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Item Selected</div>
|
||||
<button class="btn btn-primary mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('APPROVED')">APPROVED
|
||||
</button>
|
||||
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
|
||||
@click="submitWithQaStatus('REJECT')">REJECT
|
||||
</button>
|
||||
<a th:href="@{/quality-control/qc-finished-items}" class="btn btn-light">Cancel</a>
|
||||
</form>
|
||||
<script th:inline="javascript">
|
||||
</script>
|
||||
<script th:src="@{/js/vendor/compressor.min.js}"></script>
|
||||
<script th:src="@{/js/qc/finished-items-qc-form.js}"></script>
|
||||
</div>
|
||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
||||
</body>
|
||||
</main>
|
||||
</div>
|
||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue