dbmsv2 init...1
This commit is contained in:
parent
66debb0558
commit
e6cc878f79
@ -18,6 +18,7 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
|
|||||||
$routes->cli('client', 'SourceDB::client');
|
$routes->cli('client', 'SourceDB::client');
|
||||||
$routes->cli('servercode', 'SourceDB::servercode');
|
$routes->cli('servercode', 'SourceDB::servercode');
|
||||||
$routes->cli('switchcode', 'SourceDB::switchcode');
|
$routes->cli('switchcode', 'SourceDB::switchcode');
|
||||||
|
$routes->cli('partcode', 'SourceDB::partcode');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
$routes->group('', ['namespace' => 'App\Controllers'], function ($routes) {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use App\Libraries\DBMigration\Process\ClientProcess;
|
|||||||
use App\Libraries\DBMigration\Process\LineProcess;
|
use App\Libraries\DBMigration\Process\LineProcess;
|
||||||
use App\Libraries\DBMigration\Process\ServerCodeProcess;
|
use App\Libraries\DBMigration\Process\ServerCodeProcess;
|
||||||
use App\Libraries\DBMigration\Process\SwitchCodeProcess;
|
use App\Libraries\DBMigration\Process\SwitchCodeProcess;
|
||||||
|
use App\Libraries\DBMigration\Process\PartCodeProcess;
|
||||||
use App\Libraries\DBMigration\Process\MigrationProcessInterface;
|
use App\Libraries\DBMigration\Process\MigrationProcessInterface;
|
||||||
|
|
||||||
abstract class DBMigration extends BaseController
|
abstract class DBMigration extends BaseController
|
||||||
@ -27,6 +28,7 @@ abstract class DBMigration extends BaseController
|
|||||||
abstract protected function getLine(): array;
|
abstract protected function getLine(): array;
|
||||||
abstract protected function getServerCode(): array;
|
abstract protected function getServerCode(): array;
|
||||||
abstract protected function getSwitchCode(): array;
|
abstract protected function getSwitchCode(): array;
|
||||||
|
abstract protected function getPartCode(): array;
|
||||||
|
|
||||||
final protected function getTargetDB(): BaseConnection
|
final protected function getTargetDB(): BaseConnection
|
||||||
{
|
{
|
||||||
@ -91,4 +93,12 @@ abstract class DBMigration extends BaseController
|
|||||||
__FUNCTION__
|
__FUNCTION__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
final public function partcode(): void
|
||||||
|
{
|
||||||
|
$this->migration(
|
||||||
|
new PartCodeProcess($this->getTargetDB()),
|
||||||
|
$this->getPartCode(),
|
||||||
|
__FUNCTION__
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,15 @@ class SourceDB extends DBMigration
|
|||||||
->query($sql, $params)
|
->query($sql, $params)
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
}
|
}
|
||||||
|
private function executeFile(string $filename, string $deilmeter = ','): array
|
||||||
|
{
|
||||||
|
$datas = [];
|
||||||
|
$lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$datas[] = explode($deilmeter, $line);
|
||||||
|
}
|
||||||
|
return $datas;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getClient(): array
|
protected function getClient(): array
|
||||||
{
|
{
|
||||||
@ -86,4 +95,8 @@ class SourceDB extends DBMigration
|
|||||||
{
|
{
|
||||||
return $this->executeQuery(self::SQL_GET_SWITCH_CODE, ['%일회성%']);
|
return $this->executeQuery(self::SQL_GET_SWITCH_CODE, ['%일회성%']);
|
||||||
}
|
}
|
||||||
|
protected function getPartCode(): array
|
||||||
|
{
|
||||||
|
return $this->executeFile('/home/donfig/dbmsv2/app/Controllers/CLI/DBMigration/dbmsv2_part.txt');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
app/Controllers/CLI/DBMigration/dbmsv2_part.txt
Normal file
41
app/Controllers/CLI/DBMigration/dbmsv2_part.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
CPU,Xeon E5530 2.4Ghz 4Core,50000
|
||||||
|
CPU,Xeon E5540 2.4Ghz 4Core,50000
|
||||||
|
CPU,Xeon X5560 2.8Ghz 8Core,80000
|
||||||
|
CPU,Xeon X5650 2.6Ghz 12Core,100000
|
||||||
|
CPU,Xeon E5-2690v2 2.6Ghz 12Core,100000
|
||||||
|
CPU,Xeon E5-2690v4 3.0Ghz 20Core,150000
|
||||||
|
RAM,ECC 2G,20000
|
||||||
|
RAM,ECC 4G,30000
|
||||||
|
RAM,ECC 8G,40000
|
||||||
|
RAM,ECC 16G,60000
|
||||||
|
RAM,ECC 32G,100000
|
||||||
|
DISK,SATA 128G,50000
|
||||||
|
DISK,SATA 256G,70000
|
||||||
|
DISK,SATA 512G,90000
|
||||||
|
DISK,SAS 128G,60000
|
||||||
|
DISK,SAS 256G,80000
|
||||||
|
DISK,SAS 512G,100000
|
||||||
|
DISK,SSD 128G,60000
|
||||||
|
DISK,SSD 256G,80000
|
||||||
|
DISK,SSD 512G,100000
|
||||||
|
DISK,SSD 1T,120000
|
||||||
|
DISK,SSD 2T,150000
|
||||||
|
DISK,NVME 512G,120000
|
||||||
|
DISK,NVME 1T,150000
|
||||||
|
DISK,NVME 2T,180000
|
||||||
|
SOFTWARE,Windows 10,10000
|
||||||
|
SOFTWARE,Windows 11,20000
|
||||||
|
SOFTWARE,Windows NT 2008R2,30000
|
||||||
|
SOFTWARE,Windows NT 2012R2,30000
|
||||||
|
SOFTWARE,Windows NT 2016R2,30000
|
||||||
|
SOFTWARE,Windows NT 2019R2,30000
|
||||||
|
SOFTWARE,Windows MSSQL 2008,10000
|
||||||
|
SOFTWARE,Windows MSSQL 2012,10000
|
||||||
|
SOFTWARE,CentOS 7,10000
|
||||||
|
SOFTWARE,CentOS 8,10000
|
||||||
|
SOFTWARE,CentOS 9,10000
|
||||||
|
SOFTWARE,Ununtu 20.04,10000
|
||||||
|
SOFTWARE,Ununtu 21.04,10000
|
||||||
|
SOFTWARE,Ununtu 22.04,10000
|
||||||
|
SOFTWARE,닷디펜더,50000
|
||||||
|
SOFTWARE,딥파인더,50000
|
||||||
File diff suppressed because one or more lines are too long
31
app/Libraries/DBMigration/Process/PartCodeProcess.php
Normal file
31
app/Libraries/DBMigration/Process/PartCodeProcess.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Libraries\DBMigration\Process;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\PartEntity;
|
||||||
|
use CodeIgniter\Database\BaseConnection;
|
||||||
|
|
||||||
|
class PartCodeProcess implements MigrationProcessInterface
|
||||||
|
{
|
||||||
|
private $db;
|
||||||
|
public function __construct(BaseConnection $db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
}
|
||||||
|
public function process(array $row, int $cnt): void
|
||||||
|
{
|
||||||
|
if (count($row) < 2) {
|
||||||
|
echo "{$cnt} {$row[0]}:{$row[1]}-> SKIP PARTCODE\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$temps = [];
|
||||||
|
$temps['type'] = trim($row[0]);
|
||||||
|
$temps['title'] = trim($row[1]);
|
||||||
|
$temps['price'] = trim($row[2]);
|
||||||
|
$temps['status'] = PartEntity::DEFAULT_STATUS; // Assuming SwitchEntity has a STATUS_DEFAULT constant
|
||||||
|
if (!$this->db->table('partinfo')->insert($temps)) {
|
||||||
|
throw new \Exception($this->db->error()['message']);
|
||||||
|
}
|
||||||
|
echo "{$cnt} -> {$temps['title']} PARTCODE 완료.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user