Compare commits
6 Commits
eed6c3dbaa
...
8ca526e4f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ca526e4f2 | ||
|
|
e14ae2ef9c | ||
|
|
7498d14087 | ||
|
|
369f24a8e2 | ||
|
|
d455707dbc | ||
|
|
76ebdce2ea |
@@ -223,14 +223,19 @@
|
||||
{
|
||||
try {
|
||||
if (!empty($this->atmTransactionBatch)) {
|
||||
// Bulk insert/update ATM transactions
|
||||
AtmTransaction::upsert(
|
||||
$this->atmTransactionBatch,
|
||||
['transaction_id'], // Unique key
|
||||
array_values(array_diff(self::HEADER_MAP, ['id'])) // Update columns (all except transaction_id)
|
||||
);
|
||||
// Process in smaller chunks for better memory management
|
||||
foreach ($this->atmTransactionBatch as $entry) {
|
||||
// Extract all stmt_entry_ids from the current chunk
|
||||
$entryIds = array_column($entry, 'transaction_id');
|
||||
|
||||
// Reset batch after processing
|
||||
// Delete existing records with these IDs to avoid conflicts
|
||||
AtmTransaction::whereIn('transaction_id', $entryIds)->delete();
|
||||
|
||||
// Insert all records in the chunk at once
|
||||
AtmTransaction::insert($entry);
|
||||
}
|
||||
|
||||
// Reset entry batch after processing
|
||||
$this->atmTransactionBatch = [];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -182,14 +182,19 @@
|
||||
{
|
||||
try {
|
||||
if (!empty($this->billDetailBatch)) {
|
||||
// Bulk insert/update bill details
|
||||
TempBillDetail::upsert(
|
||||
$this->billDetailBatch,
|
||||
['_id'], // Unique key
|
||||
array_diff((new TempBillDetail())->getFillable(), ['_id']) // Update columns
|
||||
);
|
||||
// Process in smaller chunks for better memory management
|
||||
foreach ($this->billDetailBatch as $entry) {
|
||||
// Extract all stmt_entry_ids from the current chunk
|
||||
$entryIds = array_column($entry, '_id');
|
||||
|
||||
// Reset batch after processing
|
||||
// Delete existing records with these IDs to avoid conflicts
|
||||
TempBillDetail::whereIn('_id', $entryIds)->delete();
|
||||
|
||||
// Insert all records in the chunk at once
|
||||
TempBillDetail::insert($entry);
|
||||
}
|
||||
|
||||
// Reset entry batch after processing
|
||||
$this->billDetailBatch = [];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -186,14 +186,19 @@
|
||||
{
|
||||
try {
|
||||
if (!empty($this->transferBatch)) {
|
||||
// Bulk insert/update funds transfers
|
||||
TempFundsTransfer::upsert(
|
||||
$this->transferBatch,
|
||||
['_id'], // Unique key
|
||||
array_diff((new TempFundsTransfer())->getFillable(), ['_id']) // Update columns
|
||||
);
|
||||
// Process in smaller chunks for better memory management
|
||||
foreach ($this->transferBatch as $entry) {
|
||||
// Extract all stmt_entry_ids from the current chunk
|
||||
$entryIds = array_column($entry, '_id');
|
||||
|
||||
// Reset transfer batch after processing
|
||||
// Delete existing records with these IDs to avoid conflicts
|
||||
TempFundsTransfer::whereIn('_id', $entryIds)->delete();
|
||||
|
||||
// Insert all records in the chunk at once
|
||||
TempFundsTransfer::insert($entry);
|
||||
}
|
||||
|
||||
// Reset entry batch after processing
|
||||
$this->transferBatch = [];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -191,18 +191,23 @@
|
||||
{
|
||||
try {
|
||||
if (!empty($this->entryBatch)) {
|
||||
// Bulk insert/update statement entries
|
||||
StmtEntry::upsert(
|
||||
$this->entryBatch,
|
||||
['stmt_entry_id'], // Unique key
|
||||
array_diff((new StmtEntry())->getFillable(), ['stmt_entry_id']) // Update columns
|
||||
);
|
||||
// Process in smaller chunks for better memory management
|
||||
foreach ($this->entryBatch as $entry) {
|
||||
// Extract all stmt_entry_ids from the current chunk
|
||||
$entryIds = array_column($entry, 'stmt_entry_id');
|
||||
|
||||
// Delete existing records with these IDs to avoid conflicts
|
||||
StmtEntry::whereIn('stmt_entry_id', $entryIds)->delete();
|
||||
|
||||
// Insert all records in the chunk at once
|
||||
StmtEntry::insert($entry);
|
||||
}
|
||||
|
||||
// Reset entry batch after processing
|
||||
$this->entryBatch = [];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error("Error in saveBatch: " . $e->getMessage());
|
||||
Log::error("Error in saveBatch: " . $e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
$this->errorCount += count($this->entryBatch);
|
||||
// Reset batch even if there's an error to prevent reprocessing the same failed records
|
||||
$this->entryBatch = [];
|
||||
|
||||
@@ -293,14 +293,19 @@
|
||||
{
|
||||
try {
|
||||
if (!empty($this->tellerBatch)) {
|
||||
// Bulk insert/update teller records
|
||||
Teller::upsert(
|
||||
$this->tellerBatch,
|
||||
['id_teller'], // Unique key
|
||||
array_diff(array_values(self::HEADER_MAP), ['id_teller']) // Update columns
|
||||
);
|
||||
// Process in smaller chunks for better memory management
|
||||
foreach ($this->tellerBatch as $entry) {
|
||||
// Extract all stmt_entry_ids from the current chunk
|
||||
$entryIds = array_column($entry, 'id_teller');
|
||||
|
||||
// Reset batch after processing
|
||||
// Delete existing records with these IDs to avoid conflicts
|
||||
Teller::whereIn('id_teller', $entryIds)->delete();
|
||||
|
||||
// Insert all records in the chunk at once
|
||||
Teller::insert($entry);
|
||||
}
|
||||
|
||||
// Reset entry batch after processing
|
||||
$this->tellerBatch = [];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('stmt_entry', function (Blueprint $table) {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('stmt_entry', function (Blueprint $table) {
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user