Compare commits
No commits in common. "main" and "properties-config" have entirely different histories.
main
...
properties
|
@ -21,11 +21,6 @@
|
||||||
<option name="name" value="In project repo" />
|
<option name="name" value="In project repo" />
|
||||||
<option name="url" value="file:///D:\Projects\uind-cut-to-pack\cut-to-pack/libs" />
|
<option name="url" value="file:///D:\Projects\uind-cut-to-pack\cut-to-pack/libs" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="in-project" />
|
|
||||||
<option name="name" value="In project repo" />
|
|
||||||
<option name="url" value="file:///C:\Users\USF\Project\Cut-to-pack\cut-to-pack-service/libs" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="in-project" />
|
<option name="id" value="in-project" />
|
||||||
<option name="name" value="In project repo" />
|
<option name="name" value="In project repo" />
|
||||||
|
|
26
pom.xml
26
pom.xml
|
@ -28,24 +28,6 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>dev</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<activatedProperties>dev</activatedProperties>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>prod</id>
|
|
||||||
<properties>
|
|
||||||
<activatedProperties>prod</activatedProperties>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -55,12 +37,6 @@
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
|
||||||
<artifactId>pdfbox</artifactId>
|
|
||||||
<version>2.0.30</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||||
|
@ -395,7 +371,7 @@
|
||||||
<jvmArguments>-Xms1024m</jvmArguments>
|
<jvmArguments>-Xms1024m</jvmArguments>
|
||||||
<jvmArguments>-Xmx8g</jvmArguments>
|
<jvmArguments>-Xmx8g</jvmArguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>9</source><target>9</target></configuration></plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
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_PURCHASE_ORDER','ROLE_ADMIN')")
|
|
||||||
public @interface PurchaseOrderCTPRole {
|
|
||||||
}
|
|
|
@ -8,9 +8,6 @@ import com.utopiaindustries.service.InventoryAccountService;
|
||||||
import com.utopiaindustries.service.JobCardService;
|
import com.utopiaindustries.service.JobCardService;
|
||||||
import com.utopiaindustries.service.LocationService;
|
import com.utopiaindustries.service.LocationService;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
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.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -176,11 +173,6 @@ public class JobCardController {
|
||||||
return "job-card-view";
|
return "job-card-view";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping( value = "/pdf/{id}", produces = MediaType.APPLICATION_PDF_VALUE )
|
|
||||||
public ResponseEntity<InputStreamResource> generateJobCardPdf(@PathVariable long id, Model model ) throws Exception {
|
|
||||||
return jobCardService.getJobCardReceivingPdf(id,model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
|
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
|
||||||
ArrayList<LocalDate> localDates = new ArrayList<>();
|
ArrayList<LocalDate> localDates = new ArrayList<>();
|
||||||
while (start.isBefore(end)) {
|
while (start.isBefore(end)) {
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package com.utopiaindustries.controller;
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
import com.utopiaindustries.auth.PackagingRole;
|
import com.utopiaindustries.auth.PackagingRole;
|
||||||
import com.utopiaindustries.model.ctp.FinishedItemWrapper;
|
|
||||||
import com.utopiaindustries.service.InventoryAccountService;
|
import com.utopiaindustries.service.InventoryAccountService;
|
||||||
import com.utopiaindustries.service.LocationService;
|
import com.utopiaindustries.service.LocationService;
|
||||||
import com.utopiaindustries.service.PackagingService;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@ -18,39 +17,19 @@ import java.time.LocalDate;
|
||||||
@RequestMapping("/packaging" )
|
@RequestMapping("/packaging" )
|
||||||
public class PackagingController {
|
public class PackagingController {
|
||||||
|
|
||||||
|
|
||||||
private final InventoryAccountService inventoryAccountService;
|
private final InventoryAccountService inventoryAccountService;
|
||||||
private final PackagingService packagingService;
|
|
||||||
private final LocationService locationService;
|
private final LocationService locationService;
|
||||||
|
|
||||||
public PackagingController(InventoryAccountService inventoryAccountService, PackagingService packagingService, LocationService locationService) {
|
public PackagingController(InventoryAccountService inventoryAccountService, LocationService locationService) {
|
||||||
this.inventoryAccountService = inventoryAccountService;
|
this.inventoryAccountService = inventoryAccountService;
|
||||||
this.packagingService = packagingService;
|
|
||||||
this.locationService = locationService;
|
this.locationService = locationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String showHome(Model model ){
|
public String showHome( Model model ){
|
||||||
return "redirect:/packaging/receive-inventory";
|
return "redirect:/packaging/inventory-accounts";
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/receive-inventory")
|
|
||||||
public String packagingItemReceive( Model model ){
|
|
||||||
model.addAttribute("wrapper", new FinishedItemWrapper() );
|
|
||||||
return "/packaging/receive-inventory-form";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping( "/packaging-items" )
|
|
||||||
public String packagingItems( @ModelAttribute FinishedItemWrapper wrapper,
|
|
||||||
RedirectAttributes redirectAttributes,
|
|
||||||
Model model ){
|
|
||||||
try {
|
|
||||||
packagingService.createPackagingItem( wrapper );
|
|
||||||
redirectAttributes.addFlashAttribute("success", "Items Successfully received !" );
|
|
||||||
} catch ( Exception e ){
|
|
||||||
redirectAttributes.addFlashAttribute("error", e.getMessage() );
|
|
||||||
}
|
|
||||||
return "redirect:/finishing/finished-items";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping( "/inventory-accounts" )
|
@GetMapping( "/inventory-accounts" )
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package com.utopiaindustries.controller;
|
|
||||||
|
|
||||||
import com.utopiaindustries.auth.PurchaseOrderCTPRole;
|
|
||||||
import com.utopiaindustries.model.ctp.JobCard;
|
|
||||||
import com.utopiaindustries.service.PurchaseOrderCTPService;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/purchase-order")
|
|
||||||
@PurchaseOrderCTPRole
|
|
||||||
|
|
||||||
public class PurchaseOrderCTPController {
|
|
||||||
private final PurchaseOrderCTPService purchaseOrderCTPService;
|
|
||||||
|
|
||||||
public PurchaseOrderCTPController(PurchaseOrderCTPService purchaseOrderCTPService) {
|
|
||||||
this.purchaseOrderCTPService = purchaseOrderCTPService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public String showJobCardList( @RequestParam( value = "purchaseOrderCode", required = false ) String purchaseOrderCode,
|
|
||||||
@RequestParam( value = "articleName", required = false ) String articleName,
|
|
||||||
@RequestParam( value = "created-start-date", required = false ) String createdStartDate,
|
|
||||||
@RequestParam( value = "created-end-date", required = false ) String createdEndDate,
|
|
||||||
@RequestParam( value = "limit" , required = false) Long limit,
|
|
||||||
Model model ){
|
|
||||||
|
|
||||||
LocalDate startDate = StringUtils.isNullOrEmpty(createdStartDate) ? LocalDate.now().minusDays(30) : LocalDate.parse(createdStartDate);
|
|
||||||
LocalDate endDate = StringUtils.isNullOrEmpty(createdEndDate) ? LocalDate.now() : LocalDate.parse(createdEndDate);
|
|
||||||
model.addAttribute("purchaseOrder", purchaseOrderCTPService.getAllPurchaseOrderCtp(purchaseOrderCode, articleName, startDate.toString(), endDate.toString(), limit) );
|
|
||||||
model.addAttribute("startDate", startDate);
|
|
||||||
model.addAttribute("endDate", endDate);
|
|
||||||
return "job-card-list";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping( "/new" )
|
|
||||||
public String showPurchaseOrderCTPForm( Model model ){
|
|
||||||
model.addAttribute("purchaseOrder", purchaseOrderCTPService.createNewPurchaseOrderCTP() );
|
|
||||||
return "/purchaseOrder/purchase-order-form";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,15 @@
|
||||||
package com.utopiaindustries.controller;
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
|
import com.utopiaindustries.auth.CuttingRole;
|
||||||
import com.utopiaindustries.auth.ReportingRole;
|
import com.utopiaindustries.auth.ReportingRole;
|
||||||
import com.utopiaindustries.model.ctp.SummaryInventoryReport;
|
import com.utopiaindustries.model.ctp.SummaryInventoryReport;
|
||||||
import com.utopiaindustries.service.InventoryAccountService;
|
|
||||||
import com.utopiaindustries.service.ReportingService;
|
|
||||||
import com.utopiaindustries.service.SummaryInventoryReportService;
|
import com.utopiaindustries.service.SummaryInventoryReportService;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -23,19 +20,14 @@ import java.util.Map;
|
||||||
@ReportingRole
|
@ReportingRole
|
||||||
@RequestMapping( "/reporting" )
|
@RequestMapping( "/reporting" )
|
||||||
public class ReportingController {
|
public class ReportingController {
|
||||||
private final ReportingService reportingService;
|
|
||||||
private final SummaryInventoryReportService summaryInventoryReportService;
|
private final SummaryInventoryReportService summaryInventoryReportService;
|
||||||
private final InventoryAccountService inventoryAccountService;
|
|
||||||
|
|
||||||
|
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2) {
|
||||||
public ReportingController(SummaryInventoryReportService summaryInventoryReportService2, ReportingService reportingService, InventoryAccountService inventoryAccountService) {
|
|
||||||
this.summaryInventoryReportService = summaryInventoryReportService2;
|
this.summaryInventoryReportService = summaryInventoryReportService2;
|
||||||
this.reportingService = reportingService;
|
|
||||||
this.inventoryAccountService = inventoryAccountService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping( "/summary")
|
@GetMapping( "/summary")
|
||||||
public String summary(@RequestParam(value = "item-id", required = false ) String itemId, @RequestParam(value = "sku" , required = false) String sku, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
|
public String showMasterBundles(@RequestParam(value = "item-id", required = false ) String itemId, @RequestParam(value = "sku" , required = false) String sku, @RequestParam(value = "start-date", required = false) String startDate, @RequestParam(value = "end-date", required = false) String endDate, Model model ){
|
||||||
|
|
||||||
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(6) : LocalDate.parse(startDate);
|
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(6) : LocalDate.parse(startDate);
|
||||||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now().plusDays(1) : LocalDate.parse(endDate);
|
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now().plusDays(1) : LocalDate.parse(endDate);
|
||||||
|
@ -48,83 +40,6 @@ public class ReportingController {
|
||||||
return "/reporting/inventory-summary";
|
return "/reporting/inventory-summary";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping( "/job-card-report")
|
|
||||||
public String jobCardReport(@RequestParam( value = "job-card-id", required = false ) String jobCardId,
|
|
||||||
Model model, RedirectAttributes redirectAttributes ){
|
|
||||||
if( jobCardId == null || jobCardId.isEmpty()) {
|
|
||||||
redirectAttributes.addFlashAttribute("error", "Please Re-Select Job Card" );
|
|
||||||
return "/reporting/job-card-report";
|
|
||||||
}
|
|
||||||
model.addAttribute("totalProduction", reportingService.getTotalProduction(jobCardId));
|
|
||||||
model.addAttribute("phasesTimes", reportingService.getEachPhaseTotalTime(jobCardId));
|
|
||||||
model.addAttribute("segregateItems", reportingService.getSegregateItems(jobCardId));
|
|
||||||
model.addAttribute("pendingStatus", reportingService.countPendingItemsOnDifferentPhases(jobCardId));
|
|
||||||
model.addAttribute("completeProduction", reportingService.getCompleteProduction(jobCardId));
|
|
||||||
model.addAttribute("jobCardProgress", reportingService.getJobCardProgress(jobCardId));
|
|
||||||
model.addAttribute("cuttingDetails", reportingService.getCuttingDetails(jobCardId));
|
|
||||||
model.addAttribute("stitchingDetails", reportingService.getStitchingDetails(jobCardId));
|
|
||||||
model.addAttribute("dailyProgress", reportingService.getPhasesProgressDayWise(jobCardId));
|
|
||||||
|
|
||||||
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 ){
|
|
||||||
|
|
||||||
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
|
|
||||||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
|
||||||
model.addAttribute("startDate", startDate1);
|
|
||||||
model.addAttribute("endDate", endDate1);
|
|
||||||
model.addAttribute("accounts", inventoryAccountService.getAllCuttingAccounts() );
|
|
||||||
model.addAttribute("cutting",reportingService.getCuttingTableDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString()));
|
|
||||||
|
|
||||||
return "/reporting/cutting-report";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping( value = "/stitching-report" )
|
|
||||||
public String stitchingReport(@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 ){
|
|
||||||
|
|
||||||
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
|
|
||||||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
|
||||||
model.addAttribute("startDate", startDate1);
|
|
||||||
model.addAttribute("endDate", endDate1);
|
|
||||||
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
|
||||||
model.addAttribute("stitching",reportingService.getStitchingDetails(jobCardId, accountId, startDate1.toString(), endDate1.toString()));
|
|
||||||
|
|
||||||
return "/reporting/stitching-report";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping( "/inventory-transactions" )
|
|
||||||
public String getInventoryTransactionsByAccount( @RequestParam( value = "account-id", required = false) String accountId,
|
|
||||||
@RequestParam( value = "jobCard-id", required = false) String jobCardId,
|
|
||||||
@RequestParam( value = "sku", required = false) String sku,
|
|
||||||
@RequestParam( value = "startDate", required = false) String startDate,
|
|
||||||
@RequestParam( value = "endDate", required = false) String endDate,
|
|
||||||
Model model ){
|
|
||||||
|
|
||||||
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(31) : LocalDate.parse(startDate);
|
|
||||||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
|
||||||
model.addAttribute("startDate", startDate1);
|
|
||||||
model.addAttribute("endDate", endDate1);
|
|
||||||
model.addAttribute("transactions", reportingService.stitchingItemsTransactions( jobCardId, accountId, sku, startDate1.toString(), endDate1.toString() ));
|
|
||||||
return "/reporting/accounts-transaction-table";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
|
private ArrayList<LocalDate> generateDateList(LocalDate start, LocalDate end) {
|
||||||
ArrayList<LocalDate> localDates = new ArrayList<>();
|
ArrayList<LocalDate> localDates = new ArrayList<>();
|
||||||
while (start.isBefore(end)) {
|
while (start.isBefore(end)) {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.utopiaindustries.controller;
|
package com.utopiaindustries.controller;
|
||||||
|
|
||||||
import com.utopiaindustries.auth.StitchingRole;
|
import com.utopiaindustries.auth.StitchingRole;
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.JobCard;
|
||||||
|
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
||||||
import com.utopiaindustries.service.*;
|
import com.utopiaindustries.service.*;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -74,6 +76,8 @@ public class StitchingController {
|
||||||
@RequestParam( value = "count", required = false ) Long count,
|
@RequestParam( value = "count", required = false ) Long count,
|
||||||
Model model ) {
|
Model model ) {
|
||||||
// 2 for stitching
|
// 2 for stitching
|
||||||
|
|
||||||
|
|
||||||
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "2", false));
|
model.addAttribute("accounts", inventoryAccountService.getInventoryAccounts(id, title, active, createdBy, startDate, endDate, siteId, count, "PROCESS", "2", false));
|
||||||
model.addAttribute("locations", locationService.findAll() );
|
model.addAttribute("locations", locationService.findAll() );
|
||||||
if(count == null){
|
if(count == null){
|
||||||
|
@ -91,13 +95,13 @@ public class StitchingController {
|
||||||
@RequestParam( value = "sku", required = false ) String sku,
|
@RequestParam( value = "sku", required = false ) String sku,
|
||||||
@RequestParam( value = "start-date", required = false) String startDate,
|
@RequestParam( value = "start-date", required = false) String startDate,
|
||||||
@RequestParam( value = "end-date", required = false ) String endDate,
|
@RequestParam( value = "end-date", required = false ) String endDate,
|
||||||
@RequestParam(value = "bundle-id", required = false) Long bundleId,
|
@RequestParam( value = "job-card-id", required = false ) String jobCardId,
|
||||||
@RequestParam( value = "count", required = false, defaultValue = "100") Long count,
|
@RequestParam( value = "count", required = false, defaultValue = "100") Long count,
|
||||||
@RequestParam( value = "status", required = false) String status,
|
Model model
|
||||||
Model model, RedirectAttributes redirect){
|
,RedirectAttributes redirect){
|
||||||
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(30) : LocalDate.parse(startDate);
|
LocalDate startDate1 = StringUtils.isNullOrEmpty(startDate) ? LocalDate.now().minusDays(30) : LocalDate.parse(startDate);
|
||||||
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
LocalDate endDate1 = StringUtils.isNullOrEmpty(endDate) ? LocalDate.now() : LocalDate.parse(endDate);
|
||||||
List<StitchingOfflineItem> itemList = bundleService.getStitchedOfflineItems( id, itemId, sku, status, startDate, endDate, bundleId ,count );
|
List<StitchingOfflineItem> itemList = bundleService.getStitchedOfflineItems( id, itemId, sku, startDate, endDate, jobCardId ,count );
|
||||||
model.addAttribute("items", itemList ) ;
|
model.addAttribute("items", itemList ) ;
|
||||||
model.addAttribute("startDate", startDate1);
|
model.addAttribute("startDate", startDate1);
|
||||||
model.addAttribute("endDate", endDate1);
|
model.addAttribute("endDate", endDate1);
|
||||||
|
@ -107,17 +111,17 @@ public class StitchingController {
|
||||||
@GetMapping( "/create-stitching-items")
|
@GetMapping( "/create-stitching-items")
|
||||||
public String createFinishItems( Model model ){
|
public String createFinishItems( Model model ){
|
||||||
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
model.addAttribute("accounts" , inventoryAccountService.findInventoryAccounts( 2L ) );
|
||||||
model.addAttribute("bundleWrapper", new BundleWrapper() );
|
model.addAttribute("jobCard", jobCardService.createNewJobCard() );
|
||||||
return "/stitching/stitching-item-form";
|
return "/stitching/stitching-item-form";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping( "/create-stitching-items" )
|
@PostMapping( "/create-stitching-items" )
|
||||||
public String createStitchedOfflineItems( @ModelAttribute BundleWrapper bundleWrapper,
|
public String createStitchedOfflineItems( @ModelAttribute JobCard jobCard,
|
||||||
RedirectAttributes redirectAttributes,
|
RedirectAttributes redirectAttributes,
|
||||||
Model model ){
|
Model model ){
|
||||||
try {
|
try {
|
||||||
inventoryService.createStitchingOfflineItemsFromJobCard( bundleWrapper );
|
inventoryService.createStitchingOfflineItemsFromJobCard( jobCard );
|
||||||
redirectAttributes.addFlashAttribute("success", "Stitch Items Created Successfully");
|
redirectAttributes.addFlashAttribute("success", "Finished Item Created Successfully");
|
||||||
} catch ( Exception exception ){
|
} catch ( Exception exception ){
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
redirectAttributes.addFlashAttribute( "error", exception.getMessage() );
|
redirectAttributes.addFlashAttribute( "error", exception.getMessage() );
|
||||||
|
|
|
@ -21,17 +21,14 @@ public class BundleDAO {
|
||||||
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, wrap_quantity, barcode, type, created_by, created_at, job_card_id, master_bundle_id, production) VALUES (:id, :item_id, :sku, :wrap_quantity, :barcode, :type, :created_by, :created_at, :job_card_id, :master_bundle_id, :production) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), wrap_quantity = VALUES(wrap_quantity), barcode = VALUES(barcode), type = VALUES(type), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), master_bundle_id = VALUES(master_bundle_id), production = VALUES(production)", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, wrap_quantity, barcode, type, created_by, created_at, job_card_id, master_bundle_id) VALUES (:id, :item_id, :sku, :wrap_quantity, :barcode, :type, :created_by, :created_at, :job_card_id, :master_bundle_id) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), wrap_quantity = VALUES(wrap_quantity), barcode = VALUES(barcode), type = VALUES(type), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), master_bundle_id = VALUES(master_bundle_id)", TABLE_NAME );
|
||||||
private final String SELECT_BY_TERM_QUERY = String.format( "SELECT * FROM %s WHERE (id = :id OR sku LIKE :sku OR type LIKE :type OR barcode LIKE :barcode) AND master_bundle_id =0", TABLE_NAME );
|
private final String SELECT_BY_TERM_QUERY = String.format( "SELECT * FROM %s WHERE (id = :id OR sku LIKE :sku OR type LIKE :type OR barcode LIKE :barcode) AND master_bundle_id =0", TABLE_NAME );
|
||||||
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE master_bundle_id = :master_bundle_id ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE master_bundle_id = :master_bundle_id ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
private final String SELECT_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
private final String SELECT_BY_ITEM_ID_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id = :item_id AND job_card_id = :job_card_id", TABLE_NAME );
|
||||||
private final String SELECT_BY_ITEM_IDS_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id IN (:item_ids) AND job_card_id = :job_card_id", TABLE_NAME );
|
private final String SELECT_BY_ITEM_IDS_AND_JOB_CARD = String.format( "SELECT * FROM %s WHERE item_id IN (:item_ids) AND job_card_id = :job_card_id", TABLE_NAME );
|
||||||
private final String SELECT_LIKE_BARCODE = String.format("SELECT * FROM %s WHERE barcode LIKE :barcode", TABLE_NAME);
|
|
||||||
private final String SELECT_FIRST_BUNDLE_BY_JOB_CARD = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id ORDER BY created_at ASC LIMIT 1", TABLE_NAME);
|
|
||||||
private final String SELECT_LAST_BUNDLE_BY_JOB_CARD = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id ORDER BY created_at DESC LIMIT 1", TABLE_NAME);
|
|
||||||
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME );
|
|
||||||
|
|
||||||
public BundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public BundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -43,7 +40,6 @@ public class BundleDAO {
|
||||||
params.addValue( "id", bundle.getId() )
|
params.addValue( "id", bundle.getId() )
|
||||||
.addValue( "item_id", bundle.getItemId() )
|
.addValue( "item_id", bundle.getItemId() )
|
||||||
.addValue( "sku", bundle.getSku() )
|
.addValue( "sku", bundle.getSku() )
|
||||||
.addValue("production",bundle.getProduction())
|
|
||||||
.addValue( "wrap_quantity", bundle.getWrapQuantity() )
|
.addValue( "wrap_quantity", bundle.getWrapQuantity() )
|
||||||
.addValue( "barcode", bundle.getBarcode() )
|
.addValue( "barcode", bundle.getBarcode() )
|
||||||
.addValue( "type", bundle.getType() )
|
.addValue( "type", bundle.getType() )
|
||||||
|
@ -65,12 +61,6 @@ public class BundleDAO {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Bundle> findByBarcodeLike(String barcode) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("barcode", "%" + barcode + "%");
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_LIKE_BARCODE, params, new BundleRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
// find all
|
// find all
|
||||||
public List<Bundle> findAll() {
|
public List<Bundle> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new BundleRowMapper() );
|
||||||
|
@ -134,10 +124,11 @@ public class BundleDAO {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new BundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS , params, new BundleRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Bundle> findByCardId( long cardId ){
|
public List<Bundle> findByItemIdAndCardId( long itemId, long cardId ){
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
params.addValue("item_id", itemId );
|
||||||
params.addValue("job_card_id", cardId );
|
params.addValue("job_card_id", cardId );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD, params, new BundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_ITEM_ID_AND_JOB_CARD, params, new BundleRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Bundle> findByItemIdsAndCardId( List<Long> itemIds, long cardId ){
|
public List<Bundle> findByItemIdsAndCardId( List<Long> itemIds, long cardId ){
|
||||||
|
@ -147,27 +138,4 @@ public class BundleDAO {
|
||||||
params.addValue("job_card_id", cardId );
|
params.addValue("job_card_id", cardId );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_ITEM_IDS_AND_JOB_CARD, params, new BundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_ITEM_IDS_AND_JOB_CARD, params, new BundleRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bundle findFirstBundleByCardId(long cardId) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", cardId);
|
|
||||||
return namedParameterJdbcTemplate.queryForObject(SELECT_FIRST_BUNDLE_BY_JOB_CARD, params, new BundleRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bundle findLastBundleByCardId(long cardId) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", cardId);
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_LAST_BUNDLE_BY_JOB_CARD, params, new BundleRowMapper())
|
|
||||||
.stream()
|
|
||||||
.findFirst().orElse(new Bundle());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Bundle> findByCardIdAndDATE( long cardId, String startDate, String endDate){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", cardId );
|
|
||||||
params.addValue( "start_date", startDate );
|
|
||||||
params.addValue( "end_date", endDate );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_DATE, params, new BundleRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,7 +16,6 @@ public class BundleRowMapper implements RowMapper<Bundle> {
|
||||||
bundle.setBarcode( rs.getString( "barcode" ) );
|
bundle.setBarcode( rs.getString( "barcode" ) );
|
||||||
bundle.setType( rs.getString( "type" ) );
|
bundle.setType( rs.getString( "type" ) );
|
||||||
bundle.setCreatedBy( rs.getString( "created_by" ) );
|
bundle.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
bundle.setProduction(rs.getBigDecimal("production"));
|
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
bundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ public class CutPieceTypeDAO {
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title) VALUES (:id, :title) ON DUPLICATE KEY UPDATE title = VALUES(title)", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title) VALUES (:id, :title) ON DUPLICATE KEY UPDATE title = VALUES(title)", TABLE_NAME );
|
||||||
private final String SELECT_BY_TITLE = String.format("SELECT * FROM %s WHERE title = :title", TABLE_NAME);
|
|
||||||
|
|
||||||
public CutPieceTypeDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public CutPieceTypeDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -31,7 +30,7 @@ public class CutPieceTypeDAO {
|
||||||
private MapSqlParameterSource prepareInsertQueryParams( CutPieceType cutPieceType ) {
|
private MapSqlParameterSource prepareInsertQueryParams( CutPieceType cutPieceType ) {
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue( "id", cutPieceType.getId() )
|
params.addValue( "id", cutPieceType.getId() )
|
||||||
.addValue( "title", cutPieceType.getType() );
|
.addValue( "title", cutPieceType.getTitle() );
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,16 +44,6 @@ public class CutPieceTypeDAO {
|
||||||
.orElse( new CutPieceType() );
|
.orElse( new CutPieceType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// find
|
|
||||||
public CutPieceType findByTitle( String title ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "title", title );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_TITLE, params, new CutPieceTypeRowMapper() )
|
|
||||||
.stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new CutPieceType() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// find all
|
// find all
|
||||||
public List<CutPieceType> findAll() {
|
public List<CutPieceType> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class CutPieceTypeRowMapper implements RowMapper<CutPieceType> {
|
||||||
public CutPieceType mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
public CutPieceType mapRow( ResultSet rs, int rowNum ) throws SQLException {
|
||||||
CutPieceType cutPieceType = new CutPieceType();
|
CutPieceType cutPieceType = new CutPieceType();
|
||||||
cutPieceType.setId( rs.getLong( "id" ) );
|
cutPieceType.setId( rs.getLong( "id" ) );
|
||||||
cutPieceType.setType( rs.getString( "title" ) );
|
cutPieceType.setTitle( rs.getString( "title" ) );
|
||||||
return cutPieceType;
|
return cutPieceType;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,8 +32,6 @@ public class FinishedItemDAO {
|
||||||
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated ORDER BY ID DESC", TABLE_NAME );
|
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term AND is_segregated = :is_segregated ORDER BY ID DESC", TABLE_NAME );
|
||||||
private final String SELECT_BY_STITCHED_ITEM_ID = String.format( "SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id", TABLE_NAME );
|
private final String SELECT_BY_STITCHED_ITEM_ID = String.format( "SELECT * FROM %s WHERE stitched_item_id = :stitched_item_id", TABLE_NAME );
|
||||||
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format( "SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME );
|
private final String SELECT_BY_STITCHED_ITEM_IDS = String.format( "SELECT * FROM %s WHERE stitched_item_id IN (:stitched_item_ids)", TABLE_NAME );
|
||||||
private final String COUNT_TOTAL_FINISH_ITEM= String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_segregated IS TRUE ",TABLE_NAME);
|
|
||||||
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME );
|
|
||||||
|
|
||||||
public FinishedItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public FinishedItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -170,20 +168,4 @@ public class FinishedItemDAO {
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long calculateTotalFinishItem( long jobCardId ){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardId );
|
|
||||||
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_FINISH_ITEM, params, Long.class);
|
|
||||||
return count != null ? count : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FinishedItem> calculateTotalFinishItem( long jobCardId, String startDate, String endDate ){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardId );
|
|
||||||
params.addValue( "start_date", startDate );
|
|
||||||
params.addValue( "end_date", endDate );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_DATE, params, new FinishedItemRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -27,7 +27,6 @@ public class InventoryAccountDAO {
|
||||||
private final String SELECT_BY_IDS_AND_PARENT_ENTITY_TYPE_AND_PARENT_ID_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND parent_entity_id = :parent_entity_id AND parent_entity_type = :parent_entity_type LIMIT :limit", TABLE_NAME );
|
private final String SELECT_BY_IDS_AND_PARENT_ENTITY_TYPE_AND_PARENT_ID_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND parent_entity_id = :parent_entity_id AND parent_entity_type = :parent_entity_type LIMIT :limit", TABLE_NAME );
|
||||||
private final String SELECT_BY_IDS_PACKAGING_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND is_packaging = :is_packaging LIMIT :limit", TABLE_NAME );
|
private final String SELECT_BY_IDS_PACKAGING_AND_COUNT = String.format( "SELECT * FROM %s WHERE id IN (:ids) AND is_packaging = :is_packaging LIMIT :limit", TABLE_NAME );
|
||||||
private final String SELECT_BY_PARENT_TYPE_AND_PARENT_ID = String.format( "SELECT * FROM %s WHERE active = TRUE AND parent_entity_type = :parent_entity_type AND parent_entity_id = :parent_entity_id" , TABLE_NAME );
|
private final String SELECT_BY_PARENT_TYPE_AND_PARENT_ID = String.format( "SELECT * FROM %s WHERE active = TRUE AND parent_entity_type = :parent_entity_type AND parent_entity_id = :parent_entity_id" , TABLE_NAME );
|
||||||
private final String SELECT_BY_IS_PACKAGING_TRUE = String.format( "SELECT * FROM %s WHERE is_packaging IS TRUE", TABLE_NAME );
|
|
||||||
|
|
||||||
public InventoryAccountDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public InventoryAccountDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -145,9 +144,4 @@ public class InventoryAccountDAO {
|
||||||
params.addValue("parent_entity_id", parentEntityId );
|
params.addValue("parent_entity_id", parentEntityId );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_PARENT_TYPE_AND_PARENT_ID, params, new InventoryAccountRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_PARENT_TYPE_AND_PARENT_ID, params, new InventoryAccountRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryAccount> getPackagingAccounts(){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_IS_PACKAGING_TRUE, params, new InventoryAccountRowMapper() );
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package com.utopiaindustries.dao.ctp;
|
||||||
import com.utopiaindustries.model.ctp.InventorySummary;
|
import com.utopiaindustries.model.ctp.InventorySummary;
|
||||||
import com.utopiaindustries.model.ctp.InventoryTransactionLeg;
|
import com.utopiaindustries.model.ctp.InventoryTransactionLeg;
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
|
@ -22,7 +21,7 @@ public class InventoryTransactionLegDAO {
|
||||||
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, transaction_id, item_id, sku, type, quantity, account_id, balance, transaction_leg_datetime, parent_document_type, parent_document_id, parent_document_piece_type, job_card_id) VALUES (:id, :transaction_id, :item_id, :sku, :type, :quantity, :account_id, :balance, :transaction_leg_datetime, :parent_document_type, :parent_document_id, :parent_document_piece_type, :job_card_id) ON DUPLICATE KEY UPDATE transaction_id = VALUES(transaction_id), item_id = VALUES(item_id), sku = VALUES(sku), type = VALUES(type), quantity = VALUES(quantity), account_id = VALUES(account_id), balance = VALUES(balance), transaction_leg_datetime = VALUES(transaction_leg_datetime), parent_document_type = VALUES(parent_document_type), parent_document_id = VALUES(parent_document_id), parent_document_piece_type = VALUES(parent_document_piece_type), job_card_id = VALUES(job_card_id)", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, transaction_id, item_id, sku, type, quantity, account_id, balance, transaction_leg_datetime, parent_document_type, parent_document_id, parent_document_piece_type) VALUES (:id, :transaction_id, :item_id, :sku, :type, :quantity, :account_id, :balance, :transaction_leg_datetime, :parent_document_type, :parent_document_id, :parent_document_piece_type) ON DUPLICATE KEY UPDATE transaction_id = VALUES(transaction_id), item_id = VALUES(item_id), sku = VALUES(sku), type = VALUES(type), quantity = VALUES(quantity), account_id = VALUES(account_id), balance = VALUES(balance), transaction_leg_datetime = VALUES(transaction_leg_datetime), parent_document_type = VALUES(parent_document_type), parent_document_id = VALUES(parent_document_id), parent_document_piece_type = VALUES(parent_document_piece_type)", TABLE_NAME );
|
||||||
private final String SELECT_LAST_ACCOUNT_ID_AND_ITEM_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id AND item_id = :item_id AND parent_document_type= :parent_document_type AND parent_document_piece_type = :parent_document_piece_type ORDER BY id DESC LIMIT 1", TABLE_NAME );
|
private final String SELECT_LAST_ACCOUNT_ID_AND_ITEM_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id AND item_id = :item_id AND parent_document_type= :parent_document_type AND parent_document_piece_type = :parent_document_piece_type ORDER BY id DESC LIMIT 1", TABLE_NAME );
|
||||||
private final String SELECT_BY_ACCOUNT_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id ORDER BY id DESC" , TABLE_NAME );
|
private final String SELECT_BY_ACCOUNT_ID = String.format( "SELECT * FROM %s WHERE account_id = :account_id ORDER BY id DESC" , TABLE_NAME );
|
||||||
private final String SELECT_SUMMARY_BY_ACCOUNT_ID = String.format( "SELECT item_id, sku, parent_document_type,parent_document_piece_type," +
|
private final String SELECT_SUMMARY_BY_ACCOUNT_ID = String.format( "SELECT item_id, sku, parent_document_type,parent_document_piece_type," +
|
||||||
|
@ -45,20 +44,11 @@ public class InventoryTransactionLegDAO {
|
||||||
" WHERE itl.type = :type" +
|
" WHERE itl.type = :type" +
|
||||||
" AND itl.parent_document_type = :parent_document_type"
|
" AND itl.parent_document_type = :parent_document_type"
|
||||||
, TABLE_NAME, TABLE_NAME );
|
, TABLE_NAME, TABLE_NAME );
|
||||||
private final String COUNT_TOTAL_SEGREGATE_ITEMS = String.format("SELECT COUNT(*) FROM %s WHERE parent_document_id IN (:parent_document_id) AND account_id = :account_id", TABLE_NAME);
|
|
||||||
private final String SELECT_FIRST_TRANSACTION_PARENT_TYPE_PARENT_ID = String.format("SELECT * FROM %s WHERE parent_document_id IN (:parent_document_id) AND parent_document_type = :parent_document_type ORDER BY transaction_leg_datetime ASC LIMIT 1", TABLE_NAME);
|
|
||||||
private final String SELECT_GROUP_By_TRANSACTION_PARENT_TYPE_PARENT_ID = String.format("SELECT * FROM %s WHERE parent_document_id IN (:parent_document_id) AND parent_document_type = :parent_document_type GROUP BY account_id", TABLE_NAME);
|
|
||||||
private final String SELECT_JOB_CARD_DATES = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR transaction_leg_datetime BETWEEN :start_date AND :end_date) AND type = :type ", TABLE_NAME);
|
|
||||||
private final String SELECT_JOB_CARD_And_Date_Type_Account_Id = String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR transaction_leg_datetime BETWEEN :start_date AND :end_date) AND type = :type AND account_id IN (:account_ids)", TABLE_NAME);
|
|
||||||
|
|
||||||
public InventoryTransactionLegDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public InventoryTransactionLegDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryTransactionLeg> findByQuery(String query ){
|
|
||||||
return namedParameterJdbcTemplate.query( query, new InventoryTransactionLegRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare query params
|
// prepare query params
|
||||||
private MapSqlParameterSource prepareInsertQueryParams( InventoryTransactionLeg inventoryTransactionLeg ) {
|
private MapSqlParameterSource prepareInsertQueryParams( InventoryTransactionLeg inventoryTransactionLeg ) {
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
|
@ -73,9 +63,7 @@ public class InventoryTransactionLegDAO {
|
||||||
.addValue( "transaction_leg_datetime", inventoryTransactionLeg.getTransactionLegDateTime() )
|
.addValue( "transaction_leg_datetime", inventoryTransactionLeg.getTransactionLegDateTime() )
|
||||||
.addValue( "parent_document_type", inventoryTransactionLeg.getParentDocumentType() )
|
.addValue( "parent_document_type", inventoryTransactionLeg.getParentDocumentType() )
|
||||||
.addValue( "parent_document_id", inventoryTransactionLeg.getParentDocumentId() )
|
.addValue( "parent_document_id", inventoryTransactionLeg.getParentDocumentId() )
|
||||||
.addValue("parent_document_piece_type", inventoryTransactionLeg.getParentDocumentPieceType() )
|
.addValue("parent_document_piece_type", inventoryTransactionLeg.getParentDocumentPieceType() );
|
||||||
.addValue("job_card_id", inventoryTransactionLeg.getJobCardId() );
|
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,57 +153,4 @@ public class InventoryTransactionLegDAO {
|
||||||
params.addValue("parent_document_type", parentType );
|
params.addValue("parent_document_type", parentType );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_LAST_LEG_BY_TYPE_AND_PARENT_ID , params, new InventoryTransactionLegRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_LAST_LEG_BY_TYPE_AND_PARENT_ID , params, new InventoryTransactionLegRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long CalculateTotalGradingItems(List<Long> finishItemIds, Integer accountId) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("parent_document_id", finishItemIds);
|
|
||||||
params.addValue("account_id", accountId);
|
|
||||||
|
|
||||||
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_SEGREGATE_ITEMS, params, Long.class);
|
|
||||||
return count != null ? count : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryTransactionLeg getFirstStitchBundleTime(List<Long> parentsIds, String parentType) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("parent_document_id", parentsIds);
|
|
||||||
params.addValue("parent_document_type", parentType);
|
|
||||||
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_FIRST_TRANSACTION_PARENT_TYPE_PARENT_ID, params,new InventoryTransactionLegRowMapper())
|
|
||||||
.stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new InventoryTransactionLeg() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryTransactionLeg> getTransactionByParentIdAndType(List<Long> parentIds , String parentType){
|
|
||||||
if ( parentIds == null || parentIds.isEmpty() ){
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("parent_document_id", parentIds );
|
|
||||||
params.addValue("parent_document_type", parentType );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_GROUP_By_TRANSACTION_PARENT_TYPE_PARENT_ID , params, new InventoryTransactionLegRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryTransactionLeg> getTransactionByJobCardAndDatesAndType(long jobCardID, String startDate, String endDate, String type){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardID );
|
|
||||||
params.addValue("start_date", startDate );
|
|
||||||
params.addValue("end_date", endDate );
|
|
||||||
params.addValue("type", type );
|
|
||||||
System.out.println("Start Date: " + startDate);
|
|
||||||
System.out.println("End Date: " + endDate);
|
|
||||||
|
|
||||||
System.out.println("Params: " + params.getValues());
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_JOB_CARD_DATES , params, new InventoryTransactionLegRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryTransactionLeg> getTransactionByJobCardAndDatesAndTypeAndAccountID(long jobCardID, String startDate, String endDate, String type, List<Integer> accountId){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardID );
|
|
||||||
params.addValue("start_date", startDate );
|
|
||||||
params.addValue("end_date", endDate );
|
|
||||||
params.addValue("type", type );
|
|
||||||
params.addValue("account_ids", accountId );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_JOB_CARD_And_Date_Type_Account_Id , params, new InventoryTransactionLegRowMapper() );
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -23,7 +23,6 @@ public class InventoryTransactionLegRowMapper implements RowMapper<InventoryTran
|
||||||
inventoryTransactionLeg.setParentDocumentType( rs.getString( "parent_document_type" ) );
|
inventoryTransactionLeg.setParentDocumentType( rs.getString( "parent_document_type" ) );
|
||||||
inventoryTransactionLeg.setParentDocumentId( rs.getLong( "parent_document_id" ) );
|
inventoryTransactionLeg.setParentDocumentId( rs.getLong( "parent_document_id" ) );
|
||||||
inventoryTransactionLeg.setParentDocumentPieceType( rs.getString("parent_document_piece_type"));
|
inventoryTransactionLeg.setParentDocumentPieceType( rs.getString("parent_document_piece_type"));
|
||||||
inventoryTransactionLeg.setJobCardId( rs.getLong("job_card_id"));
|
|
||||||
return inventoryTransactionLeg;
|
return inventoryTransactionLeg;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,10 +23,11 @@ public class JobCardDAO {
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY_WITH_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC limit :limit", 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 DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, 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 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) VALUES (:id, :code, :job_order_id, :created_at, :created_by, :status, :inventory_status, :customer, :lot_number, :purchase_order_id, :location_site_id, :description) 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)", 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 );
|
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 );
|
||||||
private final String SELECT_BY_LIKE_CODE = String.format( "SELECT * FROM %s WHERE code like :code", TABLE_NAME );
|
private final String SELECT_BY_LIKE_CODE = String.format( "SELECT * FROM %s WHERE code like :code", TABLE_NAME );
|
||||||
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s WHERE created_by = :created_by ORDER BY id ASC limit :limit", TABLE_NAME );
|
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s WHERE created_by = :created_by ORDER BY id DESC limit :limit", TABLE_NAME );
|
||||||
|
|
||||||
|
|
||||||
// prepare query params
|
// prepare query params
|
||||||
private MapSqlParameterSource prepareInsertQueryParams( JobCard jobCard ) {
|
private MapSqlParameterSource prepareInsertQueryParams( JobCard jobCard ) {
|
||||||
|
@ -39,8 +40,6 @@ public class JobCardDAO {
|
||||||
.addValue("status", jobCard.getStatus() )
|
.addValue("status", jobCard.getStatus() )
|
||||||
.addValue("inventory_status", jobCard.getInventoryStatus() )
|
.addValue("inventory_status", jobCard.getInventoryStatus() )
|
||||||
.addValue("customer", jobCard.getCustomer() )
|
.addValue("customer", jobCard.getCustomer() )
|
||||||
.addValue("poQuantity", jobCard.getPoQuantity() )
|
|
||||||
.addValue("articleName", jobCard.getArticleName() )
|
|
||||||
.addValue("lot_number", jobCard.getLotNumber() )
|
.addValue("lot_number", jobCard.getLotNumber() )
|
||||||
.addValue("purchase_order_id", jobCard.getPurchaseOrderId() )
|
.addValue("purchase_order_id", jobCard.getPurchaseOrderId() )
|
||||||
.addValue("location_site_id", jobCard.getLocationSiteId() )
|
.addValue("location_site_id", jobCard.getLocationSiteId() )
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class JobCardItemDAO {
|
public class JobCardItemDAO {
|
||||||
|
@ -21,12 +22,9 @@ public class JobCardItemDAO {
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_BY_CARD_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id", TABLE_NAME );
|
private final String SELECT_BY_CARD_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id", TABLE_NAME );
|
||||||
private final String SELECT_BY_CARD_ID_AND_ITEM_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :card_id AND item_id = :item_id ", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, job_card_id, item_id, sku, expected_production, actual_production, total_production, account_id, length, width, gsm, wt_ply, ply) VALUES (:id, :job_card_id, :item_id, :sku, :expected_production, :actual_production, :total_production, :account_id, :length, :width, :gsm, :wt_ply, :ply) ON DUPLICATE KEY UPDATE job_card_id = VALUES(job_card_id), item_id = VALUES(item_id), sku = VALUES(sku), expected_production = VALUES(expected_production), actual_production = VALUES(actual_production), total_production = VALUES(total_production), account_id = VALUES(account_id), length = VALUES(length), width = VALUES(width), gsm = VALUES(gsm), wt_ply = VALUES(wt_ply), ply = VALUES(ply) ", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, job_card_id, item_id, sku, expected_production, actual_production, total_production, account_id, length, width, gsm, wt_ply, ply, is_complete) VALUES (:id, :job_card_id, :item_id, :sku, :expected_production, :actual_production, :total_production, :account_id, :length, :width, :gsm, :wt_ply, :ply, :is_complete) ON DUPLICATE KEY UPDATE job_card_id = VALUES(job_card_id), item_id = VALUES(item_id), sku = VALUES(sku), expected_production = VALUES(expected_production), actual_production = VALUES(actual_production), total_production = VALUES(total_production), account_id = VALUES(account_id), length = VALUES(length), width = VALUES(width), gsm = VALUES(gsm), wt_ply = VALUES(wt_ply), ply = VALUES(ply), is_complete =VALUES(is_complete) ", TABLE_NAME );
|
|
||||||
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
private final String SELECT_BY_JOB_CARD_AND_ACCOUNT_IDS = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND account_id IN (:account_ids) AND is_complete = FALSE ", TABLE_NAME );
|
private final String SELECT_BY_JOB_CARD_AND_ACCOUNT_IDS = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND actual_production = :actual_production AND account_id IN (:account_ids)", TABLE_NAME );
|
||||||
private final String SELECT_ALL_ACTIVE_ITEM = String.format("SELECT CASE WHEN MIN(is_complete) = TRUE THEN TRUE ELSE FALSE END FROM %s WHERE job_card_id = :job_card_id AND id IN (:id)", TABLE_NAME);
|
|
||||||
private final String SELECT_BY_JOB_CARD_IDS = String.format( "SELECT * FROM %s WHERE job_card_id IN (:job_card_id)", TABLE_NAME );
|
|
||||||
|
|
||||||
public JobCardItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public JobCardItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -47,9 +45,7 @@ public class JobCardItemDAO {
|
||||||
.addValue("width", jobCardItem.getWidth() )
|
.addValue("width", jobCardItem.getWidth() )
|
||||||
.addValue("gsm", jobCardItem.getGsm() )
|
.addValue("gsm", jobCardItem.getGsm() )
|
||||||
.addValue("wt_ply", jobCardItem.getWtPly() )
|
.addValue("wt_ply", jobCardItem.getWtPly() )
|
||||||
.addValue("ply", jobCardItem.getPly() )
|
.addValue("ply", jobCardItem.getPly() );
|
||||||
.addValue("is_complete", jobCardItem.isComplete() );
|
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,41 +95,18 @@ public class JobCardItemDAO {
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID, params, new JobCardItemRowMapper() );
|
return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID, params, new JobCardItemRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public JobCardItem findByCardIdAndItemId( long cardId,long itemItem ){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "card_id", cardId );
|
|
||||||
params.addValue("item_id",itemItem);
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_CARD_ID_AND_ITEM_ID, params, new JobCardItemRowMapper() ).stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new JobCardItem() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<JobCardItem> findByIds( List<Long> ids ){
|
public List<JobCardItem> findByIds( List<Long> ids ){
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue( "ids", ids );
|
params.addValue( "ids", ids );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_IDS, params, new JobCardItemRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_IDS, params, new JobCardItemRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JobCardItem> findByJobCardAndAccountIdsAndIsReceived( Long jobCardId, List<Long> accountIds ){
|
public List<JobCardItem> findByJobCardAndAccountIdsAndIsReceived( Long jobCardId, Long actualProduction, List<Long> accountIds ){
|
||||||
if( accountIds == null || accountIds.isEmpty() ) return new ArrayList<>();
|
if( accountIds == null || accountIds.isEmpty() ) return new ArrayList<>();
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue( "account_ids", accountIds );
|
params.addValue( "account_ids", accountIds );
|
||||||
params.addValue("job_card_id", jobCardId );
|
params.addValue("job_card_id", jobCardId );
|
||||||
|
params.addValue("actual_production", actualProduction );
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_ACCOUNT_IDS , params, new JobCardItemRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_ACCOUNT_IDS , params, new JobCardItemRowMapper() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkAllItemsComplete( Long jobCardId, List<Long> itemsId ){
|
|
||||||
if( itemsId == null || itemsId.isEmpty() ) return false;
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", itemsId );
|
|
||||||
params.addValue("job_card_id", jobCardId );
|
|
||||||
Boolean allComplete = namedParameterJdbcTemplate.queryForObject(SELECT_ALL_ACTIVE_ITEM, params, Boolean.class);
|
|
||||||
return Boolean.TRUE.equals(allComplete);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<JobCardItem> findByJobCardIds(List<Long> ids){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", ids);
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_IDS, params, new JobCardItemRowMapper() );
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ public class JobCardItemRowMapper implements RowMapper<JobCardItem> {
|
||||||
jobCardItem.setGsm( rs.getString("gsm" ) );
|
jobCardItem.setGsm( rs.getString("gsm" ) );
|
||||||
jobCardItem.setWtPly( rs.getString("wt_ply" ) );
|
jobCardItem.setWtPly( rs.getString("wt_ply" ) );
|
||||||
jobCardItem.setPly( rs.getString("ply" ) );
|
jobCardItem.setPly( rs.getString("ply" ) );
|
||||||
jobCardItem.setComplete( rs.getBoolean("is_complete" ) );
|
|
||||||
return jobCardItem;
|
return jobCardItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,8 +23,6 @@ public class JobCardRowMapper implements RowMapper<JobCard> {
|
||||||
jobCard.setPurchaseOrderId( rs.getString("purchase_order_id") );
|
jobCard.setPurchaseOrderId( rs.getString("purchase_order_id") );
|
||||||
jobCard.setLocationSiteId( rs.getLong("location_site_id" ) );
|
jobCard.setLocationSiteId( rs.getLong("location_site_id" ) );
|
||||||
jobCard.setDescription( rs.getString("description" ) );
|
jobCard.setDescription( rs.getString("description" ) );
|
||||||
jobCard.setPoQuantity( rs.getInt("poQuantity" ) );
|
|
||||||
jobCard.setArticleName( rs.getString("articleName" ) );
|
|
||||||
return jobCard;
|
return jobCard;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,12 +20,10 @@ public class MasterBundleDAO {
|
||||||
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, barcode,item_id, sku, created_by, created_at, job_card_id, account_id, is_received) VALUES (:id, :barcode, :item_id, :sku, :created_by, :created_at, :job_card_id, :account_id, :is_received) ON DUPLICATE KEY UPDATE barcode = VALUES(barcode), item_id = VALUES(item_id), sku = VALUES(sku), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), is_received = VALUES(is_received), account_id = VALUES(account_id) ", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, barcode,item_id, sku, created_by, created_at, job_card_id, is_received) VALUES (:id, :barcode, :item_id, :sku, :created_by, :created_at, :job_card_id, :is_received) ON DUPLICATE KEY UPDATE barcode = VALUES(barcode), item_id = VALUES(item_id), sku = VALUES(sku), created_by = VALUES(created_by), created_at = VALUES(created_at), job_card_id = VALUES(job_card_id), is_received = VALUES(is_received)", TABLE_NAME );
|
||||||
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
private final String SELECT_BY_TERM_AND_RECEIVED = String.format( "SELECT * FROM %s WHERE is_received = :is_received AND ( id LIKE :id OR barcode LIKE :barcode ) ", TABLE_NAME );
|
private final String SELECT_BY_TERM_AND_RECEIVED = String.format( "SELECT * FROM %s WHERE is_received = :is_received AND ( id LIKE :id OR barcode LIKE :barcode ) ", TABLE_NAME );
|
||||||
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
private final String SELECT_BY_IDS_AND_RECIEVE = String.format( "SELECT id FROM %s WHERE id IN (:ids) AND is_received = true", TABLE_NAME );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MasterBundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public MasterBundleDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
@ -39,7 +37,6 @@ public class MasterBundleDAO {
|
||||||
.addValue( "barcode", masterBundle.getBarcode() )
|
.addValue( "barcode", masterBundle.getBarcode() )
|
||||||
.addValue( "item_id", masterBundle.getItemId() )
|
.addValue( "item_id", masterBundle.getItemId() )
|
||||||
.addValue( "sku", masterBundle.getSku() )
|
.addValue( "sku", masterBundle.getSku() )
|
||||||
.addValue( "account_id", masterBundle.getAccountId() )
|
|
||||||
.addValue( "created_by", masterBundle.getCreatedBy() )
|
.addValue( "created_by", masterBundle.getCreatedBy() )
|
||||||
.addValue( "created_at", masterBundle.getCreatedAt() )
|
.addValue( "created_at", masterBundle.getCreatedAt() )
|
||||||
.addValue( "job_card_id", masterBundle.getJobCardId() )
|
.addValue( "job_card_id", masterBundle.getJobCardId() )
|
||||||
|
@ -57,13 +54,6 @@ public class MasterBundleDAO {
|
||||||
.orElse( new MasterBundle() );
|
.orElse( new MasterBundle() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all
|
|
||||||
public List<Long> findByIdAndReceiveIsTrue(List<Long> ids) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "ids", ids );
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_IDS_AND_RECIEVE, params, (rs, rowNum) -> rs.getLong("id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// find all
|
// find all
|
||||||
public List<MasterBundle> findAll() {
|
public List<MasterBundle> findAll() {
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() );
|
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new MasterBundleRowMapper() );
|
||||||
|
|
|
@ -14,7 +14,6 @@ public class MasterBundleRowMapper implements RowMapper<MasterBundle> {
|
||||||
masterBundle.setCreatedBy( rs.getString( "created_by" ) );
|
masterBundle.setCreatedBy( rs.getString( "created_by" ) );
|
||||||
masterBundle.setItemId( rs.getLong("item_id" ));
|
masterBundle.setItemId( rs.getLong("item_id" ));
|
||||||
masterBundle.setSku( rs.getString("sku" ) );
|
masterBundle.setSku( rs.getString("sku" ) );
|
||||||
masterBundle.setAccountId(rs.getLong("account_id"));
|
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +0,0 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.PackagingItems;
|
|
||||||
import com.utopiaindustries.model.ctp.PackagingItemsRowMapper;
|
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
|
||||||
import org.springframework.jdbc.support.KeyHolder;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class PackagingItemsDAO {
|
|
||||||
|
|
||||||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
||||||
|
|
||||||
private static final String TABLE_NAME = "packaging_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 static final String INSERT_QUERY = String.format(
|
|
||||||
"INSERT INTO %s (" +
|
|
||||||
"id, item_id, sku, barcode, job_card_id, created_at, created_by, " +
|
|
||||||
"is_qa, finish_item_id, is_segregated, account_id, qa_status, bundle_id, account_title" +
|
|
||||||
") VALUES (" +
|
|
||||||
":id, :item_id, :sku, :barcode, :job_card_id, :created_at, :created_by, " +
|
|
||||||
":is_qa, :finish_item_id, :is_segregated, :account_id, :qa_status, :bundle_id, :account_title" +
|
|
||||||
") 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), " +
|
|
||||||
"is_qa = VALUES(is_qa), finish_item_id = VALUES(finish_item_id), " +
|
|
||||||
"is_segregated = VALUES(is_segregated), account_id = VALUES(account_id), " +
|
|
||||||
"qa_status = VALUES(qa_status), bundle_id = VALUES(bundle_id), account_title = VALUES(account_title)",
|
|
||||||
TABLE_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
public PackagingItemsDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapSqlParameterSource prepareParams(PackagingItems 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("is_qa", item.getIsQa())
|
|
||||||
.addValue("finish_item_id", item.getFinishedItemId())
|
|
||||||
.addValue("is_segregated", item.getIsSegregated())
|
|
||||||
.addValue("account_id", item.getAccountId())
|
|
||||||
.addValue("qa_status", item.getQaStatus())
|
|
||||||
.addValue("bundle_id", item.getBundleId())
|
|
||||||
.addValue("account_title", item.getAccountTitle());
|
|
||||||
}
|
|
||||||
|
|
||||||
public PackagingItems find(long id) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource("id", id);
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_ID, params, new PackagingItemsRowMapper())
|
|
||||||
.stream().findFirst().orElse(new PackagingItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PackagingItems> findAll() {
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_ALL, new PackagingItemsRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
public long save(PackagingItems 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<PackagingItems> items) {
|
|
||||||
List<MapSqlParameterSource> batchParams = new ArrayList<>();
|
|
||||||
for (PackagingItems 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<PackagingItems> findByJobCardId(long jobCardId) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource("job_card_id", jobCardId);
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_ID, params, new PackagingItemsRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.JobCard;
|
|
||||||
import com.utopiaindustries.model.ctp.PurchaseOrderCTP;
|
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
|
||||||
import org.springframework.jdbc.support.KeyHolder;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class PurchaseOrderCTPDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
||||||
|
|
||||||
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 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) " +
|
|
||||||
"VALUES (:id, :purchase_order_code, :purchase_order_quantity, :purchase_order_quantity_required, :article_name, :created_by, :status) " +
|
|
||||||
"ON DUPLICATE KEY UPDATE " +
|
|
||||||
"purchase_order_code = VALUES(purchase_order_code), " +
|
|
||||||
"purchase_order_quantity = VALUES(purchase_order_quantity), " +
|
|
||||||
"purchase_order_quantity_required = VALUES(purchase_order_quantity_required), " +
|
|
||||||
"article_name = VALUES(article_name), " +
|
|
||||||
"created_by = VALUES(created_by), " +
|
|
||||||
"status = VALUES(status)",
|
|
||||||
TABLE_NAME);
|
|
||||||
private final String SELECT_BY_LIMIT = String.format( "SELECT * FROM %s WHERE created_by = :created_by ORDER BY id ASC limit :limit", TABLE_NAME );
|
|
||||||
|
|
||||||
|
|
||||||
// prepare query params
|
|
||||||
private MapSqlParameterSource prepareInsertQueryParams(PurchaseOrderCTP purchaseOrderCTP) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("id", purchaseOrderCTP.getId())
|
|
||||||
.addValue("purchase_order_code", purchaseOrderCTP.getPurchaseOrderCode())
|
|
||||||
.addValue("purchase_order_quantity", purchaseOrderCTP.getPurchaseOrderQuantity())
|
|
||||||
.addValue("purchase_order_quantity_required", purchaseOrderCTP.getPurchaseOrderQuantityRequired())
|
|
||||||
.addValue("article_name", purchaseOrderCTP.getArticleName())
|
|
||||||
.addValue("created_by", purchaseOrderCTP.getCreatedBy())
|
|
||||||
.addValue("status", purchaseOrderCTP.getStatus());
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// find
|
|
||||||
public PurchaseOrderCTP find(long id ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", id );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new PurchaseOrderCTPRowMapper() )
|
|
||||||
.stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new PurchaseOrderCTP() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// find all
|
|
||||||
public List<PurchaseOrderCTP> findAll() {
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new PurchaseOrderCTPRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// save
|
|
||||||
public long save( PurchaseOrderCTP PurchaseOrderCTP) {
|
|
||||||
KeyHolder keyHolder = new GeneratedKeyHolder();
|
|
||||||
MapSqlParameterSource params = prepareInsertQueryParams(PurchaseOrderCTP);
|
|
||||||
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
|
||||||
return KeyHolderFunctions.getKey( PurchaseOrderCTP.getId(), keyHolder );
|
|
||||||
}
|
|
||||||
|
|
||||||
// save all
|
|
||||||
public int[] saveAll( List<PurchaseOrderCTP> purchaseOrderCTPS) {
|
|
||||||
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
|
||||||
for ( PurchaseOrderCTP PurchaseOrderCTP : purchaseOrderCTPS) {
|
|
||||||
MapSqlParameterSource params = prepareInsertQueryParams(PurchaseOrderCTP);
|
|
||||||
batchArgs.add( params );
|
|
||||||
}
|
|
||||||
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[purchaseOrderCTPS.size()]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete
|
|
||||||
public boolean delete( long id ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", id );
|
|
||||||
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PurchaseOrderCTP> findByQuery(String query ){
|
|
||||||
return namedParameterJdbcTemplate.query( query, new PurchaseOrderCTPRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PurchaseOrderCTP> findByUserAndLimit(String createdBy, Long limit ){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("limit", limit.intValue() );
|
|
||||||
params.addValue("created_by", createdBy );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_LIMIT, params, new PurchaseOrderCTPRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PurchaseOrderCTP> findByAllWithLimit(Long limit){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("limit", limit.intValue());
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY_WITH_LIMIT, params, new PurchaseOrderCTPRowMapper() );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.PurchaseOrderCTP;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class PurchaseOrderCTPRowMapper implements RowMapper<PurchaseOrderCTP> {
|
|
||||||
public PurchaseOrderCTP mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
PurchaseOrderCTP PurchaseOrderCTP = new PurchaseOrderCTP();
|
|
||||||
PurchaseOrderCTP.setId(rs.getLong("id"));
|
|
||||||
PurchaseOrderCTP.setPurchaseOrderCode(rs.getString("purchase_order_code"));
|
|
||||||
PurchaseOrderCTP.setPurchaseOrderQuantity(rs.getInt("purchase_order_quantity"));
|
|
||||||
PurchaseOrderCTP.setPurchaseOrderQuantityRequired(rs.getInt("purchase_order_quantity_required"));
|
|
||||||
PurchaseOrderCTP.setArticleName(rs.getString("article_name"));
|
|
||||||
if (rs.getTimestamp("created_at") != null) {
|
|
||||||
PurchaseOrderCTP.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime());
|
|
||||||
}
|
|
||||||
PurchaseOrderCTP.setCreatedBy(rs.getString("created_by"));
|
|
||||||
PurchaseOrderCTP.setStatus(rs.getString("status"));
|
|
||||||
return PurchaseOrderCTP;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.CutPiece;
|
|
||||||
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class SkuCutPieceRowMapper implements RowMapper<SkuCutPieces> {
|
|
||||||
public SkuCutPieces mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
SkuCutPieces skuCutPieces = new SkuCutPieces();
|
|
||||||
skuCutPieces.setId(rs.getLong("id"));
|
|
||||||
skuCutPieces.setSku(rs.getString("sku"));
|
|
||||||
skuCutPieces.setType(rs.getString("title"));
|
|
||||||
return skuCutPieces;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.CutPieceType;
|
|
||||||
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
|
||||||
import org.springframework.jdbc.support.KeyHolder;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public class SkuCutPiecesDAO {
|
|
||||||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
||||||
|
|
||||||
private final String TABLE_NAME = "cut_to_pack.sku_cut_piece";
|
|
||||||
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
|
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
|
||||||
private final String INSERT_QUERY = String.format("INSERT INTO %s (sku, title) VALUES (:sku, :title) ON DUPLICATE KEY UPDATE sku = VALUES(sku), title = VALUES(title)", TABLE_NAME);
|
|
||||||
private final String FIND_BY_SKU = String.format( "SELECT * FROM %s WHERE sku = :sku", TABLE_NAME );
|
|
||||||
private final String CHECK_EXISTENCE_QUERY = String.format("SELECT COUNT(*) FROM %s WHERE title = :title AND sku = :sku", TABLE_NAME);
|
|
||||||
|
|
||||||
public SkuCutPiecesDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare query params
|
|
||||||
private MapSqlParameterSource prepareInsertQueryParams(SkuCutPieces skuCutPieces ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", skuCutPieces.getId() )
|
|
||||||
.addValue( "sku", skuCutPieces.getSku())
|
|
||||||
.addValue("title",skuCutPieces.getType());
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find
|
|
||||||
public SkuCutPieces find( long id ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", id );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_QUERY, params, new SkuCutPieceRowMapper() )
|
|
||||||
.stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new SkuCutPieces() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean doesExist(String type, String sku) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("title", type);
|
|
||||||
params.addValue("sku", sku);
|
|
||||||
Long count = namedParameterJdbcTemplate.queryForObject(CHECK_EXISTENCE_QUERY, params, Long.class);
|
|
||||||
return count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//find by sku
|
|
||||||
public List<SkuCutPieces> findBySku(String sku) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("sku", sku);
|
|
||||||
return namedParameterJdbcTemplate.query(FIND_BY_SKU, params, new SkuCutPieceRowMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
// find all
|
|
||||||
public List<CutPieceType> findAll() {
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_ALL_QUERY, new CutPieceTypeRowMapper() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// save
|
|
||||||
public long save( SkuCutPieces skuCutPieces ) {
|
|
||||||
KeyHolder keyHolder = new GeneratedKeyHolder();
|
|
||||||
MapSqlParameterSource params = prepareInsertQueryParams( skuCutPieces );
|
|
||||||
namedParameterJdbcTemplate.update( INSERT_QUERY, params, keyHolder );
|
|
||||||
return KeyHolderFunctions.getKey( skuCutPieces.getId(), keyHolder );
|
|
||||||
}
|
|
||||||
|
|
||||||
// save all
|
|
||||||
public int[] saveAll( List<SkuCutPieces> skuCutPieces ) {
|
|
||||||
List<MapSqlParameterSource> batchArgs = new ArrayList<>();
|
|
||||||
for ( SkuCutPieces cutPieceType: skuCutPieces ) {
|
|
||||||
MapSqlParameterSource params = prepareInsertQueryParams( cutPieceType );
|
|
||||||
batchArgs.add( params );
|
|
||||||
}
|
|
||||||
return namedParameterJdbcTemplate.batchUpdate( INSERT_QUERY, batchArgs.toArray(new MapSqlParameterSource[skuCutPieces.size()]) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete
|
|
||||||
public boolean delete( long id ) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "id", id );
|
|
||||||
return namedParameterJdbcTemplate.update( DELETE_QUERY, params ) > 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.utopiaindustries.dao.ctp;
|
package com.utopiaindustries.dao.ctp;
|
||||||
|
|
||||||
import com.utopiaindustries.model.ctp.InventoryTransactionLeg;
|
|
||||||
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
import com.utopiaindustries.model.ctp.StitchingOfflineItem;
|
||||||
import com.utopiaindustries.util.KeyHolderFunctions;
|
import com.utopiaindustries.util.KeyHolderFunctions;
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
|
@ -23,15 +22,12 @@ public class StitchingOfflineItemDAO {
|
||||||
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY id DESC", TABLE_NAME );
|
||||||
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
private final String SELECT_QUERY_BY_JOB_CARD = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
||||||
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
|
||||||
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status,bundle_id) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status, :bundle_id) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status), bundle_id = VALUES(bundle_id)", TABLE_NAME );
|
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, item_id, sku, barcode, created_at, created_by, job_card_id, is_qa, qa_remarks, qa_status) VALUES (:id, :item_id, :sku, :barcode, :created_at, :created_by, :job_card_id, :is_qa, :qa_remarks, :qa_status) ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), sku = VALUES(sku), barcode = VALUES(barcode), created_at = VALUES(created_at), created_by = VALUES(created_by), job_card_id = VALUES(job_card_id), is_qa = VALUES(is_qa), qa_remarks = VALUES(qa_remarks), qa_status = VALUES(qa_status)", TABLE_NAME );
|
||||||
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
private final String SELECT_BY_LIMIT = String.format("SELECT * FROM %s ORDER BY id DESC LIMIT :limit", TABLE_NAME );
|
||||||
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME );
|
private final String FIND_TOTAL_COUNT = String.format("SELECT COUNT(*) FROM %s where job_card_id = :job_card_id And item_id = :item_id", TABLE_NAME );
|
||||||
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
|
||||||
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term ORDER BY ID DESC", TABLE_NAME );
|
private final String SELECT_BY_TERM = String.format( "SELECT * FROM %s WHERE barcode LIKE :term ORDER BY ID DESC", TABLE_NAME );
|
||||||
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
private final String SELECT_BY_MASTER_ID = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id", TABLE_NAME );
|
||||||
private final String COUNT_TOTAL_QA_ITEMS= String.format("SELECT COUNT(*) FROM %s WHERE job_card_id = :job_card_id AND is_qa IS TRUE",TABLE_NAME);
|
|
||||||
private final String SELECT_BY_TIME_AND_CARD_ID= String.format("SELECT * FROM %s WHERE job_card_id = :job_card_id ORDER BY created_at DESC LIMIT 1;",TABLE_NAME);
|
|
||||||
private final String SELECT_BY_JOB_CARD_AND_DATE = String.format( "SELECT * FROM %s WHERE job_card_id = :job_card_id AND (:start_date IS NULL OR :end_date IS NULL OR created_at BETWEEN :start_date AND :end_date)", TABLE_NAME );
|
|
||||||
|
|
||||||
public StitchingOfflineItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public StitchingOfflineItemDAO(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
||||||
|
@ -44,7 +40,6 @@ public class StitchingOfflineItemDAO {
|
||||||
.addValue( "item_id", stitchingOfflineItem.getItemId() )
|
.addValue( "item_id", stitchingOfflineItem.getItemId() )
|
||||||
.addValue( "sku", stitchingOfflineItem.getSku() )
|
.addValue( "sku", stitchingOfflineItem.getSku() )
|
||||||
.addValue( "barcode", stitchingOfflineItem.getBarcode() )
|
.addValue( "barcode", stitchingOfflineItem.getBarcode() )
|
||||||
.addValue("bundle_id",stitchingOfflineItem.getBundleId())
|
|
||||||
.addValue( "created_at", stitchingOfflineItem.getCreatedAt() )
|
.addValue( "created_at", stitchingOfflineItem.getCreatedAt() )
|
||||||
.addValue( "created_by", stitchingOfflineItem.getCreatedBy() )
|
.addValue( "created_by", stitchingOfflineItem.getCreatedBy() )
|
||||||
.addValue("job_card_id", stitchingOfflineItem.getJobCardId() )
|
.addValue("job_card_id", stitchingOfflineItem.getJobCardId() )
|
||||||
|
@ -145,28 +140,4 @@ public class StitchingOfflineItemDAO {
|
||||||
return totalCounts;
|
return totalCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long CalculateTotalQA( long jobCardId ){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardId );
|
|
||||||
Long count = namedParameterJdbcTemplate.queryForObject(COUNT_TOTAL_QA_ITEMS, params, Long.class);
|
|
||||||
return count != null ? count : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StitchingOfflineItem getLastStitchItemByCardIdAndTime(long jobCardId) {
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue("job_card_id", jobCardId);
|
|
||||||
|
|
||||||
return namedParameterJdbcTemplate.query(SELECT_BY_TIME_AND_CARD_ID, params,new StitchingOfflineItemRowMapper())
|
|
||||||
.stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElse( new StitchingOfflineItem() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StitchingOfflineItem> findByJobCardIdAndDate(long jobCardId, String startDate, String endDate){
|
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
|
||||||
params.addValue( "job_card_id", jobCardId );
|
|
||||||
params.addValue( "start_date", startDate );
|
|
||||||
params.addValue( "end_date", endDate );
|
|
||||||
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_DATE , params, new StitchingOfflineItemRowMapper() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ public class StitchingOfflineItemRowMapper implements RowMapper<StitchingOffline
|
||||||
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
stitchingOfflineItem.setItemId( rs.getLong( "item_id" ) );
|
||||||
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
stitchingOfflineItem.setSku( rs.getString( "sku" ) );
|
||||||
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
stitchingOfflineItem.setBarcode( rs.getString( "barcode" ) );
|
||||||
stitchingOfflineItem.setBundleId(rs.getLong("bundle_id"));
|
|
||||||
if ( rs.getTimestamp( "created_at" ) != null ) {
|
if ( rs.getTimestamp( "created_at" ) != null ) {
|
||||||
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
stitchingOfflineItem.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class SummaryInventoryReportDao {
|
||||||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
private final String TABLE_NAME = "cut_to_pack.inventory_transaction_leg ";
|
private final String TABLE_NAME = "cut_to_pack.inventory_transaction_leg ";
|
||||||
String SELECT_QUERY = "SELECT job_card_id, item_id, account_id, parent_document_id, DATE(transaction_leg_datetime) AS transaction_date, "
|
String SELECT_QUERY = "SELECT item_id, account_id, parent_document_id, DATE(transaction_leg_datetime) AS transaction_date, "
|
||||||
+ "sku, parent_document_type, parent_document_piece_type, "
|
+ "sku, parent_document_type, parent_document_piece_type, "
|
||||||
+ "SUM(CASE WHEN type = 'IN' THEN 1 ELSE 0 END) AS total_in, "
|
+ "SUM(CASE WHEN type = 'IN' THEN 1 ELSE 0 END) AS total_in, "
|
||||||
+ "SUM(CASE WHEN type = 'OUT' THEN 1 ELSE 0 END) AS total_out "
|
+ "SUM(CASE WHEN type = 'OUT' THEN 1 ELSE 0 END) AS total_out "
|
||||||
|
@ -22,7 +22,7 @@ public class SummaryInventoryReportDao {
|
||||||
+ "(:sku IS NULL OR sku = :sku) "
|
+ "(:sku IS NULL OR sku = :sku) "
|
||||||
+ "AND (:item_id IS NULL OR item_id = :item_id) "
|
+ "AND (:item_id IS NULL OR item_id = :item_id) "
|
||||||
+ "OR (:start_date IS NULL OR :end_date IS NULL OR transaction_leg_datetime BETWEEN :start_date AND :end_date) "
|
+ "OR (:start_date IS NULL OR :end_date IS NULL OR transaction_leg_datetime BETWEEN :start_date AND :end_date) "
|
||||||
+ "GROUP BY DATE(transaction_leg_datetime), account_id, sku, parent_document_type, parent_document_piece_type "
|
+ "GROUP BY DATE(transaction_leg_datetime), sku, parent_document_type, parent_document_piece_type "
|
||||||
+ "ORDER BY transaction_date, sku;";
|
+ "ORDER BY transaction_date, sku;";
|
||||||
|
|
||||||
public SummaryInventoryReportDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
public SummaryInventoryReportDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ public class SummaryInventoryReportRowMapper implements RowMapper<SummaryInvento
|
||||||
summaryInventoryReport.setAccountId(rs.getString("account_id"));
|
summaryInventoryReport.setAccountId(rs.getString("account_id"));
|
||||||
summaryInventoryReport.setDate(rs.getString("transaction_date"));
|
summaryInventoryReport.setDate(rs.getString("transaction_date"));
|
||||||
summaryInventoryReport.setTotalIn(rs.getLong("total_in"));
|
summaryInventoryReport.setTotalIn(rs.getLong("total_in"));
|
||||||
summaryInventoryReport.setJobCardID(rs.getLong("job_card_id"));
|
|
||||||
summaryInventoryReport.setTotalOut(rs.getLong("total_out"));
|
summaryInventoryReport.setTotalOut(rs.getLong("total_out"));
|
||||||
summaryInventoryReport.setParentDocumentType(rs.getString("parent_document_type"));
|
summaryInventoryReport.setParentDocumentType(rs.getString("parent_document_type"));
|
||||||
summaryInventoryReport.setParentDocumentPieceType(rs.getString("parent_document_piece_type"));
|
summaryInventoryReport.setParentDocumentPieceType(rs.getString("parent_document_piece_type"));
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class ItemDAO {
|
||||||
TABLE_NAME);
|
TABLE_NAME);
|
||||||
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME);
|
private final String SELECT_BY_IDS = String.format("SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME);
|
||||||
private final String SELECT_BY_IDS_AND_ACTIVE = String.format("SELECT * FROM %s WHERE id IN (:ids) AND is_active = 1 ", TABLE_NAME);
|
private final String SELECT_BY_IDS_AND_ACTIVE = String.format("SELECT * FROM %s WHERE id IN (:ids) AND is_active = 1 ", TABLE_NAME);
|
||||||
private final String SELECT_LIKE_TITLE_AND_STATUS_QUERY_OR_SKU = String.format("SELECT * FROM %s WHERE is_active = :is_active AND title LIKE :title OR sku LIKE :sku ORDER BY title ASC limit 100 offset 0", TABLE_NAME);
|
private final String SELECT_LIKE_TITLE_AND_STATUS_QUERY = String.format("SELECT * FROM %s WHERE is_active = :is_active AND title LIKE :title ORDER BY title ASC limit 100 offset 0", TABLE_NAME);
|
||||||
private final String SELECT_LIKE_TITLE_BY_DEPARTMENT_QUERY =
|
private final String SELECT_LIKE_TITLE_BY_DEPARTMENT_QUERY =
|
||||||
String.format("SELECT * FROM %s WHERE department_id = :department_id AND title LIKE :title ORDER BY title ASC", TABLE_NAME);
|
String.format("SELECT * FROM %s WHERE department_id = :department_id AND title LIKE :title ORDER BY title ASC", TABLE_NAME);
|
||||||
private final String SELECT_LIKE_TITLE = String.format("SELECT * FROM %s WHERE title LIKE :item_title", TABLE_NAME);
|
private final String SELECT_LIKE_TITLE = String.format("SELECT * FROM %s WHERE title LIKE :item_title", TABLE_NAME);
|
||||||
|
@ -232,12 +232,11 @@ public class ItemDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all like title (active only)
|
// find all like title (active only)
|
||||||
public List<Item> findLikeTitleAndStatusORSKU(String title, boolean active) {
|
public List<Item> findLikeTitleAndStatus(String title, boolean active) {
|
||||||
MapSqlParameterSource params = new MapSqlParameterSource();
|
MapSqlParameterSource params = new MapSqlParameterSource();
|
||||||
params.addValue("title", "%" + title + "%");
|
params.addValue("title", "%" + title + "%");
|
||||||
params.addValue("is_active", active);
|
params.addValue("is_active", active);
|
||||||
params.addValue("sku", "%" + title + "%");
|
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_AND_STATUS_QUERY, params, new ItemRowMapper());
|
||||||
return namedParameterJdbcTemplate.query(SELECT_LIKE_TITLE_AND_STATUS_QUERY_OR_SKU, params, new ItemRowMapper());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all like title and department
|
// find all like title and department
|
||||||
|
|
|
@ -6,8 +6,8 @@ public enum BarcodeStickerSize {
|
||||||
SIZE_2_X_3( 3 * 72, 2 * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
SIZE_2_X_3( 3 * 72, 2 * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
SIZE_4_X_4( 4 * 72, 4 * 72, 8, 8, 8, 8, 200, 100, 250, 250, 14, 9, 7),
|
||||||
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
SIZE_1_75_X_3_5( 3.5f * 72, 1.75f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7),
|
||||||
SIZE_4_X_7( 7f * 72, 4f * 72, 200, 10, 40, 6, 50, 40, 125, 125, 14, 9, 7),
|
SIZE_4_X_7( 7f * 72, 4f * 72, 10, 10, 6, 6, 50, 50, 125, 125, 14, 9, 7);
|
||||||
SIZE_1_X_2( 67.69f, 139.73f ,10 , 10, 20, 6, 60, 60, 125, 125, 4, 9, 7);
|
|
||||||
|
|
||||||
private final float width;
|
private final float width;
|
||||||
private final float height;
|
private final float height;
|
||||||
|
|
|
@ -11,8 +11,6 @@ public class Bundle implements InventoryArtifact {
|
||||||
private long itemId;
|
private long itemId;
|
||||||
private String sku;
|
private String sku;
|
||||||
private BigDecimal wrapQuantity;
|
private BigDecimal wrapQuantity;
|
||||||
private BigDecimal production;
|
|
||||||
private BigDecimal currentProduction;
|
|
||||||
private String barcode;
|
private String barcode;
|
||||||
private String type;
|
private String type;
|
||||||
private String createdBy;
|
private String createdBy;
|
||||||
|
@ -100,22 +98,6 @@ public class Bundle implements InventoryArtifact {
|
||||||
return masterBundleId;
|
return masterBundleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getProduction() {
|
|
||||||
return production;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProduction(BigDecimal production) {
|
|
||||||
this.production = production;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getCurrentProduction() {
|
|
||||||
return currentProduction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentProduction(BigDecimal currentProduction) {
|
|
||||||
this.currentProduction = currentProduction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMasterBundleId(long masterBundleId) {
|
public void setMasterBundleId(long masterBundleId) {
|
||||||
this.masterBundleId = masterBundleId;
|
this.masterBundleId = masterBundleId;
|
||||||
}
|
}
|
||||||
|
@ -128,10 +110,6 @@ public class Bundle implements InventoryArtifact {
|
||||||
this.masterBundle = masterBundle;
|
this.masterBundle = masterBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Bundle{" +
|
return "Bundle{" +
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BundleWrapper {
|
|
||||||
private List<Bundle> bundles = new ArrayList<>(); // ✅ Initialize List
|
|
||||||
|
|
||||||
public List<Bundle> getBundles() {
|
|
||||||
return bundles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBundles(List<Bundle> bundles) {
|
|
||||||
this.bundles = bundles;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ package com.utopiaindustries.model.ctp;
|
||||||
public class CutPieceType {
|
public class CutPieceType {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
private String type;
|
private String title;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -13,19 +13,19 @@ public class CutPieceType {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getTitle() {
|
||||||
return type;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setTitle(String title) {
|
||||||
this.type = type;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CutPieceType{" +
|
return "CutPieceType{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", title='" + type + '\'' +
|
", title='" + title + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,151 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
public class CuttingJobCardItemWrapper {
|
|
||||||
private long jobCardId;
|
|
||||||
private String poName;
|
|
||||||
private String sku;
|
|
||||||
private Long total;
|
|
||||||
private String width;
|
|
||||||
private String length;
|
|
||||||
private String gsm;
|
|
||||||
private String wtPly;
|
|
||||||
private String ply;
|
|
||||||
private String articleName;
|
|
||||||
private boolean isComplete;
|
|
||||||
private String jobCardCode;
|
|
||||||
private String operatorName;
|
|
||||||
private long accountId;
|
|
||||||
|
|
||||||
public long getJobCardId() {
|
|
||||||
return jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCardId(long jobCardId) {
|
|
||||||
this.jobCardId = jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPoName() {
|
|
||||||
return poName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoName(String poName) {
|
|
||||||
this.poName = poName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSku() {
|
|
||||||
return sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSku(String sku) {
|
|
||||||
this.sku = sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWidth(String width) {
|
|
||||||
this.width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGsm() {
|
|
||||||
return gsm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGsm(String gsm) {
|
|
||||||
this.gsm = gsm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWtPly() {
|
|
||||||
return wtPly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWtPly(String wtPly) {
|
|
||||||
this.wtPly = wtPly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPly() {
|
|
||||||
return ply;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPly(String ply) {
|
|
||||||
this.ply = ply;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArticleName() {
|
|
||||||
return articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArticleName(String articleName) {
|
|
||||||
this.articleName = articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return isComplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComplete(boolean complete) {
|
|
||||||
isComplete = complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJobCardCode() {
|
|
||||||
return jobCardCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCardCode(String jobCardCode) {
|
|
||||||
this.jobCardCode = jobCardCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(String length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperatorName() {
|
|
||||||
return operatorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOperatorName(String operatorName) {
|
|
||||||
this.operatorName = operatorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountId(long accountId) {
|
|
||||||
this.accountId = accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTotal() {
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(Long total) {
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "CuttingJobCardItemWrapper{" +
|
|
||||||
"jobCardId=" + jobCardId +
|
|
||||||
", poName='" + poName + '\'' +
|
|
||||||
", sku='" + sku + '\'' +
|
|
||||||
", total=" + total +
|
|
||||||
", width='" + width + '\'' +
|
|
||||||
", length='" + length + '\'' +
|
|
||||||
", gsm='" + gsm + '\'' +
|
|
||||||
", wtPly='" + wtPly + '\'' +
|
|
||||||
", ply='" + ply + '\'' +
|
|
||||||
", articleName='" + articleName + '\'' +
|
|
||||||
", isComplete=" + isComplete +
|
|
||||||
", jobCardCode='" + jobCardCode + '\'' +
|
|
||||||
", operatorName='" + operatorName + '\'' +
|
|
||||||
", accountId=" + accountId +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class FinishedItem implements InventoryArtifact {
|
public class FinishedItem implements InventoryArtifact {
|
||||||
|
@ -142,18 +141,6 @@ public class FinishedItem implements InventoryArtifact {
|
||||||
this.qaStatus = qaStatus;
|
this.qaStatus = qaStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getWrapQuantity(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMasterBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FinishedItem{" +
|
return "FinishedItem{" +
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
public interface InventoryArtifact {
|
public interface InventoryArtifact {
|
||||||
|
|
||||||
long getId();
|
long getId();
|
||||||
long getItemId();
|
long getItemId();
|
||||||
long getJobCardId();
|
|
||||||
String getSku();
|
String getSku();
|
||||||
String getType();
|
String getType();
|
||||||
String getBarcode();
|
String getBarcode();
|
||||||
String getCreatedBy();
|
|
||||||
LocalDateTime getCreatedAt();
|
|
||||||
BigDecimal getWrapQuantity();
|
|
||||||
long getMasterBundleId();
|
|
||||||
long getBundleId();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,5 @@ package com.utopiaindustries.model.ctp;
|
||||||
public enum InventoryArtifactType {
|
public enum InventoryArtifactType {
|
||||||
BUNDLE,
|
BUNDLE,
|
||||||
STITCHING_OFFLINE,
|
STITCHING_OFFLINE,
|
||||||
FINISHED_ITEM,
|
FINISHED_ITEM
|
||||||
STITCH_BUNDLE,
|
|
||||||
PACKAGING
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class InventoryTransactionLeg {
|
||||||
private String parentDocumentType;
|
private String parentDocumentType;
|
||||||
private long parentDocumentId;
|
private long parentDocumentId;
|
||||||
private String parentDocumentPieceType;
|
private String parentDocumentPieceType;
|
||||||
private long jobCardId;
|
|
||||||
//wrapper
|
//wrapper
|
||||||
private InventoryTransaction transaction;
|
private InventoryTransaction transaction;
|
||||||
|
|
||||||
|
@ -122,14 +122,6 @@ public class InventoryTransactionLeg {
|
||||||
this.parentDocumentPieceType = parentDocumentPieceType;
|
this.parentDocumentPieceType = parentDocumentPieceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getJobCardId() {
|
|
||||||
return jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCardId(long jobCardId) {
|
|
||||||
this.jobCardId = jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryTransaction getTransaction() {
|
public InventoryTransaction getTransaction() {
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@ public class JobCard {
|
||||||
private String purchaseOrderId;
|
private String purchaseOrderId;
|
||||||
private long locationSiteId;
|
private long locationSiteId;
|
||||||
private String description;
|
private String description;
|
||||||
private String articleName;
|
|
||||||
private int poQuantity;
|
|
||||||
// wrapper
|
// wrapper
|
||||||
private List<JobCardItem> items;
|
private List<JobCardItem> items;
|
||||||
private long toAccountId;
|
private long toAccountId;
|
||||||
|
@ -164,22 +162,6 @@ public class JobCard {
|
||||||
this.locationTitle = locationTitle;
|
this.locationTitle = locationTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArticleName() {
|
|
||||||
return articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArticleName(String articleName) {
|
|
||||||
this.articleName = articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPoQuantity() {
|
|
||||||
return poQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoQuantity(int poQuantity) {
|
|
||||||
this.poQuantity = poQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "JobCard{" +
|
return "JobCard{" +
|
||||||
|
@ -192,11 +174,9 @@ public class JobCard {
|
||||||
", inventoryStatus='" + inventoryStatus + '\'' +
|
", inventoryStatus='" + inventoryStatus + '\'' +
|
||||||
", customer='" + customer + '\'' +
|
", customer='" + customer + '\'' +
|
||||||
", lotNumber='" + lotNumber + '\'' +
|
", lotNumber='" + lotNumber + '\'' +
|
||||||
", purchaseOrderId='" + purchaseOrderId + '\'' +
|
", purchaseOrderId=" + purchaseOrderId +
|
||||||
", locationSiteId=" + locationSiteId +
|
", locationSiteId=" + locationSiteId +
|
||||||
", description='" + description + '\'' +
|
", description='" + description + '\'' +
|
||||||
", articleName='" + articleName + '\'' +
|
|
||||||
", poQuantity=" + poQuantity +
|
|
||||||
", items=" + items +
|
", items=" + items +
|
||||||
", toAccountId=" + toAccountId +
|
", toAccountId=" + toAccountId +
|
||||||
", purchaseOrderTitle='" + purchaseOrderTitle + '\'' +
|
", purchaseOrderTitle='" + purchaseOrderTitle + '\'' +
|
||||||
|
|
|
@ -23,7 +23,6 @@ public class JobCardItem {
|
||||||
private List<CutPiece> cutPieces;
|
private List<CutPiece> cutPieces;
|
||||||
private String title;
|
private String title;
|
||||||
private boolean isSelected;
|
private boolean isSelected;
|
||||||
private boolean isComplete;
|
|
||||||
|
|
||||||
public JobCardItem() {
|
public JobCardItem() {
|
||||||
this.expectedProduction = BigDecimal.ZERO;
|
this.expectedProduction = BigDecimal.ZERO;
|
||||||
|
@ -168,14 +167,6 @@ public class JobCardItem {
|
||||||
isSelected = selected;
|
isSelected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isComplete() {
|
|
||||||
return isComplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComplete(boolean complete) {
|
|
||||||
isComplete = complete;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
@ -9,8 +9,6 @@ public class JobCardItemWrapper {
|
||||||
private long jobCardItemId;
|
private long jobCardItemId;
|
||||||
private List<CutPiece> pieces;
|
private List<CutPiece> pieces;
|
||||||
private BigDecimal actualProduction;
|
private BigDecimal actualProduction;
|
||||||
private int perBundleQuantity;
|
|
||||||
private boolean cuttingComplete;
|
|
||||||
|
|
||||||
public long getJobCardId() {
|
public long getJobCardId() {
|
||||||
return jobCardId;
|
return jobCardId;
|
||||||
|
@ -44,22 +42,6 @@ public class JobCardItemWrapper {
|
||||||
this.actualProduction = actualProduction;
|
this.actualProduction = actualProduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPerBundleQuantity() {
|
|
||||||
return perBundleQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPerBundleQuantity(int perBundleQuantity) {
|
|
||||||
this.perBundleQuantity = perBundleQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getCuttingComplete() {
|
|
||||||
return cuttingComplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCuttingComplete(boolean finalReceived) {
|
|
||||||
this.cuttingComplete = finalReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "JobCardItemWrapper{" +
|
return "JobCardItemWrapper{" +
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -14,8 +13,6 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
private boolean isReceived;
|
private boolean isReceived;
|
||||||
private long jobCardId;
|
private long jobCardId;
|
||||||
private long accountId;
|
|
||||||
|
|
||||||
// wrapper
|
// wrapper
|
||||||
private List<Bundle> bundles;
|
private List<Bundle> bundles;
|
||||||
private List<FinishedItem> items;
|
private List<FinishedItem> items;
|
||||||
|
@ -97,14 +94,6 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
this.bundles = bundles;
|
this.bundles = bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getWrapQuantity(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMasterBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FinishedItem> getItems() {
|
public List<FinishedItem> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -113,18 +102,6 @@ public class MasterBundle implements InventoryArtifact{
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountId(long accountId) {
|
|
||||||
this.accountId = accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MasterBundle{" +
|
return "MasterBundle{" +
|
||||||
|
|
|
@ -1,147 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
public class POsDetails {
|
|
||||||
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;
|
|
||||||
|
|
||||||
public long getPoQuantity() {
|
|
||||||
return poQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoQuantity(long poQuantity) {
|
|
||||||
this.poQuantity = poQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPoNumber() {
|
|
||||||
return poNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoNumber(String poNumber) {
|
|
||||||
this.poNumber = poNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArticleTitle() {
|
|
||||||
return articleTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArticleTitle(String articleTitle) {
|
|
||||||
this.articleTitle = articleTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalCutting() {
|
|
||||||
return totalCutting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalCutting(long totalCutting) {
|
|
||||||
this.totalCutting = totalCutting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRemainingCutting() {
|
|
||||||
return remainingCutting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemainingCutting(long remainingCutting) {
|
|
||||||
this.remainingCutting = remainingCutting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalStitching() {
|
|
||||||
return totalStitching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalStitching(long totalStitching) {
|
|
||||||
this.totalStitching = totalStitching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRemainingStitching() {
|
|
||||||
return remainingStitching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemainingStitching(long remainingStitching) {
|
|
||||||
this.remainingStitching = remainingStitching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalEndLineQC() {
|
|
||||||
return totalEndLineQC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalEndLineQC(long totalEndLineQC) {
|
|
||||||
this.totalEndLineQC = totalEndLineQC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRemainingEndLineQC() {
|
|
||||||
return remainingEndLineQC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemainingEndLineQC(long remainingEndLineQC) {
|
|
||||||
this.remainingEndLineQC = remainingEndLineQC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalFinishing() {
|
|
||||||
return totalFinishing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalFinishing(long totalFinishing) {
|
|
||||||
this.totalFinishing = totalFinishing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRemainingFinishing() {
|
|
||||||
return remainingFinishing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemainingFinishing(long remainingFinishing) {
|
|
||||||
this.remainingFinishing = remainingFinishing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalAGradeItem() {
|
|
||||||
return totalAGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalAGradeItem(long totalAGradeItem) {
|
|
||||||
this.totalAGradeItem = totalAGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalBGradeItem() {
|
|
||||||
return totalBGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalBGradeItem(long totalBGradeItem) {
|
|
||||||
this.totalBGradeItem = totalBGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalCGradeItem() {
|
|
||||||
return totalCGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalCGradeItem(long totalCGradeItem) {
|
|
||||||
this.totalCGradeItem = totalCGradeItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
public class PackagingItems 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 boolean isQa;
|
|
||||||
private long finishedItemId;
|
|
||||||
private boolean isSegregated;
|
|
||||||
// wrapper
|
|
||||||
private JobCard jobCard;
|
|
||||||
private long accountId;
|
|
||||||
private String qaStatus;
|
|
||||||
private long bundleId;
|
|
||||||
private String accountTitle;
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType() {
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getItemId() {
|
|
||||||
return itemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemId(long itemId) {
|
|
||||||
this.itemId = itemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSku() {
|
|
||||||
return sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSku(String sku) {
|
|
||||||
this.sku = sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBarcode() {
|
|
||||||
return barcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBarcode(String barcode) {
|
|
||||||
this.barcode = barcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(LocalDateTime createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreatedBy() {
|
|
||||||
return createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedBy(String createdBy) {
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getJobCardId() {
|
|
||||||
return jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCardId(long jobCardId) {
|
|
||||||
this.jobCardId = jobCardId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIsQa() {
|
|
||||||
return isQa;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsQa(boolean qa) {
|
|
||||||
isQa = qa;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getFinishedItemId() {
|
|
||||||
return finishedItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFinishedItemId(long finishedItemId) {
|
|
||||||
this.finishedItemId = finishedItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JobCard getJobCard() {
|
|
||||||
return jobCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCard(JobCard jobCard) {
|
|
||||||
this.jobCard = jobCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIsSegregated() {
|
|
||||||
return isSegregated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsSegregated(boolean segregated) {
|
|
||||||
isSegregated = segregated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountId(long accountId) {
|
|
||||||
this.accountId = accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getQaStatus() {
|
|
||||||
return qaStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQaStatus(String qaStatus) {
|
|
||||||
this.qaStatus = qaStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getWrapQuantity(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMasterBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBundleId(){
|
|
||||||
return bundleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBundleId(long bundleId) {
|
|
||||||
this.bundleId = bundleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccountTitle() {
|
|
||||||
return accountTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountTitle(String accountTitle) {
|
|
||||||
this.accountTitle = accountTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "PackagingItems{" +
|
|
||||||
"id=" + id +
|
|
||||||
", itemId=" + itemId +
|
|
||||||
", sku='" + sku + '\'' +
|
|
||||||
", barcode='" + barcode + '\'' +
|
|
||||||
", jobCardId=" + jobCardId +
|
|
||||||
", createdAt=" + createdAt +
|
|
||||||
", createdBy='" + createdBy + '\'' +
|
|
||||||
", isQa=" + isQa +
|
|
||||||
", finishedItemId=" + finishedItemId +
|
|
||||||
", isSegregated=" + isSegregated +
|
|
||||||
", jobCard=" + jobCard +
|
|
||||||
", accountId=" + accountId +
|
|
||||||
", qaStatus='" + qaStatus + '\'' +
|
|
||||||
", bundleId=" + bundleId +
|
|
||||||
", accountTitle='" + accountTitle + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class PackagingItemsRowMapper implements RowMapper<PackagingItems> {
|
|
||||||
@Override
|
|
||||||
public PackagingItems mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
PackagingItems item = new PackagingItems();
|
|
||||||
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.setIsQa(rs.getBoolean("is_qa"));
|
|
||||||
item.setFinishedItemId(rs.getLong("finish_item_id"));
|
|
||||||
item.setIsSegregated(rs.getBoolean("is_segregated"));
|
|
||||||
item.setAccountId(rs.getLong("account_id"));
|
|
||||||
item.setQaStatus(rs.getString("qa_status"));
|
|
||||||
item.setBundleId(rs.getLong("bundle_id"));
|
|
||||||
item.setAccountTitle(rs.getString("account_title"));
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
public class PurchaseOrderCTP {
|
|
||||||
|
|
||||||
public enum Status{
|
|
||||||
DRAFT,
|
|
||||||
POSTED,
|
|
||||||
}
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private String purchaseOrderCode;
|
|
||||||
private long purchaseOrderQuantity;
|
|
||||||
private long purchaseOrderQuantityRequired;
|
|
||||||
private String articleName;
|
|
||||||
private String createdBy;
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPurchaseOrderCode() {
|
|
||||||
return purchaseOrderCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPurchaseOrderCode(String purchaseOrderCode) {
|
|
||||||
this.purchaseOrderCode = purchaseOrderCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getPurchaseOrderQuantity() {
|
|
||||||
return purchaseOrderQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPurchaseOrderQuantity(long purchaseOrderQuantity) {
|
|
||||||
this.purchaseOrderQuantity = purchaseOrderQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getPurchaseOrderQuantityRequired() {
|
|
||||||
return purchaseOrderQuantityRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPurchaseOrderQuantityRequired(long purchaseOrderQuantityRequired) {
|
|
||||||
this.purchaseOrderQuantityRequired = purchaseOrderQuantityRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getArticleName() {
|
|
||||||
return articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArticleName(String articleName) {
|
|
||||||
this.articleName = articleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreatedBy() {
|
|
||||||
return createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedBy(String createdBy) {
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(LocalDateTime createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.utopiaindustries.model.ctp;
|
|
||||||
|
|
||||||
|
|
||||||
public class SkuCutPieces {
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private String sku;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSku() {
|
|
||||||
return sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSku(String sku) {
|
|
||||||
this.sku = sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "CutPiece{" +
|
|
||||||
"id=" + id +
|
|
||||||
", sku=" + sku +
|
|
||||||
", type='" + type +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.utopiaindustries.model.ctp;
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class StitchingOfflineItem implements InventoryArtifact {
|
public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
|
@ -18,7 +17,6 @@ public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
private boolean isQa;
|
private boolean isQa;
|
||||||
private String qaRemarks;
|
private String qaRemarks;
|
||||||
private String qaStatus;
|
private String qaStatus;
|
||||||
private long bundleId;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -109,22 +107,6 @@ public class StitchingOfflineItem implements InventoryArtifact {
|
||||||
this.qaStatus = qaStatus;
|
this.qaStatus = qaStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getWrapQuantity(){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMasterBundleId(){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBundleId() {
|
|
||||||
return bundleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBundleId(long bundleId) {
|
|
||||||
this.bundleId = bundleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StitchingOfflineItem{" +
|
return "StitchingOfflineItem{" +
|
||||||
|
|
|
@ -7,7 +7,6 @@ public class SummaryInventoryReport {
|
||||||
private String Date;
|
private String Date;
|
||||||
private long totalIn;
|
private long totalIn;
|
||||||
private long totalOut;
|
private long totalOut;
|
||||||
private long jobCardID;
|
|
||||||
private String parentDocumentType;
|
private String parentDocumentType;
|
||||||
private String parentDocumentId;
|
private String parentDocumentId;
|
||||||
private String accountId;
|
private String accountId;
|
||||||
|
@ -92,12 +91,4 @@ public class SummaryInventoryReport {
|
||||||
public void setAccountId(String accountId) {
|
public void setAccountId(String accountId) {
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getJobCardID() {
|
|
||||||
return jobCardID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJobCardID(long jobCardID) {
|
|
||||||
this.jobCardID = jobCardID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package com.utopiaindustries.querybuilder.ctp;
|
|
||||||
|
|
||||||
import com.utopiaindustries.querybuilder.QueryBuilder;
|
|
||||||
import com.utopiaindustries.util.CTPDateTimeFormat;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
public class PurchaseOrderCTPQueryBuilder {
|
|
||||||
public static String buildQuery(String purchaseOrderCode, String articleName, String createdBy, String startDate, String endDate, Long count ){
|
|
||||||
// format date
|
|
||||||
String formattedDate;
|
|
||||||
String formattedEndDate;
|
|
||||||
String startDate1 = "";
|
|
||||||
String endDate1 = "";
|
|
||||||
String purchaseOrderCode1 = purchaseOrderCode == null ? "" : purchaseOrderCode;
|
|
||||||
String articleName1 = articleName == null ? "" : articleName;
|
|
||||||
if ( ! StringUtils.isNullOrEmpty( startDate ) ) {
|
|
||||||
formattedDate = CTPDateTimeFormat.getMySQLFormattedDateString( startDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT );
|
|
||||||
formattedEndDate = CTPDateTimeFormat.getMySQLFormattedDateString( endDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT );
|
|
||||||
startDate1 = String.format( "'%s 00:00:01'", formattedDate );
|
|
||||||
if ( ! StringUtils.isNullOrEmpty( endDate ) ) {
|
|
||||||
endDate1 = String.format("'%s 23:59:59'", formattedEndDate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
endDate1 = String.format("'%s 23:59:59'", LocalDate.now() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new QueryBuilder())
|
|
||||||
.setTable("cut_to_pack.purchase_order")
|
|
||||||
.setColumns("*")
|
|
||||||
.where()
|
|
||||||
.columnEquals("created_by", createdBy)
|
|
||||||
.and()
|
|
||||||
.columnLike("purchase_order_code", "%" + purchaseOrderCode1 + "%")
|
|
||||||
.and()
|
|
||||||
.columnLike("article_name", articleName)
|
|
||||||
.and()
|
|
||||||
.columnEqualToOrGreaterThan("created_at", startDate1)
|
|
||||||
.and()
|
|
||||||
.columnEqualToOrLessThan("created_at", endDate1)
|
|
||||||
.limit(count.intValue())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import java.time.LocalDate;
|
||||||
|
|
||||||
public class StichedOfflineItemQueryBuilder {
|
public class StichedOfflineItemQueryBuilder {
|
||||||
|
|
||||||
public static String buildQuery(String id, String itemId, String sku, String QaStatus,String createdStartDate, String createdEndDate, Long bundleId, Long count) {
|
public static String buildQuery(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, Long count) {
|
||||||
// format date
|
// format date
|
||||||
String formattedDate;
|
String formattedDate;
|
||||||
String formattedEndDate;
|
String formattedEndDate;
|
||||||
|
@ -24,7 +24,8 @@ public class StichedOfflineItemQueryBuilder {
|
||||||
endDate1 = String.format("'%s 23:59:59'", LocalDate.now());
|
endDate1 = String.format("'%s 23:59:59'", LocalDate.now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueryBuilder qb = (new QueryBuilder())
|
|
||||||
|
return ( new QueryBuilder() )
|
||||||
.setTable("cut_to_pack.stitching_offline_item")
|
.setTable("cut_to_pack.stitching_offline_item")
|
||||||
.setColumns("*")
|
.setColumns("*")
|
||||||
.where()
|
.where()
|
||||||
|
@ -32,20 +33,17 @@ public class StichedOfflineItemQueryBuilder {
|
||||||
.and()
|
.and()
|
||||||
.columnEquals("sku", sku)
|
.columnEquals("sku", sku)
|
||||||
.and()
|
.and()
|
||||||
.columnEquals("item_id", itemId)
|
.columnEquals("item_id", itemId )
|
||||||
.and()
|
.and()
|
||||||
.columnEquals("bundle_id", bundleId)
|
.columnEquals("job_card_id", jobCardId )
|
||||||
.and()
|
.and()
|
||||||
.columnEqualToOrGreaterThan("created_at", startDate1)
|
.columnEqualToOrGreaterThan("created_at", startDate1)
|
||||||
.and()
|
.and()
|
||||||
.columnEqualToOrLessThan("created_at", endDate1);
|
.columnEqualToOrLessThan("created_at", endDate1 )
|
||||||
if (!StringUtils.isNullOrEmpty(QaStatus)) {
|
.orderBy("id","DESC")
|
||||||
qb.and().columnEquals("qa_status", QaStatus);
|
.limit(count)
|
||||||
}
|
.build();
|
||||||
qb.orderBy("id", "DESC")
|
|
||||||
.limit(count);
|
|
||||||
|
|
||||||
return qb.build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,42 +62,11 @@ public class SummaryInventoryReportQueryBuilder {
|
||||||
.bracketClose()
|
.bracketClose()
|
||||||
.bracketClose()
|
.bracketClose()
|
||||||
.and()
|
.and()
|
||||||
.columnBetween("transaction_leg_datetime",startDate,endDate)
|
.columnBetween("transaction_leg_date",startDate,endDate)
|
||||||
.groupBy("DATE(transaction_leg_datetime), sku, parent_document_type, parent_document_piece_type")
|
.groupBy("DATE(transaction_leg_datetime), sku, parent_document_type, parent_document_piece_type")
|
||||||
.orderBy("transaction_date,", "sku");
|
.orderBy("transaction_date,", "sku");
|
||||||
|
|
||||||
return qb.build();
|
return qb.build();
|
||||||
}
|
|
||||||
|
|
||||||
public static String cuttingQueryBuild(long jobCardId,
|
|
||||||
List<Long> account,
|
|
||||||
String sku,
|
|
||||||
String startDate,
|
|
||||||
String endDate,
|
|
||||||
String type,
|
|
||||||
String parentDocumentType) {
|
|
||||||
|
|
||||||
QueryBuilder qb = new QueryBuilder()
|
|
||||||
.setTable(TABLE_NAME)
|
|
||||||
.setColumns("*")
|
|
||||||
.where()
|
|
||||||
.columnIn("account_id",account.toArray(new Long[0]))
|
|
||||||
.and()
|
|
||||||
.columnEqualToOrGreaterThan("transaction_leg_datetime",startDate)
|
|
||||||
.and()
|
|
||||||
.columnEqualToOrLessThan("transaction_leg_datetime",endDate)
|
|
||||||
.and()
|
|
||||||
.columnEquals("type",type)
|
|
||||||
.and()
|
|
||||||
.columnEquals("parent_document_type",parentDocumentType);
|
|
||||||
if (jobCardId != 0){
|
|
||||||
qb.and()
|
|
||||||
.columnEquals("job_card_id", jobCardId );
|
|
||||||
}
|
|
||||||
if (!StringUtils.isNullOrEmpty(sku)){
|
|
||||||
qb.and()
|
|
||||||
.columnEquals("sku", sku );
|
|
||||||
}
|
|
||||||
return qb.build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,13 +34,4 @@ public class BundleRestController {
|
||||||
return bundleService.findBundlesByMasterId( masterId );
|
return bundleService.findBundlesByMasterId( masterId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping( "/find-bundle-by-id/{id}" )
|
|
||||||
public Bundle findBundleById( @PathVariable("id") long id ){
|
|
||||||
return bundleService.getBundlesById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping( "/find-bundle-by-barcode" )
|
|
||||||
public List<Bundle> findByMasterBarcode(@RequestParam String term ){
|
|
||||||
return bundleService.getBundles( term );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,19 @@
|
||||||
package com.utopiaindustries.restcontroller;
|
package com.utopiaindustries.restcontroller;
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.CutPieceTypeDAO;
|
|
||||||
import com.utopiaindustries.dao.ctp.SkuCutPiecesDAO;
|
|
||||||
import com.utopiaindustries.model.ctp.CutPieceType;
|
|
||||||
import com.utopiaindustries.model.ctp.SkuCutPieces;
|
|
||||||
import com.utopiaindustries.service.JobCardService;
|
import com.utopiaindustries.service.JobCardService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.ArrayList;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping( "/rest/cut-pieces" )
|
@RequestMapping( "/rest/cut-pieces" )
|
||||||
public class CutPieceRestController {
|
public class CutPieceRestController {
|
||||||
|
|
||||||
private final JobCardService jobCardService;
|
private final JobCardService jobCardService;
|
||||||
private final SkuCutPiecesDAO skuCutPiecesDAO;
|
|
||||||
private final CutPieceTypeDAO cutPieceTypeDAO;
|
|
||||||
|
|
||||||
public CutPieceRestController(JobCardService jobCardService, SkuCutPiecesDAO skuCutPiecesDAO, CutPieceTypeDAO cutPieceTypeDAO) {
|
public CutPieceRestController(JobCardService jobCardService) {
|
||||||
this.jobCardService = jobCardService;
|
this.jobCardService = jobCardService;
|
||||||
this.skuCutPiecesDAO = skuCutPiecesDAO;
|
|
||||||
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
public List<CutPieceType> getBySku(@RequestParam("sku") String sku) {
|
|
||||||
try {
|
|
||||||
ArrayList<CutPieceType> cutPieceTypes = new ArrayList<>();
|
|
||||||
List<SkuCutPieces> skuCutPieces = skuCutPiecesDAO.findBySku(sku);
|
|
||||||
for (SkuCutPieces skuCutPieces1 : skuCutPieces){
|
|
||||||
CutPieceType cutPieceType = cutPieceTypeDAO.findByTitle(skuCutPieces1.getType());
|
|
||||||
cutPieceTypes.add(cutPieceType);
|
|
||||||
}
|
|
||||||
return cutPieceTypes;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("An error occurred while fetching data for SKU: " + sku, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
|
|
@ -24,9 +24,4 @@ public class FinishedItemRestController {
|
||||||
@RequestParam( "is-segregated") boolean isSegregated ){
|
@RequestParam( "is-segregated") boolean isSegregated ){
|
||||||
return finishedItemDAO.findByTerm( term, isSegregated );
|
return finishedItemDAO.findByTerm( term, isSegregated );
|
||||||
}
|
}
|
||||||
@GetMapping( "/search-packaging" )
|
|
||||||
public List<FinishedItem> searchFinishedItemsForPackaging(@RequestParam( "term") String term,
|
|
||||||
@RequestParam( "is-segregated") boolean isSegregated ){
|
|
||||||
return finishedItemDAO.findByTerm( term, true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ItemRestController {
|
||||||
items = itemDAO.findBySkuOrTitleAndTypeIdAndActive(term, Arrays.stream(typeIds).collect(Collectors.toList()), "1" );
|
items = itemDAO.findBySkuOrTitleAndTypeIdAndActive(term, Arrays.stream(typeIds).collect(Collectors.toList()), "1" );
|
||||||
} else {
|
} else {
|
||||||
// else return all results
|
// else return all results
|
||||||
items = itemDAO.findLikeTitleAndStatusORSKU(term, true );
|
items = itemDAO.findLikeTitleAndStatus(term, true );
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
package com.utopiaindustries.service;
|
package com.utopiaindustries.service;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.itextpdf.io.font.constants.StandardFonts;
|
import com.utopiaindustries.dao.ctp.BundleDAO;
|
||||||
import com.itextpdf.io.image.ImageData;
|
import com.utopiaindustries.dao.ctp.FinishedItemDAO;
|
||||||
import com.itextpdf.kernel.colors.ColorConstants;
|
import com.utopiaindustries.dao.ctp.MasterBundleDAO;
|
||||||
import com.itextpdf.kernel.font.PdfFont;
|
import com.utopiaindustries.dao.ctp.StitchingOfflineItemDAO;
|
||||||
import com.itextpdf.kernel.font.PdfFontFactory;
|
|
||||||
import com.itextpdf.kernel.pdf.PdfPage;
|
|
||||||
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
|
|
||||||
import com.itextpdf.layout.element.AreaBreak;
|
|
||||||
import com.itextpdf.layout.element.Paragraph;
|
|
||||||
import com.itextpdf.layout.property.AreaBreakType;
|
|
||||||
import com.itextpdf.layout.property.TextAlignment;
|
|
||||||
import com.utopiaindustries.dao.ctp.*;
|
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
import com.utopiaindustries.util.BarcodeUtils;
|
import com.utopiaindustries.util.BarcodeUtils;
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
|
@ -21,39 +13,17 @@ import com.zebra.sdk.comm.TcpConnection;
|
||||||
import com.zebra.sdk.graphics.internal.ZebraImage;
|
import com.zebra.sdk.graphics.internal.ZebraImage;
|
||||||
import com.zebra.sdk.printer.ZebraPrinter;
|
import com.zebra.sdk.printer.ZebraPrinter;
|
||||||
import com.zebra.sdk.printer.ZebraPrinterFactory;
|
import com.zebra.sdk.printer.ZebraPrinterFactory;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.itextpdf.io.image.ImageDataFactory;
|
|
||||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
|
||||||
import com.itextpdf.kernel.geom.PageSize;
|
|
||||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
|
||||||
import com.itextpdf.layout.Document;
|
|
||||||
import com.itextpdf.layout.element.Image;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.FileSystems;
|
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.io.*;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.google.zxing.EncodeHintType;
|
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
|
||||||
import com.google.zxing.WriterException;
|
|
||||||
import com.google.zxing.common.BitMatrix;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BarcodeService {
|
public class BarcodeService {
|
||||||
|
@ -64,34 +34,16 @@ public class BarcodeService {
|
||||||
@Value("${ctp.printer.port}")
|
@Value("${ctp.printer.port}")
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@Value("${ctp.printer.bundleIpAdd}")
|
|
||||||
private String bundleIpAddress;
|
|
||||||
|
|
||||||
@Value("${ctp.printer.bundlePort}")
|
|
||||||
private int bundlePort;
|
|
||||||
|
|
||||||
@Value("${ctp.printer.stitchQRPath}")
|
|
||||||
private String stitchPath;
|
|
||||||
|
|
||||||
@Value("${ctp.printer.bundlePath}")
|
|
||||||
private String bundlePath;
|
|
||||||
|
|
||||||
private final BundleDAO bundleDAO;
|
private final BundleDAO bundleDAO;
|
||||||
private final JobCardDAO jobCardDAO;
|
|
||||||
private final MasterBundleDAO masterBundleDAO;
|
private final MasterBundleDAO masterBundleDAO;
|
||||||
private final FinishedItemDAO finishedItemDAO;
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
||||||
private final InventoryAccountDAO inventoryAccountDAO;
|
|
||||||
private final JobCardItemDAO jobCardItemDAO;
|
|
||||||
|
|
||||||
public BarcodeService(BundleDAO bundleDAO, JobCardDAO jobCardDAO, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, InventoryAccountDAO inventoryAccountDAO, JobCardItemDAO jobCardItemDAO) {
|
public BarcodeService(BundleDAO bundleDAO, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO) {
|
||||||
this.bundleDAO = bundleDAO;
|
this.bundleDAO = bundleDAO;
|
||||||
this.jobCardDAO = jobCardDAO;
|
|
||||||
this.masterBundleDAO = masterBundleDAO;
|
this.masterBundleDAO = masterBundleDAO;
|
||||||
this.finishedItemDAO = finishedItemDAO;
|
this.finishedItemDAO = finishedItemDAO;
|
||||||
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
||||||
this.inventoryAccountDAO = inventoryAccountDAO;
|
|
||||||
this.jobCardItemDAO = jobCardItemDAO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -104,360 +56,85 @@ public class BarcodeService {
|
||||||
List<? extends InventoryArtifact> list = new ArrayList<>();
|
List<? extends InventoryArtifact> list = new ArrayList<>();
|
||||||
if (StringUtils.compare(artifactType, Bundle.class.getSimpleName())) {
|
if (StringUtils.compare(artifactType, Bundle.class.getSimpleName())) {
|
||||||
list = bundleDAO.findByIds(ids);
|
list = bundleDAO.findByIds(ids);
|
||||||
getBarcodeImages(list, stickerSize, artifactType);
|
|
||||||
} else if (StringUtils.compare(artifactType, MasterBundle.class.getSimpleName())) {
|
} else if (StringUtils.compare(artifactType, MasterBundle.class.getSimpleName())) {
|
||||||
list = masterBundleDAO.findByIds(ids);
|
list = masterBundleDAO.findByIds(ids);
|
||||||
getBarcodeImages(list, stickerSize, artifactType);
|
|
||||||
} else if (StringUtils.compare(artifactType, FinishedItem.class.getSimpleName())) {
|
} else if (StringUtils.compare(artifactType, FinishedItem.class.getSimpleName())) {
|
||||||
String sizeForStitchItem = BarcodeStickerSize.SIZE_1_X_2.name();
|
|
||||||
BarcodeStickerSize stickerSizeForStitchItem = BarcodeStickerSize.getSize(sizeForStitchItem);
|
|
||||||
list = stitchingOfflineItemDAO.findByIds(ids);
|
list = stitchingOfflineItemDAO.findByIds(ids);
|
||||||
getBarcodeImagesForStitchItems(list, stickerSizeForStitchItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBarcodeImages(list, stickerSize, artifactType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getBarcodeImages(List<? extends InventoryArtifact> artifacts,
|
public void getBarcodeImages(List<? extends InventoryArtifact> artifacts,
|
||||||
BarcodeStickerSize stickerSize,
|
BarcodeStickerSize stickerSize,
|
||||||
String artifactType) throws Exception {
|
String artifactType) throws Exception {
|
||||||
int pageWidth = 900; // A4 Width
|
|
||||||
int pageHeight = 1200; // A4 Height
|
|
||||||
int rows = 3;
|
|
||||||
int cols = 2;
|
|
||||||
int totalStickersPerPage = rows * cols;
|
|
||||||
int totalPages = (int) Math.ceil((double) artifacts.size() / totalStickersPerPage); // Total required pages
|
|
||||||
List<BufferedImage> bufferedImages = new ArrayList<>();
|
|
||||||
for (int page = 0; page < totalPages; page++) {
|
|
||||||
// Create a Blank A4 Page Image
|
|
||||||
BufferedImage a4Image = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics2D g2d = a4Image.createGraphics();
|
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
g2d.setColor(Color.WHITE);
|
|
||||||
g2d.fillRect(0, 0, pageWidth, pageHeight);
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
|
|
||||||
Font barcodeFont = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+8);
|
|
||||||
Font detailFont = new Font("Helvetica", Font.PLAIN, stickerSize.getTextSize()+3);
|
|
||||||
|
|
||||||
for (int i = 0; i < totalStickersPerPage; i++) {
|
|
||||||
int artifactIndex = page * totalStickersPerPage + i;
|
|
||||||
if (artifactIndex >= artifacts.size()) break;
|
|
||||||
InventoryArtifact artifact = artifacts.get(artifactIndex);
|
|
||||||
int row = i / cols;
|
|
||||||
int col = i % cols;
|
|
||||||
|
|
||||||
int x = col * (pageWidth / cols);
|
|
||||||
int y = row * (pageHeight / rows);
|
|
||||||
|
|
||||||
Font stickerFont = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize() + 10);
|
|
||||||
g2d.setFont(stickerFont);
|
|
||||||
// Draw Sticker Border
|
|
||||||
g2d.drawRect(x, y, pageWidth / cols, pageHeight / rows);
|
|
||||||
|
|
||||||
this.drawCenteredText(g2d, artifactType.equals("Bundle")?"Sub-Bundle":"Master-Bundle", detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop()-20,stickerSize.getMarginLeft()-165);
|
|
||||||
|
|
||||||
// Draw SKU
|
|
||||||
g2d.setFont(barcodeFont);
|
|
||||||
String sku = artifact.getSku();
|
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
|
||||||
int textWidth = fontMetrics.stringWidth(sku);
|
|
||||||
g2d.drawString(sku, x + ((pageWidth / cols) - textWidth) / 2, y + fontMetrics.getAscent()+ stickerSize.getMarginTop()+10);
|
|
||||||
|
|
||||||
// Generate Barcode Image
|
|
||||||
g2d.setFont(barcodeFont);
|
|
||||||
byte[] imgBytes = BarcodeUtils.getBarcodeImageByteArray(
|
|
||||||
artifact.getBarcode(), BarcodeFormat.CODE_128, stickerSize.getImageWidthBarcode(), stickerSize.getImageHeightBarcode());
|
|
||||||
|
|
||||||
BufferedImage barcodeImage = ImageIO.read(new ByteArrayInputStream(imgBytes));
|
|
||||||
int originalBarcodeWidth = barcodeImage.getWidth();
|
|
||||||
int originalBarcodeHeight = barcodeImage.getHeight();
|
|
||||||
|
|
||||||
|
|
||||||
double scaleX = (double)(pageWidth / cols) / originalBarcodeWidth;
|
|
||||||
double scaleY = (double)(pageHeight / rows) / originalBarcodeHeight;
|
|
||||||
double scaleFactor = Math.min(scaleX, scaleY);
|
|
||||||
|
|
||||||
int scaledWidth = (int)(originalBarcodeWidth * scaleFactor) - 30;
|
|
||||||
int scaledHeight = (int)(originalBarcodeHeight * scaleFactor) - 10;
|
|
||||||
|
|
||||||
BufferedImage scaledBarcodeImage = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
Graphics2D g2dBarcode = scaledBarcodeImage.createGraphics();
|
|
||||||
g2dBarcode.drawImage(barcodeImage, 0, 0, scaledWidth, scaledHeight, null);
|
|
||||||
g2dBarcode.dispose();
|
|
||||||
|
|
||||||
int barcodeX = x + ((pageWidth / cols) - scaledBarcodeImage.getWidth()) / 2;
|
|
||||||
int barcodeY = y + fontMetrics.getAscent() + stickerSize.getMarginTop() + 20;
|
|
||||||
g2d.drawImage(scaledBarcodeImage, barcodeX, barcodeY, null);
|
|
||||||
|
|
||||||
//barcode text
|
|
||||||
g2d.setFont(barcodeFont);
|
|
||||||
String barcode = artifact.getBarcode();
|
|
||||||
FontMetrics barcodeFontMatrix = g2d.getFontMetrics();
|
|
||||||
int barcodeText = fontMetrics.stringWidth(barcode);
|
|
||||||
g2d.drawString(barcode, (x + ((pageWidth / cols) - barcodeText) / 2), y + barcodeFontMatrix.getAscent() + stickerSize.getMarginTop() + 120);
|
|
||||||
|
|
||||||
//draw item-id
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm");
|
|
||||||
this.drawCenteredText(g2d, "Item-ID: "+artifact.getItemId(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 150,stickerSize.getMarginLeft());
|
|
||||||
this.drawCenteredText(g2d, "Created-By: "+artifact.getCreatedBy(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 170,stickerSize.getMarginLeft());
|
|
||||||
this.drawCenteredText(g2d, "Created-At: "+formatter.format(artifact.getCreatedAt()), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 190,stickerSize.getMarginLeft());
|
|
||||||
|
|
||||||
//draw job-card details
|
|
||||||
JobCard jobCard = jobCardDAO.find(artifact.getJobCardId());
|
|
||||||
|
|
||||||
this.drawCenteredText(g2d, "Job-Card: " + jobCard.getCode(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 210, stickerSize.getMarginLeft() );
|
|
||||||
this.drawCenteredText(g2d, "Purchase-Order: " + jobCard.getPurchaseOrderId(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 230, stickerSize.getMarginLeft());
|
|
||||||
this.drawCenteredText(g2d, "Lot-Number: " + jobCard.getLotNumber(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 250, stickerSize.getMarginLeft());
|
|
||||||
if((artifactType.equals("Bundle"))){
|
|
||||||
JobCardItem jobCardItem = jobCardItemDAO.findByCardId(jobCard.getId()).get(0);
|
|
||||||
InventoryAccount inventoryAccount = inventoryAccountDAO.find(jobCardItem.getAccountId());
|
|
||||||
this.drawCenteredText(g2d, "Pieces: " + artifact.getWrapQuantity(), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 270, stickerSize.getMarginLeft());
|
|
||||||
this.drawCenteredText(g2d, "Cutting-Account: " + inventoryAccount.getTitle() , detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 290, stickerSize.getMarginLeft());
|
|
||||||
}else {
|
|
||||||
List<Bundle> bundles = bundleDAO.findByMasterId(artifact.getId());
|
|
||||||
String concatenatedIds = bundles.stream()
|
|
||||||
.map(bundle -> String.valueOf(bundle.getId()))
|
|
||||||
.collect(Collectors.joining("\\"));
|
|
||||||
int totalWrappedQuantity = bundles.stream()
|
|
||||||
.mapToInt(e->e.getWrapQuantity().intValue())
|
|
||||||
.sum();
|
|
||||||
this.drawCenteredText(g2d, "Total-Pieces: " + totalWrappedQuantity, detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 270, stickerSize.getMarginLeft());
|
|
||||||
this.drawCenteredText(g2d, "Sub-Bundles: " + concatenatedIds, detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 290, stickerSize.getMarginLeft());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawCenteredText(g2d, String.valueOf(artifact.getId()), detailFont, x, y, pageWidth, cols, stickerSize.getMarginTop() + 330, 0);
|
|
||||||
}
|
|
||||||
g2d.dispose();
|
|
||||||
bufferedImages.add(a4Image);
|
|
||||||
}
|
|
||||||
saveA4ImageToPDF(bufferedImages,bundlePath);
|
|
||||||
try {
|
|
||||||
printPDF(bundleIpAddress, bundlePath);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printPDF(String printerIP, String pdfFilePath) throws Exception {
|
|
||||||
File pdfFile = new File(pdfFilePath);
|
|
||||||
FileInputStream fis = new FileInputStream(pdfFile);
|
|
||||||
|
|
||||||
Socket printerSocket = new Socket(printerIP, port);
|
|
||||||
OutputStream out = printerSocket.getOutputStream();
|
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = fis.read(buffer)) != -1) {
|
|
||||||
out.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
fis.close();
|
|
||||||
printerSocket.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveA4ImageToPDF(List<BufferedImage> a4Images, String outputFilePath) throws Exception {
|
|
||||||
PdfWriter writer = new PdfWriter(outputFilePath);
|
|
||||||
PdfDocument pdfDoc = new PdfDocument(writer);
|
|
||||||
Document document = new Document(pdfDoc, PageSize.A4);
|
|
||||||
document.setMargins(0, 0, 0, 0);
|
|
||||||
|
|
||||||
for (int i = 0; i < a4Images.size(); i++) {
|
|
||||||
if (i > 0) {
|
|
||||||
document.add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
|
||||||
}
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
ImageIO.write(a4Images.get(i), "png", baos);
|
|
||||||
byte[] imageBytes = baos.toByteArray();
|
|
||||||
ImageData imageData = ImageDataFactory.create(imageBytes);
|
|
||||||
Image image = new Image(imageData);
|
|
||||||
|
|
||||||
// Scale and position correctly
|
|
||||||
image.scaleToFit(pdfDoc.getDefaultPageSize().getWidth(), pdfDoc.getDefaultPageSize().getHeight());
|
|
||||||
image.setFixedPosition(0, 30);
|
|
||||||
document.add(image);
|
|
||||||
}
|
|
||||||
document.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawCenteredText(Graphics2D g2d, String text, Font font, int x, int y, int pageWidth, int cols, int marginTop, int marginLeft) {
|
|
||||||
g2d.setFont(font);
|
|
||||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
|
||||||
int adjustedX = (x + ((pageWidth / cols) ) / 2) - marginLeft;
|
|
||||||
int adjustedY = y + fontMetrics.getAscent() + marginTop;
|
|
||||||
g2d.drawString(text, adjustedX, adjustedY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getBarcodeImagesForStitchItems(List<? extends InventoryArtifact> artifacts,
|
|
||||||
BarcodeStickerSize stickerSize) throws Exception {
|
|
||||||
|
|
||||||
Path pdfPath = FileSystems.getDefault().getPath(stitchPath);
|
|
||||||
PdfWriter writer = new PdfWriter(pdfPath.toFile());
|
|
||||||
PdfDocument pdfDoc = new PdfDocument(writer);
|
|
||||||
Document document = new Document(pdfDoc);
|
|
||||||
pdfDoc.setDefaultPageSize(new PageSize(stickerSize.getWidth(), stickerSize.getHeight()));
|
|
||||||
|
|
||||||
for (InventoryArtifact artifact : artifacts) {
|
for (InventoryArtifact artifact : artifacts) {
|
||||||
JobCard jobCard = jobCardDAO.find(artifact.getJobCardId());
|
// Create a blank BufferedImage (an image with the size of the sticker)
|
||||||
|
BufferedImage stickerImage = new BufferedImage((int) stickerSize.getWidth()*2, (int) stickerSize.getHeight()*2, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
Graphics2D g2d = stickerImage.createGraphics();
|
||||||
|
g2d.scale(2,2);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
PdfPage page = pdfDoc.addNewPage();
|
// Set background color (white for the sticker)
|
||||||
PdfCanvas canvas = new PdfCanvas(page);
|
g2d.setColor(Color.WHITE);
|
||||||
canvas.setFillColor(ColorConstants.WHITE);
|
g2d.fillRect(0, 0, (int) stickerSize.getWidth(), (int) stickerSize.getHeight());
|
||||||
canvas.rectangle(0, 0, stickerSize.getWidth(), stickerSize.getHeight());
|
|
||||||
canvas.fill();
|
|
||||||
|
|
||||||
// Draw QR Code on Left Side
|
// Set font for SKU and barcode
|
||||||
byte[] imgBytes = generateQRCodeImageByteArray(artifact.getBarcode(), stickerSize.getImageWidthBarcode(), stickerSize.getImageHeightBarcode());
|
Font font = new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+10);
|
||||||
Image qrCodeImage = new Image(ImageDataFactory.create(imgBytes));
|
g2d.setFont(font);
|
||||||
|
|
||||||
float qrY =stickerSize.getMarginLeft()+50 ;
|
|
||||||
float qrX = stickerSize.getMarginTop();
|
|
||||||
|
|
||||||
qrCodeImage.setFixedPosition(qrX - 16, qrY-35);
|
|
||||||
document.add(qrCodeImage);
|
|
||||||
|
|
||||||
float textX = stickerSize.getMarginLeft() + 40;
|
|
||||||
float textY = stickerSize.getMarginTop() + 40;
|
|
||||||
|
|
||||||
|
// Add SKU to the image
|
||||||
String sku = artifact.getSku();
|
String sku = artifact.getSku();
|
||||||
String jobCardCode = jobCard.getCode();
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
String combinedText = sku + " \\ " + jobCardCode + " \\ " + artifact.getBundleId();
|
int textWidth = fontMetrics.stringWidth(sku);
|
||||||
combinedText = combinedText.replaceAll("\\s+", "");
|
int x = (int) ((stickerSize.getWidth() - textWidth) / 2);
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
g2d.drawString(sku, x, stickerSize.getMarginTop() + fontMetrics.getAscent()+20);
|
||||||
|
|
||||||
int maxLength = 12;
|
// Create the barcode image
|
||||||
int start = 0;
|
byte[] imgBytes = BarcodeUtils.getBarcodeImageByteArray(artifact.getBarcode(), BarcodeFormat.CODE_128, stickerSize.getImageWidthBarcode()+500, stickerSize.getImageHeightBarcode()+30);
|
||||||
int lineCount = 0;
|
BufferedImage barcodeImage = ImageIO.read(new ByteArrayInputStream(imgBytes));
|
||||||
List<String> lines = new ArrayList<>();
|
|
||||||
|
|
||||||
while (start < combinedText.length() && lineCount < 5) {
|
// Draw the barcode image on the sticker
|
||||||
int end = Math.min(start + maxLength, combinedText.length());
|
int barcodeX =(int) (stickerSize.getWidth() - barcodeImage.getWidth()) / 2;
|
||||||
String part = combinedText.substring(start, end);
|
int barcodeY = stickerSize.getMarginTop() + fontMetrics.getAscent() + 30; // Add some margin
|
||||||
|
g2d.drawImage(barcodeImage, barcodeX, barcodeY, null);
|
||||||
|
|
||||||
if (part.matches(".*[^a-zA-Z0-9 ].*")) {
|
// Add the barcode value below the barcode image
|
||||||
if(combinedText.length() - start<=17 && combinedText.length() - start>0){
|
g2d.drawString(artifact.getBarcode(), (stickerSize.getWidth() - fontMetrics.stringWidth(artifact.getBarcode())) / 2,
|
||||||
end = Math.min(start + maxLength + 5, combinedText.length());
|
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent());
|
||||||
part = combinedText.substring(start, end);
|
|
||||||
}else {
|
// If artifactType is Bundle, add additional info
|
||||||
end = Math.min(start + maxLength + 3, combinedText.length());
|
if (artifactType.equalsIgnoreCase(Bundle.class.getSimpleName())) {
|
||||||
part = combinedText.substring(start, end);
|
String typeText = String.format("%s : %d", artifact.getType(), artifact.getId());
|
||||||
}
|
g2d.drawString(typeText, (stickerSize.getWidth() - fontMetrics.stringWidth(typeText)) / 2,
|
||||||
}
|
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 45);
|
||||||
part = part.replaceAll("\\s+", "");
|
|
||||||
lines.add(part);
|
g2d.setFont(new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+20));
|
||||||
start = end;
|
g2d.drawString(String.valueOf(artifactType.toCharArray()[0]), (stickerSize.getWidth() - fontMetrics.stringWidth(String.valueOf(artifactType.toCharArray()[0]))) / 2,
|
||||||
lineCount++;
|
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 77);
|
||||||
|
} else {
|
||||||
|
// Add first character of artifact type
|
||||||
|
String type = String.valueOf(artifactType.charAt(0));
|
||||||
|
g2d.setFont(new Font("Helvetica", Font.BOLD, stickerSize.getTextSize()+10));
|
||||||
|
g2d.drawString(type, (stickerSize.getWidth() - fontMetrics.stringWidth(type)) / 2,
|
||||||
|
barcodeY + barcodeImage.getHeight() + fontMetrics.getAscent() + 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finalize drawing
|
||||||
float labelWidth = 67.69f;
|
g2d.dispose();
|
||||||
float textBoxWidth = 120f;
|
printLabel(stickerImage);
|
||||||
float textY1 = textY-23;
|
|
||||||
float textXCenter = textX + (labelWidth / 2) - (textBoxWidth / 2)-50;
|
|
||||||
|
|
||||||
for (String line : lines) {
|
|
||||||
Paragraph rotatedText = new Paragraph(line)
|
|
||||||
.setFontColor(ColorConstants.BLACK)
|
|
||||||
.setFontSize(stickerSize.getTextSize()+2)
|
|
||||||
.setTextAlignment(TextAlignment.CENTER)
|
|
||||||
.setFixedPosition(textXCenter, textY1-13, textBoxWidth);
|
|
||||||
|
|
||||||
document.add(rotatedText);
|
|
||||||
textY1 -= 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER);
|
|
||||||
String id = String.valueOf(artifact.getId());
|
|
||||||
float textSize = stickerSize.getTextSize() + 6;
|
|
||||||
float charWidth = textSize * 0.6f;
|
|
||||||
float idWidth = id.length() * charWidth;
|
|
||||||
float xCentered = (labelWidth / 2f) - (idWidth / 2f);
|
|
||||||
|
|
||||||
document.add(new Paragraph(id)
|
|
||||||
.setFont(font)
|
|
||||||
.setBold()
|
|
||||||
.setFontColor(ColorConstants.BLACK)
|
|
||||||
.setFontSize(textSize)
|
|
||||||
.setFixedPosition(xCentered, textY + 18, 100));
|
|
||||||
|
|
||||||
|
|
||||||
float dottedLine = textY - 65;
|
|
||||||
for(int i= 0 ;i<16;i++){
|
|
||||||
document.add(new Paragraph("|")
|
|
||||||
.setFontSize(stickerSize.getTextSize())
|
|
||||||
.setFontColor(ColorConstants.BLACK)
|
|
||||||
.setBold()
|
|
||||||
.setRotationAngle(-Math.PI / 2)
|
|
||||||
.setTextAlignment(TextAlignment.LEFT)
|
|
||||||
.setFixedPosition(dottedLine,textX+55, 100));
|
|
||||||
|
|
||||||
dottedLine += 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
float dottedLine2 = textY - 65;
|
|
||||||
for(int i= 0 ;i<16;i++){
|
|
||||||
document.add(new Paragraph("|")
|
|
||||||
.setFontSize(stickerSize.getTextSize())
|
|
||||||
.setFontColor(ColorConstants.BLACK)
|
|
||||||
.setBold()
|
|
||||||
.setRotationAngle(-Math.PI / 2)
|
|
||||||
.setTextAlignment(TextAlignment.LEFT)
|
|
||||||
.setFixedPosition(dottedLine2,textX+90, 100));
|
|
||||||
|
|
||||||
dottedLine2 += 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!artifact.equals(artifacts.get(artifacts.size() - 1))) {
|
|
||||||
document.add(new AreaBreak());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pdfDoc.getNumberOfPages() > artifacts.size()) {
|
|
||||||
pdfDoc.removePage(pdfDoc.getNumberOfPages());
|
|
||||||
}
|
|
||||||
|
|
||||||
document.close();
|
|
||||||
sendPdfToZebraPrinter(pdfPath.toFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendPdfToZebraPrinter(File pdfFile) throws Exception {
|
|
||||||
PDDocument pdDocument = PDDocument.load(pdfFile);
|
|
||||||
PDFRenderer renderer = new PDFRenderer(pdDocument);
|
|
||||||
for (int pageIndex = 0; pageIndex < pdDocument.getNumberOfPages(); pageIndex++) {
|
|
||||||
BufferedImage pageImage = renderer.renderImageWithDPI(pageIndex, 320);
|
|
||||||
printLabel(pageImage);
|
|
||||||
}
|
|
||||||
pdDocument.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] generateQRCodeImageByteArray(String data, int width, int height) {
|
|
||||||
try {
|
|
||||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
||||||
Map<EncodeHintType, Object> hintMap = new HashMap<>();
|
|
||||||
hintMap.put(EncodeHintType.MARGIN, 0);
|
|
||||||
BitMatrix bitMatrix = qrCodeWriter.encode(data, BarcodeFormat.QR_CODE, width, height, hintMap);
|
|
||||||
BufferedImage qrImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
|
||||||
qrImage.createGraphics().fillRect(0, 0, width, height);
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
|
||||||
for (int y = 0; y < height; y++) {
|
|
||||||
qrImage.setRGB(x, y, bitMatrix.get(x, y) ? 0x000000 : 0xFFFFFF); // Black and white
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
ImageIO.write(qrImage, "PNG", baos);
|
|
||||||
return baos.toByteArray();
|
|
||||||
} catch (WriterException | IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return new byte[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printLabel(BufferedImage bufferedImage) throws Exception {
|
public void printLabel( BufferedImage bufferedImage ) throws Exception {
|
||||||
Connection connection = new TcpConnection(ipAddress, port);
|
Connection connection = new TcpConnection( ipAddress, port );
|
||||||
connection.open();
|
connection.open();
|
||||||
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
|
ZebraPrinter printer = ZebraPrinterFactory.getInstance( connection );
|
||||||
ZebraImage zebraImage = new ZebraImage(bufferedImage);
|
ZebraImage zebraImage = new ZebraImage( bufferedImage );
|
||||||
printer.printImage(zebraImage, 0, 0, 0, 0, false);
|
printer.printImage( zebraImage, 0, 0, 0, 0, false );
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,11 +15,9 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BundleService {
|
public class BundleService {
|
||||||
|
@ -56,35 +54,6 @@ public class BundleService {
|
||||||
return bundles;
|
return bundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* find bundle by id
|
|
||||||
* */
|
|
||||||
public Bundle getBundlesById( long id){
|
|
||||||
return bundleDAO.find(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* find bundle by barcode
|
|
||||||
* */
|
|
||||||
public List<Bundle> getBundles( String barcode){
|
|
||||||
List<Bundle> bundles = new ArrayList<>();
|
|
||||||
List<Bundle> fetchBundle = bundleDAO.findByBarcodeLike( barcode );
|
|
||||||
List<Long> ids = fetchBundle.stream()
|
|
||||||
.map(Bundle::getMasterBundleId)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if(!ids.isEmpty()){
|
|
||||||
List<Long> masterBundles = masterBundleDAO.findByIdAndReceiveIsTrue(ids);
|
|
||||||
bundles = fetchBundle.stream()
|
|
||||||
.filter(e -> masterBundles.contains(e.getMasterBundleId())
|
|
||||||
&& e.getWrapQuantity().compareTo(
|
|
||||||
e.getProduction() != null ? e.getProduction() : BigDecimal.ZERO) != 0)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return bundles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find master bundles by params
|
* find master bundles by params
|
||||||
* */
|
* */
|
||||||
|
@ -125,13 +94,13 @@ public class BundleService {
|
||||||
/*
|
/*
|
||||||
* find finished Items by params
|
* find finished Items by params
|
||||||
* */
|
* */
|
||||||
public List<StitchingOfflineItem> getStitchedOfflineItems(String id, String itemId, String sku,String status, String createdStartDate, String createdEndDate, Long bundleId, Long count ){
|
public List<StitchingOfflineItem> getStitchedOfflineItems(String id, String itemId, String sku, String createdStartDate, String createdEndDate, String jobCardId, Long count ){
|
||||||
List<StitchingOfflineItem> stitchingOfflineItems = new ArrayList<>();
|
List<StitchingOfflineItem> stitchingOfflineItems = new ArrayList<>();
|
||||||
if( count == null ){
|
if( count == null ){
|
||||||
count = 100L;
|
count = 100L;
|
||||||
}
|
}
|
||||||
if( StringUtils.isAnyNotNullOrEmpty(id, itemId, sku, createdStartDate, createdEndDate, String.valueOf(bundleId) ) ){
|
if( StringUtils.isAnyNotNullOrEmpty(id, itemId, sku, createdStartDate, createdEndDate, jobCardId ) ){
|
||||||
String query = StichedOfflineItemQueryBuilder.buildQuery( id, itemId, sku, status,createdStartDate, createdEndDate, bundleId , count );
|
String query = StichedOfflineItemQueryBuilder.buildQuery( id, itemId, sku, createdStartDate, createdEndDate, jobCardId , count );
|
||||||
System.out.println( query );
|
System.out.println( query );
|
||||||
stitchingOfflineItems = stitchingOfflineItemDAO.findByQuery( query );
|
stitchingOfflineItems = stitchingOfflineItemDAO.findByQuery( query );
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,6 +109,7 @@ public class BundleService {
|
||||||
return stitchingOfflineItems;
|
return stitchingOfflineItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.utopiaindustries.service;
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.*;
|
import com.utopiaindustries.dao.ctp.*;
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
import com.utopiaindustries.model.ctp.BundleWrapper;
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -28,9 +27,8 @@ public class InventoryService {
|
||||||
private final MasterBundleDAO masterBundleDAO;
|
private final MasterBundleDAO masterBundleDAO;
|
||||||
private final FinishedItemDAO finishedItemDAO;
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
||||||
private final 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, CutPieceDAO cutPieceDAO, BundleDAO bundleDAO, InventoryTransactionLegDAO inventoryTransactionLegDAO, InventoryTransactionDAO inventoryTransactionDAO, JobCardDAO jobCardDAO, CryptographyService cryptographyService, MasterBundleDAO masterBundleDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO) {
|
||||||
this.jobCardItemDAO = jobCardItemDAO;
|
this.jobCardItemDAO = jobCardItemDAO;
|
||||||
this.cutPieceDAO = cutPieceDAO;
|
this.cutPieceDAO = cutPieceDAO;
|
||||||
this.bundleDAO = bundleDAO;
|
this.bundleDAO = bundleDAO;
|
||||||
|
@ -41,7 +39,6 @@ public class InventoryService {
|
||||||
this.masterBundleDAO = masterBundleDAO;
|
this.masterBundleDAO = masterBundleDAO;
|
||||||
this.finishedItemDAO = finishedItemDAO;
|
this.finishedItemDAO = finishedItemDAO;
|
||||||
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
||||||
this.packagingItemsDAO = packagingItemsDAO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateJobCardInventoryStatus( JobCard card ){
|
private void updateJobCardInventoryStatus( JobCard card ){
|
||||||
|
@ -75,7 +72,6 @@ public class InventoryService {
|
||||||
.collect( Collectors.toMap( JobCardItemWrapper::getJobCardItemId, JobCardItemWrapper::getActualProduction ) );
|
.collect( Collectors.toMap( JobCardItemWrapper::getJobCardItemId, JobCardItemWrapper::getActualProduction ) );
|
||||||
|
|
||||||
List<JobCardItem> items = jobCardItemDAO.findByIds( jobCardItemWrapperIds );
|
List<JobCardItem> items = jobCardItemDAO.findByIds( jobCardItemWrapperIds );
|
||||||
|
|
||||||
if ( items != null && !items.isEmpty( ) ) {
|
if ( items != null && !items.isEmpty( ) ) {
|
||||||
// get job card item ids
|
// get job card item ids
|
||||||
List<Long> jobCardItemIds = items.stream( )
|
List<Long> jobCardItemIds = items.stream( )
|
||||||
|
@ -93,38 +89,16 @@ public class InventoryService {
|
||||||
.collect( Collectors.groupingBy( CutPiece::getJobCardItemId));
|
.collect( Collectors.groupingBy( CutPiece::getJobCardItemId));
|
||||||
|
|
||||||
for ( JobCardItem jobCardItem : items) {
|
for ( JobCardItem jobCardItem : items) {
|
||||||
|
// create + save bundles
|
||||||
int quantity = jobCardItemWrappers.stream()
|
List<Bundle> bundles = createBundles( jobCardItem, piecesMap.get( jobCardItem.getId( ) ) );
|
||||||
.filter(e -> e.getJobCardItemId() == jobCardItem.getId())
|
|
||||||
.mapToInt(JobCardItemWrapper::getPerBundleQuantity)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(0);
|
|
||||||
|
|
||||||
boolean cuttingComplete = jobCardItemWrappers.stream()
|
|
||||||
.filter(e -> e.getJobCardItemId() == jobCardItem.getId())
|
|
||||||
.map(JobCardItemWrapper::getCuttingComplete)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(false);
|
|
||||||
|
|
||||||
BigDecimal production = jobCardItemWrappers.stream()
|
|
||||||
.filter(e -> e.getJobCardItemId() == jobCardItem.getId())
|
|
||||||
.map(JobCardItemWrapper::getActualProduction)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(BigDecimal.ZERO);
|
|
||||||
|
|
||||||
List<Bundle> bundles = createBundles( jobCardItem,quantity,jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) );
|
|
||||||
// create transactions
|
// create transactions
|
||||||
createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( ));
|
createTransactions( bundles, jobCardItem.getAccountId( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ), BigDecimal.ZERO ).add(jobCardItem.getActualProduction()) );
|
jobCardItem.setActualProduction( jobCardItemIdToActualProdMap.getOrDefault( jobCardItem.getId( ) , BigDecimal.ZERO ) );
|
||||||
jobCardItem.setComplete(cuttingComplete);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// update items with quantity
|
// update items with quantity
|
||||||
jobCardItemDAO.saveAll( items );
|
jobCardItemDAO.saveAll( items );
|
||||||
// update job card inv status
|
// update job card inv status
|
||||||
if(jobCardItemDAO.checkAllItemsComplete(jobCardId,jobCardItemIds)) {
|
updateJobCardInventoryStatus( jobCard );
|
||||||
updateJobCardInventoryStatus(jobCard);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException( "Items Not found in Job Card");
|
throw new RuntimeException( "Items Not found in Job Card");
|
||||||
}
|
}
|
||||||
|
@ -176,18 +150,15 @@ public class InventoryService {
|
||||||
inventoryTransactionLeg.setParentDocumentId( artifact.getId( ));
|
inventoryTransactionLeg.setParentDocumentId( artifact.getId( ));
|
||||||
inventoryTransactionLeg.setParentDocumentPieceType( artifact.getType( ));
|
inventoryTransactionLeg.setParentDocumentPieceType( artifact.getType( ));
|
||||||
inventoryTransactionLeg.setTransactionLegDateTime( LocalDateTime.now( ));
|
inventoryTransactionLeg.setTransactionLegDateTime( LocalDateTime.now( ));
|
||||||
inventoryTransactionLeg.setJobCardId(artifact.getJobCardId());
|
|
||||||
// set balance
|
// set balance
|
||||||
BigDecimal initialBalance = calculateBalance( accountId, artifact.getItemId( ), parentDocumentType, artifact.getType( ));
|
BigDecimal initialBalance = calculateBalance( accountId, artifact.getItemId( ), parentDocumentType, artifact.getType( ));
|
||||||
|
|
||||||
if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) {
|
if ( transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.IN.name( ))) {
|
||||||
initialBalance = initialBalance.add( inventoryTransactionLeg.getQuantity( ));
|
initialBalance = initialBalance.add( inventoryTransactionLeg.getQuantity( ));
|
||||||
}else if(transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.OUT.name( ))) {
|
}else if(transactionType.equalsIgnoreCase( InventoryTransactionLeg.Type.OUT.name( )) && inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)){
|
||||||
if (inventoryTransactionLeg.getQuantity().equals(BigDecimal.ZERO)) {
|
initialBalance = BigDecimal.ZERO;
|
||||||
initialBalance = BigDecimal.ZERO;
|
} else {
|
||||||
} else {
|
initialBalance = initialBalance.subtract( inventoryTransactionLeg.getQuantity( ));
|
||||||
initialBalance = initialBalance.subtract(inventoryTransactionLeg.getQuantity());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
inventoryTransactionLeg.setBalance( initialBalance);
|
inventoryTransactionLeg.setBalance( initialBalance);
|
||||||
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
inventoryTransactionLeg.setId( inventoryTransactionLegDAO.save( inventoryTransactionLeg));
|
||||||
|
@ -208,32 +179,27 @@ public class InventoryService {
|
||||||
|
|
||||||
// create bundles from cut pieces
|
// create bundles from cut pieces
|
||||||
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
private List<Bundle> createBundles( JobCardItem jobCardItem,
|
||||||
int perBundleWrap, BigDecimal value ) {
|
List<CutPiece> jobCardItemPieces ) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||||
if ( value != null && !value.equals(BigDecimal.ZERO)) {
|
if ( jobCardItemPieces != null && !jobCardItemPieces.isEmpty( )) {
|
||||||
List<Bundle> bundles = new ArrayList<>( );
|
List<Bundle> bundles = new ArrayList<>( );
|
||||||
int quantity = value.intValue();
|
// create bundle against every cut piece
|
||||||
int batchSize = perBundleWrap;
|
for ( CutPiece cutPiece : jobCardItemPieces ) {
|
||||||
int iterations = (int) Math.ceil((double) quantity / batchSize);
|
Bundle bundle = new Bundle( );
|
||||||
|
bundle.setItemId( jobCardItem.getItemId( ));
|
||||||
for (int i = 0; i < iterations; i++) {
|
bundle.setSku( jobCardItem.getSku( ));
|
||||||
int start = i * batchSize + 1; // Start index
|
bundle.setJobCardId( jobCardItem.getJobCardId( ) );
|
||||||
int end = Math.min((i + 1) * batchSize, quantity); // Last index
|
bundle.setWrapQuantity( cutPiece.getQuantity( ));
|
||||||
int perBundleQuantity = end - start + 1;
|
bundle.setType( cutPiece.getType( ));
|
||||||
Bundle bundle = new Bundle( );
|
bundle.setCreatedAt( LocalDateTime.now( ));
|
||||||
bundle.setItemId( jobCardItem.getItemId( ));
|
bundle.setCreatedBy( authentication.getName( ));
|
||||||
bundle.setSku( jobCardItem.getSku( ));
|
bundles.add( bundle);
|
||||||
bundle.setJobCardId( jobCardItem.getJobCardId( ) );
|
bundle.setId( bundleDAO.save( bundle));
|
||||||
bundle.setWrapQuantity( BigDecimal.valueOf(perBundleQuantity));
|
bundle.setBarcode( cryptographyService.generateRandomString( 15));
|
||||||
bundle.setType( "BUNDLE");
|
// save again after barcode generation
|
||||||
bundle.setCreatedAt( LocalDateTime.now( ));
|
bundle.setId( bundleDAO.save( bundle));
|
||||||
bundle.setCreatedBy( authentication.getName( ));
|
|
||||||
bundles.add( bundle);
|
|
||||||
bundle.setId( bundleDAO.save( bundle));
|
|
||||||
bundle.setBarcode( cryptographyService.generateRandomString( 15));
|
|
||||||
// save again after barcode generation
|
|
||||||
bundle.setId( bundleDAO.save( bundle));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for ( Map.Entry<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
// for ( Map.Entry<JobCardItem, List<CutPiece>> entry : jobCardItemPieces ) {
|
||||||
// JobCardItem key = entry.getKey( );
|
// JobCardItem key = entry.getKey( );
|
||||||
// List<CutPiece> value = entry.getValue( );
|
// List<CutPiece> value = entry.getValue( );
|
||||||
|
@ -277,13 +243,11 @@ public class InventoryService {
|
||||||
long fromAccount = lastInvTransaction.getAccountId( );
|
long fromAccount = lastInvTransaction.getAccountId( );
|
||||||
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
// IN
|
// IN
|
||||||
bundle.setType("BUNDLE");
|
createInventoryTransactionLeg( transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
createInventoryTransactionLeg( transaction, bundle, toAccount, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.STITCH_BUNDLE.name( ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update status
|
// update status
|
||||||
masterBundle.setIsReceived( true);
|
masterBundle.setIsReceived( true);
|
||||||
masterBundle.setAccountId(toAccount);
|
|
||||||
masterBundleDAO.save( masterBundle);
|
masterBundleDAO.save( masterBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,70 +296,73 @@ public class InventoryService {
|
||||||
* create finished items from master bundles
|
* create finished items from master bundles
|
||||||
* */
|
* */
|
||||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
||||||
public void createStitchingOfflineItemsFromJobCard( BundleWrapper wrapper) {
|
public void createStitchingOfflineItemsFromJobCard( JobCard jobCard) {
|
||||||
List<JobCardItem> updatedItems = new ArrayList<>();
|
List<JobCardItem> jobCardItems = jobCard.getItems( );
|
||||||
List<Bundle> updateBundles = new ArrayList<>();
|
List<JobCardItem> updatedItems = new ArrayList<>( );
|
||||||
JobCard jobCard = null;
|
|
||||||
|
|
||||||
//switching table transaction in Transaction Table
|
// validate items
|
||||||
InventoryTransaction transaction = createInventoryTransaction("Against Movement from Stitching to Stitched Offline Item");
|
validateItems( jobCardItems);
|
||||||
inventoryTransactionDAO.save(transaction);
|
// check whether all bundles are received against finish goods
|
||||||
|
checkAllBundleAreReceived( jobCard.getId( ), jobCardItems);
|
||||||
|
for ( JobCardItem item : jobCardItems) {
|
||||||
|
if(item.getTotalProduction() == null){
|
||||||
|
item.setTotalProduction(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
item.setJobCardId(jobCard.getId());
|
||||||
|
// select which has inventory
|
||||||
|
if ( item.getProduction( ).compareTo( BigDecimal.ZERO ) != 0 ) {
|
||||||
|
// production is completed out bundles
|
||||||
|
if ( item.getActualProduction( ).compareTo( item.getTotalProduction( ).add( item.getProduction( ))) == 0) {
|
||||||
|
// create out transactions of bundles in master bundles
|
||||||
|
List<Bundle> bundles = bundleDAO.findByItemIdAndCardId( item.getItemId( ), jobCard.getId( ));
|
||||||
|
if ( bundles != null && !bundles.isEmpty( )) {
|
||||||
|
// bundle ids
|
||||||
|
List<Long> bundleIds = bundles.stream( ).map( Bundle::getId).collect( Collectors.toList( ));
|
||||||
|
|
||||||
//TransactionLeg Transaction
|
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
||||||
List<Long> bundleIds = wrapper.getBundles().stream().map(Bundle::getId).collect(Collectors.toList());
|
.findLastTransactionByParentIdAndParentType( InventoryTransactionLeg.Type.IN.name( ), bundleIds, InventoryArtifactType.BUNDLE.name( ))
|
||||||
Map<Long, InventoryTransactionLeg> lastBundleIdInTransactionMap = inventoryTransactionLegDAO
|
.stream( )
|
||||||
.findLastTransactionByParentIdAndParentType(InventoryTransactionLeg.Type.IN.name(), bundleIds, InventoryArtifactType.STITCH_BUNDLE.name())
|
.collect( Collectors.toMap( InventoryTransactionLeg::getParentDocumentId, Function.identity( )));
|
||||||
.stream()
|
// create Transaction
|
||||||
.collect(Collectors.toMap(InventoryTransactionLeg::getParentDocumentId, Function.identity()));
|
InventoryTransaction transaction = createInventoryTransaction( "Against Movement from Stitching to Stitched Offline Item");
|
||||||
for (Bundle subBundle : wrapper.getBundles()) {
|
inventoryTransactionDAO.save( transaction);
|
||||||
long accountId = masterBundleDAO.find(subBundle.getMasterBundleId()).getAccountId();
|
// create transaction legs
|
||||||
if(subBundle.getCurrentProduction() != null && subBundle.getCurrentProduction().compareTo(BigDecimal.ZERO) != 0){
|
for ( Bundle bundle : bundles) {
|
||||||
Bundle bundle = bundleDAO.find(subBundle.getId());
|
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault( bundle.getId( ), null);
|
||||||
jobCard = jobCardDAO.find(subBundle.getJobCardId());
|
if ( lastInvTransaction != null) {
|
||||||
long production = (bundle.getProduction() == null) ? 0 : bundle.getProduction().longValue() ;
|
// OUT
|
||||||
long wrapQuantity = bundle.getWrapQuantity().longValue();
|
long fromAccount = lastInvTransaction.getAccountId( );
|
||||||
JobCardItem jobCardItem = jobCardItemDAO.findByCardIdAndItemId(subBundle.getJobCardId(),subBundle.getItemId());
|
createInventoryTransactionLeg( transaction, bundle, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.BUNDLE.name( ));
|
||||||
BigDecimal previousTotalProduction = jobCardItem.getTotalProduction() == null ? BigDecimal.ZERO : jobCardItem.getTotalProduction();
|
}
|
||||||
|
}
|
||||||
InventoryTransactionLeg lastInvTransaction = lastBundleIdInTransactionMap.getOrDefault(subBundle.getId(), null);
|
|
||||||
|
|
||||||
if (lastInvTransaction != null ) {
|
|
||||||
if (wrapQuantity == production + subBundle.getCurrentProduction().longValue()) {
|
|
||||||
// OUT
|
|
||||||
long fromAccount = lastInvTransaction.getAccountId();
|
|
||||||
createInventoryTransactionLeg(transaction, subBundle, accountId, InventoryTransactionLeg.Type.OUT.name(), InventoryArtifactType.STITCH_BUNDLE.name());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create stitchingOfflineItems items
|
// create finished items
|
||||||
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems(subBundle.getCurrentProduction(),jobCardItem,subBundle.getId());
|
List<StitchingOfflineItem> stitchingOfflineItems = createStitchingOfflineItems( item);
|
||||||
// create IN Transactions of Finished Items into account
|
// create IN Transactions of Finished Items into account
|
||||||
createTransactions(stitchingOfflineItems, accountId, InventoryArtifactType.STITCHING_OFFLINE.name());
|
createTransactions( stitchingOfflineItems, jobCard.getToAccountId( ), InventoryArtifactType.STITCHING_OFFLINE.name( ));
|
||||||
|
item.setTotalProduction( item.getTotalProduction( ).add( item.getProduction( )));
|
||||||
jobCardItem.setTotalProduction(previousTotalProduction.add(subBundle.getCurrentProduction()));
|
item.setJobCardId( jobCard.getId( ));
|
||||||
jobCardItem.setJobCardId(jobCard.getId());
|
updatedItems.add( item);
|
||||||
updatedItems.add(jobCardItem);
|
|
||||||
BigDecimal pro = BigDecimal.valueOf(production + subBundle.getCurrentProduction().longValue());
|
|
||||||
bundle.setProduction(pro);
|
|
||||||
bundleDAO.save(bundle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobCardItemDAO.saveAll(updatedItems);
|
// save all
|
||||||
|
jobCardItemDAO.saveAll( updatedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create finished items
|
* create finished items
|
||||||
* */
|
* */
|
||||||
public List<StitchingOfflineItem> createStitchingOfflineItems( BigDecimal totalItem, JobCardItem jobCardItem,long bundleId) {
|
public List<StitchingOfflineItem> createStitchingOfflineItems( JobCardItem jobCardItem) {
|
||||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
||||||
List<StitchingOfflineItem> items = new ArrayList<>( );
|
List<StitchingOfflineItem> items = new ArrayList<>( );
|
||||||
if ( jobCardItem != null) {
|
if ( jobCardItem != null) {
|
||||||
for ( int i = 1; i <= totalItem.intValue( ); i++) {
|
for ( int i = 1; i <= jobCardItem.getProduction( ).intValue( ); i++) {
|
||||||
StitchingOfflineItem stitchingOfflineItem = new StitchingOfflineItem( );
|
StitchingOfflineItem stitchingOfflineItem = new StitchingOfflineItem( );
|
||||||
stitchingOfflineItem.setCreatedAt( LocalDateTime.now( ));
|
stitchingOfflineItem.setCreatedAt( LocalDateTime.now( ));
|
||||||
stitchingOfflineItem.setCreatedBy( authentication.getName( ));
|
stitchingOfflineItem.setCreatedBy( authentication.getName( ));
|
||||||
stitchingOfflineItem.setItemId( jobCardItem.getItemId( ));
|
stitchingOfflineItem.setItemId( jobCardItem.getItemId( ));
|
||||||
stitchingOfflineItem.setSku( jobCardItem.getSku( ));
|
stitchingOfflineItem.setSku( jobCardItem.getSku( ));
|
||||||
stitchingOfflineItem.setBundleId(bundleId);
|
|
||||||
stitchingOfflineItem.setJobCardId( jobCardItem.getJobCardId( ));
|
stitchingOfflineItem.setJobCardId( jobCardItem.getJobCardId( ));
|
||||||
stitchingOfflineItem.setIsQa( false );
|
stitchingOfflineItem.setIsQa( false );
|
||||||
long id = stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
long id = stitchingOfflineItemDAO.save( stitchingOfflineItem);
|
||||||
|
@ -603,93 +570,27 @@ public class InventoryService {
|
||||||
* item is approved and grade is selected then fI is move to grade account
|
* item is approved and grade is selected then fI is move to grade account
|
||||||
*/
|
*/
|
||||||
if ( finishedItem.getQaStatus( ).equalsIgnoreCase( "APPROVED") && finishedItem.getAccountId( ) != 0) {
|
if ( finishedItem.getQaStatus( ).equalsIgnoreCase( "APPROVED") && finishedItem.getAccountId( ) != 0) {
|
||||||
finishedItem.setIsSegregated( true);
|
|
||||||
}
|
|
||||||
updatedItems.add( finishedItem);
|
|
||||||
}
|
|
||||||
// save finish items
|
|
||||||
finishedItemDAO.saveAll( updatedItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Packaging items
|
|
||||||
* */
|
|
||||||
@Transactional( rollbackFor = Exception.class, propagation = Propagation.NESTED )
|
|
||||||
public void createPackagingItemAndTransaction( FinishedItemWrapper wrapper) {
|
|
||||||
if ( wrapper != null && wrapper.getItems( ) != null) {
|
|
||||||
|
|
||||||
List<FinishedItem> items = wrapper.getItems( );
|
|
||||||
List<FinishedItem> updatedItems = new ArrayList<>( );
|
|
||||||
List<PackagingItems> packagingItems = new ArrayList<>( );
|
|
||||||
// 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
|
|
||||||
.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( "APPROVED") && finishedItem.getIsSegregated( )) {
|
|
||||||
// create OUT and IN transactions for FI
|
// create OUT and IN transactions for FI
|
||||||
PackagingItems packagingItems1 = (createPackagingItem(finishedItem));
|
|
||||||
packagingItems1.setId(packagingItemsDAO.save(packagingItems1));
|
|
||||||
if ( lastInvTransaction != null) {
|
if ( lastInvTransaction != null) {
|
||||||
// OUT
|
// OUT
|
||||||
long fromAccount = lastInvTransaction.getAccountId( );
|
long fromAccount = lastInvTransaction.getAccountId( );
|
||||||
createInventoryTransactionLeg( transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
createInventoryTransactionLeg( transaction, finishedItem, fromAccount, InventoryTransactionLeg.Type.OUT.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||||
// IN
|
// IN
|
||||||
createInventoryTransactionLeg( transaction, packagingItems1, 8, InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.PACKAGING.name( ));
|
createInventoryTransactionLeg( transaction, finishedItem, finishedItem.getAccountId( ), InventoryTransactionLeg.Type.IN.name( ), InventoryArtifactType.FINISHED_ITEM.name( ));
|
||||||
}
|
}
|
||||||
finishedItem.setIsSegregated( true);
|
finishedItem.setIsSegregated( true);
|
||||||
packagingItems.add(packagingItems1);
|
|
||||||
}
|
}
|
||||||
updatedItems.add( finishedItem);
|
updatedItems.add( finishedItem);
|
||||||
}
|
}
|
||||||
// save finish items
|
|
||||||
finishedItemDAO.saveAll( updatedItems);
|
finishedItemDAO.saveAll( updatedItems);
|
||||||
System.out.println(packagingItems);
|
// save finish items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find item summary by account
|
* find item summary by account
|
||||||
* */
|
* */
|
||||||
public List<InventorySummary> findItemSummaryByAccountId( long accountId) {
|
public List<InventorySummary> findItemSummaryByAccountId( long accountId) {
|
||||||
return inventoryTransactionLegDAO.findSummaryByAccountId( accountId);
|
return inventoryTransactionLegDAO.findSummaryByAccountId( accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PackagingItems createPackagingItem(FinishedItem finishedItem){
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext( ).getAuthentication( );
|
|
||||||
PackagingItems packagingItems = new PackagingItems();
|
|
||||||
packagingItems.setItemId(finishedItem.getItemId());
|
|
||||||
packagingItems.setAccountId(finishedItem.getAccountId());
|
|
||||||
packagingItems.setFinishedItemId(finishedItem.getId());
|
|
||||||
packagingItems.setJobCardId(finishedItem.getJobCardId());
|
|
||||||
packagingItems.setJobCard(finishedItem.getJobCard());
|
|
||||||
packagingItems.setSku(finishedItem.getSku());
|
|
||||||
packagingItems.setBarcode(finishedItem.getBarcode());
|
|
||||||
packagingItems.setCreatedAt(LocalDateTime.now());
|
|
||||||
packagingItems.setCreatedBy(authentication.getName( ));
|
|
||||||
packagingItems.setIsQa(finishedItem.getIsQa());
|
|
||||||
packagingItems.setIsSegregated(finishedItem.getIsSegregated());
|
|
||||||
packagingItems.setQaStatus(finishedItem.getQaStatus());
|
|
||||||
return packagingItems;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,21 +7,14 @@ import com.utopiaindustries.dao.uind.PurchaseOrderDAO;
|
||||||
import com.utopiaindustries.model.ctp.*;
|
import com.utopiaindustries.model.ctp.*;
|
||||||
import com.utopiaindustries.model.uind.Item;
|
import com.utopiaindustries.model.uind.Item;
|
||||||
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
|
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
|
||||||
import com.utopiaindustries.util.HTMLBuilder;
|
|
||||||
import com.utopiaindustries.util.PDFResponseEntityInputStreamResource;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
import com.utopiaindustries.util.StringUtils;
|
||||||
import com.utopiaindustries.util.URLUtils;
|
|
||||||
import org.springframework.core.io.InputStreamResource;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.ui.Model;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,12 +35,8 @@ public class JobCardService {
|
||||||
private final UserInventoryAccountDAO userInventoryAccountDAO;
|
private final UserInventoryAccountDAO userInventoryAccountDAO;
|
||||||
private final FinishedItemDAO finishedItemDAO;
|
private final FinishedItemDAO finishedItemDAO;
|
||||||
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
private final StitchingOfflineItemDAO stitchingOfflineItemDAO;
|
||||||
private final SkuCutPiecesDAO skuCutPiecesDAO;
|
|
||||||
private final HTMLBuilder htmlBuilder;
|
|
||||||
private PDFResponseEntityInputStreamResource pdfGenerator;
|
|
||||||
|
|
||||||
public JobCardService(JobCardDAO jobCardDAO, CutPieceTypeDAO cutPieceTypeDAO, JobCardItemDAO jobCardItemDAO, CutPieceDAO cutPieceDAO, ItemDAO itemDAO, LocationSiteDAO locationSiteDAO, PurchaseOrderDAO purchaseOrderDAO, UserInventoryAccountDAO userInventoryAccountDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO, SkuCutPiecesDAO skuCutPiecesDAO, HTMLBuilder htmlBuilder, PDFResponseEntityInputStreamResource pdfGenerator) {
|
public JobCardService(JobCardDAO jobCardDAO, CutPieceTypeDAO cutPieceTypeDAO, JobCardItemDAO jobCardItemDAO, CutPieceDAO cutPieceDAO, ItemDAO itemDAO, LocationSiteDAO locationSiteDAO, PurchaseOrderDAO purchaseOrderDAO, UserInventoryAccountDAO userInventoryAccountDAO, FinishedItemDAO finishedItemDAO, StitchingOfflineItemDAO stitchingOfflineItemDAO) {
|
||||||
this.skuCutPiecesDAO = skuCutPiecesDAO;
|
|
||||||
this.jobCardDAO = jobCardDAO;
|
this.jobCardDAO = jobCardDAO;
|
||||||
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
this.cutPieceTypeDAO = cutPieceTypeDAO;
|
||||||
this.jobCardItemDAO = jobCardItemDAO;
|
this.jobCardItemDAO = jobCardItemDAO;
|
||||||
|
@ -58,8 +47,6 @@ public class JobCardService {
|
||||||
this.userInventoryAccountDAO = userInventoryAccountDAO;
|
this.userInventoryAccountDAO = userInventoryAccountDAO;
|
||||||
this.finishedItemDAO = finishedItemDAO;
|
this.finishedItemDAO = finishedItemDAO;
|
||||||
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
this.stitchingOfflineItemDAO = stitchingOfflineItemDAO;
|
||||||
this.htmlBuilder = htmlBuilder;
|
|
||||||
this.pdfGenerator = pdfGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -151,13 +138,6 @@ public class JobCardService {
|
||||||
long itemId = jobCardItemDAO.save(item);
|
long itemId = jobCardItemDAO.save(item);
|
||||||
for (CutPiece cutPiece : item.getCutPieces()) {
|
for (CutPiece cutPiece : item.getCutPieces()) {
|
||||||
cutPiece.setJobCardItemId(itemId);
|
cutPiece.setJobCardItemId(itemId);
|
||||||
if (!skuCutPiecesDAO.doesExist(cutPiece.getType(), item.getSku())){
|
|
||||||
SkuCutPieces skuCutPieces = new SkuCutPieces();
|
|
||||||
skuCutPieces.setType(cutPiece.getType());
|
|
||||||
skuCutPieces.setSku(item.getSku());
|
|
||||||
//save cut-piece for sku next time fetch
|
|
||||||
skuCutPiecesDAO.save(skuCutPieces);
|
|
||||||
}
|
|
||||||
cutPieces.add(cutPiece);
|
cutPieces.add(cutPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +175,7 @@ public class JobCardService {
|
||||||
.collect( Collectors.toList() );
|
.collect( Collectors.toList() );
|
||||||
|
|
||||||
// get items has account ids and has actual production not filled
|
// get items has account ids and has actual production not filled
|
||||||
List<JobCardItem> items = jobCardItemDAO.findByJobCardAndAccountIdsAndIsReceived( id ,accountIds );
|
List<JobCardItem> items = jobCardItemDAO.findByJobCardAndAccountIdsAndIsReceived( id, 0L ,accountIds );
|
||||||
if (items != null && !items.isEmpty()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
// get job card ite ids
|
// get job card ite ids
|
||||||
List<Long> jobCardItemIds = items.stream()
|
List<Long> jobCardItemIds = items.stream()
|
||||||
|
@ -311,29 +291,4 @@ public class JobCardService {
|
||||||
public Map<Long, Long> totalFinishItem(List<Long> itemIds, long jobCardId ){
|
public Map<Long, Long> totalFinishItem(List<Long> itemIds, long jobCardId ){
|
||||||
return finishedItemDAO.findTotalFinishedItems( itemIds, jobCardId );
|
return finishedItemDAO.findTotalFinishedItems( itemIds, jobCardId );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print Job card *
|
|
||||||
* **/
|
|
||||||
public ResponseEntity<InputStreamResource> getJobCardReceivingPdf(long id, Model model ) throws Exception {
|
|
||||||
List<JobCardItem> jobCardItems = findJobCardItemByJobCardId(id);
|
|
||||||
List<Long> jobCardItemIds = jobCardItems.stream()
|
|
||||||
.map(JobCardItem::getItemId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<Long> itemIds = jobCardItems.stream()
|
|
||||||
.map(JobCardItem::getId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
model.addAttribute( "baseUrl", URLUtils.getCurrentBaseUrl() );
|
|
||||||
model.addAttribute( "card", findByID(id));
|
|
||||||
model.addAttribute("jobCardItems", jobCardItems);
|
|
||||||
model.addAttribute("cutPiece", findCutPieceByJobCardItemIds(itemIds));
|
|
||||||
model.addAttribute("totalFinishItem", totalFinishItem(jobCardItemIds, id));
|
|
||||||
model.addAttribute("totalStitchingItem", totalStitchingItem(jobCardItemIds, id));
|
|
||||||
// html str
|
|
||||||
String htmlStr = htmlBuilder.buildHTML( "job-card-view-pdf", model );
|
|
||||||
// return pdf
|
|
||||||
return pdfGenerator.generatePdf( htmlStr, "Job-Card", "inline" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.utopiaindustries.service;
|
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.PackagingItemsDAO;
|
|
||||||
import com.utopiaindustries.model.ctp.FinishedItemWrapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class PackagingService {
|
|
||||||
|
|
||||||
private final InventoryService inventoryService;
|
|
||||||
private final PackagingItemsDAO packagingItemsDAO;
|
|
||||||
|
|
||||||
public PackagingService(InventoryService inventoryService, PackagingItemsDAO packagingItemsDAO) {
|
|
||||||
this.inventoryService = inventoryService;
|
|
||||||
this.packagingItemsDAO = packagingItemsDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createPackagingItem(FinishedItemWrapper wrapper){
|
|
||||||
inventoryService.createPackagingItemAndTransaction(wrapper);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package com.utopiaindustries.service;
|
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.PurchaseOrderCTPDao;
|
|
||||||
import com.utopiaindustries.model.ctp.*;
|
|
||||||
import com.utopiaindustries.querybuilder.ctp.JobCardQueryBuilder;
|
|
||||||
import com.utopiaindustries.querybuilder.ctp.PurchaseOrderCTPQueryBuilder;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class PurchaseOrderCTPService {
|
|
||||||
|
|
||||||
private final PurchaseOrderCTPDao purchaseOrderCTPDao;
|
|
||||||
|
|
||||||
public PurchaseOrderCTPService(PurchaseOrderCTPDao purchaseOrderCTPDao) {
|
|
||||||
this.purchaseOrderCTPDao = purchaseOrderCTPDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* search by id
|
|
||||||
* */
|
|
||||||
public PurchaseOrderCTP searchPurchaseOrderById(long id){
|
|
||||||
return purchaseOrderCTPDao.find(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create new job card
|
|
||||||
* */
|
|
||||||
public PurchaseOrderCTP createNewPurchaseOrderCTP() {
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
||||||
PurchaseOrderCTP purchaseOrderCTP = new PurchaseOrderCTP();
|
|
||||||
purchaseOrderCTP.setCreatedBy( authentication.getName() );
|
|
||||||
purchaseOrderCTP.setCreatedAt( LocalDateTime.now() );
|
|
||||||
return purchaseOrderCTP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* save card
|
|
||||||
* */
|
|
||||||
@Transactional( rollbackFor = Exception.class )
|
|
||||||
public void save(PurchaseOrderCTP purchaseOrderCTP) {
|
|
||||||
purchaseOrderCTPDao.save(purchaseOrderCTP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PurchaseOrderCTP> getAllPurchaseOrderCtp(String purchaseOrderCode, String articleName, String StartDate, String EndDate, Long limit) {
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
|
||||||
List<PurchaseOrderCTP> list = new ArrayList<>();
|
|
||||||
String createdBy = authentication.getName();
|
|
||||||
if( limit == null ){
|
|
||||||
limit = 100L;
|
|
||||||
}
|
|
||||||
if( !StringUtils.isAnyNotNullOrEmpty(purchaseOrderCode, articleName) ){
|
|
||||||
for (GrantedAuthority role : authentication.getAuthorities()){
|
|
||||||
if (role.toString().equals("ROLE_ADMIN")){
|
|
||||||
createdBy = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String query = PurchaseOrderCTPQueryBuilder.buildQuery(purchaseOrderCode, articleName, createdBy, StartDate, EndDate, limit );
|
|
||||||
System.out.println( query );
|
|
||||||
list = purchaseOrderCTPDao.findByQuery( query );
|
|
||||||
}else {
|
|
||||||
list = purchaseOrderCTPDao.findByUserAndLimit( authentication.getName(), limit );
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,853 +0,0 @@
|
||||||
package com.utopiaindustries.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.utopiaindustries.dao.ctp.*;
|
|
||||||
import com.utopiaindustries.model.ctp.*;
|
|
||||||
import com.utopiaindustries.querybuilder.ctp.SummaryInventoryReportQueryBuilder;
|
|
||||||
import com.utopiaindustries.util.CTPDateTimeFormat;
|
|
||||||
import com.utopiaindustries.util.StringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
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 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) {
|
|
||||||
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.packagingItemsDAO = packagingItemsDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Integer> getJobCardProgress(String jobCardID) {
|
|
||||||
if (jobCardID == null) {
|
|
||||||
return new LinkedHashMap<>();
|
|
||||||
} else {
|
|
||||||
Map<String, Integer> totalProgress = new HashMap<>();
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
|
|
||||||
BigDecimal totalProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
BigDecimal actualProduction = jobCardItems.stream()
|
|
||||||
.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);
|
|
||||||
|
|
||||||
// Cutting Progress Calculation
|
|
||||||
if (actualProduction.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
totalProgress.put("Cutting Progress", 0);
|
|
||||||
} else if (actualProduction.compareTo(expectedProduction) < 0) {
|
|
||||||
BigDecimal cuttingProgress = actualProduction
|
|
||||||
.divide(expectedProduction, 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
totalProgress.put("Cutting Progress", cuttingProgress.intValue());
|
|
||||||
} else {
|
|
||||||
totalProgress.put("Cutting Progress", 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stitching Progress Calculation
|
|
||||||
if (totalProduction.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
totalProgress.put("Stitching Progress", 0);
|
|
||||||
} else {
|
|
||||||
BigDecimal stitchingProgress = totalProduction
|
|
||||||
.divide(actualProduction, 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
totalProgress.put("Stitching Progress", stitchingProgress.intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// QA Progress Calculation
|
|
||||||
Long qaProgressItems = stitchingOfflineItemDAO.CalculateTotalQA(Long.parseLong(jobCardID));
|
|
||||||
if (qaProgressItems == 0) {
|
|
||||||
totalProgress.put("QA Progress", 0);
|
|
||||||
} else {
|
|
||||||
BigDecimal qaProgress = BigDecimal.valueOf(qaProgressItems)
|
|
||||||
.divide(actualProduction, 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
totalProgress.put("QA Progress", qaProgress.intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finishing Progress Calculation
|
|
||||||
Long totalFinishItem = finishedItemDAO.calculateTotalFinishItem(Long.parseLong(jobCardID));
|
|
||||||
if (totalFinishItem == 0) {
|
|
||||||
totalProgress.put("Finishing Progress", 0);
|
|
||||||
} else {
|
|
||||||
BigDecimal finishItemProgress = BigDecimal.valueOf(totalFinishItem)
|
|
||||||
.divide(actualProduction, 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
totalProgress.put("Finishing Progress", finishItemProgress.intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Job Card Progress Calculation
|
|
||||||
if (totalProduction.compareTo(BigDecimal.ZERO) == 0 && actualProduction.compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
totalProgress.put("Job Card Progress", 0);
|
|
||||||
} else {
|
|
||||||
BigDecimal progressPercentage;
|
|
||||||
if (actualProduction.compareTo(expectedProduction) > 0) {
|
|
||||||
progressPercentage = actualProduction.add(totalProduction)
|
|
||||||
.add(BigDecimal.valueOf(qaProgressItems))
|
|
||||||
.add(BigDecimal.valueOf(totalFinishItem))
|
|
||||||
.divide(actualProduction.multiply(BigDecimal.valueOf(4)), 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
} else {
|
|
||||||
progressPercentage = actualProduction.add(totalProduction)
|
|
||||||
.add(BigDecimal.valueOf(qaProgressItems))
|
|
||||||
.add(BigDecimal.valueOf(totalFinishItem))
|
|
||||||
.divide(expectedProduction.multiply(BigDecimal.valueOf(4)), 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(BigDecimal.valueOf(100));
|
|
||||||
}
|
|
||||||
totalProgress.put("Job Card Progress", progressPercentage.intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sorting Map based on Custom Order
|
|
||||||
Map<String, Integer> indexMap = new HashMap<>();
|
|
||||||
indexMap.put("Cutting Progress", 1);
|
|
||||||
indexMap.put("Stitching Progress", 2);
|
|
||||||
indexMap.put("QA Progress", 3);
|
|
||||||
indexMap.put("Finishing Progress", 4);
|
|
||||||
indexMap.put("Job Card Progress", 5);
|
|
||||||
|
|
||||||
return totalProgress.entrySet()
|
|
||||||
.stream()
|
|
||||||
.sorted(Comparator.comparingInt(entry -> indexMap.get(entry.getKey())))
|
|
||||||
.collect(LinkedHashMap::new, (m, v) -> m.put(v.getKey(), v.getValue()), Map::putAll);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Integer getTotalProduction(String jobCardID){
|
|
||||||
if (jobCardID == null){
|
|
||||||
return 0;
|
|
||||||
}else {
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
BigDecimal actualProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
return actualProduction.intValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Integer> getCompleteProduction(String jobCardID) {
|
|
||||||
if (jobCardID == null) {
|
|
||||||
return new LinkedHashMap<>();
|
|
||||||
} else {
|
|
||||||
HashMap<String, Integer> totalProgress = new HashMap<>();
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
|
|
||||||
BigDecimal totalProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
BigDecimal actualProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
Long qaProgressItems = stitchingOfflineItemDAO.CalculateTotalQA(Long.parseLong(jobCardID));
|
|
||||||
Long totalFinishItem = finishedItemDAO.calculateTotalFinishItem(Long.parseLong(jobCardID));
|
|
||||||
|
|
||||||
// Get Job card Complete Items
|
|
||||||
Map<String, Integer> jobCardCompleteItems = getSegregateItems(jobCardID);
|
|
||||||
Integer segregateTotalItems = jobCardCompleteItems.values().stream().mapToInt(Integer::intValue).sum();
|
|
||||||
|
|
||||||
// Add values to totalProgress map
|
|
||||||
totalProgress.put("Cutting Progress", actualProduction.intValue());
|
|
||||||
totalProgress.put("Stitching Progress", totalProduction.intValue());
|
|
||||||
totalProgress.put("QA Progress", qaProgressItems.intValue());
|
|
||||||
totalProgress.put("Finishing Progress", totalFinishItem.intValue());
|
|
||||||
totalProgress.put("Job Card Progress", segregateTotalItems);
|
|
||||||
|
|
||||||
//custom order
|
|
||||||
Map<String, Integer> indexMap = new HashMap<>();
|
|
||||||
indexMap.put("Job Card Progress", 1);
|
|
||||||
indexMap.put("Cutting Progress", 2);
|
|
||||||
indexMap.put("Stitching Progress", 3);
|
|
||||||
indexMap.put("Finishing Progress", 4);
|
|
||||||
indexMap.put("QA Progress", 5);
|
|
||||||
|
|
||||||
// Sort the keys based on custom order
|
|
||||||
return totalProgress.entrySet()
|
|
||||||
.stream()
|
|
||||||
.sorted(Comparator.comparingInt(entry -> indexMap.get(entry.getKey())))
|
|
||||||
.collect(LinkedHashMap::new, (m, v) -> m.put(v.getKey(), v.getValue()), Map::putAll);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String,Integer> getSegregateItems(String jobCardID){
|
|
||||||
if (jobCardID == null){
|
|
||||||
return new HashMap<>();
|
|
||||||
}else {
|
|
||||||
HashMap<String,Integer> gradingItems = new HashMap<>();
|
|
||||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.getPackagingAccounts();
|
|
||||||
List<FinishedItem> finishedItems = finishedItemDAO.findByJobCardId(Long.parseLong(jobCardID));
|
|
||||||
List<PackagingItems> packagingItems = packagingItemsDAO.findByJobCardId(Long.parseLong(jobCardID));
|
|
||||||
|
|
||||||
List<Long> finishItemsIds = finishedItems.stream()
|
|
||||||
.map(FinishedItem::getId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<Long> packagingItemsIds = packagingItems.stream()
|
|
||||||
.map(PackagingItems::getId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (finishItemsIds.isEmpty()){
|
|
||||||
gradingItems.put("A GRADE",0);
|
|
||||||
gradingItems.put("B GRADE",0);
|
|
||||||
gradingItems.put("C GRADE",0);
|
|
||||||
return gradingItems;
|
|
||||||
}else {
|
|
||||||
for (InventoryAccount inventoryAccount : inventoryAccounts){
|
|
||||||
if (inventoryAccount.getIsPackaging()){
|
|
||||||
long totalGradingItems = inventoryTransactionLegDAO.CalculateTotalGradingItems(packagingItemsIds,(int) inventoryAccount.getId());
|
|
||||||
gradingItems.put(inventoryAccount.getTitle(), (int) totalGradingItems);
|
|
||||||
}else {
|
|
||||||
long totalGradingItems = inventoryTransactionLegDAO.CalculateTotalGradingItems(finishItemsIds,(int) inventoryAccount.getId());
|
|
||||||
gradingItems.put(inventoryAccount.getTitle(), (int) totalGradingItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gradingItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String,String> getEachPhaseTotalTime(String jobCardID){
|
|
||||||
if (jobCardID == null){
|
|
||||||
return new HashMap<>();
|
|
||||||
}else {
|
|
||||||
HashMap<String,String> phasesTimes = new HashMap<>();
|
|
||||||
JobCard jobCard = jobCardDAO.find(Long.parseLong(jobCardID));
|
|
||||||
Bundle lastBundle = bundleDAO.findLastBundleByCardId(Long.parseLong(jobCardID));
|
|
||||||
|
|
||||||
//Cutting time
|
|
||||||
StringBuilder cuttingTime = generateTime(jobCard.getCreatedAt(),lastBundle.getCreatedAt());
|
|
||||||
phasesTimes.put("Cutting Total Time",cuttingTime.toString());
|
|
||||||
|
|
||||||
//Stitching time
|
|
||||||
List<Long> bundlesIds = bundleDAO.findByCardId(Long.parseLong(jobCardID)).stream().map(Bundle::getId).collect(Collectors.toList());
|
|
||||||
if (!bundlesIds.isEmpty()){
|
|
||||||
InventoryTransactionLeg inventoryTransactionLeg = inventoryTransactionLegDAO.getFirstStitchBundleTime(bundlesIds,"STITCH_BUNDLE");
|
|
||||||
StitchingOfflineItem lastStitchItem = stitchingOfflineItemDAO.getLastStitchItemByCardIdAndTime(Long.parseLong(jobCardID));
|
|
||||||
StringBuilder stitchingTime = generateTime(inventoryTransactionLeg.getTransactionLegDateTime(),lastStitchItem.getCreatedAt());
|
|
||||||
phasesTimes.put("Stitching Total Time",stitchingTime.toString());
|
|
||||||
}else {
|
|
||||||
phasesTimes.put("Stitching Total Time",null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return phasesTimes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String,String> countPendingItemsOnDifferentPhases(String jobCardID){
|
|
||||||
if (jobCardID == null){
|
|
||||||
return new HashMap<>();
|
|
||||||
}else {
|
|
||||||
HashMap<String,String> phasePending = new HashMap<String,String>();
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
BigDecimal totalProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
BigDecimal actualProduction = jobCardItems.stream()
|
|
||||||
.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 {
|
|
||||||
phasePending.put("Stitching Total Time", "Pending");
|
|
||||||
}
|
|
||||||
return phasePending;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Map<String, Object>> getCuttingDetails(String jobCardID) {
|
|
||||||
if (jobCardID == null) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Map<String, Object>> cuttingDetails = new HashMap<>();
|
|
||||||
Map<String, InventoryAccount> cuttingAccount = new HashMap<>();
|
|
||||||
Map<String, String> cuttingPersonName = new HashMap<>();
|
|
||||||
Map<String, LocalDate> cuttingDate = new HashMap<>();
|
|
||||||
|
|
||||||
List<Bundle> bundles = bundleDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
if (bundles.isEmpty()) {
|
|
||||||
return cuttingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Long, Bundle> bundleMap = bundles.stream()
|
|
||||||
.collect(Collectors.toMap(Bundle::getId, Function.identity()));
|
|
||||||
|
|
||||||
List<Long> bundleIds = new ArrayList<>(bundleMap.keySet());
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO
|
|
||||||
.getTransactionByParentIdAndType(bundleIds, "BUNDLE");
|
|
||||||
|
|
||||||
for (InventoryTransactionLeg inventoryTransactionLeg : inventoryTransactionLegs) {
|
|
||||||
Integer accountId = inventoryTransactionLeg.getAccountId();
|
|
||||||
InventoryAccount inventoryAccount = inventoryAccountDAO.find(accountId.longValue());
|
|
||||||
if (inventoryAccount != null) {
|
|
||||||
String accountTitle = inventoryAccount.getTitle();
|
|
||||||
cuttingAccount.put(accountTitle, inventoryAccount);
|
|
||||||
Bundle bundle = bundleMap.get(inventoryTransactionLeg.getParentDocumentId());
|
|
||||||
cuttingPersonName.put(accountTitle, (bundle != null) ? bundle.getCreatedBy() : null);
|
|
||||||
cuttingDate.put(accountTitle,(bundle != null) ? bundle.getCreatedAt().toLocalDate() : null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cuttingDetails.put("accounts", new HashMap<>(cuttingAccount));
|
|
||||||
cuttingDetails.put("personName", new HashMap<>(cuttingPersonName));
|
|
||||||
cuttingDetails.put("date", new HashMap<>(cuttingDate));
|
|
||||||
|
|
||||||
return cuttingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Map<String, Object>> getStitchingDetails(String jobCardID) {
|
|
||||||
if (jobCardID == null) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Map<String, Object>> stitchingDetails = new HashMap<>();
|
|
||||||
Map<String, InventoryAccount> stitchingAccount = new HashMap<>();
|
|
||||||
Map<String, String> stitchingPersonName = new HashMap<>();
|
|
||||||
Map<String, LocalDate> stitchingDate = new HashMap<>();
|
|
||||||
|
|
||||||
List<StitchingOfflineItem> stitchingOfflineItems = stitchingOfflineItemDAO.findByJobCardId(Long.parseLong(jobCardID));
|
|
||||||
if (stitchingOfflineItems.isEmpty()) {
|
|
||||||
return stitchingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Long, StitchingOfflineItem> stitchingOfflineItemMap = stitchingOfflineItems.stream()
|
|
||||||
.collect(Collectors.toMap(StitchingOfflineItem::getId, Function.identity()));
|
|
||||||
|
|
||||||
List<Long> stitchingItemsArray = new ArrayList<>(stitchingOfflineItemMap.keySet());
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO
|
|
||||||
.getTransactionByParentIdAndType(stitchingItemsArray, "STITCHING_OFFLINE");
|
|
||||||
|
|
||||||
for (InventoryTransactionLeg inventoryTransactionLeg : inventoryTransactionLegs) {
|
|
||||||
Integer accountId = inventoryTransactionLeg.getAccountId();
|
|
||||||
InventoryAccount inventoryAccount = inventoryAccountDAO.find(accountId.longValue());
|
|
||||||
if (inventoryAccount != null) {
|
|
||||||
String accountTitle = inventoryAccount.getTitle();
|
|
||||||
stitchingAccount.put(accountTitle, inventoryAccount);
|
|
||||||
StitchingOfflineItem stitchingOfflineItem = stitchingOfflineItemMap.get(inventoryTransactionLeg.getParentDocumentId());
|
|
||||||
stitchingPersonName.put(accountTitle, (stitchingOfflineItem != null) ? stitchingOfflineItem.getCreatedBy() : null);
|
|
||||||
stitchingDate.put(accountTitle,(stitchingOfflineItem != null) ? stitchingOfflineItem.getCreatedAt().toLocalDate() : null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stitchingDetails.put("accounts", new HashMap<>(stitchingAccount));
|
|
||||||
stitchingDetails.put("personName", new HashMap<>(stitchingPersonName));
|
|
||||||
stitchingDetails.put("date", new HashMap<>(stitchingDate));
|
|
||||||
|
|
||||||
return stitchingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Map<String, List<?>> getPhasesProgressDayWise(String jobCardID) {
|
|
||||||
if (jobCardID == null) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findByParentEntityTypeAndParentId("PROCESS",6L);
|
|
||||||
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(Long.parseLong(jobCardID));
|
|
||||||
BigDecimal actualProduction = jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getActualProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
LocalDateTime startDate = jobCardDAO.find(Long.parseLong(jobCardID)).getCreatedAt();
|
|
||||||
HashMap<String, List<?>> barChartData = new HashMap<>();
|
|
||||||
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO
|
|
||||||
.getTransactionByJobCardAndDatesAndType(Long.parseLong(jobCardID), startDate.toString(), LocalDateTime.now().toString(), "IN");
|
|
||||||
|
|
||||||
//remove quality multiple transaction entry approved/rejects
|
|
||||||
List<InventoryTransactionLeg> filteredTransactions = inventoryTransactionLegs.stream()
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
leg -> leg.getAccountId() + "-" + leg.getParentDocumentType() + "-" + leg.getParentDocumentId(),
|
|
||||||
leg -> leg, // Value
|
|
||||||
(existing, replacement) -> existing.getTransactionLegDateTime().isBefore(replacement.getTransactionLegDateTime()) ? existing : replacement // Keep Oldest
|
|
||||||
))
|
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
||||||
|
|
||||||
List<String> uniqueDates = inventoryTransactionLegs.stream()
|
|
||||||
.map(leg -> leg.getTransactionLegDateTime().toLocalDate().format(formatter))
|
|
||||||
.distinct()
|
|
||||||
.sorted()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Map<String, Integer> dateIndexMap = new HashMap<>();
|
|
||||||
for (int i = 0; i < uniqueDates.size(); i++) {
|
|
||||||
dateIndexMap.put(uniqueDates.get(i), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Integer> cuttingList = new ArrayList<>(Collections.nCopies(uniqueDates.size(), 0));
|
|
||||||
List<Integer> stitchingList = new ArrayList<>(Collections.nCopies(uniqueDates.size(), 0));
|
|
||||||
List<Integer> qualityList = new ArrayList<>(Collections.nCopies(uniqueDates.size(), 0));
|
|
||||||
List<Integer> finishItems = new ArrayList<>(Collections.nCopies(uniqueDates.size(), 0));
|
|
||||||
|
|
||||||
for (InventoryTransactionLeg leg : filteredTransactions) {
|
|
||||||
String dateKey = leg.getTransactionLegDateTime().format(formatter);
|
|
||||||
int index = dateIndexMap.get(dateKey);
|
|
||||||
if ("BUNDLE".equals(leg.getParentDocumentType())) {
|
|
||||||
Bundle bundle = bundleDAO.find(leg.getParentDocumentId());
|
|
||||||
cuttingList.set(index, cuttingList.get(index) + bundle.getWrapQuantity().intValue());
|
|
||||||
}
|
|
||||||
else if ("STITCHING_OFFLINE".equals(leg.getParentDocumentType())) {
|
|
||||||
stitchingList.set(index, stitchingList.get(index) + leg.getQuantity().intValue());
|
|
||||||
}
|
|
||||||
else if ("FINISHED_ITEM".equals(leg.getParentDocumentType()) && (leg.getAccountId().equals(7) || leg.getAccountId().equals(12))) {
|
|
||||||
if (index == 0 || !dateIndexMap.containsKey(dateKey)) {
|
|
||||||
qualityList.set(index, 0);
|
|
||||||
}
|
|
||||||
qualityList.set(index, qualityList.get(index) + leg.getQuantity().intValue());
|
|
||||||
}
|
|
||||||
else if ("PACKAGING".equals(leg.getParentDocumentType()) && inventoryAccounts.stream().anyMatch(e -> e.getId() == leg.getAccountId().longValue())) {
|
|
||||||
if (index == 0 || !dateIndexMap.containsKey(dateKey)) {
|
|
||||||
finishItems.set(index, 0);
|
|
||||||
}
|
|
||||||
finishItems.set(index, finishItems.get(index) + leg.getQuantity().intValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
barChartData.put("dates", uniqueDates);
|
|
||||||
barChartData.put("cutting", cuttingList);
|
|
||||||
barChartData.put("stitching", stitchingList);
|
|
||||||
barChartData.put("quality", qualityList);
|
|
||||||
barChartData.put("finishing", finishItems);
|
|
||||||
|
|
||||||
return barChartData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<POsDetails> getAllPOs(String poName) {
|
|
||||||
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()
|
|
||||||
));
|
|
||||||
}else {
|
|
||||||
filterJobCardsByPos = jobCards.stream()
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
JobCard::getPurchaseOrderId,
|
|
||||||
HashMap::new,
|
|
||||||
Collectors.toList()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String,Integer> jobCardCompleteItems = new HashMap<>();
|
|
||||||
for (String pos : filterJobCardsByPos.keySet()) {
|
|
||||||
BigDecimal totalProduction = BigDecimal.ZERO;
|
|
||||||
BigDecimal actualProduction = BigDecimal.ZERO;
|
|
||||||
int poQuantity = 0;
|
|
||||||
String articleName = "";
|
|
||||||
Long qaProgressItems = 0L;
|
|
||||||
Long totalFinishItem = 0L;
|
|
||||||
POsDetails pOsDetails = new POsDetails();
|
|
||||||
for (JobCard jobCard : filterJobCardsByPos.get(pos)) {
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCard.getId());
|
|
||||||
totalProduction = totalProduction.add(jobCardItems.stream()
|
|
||||||
.map(item -> Optional.ofNullable(item.getTotalProduction()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
|
|
||||||
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<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
pOsDetailsList.add(pOsDetails);
|
|
||||||
}
|
|
||||||
return pOsDetailsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, Map<String, Integer>> getAllPoJobCards(String PONumber, 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<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()
|
|
||||||
.map(bundle -> Optional.ofNullable(bundle.getWrapQuantity()).orElse(BigDecimal.ZERO))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
//stitching day wise
|
|
||||||
Integer stitching = stitchingOfflineItems.size();
|
|
||||||
|
|
||||||
//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> 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);
|
|
||||||
|
|
||||||
// Define sorting order
|
|
||||||
Map<String, Integer> indexMap = new HashMap<>();
|
|
||||||
indexMap.put("Job Card Progress", 1);
|
|
||||||
indexMap.put("Cutting Progress", 2);
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Sort items based on indexMap order
|
|
||||||
Map<String, Integer> sortedItems = items.entrySet()
|
|
||||||
.stream()
|
|
||||||
.sorted(Comparator.comparingInt(entry -> indexMap.getOrDefault(entry.getKey(), Integer.MAX_VALUE)))
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
Map.Entry::getKey,
|
|
||||||
Map.Entry::getValue,
|
|
||||||
(oldValue, newValue) -> oldValue,
|
|
||||||
LinkedHashMap::new
|
|
||||||
));
|
|
||||||
|
|
||||||
// Add sorted items to the result map
|
|
||||||
poJobCardItemsProgress.put(jobCard.getCode(), sortedItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
return poJobCardItemsProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getCuttingTableDetails(String jobCardId, String cuttingTableId, String startDate, String endDate) {
|
|
||||||
Map<String, Object> cuttingDetails = new HashMap<>();
|
|
||||||
long jobCardIdTemp = 0L;
|
|
||||||
String startDate1 = null;
|
|
||||||
String endDate1 = null;
|
|
||||||
|
|
||||||
if (!StringUtils.isNullOrEmpty(startDate)) {
|
|
||||||
String formattedStart = CTPDateTimeFormat.getMySQLFormattedDateString(startDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT);
|
|
||||||
String formattedEnd = !StringUtils.isNullOrEmpty(endDate)
|
|
||||||
? CTPDateTimeFormat.getMySQLFormattedDateString(endDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT)
|
|
||||||
: LocalDate.now().toString();
|
|
||||||
|
|
||||||
startDate1 = String.format("'%s 00:00:01'", formattedStart);
|
|
||||||
endDate1 = String.format("'%s 23:59:59'", formattedEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findByParentEntityTypeAndParentId("PROCESS", 1L);
|
|
||||||
List<Long> inventoryAccountIds = inventoryAccounts.stream().map(InventoryAccount::getId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!StringUtils.isNullOrEmpty(jobCardId)) {
|
|
||||||
jobCardIdTemp = Long.parseLong(jobCardId);
|
|
||||||
} else if (!StringUtils.isNullOrEmpty(cuttingTableId)) {
|
|
||||||
inventoryAccountIds = List.of(Long.parseLong(cuttingTableId));
|
|
||||||
}
|
|
||||||
|
|
||||||
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds, null, startDate1, endDate1, "IN","BUNDLE");
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
|
|
||||||
|
|
||||||
Map<String, Integer> dateWiseProduction = new TreeMap<>();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
|
||||||
|
|
||||||
Map<LocalDate, List<Long>> dateWiseJobCardIds = inventoryTransactionLegs.stream()
|
|
||||||
.filter(e -> e.getTransactionLegDateTime() != null && e.getJobCardId() != 0)
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
e -> e.getTransactionLegDateTime().toLocalDate(),
|
|
||||||
Collectors.mapping(InventoryTransactionLeg::getJobCardId, Collectors.toList())
|
|
||||||
));
|
|
||||||
|
|
||||||
for (Map.Entry<LocalDate, List<Long>> entry : dateWiseJobCardIds.entrySet()) {
|
|
||||||
List<Long> jobCardIds = entry.getValue();
|
|
||||||
if (!jobCardIds.isEmpty()) {
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByJobCardIds(jobCardIds);
|
|
||||||
int totalProduction = jobCardItems.stream()
|
|
||||||
.filter(item -> item.getActualProduction() != null)
|
|
||||||
.mapToInt(item -> item.getActualProduction().intValue())
|
|
||||||
.sum();
|
|
||||||
dateWiseProduction.put(entry.getKey().format(formatter), totalProduction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Long> distinctJobCardIds = inventoryTransactionLegs.stream()
|
|
||||||
.map(InventoryTransactionLeg::getJobCardId)
|
|
||||||
.filter(id -> id != 0)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Map<Long, List<CuttingJobCardItemWrapper>> jobCardItemsCuttingDetailsMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (long jobCardIdEntry : distinctJobCardIds) {
|
|
||||||
Long accountId = inventoryTransactionLegs.stream()
|
|
||||||
.filter(e -> e.getJobCardId() == jobCardIdEntry)
|
|
||||||
.map(e -> e.getAccountId().longValue())
|
|
||||||
.findFirst()
|
|
||||||
.orElse(0L);
|
|
||||||
|
|
||||||
JobCard jobCard = jobCardDAO.find(jobCardIdEntry);
|
|
||||||
Bundle bundle = bundleDAO.findByCardId(jobCardIdEntry).stream().findFirst().orElse(new Bundle());
|
|
||||||
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCardIdEntry);
|
|
||||||
|
|
||||||
List<CuttingJobCardItemWrapper> wrappers = jobCardItems.stream().map(item -> {
|
|
||||||
CuttingJobCardItemWrapper wrapper = new CuttingJobCardItemWrapper();
|
|
||||||
wrapper.setArticleName(jobCard.getArticleName());
|
|
||||||
wrapper.setJobCardCode(jobCard.getCode());
|
|
||||||
wrapper.setGsm(item.getGsm());
|
|
||||||
wrapper.setPly(item.getPly());
|
|
||||||
wrapper.setSku(item.getSku());
|
|
||||||
wrapper.setTotal(item.getActualProduction().longValue());
|
|
||||||
wrapper.setWidth(item.getWidth());
|
|
||||||
wrapper.setWtPly(item.getWtPly());
|
|
||||||
wrapper.setComplete(item.isComplete());
|
|
||||||
wrapper.setPoName(jobCard.getPurchaseOrderId());
|
|
||||||
wrapper.setOperatorName(bundle.getCreatedBy());
|
|
||||||
wrapper.setJobCardId(item.getJobCardId());
|
|
||||||
wrapper.setLength(item.getLength());
|
|
||||||
wrapper.setAccountId(accountId);
|
|
||||||
return wrapper;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
jobCardItemsCuttingDetailsMap.computeIfAbsent(accountId, k -> new ArrayList<>()).addAll(wrappers);
|
|
||||||
}
|
|
||||||
|
|
||||||
cuttingDetails.put("Date Wise Cutting", dateWiseProduction);
|
|
||||||
cuttingDetails.put("accountWiseCutting", jobCardItemsCuttingDetailsMap);
|
|
||||||
cuttingDetails.put("cuttingAccount", inventoryAccounts);
|
|
||||||
return cuttingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getStitchingDetails(String jobCardId, String stitchingLine, String startDate, String endDate) {
|
|
||||||
Map<String, Object> stitchingDetails = new HashMap<>();
|
|
||||||
long jobCardIdTemp = 0L;
|
|
||||||
String startDate1 = null;
|
|
||||||
String endDate1 = null;
|
|
||||||
|
|
||||||
if (!StringUtils.isNullOrEmpty(startDate)) {
|
|
||||||
String formattedStart = CTPDateTimeFormat.getMySQLFormattedDateString(startDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT);
|
|
||||||
String formattedEnd = !StringUtils.isNullOrEmpty(endDate)
|
|
||||||
? CTPDateTimeFormat.getMySQLFormattedDateString(endDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT)
|
|
||||||
: LocalDate.now().toString();
|
|
||||||
|
|
||||||
startDate1 = String.format("'%s 00:00:01'", formattedStart);
|
|
||||||
endDate1 = String.format("'%s 23:59:59'", formattedEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findByParentEntityTypeAndParentId("PROCESS", 2L);
|
|
||||||
List<Long> inventoryAccountIds = inventoryAccounts.stream().map(InventoryAccount::getId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!StringUtils.isNullOrEmpty(jobCardId)) {
|
|
||||||
jobCardIdTemp = Long.parseLong(jobCardId);
|
|
||||||
} else if (!StringUtils.isNullOrEmpty(stitchingLine)) {
|
|
||||||
inventoryAccountIds = List.of(Long.parseLong(stitchingLine));
|
|
||||||
}
|
|
||||||
|
|
||||||
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(jobCardIdTemp, inventoryAccountIds,null, startDate1, endDate1, "IN","STITCHING_OFFLINE");
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
|
|
||||||
|
|
||||||
Map<String, Integer> dateWiseProduction = new TreeMap<>();
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
|
||||||
|
|
||||||
Map<LocalDate, List<Long>> dateWiseJobCardIds = inventoryTransactionLegs.stream()
|
|
||||||
.filter(e -> e.getTransactionLegDateTime() != null && e.getJobCardId() != 0)
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
e -> e.getTransactionLegDateTime().toLocalDate(),
|
|
||||||
Collectors.mapping(InventoryTransactionLeg::getJobCardId, Collectors.toList())
|
|
||||||
));
|
|
||||||
|
|
||||||
for (Map.Entry<LocalDate, List<Long>> entry : dateWiseJobCardIds.entrySet()) {
|
|
||||||
LocalDate date = entry.getKey();
|
|
||||||
List<Long> jobCardIds = entry.getValue();
|
|
||||||
|
|
||||||
if (!jobCardIds.isEmpty()) {
|
|
||||||
int totalProduction = inventoryTransactionLegs.stream()
|
|
||||||
.filter(item -> jobCardIds.contains(item.getJobCardId()) &&
|
|
||||||
"STITCHING_OFFLINE".equals(item.getParentDocumentType()) && item.getTransactionLegDateTime().toLocalDate().equals(date))
|
|
||||||
.mapToInt(item -> item.getQuantity().intValue())
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
dateWiseProduction.put(date.format(formatter), totalProduction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Long> distinctJobCardIds = inventoryTransactionLegs.stream()
|
|
||||||
.map(InventoryTransactionLeg::getJobCardId)
|
|
||||||
.filter(id -> id != 0)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Map<Long, List<CuttingJobCardItemWrapper>> jobCardItemsStitchingDetailsMap = new HashMap<>();
|
|
||||||
Map<String, Integer> totalStitchingBasedOnAccountID = new HashMap<>();
|
|
||||||
|
|
||||||
for (long jobCardIdEntry : distinctJobCardIds) {
|
|
||||||
Long accountId = inventoryTransactionLegs.stream()
|
|
||||||
.filter(e -> e.getJobCardId() == jobCardIdEntry)
|
|
||||||
.map(e -> e.getAccountId().longValue())
|
|
||||||
.findFirst()
|
|
||||||
.orElse(0L);
|
|
||||||
|
|
||||||
JobCard jobCard = jobCardDAO.find(jobCardIdEntry);
|
|
||||||
List<StitchingOfflineItem> stitchingOfflineItem = stitchingOfflineItemDAO.findByJobCardId(jobCardIdEntry);
|
|
||||||
|
|
||||||
List<JobCardItem> jobCardItems = jobCardItemDAO.findByCardId(jobCardIdEntry);
|
|
||||||
|
|
||||||
List<CuttingJobCardItemWrapper> wrappers = jobCardItems.stream().map(item -> {
|
|
||||||
CuttingJobCardItemWrapper wrapper = new CuttingJobCardItemWrapper();
|
|
||||||
wrapper.setArticleName(jobCard.getArticleName());
|
|
||||||
wrapper.setJobCardId(jobCard.getId());
|
|
||||||
wrapper.setJobCardCode(jobCard.getCode());
|
|
||||||
wrapper.setSku(item.getSku());
|
|
||||||
wrapper.setPoName(jobCard.getPurchaseOrderId());
|
|
||||||
wrapper.setJobCardId(item.getJobCardId());
|
|
||||||
wrapper.setOperatorName(stitchingOfflineItem.get(0).getCreatedBy());
|
|
||||||
wrapper.setAccountId(accountId);
|
|
||||||
return wrapper;
|
|
||||||
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
totalStitchingBasedOnAccountID.put(jobCard.getId()+stitchingOfflineItem.get(0).getSku(), stitchingOfflineItem.size());
|
|
||||||
jobCardItemsStitchingDetailsMap.computeIfAbsent(accountId, k -> new ArrayList<>()).addAll(wrappers);
|
|
||||||
}
|
|
||||||
|
|
||||||
stitchingDetails.put("totalStitchingBasedOnAccountID", totalStitchingBasedOnAccountID);
|
|
||||||
stitchingDetails.put("jobCardItemsStitchingDetailsMap", jobCardItemsStitchingDetailsMap);
|
|
||||||
stitchingDetails.put("Date Wise Stitching", dateWiseProduction);
|
|
||||||
|
|
||||||
stitchingDetails.put("stitchingAccount", inventoryAccounts);
|
|
||||||
return stitchingDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<StitchingOfflineItem> stitchingItemsTransactions(String jobCardId, String accountId, String sku, String startDate, String endDate) {
|
|
||||||
List<Long> accountID = new ArrayList<>();
|
|
||||||
String startDate1 = null;
|
|
||||||
String endDate1 = null;
|
|
||||||
|
|
||||||
if (!StringUtils.isNullOrEmpty(startDate) && !StringUtils.isNullOrEmpty(accountId) && !StringUtils.isNullOrEmpty(jobCardId)) {
|
|
||||||
String formattedStart = CTPDateTimeFormat.getMySQLFormattedDateString(startDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT);
|
|
||||||
String formattedEnd = !StringUtils.isNullOrEmpty(endDate)
|
|
||||||
? CTPDateTimeFormat.getMySQLFormattedDateString(endDate, CTPDateTimeFormat.HTML5_DATE_INPUT_FORMAT)
|
|
||||||
: LocalDate.now().toString();
|
|
||||||
|
|
||||||
startDate1 = String.format("'%s 00:00:01'", formattedStart);
|
|
||||||
endDate1 = String.format("'%s 23:59:59'", formattedEnd);
|
|
||||||
accountID.add(Long.parseLong(accountId));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String query = SummaryInventoryReportQueryBuilder.cuttingQueryBuild(Long.parseLong(jobCardId), accountID, sku, startDate1, endDate1,"IN","STITCHING_OFFLINE");
|
|
||||||
List<InventoryTransactionLeg> inventoryTransactionLegs = inventoryTransactionLegDAO.findByQuery(query);
|
|
||||||
List<Long> stitchingItemsList = inventoryTransactionLegs.stream()
|
|
||||||
.map(InventoryTransactionLeg::getParentDocumentId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
return stitchingOfflineItemDAO.findByIds(stitchingItemsList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private StringBuilder generateTime(LocalDateTime startDate, LocalDateTime endDate){
|
|
||||||
StringBuilder totalTime = new StringBuilder();
|
|
||||||
if(startDate != null && endDate != null){
|
|
||||||
Duration duration = Duration.between(startDate, endDate);
|
|
||||||
if (duration.toDays() > 0) {
|
|
||||||
totalTime.append(String.format("%d days, ", duration.toDays()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (duration.toHours() % 24 > 0) {
|
|
||||||
totalTime.append(String.format("%d hours, ", duration.toHours() % 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (duration.toMinutes() % 60 > 0) {
|
|
||||||
totalTime.append(String.format("%d minutes ", duration.toMinutes() % 60));
|
|
||||||
}
|
|
||||||
return totalTime;
|
|
||||||
}else return totalTime.append("");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.utopiaindustries.util;
|
|
||||||
|
|
||||||
import com.itextpdf.html2pdf.attach.ITagWorker;
|
|
||||||
import com.itextpdf.html2pdf.attach.ProcessorContext;
|
|
||||||
import com.itextpdf.html2pdf.attach.impl.DefaultTagWorkerFactory;
|
|
||||||
import com.itextpdf.html2pdf.html.TagConstants;
|
|
||||||
import com.itextpdf.styledxmlparser.node.IElementNode;
|
|
||||||
|
|
||||||
public class CustomTagWorkerFactory extends DefaultTagWorkerFactory {
|
|
||||||
public ITagWorker getCustomTagWorker( IElementNode tag, ProcessorContext context) {
|
|
||||||
if ( TagConstants.HTML.equals(tag.name())) {
|
|
||||||
return new ZeroMarginHtmlTagWorker(tag, context);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
package com.utopiaindustries.util;
|
|
||||||
|
|
||||||
import com.utopiaindustries.dialect.CTPDialect;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.ui.ModelMap;
|
|
||||||
import org.thymeleaf.TemplateEngine;
|
|
||||||
import org.thymeleaf.context.Context;
|
|
||||||
import org.thymeleaf.templatemode.TemplateMode;
|
|
||||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
|
||||||
import org.w3c.tidy.Tidy;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class HTMLBuilder {
|
|
||||||
private final String UTF_8 = StandardCharsets.UTF_8.displayName();
|
|
||||||
|
|
||||||
public String buildHTML( String templateName, Model model ) throws Exception {
|
|
||||||
// template resolver
|
|
||||||
ClassLoaderTemplateResolver pdfTemplateResolver = createPDFTemplateResolver();
|
|
||||||
// template engine
|
|
||||||
TemplateEngine templateEngine = new TemplateEngine();
|
|
||||||
templateEngine.setTemplateResolver( pdfTemplateResolver );
|
|
||||||
templateEngine.addDialect( new CTPDialect() );
|
|
||||||
// context
|
|
||||||
Context ctx = configureContext( model );
|
|
||||||
// render the template
|
|
||||||
String renderedHTMLContent = templateEngine.process( templateName, ctx );
|
|
||||||
return convertToXhtml( renderedHTMLContent );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildHTMLMap( String templateName, ModelMap model ) throws Exception {
|
|
||||||
// template resolver
|
|
||||||
ClassLoaderTemplateResolver pdfTemplateResolver = createPDFTemplateResolver();
|
|
||||||
// template engine
|
|
||||||
TemplateEngine templateEngine = new TemplateEngine();
|
|
||||||
templateEngine.setTemplateResolver( pdfTemplateResolver );
|
|
||||||
templateEngine.addDialect( new CTPDialect() );
|
|
||||||
// context
|
|
||||||
Context ctx = configureContextMap( model );
|
|
||||||
// render the template
|
|
||||||
String renderedHTMLContent = templateEngine.process( templateName, ctx );
|
|
||||||
return convertToXhtml( renderedHTMLContent );
|
|
||||||
}
|
|
||||||
|
|
||||||
private String convertToXhtml( String html ) throws UnsupportedEncodingException {
|
|
||||||
Tidy tidy = new Tidy();
|
|
||||||
tidy.setInputEncoding( UTF_8 );
|
|
||||||
tidy.setOutputEncoding( UTF_8 );
|
|
||||||
tidy.setXHTML( true );
|
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream( html.getBytes( UTF_8 ) );
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
tidy.parseDOM( inputStream, outputStream );
|
|
||||||
return outputStream.toString( UTF_8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClassLoaderTemplateResolver createPDFTemplateResolver() {
|
|
||||||
ClassLoaderTemplateResolver pdfTemplateResolver = new ClassLoaderTemplateResolver();
|
|
||||||
pdfTemplateResolver.setPrefix( "/templates/" );
|
|
||||||
pdfTemplateResolver.setTemplateMode( TemplateMode.HTML );
|
|
||||||
pdfTemplateResolver.setSuffix( ".html" );
|
|
||||||
pdfTemplateResolver.setCharacterEncoding( UTF_8 );
|
|
||||||
pdfTemplateResolver.setOrder( 1 );
|
|
||||||
return pdfTemplateResolver;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Context configureContext( Model model ) {
|
|
||||||
Context ctx = new Context();
|
|
||||||
// adding model attributes to context
|
|
||||||
for ( Map.Entry<String, Object> entry: model.asMap().entrySet() ) {
|
|
||||||
ctx.setVariable( entry.getKey(), entry.getValue() );
|
|
||||||
}
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Context configureContextMap( ModelMap model ) {
|
|
||||||
Context ctx = new Context();
|
|
||||||
// adding model attributes to context
|
|
||||||
for ( Map.Entry<String, Object> entry: model.entrySet() ) {
|
|
||||||
ctx.setVariable( entry.getKey(), entry.getValue() );
|
|
||||||
}
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
package com.utopiaindustries.util;
|
|
||||||
|
|
||||||
import com.itextpdf.html2pdf.ConverterProperties;
|
|
||||||
import com.itextpdf.html2pdf.HtmlConverter;
|
|
||||||
import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
|
|
||||||
import com.itextpdf.kernel.geom.PageSize;
|
|
||||||
import com.itextpdf.kernel.geom.Rectangle;
|
|
||||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
|
||||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
|
||||||
import com.itextpdf.layout.Document;
|
|
||||||
import org.springframework.core.io.InputStreamResource;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class PDFResponseEntityInputStreamResource {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* prepare pdf document from html string
|
|
||||||
*/
|
|
||||||
private ResponseEntity<InputStreamResource> createPDFResponseEntityInputStreamResource( String htmlStr, String filename, String method ) throws IOException {
|
|
||||||
// output stream
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
// converter properties
|
|
||||||
ConverterProperties properties = new ConverterProperties();
|
|
||||||
properties.setFontProvider( new DefaultFontProvider( false, false, true ) );
|
|
||||||
// pdf document
|
|
||||||
PdfWriter writer = new PdfWriter( outputStream );
|
|
||||||
//temp Code
|
|
||||||
/* PdfDocument temp = new PdfDocument(writer);
|
|
||||||
Rectangle rectangle3x5 = new Rectangle(216, 360);
|
|
||||||
PageSize pageSize =new PageSize( rectangle3x5 );
|
|
||||||
temp.setDefaultPageSize( pageSize);
|
|
||||||
properties.setTagWorkerFactory( new CustomTagWorkerFactory() );*/
|
|
||||||
//temp code end
|
|
||||||
Document document = HtmlConverter.convertToDocument( htmlStr, writer, properties );
|
|
||||||
document.close();
|
|
||||||
// input stream
|
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream( outputStream.toByteArray() );
|
|
||||||
// content disposition header
|
|
||||||
String headerContentDispositionStr = String.format( "%s; filename=%s.pdf", method, filename.replaceAll( ",", "-" ) );
|
|
||||||
// return response
|
|
||||||
return ResponseEntity
|
|
||||||
.ok()
|
|
||||||
.header( HttpHeaders.CONTENT_DISPOSITION, headerContentDispositionStr )
|
|
||||||
.contentType( MediaType.APPLICATION_PDF )
|
|
||||||
.body( new InputStreamResource( inputStream ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* prepare pdf document from html string
|
|
||||||
*/
|
|
||||||
private ResponseEntity<InputStreamResource> createPDFResponseEntityInvoiceInputStreamResource( String htmlStr, String filename, String method, long height, long width )
|
|
||||||
throws IOException {
|
|
||||||
// output stream
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
// converter properties
|
|
||||||
ConverterProperties properties = new ConverterProperties();
|
|
||||||
properties.setFontProvider( new DefaultFontProvider( false, true, false ) );
|
|
||||||
// pdf document
|
|
||||||
PdfWriter writer = new PdfWriter( outputStream );
|
|
||||||
//Code for invoice slips
|
|
||||||
PdfDocument temp = new PdfDocument( writer );
|
|
||||||
Rectangle rectangle3x5 = new Rectangle( width, height );
|
|
||||||
PageSize pageSize = new PageSize( rectangle3x5 );
|
|
||||||
temp.setDefaultPageSize( pageSize );
|
|
||||||
properties.setTagWorkerFactory( new CustomTagWorkerFactory() );
|
|
||||||
//temp code end
|
|
||||||
Document document = HtmlConverter.convertToDocument( htmlStr, temp, properties );
|
|
||||||
//document.setFontSize( 200.0f );
|
|
||||||
document.close();
|
|
||||||
// input stream
|
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream( outputStream.toByteArray() );
|
|
||||||
// content disposition header
|
|
||||||
String headerContentDispositionStr = String.format( "%s; filename=%s.pdf", method, filename.replaceAll( ",", "-" ) );
|
|
||||||
// return response
|
|
||||||
return ResponseEntity
|
|
||||||
.ok()
|
|
||||||
.header( HttpHeaders.CONTENT_DISPOSITION, headerContentDispositionStr )
|
|
||||||
.contentType( MediaType.APPLICATION_PDF )
|
|
||||||
.body( new InputStreamResource( inputStream ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* with inline as default content disposition "inline"
|
|
||||||
*/
|
|
||||||
public ResponseEntity<InputStreamResource> generatePdf( String htmlStr, String filename ) throws IOException {
|
|
||||||
return this.createPDFResponseEntityInputStreamResource( htmlStr, filename, "inline" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manual content disposition
|
|
||||||
*/
|
|
||||||
public ResponseEntity<InputStreamResource> generatePdf( String htmlStr, String filename, String method ) throws IOException {
|
|
||||||
return this.createPDFResponseEntityInputStreamResource( htmlStr, filename, method );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* manual content disposition
|
|
||||||
*/
|
|
||||||
public ResponseEntity<InputStreamResource> generateInvoicePdf( String htmlStr, String filename, String method, long height, long width ) throws IOException {
|
|
||||||
return this.createPDFResponseEntityInvoiceInputStreamResource( htmlStr, filename, method, height, width );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.utopiaindustries.util;
|
|
||||||
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
public class URLUtils {
|
|
||||||
|
|
||||||
public static String getCurrentBaseUrl() {
|
|
||||||
ServletRequestAttributes sra = ( ServletRequestAttributes ) RequestContextHolder.getRequestAttributes();
|
|
||||||
HttpServletRequest req = sra.getRequest();
|
|
||||||
return req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.utopiaindustries.util;
|
|
||||||
|
|
||||||
import com.itextpdf.html2pdf.attach.ProcessorContext;
|
|
||||||
import com.itextpdf.html2pdf.attach.impl.tags.HtmlTagWorker;
|
|
||||||
import com.itextpdf.layout.Document;
|
|
||||||
import com.itextpdf.styledxmlparser.node.IElementNode;
|
|
||||||
|
|
||||||
public class ZeroMarginHtmlTagWorker extends HtmlTagWorker {
|
|
||||||
public ZeroMarginHtmlTagWorker( IElementNode element, ProcessorContext context) {
|
|
||||||
super(element, context);
|
|
||||||
Document doc = (Document) getElementResult();
|
|
||||||
doc.setMargins(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
spring:
|
spring:
|
||||||
uinddatasource:
|
uinddatasource:
|
||||||
jdbcUrl: jdbc:mysql://utopia-industries-rr.c5qech8o9lgg.us-east-1.rds.amazonaws.com:3306/inventory
|
jdbcUrl: jdbc:mysql://localhost:3306
|
||||||
username: cut-to-pack
|
username: root
|
||||||
password: mAzFAivImnTqKJx4KNJ0
|
password: Utopia01
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
logbackUrl: jdbc:mysql://localhost:3306/uind_logs?serverTimezone=Asia/Karachi
|
||||||
hikari:
|
hikari:
|
||||||
maximum-pool-size: 5
|
maximum-pool-size: 5
|
||||||
minimum-idle: 5
|
minimum-idle: 5
|
||||||
|
@ -12,7 +13,7 @@ spring:
|
||||||
connection-timeout: 30000 # 30 seconds
|
connection-timeout: 30000 # 30 seconds
|
||||||
leak-detection-threshold: 10000
|
leak-detection-threshold: 10000
|
||||||
cosmosdatasource:
|
cosmosdatasource:
|
||||||
jdbcUrl: jdbc:mysql://192.168.90.147:3307
|
jdbcUrl: jdbc:mysql://localhost:3307
|
||||||
username: root
|
username: root
|
||||||
password: Utopia01
|
password: Utopia01
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
@ -32,9 +33,5 @@ spring:
|
||||||
|
|
||||||
ctp:
|
ctp:
|
||||||
printer:
|
printer:
|
||||||
ipAdd: 172.16.53.53
|
ipAdd: 172.16.53.32
|
||||||
port: 9100
|
port: 9100
|
||||||
stitchQRPath: src/main/resources/static/sample_qr_output.pdf
|
|
||||||
bundleIpAdd: 172.16.53.22
|
|
||||||
bundlePort: 9100
|
|
||||||
bundlePath: src/main/resources/static/bundle.pdf
|
|
|
@ -1,11 +1,11 @@
|
||||||
application:
|
application:
|
||||||
title: Cut To Pack Service
|
title: Cut To Pack Service
|
||||||
version: v1.0
|
version: v1.0
|
||||||
name: application-prod
|
name: application-dev
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: @activatedProperties@
|
active: dev
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
chain:
|
chain:
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
*,*:before,*:after{padding:0;margin:0;box-sizing:border-box}body{font-family:"Open Sans",sans-serif;font-size:7pt;font-weight:400;line-height:1.2em;background:#fff !important;color:#111;position:relative;background:rgba(0,0,0,0) !important}body.draft:before,body.draft:after,body.terminated:before,body.terminated:after,body.not-approved:before,body.not-approved:after,body.duplicate:before,body.duplicate:after,body.cancel:before,body.cancel:after{font-size:70pt;font-weight:bold;color:red;text-align:center;display:block;opacity:.6;position:absolute;top:250pt;left:0;transform:rotate(-45deg)}body.duplicate:before,body.duplicate:after{content:"DUPLICATE"}body.cancel:before,body.cancel:after{content:"CANCEL"}body.draft:before,body.draft:after{content:"DRAFT"}body.terminated:before,body.terminated:after{content:"TERMINATED"}body.not-approved:before,body.not-approved:after{content:"NOT APPROVED"}@page{font-family:"Open Sans",sans-serif;font-size:6.65pt;font-style:italic;margin:1.25cm 1.25cm;@bottom-left{content:"Utopia Industries Pvt. Limited"}@bottom-center{content:"Page " counter(page) " of " counter(pages)}@bottom-right{width:126px;height:122px;margin-top:-130px}}h1{font-size:2em}h2{font-size:2.2857142857em}h3{font-size:1.8571428571em}h4{font-size:1.7142857143em}h5{font-size:1.5714285714em}h6{font-size:1.4285714286em}h1,h2,h3,h4,h5,h6{font-family:"Open Sans Condensed",sans-serif;font-weight:700;page-break-after:avoid;page-break-inside:avoid;text-transform:uppercase;margin:1.5em 0 1em}h1.no-margin-top,h2.no-margin-top,h3.no-margin-top,h4.no-margin-top,h5.no-margin-top,h6.no-margin-top{margin-top:0}h1.no-margin-bottom,h2.no-margin-bottom,h3.no-margin-bottom,h4.no-margin-bottom,h5.no-margin-bottom,h6.no-margin-bottom{margin-bottom:0}.text-right{text-align:right}.text-uppercase{text-transform:uppercase}.text-center{text-align:center}.font-monospace{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}b{font-weight:700}img{page-break-inside:avoid;page-break-after:avoid}ul,ol,dl{page-break-before:avoid}table{width:100%;border-collapse:collapse;border:none}table td{border:none}table.bordered,table.bordered td{border:1px solid #111}table.borderless,table.borderless td{border:none;padding:0}.tr-footer{text-transform:uppercase}td{padding:.4285714286em .8571428571em;vertical-align:top}td.spacer{padding:1em 0}.tr-header td{font-family:"Open Sans Condensed",sans-serif;font-size:1em;font-weight:bold;text-transform:uppercase;color:#fff;background:#111}td.pd-0{padding:0}ul,ol{padding:0 1.4285714286em;margin:0}ul{list-style-type:disc}.spacer{width:100%;height:1px;margin:2em 0 1em}.row{overflow:hidden;width:100%}.col{float:left}.col.col-half{width:49.96%}.col.col-half.col-padded:first-child{padding-right:3.5pt}.col.col-half.col-padded:last-child{padding-left:3.5pt}.col.col-two-third{width:66.6666%}.col.col-one-third{width:33.3333%}.col.col-one-third.col-padded{padding-left:3.5pt;padding-right:3.5pt}.col.col-one-third.col-padded:first-child{padding-left:0}.col.col-one-third.col-padded:last-child{padding-right:0}.visitor-photo{text-align:center;width:23%;height:77pt;line-height:77pt;margin-left:5pt;border:1px solid #111}.visitor-photo img{display:inline-block;width:90%;height:auto}/*# sourceMappingURL=print.css.map */
|
|
|
@ -1,43 +0,0 @@
|
||||||
( async function(){
|
|
||||||
|
|
||||||
Vue.prototype.$types = window.ctp.types;
|
|
||||||
Vue.prototype.$accounts = window.ctp.accounts;
|
|
||||||
|
|
||||||
let app = new Vue({
|
|
||||||
el : '#dashboard',
|
|
||||||
data :{
|
|
||||||
jobCard : {}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
getStatus: function() {
|
|
||||||
return `badge-${this.jobCard.status}`;
|
|
||||||
},
|
|
||||||
getInvStatus: function() {
|
|
||||||
return `badge-${this.jobCard.inventoryStatus}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods : {
|
|
||||||
onCardSelect : function ( id, card ) {
|
|
||||||
// $.ajax({
|
|
||||||
// url: `/ctp/rest/job-cards/find/${id}`,
|
|
||||||
// method: 'GET',
|
|
||||||
// contentType: 'application/json',
|
|
||||||
// dataType: 'json',
|
|
||||||
// success: ( data ) => {
|
|
||||||
// this.jobCard = data;
|
|
||||||
// },
|
|
||||||
// error : function ( err ){
|
|
||||||
// alert( err );
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
console.log("hello")
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted : function () {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
})(jQuery);
|
|
|
@ -1,278 +0,0 @@
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
if (typeof Highcharts === "undefined") {
|
|
||||||
console.error("Highcharts library not loaded!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createGaugeChart(progress, color, divId, title, height, width , fontSize, fontYAxis, fontXAxis, fontColor, total, actual, aGrade, bGrade, cGrade) {
|
|
||||||
Highcharts.chart(divId, {
|
|
||||||
chart: {
|
|
||||||
type: 'solidgauge',
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
plotBackgroundColor: null,
|
|
||||||
shadow: false
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
text: title,
|
|
||||||
y: 30
|
|
||||||
},
|
|
||||||
pane: {
|
|
||||||
startAngle: 0,
|
|
||||||
endAngle: 360,
|
|
||||||
y: 0,
|
|
||||||
background: [{
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
shape: "arc",
|
|
||||||
borderWidth: 0,
|
|
||||||
innerRadius: '60%',
|
|
||||||
outerRadius: '100%'
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
min: 0,
|
|
||||||
max: 100,
|
|
||||||
tickPositions: [],
|
|
||||||
lineWidth: 0,
|
|
||||||
minorTickLength: 0,
|
|
||||||
tickWidth: 0,
|
|
||||||
gridLineWidth: 0,
|
|
||||||
stops: [
|
|
||||||
[1, color]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
series: [{
|
|
||||||
name: 'Percentage',
|
|
||||||
data: [progress],
|
|
||||||
dataLabels: {
|
|
||||||
format: '{y}% ',
|
|
||||||
y: fontYAxis,
|
|
||||||
x: fontXAxis,
|
|
||||||
borderWidth: 0,
|
|
||||||
backgroundColor: 'none',
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize + 'px',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
color:fontColor
|
|
||||||
},
|
|
||||||
zIndex: 10
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
pointFormat: title == 'Finishing Progress' ? 'Percentage: ' + progress + '%<br>Total: ' + total + '<br>Completed: ' + actual + '<br>A Grade: ' + aGrade + '<br>B Grade: ' + bGrade + '<br>C Grade: ' + cGrade : 'Percentage: ' + progress + '%<br>Total: ' + total + '<br>Completed:'+actual
|
|
||||||
},
|
|
||||||
color: color,
|
|
||||||
showInLegend: false
|
|
||||||
}],
|
|
||||||
credits: {
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function createBarChart(divId, height, width, title, aHeading, aData, bHeading, bData, cHeading, cData, dHeading, dData, dates, fontSize, maxValue) {
|
|
||||||
if (!document.getElementById(divId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Highcharts.chart(divId, {
|
|
||||||
chart: {
|
|
||||||
type: 'column',
|
|
||||||
height: height,
|
|
||||||
width: width,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
text: title,
|
|
||||||
align: 'center',
|
|
||||||
verticalAlign: 'top',
|
|
||||||
y: 30,
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
categories: dates,
|
|
||||||
labels: {
|
|
||||||
rotation: -45,
|
|
||||||
style: {
|
|
||||||
fontSize: 10-fontSize,
|
|
||||||
fontWeight: 'bold'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
min: 0,
|
|
||||||
max: maxValue,
|
|
||||||
softMax: maxValue,
|
|
||||||
softMin: 0,
|
|
||||||
startOnTick: true,
|
|
||||||
endOnTick: true,
|
|
||||||
title: {
|
|
||||||
text: 'Total Progress',
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
labels: {
|
|
||||||
format: '{value}%'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
scrollbar: {
|
|
||||||
enabled: true
|
|
||||||
},
|
|
||||||
series: [{
|
|
||||||
name: aHeading,
|
|
||||||
data: aData
|
|
||||||
}, {
|
|
||||||
name: bHeading,
|
|
||||||
data: bData
|
|
||||||
}, {
|
|
||||||
name: cHeading,
|
|
||||||
data: cData
|
|
||||||
}, {
|
|
||||||
name: dHeading,
|
|
||||||
data: dData
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createSingleBarChart(divId, height, width, title,Heading, Data, dates, fontSize, maxValue) {
|
|
||||||
if (!document.getElementById(divId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Highcharts.chart(divId, {
|
|
||||||
chart: {
|
|
||||||
type: 'column',
|
|
||||||
height: height,
|
|
||||||
width: width,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
text: title,
|
|
||||||
align: 'center',
|
|
||||||
verticalAlign: 'top',
|
|
||||||
y: 30,
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
categories: dates,
|
|
||||||
labels: {
|
|
||||||
rotation: -45,
|
|
||||||
style: {
|
|
||||||
fontSize: 10-fontSize,
|
|
||||||
fontWeight: 'bold'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
min: 0,
|
|
||||||
max: maxValue,
|
|
||||||
softMax: maxValue,
|
|
||||||
softMin: 0,
|
|
||||||
startOnTick: true,
|
|
||||||
endOnTick: true,
|
|
||||||
title: {
|
|
||||||
text: 'Total Progress',
|
|
||||||
style: {
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
labels: {
|
|
||||||
format: '{value}%'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
itemStyle: {
|
|
||||||
fontSize: 10-fontSize,
|
|
||||||
fontWeight: 'bold'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scrollbar: {
|
|
||||||
enabled: true
|
|
||||||
},
|
|
||||||
series: [{
|
|
||||||
name: Heading,
|
|
||||||
data: Data
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
initializeGauges();
|
|
||||||
function initializeGauges() {
|
|
||||||
|
|
||||||
const gaugeDivs2 = document.querySelectorAll('.gauge-chart2');
|
|
||||||
gaugeDivs2.forEach(function (div) {
|
|
||||||
const progress = div.getAttribute('data-progress');
|
|
||||||
const color = div.getAttribute('data-color');
|
|
||||||
const title = div.getAttribute('data-title');
|
|
||||||
const height = div.getAttribute('data-height');
|
|
||||||
const width = div.getAttribute('data-width');
|
|
||||||
const fontSize = div.getAttribute('data-fontSize');
|
|
||||||
const fontColor = div.getAttribute('data-fontColor');
|
|
||||||
const total = div.getAttribute('data-totalProduction');
|
|
||||||
const actual = div.getAttribute('data-actualProduction');
|
|
||||||
const divId = div.id;
|
|
||||||
console.log(actual)
|
|
||||||
createGaugeChart(parseInt(progress), color, divId, title, height, width, fontSize, -20, 4, fontColor, total, actual);
|
|
||||||
});
|
|
||||||
|
|
||||||
const gaugeDivs = document.querySelectorAll('.gauge-chart');
|
|
||||||
gaugeDivs.forEach(function (div) {
|
|
||||||
const progress = div.getAttribute('data-progress');
|
|
||||||
const color = div.getAttribute('data-color');
|
|
||||||
const title = div.getAttribute('data-title');
|
|
||||||
const height = div.getAttribute('data-height');
|
|
||||||
const width = div.getAttribute('data-width');
|
|
||||||
const fontSize = div.getAttribute('data-fontSize');
|
|
||||||
const fontColor = div.getAttribute('data-fontColor');
|
|
||||||
const total = div.getAttribute('data-totalProduction');
|
|
||||||
const actual = div.getAttribute('data-actualProduction');
|
|
||||||
const aGrade = div.getAttribute('data-aGrade');
|
|
||||||
const bGrade = div.getAttribute('data-bGrade');
|
|
||||||
const cGrade = div.getAttribute('data-cGrade');
|
|
||||||
const divId = div.id;
|
|
||||||
createGaugeChart(parseInt(progress), color, divId, title, height, width, fontSize, -15, 2, fontColor, total, actual, aGrade, bGrade, cGrade);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const barChart = document.querySelectorAll('.barChart');
|
|
||||||
barChart.forEach(function (div) {
|
|
||||||
const title = div.getAttribute('data-title');
|
|
||||||
const height = div.getAttribute('data-height');
|
|
||||||
const width = div.getAttribute('data-width');
|
|
||||||
const fontSize = div.getAttribute('data-fontSize');
|
|
||||||
const maxValue = Number(div.getAttribute('data-totalProduction'));
|
|
||||||
const aHeading = 'Cutting';
|
|
||||||
const aData = JSON.parse(div.getAttribute('data-cutting'));
|
|
||||||
const bHeading='Stitching';
|
|
||||||
const bData =JSON.parse(div.getAttribute('data-stitching'));
|
|
||||||
const cHeading='End Line Quality Checking';
|
|
||||||
const cData =JSON.parse(div.getAttribute('data-quality'));
|
|
||||||
const dHeading="Finish Items";
|
|
||||||
const dData =JSON.parse(div.getAttribute('data-finishing'));
|
|
||||||
const dates = div.getAttribute('data-dates');
|
|
||||||
const datesArray = dates.split(',');
|
|
||||||
const divId = div.id;
|
|
||||||
createBarChart( divId, height, width, title, aHeading, aData, bHeading, bData, cHeading, cData, dHeading, dData, datesArray, fontSize, maxValue);
|
|
||||||
});
|
|
||||||
|
|
||||||
const cuttingBarChart = document.querySelectorAll('.singleBarChart');
|
|
||||||
cuttingBarChart.forEach(function (div) {
|
|
||||||
const title = div.getAttribute('data-title');
|
|
||||||
const height = div.getAttribute('data-height');
|
|
||||||
const width = div.getAttribute('data-width');
|
|
||||||
const fontSize = div.getAttribute('data-fontSize');
|
|
||||||
const maxValue = Number(div.getAttribute('data-totalProduction'));
|
|
||||||
const Heading = div.getAttribute('data-barHeading');
|
|
||||||
const Data = JSON.parse(div.getAttribute('data-barData'));
|
|
||||||
const dates = div.getAttribute('data-dates');
|
|
||||||
const datesArray = dates.split(',');
|
|
||||||
const divId = div.id;
|
|
||||||
createSingleBarChart( divId, height, width, title, Heading, Data, datesArray, fontSize, maxValue);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,91 +0,0 @@
|
||||||
(async function () {
|
|
||||||
|
|
||||||
Vue.component('bundle-table', {
|
|
||||||
props: ['bundles'],
|
|
||||||
methods: {
|
|
||||||
removeBundle: function (idx) {
|
|
||||||
this.$emit('bundle-remove', idx)
|
|
||||||
},
|
|
||||||
getFormattedDateTime: function (bundle) {
|
|
||||||
if (!!bundle.createdAt) {
|
|
||||||
return bundle.createdAt.split('T')[0] + ' ' + bundle.createdAt.split('T')[1];
|
|
||||||
}
|
|
||||||
return luxon.DateTime.now().toFormat('yyyy-MM-dd HH:mm:ss');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
template: `
|
|
||||||
<table class="table table-bordered bg-white col-sm-8">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Item ID</th>
|
|
||||||
<th>Sku</th>
|
|
||||||
<th>Job Card ID</th>
|
|
||||||
<th>Wrap Quantity</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Action</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(bundle,index) in bundles">
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].id'" v-bind:value="bundle.id" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].itemId'" v-bind:value="bundle.itemId" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].sku'" v-bind:value="bundle.sku" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].masterBundleId'" v-bind:value="bundle.masterBundleId" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].jobCardId'" v-bind:value="bundle.jobCardId" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].wrapQuantity'" v-bind:value="bundle.wrapQuantity" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].type'" v-bind:value="bundle.type" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].barcode'" v-bind:value="bundle.barcode" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(bundle.createdAt)" >
|
|
||||||
<input hidden="hidden" v-bind:name="'bundles[' + index + '].createdBy'" v-bind:value="bundle.createdBy" >
|
|
||||||
<td><span>{{bundle.id}}</span></td>
|
|
||||||
<td><span>{{bundle.itemId}}</span></td>
|
|
||||||
<td><span>{{bundle.sku}}</span></td>
|
|
||||||
<td><span>{{bundle.jobCardId}}</span></td>
|
|
||||||
<td><span>{{bundle.wrapQuantity}}</span></td>
|
|
||||||
<td><span>{{bundle.type}}</span></td>
|
|
||||||
<td>
|
|
||||||
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeBundle(index)">
|
|
||||||
<i class="bi bi-trash"></i>
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
`
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
let app = new Vue({
|
|
||||||
el: "#jobcardsidebar",
|
|
||||||
data: {
|
|
||||||
bundles: [],
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
removeBundle: function (idx) {
|
|
||||||
this.bundles.splice(idx, 1)
|
|
||||||
},
|
|
||||||
onBundleSelect: function (id, bundle) {
|
|
||||||
this.bundles.push(
|
|
||||||
bundle
|
|
||||||
)
|
|
||||||
},
|
|
||||||
hasMultipleItemSelect : function () {
|
|
||||||
const ids = this.bundles.map(item => item.itemId);
|
|
||||||
const uniqueIds = new Set(ids);
|
|
||||||
return uniqueIds.size > 1;
|
|
||||||
},
|
|
||||||
hasDuplicates: function () {
|
|
||||||
const ids = this.bundles.map(item => item.id);
|
|
||||||
const uniqueIds = new Set(ids);
|
|
||||||
return ids.length !== uniqueIds.size;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted: function () {
|
|
||||||
this.bundles = window.ctp.wrapper.bundles;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
})(jQuery);
|
|
|
@ -84,24 +84,6 @@
|
||||||
onItemSelect(itemId, invItem) {
|
onItemSelect(itemId, invItem) {
|
||||||
this.item.itemId = invItem.id;
|
this.item.itemId = invItem.id;
|
||||||
this.item.sku = invItem.sku;
|
this.item.sku = invItem.sku;
|
||||||
},
|
|
||||||
searchCutPieceBySku(sku) {
|
|
||||||
$.ajax({
|
|
||||||
url: `/ctp/rest/cut-pieces?sku=${sku}`,
|
|
||||||
method: 'GET',
|
|
||||||
success: (response) => {
|
|
||||||
this.$set(this.item, 'cutPieces', response);
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.error('Error fetching data:', error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'item.sku': function(newSku, oldSku) {
|
|
||||||
console.log('SKU changed:', newSku);
|
|
||||||
this.searchCutPieceBySku(newSku);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
|
@ -179,6 +161,8 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
@ -193,16 +177,15 @@
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<div class="row mt-1">
|
<div class="row mt-1">
|
||||||
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index + '].jobCardItemId'" v-bind:value="piece.jobCardItemId || 0">
|
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].id'" v-bind:value="piece.id">
|
||||||
|
<input hidden="hidden" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].jobCardItemId'" v-bind:value="piece.jobCardItemId">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<select class="form-control"
|
<select class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].type'" v-model="piece.type" required>
|
||||||
v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].type'"
|
<option value="">Please Select</option>
|
||||||
v-model="piece.type" required>
|
<option v-for="(type,index) in $types"
|
||||||
<option value="">Please Select</option>
|
v-bind:selected="type.title === piece.type"
|
||||||
<option v-for="(title, index) in $types"
|
v-bind:value="type.title">{{type.title}}</option>
|
||||||
v-bind:selected="title.type === piece.type"
|
</select>
|
||||||
v-bind:value="title.type">{{ title.type }}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<input type="number" class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].quantity'" v-model="piece.quantity" required>
|
<input type="number" class="form-control" v-bind:name="'items[' + pIndex + '].cutPieces[' + index +'].quantity'" v-model="piece.quantity" required>
|
||||||
|
@ -212,8 +195,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let app = new Vue({
|
let app = new Vue({
|
||||||
el: '#jobCardApp',
|
el: '#jobCardApp',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
( async function(){
|
|
||||||
|
|
||||||
Vue.prototype.$accounts = window.ctp.accounts;
|
|
||||||
|
|
||||||
Vue.component('finish-item-table',{
|
|
||||||
props : [ 'items' ],
|
|
||||||
methods: {
|
|
||||||
getFormattedDateTime: function (dateTime) {
|
|
||||||
if (!!dateTime) {
|
|
||||||
return dateTime.split('T')[0] + ' ' + dateTime.split('T')[1];
|
|
||||||
}
|
|
||||||
return luxon.DateTime.now().toFormat('yyyy-MM-dd HH:mm:ss');
|
|
||||||
},
|
|
||||||
removeItem: function (index) {
|
|
||||||
this.$emit('remove-item', index)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
template : `
|
|
||||||
<table class="table table-bordered bg-white col-sm-12">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Item ID</th>
|
|
||||||
<th>Sku</th>
|
|
||||||
<th>Created By</th>
|
|
||||||
<th>Created At</th>
|
|
||||||
<th>Job Card ID</th>
|
|
||||||
<th>Barcode</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th>Action</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(item,index) in items">
|
|
||||||
<td>
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].createdBy'" v-bind:value="item.createdBy">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode" >
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].stitchedItemId'" v-bind:value="item.stitchedItemId">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isSegregated'" v-bind:value="item.isSegregated">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].qaStatus'" v-bind:value="item.qaStatus">
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].accountId'" v-bind:value="item.accountId">
|
|
||||||
<span> {{item.id}} </span>
|
|
||||||
</td>
|
|
||||||
<td> {{item.itemId}} </td>
|
|
||||||
<td> {{item.sku}} </td>
|
|
||||||
<td> {{item.createdBy}} </td>
|
|
||||||
<td> {{ getFormattedDateTime( item.createdAt) }} </td>
|
|
||||||
<td> {{item.jobCardId}}</td>
|
|
||||||
<td> {{item.barcode}} </td>
|
|
||||||
<td > {{item.qaStatus}} </td>
|
|
||||||
<td>
|
|
||||||
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
|
|
||||||
<i class="bi bi-trash"></i>
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
`,
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
let app = new Vue({
|
|
||||||
el : '#packagingApp',
|
|
||||||
data : {
|
|
||||||
items : []
|
|
||||||
},
|
|
||||||
methods : {
|
|
||||||
onItemSelect: function (id, item) {
|
|
||||||
this.items.push(item);
|
|
||||||
},
|
|
||||||
removeItem: function (index) {
|
|
||||||
this.items.splice(index, 1);
|
|
||||||
},
|
|
||||||
hasDuplicates: function () {
|
|
||||||
const ids = this.items.map(item => item.id);
|
|
||||||
const uniqueIds = new Set(ids);
|
|
||||||
return ids.length !== uniqueIds.size;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted : function () {
|
|
||||||
console.log( this.$accounts )
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
})(jQuery)
|
|
File diff suppressed because one or more lines are too long
|
@ -39,7 +39,6 @@
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
<input hidden="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode" >
|
<input hidden="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode" >
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].bundleId'" v-bind:value="item.bundleId" >
|
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
||||||
<span> {{item.id}} </span>
|
<span> {{item.id}} </span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -4,27 +4,23 @@
|
||||||
Vue.prototype.$accounts = window.ctp.accounts;
|
Vue.prototype.$accounts = window.ctp.accounts;
|
||||||
|
|
||||||
Vue.component('item-rows', {
|
Vue.component('item-rows', {
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
wrapQuantity: 0
|
|
||||||
};
|
|
||||||
},
|
|
||||||
props: ['index', 'item'],
|
props: ['index', 'item'],
|
||||||
methods : {
|
methods : {
|
||||||
populateCuttingAccount : function (){
|
populateCuttingAccount : function (){
|
||||||
return this.$accounts.find(account => account.id === this.item.accountId).title;
|
return this.$accounts.find(account => account.id === this.item.accountId).title;
|
||||||
},
|
},
|
||||||
handleValueChange : function(value){
|
|
||||||
this.wrapQuantity = value
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<tr>
|
<tr>
|
||||||
<td width="120">
|
<td width="400">
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId" >
|
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId" >
|
||||||
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardItemId'" v-bind:value="item.id" >
|
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardItemId'" v-bind:value="item.id" >
|
||||||
<span class="form-control" readonly>{{item.id}}</span>
|
<item-search
|
||||||
|
v-bind:id-field-name="'items[' + index + '].itemId'"
|
||||||
|
v-bind:id="item.itemId"
|
||||||
|
v-bind:title="item.title"
|
||||||
|
v-bind:show-label="false"
|
||||||
|
v-bind:disabled="true"></item-search>
|
||||||
</td>
|
</td>
|
||||||
<td width="400">
|
<td width="400">
|
||||||
<span class="form-control" readonly >{{item.sku}}</span>
|
<span class="form-control" readonly >{{item.sku}}</span>
|
||||||
|
@ -40,17 +36,8 @@
|
||||||
<td width="200">
|
<td width="200">
|
||||||
<span class="form-control" readonly>{{item.expectedProduction}}</span>
|
<span class="form-control" readonly>{{item.expectedProduction}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td width="100">
|
|
||||||
<span class="form-control" readonly>{{item.actualProduction}}</span>
|
|
||||||
</td>
|
|
||||||
<td width="200">
|
<td width="200">
|
||||||
<input class="form-control" @input="handleValueChange($event.target.value)" :min="0" type="number" v-bind:name="'items[' + index + '].actualProduction'" required>
|
<input class="form-control" min="0" type="number" v-bind:name="'items[' + index + '].actualProduction'" v-bind:max="item.expectedProduction" required>
|
||||||
</td>
|
|
||||||
<td width="200">
|
|
||||||
<input class="form-control" min="1" :max="wrapQuantity" type="number" v-bind:name="'items[' + index + '].perBundleQuantity'" required>
|
|
||||||
</td>
|
|
||||||
<td width="10" style="text-align: center;" >
|
|
||||||
<input type="checkbox" v-bind:name="'items[' + index + '].cuttingComplete'">
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ populateCuttingAccount() }}
|
{{ populateCuttingAccount() }}
|
||||||
|
@ -77,12 +64,12 @@
|
||||||
<select style="width: 150px;" class="form-control" v-bind:name="'pieces[' + index +'].type'" v-model="piece.type" disabled>
|
<select style="width: 150px;" class="form-control" v-bind:name="'pieces[' + index +'].type'" v-model="piece.type" disabled>
|
||||||
<option value="">Please Select</option>
|
<option value="">Please Select</option>
|
||||||
<option v-for="(type,index) in $types"
|
<option v-for="(type,index) in $types"
|
||||||
v-bind:selected="type.type === piece.type"
|
v-bind:selected="type.title === piece.type"
|
||||||
v-bind:value="type.type">{{type.type}}</option>
|
v-bind:value="type.title">{{type.title}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6" style="padding-left: 40px;">
|
<div class="col-md-6" style="padding-left: 40px;">
|
||||||
<input class="form-control" type="number" v-bind:name="'items[' + pIndex + '].pieces[' + index +'].quantity'" v-model="piece.quantity" min="0" required/>
|
<input class="form-control" type="number" v-bind:name="'items[' + pIndex + '].pieces[' + index +'].quantity'" v-model="piece.quantity" required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
@ -97,15 +84,12 @@
|
||||||
<table class="table table-bordered bg-white w-100">
|
<table class="table table-bordered bg-white w-100">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>Item</th>
|
||||||
<th>Item Sku/Title</th>
|
<th>Item Sku/Title</th>
|
||||||
<th>Cut Pieces</th>
|
<th>Cut Pieces</th>
|
||||||
<th>Expected Production</th>
|
<th>Expected Production</th>
|
||||||
<th>Current Production</th>
|
|
||||||
<th>Actual Production</th>
|
<th>Actual Production</th>
|
||||||
<th>Per Bundle Quantity</th>
|
<th style="width: 312px" >Account</th>
|
||||||
<th>Cutting Complete</th>
|
|
||||||
<th style="width: 312px" >Account</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
onJobCardSelect : function( id, card ){
|
onJobCardSelect : function( id, card ){
|
||||||
this.card = card;
|
this.card = card;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/ctp/rest/job-cards/${id}`,
|
url: `/ctp/rest/job-cards/${id}/items`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -23,25 +23,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
|
||||||
onBundleSelects : function( id, card ){
|
|
||||||
this.card = card;
|
|
||||||
console.log(id);
|
|
||||||
console.log(card);
|
|
||||||
$.ajax({
|
|
||||||
url: `/ctp/rest/bundles/find-bundle-by-id/${id}`,
|
|
||||||
method: 'GET',
|
|
||||||
contentType: 'application/json',
|
|
||||||
dataType: 'json',
|
|
||||||
success: ( data ) =>{
|
|
||||||
console.log(data)
|
|
||||||
this.items.push(data);
|
|
||||||
},
|
|
||||||
error: function (err) {
|
|
||||||
console.log(err)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
mounted : function () {
|
mounted : function () {
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,6 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
v-bind:disabled="disabled"
|
v-bind:disabled="disabled"
|
||||||
v-bind:readonly="readOnly"
|
v-bind:readonly="readOnly"
|
||||||
v-bind:inputmode="inputMode"
|
v-bind:inputmode="inputMode"
|
||||||
autofocus
|
|
||||||
v-bind:class="{ 'is-invalid': ( showInputErrorOnZeroId && ( entityId === 0 || entityId == null ) ) }"
|
v-bind:class="{ 'is-invalid': ( showInputErrorOnZeroId && ( entityId === 0 || entityId == null ) ) }"
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<!-- autocomplete list -->
|
<!-- autocomplete list -->
|
||||||
|
@ -1050,35 +1049,6 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* location site search component
|
|
||||||
*/
|
|
||||||
Vue.component( 'search-job-card-dashBoard', {
|
|
||||||
mixins: [searchComponentMixin],
|
|
||||||
methods: {
|
|
||||||
getSearchUrl: function() {
|
|
||||||
return `/ctp/rest/locations/sites/search?term=${encodeURIComponent( this.list.term )}`;
|
|
||||||
},
|
|
||||||
getEmittedEventName: function() {
|
|
||||||
return 'location-site-select';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
labelText: {
|
|
||||||
default: 'Search Site'
|
|
||||||
},
|
|
||||||
titleFieldName: {
|
|
||||||
default: 'siteTitle'
|
|
||||||
},
|
|
||||||
idFieldName: {
|
|
||||||
default: 'siteId'
|
|
||||||
},
|
|
||||||
codeFieldName: {
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* location site search component
|
* location site search component
|
||||||
|
@ -1180,7 +1150,7 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
}
|
}
|
||||||
// else format item title with code
|
// else format item title with code
|
||||||
if ( typeof item.code !== 'undefined' ) {
|
if ( typeof item.code !== 'undefined' ) {
|
||||||
return `${item.title} (${item.sku}) (${item.code})`;
|
return `${item.title} (${item.code})`;
|
||||||
}
|
}
|
||||||
// item title only
|
// item title only
|
||||||
return item.title;
|
return item.title;
|
||||||
|
@ -3397,87 +3367,6 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bundle search
|
|
||||||
* */
|
|
||||||
Vue.component('bundle-search-by-barcode',{
|
|
||||||
mixins: [searchComponentMixin],
|
|
||||||
methods : {
|
|
||||||
getSearchUrl : function () {
|
|
||||||
let url = `/ctp/rest/bundles/find-bundle-by-barcode?term=${encodeURIComponent( this.list.term )}`
|
|
||||||
return url;
|
|
||||||
},
|
|
||||||
getEmittedEventName: function() {
|
|
||||||
return 'job-card-select';
|
|
||||||
},
|
|
||||||
getTitle: function( card ) {
|
|
||||||
return `(${card.barcode})`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
labelText: {
|
|
||||||
default: 'Search By Bundle'
|
|
||||||
},
|
|
||||||
titleFieldName: {
|
|
||||||
default: 'cardTitle'
|
|
||||||
},
|
|
||||||
idFieldName: {
|
|
||||||
default: 'jobCardId'
|
|
||||||
},
|
|
||||||
codeFieldName : {
|
|
||||||
default : 'jobCardCode'
|
|
||||||
},
|
|
||||||
filter : {
|
|
||||||
default : true
|
|
||||||
},
|
|
||||||
inputMode: {
|
|
||||||
default : 'none'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* job card search for reporting
|
|
||||||
* */
|
|
||||||
Vue.component('job-card-for-reporting',{
|
|
||||||
mixins: [searchComponentMixin],
|
|
||||||
methods : {
|
|
||||||
getSearchUrl : function () {
|
|
||||||
let url = `/ctp/rest/job-cards/search?term=${encodeURIComponent(this.list.term)}&filter=false`;
|
|
||||||
if( ! this.filter ){
|
|
||||||
url += '&filter=false'
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
},
|
|
||||||
getEmittedEventName: function() {
|
|
||||||
return 'job-card-select';
|
|
||||||
},
|
|
||||||
getTitle: function( card ) {
|
|
||||||
return `(${card.code}) - ${card.createdBy}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
labelText: {
|
|
||||||
default: 'Search Job Card'
|
|
||||||
},
|
|
||||||
titleFieldName: {
|
|
||||||
default: 'cardTitle'
|
|
||||||
},
|
|
||||||
idFieldName: {
|
|
||||||
default: 'jobCardId'
|
|
||||||
},
|
|
||||||
codeFieldName : {
|
|
||||||
default : 'jobCardCode'
|
|
||||||
},
|
|
||||||
filter : {
|
|
||||||
default : true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* job card search
|
* job card search
|
||||||
* */
|
* */
|
||||||
|
@ -3513,6 +3402,9 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
},
|
},
|
||||||
filter : {
|
filter : {
|
||||||
default : true
|
default : true
|
||||||
|
},
|
||||||
|
inputMode: {
|
||||||
|
default : 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -3593,75 +3485,43 @@ if ( typeof Vue !== 'undefined' ) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Vue.component('search-item', {
|
/*
|
||||||
props: {
|
* finished item search
|
||||||
label: {
|
* */
|
||||||
type: String,
|
Vue.component('finished-item-search',{
|
||||||
default: 'Search Finished Item'
|
mixins: [searchComponentMixin],
|
||||||
|
methods : {
|
||||||
|
getSearchUrl : function () {
|
||||||
|
return `/ctp/rest/finished-items/search?term=${encodeURIComponent( this.list.term )}&is-segregated=${this.isSegregated}`
|
||||||
|
},
|
||||||
|
getEmittedEventName: function() {
|
||||||
|
return 'finished-item-select';
|
||||||
|
},
|
||||||
|
getTitle: function( item ) {
|
||||||
|
return `${item.id} - ( ${item.barcode} )`;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
url: {
|
props: {
|
||||||
type: String,
|
labelText: {
|
||||||
default: ''
|
default: 'Search Finished Item'
|
||||||
},
|
},
|
||||||
isSegregated: {
|
titleFieldName: {
|
||||||
type: Boolean,
|
default: 'title'
|
||||||
default: false
|
},
|
||||||
},
|
idFieldName: {
|
||||||
debounceTime: {
|
default: 'id'
|
||||||
type: Number,
|
},
|
||||||
default: 500
|
codeFieldName : {
|
||||||
}
|
default : 'code'
|
||||||
},
|
},
|
||||||
data() {
|
isSegregated : {
|
||||||
return {
|
default : false
|
||||||
searchTerm: '',
|
},
|
||||||
timeout: null
|
inputMode: {
|
||||||
};
|
default : 'none'
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleInput() {
|
|
||||||
clearTimeout(this.timeout);
|
|
||||||
this.timeout = setTimeout(() => {
|
|
||||||
this.fetchData();
|
|
||||||
}, this.debounceTime);
|
|
||||||
},
|
|
||||||
async fetchData() {
|
|
||||||
if (this.searchTerm.trim() === '') return;
|
|
||||||
try {
|
|
||||||
const response = await fetch(`${this.url}?term=${encodeURIComponent(this.searchTerm)}&is-segregated=${this.isSegregated}`);
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.length > 0) {
|
|
||||||
const selectedItem = data[0];
|
|
||||||
this.$emit('finished-item-select', selectedItem.id, selectedItem);
|
|
||||||
this.searchTerm = `${selectedItem.id} - (${selectedItem.barcode})`;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.searchTerm = '';
|
|
||||||
}, 500);
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.searchTerm = '';
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching search results:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
|
|
||||||
template: `
|
|
||||||
<div class="search-container">
|
|
||||||
<label>{{ label }}</label>
|
|
||||||
<input type="text" class="form-control"
|
|
||||||
v-model="searchTerm"
|
|
||||||
@input="handleInput"
|
|
||||||
placeholder="Scan QR"
|
|
||||||
autocomplete="off"
|
|
||||||
inputmode="none"
|
|
||||||
autofocus>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bundle search component
|
* bundle search component
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
<script th:src="@{/js/vendor/bignumber.min.js}"></script>
|
<script th:src="@{/js/vendor/bignumber.min.js}"></script>
|
||||||
<script th:src="@{/js/vue-components.js}"></script>
|
<script th:src="@{/js/vue-components.js}"></script>
|
||||||
<script th:src="@{/js/utils.js}"></script>
|
<script th:src="@{/js/utils.js}"></script>
|
||||||
<script src="https://code.highcharts.com/highcharts.js"></script>
|
|
||||||
<script src="https://code.highcharts.com/highcharts-more.js"></script>
|
|
||||||
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
|
|
||||||
<title th:text="${#strings.concat(title, ' - CTP')}"></title>
|
<title th:text="${#strings.concat(title, ' - CTP')}"></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -31,10 +28,6 @@
|
||||||
<img th:src="@{/img/utopia-industries-white.svg}" class="page-header__logo" alt="Utopia Industries">
|
<img th:src="@{/img/utopia-industries-white.svg}" class="page-header__logo" alt="Utopia Industries">
|
||||||
</a>
|
</a>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<!-- <li class="nav-item" sec:authorize="hasAnyRole('ROLE_PURCHASE_ORDER', 'ROLE_ADMIN')">-->
|
|
||||||
<!-- <a th:href="@{/purchase-order/}" class="nav-link"-->
|
|
||||||
<!-- th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/purchase-order') ? 'active' : ''}">Purchase Order</a>-->
|
|
||||||
<!-- </li>-->
|
|
||||||
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_JOB_CARD', 'ROLE_ADMIN')">
|
<li class="nav-item" sec:authorize="hasAnyRole('ROLE_JOB_CARD', 'ROLE_ADMIN')">
|
||||||
<a th:href="@{/job-cards/}" class="nav-link"
|
<a th:href="@{/job-cards/}" class="nav-link"
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/job-cards') ? 'active' : ''}">Job Cards</a>
|
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/job-cards') ? 'active' : ''}">Job Cards</a>
|
||||||
|
@ -95,16 +88,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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">Cards</a>-->
|
|
||||||
<!-- </li>-->
|
|
||||||
<!-- </ul>-->
|
|
||||||
<!-- </nav>-->
|
|
||||||
<!-- second level job cards-->
|
<!-- second level job cards-->
|
||||||
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
||||||
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/job-cards')}">
|
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/job-cards')}">
|
||||||
|
@ -142,32 +125,6 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<!--Second level of reporting-->
|
|
||||||
<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>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item"
|
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/cutting-report') ? 'active' : ''}">
|
|
||||||
<a th:href="@{/reporting/cutting-report}" class="nav-link">Cutting Tables Report</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item"
|
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/stitching-report') ? 'active' : ''}">
|
|
||||||
<a th:href="@{/reporting/stitching-report}" class="nav-link">Stitching Line Report</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item"
|
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/reporting/summary') ? 'active' : ''}">
|
|
||||||
<a th:href="@{/reporting/summary}" class="nav-link">Summary</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
<!-- second level stitching -->
|
<!-- second level stitching -->
|
||||||
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
||||||
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/stitching')}">
|
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/stitching')}">
|
||||||
|
@ -222,10 +179,6 @@
|
||||||
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
<nav class="navbar navbar-light bg-light navbar-expand-lg justify-content-between"
|
||||||
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging')}">
|
th:if="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging')}">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item"
|
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging/receive-inventory') ? 'active' : ''}">
|
|
||||||
<a th:href="@{/packaging/receive-inventory}" class="nav-link">Receive Inventory</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item"
|
<li class="nav-item"
|
||||||
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging/inventory-accounts') ? 'active' : ''}">
|
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/packaging/inventory-accounts') ? 'active' : ''}">
|
||||||
<a th:href="@{/packaging/inventory-accounts}" class="nav-link">Inventory Accounts</a>
|
<a th:href="@{/packaging/inventory-accounts}" class="nav-link">Inventory Accounts</a>
|
||||||
|
|
|
@ -32,20 +32,12 @@
|
||||||
<label>Lot Number</label>
|
<label>Lot Number</label>
|
||||||
<input class="form-control" th:field="*{lotNumber}" required>
|
<input class="form-control" th:field="*{lotNumber}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 form-group">
|
|
||||||
<label>Article Name</label>
|
|
||||||
<input class="form-control" th:field="*{articleName}" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-sm-3 form-group">
|
<div class="col-sm-3 form-group">
|
||||||
<label>Purchase Order</label>
|
<label>Purchase Order</label>
|
||||||
<input type="text" class="form-control" th:field="*{purchaseOrderId}" required>
|
<input type="text" class="form-control" th:field="*{purchaseOrderId}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 form-group">
|
|
||||||
<label>PO Quantity</label>
|
|
||||||
<input type="number" class="form-control" th:field="*{poQuantity}" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3 form-group" th:with="title=*{locationTitle},id=*{locationSiteId}">
|
<div class="col-sm-3 form-group" th:with="title=*{locationTitle},id=*{locationSiteId}">
|
||||||
<location-site-search th:attr="id=${id},title=${title}"
|
<location-site-search th:attr="id=${id},title=${title}"
|
||||||
v-bind:id-field-name="'locationSiteId'">
|
v-bind:id-field-name="'locationSiteId'">
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
<select name="type" class="form-control">
|
<select name="type" class="form-control">
|
||||||
<option value="">Please select</option>
|
<option value="">Please select</option>
|
||||||
<option th:each="type: ${types}"
|
<option th:each="type: ${types}"
|
||||||
th:value="${type.type}"
|
th:value="${type.title}"
|
||||||
th:text="${type.type}"
|
th:text="${type.title}"
|
||||||
th:selected="${#strings.equals(param['type'], #strings.toString(type.type))}"
|
th:selected="${#strings.equals(param['type'], #strings.toString(type.title))}"
|
||||||
></option>
|
></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
||||||
<form th:action="@{/cutting/generate-bundle-barcodes}" method="post">
|
<form th:action="@{/cutting/generate-bundle-barcodes}" method="post">
|
||||||
<input hidden="hidden" name="artifactType" value="Bundle">
|
<input hidden="hidden" name="artifactType" value="Bundle">
|
||||||
<table class="table table-striped" data-table data-order="[[ 0, "desc" ]]">
|
<table class="table table-striped" data-table data-order="[[ 0, "asc" ]]">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<th>Created By</th>
|
<th>Created By</th>
|
||||||
<th>
|
<th>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<button class="btn btn-sm btn-outline-primary" type="submit">Generate Bundle Barcode</button>
|
<button class="btn btn-sm btn-outline-primary" type="submit">Generate Barcode</button>
|
||||||
</div>
|
</div>
|
||||||
<div><input type="checkbox" data-checkbox-all></div>
|
<div><input type="checkbox" data-checkbox-all></div>
|
||||||
</th>
|
</th>
|
||||||
|
|
|
@ -17,11 +17,9 @@
|
||||||
<div class="bg-light p-3 mb-3">
|
<div class="bg-light p-3 mb-3">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<search-item
|
<bundle-search
|
||||||
label="Search Bundle"
|
v-on:bundle-select="onBundleSelect"
|
||||||
url="/ctp/rest/bundles/search"
|
></bundle-search>
|
||||||
v-on:finished-item-select="onBundleSelect">
|
|
||||||
</search-item>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<form th:action="@{/cutting/generate-master-barcodes}" method="post">
|
<form th:action="@{/cutting/generate-master-barcodes}" method="post">
|
||||||
<input hidden="hidden" name="artifactType" value="MasterBundle">
|
<input hidden="hidden" name="artifactType" value="MasterBundle">
|
||||||
<table class="table table-striped table-bordered" data-bundle-table
|
<table class="table table-striped table-bordered" data-bundle-table
|
||||||
data-order="[[ 6, "desc" ]]">
|
data-order="[[ 0, "asc" ]]">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -29,10 +29,9 @@
|
||||||
<th>Sku</th>
|
<th>Sku</th>
|
||||||
<th>Created By</th>
|
<th>Created By</th>
|
||||||
<th>Created At</th>
|
<th>Created At</th>
|
||||||
<th>Received</th>
|
|
||||||
<th>
|
<th>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<button class="btn btn-sm btn-outline-primary" type="submit">Generate Master
|
<button class="btn btn-sm btn-outline-primary" type="submit">Generate
|
||||||
Barcode
|
Barcode
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +51,6 @@
|
||||||
<td th:text="*{sku}"></td>
|
<td th:text="*{sku}"></td>
|
||||||
<td th:text="*{createdBy}"></td>
|
<td th:text="*{createdBy}"></td>
|
||||||
<td ctp:formatdatetime="*{createdAt}"></td>
|
<td ctp:formatdatetime="*{createdAt}"></td>
|
||||||
<td th:text="${bundle.isReceived ? 'YES' : 'NO'}"></td>
|
|
||||||
<td>
|
<td>
|
||||||
<div class="form-group form-check mb-0">
|
<div class="form-group form-check mb-0">
|
||||||
<input class="form-check-input" type="checkbox"
|
<input class="form-check-input" type="checkbox"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<main class="row page-main">
|
<main class="row page-main">
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<div th:replace="_notices :: page-notices"></div>
|
<div th:replace="_notices :: page-notices"></div>
|
||||||
<h3 class="pb-2">Receive Inventory Against Job Card</h3>
|
<h3 class="pb-2">Receive Inventory</h3>
|
||||||
<form th:action="@{/cutting/receive-inventory}"
|
<form th:action="@{/cutting/receive-inventory}"
|
||||||
method="POST"
|
method="POST"
|
||||||
id="receiveInvApp"
|
id="receiveInvApp"
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
v-on:job-card-select="onCardSelect"
|
v-on:job-card-select="onCardSelect"
|
||||||
v-bind:required="true"
|
v-bind:required="true"
|
||||||
></job-card-search>
|
></job-card-search>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="col-sm-3">-->
|
<!-- <div class="col-sm-3">-->
|
||||||
<!-- <label>Cutting Account</label>-->
|
<!-- <label>Cutting Account</label>-->
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
||||||
<form th:action="@{/cutting/generate-barcodes}" method="post">
|
<form th:action="@{/cutting/generate-barcodes}" method="post">
|
||||||
<input hidden="hidden" name="artifactType" value="Bundle">
|
<input hidden="hidden" name="artifactType" value="Bundle">
|
||||||
<table class="table table-striped" data-table data-order="[[ 0, "desc" ]]">
|
<table class="table table-striped" data-table data-order="[[ 0, "asc" ]]">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
<div class="bg-light p-3 mb-3">
|
<div class="bg-light p-3 mb-3">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-sm-3 form-group">
|
<div class="col-sm-3 form-group">
|
||||||
<search-item
|
<finished-item-search
|
||||||
url="/ctp/rest/finished-items/search"
|
v-bind:is-segregated="false"
|
||||||
v-on:finished-item-select="onItemSelect">
|
v-on:finished-item-select="onItemSelect"
|
||||||
</search-item>
|
>
|
||||||
|
</finished-item-search>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 form-group">
|
<div class="col-sm-3 form-group">
|
||||||
<!-- <label>Packaging Account</label>-->
|
<!-- <label>Packaging Account</label>-->
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
|
<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:uind="http://www.w3.org/1999/xhtml" xmlns:ctp="http://www.w3.org/1999/xhtml">
|
|
||||||
<head th:replace="_fragments :: head('Job Cards')"></head>
|
<head th:replace="_fragments :: head('Job Cards')"></head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
@ -61,9 +60,6 @@
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
</a>
|
</a>
|
||||||
</th:block>
|
</th:block>
|
||||||
<a th:href="@{'/job-cards/pdf/' + *{id}}" target="_blank" class="btn btn-sm btn-secondary" title="View PDF">
|
|
||||||
<i class="bi bi-filetype-pdf"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
<?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|}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td width="400">
|
|
||||||
<img width="200" th:src="@{|${baseUrl}/img/utopia-industries.png|}" alt="Utopia Industries">
|
|
||||||
</td>
|
|
||||||
<td >
|
|
||||||
<table class="bordered">
|
|
||||||
<tr class="tr-header">
|
|
||||||
<td colspan="2" th:text="'JOB CARD DETAIL'"></td>
|
|
||||||
</tr>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 40%; border: 1px solid black;"><i>Job Card ID</i></td>
|
|
||||||
<td style="width: 60%; border: 1px solid black;">
|
|
||||||
<a class="text-reset" target="_blank" th:text="${card.getCode()}"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td style="width: 40%; border: 1px solid black;"><i>Job Order ID</i></td>
|
|
||||||
<td style="width: 60%; border: 1px solid black;">
|
|
||||||
<a class="text-reset" target="_blank" th:text="${card.getJobOrderId()}"></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="align-middle" style="border: 1px solid black;"><i>Card Status</i></td>
|
|
||||||
<td style="border: 1px solid black;"><span th:text="${card.getStatus()}"></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="align-middle" style="border: 1px solid black;"><i>Inventory Status</i></td>
|
|
||||||
<td style="border: 1px solid black;"><span th:text="${card.getInventoryStatus()}"></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="align-middle" style="border: 1px solid black;"><i>Customer</i></td>
|
|
||||||
<td style="border: 1px solid black;"><span th:text="${card.getCustomer()}"></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="align-middle" style="border: 1px solid black;"><i>Lot Number</i></td>
|
|
||||||
<td style="border: 1px solid black;"><span th:text="${card.getLotNumber()}"></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="align-middle" style="border: 1px solid black;"><i>Purchase Order ID</i></td>
|
|
||||||
<td style="border: 1px solid black;"><span th:text="${card.getPurchaseOrderId()}"></span></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table class="bordered" style="width: 100%; margin-top: 20px; border-collapse: collapse; ">
|
|
||||||
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 20px;">CUTTING DETAILS</h5>
|
|
||||||
<thead >
|
|
||||||
<tr class="tr-header">
|
|
||||||
<td th:text="'Sku'"></td>
|
|
||||||
<td th:text="'Length'"></td>
|
|
||||||
<td th:text="'Width'"></td>
|
|
||||||
<td th:text="'Gsm'"></td>
|
|
||||||
<td th:text="'WT_Ply'"></td>
|
|
||||||
<td th:text="'Ply'"></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="cardItem : ${jobCardItems}">
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getSku()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getLength()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getWidth()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getGsm()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getWtPly()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getPly()}"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<table class="bordered" style="width: 100%; margin-top: 20px; border-collapse: collapse; ">
|
|
||||||
<h5 class="no-margin-top no-margin-bottom" style="margin-top: 20px;">ITEMS</h5>
|
|
||||||
<thead >
|
|
||||||
<tr class="tr-header">
|
|
||||||
<td th:text="'ID'"></td>
|
|
||||||
<td th:text="'Item ID'"></td>
|
|
||||||
<td th:text="'Sku'"></td>
|
|
||||||
<td th:text="'Expected Production'"></td>
|
|
||||||
<td th:text="'Actual Production'"></td>
|
|
||||||
<td th:text="'Total Production'"></td>
|
|
||||||
<td th:text="'Cut Piece Items'"></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<!-- Table Body -->
|
|
||||||
<tbody>
|
|
||||||
<tr th:each="cardItem : ${jobCardItems}">
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getId()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getItemId()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getSku()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getExpectedProduction()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getActualProduction()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${cardItem.getTotalProduction()}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${totalStitchingItem.get(cardItem.getItemId())}"></td>
|
|
||||||
<td style="border: 1px solid black;" th:text="${totalFinishItem.get(cardItem.getItemId())}"></td>
|
|
||||||
<td style="margin:0px; padding:0px">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -121,7 +121,6 @@
|
||||||
<td>
|
<td>
|
||||||
<span th:if="${cardStitchingItem.getQaStatus() == 'APPROVED'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-APPROVED font-sm"></span>
|
<span th:if="${cardStitchingItem.getQaStatus() == 'APPROVED'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-APPROVED font-sm"></span>
|
||||||
<span th:if="${cardStitchingItem.getQaStatus() == 'REJECT'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-warning font-sm"></span>
|
<span th:if="${cardStitchingItem.getQaStatus() == 'REJECT'}" th:text="${cardStitchingItem.getQaStatus()}" class="badge badge-warning font-sm"></span>
|
||||||
<span th:if="${cardStitchingItem.getQaStatus() == null}" th:text="NOT-PERFORMED" class="badge badge-danger font-sm"></span>
|
|
||||||
</td>
|
</td>
|
||||||
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
<td th:text="${cardStitchingItem.getQaRemarks()}"></td>
|
||||||
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
<td ctp:formatdatetime="${cardStitchingItem.getCreatedAt()}"></td>
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml"
|
|
||||||
xmlns:v-bind="http://www.w3.org/1999/xhtml">
|
|
||||||
<head th:replace="_fragments :: head('Segregate Finished Items')"></head>
|
|
||||||
<body>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
|
||||||
<main class="row page-main">
|
|
||||||
<div class="col-sm">
|
|
||||||
<div class="mb-4 d-flex justify-content-between">
|
|
||||||
<h3>Receive Finished Items</h3>
|
|
||||||
</div>
|
|
||||||
<form th:action="'/ctp/packaging/packaging-items'" method="post" id="packagingApp">
|
|
||||||
<div class="bg-light p-3 mb-3">
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="col-sm-3 form-group">
|
|
||||||
<search-item
|
|
||||||
url="/ctp/rest/finished-items/search-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>-->
|
|
||||||
</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" type="submit" v-bind:disabled="hasDuplicates()">Submit</button>
|
|
||||||
<a th:href="@{/finishing/finished-items}" class="btn btn-light">Cancel</a>
|
|
||||||
</form>
|
|
||||||
<script th:inline="javascript">
|
|
||||||
window.ctp.accounts = [[${accounts}]];
|
|
||||||
</script>
|
|
||||||
<script th:src="@{/js/vendor/compressor.min.js}"></script>
|
|
||||||
<script th:src="@{/js/packaging/packaging-item-form.js}"></script>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,38 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml" xmlns:v-bind="http://www.w3.org/1999/xhtml">
|
|
||||||
<head th:replace="_fragments :: head('Home Page')"></head>
|
|
||||||
<body>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<header class="row page-header" th:replace="_fragments :: page-header"></header>
|
|
||||||
<main class="row page-main">
|
|
||||||
<div class="col-sm" th:fragment="cardFragment">
|
|
||||||
<div th:replace="_notices :: page-notices"></div>
|
|
||||||
<form th:action="@{ ${purchaseOrderCTP.id} ? ('/purchase-order/edit/' + ${purchaseOrderCTP.id}) : '/purchase-order/edit' }"
|
|
||||||
method="POST"
|
|
||||||
th:object="${purchaseOrderCTP}"
|
|
||||||
id="purchaseOrderApp">
|
|
||||||
<input hidden="hidden" th:field="*{id}">
|
|
||||||
<input hidden="hidden" th:field="*{order}">
|
|
||||||
<div class="bg-light p-3 mb-3">
|
|
||||||
<h6 class="mb-3">Info</h6>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="col-sm-3 form-group">
|
|
||||||
<label>Job Order</label>
|
|
||||||
<input type="number" class="form-control" th:field="*{jobOrderId}" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<button class="btn btn-secondary" type="submit" name="user" value="draft" v-bind:disabled="hasEmptyItems()">Save Draft</button>
|
|
||||||
<button class="btn btn-primary" type="submit" name="user" value="post" v-bind:disabled="hasEmptyItems()">Post</button>
|
|
||||||
<a th:href="@{/job-cards}" class="btn btn-light">Cancel</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<div th:replace="_fragments :: page-footer-scripts"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -16,7 +16,7 @@
|
||||||
<h3>Packaging Inventory Accounts</h3>
|
<h3>Packaging Inventory Accounts</h3>
|
||||||
</div>
|
</div>
|
||||||
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
<div th:replace="_fragments :: table-loading-skeleton"></div>
|
||||||
<table class="table table-striped" data-account-table data-order="[[ 0, "desc" ]]">
|
<table class="table table-striped" data-account-table data-order="[[ 0, "asc" ]]">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
|
|
@ -13,13 +13,12 @@
|
||||||
<form th:action="'/ctp/quality-control/qc-finished-item'" method="post" id="qcForm"
|
<form th:action="'/ctp/quality-control/qc-finished-item'" method="post" id="qcForm"
|
||||||
th:object="${wrapper}">
|
th:object="${wrapper}">
|
||||||
<div class="bg-light p-3 mb-3">
|
<div class="bg-light p-3 mb-3">
|
||||||
|
<h6 class="mb-3">Search Stitched Item</h6>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col-sm-3 form-group">
|
<div class="col-sm-3 form-group">
|
||||||
<search-item
|
<stitching-offline-item
|
||||||
label="Search Stitch Item"
|
v-on:stitching-offline-item-select="onItemSelect"
|
||||||
url="/ctp/rest/stitching-offline-items/search"
|
></stitching-offline-item>
|
||||||
v-on:finished-item-select="onItemSelect">
|
|
||||||
</search-item>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 form-group">
|
<div class="col-sm-3 form-group">
|
||||||
<label>Finishing Account</label>
|
<label>Finishing Account</label>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue