dbms_primeidc/extdbms/lib/Models/ServiceModel.php
2025-03-21 18:48:48 +09:00

94 lines
2.8 KiB
PHP

<?php
namespace lib\Models;
use lib\Entitys\ServiceEntity as Entity;
class ServiceModel extends CommonModel
{
public function __construct()
{
parent::__construct();
} //
final public function getTable()
{
return 'servicedb';
}
final public function getEntity(): Entity
{
return new Entity($this->getRow());
} //
final public function getEntitys(): array
{
$entitys = [];
foreach ($this->getRows() as $row) {
$entitys[] = new Entity($row);
}
return $entitys;
} //
final public function getExtras($code)
{
$sql = sprintf("SELECT C.Client_Name,S.server_code,S.service_ip,S.service_os,S.service_sw
FROM servicedb AS S
JOIN clientdb AS C
ON S.client_code = C.Client_Code
WHERE S.service_code IN (SELECT service_code FROM adddb WHERE addDB_code ='%s')", $code);
return $this->getRows($sql);
}
//Dashboard
private function getCompanies($site_id)
{
$companies = [];
switch ($site_id) {
case 'PRIMEIDC':
$companies = [
"idcjp" => "Client_Code NOT IN ('C116','C012','C636')",
"winidc" => "Client_Code='C116'",
"gamewing" => "Client_Code='C012'",
"GDIDC" => "Client_Code='C636'",
];
break;
case "ITSOLUTION":
$companies = [
"winidc" => "Client_Code NOT IN ('C237')",
"bosch" => "Client_Code='C237'",
];
break;
case 'GDIDC':
$companies = [
"gdidc" => "",
];
break;
default:
throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id));
}
return $companies;
}
final public function getTypes_Dashboard()
{
return array("normal", "defence", "solo", "substitution", "test");
}
final public function getSummary_Dashboard($site_id)
{
$temps = array();
foreach ($this->getCompanies($site_id) as $name => $where) {
$temps[$name] = array();
foreach ($this->getTypes_Dashboard() as $type) {
$this->where([
$where,
"service_line" => $type,
"service_status" => 'o',
"Chiba=service_sw BETWEEN 'C00%' AND 'C64%'" => "",
"Tokyo=service_sw BETWEEN 'C80%' AND 'C99%'" => "",
]);
$temps[$name][$type] = $this->getSelectColumn("COUNT(*)");
} //foreach
//echo var_dump($temps);
} //foreach
return $temps;
}
} //Class