diff --git a/pom.xml b/pom.xml index a214b33..afc29ab 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,12 @@ org.thymeleaf.extras thymeleaf-extras-java8time + + org.apache.pdfbox + pdfbox + 2.0.30 + compile + org.thymeleaf.extras thymeleaf-extras-springsecurity5 diff --git a/src/main/java/com/utopiaindustries/controller/StitchingController.java b/src/main/java/com/utopiaindustries/controller/StitchingController.java index 58c83f7..486d91e 100644 --- a/src/main/java/com/utopiaindustries/controller/StitchingController.java +++ b/src/main/java/com/utopiaindustries/controller/StitchingController.java @@ -1,11 +1,9 @@ package com.utopiaindustries.controller; import com.utopiaindustries.auth.StitchingRole; -import com.utopiaindustries.model.ctp.JobCard; -import com.utopiaindustries.model.ctp.StitchingOfflineItem; +import com.utopiaindustries.model.ctp.*; import com.utopiaindustries.service.*; import com.utopiaindustries.util.StringUtils; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @@ -111,17 +109,17 @@ public class StitchingController { @GetMapping( "/create-stitching-items") public String createFinishItems( Model model ){ model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) ); - model.addAttribute("jobCard", jobCardService.createNewJobCard() ); - return "/stitching/stitching-item-form"; + model.addAttribute("bundleWrapper", new BundleWrapper() ); + return "/stitching/stitching-item-form"; } @PostMapping( "/create-stitching-items" ) - public String createStitchedOfflineItems( @ModelAttribute JobCard jobCard, + public String createStitchedOfflineItems( @ModelAttribute BundleWrapper bundleWrapper, RedirectAttributes redirectAttributes, Model model ){ try { - inventoryService.createStitchingOfflineItemsFromJobCard( jobCard ); - redirectAttributes.addFlashAttribute("success", "Finished Item Created Successfully"); + inventoryService.createStitchingOfflineItemsFromJobCard( bundleWrapper ); + redirectAttributes.addFlashAttribute("success", "Stitch Items Created Successfully"); } catch ( Exception exception ){ exception.printStackTrace(); redirectAttributes.addFlashAttribute( "error", exception.getMessage() ); diff --git a/src/main/java/com/utopiaindustries/dao/ctp/BundleDAO.java b/src/main/java/com/utopiaindustries/dao/ctp/BundleDAO.java index c543a67..90e0121 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/BundleDAO.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/BundleDAO.java @@ -21,13 +21,14 @@ public class BundleDAO { 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 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, wrap_quantity, barcode, type, created_by, created_at, job_card_id, master_bundle_id) VALUES (:id, :item_id, :sku, :wrap_quantity, :barcode, :type, :created_by, :created_at, :job_card_id, :master_bundle_id) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), wrap_quantity = VALUES(wrap_quantity), barcode = VALUES(barcode), type = VALUES(type), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), master_bundle_id = VALUES(master_bundle_id)", TABLE_NAME ); + private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, wrap_quantity, barcode, type, created_by, created_at, job_card_id, master_bundle_id, production) VALUES (:id, :item_id, :sku, :wrap_quantity, :barcode, :type, :created_by, :created_at, :job_card_id, :master_bundle_id, :production) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), wrap_quantity = VALUES(wrap_quantity), barcode = VALUES(barcode), type = VALUES(type), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), master_bundle_id = VALUES(master_bundle_id), production = VALUES(production)", TABLE_NAME ); private final String SELECT_BY_TERM_QUERY = String.format( "SELECT * FROM %s WHERE (id = :id OR sku LIKE :sku OR type LIKE :type OR barcode LIKE :barcode) AND master_bundle_id =0", 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_MASTER_ID = String.format( "SELECT * FROM %s WHERE master_bundle_id = :master_bundle_id ORDER BY id DESC", TABLE_NAME ); private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME ); private final String SELECT_BY_ITEM_ID_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id = :item_id AND job_card_id = :job_card_id", TABLE_NAME ); private final String SELECT_BY_ITEM_IDS_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id IN (:item_ids) AND job_card_id = :job_card_id", TABLE_NAME ); + private final String SELECT_LIKE_BARCODE = String.format("SELECT * FROM %s WHERE barcode LIKE :barcode", TABLE_NAME); public BundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) { @@ -40,6 +41,7 @@ public class BundleDAO { params.addValue( "id", bundle.getId() ) .addValue( "item_id", bundle.getItemId() ) .addValue( "sku", bundle.getSku() ) + .addValue("production",bundle.getProduction()) .addValue( "wrap_quantity", bundle.getWrapQuantity() ) .addValue( "barcode", bundle.getBarcode() ) .addValue( "type", bundle.getType() ) @@ -61,6 +63,12 @@ public class BundleDAO { } + public List findByBarcodeLike(String barcode) { + MapSqlParameterSource params = new MapSqlParameterSource(); + params.addValue("barcode", "%" + barcode + "%"); + return namedParameterJdbcTemplate.query(SELECT_LIKE_BARCODE, params, new BundleRowMapper()); + } + // find all public List findAll() { return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() ); diff --git a/src/main/java/com/utopiaindustries/dao/ctp/BundleRowMapper.java b/src/main/java/com/utopiaindustries/dao/ctp/BundleRowMapper.java index bdeb042..a2107af 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/BundleRowMapper.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/BundleRowMapper.java @@ -16,6 +16,7 @@ public class BundleRowMapper implements RowMapper { bundle.setBarcode( rs.getString( "barcode" ) ); bundle.setType( rs.getString( "type" ) ); bundle.setCreatedBy( rs.getString( "created_by" ) ); + bundle.setProduction(rs.getBigDecimal("production")); if ( rs.getTimestamp( "created_at" ) != null ) { bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() ); } diff --git a/src/main/java/com/utopiaindustries/dao/ctp/JobCardItemDAO.java b/src/main/java/com/utopiaindustries/dao/ctp/JobCardItemDAO.java index 8cf2b09..d4b3327 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/JobCardItemDAO.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/JobCardItemDAO.java @@ -1,6 +1,7 @@ package com.utopiaindustries.dao.ctp; import com.utopiaindustries.model.ctp.JobCardItem; +import com.utopiaindustries.model.ctp.MasterBundle; import com.utopiaindustries.util.KeyHolderFunctions; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; @@ -22,6 +23,7 @@ public class JobCardItemDAO { private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME ); private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME ); private final String SELECT_BY_CARD_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id", TABLE_NAME ); + private final String SELECT_BY_CARD_ID_AND_ITEM_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id AND item_id = :item_id ", TABLE_NAME ); private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, job_card_id, item_id, sku, expected_production, actual_production, total_production, account_id, length, width, gsm, wt_ply, ply) VALUES (:id, :job_card_id, :item_id, :sku, :expected_production, :actual_production, :total_production, :account_id, :length, :width, :gsm, :wt_ply, :ply) ON DUPLICATE KEY UPDATE job_card_id = VALUES(job_card_id), item_id = VALUES(item_id), sku = VALUES(sku), expected_production = VALUES(expected_production), actual_production = VALUES(actual_production), total_production = VALUES(total_production), account_id = VALUES(account_id), length = VALUES(length), width = VALUES(width), gsm = VALUES(gsm), wt_ply = VALUES(wt_ply), ply = VALUES(ply) ", TABLE_NAME ); private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME ); private final String SELECT_BY_JOB_CARD_AND_ACCOUNT_IDS = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND actual_production = :actual_production AND account_id IN (:account_ids)", TABLE_NAME ); @@ -95,6 +97,15 @@ public class JobCardItemDAO { return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID, params, new JobCardItemRowMapper() ); } + public JobCardItem findByCardIdAndItemId( long cardId,long itemItem ){ + MapSqlParameterSource params = new MapSqlParameterSource(); + params.addValue( "card_id", cardId ); + params.addValue("item_id",itemItem); + return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID_AND_ITEM_ID, params, new JobCardItemRowMapper() ).stream() + .findFirst() + .orElse( new JobCardItem() ); + } + public List findByIds( List ids ){ MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue( "ids", ids ); diff --git a/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleDAO.java b/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleDAO.java index d0dba4d..c8143d6 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleDAO.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleDAO.java @@ -20,10 +20,12 @@ public class MasterBundleDAO { 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 DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME ); - private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, barcode,item_id, sku, created_by, created_at, job_card_id, is_received) VALUES (:id, :barcode, :item_id, :sku, :created_by, :created_at, :job_card_id, :is_received) ON DUPLICATE KEY UPDATE barcode = VALUES(barcode), item_id = VALUES(item_id), sku = VALUES(sku), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), is_received = VALUES(is_received)", TABLE_NAME ); + private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, barcode,item_id, sku, created_by, created_at, job_card_id, account_id, is_received) VALUES (:id, :barcode, :item_id, :sku, :created_by, :created_at, :job_card_id, :account_id, :is_received) ON DUPLICATE KEY UPDATE barcode = VALUES(barcode), item_id = VALUES(item_id), sku = VALUES(sku), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), is_received = VALUES(is_received), account_id = VALUES(account_id) ", 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_TERM_AND_RECEIVED = String.format( "SELECT * FROM %s WHERE is_received = :is_received AND ( id LIKE :id OR barcode LIKE :barcode ) ", TABLE_NAME ); private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME ); + private final String SELECT_BY_IDS_AND_RECIEVE = String.format( "SELECT id FROM %s WHERE id IN (:ids) AND is_received = true", TABLE_NAME ); + public MasterBundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) { @@ -37,6 +39,7 @@ public class MasterBundleDAO { .addValue( "barcode", masterBundle.getBarcode() ) .addValue( "item_id", masterBundle.getItemId() ) .addValue( "sku", masterBundle.getSku() ) + .addValue( "account_id", masterBundle.getAccountId() ) .addValue( "created_by", masterBundle.getCreatedBy() ) .addValue( "created_at", masterBundle.getCreatedAt() ) .addValue( "job_card_id", masterBundle.getJobCardId() ) @@ -54,6 +57,13 @@ public class MasterBundleDAO { .orElse( new MasterBundle() ); } + // find all + public List findByIdAndReceiveIsTrue(List ids) { + MapSqlParameterSource params = new MapSqlParameterSource(); + params.addValue( "ids", ids ); + return namedParameterJdbcTemplate.query(SELECT_BY_IDS_AND_RECIEVE, params, (rs, rowNum) -> rs.getLong("id")); + } + // find all public List findAll() { return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() ); diff --git a/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleRowMapper.java b/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleRowMapper.java index c28f4b0..d78a611 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleRowMapper.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/MasterBundleRowMapper.java @@ -14,6 +14,7 @@ public class MasterBundleRowMapper implements RowMapper { masterBundle.setCreatedBy( rs.getString( "created_by" ) ); masterBundle.setItemId( rs.getLong("item_id" )); masterBundle.setSku( rs.getString("sku" ) ); + masterBundle.setAccountId(rs.getLong("account_id")); if ( rs.getTimestamp( "created_at" ) != null ) { masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() ); } diff --git a/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemDAO.java b/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemDAO.java index b58b11c..ee5670c 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemDAO.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemDAO.java @@ -22,7 +22,7 @@ public class StitchingOfflineItemDAO { private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME ); private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME ); private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME ); - private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status)", TABLE_NAME ); + private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status,bundle_id) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status, :bundle_id) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status), bundle_id = VALUES(bundle_id)", TABLE_NAME ); private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME ); private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME ); private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME ); @@ -40,6 +40,7 @@ public class StitchingOfflineItemDAO { .addValue( "item_id", stitchingOfflineItem.getItemId() ) .addValue( "sku", stitchingOfflineItem.getSku() ) .addValue( "barcode", stitchingOfflineItem.getBarcode() ) + .addValue("bundle_id",stitchingOfflineItem.getBundleId()) .addValue( "created_at", stitchingOfflineItem.getCreatedAt() ) .addValue( "created_by", stitchingOfflineItem.getCreatedBy() ) .addValue("job_card_id", stitchingOfflineItem.getJobCardId() ) diff --git a/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemRowMapper.java b/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemRowMapper.java index adb9b90..baf4c2a 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemRowMapper.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/StitchingOfflineItemRowMapper.java @@ -15,6 +15,7 @@ public class StitchingOfflineItemRowMapper implements RowMapper bundles = new ArrayList<>(); // ✅ Initialize List + + public List getBundles() { + return bundles; + } + + public void setBundles(List bundles) { + this.bundles = bundles; + } +} diff --git a/src/main/java/com/utopiaindustries/model/ctp/FinishedItem.java b/src/main/java/com/utopiaindustries/model/ctp/FinishedItem.java index baf43be..d817f97 100644 --- a/src/main/java/com/utopiaindustries/model/ctp/FinishedItem.java +++ b/src/main/java/com/utopiaindustries/model/ctp/FinishedItem.java @@ -150,6 +150,10 @@ public class FinishedItem implements InventoryArtifact { return 0; } + public long getBundleId(){ + return 0; + } + @Override public String toString() { return "FinishedItem{" + diff --git a/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifact.java b/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifact.java index 6d5e1a8..74b6777 100644 --- a/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifact.java +++ b/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifact.java @@ -15,4 +15,5 @@ public interface InventoryArtifact { LocalDateTime getCreatedAt(); BigDecimal getWrapQuantity(); long getMasterBundleId(); + long getBundleId(); } diff --git a/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifactType.java b/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifactType.java index cd43cdc..45fb996 100644 --- a/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifactType.java +++ b/src/main/java/com/utopiaindustries/model/ctp/InventoryArtifactType.java @@ -3,5 +3,7 @@ package com.utopiaindustries.model.ctp; public enum InventoryArtifactType { BUNDLE, STITCHING_OFFLINE, - FINISHED_ITEM + FINISHED_ITEM, + STITCH_BUNDLE + } diff --git a/src/main/java/com/utopiaindustries/model/ctp/MasterBundle.java b/src/main/java/com/utopiaindustries/model/ctp/MasterBundle.java index 316fabc..b3136f5 100644 --- a/src/main/java/com/utopiaindustries/model/ctp/MasterBundle.java +++ b/src/main/java/com/utopiaindustries/model/ctp/MasterBundle.java @@ -14,6 +14,8 @@ public class MasterBundle implements InventoryArtifact{ private LocalDateTime createdAt; private boolean isReceived; private long jobCardId; + private long accountId; + // wrapper private List bundles; private List items; @@ -111,6 +113,18 @@ public class MasterBundle implements InventoryArtifact{ this.items = items; } + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + public long getBundleId(){ + return 0; + } + @Override public String toString() { return "MasterBundle{" + diff --git a/src/main/java/com/utopiaindustries/model/ctp/StitchingOfflineItem.java b/src/main/java/com/utopiaindustries/model/ctp/StitchingOfflineItem.java index cc82f7a..3a7f61d 100644 --- a/src/main/java/com/utopiaindustries/model/ctp/StitchingOfflineItem.java +++ b/src/main/java/com/utopiaindustries/model/ctp/StitchingOfflineItem.java @@ -18,6 +18,7 @@ public class StitchingOfflineItem implements InventoryArtifact { private boolean isQa; private String qaRemarks; private String qaStatus; + private long bundleId; @Override public String getType() { @@ -116,6 +117,14 @@ public class StitchingOfflineItem implements InventoryArtifact { return 0; } + public long getBundleId() { + return bundleId; + } + + public void setBundleId(long bundleId) { + this.bundleId = bundleId; + } + @Override public String toString() { return "StitchingOfflineItem{" + diff --git a/src/main/java/com/utopiaindustries/restcontroller/BundleRestController.java b/src/main/java/com/utopiaindustries/restcontroller/BundleRestController.java index 8dd347e..46bc001 100644 --- a/src/main/java/com/utopiaindustries/restcontroller/BundleRestController.java +++ b/src/main/java/com/utopiaindustries/restcontroller/BundleRestController.java @@ -34,4 +34,13 @@ public class BundleRestController { return bundleService.findBundlesByMasterId( masterId ); } + @GetMapping( "/find-bundle-by-id/{id}" ) + public Bundle findBundleById( @PathVariable("id") long id ){ + return bundleService.getBundlesById(id); + } + + @GetMapping( "/find-bundle-by-barcode" ) + public List findByMasterBarcode(@RequestParam String term ){ + return bundleService.getBundles( term ); + } } diff --git a/src/main/java/com/utopiaindustries/service/BarcodeService.java b/src/main/java/com/utopiaindustries/service/BarcodeService.java index a2aa58b..8883dce 100644 --- a/src/main/java/com/utopiaindustries/service/BarcodeService.java +++ b/src/main/java/com/utopiaindustries/service/BarcodeService.java @@ -1,9 +1,7 @@ package com.utopiaindustries.service; import com.google.zxing.BarcodeFormat; -import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.kernel.colors.ColorConstants; -import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.layout.element.AreaBreak; @@ -18,6 +16,8 @@ import com.zebra.sdk.comm.TcpConnection; import com.zebra.sdk.graphics.internal.ZebraImage; import com.zebra.sdk.printer.ZebraPrinter; import com.zebra.sdk.printer.ZebraPrinterFactory; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.PDFRenderer; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.itextpdf.io.image.ImageDataFactory; @@ -31,16 +31,11 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.nio.file.Path; import java.nio.file.FileSystems; -import javax.imageio.ImageIO; import java.awt.*; import java.awt.Font; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; import java.io.*; -import java.nio.file.FileSystems; -import java.nio.file.Path; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -106,15 +101,11 @@ public class BarcodeService { public void getBarcodeImages(List artifacts, BarcodeStickerSize stickerSize, String artifactType) throws Exception { - - int pageWidth = 900; // A4 Width int pageHeight = 1200; // A4 Height - int rows = 3; int cols = 2; int totalStickersPerPage = rows * cols; - int totalPages = (int) Math.ceil((double) artifacts.size() / totalStickersPerPage); // Total required pages for (int page = 0; page < totalPages; page++) { @@ -126,7 +117,6 @@ public class BarcodeService { g2d.fillRect(0, 0, pageWidth, pageHeight); g2d.setColor(Color.BLACK); - Font barcodeFont = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+8); Font detailFont = new Font("Helvetica", Font.PLAIN, stickerSize.getTextSize()+3); @@ -154,7 +144,6 @@ public class BarcodeService { int textWidth = fontMetrics.stringWidth(sku); g2d.drawString(sku, x + ((pageWidth / cols) - textWidth) / 2, y + fontMetrics.getAscent()+ stickerSize.getMarginTop()+10); - // Generate Barcode Image g2d.setFont(barcodeFont); byte[] imgBytes = BarcodeUtils.getBarcodeImageByteArray( @@ -188,6 +177,7 @@ public class BarcodeService { int barcodeText = fontMetrics.stringWidth(barcode); g2d.drawString(barcode, (x + ((pageWidth / cols) - barcodeText) / 2), y + barcodeFontMatrix.getAscent() + stickerSize.getMarginTop() + 120); + //draw item-id DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm"); this.drawCenteredText(g2d, "Item-ID: "+artifact.getItemId(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 150,stickerSize.getMarginLeft()); this.drawCenteredText(g2d, "Created-By: "+artifact.getCreatedBy(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 170,stickerSize.getMarginLeft()); @@ -213,22 +203,17 @@ public class BarcodeService { this.drawCenteredText(g2d, "Sub-Bundles: " + concatenatedIds, detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 290, stickerSize.getMarginLeft()); } - this.drawCenteredText(g2d, String.valueOf(artifact.getId()), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 330, 0); - } // Finalize Drawing g2d.dispose(); - - // Save A4 Page as PNG Path path = FileSystems.getDefault().getPath("./src/main/resources/static/barcode_a4_" + (page + 1) + ".png"); File outputFile = path.toFile(); ImageIO.write(a4Image, "PNG", outputFile); } } - //use for detail heading private void drawCenteredText(Graphics2D g2d, String text, Font font, int x, int y, int pageWidth, int cols, int marginTop, int marginLeft) { g2d.setFont(font); FontMetrics fontMetrics = g2d.getFontMetrics(); @@ -244,48 +229,37 @@ public class BarcodeService { Path pdfPath = FileSystems.getDefault().getPath("./src/main/resources/static/sample_qr_output.pdf"); PdfWriter writer = new PdfWriter(pdfPath.toFile()); - PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc); - pdfDoc.setDefaultPageSize(new PageSize(stickerSize.getWidth(), stickerSize.getHeight())); for (InventoryArtifact artifact : artifacts) { JobCard jobCard = jobCardDAO.find(artifact.getJobCardId()); - List bundles = bundleDAO.findByItemIdAndCardId(artifact.getItemId(), jobCard.getId()); - String concatenatedIds = bundles.stream() - .map(bundle -> String.valueOf(bundle.getId())) - .collect(Collectors.joining("\\")); - // **Add New Page for Each Artifact** PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); - - // **Set Background White** canvas.setFillColor(ColorConstants.WHITE); canvas.rectangle(0, 0, stickerSize.getWidth(), stickerSize.getHeight()); canvas.fill(); - // **Draw QR Code on Left Side** + // Draw QR Code on Left Side** byte[] imgBytes = generateQRCodeImageByteArray(artifact.getBarcode(), stickerSize.getImageWidthBarcode(), stickerSize.getImageHeightBarcode()); Image qrCodeImage = new Image(ImageDataFactory.create(imgBytes)); - float qrX =stickerSize.getMarginLeft() ; - float qrY = stickerSize.getMarginTop(); + float qrY =stickerSize.getMarginLeft()+50 ; + float qrX = stickerSize.getMarginTop(); - qrCodeImage.setFixedPosition(qrX + 15, qrY-12); + qrCodeImage.setFixedPosition(qrX - 16, qrY-47); document.add(qrCodeImage); - float textX = stickerSize.getMarginLeft() + 40; float textY = stickerSize.getMarginTop() +40; - // **Prepare Text Lines** String sku = artifact.getSku(); String jobCardCode = jobCard.getCode(); - String combinedText = sku + " \\" + jobCardCode + concatenatedIds; + String combinedText = sku + " \\ " + jobCardCode + " \\ " + artifact.getBundleId(); - int maxLength = 16; + int maxLength = 14; List lines = new ArrayList<>(); for (int i = 0; i < 3; i++) { int start = i * maxLength; @@ -295,63 +269,75 @@ public class BarcodeService { } } - // **Draw Rotated Text to the Right of QR Code** - float lineX = textX-30; + float textY1 = textY-30; for (String line : lines) { Paragraph rotatedText = new Paragraph(line) - .setBold() - .setFontColor(ColorConstants.BLACK) // ✅ Text Color - .setFontSize(stickerSize.getTextSize()) + .setFontColor(ColorConstants.BLACK) + .setFontSize((float) (stickerSize.getTextSize()+2)) .setTextAlignment(TextAlignment.LEFT) - .setFixedPosition( lineX, textY+5, 200) - .setRotationAngle(-Math.PI / 2); // ✅ -90 Degree Rotate + .setFixedPosition( textX-48, textY1-18, 220); document.add(rotatedText); - lineX -= 5; // ✅ Line Gap + textY1 -= 6; } String id = String.valueOf(artifact.getId()); document.add(new Paragraph(id) - .setFontSize(stickerSize.getTextSize()) - .setBold() - .setRotationAngle(-Math.PI / 2) + .setFontColor(ColorConstants.BLACK) + .setFontSize(stickerSize.getTextSize()+6) .setTextAlignment(TextAlignment.LEFT) - .setFixedPosition(textX + 30, textY-16, 100)); + .setFixedPosition(textX-21, textY + 10, 140)); - float dottedLine = textY - 50; + float dottedLine = textY - 60; for(int i= 0 ;i<16;i++){ document.add(new Paragraph("|") .setFontSize(stickerSize.getTextSize()) + .setFontColor(ColorConstants.BLACK) .setBold() + .setRotationAngle(-Math.PI / 2) // ✅ -90 Degree Rotate .setTextAlignment(TextAlignment.LEFT) - .setFixedPosition(textX + 47, dottedLine, 100)); + .setFixedPosition(dottedLine,textX+40, 100)); - dottedLine += 10; + dottedLine += 7; } + float dottedLine2 = textY - 60; + for(int i= 0 ;i<16;i++){ + document.add(new Paragraph("|") + .setFontSize(stickerSize.getTextSize()) + .setFontColor(ColorConstants.BLACK) + .setBold() + .setRotationAngle(-Math.PI / 2) // ✅ -90 Degree Rotate + .setTextAlignment(TextAlignment.LEFT) + .setFixedPosition(dottedLine2,textX+75, 100)); + dottedLine2 += 7; + } - document.add(new AreaBreak()); + if (artifact != artifacts.get(artifacts.size() - 1)) { + document.add(new AreaBreak()); + } } - document.close(); + sendPdfToZebraPrinter(pdfPath.toFile()); } - - + public void sendPdfToZebraPrinter(File pdfFile) throws Exception { + PDDocument pdDocument = PDDocument.load(pdfFile); + PDFRenderer renderer = new PDFRenderer(pdDocument); + for (int pageIndex = 0; pageIndex < pdDocument.getNumberOfPages(); pageIndex++) { + BufferedImage pageImage = renderer.renderImageWithDPI(pageIndex, 320); + printLabel(pageImage); + } + pdDocument.close(); + } public byte[] generateQRCodeImageByteArray(String data, int width, int height) { try { QRCodeWriter qrCodeWriter = new QRCodeWriter(); - - // QR Code generation settings Map hintMap = new HashMap<>(); hintMap.put(EncodeHintType.MARGIN, 1); // Optional: control margin size - - // Generate QR code matrix BitMatrix bitMatrix = qrCodeWriter.encode(data, BarcodeFormat.QR_CODE, width, height, hintMap); - - // Convert BitMatrix to BufferedImage BufferedImage qrImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); qrImage.createGraphics().fillRect(0, 0, width, height); diff --git a/src/main/java/com/utopiaindustries/service/BundleService.java b/src/main/java/com/utopiaindustries/service/BundleService.java index 65e0110..2fc7b36 100644 --- a/src/main/java/com/utopiaindustries/service/BundleService.java +++ b/src/main/java/com/utopiaindustries/service/BundleService.java @@ -15,9 +15,11 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service public class BundleService { @@ -54,6 +56,35 @@ public class BundleService { return bundles; } + /* + * find bundle by id + * */ + public Bundle getBundlesById( long id){ + return bundleDAO.find(id); + } + + /* + * find bundle by barcode + * */ + public List getBundles( String barcode){ + List bundles = new ArrayList<>(); + List fetchBundle = bundleDAO.findByBarcodeLike( barcode ); + List ids = fetchBundle.stream() + .map(Bundle::getMasterBundleId) + .distinct() + .collect(Collectors.toList()); + if(!ids.isEmpty()){ + List masterBundles = masterBundleDAO.findByIdAndReceiveIsTrue(ids); + bundles = fetchBundle.stream() + .filter(e -> masterBundles.contains(e.getMasterBundleId()) + && e.getWrapQuantity().compareTo( + e.getProduction() != null ? e.getProduction() : BigDecimal.ZERO) != 0) + .collect(Collectors.toList()); + } + + return bundles; + } + /* * find master bundles by params * */ @@ -109,7 +140,6 @@ public class BundleService { return stitchingOfflineItems; } - /* * * */ diff --git a/src/main/java/com/utopiaindustries/service/InventoryService.java b/src/main/java/com/utopiaindustries/service/InventoryService.java index f469fbb..2afd17b 100644 --- a/src/main/java/com/utopiaindustries/service/InventoryService.java +++ b/src/main/java/com/utopiaindustries/service/InventoryService.java @@ -2,6 +2,7 @@ package com.utopiaindustries.service; import com.utopiaindustries.dao.ctp.*; import com.utopiaindustries.model.ctp.*; +import com.utopiaindustries.model.ctp.BundleWrapper; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; @@ -90,7 +91,7 @@ public class InventoryService { for ( JobCardItem jobCardItem : items) { // create + save bundles - List bundles = createBundles( jobCardItem, piecesMap.get( jobCardItem.getId( ) ) ); + List bundles = createBundles( jobCardItem, piecesMap.get( jobCardItem.getId( ) ),jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) ); // create transactions createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( )); jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) ); @@ -155,10 +156,12 @@ public class InventoryService { if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) { initialBalance = initialBalance.add( inventoryTransactionLeg.getQuantity( )); - }else if(transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.OUT.name( )) && inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)){ - initialBalance = BigDecimal.ZERO; - } else { - initialBalance = initialBalance.subtract( 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)); @@ -179,18 +182,18 @@ public class InventoryService { // create bundles from cut pieces private List createBundles( JobCardItem jobCardItem, - List jobCardItemPieces ) { + List jobCardItemPieces, BigDecimal value ) { Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( ); - if ( jobCardItemPieces != null && !jobCardItemPieces.isEmpty( )) { + if ( value != null && !value.equals(BigDecimal.ZERO)) { List bundles = new ArrayList<>( ); // create bundle against every cut piece - for ( CutPiece cutPiece : jobCardItemPieces ) { + if(value.intValue()<=20){ Bundle bundle = new Bundle( ); bundle.setItemId( jobCardItem.getItemId( )); bundle.setSku( jobCardItem.getSku( )); bundle.setJobCardId( jobCardItem.getJobCardId( ) ); - bundle.setWrapQuantity( cutPiece.getQuantity( )); - bundle.setType( cutPiece.getType( )); + bundle.setWrapQuantity(BigDecimal.valueOf(20)); + bundle.setType( "BUNDLE"); bundle.setCreatedAt( LocalDateTime.now( )); bundle.setCreatedBy( authentication.getName( )); bundles.add( bundle); @@ -198,8 +201,32 @@ public class InventoryService { bundle.setBarcode( cryptographyService.generateRandomString( 15)); // save again after barcode generation bundle.setId( bundleDAO.save( bundle)); - } + }else{ + int quantity = value.intValue(); + int batchSize = 20; + 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 ( Map.Entry> entry : jobCardItemPieces ) { // JobCardItem key = entry.getKey( ); // List value = entry.getValue( ); @@ -243,11 +270,13 @@ public class InventoryService { long fromAccount = lastInvTransaction.getAccountId( ); createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( )); // IN - createInventoryTransactionLeg( transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.BUNDLE.name( )); + bundle.setType("BUNDLE"); + createInventoryTransactionLeg( transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.STITCH_BUNDLE.name( )); } } // update status masterBundle.setIsReceived( true); + masterBundle.setAccountId(toAccount); masterBundleDAO.save( masterBundle); } } @@ -296,73 +325,69 @@ public class InventoryService { * create finished items from master bundles * */ @Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED ) - public void createStitchingOfflineItemsFromJobCard( JobCard jobCard) { - List jobCardItems = jobCard.getItems( ); - List updatedItems = new ArrayList<>( ); + public void createStitchingOfflineItemsFromJobCard( BundleWrapper wrapper) { + List updatedItems = new ArrayList<>(); + List updateBundles = new ArrayList<>(); + JobCard jobCard = null; - // validate items - validateItems( jobCardItems); - // check whether all bundles are received against finish goods - checkAllBundleAreReceived( jobCard.getId( ), jobCardItems); - for ( JobCardItem item : jobCardItems) { - if(item.getTotalProduction() == null){ - item.setTotalProduction(BigDecimal.ZERO); - } - item.setJobCardId(jobCard.getId()); - // select which has inventory - if ( item.getProduction( ).compareTo( BigDecimal.ZERO ) != 0 ) { - // production is completed out bundles - if ( item.getActualProduction( ).compareTo( item.getTotalProduction( ).add( item.getProduction( ))) == 0) { - // create out transactions of bundles in master bundles - List bundles = bundleDAO.findByItemIdAndCardId( item.getItemId( ), jobCard.getId( )); - if ( bundles != null && !bundles.isEmpty( )) { - // bundle ids - List bundleIds = bundles.stream( ).map( Bundle::getId).collect( Collectors.toList( )); + //switching table transaction in Transaction Table + InventoryTransaction transaction = createInventoryTransaction("Against Movement from Stitching to Stitched Offline Item"); + inventoryTransactionDAO.save(transaction); - Map lastBundleIdInTransactionMap = inventoryTransactionLegDAO - .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 Stitching to Stitched Offline Item"); - inventoryTransactionDAO.save( transaction); - // create transaction legs - 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( )); - } - } + //TransactionLeg Transaction + List bundleIds = wrapper.getBundles().stream().map(Bundle::getId).collect(Collectors.toList()); + Map lastBundleIdInTransactionMap = inventoryTransactionLegDAO + .findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), bundleIds, InventoryArtifactType.STITCH_BUNDLE.name()) + .stream() + .collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity())); + for (Bundle subBundle : wrapper.getBundles()) { + long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId(); + if(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 wrapQuantity = bundle.getWrapQuantity().longValue(); + JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(),subBundle.getItemId()); + + InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(subBundle.getId(), null); + + if (lastInvTransaction != null ) { + if (wrapQuantity == production + subBundle.getCurrentProduction().longValue()) { + // OUT + long fromAccount = lastInvTransaction.getAccountId(); + createInventoryTransactionLeg(transaction, subBundle, accountId, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.STITCH_BUNDLE.name()); } } - // create finished items - List stitchingOfflineItems = createStitchingOfflineItems( item); + // create stitchingOfflineItems items + List stitchingOfflineItems = createStitchingOfflineItems(subBundle.getCurrentProduction(),jobCardItem,subBundle.getId()); // create IN Transactions of Finished Items into account - createTransactions( stitchingOfflineItems, jobCard.getToAccountId( ), InventoryArtifactType.STITCHING_OFFLINE.name( )); - item.setTotalProduction( item.getTotalProduction( ).add( item.getProduction( ))); - item.setJobCardId( jobCard.getId( )); - updatedItems.add( item); + createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name()); + + jobCardItem.setTotalProduction(jobCardItem.getTotalProduction().add(subBundle.getCurrentProduction())); + jobCardItem.setJobCardId(jobCard.getId()); + updatedItems.add(jobCardItem); + BigDecimal pro = subBundle.getCurrentProduction(); + bundle.setProduction(pro); + bundleDAO.save(bundle); } } - // save all - jobCardItemDAO.saveAll( updatedItems); + jobCardItemDAO.saveAll(updatedItems); } /* * create finished items * */ - public List createStitchingOfflineItems( JobCardItem jobCardItem) { + public List createStitchingOfflineItems( BigDecimal totalItem, JobCardItem jobCardItem,long bundleId) { Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( ); List items = new ArrayList<>( ); if ( jobCardItem != null) { - for ( int i = 1; i <= jobCardItem.getProduction( ).intValue( ); i++) { + 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); diff --git a/src/main/resources/static/js/job-card-form.js b/src/main/resources/static/js/job-card-form.js index bef200e..6cc224c 100644 --- a/src/main/resources/static/js/job-card-form.js +++ b/src/main/resources/static/js/job-card-form.js @@ -193,7 +193,6 @@ }, template: `
-
+ {{item.id}} diff --git a/src/main/resources/static/js/receive-inventory.js b/src/main/resources/static/js/receive-inventory.js index 2727f75..6009347 100644 --- a/src/main/resources/static/js/receive-inventory.js +++ b/src/main/resources/static/js/receive-inventory.js @@ -37,7 +37,7 @@ {{item.expectedProduction}} - + {{ populateCuttingAccount() }} diff --git a/src/main/resources/static/js/stitching/create-finished-item.js b/src/main/resources/static/js/stitching/create-finished-item.js index 7995d81..d96cdcf 100644 --- a/src/main/resources/static/js/stitching/create-finished-item.js +++ b/src/main/resources/static/js/stitching/create-finished-item.js @@ -11,7 +11,7 @@ onJobCardSelect : function( id, card ){ this.card = card; $.ajax({ - url: `/ctp/rest/job-cards/${id}/items`, + url: `/ctp/rest/job-cards/${id}`, method: 'GET', contentType: 'application/json', dataType: 'json', @@ -23,8 +23,25 @@ } }); + }, + onBundleSelects : function( id, card ){ + this.card = card; + console.log(id); + console.log(card); + $.ajax({ + url: `/ctp/rest/bundles/find-bundle-by-id/${id}`, + method: 'GET', + contentType: 'application/json', + dataType: 'json', + success: ( data ) =>{ + console.log(data) + this.items.push(data); + }, + error: function (err) { + console.log(err) + } + }); } - }, mounted : function () { } diff --git a/src/main/resources/static/js/vue-components.js b/src/main/resources/static/js/vue-components.js index db173f3..8a942ed 100644 --- a/src/main/resources/static/js/vue-components.js +++ b/src/main/resources/static/js/vue-components.js @@ -3367,6 +3367,49 @@ if ( typeof Vue !== 'undefined' ) { }); + + /* + * bundle search + * */ + Vue.component('bundle-search-by-barcode',{ + mixins: [searchComponentMixin], + methods : { + getSearchUrl : function () { + let url = `/ctp/rest/bundles/find-bundle-by-barcode?term=${encodeURIComponent( this.list.term )}` + return url; + }, + getEmittedEventName: function() { + return 'job-card-select'; + }, + getTitle: function( card ) { + return `(${card.barcode})`; + } + }, + props: { + labelText: { + default: 'Search By Bundle' + }, + titleFieldName: { + default: 'cardTitle' + }, + idFieldName: { + default: 'jobCardId' + }, + codeFieldName : { + default : 'jobCardCode' + }, + filter : { + default : true + }, + inputMode: { + default : 'none' + } + } + }) + + + + /* * job card search * */ diff --git a/src/main/resources/templates/cutting/master-bundles.html b/src/main/resources/templates/cutting/master-bundles.html index e11cdb8..2c2ae02 100644 --- a/src/main/resources/templates/cutting/master-bundles.html +++ b/src/main/resources/templates/cutting/master-bundles.html @@ -29,6 +29,7 @@ Sku Created By Created At + Received