FIC_Solar/SolarPower/DBSchema/solar_power_schema.sql
Kai 7e9614c6ad 1. 修改資料庫連線
2. 加入db schema
3. 修改權限
2021-06-14 15:09:16 +08:00

241 lines
14 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- --------------------------------------------------------
-- 主機: 127.0.0.1
-- 伺服器版本: 10.5.6-MariaDB - mariadb.org binary distribution
-- 伺服器作業系統: Win64
-- HeidiSQL 版本: 11.2.0.6213
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- 傾印 solar_power 的資料庫結構
CREATE DATABASE IF NOT EXISTS `solar_power` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
USE `solar_power`;
-- 傾印 資料表 solar_power.auth_page 結構
CREATE TABLE IF NOT EXISTS `auth_page` (
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`MainName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '大項名稱',
`SubName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '功能名稱',
`ControlName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`AuthCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定權限頁面';
-- 正在傾印表格 solar_power.auth_page 的資料:~-1 rows (近似值)
DELETE FROM `auth_page`;
-- 傾印 資料表 solar_power.company 結構
CREATE TABLE IF NOT EXISTS `company` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除0:否 1:是',
`Status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '狀態0:凍結 1:正常',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司名稱',
`Logo` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司logo',
`TaxIDNumber` varchar(8) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '統一編號',
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話',
`Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
`RegisterUpperLimit` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '註冊上限',
`SPStationAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '太陽能電站數量',
`RelationalDB` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公司各自資料庫',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`,`Status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公司資料';
-- 正在傾印表格 solar_power.company 的資料:~-1 rows (近似值)
DELETE FROM `company`;
/*!40000 ALTER TABLE `company` DISABLE KEYS */;
/*!40000 ALTER TABLE `company` ENABLE KEYS */;
-- 傾印 資料表 solar_power.company_auth_page 結構
CREATE TABLE IF NOT EXISTS `company_auth_page` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`CompanyId` int(10) unsigned NOT NULL,
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`CreatedBy` int(10) unsigned DEFAULT NULL,
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`Id`),
KEY `IDX_01` (`CompanyId`,`AuthCode`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公司擁有的權限池';
-- 正在傾印表格 solar_power.company_auth_page 的資料:~-1 rows (近似值)
DELETE FROM `company_auth_page`;
/*!40000 ALTER TABLE `company_auth_page` DISABLE KEYS */;
/*!40000 ALTER TABLE `company_auth_page` ENABLE KEYS */;
-- 傾印 資料表 solar_power.operator_log 結構
CREATE TABLE IF NOT EXISTS `operator_log` (
`Id` bigint(19) unsigned NOT NULL AUTO_INCREMENT,
`ControllerName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`ActionName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Parameter` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`CreatedBy` int(10) unsigned DEFAULT NULL,
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`Id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='操作紀錄';
-- 傾印 資料表 solar_power.power_station 結構
CREATE TABLE IF NOT EXISTS `power_station` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公司編號',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
`Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+流水號 ',
`IsEscrow` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否為代管0:否 1:是',
`EscrowName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '代管名稱',
`ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '台電掛錶日',
`EstimatedRecoveryTime` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '預估回收時間',
`GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT 0.0 COMMENT '電廠發電容量,單位(千瓦)',
`PowerRate` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '受電費率',
`Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
`InverterBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器廠牌',
`InverterProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器型號',
`InverterAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '逆變器數量',
`PhotovoltaicPanelBrand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板廠牌',
`PhotovoltaicPanelProductModel` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板型號',
`PhotovoltaicPanelSpecification` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '光電板規格',
`PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '光電板數量',
`BoEFile` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局檔案',
`BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局折扣率',
`BoEDeviceRegisterNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局設備登記編號',
`BoERentRatio` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '能源局租金比率,單位(%)',
`TPCContractNumber` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電契約編號',
`TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '台電簽約日期',
`TPCSellDeadline` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電售電期限,單位(年)',
`TPCMeterReading` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '台電每期抄錶日',
`TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式購電日',
`TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式售電日',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`),
KEY `IDX_02` (`CompanyId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
-- 正在傾印表格 solar_power.power_station 的資料:~-1 rows (近似值)
DELETE FROM `power_station`;
/*!40000 ALTER TABLE `power_station` DISABLE KEYS */;
/*!40000 ALTER TABLE `power_station` ENABLE KEYS */;
-- 傾印 資料表 solar_power.role 結構
CREATE TABLE IF NOT EXISTS `role` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
`CompanyId` int(10) NOT NULL,
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '角色名稱',
`Layer` tinyint(4) NOT NULL DEFAULT -1 COMMENT '角色層級0平台(FIC)超級使用者 1平台(FIC)使用者 2公司管理員 3公司一般人員',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`),
KEY `IDX_02` (`CompanyId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色資料';
-- 正在傾印表格 solar_power.role 的資料:~-1 rows (近似值)
DELETE FROM `role`;
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
/*!40000 ALTER TABLE `role` ENABLE KEYS */;
-- 傾印 資料表 solar_power.role_auth 結構
CREATE TABLE IF NOT EXISTS `role_auth` (
`Id` int(10) unsigned NOT NULL,
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
PRIMARY KEY (`Id`,`AuthCode`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色權限';
-- 正在傾印表格 solar_power.role_auth 的資料:~-1 rows (近似值)
DELETE FROM `role_auth`;
/*!40000 ALTER TABLE `role_auth` DISABLE KEYS */;
/*!40000 ALTER TABLE `role_auth` ENABLE KEYS */;
-- 傾印 資料表 solar_power.user 結構
CREATE TABLE IF NOT EXISTS `user` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除, 0:否 1:是',
`Status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '狀態0:凍結 1:正常',
`Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '姓名',
`Account` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '帳號',
`Password` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '密碼',
`IsGod` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT '是否為超級使用者。1:是0:否',
`CompanyId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '公司編號',
`DepartmentId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '部門編號',
`RoleId` int(10) unsigned DEFAULT 0 COMMENT '權限角色編號',
`JobTitle` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '職稱',
`Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手機',
`Tel` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '市話',
`Email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電子信箱',
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
`UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者',
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
PRIMARY KEY (`Id`) USING BTREE,
KEY `IDX_01` (`Deleted`,`Status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='使用者資料表';
-- 正在傾印表格 solar_power.user 的資料:~-1 rows (近似值)
DELETE FROM `user`;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
-- 傾印 資料表 solar_power.variable 結構
CREATE TABLE IF NOT EXISTS `variable` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '變數名稱',
`value` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '變數內容值',
`remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '備註',
PRIMARY KEY (`id`),
KEY `IDX_01` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定變數';
-- 正在傾印表格 solar_power.variable 的資料:~-1 rows (近似值)
DELETE FROM `variable`;
/*!40000 ALTER TABLE `variable` DISABLE KEYS */;
/*!40000 ALTER TABLE `variable` ENABLE KEYS */;
/*!40000 ALTER TABLE `auth_page` DISABLE KEYS */;
INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `ControlName`) VALUES
('A', '系統管理', '帳號管理', 'User,Role'),
('B', '系統管理', '公司管理', 'Company'),
('C', '系統管理', '電站資料管理', 'AAA'),
('D', '系統管理', '定時任務設定', 'Setting'),
('E', '系統管理', '功能清單', 'ASDA'),
('F', '總覽', '地圖總覽', 'BBB'),
('G', '總攬', '電占總覽', 'CCC'),
('H', '總覽', '運為總覽', 'HHH'),
('J', '即時告警', '即時告警', 'JJJ'),
('K', '交叉分析', '逆變器', 'KKK'),
('L', '交叉分析', '電站運轉效率', 'LLL');
/*!40000 ALTER TABLE `auth_page` ENABLE KEYS */;
INSERT INTO `user` (`Id`, `Deleted`, `Status`, `Name`, `Account`, `Password`, `IsGod`, `CompanyId`, `DepartmentId`, `RoleId`, `JobTitle`, `Phone`, `Tel`, `Email`, `CreatedBy`, `CreatedAt`, `UpdatedBy`, `UpdatedAt`) VALUES
(1, 0, 1, '野原新之助', 'admin', 'Ki4SV2TZiQbvDjdEVLNMmVkJfZC9VyTh88DmLSXP+Iw=', 1, 1, 0, 1, NULL, '0987987987', NULL, 'god@admin.com', 1, '2021-06-07 19:19:08', NULL, '2021-06-13 19:08:22');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
-- 新增FIC平台公司
INSERT INTO `solar_power`.`company` (`Name`, `TaxIDNumber`, `Phone`, `Address`, `RegisterUpperLimit`, `CreatedBy`) VALUES ('大眾電腦', '20840777', '02-87518751', '臺北市內湖區陽光街300號1至9樓', '100', '1');
-- 新增平台管理員角色
INSERT INTO `solar_power`.`role` (`CompanyId`, `Name`, `Layer`, `CreatedBy`) VALUES ('1', '平台管理員', '0', '1');
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;