From a587f600a3f593f2cb045483149cf6576ab1b8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Fri, 21 Mar 2025 18:48:48 +0900 Subject: [PATCH] dbms init...1 --- extdbms/coupon.php | 15 +-- extdbms/deepfinder_list.php | 11 +- extdbms/depositbillpaper.php | 7 +- extdbms/dotdefender_list.php | 11 +- extdbms/lib/Controller/Billing.php | 46 ------- extdbms/lib/Controller/Coupon.php | 46 ------- extdbms/lib/Controller/ExtraService.php | 18 --- extdbms/lib/Controllers/ClientController.php | 23 ++++ extdbms/lib/Controllers/CommonController.php | 76 +++++++++++ .../DashboardController.php} | 13 +- extdbms/lib/Controllers/ServiceController.php | 52 ++++++++ extdbms/lib/Core/Controller.php | 51 +------- extdbms/lib/Core/Entity.php | 30 +++++ extdbms/lib/Core/Model.php | 112 ++++++++++------ extdbms/lib/Entitys/ClientEntity.php | 13 ++ extdbms/lib/Entitys/CommonEntity.php | 11 ++ extdbms/lib/Entitys/ServiceEntity.php | 13 ++ extdbms/lib/Model/Client.php | 23 ---- extdbms/lib/Model/Service.php | 120 ------------------ extdbms/lib/Models/ClientModel.php | 31 +++++ extdbms/lib/Models/CommonModel.php | 13 ++ extdbms/lib/Models/ServiceModel.php | 93 ++++++++++++++ extdbms/total_counting.php | 7 +- .../WebContent/jsp/service/serviceDetail.jsp | 1 + 24 files changed, 463 insertions(+), 373 deletions(-) delete mode 100644 extdbms/lib/Controller/Billing.php delete mode 100644 extdbms/lib/Controller/Coupon.php delete mode 100644 extdbms/lib/Controller/ExtraService.php create mode 100644 extdbms/lib/Controllers/ClientController.php create mode 100644 extdbms/lib/Controllers/CommonController.php rename extdbms/lib/{Controller/Statistics.php => Controllers/DashboardController.php} (77%) create mode 100644 extdbms/lib/Controllers/ServiceController.php create mode 100644 extdbms/lib/Core/Entity.php create mode 100644 extdbms/lib/Entitys/ClientEntity.php create mode 100644 extdbms/lib/Entitys/CommonEntity.php create mode 100644 extdbms/lib/Entitys/ServiceEntity.php delete mode 100644 extdbms/lib/Model/Client.php delete mode 100644 extdbms/lib/Model/Service.php create mode 100644 extdbms/lib/Models/ClientModel.php create mode 100644 extdbms/lib/Models/CommonModel.php create mode 100644 extdbms/lib/Models/ServiceModel.php diff --git a/extdbms/coupon.php b/extdbms/coupon.php index 4f86e8b..49e119b 100644 --- a/extdbms/coupon.php +++ b/extdbms/coupon.php @@ -1,5 +1,6 @@ execute($lines,$client_type,$debug); -print("Coupon 설정이 완료되었습니다.\n"); -print_r($successes); -print_r($failes); +$control = new ServiceController(); +$control->execute($lines, $client_field); +echo "Coupon 설정이 완료되었습니다.\n"; diff --git a/extdbms/deepfinder_list.php b/extdbms/deepfinder_list.php index 5d94a07..2780bb5 100644 --- a/extdbms/deepfinder_list.php +++ b/extdbms/deepfinder_list.php @@ -1,10 +1,7 @@ execute("딥파인더"); -} catch (\Exception $e) { - die($e->getMessage()); -} +$control = new ServiceController(); +return $extra->execute("딥파인더"); diff --git a/extdbms/depositbillpaper.php b/extdbms/depositbillpaper.php index 5c7c216..98489fa 100644 --- a/extdbms/depositbillpaper.php +++ b/extdbms/depositbillpaper.php @@ -1,10 +1,11 @@ execute($_GET); + $control = new ClientController(); + return $control->getBillingPaper($_GET); } catch (\Exception $e) { die($e->getMessage()); } diff --git a/extdbms/dotdefender_list.php b/extdbms/dotdefender_list.php index 034ea32..0068fad 100644 --- a/extdbms/dotdefender_list.php +++ b/extdbms/dotdefender_list.php @@ -1,10 +1,7 @@ execute("닷 디펜더"); -} catch (\Exception $e) { - die($e->getMessage()); -} +$control = new ServiceController(); +return $extra->execute("닷 디펜더"); diff --git a/extdbms/lib/Controller/Billing.php b/extdbms/lib/Controller/Billing.php deleted file mode 100644 index 3008fa2..0000000 --- a/extdbms/lib/Controller/Billing.php +++ /dev/null @@ -1,46 +0,0 @@ - "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"], - ]; - break; - case "ITSOLUTION": - return [ - ["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"], - ["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"], - ]; - break; - case 'GDIDC': - return [ - ["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"], - ]; - break; - default: - throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id)); - break; - } - } - - public function execute($datas) - { - $this->view->site = $this->getSite(); - $this->view->client = $this->getModel("Client")->getData(array(sprintf("Client_Code='%s'", $datas['client_code']))); - $this->view->accounts = $this->getAccounts($this->view->site['id']); - return $this->render('depositbillpaper'); - } -} diff --git a/extdbms/lib/Controller/Coupon.php b/extdbms/lib/Controller/Coupon.php deleted file mode 100644 index 6a7be21..0000000 --- a/extdbms/lib/Controller/Coupon.php +++ /dev/null @@ -1,46 +0,0 @@ -getModel("Client")->getClient(sprintf("%s='%s'", $field, $data)); - $service = $this->getModel("Service")->getOneTime($client->Client_Name); - return array( - "client" => $client, - "service" => $service, - ); - } // - - public function execute(array $lines, $field = "Client_Code", $debug=false) - { - $loop=1; - $successes = array(); - $failes = array(); - foreach ($lines as $line) { - list($info, $coupon_cnt) = explode("||", rtrim($line)); - $coupon = $this->getCouponInfo($info, $field); - if(isset($coupon['service']->service_code)){ - //쿠폰 설정 - $where = sprintf("service_code='%s'", $coupon['service']->service_code); - $this->getModel("Service")->setCoupon($coupon_cnt, $where, $debug); - - $result = sprintf("%20s[%20s:%15s]=>쿠폰 %3d개 설정 성공\n", $coupon['client']->Client_Name, - $coupon['service']->server_code, $coupon['service']->service_code, $coupon_cnt); - array_push($successes, $result); - } else { - $result = sprintf("%5d번째: %s 설정 실패\n", $loop,rtrim($line)); - array_push($failes, $result); - } - $loop++; - } - return array($successes,$failes); - } -} diff --git a/extdbms/lib/Controller/ExtraService.php b/extdbms/lib/Controller/ExtraService.php deleted file mode 100644 index 73bb6e3..0000000 --- a/extdbms/lib/Controller/ExtraService.php +++ /dev/null @@ -1,18 +0,0 @@ -view->results = $this->getModel("Service")->getExtras($code); - return $this->render('extraservice'); - } -} //Class diff --git a/extdbms/lib/Controllers/ClientController.php b/extdbms/lib/Controllers/ClientController.php new file mode 100644 index 0000000..24516d7 --- /dev/null +++ b/extdbms/lib/Controllers/ClientController.php @@ -0,0 +1,23 @@ +view->siteinfo = $this->getSiteInfo(); + $this->getClientModel()->where(["Client_Code" => $datas['client_code']]); + $entity = $this->getClientModel()->getEntity(); + if (!$entity) { + throw new \Exception($datas['client_code'] . "에 해당하는 고객이 존재하지 않습니다."); + } + $this->view->client = $entity; + return $this->render('depositbillpaper'); + } +} diff --git a/extdbms/lib/Controllers/CommonController.php b/extdbms/lib/Controllers/CommonController.php new file mode 100644 index 0000000..90ad169 --- /dev/null +++ b/extdbms/lib/Controllers/CommonController.php @@ -0,0 +1,76 @@ +_clientModel === null) { + $this->_clientModel = new ClientModel(); + } + return $this->_clientModel; + } + final protected function getServiceModel(): ServiceModel + { + if ($this->_serviceModel === null) { + $this->_serviceModel = new ServiceModel(); + } + return $this->_serviceModel; + } + + final public function getSiteInfo(): array + { + $domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false; + switch ($domain) { + case 'dbms.prime-idc.jp': + return [ + "id" => "PRIMEIDC", + "domain" => "dbms.prime-idc.jp", + "name" => "PrimeIDC", + "email" => "primeidc.jp@gmail.com", + "banks" => [ + ["id" => "331301-04-217387", "name" => '국민은행', "owner" => "주)듀나미스"] + ], + ]; + break; + case "dbms.itsolution-idc.jp": + return [ + "id" => "ITSOLUTION", + "domain" => "dbms.itsolution-idc.jp", + "name" => "Itsolution", + "email" => "support@itsoution-idc.jp", + "banks" => [ + ["id" => "9002-1932-1654-1", "name" => '새마을금고', "owner" => "주식회사 르호봇"], + ["id" => "351-0995-6751-73", "name" => '농협', "owner" => "주식회사 르호봇"], + ], + ]; + break; + case 'dbms.gdidc.jp': + return [ + "id" => "GDIDC", + "domain" => "dbms.gdidc.jp", + "name" => "GDIDC", + "email" => "support@gdidc.jp", + "banks" => [ + ["id" => "1005-204-100758", "name" => '우리은행', "owner" => " (주)브엘라해로이"], + ], + ]; + break; + default: + throw new \Exception(sprintf(__METHOD__ . "에서 오류 Domain[%s]이 정의되지 않았습니다.", $domain)); + break; + } + } +} //Class diff --git a/extdbms/lib/Controller/Statistics.php b/extdbms/lib/Controllers/DashboardController.php similarity index 77% rename from extdbms/lib/Controller/Statistics.php rename to extdbms/lib/Controllers/DashboardController.php index a89f4af..1f39ddb 100644 --- a/extdbms/lib/Controller/Statistics.php +++ b/extdbms/lib/Controllers/DashboardController.php @@ -1,18 +1,18 @@ view->types = $this->getModel("Service")->getTypes_Dashboard(); - $this->view->results = $this->getModel("Service")->getSummary_Dashboard($this->getSite()['id']); + $this->view->types = $this->getServiceModel()->getTypes_Dashboard(); + $site = $this->getSiteInfo(); + $this->view->results = $this->getServiceModel()->getSummary_Dashboard($site['id']); $summary = array(); foreach ($this->view->types as $type) { @@ -32,7 +32,6 @@ class Statistics extends Controller $total['Tokyo'] += $summary[$type]['Tokyo']; $total['Chiba'] += $summary[$type]['Chiba']; } - $this->view->summary = $summary; $this->view->total = $total; return $this->render('total_counting'); diff --git a/extdbms/lib/Controllers/ServiceController.php b/extdbms/lib/Controllers/ServiceController.php new file mode 100644 index 0000000..e702eb6 --- /dev/null +++ b/extdbms/lib/Controllers/ServiceController.php @@ -0,0 +1,52 @@ +view->results = $this->getServiceModel()->getExtras($code); + return $this->render('extraservice'); + } + + public function execute(array $lines, $client_field = "Client_Code", $debug = false) + { + $loop = 1; + foreach ($lines as $line) { + list($clientData, $coupon_cnt) = explode("||", rtrim($line)); + try { + //고객정보 가져오기 + $this->getClientModel()->where([$client_field => $clientData]); + $client = $this->getClientModel()->getEntity(); + //고객 일회성서비스정보(쿠폰) 가져오기 + $this->getServiceModel()->where(["server_code" => $client->Client_Name . "-일회성"]); + $service = $this->getServiceModel()->getEntity(); + if (isset($service->service_code)) { + throw new \Exception("{$loop}번째: [{$client->Client_Name}]고객의 일회성장비가 존재하지 않습니다."); + } + //쿠폰 설정 + $this->getServiceModel()->where(["service_code" => $service->service_code]); + $this->getServiceModel()->modify(['coupon' => $coupon_cnt]); + printf( + "%20s[%20s:%15s]=>쿠폰 %3d개 설정 성공\n", + $client->Client_Name, + $service->server_code, + $service->service_code, + $coupon_cnt + ); + } catch (\Exception $e) { + printf( + "{$loop}번째: %s 설정 실패:%s\n", + rtrim($line), + $e->getMessage() + ); + } + $loop++; + } + } +} diff --git a/extdbms/lib/Core/Controller.php b/extdbms/lib/Core/Controller.php index 101e448..deebe4e 100644 --- a/extdbms/lib/Core/Controller.php +++ b/extdbms/lib/Core/Controller.php @@ -1,10 +1,12 @@ _debug; } - - //Model - final public function getModel($name) - { - if (!array_key_exists($name, $this->_models)) { - //require_once "lib/Model/" . $model . ".php"; - $modelName = sprintf("lib\Model\%s", $name); - $model = new $modelName(); - if (!$model instanceof Model) { - throw new \Exception("%s Model이 생성되지 않았습니다\n", $modelName); - } - $this->_models[$name] = $model; - } - return $this->_models[$name]; - } - public function render($file) { return $this->view->render($file); } - - final public function getSite() - { - $domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false; - switch ($domain) { - case 'dbms.prime-idc.jp': - return array( - "id" => "PRIMEIDC", - "domain" => "dbms.prime-idc.jp", - "name" => "PrimeIDC", - "email" => "primeidc.jp@gmail.com"); - break; - case "dbms.itsolution-idc.jp": - return array( - "id" => "ITSOLUTION", - "domain" => "dbms.itsolution-idc.jp", - "name" => "Itsolution", - "email" => "support@itsoution-idc.jp"); - break; - case 'dbms.gdidc.jp': - return array( - "id" => "GDIDC", - "domain" => "dbms.gdidc.jp", - "name" => "GDIDC", - "email" => "support@gdidc.jp"); - break; - default: - throw new \Exception(sprintf(__METHOD__ . "에서 오류 Domain[%s]이 정의되지 않았습니다.", $domain)); - break; - } - } } //Class diff --git a/extdbms/lib/Core/Entity.php b/extdbms/lib/Core/Entity.php new file mode 100644 index 0000000..39bfc3a --- /dev/null +++ b/extdbms/lib/Core/Entity.php @@ -0,0 +1,30 @@ +values = $datas; + } // + final public function setDebug($debug) + { + $this->_debug = $debug; + } + final public function getDebug() + { + return $this->_debug; + } + + final public function __get($name) + { + return $this->_values[$name]; + } + final public function __set($name, $value) + { + $this->_values[$name] = $value; + } +} //Class diff --git a/extdbms/lib/Core/Model.php b/extdbms/lib/Core/Model.php index 3fb9359..bc96a37 100644 --- a/extdbms/lib/Core/Model.php +++ b/extdbms/lib/Core/Model.php @@ -1,29 +1,35 @@ _db === null) { $envs = parse_ini_file("./env.ini", true); if (!$envs) { throw new \Exception(var_export($envs, true)); } //echo var_dump($envs);exit; - $dsn = sprintf("%s:host=%s;dbname=%s;charset=%s", $envs['db']['driver'], $envs['db']['host'], $envs['db']['name'], $envs['db']['charset']); - $this->db = new PDO($dsn, $envs['db']['id'], $envs['db']['passwd']); - $this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } // - - abstract public function getTable(); - final public function getDB() - { + $dsn = sprintf("%s:host=%s;dbname=%s;charset=%s", $envs['db']['driver'], $envs['db']['host'], $envs['db']['name'], $envs['db']['charset']); + $this->_db = new PDO($dsn, $envs['db']['id'], $envs['db']['passwd']); + $this->_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } return $this->_db; } final public function setDebug($debug) @@ -34,42 +40,76 @@ abstract class Model { return $this->_debug; } - final public function setMode($mode) + + final public function where(array $wheres, $condition = "AND") { - $this->_mode = $mode; + foreach ($wheres as $key => $value) { + if ($value !== "") { + $value = "='{$value}'"; + } + $this->_wheres[] = sprintf("%s%s%s", count($this->_wheres) ? " " . $condition . " " : "", $key, $value); + } } - final public function getMode() + final public function orWhere(array $wheres) { - return $this->_mode; + $this->where($wheres, "OR"); + } + final public function getWhere() + { + return count($this->_wheres) ? "WHERE " . implode(" ", $this->_wheres) : ""; } - final public function execute($sql) + final public function execute($sql): bool|PDOStatement { - $stmt = $this->db->prepare($sql); + $stmt = $this->getConnect()->prepare($sql); $stmt->execute(); + $this->_wheres = []; + $this->_column = "*"; return $stmt; } - final protected function getRow($sql) - { - $stmt = $this->execute($sql); - return $stmt->fetch($this->getMode()); - } - final protected function getRows($sql, $mode = PDO::FETCH_OBJ) - { - $stmt = $this->execute($sql); - return $stmt->fetchAll($this->getMode()); - } - final public function getData($wheres = array(), $column = "*") + //CUD문 + final public function create($datas) { - $sql = sprintf("SELECT %s FROM %s %s", $column, $this->getTable(), count($wheres) ? "WHERE " . implode("AND", $wheres) : ""); - //echo $sql; - return $this->getRow($sql); + $sql = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), implode(",", $datas), $this->getWhere()); + return $this->execute($sql); + } // + final public function modify($datas) + { + $sql = sprintf("UPDATE %s SET %s %s", $this->getTable(), implode(",", $datas), $this->getWhere()); + return $this->execute($sql); + } // + final public function delete() + { + $sql = sprintf("DELETE FROM %s %s", $this->getTable(), $this->getWhere()); + return $this->execute($sql); + } // + + //Select문 + final public function setColumn($column) + { + $this->_column = $column; } - final public function getDatas(array $wheres = array(), $column = "*") + final public function getColumn() { - $sql = sprintf("SELECT %s FROM %s %s", $column, $this->getTable(), count($wheres) ? "WHERE " . implode("AND", $wheres) : ""); - //echo $sql; - return $this->getRows($sql); + return $this->_column; + } + final protected function getRow($mode = PDO::FETCH_OBJ) + { + $sql = sprintf("SELECT %s FROM %s WHERE %s", $this->getColumn(), $this->getTable(), $this->getWhere()); + $stmt = $this->execute($sql); + return $stmt->fetch($mode); + } + final protected function getRows($mode = PDO::FETCH_OBJ) + { + $sql = sprintf("SELECT %s FROM %s WHERE %s", $this->getColumn(), $this->getTable(), $this->getWhere()); + $stmt = $this->execute($sql); + return $stmt->fetchAll($mode); + } + final protected function getSelectColumn($column, int $return_column = 0) + { + $sql = sprintf("SELECT %s FROM %s WHERE %s", $column, $this->getTable(), $this->getWhere()); + $stmt = $this->execute($sql); + return $stmt->fetchColumn($return_column); } } //Class diff --git a/extdbms/lib/Entitys/ClientEntity.php b/extdbms/lib/Entitys/ClientEntity.php new file mode 100644 index 0000000..fadcd0a --- /dev/null +++ b/extdbms/lib/Entitys/ClientEntity.php @@ -0,0 +1,13 @@ +getTable(), $where); - return $this->getRow($sql); - } // -} //Class diff --git a/extdbms/lib/Model/Service.php b/extdbms/lib/Model/Service.php deleted file mode 100644 index 0057e73..0000000 --- a/extdbms/lib/Model/Service.php +++ /dev/null @@ -1,120 +0,0 @@ -getTable(), $coupon, $where ? "WHERE " . $where : $where); - if($debug){ - echo $sql."\n"; - }else{ - return $this->execute($sql); - } - } // - //쿠폰 설정 - final public function setCoupon($coupon, $where = "",$debug=false) - { - $sql = sprintf("UPDATE %s SET coupon = %d %s", $this->getTable(), $coupon, $where ? "WHERE " . $where : $where); - if($debug){ - echo $sql."\n"; - }else{ - return $this->execute($sql); - } - } // - //일회성서비스정보 가져오기 - final public function getOneTime($client_name) - { - $sql = sprintf("SELECT * FROM %s WHERE server_code = '%s-일회성'", $this->getTable(), $client_name); - //echo $sql . "\n"; - return $this->getRow($sql); - } // - final public function getCount($where = "") - { - $sql = sprintf("SELECT COUNT(*) FROM %s WHERE %s ", $this->getTable(), $where); - //echo $sql . "\n"; - $stmt = $this->execute($sql); - return $stmt->fetchColumn(0); - } // - - 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) - { - switch ($site_id) { - case 'PRIMEIDC': - return array( - "idcjp" => "AND Client_Code NOT IN ('C116','C012','C636')", - "winidc" => "AND Client_Code='C116'", - "gamewing" => "AND Client_Code='C012'", - "GDIDC" => "AND Client_Code='C636'", - ); - break; - case "ITSOLUTION": - return array( - "winidc" => "AND Client_Code NOT IN ('C237')", - "bosch" => "AND Client_Code='C237'", - ); - break; - case 'GDIDC': - return array( - "gdidc" => "", - ); - break; - default: - throw new \Exception(sprintf(__METHOD__ . "에서 오류 SiteID[%s]가 정의되지 않았습니다.", $site_id)); - break; - } - } - final public function getTypes_Dashboard() - { - return array("normal", "defence", "solo", "substitution", "test"); - } - private function getCountByCenter_Dashboard($where) - { - $centers_conditions = array( - "Chiba" => "service_sw BETWEEN 'C00%' AND 'C64%'", - "Tokyo" => "service_sw BETWEEN 'C80%' AND 'C99%'", - ); - $temps = array(); - foreach ($centers_conditions as $name => $condition) { - $temps[$name] = $this->getCount(sprintf("%s AND %s", $where, $condition)); - } - //return array("Chiba" => $temps['Center1'] + $temps['Center2'], "Tokyo" => $temps['Tokyo']); - return $temps; - } - final public function getSummary_Dashboard($site_id) - { - $temps = array(); - foreach ($this->getCompanies($site_id) as $name => $condition) { - $temps[$name] = array(); - foreach ($this->getTypes_Dashboard() as $type) { - $where = sprintf("service_line='%s' AND service_status='o' %s", $type, $condition); - $temps[$name][$type] = $this->getCountByCenter_Dashboard($where); - } //foreach - //echo var_dump($temps); - } //foreach - return $temps; - } -} //Class diff --git a/extdbms/lib/Models/ClientModel.php b/extdbms/lib/Models/ClientModel.php new file mode 100644 index 0000000..d6770b8 --- /dev/null +++ b/extdbms/lib/Models/ClientModel.php @@ -0,0 +1,31 @@ +getRow()); + } // + final public function getEntitys(): array + { + $entitys = []; + foreach ($this->getRows() as $row) { + $entitys[] = new Entity($row); + } + return $entitys; + } // +} //Class diff --git a/extdbms/lib/Models/CommonModel.php b/extdbms/lib/Models/CommonModel.php new file mode 100644 index 0000000..6b17cfb --- /dev/null +++ b/extdbms/lib/Models/CommonModel.php @@ -0,0 +1,13 @@ +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 diff --git a/extdbms/total_counting.php b/extdbms/total_counting.php index 2fd7ce6..3e86912 100644 --- a/extdbms/total_counting.php +++ b/extdbms/total_counting.php @@ -1,10 +1,11 @@ execute(); + $control = new DashboardController(); + return $control->mainPage(); } catch (\Exception $e) { die($e->getMessage()); } diff --git a/idcproject/WebContent/jsp/service/serviceDetail.jsp b/idcproject/WebContent/jsp/service/serviceDetail.jsp index 1c9927b..f2dd676 100644 --- a/idcproject/WebContent/jsp/service/serviceDetail.jsp +++ b/idcproject/WebContent/jsp/service/serviceDetail.jsp @@ -987,6 +987,7 @@ $(function() +