mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 15:04:19 +00:00
1688 PO Automation Project
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Transactions\Processors\ETLPurchaseOrderTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\ETLPDFPurchaseOrderClaudeProcessor;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -16,24 +16,19 @@ class ETLPurchaseOrderTransactionV2CommandJob implements ShouldQueue
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var array */
|
||||
private $products;
|
||||
|
||||
/** @var array */
|
||||
private $productsMetadata;
|
||||
private $files;
|
||||
|
||||
/** @var int|null */
|
||||
private $bookingId;
|
||||
|
||||
/**
|
||||
* ETLPurchaseOrderTransactionV2CommandJob constructor.
|
||||
* @param array $products
|
||||
* @param array $productsMetadata
|
||||
* @param array $files
|
||||
* @param int $bookingId
|
||||
*/
|
||||
public function __construct(array $products, array $productsMetadata, ?int $bookingId)
|
||||
public function __construct(array $files, ?int $bookingId)
|
||||
{
|
||||
$this->products = $products;
|
||||
$this->productsMetadata = $productsMetadata;
|
||||
$this->files = $files;
|
||||
$this->bookingId = $bookingId;
|
||||
}
|
||||
|
||||
@@ -42,7 +37,7 @@ class ETLPurchaseOrderTransactionV2CommandJob implements ShouldQueue
|
||||
Log::info(Carbon::now() . ': Start job - ETL Purchase Order Transaction.');
|
||||
$start = new Carbon();
|
||||
|
||||
// (App()->make(ETLPurchaseOrderTransactionProcessor::class))->execute($this->products, $this->productsMetadata, $this->bookingId);
|
||||
(App()->make(ETLPDFPurchaseOrderClaudeProcessor::class))->execute($this->files, $this->bookingId);
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
+27
-1
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ETLPurchaseOrderTransactionV2CommandJob;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBooking;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
@@ -85,7 +86,32 @@ class ImportPurchaseOrderTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
if(empty($products)){
|
||||
$files = $request->input('files');
|
||||
$products = $this->eTLPDFPurchaseOrderClaudeProcessor->execute($files);
|
||||
$files = $request->input('files');
|
||||
|
||||
$maxSize = 150 * 1024; // 150 KB
|
||||
$totalSize = 0;
|
||||
|
||||
foreach ($files as $index => $fileBase64) {
|
||||
if (preg_match('/^data:application\/pdf;base64,/', $fileBase64)) {
|
||||
$fileBase64 = preg_replace('/^data:application\/pdf;base64,/', '', $fileBase64);
|
||||
}
|
||||
|
||||
$fileContent = base64_decode($fileBase64, true);
|
||||
if ($fileContent === false) {
|
||||
Log::info("Invalid Base64 for file index {$index}");
|
||||
}
|
||||
|
||||
$totalSize += strlen($fileContent);
|
||||
}
|
||||
|
||||
if ($totalSize > $maxSize) {
|
||||
ETLPurchaseOrderTransactionV2CommandJob::dispatch($files, $request->route('id'));
|
||||
$this->notificationMessage = "Please refresh page in a few minutes";
|
||||
return $this->response([]);
|
||||
}
|
||||
else{
|
||||
$products = $this->eTLPDFPurchaseOrderClaudeProcessor->execute($files);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user