This commit is contained in:
桂任 林 2021-06-18 11:46:53 +08:00
commit 307361042a
9 changed files with 1630 additions and 474 deletions

View File

@ -843,7 +843,8 @@ namespace SolarPower.Controllers
TableName = Device.TableName,
Type = Device.Type,
UID = Device.PowerStationId + "-" + Device.Type,
CreatedBy = myUser.Id
CreatedBy = myUser.Id,
TypeName = Device.TypeName
};
List<string> properties = new List<string>()
{
@ -858,7 +859,8 @@ namespace SolarPower.Controllers
"TableName",
"Type",
"UID",
"CreatedBy"
"CreatedBy",
"TypeName"
};
await powerStationRepository.AddDevice(DeviceInfo,properties);
@ -880,7 +882,8 @@ namespace SolarPower.Controllers
TableName = Device.TableName,
Type = Device.Type,
UID = Device.PowerStationId + "-" + Device.Type,
CreatedBy = myUser.Id
CreatedBy = myUser.Id,
TypeName = Device.TypeName
};
List<string> properties = new List<string>()
{
@ -895,7 +898,8 @@ namespace SolarPower.Controllers
"TableName",
"Type",
"UID",
"CreatedBy"
"CreatedBy",
"TypeName"
};
await powerStationRepository.UpdateDevice(DeviceInfo, properties);
apiResult.Code = "0000";
@ -910,7 +914,11 @@ namespace SolarPower.Controllers
}
return apiResult;
}
/// <summary>
/// 設備DataTable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
public async Task<ActionResult> DeviceTable(int stationId)
{
List<DeviceTable> deviceTables = new List<DeviceTable>();
@ -938,7 +946,6 @@ namespace SolarPower.Controllers
});
return result;
}
/// <summary>
/// 軟刪除單一土地房屋資訊
/// </summary>
@ -976,6 +983,234 @@ namespace SolarPower.Controllers
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
/// <summary>
/// 取單一設備資料
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<DeviceInfo>> GetOneDevice(int id)
{
DeviceInfo Device = new DeviceInfo();
ApiResult<DeviceInfo> apiResult = new ApiResult<DeviceInfo>();
try
{
apiResult.Code = "0000";
Device = await powerStationRepository.OneDeviceInfo(id);
apiResult.Data = Device;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
/// <summary>
/// 刪除設備
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<string>> DeleteOneDevice(int id)
{
ApiResult<string> apiResult = new ApiResult<string>();
DeviceInfo Device = new DeviceInfo();
try
{
Device = await powerStationRepository.OneDeviceInfo(id);
if (Device == null)
{
apiResult.Code = "9996";
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
await powerStationRepository.DeleteOneOtherTable(Device.Id, "device");
apiResult.Code = "0000";
apiResult.Msg = "刪除成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
/// <summary>
/// 新增/修改異常
/// </summary>
/// <param name="exceptionModal"></param>
/// <returns></returns>
public async Task<ApiResult<string>> SaveException(ExceptionModal exceptionModal)
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
if (exceptionModal.Id == 0)
{
ExceptionModal Exception = new ExceptionModal()
{
Alarm = exceptionModal.Alarm,
CreatedBy = myUser.Id,
PowerStationId = exceptionModal.PowerStationId,
Id = exceptionModal.Id,
LowerLimit = exceptionModal.LowerLimit,
Type = exceptionModal.Type,
UpperLimit = exceptionModal.UpperLimit
};
List<string> properties = new List<string>()
{
"Alarm",
"CreatedBy",
"PowerStationId",
"Id",
"LowerLimit",
"Type",
"UpperLimit",
};
await powerStationRepository.AddException(Exception, properties);
apiResult.Code = "0000";
apiResult.Msg = "新增成功";
}
else
{
ExceptionModal Exception = new ExceptionModal()
{
Alarm = exceptionModal.Alarm,
CreatedBy = myUser.Id,
PowerStationId = exceptionModal.PowerStationId,
Id = exceptionModal.Id,
LowerLimit = exceptionModal.LowerLimit,
Type = exceptionModal.Type,
UpperLimit = exceptionModal.UpperLimit
};
List<string> properties = new List<string>()
{
"Alarm",
"CreatedBy",
"PowerStationId",
"Id",
"LowerLimit",
"Type",
"UpperLimit",
};
await powerStationRepository.UpdateException(Exception, properties);
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
}
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
/// <summary>
/// 異常dataTable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
public async Task<ActionResult> ExceptionTable(int stationId)
{
List<ExceptionTable> exceptionTable = new List<ExceptionTable>();
ApiResult<List<ExceptionTable>> apiResult = new ApiResult<List<ExceptionTable>>();
try
{
apiResult.Code = "0000";
exceptionTable = await powerStationRepository.ExceptionTable(stationId);
foreach (ExceptionTable a in exceptionTable)
{
a.Function = @"
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'></button>
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'></button>";
if(a.Type == 1)
{
a.TypeName = "PR值";
}
if (a.Alarm == 1)
{
a.AlarmName = "email通知";
}
}
apiResult.Data = exceptionTable;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
var result = Json(new
{
data = apiResult
});
return result;
}
/// <summary>
/// 取一筆異常設定
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<ExceptionModal>> GetOneException(int id)
{
ExceptionModal Exception = new ExceptionModal();
ApiResult<ExceptionModal> apiResult = new ApiResult<ExceptionModal>();
try
{
apiResult.Code = "0000";
Exception = await powerStationRepository.OneException(id);
apiResult.Data = Exception;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
/// <summary>
/// 刪除一筆異常設定
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ApiResult<string>> DeleteOneException(int id)
{
ApiResult<string> apiResult = new ApiResult<string>();
ExceptionModal Exception = new ExceptionModal();
try
{
Exception = await powerStationRepository.OneException(id);
if (Exception == null)
{
apiResult.Code = "9996";
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
await powerStationRepository.DeleteOneOtherTable(Exception.Id, "power_station_exception");
apiResult.Code = "0000";
apiResult.Msg = "刪除成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
}

View File

@ -17,6 +17,390 @@
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 */;
-- 傾印 資料表 solar_power.auth_page 結構
CREATE TABLE IF NOT EXISTS `auth_page` (
`AuthCode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
@ -28,7 +412,58 @@ CREATE TABLE IF NOT EXISTS `auth_page` (
-- 正在傾印表格 solar_power.auth_page 的資料:~-1 rows (近似值)
DELETE FROM `auth_page`;
/*!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 */;
-- 傾印 資料表 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` (
@ -49,11 +484,14 @@ CREATE TABLE IF NOT EXISTS `company` (
`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='公司資料';
) ENGINE=InnoDB AUTO_INCREMENT=3 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'),
(2, 0, 1, '台積電', '2.png', '11223345', NULL, NULL, 10, 0, 'solar_com_0002', 1, '2021-06-14 17:38:49', NULL, '2021-06-14 17:39:00');
/*!40000 ALTER TABLE `company` ENABLE KEYS */;
-- 傾印 資料表 solar_power.company_auth_page 結構
@ -72,6 +510,83 @@ 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,
@ -83,28 +598,37 @@ CREATE TABLE IF NOT EXISTS `operator_log` (
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 '電站代碼,縣市+區域+流水號 ',
`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` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL 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 NOT 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 '能源局設備登記編號',
@ -121,7 +645,8 @@ CREATE TABLE IF NOT EXISTS `power_station` (
`UpdatedAt` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT '修改時間',
PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`),
KEY `IDX_02` (`CompanyId`)
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 (近似值)
@ -129,6 +654,81 @@ 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,
@ -143,11 +743,14 @@ CREATE TABLE IF NOT EXISTS `role` (
PRIMARY KEY (`Id`),
KEY `IDX_01` (`Deleted`),
KEY `IDX_02` (`CompanyId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='角色資料';
) 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 結構
@ -191,47 +794,32 @@ CREATE TABLE IF NOT EXISTS `user` (
-- 正在傾印表格 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` 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 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定變數';
) 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 */;
/*!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 */;
/******************************
** SQL修改從以下開始新增 **
*******************************/
-- 新增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, '') */;

View File

@ -301,6 +301,9 @@ namespace SolarPower.Models.PowerStation
{
public List<Type> Type { get; set; }
}
/// <summary>
/// 表Variable 取來解析
/// </summary>
public class Variable
{
public string name { get; set; }
@ -321,15 +324,43 @@ namespace SolarPower.Models.PowerStation
public string TableName { get; set; }
public string ColName { get; set; }
public string Remark { get; set; }
public string TypeName { get; set; }//類型名稱
}
public class Device : DeviceInfo
{
public string UID { get; set; }//設備編號
public int CreatedBy { get; set; }//建立者
}
/// <summary>
///設備dataTable
/// </summary>
public class DeviceTable : DeviceInfo
{
public string UID { get; set; }//設備編號
public string Function { get; set; }//功能
}
/// <summary>
/// 異常modal
/// </summary>
public class ExceptionModal : Created
{
public int Id { get; set; }
public int PowerStationId { get; set; }
public byte Type { get; set; }
public decimal UpperLimit { get; set; }
public decimal LowerLimit { get; set; }
public byte Alarm { get; set; }
}
/// <summary>
/// 異常設定Table
/// </summary>
public class ExceptionTable : ExceptionModal
{
public string PowerStationName { get; set; }
public string PowerStationCode { get; set; }
public string Function { get; set; }//功能
public string TypeName { get; set; }
public string AlarmName { get; set; }
}
}

View File

@ -406,8 +406,13 @@ namespace SolarPower.Repository.Implement
}
}
}
/// <summary>
/// 新增運維
/// </summary>
/// <param name="operation"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task<int> AddOperation(OperationInfo operation, List<string> properties)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
@ -493,7 +498,12 @@ namespace SolarPower.Repository.Implement
return operation;
}
}
/// <summary>
/// 更新運維
/// </summary>
/// <param name="operation"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task UpdateOperation(OperationInfo operation , List<string> properties)
{
using IDbConnection conn = _databaseHelper.GetConnection();
@ -640,6 +650,141 @@ namespace SolarPower.Repository.Implement
}
return Device;
}
/// <summary>
/// 取單一筆DeviceInfo
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DeviceInfo> OneDeviceInfo(int id)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
DeviceInfo Device;
conn.Open();
try
{
string sql = @$"SELECT * FROM device WHERE Id = @Id";
Device = await conn.QueryFirstOrDefaultAsync<DeviceInfo>(sql, new { Id = id });
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return Device;
}
}
/// <summary>
/// 新增 異常設定
/// </summary>
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task AddException(ExceptionModal Exception, List<string> properties)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
try
{
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_exception");
await conn.ExecuteAsync(sql, Exception);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
}
/// <summary>
/// 異常dataTable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
public async Task<List<ExceptionTable>> ExceptionTable(int stationId)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
List<ExceptionTable> Exception = new List<ExceptionTable>();
try
{
string sql = @$"SELECT pe.Type,pe.UpperLimit,pe.LowerLimit,pe.Alarm,ps.Code AS PowerStationCode ,ps.Name AS PowerStationName,pe.CreatedAt,pe.Id
FROM power_station_exception pe
LEFT JOIN power_station ps ON pe.PowerStationId = ps.Id
WHERE pe.Deleted = 0 AND pe.PowerStationId = @StationId";
Exception = (await conn.QueryAsync<ExceptionTable>(sql, new { StationId = stationId })).ToList();
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return Exception;
}
/// <summary>
/// 取一筆異常設定
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<ExceptionModal> OneException(int id)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
ExceptionModal Exception;
conn.Open();
try
{
string sql = @$"SELECT * FROM power_station_exception WHERE Id = @Id";
Exception = await conn.QueryFirstOrDefaultAsync<ExceptionModal>(sql, new { Id = id });
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return Exception;
}
}
/// <summary>
/// 更新異常設定
/// </summary>
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
public async Task UpdateException(ExceptionModal Exception, List<string> properties)
{
using IDbConnection conn = _databaseHelper.GetConnection();
conn.Open();
var trans = conn.BeginTransaction();
try
{
var updateQuery = GenerateUpdateQueryWithCustomTable(properties, "power_station_exception");
await conn.ExecuteAsync(updateQuery.ToString(), Exception, trans);
trans.Commit();
}
catch (Exception exception)
{
trans.Rollback();
throw exception;
}
finally
{
conn.Close();
}
}
}
}

View File

@ -98,6 +98,12 @@ namespace SolarPower.Repository.Interface
/// <param name="id"></param>
/// <returns></returns>
Task DeleteOneLandBuildingInfo(int id);
/// <summary>
/// 新增運維
/// </summary>
/// <param name="operation"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task<int> AddOperation(OperationInfo operation, List<string> properties);
/// <summary>
/// 運維dataTable
@ -105,7 +111,18 @@ namespace SolarPower.Repository.Interface
/// <param name="stationId"></param>
/// <returns></returns>
Task<List<OperationTable>> OperationTable (int stationId);
/// <summary>
/// 取一筆運維
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
Task<OperationInfo> OneOperationInfo (int stationId);
/// <summary>
/// 更新運維
/// </summary>
/// <param name="operation"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task UpdateOperation(OperationInfo operation, List<string> properties);
/// <summary>
/// 裝置類型下拉式選單
@ -131,5 +148,38 @@ namespace SolarPower.Repository.Interface
/// <param name="stationId"></param>
/// <returns></returns>
Task<List<DeviceTable>> DeviceTable(int stationId);
/// <summary>
/// 異常datatable
/// </summary>
/// <param name="stationId"></param>
/// <returns></returns>
Task<List<ExceptionTable>> ExceptionTable(int stationId);
/// <summary>
/// 取單一筆DeviceInfo
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DeviceInfo> OneDeviceInfo(int id);
/// <summary>
/// 新增 異常設定
/// </summary>
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task AddException(ExceptionModal Exception, List<string> properties);
/// <summary>
/// 取一筆異常設定
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<ExceptionModal> OneException(int id);
/// <summary>
/// 更新異常設定
/// </summary>
/// <param name="Exception"></param>
/// <param name="properties"></param>
/// <returns></returns>
Task UpdateException(ExceptionModal Exception, List<string> properties);
}
}

View File

@ -1,163 +0,0 @@
<!-- Your main content goes below here: -->
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<div class="tab-content p-3">
<div class="row mb-5">
<div class="card border mb-g w-100">
<!-- notice the additions of utility paddings and display properties on .card-header -->
<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">
<!-- we wrap header title inside a div tag with utility padding -->
<div class="card-title font-weight-bold">電站基本資料</div>
<div class="text-right">
<a href="javascript:;" class="btn btn-sm btn-info ml-auto waves-effect waves-themed">
<span class="fal fa-cog mr-1"></span> 儲存
</a>
</div>
</div>
<div class="card-body">
<div class="row d-flex justify-content-between">
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_id">電站編號</label>
<input type="text" id="power_station_id" name="power_station_id" disabled="disabled" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_name">電站名稱</label>
<input type="text" id="power_station_name" name="power_station_name" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<p>是否為代管:</p>
<p class="color-info-600">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="IsEscrow" name="IsEscrow">
<label class="custom-control-label" for="IsEscrow" id="IsEscrowLabel">No</label>
</div>
</p>
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="ElectricityMeterAt">台電掛錶日</label>
<input type="date" id="ElectricityMeterAt" name="ElectricityMeterAt" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="EstimatedRecoveryTime">預計回收年限</label>
<input type="text" id="EstimatedRecoveryTime" name="EstimatedRecoveryTime" class="form-control">
</div>
</div>
<div class="row d-flex justify-content-between mb-5">
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="GeneratingCapacity">電廠發電容量</label>
<input type="text" id="GeneratingCapacity" name="GeneratingCapacity" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="power_station_operation_personnel">運維人員</label>
<br />
<select class="js-example-basic-multiple form-control" id="power_station_operation_personnel" multiple="multiple">
</select>
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="EscrowName">被代管公司</label>
<input type="text" id="EscrowName" name="EscrowName" class="form-control" disabled="disabled">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="PowerRate">授電費率</label>
<input type="text" id="PowerRate" name="PowerRate" class="form-control">
</div>
<div class="col-xl-2 justify-content-center">
<label class="form-label" for="Coordinate">座標</label>
<input type="text" id="Coordinate" name="Coordinate" class="form-control">
</div>
</div>
<div class="row">
<div class="col-xl-6">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">逆變器</h5>
<div class="row d-flex justify-content-between px-5">
<div class="col-xl-4">
<label class="form-label" for="InverterBrand">廠牌</label>
<input type="text" id="InverterBrand" name="InverterBrand" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="InverterProductModel">型號</label>
<input type="text" id="InverterProductModel" name="InverterProductModel" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="InverterAmount">數量</label>
<input type="text" id="InverterAmount" name="InverterAmount" class="form-control">
</div>
</div>
</div>
<div class="col-xl-6">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5>
<div class="row d-flex justify-content-between px-5">
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelBrand">廠牌</label>
<input type="text" id="PhotovoltaicPanelBrand" name="PhotovoltaicPanelBrand" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelSpecification">規格</label>
<input type="text" id="PhotovoltaicPanelSpecification" name="PhotovoltaicPanelSpecification" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelAmount">數量</label>
<input type="text" id="PhotovoltaicPanelAmount" name="PhotovoltaicPanelAmount" class="form-control">
</div>
<div class="col-xl-4">
<label class="form-label" for="PhotovoltaicPanelProductModel">型號</label>
<input type="text" id="PhotovoltaicPanelProductModel" name="PhotovoltaicPanelProductModel" class="form-control">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@section Scripts{
<script>
//#region 預先載入公司下拉式選單select_option
var url_user_select_option = "/PowerStation/GetUserSelectOptionList";
$.get(url_user_select_option, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#power_station_operation_personnel").empty();
$.each(rel.data, function (index, val) {
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
});
//預設查詢第一個
$("#power_station_operation_personnel").val($("#power_station_operation_personnel option:first").val());
});
//#endregion
$('.js-example-basic-multiple').select2();
$("#IsEscrow").click(function () {
if ($(this).prop("checked")) {
$('#IsEscrowLabel').html("Yes");
$("#EscrowName").attr('disabled', false)
} else {
$('#IsEscrowLabel').html("No");
$("#EscrowName").attr('disabled', true)
}
});
</script>
}

View File

@ -52,7 +52,7 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link fs-lg px-4 disabled" data-toggle="tab" href="#tab-005" role="tab">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-exception" role="tab">
<i class="fal fa-home text-success"></i> <span class="hidden-sm-down ml-1">異常設定</span>
</a>
</li>
@ -74,10 +74,8 @@
@Html.Partial("_UploadImage")
</div>
<div class="tab-pane fade" id="tab-005" role="tabpanel" aria-labelledby="tab-005">
<div class="row mb-5">
此處放異常設定數據
</div>
<div class="tab-pane fade" id="tab-exception" role="tabpanel" aria-labelledby="tab-exception">
@Html.Partial("_Exception")
</div>
</div>
</div>
@ -177,92 +175,175 @@
}
}
});
//#endregion
//#region 運維列表 DataTable
//#endregion
//#region 設備列表 DataTable
DeviceTable = $("#Device_table").DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[9, "desc"]],
"columns": [{
"data": "uID"
}, {
"data": "name"
}, {
"data": "type"
}, {
"data": "brand"
}, {
"data": "productModel"
}, {
"data": "dBName"
}, {
"data": "tableName"
}, {
"data": "colName"
}, {
"data": "remark"
},{
"data": "function"
}],
"columnDefs": [{
'targets': 1,
'searchable': false,
'orderable': false,
'className': 'dt-body-center'
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
},
"ajax": {
"url": "/PowerStation/DeviceTable",
"type": "POST",
"data": function (d) {
d.stationId = stationId;
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
toast_error(rel.data.msg);
return;
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[9, "desc"]],
"columns": [{
"data": "uid"
}, {
"data": "name"
}, {
"data": "typeName"
}, {
"data": "brand"
}, {
"data": "productModel"
}, {
"data": "dbName"
}, {
"data": "tableName"
}, {
"data": "colName"
}, {
"data": "remark"
},{
"data": "function"
}],
"columnDefs": [{
'targets': 1,
'searchable': false,
'orderable': false,
'className': 'dt-body-center'
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
},
"ajax": {
"url": "/PowerStation/DeviceTable",
"type": "POST",
"data": function (d) {
d.stationId = stationId;
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
toast_error(rel.data.msg);
return;
}
data = rel.data.data;
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
return data;
}
}
});
//#endregion
});
//#endregion
//#region 異常設定列表 DataTable
ExceptionTable = $("#Exception_table").DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[7, "desc"]],
"columns": [{
"data": "powerStationCode"
}, {
"data": "powerStationName"
}, {
"data": "typeName"
}, {
"data": "upperLimit"
}, {
"data": "lowerLimit"
}, {
"data": "alarmName"
}, {
"data": "createdAt"
}, {
"data": "function"
}],
"columnDefs": [{
'targets': 1,
'searchable': false,
'orderable': false,
'className': 'dt-body-center'
}],
"language": {
"emptyTable": "無資料...",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
},
"ajax": {
"url": "/PowerStation/ExceptionTable",
"type": "POST",
"data": function (d) {
d.stationId = stationId;
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
toast_error(rel.data.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
return data;
}
}
});
//#endregion
//#region 電站資料 view 控制
if (stationId == 'new') {
//#region 電站基本資料
@ -299,6 +380,7 @@
$("#land_buildingPart").hide();
$("#tablist").hide();
$("#tablist").find(".nav-item > a").first().click();
} else {
var url = "/PowerStation/GetOnePowerStation"
@ -331,6 +413,7 @@
}, 'json');
}
//#endregion
//#region 預先載入運維人員下拉式選單select_option
var url_user_select_option = "/PowerStation/GetUserSelectOptionList";
@ -407,6 +490,8 @@
});
});
//#endregion
//#region 預先載入設備類型下拉式選單select_option
var url_DeviceType = "/PowerStation/GetDeviceTypeSelectOptionList";
$.get(url_DeviceType, function (rel) {
if (rel.code != "0000") {
@ -419,11 +504,10 @@
$("#Device_Type_modal").append($("<option />").val(val.value).text(val.text));
});
})
//#endregion
});
//#region 代管切換
$("#check_escrow").click(function () {
if ($(this).prop("checked")) {
@ -567,7 +651,6 @@
//觀看
//#region 電站基本資料 文字
$("#address_detail_text").show();
$("#power_station_code_text").show();
$("#power_station_name_text").show();
@ -889,7 +972,6 @@
$("#photovoltaic_panel_specification").val(powerStationData.photovoltaicPanelSpecification);
$("#photovoltaic_panel_amount").val(powerStationData.photovoltaicPanelAmount);
//#endregion
}
//#endregion
@ -942,6 +1024,7 @@
//加入新增土地房屋卡片
CreateAddLandBuildingCard(landBuildingCard);
}
//#endregion
//#region 創建每份土地房屋資訊卡片
function CreateLandBuildingCard(dom, value) {
@ -1140,148 +1223,8 @@
'</div>';
dom.append(appendStr);
}
//#region 新增維運資料
function AddOperation()
{
$("#Operation-modal .modal-title").html("運維廠商資料 - 新增");
$("#Operation-form").trigger("reset");
$("#Operation-modal").modal();
}
//#endregion
//#region 儲存運維資料
function SaveOperation() {
if ($("#Operation-form").valid()) {
var url = "/PowerStation/SaveOperation";
var send_data = {
Id: selected_id,
PowerStationId: stationId,
Type: $("#Operation_role_modal").val(),
Name: $("#Operation_factory_modal").val(),
ContactPerson: $("#Operation_name_modal").val(),
Phone: $("#Operation_phone_modal").val(),
Email: $("#Operation_email_modal").val(),
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
else
{
toast_ok(rel.msg);
$('#Operation-modal').modal('hide');
OperationTable.ajax.reload();
return;
}
}, 'json');
}
}
//#endregion
//#region 取一筆運維
$('#Operation_table').on("click", "button.edit-btn", function () {
$("#Operation-modal .modal-title").html("運維廠商資料 - 編輯");
selected_id = $(this).parents('tr').attr('data-id');
//取得單一運維基本資料
var url = "/PowerStation/GetOneOperation/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#Operation_role_modal").val(rel.data.type);
$("#Operation_factory_modal").val(rel.data.name);
$("#Operation_name_modal").val(rel.data.contactPerson);
$("#Operation_phone_modal").val(rel.data.phone);
$("#Operation_email_modal").val(rel.data.email);
$("#Operation-modal").modal();
}, 'json');
});
//#endregion
//#region 刪除運維
$('#Operation_table').on("click", "button.del-btn", function () {
selected_id = $(this).parents('tr').attr('data-id');
var url = "/PowerStation/DeleteOneOperation/";
var send_data = {
Id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
OperationTable.ajax.reload();
}, 'json');
});
//#endregion
//#region 新增裝置資料
function AddDevice() {
$("#Device-modal .modal-title").html("裝置資料 - 新增");
$("#Device-form").trigger("reset");
$("#Device-modal").modal();
}
//#endregion
//#region 儲存裝置資料
function SaveDevice() {
if ($("#Device-form").valid()) {
var url = "/PowerStation/SaveDevice";
var send_data = {
Id: selected_id,
PowerStationId: stationId,
Name: $("#Device_Name_modal").val(),
Type: $("#Device_Type_modal").val(),
Brand: $("#Device_Brand_modal").val(),
ProductModel: $("#Device_ProductModel_modal").val(),
DBName: $("#Device_DBName_modal").val(),
TableName: $("#Device_TableName_modal").val(),
ColName: $("#Device_ColName_modal").val(),
Remark: $("#Device_Remark_modal").val(),
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
else {
toast_ok(rel.msg);
$('#Device-modal').modal('hide');
return;
}
}, 'json');
}
}
//#endregion
//#region 土地與房屋按鈕控制
//儲存
@ -1353,5 +1296,302 @@
$("#add-land-building-card button#cancel-add-land-building-info-btn").hide();
});
//#endregion
//#region 新增維運資料
function AddOperation()
{
selected_id = 0;
$("#Operation-modal .modal-title").html("運維廠商資料 - 新增");
$("#Operation-form").trigger("reset");
$("#Operation-modal").modal();
}
//#endregion
//#region 儲存運維資料
function SaveOperation() {
if ($("#Operation-form").valid()) {
var url = "/PowerStation/SaveOperation";
var send_data = {
Id: selected_id,
PowerStationId: stationId,
Type: $("#Operation_role_modal").val(),
Name: $("#Operation_factory_modal").val(),
ContactPerson: $("#Operation_name_modal").val(),
Phone: $("#Operation_phone_modal").val(),
Email: $("#Operation_email_modal").val(),
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
else
{
toast_ok(rel.msg);
$('#Operation-modal').modal('hide');
OperationTable.ajax.reload();
return;
}
}, 'json');
}
}
//#endregion
//#region 取一筆運維
$('#Operation_table').on("click", "button.edit-btn", function () {
$("#Operation-modal .modal-title").html("運維廠商資料 - 編輯");
selected_id = $(this).parents('tr').attr('data-id');
//取得單一運維基本資料
var url = "/PowerStation/GetOneOperation/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#Operation_role_modal").val(rel.data.type);
$("#Operation_factory_modal").val(rel.data.name);
$("#Operation_name_modal").val(rel.data.contactPerson);
$("#Operation_phone_modal").val(rel.data.phone);
$("#Operation_email_modal").val(rel.data.email);
$("#Operation-modal").modal();
}, 'json');
});
//#endregion
//#region 刪除運維資料
$('#Operation_table').on("click", "button.del-btn", function () {
selected_id = $(this).parents('tr').attr('data-id');
var url = "/PowerStation/DeleteOneOperation/";
var send_data = {
Id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
OperationTable.ajax.reload();
}, 'json');
});
//#endregion
//#region 新增裝置資料
function AddDevice() {
selected_id = 0;
$("#Device-modal .modal-title").html("裝置資料 - 新增");
$("#Device-form").trigger("reset");
$("#Device-modal").modal();
}
//#endregion
//#region 儲存裝置資料
function SaveDevice() {
if ($("#Device-form").valid()) {
var url = "/PowerStation/SaveDevice";
var send_data = {
Id: selected_id,
PowerStationId: stationId,
Name: $("#Device_Name_modal").val(),
Type: $("#Device_Type_modal").val(),
TypeName: $("#Device_Type_modal :selected").text(),
Brand: $("#Device_Brand_modal").val(),
ProductModel: $("#Device_ProductModel_modal").val(),
DBName: $("#Device_DBName_modal").val(),
TableName: $("#Device_TableName_modal").val(),
ColName: $("#Device_ColName_modal").val(),
Remark: $("#Device_Remark_modal").val()
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
else {
toast_ok(rel.msg);
$('#Device-modal').modal('hide');
DeviceTable.ajax.reload();
return;
}
}, 'json');
}
}
//#endregion
//#region 取一筆設備
$('#Device_table').on("click", "button.edit-btn", function () {
$("#Device-modal .modal-title").html("設備資料 - 編輯");
selected_id = $(this).parents('tr').attr('data-id');
//取得單一運維基本資料
var url = "/PowerStation/GetOneDevice/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#Device_Name_modal").val(rel.data.name);
$("#Device_Type_modal").val(rel.data.type);
$("#Device_Brand_modal").val(rel.data.brand);
$("#Device_ProductModel_modal").val(rel.data.productModel);
$("#Device_DBName_modal").val(rel.data.dbName);
$("#Device_TableName_modal").val(rel.data.tableName);
$("#Device_ColName_modal").val(rel.data.colName);
$("#Device_Remark_modal").val(rel.data.remark);
$("#Device-modal").modal();
}, 'json');
});
//#endregion
//#region 刪除裝置
$('#Device_table').on("click", "button.del-btn", function () {
selected_id = $(this).parents('tr').attr('data-id');
var url = "/PowerStation/DeleteOneDevice/";
var send_data = {
Id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
DeviceTable.ajax.reload();
}, 'json');
});
//#endregion
//#region 新增異常設定資料
function AddException() {
selected_id = 0;
$("#Exception-modal .modal-title").html("異常設定資料 - 新增");
$("#Exception-form").trigger("reset");
$("#Exception-modal").modal();
}
//#endregion
//#region 儲存異常設定資料
function SaveException() {
if ($("#Exception-form").valid()) {
var url = "/PowerStation/SaveException";
var send_data = {
Id: selected_id,
PowerStationId: stationId,
Type: $("#Exception_Type_modal").val(),
UpperLimit: $("#Exception_UpperLimit_modal").val(),
LowerLimit: $("#Exception_LowerLimit_modal").val(),
Alarm: $("#Exception_Alarm_modal").val()
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
else {
toast_ok(rel.msg);
$('#Exception-modal').modal('hide');
ExceptionTable.ajax.reload();
return;
}
}, 'json');
}
}
//#endregion
//#region 取一筆異常設定
$('#Exception_table').on("click", "button.edit-btn", function () {
$("#Exception-modal .modal-title").html("異常設定資料 - 編輯");
selected_id = $(this).parents('tr').attr('data-id');
//取得單一異常設定資料
var url = "/PowerStation/GetOneException/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$("#Exception_Type_modal").val(rel.data.type);
$("#Exception_Alarm_modal").val(rel.data.alarm);
$("#Exception_UpperLimit_modal").val(rel.data.upperLimit);
$("#Exception_LowerLimit_modal").val(rel.data.lowerLimit);
$("#Exception-modal").modal();
}, 'json');
});
//#endregion
//#region 刪除異常
$('#Exception_table').on("click", "button.del-btn", function () {
selected_id = $(this).parents('tr').attr('data-id');
var url = "/PowerStation/DeleteOneException/";
var send_data = {
Id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
ExceptionTable.ajax.reload();
}, 'json');
});
//#endregion
</script>
}

View File

@ -22,49 +22,6 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">PEP-NTP001-PYR-01</th>
<td>日照計01</td>
<td>日照計</td>
<td>ADTEK</td>
<td>CS1</td>
<td></td>
<td>CS1</td>
<td></td>
<td></td>
<td>
<button type="button" class="btn btn-primary btn-pills waves-effect waves-themed">修改</button>
</td>
</tr>
<tr>
<th scope="row">PEP-NTP001-THR-01</th>
<td>溫度計03</td>
<td>溫度計</td>
<td>ADTEK</td>
<td>CS1</td>
<td></td>
<td>CS1</td>
<td></td>
<td></td>
<td>
<button type="button" class="btn btn-primary btn-pills waves-effect waves-themed">修改</button>
</td>
</tr>
<tr>
<th scope="row">05101300967-PWR</th>
<td>電表01</td>
<td>電表</td>
<td>ADTEK</td>
<td>CS1</td>
<td></td>
<td>CS1</td>
<td></td>
<td></td>
<td>
<button type="button" class="btn btn-primary btn-pills waves-effect waves-themed">修改</button>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,73 @@
<div class="row mb-5">
<div class="col-6"><h3>異常自動檢查設定</h3></div>
<div class="col-6 text-right">
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" id="addException-btn" onclick="AddException()">
<span class="fal fa-plus mr-1"></span>新增
</a>
</div>
<div class="w-100">
<table id="Exception_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>電站編號</th>
<th>電站名稱</th>
<th>項目</th>
<th>下限 ( <= )</th>
<th>上限 ( >= )</th>
<th>警示方式</th>
<th>建立時間</th>
<th>功能</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="Exception-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
異常設定資料 - 新增
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<form class="Exception-form" id="Exception-form">
<div class="row">
<div class="form-group col-lg-6">
<label class="form-label" for="Exception_Type_modal"><span class="text-danger">*</span>項目</label>
<select class="form-control" id="Exception_Type_modal">
<option value="1">PR值</option>
</select>
</div>
<div class="form-group col-lg-6">
<label class="form-label" for="Exception_Alarm_modal"><span class="text-danger">*</span>警示方式</label>
<select class="form-control" id="Exception_Alarm_modal">
<option value="1">email通知</option>
</select>
</div>
<div class="form-group col-lg-6">
<label class="form-label" for="Exception_UpperLimit_modal"><span class="text-danger">*</span>上限</label>
<input type="number" id="Exception_UpperLimit_modal" name="Exception_UpperLimit_modal" class="form-control">
</div>
<div class="form-group col-lg-6">
<label class="form-label" for="Exception_LowerLimit_modal"><span class="text-danger">*</span>下限</label>
<input type="number" id="Exception_LowerLimit_modal" name="Exception_LowerLimit_modal" class="form-control">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" onclick="SaveException()">確定</button>
</div>
</div>
</div>
</div>