Compare commits

...

20 Commits

Author SHA1 Message Date
usama.jameel c2e04a0284 Merge pull request 'fix po pdf layout' (#31) from fix-po-pdf-layout into main
Reviewed-on: #31
2025-06-16 04:57:56 +00:00
usama.jameel b083a12b3a fix po pdf layout 2025-06-16 09:55:50 +05:00
usama.jameel a17a6b358c Merge pull request 'fix-po-pdf-layout' (#30) from fix-po-pdf-layout into main
Reviewed-on: #30
2025-06-13 10:09:42 +00:00
usama.jameel d14a24fa3f Merge branch 'main' of https://git.utopiadeals.com/UIND/cut-to-pack-service into fix-po-pdf-layout 2025-06-13 15:05:31 +05:00
saif.haq 3d3f8c4c1e Merge pull request 'po-store-category-items' (#29) from po-store-category-items into main
Reviewed-on: http://git.utopiadeals.com:8080/UIND/cut-to-pack-service/pulls/29
2025-06-12 11:00:51 +00:00
usama.jameel 2fa65059c4 fix po pdf layout 2025-06-12 15:04:57 +05:00
usama.jameel 59a430de50 fix order table 2025-06-11 11:17:48 +05:00
usama.jameel c80cca6811 add store pop up window in po status pdf generating screen 2025-06-11 09:21:17 +05:00
usama.jameel b255071c2e finish value set in dashboard screen one 2025-06-10 11:11:00 +05:00
usama.jameel d6a9c6a87c add store receiving categories and fixed account select field required 2025-06-10 10:37:17 +05:00
usama.jameel a0aa80ba8c add qa status online and in header 2025-06-04 15:32:26 +05:00
usama.jameel c8bffbb24a add po-online-status 2025-06-03 13:46:09 +05:00
usama.jameel 98a4f33f5a Merge pull request 'add-store' (#27) from add-store into main
Reviewed-on: #27
2025-05-29 06:58:33 +00:00
usama.jameel 3d981345c3 change qc finished page heading 2025-05-29 11:56:57 +05:00
usama.jameel eb82cbd5b2 add select account in store and packaging screen 2025-05-29 11:51:12 +05:00
usama.jameel e8b107ac72 add store and add transactions functionalities 2025-05-27 16:23:35 +05:00
usama.jameel 38d57343d5 Merge pull request 'qa-report' (#26) from qa-report into main
Reviewed-on: #26
2025-05-27 07:01:32 +00:00
usama.jameel 96bd395261 Merge pull request 'fixed data issue for dashboard' (#25) from qa-report into main
Reviewed-on: #25
2025-05-23 09:46:53 +00:00
usama.jameel 0a43acbcbe Merge pull request 'qa-report' (#24) from qa-report into main
Reviewed-on: #24
2025-05-23 04:07:34 +00:00
usama.jameel 2bc6f810e3 Merge pull request 'qa-report' (#23) from qa-report into main
Reviewed-on: #23
2025-05-20 11:05:52 +00:00
46 changed files with 1692 additions and 302 deletions

View File

@ -0,0 +1,14 @@
package com.utopiaindustries.auth;
import org.springframework.security.access.prepost.PreAuthorize;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@PreAuthorize( "hasAnyRole('ROLE_STORE','ROLE_ADMIN')")
public @interface StoreRole {
}

View File

@ -35,22 +35,22 @@ public class DataSourceConfiguration {
/* COSMOS */
@Bean(name = "dataSourceCosmos")
@ConfigurationProperties(prefix = "spring.cosmosdatasource")
public DataSource cosmosDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "jdbcTemplateCosmos")
public JdbcTemplate cosmosJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
return new JdbcTemplate( ds );
}
@Bean(name = "namedParameterJdbcTemplateCosmos")
public NamedParameterJdbcTemplate cosmosNamedParameterJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
return new NamedParameterJdbcTemplate( ds );
}
// @Bean(name = "dataSourceCosmos")
// @ConfigurationProperties(prefix = "spring.cosmosdatasource")
// public DataSource cosmosDataSource() {
// return DataSourceBuilder.create().build();
// }
//
//
// @Bean(name = "jdbcTemplateCosmos")
// public JdbcTemplate cosmosJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
// return new JdbcTemplate( ds );
// }
//
// @Bean(name = "namedParameterJdbcTemplateCosmos")
// public NamedParameterJdbcTemplate cosmosNamedParameterJdbcTemplate( @Qualifier( "dataSourceCosmos" ) DataSource ds ) {
// return new NamedParameterJdbcTemplate( ds );
// }
/* LOCAL */
@ -73,6 +73,4 @@ public class DataSourceConfiguration {
public NamedParameterJdbcTemplate localNamedParameterJdbcTemplate( @Qualifier( "dataSourceLocal" ) DataSource ds ) {
return new NamedParameterJdbcTemplate( ds );
}
}

View File

@ -0,0 +1,56 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.PurchaseOrderCTPRole;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.service.PurchaseOrderService;
import com.utopiaindustries.service.ReportingService;
import com.utopiaindustries.service.SummaryInventoryReportService;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/po-status")
@PurchaseOrderCTPRole
public class POStatusController {
private final ReportingService reportingService;
private final PurchaseOrderService purchaseOrderService;
public POStatusController(ReportingService reportingService, PurchaseOrderService purchaseOrderService) {
this.reportingService = reportingService;
this.purchaseOrderService = purchaseOrderService;
}
@GetMapping
public String homePage( Model model ){
return "redirect:/po-status/all-pos";
}
@GetMapping( "/all-pos")
public String poReport(@RequestParam(value = "poName", required = false) String poName, Model model){
model.addAttribute("allPOs", reportingService.getAllPOs(poName));
return "/reporting/po-report";
}
@GetMapping( value = "/po-report-view/{poId}" )
public String showJobCardDetail(@PathVariable("poId") long poId, @RequestParam(value = "select-date", required = false) String selectDate ,
Model model ){
model.addAttribute("allJobCard", reportingService.getAllPoJobCards(poId, selectDate));
return "/reporting/po-job-card-report";
}
@GetMapping(value = "/generate-po-pdf", produces = MediaType.APPLICATION_PDF_VALUE)
public ResponseEntity<InputStreamResource> sendPoAndReturnPdf(@ModelAttribute POsDetails pOsDetails,
@RequestParam(required = false, defaultValue = "true") boolean includeJobCard,
@RequestParam(required = false, defaultValue = "true") boolean includeStoreDetails,
Model model) throws Exception{
return purchaseOrderService.generatePOPdf(pOsDetails, model, includeJobCard, includeStoreDetails);
}
}

View File

@ -35,6 +35,7 @@ public class PackagingController {
@GetMapping("/receive-inventory")
public String packagingItemReceive( Model model ){
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(6L));
model.addAttribute("wrapper", new FinishedItemWrapper() );
return "/packaging/receive-inventory-form";
}

View File

@ -5,6 +5,7 @@ import com.utopiaindustries.model.ctp.JobCard;
import com.utopiaindustries.model.ctp.PurchaseOrderCTP;
import com.utopiaindustries.service.PurchaseOrderCTPService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@ -85,6 +86,11 @@ public class PurchaseOrderCTPController {
return "redirect:/purchase-order";
}
@GetMapping( "/store-items/{id}" )
public String getPOStoreItems( @PathVariable("id") long poId,
Model model ){
model.addAttribute("storeItems", purchaseOrderCTPService.getStoreItemsByPoId( poId ));
return "/reporting/po-store-items-table";
}
}

View File

@ -1,17 +1,19 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.ReportingRole;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.model.ctp.SummaryInventoryReport;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.service.PurchaseOrderService;
import com.utopiaindustries.service.ReportingService;
import com.utopiaindustries.service.SummaryInventoryReportService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.time.LocalDate;
@ -26,12 +28,19 @@ public class ReportingController {
private final ReportingService reportingService;
private final SummaryInventoryReportService summaryInventoryReportService;
private final InventoryAccountService inventoryAccountService;
private final PurchaseOrderService purchaseOrderService;
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2, ReportingService reportingService, InventoryAccountService inventoryAccountService) {
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2, ReportingService reportingService, InventoryAccountService inventoryAccountService, PurchaseOrderService purchaseOrderService) {
this.summaryInventoryReportService = summaryInventoryReportService2;
this.reportingService = reportingService;
this.inventoryAccountService = inventoryAccountService;
this.purchaseOrderService = purchaseOrderService;
}
@GetMapping
public String homePage( Model model ){
return "redirect:/reporting/job-card-report";
}
@GetMapping( "/summary")
@ -68,20 +77,6 @@ public class ReportingController {
return "/reporting/job-card-report";
}
@GetMapping( "/po-report")
public String poReport(@RequestParam(value = "poName", required = false) String poName, Model model){
model.addAttribute("allPOs", reportingService.getAllPOs(poName));
return "/reporting/po-report";
}
@GetMapping( value = "/po-report-view/{poNo}" )
public String showJobCardDetail( @PathVariable("poNo") String poNo, @RequestParam(value = "select-date", required = false) String selectDate ,
Model model ){
model.addAttribute("allJobCard", reportingService.getAllPoJobCards(poNo, selectDate));
return "/reporting/po-job-card-report";
}
@GetMapping( value = "/cutting-report" )
public String cuttingReport(@RequestParam(value = "job-card-id", required = false ) String jobCardId, @RequestParam(value = "accountId" , required = false) String accountId, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
@ -124,7 +119,6 @@ public class ReportingController {
return "/reporting/accounts-transaction-table";
}
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
ArrayList<LocalDate> localDates = new ArrayList<>();
while (start.isBefore(end)) {

View File

@ -0,0 +1,72 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.StoreRole;
import com.utopiaindustries.model.ctp.FinishedItemWrapper;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.service.LocationService;
import com.utopiaindustries.service.StoreService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@StoreRole
@RequestMapping( "/store" )
public class StoreController {
private final InventoryAccountService inventoryAccountService;
private final StoreService storeService;
private final LocationService locationService;
public StoreController(InventoryAccountService inventoryAccountService, StoreService storeService, LocationService locationService) {
this.inventoryAccountService = inventoryAccountService;
this.storeService = storeService;
this.locationService = locationService;
}
@GetMapping
public String showHome(Model model ){
return "redirect:/store/receive-inventory";
}
@GetMapping("/receive-inventory")
public String packagingItemReceive( Model model ){
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(9L));
model.addAttribute("wrapper", new FinishedItemWrapper() );
return "/store/receive-inventory-form";
}
@PostMapping( "/store-items" )
public String packagingItems( @ModelAttribute FinishedItemWrapper wrapper,
RedirectAttributes redirectAttributes,
Model model ){
try {
storeService.createStoreItems( wrapper );
redirectAttributes.addFlashAttribute("success", "Items Successfully received !" );
} catch ( Exception e ){
redirectAttributes.addFlashAttribute("error", e.getMessage() );
}
return "redirect:/store/receive-inventory";
}
@GetMapping( "/inventory-accounts" )
public String showInventoryAccounts(@RequestParam( value = "id", required = false ) String id,
@RequestParam( value = "title", required = false) String title,
@RequestParam( value = "active", required = false ) String active,
@RequestParam( value = "created-by", required = false ) String createdBy,
@RequestParam( value = "start-date", required = false ) String startDate,
@RequestParam( value = "end-date", required = false ) String endDate,
@RequestParam( value = "site-id", required = false ) String siteId,
@RequestParam( value = "count", required = false ) Long count,
Model model ){
if(StringUtils.isNullOrEmpty( active )){
return "redirect:/store/inventory-accounts?id=&title=&active=1&created-by=&start-date=&end-date=&site-id=&site-title=&count=100";
}
model.addAttribute("accounts", inventoryAccountService.findInventoryAccounts(9L));
model.addAttribute("locations", locationService.findAll() );
return "/store/inventory-accounts";
}
}

View File

@ -21,18 +21,18 @@ public class FinishedItemDAO {
private final String TABLE_NAME = "cut_to_pack.finished_item";
private final String SELECT_QUERY = String.format("SELECT * FROM %s WHERE id = :id", TABLE_NAME);
private final String SELECT_ALL_QUERY = String.format("SELECT * FROM %s ORDER BY id DESC", TABLE_NAME);
private final String SELECT_QUERY_BY_BARCODE_QA_STATUS = String.format("SELECT case when EXISTS ( SELECT * FROM %s WHERE barcode = :barcode AND (qa_status = 'APPROVED' OR qa_status = 'WASHED') ) then true else false End as Result", TABLE_NAME);
private final String SELECT_QUERY_BY_BARCODE_QA_STATUS =String.format("SELECT CASE WHEN EXISTS (SELECT 1 FROM %s WHERE barcode = :barcode AND (is_store = TRUE OR is_packed = TRUE)) THEN TRUE ELSE FALSE END AS result", TABLE_NAME);
private final String SELECT_QUERY_BY_JOB_CARD = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME);
private final String DELETE_QUERY = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
private final String INSERT_QUERY = String.format("INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, stitched_item_id, is_segregated, qa_status, is_packed, operation_date) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status, :is_packed, :operation_date) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), stitched_item_id = VALUES(stitched_item_id), is_segregated = VALUES(is_segregated), qa_status = VALUES(qa_status), is_packed = VALUES(is_packed), operation_date = VALUES(operation_date) ", TABLE_NAME);
private final String INSERT_QUERY = String.format("INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, stitched_item_id, is_segregated, qa_status, is_packed, operation_date, is_store) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :stitched_item_id, :is_segregated, :qa_status, :is_packed, :operation_date, :is_store) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), stitched_item_id = VALUES(stitched_item_id), is_segregated = VALUES(is_segregated), qa_status = VALUES(qa_status), is_packed = VALUES(is_packed), operation_date = VALUES(operation_date), is_store = VALUES(is_store)", TABLE_NAME);
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME);
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME);
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME);
private final String SELECT_BY_TERM = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_qa = :is_qa AND is_packed = FALSE ORDER BY ID DESC", TABLE_NAME);
private final String SELECT_BY_TERM_FOR_PACKAGING = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated AND qa_status = 'APPROVED' AND is_packed = FALSE ORDER BY ID DESC", TABLE_NAME);
private final String SELECT_BY_TERM = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_qa = :is_qa AND is_packed = FALSE AND is_store = FALSE ORDER BY ID DESC", TABLE_NAME);
private final String SELECT_BY_TERM_FOR_PACKAGING = String.format("SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated AND qa_status = :qa_status AND is_packed = FALSE AND is_store = FALSE ORDER BY ID DESC", TABLE_NAME);
private final String SELECT_BY_STITCHED_ITEM_ID = String.format("SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id AND is_packed = FALSE", TABLE_NAME);
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format("SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_segregated IS TRUE ", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_qa = TRUE AND (is_segregated IS TRUE OR is_store = TRUE) ", TABLE_NAME);
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME);
private final String SELECT_BY_DATE_QA_STATUS = String.format( "SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR operation_date >= :start_date) AND operation_date <= :end_date AND qa_status = :qa_status AND id in (:ids) AND is_packed = FALSE AND is_qa = TRUE", TABLE_NAME );
@ -55,6 +55,7 @@ public class FinishedItemDAO {
.addValue("is_segregated", finishedItem.getIsSegregated())
.addValue("qa_status", finishedItem.getQaStatus())
.addValue("is_packed", finishedItem.isPackaging())
.addValue("is_store", finishedItem.isStore())
.addValue("operation_date", finishedItem.getOperationDate());
return params;
}
@ -123,10 +124,11 @@ public class FinishedItemDAO {
return namedParameterJdbcTemplate.query(SELECT_BY_TERM, params, new FinishedItemRowMapper());
}
public List<FinishedItem> findByTermForPackaging(String term, boolean isSegregated) {
public List<FinishedItem> findByTermForPackaging(String term, boolean isSegregated, String qaStatus) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("term", "%" + term + "%");
params.addValue("is_segregated", isSegregated);
params.addValue("qa_status", qaStatus);
return namedParameterJdbcTemplate.query(SELECT_BY_TERM_FOR_PACKAGING, params, new FinishedItemRowMapper());
}

View File

@ -26,6 +26,7 @@ public class FinishedItemRowMapper implements RowMapper<FinishedItem> {
finishedItem.setIsSegregated( rs.getBoolean( "is_segregated") );
finishedItem.setQaStatus( rs.getString("qa_status" ) );
finishedItem.setPackaging( rs.getBoolean("is_packed" ) );
finishedItem.setStore( rs.getBoolean("is_store" ) );
return finishedItem;
}
}

View File

@ -21,7 +21,7 @@ public class JobCardDAO {
private final String TABLE_NAME = "cut_to_pack.job_card";
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_WITH_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC limit :limit", TABLE_NAME );
private final String SELECT_ALL_BY_PO_ID = String.format( "SELECT * FROM %s WHERE purchase_order_id = :purchase_order_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, code, job_order_id, created_at, created_by, status, inventory_status, customer, lot_number, purchase_order_id, location_site_id, description, poQuantity, articleName) VALUES (:id, :code, :job_order_id, :created_at, :created_by, :status, :inventory_status, :customer, :lot_number, :purchase_order_id, :location_site_id, :description, :poQuantity, :articleName) ON DUPLICATE KEY UPDATE code = VALUES(code), job_order_id = VALUES(job_order_id), created_at = VALUES(created_at), created_by = VALUES(created_by), status = VALUES(status), inventory_status = VALUES(inventory_status), customer = VALUES(customer), lot_number = VALUES(lot_number), purchase_order_id = VALUES(purchase_order_id), location_site_id = VALUES(location_site_id), description = VALUES(description), poQuantity = VALUES(poQuantity), articleName = VALUES(articleName) ", TABLE_NAME );
private final String SELECT_BY_LIKE_CODE_AND_INV_STATUS_AND_STATUS = String.format( "SELECT * FROM %s WHERE code like :code AND status = :status AND inventory_status = :inventory_status", TABLE_NAME );
@ -114,9 +114,9 @@ public class JobCardDAO {
return namedParameterJdbcTemplate.query( query, new JobCardRowMapper() );
}
public List<JobCard> findByAllWithLimit(Long limit){
public List<JobCard> findByPoId(long poId){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("limit", limit.intValue());
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY_WITH_LIMIT, params, new JobCardRowMapper() );
params.addValue("purchase_order_id", poId);
return namedParameterJdbcTemplate.query( SELECT_ALL_BY_PO_ID, params, new JobCardRowMapper() );
}
}

View File

@ -23,8 +23,8 @@ public class PurchaseOrderCTPDao {
private final String TABLE_NAME = "cut_to_pack.purchase_order";
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_WITH_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC limit :limit", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ", TABLE_NAME );
private final String SELECT_BY_PO_CODE = String.format( "SELECT * FROM %s WHERE purchase_order_code = :purchase_order_code", 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, purchase_order_code, purchase_order_quantity, purchase_order_quantity_required, article_name, created_by, status) " +
@ -107,10 +107,10 @@ public class PurchaseOrderCTPDao {
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT, params, new PurchaseOrderCTPRowMapper() );
}
public List<PurchaseOrderCTP> findByAllWithLimit(Long limit){
public List<PurchaseOrderCTP> findByPoCode(String poCode){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("limit", limit.intValue());
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY_WITH_LIMIT, params, new PurchaseOrderCTPRowMapper() );
params.addValue("purchase_order_code", poCode);
return namedParameterJdbcTemplate.query( SELECT_BY_PO_CODE, params, new PurchaseOrderCTPRowMapper() );
}
/*

View File

@ -0,0 +1,131 @@
package com.utopiaindustries.dao.ctp;
import com.utopiaindustries.model.ctp.StoreItem;
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.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class StoreItemDao {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private static final String TABLE_NAME = "store_items";
private static final String SELECT_BY_ID = String.format("SELECT * FROM %s WHERE id = :id", TABLE_NAME);
private static final String SELECT_ALL = String.format("SELECT * FROM %s ORDER BY id DESC", TABLE_NAME);
private static final String DELETE_BY_ID = String.format("DELETE FROM %s WHERE id = :id", TABLE_NAME);
private static final String SELECT_BY_JOB_CARD_ID = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME);
private final String COUNT_TOTAL_FINISH_ITEM = String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME);
private static final String INSERT_QUERY = String.format(
"INSERT INTO %s (" +
"id, item_id, sku, barcode, job_card_id, created_at, created_by, " +
"finish_item_id, account_id, bundle_id, reject_reason" +
") VALUES (" +
":id, :item_id, :sku, :barcode, :job_card_id, :created_at, :created_by, " +
":finish_item_id, :account_id, :bundle_id, :reject_reason" +
") ON DUPLICATE KEY UPDATE " +
"item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), " +
"job_card_id = VALUES(job_card_id), created_at = VALUES(created_at), created_by = VALUES(created_by), " +
"finish_item_id = VALUES(finish_item_id), account_id = VALUES(account_id), bundle_id = VALUES(bundle_id), reject_reason = VALUES(reject_reason)",
TABLE_NAME
);
String SELECT_BY_JOB_CARD_GROUP_REJECT_REASON = String.format("SELECT reject_reason, COUNT(*) AS total FROM %s WHERE job_card_id IN (:job_card_id) GROUP BY reject_reason", TABLE_NAME);
private static final String SELECT_BY_DATE_AND_IDs = String.format("SELECT COUNT(*) FROM %s WHERE (:start_date IS NULL OR created_at >= :start_date) AND created_at <= :end_date AND id IN (:ids)", TABLE_NAME);
public StoreItemDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
}
private MapSqlParameterSource prepareParams(StoreItem item) {
return new MapSqlParameterSource()
.addValue("id", item.getId())
.addValue("item_id", item.getItemId())
.addValue("sku", item.getSku())
.addValue("barcode", item.getBarcode())
.addValue("job_card_id", item.getJobCardId())
.addValue("created_at", item.getCreatedAt())
.addValue("created_by", item.getCreatedBy())
.addValue("finish_item_id", item.getFinishedItemId())
.addValue("account_id", item.getAccountId())
.addValue("bundle_id", item.getBundleId())
.addValue("reject_reason", item.getRejectedReason());
}
public StoreItem find(long id) {
MapSqlParameterSource params = new MapSqlParameterSource("id", id);
return namedParameterJdbcTemplate.query(SELECT_BY_ID, params, new StoreItemRowMapper())
.stream().findFirst().orElse(new StoreItem());
}
public List<StoreItem> findAll() {
return namedParameterJdbcTemplate.query(SELECT_ALL, new StoreItemRowMapper());
}
public long save(StoreItem item) {
KeyHolder keyHolder = new GeneratedKeyHolder();
MapSqlParameterSource params = prepareParams(item);
namedParameterJdbcTemplate.update(INSERT_QUERY, params, keyHolder);
return KeyHolderFunctions.getKey(item.getId(), keyHolder);
}
public int[] saveAll(List<StoreItem> items) {
List<MapSqlParameterSource> batchParams = new ArrayList<>();
for (StoreItem item : items) {
batchParams.add(prepareParams(item));
}
return namedParameterJdbcTemplate.batchUpdate(INSERT_QUERY, batchParams.toArray(new MapSqlParameterSource[0]));
}
public boolean delete(long id) {
MapSqlParameterSource params = new MapSqlParameterSource("id", id);
return namedParameterJdbcTemplate.update(DELETE_BY_ID, params) > 0;
}
public List<StoreItem> findByJobCardId(long jobCardId) {
MapSqlParameterSource params = new MapSqlParameterSource("job_card_id", jobCardId);
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_ID, params, new StoreItemRowMapper());
}
public Long calculateTotalRejectItemByJobCardId(long jobCardId) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("job_card_id", jobCardId);
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_FINISH_ITEM, params, Long.class);
return count != null ? count : 0;
}
public Long findByDateAndIds(String startDate, String endDate, List<Long> ids) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("start_date", startDate);
params.addValue("end_date", endDate);
params.addValue("ids", ids);
Long count = namedParameterJdbcTemplate.queryForObject(SELECT_BY_DATE_AND_IDs, params, Long.class);
return count != null ? count : 0;
}
public Map<String, Integer> totalCountByJobCardIdsAndGroupByRejectReason(List<Long> jobCardIds) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("job_card_id", jobCardIds);
List<Map<String, Object>> rows = namedParameterJdbcTemplate.queryForList(SELECT_BY_JOB_CARD_GROUP_REJECT_REASON, params);
Map<String, Integer> result = new HashMap<>();
for (Map<String, Object> row : rows) {
String reason = (String) row.get("reject_reason");
Integer total = ((Number) row.get("total")).intValue();
result.put(reason, total);
}
return result;
}
}

View File

@ -0,0 +1,27 @@
package com.utopiaindustries.dao.ctp;
import com.utopiaindustries.model.ctp.PackagingItems;
import com.utopiaindustries.model.ctp.StoreItem;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public class StoreItemRowMapper implements RowMapper<StoreItem> {
@Override
public StoreItem mapRow(ResultSet rs, int rowNum) throws SQLException {
StoreItem item = new StoreItem();
item.setId(rs.getLong("id"));
item.setItemId(rs.getLong("item_id"));
item.setSku(rs.getString("sku"));
item.setBarcode(rs.getString("barcode"));
item.setJobCardId(rs.getLong("job_card_id"));
item.setCreatedAt(rs.getTimestamp("created_at") != null ? rs.getTimestamp("created_at").toLocalDateTime() : null);
item.setCreatedBy(rs.getString("created_by"));
item.setFinishedItemId(rs.getLong("finish_item_id"));
item.setAccountId(rs.getLong("account_id"));
item.setBundleId(rs.getLong("bundle_id"));
item.setRejectedReason(rs.getString("reject_reason"));
return item;
}
}

View File

@ -11,5 +11,6 @@ public enum Roles {
ROLE_PACKAGING,
ROLE_REPORTING,
ROLE_PURCHASE_ORDER,
ROLE_INVENTORY_ACCOUNT
ROLE_INVENTORY_ACCOUNT,
ROLE_STORE
}

View File

@ -24,6 +24,7 @@ public class FinishedItem implements InventoryArtifact {
private long accountId;
private String qaStatus;
private boolean isPackaging;
private boolean isStore;
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
private LocalDateTime operationDate;
@ -173,6 +174,14 @@ public class FinishedItem implements InventoryArtifact {
this.operationDate = operationDate;
}
public boolean isStore() {
return isStore;
}
public void setStore(boolean store) {
isStore = store;
}
@Override
public String toString() {
return "FinishedItem{" +

View File

@ -5,6 +5,8 @@ import java.util.List;
public class FinishedItemWrapper {
private String qaStatus;
private Long accountId;
private String rejectReason;
private List<FinishedItem> items;
@ -24,6 +26,22 @@ public class FinishedItemWrapper {
this.qaStatus = qaStatus;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getRejectReason() {
return rejectReason;
}
public void setRejectReason(String rejectReason) {
this.rejectReason = rejectReason;
}
@Override
public String toString() {
return "FinishedItemWrapper{" +

View File

@ -5,6 +5,7 @@ public enum InventoryArtifactType {
STITCHING_OFFLINE,
FINISHED_ITEM,
STITCH_BUNDLE,
PACKAGING
PACKAGING,
STORED_ITEM,
}

View File

@ -1,20 +1,33 @@
package com.utopiaindustries.model.ctp;
public class POsDetails {
//po detail
private long poId;
private String poNumber;
private String articleTitle;
private long poQuantity;
private long totalCutting;
private long remainingCutting;
private long totalStitching;
private long remainingStitching;
private long totalEndLineQC;
private long remainingEndLineQC;
private long totalFinishing;
private long remainingFinishing;
private long totalAGradeItem;
private long totalBGradeItem;
private long totalCGradeItem;
private long poRequiredQuantity;
// items detail
private long actualCutting;
private long balanceToCutting;
private long cuttingReceived;
private long cuttingOki;
private long cuttingReject;
private long stitchingIn;
private long stitchingWips;
private long stitchingOut;
private long finishIn;
private long finishRej;
private long finishQaApproved;
private long storeReceived;
private long storeWaiting;
private long packagingIn;
private long packagingOut;
private long packagingStock;
private long shippedScan;
private long shippedNet;
private boolean poStatus;
public long getPoQuantity() {
return poQuantity;
@ -40,108 +53,200 @@ public class POsDetails {
this.articleTitle = articleTitle;
}
public long getTotalCutting() {
return totalCutting;
public long getPoId() {
return poId;
}
public void setTotalCutting(long totalCutting) {
this.totalCutting = totalCutting;
public void setPoId(long poId) {
this.poId = poId;
}
public long getRemainingCutting() {
return remainingCutting;
public long getPoRequiredQuantity() {
return poRequiredQuantity;
}
public void setRemainingCutting(long remainingCutting) {
this.remainingCutting = remainingCutting;
public void setPoRequiredQuantity(long poRequiredQuantity) {
this.poRequiredQuantity = poRequiredQuantity;
}
public long getTotalStitching() {
return totalStitching;
public long getActualCutting() {
return actualCutting;
}
public void setTotalStitching(long totalStitching) {
this.totalStitching = totalStitching;
public void setActualCutting(long actualCutting) {
this.actualCutting = actualCutting;
}
public long getRemainingStitching() {
return remainingStitching;
public long getBalanceToCutting() {
return balanceToCutting;
}
public void setRemainingStitching(long remainingStitching) {
this.remainingStitching = remainingStitching;
public void setBalanceToCutting(long balanceToCutting) {
this.balanceToCutting = balanceToCutting;
}
public long getTotalEndLineQC() {
return totalEndLineQC;
public long getCuttingReceived() {
return cuttingReceived;
}
public void setTotalEndLineQC(long totalEndLineQC) {
this.totalEndLineQC = totalEndLineQC;
public void setCuttingReceived(long cuttingReceived) {
this.cuttingReceived = cuttingReceived;
}
public long getRemainingEndLineQC() {
return remainingEndLineQC;
public long getCuttingOki() {
return cuttingOki;
}
public void setRemainingEndLineQC(long remainingEndLineQC) {
this.remainingEndLineQC = remainingEndLineQC;
public void setCuttingOki(long cuttingOki) {
this.cuttingOki = cuttingOki;
}
public long getTotalFinishing() {
return totalFinishing;
public long getCuttingReject() {
return cuttingReject;
}
public void setTotalFinishing(long totalFinishing) {
this.totalFinishing = totalFinishing;
public void setCuttingReject(long cuttingReject) {
this.cuttingReject = cuttingReject;
}
public long getRemainingFinishing() {
return remainingFinishing;
public long getStitchingIn() {
return stitchingIn;
}
public void setRemainingFinishing(long remainingFinishing) {
this.remainingFinishing = remainingFinishing;
public void setStitchingIn(long stitchingIn) {
this.stitchingIn = stitchingIn;
}
public long getTotalAGradeItem() {
return totalAGradeItem;
public long getStitchingWips() {
return stitchingWips;
}
public void setTotalAGradeItem(long totalAGradeItem) {
this.totalAGradeItem = totalAGradeItem;
public void setStitchingWips(long stitchingWips) {
this.stitchingWips = stitchingWips;
}
public long getTotalBGradeItem() {
return totalBGradeItem;
public long getStitchingOut() {
return stitchingOut;
}
public void setTotalBGradeItem(long totalBGradeItem) {
this.totalBGradeItem = totalBGradeItem;
public void setStitchingOut(long stitchingOut) {
this.stitchingOut = stitchingOut;
}
public long getTotalCGradeItem() {
return totalCGradeItem;
public long getFinishIn() {
return finishIn;
}
public void setTotalCGradeItem(long totalCGradeItem) {
this.totalCGradeItem = totalCGradeItem;
public void setFinishIn(long finishIn) {
this.finishIn = finishIn;
}
public long getFinishRej() {
return finishRej;
}
public void setFinishRej(long finishRej) {
this.finishRej = finishRej;
}
public long getFinishQaApproved() {
return finishQaApproved;
}
public void setFinishQaApproved(long finishQaApproved) {
this.finishQaApproved = finishQaApproved;
}
public long getStoreReceived() {
return storeReceived;
}
public void setStoreReceived(long storeReceived) {
this.storeReceived = storeReceived;
}
public long getStoreWaiting() {
return storeWaiting;
}
public void setStoreWaiting(long storeWaiting) {
this.storeWaiting = storeWaiting;
}
public long getPackagingIn() {
return packagingIn;
}
public void setPackagingIn(long packagingIn) {
this.packagingIn = packagingIn;
}
public long getPackagingOut() {
return packagingOut;
}
public void setPackagingOut(long packagingOut) {
this.packagingOut = packagingOut;
}
public long getPackagingStock() {
return packagingStock;
}
public void setPackagingStock(long packagingStock) {
this.packagingStock = packagingStock;
}
public long getShippedScan() {
return shippedScan;
}
public void setShippedScan(long shippedScan) {
this.shippedScan = shippedScan;
}
public long getShippedNet() {
return shippedNet;
}
public void setShippedNet(long shippedNet) {
this.shippedNet = shippedNet;
}
public boolean isPoStatus() {
return poStatus;
}
public void setPoStatus(boolean poStatus) {
this.poStatus = poStatus;
}
@Override
public String toString() {
return "POsDetails{" +
"totalCutting=" + totalCutting +
", remainingCutting=" + remainingCutting +
", totalStitching=" + totalStitching +
", remainingStitching=" + remainingStitching +
", totalEndLineQC=" + totalEndLineQC +
", remainingEndLineQC=" + remainingEndLineQC +
", totalFinishing=" + totalFinishing +
", remainingFinishing=" + remainingFinishing +
", totalAGradeItem=" + totalAGradeItem +
", totalBGradeItem=" + totalBGradeItem +
", totalCGradeItem=" + totalCGradeItem +
"poId=" + poId +
", poNumber='" + poNumber + '\'' +
", articleTitle='" + articleTitle + '\'' +
", poQuantity=" + poQuantity +
", poRequiredQuantity=" + poRequiredQuantity +
", actualCutting=" + actualCutting +
", balanceToCutting=" + balanceToCutting +
", cuttingReceived=" + cuttingReceived +
", cuttingOki=" + cuttingOki +
", cuttingReject=" + cuttingReject +
", stitchingIn=" + stitchingIn +
", stitchingWips=" + stitchingWips +
", stitchingOut=" + stitchingOut +
", finishIn=" + finishIn +
", finishRej=" + finishRej +
", finishQaApproved=" + finishQaApproved +
", storeReceived=" + storeReceived +
", storeWaiting=" + storeWaiting +
", packagingIn=" + packagingIn +
", packagingOut=" + packagingOut +
", packagingStock=" + packagingStock +
", shippedScan=" + shippedScan +
", shippedNet=" + shippedNet +
'}';
}
}

View File

@ -0,0 +1,151 @@
package com.utopiaindustries.model.ctp;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
public class StoreItem implements InventoryArtifact {
private long id;
private long itemId;
private String sku;
private String barcode;
private long jobCardId;
@DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
private LocalDateTime createdAt;
private String createdBy;
private long finishedItemId;
private long bundleId;
private long accountId;
private String rejectedReason;
@Override
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Override
public long getItemId() {
return itemId;
}
public void setItemId(long itemId) {
this.itemId = itemId;
}
@Override
public String getSku() {
return sku;
}
@Override
public String getType() {
return "";
}
public void setSku(String sku) {
this.sku = sku;
}
@Override
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
@Override
public long getJobCardId() {
return jobCardId;
}
public void setJobCardId(long jobCardId) {
this.jobCardId = jobCardId;
}
@Override
public LocalDateTime getCreatedAt() {
return createdAt;
}
@Override
public BigDecimal getWrapQuantity() {
return null;
}
@Override
public long getMasterBundleId() {
return 0;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
@Override
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public long getFinishedItemId() {
return finishedItemId;
}
public void setFinishedItemId(long finishedItemId) {
this.finishedItemId = finishedItemId;
}
@Override
public long getBundleId() {
return bundleId;
}
public void setBundleId(long bundleId) {
this.bundleId = bundleId;
}
public long getAccountId() {
return accountId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
public String getRejectedReason() {
return rejectedReason;
}
public void setRejectedReason(String rejectedReason) {
this.rejectedReason = rejectedReason;
}
@Override
public String toString() {
return "StoreItem{" +
"id=" + id +
", itemId=" + itemId +
", sku='" + sku + '\'' +
", barcode='" + barcode + '\'' +
", jobCardId=" + jobCardId +
", createdAt=" + createdAt +
", createdBy='" + createdBy + '\'' +
", finishedItemId=" + finishedItemId +
", bundleId=" + bundleId +
", accountId=" + accountId +
", rejectedReason='" + rejectedReason + '\'' +
'}';
}
}

View File

@ -28,6 +28,12 @@ public class FinishedItemRestController {
@GetMapping("/search-packaging")
public List<FinishedItem> searchFinishedItemsForPackaging(@RequestParam("term") String term,
@RequestParam("is-segregated") boolean isSegregated) {
return finishedItemDAO.findByTermForPackaging(term, true);
return finishedItemDAO.findByTermForPackaging(term, isSegregated, "APPROVED");
}
@GetMapping("/search-store")
public List<FinishedItem> searchFinishedItemsForStore(@RequestParam("term") String term,
@RequestParam("is-segregated") boolean isSegregated) {
return finishedItemDAO.findByTermForPackaging(term, isSegregated,"REJECT");
}
}

View File

@ -50,7 +50,7 @@ public class DashboardService {
//set inventory accounts
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findAll();
InventoryAccount inventoryAccount = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
.filter(e -> stitchingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
Map<String, Integer> inventoryAccountMap = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle()) ||
stitchingAccount.equals(e.getTitle()) ||
@ -80,10 +80,10 @@ public class DashboardService {
approvedStitchingOfflineItems = stitchingOfflineItemDAO.findByQCOperationDateAndApproved(startDate1, endDate1, "APPROVED");
qcReject = stitchingOfflineItemDAO.findByQCOperationDateAndIds(startDate1, endDate1, "REJECT", stitchingItemIds);
remaininfQcAlterPieces = stitchingOfflineItemDAO.findByQCOperationDateAndIds(null, forPreviousDate, "REJECT", stitchingItemIds);
approvedStitchingOfflineItemsThenReject = stitchingOfflineItemDAO.findByQCOperationDateAndIds(startDate1, endDate1, "REJECT", stitchingOutIds);
}
if(stitchingOutIds != null && !stitchingOutIds.isEmpty()) {
approvedStitchingOfflineItemsThenReject = stitchingOfflineItemDAO.findByQCOperationDateAndIds(startDate1, endDate1, "REJECT", stitchingOutIds);
}
//set finishing related details
Long alterationPieceFinish = 0L;
Long rejectFinishedItem = 0L;
@ -127,10 +127,11 @@ public class DashboardService {
progress.put("totalWips", (float) stitchingItemIds.size() - qcReject);
progress.put("Alteration", (float) qcReject + approvedStitchingOfflineItemsThenReject);
progress.put("finishing", (float) approved + operationNotPerformed);
progress.put("finishing", (float) approved );
progress.put("ALTER", (float) alterationPieceFinish);
progress.put("Reject", (float) rejectFinishedItem);
progress.put("wash", (float) washFinishedItem);
progress.put("finishingValueForBarChart", (float) approved + alterationPieceFinish + rejectFinishedItem + washFinishedItem + packagingItems);
progress.put("packaging", (float) packagingItems);
progress.put("totalPackaging", (float) packagingItemIDs.size());
@ -142,10 +143,11 @@ public class DashboardService {
}
public Map<String, String> getLineDetails(String lineNo) {
String cuttingAccount = "CUTTING ACCOUNT " + lineNo;
String stitchingAccount = "STITCHING ACCOUNT " + lineNo;
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findAll();
InventoryAccount inventoryAccount = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
.filter(e -> stitchingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
int shiftTarget = getTargetShiftWiseOrHourlyWise(inventoryAccount.getShiftMinutes(), inventoryAccount);
int shiftHourlyTarget = getTargetShiftWiseOrHourlyWise(60, inventoryAccount);

View File

@ -19,7 +19,7 @@ import java.util.stream.Collectors;
public class InventoryService {
private final JobCardItemDAO jobCardItemDAO;
private final CutPieceDAO cutPieceDAO;
private final StoreItemDao storeItemDao;
private final BundleDAO bundleDAO;
private final InventoryTransactionLegDAO inventoryTransactionLegDAO;
private final InventoryTransactionDAO inventoryTransactionDAO;
@ -30,9 +30,9 @@ public class InventoryService {
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
private final PackagingItemsDAO packagingItemsDAO;
public InventoryService(JobCardItemDAO jobCardItemDAO, CutPieceDAO cutPieceDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, InventoryTransactionDAO inventoryTransactionDAO, JobCardDAO jobCardDAO, CryptographyService cryptographyService, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, PackagingItemsDAO packagingItemsDAO) {
public InventoryService(JobCardItemDAO jobCardItemDAO, StoreItemDao storeItemDao, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, InventoryTransactionDAO inventoryTransactionDAO, JobCardDAO jobCardDAO, CryptographyService cryptographyService, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, PackagingItemsDAO packagingItemsDAO) {
this.jobCardItemDAO = jobCardItemDAO;
this.cutPieceDAO = cutPieceDAO;
this.storeItemDao = storeItemDao;
this.bundleDAO = bundleDAO;
this.inventoryTransactionLegDAO = inventoryTransactionLegDAO;
this.inventoryTransactionDAO = inventoryTransactionDAO;
@ -614,6 +614,7 @@ public class InventoryService {
createInventoryTransactionLeg(transaction, finishedItem, lastOutTransaction.getAccountId(), InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.FINISHED_ITEM.name());
finishedItem.setQaStatus("ALTER");
finishedItem.setIsSegregated(false);
finishedItem.setIsQa(false);
}
}
@ -661,7 +662,7 @@ public class InventoryService {
* Packaging items
* */
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
public void createPackagingItemAndTransaction(FinishedItemWrapper wrapper) {
public void createPackagingItemAndTransaction(FinishedItemWrapper wrapper, long accountId) {
if (wrapper != null && wrapper.getItems() != null) {
List<FinishedItem> items = wrapper.getItems();
@ -670,9 +671,6 @@ public class InventoryService {
// finished ids
List<Long> finishedItemIds = items.stream().map(FinishedItem::getId)
.collect(Collectors.toList());
// stitched ids
List<Long> stitchedItemIds = items.stream().map(FinishedItem::getStitchedItemId)
.collect(Collectors.toList());
// find parent doc type last IN transaction map
Map<Long, InventoryTransactionLeg> lastFinishedItemIdInTransactionMap = inventoryTransactionLegDAO
@ -696,9 +694,10 @@ public class InventoryService {
if (lastInvTransaction != null) {
// OUT
long fromAccount = lastInvTransaction.getAccountId();
packagingItems1.setAccountId(fromAccount);
createInventoryTransactionLeg(transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
// IN
createInventoryTransactionLeg(transaction, packagingItems1, 8, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.PACKAGING.name());
createInventoryTransactionLeg(transaction, packagingItems1, accountId, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.PACKAGING.name());
}
finishedItem.setIsSegregated(true);
finishedItem.setPackaging(true);
@ -712,6 +711,57 @@ public class InventoryService {
}
}
/*
* store items
* */
@Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED)
public void createStoreItemAndTransaction(FinishedItemWrapper wrapper, long toAccount) {
if (wrapper != null && wrapper.getItems() != null) {
List<FinishedItem> items = wrapper.getItems();
List<FinishedItem> updatedItems = new ArrayList<>();
List<StoreItem> storeItems = new ArrayList<>();
// finished ids
List<Long> finishedItemIds = items.stream().map(FinishedItem::getId)
.collect(Collectors.toList());
// find parent doc type last IN transaction map
Map<Long, InventoryTransactionLeg> lastFinishedItemIdInTransactionMap = inventoryTransactionLegDAO
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), finishedItemIds, InventoryArtifactType.FINISHED_ITEM.name())
.stream()
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
// create transaction
InventoryTransaction transaction = createInventoryTransaction("Against Segregation of Finished Items");
// create IN and OUT for all approved items
for (FinishedItem finishedItem : items) {
InventoryTransactionLeg lastInvTransaction = lastFinishedItemIdInTransactionMap.getOrDefault(finishedItem.getId(), null);
finishedItem.setIsQa(true);
if (finishedItem.getQaStatus().equalsIgnoreCase("REJECT")) {
// create OUT and IN transactions for FI
StoreItem storeItem = (createStoreItems(finishedItem, wrapper.getRejectReason()));
storeItem.setId(storeItemDao.save(storeItem));
if (lastInvTransaction != null) {
// OUT
long fromAccount = lastInvTransaction.getAccountId();
storeItem.setAccountId(fromAccount);
createInventoryTransactionLeg(transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.FINISHED_ITEM.name());
// IN
createInventoryTransactionLeg(transaction, storeItem, toAccount, InventoryTransactionLeg.Type.IN.name(), InventoryArtifactType.STORED_ITEM.name());
}
finishedItem.setIsSegregated(true);
finishedItem.setStore(true);
storeItems.add(storeItem);
}
updatedItems.add(finishedItem);
}
// save finish items
finishedItemDAO.saveAll(updatedItems);
storeItemDao.saveAll(storeItems);
}
}
/*
* find item summary by account
@ -737,4 +787,19 @@ public class InventoryService {
packagingItems.setQaStatus(finishedItem.getQaStatus());
return packagingItems;
}
private StoreItem createStoreItems(FinishedItem finishedItem, String reason) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
StoreItem storeItem = new StoreItem();
storeItem.setItemId(finishedItem.getItemId());
storeItem.setAccountId(finishedItem.getAccountId());
storeItem.setFinishedItemId(finishedItem.getId());
storeItem.setJobCardId(finishedItem.getJobCardId());
storeItem.setSku(finishedItem.getSku());
storeItem.setBarcode(finishedItem.getBarcode());
storeItem.setCreatedAt(LocalDateTime.now());
storeItem.setCreatedBy(authentication.getName());
storeItem.setRejectedReason(reason);
return storeItem;
}
}

View File

@ -16,7 +16,7 @@ public class PackagingService {
}
public void createPackagingItem(FinishedItemWrapper wrapper){
inventoryService.createPackagingItemAndTransaction(wrapper);
inventoryService.createPackagingItemAndTransaction(wrapper, wrapper.getAccountId());
}
}

View File

@ -1,6 +1,8 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.JobCardDAO;
import com.utopiaindustries.dao.ctp.PurchaseOrderCTPDao;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.model.ctp.*;
import com.utopiaindustries.model.uind.PurchaseOrder;
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
@ -14,15 +16,22 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderCTPService {
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final JobCardDAO jobCardDAO;
private final StoreItemDao storeItemDao;
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao) {
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao, JobCardDAO jobCardDAO, StoreItemDao storeItemDao) {
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.jobCardDAO = jobCardDAO;
this.storeItemDao = storeItemDao;
}
/*
@ -77,4 +86,17 @@ public class PurchaseOrderCTPService {
return purchaseOrderCTPDao.findByTerm( term );
}
public Map<String,Integer> getStoreItemsByPoId(Long poId){
Map<String,Integer> totalItems = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findByPoId(poId);
List<Long> jobCardIds = jobCards.stream()
.map(JobCard::getId)
.collect(Collectors.toList());
if(!jobCardIds.isEmpty()){
return storeItemDao.totalCountByJobCardIdsAndGroupByRejectReason(jobCardIds);
}else {
return totalItems;
}
}
}

View File

@ -1,21 +1,58 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.StoreItemDao;
import com.utopiaindustries.dao.uind.PurchaseOrderDAO;
import com.utopiaindustries.model.ctp.JobCardItem;
import com.utopiaindustries.model.ctp.POsDetails;
import com.utopiaindustries.model.uind.PurchaseOrder;
import com.utopiaindustries.util.HTMLBuilder;
import com.utopiaindustries.util.PDFResponseEntityInputStreamResource;
import com.utopiaindustries.util.URLUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class PurchaseOrderService {
private final PurchaseOrderDAO purchaseOrderDAO;
private final PurchaseOrderCTPService purchaseOrderCTPService;
private final HTMLBuilder htmlBuilder;
private PDFResponseEntityInputStreamResource pdfGenerator;
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO) {
public PurchaseOrderService(PurchaseOrderDAO purchaseOrderDAO, PurchaseOrderCTPService purchaseOrderCTPService, HTMLBuilder htmlBuilder, PDFResponseEntityInputStreamResource pdfGenerator) {
this.purchaseOrderDAO = purchaseOrderDAO;
this.purchaseOrderCTPService = purchaseOrderCTPService;
this.htmlBuilder = htmlBuilder;
this.pdfGenerator = pdfGenerator;
}
public List<PurchaseOrder> findByTerm( String term ){
return purchaseOrderDAO.findByTerm( term );
}
/**
* Print Job card *
* **/
public ResponseEntity<InputStreamResource> generatePOPdf(POsDetails pOsDetails, Model model, boolean jobCardDetail, boolean storeDetail ) throws Exception {
Map<String,Integer> storeItems = purchaseOrderCTPService.getStoreItemsByPoId(pOsDetails.getPoId());
model.addAttribute("poDetail", pOsDetails);
model.addAttribute( "baseUrl", URLUtils.getCurrentBaseUrl() );
if (storeDetail && !storeItems.isEmpty()){
model.addAttribute("showStore", true);
model.addAttribute("store", storeItems);
}else {
model.addAttribute("showStore", false);
}
String htmlStr = htmlBuilder.buildHTML( "po-status-pdf", model );
// return pdf
return pdfGenerator.generatePdf( htmlStr, "Po-status", "inline" );
}
}

View File

@ -22,30 +22,26 @@ import java.util.stream.Collectors;
public class ReportingService {
private final JobCardItemDAO jobCardItemDAO;
private final ProcessDAO processDAO;
private final BundleDAO bundleDAO;
private final InventoryTransactionLegDAO inventoryTransactionLegDAO;
private final InventoryTransactionDAO inventoryTransactionDAO;
private final JobCardDAO jobCardDAO;
private final CryptographyService cryptographyService;
private final MasterBundleDAO masterBundleDAO;
private final FinishedItemDAO finishedItemDAO;
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
private final InventoryAccountDAO inventoryAccountDAO;
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
private final StoreItemDao storeItemDao;
private final PackagingItemsDAO packagingItemsDAO;
public ReportingService(JobCardItemDAO jobCardItemDAO, ProcessDAO processDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, InventoryTransactionDAO inventoryTransactionDAO, JobCardDAO jobCardDAO, CryptographyService cryptographyService, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PackagingItemsDAO packagingItemsDAO) {
public ReportingService(JobCardItemDAO jobCardItemDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, JobCardDAO jobCardDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, PurchaseOrderCTPDao purchaseOrderCTPDao, StoreItemDao storeItemDao, PackagingItemsDAO packagingItemsDAO) {
this.jobCardItemDAO = jobCardItemDAO;
this.processDAO = processDAO;
this.bundleDAO = bundleDAO;
this.inventoryTransactionLegDAO = inventoryTransactionLegDAO;
this.inventoryTransactionDAO = inventoryTransactionDAO;
this.jobCardDAO = jobCardDAO;
this.cryptographyService = cryptographyService;
this.masterBundleDAO = masterBundleDAO;
this.finishedItemDAO = finishedItemDAO;
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
this.inventoryAccountDAO = inventoryAccountDAO;
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
this.storeItemDao = storeItemDao;
this.packagingItemsDAO = packagingItemsDAO;
}
@ -216,7 +212,7 @@ public class ReportingService {
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(Long.parseLong(jobCardID));
List<FinishedItem> bGradeFinishItemsIds= finishedItems.stream()
.filter(item -> "B GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
.filter(item -> "REJECT".equals(item.getQaStatus())).collect(Collectors.toList());
List<FinishedItem> cGradeFinishItemsIds= finishedItems.stream()
.filter(item -> "C GRADE".equals(item.getQaStatus())).collect(Collectors.toList());
@ -281,9 +277,6 @@ public class ReportingService {
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal expectedProduction = jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getExpectedProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);
if(actualProduction.compareTo(totalProduction) == 0) {
phasePending.put("Stitching Total Time", null);
}else {
@ -444,38 +437,36 @@ public class ReportingService {
return barChartData;
}
public List<POsDetails> getAllPOs(String poName) {
public List<POsDetails> getAllPOs(String poCode) {
List<POsDetails> pOsDetailsList = new ArrayList<>();
List<JobCard> jobCards = jobCardDAO.findAll() ;
HashMap<String, List<JobCard>> filterJobCardsByPos;
if(poName != null && !poName.isEmpty()) {
filterJobCardsByPos = jobCards.stream()
.filter(jobCard -> jobCard.getPurchaseOrderId().equals(poName))
.collect(Collectors.groupingBy(
JobCard::getPurchaseOrderId,
HashMap::new,
Collectors.toList()
));
List<PurchaseOrderCTP> purchaseOrderCTPList;
if (poCode != null && !poCode.isEmpty()) {
purchaseOrderCTPList = purchaseOrderCTPDao.findByPoCode(poCode);
}else {
filterJobCardsByPos = jobCards.stream()
.collect(Collectors.groupingBy(
JobCard::getPurchaseOrderId,
HashMap::new,
Collectors.toList()
));
purchaseOrderCTPList = purchaseOrderCTPDao.findAll();
}
Map<String,Integer> jobCardCompleteItems = new HashMap<>();
for (String pos : filterJobCardsByPos.keySet()) {
for (PurchaseOrderCTP pos : purchaseOrderCTPList) {
List<JobCard> jobCards = jobCardDAO.findByPoId(pos.getId());
BigDecimal totalProduction = BigDecimal.ZERO;
BigDecimal expectedProduction = BigDecimal.ZERO;
BigDecimal actualProduction = BigDecimal.ZERO;
int poQuantity = 0;
String articleName = "";
Long qaProgressItems = 0L;
Long totalFinishItem = 0L;
long stitchingIn = 0L;
long stitchingOut = 0L;
long finishApprovedItem = 0L;
long finishRejectItem = 0L;
long storeItems = 0L;
long packagingItems = 0L;
POsDetails pOsDetails = new POsDetails();
for (JobCard jobCard : filterJobCardsByPos.get(pos)) {
for (JobCard jobCard : jobCards) {
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCard.getId());
expectedProduction = expectedProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getExpectedProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
totalProduction = totalProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
@ -483,56 +474,67 @@ public class ReportingService {
actualProduction = actualProduction.add(jobCardItems.stream()
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add));
poQuantity = jobCard.getPoQuantity();
articleName = jobCard.getArticleName();
qaProgressItems += Optional.ofNullable(stitchingOfflineItemDAO.CalculateTotalQA(jobCard.getId())).orElse(0L);
totalFinishItem += Optional.ofNullable(finishedItemDAO.calculateTotalFinishItem(jobCard.getId())).orElse(0L);
jobCardCompleteItems = getSegregateItems(String.valueOf(jobCard.getId()));
if (jobCardCompleteItems == null) {
jobCardCompleteItems = new HashMap<>();
}
//stitching detail
stitchingIn += Optional.of(stitchingOfflineItemDAO.findByJobCardId(jobCard.getId()).size()).orElse(0);
stitchingOut += Optional.ofNullable(stitchingOfflineItemDAO.CalculateTotalQA(jobCard.getId())).orElse(0L);
//finishItems detail
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(jobCard.getId());
finishApprovedItem += finishedItems.stream().filter(e -> e.getQaStatus().equals("APPROVED")).count();
finishRejectItem += finishedItems.stream().filter(e -> e.getQaStatus().equals("REJECT")).count();
//reject store details
storeItems += Optional.ofNullable(storeItemDao.calculateTotalRejectItemByJobCardId(jobCard.getId())).orElse(0L);
//reject packaging details
packagingItems += Optional.of(packagingItemsDAO.findByJobCardId(jobCard.getId()).size()).orElse(0);
}
pOsDetails.setPoNumber(pos);
pOsDetails.setArticleTitle(articleName);
pOsDetails.setPoQuantity(poQuantity);
pOsDetails.setTotalCutting(actualProduction.intValue());
pOsDetails.setTotalStitching(totalProduction.intValue());
pOsDetails.setTotalEndLineQC(qaProgressItems.intValue());
pOsDetails.setTotalFinishing(totalFinishItem);
pOsDetails.setRemainingCutting(poQuantity - actualProduction.intValue());
pOsDetails.setRemainingStitching(poQuantity - totalProduction.intValue());
pOsDetails.setRemainingEndLineQC(poQuantity - qaProgressItems);
pOsDetails.setRemainingFinishing(poQuantity - totalFinishItem);
pOsDetails.setTotalAGradeItem(jobCardCompleteItems.getOrDefault("A GRADE", 0));
pOsDetails.setTotalBGradeItem(jobCardCompleteItems.getOrDefault("B GRADE", 0));
pOsDetails.setTotalCGradeItem(jobCardCompleteItems.getOrDefault("C GRADE", 0));
pOsDetails.setPoId(pos.getId());
pOsDetails.setPoNumber(pos.getPurchaseOrderCode());
pOsDetails.setArticleTitle(pos.getArticleName());
pOsDetails.setPoQuantity(pos.getPurchaseOrderQuantity());
pOsDetails.setPoRequiredQuantity(pos.getPurchaseOrderQuantityRequired());
pOsDetails.setActualCutting(expectedProduction.longValue());
pOsDetails.setBalanceToCutting(pos.getPurchaseOrderQuantityRequired() - actualProduction.longValue());
pOsDetails.setCuttingReceived(expectedProduction.longValue());
pOsDetails.setCuttingOki(actualProduction.intValue());
pOsDetails.setCuttingReject(expectedProduction.subtract(actualProduction).intValue());
pOsDetails.setStitchingIn(stitchingIn);
pOsDetails.setStitchingOut(stitchingOut);
pOsDetails.setStitchingWips(stitchingIn - stitchingOut);
pOsDetails.setFinishIn(stitchingOut);
pOsDetails.setFinishRej(finishRejectItem);
pOsDetails.setFinishQaApproved(finishApprovedItem);
pOsDetails.setStoreReceived(storeItems);
pOsDetails.setStoreWaiting(finishRejectItem - storeItems);
pOsDetails.setFinishQaApproved(finishApprovedItem);
pOsDetails.setPackagingIn(packagingItems);
pOsDetails.setPackagingOut(packagingItems);
pOsDetails.setPackagingStock(0);
pOsDetails.setShippedScan(packagingItems);
pOsDetails.setShippedNet(packagingItems);
pOsDetails.setPackagingStock(0);
pOsDetails.setPoStatus(false);
pOsDetailsList.add(pOsDetails);
}
return pOsDetailsList;
}
public HashMap<String, Map<String, Integer>> getAllPoJobCards(String PONumber, String selectDate) {
public HashMap<String, Map<String, Integer>> getAllPoJobCards(long poId, String selectDate) {
String startDate = selectDate != null && !selectDate.isEmpty() ? selectDate + " 00:00:01": null;
String endDate = selectDate != null && !selectDate.isEmpty() ? selectDate + " 23:59:59": null;
HashMap<String, Map<String, Integer>> poJobCardItemsProgress = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findAll();
// Filter JobCards by Purchase Order ID
List<JobCard> filterJobCardsByPos = jobCards.stream()
.filter(e -> e.getPurchaseOrderId().equals(PONumber))
.collect(Collectors.toList());
List<JobCard> filterJobCardsByPos = jobCardDAO.findByPoId(poId);
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.getPackagingAccounts();
List<Integer> gradingAccounts = inventoryAccounts.stream().map(e-> (int)(e.getId())).collect(Collectors.toList());
for (JobCard jobCard : filterJobCardsByPos) {
List<Bundle> bundles = bundleDAO.findByCardIdAndDATE(jobCard.getId(),startDate,endDate);
List<StitchingOfflineItem> stitchingOfflineItems = stitchingOfflineItemDAO.findByJobCardIdAndDate(jobCard.getId(),startDate,endDate);
List<FinishedItem> finishedItems = finishedItemDAO.calculateTotalFinishItem(jobCard.getId(),startDate,endDate);
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.getTransactionByJobCardAndDatesAndTypeAndAccountID(jobCard.getId(),startDate,endDate,"IN", gradingAccounts);
//cutting days wise
BigDecimal cutting = bundles.stream()
@ -544,26 +546,21 @@ public class ReportingService {
//total qa
Integer qa = finishedItems.size();
Map<String, Integer> segregateItems = inventoryTransactionLegs.stream()
.filter(leg -> inventoryAccounts.stream()
.anyMatch(account -> (int) account.getId() == (leg.getAccountId())))
.collect(Collectors.toMap(
leg -> inventoryAccounts.stream()
.filter(account -> (int) account.getId() == (leg.getAccountId()))
.findFirst()
.map(InventoryAccount::getTitle)
.orElse("Unknown"),
leg -> leg.getQuantity().intValue(),
Integer::sum,
HashMap::new
Map<String, Integer> segregateItems = finishedItems.stream()
.collect(Collectors.groupingBy(
FinishedItem::getQaStatus,
Collectors.collectingAndThen(
Collectors.counting(),
Long::intValue
)
));
Map<String, Integer> items = getCompleteProduction(String.valueOf(jobCard.getId()));
items.put("Cutting Progress",cutting.intValue());
items.put("Stitching Progress",stitching);
items.put("QA Progress",qa);
items.put("A Grade",segregateItems.get("A GRADE") != null ? segregateItems.get("A GRADE") : 0);
items.put("B Grade",segregateItems.get("B GRADE") != null ? segregateItems.get("B GRADE") : 0);
items.put("C Grade",segregateItems.get("C GRADE") != null ? segregateItems.get("C GRADE") : 0);
items.put("A Grade",segregateItems.get("APPROVED") != null ? segregateItems.get("APPROVED") : 0);
items.put("B Grade / Reject",segregateItems.get("REJECT") != null ? segregateItems.get("REJECT") : 0);
// Define sorting order
Map<String, Integer> indexMap = new HashMap<>();
@ -572,9 +569,8 @@ public class ReportingService {
indexMap.put("Stitching Progress", 3);
indexMap.put("QA Progress", 4);
indexMap.put("Finishing Progress", 5);
indexMap.put("A GRADE", 6);
indexMap.put("B GRADE", 7);
indexMap.put("C GRADE", 8);
indexMap.put("APPROVED", 6);
indexMap.put("REJECT", 7);
// Sort items based on indexMap order
Map<String, Integer> sortedItems = items.entrySet()

View File

@ -0,0 +1,19 @@
package com.utopiaindustries.service;
import com.utopiaindustries.dao.ctp.PackagingItemsDAO;
import com.utopiaindustries.model.ctp.FinishedItemWrapper;
import org.springframework.stereotype.Service;
@Service
public class StoreService {
private final InventoryService inventoryService;
public StoreService(InventoryService inventoryService, PackagingItemsDAO packagingItemsDAO) {
this.inventoryService = inventoryService;
}
public void createStoreItems(FinishedItemWrapper wrapper ) {
inventoryService.createStoreItemAndTransaction(wrapper, wrapper.getAccountId());
}
}

View File

@ -1,8 +1,8 @@
spring:
uinddatasource:
jdbcUrl: jdbc:mysql://192.168.90.147:3306
username: utopia
password: Utopia01
jdbcUrl: jdbc:mysql://utopia-industries-rr.c5qech8o9lgg.us-east-1.rds.amazonaws.com:3306/inventory
username: cut-to-pack
password: mAzFAivImnTqKJx4KNJ0
driverClassName: com.mysql.cj.jdbc.Driver
logbackUrl: jdbc:mysql://192.168.90.147:3306/uind_logs?serverTimezone=Asia/Karachi
hikari:
@ -19,7 +19,7 @@ spring:
pool-name: UINDCosmosPool
leak-detection-threshold: 2000
localdatasource:
jdbcUrl: jdbc:mysql://192.168.90.147:3306/cut_to_pack
jdbcUrl: jdbc:mysql://localhost:3306/cut_to_pack
username: utopia
password: Utopia01
driverClassName: com.mysql.cj.jdbc.Driver

View File

@ -9,7 +9,7 @@ spring:
minimum-idle: 5
idle-timeout: 30000 # 30 seconds
max-lifetime: 1800000 # 30 minutes
connection-timeout: 30000 # 30 seconds
connection-timeout: 60000 # 30 seconds
leak-detection-threshold: 10000
cosmosdatasource:
jdbcUrl: jdbc:mysql://192.168.90.147:3307

View File

@ -55,6 +55,7 @@
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'ALTER' || item.qaStatus === 'B GRADE' || item.qaStatus === 'C GRADE' " class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'WASHED'" class="font-lg badge badge-APPROVED">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'REJECT'" class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
<td>
<button type="button" class="btn btn-light" v-on:click="removeItem(index)">
<i class="bi bi-trash"></i>

View File

@ -221,7 +221,7 @@
items: [],
purchaseOrderID:0,
articleName: '',
purchaseOrderQuantity: 0,
purchaseOrderQuantityRequired: 0,
purchaseOrderCode: '',
},
methods: {
@ -266,7 +266,7 @@
}, onPoSelect(id,purchaseOrder) {
this.purchaseOrderID = id,
this.articleName = purchaseOrder.articleName,
this.purchaseOrderQuantity = purchaseOrder.purchaseOrderQuantity,
this.purchaseOrderQuantityRequired = purchaseOrder.purchaseOrderQuantityRequired,
this.purchaseOrderCode = purchaseOrder.purchaseOrderCode
}
},
@ -274,7 +274,7 @@
this.jobCard = window.ctp.jobCard;
this.purchaseOrderID = this.jobCard.purchaseOrderId,
this.articleName = this.jobCard.articleName,
this.purchaseOrderQuantity = this.jobCard.poQuantity,
this.purchaseOrderQuantityRequired = this.jobCard.poQuantity,
this.purchaseOrderCode = this.jobCard.purchaseOrderTitle
this.items = this.jobCard.items;

View File

@ -59,7 +59,7 @@
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'ALTER' || item.qaStatus === 'B GRADE'" class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'WASHED'" class="font-lg badge badge-APPROVED">{{ item.qaStatus }}</span>
<span v-else-if="item.qaStatus === 'REJECT'" class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
</td>
<td>
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
@ -76,7 +76,8 @@
let app = new Vue({
el : '#packagingApp',
data : {
items : []
items : [],
reason: '',
},
methods : {
onItemSelect: function (id, item) {
@ -90,6 +91,18 @@
const uniqueIds = new Set(ids);
return ids.length !== uniqueIds.size;
},
submitWithRejectReason: function (reason) {
this.reason = reason;
this.$nextTick(() => {
const form = document.getElementById('packagingApp');
if (form.checkValidity()) {
form.submit();
} else {
form.reportValidity();
}
});
}
},
mounted : function () {
console.log( this.$accounts )

View File

@ -86,11 +86,16 @@
return ids.length !== uniqueIds.size;
},
submitWithQaStatus: function (status) {
this.QaStatus = status;
this.$nextTick(() => {
document.getElementById('qcForm').submit();
});
}
this.QaStatus = status;
this.$nextTick(() => {
const form = document.getElementById('qcForm');
if (form.checkValidity()) {
form.submit();
} else {
form.reportValidity();
}
});
}
},
mounted: function () {

View File

@ -74,13 +74,19 @@
<a th:href="@{/packaging/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging') ? 'active' : ''}">Packaging</a>
</li>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_STORE', 'ROLE_ADMIN')">
<a th:href="@{/store/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store') ? 'active' : ''}">Store</a>
</li>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_PURCHASE_ORDER', 'ROLE_ADMIN')">
<a th:href="@{/po-status/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status') ? 'active' : ''}">Online PO Status</a>
</li>
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_REPORTING', 'ROLE_ADMIN')">
<a th:href="@{/reporting/summary}" class="nav-link"
<a th:href="@{/reporting/}" class="nav-link"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting') ? 'active' : ''}">Reporting</a>
</li>
<li class="nav-item dropdown" sec:authorize="hasRole('ROLE_ADMIN')">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Admin</a>
<div class="dropdown-menu">
@ -139,6 +145,17 @@
</li>
</ul>
</nav>
<!-- second level purchase order-->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/purchase-order')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/purchase-order') ? 'active' : ''}">
<a th:href="@{/purchase-order/}" class="nav-link">PO's</a>
</li>
</ul>
</nav>
<!-- second level cutting -->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/cutting')}">
@ -170,10 +187,6 @@
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/po-report') ? 'active' : ''}">
<a th:href="@{/reporting/po-report}" class="nav-link">PO Report</a>
</li>
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/job-card-report') ? 'active' : ''}">
<a th:href="@{/reporting/job-card-report}" class="nav-link">Job Card Report</a>
@ -192,6 +205,17 @@
</li>
</ul>
</nav>
<!--Second level of po-status-->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/po-status/all-pos') ? 'active' : ''}">
<a th:href="@{/po-status/all-pos}" class="nav-link">All PO's</a>
</li>
</ul>
</nav>
<!-- second level stitching -->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/stitching')}">
@ -256,6 +280,21 @@
</li>
</ul>
</nav>
<!-- second level store -->
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store')}">
<ul class="navbar-nav">
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store/receive-inventory') ? 'active' : ''}">
<a th:href="@{/store/receive-inventory}" class="nav-link">Receive Inventory</a>
</li>
<li class="nav-item"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/store/inventory-accounts') ? 'active' : ''}">
<a th:href="@{/store/inventory-accounts}" class="nav-link">Inventory Accounts</a>
</li>
</ul>
</nav>
</div>
</header>
<!-- table loading skeleton -->

View File

@ -21,7 +21,7 @@
<!-- Hidden Inputs for Dynamic Values -->
<input type="hidden" name="articleName" :value="articleName">
<input type="hidden" name="poQuantity" :value="purchaseOrderQuantity">
<input type="hidden" name="poQuantity" :value="purchaseOrderQuantityRequired">
<input type="hidden" name="purchaseOrderTitle" :value="purchaseOrderCode">
<input type="hidden" name="purchaseOrderId" :value="purchaseOrderID">
@ -57,7 +57,7 @@
<div class="col-sm-3 form-group">
<label>PO Quantity</label>
<!-- Dynamically show PO quantity -->
<span class="form-control">{{ purchaseOrderQuantity || jobCard.poQuantity }}</span>
<span class="form-control">{{ purchaseOrderQuantityRequired || jobCard.poQuantity }}</span>
</div>
<div class="col-sm-3 form-group" th:with="title=*{locationTitle},id=*{locationSiteId}">

View File

@ -157,7 +157,7 @@
th:data-title="${detail.get('articleName')} + ' (' + ${date} + ')'"
th:data-dates="${date}"
th:data-stitching="${phases.get('Stitching')?.intValue() ?: 0}"
th:data-finishing="${phases.get('finishing')?.intValue() ?: 0}"
th:data-finishing="${phases.get('finishingValueForBarChart')?.intValue() ?: 0}"
th:data-packaging="${phases.get('packaging')?.intValue() ?: 0}"
th:data-totalProduction="${detail.get('Shift Target')}"
th:data-fontSize="35">
@ -193,8 +193,6 @@
</div>
</div>
</div>
</main>
</div>
<script>

View File

@ -7,26 +7,28 @@
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<div class="col-sm">
<div th:replace="_notices :: page-notices"></div>
<div class="mb-4 d-flex justify-content-between">
<h3>Receive Finished Items</h3>
<h3>Receive Packing Items</h3>
</div>
<form th:action="'/ctp/packaging/packaging-items'" method="post" id="packagingApp">
<form th:action="'/ctp/packaging/packaging-items'" method="post" id="packagingApp" th:object="${wrapper}">
<div class="bg-light p-3 mb-3">
<div class="form-row">
<div class="col-sm-3 form-group">
<search-item
:is-segregated="true"
url="/ctp/rest/finished-items/search-packaging"
v-on:finished-item-select="onItemSelect">
</search-item>
</div>
<div class="col-sm-3 form-group">
<!-- <label>Packaging Account</label>-->
<!-- <select class="form-control" name="account-id" th:field="*{finishedAccountId}" required>-->
<!-- <option value="">PLease select</option>-->
<!-- <option th:each="account : ${accounts}"-->
<!-- th:value="${account.id}"-->
<!-- th:text="${account.title}"></option>-->
<!-- </select>-->
<label>Packaging Account</label>
<select class="form-control" name="account-id" th:field="*{accountId}" required>
<option value="">PLease select</option>
<option th:each="account : ${accounts}"
th:value="${account.id}"
th:text="${account.title}"></option>
</select>
</div>
</div>
</div>

View File

@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:uind="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Job Card</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:700|Open+Sans:400,400i&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" th:href="@{|${baseUrl}/css/print.css|}">
<style type="text/css">
@page {
size: landscape;
margin: 10mm;
}
@media print {
body {
transform: rotate(0deg); /* Not needed for @page landscape */
width: 100%;
}
}
.td-value{
text-align: center;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="container-fluid">
<table>
<tr>
<td width="50%">
<img width="200" th:src="@{|${baseUrl}/img/utopia-industries.png|}" alt="Utopia Industries">
</td>
<td width="50%">
<table class="bordered">
<tr class="tr-header">
<td colspan="2" style="text-align: center" th:text="'PO Online Status'"></td>
</tr>
<tbody>
<tr>
<td style="width: 40%;"><i>PO Code</i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${poDetail.getPoNumber()}"></a>
</td>
</tr>
<tr>
<td style="width: 40%;"><i>Article Name</i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${poDetail.getArticleTitle()}"></a>
</td>
</tr>
<tr>
<td class="align-middle"><i>PO Quantity</i></td>
<td><span th:text="${poDetail.getPoQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle"><i>PO Required Excess+</i></td>
<td><span th:text="${poDetail.getPoRequiredQuantity()}"></span></td>
</tr>
<tr>
<td class="align-middle"><i>PO Status</i></td>
<td>
<span th:if="*{poDetail.isPoStatus}" th:text="'CLOSE'"></span>
<span th:if="*{!poDetail.isPoStatus}" th:text="'OPEN'"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<table style="margin-top: 10px;">
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 10px;">PO Details</h5>
<thead>
<tr class="tr-header">
<td style="width: 70px; text-align: center"></td>
<td style="width: 60px; text-align: center">Cutting Insp.</td>
<td style="width: 150px; text-align: center">Stitching</td>
<td style="width: 60px; text-align: center">Finished</td>
<td style="width: 90px; text-align: center; padding-left: 40px">Rej. Store</td>
<td style="width: 100px; text-align: center">Packaging</td>
<td style="width: 80px; text-align: center">Shipped</td>
</tr>
</thead>
</table>
<table >
<thead>
<tr class="tr-header">
<td style="width: 50px; text-align: center" >Actual Cut</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Bal.To Cut</td>
<td style="width: 50px; text-align: center;">Rcvd.</td>
<td style="width: 50px; text-align: center">Ok</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Rej.</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">WIP</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Out</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">Rej</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">QA Approv.</td>
<td style="width: 50px; text-align: center">Rcvd.</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">waiting</td>
<td style="width: 50px; text-align: center">In</td>
<td style="width: 50px; text-align: center">Out</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Stock</td>
<td style="width: 50px; text-align: center">Scan</td>
<td style="width: 50px; text-align: center; border-right: 1px solid white;">Net</td>
</tr>
</thead>
<tbody>
<tr >
<td th:text="${poDetail.getActualCutting()}" class="td-value"></td>
<td th:text="${poDetail.getBalanceToCutting()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingReceived()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingOki()}" class="td-value"></td>
<td th:text="${poDetail.getCuttingReject()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingIn()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingWips()}" class="td-value"></td>
<td th:text="${poDetail.getStitchingOut()}" class="td-value"></td>
<td th:text="${poDetail.getFinishIn()}" class="td-value"></td>
<td th:text="${poDetail.getFinishRej()}" class="td-value"></td>
<td th:text="${poDetail.getFinishQaApproved()}" class="td-value"></td>
<td th:text="${poDetail.getStoreReceived()}" class="td-value"></td>
<td th:text="${poDetail.getStoreWaiting()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingIn()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingOut()}" class="td-value"></td>
<td th:text="${poDetail.getPackagingStock()}" class="td-value"></td>
<td th:text="${poDetail.getShippedScan()}" class="td-value"></td>
<td th:text="${poDetail.getShippedNet()}" class="td-value"></td>
</tr>
</tbody>
</table>
<table class="bordered" style="width: 50%; margin-top: 20px;" th:if="${showStore}">
<tr class="tr-header">
<td colspan="2" style="text-align: center" th:text="'Reject Items In Store'"></td>
</tr>
<tbody>
<tr th:each="heading : ${store.keySet()}"
th:if="${store != null and not store.isEmpty()}">
<td style="width: 40%;"><i th:text="${heading}"></i></td>
<td style="width: 60%;">
<a class="text-reset" target="_blank" th:text="${store.get(heading)}"></a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

View File

@ -13,7 +13,7 @@
<div class="col-sm">
<div th:replace="_notices :: page-notices"></div>
<div class="mb-4 d-flex justify-content-between">
<h3>Job Cards</h3>
<h3>All PO's</h3>
<a th:href="@{/purchase-order/new}" class="btn btn-primary">Add New</a>
</div>
<div th:replace="_fragments :: table-loading-skeleton"></div>
@ -55,7 +55,7 @@
</tbody>
</table>
<!-- Show message if purchaseOrder is null or empty -->
<h4 th:if="${purchaseOrder == null or purchaseOrder.isEmpty()}">No cards found.</h4>
<h4 th:if="${purchaseOrder == null or purchaseOrder.isEmpty()}">No POs found.</h4>
</div>
</main>
</div>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
xmlns:uind="http://www.w3.org/1999/xhtml" xmlns:ctp="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Finished Item')"></head>
<head th:replace="_fragments :: head('Qc Finished Item')"></head>
<body>
<div class="container-fluid">
<header class="row page-header" th:replace="_fragments :: page-header"></header>

View File

@ -8,6 +8,7 @@
<main class="row page-main">
<aside class="col-sm-2" th:replace="/reporting/po-job-card-report-sidebar :: sidebar"></aside>
<div class="col-sm">
<h3>PO Job Cards</h3>
<table class="table">
<tbody>
<tr th:if="${allJobCard != null}" th:each="jobCard : ${allJobCard.keySet()}"

View File

@ -8,7 +8,7 @@
<form th:action="@{${#strings.replace(#httpServletRequest.requestURI, #request.getContextPath(), '')}}">
<h5 class="mb-4">Refine Your Search</h5>
<div class="form-group">
<label>PO Name</label>
<label>PO Code</label>
<input type="text" class="form-control" name="poName" th:value="${param['poName'] ?: poName}">
</div>
<input type="submit" class="btn btn-secondary btn-block" value="Search">

View File

@ -1,63 +1,250 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
xmlns:ctp="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('PO Report')"></head>
<body>
<div class="container-fluid">
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<aside class="col-sm-2" th:replace="/reporting/po-report-sidebar :: sidebar"></aside>
<div class="col-lg-10 col-sm-10">
<h3>PO's Report</h3>
<table class="table table-striped font-sm" data-order="[[ 0, &quot;asc&quot; ]]">
<div class="col-lg-10 col-sm-10" style="overflow-x: auto;">
<h3>All PO's</h3>
<div class="table-responsive"> <!-- Bootstrap responsive table wrapper -->
<table th:if="${ #lists != null && #lists.size(allPOs) != 0 }"
class="table table-striped font-sm" style="min-width: 1500px;">
<thead>
<tr>
<th>PO Number</th>
<th>PO Article</th>
<th>PO Quantity</th>
<th>Cutting</th>
<th>Cutting Balance</th>
<th>Stitching</th>
<th>Stitching Balance</th>
<th>End Line QC</th>
<th>End Line QC Balance</th>
<th>Finishing Items</th>
<th>Finishing Items Balance</th>
<th>A Grade Items</th>
<th>B Grade Items</th>
<th>C Grade Items</th>
<th>Req+ Excess</th>
<th>Cut.</th>
<th>Cut Bal.</th>
<th>Cut Recv.</th>
<th>Cut oki</th>
<th>Cut Rej.</th>
<th>Stit. In</th>
<th>Stit. Out</th>
<th>Stit. Wips</th>
<th>finish In</th>
<th>finish Rej.</th>
<th>finish QA APP.</th>
<th>Rej. Store Rcvd</th>
<th>Rej. Store Waiting</th>
<th>Packed In</th>
<th>Packed Out</th>
<th>Packed Stock</th>
<th>Shipped Scan</th>
<th>Shipped Net</th>
<th></th>
<th>PO Status</th>
<th>Generate PDF</th>
</tr>
</thead>
<tbody>
<!-- Dummy data for testing purposes -->
<tr th:each="poDetail : ${allPOs}">
<td><a class="text-reset" th:href="@{'/reporting/po-report-view/' + ${poDetail.poNumber}}" th:text="${poDetail.poNumber}"></a></td>
<td><a class="text-reset" th:href="@{'/po-status/po-report-view/' + ${poDetail.poId}}"
th:text="${poDetail.poNumber}"></a></td>
<td th:text="${poDetail.articleTitle}"></td>
<td th:text="${poDetail.poQuantity}"></td>
<td th:text="${poDetail.totalCutting}"></td>
<td th:text="${poDetail.remainingCutting}"></td>
<td th:text="${poDetail.totalStitching}"></td>
<td th:text="${poDetail.remainingStitching}"></td>
<td th:text="${poDetail.totalEndLineQC}"></td>
<td th:text="${poDetail.remainingEndLineQC}"></td>
<td th:text="${poDetail.totalFinishing}"></td>
<td th:text="${poDetail.remainingFinishing}"></td>
<td th:text="${poDetail.totalAGradeItem}"></td>
<td th:text="${poDetail.totalBGradeItem}"></td>
<td th:text="${poDetail.totalCGradeItem}"></td>
<td th:text="${poDetail.poRequiredQuantity}"></td>
<td th:text="${poDetail.actualCutting}"></td>
<td th:text="${poDetail.balanceToCutting}"></td>
<td th:text="${poDetail.cuttingReceived}"></td>
<td th:text="${poDetail.cuttingOki}"></td>
<td th:text="${poDetail.cuttingReject}"></td>
<td th:text="${poDetail.stitchingIn}"></td>
<td th:text="${poDetail.stitchingOut}"></td>
<td th:text="${poDetail.stitchingWips}"></td>
<td th:text="${poDetail.finishIn}"></td>
<td th:text="${poDetail.finishRej}"></td>
<td th:text="${poDetail.finishQaApproved}"></td>
<td th:text="${poDetail.storeReceived}"></td>
<td th:text="${poDetail.storeWaiting}"></td>
<td th:text="${poDetail.packagingIn}"></td>
<td th:text="${poDetail.packagingOut}"></td>
<td th:text="${poDetail.packagingStock}"></td>
<td th:text="${poDetail.shippedScan}"></td>
<td th:text="${poDetail.shippedNet}"></td>
<td data-show-dropdown-transactions
th:data-po-id="${poDetail.poId}"
title="Store-Items">
<span data-dropdown-icon-transactions class="bi bi-caret-right-fill"></span>
</td>
<td>
<span class="badge font-sm badge-danger" th:if="*{poDetail.poStatus}" th:text="'CLOSE'"></span>
<span class="badge font-sm badge-ACTIVE" th:if="*{!poDetail.poStatus}" th:text="'OPEN'"></span>
</td>
<td>
<form th:action="@{/po-status/generate-po-pdf}" method="get" target="_blank"
th:id="'form-' + ${poDetail.poId}">
<!-- Hidden inputs for all fields -->
<input type="hidden" name="poId" th:value="${poDetail.poId}"/>
<input type="hidden" name="poNumber" th:value="${poDetail.poNumber}"/>
<input type="hidden" name="articleTitle" th:value="${poDetail.articleTitle}"/>
<input type="hidden" name="poQuantity" th:value="${poDetail.poQuantity}"/>
<input type="hidden" name="poRequiredQuantity" th:value="${poDetail.poRequiredQuantity}"/>
<input type="hidden" name="actualCutting" th:value="${poDetail.actualCutting}"/>
<input type="hidden" name="balanceToCutting" th:value="${poDetail.balanceToCutting}"/>
<input type="hidden" name="cuttingReceived" th:value="${poDetail.cuttingReceived}"/>
<input type="hidden" name="cuttingOki" th:value="${poDetail.cuttingOki}"/>
<input type="hidden" name="cuttingReject" th:value="${poDetail.cuttingReject}"/>
<input type="hidden" name="stitchingIn" th:value="${poDetail.stitchingIn}"/>
<input type="hidden" name="stitchingOut" th:value="${poDetail.stitchingOut}"/>
<input type="hidden" name="stitchingWips" th:value="${poDetail.stitchingWips}"/>
<input type="hidden" name="finishIn" th:value="${poDetail.finishIn}"/>
<input type="hidden" name="finishRej" th:value="${poDetail.finishRej}"/>
<input type="hidden" name="finishQaApproved" th:value="${poDetail.finishQaApproved}"/>
<input type="hidden" name="storeReceived" th:value="${poDetail.storeReceived}"/>
<input type="hidden" name="storeWaiting" th:value="${poDetail.storeWaiting}"/>
<input type="hidden" name="packagingIn" th:value="${poDetail.packagingIn}"/>
<input type="hidden" name="packagingOut" th:value="${poDetail.packagingOut}"/>
<input type="hidden" name="packagingStock" th:value="${poDetail.packagingStock}"/>
<input type="hidden" name="shippedScan" th:value="${poDetail.shippedScan}"/>
<input type="hidden" name="shippedNet" th:value="${poDetail.shippedNet}"/>
<input type="hidden" name="poStatus" th:value="${poDetail.poStatus}"/>
<a href="javascript:void(0);"
th:onclick="'showPdfOptions(' + ${poDetail.poId} + ')'"
class="btn btn-sm btn-secondary"
title="Generate PDF">
<i class="bi bi-filetype-pdf"></i>
</a>
</form>
</td>
</tr>
</tbody>
</table>
<h4 th:if="${#lists.size(allPOs) == 0 }">No PO found.</h4>
</div>
</div>
<div class="modal fade" id="pdfOptionsModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Select PDF Options</h5>
</div>
<div class="modal-body">
<!-- <div class="form-check">-->
<!-- <input class="form-check-input" type="checkbox" id="includeJobCard" name="includeJobCard" value="true" checked>-->
<!-- <label class="form-check-label" for="includeJobCard">-->
<!-- Include Job Card Details-->
<!-- </label>-->
<!-- </div>-->
<div class="form-check">
<input class="form-check-input" type="checkbox" id="includeStoreDetails" name="includeStoreDetails" value="true" checked>
<label class="form-check-label" for="includeStoreDetails">
Include Store Details
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitPdfForm()">Generate PDF</button>
</div>
</div>
</div>
<!-- <h4 th:if="${#lists.size(cards) == 0 }">No cards found.</h4>-->
</div>
</main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script th:src="@{/js/summary.js}"></script>
<script>
// PDF Generation Functions
let currentPoIdForPdf = null;
function showPdfOptions(poId) {
currentPoIdForPdf = poId;
$('#pdfOptionsModal').modal('show');
}
function submitPdfForm() {
if (!currentPoIdForPdf) return;
const form = document.getElementById('form-' + currentPoIdForPdf);
// Remove existing options if they exist
const existingJobCard = form.querySelector('input[name="includeJobCard"]');
const existingStoreDetails = form.querySelector('input[name="includeStoreDetails"]');
if (existingJobCard) form.removeChild(existingJobCard);
if (existingStoreDetails) form.removeChild(existingStoreDetails);
// Add params to show store details in pdf
const includeStoreDetails = document.createElement('input');
includeStoreDetails.type = 'hidden';
includeStoreDetails.name = 'includeStoreDetails';
includeStoreDetails.value = document.getElementById('includeStoreDetails').checked;
form.appendChild(includeStoreDetails);
form.submit();
$('#pdfOptionsModal').modal('hide');
}
// DataTable and Dropdown Initialization
$(document).ready(function() {
const $body = $('body');
// Initialize DataTables for each individual table
$('table[data-account-table]').each(function () {
$(this).DataTable({
paging: false,
pageLength: 100,
searching: false,
lengthChange: false,
processing: false,
dom: `
<'row'<'col-sm-3'B><'col-sm-4'f>>
<'row'<'col-sm-6't>>
<'row'<'col-sm-3'i><'col-sm-4'p>>`,
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
});
// Dropdown transactions toggle
$body.on('click', '[data-show-dropdown-transactions]', function (e) {
e.preventDefault();
const $this = $(this);
const $tr = $this.closest('tr');
const $table = $this.closest('table');
const dataTable = $table.DataTable();
const $row = dataTable.row($tr);
const $spanDropdown = $this.find('[data-dropdown-icon-transactions]');
const poId = $this.data('po-id');
$spanDropdown.toggleClass('bi-caret-right-fill bi-caret-down-fill');
if ($row.child.isShown()) {
$row.child.hide();
} else {
$row.child(`<span class="spinner-border text-center spinner-border-md" role="status"></span>`).show();
$.ajax({
url: `/ctp/purchase-order/store-items/${poId}`,
success: function(data) {
if (data.includes('page-login') ||
data.includes('login__form') ||
data.includes('Sign in')) {
// Redirect to login page
window.location.href = '/ctp/login?logout';
} else {
$row.child(data).show();
}
},
error: function(xhr) {
if (xhr.status === 401) {
window.location.href = '/ctp/login?logout';
} else {
$row.child('<span class="text-danger">Error loading data</span>').show();
}
}
});
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-8">
<table th:if="${#lists != null && #lists.size(storeItems.keySet()) != 0 }" class="table table-bordered font-sm mb-4" data-account-tables >
<thead>
<tr>
<th th:each="heading : ${storeItems.keySet()}" th:text="${heading}"></th>
</tr>
</thead>
<tbody>
<tr>
<td th:each="heading : ${storeItems.keySet()}" th:text="${storeItems.get(heading)}"></td>
</tr>
</tbody>
</table>
<h5 th:if="${#lists.size(storeItems.keySet()) == 0}" class="mt-2">No Items found.</h5>
</div>
</div>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script th:inline="javascript">
// Initialize DataTables for each individual table
$('table[data-account-tables]').each(function () {
const $table = $(this);
// Prevent reinitializing if already done
if (!$.fn.DataTable.isDataTable($table)) {
$table.DataTable({
paging: false,
searching: false,
lengthChange: false,
info: false,
dom: 't',
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm d-none'
}]
});
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,135 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
xmlns:uind="http://www.w3.org/1999/xhtml" xmlns:ctp="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Store Inventory Accounts')"></head>
<body>
<div class="container-fluid">
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<!-- sidebar starts -->
<aside class="col-sm-2" th:replace="/cutting/_cutting-inventory-account-sidebar :: sidebar"></aside>
<!-- sidebar ends -->
<!--header starts-->
<div class="col-sm">
<div th:replace="_notices :: page-notices"></div>
<div class="mb-4 d-flex justify-content-between">
<h3>Store Inventory Accounts</h3>
</div>
<div th:replace="_fragments :: table-loading-skeleton"></div>
<table class="table table-striped" data-account-table data-order="[[ 0, &quot;asc&quot; ]]">
<thead>
<tr>
<th></th>
<th></th>
<th>ID</th>
<th>Title</th>
<th>Parent Type</th>
<th>Active</th>
<th>Created By</th>
<th>Created At</th>
<th>Location</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr th:each="account : ${accounts}" th:object="${account}">
<td data-show-dropdown-transactions
th:data-account-id="${account.id}" title="Transactions">
<span data-dropdown-icon-transactions class="bi bi-caret-right-fill"></span>
</td>
<td data-show-dropdown-summary
th:data-account-id="${account.id}" title="Summary">
<span data-dropdown-icon-summary class="bi bi-caret-right"></span>
</td>
<td th:text="*{id}"></td>
<td th:text="*{title}"></td>
<td th:text="*{parentEntityType}"></td>
<td>
<span class="badge badge-ACTIVE" th:if="*{active}">ACTIVE</span>
<span class="badge badge-danger" th:unless="*{active}" >INACTIVE</span>
</td>
<td th:text="*{createdBy}"></td>
<td ctp:formatdatetime="*{createdAt}"></td>
<td >
<th:block th:switch="*{locationSiteId}">
<span th:each="location: ${locations}" th:case="${location.id}" th:text="${location.title}"></span>
</th:block>
</td>
<td class="font-italic" th:text="*{notes}"></td>
</tr>
</tbody>
</table>
</div>
</main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
<script>
const $body = $( 'body' );
// custom data table config
const dataTableConfig = {
pageLength: 100,
searching: true,
lengthChange: false,
processing: false,
dom: `
<'row'<'col-sm-5'B><'col-sm-7'f>>
<'row'<'col-sm-12't>>
<'row'<'col-sm-5'i><'col-sm-7'p>>`,
buttons: [{
extend: 'excel',
text: '',
className: 'bi bi-file-earmark-spreadsheet btn-sm'
}]
}
const accTable = $( '[data-account-table]' ).DataTable( dataTableConfig );
// handle click on dropdown
$body.on( 'click', '[data-show-dropdown-transactions]', function( e ) {
e.preventDefault();
const $this = $( this );
const $tr = $this.closest( 'tr' );
const $row = accTable.row( $tr );
const $spanDropdown = $tr.find( '[data-dropdown-icon-transactions]' );
const accountId= $this.data( 'account-id' );
$spanDropdown.toggleClass( 'bi-caret-right-fill bi-caret-down-fill' );
if( $row.child.isShown() ){
$row.child.hide();
}
else {
$row.child(`<span class="spinner-border text-center spinner-border-md" role="status"></span>`).show();
$.ajax({
url: `/ctp/inventory-transactions?account-id=${accountId}`,
success: function( data ){
// show fetched page
$row.child( data ).show();
}
});
}
});
$body.on( 'click', '[data-show-dropdown-summary]', function( e ) {
e.preventDefault();
const $this = $( this );
const $tr = $this.closest( 'tr' );
const $row = accTable.row( $tr );
const $spanDropdown = $tr.find( '[data-dropdown-icon-summary]' );
const accountId= $this.data( 'account-id' );
$spanDropdown.toggleClass( 'bi-caret-right bi-caret-down' );
if( $row.child.isShown() ){
$row.child.hide();
}
else {
$row.child(`<span class="spinner-border text-center spinner-border-md" role="status"></span>`).show();
$.ajax({
url: `/ctp/inventory-summary?account-id=${accountId}`,
success: function( data ){
// show fetched page
$row.child( data ).show();
}
});
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head('Store Receive Inventory')"></head>
<body>
<div class="container-fluid">
<header class="row page-header" th:replace="_fragments :: page-header"></header>
<main class="row page-main">
<div class="col-sm">
<div th:replace="_notices :: page-notices"></div>
<div class="mb-4 d-flex justify-content-between">
<h3>Receive Rejected Items</h3>
</div>
<form th:action="'/ctp/store/store-items'" method="post" id="packagingApp" th:object="${wrapper}">
<div class="bg-light p-3 mb-3">
<div class="form-row">
<div class="col-sm-3 form-group">
<search-item
:is-segregated="false"
url="/ctp/rest/finished-items/search-store"
v-on:finished-item-select="onItemSelect">
</search-item>
</div>
<input type="hidden" name="rejectReason" v-model="reason">
<div class="col-sm-3 form-group">
<label>Store Account</label>
<select class="form-control" name="accountId" th:field="*{accountId}" required>
<option value="">PLease select</option>
<option th:each="account : ${accounts}"
th:value="${account.id}"
th:text="${account.title}"></option>
</select>
</div>
</div>
</div>
<div class="bg-light p-3 mb-3">
<h6 class="mb-3">Search Finished Items</h6>
<finish-item-table
v-bind:items="items"
v-on:remove-item="removeItem"
></finish-item-table>
</div>
<div class="alert alert-danger" v-if="hasDuplicates()">Duplicate Item Selected</div>
<button class="btn btn-primary mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Cut To Pack')">Cut To Pack
</button>
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Knitting')">Knitting
</button>
<button class="btn btn-danger mr-2" type="button" :disabled="hasDuplicates() || items.length === 0"
@click="submitWithRejectReason('Dying')">Dying
</button>
<a th:href="@{/store/receive-inventory}" class="btn btn-light">Cancel</a>
</form>
<script th:inline="javascript">
window.ctp.accounts = [[${accounts}]];
</script>
<script th:src="@{/js/vendor/compressor.min.js}"></script>
<script th:src="@{/js/packaging/packaging-item-form.js}"></script>
</div>
</main>
</div>
<div th:replace="_fragments :: page-footer-scripts"></div>
</body>
</html>