天氣API
This commit is contained in:
parent
c44ca18f18
commit
ae7a5f7230
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
@ -7,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Controllers
|
||||
@ -154,7 +156,11 @@ namespace SolarPower.Controllers
|
||||
var powerStation = await powerStationRepository.GetOneAsync(post.Ids.First());
|
||||
|
||||
stationOverview.SolarType = powerStation.SolarType;
|
||||
|
||||
stationOverview.CityName = powerStation.CityName;
|
||||
stationOverview.TodayWeather = powerStation.TodayWeather;
|
||||
stationOverview.TodayWeatherTemp = powerStation.TodayWeatherTemp;
|
||||
stationOverview.RateOfRain = powerStation.RateOfRain;
|
||||
stationOverview.StationName = powerStation.Name;
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = stationOverview;
|
||||
|
||||
@ -483,6 +489,8 @@ namespace SolarPower.Controllers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = inverterkwhBar;
|
||||
}
|
||||
@ -528,6 +536,8 @@ namespace SolarPower.Controllers
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = History;
|
||||
}
|
||||
|
||||
@ -1105,6 +1105,407 @@ ALTER TABLE `sensor_history_hour`
|
||||
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='天氣觀測';
|
||||
|
||||
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||
|
||||
@ -317,4 +317,5 @@ namespace SolarPower.Models
|
||||
public int ScheduleType { get; set; }
|
||||
public string StartTime { get { return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { startTime = value; } } //修改時間
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -56,6 +56,11 @@ namespace SolarPower.Models
|
||||
public byte IsShowMoney { get; set; } //是否顯示發電金額
|
||||
public byte SolarType { get; set; }
|
||||
public string UpdatedAt { get; set; } //畫面資料更新時間
|
||||
public string RateOfRain { get; set; }
|
||||
public string TodayWeather { get; set; }
|
||||
public double TodayWeatherTemp { get; set; }
|
||||
public string StationName { get; set; }
|
||||
public string CityName { get; set; }
|
||||
}
|
||||
|
||||
public class ChartUptoDate
|
||||
|
||||
@ -129,6 +129,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public string SiteDB { get; set; } //電站 DB name: solar_com
|
||||
public string TodayWeather { get; set; } //今日天氣
|
||||
public double TodayWeatherTemp { get; set; } //今日溫度
|
||||
public string WeathersStationId { get; set; }//氣象站編號
|
||||
public string RateOfRain { get; set; }//降雨機率
|
||||
public string CreatorName { get; set; } //創建者名稱
|
||||
}
|
||||
|
||||
@ -571,6 +573,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public int DeviceId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class PowerStationHistory
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
@ -652,5 +655,102 @@ namespace SolarPower.Models.PowerStation
|
||||
public double TODAYKWH { get; set; }
|
||||
public double KWHKWP { get; set; }
|
||||
}
|
||||
#region 氣象觀測
|
||||
public class FieldsItem
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
public class Result
|
||||
{
|
||||
public string Resource_id { get; set; }
|
||||
public List<FieldsItem> Fields { get; set; }
|
||||
}
|
||||
|
||||
public class Time
|
||||
{
|
||||
public string ObsTime { get; set; }
|
||||
}
|
||||
|
||||
public class WeatherElementItem
|
||||
{
|
||||
public string ElementName { get; set; }
|
||||
public string ElementValue { get; set; }
|
||||
public List<TimeItem> Time { get; set; }
|
||||
}
|
||||
|
||||
public class ParameterItem
|
||||
{
|
||||
public string ParameterName { get; set; }
|
||||
public string ParameterValue { get; set; }
|
||||
}
|
||||
|
||||
public class LocationItem
|
||||
{
|
||||
public string Lat { get; set; }
|
||||
public string Lon { get; set; }
|
||||
public string LocationName { get; set; }
|
||||
public string StationId { get; set; }
|
||||
public Time Time { get; set; }
|
||||
public List<WeatherElementItem> WeatherElement { get; set; }
|
||||
public List<ParameterItem> Parameter { get; set; }
|
||||
}
|
||||
|
||||
public class Records
|
||||
{
|
||||
public string DatasetDescription { get; set; }
|
||||
public List<LocationItem> Location { get; set; }
|
||||
}
|
||||
|
||||
public class Root2 //氣象觀測(主要)(opendata取資料)
|
||||
{
|
||||
public string Success { get; set; }
|
||||
public Result Result { get; set; }
|
||||
public Records Records { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public class WeatherObservation //氣象觀測(資料庫)
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
private string obsTime;
|
||||
public string ObsTime { get { return Convert.ToDateTime(obsTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { obsTime = value; } }
|
||||
public double Temp { get; set; }
|
||||
}
|
||||
|
||||
public class WeatherForecast //氣象預報(資料庫)
|
||||
{
|
||||
public string LocationName { get; set; }
|
||||
public string Wx { get; set; }
|
||||
public string WxValue { get; set; }
|
||||
public string PoP { get; set; }
|
||||
private string startTime;
|
||||
public string StartTime { get { return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { startTime = value; } }
|
||||
private string endTime;
|
||||
public string EndTime { get { return Convert.ToDateTime(endTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { endTime = value; } }
|
||||
}
|
||||
|
||||
public class Parameter//氣象預報(opendata取資料)
|
||||
{
|
||||
public string ParameterName { get; set; }
|
||||
public string ParameterValue { get; set; }
|
||||
public string ParameterUnit { get; set; }
|
||||
}
|
||||
|
||||
public class TimeItem//氣象預報(opendata取資料)
|
||||
{
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public Parameter Parameter { get; set; }
|
||||
}
|
||||
|
||||
public class NowWeather
|
||||
{
|
||||
public string WeatherKey { get; set; } //現在天氣
|
||||
public string PoP { get; set; } //降雨機率
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Quartz;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Quartz.Jobs
|
||||
@ -41,11 +43,99 @@ namespace SolarPower.Quartz.Jobs
|
||||
List<InverterHistory> allofInverterHistorDays = new List<InverterHistory>();
|
||||
List<InverterHistory> insertInverterHistoryMonths = new List<InverterHistory>();
|
||||
List<InverterHistory> updateInverterHistoryMonths = new List<InverterHistory>();
|
||||
List<WeatherForecast> weatherForecasts = new List<WeatherForecast>();
|
||||
|
||||
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
var count = 0;
|
||||
|
||||
#region 氣象觀測(取資料)
|
||||
var client = new HttpClient();
|
||||
var UVUri = "https://opendata.cwb.gov.tw/api/v1/rest/datastore/F-C0032-001?Authorization=CWB-EA24220B-DDCC-4188-84E5-AD37A0E03F80&elementName=Wx,PoP&sort=time";
|
||||
HttpResponseMessage response = client.GetAsync(UVUri).Result;
|
||||
String jsonUVs = response.Content.ReadAsStringAsync().Result.ToString();
|
||||
Root2 observation = JsonConvert.DeserializeObject<Root2>(jsonUVs);
|
||||
#endregion
|
||||
|
||||
foreach(var location in observation.Records.Location)
|
||||
{
|
||||
WeatherForecast weatherForecast = new WeatherForecast();
|
||||
weatherForecast.LocationName = location.LocationName;
|
||||
|
||||
List<WeatherForecast> SubweatherForecasts = new List<WeatherForecast>();
|
||||
|
||||
foreach (var a in location.WeatherElement)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (a.ElementName == "Wx")
|
||||
{
|
||||
foreach (var time in a.Time)
|
||||
{
|
||||
int index = 0;
|
||||
if (location.WeatherElement[0].ElementName == "Wx")
|
||||
{
|
||||
weatherForecast = new WeatherForecast();
|
||||
weatherForecast.LocationName = location.LocationName;
|
||||
weatherForecast.StartTime = time.StartTime.ToString();
|
||||
weatherForecast.EndTime = time.EndTime.ToString();
|
||||
weatherForecast.Wx = time.Parameter.ParameterName;
|
||||
weatherForecast.WxValue = time.Parameter.ParameterValue;
|
||||
SubweatherForecasts.Add(weatherForecast);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
SubweatherForecasts[index].StartTime = time.StartTime.ToString();
|
||||
SubweatherForecasts[index].EndTime = time.EndTime.ToString();
|
||||
SubweatherForecasts[index].Wx = time.Parameter.ParameterName;
|
||||
SubweatherForecasts[index].WxValue = time.Parameter.ParameterValue;
|
||||
//SubweatherForecasts.Add(weatherForecast);
|
||||
index++;
|
||||
}
|
||||
//weatherForecasts.Add(weatherForecast);
|
||||
}
|
||||
}
|
||||
if (a.ElementName == "PoP")
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var time in a.Time)
|
||||
{
|
||||
if (location.WeatherElement[0].ElementName == "PoP")
|
||||
{
|
||||
weatherForecast = new WeatherForecast();
|
||||
weatherForecast.LocationName = location.LocationName;
|
||||
weatherForecast.PoP = time.Parameter.ParameterName;
|
||||
SubweatherForecasts.Add(weatherForecast);
|
||||
}
|
||||
else
|
||||
{
|
||||
SubweatherForecasts[index].PoP = time.Parameter.ParameterName;
|
||||
|
||||
//SubweatherForecasts.Add(weatherForecast);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
weatherForecasts.AddRange(SubweatherForecasts);
|
||||
}
|
||||
List<string> weather_forecast_properties = new List<string>()
|
||||
{
|
||||
"LocationName",
|
||||
"StartTime",
|
||||
"EndTime",
|
||||
"Wx",
|
||||
"WxValue",
|
||||
"PoP"
|
||||
};
|
||||
await powerStationRepository.AddWeatherForecast(weatherForecasts, weather_forecast_properties);
|
||||
|
||||
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Quartz;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Quartz.Jobs
|
||||
@ -36,10 +38,19 @@ namespace SolarPower.Quartz.Jobs
|
||||
List<PyrheliometerHistory> TempHistoriesHour = new List<PyrheliometerHistory>();
|
||||
List<InverterHistory> inverterHistories = new List<InverterHistory>();
|
||||
List<PowerStation> calcPowerStations = new List<PowerStation>();
|
||||
List<WeatherObservation> weatherObservations = new List<WeatherObservation>();
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
var count = 0;
|
||||
#region 氣象觀測(取資料)
|
||||
var client = new HttpClient();
|
||||
var UVUri = "https://opendata.cwb.gov.tw/api/v1/rest/datastore/O-A0003-001?Authorization=CWB-EA24220B-DDCC-4188-84E5-AD37A0E03F80";
|
||||
HttpResponseMessage response = client.GetAsync(UVUri).Result;
|
||||
String jsonUVs = response.Content.ReadAsStringAsync().Result.ToString();
|
||||
Root2 observation = JsonConvert.DeserializeObject<Root2>(jsonUVs);
|
||||
#endregion
|
||||
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
@ -148,7 +159,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
if (deviceInfos != null)
|
||||
{
|
||||
//2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均
|
||||
var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, deviceInfos,0);
|
||||
var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, deviceInfos, 0);
|
||||
|
||||
if (pyrheliometerHistory != null)
|
||||
{
|
||||
@ -178,7 +189,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
var inverter_table_name = String.Format("`{0}`.{1}01_inv", powerStation.SiteDB, powerStation.Code);
|
||||
|
||||
inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, inverter_table_name);
|
||||
foreach(var inverterHistory in inverterHistories)
|
||||
foreach (var inverterHistory in inverterHistories)
|
||||
{
|
||||
inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||
inverterHistory.PowerStationId = powerStation.Id;
|
||||
@ -186,9 +197,53 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
#endregion
|
||||
|
||||
#region 確認是否有觀測站(沒有則新增)
|
||||
if (powerStation.WeathersStationId == null)
|
||||
{
|
||||
var weatherStationId = "";
|
||||
double shortLocation = 9999;
|
||||
foreach (var Location in observation.Records.Location)
|
||||
{
|
||||
var powerLocation = powerStation.Coordinate.Split(',');
|
||||
var nowLocation = Math.Sqrt(Math.Pow(Convert.ToDouble(powerLocation[0]) - Convert.ToDouble(Location.Lat), 2) + Math.Pow(Convert.ToDouble(powerLocation[1]) - Convert.ToDouble(Location.Lon), 2));
|
||||
if (nowLocation < shortLocation)
|
||||
{
|
||||
shortLocation = nowLocation;
|
||||
weatherStationId = Location.StationId;
|
||||
calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
}
|
||||
}
|
||||
|
||||
calcPowerStation.WeathersStationId = weatherStationId;
|
||||
}
|
||||
#endregion
|
||||
|
||||
WeatherObservation weatherObservation = new WeatherObservation();
|
||||
if (powerStation.WeathersStationId != null)
|
||||
{
|
||||
foreach(var Location in observation.Records.Location)
|
||||
{
|
||||
if(Location.StationId == powerStation.WeathersStationId)
|
||||
{
|
||||
calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
weatherObservation.PowerStationId = powerStation.Id;
|
||||
weatherObservation.Temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue);
|
||||
weatherObservation.ObsTime = Location.Time.ObsTime.ToString();
|
||||
calcPowerStation.WeathersStationId = powerStation.WeathersStationId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var weather = await powerStationRepository.SelectNowWeather(powerStation.CityId);
|
||||
calcPowerStation.TodayWeather = weather.WeatherKey;
|
||||
calcPowerStation.RateOfRain = weather.PoP;
|
||||
|
||||
weatherObservations.Add(weatherObservation);
|
||||
calcPowerStations.Add(calcPowerStation);
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -244,7 +299,11 @@ namespace SolarPower.Quartz.Jobs
|
||||
"today_PR",
|
||||
"today_carbon",
|
||||
"total_carbon",
|
||||
"today_irradiance"
|
||||
"today_irradiance",
|
||||
"WeathersStationId",
|
||||
"TodayWeatherTemp",
|
||||
"TodayWeather",
|
||||
"RateOfRain"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdateList(calcPowerStations, power_station_properties);
|
||||
@ -264,6 +323,17 @@ namespace SolarPower.Quartz.Jobs
|
||||
await powerStationRepository.AddInverterHisyort(inverterHistories, inverter_history_properties);
|
||||
#endregion
|
||||
|
||||
List<string> weather_observation_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"ObsTime",
|
||||
"Temp"
|
||||
};
|
||||
await powerStationRepository.AddWeatherObservation(weatherObservations, weather_observation_properties);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -2822,5 +2822,87 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AddWeatherObservation(List<WeatherObservation> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "weather_observation");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async Task AddWeatherForecast(List<WeatherForecast> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "weather_forecast");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<NowWeather> SelectNowWeather (int CityId)
|
||||
{
|
||||
NowWeather result = new NowWeather();
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT wf.PoP, wd.WeatherKey
|
||||
FROM city c
|
||||
LEFT JOIN weather_forecast wf ON wf.LocationName = c.`Name`
|
||||
LEFT JOIN weather_description wd ON wd.WeatherName = wf.Wx
|
||||
WHERE c.Priority = {CityId} AND '{now}' BETWEEN wf.StartTime AND wf.EndTime ORDER BY wf.CreatedAt desc";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<NowWeather>(sql);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,6 +521,9 @@ namespace SolarPower.Repository.Interface
|
||||
Task<int> UpdateInverterHistoryMonthList(List<InverterHistory> entity);
|
||||
|
||||
Task<List<int>> GetPowerStationIdsByUserRole(MyUser myUser);
|
||||
Task AddWeatherObservation(List<WeatherObservation> entity, List<string> properties);
|
||||
Task AddWeatherForecast(List<WeatherForecast> entity, List<string> properties);
|
||||
Task<NowWeather> SelectNowWeather(int CityId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,8 +745,10 @@
|
||||
$.each(rel.data, function (index, val) {
|
||||
$("#ShareDevice_PowerStationId_modal").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
|
||||
if (rel.data.length > 0)
|
||||
{
|
||||
DeviceUIDList($("#ShareDevice_PowerStationId_modal").val());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -2110,7 +2112,7 @@
|
||||
$("#Device_TableName_modal").val(rel.data.tableName);
|
||||
$("#Device_ColName_modal").val(rel.data.colName);
|
||||
$("#Device_Controller_modal").val(rel.data.controllerId);
|
||||
|
||||
$("#Device_Name_modal").val(rel.data.name);
|
||||
$("#Device_Status_modal").val(rel.data.status);
|
||||
$("#Device_Enabled_modal").val(rel.data.enabled);
|
||||
$("#Device_InstallDate_modal").val(rel.data.installDate);
|
||||
|
||||
@ -155,7 +155,7 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Controller_Count_modal"><span class="text-danger">*</span>控制器數量</label>
|
||||
<input type="number" id="Controller_Count_modal" name="Device_Name_modal" class="form-control">
|
||||
<input type="number" id="Controller_Count_modal" name="Controller_Count_modal" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -268,8 +268,8 @@
|
||||
<input type="text" id="Device_Brand_modal" name="Device_Brand_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Device_Brand_modal"><span class="text-danger">*</span>名稱</label>
|
||||
<input type="text" id="Device_Name_modal" name="Device_Brand_modal" class="form-control">
|
||||
<label class="form-label" for="Device_Name_modal"><span class="text-danger">*</span>名稱</label>
|
||||
<input type="text" id="Device_Name_modal" name="Device_Name_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Device_ProductModel_modal"><span class="text-danger">*</span>型號</label>
|
||||
|
||||
@ -170,6 +170,7 @@
|
||||
<h4 id="solarName" class="font-weight-bold" style="line-height: 27px;">
|
||||
新竹巨城站
|
||||
</h4>
|
||||
<p class="card-text"><i class="fal fa-cloud-sun-rain fa-2x" id="weathericon"></i></p>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item px-2">
|
||||
@ -380,7 +381,8 @@
|
||||
statusicon = 'NULL'; break;
|
||||
}
|
||||
$('#card_' + val.id).find('#solarName').html(statusicon + val.name);
|
||||
$('#card_' + val.id).find('#Temp').html(val.todayWeatherTemp);
|
||||
$('#card_' + val.id).find('#weathericon')[0].setAttribute("class", 'fal fa-' + val.todayWeather + ' fa-2x');
|
||||
$('#card_' + val.id).find('#Temp').html(val.todayWeatherTemp + '°C');
|
||||
var type = "";
|
||||
switch (val.solarType) {
|
||||
case 0: type = "自建躉售"; break;
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
ViewData["Title"] = "電站總覽";
|
||||
}
|
||||
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
<ol class="breadcrumb page-breadcrumb" >
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">總覽</a></li>
|
||||
<li class="breadcrumb-item">@ViewData["Title"]</li>
|
||||
<li class="breadcrumb-item city-name">新竹市</li>
|
||||
<li class="breadcrumb-item power-station-name active">新竹巨城站</li>
|
||||
<li class="breadcrumb-item city-name" id="breadcrumbcity">新竹市</li>
|
||||
<li class="breadcrumb-item power-station-name active" id="breadcrumbname">新竹巨城站</li>
|
||||
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
|
||||
</ol>
|
||||
<div class="row">
|
||||
@ -24,12 +24,12 @@
|
||||
<i class="base-7 icon-stack-2x color-info-700"></i>
|
||||
<i class="ni ni-graph icon-stack-1x text-white"></i>
|
||||
</span>
|
||||
<span id="power-station-title">新竹巨城站</span>
|
||||
<span id="power-station-title" >新竹巨城站</span>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="col-xl-3 d-flex justify-content-start">
|
||||
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x"></i></p>
|
||||
<p class="font-weight-bold">27°C<br>降雨幾率: 15%</p>
|
||||
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x" id="weather-icon"></i></p>
|
||||
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨幾率: 15%</p>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="nav nav-tabs mb-5" role="tablist">
|
||||
@ -142,6 +142,12 @@
|
||||
$("#today_carbon").html(stationOverview.today_carbon);
|
||||
$("#total_carbon").html(stationOverview.total_carbon);
|
||||
$("#update_at").html(stationOverview.updatedAt);
|
||||
$('#power-station-title').html(stationOverview.stationName);
|
||||
$('#weather-temp').html(stationOverview.todayWeatherTemp + '°C <br>降雨幾率: ' + stationOverview.rateOfRain + '%');
|
||||
$('#weather-icon')[0].setAttribute("class", 'fal fa-' + stationOverview.todayWeather + ' fa-3x');
|
||||
$('#breadcrumbname').html(stationOverview.stationName);
|
||||
$('#breadcrumbcity').html(stationOverview.cityName);
|
||||
|
||||
|
||||
if (stationOverview.isShowMoney == 1) {
|
||||
$(".money-card").show();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user