-- --------------------------------------------------------
-- 主機:                           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.area 結構
CREATE TABLE IF NOT EXISTS `area` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CityId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '縣市編號',
  `Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ZipCode` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`CityId`)
) ENGINE=InnoDB AUTO_INCREMENT=369 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='台灣區域';

-- 正在傾印表格  solar_power.area 的資料：~-1 rows (近似值)
DELETE FROM `area`;
/*!40000 ALTER TABLE `area` DISABLE KEYS */;
INSERT INTO `area` (`Id`, `CityId`, `Name`, `ZipCode`) VALUES
	(1, 2, '松山區', '01'),
	(2, 2, '信義區', '02'),
	(3, 2, '大安區', '03'),
	(4, 2, '中山區', '04'),
	(5, 2, '中正區', '05'),
	(6, 2, '大同區', '06'),
	(7, 2, '萬華區', '07'),
	(8, 2, '文山區', '08'),
	(9, 2, '南港區', '09'),
	(10, 2, '內湖區', '10'),
	(11, 2, '士林區', '11'),
	(12, 2, '北投區', '12'),
	(13, 17, '鹽埕區', '01'),
	(14, 17, '鼓山區', '02'),
	(15, 17, '左營區', '03'),
	(16, 17, '楠梓區', '04'),
	(17, 17, '三民區', '05'),
	(18, 17, '新興區', '06'),
	(19, 17, '前金區', '07'),
	(20, 17, '苓雅區', '08'),
	(21, 17, '前鎮區', '09'),
	(22, 17, '旗津區', '10'),
	(23, 17, '小港區', '11'),
	(24, 17, '鳳山區', '12'),
	(25, 17, '林園區', '13'),
	(26, 17, '大寮區', '14'),
	(27, 17, '大樹區', '15'),
	(28, 17, '大社區', '16'),
	(29, 17, '仁武區', '17'),
	(30, 17, '鳥松區', '18'),
	(31, 17, '岡山區', '19'),
	(32, 17, '橋頭區', '20'),
	(33, 17, '燕巢區', '21'),
	(34, 17, '田寮區', '22'),
	(35, 17, '阿蓮區', '23'),
	(36, 17, '路竹區', '24'),
	(37, 17, '湖內區', '25'),
	(38, 17, '茄萣區', '26'),
	(39, 17, '永安區', '27'),
	(40, 17, '彌陀區', '28'),
	(41, 17, '梓官區', '29'),
	(42, 17, '旗山區', '30'),
	(43, 17, '美濃區', '31'),
	(44, 17, '六龜區', '32'),
	(45, 17, '甲仙區', '33'),
	(46, 17, '杉林區', '34'),
	(47, 17, '內門區', '35'),
	(48, 17, '茂林區', '36'),
	(49, 17, '桃源區', '37'),
	(50, 17, '那瑪夏區', '38'),
	(51, 3, '板橋區', '01'),
	(52, 3, '三重區', '02'),
	(53, 3, '中和區', '03'),
	(54, 3, '永和區', '04'),
	(55, 3, '新莊區', '05'),
	(56, 3, '新店區', '06'),
	(57, 3, '樹林區', '07'),
	(58, 3, '鶯歌區', '08'),
	(59, 3, '三峽區', '09'),
	(60, 3, '淡水區', '10'),
	(61, 3, '汐止區', '11'),
	(62, 3, '瑞芳區', '12'),
	(63, 3, '土城區', '13'),
	(64, 3, '蘆洲區', '14'),
	(65, 3, '五股區', '15'),
	(66, 3, '泰山區', '16'),
	(67, 3, '林口區', '17'),
	(68, 3, '深坑區', '18'),
	(69, 3, '石碇區', '19'),
	(70, 3, '坪林區', '20'),
	(71, 3, '三芝區', '21'),
	(72, 3, '石門區', '22'),
	(73, 3, '八里區', '23'),
	(74, 3, '平溪區', '24'),
	(75, 3, '雙溪區', '25'),
	(76, 3, '貢寮區', '26'),
	(77, 3, '金山區', '27'),
	(78, 3, '萬里區', '28'),
	(79, 3, '烏來區', '29'),
	(80, 10, '中區', '01'),
	(81, 10, '東區', '02'),
	(82, 10, '南區', '03'),
	(83, 10, '西區', '04'),
	(84, 10, '北區', '05'),
	(85, 10, '西屯區', '06'),
	(86, 10, '南屯區', '07'),
	(87, 10, '北屯區', '08'),
	(88, 10, '豐原區', '09'),
	(89, 10, '東勢區', '10'),
	(90, 10, '大甲區', '11'),
	(91, 10, '清水區', '12'),
	(92, 10, '沙鹿區', '13'),
	(93, 10, '梧棲區', '14'),
	(94, 10, '后里區', '15'),
	(95, 10, '神岡區', '16'),
	(96, 10, '潭子區', '17'),
	(97, 10, '大雅區', '18'),
	(98, 10, '新社區', '19'),
	(99, 10, '石岡區', '20'),
	(100, 10, '外埔區', '21'),
	(101, 10, '大安區', '22'),
	(102, 10, '烏日區', '23'),
	(103, 10, '大肚區', '24'),
	(104, 10, '龍井區', '25'),
	(105, 10, '霧峰區', '26'),
	(106, 10, '太平區', '27'),
	(107, 10, '大里區', '28'),
	(108, 10, '和平區', '29'),
	(109, 16, '新營區', '01'),
	(110, 16, '鹽水區', '02'),
	(111, 16, '白河區', '03'),
	(112, 16, '柳營區', '04'),
	(113, 16, '後壁區', '05'),
	(114, 16, '東山區', '06'),
	(115, 16, '麻豆區', '07'),
	(116, 16, '下營區', '08'),
	(117, 16, '六甲區', '09'),
	(118, 16, '官田區', '10'),
	(119, 16, '大內區', '11'),
	(120, 16, '佳里區', '12'),
	(121, 16, '學甲區', '13'),
	(122, 16, '西港區', '14'),
	(123, 16, '七股區', '15'),
	(124, 16, '將軍區', '16'),
	(125, 16, '北門區', '17'),
	(126, 16, '新化區', '18'),
	(127, 16, '善化區', '19'),
	(128, 16, '新市區', '20'),
	(129, 16, '安定區', '21'),
	(130, 16, '山上區', '22'),
	(131, 16, '玉井區', '23'),
	(132, 16, '楠西區', '24'),
	(133, 16, '南化區', '25'),
	(134, 16, '左鎮', '26'),
	(135, 16, '仁德區', '27'),
	(136, 16, '歸仁區', '28'),
	(137, 16, '關廟區', '29'),
	(138, 16, '龍崎區', '30'),
	(139, 16, '永康區', '31'),
	(140, 16, '東區', '32'),
	(141, 16, '南區', '33'),
	(142, 16, '北區', '34'),
	(143, 16, '安南區', '35'),
	(144, 16, '安平區', '36'),
	(145, 16, '中西區', '37'),
	(146, 7, '宜蘭市', '01'),
	(147, 7, '羅東鎮', '02'),
	(148, 7, '蘇澳鎮', '03'),
	(149, 7, '頭城鎮', '04'),
	(150, 7, '礁溪鄉', '05'),
	(151, 7, '壯圍鄉', '06'),
	(152, 7, '員山鄉', '07'),
	(153, 7, '冬山鄉', '08'),
	(154, 7, '五結鄉', '09'),
	(155, 7, '三星鄉', '10'),
	(156, 7, '大同鄉', '11'),
	(157, 7, '南澳鄉', '12'),
	(158, 4, '桃園市', '01'),
	(159, 4, '中壢市', '02'),
	(160, 4, '大溪鎮', '03'),
	(161, 4, '楊梅市', '04'),
	(162, 4, '蘆竹市', '05'),
	(163, 4, '大園鄉', '06'),
	(164, 4, '龜山鄉', '07'),
	(165, 4, '八德市', '08'),
	(166, 4, '龍潭鄉', '09'),
	(167, 4, '平鎮市', '10'),
	(168, 4, '新屋鄉', '11'),
	(169, 4, '觀音鄉', '12'),
	(170, 4, '復興鄉', '13'),
	(171, 6, '竹北市', '01'),
	(172, 6, '竹東鎮', '02'),
	(173, 6, '新埔鎮', '03'),
	(174, 6, '關西鎮', '04'),
	(175, 6, '湖口鄉', '05'),
	(176, 6, '新豐鄉', '06'),
	(177, 6, '芎林鄉', '07'),
	(178, 6, '橫山鄉', '08'),
	(179, 6, '北埔鄉', '09'),
	(180, 6, '寶山鄉', '10'),
	(181, 6, '峨眉鄉', '11'),
	(182, 6, '尖石鄉', '12'),
	(183, 6, '五峰鄉', '13'),
	(184, 9, '苗栗市', '01'),
	(185, 9, '苑裡鎮', '02'),
	(186, 9, '通霄鎮', '03'),
	(187, 9, '竹南鎮', '04'),
	(188, 9, '頭份鎮', '05'),
	(189, 9, '後龍鎮', '06'),
	(190, 9, '卓蘭鎮', '07'),
	(191, 9, '大湖鄉', '08'),
	(192, 9, '公館鄉', '09'),
	(193, 9, '銅鑼鄉', '10'),
	(194, 9, '南庄鄉', '11'),
	(195, 9, '頭屋鄉', '12'),
	(196, 9, '三義鄉', '13'),
	(197, 9, '西湖鄉', '14'),
	(198, 9, '造橋鄉', '15'),
	(199, 9, '三灣鄉', '16'),
	(200, 9, '獅潭鄉', '17'),
	(201, 9, '泰安鄉', '18'),
	(202, 11, '彰化市', '01'),
	(203, 11, '鹿港鎮', '02'),
	(204, 11, '和美鎮', '03'),
	(205, 11, '線西鄉', '04'),
	(206, 11, '伸港鄉', '05'),
	(207, 11, '福興鄉', '06'),
	(208, 11, '秀水鄉', '07'),
	(209, 11, '花壇鄉', '08'),
	(210, 11, '芬園鄉', '09'),
	(211, 11, '員林鎮', '10'),
	(212, 11, '溪湖鎮', '11'),
	(213, 11, '田中鎮', '12'),
	(214, 11, '大村鄉', '13'),
	(215, 11, '埔鹽鄉', '14'),
	(216, 11, '埔心鄉', '15'),
	(217, 11, '永靖鄉', '16'),
	(218, 11, '社頭鄉', '17'),
	(219, 11, '二水鄉', '18'),
	(220, 11, '北斗鎮', '19'),
	(221, 11, '二林鎮', '20'),
	(222, 11, '田尾鄉', '21'),
	(223, 11, '埤頭鄉', '22'),
	(224, 11, '芳苑鄉', '23'),
	(225, 11, '大城鄉', '24'),
	(226, 11, '竹塘鄉', '25'),
	(227, 11, '溪州鄉', '26'),
	(228, 12, '南投市', '01'),
	(229, 12, '埔里鎮', '02'),
	(230, 12, '草屯鎮', '03'),
	(231, 12, '竹山鎮', '04'),
	(232, 12, '集集鎮', '05'),
	(233, 12, '名間鄉', '06'),
	(234, 12, '鹿谷鄉', '07'),
	(235, 12, '中寮鄉', '08'),
	(236, 12, '魚池鄉', '09'),
	(237, 12, '國姓鄉', '10'),
	(238, 12, '水里鄉', '11'),
	(239, 12, '信義鄉', '12'),
	(240, 12, '仁愛鄉', '13'),
	(241, 13, '斗六市', '01'),
	(242, 13, '斗南鎮', '02'),
	(243, 13, '虎尾鎮', '03'),
	(244, 13, '西螺鎮', '04'),
	(245, 13, '土庫鎮', '05'),
	(246, 13, '北港鎮', '06'),
	(247, 13, '古坑鄉', '07'),
	(248, 13, '大埤鄉', '08'),
	(249, 13, '莿桐鄉', '09'),
	(250, 13, '林內鄉', '10'),
	(251, 13, '二崙鄉', '11'),
	(252, 13, '崙背鄉', '12'),
	(253, 13, '麥寮鄉', '13'),
	(254, 13, '東勢鄉', '14'),
	(255, 13, '褒忠鄉', '15'),
	(256, 13, '臺西鄉', '16'),
	(257, 13, '元長鄉', '17'),
	(258, 13, '四湖鄉', '18'),
	(259, 13, '口湖鄉', '19'),
	(260, 13, '水林鄉', '20'),
	(261, 15, '太保市', '01'),
	(262, 15, '朴子市', '02'),
	(263, 15, '布袋鎮', '03'),
	(264, 15, '大林鎮', '04'),
	(265, 15, '民雄鄉', '05'),
	(266, 15, '溪口鄉', '06'),
	(267, 15, '新港鄉', '07'),
	(268, 15, '六腳鄉', '08'),
	(269, 15, '東石鄉', '09'),
	(270, 15, '義竹鄉', '10'),
	(271, 15, '鹿草鄉', '11'),
	(272, 15, '水上鄉', '12'),
	(273, 15, '中埔鄉', '13'),
	(274, 15, '竹崎鄉', '14'),
	(275, 15, '梅山鄉', '15'),
	(276, 15, '番路鄉', '16'),
	(277, 15, '大埔鄉', '17'),
	(278, 15, '阿里山鄉', '18'),
	(279, 18, '屏東市', '01'),
	(280, 18, '潮州鎮', '02'),
	(281, 18, '東港鎮', '03'),
	(282, 18, '恆春鎮', '04'),
	(283, 18, '萬丹鄉', '05'),
	(284, 18, '長治鄉', '06'),
	(285, 18, '麟洛鄉', '07'),
	(286, 18, '九如鄉', '08'),
	(287, 18, '里港鄉', '09'),
	(288, 18, '鹽埔鄉', '10'),
	(289, 18, '高樹鄉', '11'),
	(290, 18, '萬巒鄉', '12'),
	(291, 18, '內埔鄉', '13'),
	(292, 18, '竹田鄉', '14'),
	(293, 18, '新埤鄉', '15'),
	(294, 18, '枋寮鄉', '16'),
	(295, 18, '新園鄉', '17'),
	(296, 18, '崁頂鄉', '18'),
	(297, 18, '林邊鄉', '19'),
	(298, 18, '南州鄉', '20'),
	(299, 18, '佳冬鄉', '21'),
	(300, 18, '琉球鄉', '22'),
	(301, 18, '車城鄉', '23'),
	(302, 18, '滿州鄉', '24'),
	(303, 18, '枋山鄉', '25'),
	(304, 18, '三地門鄉', '26'),
	(305, 18, '霧臺鄉', '27'),
	(306, 18, '瑪家鄉', '28'),
	(307, 18, '泰武鄉', '29'),
	(308, 18, '來義鄉', '30'),
	(309, 18, '春日鄉', '31'),
	(310, 18, '獅子鄉', '32'),
	(311, 18, '牡丹鄉', '33'),
	(312, 19, '臺東市', '01'),
	(313, 19, '成功鎮', '02'),
	(314, 19, '關山鎮', '03'),
	(315, 19, '卑南鄉', '04'),
	(316, 19, '鹿野鄉', '05'),
	(317, 19, '池上鄉', '06'),
	(318, 19, '東河鄉', '07'),
	(319, 19, '長濱鄉', '08'),
	(320, 19, '太麻里鄉', '09'),
	(321, 19, '大武鄉', '10'),
	(322, 19, '綠島鄉', '11'),
	(323, 19, '海端鄉', '12'),
	(324, 19, '延平鄉', '13'),
	(325, 19, '金峰鄉', '14'),
	(326, 19, '達仁鄉', '15'),
	(327, 19, '蘭嶼鄉', '16'),
	(328, 8, '花蓮市', '01'),
	(329, 8, '鳳林鎮', '02'),
	(330, 8, '玉里鎮', '03'),
	(331, 8, '新城鄉', '04'),
	(332, 8, '吉安鄉', '05'),
	(333, 8, '壽豐鄉', '06'),
	(334, 8, '光復鄉', '07'),
	(335, 8, '豐濱鄉', '08'),
	(336, 8, '瑞穗鄉', '09'),
	(337, 8, '富里鄉', '10'),
	(338, 8, '秀林鄉', '11'),
	(339, 8, '萬榮鄉', '12'),
	(340, 8, '卓溪鄉', '13'),
	(341, 20, '馬公市', '01'),
	(342, 20, '湖西鄉', '02'),
	(343, 20, '白沙鄉', '03'),
	(344, 20, '西嶼鄉', '04'),
	(345, 20, '望安鄉', '05'),
	(346, 20, '七美鄉', '06'),
	(347, 1, '中正區', '01'),
	(348, 1, '七堵區', '02'),
	(349, 1, '暖暖區', '03'),
	(350, 1, '仁愛區', '04'),
	(351, 1, '中山區', '05'),
	(352, 1, '安樂區', '06'),
	(353, 1, '信義區', '07'),
	(354, 5, '東區', '01'),
	(355, 5, '北區', '02'),
	(356, 5, '香山區', '03'),
	(357, 14, '東區', '01'),
	(358, 14, '西區', '02'),
	(359, 22, '南竿鄉', '01'),
	(360, 22, '北竿鄉', '02'),
	(361, 22, '莒光鄉', '03'),
	(362, 22, '東引鄉', '04'),
	(363, 21, '金城鎮', '01'),
	(364, 21, '金沙鎮', '02'),
	(365, 21, '金湖鎮', '03'),
	(366, 21, '金寧鄉', '04'),
	(367, 21, '烈嶼鄉', '05'),
	(368, 21, '烏坵鄉', '06');
/*!40000 ALTER TABLE `area` ENABLE KEYS */;

-- 傾印  資料表 auth_page 結構
CREATE TABLE IF NOT EXISTS `auth_page` (
  `AuthCode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `MainName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '大項名稱',
  `SubName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '功能名稱',
  `TagName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '細項功能名稱',
  `ControlName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`AuthCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定權限頁面';

-- 正在傾印表格  auth_page 的資料
DELETE FROM `auth_page`;
/*!40000 ALTER TABLE `auth_page` DISABLE KEYS */;
INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `TagName`, `ControlName`) VALUES
	('A', '總覽', '地圖總覽', NULL, 'MapOverview'),
	('B', '總覽', '電站總覽', NULL, 'StationOverview'),
	('C', '總覽', '電站總覽', '即時資訊', 'StationOverview_UpToDate'),
	('D', '總覽', '電站總覽', '基本資料', 'StationOverview_Info'),
	('E', '總覽', '電站總覽', '歷史資料', 'StationOverview_History'),
	('F', '總覽', '電站總覽', '逆變器分析', 'StationOverview_Inverter'),
	('G', '總覽', '電站總覽', '異常記錄', 'StationOverview_Exception'),
	('H', '總覽', '電站總覽', '運維記錄', 'StationOverview_OperationRecord'),
	('J', '總覽', '電站總覽', '顯示發電金額', 'ShowMoney'),
	('K', '電站資訊', '電站資訊', NULL, 'PowerStationInfo'),
	('L', '交叉分析', '合併電站', NULL, 'AnalysisStationCombine'),
	('M', '交叉分析', '電站交叉分析', NULL, 'AnalysisStationInfo'),
	('N', '交叉分析', '逆變器交叉分析', NULL, 'AnalysisInverter'),
	('P', '報表查詢', '電站報表', NULL, 'CCC'),
	('Q', '報表查詢', '電廠發電效能統計', NULL, 'HHH'),
	('R', '報表查詢', '輸入台電售電紀錄', NULL, 'JJJ'),
	('S', '報表查詢', '報告發送設定', NULL, 'JJJ'),
	('T', '即時告警', '異常事件查詢', NULL, 'KKK'),
	('U', '運維管理', '電站管理', NULL, 'PowerStationManager'),
	('V', '運維管理', '定期計畫建立', NULL, 'Operation'),
	('W', '運維管理', '運維作業記錄', NULL, 'OperationRecord'),
	('X', '系統管理', '公司管理', NULL, 'Company'),
	('Y', '系統管理', '帳號管理', NULL, 'User,Role'),
	('Z', '系統管理', '定時任務設定', NULL, 'LLL');
/*!40000 ALTER TABLE `auth_page` ENABLE KEYS */;

-- 傾印  資料表 solar_power.city 結構
CREATE TABLE IF NOT EXISTS `city` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '縣市名稱',
  `ZipCode` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '縣市代碼',
  `Priority` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '優先順序',
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`Priority`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='台灣縣市';

-- 正在傾印表格  solar_power.city 的資料：~-1 rows (近似值)
DELETE FROM `city`;
/*!40000 ALTER TABLE `city` DISABLE KEYS */;
INSERT INTO `city` (`Id`, `Name`, `ZipCode`, `Priority`) VALUES
	(1, '基隆市', '020', 1),
	(2, '台北市', '021', 2),
	(3, '新北市', '022', 3),
	(4, '桃園縣', '030', 4),
	(5, '新竹市', '031', 5),
	(6, '新竹縣', '032', 6),
	(7, '宜蘭縣', '033', 19),
	(8, '花蓮縣', '034', 18),
	(9, '苗栗縣', '037', 7),
	(10, '台中市', '040', 8),
	(11, '彰化縣', '041', 9),
	(12, '南投縣', '049', 10),
	(13, '雲林縣', '050', 11),
	(14, '嘉義市', '051', 12),
	(15, '嘉義縣', '052', 13),
	(16, '台南市', '060', 14),
	(17, '高雄市', '070', 15),
	(18, '屏東縣', '080', 16),
	(19, '臺東縣', '089', 17),
	(20, '澎湖縣', '061', 20),
	(21, '金門縣', '082', 21),
	(22, '連江縣', '083', 22);
/*!40000 ALTER TABLE `city` ENABLE KEYS */;

-- 傾印  資料表 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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公司資料';

-- 正在傾印表格  solar_power.company 的資料：~-1 rows (近似值)
DELETE FROM `company`;
/*!40000 ALTER TABLE `company` DISABLE KEYS */;
INSERT INTO `company` (`Id`, `Deleted`, `Status`, `Name`, `Logo`, `TaxIDNumber`, `Phone`, `Address`, `RegisterUpperLimit`, `SPStationAmount`, `RelationalDB`, `CreatedBy`, `CreatedAt`, `UpdatedBy`, `UpdatedAt`) VALUES
	(1, 0, 1, '大眾電腦', NULL, '20840777', '02-87518751', '臺北市內湖區陽光街300號1至9樓', 100, 0, NULL, 1, '2021-06-14 14:52:20', NULL, '2021-06-14 14:52:37');	
/*!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.device 結構
CREATE TABLE IF NOT EXISTS `device` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `UID` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '設備編號，縣市 +區域+電廠流水號(0001~9999)+設備類別(字母：3碼) + SN(設備流水號；3碼)',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '所屬電站編號',
  `Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
  `Type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '類型',
  `TypeName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '類型名稱',
  `Brand` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '廠牌',
  `ProductModel` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '型號',
  `DBName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `TableName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ColName` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `Remark` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `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`) USING BTREE,
  KEY `IDX_02` (`UID`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='裝置列表';

-- 正在傾印表格  solar_power.device 的資料：~-1 rows (近似值)
DELETE FROM `device`;
/*!40000 ALTER TABLE `device` DISABLE KEYS */;
/*!40000 ALTER TABLE `device` ENABLE KEYS */;

-- 傾印  資料表 solar_power.land_building 結構
CREATE TABLE IF NOT EXISTS `land_building` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '所屬電站編號',
  `Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
  `LeaseNotarizationAt` timestamp NULL DEFAULT NULL COMMENT '租約公證日期',
  `Landowner` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地主姓名',
  `Purpose` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '房屋用途',
  `LeaseRate` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '租金比例(%)',
  `Coordinate` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
  `Phone` varchar(20) 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`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='土地與房屋';

-- 正在傾印表格  solar_power.land_building 的資料：~-1 rows (近似值)
DELETE FROM `land_building`;
/*!40000 ALTER TABLE `land_building` DISABLE KEYS */;
/*!40000 ALTER TABLE `land_building` ENABLE KEYS */;

-- 傾印  資料表 solar_power.operation_firm 結構
CREATE TABLE IF NOT EXISTS `operation_firm` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '所屬電站編號',
  `Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
  `Type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '廠商類別，0:施工 1:清洗 2:運維',
  `ContactPerson` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '聯絡人',
  `Phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話',
  `Email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Email',
  `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`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='運維廠商';

-- 正在傾印表格  solar_power.operation_firm 的資料：~-1 rows (近似值)
DELETE FROM `operation_firm`;
/*!40000 ALTER TABLE `operation_firm` DISABLE KEYS */;
/*!40000 ALTER TABLE `operation_firm` 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.operator_log 的資料：~-1 rows (近似值)
DELETE FROM `operator_log`;
/*!40000 ALTER TABLE `operator_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `operator_log` ENABLE KEYS */;

-- 傾印  資料表 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 '公司編號',
  `CityId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站縣市',
  `AreaId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站區域',
  `Address` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站詳細地址',
  `Name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
  `Code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼，縣市+區域+四碼流水號',
  `SerialNumber` varchar(4) 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` decimal(10,3) NOT NULL DEFAULT 0.000 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 DEFAULT NULL COMMENT '光電板規格',
  `PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '光電板數量',
  `BoEFileName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL 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`),
  KEY `IDX_03` (`CityId`,`AreaId`)
) 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.power_station_exception 結構
CREATE TABLE IF NOT EXISTS `power_station_exception` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
  `Type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '類型，0:PR值',
  `UpperLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '上限值',
  `LowerLimit` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '下限值',
  `Alarm` tinyint(4) NOT NULL DEFAULT 0 COMMENT '警報方式，0:email通知',
  `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`,`PowerStationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站異常值設定';

-- 正在傾印表格  solar_power.power_station_exception 的資料：~-1 rows (近似值)
DELETE FROM `power_station_exception`;
/*!40000 ALTER TABLE `power_station_exception` DISABLE KEYS */;
/*!40000 ALTER TABLE `power_station_exception` ENABLE KEYS */;

-- 傾印  資料表 solar_power.power_station_image 結構
CREATE TABLE IF NOT EXISTS `power_station_image` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
  `IsMainDisplay` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否主要顯示圖片， 0:否 1:是',
  ` image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
  `CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`Deleted`,`IsMainDisplay`,`PowerStationId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';

-- 正在傾印表格  solar_power.power_station_image 的資料：~-1 rows (近似值)
DELETE FROM `power_station_image`;
/*!40000 ALTER TABLE `power_station_image` DISABLE KEYS */;
/*!40000 ALTER TABLE `power_station_image` ENABLE KEYS */;

-- 傾印  資料表 solar_power.power_station_operation_personnel 結構
CREATE TABLE IF NOT EXISTS `power_station_operation_personnel` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0,
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
  `UserId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '人員編號',
  `CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`Deleted`),
  KEY `IDX_02` (`PowerStationId`,`UserId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站運維人員';

-- 正在傾印表格  solar_power.power_station_operation_personnel 的資料：~-1 rows (近似值)
DELETE FROM `power_station_operation_personnel`;
/*!40000 ALTER TABLE `power_station_operation_personnel` DISABLE KEYS */;
/*!40000 ALTER TABLE `power_station_operation_personnel` ENABLE KEYS */;

-- 傾印  資料表 solar_power.power_station_single_line_diagram 結構
CREATE TABLE IF NOT EXISTS `power_station_single_line_diagram` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否刪除， 0:否 1:是',
  `PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
  ` image` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '圖片檔名',
  `CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
  `CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`Deleted`,`PowerStationId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站單線圖';

-- 正在傾印表格  solar_power.power_station_single_line_diagram 的資料：~-1 rows (近似值)
DELETE FROM `power_station_single_line_diagram`;
/*!40000 ALTER TABLE `power_station_single_line_diagram` DISABLE KEYS */;
/*!40000 ALTER TABLE `power_station_single_line_diagram` 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 AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色資料';

-- 正在傾印表格  solar_power.role 的資料：~-1 rows (近似值)
DELETE FROM `role`;
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
INSERT INTO `role` (`Id`, `Deleted`, `CompanyId`, `Name`, `Layer`, `CreatedBy`, `CreatedAt`, `UpdatedBy`, `UpdatedAt`) VALUES
	(1, 0, 1, '平台管理員', 0, 1, '2021-06-14 14:48:15', NULL, NULL),
	(2, 0, 2, '公司管理員', 2, 1, '2021-06-14 17:38:49', NULL, NULL);
/*!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 */;
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=', 0, 1, 0, 1, NULL, '0987987987', NULL, 'god@admin.com', 1, '2021-06-07 19:19:08', NULL, '2021-06-14 14:30:02');
/*!40000 ALTER TABLE `user` ENABLE 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` text 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 AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定變數';

-- 正在傾印表格  solar_power.variable 的資料：~-1 rows (近似值)
DELETE FROM `variable`;
/*!40000 ALTER TABLE `variable` DISABLE KEYS */;
INSERT INTO `variable` (`id`, `name`, `value`, `remark`) VALUES
	(1, 'Type', '{"Type":[{"Name":"日照計","EName":"PYR"},{"Name":"模組溫度計","EName":"MTR"},{"Name":"環境溫度計","EName":"ETR"},{"Name":"環境濕度計","EName":"EMM"},{"Name":"風速計","EName":"VAN"},{"Name":" 電表","EName":"PWR"}]}', '裝置類型');
/*!40000 ALTER TABLE `variable` ENABLE KEYS */;


/******************************
** 後續SQL修改從以下開始新增 **
*******************************/
-- 設備流水號 - 2021/6/18 12:21:00
ALTER TABLE `device` ADD COLUMN `SerialNumber` VARCHAR(3) NULL DEFAULT NULL COMMENT '單一設備流水號' COLLATE 'utf8mb4_unicode_ci' AFTER `PowerStationId`;

-- 修改 公司子資料庫的欄位名稱 20210628
ALTER TABLE `company`
	CHANGE COLUMN `RelationalDB` `SiteDB` VARCHAR(50) NULL DEFAULT NULL COMMENT '公司各自資料庫' COLLATE 'utf8mb4_unicode_ci' AFTER `SPStationAmount`;

-- 創建 定期計畫建立資料表 20210628
CREATE TABLE `operation_plan_create` (
	`Id` INT(10) NOT NULL AUTO_INCREMENT COMMENT '流水號',
	`Deleted` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否刪除， 0:否 1:是',
	`PlanId` VARCHAR(50) NULL DEFAULT NULL COMMENT '計畫單號' COLLATE 'utf8mb4_unicode_ci',
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`SerialNumber` VARCHAR(4) NULL DEFAULT NULL COMMENT '計畫單號用流水號' COLLATE 'utf8mb4_unicode_ci',
	`ScheduleNum` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排程數字',
	`ScheduleType` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排程屬性，0:天 1:周 2:月 3:季 4:年',
	`WorkDay` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '預期工作天數',
	`StartTime` TIMESTAMP NULL DEFAULT NULL COMMENT '開始時間',
	`Type` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT '項目， 0:清洗 1:巡檢',
	`EmailType` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'email提醒種類，0:當天 1:前一天 2:前兩天 3:前三天',
	`Description` MEDIUMTEXT NULL DEFAULT NULL COMMENT '描述' COLLATE 'utf8mb4_unicode_ci',
	`CreatedBy` INT(10) NULL DEFAULT '0',
	`CreatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
	`UpdatedBy` INT(10) NULL DEFAULT '0',
	`UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`Deleted`, `PowerStationId`, `CreatedBy`, `StartTime`, `PlanId`) USING BTREE
)
COMMENT='運維計劃建立'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

-- 創建 運維作業記錄資料表 20210628
CREATE TABLE `operation_record` (
	`Id` INT(10) NOT NULL AUTO_INCREMENT COMMENT '流水號',
	`Deleted` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否刪除 0:否 1:是',
	`FormId` VARCHAR(20) NULL DEFAULT NULL COMMENT '表單號' COLLATE 'utf8mb4_unicode_ci',
	`SerialNumber` VARCHAR(4) NULL DEFAULT NULL COMMENT '表單流水號' COLLATE 'utf8_general_ci',
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`WorkType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '工作項目， 0:清洗 1:巡檢 2:維修',
	`ErrorCode` VARCHAR(50) NULL DEFAULT NULL COMMENT '異常代號' COLLATE 'utf8mb4_unicode_ci',
	`FixDo` VARCHAR(50) NULL DEFAULT '0' COMMENT '維修項目' COLLATE 'utf8mb4_unicode_ci',
	`Status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '狀態 0:未完成 1:完成 2:未完成-過期 3:完成-過期',
	`WorkPersonId` INT(10) NULL DEFAULT '0' COMMENT '工作人員編號',
	`StartTime` TIMESTAMP NULL DEFAULT NULL COMMENT '預計開始時間',
	`EndTime` TIMESTAMP NULL DEFAULT NULL COMMENT '預計結束時間',
	`FinishTime` TIMESTAMP NULL DEFAULT NULL COMMENT '完成時間',
	`WorkTime` TIMESTAMP NULL DEFAULT NULL COMMENT '作業時間',
	`Notice` MEDIUMTEXT NULL DEFAULT NULL COMMENT '注意事項' COLLATE 'utf8mb4_unicode_ci',
	`Description` MEDIUMTEXT NULL DEFAULT NULL COMMENT '結果描述' COLLATE 'utf8mb4_unicode_ci',
	`CreatedBy` INT(10) NULL DEFAULT NULL,
	`CreatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
	`UpdatedBy` INT(10) NULL DEFAULT NULL,
	`UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`Deleted`, `FormId`, `WorkPersonId`) USING BTREE
)
COMMENT='運維作業紀錄'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

-- 創建 運維作業記錄檔案資料表 20210628
CREATE TABLE `operation_record_file` (
	`Id` INT(10) NOT NULL AUTO_INCREMENT,
	`Deleted` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否刪除， 0:否 1:是',
	`RecordId` INT(10) NULL DEFAULT NULL COMMENT '主表流水號',
	`FileName` VARCHAR(100) NULL DEFAULT NULL COMMENT '檔案名稱' COLLATE 'utf8_general_ci',
	`CreatedBy` INT(10) UNSIGNED NOT NULL COMMENT '建立者',
	`CreatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立時間',
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`RecordId`, `Deleted`) USING BTREE
)
COMMENT='運維紀錄 檔案 or 圖片'
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

-- 創建 電站每小時歷史資料 20210702
CREATE TABLE `power_station_history_hour` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` BIGINT(20) NULL DEFAULT NULL,
	`SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`SITETYPE` INT(11) NULL DEFAULT NULL,
	`KWH` DOUBLE NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`TOTALKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`MP` DOUBLE NULL DEFAULT NULL,
	`SOLARHOUR` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每小時的歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 修改 power_station 欄位 20210702
ALTER TABLE `power_station`
	ADD COLUMN `today_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '今日kwhkwp' AFTER `Total_kwh`,
	ADD COLUMN `avg_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '30天平均kwhkwp' AFTER `today_kwhkwp`,
	ADD COLUMN `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
	ADD COLUMN `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`,
	ADD COLUMN `today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值' AFTER `total_money`,
	ADD COLUMN `avg_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均Pr值' AFTER `today_PR`,
	ADD COLUMN `today_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日減碳量' AFTER `avg_PR`,
	ADD COLUMN `total_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總減碳量' AFTER `today_carbon`,
	ADD COLUMN `today_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '今日日照度' AFTER `total_carbon`,
	ADD COLUMN `avg_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均日照度' AFTER `today_irradiance`,
	DROP COLUMN `kwhkwp`,
	DROP COLUMN `PR`,
	DROP COLUMN `MP`;

-- 創建 電站每天歷史資料 20210706
CREATE TABLE `power_station_history_day` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`SITETYPE` INT(11) NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`TOTALKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`MP` DOUBLE NULL DEFAULT NULL,
	`SOLARHOUR` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每天的歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 創建 電站每月歷史資料 20210706
CREATE TABLE `power_station_history_month` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`SITEID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`SITETYPE` INT(11) NULL DEFAULT NULL,
	`MONTHKWH` DOUBLE NULL DEFAULT NULL,
	`TOTALKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`MP` DOUBLE NULL DEFAULT NULL,
	`SOLARHOUR` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每月的歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 修改 電站資料 更新時間預設值
ALTER TABLE `power_station`
	CHANGE COLUMN `UpdatedAt` `UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間' AFTER `UpdatedBy`;
-- 新增欄位 電站資料 電站狀態
ALTER TABLE `power_station`
	ADD COLUMN `HealthStatus` TINYINT(4) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1:設備正常 2:設備斷線 3:設備異常' AFTER `AreaId`;

-- 各電站每天日照度的平均值 20210708
CREATE TABLE `sensor_history_day` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '每日平均日照度',
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每天日照度的平均值'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 各電站每小時日照度的平均值 20210708
CREATE TABLE `sensor_history_hour` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '即時平均日照度',
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每小時日照度的平均值'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 各電站每月日照度的平均值 20210708
CREATE TABLE `sensor_history_month` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '每月平均日照度',
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每月日照度的平均值'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 各電站每小時的逆變器歷史記錄 20210712
CREATE TABLE `inverter_history_hour` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DOUBLE NULL DEFAULT NULL,
	`AC1V` DOUBLE NULL DEFAULT NULL,
	`AC1A` DOUBLE NULL DEFAULT NULL,
	`AC1W` DOUBLE NULL DEFAULT NULL,
	`AC1F` DOUBLE NULL DEFAULT NULL,
	`AC1WH` DOUBLE NULL DEFAULT NULL,
	`AC2V` DOUBLE NULL DEFAULT NULL,
	`AC2A` DOUBLE NULL DEFAULT NULL,
	`AC2W` DOUBLE NULL DEFAULT NULL,
	`AC2F` DOUBLE NULL DEFAULT NULL,
	`AC2WH` DOUBLE NULL DEFAULT NULL,
	`AC3V` DOUBLE NULL DEFAULT NULL,
	`AC3A` DOUBLE NULL DEFAULT NULL,
	`AC3W` DOUBLE NULL DEFAULT NULL,
	`AC3F` DOUBLE NULL DEFAULT NULL,
	`AC3WH` DOUBLE NULL DEFAULT NULL,
	`DC1V` DOUBLE NULL DEFAULT NULL,
	`DC1A` DOUBLE NULL DEFAULT NULL,
	`DC1W` DOUBLE NULL DEFAULT NULL,
	`DC1KW` DOUBLE NULL DEFAULT NULL,
	`DC1WH` DOUBLE NULL DEFAULT NULL,
	`DC2V` DOUBLE NULL DEFAULT NULL,
	`DC2A` DOUBLE NULL DEFAULT NULL,
	`DC2W` DOUBLE NULL DEFAULT NULL,
	`DC2KW` DOUBLE NULL DEFAULT NULL,
	`DC2WH` DOUBLE NULL DEFAULT NULL,
	`DC3V` DOUBLE NULL DEFAULT NULL,
	`DC3A` DOUBLE NULL DEFAULT NULL,
	`DC3W` DOUBLE NULL DEFAULT NULL,
	`DC3KW` DOUBLE NULL DEFAULT NULL,
	`DC3WH` DOUBLE NULL DEFAULT NULL,
	`DC4V` DOUBLE NULL DEFAULT NULL,
	`DC4A` DOUBLE NULL DEFAULT NULL,
	`DC4W` DOUBLE NULL DEFAULT NULL,
	`DC4KW` DOUBLE NULL DEFAULT NULL,
	`DC4WH` DOUBLE NULL DEFAULT NULL,
	`DC5V` DOUBLE NULL DEFAULT NULL,
	`DC5A` DOUBLE NULL DEFAULT NULL,
	`DC5W` DOUBLE NULL DEFAULT NULL,
	`DC5KW` DOUBLE NULL DEFAULT NULL,
	`DC5WH` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`RA1` DOUBLE NULL DEFAULT NULL,
	`RA2` DOUBLE NULL DEFAULT NULL,
	`RA3` DOUBLE NULL DEFAULT NULL,
	`RA4` DOUBLE NULL DEFAULT NULL,
	`RA5` DOUBLE NULL DEFAULT NULL,
	`DCKW` DOUBLE NULL DEFAULT NULL,
	`ACKW` DOUBLE NULL DEFAULT NULL,
	`KWH` DOUBLE NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每小時的逆變器歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 各電站每天的逆變器歷史記錄 20210712
CREATE TABLE `inverter_history_day` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DOUBLE NULL DEFAULT NULL,
	`AC1V` DOUBLE NULL DEFAULT NULL,
	`AC1A` DOUBLE NULL DEFAULT NULL,
	`AC1W` DOUBLE NULL DEFAULT NULL,
	`AC1F` DOUBLE NULL DEFAULT NULL,
	`AC1WH` DOUBLE NULL DEFAULT NULL,
	`AC2V` DOUBLE NULL DEFAULT NULL,
	`AC2A` DOUBLE NULL DEFAULT NULL,
	`AC2W` DOUBLE NULL DEFAULT NULL,
	`AC2F` DOUBLE NULL DEFAULT NULL,
	`AC2WH` DOUBLE NULL DEFAULT NULL,
	`AC3V` DOUBLE NULL DEFAULT NULL,
	`AC3A` DOUBLE NULL DEFAULT NULL,
	`AC3W` DOUBLE NULL DEFAULT NULL,
	`AC3F` DOUBLE NULL DEFAULT NULL,
	`AC3WH` DOUBLE NULL DEFAULT NULL,
	`DC1V` DOUBLE NULL DEFAULT NULL,
	`DC1A` DOUBLE NULL DEFAULT NULL,
	`DC1W` DOUBLE NULL DEFAULT NULL,
	`DC1KW` DOUBLE NULL DEFAULT NULL,
	`DC1WH` DOUBLE NULL DEFAULT NULL,
	`DC2V` DOUBLE NULL DEFAULT NULL,
	`DC2A` DOUBLE NULL DEFAULT NULL,
	`DC2W` DOUBLE NULL DEFAULT NULL,
	`DC2KW` DOUBLE NULL DEFAULT NULL,
	`DC2WH` DOUBLE NULL DEFAULT NULL,
	`DC3V` DOUBLE NULL DEFAULT NULL,
	`DC3A` DOUBLE NULL DEFAULT NULL,
	`DC3W` DOUBLE NULL DEFAULT NULL,
	`DC3KW` DOUBLE NULL DEFAULT NULL,
	`DC3WH` DOUBLE NULL DEFAULT NULL,
	`DC4V` DOUBLE NULL DEFAULT NULL,
	`DC4A` DOUBLE NULL DEFAULT NULL,
	`DC4W` DOUBLE NULL DEFAULT NULL,
	`DC4KW` DOUBLE NULL DEFAULT NULL,
	`DC4WH` DOUBLE NULL DEFAULT NULL,
	`DC5V` DOUBLE NULL DEFAULT NULL,
	`DC5A` DOUBLE NULL DEFAULT NULL,
	`DC5W` DOUBLE NULL DEFAULT NULL,
	`DC5KW` DOUBLE NULL DEFAULT NULL,
	`DC5WH` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`RA1` DOUBLE NULL DEFAULT NULL,
	`RA2` DOUBLE NULL DEFAULT NULL,
	`RA3` DOUBLE NULL DEFAULT NULL,
	`RA4` DOUBLE NULL DEFAULT NULL,
	`RA5` DOUBLE NULL DEFAULT NULL,
	`DCKW` DOUBLE NULL DEFAULT NULL,
	`ACKW` DOUBLE NULL DEFAULT NULL,
	`KWH` DOUBLE NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每天的逆變器歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 各電站每月的逆變器歷史記錄 20210712
CREATE TABLE `inverter_history_month` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`Irradiance` DOUBLE NULL DEFAULT NULL,
	`AC1V` DOUBLE NULL DEFAULT NULL,
	`AC1A` DOUBLE NULL DEFAULT NULL,
	`AC1W` DOUBLE NULL DEFAULT NULL,
	`AC1F` DOUBLE NULL DEFAULT NULL,
	`AC1WH` DOUBLE NULL DEFAULT NULL,
	`AC2V` DOUBLE NULL DEFAULT NULL,
	`AC2A` DOUBLE NULL DEFAULT NULL,
	`AC2W` DOUBLE NULL DEFAULT NULL,
	`AC2F` DOUBLE NULL DEFAULT NULL,
	`AC2WH` DOUBLE NULL DEFAULT NULL,
	`AC3V` DOUBLE NULL DEFAULT NULL,
	`AC3A` DOUBLE NULL DEFAULT NULL,
	`AC3W` DOUBLE NULL DEFAULT NULL,
	`AC3F` DOUBLE NULL DEFAULT NULL,
	`AC3WH` DOUBLE NULL DEFAULT NULL,
	`DC1V` DOUBLE NULL DEFAULT NULL,
	`DC1A` DOUBLE NULL DEFAULT NULL,
	`DC1W` DOUBLE NULL DEFAULT NULL,
	`DC1KW` DOUBLE NULL DEFAULT NULL,
	`DC1WH` DOUBLE NULL DEFAULT NULL,
	`DC2V` DOUBLE NULL DEFAULT NULL,
	`DC2A` DOUBLE NULL DEFAULT NULL,
	`DC2W` DOUBLE NULL DEFAULT NULL,
	`DC2KW` DOUBLE NULL DEFAULT NULL,
	`DC2WH` DOUBLE NULL DEFAULT NULL,
	`DC3V` DOUBLE NULL DEFAULT NULL,
	`DC3A` DOUBLE NULL DEFAULT NULL,
	`DC3W` DOUBLE NULL DEFAULT NULL,
	`DC3KW` DOUBLE NULL DEFAULT NULL,
	`DC3WH` DOUBLE NULL DEFAULT NULL,
	`DC4V` DOUBLE NULL DEFAULT NULL,
	`DC4A` DOUBLE NULL DEFAULT NULL,
	`DC4W` DOUBLE NULL DEFAULT NULL,
	`DC4KW` DOUBLE NULL DEFAULT NULL,
	`DC4WH` DOUBLE NULL DEFAULT NULL,
	`DC5V` DOUBLE NULL DEFAULT NULL,
	`DC5A` DOUBLE NULL DEFAULT NULL,
	`DC5W` DOUBLE NULL DEFAULT NULL,
	`DC5KW` DOUBLE NULL DEFAULT NULL,
	`DC5WH` DOUBLE NULL DEFAULT NULL,
	`PR` DOUBLE NULL DEFAULT NULL,
	`RA1` DOUBLE NULL DEFAULT NULL,
	`RA2` DOUBLE NULL DEFAULT NULL,
	`RA3` DOUBLE NULL DEFAULT NULL,
	`RA4` DOUBLE NULL DEFAULT NULL,
	`RA5` DOUBLE NULL DEFAULT NULL,
	`DCKW` DOUBLE NULL DEFAULT NULL,
	`ACKW` DOUBLE NULL DEFAULT NULL,
	`KWH` DOUBLE NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每月的逆變器歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 新增模組溫度計溫度 20210712
ALTER TABLE `sensor_history_day`
	ADD COLUMN `Temperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '每日平均模組溫度計溫度' AFTER `Irradiance`;

ALTER TABLE `sensor_history_hour`
	ADD COLUMN `Temperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '即時模組溫度計溫度' AFTER `Irradiance`;

ALTER TABLE `sensor_history_month`
	ADD COLUMN `Temperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '每月平均模組溫度計溫度' AFTER `Irradiance`;

-- 電站新增降雨率、氣象站編號 20210713
ALTER TABLE `power_station`
	ADD COLUMN `WeathersStationId` VARCHAR(50) NULL DEFAULT NULL COMMENT '氣象站編號' AFTER `TodayWeatherTemp`,
	ADD COLUMN `RateOfRain` VARCHAR(50) NULL DEFAULT NULL COMMENT '今日降雨率' AFTER `WeathersStationId`;

-- 新增三張表(天氣觀測、天氣預報、天氣描述(固定值)) 20210713
CREATE TABLE IF NOT EXISTS `weather_description` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `WeatherName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '中文名稱',
  `WeatherValue` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分類代碼',
  `WeatherKey` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'icon代號',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=355 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='天氣描述分類';

-- 正在傾印表格  solar_power_test.weather_description 的資料：~0 rows (近似值)
DELETE FROM `weather_description`;
/*!40000 ALTER TABLE `weather_description` DISABLE KEYS */;
INSERT INTO `weather_description` (`Id`, `WeatherName`, `WeatherValue`, `WeatherKey`) VALUES
	(1, '晴天', '1', 'sun'),
	(2, '晴時多雲', '2', 'cloud-sun'),
	(3, '多雲時晴', '3', 'clouds-sun'),
	(4, '多雲', '4', 'clouds'),
	(5, '多雲時陰', '5', 'clouds'),
	(6, '陰時多雲', '6', 'clouds'),
	(7, '陰天', '7', 'clouds'),
	(8, '多雲陣雨', '8', 'cloud-rain'),
	(9, '多雲短暫雨', '8', 'cloud-rain'),
	(10, '多雲短暫陣雨', '8', 'cloud-rain'),
	(11, '午後短暫陣雨', '8', 'cloud-rain'),
	(12, '短暫陣雨', '8', 'cloud-sun-rain'),
	(13, '多雲時晴短暫陣雨', '8', 'cloud-sun-rain'),
	(14, '多雲時晴短暫雨', '8', 'cloud-sun-rain'),
	(15, '晴時多雲短暫陣雨', '8', 'cloud-sun-rain'),
	(16, '晴短暫陣雨', '8', 'cloud-sun-rain'),
	(17, '短暫雨', '8', 'cloud-showers'),
	(18, '多雲時陰短暫雨', '9', 'cloud-showers'),
	(19, '多雲時陰短暫陣雨', '9', 'cloud-showers'),
	(20, '陰時多雲短暫雨', '10', 'cloud-showers'),
	(21, '陰時多雲短暫陣雨', '10', 'cloud-showers'),
	(22, '雨天', '11', 'cloud-showers'),
	(23, '晴午後陰短暫雨', '11', 'cloud-sun-rain'),
	(24, '晴午後陰短暫陣雨', '11', 'cloud-sun-rain'),
	(25, '陰短暫雨', '11', 'cloud-sun-rain'),
	(26, '陰短暫陣雨', '11', 'cloud-sun-rain'),
	(27, '陰午後短暫陣雨', '11', 'cloud-sun-rain'),
	(28, '多雲時陰有雨', '12', 'cloud-sun-rain'),
	(29, '多雲時陰陣雨', '12', 'cloud-sun-rain'),
	(30, '晴時多雲陣雨', '12', 'cloud-sun-rain'),
	(31, '多雲時晴陣雨', '12', 'cloud-sun-rain'),
	(32, '陰時多雲有雨', '13', 'cloud-showers'),
	(33, '陰時多雲有陣雨', '13', 'cloud-showers'),
	(34, '陰時多雲陣雨', '13', 'cloud-showers'),
	(35, '陰有雨', '14', 'cloud-showers'),
	(36, '陰有陣雨', '14', 'cloud-showers'),
	(37, '陰雨', '14', 'cloud-showers'),
	(38, '陰陣雨', '14', 'cloud-showers'),
	(39, '陣雨', '14', 'cloud-showers'),
	(40, '午後陣雨', '14', 'cloud-showers'),
	(41, '有雨', '14', 'cloud-showers'),
	(42, '多雲陣雨或雷雨', '15', 'cloud-showers'),
	(43, '多雲短暫陣雨或雷雨', '15', 'cloud-showers'),
	(44, '多雲短暫雷陣雨', '15', 'cloud-showers'),
	(45, '多雲雷陣雨', '15', 'cloud-showers'),
	(46, '短暫陣雨或雷雨後多雲', '15', 'cloud-showers'),
	(47, '短暫雷陣雨後多雲', '15', 'cloud-showers'),
	(48, '短暫陣雨或雷雨', '15', 'cloud-showers'),
	(49, '晴時多雲短暫陣雨或雷雨', '15', 'cloud-sun-rain'),
	(50, '晴短暫陣雨或雷雨', '15', 'cloud-sun-rain'),
	(51, '多雲時晴短暫陣雨或雷雨', '15', 'cloud-sun-rain'),
	(52, '午後短暫雷陣雨', '15', 'cloud-sun-rain'),
	(53, '多雲時陰陣雨或雷雨', '16', 'cloud-showers'),
	(54, '多雲時陰短暫陣雨或雷雨', '16', 'cloud-rain'),
	(55, '多雲時陰短暫雷陣雨', '16', 'cloud-rain'),
	(56, '多雲時陰雷陣雨', '16', 'cloud-rain'),
	(57, '晴陣雨或雷雨', '16', 'cloud-sun-rain'),
	(58, '晴時多雲陣雨或雷雨', '16', 'cloud-sun-rain'),
	(59, '多雲時晴陣雨或雷雨', '16', 'cloud-sun-rain'),
	(60, '陰時多雲有雷陣雨', '17', 'cloud-rain'),
	(61, '陰時多雲陣雨或雷雨', '17', 'cloud-rain'),
	(62, '陰時多雲短暫陣雨或雷雨', '17', 'cloud-rain'),
	(63, '陰時多雲短暫雷陣雨', '17', 'cloud-rain'),
	(64, '陰時多雲雷陣雨', '17', 'cloud-rain'),
	(65, '陰有陣雨或雷雨', '18', 'cloud-rain'),
	(66, '陰有雷陣雨', '18', 'cloud-rain'),
	(67, '陰陣雨或雷雨', '18', 'cloud-rain'),
	(68, '陰雷陣雨', '18', 'cloud-rain'),
	(69, '晴午後陰短暫陣雨或雷雨', '18', 'cloud-sun-rain'),
	(70, '晴午後陰短暫雷陣雨', '18', 'cloud-sun-rain'),
	(71, '陰短暫陣雨或雷雨', '18', 'cloud-rain'),
	(72, '陰短暫雷陣雨', '18', 'cloud-showers'),
	(73, '雷雨', '18', 'cloud-showers'),
	(74, '陣雨或雷雨後多雲', '18', 'cloud-showers'),
	(75, '陰陣雨或雷雨後多雲', '18', 'cloud-showers'),
	(76, '陰短暫陣雨或雷雨後多雲', '18', 'cloud-showers'),
	(77, '陰短暫雷陣雨後多雲', '18', 'cloud-showers'),
	(78, '陰雷陣雨後多雲', '18', 'cloud-showers'),
	(79, '雷陣雨後多雲', '18', 'cloud-showers'),
	(80, '陣雨或雷雨', '18', 'cloud-showers'),
	(81, '雷陣雨', '18', 'cloud-showers'),
	(82, '午後雷陣雨', '18', 'cloud-sun-rain'),
	(83, '晴午後多雲局部雨', '19', 'cloud-sun-rain'),
	(84, '晴午後多雲局部陣雨', '19', 'cloud-sun-rain'),
	(85, '晴午後多雲局部短暫雨', '19', 'cloud-sun-rain'),
	(86, '晴午後多雲局部短暫陣雨', '19', 'cloud-sun-rain'),
	(87, '晴午後多雲短暫雨', '19', 'cloud-sun-rain'),
	(88, '晴午後多雲短暫陣雨', '19', 'cloud-sun-rain'),
	(89, '晴午後局部雨', '19', 'cloud-sun-rain'),
	(90, '晴午後局部陣雨', '19', 'cloud-sun-rain'),
	(91, '晴午後局部短暫雨', '19', 'cloud-sun-rain'),
	(92, '晴午後局部短暫陣雨', '19', 'cloud-sun-rain'),
	(93, '晴午後陣雨', '19', 'cloud-sun-rain'),
	(94, '晴午後短暫雨', '19', 'cloud-sun-rain'),
	(95, '晴午後短暫陣雨', '19', 'cloud-sun-rain'),
	(96, '晴時多雲午後短暫陣雨', '19', 'cloud-sun-rain'),
	(97, '多雲午後局部雨', '20', 'cloud-sun-rain'),
	(98, '多雲午後局部陣雨', '20', 'cloud-sun-rain'),
	(99, '多雲午後局部短暫雨', '20', 'cloud-sun-rain'),
	(100, '多雲午後局部短暫陣雨', '20', 'cloud-sun-rain'),
	(101, '多雲午後陣雨', '20', 'cloud-sun-rain'),
	(102, '多雲午後短暫雨', '20', 'cloud-sun-rain'),
	(103, '多雲午後短暫陣雨', '20', 'cloud-sun-rain'),
	(104, '多雲時陰午後短暫陣雨', '20', 'cloud-showers'),
	(105, '陰時多雲午後短暫陣雨', '20', 'cloud-showers'),
	(106, '多雲時晴午後短暫陣雨', '20', 'cloud-showers'),
	(107, '晴午後多雲陣雨或雷雨', '21', 'cloud-sun-rain'),
	(108, '晴午後多雲雷陣雨', '21', 'cloud-sun-rain'),
	(109, '晴午後陣雨或雷雨', '21', 'cloud-sun-rain'),
	(110, '晴午後雷陣雨', '21', 'cloud-sun-rain'),
	(111, '晴午後多雲局部陣雨或雷雨', '21', 'cloud-sun-rain'),
	(112, '晴午後多雲局部短暫陣雨或雷雨', '21', 'cloud-sun-rain'),
	(113, '晴午後多雲局部短暫雷陣雨', '21', 'cloud-sun-rain'),
	(114, '晴午後多雲局部雷陣雨', '21', 'cloud-sun-rain'),
	(115, '晴午後多雲短暫陣雨或雷雨', '21', 'cloud-sun-rain'),
	(116, '晴午後多雲短暫雷陣雨', '21', 'cloud-sun-rain'),
	(117, '晴午後局部短暫雷陣雨', '21', 'cloud-sun-rain'),
	(118, '晴午後局部雷陣雨', '21', 'cloud-sun-rain'),
	(119, '晴午後短暫雷陣雨', '21', 'cloud-sun-rain'),
	(120, '晴雷陣雨', '21', 'cloud-sun-rain'),
	(121, '晴時多雲雷陣雨', '21', 'cloud-sun-rain'),
	(122, '晴時多雲午後短暫雷陣雨', '21', 'cloud-sun-rain'),
	(123, '多雲午後局部陣雨或雷雨', '22', 'cloud-showers'),
	(124, '多雲午後局部短暫陣雨或', '22', 'cloud-showers'),
	(125, '多雲午後局部短暫雷陣雨', '22', 'cloud-showers'),
	(126, '多雲午後局部雷陣雨', '22', 'cloud-showers'),
	(127, '多雲午後陣雨或雷雨', '22', 'cloud-showers'),
	(128, '多雲午後短暫陣雨或雷雨', '22', 'cloud-showers'),
	(129, '多雲午後短暫雷陣雨', '22', 'cloud-showers'),
	(130, '多雲午後雷陣雨', '22', 'cloud-showers'),
	(131, '多雲時晴雷陣雨', '22', 'cloud-showers'),
	(132, '多雲時晴午後短暫雷陣雨', '22', 'cloud-showers'),
	(133, '多雲時陰午後短暫雷陣雨', '22', 'cloud-showers'),
	(134, '陰時多雲午後短暫雷陣雨', '22', 'cloud-showers'),
	(135, '陰午後短暫雷陣雨', '22', 'cloud-showers'),
	(136, '多雲局部陣雨或雪', '23', 'cloud-showers'),
	(137, '多雲時陰有雨或雪', '23', 'cloud-showers'),
	(138, '多雲時陰短暫雨或雪', '23', 'cloud-showers'),
	(139, '多雲短暫雨或雪', '23', 'cloud-showers'),
	(140, '陰有雨或雪', '23', 'cloud-showers'),
	(141, '陰時多雲有雨或雪', '23', 'cloud-showers'),
	(142, '陰時多雲短暫雨或雪', '23', 'cloud-showers'),
	(143, '陰短暫雨或雪', '23', 'cloud-showers'),
	(144, '多雲時陰有雪', '23', 'cloud-showers'),
	(145, '多雲時陰短暫雪', '23', 'cloud-showers'),
	(146, '多雲短暫雪', '23', 'cloud-showers'),
	(147, '陰有雪', '23', 'cloud-showers'),
	(148, '陰時多雲有雪', '23', 'cloud-showers'),
	(149, '陰時多雲短暫雪', '23', 'cloud-sleet'),
	(150, '陰短暫雪', '23', 'cloud-sleet'),
	(151, '有雨或雪', '23', 'cloud-sleet'),
	(152, '有雨或短暫雪', '23', 'cloud-sleet'),
	(153, '陰有雨或短暫雪', '23', 'cloud-sleet'),
	(154, '陰時多雲有雨或短暫雪', '23', 'cloud-sleet'),
	(155, '多雲時陰有雨或短暫雪', '23', 'cloud-sleet'),
	(156, '多雲有雨或短暫雪', '23', 'cloud-sleet'),
	(157, '多雲有雨或雪', '23', 'cloud-sleet'),
	(158, '多雲時晴有雨或雪', '23', 'cloud-sleet'),
	(159, '晴時多雲有雨或雪', '23', 'cloud-sleet'),
	(160, '晴有雨或雪', '23', 'cloud-sleet'),
	(161, '短暫雨或雪', '23', 'cloud-sleet'),
	(162, '多雲時晴短暫雨或雪', '23', 'cloud-sleet'),
	(163, '晴時多雲短暫雨或雪', '23', 'cloud-sleet'),
	(164, '晴短暫雨或雪', '23', 'cloud-sleet'),
	(165, '有雪', '23', 'cloud-snow'),
	(166, '多雲有雪', '23', 'cloud-snow'),
	(167, '多雲時晴有雪', '23', 'cloud-snow'),
	(168, '晴時多雲有雪', '23', 'cloud-snow'),
	(169, '晴有雪', '23', 'cloud-snow'),
	(170, '短暫雪', '23', 'cloud-snow'),
	(171, '多雲時晴短暫雪', '23', 'cloud-snow'),
	(172, '晴時多雲短暫雪', '23', 'cloud-snow'),
	(173, '晴短暫雪', '23', 'cloud-snow'),
	(174, '晴有霧', '24', 'sun-haze'),
	(175, '晴晨霧', '24', 'sun-haze'),
	(176, '晴時多雲有霧', '25', 'sun-haze'),
	(177, '晴時多雲晨霧', '25', 'fog'),
	(178, '多雲時晴有霧', '26', 'fog'),
	(179, '多雲時晴晨霧', '26', 'fog'),
	(180, '多雲有霧', '27', 'fog'),
	(181, '多雲晨霧', '27', 'fog'),
	(182, '有霧', '27', 'fog'),
	(183, '晨霧', '27', 'fog'),
	(184, '陰有霧', '28', 'fog'),
	(185, '陰晨霧', '28', 'fog'),
	(186, '多雲時陰有霧', '28', 'fog'),
	(187, '多雲時陰晨霧', '28', 'fog'),
	(188, '陰時多雲有霧', '28', 'fog'),
	(189, '陰時多雲晨霧', '28', 'fog'),
	(190, '多雲局部雨', '29', 'cloud-rain'),
	(191, '多雲局部陣雨', '29', 'cloud-rain'),
	(192, '多雲局部短暫雨', '29', 'cloud-rain'),
	(193, '多雲局部短暫陣雨', '29', 'cloud-rain'),
	(194, '多雲時陰局部雨', '30', 'cloud-rain'),
	(195, '多雲時陰局部陣雨', '30', 'cloud-rain'),
	(196, '多雲時陰局部短暫雨', '30', 'cloud-rain'),
	(197, '多雲時陰局部短暫陣雨', '30', 'cloud-rain'),
	(198, '晴午後陰局部雨', '30', 'cloud-sun-rain'),
	(199, '晴午後陰局部陣雨', '30', 'cloud-sun-rain'),
	(200, '晴午後陰局部短暫雨', '30', 'cloud-sun-rain'),
	(201, '晴午後陰局部短暫陣雨', '30', 'cloud-sun-rain'),
	(202, '陰局部雨', '30', 'cloud-rain'),
	(203, '陰局部陣雨', '30', 'cloud-rain'),
	(204, '陰局部短暫雨', '30', 'cloud-rain'),
	(205, '陰局部短暫陣雨', '30', 'cloud-rain'),
	(206, '陰時多雲局部雨', '30', 'cloud-rain'),
	(207, '陰時多雲局部陣雨', '30', 'cloud-rain'),
	(208, '陰時多雲局部短暫雨', '30', 'cloud-rain'),
	(209, '陰時多雲局部短暫陣雨', '30', 'cloud-rain'),
	(210, '多雲有霧有局部雨', '31', 'cloud-rain'),
	(211, '多雲有霧有局部陣雨', '31', 'cloud-rain'),
	(212, '多雲有霧有局部短暫雨', '31', 'cloud-rain'),
	(213, '多雲有霧有局部短暫陣雨', '31', 'cloud-rain'),
	(214, '多雲有霧有陣雨', '31', 'cloud-rain'),
	(215, '多雲有霧有短暫雨', '31', 'cloud-rain'),
	(216, '多雲有霧有短暫陣雨', '31', 'cloud-rain'),
	(217, '多雲局部雨有霧', '31', 'cloud-rain'),
	(218, '多雲局部雨晨霧', '31', 'cloud-rain'),
	(219, '多雲局部陣雨有霧', '31', 'cloud-rain'),
	(220, '多雲局部陣雨晨霧', '31', 'cloud-rain'),
	(221, '多雲局部短暫雨有霧', '31', 'cloud-rain'),
	(222, '多雲局部短暫雨晨霧', '31', 'cloud-rain'),
	(223, '多雲局部短暫陣雨有霧', '31', 'cloud-rain'),
	(224, '多雲局部短暫陣雨晨霧', '31', 'cloud-rain'),
	(225, '多雲陣雨有霧', '31', 'cloud-rain'),
	(226, '多雲短暫雨有霧', '31', 'cloud-rain'),
	(227, '多雲短暫雨晨霧', '31', 'cloud-rain'),
	(228, '多雲短暫陣雨有霧', '31', 'cloud-rain'),
	(229, '多雲短暫陣雨晨霧', '31', 'cloud-rain'),
	(230, '有霧有短暫雨', '31', 'cloud-rain'),
	(231, '有霧有短暫陣雨', '31', 'cloud-rain'),
	(232, '多雲時陰有霧有局部雨', '32', 'cloud-rain'),
	(233, '多雲時陰有霧有局部陣雨', '32', 'cloud-rain'),
	(234, '多雲時陰有霧有局部短暫雨', '32', 'cloud-rain'),
	(235, '多雲時陰有霧有局部短暫陣雨', '32', 'cloud-rain'),
	(236, '多雲時陰有霧有陣雨', '32', 'cloud-rain'),
	(237, '多雲時陰有霧有短暫雨', '32', 'cloud-rain'),
	(238, '多雲時陰有霧有短暫陣雨', '32', 'cloud-rain'),
	(239, '多雲時陰局部雨有霧', '32', 'cloud-rain'),
	(240, '多雲時陰局部陣雨有霧', '32', 'cloud-rain'),
	(241, '多雲時陰局部短暫雨有霧', '32', 'cloud-rain'),
	(242, '多雲時陰局部短暫陣雨有霧', '32', 'cloud-rain'),
	(243, '多雲時陰陣雨有霧', '32', 'cloud-rain'),
	(244, '多雲時陰短暫雨有霧', '32', 'cloud-rain'),
	(245, '多雲時陰短暫雨晨霧', '32', 'cloud-rain'),
	(246, '多雲時陰短暫陣雨有霧', '32', 'cloud-rain'),
	(247, '多雲時陰短暫陣雨晨霧', '32', 'cloud-rain'),
	(248, '陰有霧有陣雨', '32', 'cloud-rain'),
	(249, '陰局部雨有霧', '32', 'cloud-rain'),
	(250, '陰局部陣雨有霧', '32', 'cloud-rain'),
	(251, '陰局部短暫陣雨有霧', '32', 'cloud-rain'),
	(252, '陰時多雲有霧有局部雨', '32', 'cloud-rain'),
	(253, '陰時多雲有霧有局部陣雨', '32', 'cloud-rain'),
	(254, '陰時多雲有霧有局部短暫雨', '32', 'cloud-rain'),
	(255, '陰時多雲有霧有局部短暫陣雨', '32', 'cloud-rain'),
	(256, '陰時多雲有霧有陣雨', '32', 'cloud-rain'),
	(257, '陰時多雲有霧有短暫雨', '32', 'cloud-rain'),
	(258, '陰時多雲有霧有短暫陣雨', '32', 'cloud-rain'),
	(259, '陰時多雲局部雨有霧', '32', 'cloud-rain'),
	(260, '陰時多雲局部陣雨有霧', '32', 'cloud-rain'),
	(261, '陰時多雲局部短暫雨有霧', '32', 'cloud-rain'),
	(262, '陰時多雲局部短暫陣雨有霧', '32', 'cloud-rain'),
	(263, '陰時多雲陣雨有霧', '32', 'cloud-rain'),
	(264, '陰時多雲短暫雨有霧', '32', 'cloud-rain'),
	(265, '陰時多雲短暫雨晨霧', '32', 'cloud-rain'),
	(266, '陰時多雲短暫陣雨有霧', '32', 'cloud-rain'),
	(267, '陰時多雲短暫陣雨晨霧', '32', 'cloud-rain'),
	(268, '陰陣雨有霧', '32', 'cloud-rain'),
	(269, '陰短暫雨有霧', '32', 'cloud-rain'),
	(270, '陰短暫雨晨霧', '32', 'cloud-rain'),
	(271, '陰短暫陣雨有霧', '32', 'cloud-rain'),
	(272, '陰短暫陣雨晨霧', '32', 'cloud-rain'),
	(273, '多雲局部陣雨或雷雨', '33', 'cloud-rain'),
	(274, '多雲局部短暫陣雨或雷雨', '33', 'cloud-rain'),
	(275, '多雲局部短暫雷陣雨', '33', 'cloud-rain'),
	(276, '多雲局部雷陣雨', '33', 'cloud-rain'),
	(277, '多雲時陰局部陣雨或雷雨', '34', 'cloud-rain'),
	(278, '多雲時陰局部短暫陣雨或雷雨', '34', 'cloud-rain'),
	(279, '多雲時陰局部短暫雷陣雨', '34', 'cloud-rain'),
	(280, '多雲時陰局部雷陣雨', '34', 'cloud-rain'),
	(281, '晴午後陰局部陣雨或雷雨', '34', 'cloud-sun-rain'),
	(282, '晴午後陰局部短暫陣雨或雷雨', '34', 'cloud-sun-rain'),
	(283, '晴午後陰局部短暫雷陣雨', '34', 'cloud-sun-rain'),
	(284, '晴午後陰局部雷陣雨', '34', 'cloud-sun-rain'),
	(285, '陰局部陣雨或雷雨', '34', 'cloud-showers'),
	(286, '陰局部短暫陣雨或雷雨', '34', 'cloud-showers'),
	(287, '陰局部短暫雷陣雨', '34', 'cloud-showers'),
	(288, '陰局部雷陣雨', '34', 'cloud-showers'),
	(289, '陰時多雲局部陣雨或雷雨', '34', 'cloud-showers'),
	(290, '陰時多雲局部短暫陣雨或雷雨', '34', 'cloud-showers'),
	(291, '陰時多雲局部短暫雷陣雨', '34', 'cloud-showers'),
	(292, '陰時多雲局部雷陣雨', '34', 'cloud-showers'),
	(293, '多雲有陣雨或雷雨有霧', '35', 'cloud-showers'),
	(294, '多雲有雷陣雨有霧', '35', 'cloud-showers'),
	(295, '多雲有霧有陣雨或雷雨', '35', 'cloud-showers'),
	(296, '多雲有霧有雷陣雨', '35', 'cloud-showers'),
	(297, '多雲局部陣雨或雷雨有霧', '35', 'cloud-showers'),
	(298, '多雲局部短暫陣雨或雷雨有霧', '35', 'cloud-showers'),
	(299, '多雲局部短暫雷陣雨有霧', '35', 'cloud-showers'),
	(300, '多雲局部雷陣雨有霧', '35', 'cloud-showers'),
	(301, '多雲陣雨或雷雨有霧', '35', 'cloud-showers'),
	(302, '多雲短暫陣雨或雷雨有霧', '35', 'cloud-showers'),
	(303, '多雲短暫雷陣雨有霧', '35', 'cloud-showers'),
	(304, '多雲雷陣雨有霧', '35', 'cloud-showers'),
	(305, '多雲時晴短暫陣雨或雷雨有霧', '35', 'cloud-showers'),
	(306, '多雲時陰有陣雨或雷雨有霧', '36', 'cloud-showers'),
	(307, '多雲時陰有雷陣雨有霧', '36', 'cloud-showers'),
	(308, '多雲時陰有霧有陣雨或雷雨', '36', 'cloud-showers'),
	(309, '多雲時陰有霧有雷陣雨', '36', 'cloud-showers'),
	(310, '多雲時陰局部陣雨或雷雨', '36', 'cloud-showers'),
	(311, '有霧', '36', 'cloud-showers'),
	(312, '多雲時陰局部短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(313, '多雲時陰局部短暫雷陣雨有霧', '36', 'cloud-showers'),
	(314, '多雲時陰局部雷陣雨有霧', '36', 'cloud-showers'),
	(315, '多雲時陰陣雨或雷雨有霧', '36', 'cloud-showers'),
	(316, '多雲時陰短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(317, '多雲時陰短暫雷陣雨有霧', '36', 'cloud-showers'),
	(318, '多雲時陰雷陣雨有霧', '36', 'cloud-showers'),
	(319, '陰局部陣雨或雷雨有霧', '36', 'cloud-showers'),
	(320, '陰局部短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(321, '陰局部短暫雷陣雨有霧', '36', 'cloud-showers'),
	(322, '陰局部雷陣雨有霧', '36', 'cloud-showers'),
	(323, '陰時多雲有陣雨或雷雨有霧', '36', 'cloud-showers'),
	(324, '陰時多雲有雷陣雨有霧', '36', 'cloud-showers'),
	(325, '陰時多雲有霧有陣雨或雷雨', '36', 'cloud-showers'),
	(326, '陰時多雲有霧有雷陣雨', '36', 'cloud-showers'),
	(327, '陰時多雲局部陣雨或雷雨有霧', '36', 'cloud-showers'),
	(328, '陰時多雲局部短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(329, '陰時多雲局部短暫雷陣雨有霧', '36', 'cloud-showers'),
	(330, '陰時多雲局部雷陣雨有霧', '36', 'cloud-showers'),
	(331, '陰時多雲陣雨或雷雨有霧', '36', 'cloud-showers'),
	(332, '陰時多雲短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(333, '陰時多雲短暫雷陣雨有霧', '36', 'cloud-showers'),
	(334, '陰時多雲雷陣雨有霧', '36', 'cloud-showers'),
	(335, '陰短暫陣雨或雷雨有霧', '36', 'cloud-showers'),
	(336, '陰短暫雷陣雨有霧', '36', 'cloud-showers'),
	(337, '雷陣雨有霧', '36', 'cloud-showers'),
	(338, '多雲局部雨或雪有霧', '37', 'cloud-showers'),
	(339, '多雲時陰局部雨或雪有霧', '37', 'cloud-showers'),
	(340, '陰時多雲局部雨或雪有霧', '37', 'cloud-showers'),
	(341, '陰局部雨或雪有霧', '37', 'cloud-showers'),
	(342, '短暫雨或雪有霧', '37', 'cloud-showers'),
	(343, '有雨或雪有霧', '37', 'cloud-showers'),
	(344, '短暫陣雨有霧', '38', 'cloud-showers'),
	(345, '短暫陣雨晨霧', '38', 'cloud-showers'),
	(346, '短暫雨有霧', '38', 'cloud-showers'),
	(347, '短暫雨晨霧', '38', 'cloud-showers'),
	(348, '有雨有霧', '39', 'cloud-sleet'),
	(349, '陣雨有霧', '39', 'cloud-showers'),
	(350, '短暫陣雨或雷雨有霧', '41', 'cloud-showers'),
	(351, '陣雨或雷雨有霧', '41', 'cloud-showers'),
	(352, '下雪', '42', 'cloud-snow'),
	(353, '積冰', '42', 'cloud-snow'),
	(354, '暴風雪', '42', 'cloud-meatball');
/*!40000 ALTER TABLE `weather_description` ENABLE KEYS */;

-- 傾印  資料表 solar_power_test.weather_forecast 結構
CREATE TABLE IF NOT EXISTS `weather_forecast` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `LocationName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `StartTime` timestamp NULL DEFAULT NULL COMMENT '開始時間',
  `EndTime` timestamp NULL DEFAULT NULL COMMENT '結束時間',
  `Wx` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '天氣現象',
  `WxValue` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '天氣現象代號',
  `PoP` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '降雨機率',
  `CreatedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`LocationName`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='天氣預報';



-- 傾印  資料表 solar_power_test.weather_observation 結構
CREATE TABLE IF NOT EXISTS `weather_observation` (
  `Id` int(10) NOT NULL AUTO_INCREMENT COMMENT '流水號',
  `PowerStationId` int(10) DEFAULT NULL COMMENT '電站流水號',
  `ObsTime` timestamp NULL DEFAULT NULL COMMENT '紀錄時間',
  `Temp` double DEFAULT NULL COMMENT '溫度',
  PRIMARY KEY (`Id`),
  KEY `IDX_01` (`PowerStationId`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='天氣觀測';



-- 傾印 alarmorion_orionalarmclass 結構
CREATE TABLE IF NOT EXISTS `alarmorion_orionalarmclass` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `alarmClass` varchar(64) NOT NULL,
  `unackedAlarmCount` int(11) DEFAULT NULL,
  `openAlarmCount` int(11) DEFAULT NULL,
  `inAlarmCount` int(11) DEFAULT NULL,
  `totalAlarmCount` int(11) DEFAULT NULL,
  `timeOfLastAlarm` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `alarmOrion_OrionAlarmClassalarmClassUQ` (`alarmClass`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 正在傾印表格 alarmorion_orionalarmclass 的資料
DELETE FROM `alarmorion_orionalarmclass`;
/*!40000 ALTER TABLE `alarmorion_orionalarmclass` DISABLE KEYS */;
INSERT INTO `alarmorion_orionalarmclass` (`id`, `alarmClass`, `unackedAlarmCount`, `openAlarmCount`, `inAlarmCount`, `totalAlarmCount`, `timeOfLastAlarm`) VALUES
	(1, 'defaultAlarmClass', 0, 0, 0, 1, 1625569030632),
	(2, 'Network', 7, 7, 0, 9, 1625728376568),
	(3, 'Inverter', 78, 78, 0, 79, 1625722999680),
	(4, 'PR', 2, 2, 0, 6, 1625653811674);
/*!40000 ALTER TABLE `alarmorion_orionalarmclass` ENABLE KEYS */;

-- 傾印 ref_err_device 結構
CREATE TABLE IF NOT EXISTS `ref_err_device` (
  `id` smallint(2) NOT NULL,
  `deviceType` varchar(20) DEFAULT NULL COMMENT '設備類別',
  `errCode` smallint(1) DEFAULT NULL COMMENT '錯誤代碼',
  `errMsg` varchar(40) DEFAULT NULL,
  `errMsg_tw` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

-- 正在傾印表格 ref_err_device 的資料
DELETE FROM `ref_err_device`;
/*!40000 ALTER TABLE `ref_err_device` DISABLE KEYS */;
INSERT INTO `ref_err_device` (`id`, `deviceType`, `errCode`, `errMsg`, `errMsg_tw`) VALUES
	(1, 'DeviceNetwork', 1, 'b:true', '設備斷線'),
	(2, 'Network', 2, 'b:true', '網路斷線'),
	(3, 'PR', 6, 'd', 'PR異常');
/*!40000 ALTER TABLE `ref_err_device` ENABLE KEYS */;

-- 傾印  資料表 solar_power_test.ref_err_inv 結構
CREATE TABLE IF NOT EXISTS `ref_err_inv` (
  `id` smallint(2) NOT NULL,
  `brend` varchar(30) DEFAULT NULL COMMENT '廠牌',
  `deviceType` varchar(20) DEFAULT NULL COMMENT '設備類別',
  `errCode` smallint(1) DEFAULT NULL COMMENT '錯誤代碼',
  `errMsg` varchar(40) DEFAULT NULL,
  `errMsg_tw` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

-- 正在傾印表格  solar_power_test.ref_err_inv 的資料：~8 rows (近似值)
DELETE FROM `ref_err_inv`;
/*!40000 ALTER TABLE `ref_err_inv` DISABLE KEYS */;
INSERT INTO `ref_err_inv` (`id`, `brend`, `deviceType`, `errCode`, `errMsg`, `errMsg_tw`) VALUES
	(1, 'solaredge', 'inverter', 1, 'Off', '關機'),
	(2, 'solaredge', 'inverter', 2, 'Night mode', '夜間模式'),
	(3, 'solaredge', 'inverter', 3, 'Grid Monitoring/wake-up', '監控中/開機'),
	(4, 'solaredge', 'inverter', 4, 'Inverter is ON and producing power', '正常'),
	(5, 'solaredge', 'inverter', 5, 'Production (curtailed)', '電力縮減'),
	(6, 'solaredge', 'inverter', 6, 'Shutting down', '關機中'),
	(7, 'solaredge', 'inverter', 7, 'Fault', '設備異常'),
	(8, 'solaredge', 'inverter', 8, 'Maintenance/setup', '維修中/設定中');

-- 新增定時任務紀錄時間 20210714
ALTER TABLE `operation_plan_create`
	ADD COLUMN `LastCreateTime` TIMESTAMP NULL DEFAULT NULL COMMENT '最新一次產生紀錄時間' AFTER `Description`;

-- 修改欄位值 20210714
ALTER TABLE `operation_plan_create`
	CHANGE COLUMN `UpdatedAt` `UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP() AFTER `UpdatedBy`;
ALTER TABLE `operation_record`
	CHANGE COLUMN `FixDo` `FixDo` VARCHAR(50) NULL DEFAULT NULL COMMENT '維修項目' COLLATE 'utf8mb4_unicode_ci' AFTER `ErrorCode`;

-- 各電站每15min的逆變器歷史記錄 20210715
CREATE TABLE `inverter_history_15min` (
	`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`INVERTERID` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`KWH` DOUBLE NULL DEFAULT NULL,
	`TODAYKWH` DOUBLE NULL DEFAULT NULL,
	`KWHKWP` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE,
	INDEX `IDX_01` (`PowerStationId`) USING BTREE
)
COMMENT='各電站每15min的逆變器歷史記錄'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


-- 新增發電金額及減碳量 20210716
ALTER TABLE `power_station_history_hour`
	ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
	ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;
ALTER TABLE `power_station_history_day`
	ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
	ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;
ALTER TABLE `power_station_history_month`
	ADD COLUMN `MONEY` DOUBLE NULL DEFAULT NULL AFTER `SOLARHOUR`,
	ADD COLUMN `CARBON` DOUBLE NULL DEFAULT NULL AFTER `MONEY`;



-- 新增累計金額及減碳量 20210719
ALTER TABLE `power_station_history_hour`
	ADD COLUMN `TODAYMONEY` DOUBLE NULL DEFAULT NULL AFTER `MONEY`,
	ADD COLUMN `TOTALMONEY` DOUBLE NULL DEFAULT NULL AFTER `TODAYMONEY`,
	ADD COLUMN `TODAYCARBON` DOUBLE NULL DEFAULT NULL AFTER `CARBON`,
	ADD COLUMN `TOTALCARBON` DOUBLE NULL DEFAULT NULL AFTER `TODAYCARBON`;

ALTER TABLE `power_station_history_day`
	ADD COLUMN `TOTALMONEY` DOUBLE NULL DEFAULT NULL AFTER `MONEY`,
	ADD COLUMN `TOTALCARBON` DOUBLE NULL DEFAULT NULL AFTER `CARBON`;

ALTER TABLE `power_station_history_month`
	ADD COLUMN `TOTALMONEY` DOUBLE NULL DEFAULT NULL AFTER `MONEY`,
	ADD COLUMN `TOTALCARBON` DOUBLE NULL DEFAULT NULL AFTER `CARBON`;

-- 修正 欄位名稱 20210720
ALTER TABLE `power_station`
	CHANGE COLUMN `today_monery` `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額' AFTER `avg_kwhkwp`,
	CHANGE COLUMN `total_monery` `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額' AFTER `today_money`;

-- 各電站每小時的sensor avg 歷史資料 20210721
CREATE TABLE `sensoravg_history_hour` (
	`Id` INT(11) NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE
)
COMMENT='各電站每小時的sensor avg 歷史資料'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 各電站每天的sensor avg 歷史資料 20210721
CREATE TABLE `sensoravg_history_day` (
	`Id` INT(11) NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE
)
COMMENT='各電站每天的sensor avg 歷史資料'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

-- 各電站每月的sensor avg 歷史資料 20210721
CREATE TABLE `sensoravg_history_month` (
	`Id` INT(11) NOT NULL AUTO_INCREMENT,
	`PowerStationId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站編號',
	`TIMESTAMP` TIMESTAMP NULL DEFAULT NULL,
	`SENSORAVG01` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG02` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG03` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG04` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG05` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG06` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG07` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG08` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG09` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG10` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG11` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG12` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG13` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG14` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG15` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG16` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG17` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG18` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG19` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG20` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG21` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG22` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG23` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG24` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG25` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG26` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG27` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG28` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG29` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG30` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG31` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG32` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG33` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG34` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG35` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG36` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG37` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG38` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG39` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG40` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG41` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG42` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG43` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG44` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG45` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG46` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG47` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG48` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG49` DOUBLE NULL DEFAULT NULL,
	`SENSORAVG50` DOUBLE NULL DEFAULT NULL,
	PRIMARY KEY (`Id`) USING BTREE
)
COMMENT='各電站每月的sensor avg 歷史資料'
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2
;



/*!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) */;
