Merge pull request 'add_QRCode' (#8) from add_QRCode into main
Reviewed-on: http://git.utopiadeals.com:8080/UIND/cut-to-pack-service/pulls/8fixed-serach-item
commit
b3bc4c5e6d
|
@ -21,6 +21,11 @@
|
||||||
<option name="name" value="In project repo" />
|
<option name="name" value="In project repo" />
|
||||||
<option name="url" value="file:///D:\Projects\uind-cut-to-pack\cut-to-pack/libs" />
|
<option name="url" value="file:///D:\Projects\uind-cut-to-pack\cut-to-pack/libs" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="in-project" />
|
||||||
|
<option name="name" value="In project repo" />
|
||||||
|
<option name="url" value="file:///C:\Users\USF\Project\Cut-to-pack\cut-to-pack-service/libs" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="in-project" />
|
<option name="id" value="in-project" />
|
||||||
<option name="name" value="In project repo" />
|
<option name="name" value="In project repo" />
|
||||||
|
|
8
pom.xml
8
pom.xml
|
@ -55,6 +55,12 @@
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox</artifactId>
|
||||||
|
<version>2.0.30</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||||
|
@ -389,7 +395,7 @@
|
||||||
<jvmArguments>-Xms1024m</jvmArguments>
|
<jvmArguments>-Xms1024m</jvmArguments>
|
||||||
<jvmArguments>-Xmx8g</jvmArguments>
|
<jvmArguments>-Xmx8g</jvmArguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package com.utopiaindustries.controller;
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
import com.utopiaindustries.auth.StitchingRole;
|
import com.utopiaindustries.auth.StitchingRole;
|
||||||
import com.utopiaindustries.model.ctp.JobCard;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
|
||||||
import com.utopiaindustries.service.*;
|
import com.utopiaindustries.service.*;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -111,17 +109,17 @@ public class StitchingController {
|
||||||
@GetMapping( "/create-stitching-items")
|
@GetMapping( "/create-stitching-items")
|
||||||
public String createFinishItems( Model model ){
|
public String createFinishItems( Model model ){
|
||||||
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
||||||
model.addAttribute("jobCard", jobCardService.createNewJobCard() );
|
model.addAttribute("bundleWrapper", new BundleWrapper() );
|
||||||
return "/stitching/stitching-item-form";
|
return "/stitching/stitching-item-form";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping( "/create-stitching-items" )
|
@PostMapping( "/create-stitching-items" )
|
||||||
public String createStitchedOfflineItems( @ModelAttribute JobCard jobCard,
|
public String createStitchedOfflineItems( @ModelAttribute BundleWrapper bundleWrapper,
|
||||||
RedirectAttributes redirectAttributes,
|
RedirectAttributes redirectAttributes,
|
||||||
Model model ){
|
Model model ){
|
||||||
try {
|
try {
|
||||||
inventoryService.createStitchingOfflineItemsFromJobCard( jobCard );
|
inventoryService.createStitchingOfflineItemsFromJobCard( bundleWrapper );
|
||||||
redirectAttributes.addFlashAttribute("success", "Finished Item Created Successfully");
|
redirectAttributes.addFlashAttribute("success", "Stitch Items Created Successfully");
|
||||||
} catch ( Exception exception ){
|
} catch ( Exception exception ){
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
redirectAttributes.addFlashAttribute( "error", exception.getMessage() );
|
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_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_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 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_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_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_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_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_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_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) {
|
public BundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
@ -40,6 +41,7 @@ public class BundleDAO {
|
||||||
params.addValue( "id", bundle.getId() )
|
params.addValue( "id", bundle.getId() )
|
||||||
.addValue( "item_id", bundle.getItemId() )
|
.addValue( "item_id", bundle.getItemId() )
|
||||||
.addValue( "sku", bundle.getSku() )
|
.addValue( "sku", bundle.getSku() )
|
||||||
|
.addValue("production",bundle.getProduction())
|
||||||
.addValue( "wrap_quantity", bundle.getWrapQuantity() )
|
.addValue( "wrap_quantity", bundle.getWrapQuantity() )
|
||||||
.addValue( "barcode", bundle.getBarcode() )
|
.addValue( "barcode", bundle.getBarcode() )
|
||||||
.addValue( "type", bundle.getType() )
|
.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
|
// find all
|
||||||
public List<Bundle> findAll() {
|
public List<Bundle> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class BundleRowMapper implements RowMapper<Bundle> {
|
||||||
bundle.setBarcode( rs.getString( "barcode" ) );
|
bundle.setBarcode( rs.getString( "barcode" ) );
|
||||||
bundle.setType( rs.getString( "type" ) );
|
bundle.setType( rs.getString( "type" ) );
|
||||||
bundle.setCreatedBy( rs.getString( "created_by" ) );
|
bundle.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
|
bundle.setProduction(rs.getBigDecimal("production"));
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class CutPieceTypeDAO {
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", 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 DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title) VALUES (:id, :title) ON DUPLICATE KEY UPDATE title = VALUES(title)", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title) VALUES (:id, :title) ON DUPLICATE KEY UPDATE title = VALUES(title)", TABLE_NAME );
|
||||||
|
private final String SELECT_BY_TITLE = String.format("SELECT * FROM %s WHERE title = :title", TABLE_NAME);
|
||||||
|
|
||||||
public CutPieceTypeDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public CutPieceTypeDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -30,7 +31,7 @@ public class CutPieceTypeDAO {
|
||||||
private MapSqlParameterSource prepareInsertQueryParams( CutPieceType cutPieceType ) {
|
private MapSqlParameterSource prepareInsertQueryParams( CutPieceType cutPieceType ) {
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue( "id", cutPieceType.getId() )
|
params.addValue( "id", cutPieceType.getId() )
|
||||||
.addValue( "title", cutPieceType.getTitle() );
|
.addValue( "title", cutPieceType.getType() );
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +45,16 @@ public class CutPieceTypeDAO {
|
||||||
.orElse( new CutPieceType() );
|
.orElse( new CutPieceType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public CutPieceType findByTitle( String title ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "title", title );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_BY_TITLE, params, new CutPieceTypeRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new CutPieceType() );
|
||||||
|
}
|
||||||
|
|
||||||
// find all
|
// find all
|
||||||
public List<CutPieceType> findAll() {
|
public List<CutPieceType> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class CutPieceTypeRowMapper implements RowMapper<CutPieceType> {
|
||||||
public CutPieceType mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
public CutPieceType mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
CutPieceType cutPieceType = new CutPieceType();
|
CutPieceType cutPieceType = new CutPieceType();
|
||||||
cutPieceType.setId( rs.getLong( "id" ) );
|
cutPieceType.setId( rs.getLong( "id" ) );
|
||||||
cutPieceType.setTitle( rs.getString( "title" ) );
|
cutPieceType.setType( rs.getString( "title" ) );
|
||||||
return cutPieceType;
|
return cutPieceType;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.JobCardItem;
|
import com.utopiaindustries.model.ctp.JobCardItem;
|
||||||
|
import com.utopiaindustries.model.ctp.MasterBundle;
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
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 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 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 = 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 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_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 );
|
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() );
|
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 ){
|
public List<JobCardItem> findByIds( List<Long> ids ){
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue( "ids", ids );
|
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_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_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 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_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_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 = 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) {
|
public MasterBundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
@ -37,6 +39,7 @@ public class MasterBundleDAO {
|
||||||
.addValue( "barcode", masterBundle.getBarcode() )
|
.addValue( "barcode", masterBundle.getBarcode() )
|
||||||
.addValue( "item_id", masterBundle.getItemId() )
|
.addValue( "item_id", masterBundle.getItemId() )
|
||||||
.addValue( "sku", masterBundle.getSku() )
|
.addValue( "sku", masterBundle.getSku() )
|
||||||
|
.addValue( "account_id", masterBundle.getAccountId() )
|
||||||
.addValue( "created_by", masterBundle.getCreatedBy() )
|
.addValue( "created_by", masterBundle.getCreatedBy() )
|
||||||
.addValue( "created_at", masterBundle.getCreatedAt() )
|
.addValue( "created_at", masterBundle.getCreatedAt() )
|
||||||
.addValue( "job_card_id", masterBundle.getJobCardId() )
|
.addValue( "job_card_id", masterBundle.getJobCardId() )
|
||||||
|
@ -54,6 +57,13 @@ public class MasterBundleDAO {
|
||||||
.orElse( new MasterBundle() );
|
.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
|
// find all
|
||||||
public List<MasterBundle> findAll() {
|
public List<MasterBundle> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() );
|
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.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
masterBundle.setItemId( rs.getLong("item_id" ));
|
masterBundle.setItemId( rs.getLong("item_id" ));
|
||||||
masterBundle.setSku( rs.getString("sku" ) );
|
masterBundle.setSku( rs.getString("sku" ) );
|
||||||
|
masterBundle.setAccountId(rs.getLong("account_id"));
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPiece;
|
||||||
|
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class SkuCutPieceRowMapper implements RowMapper<SkuCutPieces> {
|
||||||
|
public SkuCutPieces mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
|
SkuCutPieces skuCutPieces = new SkuCutPieces();
|
||||||
|
skuCutPieces.setId(rs.getLong("id"));
|
||||||
|
skuCutPieces.setSku(rs.getString("sku"));
|
||||||
|
skuCutPieces.setType(rs.getString("title"));
|
||||||
|
return skuCutPieces;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
|
import com.utopiaindustries.model.ctp.CutPieceType;
|
||||||
|
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
||||||
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class SkuCutPiecesDAO {
|
||||||
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
|
private final String TABLE_NAME = "cut_to_pack.sku_cut_piece";
|
||||||
|
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 (sku, title) VALUES (:sku, :title) ON DUPLICATE KEY UPDATE sku = VALUES(sku), title = VALUES(title)", TABLE_NAME);
|
||||||
|
private final String FIND_BY_SKU = String.format( "SELECT * FROM %s WHERE sku = :sku", TABLE_NAME );
|
||||||
|
private final String CHECK_EXISTENCE_QUERY = String.format("SELECT COUNT(*) FROM %s WHERE title = :title AND sku = :sku", TABLE_NAME);
|
||||||
|
|
||||||
|
public SkuCutPiecesDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare query params
|
||||||
|
private MapSqlParameterSource prepareInsertQueryParams(SkuCutPieces skuCutPieces ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", skuCutPieces.getId() )
|
||||||
|
.addValue( "sku", skuCutPieces.getSku())
|
||||||
|
.addValue("title",skuCutPieces.getType());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find
|
||||||
|
public SkuCutPieces find( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new SkuCutPieceRowMapper() )
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElse( new SkuCutPieces() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doesExist(String type, String sku) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("title", type);
|
||||||
|
params.addValue("sku", sku);
|
||||||
|
Long count = namedParameterJdbcTemplate.queryForObject(CHECK_EXISTENCE_QUERY, params, Long.class);
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//find by sku
|
||||||
|
public List<SkuCutPieces> findBySku(String sku) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("sku", sku);
|
||||||
|
return namedParameterJdbcTemplate.query(FIND_BY_SKU, params, new SkuCutPieceRowMapper());
|
||||||
|
}
|
||||||
|
|
||||||
|
// find all
|
||||||
|
public List<CutPieceType> findAll() {
|
||||||
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save
|
||||||
|
public long save( SkuCutPieces skuCutPieces ) {
|
||||||
|
KeyHolder keyHolder = new GeneratedKeyHolder();
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( skuCutPieces );
|
||||||
|
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
||||||
|
return KeyHolderFunctions.getKey( skuCutPieces.getId(), keyHolder );
|
||||||
|
}
|
||||||
|
|
||||||
|
// save all
|
||||||
|
public int[] saveAll( List<SkuCutPieces> skuCutPieces ) {
|
||||||
|
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
||||||
|
for ( SkuCutPieces cutPieceType: skuCutPieces ) {
|
||||||
|
MapSqlParameterSource params = prepareInsertQueryParams( cutPieceType );
|
||||||
|
batchArgs.add( params );
|
||||||
|
}
|
||||||
|
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[skuCutPieces.size()]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
public boolean delete( long id ) {
|
||||||
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue( "id", id );
|
||||||
|
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :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 SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME );
|
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", 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 = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
|
@ -40,6 +40,7 @@ public class StitchingOfflineItemDAO {
|
||||||
.addValue( "item_id", stitchingOfflineItem.getItemId() )
|
.addValue( "item_id", stitchingOfflineItem.getItemId() )
|
||||||
.addValue( "sku", stitchingOfflineItem.getSku() )
|
.addValue( "sku", stitchingOfflineItem.getSku() )
|
||||||
.addValue( "barcode", stitchingOfflineItem.getBarcode() )
|
.addValue( "barcode", stitchingOfflineItem.getBarcode() )
|
||||||
|
.addValue("bundle_id",stitchingOfflineItem.getBundleId())
|
||||||
.addValue( "created_at", stitchingOfflineItem.getCreatedAt() )
|
.addValue( "created_at", stitchingOfflineItem.getCreatedAt() )
|
||||||
.addValue( "created_by", stitchingOfflineItem.getCreatedBy() )
|
.addValue( "created_by", stitchingOfflineItem.getCreatedBy() )
|
||||||
.addValue("job_card_id", stitchingOfflineItem.getJobCardId() )
|
.addValue("job_card_id", stitchingOfflineItem.getJobCardId() )
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class StitchingOfflineItemRowMapper implements RowMapper<StitchingOffline
|
||||||
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
||||||
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
||||||
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
||||||
|
stitchingOfflineItem.setBundleId(rs.getLong("bundle_id"));
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class SummaryInventoryReportDao {
|
||||||
+ "(:sku IS NULL OR sku = :sku) "
|
+ "(:sku IS NULL OR sku = :sku) "
|
||||||
+ "AND (:item_id IS NULL OR item_id = :item_id) "
|
+ "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) "
|
+ "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;";
|
+ "ORDER BY transaction_date, sku;";
|
||||||
|
|
||||||
public SummaryInventoryReportDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public SummaryInventoryReportDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
|
|
@ -6,8 +6,8 @@ public enum BarcodeStickerSize {
|
||||||
SIZE_2_X_3( 3 * 72, 2 * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
SIZE_2_X_3( 3 * 72, 2 * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
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_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, 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( 67.69f, 125.73f ,10 , 10, 20, 6, 60, 60, 125, 125, 4, 9, 7);
|
||||||
|
|
||||||
private final float width;
|
private final float width;
|
||||||
private final float height;
|
private final float height;
|
||||||
|
|
|
@ -11,6 +11,8 @@ public class Bundle implements InventoryArtifact {
|
||||||
private long itemId;
|
private long itemId;
|
||||||
private String sku;
|
private String sku;
|
||||||
private BigDecimal wrapQuantity;
|
private BigDecimal wrapQuantity;
|
||||||
|
private BigDecimal production;
|
||||||
|
private BigDecimal currentProduction;
|
||||||
private String barcode;
|
private String barcode;
|
||||||
private String type;
|
private String type;
|
||||||
private String createdBy;
|
private String createdBy;
|
||||||
|
@ -98,6 +100,22 @@ public class Bundle implements InventoryArtifact {
|
||||||
return masterBundleId;
|
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) {
|
public void setMasterBundleId(long masterBundleId) {
|
||||||
this.masterBundleId = masterBundleId;
|
this.masterBundleId = masterBundleId;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +128,10 @@ public class Bundle implements InventoryArtifact {
|
||||||
this.masterBundle = masterBundle;
|
this.masterBundle = masterBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Bundle{" +
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ package com.utopiaindustries.model.ctp;
|
||||||
public class CutPieceType {
|
public class CutPieceType {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String title;
|
private String type;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -13,19 +13,19 @@ public class CutPieceType {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getType() {
|
||||||
return title;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setType(String type) {
|
||||||
this.title = title;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CutPieceType{" +
|
return "CutPieceType{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", title='" + title + '\'' +
|
", title='" + type + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class FinishedItem implements InventoryArtifact {
|
public class FinishedItem implements InventoryArtifact {
|
||||||
|
@ -141,6 +142,18 @@ public class FinishedItem implements InventoryArtifact {
|
||||||
this.qaStatus = qaStatus;
|
this.qaStatus = qaStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getWrapQuantity(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMasterBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FinishedItem{" +
|
return "FinishedItem{" +
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public interface InventoryArtifact {
|
public interface InventoryArtifact {
|
||||||
|
|
||||||
long getId();
|
long getId();
|
||||||
long getItemId();
|
long getItemId();
|
||||||
|
long getJobCardId();
|
||||||
String getSku();
|
String getSku();
|
||||||
String getType();
|
String getType();
|
||||||
String getBarcode();
|
String getBarcode();
|
||||||
|
String getCreatedBy();
|
||||||
|
LocalDateTime getCreatedAt();
|
||||||
|
BigDecimal getWrapQuantity();
|
||||||
|
long getMasterBundleId();
|
||||||
|
long getBundleId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,7 @@ package com.utopiaindustries.model.ctp;
|
||||||
public enum InventoryArtifactType {
|
public enum InventoryArtifactType {
|
||||||
BUNDLE,
|
BUNDLE,
|
||||||
STITCHING_OFFLINE,
|
STITCHING_OFFLINE,
|
||||||
FINISHED_ITEM
|
FINISHED_ITEM,
|
||||||
|
STITCH_BUNDLE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
private boolean isReceived;
|
private boolean isReceived;
|
||||||
private long jobCardId;
|
private long jobCardId;
|
||||||
|
private long accountId;
|
||||||
|
|
||||||
// wrapper
|
// wrapper
|
||||||
private List<Bundle> bundles;
|
private List<Bundle> bundles;
|
||||||
private List<FinishedItem> items;
|
private List<FinishedItem> items;
|
||||||
|
@ -94,6 +97,14 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
this.bundles = bundles;
|
this.bundles = bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getWrapQuantity(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMasterBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FinishedItem> getItems() {
|
public List<FinishedItem> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +113,18 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(long accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MasterBundle{" +
|
return "MasterBundle{" +
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
|
|
||||||
|
public class SkuCutPieces {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String sku;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSku() {
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSku(String sku) {
|
||||||
|
this.sku = sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CutPiece{" +
|
||||||
|
"id=" + id +
|
||||||
|
", sku=" + sku +
|
||||||
|
", type='" + type +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class StitchingOfflineItem implements InventoryArtifact {
|
public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
|
@ -17,6 +18,7 @@ public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
private boolean isQa;
|
private boolean isQa;
|
||||||
private String qaRemarks;
|
private String qaRemarks;
|
||||||
private String qaStatus;
|
private String qaStatus;
|
||||||
|
private long bundleId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -107,6 +109,22 @@ public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
this.qaStatus = qaStatus;
|
this.qaStatus = qaStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getWrapQuantity(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMasterBundleId(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBundleId() {
|
||||||
|
return bundleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBundleId(long bundleId) {
|
||||||
|
this.bundleId = bundleId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StitchingOfflineItem{" +
|
return "StitchingOfflineItem{" +
|
||||||
|
|
|
@ -34,4 +34,13 @@ public class BundleRestController {
|
||||||
return bundleService.findBundlesByMasterId( masterId );
|
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,19 +1,42 @@
|
||||||
package com.utopiaindustries.restcontroller;
|
package com.utopiaindustries.restcontroller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.dao.ctp.CutPieceTypeDAO;
|
||||||
|
import com.utopiaindustries.dao.ctp.SkuCutPiecesDAO;
|
||||||
|
import com.utopiaindustries.model.ctp.CutPieceType;
|
||||||
|
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
||||||
import com.utopiaindustries.service.JobCardService;
|
import com.utopiaindustries.service.JobCardService;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import java.util.ArrayList;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping( "/rest/cut-pieces" )
|
@RequestMapping( "/rest/cut-pieces" )
|
||||||
public class CutPieceRestController {
|
public class CutPieceRestController {
|
||||||
|
|
||||||
private final JobCardService jobCardService;
|
private final JobCardService jobCardService;
|
||||||
|
private final SkuCutPiecesDAO skuCutPiecesDAO;
|
||||||
|
private final CutPieceTypeDAO cutPieceTypeDAO;
|
||||||
|
|
||||||
public CutPieceRestController(JobCardService jobCardService) {
|
public CutPieceRestController(JobCardService jobCardService, SkuCutPiecesDAO skuCutPiecesDAO, CutPieceTypeDAO cutPieceTypeDAO) {
|
||||||
this.jobCardService = jobCardService;
|
this.jobCardService = jobCardService;
|
||||||
|
this.skuCutPiecesDAO = skuCutPiecesDAO;
|
||||||
|
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public List<CutPieceType> getBySku(@RequestParam("sku") String sku) {
|
||||||
|
try {
|
||||||
|
ArrayList<CutPieceType> cutPieceTypes = new ArrayList<>();
|
||||||
|
List<SkuCutPieces> skuCutPieces = skuCutPiecesDAO.findBySku(sku);
|
||||||
|
for (SkuCutPieces skuCutPieces1 : skuCutPieces){
|
||||||
|
CutPieceType cutPieceType = cutPieceTypeDAO.findByTitle(skuCutPieces1.getType());
|
||||||
|
cutPieceTypes.add(cutPieceType);
|
||||||
|
}
|
||||||
|
return cutPieceTypes;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("An error occurred while fetching data for SKU: " + sku, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package com.utopiaindustries.service;
|
package com.utopiaindustries.service;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.utopiaindustries.dao.ctp.BundleDAO;
|
import com.itextpdf.io.font.constants.StandardFonts;
|
||||||
import com.utopiaindustries.dao.ctp.FinishedItemDAO;
|
import com.itextpdf.io.image.ImageData;
|
||||||
import com.utopiaindustries.dao.ctp.MasterBundleDAO;
|
import com.itextpdf.kernel.colors.ColorConstants;
|
||||||
import com.utopiaindustries.dao.ctp.StitchingOfflineItemDAO;
|
import com.itextpdf.kernel.font.PdfFont;
|
||||||
|
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;
|
||||||
|
import com.itextpdf.layout.element.Paragraph;
|
||||||
|
import com.itextpdf.layout.property.AreaBreakType;
|
||||||
|
import com.itextpdf.layout.property.TextAlignment;
|
||||||
|
import com.utopiaindustries.dao.ctp.*;
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
import com.utopiaindustries.util.BarcodeUtils;
|
import com.utopiaindustries.util.BarcodeUtils;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
|
@ -13,17 +21,39 @@ import com.zebra.sdk.comm.TcpConnection;
|
||||||
import com.zebra.sdk.graphics.internal.ZebraImage;
|
import com.zebra.sdk.graphics.internal.ZebraImage;
|
||||||
import com.zebra.sdk.printer.ZebraPrinter;
|
import com.zebra.sdk.printer.ZebraPrinter;
|
||||||
import com.zebra.sdk.printer.ZebraPrinterFactory;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.itextpdf.io.image.ImageDataFactory;
|
||||||
|
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||||
|
import com.itextpdf.kernel.geom.PageSize;
|
||||||
|
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||||
|
import com.itextpdf.layout.Document;
|
||||||
|
import com.itextpdf.layout.element.Image;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.FileSystems;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.image.BufferedImage;
|
import java.io.*;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BarcodeService {
|
public class BarcodeService {
|
||||||
|
@ -34,16 +64,34 @@ public class BarcodeService {
|
||||||
@Value("${ctp.printer.port}")
|
@Value("${ctp.printer.port}")
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
|
@Value("${ctp.printer.bundleIpAdd}")
|
||||||
|
private String bundleIpAddress;
|
||||||
|
|
||||||
|
@Value("${ctp.printer.bundlePort}")
|
||||||
|
private int bundlePort;
|
||||||
|
|
||||||
|
@Value("${ctp.printer.stitchQRPath}")
|
||||||
|
private String stitchPath;
|
||||||
|
|
||||||
|
@Value("${ctp.printer.bundlePath}")
|
||||||
|
private String bundlePath;
|
||||||
|
|
||||||
private final BundleDAO bundleDAO;
|
private final BundleDAO bundleDAO;
|
||||||
|
private final JobCardDAO jobCardDAO;
|
||||||
private final MasterBundleDAO masterBundleDAO;
|
private final MasterBundleDAO masterBundleDAO;
|
||||||
private final FinishedItemDAO finishedItemDAO;
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
||||||
|
private final InventoryAccountDAO inventoryAccountDAO;
|
||||||
|
private final JobCardItemDAO jobCardItemDAO;
|
||||||
|
|
||||||
public BarcodeService(BundleDAO bundleDAO, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO) {
|
public BarcodeService(BundleDAO bundleDAO, JobCardDAO jobCardDAO, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, JobCardItemDAO jobCardItemDAO) {
|
||||||
this.bundleDAO = bundleDAO;
|
this.bundleDAO = bundleDAO;
|
||||||
|
this.jobCardDAO = jobCardDAO;
|
||||||
this.masterBundleDAO = masterBundleDAO;
|
this.masterBundleDAO = masterBundleDAO;
|
||||||
this.finishedItemDAO = finishedItemDAO;
|
this.finishedItemDAO = finishedItemDAO;
|
||||||
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
||||||
|
this.inventoryAccountDAO = inventoryAccountDAO;
|
||||||
|
this.jobCardItemDAO = jobCardItemDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,85 +104,364 @@ public class BarcodeService {
|
||||||
List<? extends InventoryArtifact> list = new ArrayList<>();
|
List<? extends InventoryArtifact> list = new ArrayList<>();
|
||||||
if (StringUtils.compare(artifactType, Bundle.class.getSimpleName())) {
|
if (StringUtils.compare(artifactType, Bundle.class.getSimpleName())) {
|
||||||
list = bundleDAO.findByIds(ids);
|
list = bundleDAO.findByIds(ids);
|
||||||
|
getBarcodeImages(list, stickerSize, artifactType);
|
||||||
} else if (StringUtils.compare(artifactType, MasterBundle.class.getSimpleName())) {
|
} else if (StringUtils.compare(artifactType, MasterBundle.class.getSimpleName())) {
|
||||||
list = masterBundleDAO.findByIds(ids);
|
list = masterBundleDAO.findByIds(ids);
|
||||||
|
getBarcodeImages(list, stickerSize, artifactType);
|
||||||
} else if (StringUtils.compare(artifactType, FinishedItem.class.getSimpleName())) {
|
} else if (StringUtils.compare(artifactType, FinishedItem.class.getSimpleName())) {
|
||||||
|
String sizeForStitchItem = BarcodeStickerSize.SIZE_1_X_2.name();
|
||||||
|
BarcodeStickerSize stickerSizeForStitchItem = BarcodeStickerSize.getSize(sizeForStitchItem);
|
||||||
list = stitchingOfflineItemDAO.findByIds(ids);
|
list = stitchingOfflineItemDAO.findByIds(ids);
|
||||||
|
getBarcodeImagesForStitchItems(list, stickerSizeForStitchItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBarcodeImages(list, stickerSize, artifactType);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getBarcodeImages(List<? extends InventoryArtifact> artifacts,
|
public void getBarcodeImages(List<? extends InventoryArtifact> artifacts,
|
||||||
BarcodeStickerSize stickerSize,
|
BarcodeStickerSize stickerSize,
|
||||||
String artifactType) throws Exception {
|
String artifactType) throws Exception {
|
||||||
|
int pageWidth = 900; // A4 Width
|
||||||
for (InventoryArtifact artifact : artifacts) {
|
int pageHeight = 1200; // A4 Height
|
||||||
// Create a blank BufferedImage (an image with the size of the sticker)
|
int rows = 3;
|
||||||
BufferedImage stickerImage = new BufferedImage((int) stickerSize.getWidth()*2, (int) stickerSize.getHeight()*2, BufferedImage.TYPE_INT_ARGB);
|
int cols = 2;
|
||||||
Graphics2D g2d = stickerImage.createGraphics();
|
int totalStickersPerPage = rows * cols;
|
||||||
g2d.scale(2,2);
|
int totalPages = (int) Math.ceil((double) artifacts.size() / totalStickersPerPage); // Total required pages
|
||||||
|
List<BufferedImage> bufferedImages = new ArrayList<>();
|
||||||
|
for (int page = 0; page < totalPages; page++) {
|
||||||
|
// Create a Blank A4 Page Image
|
||||||
|
BufferedImage a4Image = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics2D g2d = a4Image.createGraphics();
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
// Set background color (white for the sticker)
|
|
||||||
g2d.setColor(Color.WHITE);
|
g2d.setColor(Color.WHITE);
|
||||||
g2d.fillRect(0, 0, (int) stickerSize.getWidth(), (int) stickerSize.getHeight());
|
g2d.fillRect(0, 0, pageWidth, pageHeight);
|
||||||
|
|
||||||
// Set font for SKU and barcode
|
|
||||||
Font font = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+10);
|
|
||||||
g2d.setFont(font);
|
|
||||||
|
|
||||||
// Add SKU to the image
|
|
||||||
String sku = artifact.getSku();
|
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
|
||||||
int textWidth = fontMetrics.stringWidth(sku);
|
|
||||||
int x = (int) ((stickerSize.getWidth() - textWidth) / 2);
|
|
||||||
g2d.setColor(Color.BLACK);
|
g2d.setColor(Color.BLACK);
|
||||||
g2d.drawString(sku, x, stickerSize.getMarginTop() + fontMetrics.getAscent()+20);
|
|
||||||
|
|
||||||
// Create the barcode image
|
Font barcodeFont = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+8);
|
||||||
byte[] imgBytes = BarcodeUtils.getBarcodeImageByteArray(artifact.getBarcode(), BarcodeFormat.CODE_128, stickerSize.getImageWidthBarcode()+500, stickerSize.getImageHeightBarcode()+30);
|
Font detailFont = new Font("Helvetica", Font.PLAIN, stickerSize.getTextSize()+3);
|
||||||
BufferedImage barcodeImage = ImageIO.read(new ByteArrayInputStream(imgBytes));
|
|
||||||
|
|
||||||
// Draw the barcode image on the sticker
|
for (int i = 0; i < totalStickersPerPage; i++) {
|
||||||
int barcodeX =(int) (stickerSize.getWidth() - barcodeImage.getWidth()) / 2;
|
int artifactIndex = page * totalStickersPerPage + i;
|
||||||
int barcodeY = stickerSize.getMarginTop() + fontMetrics.getAscent() + 30; // Add some margin
|
if (artifactIndex >= artifacts.size()) break;
|
||||||
g2d.drawImage(barcodeImage, barcodeX, barcodeY, null);
|
InventoryArtifact artifact = artifacts.get(artifactIndex);
|
||||||
|
int row = i / cols;
|
||||||
|
int col = i % cols;
|
||||||
|
|
||||||
// Add the barcode value below the barcode image
|
int x = col * (pageWidth / cols);
|
||||||
g2d.drawString(artifact.getBarcode(), (stickerSize.getWidth() - fontMetrics.stringWidth(artifact.getBarcode())) / 2,
|
int y = row * (pageHeight / rows);
|
||||||
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent());
|
|
||||||
|
|
||||||
// If artifactType is Bundle, add additional info
|
Font stickerFont = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize() + 10);
|
||||||
if (artifactType.equalsIgnoreCase(Bundle.class.getSimpleName())) {
|
g2d.setFont(stickerFont);
|
||||||
String typeText = String.format("%s : %d", artifact.getType(), artifact.getId());
|
// Draw Sticker Border
|
||||||
g2d.drawString(typeText, (stickerSize.getWidth() - fontMetrics.stringWidth(typeText)) / 2,
|
g2d.drawRect(x, y, pageWidth / cols, pageHeight / rows);
|
||||||
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 45);
|
|
||||||
|
|
||||||
g2d.setFont(new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+20));
|
this.drawCenteredText(g2d, artifactType.equals("Bundle")?"Sub-Bundle":"Master-Bundle", detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop()-20,stickerSize.getMarginLeft()-165);
|
||||||
g2d.drawString(String.valueOf(artifactType.toCharArray()[0]), (stickerSize.getWidth() - fontMetrics.stringWidth(String.valueOf(artifactType.toCharArray()[0]))) / 2,
|
|
||||||
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 77);
|
// Draw SKU
|
||||||
} else {
|
g2d.setFont(barcodeFont);
|
||||||
// Add first character of artifact type
|
String sku = artifact.getSku();
|
||||||
String type = String.valueOf(artifactType.charAt(0));
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
g2d.setFont(new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+10));
|
int textWidth = fontMetrics.stringWidth(sku);
|
||||||
g2d.drawString(type, (stickerSize.getWidth() - fontMetrics.stringWidth(type)) / 2,
|
g2d.drawString(sku, x + ((pageWidth / cols) - textWidth) / 2, y + fontMetrics.getAscent()+ stickerSize.getMarginTop()+10);
|
||||||
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 45);
|
|
||||||
|
// Generate Barcode Image
|
||||||
|
g2d.setFont(barcodeFont);
|
||||||
|
byte[] imgBytes = BarcodeUtils.getBarcodeImageByteArray(
|
||||||
|
artifact.getBarcode(), BarcodeFormat.CODE_128, stickerSize.getImageWidthBarcode(), stickerSize.getImageHeightBarcode());
|
||||||
|
|
||||||
|
BufferedImage barcodeImage = ImageIO.read(new ByteArrayInputStream(imgBytes));
|
||||||
|
int originalBarcodeWidth = barcodeImage.getWidth();
|
||||||
|
int originalBarcodeHeight = barcodeImage.getHeight();
|
||||||
|
|
||||||
|
|
||||||
|
double scaleX = (double)(pageWidth / cols) / originalBarcodeWidth;
|
||||||
|
double scaleY = (double)(pageHeight / rows) / originalBarcodeHeight;
|
||||||
|
double scaleFactor = Math.min(scaleX, scaleY);
|
||||||
|
|
||||||
|
int scaledWidth = (int)(originalBarcodeWidth * scaleFactor) - 30;
|
||||||
|
int scaledHeight = (int)(originalBarcodeHeight * scaleFactor) - 10;
|
||||||
|
|
||||||
|
BufferedImage scaledBarcodeImage = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics2D g2dBarcode = scaledBarcodeImage.createGraphics();
|
||||||
|
g2dBarcode.drawImage(barcodeImage, 0, 0, scaledWidth, scaledHeight, null);
|
||||||
|
g2dBarcode.dispose();
|
||||||
|
|
||||||
|
int barcodeX = x + ((pageWidth / cols) - scaledBarcodeImage.getWidth()) / 2;
|
||||||
|
int barcodeY = y + fontMetrics.getAscent() + stickerSize.getMarginTop() + 20;
|
||||||
|
g2d.drawImage(scaledBarcodeImage, barcodeX, barcodeY, null);
|
||||||
|
|
||||||
|
//barcode text
|
||||||
|
g2d.setFont(barcodeFont);
|
||||||
|
String barcode = artifact.getBarcode();
|
||||||
|
FontMetrics barcodeFontMatrix = g2d.getFontMetrics();
|
||||||
|
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());
|
||||||
|
this.drawCenteredText(g2d, "Created-At: "+formatter.format(artifact.getCreatedAt()), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 190,stickerSize.getMarginLeft());
|
||||||
|
|
||||||
|
//draw job-card details
|
||||||
|
JobCard jobCard = jobCardDAO.find(artifact.getJobCardId());
|
||||||
|
|
||||||
|
this.drawCenteredText(g2d, "Job-Card: " + jobCard.getCode(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 210, stickerSize.getMarginLeft() );
|
||||||
|
this.drawCenteredText(g2d, "Purchase-Order: " + jobCard.getPurchaseOrderId(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 230, stickerSize.getMarginLeft());
|
||||||
|
this.drawCenteredText(g2d, "Lot-Number: " + jobCard.getLotNumber(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 250, stickerSize.getMarginLeft());
|
||||||
|
if((artifactType.equals("Bundle"))){
|
||||||
|
JobCardItem jobCardItem = jobCardItemDAO.findByCardId(jobCard.getId()).get(0);
|
||||||
|
InventoryAccount inventoryAccount = inventoryAccountDAO.find(jobCardItem.getAccountId());
|
||||||
|
this.drawCenteredText(g2d, "Pieces: " + artifact.getWrapQuantity(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 270, stickerSize.getMarginLeft());
|
||||||
|
this.drawCenteredText(g2d, "Cutting-Account: " + inventoryAccount.getTitle() , detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 290, stickerSize.getMarginLeft());
|
||||||
|
}else {
|
||||||
|
List<Bundle> bundles = bundleDAO.findByMasterId(artifact.getId());
|
||||||
|
String concatenatedIds = bundles.stream()
|
||||||
|
.map(bundle -> String.valueOf(bundle.getId()))
|
||||||
|
.collect(Collectors.joining("\\"));
|
||||||
|
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();
|
g2d.dispose();
|
||||||
printLabel(stickerImage);
|
bufferedImages.add(a4Image);
|
||||||
|
}
|
||||||
|
saveA4ImageToPDF(bufferedImages,bundlePath);
|
||||||
|
try {
|
||||||
|
printPDF(bundleIpAddress, bundlePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printLabel( BufferedImage bufferedImage ) throws Exception {
|
public void printPDF(String printerIP, String pdfFilePath) throws Exception {
|
||||||
Connection connection = new TcpConnection( ipAddress, port );
|
File pdfFile = new File(pdfFilePath);
|
||||||
|
FileInputStream fis = new FileInputStream(pdfFile);
|
||||||
|
|
||||||
|
Socket printerSocket = new Socket(printerIP, port);
|
||||||
|
OutputStream out = printerSocket.getOutputStream();
|
||||||
|
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
fis.close();
|
||||||
|
printerSocket.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveA4ImageToPDF(List<BufferedImage> a4Images, String outputFilePath) throws Exception {
|
||||||
|
PdfWriter writer = new PdfWriter(outputFilePath);
|
||||||
|
PdfDocument pdfDoc = new PdfDocument(writer);
|
||||||
|
Document document = new Document(pdfDoc, PageSize.A4);
|
||||||
|
document.setMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < a4Images.size(); i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
document.add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(a4Images.get(i), "png", baos);
|
||||||
|
byte[] imageBytes = baos.toByteArray();
|
||||||
|
ImageData imageData = ImageDataFactory.create(imageBytes);
|
||||||
|
Image image = new Image(imageData);
|
||||||
|
|
||||||
|
// Scale and position correctly
|
||||||
|
image.scaleToFit(pdfDoc.getDefaultPageSize().getWidth(), pdfDoc.getDefaultPageSize().getHeight());
|
||||||
|
image.setFixedPosition(0, 30);
|
||||||
|
document.add(image);
|
||||||
|
}
|
||||||
|
document.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
int adjustedX = (x + ((pageWidth / cols) ) / 2) - marginLeft;
|
||||||
|
int adjustedY = y + fontMetrics.getAscent() + marginTop;
|
||||||
|
g2d.drawString(text, adjustedX, adjustedY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void getBarcodeImagesForStitchItems(List<? extends InventoryArtifact> artifacts,
|
||||||
|
BarcodeStickerSize stickerSize) throws Exception {
|
||||||
|
|
||||||
|
Path pdfPath = FileSystems.getDefault().getPath(stitchPath);
|
||||||
|
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());
|
||||||
|
|
||||||
|
PdfPage page = pdfDoc.addNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
canvas.setFillColor(ColorConstants.WHITE);
|
||||||
|
canvas.rectangle(0, 0, stickerSize.getWidth(), stickerSize.getHeight());
|
||||||
|
canvas.fill();
|
||||||
|
|
||||||
|
// Draw QR Code on Left Side
|
||||||
|
byte[] imgBytes = generateQRCodeImageByteArray(artifact.getBarcode(), stickerSize.getImageWidthBarcode(), stickerSize.getImageHeightBarcode());
|
||||||
|
Image qrCodeImage = new Image(ImageDataFactory.create(imgBytes));
|
||||||
|
|
||||||
|
float qrY =stickerSize.getMarginLeft()+50 ;
|
||||||
|
float qrX = stickerSize.getMarginTop();
|
||||||
|
|
||||||
|
qrCodeImage.setFixedPosition(qrX - 16, qrY-47);
|
||||||
|
document.add(qrCodeImage);
|
||||||
|
|
||||||
|
float textX = stickerSize.getMarginLeft() + 40;
|
||||||
|
float textY = stickerSize.getMarginTop() + 40;
|
||||||
|
|
||||||
|
String sku = artifact.getSku();
|
||||||
|
String jobCardCode = jobCard.getCode();
|
||||||
|
String combinedText = sku + " \\ " + jobCardCode + " \\ " + artifact.getBundleId();
|
||||||
|
combinedText = combinedText.replaceAll("\\s+", "");
|
||||||
|
|
||||||
|
int maxLength = 14;
|
||||||
|
List<String> lines = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
int start = i * maxLength;
|
||||||
|
if (start < combinedText.length()) {
|
||||||
|
String part = combinedText.substring(start, Math.min(start + maxLength, combinedText.length())).replaceAll("\\s+", "");
|
||||||
|
lines.add(part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float labelWidth = 67.69f;
|
||||||
|
float textBoxWidth = 220;
|
||||||
|
float textY1 = textY-30;
|
||||||
|
float textXCenter = textX + (labelWidth / 2) - (textBoxWidth / 2)-50;
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
Paragraph rotatedText = new Paragraph(line)
|
||||||
|
.setFontColor(ColorConstants.BLACK)
|
||||||
|
.setFontSize(stickerSize.getTextSize() + 2)
|
||||||
|
.setTextAlignment(TextAlignment.CENTER)
|
||||||
|
.setFixedPosition(textXCenter, textY1-18, textBoxWidth);
|
||||||
|
|
||||||
|
document.add(rotatedText);
|
||||||
|
textY1 -= 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER_OBLIQUE);
|
||||||
|
String id = String.valueOf(artifact.getId());
|
||||||
|
document.add(new Paragraph(id)
|
||||||
|
.setFont(font)
|
||||||
|
.setFontColor(ColorConstants.BLACK)
|
||||||
|
.setBold()
|
||||||
|
.setFontSize(stickerSize.getTextSize() + 8)
|
||||||
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
|
.setFixedPosition(textX - 25, textY + 8, 140));
|
||||||
|
|
||||||
|
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)
|
||||||
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
|
.setFixedPosition(dottedLine,textX+40, 100));
|
||||||
|
|
||||||
|
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)
|
||||||
|
.setTextAlignment(TextAlignment.LEFT)
|
||||||
|
.setFixedPosition(dottedLine2,textX+75, 100));
|
||||||
|
|
||||||
|
dottedLine2 += 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!artifact.equals(artifacts.get(artifacts.size() - 1))) {
|
||||||
|
document.add(new AreaBreak());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pdfDoc.getNumberOfPages() > artifacts.size()) {
|
||||||
|
pdfDoc.removePage(pdfDoc.getNumberOfPages());
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
Map<EncodeHintType, Object> hintMap = new HashMap<>();
|
||||||
|
hintMap.put(EncodeHintType.MARGIN, 0);
|
||||||
|
BitMatrix bitMatrix = qrCodeWriter.encode(data, BarcodeFormat.QR_CODE, width, height, hintMap);
|
||||||
|
BufferedImage qrImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
qrImage.createGraphics().fillRect(0, 0, width, height);
|
||||||
|
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
qrImage.setRGB(x, y, bitMatrix.get(x, y) ? 0x000000 : 0xFFFFFF); // Black and white
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(qrImage, "PNG", baos);
|
||||||
|
return baos.toByteArray();
|
||||||
|
} catch (WriterException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printLabel(BufferedImage bufferedImage) throws Exception {
|
||||||
|
Connection connection = new TcpConnection(ipAddress, port);
|
||||||
connection.open();
|
connection.open();
|
||||||
ZebraPrinter printer = ZebraPrinterFactory.getInstance( connection );
|
|
||||||
ZebraImage zebraImage = new ZebraImage( bufferedImage );
|
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
|
||||||
printer.printImage( zebraImage, 0, 0, 0, 0, false );
|
|
||||||
|
//Reset Printer Settings
|
||||||
|
String resetSettings = "^XA^JUS^XZ";
|
||||||
|
printer.sendCommand(resetSettings);
|
||||||
|
|
||||||
|
//Force Label Length & Disable Auto Feed
|
||||||
|
String lengthFix = "^XA^LL555^PON^XZ"; // **Reduce Length (880) & Disable Auto Feed
|
||||||
|
printer.sendCommand(lengthFix);
|
||||||
|
|
||||||
|
//Apply New Settings
|
||||||
|
String settings = "^XA" +
|
||||||
|
"^MMT" + // Continuous Mode
|
||||||
|
"^MTT" + // Thermal Transfer Mode
|
||||||
|
"^LH0,0" + // Home Position
|
||||||
|
"^PR6" + // Print Speed (~120mm/sec)
|
||||||
|
"^MD25" + // Darkness Level
|
||||||
|
"^PW541" + // Label Width (67.69mm for 203 DPI)
|
||||||
|
"^LL550" + // Reduced Label Length (fix gap)
|
||||||
|
"^PN0" + // No Extra Page Feed
|
||||||
|
"^PON" + // Disable Printer's Auto Feed Mode
|
||||||
|
"^XZ";
|
||||||
|
|
||||||
|
printer.sendCommand(settings);
|
||||||
|
|
||||||
|
// Convert BufferedImage to ZebraImage
|
||||||
|
ZebraImage zebraImage = new ZebraImage(bufferedImage);
|
||||||
|
|
||||||
|
// Print image
|
||||||
|
printer.printImage(zebraImage, 0, 0, 0, 0, false);
|
||||||
|
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,9 +15,11 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BundleService {
|
public class BundleService {
|
||||||
|
@ -54,6 +56,35 @@ public class BundleService {
|
||||||
return bundles;
|
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
|
* find master bundles by params
|
||||||
* */
|
* */
|
||||||
|
@ -109,7 +140,6 @@ public class BundleService {
|
||||||
return stitchingOfflineItems;
|
return stitchingOfflineItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.utopiaindustries.service;
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.*;
|
import com.utopiaindustries.dao.ctp.*;
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
|
import com.utopiaindustries.model.ctp.BundleWrapper;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -90,7 +91,7 @@ public class InventoryService {
|
||||||
|
|
||||||
for ( JobCardItem jobCardItem : items) {
|
for ( JobCardItem jobCardItem : items) {
|
||||||
// create + save bundles
|
// 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
|
// create transactions
|
||||||
createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( ));
|
createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) );
|
jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) );
|
||||||
|
@ -155,10 +156,12 @@ public class InventoryService {
|
||||||
|
|
||||||
if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) {
|
if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) {
|
||||||
initialBalance = initialBalance.add( inventoryTransactionLeg.getQuantity( ));
|
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( ))) {
|
||||||
initialBalance = BigDecimal.ZERO;
|
if (inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)) {
|
||||||
} else {
|
initialBalance = BigDecimal.ZERO;
|
||||||
initialBalance = initialBalance.subtract( inventoryTransactionLeg.getQuantity( ));
|
} else {
|
||||||
|
initialBalance = initialBalance.subtract(inventoryTransactionLeg.getQuantity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inventoryTransactionLeg.setBalance( initialBalance);
|
inventoryTransactionLeg.setBalance( initialBalance);
|
||||||
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
||||||
|
@ -179,18 +182,18 @@ public class InventoryService {
|
||||||
|
|
||||||
// create bundles from cut pieces
|
// create bundles from cut pieces
|
||||||
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
||||||
List<CutPiece> jobCardItemPieces ) {
|
List<CutPiece> jobCardItemPieces, BigDecimal value ) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||||
if ( jobCardItemPieces != null && !jobCardItemPieces.isEmpty( )) {
|
if ( value != null && !value.equals(BigDecimal.ZERO)) {
|
||||||
List<Bundle> bundles = new ArrayList<>( );
|
List<Bundle> bundles = new ArrayList<>( );
|
||||||
// create bundle against every cut piece
|
// create bundle against every cut piece
|
||||||
for ( CutPiece cutPiece : jobCardItemPieces ) {
|
if(value.intValue()<=20){
|
||||||
Bundle bundle = new Bundle( );
|
Bundle bundle = new Bundle( );
|
||||||
bundle.setItemId( jobCardItem.getItemId( ));
|
bundle.setItemId( jobCardItem.getItemId( ));
|
||||||
bundle.setSku( jobCardItem.getSku( ));
|
bundle.setSku( jobCardItem.getSku( ));
|
||||||
bundle.setJobCardId( jobCardItem.getJobCardId( ) );
|
bundle.setJobCardId( jobCardItem.getJobCardId( ) );
|
||||||
bundle.setWrapQuantity( cutPiece.getQuantity( ));
|
bundle.setWrapQuantity(value);
|
||||||
bundle.setType( cutPiece.getType( ));
|
bundle.setType( "BUNDLE");
|
||||||
bundle.setCreatedAt( LocalDateTime.now( ));
|
bundle.setCreatedAt( LocalDateTime.now( ));
|
||||||
bundle.setCreatedBy( authentication.getName( ));
|
bundle.setCreatedBy( authentication.getName( ));
|
||||||
bundles.add( bundle);
|
bundles.add( bundle);
|
||||||
|
@ -198,8 +201,32 @@ public class InventoryService {
|
||||||
bundle.setBarcode( cryptographyService.generateRandomString( 15));
|
bundle.setBarcode( cryptographyService.generateRandomString( 15));
|
||||||
// save again after barcode generation
|
// save again after barcode generation
|
||||||
bundle.setId( bundleDAO.save( bundle));
|
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<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
// for ( Map.Entry<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
||||||
// JobCardItem key = entry.getKey( );
|
// JobCardItem key = entry.getKey( );
|
||||||
// List<CutPiece> value = entry.getValue( );
|
// List<CutPiece> value = entry.getValue( );
|
||||||
|
@ -243,11 +270,13 @@ public class InventoryService {
|
||||||
long fromAccount = lastInvTransaction.getAccountId( );
|
long fromAccount = lastInvTransaction.getAccountId( );
|
||||||
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
// IN
|
// 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
|
// update status
|
||||||
masterBundle.setIsReceived( true);
|
masterBundle.setIsReceived( true);
|
||||||
|
masterBundle.setAccountId(toAccount);
|
||||||
masterBundleDAO.save( masterBundle);
|
masterBundleDAO.save( masterBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,73 +325,69 @@ public class InventoryService {
|
||||||
* create finished items from master bundles
|
* create finished items from master bundles
|
||||||
* */
|
* */
|
||||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||||
public void createStitchingOfflineItemsFromJobCard( JobCard jobCard) {
|
public void createStitchingOfflineItemsFromJobCard( BundleWrapper wrapper) {
|
||||||
List<JobCardItem> jobCardItems = jobCard.getItems( );
|
List<JobCardItem> updatedItems = new ArrayList<>();
|
||||||
List<JobCardItem> updatedItems = new ArrayList<>( );
|
List<Bundle> updateBundles = new ArrayList<>();
|
||||||
|
JobCard jobCard = null;
|
||||||
|
|
||||||
// validate items
|
//switching table transaction in Transaction Table
|
||||||
validateItems( jobCardItems);
|
InventoryTransaction transaction = createInventoryTransaction("Against Movement from Stitching to Stitched Offline Item");
|
||||||
// check whether all bundles are received against finish goods
|
inventoryTransactionDAO.save(transaction);
|
||||||
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( ));
|
|
||||||
|
|
||||||
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
//TransactionLeg Transaction
|
||||||
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), bundleIds, InventoryArtifactType.BUNDLE.name( ))
|
List<Long> bundleIds = wrapper.getBundles().stream().map(Bundle::getId).collect(Collectors.toList());
|
||||||
.stream( )
|
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
||||||
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), bundleIds, InventoryArtifactType.STITCH_BUNDLE.name())
|
||||||
// create Transaction
|
.stream()
|
||||||
InventoryTransaction transaction = createInventoryTransaction( "Against Movement from Stitching to Stitched Offline Item");
|
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
||||||
inventoryTransactionDAO.save( transaction);
|
for (Bundle subBundle : wrapper.getBundles()) {
|
||||||
// create transaction legs
|
long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId();
|
||||||
for ( Bundle bundle : bundles) {
|
if(subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0){
|
||||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault( bundle.getId( ), null);
|
Bundle bundle = bundleDAO.find(subBundle.getId());
|
||||||
if ( lastInvTransaction != null) {
|
jobCard = jobCardDAO.find(subBundle.getJobCardId());
|
||||||
// OUT
|
long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue() ;
|
||||||
long fromAccount = lastInvTransaction.getAccountId( );
|
long wrapQuantity = bundle.getWrapQuantity().longValue();
|
||||||
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
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
|
// create stitchingOfflineItems items
|
||||||
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems( item);
|
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems(subBundle.getCurrentProduction(),jobCardItem,subBundle.getId());
|
||||||
// create IN Transactions of Finished Items into account
|
// create IN Transactions of Finished Items into account
|
||||||
createTransactions( stitchingOfflineItems, jobCard.getToAccountId( ), InventoryArtifactType.STITCHING_OFFLINE.name( ));
|
createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name());
|
||||||
item.setTotalProduction( item.getTotalProduction( ).add( item.getProduction( )));
|
|
||||||
item.setJobCardId( jobCard.getId( ));
|
jobCardItem.setTotalProduction(jobCardItem.getTotalProduction().add(subBundle.getCurrentProduction()));
|
||||||
updatedItems.add( item);
|
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
|
* create finished items
|
||||||
* */
|
* */
|
||||||
public List<StitchingOfflineItem> createStitchingOfflineItems( JobCardItem jobCardItem) {
|
public List<StitchingOfflineItem> createStitchingOfflineItems( BigDecimal totalItem, JobCardItem jobCardItem,long bundleId) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||||
List<StitchingOfflineItem> items = new ArrayList<>( );
|
List<StitchingOfflineItem> items = new ArrayList<>( );
|
||||||
if ( jobCardItem != null) {
|
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 stitchingOfflineItem = new StitchingOfflineItem( );
|
||||||
stitchingOfflineItem.setCreatedAt( LocalDateTime.now( ));
|
stitchingOfflineItem.setCreatedAt( LocalDateTime.now( ));
|
||||||
stitchingOfflineItem.setCreatedBy( authentication.getName( ));
|
stitchingOfflineItem.setCreatedBy( authentication.getName( ));
|
||||||
stitchingOfflineItem.setItemId( jobCardItem.getItemId( ));
|
stitchingOfflineItem.setItemId( jobCardItem.getItemId( ));
|
||||||
stitchingOfflineItem.setSku( jobCardItem.getSku( ));
|
stitchingOfflineItem.setSku( jobCardItem.getSku( ));
|
||||||
|
stitchingOfflineItem.setBundleId(bundleId);
|
||||||
stitchingOfflineItem.setJobCardId( jobCardItem.getJobCardId( ));
|
stitchingOfflineItem.setJobCardId( jobCardItem.getJobCardId( ));
|
||||||
stitchingOfflineItem.setIsQa( false );
|
stitchingOfflineItem.setIsQa( false );
|
||||||
long id = stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
long id = stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
||||||
|
|
|
@ -35,8 +35,10 @@ public class JobCardService {
|
||||||
private final UserInventoryAccountDAO userInventoryAccountDAO;
|
private final UserInventoryAccountDAO userInventoryAccountDAO;
|
||||||
private final FinishedItemDAO finishedItemDAO;
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
||||||
|
private final SkuCutPiecesDAO skuCutPiecesDAO;
|
||||||
|
|
||||||
public JobCardService(JobCardDAO jobCardDAO, CutPieceTypeDAO cutPieceTypeDAO, JobCardItemDAO jobCardItemDAO, CutPieceDAO cutPieceDAO, ItemDAO itemDAO, LocationSiteDAO locationSiteDAO, PurchaseOrderDAO purchaseOrderDAO, UserInventoryAccountDAO userInventoryAccountDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO) {
|
public JobCardService(JobCardDAO jobCardDAO, CutPieceTypeDAO cutPieceTypeDAO, JobCardItemDAO jobCardItemDAO, CutPieceDAO cutPieceDAO, ItemDAO itemDAO, LocationSiteDAO locationSiteDAO, PurchaseOrderDAO purchaseOrderDAO, UserInventoryAccountDAO userInventoryAccountDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, SkuCutPiecesDAO skuCutPiecesDAO) {
|
||||||
|
this.skuCutPiecesDAO = skuCutPiecesDAO;
|
||||||
this.jobCardDAO = jobCardDAO;
|
this.jobCardDAO = jobCardDAO;
|
||||||
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
||||||
this.jobCardItemDAO = jobCardItemDAO;
|
this.jobCardItemDAO = jobCardItemDAO;
|
||||||
|
@ -138,6 +140,13 @@ public class JobCardService {
|
||||||
long itemId = jobCardItemDAO.save(item);
|
long itemId = jobCardItemDAO.save(item);
|
||||||
for (CutPiece cutPiece : item.getCutPieces()) {
|
for (CutPiece cutPiece : item.getCutPieces()) {
|
||||||
cutPiece.setJobCardItemId(itemId);
|
cutPiece.setJobCardItemId(itemId);
|
||||||
|
if (!skuCutPiecesDAO.doesExist(cutPiece.getType(), item.getSku())){
|
||||||
|
SkuCutPieces skuCutPieces = new SkuCutPieces();
|
||||||
|
skuCutPieces.setType(cutPiece.getType());
|
||||||
|
skuCutPieces.setSku(item.getSku());
|
||||||
|
//save cut-piece for sku next time fetch
|
||||||
|
skuCutPiecesDAO.save(skuCutPieces);
|
||||||
|
}
|
||||||
cutPieces.add(cutPiece);
|
cutPieces.add(cutPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,9 @@ spring:
|
||||||
|
|
||||||
ctp:
|
ctp:
|
||||||
printer:
|
printer:
|
||||||
ipAdd: 172.16.53.32
|
ipAdd: 172.16.53.53
|
||||||
port: 9100
|
port: 9100
|
||||||
|
stitchQRPath: ./src/main/resources/static/sample_qr_output.pdf
|
||||||
|
bundleIpAdd: 172.16.53.22
|
||||||
|
bundlePort: 9100
|
||||||
|
bundlePath: ./src/main/resources/static/bundle.pdf
|
|
@ -1,7 +1,7 @@
|
||||||
application:
|
application:
|
||||||
title: Cut To Pack Service
|
title: Cut To Pack Service
|
||||||
version: v1.0
|
version: v1.0
|
||||||
name: application-dev
|
name: application-prod
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
|
|
|
@ -84,6 +84,24 @@
|
||||||
onItemSelect(itemId, invItem) {
|
onItemSelect(itemId, invItem) {
|
||||||
this.item.itemId = invItem.id;
|
this.item.itemId = invItem.id;
|
||||||
this.item.sku = invItem.sku;
|
this.item.sku = invItem.sku;
|
||||||
|
},
|
||||||
|
searchCutPieceBySku(sku) {
|
||||||
|
$.ajax({
|
||||||
|
url: `/ctp/rest/cut-pieces?sku=${sku}`,
|
||||||
|
method: 'GET',
|
||||||
|
success: (response) => {
|
||||||
|
this.$set(this.item, 'cutPieces', response);
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'item.sku': function(newSku, oldSku) {
|
||||||
|
console.log('SKU changed:', newSku);
|
||||||
|
this.searchCutPieceBySku(newSku);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
|
@ -161,8 +179,6 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
@ -177,15 +193,16 @@
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<div class="row mt-1">
|
<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">
|
||||||
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].jobCardItemId'" v-bind:value="piece.jobCardItemId">
|
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<select class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].type'" v-model="piece.type" required>
|
<select class="form-control"
|
||||||
<option value="">Please Select</option>
|
v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].type'"
|
||||||
<option v-for="(type,index) in $types"
|
v-model="piece.type" required>
|
||||||
v-bind:selected="type.title === piece.type"
|
<option value="">Please Select</option>
|
||||||
v-bind:value="type.title">{{type.title}}</option>
|
<option v-for="(title, index) in $types"
|
||||||
</select>
|
v-bind:selected="title.type === piece.type"
|
||||||
|
v-bind:value="title.type">{{ title.type }}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<input type="number" class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].quantity'" v-model="piece.quantity" required>
|
<input type="number" class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].quantity'" v-model="piece.quantity" required>
|
||||||
|
@ -195,10 +212,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let app = new Vue({
|
let app = new Vue({
|
||||||
el: '#jobCardApp',
|
el: '#jobCardApp',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -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 + '].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 + '].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 + '].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">
|
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
||||||
<span> {{item.id}} </span>
|
<span> {{item.id}} </span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<item-search
|
<item-search
|
||||||
v-bind:id-field-name="'items[' + index + '].itemId'"
|
v-bind:id-field-name="'items[' + index + '].itemId'"
|
||||||
v-bind:id="item.itemId"
|
v-bind:id="item.itemId"
|
||||||
v-bind:title="item.title"
|
v-bind:type="item.type"
|
||||||
v-bind:show-label="false"
|
v-bind:show-label="false"
|
||||||
v-bind:disabled="true"></item-search>
|
v-bind:disabled="true"></item-search>
|
||||||
</td>
|
</td>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<span class="form-control" readonly>{{item.expectedProduction}}</span>
|
<span class="form-control" readonly>{{item.expectedProduction}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td width="200">
|
<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>
|
||||||
<td>
|
<td>
|
||||||
{{ populateCuttingAccount() }}
|
{{ populateCuttingAccount() }}
|
||||||
|
@ -64,12 +64,12 @@
|
||||||
<select style="width: 150px;" class="form-control" v-bind:name="'pieces[' + index +'].type'" v-model="piece.type" disabled>
|
<select style="width: 150px;" class="form-control" v-bind:name="'pieces[' + index +'].type'" v-model="piece.type" disabled>
|
||||||
<option value="">Please Select</option>
|
<option value="">Please Select</option>
|
||||||
<option v-for="(type,index) in $types"
|
<option v-for="(type,index) in $types"
|
||||||
v-bind:selected="type.title === piece.type"
|
v-bind:selected="type.type === piece.type"
|
||||||
v-bind:value="type.title">{{type.title}}</option>
|
v-bind:value="type.type">{{type.type}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6" style="padding-left: 40px;">
|
<div class="col-md-6" style="padding-left: 40px;">
|
||||||
<input class="form-control" type="number" v-bind:name="'items[' + pIndex + '].pieces[' + index +'].quantity'" v-model="piece.quantity" required/>
|
<input class="form-control" type="number" v-bind:name="'items[' + pIndex + '].pieces[' + index +'].quantity'" v-model="piece.quantity" min="0" required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
onJobCardSelect : function( id, card ){
|
onJobCardSelect : function( id, card ){
|
||||||
this.card = card;
|
this.card = card;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/ctp/rest/job-cards/${id}/items`,
|
url: `/ctp/rest/job-cards/${id}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
dataType: '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 () {
|
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
|
* job card search
|
||||||
* */
|
* */
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
<select name="type" class="form-control">
|
<select name="type" class="form-control">
|
||||||
<option value="">Please select</option>
|
<option value="">Please select</option>
|
||||||
<option th:each="type: ${types}"
|
<option th:each="type: ${types}"
|
||||||
th:value="${type.title}"
|
th:value="${type.type}"
|
||||||
th:text="${type.title}"
|
th:text="${type.type}"
|
||||||
th:selected="${#strings.equals(param['type'], #strings.toString(type.title))}"
|
th:selected="${#strings.equals(param['type'], #strings.toString(type.type))}"
|
||||||
></option>
|
></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
<th>Sku</th>
|
<th>Sku</th>
|
||||||
<th>Created By</th>
|
<th>Created By</th>
|
||||||
<th>Created At</th>
|
<th>Created At</th>
|
||||||
|
<th>Received</th>
|
||||||
<th>
|
<th>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<button class="btn btn-sm btn-outline-primary" type="submit">Generate
|
<button class="btn btn-sm btn-outline-primary" type="submit">Generate
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
<td th:text="*{sku}"></td>
|
<td th:text="*{sku}"></td>
|
||||||
<td th:text="*{createdBy}"></td>
|
<td th:text="*{createdBy}"></td>
|
||||||
<td ctp:formatdatetime="*{createdAt}"></td>
|
<td ctp:formatdatetime="*{createdAt}"></td>
|
||||||
|
<td th:text="${bundle.isReceived ? 'YES' : 'NO'}"></td>
|
||||||
<td>
|
<td>
|
||||||
<div class="form-group form-check mb-0">
|
<div class="form-group form-check mb-0">
|
||||||
<input class="form-check-input" type="checkbox"
|
<input class="form-check-input" type="checkbox"
|
||||||
|
|
|
@ -121,6 +121,7 @@
|
||||||
<td>
|
<td>
|
||||||
<span th:if="${cardStitchingItem.getQaStatus() == 'APPROVED'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-APPROVED font-sm"></span>
|
<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() == '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>
|
||||||
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
||||||
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
||||||
|
|
|
@ -13,26 +13,17 @@
|
||||||
<form th:action="@{/stitching/create-stitching-items}"
|
<form th:action="@{/stitching/create-stitching-items}"
|
||||||
method="POST"
|
method="POST"
|
||||||
id="finishedItemApp"
|
id="finishedItemApp"
|
||||||
th:object="${jobCard}">
|
th:object="${bundleWrapper}">
|
||||||
|
|
||||||
<div class="bg-light p-3 mb-3 col-sm-8">
|
<div class="bg-light p-3 mb-3 col-sm-8">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-sm-5 p-0">
|
<div class="col-sm-5 p-0">
|
||||||
<job-card-search
|
<bundle-search-by-barcode
|
||||||
v-bind:id-field-name="'id'"
|
v-bind:id-field-name="'id'"
|
||||||
v-bind:filter="false"
|
v-bind:filter="false"
|
||||||
v-bind:items="true"
|
v-bind:items="true"
|
||||||
v-on:job-card-select="onJobCardSelect">
|
v-on:job-card-select="onBundleSelects">
|
||||||
</job-card-search>
|
</bundle-search-by-barcode>
|
||||||
</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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,48 +37,48 @@
|
||||||
<th>Item ID</th>
|
<th>Item ID</th>
|
||||||
<th>Sku</th>
|
<th>Sku</th>
|
||||||
<th>Expected Production</th>
|
<th>Expected Production</th>
|
||||||
<th>Actual Production</th>
|
|
||||||
<th>Current Production</th>
|
<th>Current Production</th>
|
||||||
<th>Production</th>
|
<th>Production</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody>
|
<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 >
|
<td >
|
||||||
<div class="form-group form-check mb-0">
|
<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">
|
<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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
<span class="form-control">{{item.id}}</span>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
<span class="form-control">{{item.itemId}}</span>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
<span class="form-control">{{item.sku}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].expectedProduction'" v-bind:value="item.expectedProduction">
|
<input hidden="hidden" v-bind:name="'bundles[' + index + '].wrapQuantity'" v-bind:value="item.wrapQuantity">
|
||||||
<span class="form-control">{{item.expectedProduction}}</span>
|
<span class="form-control">{{item.wrapQuantity}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].actualProduction'" v-bind:value="item.actualProduction">
|
<input hidden="hidden" v-bind:name="'bundles[' + index + '].production'" v-bind:value="item.production">
|
||||||
<span class="form-control">{{item.actualProduction}}</span>
|
<span class="form-control">{{item.production}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].totalProduction'" v-bind:value="item.totalProduction">
|
<input class="form-control" v-bind:name="'bundles[' + index + '].currentProduction'"
|
||||||
<span class="form-control">{{item.totalProduction}}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input class="form-control" v-bind:name="'items[' + index + '].production'"
|
|
||||||
type="number"
|
type="number"
|
||||||
v-bind:value="item.production"
|
v-bind:value="item.currentProduction"
|
||||||
v-bind:min="0"
|
v-bind:min="0"
|
||||||
v-bind:max="item.actualProduction - item.totalProduction"
|
v-bind:max="item.wrapQuantity - item.production"
|
||||||
v-bind:readonly="!item.isSelected"
|
v-bind:readonly="!item.isSelected"
|
||||||
>
|
>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue