This commit is contained in:
b110212000 2021-07-28 19:23:23 +08:00
commit 2a48cc71c7
13 changed files with 2010 additions and 282 deletions

View File

@ -34,17 +34,17 @@ namespace SolarPower.Controllers
var powerStations = new List<PowerStation>();
if (IsPlatformLayer(myUser.Role.Layer))
{
powerStations = await powerStationRepository.GetAllAsync();
powerStations = await powerStationRepository.GetAllAsync();
}
else
{
powerStations = await powerStationRepository.GetPowerStationsByCompanyId(myUser.CompanyId);
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)
foreach (var stations in powerStation_Group)
{
var powerStationIds = stations.Select(x => x.Id).ToList();
siteDBNamePowerStationId.Add(stations.Key, powerStationIds);
@ -84,5 +84,822 @@ namespace SolarPower.Controllers
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
[HttpPost]
public async Task<ApiResult<AnalysisInverter>> GetAnalysisByInverterIds(PostAnalysisInverter post)
{
ApiResult<AnalysisInverter> apiResult = new ApiResult<AnalysisInverter>();
try
{
AnalysisInverter analysisInverter = new AnalysisInverter();
var inverterHistories = new List<InverterHistory>();
var stationIdWithInverterIdsList = new List<StationIdWithInverterIds>();
List<InverterHistoryInfo> series = new List<InverterHistoryInfo>();
var powerStation_Group = post.InverterIdInfos.GroupBy(x => x.PowerStationId).ToList();
if(post.SearchType == 0)
{ //單日
var StationCodeWithInverterIdsList = new List<StationCodeWithInverterIds>();
foreach (var ps in powerStation_Group)
{
var powerStation = await powerStationRepository.GetOneAsync(ps.Key);
StationCodeWithInverterIds stationCodeWithInverterIds = new StationCodeWithInverterIds();
stationCodeWithInverterIds.SiteDB = powerStation.SiteDB;
stationCodeWithInverterIds.Code = powerStation.Code;
stationCodeWithInverterIds.InverterIds = ps.Select(x => x.InverterId).ToList();
StationCodeWithInverterIdsList.Add(stationCodeWithInverterIds);
}
inverterHistories = await powerStationRepository.GetInverterHistoryRowData(post.SelectedDate, StationCodeWithInverterIdsList);
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
analysisInverter.MultipleYaxes = new Dictionary<string, string>(){
{ "Irradiance", "日照度"},
{ "DCKW", "直流功率 (KW)"},
{ "ACKW", "輸出功率 (KW)"},
{ "DC1V", "直流電壓1 (V)"},
{ "DC1A", "直流電流1 (A)"},
{ "DC1KW", "直流功率1 (KW)"},
{ "DC2V", "直流電壓2 (V)"},
{ "DC2A", "直流電流2 (A)"},
{ "DC2KW", "直流功率2 (KW)"},
{ "DC3V", "直流電壓3 (V)"},
{ "DC3A", "直流電流3 (A)"},
{ "DC3KW", "直流功率3 (KW)"},
{ "DC4V", "直流電壓4 (V)"},
{ "DC4A", "直流電流4 (A)"},
{ "DC4KW", "直流功率4 (KW)"},
{ "DC5V", "直流電壓5 (V)"},
{ "DC5A", "直流電流5 (A)"},
{ "DC5KW", "直流功率5 (KW)"},
{ "AC1V", "交流電壓A (V)"},
{ "AC2V", "交流電壓B (V)"},
{ "AC3V", "交流電壓C (V)"},
{ "AC1A", "交流電流A (A)"},
{ "AC2A", "交流電流B (A)"},
{ "AC3A", "交流電流C (A)"},
{ "PR", "PR"},
{ "RA1", "RA1 (%)"},
{ "RA2", "RA2 (%)"},
{ "RA3", "RA3 (%)"},
{ "RA4", "RA4 (%)"},
{ "RA5", "RA5 (%)"},
};
var inverterHistories_Group = inverterHistories.GroupBy(x => x.INVERTERID).ToList();
series = new List<InverterHistoryInfo>();
#region
foreach (var item in inverterHistories_Group)
{
var temp_item = item.OrderBy(x => x.TIMESTAMP).ToList();
InverterHistoryInfo DCKW = new InverterHistoryInfo();
DCKW.Name = string.Format("{0}:{1}", item.Key, "直流功率 (KW)");
DCKW.YaxesKey = "DCKW";
DCKW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DCKW.Values.Add(history.DCKW);
}
else
{
DCKW.Values.Add(0);
}
}
series.Add(DCKW);
InverterHistoryInfo ACKW = new InverterHistoryInfo();
ACKW.Name = string.Format("{0}:{1}", item.Key, "輸出功率 (KW)");
ACKW.YaxesKey = "ACKW";
ACKW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
ACKW.Values.Add(history.ACKW);
}
else
{
ACKW.Values.Add(0);
}
}
series.Add(ACKW);
InverterHistoryInfo DC1V = new InverterHistoryInfo();
DC1V.Name = string.Format("{0}:{1}", item.Key, "直流電壓1 (V)");
DC1V.YaxesKey = "DC1V";
DC1V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC1V.Values.Add(history.DC1V);
}
else
{
DC1V.Values.Add(0);
}
}
series.Add(DC1V);
InverterHistoryInfo DC1A = new InverterHistoryInfo();
DC1A.Name = string.Format("{0}:{1}", item.Key, "直流電流1 (A)");
DC1A.YaxesKey = "DC1A";
DC1A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC1A.Values.Add(history.DC1A);
}
else
{
DC1A.Values.Add(0);
}
}
series.Add(DC1A);
InverterHistoryInfo DC1KW = new InverterHistoryInfo();
DC1KW.Name = string.Format("{0}:{1}", item.Key, "直流功率1 (KW)");
DC1KW.YaxesKey = "DC1KW";
DC1KW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC1KW.Values.Add(history.DC1W / 1000);
}
else
{
DC1KW.Values.Add(0);
}
}
series.Add(DC1KW);
InverterHistoryInfo DC2V = new InverterHistoryInfo();
DC2V.Name = string.Format("{0}:{1}", item.Key, "直流電壓2 (V)");
DC2V.YaxesKey = "DC2V";
DC2V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC2V.Values.Add(history.DC2V);
}
else
{
DC2V.Values.Add(0);
}
}
series.Add(DC2V);
InverterHistoryInfo DC2A = new InverterHistoryInfo();
DC2A.Name = string.Format("{0}:{1}", item.Key, "直流電流2 (A)");
DC2A.YaxesKey = "DC2A";
DC2A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC2A.Values.Add(history.DC2A);
}
else
{
DC2A.Values.Add(0);
}
}
series.Add(DC2A);
InverterHistoryInfo DC2KW = new InverterHistoryInfo();
DC2KW.Name = string.Format("{0}:{1}", item.Key, "直流功率2 (KW)");
DC2KW.YaxesKey = "DC2KW";
DC2KW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC2KW.Values.Add(history.DC2W / 1000);
}
else
{
DC2KW.Values.Add(0);
}
}
series.Add(DC2KW);
InverterHistoryInfo DC3V = new InverterHistoryInfo();
DC3V.Name = string.Format("{0}:{1}", item.Key, "直流電壓3 (V)");
DC3V.YaxesKey = "DC3V";
DC3V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC3V.Values.Add(history.DC3V);
}
else
{
DC3V.Values.Add(0);
}
}
series.Add(DC3V);
InverterHistoryInfo DC3A = new InverterHistoryInfo();
DC3A.Name = string.Format("{0}:{1}", item.Key, "直流電流3 (A)");
DC3A.YaxesKey = "DC3A";
DC3A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC3A.Values.Add(history.DC3A);
}
else
{
DC3A.Values.Add(0);
}
}
series.Add(DC3A);
InverterHistoryInfo DC3KW = new InverterHistoryInfo();
DC3KW.Name = string.Format("{0}:{1}", item.Key, "直流功率3 (KW)");
DC3KW.YaxesKey = "DC3KW";
DC3KW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC3KW.Values.Add(history.DC3W / 1000);
}
else
{
DC3KW.Values.Add(0);
}
}
series.Add(DC3KW);
InverterHistoryInfo DC4V = new InverterHistoryInfo();
DC4V.Name = string.Format("{0}:{1}", item.Key, "直流電壓4 (V)");
DC4V.YaxesKey = "DC4V";
DC4V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC4V.Values.Add(history.DC4V);
}
else
{
DC4V.Values.Add(0);
}
}
series.Add(DC4V);
InverterHistoryInfo DC4A = new InverterHistoryInfo();
DC4A.Name = string.Format("{0}:{1}", item.Key, "直流電流4 (A)");
DC4A.YaxesKey = "DC4A";
DC4A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC4A.Values.Add(history.DC4A);
}
else
{
DC4A.Values.Add(0);
}
}
series.Add(DC4A);
InverterHistoryInfo DC4KW = new InverterHistoryInfo();
DC4KW.Name = string.Format("{0}:{1}", item.Key, "直流功率4 (KW)");
DC4KW.YaxesKey = "DC4KW";
DC4KW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC4KW.Values.Add(history.DC4W / 1000);
}
else
{
DC4KW.Values.Add(0);
}
}
series.Add(DC4KW);
InverterHistoryInfo DC5V = new InverterHistoryInfo();
DC5V.Name = string.Format("{0}:{1}", item.Key, "直流電壓5 (V)");
DC5V.YaxesKey = "DC5V";
DC5V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC5V.Values.Add(history.DC5V);
}
else
{
DC5V.Values.Add(0);
}
}
series.Add(DC5V);
InverterHistoryInfo DC5A = new InverterHistoryInfo();
DC5A.Name = string.Format("{0}:{1}", item.Key, "直流電流5 (A)");
DC5A.YaxesKey = "DC5A";
DC5A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC5A.Values.Add(history.DC5A);
}
else
{
DC5A.Values.Add(0);
}
}
series.Add(DC5A);
InverterHistoryInfo DC5KW = new InverterHistoryInfo();
DC5KW.Name = string.Format("{0}:{1}", item.Key, "直流功率5 (KW)");
DC5KW.YaxesKey = "DC5KW";
DC5KW.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
DC5KW.Values.Add(history.DC5W / 1000);
}
else
{
DC5KW.Values.Add(0);
}
}
series.Add(DC5KW);
InverterHistoryInfo AC1V = new InverterHistoryInfo();
AC1V.Name = string.Format("{0}:{1}", item.Key, "交流電壓A (V)");
AC1V.YaxesKey = "AC1V";
AC1V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC1V.Values.Add(history.AC1V);
}
else
{
AC1V.Values.Add(0);
}
}
series.Add(AC1V);
InverterHistoryInfo AC2V = new InverterHistoryInfo();
AC2V.Name = string.Format("{0}:{1}", item.Key, "交流電壓B (V)");
AC2V.YaxesKey = "AC2V";
AC2V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC2V.Values.Add(history.AC2V);
}
else
{
AC2V.Values.Add(0);
}
}
series.Add(AC2V);
InverterHistoryInfo AC3V = new InverterHistoryInfo();
AC3V.Name = string.Format("{0}:{1}", item.Key, "交流電壓C (V)");
AC3V.YaxesKey = "AC3V";
AC3V.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC3V.Values.Add(history.AC3V);
}
else
{
AC3V.Values.Add(0);
}
}
series.Add(AC3V);
InverterHistoryInfo AC1A = new InverterHistoryInfo();
AC1A.Name = string.Format("{0}:{1}", item.Key, "交流電流A (A)");
AC1A.YaxesKey = "AC1A";
AC1A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC1A.Values.Add(history.AC1A);
}
else
{
AC1A.Values.Add(0);
}
}
series.Add(AC1A);
InverterHistoryInfo AC2A = new InverterHistoryInfo();
AC2A.Name = string.Format("{0}:{1}", item.Key, "交流電流B (A)");
AC2A.YaxesKey = "AC2A";
AC2A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC2A.Values.Add(history.AC2A);
}
else
{
AC2A.Values.Add(0);
}
}
series.Add(AC2A);
InverterHistoryInfo AC3A = new InverterHistoryInfo();
AC3A.Name = string.Format("{0}:{1}", item.Key, "交流電流C (A)");
AC3A.YaxesKey = "AC3A";
AC3A.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
AC3A.Values.Add(history.AC3A);
}
else
{
AC3A.Values.Add(0);
}
}
series.Add(AC3A);
InverterHistoryInfo PR = new InverterHistoryInfo();
PR.Name = string.Format("{0}:{1}", item.Key, "PR");
PR.YaxesKey = "PR";
PR.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
PR.Values.Add(history.PR);
}
else
{
PR.Values.Add(0);
}
}
series.Add(PR);
InverterHistoryInfo RA1 = new InverterHistoryInfo();
RA1.Name = string.Format("{0}:{1}", item.Key, "RA1 (%)");
RA1.YaxesKey = "RA1";
RA1.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA1.Values.Add(history.RA1);
}
else
{
RA1.Values.Add(0);
}
}
series.Add(RA1);
InverterHistoryInfo RA2 = new InverterHistoryInfo();
RA2.Name = string.Format("{0}:{1}", item.Key, "RA2 (%)");
RA2.YaxesKey = "RA2";
RA2.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA2.Values.Add(history.RA2);
}
else
{
RA2.Values.Add(0);
}
}
series.Add(RA2);
InverterHistoryInfo RA3 = new InverterHistoryInfo();
RA3.Name = string.Format("{0}:{1}", item.Key, "RA3 (%)");
RA3.YaxesKey = "RA3";
RA3.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA3.Values.Add(history.RA3);
}
else
{
RA3.Values.Add(0);
}
}
series.Add(RA3);
InverterHistoryInfo RA4 = new InverterHistoryInfo();
RA4.Name = string.Format("{0}:{1}", item.Key, "RA4 (%)");
RA4.YaxesKey = "RA4";
RA4.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA4.Values.Add(history.RA4);
}
else
{
RA4.Values.Add(0);
}
}
series.Add(RA4);
InverterHistoryInfo RA5 = new InverterHistoryInfo();
RA5.Name = string.Format("{0}:{1}", item.Key, "RA5 (%)");
RA5.YaxesKey = "RA5";
RA5.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA5.Values.Add(history.RA5);
}
else
{
RA5.Values.Add(0);
}
}
series.Add(RA5);
}
#endregion
analysisInverter.Series = series;
}
else
{ //日區間、月、年
stationIdWithInverterIdsList = new List<StationIdWithInverterIds>();
foreach (var ps in powerStation_Group)
{
StationIdWithInverterIds stationIdWithInverterIds = new StationIdWithInverterIds();
stationIdWithInverterIds.PowerStationId = ps.Key;
stationIdWithInverterIds.InverterIds = ps.Select(x => x.InverterId).ToList();
stationIdWithInverterIdsList.Add(stationIdWithInverterIds);
}
switch (post.SearchType)
{
case 1:
var date_split = post.SelectedDate.Split('-');
inverterHistories = await powerStationRepository.GetInverterHistoryByDate(date_split[0].Trim(), date_split[1].Trim(), stationIdWithInverterIdsList);
break;
case 2:
var startDate = Convert.ToDateTime(post.SelectedDate).ToString("yyyy-MM-dd");
var endDate = Convert.ToDateTime(post.SelectedDate).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
inverterHistories = await powerStationRepository.GetInverterHistoryByDate(startDate, endDate, stationIdWithInverterIdsList);
break;
case 3:
var year = post.SelectedDate;
inverterHistories = await powerStationRepository.GetInverterHistoryByYear(year, stationIdWithInverterIdsList);
break;
}
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
analysisInverter.MultipleYaxes = new Dictionary<string, string>(){
{ "Irradiance", "日照度"},
{ "KWH", "KWH"},
{ "TodayKWH", "TodayKWH"},
{ "TotalKWH", "TotalKWH"},
{ "PR", "PR"},
{ "RA1", "RA1 (%)"},
{ "RA2", "RA2 (%)"},
{ "RA3", "RA3 (%)"},
{ "RA4", "RA4 (%)"},
{ "RA5", "RA5 (%)"},
};
var inverterHistoriesDay_Group = inverterHistories.GroupBy(x => x.INVERTERID).ToList();
#region
foreach (var item in inverterHistoriesDay_Group)
{
var temp_item = item.OrderBy(x => x.TIMESTAMP).ToList();
InverterHistoryInfo Irradiance = new InverterHistoryInfo();
Irradiance.Name = string.Format("{0}:{1}", item.Key, "日照度");
Irradiance.YaxesKey = "Irradiance";
Irradiance.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
Irradiance.Values.Add(history.Irradiance);
}
else
{
Irradiance.Values.Add(0);
}
}
series.Add(Irradiance);
InverterHistoryInfo KWH = new InverterHistoryInfo();
KWH.Name = string.Format("{0}:{1}", item.Key, "KWH");
KWH.YaxesKey = "KWH";
KWH.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
KWH.Values.Add(history.KWH);
}
else
{
KWH.Values.Add(0);
}
}
series.Add(KWH);
InverterHistoryInfo TodayKWH = new InverterHistoryInfo();
TodayKWH.Name = string.Format("{0}:{1}", item.Key, "TodayKWH");
TodayKWH.YaxesKey = "TodayKWH";
TodayKWH.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
TodayKWH.Values.Add(history.TODAYKWH);
}
else
{
TodayKWH.Values.Add(0);
}
}
series.Add(TodayKWH);
InverterHistoryInfo TotalKWH = new InverterHistoryInfo();
TotalKWH.Name = string.Format("{0}:{1}", item.Key, "TotalKWH");
TotalKWH.YaxesKey = "TotalKWH";
TotalKWH.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
TotalKWH.Values.Add(history.TOTALKWH);
}
else
{
TotalKWH.Values.Add(0);
}
}
series.Add(TotalKWH);
InverterHistoryInfo PR = new InverterHistoryInfo();
PR.Name = string.Format("{0}:{1}", item.Key, "PR");
PR.YaxesKey = "PR";
PR.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
PR.Values.Add(history.PR);
}
else
{
PR.Values.Add(0);
}
}
series.Add(PR);
InverterHistoryInfo RA1 = new InverterHistoryInfo();
RA1.Name = string.Format("{0}:{1}", item.Key, "RA1 (%)");
RA1.YaxesKey = "RA1";
RA1.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA1.Values.Add(history.RA1);
}
else
{
RA1.Values.Add(0);
}
}
series.Add(RA1);
InverterHistoryInfo RA2 = new InverterHistoryInfo();
RA2.Name = string.Format("{0}:{1}", item.Key, "RA2 (%)");
RA2.YaxesKey = "RA2";
RA2.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA2.Values.Add(history.RA2);
}
else
{
RA2.Values.Add(0);
}
}
series.Add(RA2);
InverterHistoryInfo RA3 = new InverterHistoryInfo();
RA3.Name = string.Format("{0}:{1}", item.Key, "RA3 (%)");
RA3.YaxesKey = "RA3";
RA3.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA3.Values.Add(history.RA3);
}
else
{
RA3.Values.Add(0);
}
}
series.Add(RA3);
InverterHistoryInfo RA4 = new InverterHistoryInfo();
RA4.Name = string.Format("{0}:{1}", item.Key, "RA4 (%)");
RA4.YaxesKey = "RA4";
RA4.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA4.Values.Add(history.RA4);
}
else
{
RA4.Values.Add(0);
}
}
series.Add(RA4);
InverterHistoryInfo RA5 = new InverterHistoryInfo();
RA5.Name = string.Format("{0}:{1}", item.Key, "RA5 (%)");
RA5.YaxesKey = "RA5";
RA5.Values = new List<double>();
foreach (var history in temp_item)
{
if (analysisInverter.XAxis.IndexOf(history.TIMESTAMP) > -1)
{
RA5.Values.Add(history.RA5);
}
else
{
RA5.Values.Add(0);
}
}
series.Add(RA5);
}
#endregion
analysisInverter.Series = series;
}
apiResult.Code = "0000";
apiResult.Data = analysisInverter;
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
}
}

View File

@ -1,4 +1,8 @@
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;
using System.Linq;
@ -8,9 +12,76 @@ namespace SolarPower.Controllers
{
public class AnalysisStationInfoController : MyBaseController<AnalysisStationInfoController>
{
private readonly IPowerStationRepository powerStationRepository;
public AnalysisStationInfoController(IPowerStationRepository powerStationRepository) : base()
{
this.powerStationRepository = powerStationRepository;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<ApiResult<Dictionary<string, Dictionary<string, List<PowerStationDevice>>>>> GetDeviceCollapse(string filter)
{
ApiResult<Dictionary<string, Dictionary<string, List<PowerStationDevice>>>> apiResult = new ApiResult<Dictionary<string, Dictionary<string, List<PowerStationDevice>>>>();
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 powerStationDevices = await powerStationRepository.GetPowerStationDevice(siteDBNamePowerStationId, filter);
powerStationDevices = powerStationDevices.Where(x => x.DeviceId != null).ToList();
var powerStationDevice_Group = powerStationDevices.GroupBy(x => x.CityName).ToList();
var deviceCollapse = new Dictionary<string, Dictionary<string, List<PowerStationDevice>>>();
foreach (var powerStationDevice in powerStationDevice_Group)
{
var device_Group = powerStationDevice.GroupBy(x => x.PowerStationName).ToList();
var deviceDic = new Dictionary<string, List<PowerStationDevice>>();
foreach (var inverter in device_Group)
{
deviceDic.Add(inverter.Key, inverter.ToList());
}
deviceCollapse.Add(powerStationDevice.Key, deviceDic);
}
apiResult.Code = "0000";
apiResult.Data = deviceCollapse;
}
catch (Exception exception)
{
apiResult.Code = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
}
}

View File

@ -1975,7 +1975,13 @@ ALTER TABLE `power_station`
ALTER TABLE `operation_plan_create`
ADD COLUMN `IsDelivery` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否建立 發送Email資料 0:否 1:是' AFTER `LastCreateTime`;
-- 新增逆變器歷史資料欄位 20210727
ALTER TABLE `inverter_history_hour`
ADD COLUMN `TOTALKWH` DOUBLE NULL DEFAULT NULL AFTER `TODAYKWH`;
ALTER TABLE `inverter_history_day`
ADD COLUMN `TOTALKWH` DOUBLE NULL DEFAULT NULL AFTER `TODAYKWH`;
ALTER TABLE `inverter_history_month`
ADD COLUMN `TOTALKWH` DOUBLE NULL DEFAULT NULL AFTER `TODAYKWH`;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

View File

@ -14,17 +14,44 @@ namespace SolarPower.Models
public string InverterId { get; set; }
}
public class PostAnalysisInverter
{
public byte SearchType { get; set; }
public string SelectedDate { get; set; }
public List<InverterIdInfo> InverterIdInfos { get; set; }
}
public class InverterIdInfo
{
public int PowerStationId { get; set; }
public string InverterId { get; set; }
}
public class StationCodeWithInverterIds
{
public string SiteDB { get; set; }
public string Code { get; set; }
public List<string> InverterIds { get; set; }
}
public class AnalysisInverter
{
public List<string> XAxis { get; set; } //時間
public List<string> MultipleYaxes { get; set; } //Y軸名稱
public Dictionary<string, List<InverterHistoryInfo>> Series { get; set; } //數組
public List<string> XAxisOnTime { get; set; } //時間(整點)
public Dictionary<string, string> MultipleYaxes { get; set; } //Y軸名稱
public List<InverterHistoryInfo> Series { get; set; } //數組
}
public class InverterHistoryInfo
{
public string Time { get; set; }
public string Yaxes { get; set; }
public double Value { get; set; }
public string Name { get; set; }
public string YaxesKey { get; set; }
public List<double> Values { get; set; }
}
public class StationIdWithInverterIds
{
public int PowerStationId { get; set; }
public List<string> InverterIds { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SolarPower.Models
{
public class AnalysisStationInfo
{
}
public class PowerStationDevice
{
public int PowerStationId { get; set; }
public string CityName { get; set; }
public string PowerStationName { get; set; }
public string DeviceName { get; set; }
public string DeviceType { get; set; }
public string DeviceId { get; set; }
}
}

View File

@ -718,6 +718,7 @@ namespace SolarPower.Models.PowerStation
public double ACKW { get; set; }
public double KWH { get; set; }
public double TODAYKWH { get; set; }
public double TOTALKWH { get; set; }
public double KWHKWP { get; set; }
}
#region

View File

@ -96,8 +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}", System.Text.Json.JsonSerializer.Serialize(calcInverter15mins));
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)

View File

@ -31,6 +31,7 @@ namespace SolarPower.Quartz.Jobs
{
var DateTimeNow = DateTime.Now;
var dateTime = DateTimeNow.AddHours(-1).ToString("yyyy-MM-dd HH");
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
#region step1.
@ -116,14 +117,14 @@ namespace SolarPower.Quartz.Jobs
{
sumLeaseRate += landBuilding.LeaseRate;
}
avgLeaseRate = sumLeaseRate / landBuildings.Count();
//avgLeaseRate = sumLeaseRate / landBuildings.Count();
//今日發電金額計算方式todaykWh * 出借費率(各個土地房屋租借比率平均)
calcPowerStation.Today_Money = history.TodayKWh * avgLeaseRate;
calcPowerStation.Today_Money = history.TodayKWh * sumLeaseRate;
history.MONEY = history.KWH * avgLeaseRate;
history.MONEY = history.KWH * sumLeaseRate;
//總發電金額 計算方式totalkWh * 授電費率
calcPowerStation.Total_Money = history.TotalKWH * avgLeaseRate;
calcPowerStation.Total_Money = history.TotalKWH * sumLeaseRate;
break;
case (int)SolarTypeEnum.SelfUse: //自建自用
//今日發電金額 計算方式todaykWh * 授電費率

View File

@ -2252,7 +2252,9 @@ namespace SolarPower.Repository.Implement
{
try
{
var sql = $@"SELECT *
var sql = $@"SELECT temp.*
FROM(
SELECT d.*
FROM {db_name}.device d
WHERE d.PowerStationId = @PowerStationId AND d.`Type` = 'PYR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0
UNION
@ -2260,6 +2262,8 @@ namespace SolarPower.Repository.Implement
FROM {db_name}.sharedevice sd
LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id
WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'PYR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0
) temp
ORDER BY temp.ColName LIMIT 1
";
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId })).ToList();
@ -2321,7 +2325,8 @@ namespace SolarPower.Repository.Implement
{
var str = @$"SELECT DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/ 1000), '%Y-%m-%d %H') AS TIMESTAMP, s.SITEID, AVG(s.{device.ColName}) AS SENSOR
FROM {device.DBName}.{device.TableName} s
WHERE DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/ 1000), '%Y-%m-%d %H') = @DateTime
WHERE s.{device.ColName} != 0
AND DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/ 1000), '%Y-%m-%d %H') = @DateTime
GROUP BY DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/ 1000), '%Y-%m-%d %H')";
sql_per_device.Add(str);
@ -2690,40 +2695,40 @@ namespace SolarPower.Repository.Implement
s.INVERTERID,
AVG(s.AC1V) AS AC1V,
AVG(s.AC1A) AS AC1A,
AVG(s.AC1W) AS AC1W,
SUM(s.AC1W) AS AC1W,
AVG(s.AC1F) AS AC1F,
AVG(s.AC1WH) AS AC1WH,
SUM(s.AC1WH) AS AC1WH,
AVG(s.AC2V) AS AC2V,
AVG(s.AC2A) AS AC2A,
AVG(s.AC2W) AS AC2W,
SUM(s.AC2W) AS AC2W,
AVG(s.AC2F) AS AC2F,
AVG(s.AC2WH) AS AC2WH,
SUM(s.AC2WH) AS AC2WH,
AVG(s.AC3V) AS AC3V,
AVG(s.AC3A) AS AC3A,
AVG(s.AC3W) AS AC3W,
SUM(s.AC3W) AS AC3W,
AVG(s.AC3F) AS AC3F,
AVG(s.AC3WH) AS AC3WH,
SUM(s.AC3WH) AS AC3WH,
AVG(s.DC1V) AS DC1V,
AVG(s.DC1A) AS DC1A,
AVG(s.DC1W) AS DC1W,
AVG(s.DC1WH) AS DC1WH,
SUM(s.DC1W) AS DC1W,
SUM(s.DC1WH) AS DC1WH,
AVG(s.DC2V) AS DC2V,
AVG(s.DC2A) AS DC2A,
AVG(s.DC2W) AS DC2W,
AVG(s.DC2WH) AS DC2WH,
SUM(s.DC2W) AS DC2W,
SUM(s.DC2WH) AS DC2WH,
AVG(s.DC3V) AS DC3V,
AVG(s.DC3A) AS DC3A,
AVG(s.DC3W) AS DC3W,
AVG(s.DC3WH) AS DC3WH,
AVG(s.DC4V) AS DC4V,
AVG(s.DC4A) AS DC4A,
AVG(s.DC4W) AS DC4W,
AVG(s.DC4WH) AS DC4WH,
SUM(s.DC4W) AS DC4W,
SUM(s.DC4WH) AS DC4WH,
AVG(s.DC5V) AS DC5V,
AVG(s.DC5A) AS DC5A,
AVG(s.DC5W) AS DC5W,
AVG(s.DC5WH) AS DC5WH,
AVG(s.PR) AS PR,
SUM(s.DC5W) AS DC5W,
SUM(s.DC5WH) AS DC5WH,
inv_pr.PR AS PR,
AVG(s.RA1) AS RA1,
AVG(s.RA2) AS RA2,
AVG(s.RA3) AS RA3,
@ -2731,9 +2736,11 @@ namespace SolarPower.Repository.Implement
AVG(s.RA5) AS RA5,
a.KWH,
MAX(s.TODAYKWH) AS TODAYKWH,
MAX(s.TOTALKWH) AS TOTALKWH,
i.Capacity,
(a.KWH/i.Capacity) AS KWHKWP
FROM {table_name} s
-- KWH
LEFT JOIN (
SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
@ -2744,6 +2751,18 @@ namespace SolarPower.Repository.Implement
AND inv.INVERTERID IN @InverterIds
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) a
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID
-- PR
LEFT JOIN (
SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
inv.INVERTERID,
inv.PR
FROM {table_name} inv
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H:%i') = CONCAT(@DateTime, ':55')
AND inv.INVERTERID IN @InverterIds
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) inv_pr
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = inv_pr.TIMESTAMP AND s.INVERTERID = inv_pr. INVERTERID
--
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = i.InverterId
WHERE FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime
AND s.INVERTERID IN @InverterIds
@ -2795,7 +2814,8 @@ namespace SolarPower.Repository.Implement
WHEN AVG({col_name}) IS NOT NULL THEN AVG({col_name})
END
FROM {db_name}.{table_name}
WHERE FROM_UNIXTIME(TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime";
WHERE {col_name} != 0
AND FROM_UNIXTIME(TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime";
result = await conn.QueryFirstOrDefaultAsync<double>(sql, new { DateTime = dateTime });
}
@ -3637,7 +3657,7 @@ namespace SolarPower.Repository.Implement
{
List<string> sql_perSiteDB = new List<string>();
var sql = "";
foreach(var powerStationDic in dic)
foreach (var powerStationDic in dic)
{
var powerStationIds = string.Join(",", powerStationDic.Value);
@ -3662,7 +3682,216 @@ namespace SolarPower.Repository.Implement
sql = string.Join(" UNION ", sql_perSiteDB);
result = (await conn.QueryAsync<PowerStationInverter>(sql, new { Filter = filter})).ToList();
result = (await conn.QueryAsync<PowerStationInverter>(sql, new { Filter = filter })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
public async Task<List<PowerStationDevice>> GetPowerStationDevice(Dictionary<string, List<int>> dic, string filter)
{
List<PowerStationDevice> 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,
d.Name AS DeviceName,
d.`Type` AS DeviceType,
d.UID AS DeviceId
FROM power_station ps
LEFT JOIN `city` c ON ps.CityId = c.Id
LEFT JOIN {powerStationDic.Key}.device d ON ps.Id = d.PowerStationId AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status = 1
WHERE ps.Deleted = 0
AND ps.Id IN ({powerStationIds})";
if (!string.IsNullOrEmpty(filter))
{
temp_sql += " AND d.Name LIKE CONCAT('%', @Filter, '%')";
}
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
result = (await conn.QueryAsync<PowerStationDevice>(sql, new { Filter = filter })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
public async Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities)
{
List<InverterHistory> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
List<string> sql_perSiteDB = new List<string>();
var sql = "";
foreach (var entity in entities)
{
var table_name = string.Format("`{0}`.`s{1}01_inv`", entity.SiteDB, entity.Code);
var inverterIds = string.Join("','", entity.InverterIds);
var temp_sql = $@"SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP,
inv.INVERTERID,
((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW,
((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW,
inv.AC1V,
inv.AC1A,
inv.AC1W,
inv.AC1F,
inv.AC1WH,
inv.AC2V,
inv.AC2A,
inv.AC2W,
inv.AC2F,
inv.AC2WH,
inv.AC3V,
inv.AC3A,
inv.AC3W,
inv.AC3F,
inv.AC3WH,
inv.DC1V,
inv.DC1A,
inv.DC1W,
inv.DC1WH,
inv.DC2V,
inv.DC2A,
inv.DC2W,
inv.DC2WH,
inv.DC3V,
inv.DC3A,
inv.DC3W,
inv.DC3WH,
inv.DC4V,
inv.DC4A,
inv.DC4W,
inv.DC4WH,
inv.DC5V,
inv.DC5A,
inv.DC5W,
inv.DC5WH,
inv.PR,
inv.RA1,
inv.RA2,
inv.RA3,
inv.RA4,
inv.RA5
FROM {table_name} inv
WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
AND INVERTERID IN ('{inverterIds}')";
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
public async Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities)
{
List<InverterHistory> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
List<string> sql_perSiteDB = new List<string>();
var sql = "";
foreach (var entity in entities)
{
var inverterIds = string.Join("','", entity.InverterIds);
var temp_sql = $@"SELECT
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
INVERTERID,
inv.Irradiance,
inv.KWH,
inv.TODAYKWH,
inv.PR,
inv.RA1,
inv.RA2,
inv.RA3,
inv.RA4,
inv.RA5
FROM inverter_history_day inv
WHERE inv.PowerStationId = {entity.PowerStationId}
AND inv.INVERTERID IN ('{inverterIds}')
AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay";
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDay = startDay, EndDay = endDay })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
public async Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities)
{
List<InverterHistory> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
List<string> sql_perSiteDB = new List<string>();
var sql = "";
foreach (var entity in entities)
{
var inverterIds = string.Join("','", entity.InverterIds);
var temp_sql = $@"SELECT
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
INVERTERID,
inv.KWH,
inv.TODAYKWH,
inv.PR,
inv.RA1,
inv.RA2,
inv.RA3,
inv.RA4,
inv.RA5
FROM inverter_history_month inv
WHERE inv.PowerStationId = {entity.PowerStationId}
AND inv.INVERTERID IN ('{inverterIds}')
AND DATE_FORMAT(inv.TIMESTAMP, '%Y') = @Year";
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
result = (await conn.QueryAsync<InverterHistory>(sql, new { Year = year })).ToList();
}
catch (Exception exception)
{

View File

@ -548,6 +548,10 @@ namespace SolarPower.Repository.Interface
Task<int> UpdateSensorAvgHistoryMonthList(List<SensorAvgHistory> entity);
Task<List<PowerStation>> GetPowerStationsByCompanyId(int companyId);
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
Task<List<PowerStationDevice>> GetPowerStationDevice(Dictionary<string, List<int>> dic, string filter);
Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities);
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(int companyId,string filter);
Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilter(string filter);
}

View File

@ -15,149 +15,6 @@
<input type="text" class="form-control form-control-lg shadow-inset-2 m-0" id="js_list_accordion_filter" placeholder="">
</div>
<div id="js_list_accordion" class="accordion accordion-hover accordion-clean js-list-filter">
<div class="card border-top-left-radius-0 border-top-right-radius-0">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-a" aria-expanded="false" data-filter-tags="settings">
<i class="fal fa-globe width-2 fs-xl"></i>
新北市
<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-a" class="collapse" data-parent="#js_list_accordion" style="">
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹交大站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-tachometer-alt-slow"></i> 電錶 R001</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-sun"></i> 日照計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-thermometer-half"></i> 環境溫度計 R003</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-wind"></i> 風速計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-sun-dust"></i> 落塵計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-tint"></i> 濕度計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-server"></i> 逆變器 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
</ul>
</li>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹動物園站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹火車站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-b" aria-expanded="false" data-filter-tags="merge">
<i class="fal fa-globe width-2 fs-xl"></i>
台南市
<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-b" class="collapse" data-parent="#js_list_accordion">
<div class="card-body">
放台南市list
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-c" aria-expanded="false" data-filter-tags="backup">
<i class="fal fa-globe width-2 fs-xl"></i>
屏東縣
<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-c" class="collapse" data-parent="#js_list_accordion">
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">
<span data-filter-tags="reports file">Reports</span>
</li>
<li class="list-group-item">
<span data-filter-tags="analytics graphs">Analytics</span>
</li>
<li class="list-group-item">
<span data-filter-tags="export download">Export</span>
</li>
<li class="list-group-item">
<span data-filter-tags="storage">Storage</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<span class="filter-message js-filter-message"></span>
</div>
@ -167,8 +24,6 @@
<a href="javascript:;" data-target=".sidebar" data-toggle="collapse" class="btn btn-default btn-xs btn-icon waves-effect waves-themed" style="border-radius: 0;"><i onclick="myfunc(this)" class="fal fa-angle-right fa-lg py-3"></i></a>
</div>
<main class="col px-5 pl-md-2 main">
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">交叉分析</a></li>
@ -181,7 +36,6 @@
</h1>
</div>
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
@ -210,7 +64,7 @@
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">查詢</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="GetAnalysisInverter()">查詢</button>
</div>
</div>
@ -220,31 +74,62 @@
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">選擇比較欄位 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">選擇比較欄位</button>
<ul class="dropdown-menu" id="compare-dropdown-menu" style="width:10vw;overflow-x:hidden; max-height:50vh">
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option1" tabIndex="-1">日照度<input type="checkbox" class="float-right" name="compare_col[]" value="Irradiance" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option2" tabIndex="-1">直流功率 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DCKW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option3" tabIndex="-1">輸出功率 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="ACKW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option4" tabIndex="-1">直流電壓1 (V)<input type="checkbox" class="float-right" name="compare_col[]" value="DC1V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option5" tabIndex="-1">直流電流1 (A)<input type="checkbox" class="float-right" name="compare_col[]" value="DC1A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">直流功率1 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DC1KW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option4" tabIndex="-1">直流電壓2 (V)<input type="checkbox" class="float-right" name="compare_col[]" value="DC2V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option5" tabIndex="-1">直流電流2 (A)<input type="checkbox" class="float-right" name="compare_col[]" value="DC2A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">直流功率2 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DC2KW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option4" tabIndex="-1">直流電壓3 (V)<input type="checkbox" class="float-right" name="compare_col[]" value="DC3V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option5" tabIndex="-1">直流電流3 (A)<input type="checkbox" class="float-right" name="compare_col[]" value="DC3A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">直流功率3 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DC3KW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option4" tabIndex="-1">直流電壓4 (V)<input type="checkbox" class="float-right" name="compare_col[]" value="DC4V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option5" tabIndex="-1">直流電流4 (A)<input type="checkbox" class="float-right" name="compare_col[]" value="DC4A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">直流功率4 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DC4KW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option4" tabIndex="-1">直流電壓5 (V)<input type="checkbox" class="float-right" name="compare_col[]" value="DC5V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option5" tabIndex="-1">直流電流5 (A)<input type="checkbox" class="float-right" name="compare_col[]" value="DC5A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">直流功率5 (KW)<input type="checkbox" class="float-right" name="compare_col[]" value="DC5KW" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電壓A (V)<input type="checkbox" class="float-right" name="compare_col[]" value="AC1V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電壓B (V)<input type="checkbox" class="float-right" name="compare_col[]" value="AC2V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電壓C (V)<input type="checkbox" class="float-right" name="compare_col[]" value="AC3V" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電流A (A)<input type="checkbox" class="float-right" name="compare_col[]" value="AC1A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電流B (A)<input type="checkbox" class="float-right" name="compare_col[]" value="AC2A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">交流電流C (A)<input type="checkbox" class="float-right" name="compare_col[]" value="AC3A" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">PR<input type="checkbox" class="float-right" name="compare_col[]" value="PR" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">RA1 (%)<input type="checkbox" class="float-right" name="compare_col[]" value="RA1" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">RA2 (%)<input type="checkbox" class="float-right" name="compare_col[]" value="RA2" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">RA3 (%)<input type="checkbox" class="float-right" name="compare_col[]" value="RA3" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">RA4 (%)<input type="checkbox" class="float-right" name="compare_col[]" value="RA4" /></a></li>
<li><a href="javascript:void(0)" class="dropdown-item" data-value="option6" tabIndex="-1">RA5 (%)<input type="checkbox" class="float-right" name="compare_col[]" value="RA5" /></a></li>
</ul>
</div>
</div>
</div>
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">下載 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
@*<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">下載 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
</div>
</div>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed"><i class="fal fa-expand fs-md"></i></button>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed"><i class="fal fa-expand fs-md"></i></button>
</div>*@
</div>
<p>放圖表</p>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
</div>
</div>
</div>
@ -261,7 +146,58 @@
var searchType = 0;//搜尋條件(日,日區間,月,年)
var datepicker;
var timerange;//選取時間
var selecterd_invert = [];
var selected_inverter = [];
var selected_YAxis = [];
var analysisInverter;
var myXAxis = []; var myYAxis = []; var mySeries = [];
var chart;
var default_compare_row_data = ["ACKW"]
var compare_row_data = [
{ key: "Irradiance", title: "日照度"},
{ key: "DCKW", title: "直流功率 (KW)"},
{ key: "ACKW", title: "輸出功率 (KW)"},
{ key: "DC1V", title: "直流電壓1 (V)"},
{ key: "DC1A", title: "直流電流1 (A)"},
{ key: "DC1KW", title: "直流功率1 (KW)"},
{ key: "DC2V", title: "直流電壓2 (V)"},
{ key: "DC2A", title: "直流電流2 (A)"},
{ key: "DC2KW", title: "直流功率2 (KW)"},
{ key: "DC3V", title: "直流電壓3 (V)"},
{ key: "DC3A", title: "直流電流3 (A)"},
{ key: "DC3KW", title: "直流功率3 (KW)"},
{ key: "DC4V", title: "直流電壓4 (V)"},
{ key: "DC4A", title: "直流電流4 (A)"},
{ key: "DC4KW", title: "直流功率4 (KW)"},
{ key: "DC5V", title: "直流電壓5 (V)"},
{ key: "DC5A", title: "直流電流5 (A)"},
{ key: "DC5KW", title: "直流功率5 (KW)"},
{ key: "AC1V", title: "交流電壓A (V)"},
{ key: "AC2V", title: "交流電壓B (V)"},
{ key: "AC3V", title: "交流電壓C (V)"},
{ key: "AC1A", title: "交流電流A (A)"},
{ key: "AC2A", title: "交流電流B (A)"},
{ key: "AC3A", title: "交流電流C (A)"},
{ key: "PR", title: "PR"},
{ key: "RA1", title: "RA1 (%)"},
{ key: "RA2", title: "RA2 (%)"},
{ key: "RA3", title: "RA3 (%)"},
{ key: "RA4", title: "RA4 (%)"},
{ key: "RA5", title: "RA5 (%)"}
]
var default_compare_date = ["KWH"]
var compare_date = [
{ key: "Irradiance", title: "日照度"},
{ key: "KWH", title: "KWH"},
{ key: "TodayKWH", title: "TodayKWH"},
{ key: "TotalKWH", title: "TotalKWH"},
{ key: "PR", title: "PR"},
{ key: "RA1", title: "RA1 (%)"},
{ key: "RA2", title: "RA2 (%)"},
{ key: "RA3", title: "RA3 (%)"},
{ key: "RA4", title: "RA4 (%)"},
{ key: "RA5", title: "RA5 (%)"}
]
$(function () {
//#region 預設初始值
@ -275,6 +211,8 @@
//#region 載入左邊選單列表
GetPowerStationCollapse("");
//#endregion
})
function myfunc(div) {
@ -302,6 +240,13 @@
$(".btn-change-quickSearch2").html("昨天");
var today = new Date().toISOString().substring(0, 10);
$('#DateGet').val(today);
$("#compare-dropdown-menu").empty();
var str = "";
$.each(compare_row_data, function (index, item) {
str += '<li><a href="javascript:void(0)" class="dropdown-item" tabIndex="-1">' + item.title + '<input type="checkbox" class="float-right" name="compare_col[]" value="' + item.key + '" /></a></li>'
});
$("#compare-dropdown-menu").append(str);
break;
case 1:
@ -337,12 +282,27 @@
//#endregion
$('#DateGettext').val(dateLimit_format + ' - ' + today_format);
$("#compare-dropdown-menu").empty();
var str = "";
$.each(compare_date, function (index, item) {
str += '<li><a href="javascript:void(0)" class="dropdown-item" tabIndex="-1">' + item.title + '<input type="checkbox" class="float-right" name="compare_col[]" value="' + item.key + '" /></a></li>'
});
$("#compare-dropdown-menu").append(str);
break;
case 2: $('#DateGet').prop({ 'type': 'month' });
$(".btn-change-quickSearch1").html("本月");
$(".btn-change-quickSearch2").html("上個月");
var now_month = new Date().toISOString().substring(0, 7);
$('#DateGet').val(now_month);
$("#compare-dropdown-menu").empty();
var str = "";
$.each(compare_date, function (index, item) {
str += '<li><a href="javascript:void(0)" class="dropdown-item" tabIndex="-1">' + item.title + '<input type="checkbox" class="float-right" name="compare_col[]" value="' + item.key + '" /></a></li>'
});
$("#compare-dropdown-menu").append(str);
break;
case 3:
$(".btn-change-quickSearch1").html("今年");
@ -350,6 +310,14 @@
var now_year = new Date().toISOString().substring(0, 4);
$('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
$('#DateGet').val(now_year);
$("#compare-dropdown-menu").empty();
var str = "";
$.each(compare_date, function (index, item) {
str += '<li><a href="javascript:void(0)" class="dropdown-item" tabIndex="-1">' + item.title + '<input type="checkbox" class="float-right" name="compare_col[]" value="' + item.key + '" /></a></li>'
});
$("#compare-dropdown-menu").append(str);
break;
}
if (type == 1) {
@ -436,16 +404,17 @@
$('#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);
if ($.inArray(this.value, selected_inverter) < 0) {
var powerStationId = $(this).attr('data-power-station-id');
selected_inverter.push({ powerStationId: powerStationId, InverterId: this.value });
}
} else {
if ($.inArray(this.value, selecterd_invert) > -1) {
selecterd_invert.splice($.inArray(this.value, selecterd_invert), 1);
if ($.inArray(this.value, selected_inverter) > -1) {
var powerStationId = $(this).attr('data-power-station-id');
selected_inverter.splice($.inArray({ powerStationId: powerStationId, InverterId: this.value }, selected_inverter), 1);
}
}
console.log(selecterd_invert);
console.log(selected_inverter);
});
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
@ -456,6 +425,16 @@
}
});
$('#compare-dropdown-menu').on('change','input[name="compare_col[]"]', function (e) {
if (this.checked) {
selected_YAxis.push($(this).val());
} else {
selected_YAxis.splice($.inArray($(this).val(), selected_YAxis), 1);
}
ReloadHighCharts();
});
function GetPowerStationCollapse(filter) {
var url = "/AnalysisInverter/GetInverterCollapse"
@ -471,11 +450,9 @@
var inverterCollapse = rel.data;
$('#js_list_accordion').empty();
if (inverterCollapse.length <= 0) {
if (inverterCollapse == undefined && inverterCollapse.length <= 0) {
$('#js_list_accordion').append("<div>查無結果</div>");
}
@ -484,7 +461,7 @@
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">' +
'<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">' +
@ -508,7 +485,7 @@
$.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>&nbsp;' + inverter.inverterName + '</a>' +
'<div class=""><input type="checkbox" class="" name="selectedInverterId[]" value="' + inverter.inverterId + '">' + '</div>'
'<div class=""><input type="checkbox" class="" name="selectedInverterId[]" data-power-station-id="' + inverter.powerStationId + '" value="' + inverter.inverterId + '">' + '</div>'
'</li>';
});
str += '</ul>' +
@ -524,21 +501,165 @@
$('#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)
if (selected_inverter.length <= 0) {
$('input[name="selectedInverterId[]"]').first().trigger("click");
}
$('input[name="selectedInverterId[]"]').each(function () {
if ($.inArray(this.value, selecterd_invert) > -1) {
if ($.inArray(this.value, selected_inverter) > -1) {
$(this).prop('checked', true);
}
});
$("#js_list_accordion .collapse").collapse('show');
}, 'json');
}
function GetAnalysisInverter() {
var date;
if (searchType != 1) {
date = $('#DateGet').val();
} else {
date = $('#DateGettext').val();
}
var url = "/AnalysisInverter/GetAnalysisByInverterIds";
var send_data = {
SearchType: searchType,
SelectedDate: date,
InverterIdInfos: selected_inverter
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
analysisInverter = rel.data;
if (searchType != 0) {
$('input[name="compare_col[]"]').each(function () {
if ($.inArray(this.value, default_compare_date) > -1) {
$(this).prop('checked', true).trigger('change');
}
});
}
else {
$('input[name="compare_col[]"]').each(function () {
if ($.inArray(this.value, default_compare_row_data) > -1) {
$(this).prop('checked', true).trigger('change');
}
});
}
ReloadHighCharts();
}, 'json');
}
function ReloadHighCharts() {
myYAxis = []; mySeries = [];
myXAxis = analysisInverter.xAxis
Object.keys(analysisInverter.multipleYaxes).map(function (key, index) {
if (selected_YAxis.indexOf(key) > -1) {
var yAxis = {
title: {
text: analysisInverter.multipleYaxes[key],
},
id: key,
opposite: myYAxis.length > 0 ? true : false,
showEmpty: false
}
myYAxis.push(yAxis);
}
});
analysisInverter.series.map(function (item, index) {
if (selected_YAxis.indexOf(item.yaxesKey) > -1) {
var ser = {
type: 'spline',
name: item.name,
data: item.values,
yAxis: item.yaxesKey,
}
mySeries.push(ser);
}
});
if (chart) {
chart.destroy();
}
chart = new Highcharts.Chart({
lang: { //匯出相關中文名稱配置
printChart: '列印圖表',
downloadJPEG: '下載JPEG檔案',
downloadPDF: '下載PDF檔案',
downloadPNG: '下載PNG檔案',
downloadSVG: '下載SVG檔案',
downloadCSV: '下載CSV檔案',
downloadXLS: '下載XLS檔案',
viewData: '檢視資料表格',
viewFullscreen: '全屏檢視'
},
chart: {
renderTo: 'container',
height: 600,
animation: false
},
title: {
text: '交叉分析圖表'
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br>' +
'<span>' + this.x + '</span><br>' +
'<b style = "color:rgb(103, 180, 172);" >' + this.point.y + '</b>';
}
},
xAxis: {
categories: myXAxis,
labels: {
step: 1,
formatter: function () {
if (searchType == 0) {
var aa = this.value.substr(-2);
if (aa == "00") {
return '<span>' + this.value + '</span>';
} else {
return '<span style="display:none">' + this.value + '</span>';
}
} else {
return this.value
}
}
}
},
yAxis: myYAxis,
series: mySeries,
});
@*$("#container").highcharts({
chart: {
height: 600
},
xAxis: {
categories: myXAxis
},
yAxis: myYAxis,
series: mySeries,
});*@
}
</script>
}

View File

@ -3,87 +3,513 @@
ViewData["SubNum"] = "2";
ViewData["Title"] = "電站交叉分析";
}
@using SolarPower.Models.Role
@model RoleLayerEnum
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">交叉分析</a></li>
<li class="breadcrumb-item active">電站交叉分析</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>
<div class="subheader">
<h1 class="subheader-title">
<i class="subheader-icon fal fa-crosshairs"></i> 電站交叉分析
</h1>
</div>
<div class="container-fluid">
<div class="row flex-nowrap wrapper">
<div class="col-md-2 col-1 pl-0 pr-0 collapse width border-right sidebar vh-100">
<div class="list-group border-0 card text-center text-md-left" id="sidebar">
<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="mb-5 d-flex justify-content-start">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed">日期</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">日區間</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">年</button>
</div>
</div>
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed">今天</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">昨天</button>
</div>
</div>
<div class="pr-3">
<div class="form-group">
<input class="form-control" id="example-date" type="date" name="date" value="2023-07-23">
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">查詢</button>
</div>
<div class="border bg-light rounded-top">
<div class="form-group p-2 m-0 rounded-top">
<input type="text" class="form-control form-control-lg shadow-inset-2 m-0" id="js_list_accordion_filter" placeholder="">
</div>
<div id="js_list_accordion" class="accordion accordion-hover accordion-clean js-list-filter">
</div>
<span class="filter-message js-filter-message"></span>
</div>
</div>
</div>
<div class="col-auto px-0">
<a href="javascript:;" data-target=".sidebar" data-toggle="collapse" class="btn btn-default btn-xs btn-icon waves-effect waves-themed" style="border-radius: 0;"><i onclick="myfunc(this)" class="fal fa-angle-right fa-lg py-3"></i></a>
</div>
</div>
<main class="col px-5 pl-md-2 main">
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">交叉分析</a></li>
<li class="breadcrumb-item active">@ViewData["Title"]</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>
<div class="subheader">
<h1 class="subheader-title">
<i class="subheader-icon fal fa-crosshairs"></i> @ViewData["Title"]
</h1>
</div>
<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="mb-5 d-flex justify-content-start">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed btn-change-searchType" id="Group0" onclick="changeType(0,this)">日</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group1" onclick="changeType(1,this)">日區間</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group2" onclick="changeType(2,this)">月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group3" onclick="changeType(3,this)">年</button>
</div>
</div>
<div class="pr-3" id="quickSearchOption">
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-quickSearch1" onclick="quickSearch(0)">今天</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-quickSearch2" onclick="quickSearch(1)">昨天</button>
</div>
<div class="mb-5">
<div class="card p-3 w-100">
<div class="row mb-5 d-flex justify-content-end">
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">選擇比較欄位 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
</div>
<input type="date" class="form-control" id="DateGet" />
</div>
<div class="btn-group" id="DateGettextdiv" role="group" aria-label="Button group with nested dropdown">
<input type="text" class="form-control" id="DateGettext" />
</div>
</div>
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">下載 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
<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">
<div class="row mb-5 d-flex justify-content-end">
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">選擇比較欄位 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed"><i class="fal fa-expand fs-md"></i></button>
</div>
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">下載 </button>
<div class="dropdown-menu">
<a class="dropdown-item" href="javascript:void(0)">2021 四月</a>
<a class="dropdown-item" href="javascript:void(0)">2021 三月</a>
</div>
</div>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed"><i class="fal fa-expand fs-md"></i></button>
</div>
</div>
<p>放圖表</p>
</div>
</div>
<p>放圖表</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
@section Scripts{
<script>
var searchType = 0;//搜尋條件(日,日區間,月,年)
var datepicker;
var timerange;//選取時間
var selected_device = [];
var PYR_select_col = [{ name: "日照度", type: "PYR", value: "Irradiance" }];
var ETR_select_col = [{ name: "環境溫度計", type: "ETR", value: "Temperature" }];
var EMM_select_col = [{ name: "濕度", type: "EMM", value: "Humidity" }];
var VAN_select_col = [{ name: "風速", type: "VAN", value: "Vane" }];
var FOM_select_col = [{ name: "落塵%", type: "FOM", value: "Dust" }];
var all_selected_compare_col = [];
var checked_compare_col = [];
$(function () {
//#region 預設初始值
$('#DateGet').val(new Date().toISOString().substring(0, 10));
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
$('#DateGet').attr('style', 'width:205px');
$('#DateGettext').attr('style', 'width:205px');
timerange = $('#DateGet').val();
//#endregion
//#region 載入左邊選單列表
GetPowerStationCollapse("");
//#endregion
})
function myfunc(div) {
var className = div.getAttribute("class");
if (className == "fal fa-angle-left fa-lg py-3") {
div.className = "fal fa-angle-right fa-lg py-3";
}
else {
div.className = "fal fa-angle-left fa-lg py-3";
}
}
//#region 更換搜尋條件(日,日區間,月,年)
function changeType(type, e) {
searchType = type;
if ($(".btn-change-searchType").hasClass("btn-success")) {
$(".btn-change-searchType").removeClass("btn-success").addClass("btn-secondary");
}
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
document.getElementById("DateGet").style.display = "";//隱藏
$(e).removeClass("btn-secondary").addClass("btn-success");
switch (type) {
case 0: $('#DateGet').prop({ 'type': 'date' });
$(".btn-change-quickSearch1").html("今天");
$(".btn-change-quickSearch2").html("昨天");
var today = new Date().toISOString().substring(0, 10);
$('#DateGet').val(today);
break;
case 1:
//#region Date-Picker
datepicker = $('#DateGettext').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
});
$('#DateGettext').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#DateGettext').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
$(".btn-change-quickSearch1").html("近7天");
$(".btn-change-quickSearch2").html("近30天");
//#region 預設近7天
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 7));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
document.getElementById("DateGettextdiv").style.display = "";//隱藏
document.getElementById("DateGet").style.display = "none";//隱藏
//#endregion
$('#DateGettext').val(dateLimit_format + ' - ' + today_format);
break;
case 2: $('#DateGet').prop({ 'type': 'month' });
$(".btn-change-quickSearch1").html("本月");
$(".btn-change-quickSearch2").html("上個月");
var now_month = new Date().toISOString().substring(0, 7);
$('#DateGet').val(now_month);
break;
case 3:
$(".btn-change-quickSearch1").html("今年");
$(".btn-change-quickSearch2").html("去年");
var now_year = new Date().toISOString().substring(0, 4);
$('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
$('#DateGet').val(now_year);
break;
}
if (type == 1) {
timerange = $('#DateGettext').val();
}
else {
timerange = $('#DateGet').val();
}
}
//#endregion
//#region 快速填入條件(EX.今昨天)
function quickSearch(day) {
switch (searchType) {
case 0:
if (day == 0) {
var today = new Date().toISOString().substring(0, 10);
$('#DateGet').val(today).trigger('change');
} else {
var dateLimit = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().substring(0, 10);
$('#DateGet').val(dateLimit).trigger('change');
}
break;
case 1:
if (day == 0) {
//#region 預設近7天
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 7));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
//#endregion
$('#DateGettext').val(dateLimit_format + ' - ' + today_format).trigger('change');
} else {
//#region 預設近30天
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
//#endregion
$('#DateGettext').val(dateLimit_format + ' - ' + today_format).trigger('change');
}
break;
case 2:
if (day == 0) {
var now_month = new Date().toISOString().substring(0, 7);
$('#DateGet').val(now_month).trigger('change');
} else {
var dateLimit = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().substring(0, 7);
$('#DateGet').val(dateLimit).trigger('change');
}
break;
case 3:
if (day == 0) {
var now_year = new Date().toISOString().substring(0, 4);
$('#DateGet').val(now_year).trigger('change');
} else {
var dateLimit = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString().substring(0, 4);
$('#DateGet').val(dateLimit).trigger('change');
}
break;
}
}
//#endregion
//#region 更換input
$('#DateGet').on('change', function () {
timerange = $('#DateGet').val();
});
//#endregion
//#region 更換inputtext
$('#DateGettext').on('change', function () {
timerange = $('#DateGettext').val();
});
//#endregion
$("#js_list_accordion_filter").change(function (e) {
GetPowerStationCollapse($(this).val());
});
$('#js_list_accordion').on("change", 'input[name="selectedDeviceId[]"]', function (event) {
if (this.checked) {
if ($.inArray(this.value, selected_device) < 0) {
selected_device.push(this.value);
var type = $(this).attr("data-type");
switch (type) {
case 'PWR': //電錶
break;
case 'PYR': //日照計
$.each(PYR_select_col, function (index, item) {
if (!all_selected_compare_col.includes(item)) {
all_selected_compare_col.push(item);
}
});
break;
case 'ETR': //環境溫度計
$.each(ETR_select_col, function (index, item) {
if (!all_selected_compare_col.includes(item)) {
all_selected_compare_col.push(item);
}
});
break;
case 'VAN': //風速計
$.each(VAN_select_col, function (index, item) {
if (!all_selected_compare_col.includes(item)) {
all_selected_compare_col.push(item);
}
});
break;
case 'FOM': //落塵計
$.each(FOM_select_col, function (index, item) {
if (!all_selected_compare_col.includes(item)) {
all_selected_compare_col.push(item);
}
});
break;
case 'EMM': //環境濕度計
$.each(EMM_select_col, function (index, item) {
if (!all_selected_compare_col.includes(item)) {
all_selected_compare_col.push(item);
}
});
break;
}
console.log(all_selected_compare_col);
}
} else {
if ($.inArray(this.value, selected_device) > -1) {
selected_device.splice($.inArray(this.value, selected_device), 1);
switch (type) {
case 'PWR': //電錶
break;
case 'PYR': //日照計
$.each(PYR_select_col, function (index, item) {
if (all_selected_compare_col.includes(item)) {
all_selected_compare_col($.inArray(item, all_selected_compare_col), 1);
}
});
break;
case 'ETR': //環境溫度計
$.each(ETR_select_col, function (index, item) {
if (all_selected_compare_col.includes(item)) {
all_selected_compare_col($.inArray(item, all_selected_compare_col), 1);
}
});
break;
case 'VAN': //風速計
$.each(VAN_select_col, function (index, item) {
if (all_selected_compare_col.includes(item)) {
all_selected_compare_col($.inArray(item, all_selected_compare_col), 1);
}
});
break;
case 'FOM': //落塵計
$.each(FOM_select_col, function (index, item) {
if (all_selected_compare_col.includes(item)) {
all_selected_compare_col($.inArray(item, all_selected_compare_col), 1);
}
});
break;
case 'EMM': //環境濕度計
$.each(EMM_select_col, function (index, item) {
if (all_selected_compare_col.includes(item)) {
all_selected_compare_col($.inArray(item, all_selected_compare_col), 1);
}
});
break;
}
}
}
console.log(selected_device);
});
$('#js_list_accordion').on("change", 'input[name="selectedDeviceLayer2[]"]', function (event) {
if (this.checked) {
$(this).parents(".list-group-item").find('input[name="selectedDeviceId[]"]').prop("checked", true).trigger("change");
} else {
$(this).parents(".list-group-item").find('input[name="selectedDeviceId[]"]').prop("checked", false).trigger("change");
}
});
function GetPowerStationCollapse(filter) {
var url = "/AnalysisStationInfo/GetDeviceCollapse"
var send_data = {
Filter: filter
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.data.msg);
return;
}
var deviceCollapse = rel.data;
$('#js_list_accordion').empty();
if (deviceCollapse.length <= 0) {
$('#js_list_accordion').append("<div>查無結果</div>");
}
var str = "";
Object.keys(deviceCollapse).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(deviceCollapse[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="selectedDeviceLayer2[]" >' +
'</div>' +
'</div>' +
'<ul class="list-group list-group-flush">';
$.each(deviceCollapse[key][powerStationkey], function (index, device) {
var device_icon = "";
switch (device.deviceType) {
case 'PWR': //電錶
device_icon = '<i class="fal fa-tachometer-alt-slow"></i>';
break;
case 'PYR': //日照計
device_icon = '<i class="fal fa-sun"></i>';
break;
case 'ETR': //環境溫度計
device_icon = '<i class="fal fa-thermometer-half"></i>';
break;
case 'VAN': //風速計
device_icon = '<i class="fal fa-wind"></i>';
break;
case 'FOM': //落塵計
device_icon = '<i class="fal fa-sun-dust"></i>';
break;
case 'EMM': //環境濕度計
device_icon = '<i class="fal fa-tint"></i>';
break;
}
str += '<li class="list-group-item pr-0 d-flex justify-content-between">' +
'<a href="#">' + device_icon + '&nbsp;' + device.deviceName + '</a>' +
'<div class=""><input type="checkbox" class="" name="selectedDeviceId[]" data-type="' + device.deviceType + '" value="' + device.deviceId + '">' + '</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 (selected_device.length <= 0) {
selected_device.push(Object.values(Object.values(deviceCollapse)[0])[0][0].deviceId)
}
$('input[name="selectedDeviceId[]"]').each(function () {
if ($.inArray(this.value, selected_device) > -1) {
$(this).prop('checked', true);
}
});
$("#js_list_accordion .collapse").collapse('show');
}, 'json');
}
function ChangeColSelectOption() {
}
</script>
}

View File

@ -1273,6 +1273,10 @@
<script src="~/js/jquery.table2excel.min.js"></script>
<!--Chart.js-->
<script src="~/js/statistics/chartjs/chartjs.bundle.js"></script>
<!--HighCharts.js-->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<!-- Custome JS -->
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/js/image.zoom.js" asp-append-version="true"></script>