change barcode and QR code for stitch item and change code for bundles and stitch-items and fix transactions
parent
78c6d7f459
commit
a22979f8ca
6
pom.xml
6
pom.xml
|
@ -55,6 +55,12 @@
|
|||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.30</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||
|
|
|
@ -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() );
|
||||
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() );
|
||||
|
|
|
@ -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<Bundle> findByBarcodeLike(String barcode) {
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue("barcode", "%" + barcode + "%");
|
||||
return namedParameterJdbcTemplate.query(SELECT_LIKE_BARCODE, params, new BundleRowMapper());
|
||||
}
|
||||
|
||||
// find all
|
||||
public List<Bundle> findAll() {
|
||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
||||
|
|
|
@ -16,6 +16,7 @@ public class BundleRowMapper implements RowMapper<Bundle> {
|
|||
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() );
|
||||
}
|
||||
|
|
|
@ -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<JobCardItem> findByIds( List<Long> ids ){
|
||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||
params.addValue( "ids", ids );
|
||||
|
|
|
@ -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<Long> findByIdAndReceiveIsTrue(List<Long> 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<MasterBundle> findAll() {
|
||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() );
|
||||
|
|
|
@ -14,6 +14,7 @@ public class MasterBundleRowMapper implements RowMapper<MasterBundle> {
|
|||
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() );
|
||||
}
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -15,6 +15,7 @@ public class StitchingOfflineItemRowMapper implements RowMapper<StitchingOffline
|
|||
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
||||
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
||||
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
||||
stitchingOfflineItem.setBundleId(rs.getLong("bundle_id"));
|
||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class SummaryInventoryReportDao {
|
|||
+ "(:sku IS NULL OR sku = :sku) "
|
||||
+ "AND (:item_id IS NULL OR item_id = :item_id) "
|
||||
+ "OR (:start_date IS NULL OR :end_date IS NULL OR transaction_leg_datetime BETWEEN :start_date AND :end_date) "
|
||||
+ "GROUP BY DATE(transaction_leg_datetime), sku, parent_document_type, parent_document_piece_type "
|
||||
+ "GROUP BY DATE(transaction_leg_datetime), account_id, sku, parent_document_type, parent_document_piece_type "
|
||||
+ "ORDER BY transaction_date, sku;";
|
||||
|
||||
public SummaryInventoryReportDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||
|
|
|
@ -7,8 +7,7 @@ public enum BarcodeStickerSize {
|
|||
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
||||
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||
SIZE_4_X_7( 7f * 72, 4f * 72, 200, 10, 40, 6, 50, 40, 125, 125, 14, 9, 7),
|
||||
SIZE_1_X_2( 141.73f, 56.69f , 20, 10, 10, 6, 60, 60, 125, 125, 4, 9, 7);
|
||||
|
||||
SIZE_1_X_2( 67.69f, 125.73f ,10 , 10, 20, 6, 60, 60, 125, 125, 4, 9, 7);
|
||||
|
||||
private final float width;
|
||||
private final float height;
|
||||
|
|
|
@ -11,6 +11,8 @@ public class Bundle implements InventoryArtifact {
|
|||
private long itemId;
|
||||
private String sku;
|
||||
private BigDecimal wrapQuantity;
|
||||
private BigDecimal production;
|
||||
private BigDecimal currentProduction;
|
||||
private String barcode;
|
||||
private String type;
|
||||
private String createdBy;
|
||||
|
@ -98,6 +100,22 @@ public class Bundle implements InventoryArtifact {
|
|||
return masterBundleId;
|
||||
}
|
||||
|
||||
public BigDecimal getProduction() {
|
||||
return production;
|
||||
}
|
||||
|
||||
public void setProduction(BigDecimal production) {
|
||||
this.production = production;
|
||||
}
|
||||
|
||||
public BigDecimal getCurrentProduction() {
|
||||
return currentProduction;
|
||||
}
|
||||
|
||||
public void setCurrentProduction(BigDecimal currentProduction) {
|
||||
this.currentProduction = currentProduction;
|
||||
}
|
||||
|
||||
public void setMasterBundleId(long masterBundleId) {
|
||||
this.masterBundleId = masterBundleId;
|
||||
}
|
||||
|
@ -110,6 +128,10 @@ public class Bundle implements InventoryArtifact {
|
|||
this.masterBundle = masterBundle;
|
||||
}
|
||||
|
||||
public long getBundleId(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Bundle{" +
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.utopiaindustries.model.ctp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BundleWrapper {
|
||||
private List<Bundle> bundles = new ArrayList<>(); // ✅ Initialize List
|
||||
|
||||
public List<Bundle> getBundles() {
|
||||
return bundles;
|
||||
}
|
||||
|
||||
public void setBundles(List<Bundle> bundles) {
|
||||
this.bundles = bundles;
|
||||
}
|
||||
}
|
|
@ -150,6 +150,10 @@ public class FinishedItem implements InventoryArtifact {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public long getBundleId(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishedItem{" +
|
||||
|
|
|
@ -15,4 +15,5 @@ public interface InventoryArtifact {
|
|||
LocalDateTime getCreatedAt();
|
||||
BigDecimal getWrapQuantity();
|
||||
long getMasterBundleId();
|
||||
long getBundleId();
|
||||
}
|
||||
|
|
|
@ -3,5 +3,7 @@ package com.utopiaindustries.model.ctp;
|
|||
public enum InventoryArtifactType {
|
||||
BUNDLE,
|
||||
STITCHING_OFFLINE,
|
||||
FINISHED_ITEM
|
||||
FINISHED_ITEM,
|
||||
STITCH_BUNDLE
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ public class MasterBundle implements InventoryArtifact{
|
|||
private LocalDateTime createdAt;
|
||||
private boolean isReceived;
|
||||
private long jobCardId;
|
||||
private long accountId;
|
||||
|
||||
// wrapper
|
||||
private List<Bundle> bundles;
|
||||
private List<FinishedItem> 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{" +
|
||||
|
|
|
@ -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{" +
|
||||
|
|
|
@ -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<Bundle> findByMasterBarcode(@RequestParam String term ){
|
||||
return bundleService.getBundles( term );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<? extends InventoryArtifact> 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<Bundle> 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<String> 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;
|
||||
}
|
||||
|
||||
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<EncodeHintType, Object> 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);
|
||||
|
||||
|
|
|
@ -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<Bundle> getBundles( String barcode){
|
||||
List<Bundle> bundles = new ArrayList<>();
|
||||
List<Bundle> fetchBundle = bundleDAO.findByBarcodeLike( barcode );
|
||||
List<Long> ids = fetchBundle.stream()
|
||||
.map(Bundle::getMasterBundleId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if(!ids.isEmpty()){
|
||||
List<Long> 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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* */
|
||||
|
|
|
@ -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<Bundle> bundles = createBundles( jobCardItem, piecesMap.get( jobCardItem.getId( ) ) );
|
||||
List<Bundle> 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)){
|
||||
}else if(transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.OUT.name( ))) {
|
||||
if (inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)) {
|
||||
initialBalance = BigDecimal.ZERO;
|
||||
} else {
|
||||
initialBalance = initialBalance.subtract( inventoryTransactionLeg.getQuantity( ));
|
||||
initialBalance = initialBalance.subtract(inventoryTransactionLeg.getQuantity());
|
||||
}
|
||||
}
|
||||
inventoryTransactionLeg.setBalance( initialBalance);
|
||||
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
||||
|
@ -179,18 +182,41 @@ public class InventoryService {
|
|||
|
||||
// create bundles from cut pieces
|
||||
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
||||
List<CutPiece> jobCardItemPieces ) {
|
||||
List<CutPiece> jobCardItemPieces, BigDecimal value ) {
|
||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||
if ( jobCardItemPieces != null && !jobCardItemPieces.isEmpty( )) {
|
||||
if ( value != null && !value.equals(BigDecimal.ZERO)) {
|
||||
List<Bundle> 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);
|
||||
bundle.setId( bundleDAO.save( bundle));
|
||||
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);
|
||||
|
@ -200,6 +226,7 @@ public class InventoryService {
|
|||
bundle.setId( bundleDAO.save( bundle));
|
||||
}
|
||||
|
||||
}
|
||||
// for ( Map.Entry<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
||||
// JobCardItem key = entry.getKey( );
|
||||
// List<CutPiece> 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<JobCardItem> jobCardItems = jobCard.getItems( );
|
||||
List<JobCardItem> updatedItems = new ArrayList<>( );
|
||||
public void createStitchingOfflineItemsFromJobCard( BundleWrapper wrapper) {
|
||||
List<JobCardItem> updatedItems = new ArrayList<>();
|
||||
List<Bundle> 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<Bundle> bundles = bundleDAO.findByItemIdAndCardId( item.getItemId( ), jobCard.getId( ));
|
||||
if ( bundles != null && !bundles.isEmpty( )) {
|
||||
// bundle ids
|
||||
List<Long> 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);
|
||||
|
||||
//TransactionLeg Transaction
|
||||
List<Long> bundleIds = wrapper.getBundles().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( )));
|
||||
// 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) {
|
||||
.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, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||
long fromAccount = lastInvTransaction.getAccountId();
|
||||
createInventoryTransactionLeg(transaction, subBundle, accountId, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.STITCH_BUNDLE.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// create finished items
|
||||
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems( item);
|
||||
// create stitchingOfflineItems items
|
||||
List<StitchingOfflineItem> 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<StitchingOfflineItem> createStitchingOfflineItems( JobCardItem jobCardItem) {
|
||||
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 <= 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);
|
||||
|
|
|
@ -193,7 +193,6 @@
|
|||
},
|
||||
template: `
|
||||
<div class="row mt-1">
|
||||
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].id'" v-bind:value="piece.id">
|
||||
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index + '].jobCardItemId'" v-bind:value="piece.jobCardItemId || 0">
|
||||
<div class="col-md-5">
|
||||
<select class="form-control"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<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 + '].bundleId'" v-bind:value="item.bundleId" >
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
||||
<span> {{item.id}} </span>
|
||||
</td>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<span class="form-control" readonly>{{item.expectedProduction}}</span>
|
||||
</td>
|
||||
<td width="200">
|
||||
<input class="form-control" min="0" type="number" v-bind:name="'items[' + index + '].actualProduction'" v-bind:max="item.expectedProduction" required>
|
||||
<input class="form-control" min="0" type="number" v-bind:name="'items[' + index + '].actualProduction'" required>
|
||||
</td>
|
||||
<td>
|
||||
{{ populateCuttingAccount() }}
|
||||
|
|
|
@ -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 () {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<th>Sku</th>
|
||||
<th>Created By</th>
|
||||
<th>Created At</th>
|
||||
<th>Received</th>
|
||||
<th>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-sm btn-outline-primary" type="submit">Generate
|
||||
|
@ -51,6 +52,7 @@
|
|||
<td th:text="*{sku}"></td>
|
||||
<td th:text="*{createdBy}"></td>
|
||||
<td ctp:formatdatetime="*{createdAt}"></td>
|
||||
<td th:text="${bundle.isReceived ? 'YES' : 'NO'}"></td>
|
||||
<td>
|
||||
<div class="form-group form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
<td>
|
||||
<span th:if="${cardStitchingItem.getQaStatus() == 'APPROVED'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-APPROVED font-sm"></span>
|
||||
<span th:if="${cardStitchingItem.getQaStatus() == 'REJECT'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-warning font-sm"></span>
|
||||
<span th:if="${cardStitchingItem.getQaStatus() == null}" th:text="NOT-PERFORMED" class="badge badge-danger font-sm"></span>
|
||||
</td>
|
||||
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
||||
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
||||
|
|
|
@ -13,26 +13,17 @@
|
|||
<form th:action="@{/stitching/create-stitching-items}"
|
||||
method="POST"
|
||||
id="finishedItemApp"
|
||||
th:object="${jobCard}">
|
||||
th:object="${bundleWrapper}">
|
||||
|
||||
<div class="bg-light p-3 mb-3 col-sm-8">
|
||||
<div class="form-row">
|
||||
<div class="col-sm-5 p-0">
|
||||
<job-card-search
|
||||
<bundle-search-by-barcode
|
||||
v-bind:id-field-name="'id'"
|
||||
v-bind:filter="false"
|
||||
v-bind:items="true"
|
||||
v-on:job-card-select="onJobCardSelect">
|
||||
</job-card-search>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<label>Stitching Account</label>
|
||||
<select class="form-control" name="toAccountId" required>
|
||||
<option value="">Please Select</option>
|
||||
<option th:each="account :${accounts}"
|
||||
th:value="${account.id}"
|
||||
th:text="${account.title}"
|
||||
th:title="${account.notes}"></option>
|
||||
</select>
|
||||
v-on:job-card-select="onBundleSelects">
|
||||
</bundle-search-by-barcode>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,48 +37,48 @@
|
|||
<th>Item ID</th>
|
||||
<th>Sku</th>
|
||||
<th>Expected Production</th>
|
||||
<th>Actual Production</th>
|
||||
<th>Current Production</th>
|
||||
<th>Production</th>
|
||||
</tr>
|
||||
<tbody>
|
||||
<tr v-if="(item.actualProduction !== item.totalProduction)" v-for="(item,index) in items">
|
||||
<tr v-if="(item.wrapQuantity !== item.production)" v-for="(item,index) in items">
|
||||
<td >
|
||||
<div class="form-group form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox" v-bind:name="'items[' + index + '].isSelected'" v-model="item.isSelected">
|
||||
<label th:for="*{id}" class="form-check-label"></label>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].itemId'" v-bind:value="item.itemId">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].id'" v-bind:value="item.id">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].masterBundleId'" v-bind:value="item.masterBundleId">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].type'" v-bind:value="item.type">
|
||||
|
||||
<span class="form-control">{{item.id}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].itemId'" v-bind:value="item.itemId">
|
||||
<span class="form-control">{{item.itemId}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].sku'" v-bind:value="item.sku">
|
||||
<span class="form-control">{{item.sku}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].expectedProduction'" v-bind:value="item.expectedProduction">
|
||||
<span class="form-control">{{item.expectedProduction}}</span>
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].wrapQuantity'" v-bind:value="item.wrapQuantity">
|
||||
<span class="form-control">{{item.wrapQuantity}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].actualProduction'" v-bind:value="item.actualProduction">
|
||||
<span class="form-control">{{item.actualProduction}}</span>
|
||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].production'" v-bind:value="item.production">
|
||||
<span class="form-control">{{item.production}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input hidden="hidden" v-bind:name="'items[' + index + '].totalProduction'" v-bind:value="item.totalProduction">
|
||||
<span class="form-control">{{item.totalProduction}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" v-bind:name="'items[' + index + '].production'"
|
||||
<input class="form-control" v-bind:name="'bundles[' + index + '].currentProduction'"
|
||||
type="number"
|
||||
v-bind:value="item.production"
|
||||
v-bind:value="item.currentProduction"
|
||||
v-bind:min="0"
|
||||
v-bind:max="item.actualProduction - item.totalProduction"
|
||||
v-bind:max="item.wrapQuantity - item.production"
|
||||
v-bind:readonly="!item.isSelected"
|
||||
>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue