1. 逆變器選單列表
2. 修改 逆變器 抓KWH 計算方式
This commit is contained in:
parent
c2d0e04962
commit
e42fbc7f76
@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -23,6 +25,64 @@ namespace SolarPower.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<Dictionary<string, Dictionary<string, List<PowerStationInverter>>>>> GetInverterCollapse(string filter)
|
||||
{
|
||||
ApiResult<Dictionary<string, Dictionary<string, List<PowerStationInverter>>>> apiResult = new ApiResult<Dictionary<string, Dictionary<string, List<PowerStationInverter>>>>();
|
||||
try
|
||||
{
|
||||
var powerStations = new List<PowerStation>();
|
||||
if (IsPlatformLayer(myUser.Role.Layer))
|
||||
{
|
||||
powerStations = await powerStationRepository.GetAllAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
powerStations = await powerStationRepository.GetPowerStationsByCompanyId(myUser.CompanyId);
|
||||
}
|
||||
|
||||
var siteDBNamePowerStationId = new Dictionary<string, List<int>>();
|
||||
|
||||
var powerStation_Group = powerStations.GroupBy(x => x.SiteDB).ToList();
|
||||
foreach(var stations in powerStation_Group)
|
||||
{
|
||||
var powerStationIds = stations.Select(x => x.Id).ToList();
|
||||
siteDBNamePowerStationId.Add(stations.Key, powerStationIds);
|
||||
}
|
||||
|
||||
var powerStationInverters = await powerStationRepository.GetPowerStationInverter(siteDBNamePowerStationId, filter);
|
||||
|
||||
powerStationInverters = powerStationInverters.Where(x => x.InverterId != null).ToList();
|
||||
|
||||
var powerStationInverter_Group = powerStationInverters.GroupBy(x => x.CityName).ToList();
|
||||
|
||||
var inverterCollapse = new Dictionary<string, Dictionary<string, List<PowerStationInverter>>>();
|
||||
foreach (var powerStationInverter in powerStationInverter_Group)
|
||||
{
|
||||
var inverter_Group = powerStationInverter.GroupBy(x => x.PowerStationName).ToList();
|
||||
|
||||
var inverterDic = new Dictionary<string, List<PowerStationInverter>>();
|
||||
foreach (var inverter in inverter_Group)
|
||||
{
|
||||
inverterDic.Add(inverter.Key, inverter.ToList());
|
||||
}
|
||||
|
||||
inverterCollapse.Add(powerStationInverter.Key, inverterDic);
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
|
||||
apiResult.Data = inverterCollapse;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】");
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1963,9 +1963,14 @@ CREATE TABLE `sensoravg_history_month` (
|
||||
COMMENT='各電站每月的sensor avg 歷史資料'
|
||||
COLLATE='utf8mb4_unicode_ci'
|
||||
ENGINE=InnoDB
|
||||
AUTO_INCREMENT=2
|
||||
;
|
||||
|
||||
-- 新增電站欄位 20210721
|
||||
ALTER TABLE `power_station`
|
||||
ADD COLUMN `line_token` VARCHAR(255) NULL AFTER `RateOfRain`,
|
||||
ADD COLUMN `Estimate_kwh` DECIMAL(10,2) NULL DEFAULT '0.00' COMMENT '預估發電度數' AFTER `line_token`,
|
||||
ADD COLUMN `EstimateEfficacy` DECIMAL(10,2) NULL DEFAULT '0.00' COMMENT '預估發電效能' AFTER `Estimate_kwh`;
|
||||
|
||||
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
|
||||
@ -5,7 +5,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Models
|
||||
{
|
||||
|
||||
public class PowerStationInverter
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public string CityName { get; set; }
|
||||
public string PowerStationName { get; set; }
|
||||
public string InverterName { get; set; }
|
||||
public string InverterId { get; set; }
|
||||
}
|
||||
|
||||
public class AnalysisInverter
|
||||
{
|
||||
|
||||
@ -26,7 +26,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
try
|
||||
{
|
||||
//var day_array = new string[] { "15", "16", "17", "18", "19" };
|
||||
////var day_array = new string[] { "15" };
|
||||
//var day_array = new string[] { "22" };
|
||||
//var time_array = new string[] { "00:02", "00:17", "00:32", "00:47",
|
||||
// "01:02", "01:17", "01:32", "01:47",
|
||||
// "02:02", "02:17", "02:32", "02:47",
|
||||
@ -71,14 +71,13 @@ namespace SolarPower.Quartz.Jobs
|
||||
//{
|
||||
// for (var j = 0; j < time_array.Count(); j++)
|
||||
// {
|
||||
//var dateNowTime = string.Format("2021-07-{0} {1}", day_array[i], time_array[j]);
|
||||
//var dateNowTime = string.Format("2021-07-{0} {1}", day_array[i], time_array[j]);
|
||||
|
||||
|
||||
#region step2. 從電站的DB及電站編號找出該電站的控制器
|
||||
foreach (var powerStation in powerStations)
|
||||
{
|
||||
|
||||
|
||||
|
||||
//取得所有該電站的逆變器
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
|
||||
var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB);
|
||||
@ -97,7 +96,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
logger.LogInformation("【CalcInverter15minJob】【開始計算電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
calcInverter15mins = await powerStationRepository.CalcInverterHisyort15minData(dateNowTime, powerStation.SiteDB, full_table_name, inverterIds);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算完成電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算完成電站[{0}]在{1}的每15分鐘逆變器資訊】", powerStation.Code, dateNowTime);
|
||||
logger.LogInformation("【CalcInverter15minJob】【計算結果】 - {0}", System.Text.Json.JsonSerializer.Serialize(calcInverter15mins));
|
||||
if (calcInverter15mins.Count() > 0)
|
||||
{
|
||||
foreach (var inverterHistory in calcInverter15mins)
|
||||
@ -130,9 +130,6 @@ namespace SolarPower.Quartz.Jobs
|
||||
#endregion
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -429,7 +429,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql = @$"
|
||||
-- 傾印 子資料庫結構
|
||||
CREATE DATABASE IF NOT EXISTS `{db_name}`;
|
||||
CREATE DATABASE IF NOT EXISTS `{db_name}` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
|
||||
USE `{db_name}`;
|
||||
|
||||
-- 傾印 資料表 controller 結構
|
||||
@ -437,8 +437,8 @@ namespace SolarPower.Repository.Implement
|
||||
`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 '所屬電站編號',
|
||||
`ControllerId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '控制器編號',
|
||||
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '控制器各電站流水號',
|
||||
`ControllerId` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '控制器編號',
|
||||
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '控制器各電站流水號',
|
||||
`CreatedBy` int(10) unsigned NOT NULL,
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`UpdatedBy` int(10) unsigned DEFAULT NULL,
|
||||
@ -481,7 +481,7 @@ namespace SolarPower.Repository.Implement
|
||||
`Enabled` tinyint(4) DEFAULT '0' COMMENT '是否啟用,0:未啟用 1:啟用',
|
||||
`Status` tinyint(4) DEFAULT '0' COMMENT '狀態,0:未啟用 1:正常 2:異常',
|
||||
`InstallDate` timestamp NULL DEFAULT NULL COMMENT '安裝日期',
|
||||
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '逆變器流水號(用控制器排序)',
|
||||
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器流水號(用控制器排序)',
|
||||
`InverterName` varchar(50) DEFAULT NULL COMMENT '逆變器名稱',
|
||||
`InverterId` varchar(50) DEFAULT NULL COMMENT '逆變器UID',
|
||||
`ControllerId` int(10) DEFAULT NULL COMMENT '所屬控制器',
|
||||
@ -535,71 +535,77 @@ namespace SolarPower.Repository.Implement
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='運維廠商';
|
||||
|
||||
-- 傾印 資料表 power_station 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station` (
|
||||
`Id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`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 '電站區域',
|
||||
`HealthStatus` TINYINT(4) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1:設備正常 2:設備斷線 3:設備異常',
|
||||
`Address` VARCHAR(100) NULL DEFAULT NULL COMMENT '電站詳細地址' COLLATE 'utf8mb4_unicode_ci',
|
||||
`Name` VARCHAR(50) NULL DEFAULT NULL COMMENT '名稱' COLLATE 'utf8mb4_unicode_ci',
|
||||
`MainDisplay` VARCHAR(50) NULL DEFAULT NULL COMMENT '主要顯示圖片' COLLATE 'utf8mb4_unicode_ci',
|
||||
`Code` VARCHAR(50) NULL DEFAULT NULL COMMENT '電站代碼,縣市+區域+四碼流水號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`SerialNumber` VARCHAR(4) NULL DEFAULT NULL COMMENT '四碼流水號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`IsEscrow` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否為代管,0:否 1:是',
|
||||
`EscrowName` VARCHAR(50) NULL DEFAULT NULL COMMENT '代管名稱' COLLATE 'utf8mb4_unicode_ci',
|
||||
`ElectricityMeterAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電掛錶日',
|
||||
`EstimatedRecoveryTime` VARCHAR(10) NULL DEFAULT NULL COMMENT '預估回收時間' COLLATE 'utf8mb4_unicode_ci',
|
||||
`GeneratingCapacity` DECIMAL(10,1) NOT NULL DEFAULT '0.0' COMMENT '電廠發電容量,單位(千瓦)',
|
||||
`PowerRate` DECIMAL(10,3) NOT NULL DEFAULT '0.000' COMMENT '受電費率',
|
||||
`Coordinate` VARCHAR(50) NULL DEFAULT NULL COMMENT '座標' COLLATE 'utf8mb4_unicode_ci',
|
||||
`InverterBrand` VARCHAR(50) NULL DEFAULT NULL COMMENT '逆變器廠牌' COLLATE 'utf8mb4_unicode_ci',
|
||||
`InverterProductModel` VARCHAR(50) NULL DEFAULT NULL COMMENT '逆變器型號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`InverterAmount` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '逆變器數量',
|
||||
`PhotovoltaicPanelBrand` VARCHAR(50) NULL DEFAULT NULL COMMENT '光電板廠牌' COLLATE 'utf8mb4_unicode_ci',
|
||||
`PhotovoltaicPanelProductModel` VARCHAR(50) NULL DEFAULT NULL COMMENT '光電板型號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`PhotovoltaicPanelSpecification` VARCHAR(100) NULL DEFAULT NULL COMMENT '光電板規格' COLLATE 'utf8mb4_unicode_ci',
|
||||
`PhotovoltaicPanelAmount` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '光電板數量',
|
||||
`BoEFileName` VARCHAR(255) NULL DEFAULT NULL COMMENT '能源局原檔案名' COLLATE 'utf8mb4_unicode_ci',
|
||||
`BoEFile` VARCHAR(255) NULL DEFAULT NULL COMMENT '能源局檔案' COLLATE 'utf8mb4_unicode_ci',
|
||||
`BoEDiscountRate` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '能源局折扣率',
|
||||
`BoEDeviceRegisterNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '能源局設備登記編號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`BoERentRatio` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '能源局租金比率,單位(%)',
|
||||
`TPCContractNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '台電契約編號' COLLATE 'utf8mb4_unicode_ci',
|
||||
`TPCContractAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電簽約日期',
|
||||
`TPCSellDeadline` INT(10) UNSIGNED NULL DEFAULT '0' COMMENT '台電售電期限,單位(年)',
|
||||
`TPCMeterReading` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '台電每期抄錶日',
|
||||
`TPCPurchaseElectricityAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電正式購電日',
|
||||
`TPCSellElectricityAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電正式售電日',
|
||||
`SolarType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '電站類型',
|
||||
`kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000',
|
||||
`Today_kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '今日發電量',
|
||||
`Total_kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '總發電量',
|
||||
`today_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '今日kwhkwp',
|
||||
`avg_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '30天平均kwhkwp',
|
||||
`today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額',
|
||||
`total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額',
|
||||
`today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值',
|
||||
`avg_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均Pr值',
|
||||
`today_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日減碳量',
|
||||
`total_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總減碳量',
|
||||
`today_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '今日日照度',
|
||||
`avg_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均日照度',
|
||||
`SolarHour` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '總運轉小時',
|
||||
`SiteDB` VARCHAR(20) NULL DEFAULT NULL COMMENT '電站 DB name: solar_com' COLLATE 'utf8mb4_unicode_ci',
|
||||
`TodayWeather` VARCHAR(20) NULL DEFAULT NULL COMMENT '今日天氣' COLLATE 'utf8mb4_unicode_ci',
|
||||
`TodayWeatherTemp` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '今日溫度',
|
||||
`CreatedBy` INT(10) UNSIGNED NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立時間',
|
||||
`UpdatedBy` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT '修改者',
|
||||
`UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `IDX_01` (`Deleted`),
|
||||
KEY `IDX_02` (`CompanyId`),
|
||||
KEY `IDX_03` (`CityId`,`AreaId`)
|
||||
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 '電站區域',
|
||||
`HealthStatus` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '1:設備正常 2:設備斷線 3:設備異常',
|
||||
`Address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站詳細地址',
|
||||
`Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱',
|
||||
`MainDisplay` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主要顯示圖片',
|
||||
`Code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+四碼流水號',
|
||||
`SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '四碼流水號',
|
||||
`IsEscrow` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否為代管,0:否 1:是',
|
||||
`EscrowName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '代管名稱',
|
||||
`ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '台電掛錶日',
|
||||
`EstimatedRecoveryTime` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '預估回收時間',
|
||||
`GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT '0.0' COMMENT '電廠發電容量,單位(千瓦)',
|
||||
`PowerRate` decimal(10,3) NOT NULL DEFAULT '0.000' COMMENT '受電費率',
|
||||
`Coordinate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標',
|
||||
`InverterBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器廠牌',
|
||||
`InverterProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器型號',
|
||||
`InverterAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '逆變器數量',
|
||||
`PhotovoltaicPanelBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板廠牌',
|
||||
`PhotovoltaicPanelProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板型號',
|
||||
`PhotovoltaicPanelSpecification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板規格',
|
||||
`PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '光電板數量',
|
||||
`BoEFileName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局原檔案名',
|
||||
`BoEFile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局檔案',
|
||||
`BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '能源局折扣率',
|
||||
`BoEDeviceRegisterNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局設備登記編號',
|
||||
`BoERentRatio` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '能源局租金比率,單位(%)',
|
||||
`TPCContractNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電契約編號',
|
||||
`TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '台電簽約日期',
|
||||
`TPCSellDeadline` int(10) unsigned DEFAULT '0' COMMENT '台電售電期限,單位(年)',
|
||||
`TPCMeterReading` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '台電每期抄錶日',
|
||||
`TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式購電日',
|
||||
`TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式售電日',
|
||||
`SolarType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '電站類型',
|
||||
`kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000',
|
||||
`Today_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '今日發電量',
|
||||
`Total_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '總發電量',
|
||||
`today_kwhkwp` decimal(10,3) DEFAULT NULL COMMENT '今日kwhkwp',
|
||||
`avg_kwhkwp` decimal(10,3) DEFAULT NULL COMMENT '30天平均kwhkwp',
|
||||
`today_money` decimal(10,2) DEFAULT NULL COMMENT '今日金額',
|
||||
`total_money` decimal(10,2) DEFAULT NULL COMMENT '總金額',
|
||||
`today_PR` decimal(5,2) DEFAULT NULL COMMENT '電站Pr值',
|
||||
`avg_PR` decimal(5,2) DEFAULT NULL COMMENT '平均Pr值',
|
||||
`today_carbon` decimal(10,2) DEFAULT NULL COMMENT '今日減碳量',
|
||||
`total_carbon` decimal(10,2) DEFAULT NULL COMMENT '總減碳量',
|
||||
`today_irradiance` decimal(5,2) DEFAULT NULL COMMENT '今日日照度',
|
||||
`avg_irradiance` decimal(5,2) DEFAULT NULL COMMENT '平均日照度',
|
||||
`SolarHour` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '總運轉小時',
|
||||
`SiteDB` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站 DB name: solar_com',
|
||||
`TodayWeather` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '今日天氣',
|
||||
`TodayWeatherTemp` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '今日溫度',
|
||||
`WeathersStationId` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '氣象站編號',
|
||||
`RateOfRain` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '今日降雨率',
|
||||
`line_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`Estimate_kwh` decimal(10,2) DEFAULT '0.00' COMMENT '預估發電度數',
|
||||
`EstimateEfficacy` decimal(10,2) DEFAULT '0.00' 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 CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`) USING BTREE,
|
||||
KEY `IDX_01` (`Deleted`) USING BTREE,
|
||||
KEY `IDX_02` (`CompanyId`) USING BTREE,
|
||||
KEY `IDX_03` (`CityId`,`AreaId`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
|
||||
|
||||
|
||||
-- 傾印 資料表 power_station_exception 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station_exception` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
|
||||
@ -202,7 +202,7 @@ namespace SolarPower.Repository.Implement
|
||||
FROM power_station_history_hour ps
|
||||
LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d %H')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = @NowDay";
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = @NowDay ORDER BY ps.timestamp";
|
||||
|
||||
result = (await conn.QueryAsync<PowerIrradiance>(sql_power, new { PowerStationId = powerStationId, NowDay = nowDay })).ToList();
|
||||
}
|
||||
@ -226,7 +226,7 @@ namespace SolarPower.Repository.Implement
|
||||
FROM power_station_history_day ps
|
||||
LEFT JOIN sensor_history_day pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d')
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') BETWEEN @StartDay AND @NowDay";
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') BETWEEN @StartDay AND @NowDay ORDER BY ps.timestamp";
|
||||
|
||||
result = (await conn.QueryAsync<PowerIrradiance>(sql_power, new { PowerStationId = powerStationId, StartDay = startDay, NowDay = nowDay })).ToList();
|
||||
}
|
||||
@ -319,7 +319,7 @@ namespace SolarPower.Repository.Implement
|
||||
//var endDataTime = dateTime + " 19:00";
|
||||
|
||||
//var sql = @$"SELECT * FROM inverter_history_15min WHERE PowerStationId = @PowerStationId AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime";
|
||||
var sql = @$"SELECT * FROM inverter_history_15min WHERE PowerStationId = @PowerStationId AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') = @DateTime";
|
||||
var sql = @$"SELECT * FROM inverter_history_15min WHERE PowerStationId = @PowerStationId AND DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') = @DateTime ORDER BY TIMESTAMP";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { PowerStationId = powerStationId, DateTime = dateTime })).ToList();
|
||||
}
|
||||
|
||||
@ -2618,7 +2618,7 @@ namespace SolarPower.Repository.Implement
|
||||
a.KWH,
|
||||
s.TODAYKWH,
|
||||
i.Capacity,
|
||||
(a.KWH/i.Capacity) AS KWHKWP
|
||||
a.KWH/(i.Capacity/4) AS KWHKWP
|
||||
FROM (SELECT
|
||||
MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
||||
sub_inv.INVERTERID,
|
||||
@ -2630,7 +2630,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN (
|
||||
SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
||||
sub_inv.INVERTERID,
|
||||
AVG(sub_inv.WH)/1000 AS KWH
|
||||
SUM(sub_inv.WH)/1000 AS KWH
|
||||
FROM {table_name} sub_inv
|
||||
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
||||
AND sub_inv.INVERTERID IN @InverterIds
|
||||
@ -2738,7 +2738,7 @@ namespace SolarPower.Repository.Implement
|
||||
SELECT
|
||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
AVG(inv.WH)/1000 AS KWH
|
||||
SUM(inv.WH)/1000 AS KWH
|
||||
FROM {table_name} inv
|
||||
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime
|
||||
AND inv.INVERTERID IN @InverterIds
|
||||
@ -2860,7 +2860,7 @@ namespace SolarPower.Repository.Implement
|
||||
AVG(inv.RA3) AS RA3,
|
||||
AVG(inv.RA4) AS RA4,
|
||||
AVG(inv.RA5) AS RA5,
|
||||
AVG(inv.KWH) AS KWH,
|
||||
SUM(inv.KWH) AS KWH,
|
||||
MAX(inv.TODAYKWH) AS TODAYKWH,
|
||||
MAX(inv.TODAYKWH) / i.Capacity AS KWHKWP
|
||||
FROM inverter_history_hour inv
|
||||
@ -2981,7 +2981,7 @@ namespace SolarPower.Repository.Implement
|
||||
AVG(inv.RA3) AS RA3,
|
||||
AVG(inv.RA4) AS RA4,
|
||||
AVG(inv.RA5) AS RA5,
|
||||
AVG(inv.KWH) AS KWH,
|
||||
SUM(inv.KWH) AS KWH,
|
||||
SUM(inv.TODAYKWH) AS TODAYKWH,
|
||||
SUM(inv.TODAYKWH) / i.Capacity AS KWHKWP
|
||||
FROM inverter_history_day inv
|
||||
@ -3608,5 +3608,69 @@ namespace SolarPower.Repository.Implement
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<PowerStation>> GetPowerStationsByCompanyId(int companyId)
|
||||
{
|
||||
List<PowerStation> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0 AND CompanyId = @CompanyId";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStation>(sql, new { CompanyId = companyId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter)
|
||||
{
|
||||
List<PowerStationInverter> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> sql_perSiteDB = new List<string>();
|
||||
var sql = "";
|
||||
foreach(var powerStationDic in dic)
|
||||
{
|
||||
var powerStationIds = string.Join(",", powerStationDic.Value);
|
||||
|
||||
var temp_sql = @$"SELECT ps.Id AS PowerStationId,
|
||||
c.Name AS CityName,
|
||||
ps.Name AS PowerStationName,
|
||||
inv.InverterName AS InverterName,
|
||||
inv.InverterId AS InverterId
|
||||
FROM power_station ps
|
||||
LEFT JOIN `city` c ON ps.CityId = c.Id
|
||||
LEFT JOIN {powerStationDic.Key}.controller con ON ps.Id = con.PowerStationId
|
||||
LEFT JOIN {powerStationDic.Key}.inverter inv ON con.Id = inv.ControllerId
|
||||
WHERE ps.Deleted = 0
|
||||
AND ps.Id IN ({powerStationIds})";
|
||||
if (!string.IsNullOrEmpty(filter))
|
||||
{
|
||||
temp_sql += " AND inv.InverterName LIKE CONCAT('%', @Filter, '%')";
|
||||
}
|
||||
|
||||
sql_perSiteDB.Add(temp_sql);
|
||||
}
|
||||
|
||||
sql = string.Join(" UNION ", sql_perSiteDB);
|
||||
|
||||
result = (await conn.QueryAsync<PowerStationInverter>(sql, new { Filter = filter})).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,5 +546,7 @@ namespace SolarPower.Repository.Interface
|
||||
Task<SensorAvgHistory> CalcSensorAvgHistoryMonthDataByPowerStationId(string month, int powerStationId);
|
||||
Task<int> AddSensorAvgHistoryMonthList(List<SensorAvgHistory> entity, List<string> properties);
|
||||
Task<int> UpdateSensorAvgHistoryMonthList(List<SensorAvgHistory> entity);
|
||||
Task<List<PowerStation>> GetPowerStationsByCompanyId(int companyId);
|
||||
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,35 +212,6 @@
|
||||
<div class="pr-3">
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">查詢</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-5">
|
||||
<div class="card p-3 w-100">
|
||||
<h5 class="font-weight-bold mb-3 pl-5 pb-3">總結</h5>
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>時間</th>
|
||||
<th>發電量(kWh)</th>
|
||||
<th>發電小時</th>
|
||||
<th>日射量(kWh/m2)</th>
|
||||
<th>PR(%)</th>
|
||||
<th>溫度修正PR(%)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">2021-05</th>
|
||||
<td>126,121.7</td>
|
||||
<td>119.04</td>
|
||||
<td>140.39</td>
|
||||
<td>84.8</td>
|
||||
<td>91.9</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-5">
|
||||
@ -290,6 +261,7 @@
|
||||
var searchType = 0;//搜尋條件(日,日區間,月,年)
|
||||
var datepicker;
|
||||
var timerange;//選取時間
|
||||
var selecterd_invert = [];
|
||||
|
||||
$(function () {
|
||||
//#region 預設初始值
|
||||
@ -300,6 +272,9 @@
|
||||
timerange = $('#DateGet').val();
|
||||
//#endregion
|
||||
|
||||
//#region 載入左邊選單列表
|
||||
GetPowerStationCollapse("");
|
||||
//#endregion
|
||||
})
|
||||
|
||||
function myfunc(div) {
|
||||
@ -454,5 +429,116 @@
|
||||
timerange = $('#DateGettext').val();
|
||||
});
|
||||
//#endregion
|
||||
|
||||
$("#js_list_accordion_filter").change(function (e) {
|
||||
GetPowerStationCollapse($(this).val());
|
||||
});
|
||||
|
||||
$('#js_list_accordion').on("change", 'input[name="selectedInverterId[]"]', function (event) {
|
||||
if (this.checked) {
|
||||
if ($.inArray(this.value, selecterd_invert) < 0) {
|
||||
selecterd_invert.push(this.value);
|
||||
}
|
||||
} else {
|
||||
if ($.inArray(this.value, selecterd_invert) > -1) {
|
||||
selecterd_invert.slice($.inArray(this.value, selecterd_invert), 1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(selecterd_invert);
|
||||
});
|
||||
|
||||
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
|
||||
if (this.checked) {
|
||||
$(this).parents(".list-group-item").find('input[name="selectedInverterId[]"]').prop("checked", true).trigger("change");
|
||||
} else {
|
||||
$(this).parents(".list-group-item").find('input[name="selectedInverterId[]"]').prop("checked", false).trigger("change");
|
||||
}
|
||||
});
|
||||
|
||||
function GetPowerStationCollapse(filter) {
|
||||
var url = "/AnalysisInverter/GetInverterCollapse"
|
||||
|
||||
var send_data = {
|
||||
Filter: filter
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var inverterCollapse = rel.data;
|
||||
|
||||
|
||||
|
||||
$('#js_list_accordion').empty();
|
||||
|
||||
if (inverterCollapse.length <= 0) {
|
||||
$('#js_list_accordion').append("<div>查無結果</div>");
|
||||
}
|
||||
|
||||
var str = "";
|
||||
|
||||
Object.keys(inverterCollapse).map(function (key, index) {
|
||||
str += '<div class="card border-top-left-radius-0 border-top-right-radius-0" id="templateCard">' +
|
||||
'<div class="card-header">' +
|
||||
'<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-' + index + '" aria-expanded="false" data-filter-tags="settings">' +
|
||||
'<i class="fal fa-globe width-2 fs-xl"></i>' +
|
||||
'<span class="city-name">' + key + '</span>' +
|
||||
'<span class="ml-auto">' +
|
||||
'<span class="collapsed-reveal"><i class="fal fa-chevron-up fs-xl"></i></span>' +
|
||||
'<span class="collapsed-hidden"><i class="fal fa-chevron-down fs-xl"></i></span>' +
|
||||
'</span>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'<div id="js_list_accordion-' + index + '" class="collapse" data-parent="#js_list_accordion" style="">' +
|
||||
'<div class="card-body">' +
|
||||
'<ul class="list-group list-group-flush">';
|
||||
Object.keys(inverterCollapse[key]).map(function (powerStationkey, index) {
|
||||
str += '<li class="list-group-item">' +
|
||||
'<div class="d-flex justify-content-between">' +
|
||||
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + powerStationkey + '</h4>' +
|
||||
'<div class="">' +
|
||||
'<input type="checkbox" class="" name="selectedInverterLayer2[]" >' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<ul class="list-group list-group-flush">';
|
||||
$.each(inverterCollapse[key][powerStationkey], function (index, inverter) {
|
||||
str += '<li class="list-group-item pr-0 d-flex justify-content-between">' +
|
||||
'<a href="#"><i class="fal fa-server"></i> ' + inverter.inverterName + '</a>' +
|
||||
'<div class=""><input type="checkbox" class="" name="selectedInverterId[]" value="' + inverter.inverterId + '">' + '</div>'
|
||||
'</li>';
|
||||
});
|
||||
str += '</ul>' +
|
||||
'</li>';
|
||||
});
|
||||
|
||||
str += '</ul>';
|
||||
str += '</div>';
|
||||
str += '</div>';
|
||||
|
||||
});
|
||||
|
||||
$('#js_list_accordion').append(str);
|
||||
$('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0");
|
||||
|
||||
if (selecterd_invert.length <= 0) {
|
||||
|
||||
var first_val = Object.values(inverterCollapse)[0];
|
||||
var child_val = Object.values(Object.values(inverterCollapse)[0])[0];
|
||||
selecterd_invert.push(Object.values(Object.values(inverterCollapse)[0])[0][0].inverterId)
|
||||
}
|
||||
|
||||
$('input[name="selectedInverterId[]"]').each(function () {
|
||||
if ($.inArray(this.value, selecterd_invert) > -1) {
|
||||
$(this).prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@
|
||||
<!-- BEGIN Left Aside -->
|
||||
<aside class="page-sidebar">
|
||||
<div class="page-logo">
|
||||
<a href="#" class="page-logo-link press-scale-down" data-toggle="modal" data-target="#modal-shortcut">
|
||||
<a href="#" class="page-logo-link press-scale-down">
|
||||
<img src="~/img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo"> <span class="page-logo-text mr-1"></span> <span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
|
||||
<!--<i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>-->
|
||||
</a>
|
||||
|
||||
@ -1736,7 +1736,7 @@
|
||||
function CreatePowerStationImagecarousel(dom, value, index) {
|
||||
var indicators = '<li data-target="#carouselExampleIndicators" data-slide-to="' + index + '"></li>'
|
||||
var carousel_item = '<div class="carousel-item">' +
|
||||
'<img class="d-block w-100" width="250px" height="150" src="' + value.image + '">' +
|
||||
'<img class="d-block w-100" src="' + value.image + '">' +
|
||||
'</div>'
|
||||
|
||||
dom.find(".carousel-indicators").append(indicators);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user