Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
9c5c9ca84c
@ -110,7 +110,13 @@ namespace SolarPower.Controllers
|
|||||||
StationCodeWithInverterIdsList.Add(stationCodeWithInverterIds);
|
StationCodeWithInverterIdsList.Add(stationCodeWithInverterIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
inverterHistories = await powerStationRepository.GetInverterHistoryRowData(post.SelectedDate, StationCodeWithInverterIdsList);
|
var date_start = Convert.ToDateTime(post.SelectedDate.Trim() + " 00:00:00");
|
||||||
|
var date_end = Convert.ToDateTime(post.SelectedDate.Trim() + " 23:59:59");
|
||||||
|
|
||||||
|
var start_timestamp = (long)date_start.Subtract(new DateTime(1970, 1, 1).AddHours(8)).TotalMilliseconds;
|
||||||
|
var end_timestamp = (long)date_end.Subtract(new DateTime(1970, 1, 1).AddHours(8)).TotalMilliseconds;
|
||||||
|
|
||||||
|
inverterHistories = await powerStationRepository.GetInverterHistoryRowData(start_timestamp, end_timestamp, StationCodeWithInverterIdsList);
|
||||||
|
|
||||||
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
|
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ namespace SolarPower.Controllers
|
|||||||
temp.Add(powerStation);
|
temp.Add(powerStation);
|
||||||
foreach (var device in psName_Group)
|
foreach (var device in psName_Group)
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(device.DeviceId))
|
if (!string.IsNullOrEmpty(device.DeviceId))
|
||||||
{
|
{
|
||||||
temp.Add(device);
|
temp.Add(device);
|
||||||
}
|
}
|
||||||
@ -114,13 +114,17 @@ namespace SolarPower.Controllers
|
|||||||
Dictionary<int, List<Device>> deviceDic = new Dictionary<int, List<Device>>();
|
Dictionary<int, List<Device>> deviceDic = new Dictionary<int, List<Device>>();
|
||||||
List<StationIdWithMeterIds> meterDic = new List<StationIdWithMeterIds>();
|
List<StationIdWithMeterIds> meterDic = new List<StationIdWithMeterIds>();
|
||||||
List<int> selected_powerStationIds = new List<int>();
|
List<int> selected_powerStationIds = new List<int>();
|
||||||
|
|
||||||
|
List<PowerStationHistory> powerStationHistories = new List<PowerStationHistory>();
|
||||||
|
List<MeterHistory> meterHistories = new List<MeterHistory>();
|
||||||
|
|
||||||
foreach (var psId_Group in device_powerStationId_Group)
|
foreach (var psId_Group in device_powerStationId_Group)
|
||||||
{
|
{
|
||||||
var powerStation = await powerStationRepository.GetOneAsync(psId_Group.Key);
|
var powerStation = await powerStationRepository.GetOneAsync(psId_Group.Key);
|
||||||
|
|
||||||
//區分電站總覽or設備
|
//區分電站總覽or設備
|
||||||
var temp_psIds = psId_Group.Where(x => x.DeviceType == "PWS").Select(x => Convert.ToInt32(x.DeviceId)).ToList();
|
var temp_psIds = psId_Group.Where(x => x.DeviceType == "PWS").Select(x => Convert.ToInt32(x.DeviceId)).ToList();
|
||||||
if(temp_psIds.Count() > 0)
|
if (temp_psIds.Count() > 0)
|
||||||
{
|
{
|
||||||
selected_powerStationIds.AddRange(temp_psIds);
|
selected_powerStationIds.AddRange(temp_psIds);
|
||||||
}
|
}
|
||||||
@ -170,13 +174,41 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
var XAxis = new List<string>();
|
var XAxis = new List<string>();
|
||||||
|
|
||||||
#region 電站資料
|
//針對x軸先進行處理,並同時抓取資料
|
||||||
if (selected_powerStationIds.Count() > 0)
|
if (selected_powerStationIds.Count() > 0)
|
||||||
{
|
{
|
||||||
var powerStationHistories = await powerStationRepository.GetPowerStationHistory(post.SelectedDate, post.SearchType, selected_powerStationIds);
|
powerStationHistories = await powerStationRepository.GetPowerStationHistory(post.SelectedDate, post.SearchType, selected_powerStationIds);
|
||||||
|
|
||||||
XAxis.AddRange(powerStationHistories.Select(x => x.Timestamp).Distinct().ToList());
|
XAxis.AddRange(powerStationHistories.Select(x => x.Timestamp).Distinct().ToList());
|
||||||
|
}
|
||||||
|
if (meterDic.Count() > 0)
|
||||||
|
{
|
||||||
|
meterHistories = await powerStationRepository.GetMeterHistory(post.SelectedDate, post.SearchType, meterDic);
|
||||||
|
|
||||||
|
XAxis.AddRange(meterHistories.Select(x => x.TIMESTAMP).Distinct().ToList());
|
||||||
|
}
|
||||||
|
if (deviceDic.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var devices in deviceDic)
|
||||||
|
{
|
||||||
|
var result = await powerStationRepository.GetSensorAvgByDevices(post.SelectedDate, post.SearchType, devices.Value);
|
||||||
|
|
||||||
|
foreach (var rows in result)
|
||||||
|
{
|
||||||
|
var fields = rows as IDictionary<string, object>;
|
||||||
|
XAxis.Add(fields["TIMESTAMP"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
XAxis = XAxis.Distinct().ToList();
|
||||||
|
}
|
||||||
|
XAxis.Sort();
|
||||||
|
|
||||||
|
analysisDevice.XAxis = XAxis;
|
||||||
|
|
||||||
|
#region 電站資料
|
||||||
|
if (powerStationHistories.Count() > 0)
|
||||||
|
{
|
||||||
var powerStationHistories_Id_Group = powerStationHistories.GroupBy(x => x.PowerStationId).ToList();
|
var powerStationHistories_Id_Group = powerStationHistories.GroupBy(x => x.PowerStationId).ToList();
|
||||||
|
|
||||||
foreach (var item in powerStationHistories_Id_Group)
|
foreach (var item in powerStationHistories_Id_Group)
|
||||||
@ -185,32 +217,36 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
var temp_item = item.OrderBy(x => x.Timestamp).ToList();
|
var temp_item = item.OrderBy(x => x.Timestamp).ToList();
|
||||||
|
|
||||||
DeviceHistoryInfo Irradiance = new DeviceHistoryInfo();
|
//DeviceHistoryInfo Irradiance = new DeviceHistoryInfo();
|
||||||
Irradiance.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["Irradiance"]);
|
//Irradiance.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["Irradiance"]);
|
||||||
Irradiance.YaxesKey = "Irradiance";
|
//Irradiance.YaxesKey = "Irradiance";
|
||||||
Irradiance.Values = new List<double>();
|
//Irradiance.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
//foreach (var xa in XAxis)
|
||||||
{
|
//{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
// var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
{
|
|
||||||
Irradiance.Values.Add(history.Irradiance);
|
// if (history != null)
|
||||||
}
|
// {
|
||||||
else
|
// Irradiance.Values.Add(history.Irradiance);
|
||||||
{
|
// }
|
||||||
Irradiance.Values.Add(0);
|
// else
|
||||||
}
|
// {
|
||||||
}
|
// Irradiance.Values.Add(0);
|
||||||
analysisDevice.Series.Add(Irradiance);
|
// }
|
||||||
|
//}
|
||||||
|
//analysisDevice.Series.Add(Irradiance);
|
||||||
|
|
||||||
DeviceHistoryInfo KWH = new DeviceHistoryInfo();
|
DeviceHistoryInfo KWH = new DeviceHistoryInfo();
|
||||||
KWH.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["KWH"]);
|
KWH.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["KWH"]);
|
||||||
KWH.YaxesKey = "KWH";
|
KWH.YaxesKey = "KWH";
|
||||||
KWH.Values = new List<double>();
|
KWH.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
KWH.Values.Add(Math.Round(history.KWH, 2));
|
KWH.Values.Add(history.KWH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -223,9 +259,11 @@ namespace SolarPower.Controllers
|
|||||||
solarHour.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["SolarHour"]);
|
solarHour.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["SolarHour"]);
|
||||||
solarHour.YaxesKey = "SolarHour";
|
solarHour.YaxesKey = "SolarHour";
|
||||||
solarHour.Values = new List<double>();
|
solarHour.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
solarHour.Values.Add(Math.Round(history.SolarHour, 2));
|
solarHour.Values.Add(Math.Round(history.SolarHour, 2));
|
||||||
}
|
}
|
||||||
@ -240,9 +278,11 @@ namespace SolarPower.Controllers
|
|||||||
KWHKWP.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["KWHKWP"]);
|
KWHKWP.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["KWHKWP"]);
|
||||||
KWHKWP.YaxesKey = "KWHKWP";
|
KWHKWP.YaxesKey = "KWHKWP";
|
||||||
KWHKWP.Values = new List<double>();
|
KWHKWP.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
KWHKWP.Values.Add(Math.Round(history.KWHKWP, 2));
|
KWHKWP.Values.Add(Math.Round(history.KWHKWP, 2));
|
||||||
}
|
}
|
||||||
@ -257,9 +297,11 @@ namespace SolarPower.Controllers
|
|||||||
PR.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["PR"]);
|
PR.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["PR"]);
|
||||||
PR.YaxesKey = "PR";
|
PR.YaxesKey = "PR";
|
||||||
PR.Values = new List<double>();
|
PR.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
PR.Values.Add(Math.Round(history.PR, 2));
|
PR.Values.Add(Math.Round(history.PR, 2));
|
||||||
}
|
}
|
||||||
@ -270,33 +312,31 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
analysisDevice.Series.Add(PR);
|
analysisDevice.Series.Add(PR);
|
||||||
|
|
||||||
DeviceHistoryInfo modelTemperature = new DeviceHistoryInfo();
|
//DeviceHistoryInfo modelTemperature = new DeviceHistoryInfo();
|
||||||
modelTemperature.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["Temperature"]);
|
//modelTemperature.Name = string.Format("{0}:{1}", powerStation.Name, analysisDevice.MultipleYaxes["Temperature"]);
|
||||||
modelTemperature.YaxesKey = "Temperature";
|
//modelTemperature.YaxesKey = "Temperature";
|
||||||
modelTemperature.Values = new List<double>();
|
//modelTemperature.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
//foreach (var xa in XAxis)
|
||||||
{
|
//{
|
||||||
if (XAxis.IndexOf(history.Timestamp) > -1)
|
// var history = temp_item.Where(x => xa == x.Timestamp).FirstOrDefault();
|
||||||
{
|
|
||||||
modelTemperature.Values.Add(Math.Round(history.Temperature, 2));
|
// if (history != null)
|
||||||
}
|
// {
|
||||||
else
|
// modelTemperature.Values.Add(Math.Round(history.Temperature, 2));
|
||||||
{
|
// }
|
||||||
modelTemperature.Values.Add(0);
|
// else
|
||||||
}
|
// {
|
||||||
}
|
// modelTemperature.Values.Add(0);
|
||||||
analysisDevice.Series.Add(modelTemperature);
|
// }
|
||||||
|
//}
|
||||||
|
//analysisDevice.Series.Add(modelTemperature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 電錶資料
|
#region 電錶資料
|
||||||
if (meterDic.Count() > 0)
|
if (meterHistories.Count() > 0)
|
||||||
{
|
{
|
||||||
var meterHistories = await powerStationRepository.GetMeterHistory(post.SelectedDate, post.SearchType, meterDic);
|
|
||||||
|
|
||||||
XAxis.AddRange(meterHistories.Select(x => x.TIMESTAMP).Distinct().ToList());
|
|
||||||
|
|
||||||
var meterHistories_Id_Group = meterHistories.GroupBy(x => x.METERID).ToList();
|
var meterHistories_Id_Group = meterHistories.GroupBy(x => x.METERID).ToList();
|
||||||
|
|
||||||
foreach (var item in meterHistories_Id_Group)
|
foreach (var item in meterHistories_Id_Group)
|
||||||
@ -307,9 +347,11 @@ namespace SolarPower.Controllers
|
|||||||
OUTPUT_KWH.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["OUTPUT_KWH"]);
|
OUTPUT_KWH.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["OUTPUT_KWH"]);
|
||||||
OUTPUT_KWH.YaxesKey = "OUTPUT_KWH";
|
OUTPUT_KWH.YaxesKey = "OUTPUT_KWH";
|
||||||
OUTPUT_KWH.Values = new List<double>();
|
OUTPUT_KWH.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
OUTPUT_KWH.Values.Add(Math.Round(history.OUTPUT_KWH, 2));
|
OUTPUT_KWH.Values.Add(Math.Round(history.OUTPUT_KWH, 2));
|
||||||
}
|
}
|
||||||
@ -324,9 +366,11 @@ namespace SolarPower.Controllers
|
|||||||
INPUT_KWH.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["INPUT_KWH"]);
|
INPUT_KWH.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["INPUT_KWH"]);
|
||||||
INPUT_KWH.YaxesKey = "INPUT_KWH";
|
INPUT_KWH.YaxesKey = "INPUT_KWH";
|
||||||
INPUT_KWH.Values = new List<double>();
|
INPUT_KWH.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
INPUT_KWH.Values.Add(Math.Round(history.INPUT_KWH, 2));
|
INPUT_KWH.Values.Add(Math.Round(history.INPUT_KWH, 2));
|
||||||
}
|
}
|
||||||
@ -341,9 +385,11 @@ namespace SolarPower.Controllers
|
|||||||
V_AB.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_AB"]);
|
V_AB.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_AB"]);
|
||||||
V_AB.YaxesKey = "V_AB";
|
V_AB.YaxesKey = "V_AB";
|
||||||
V_AB.Values = new List<double>();
|
V_AB.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
V_AB.Values.Add(Math.Round(history.V_AB, 2));
|
V_AB.Values.Add(Math.Round(history.V_AB, 2));
|
||||||
}
|
}
|
||||||
@ -358,9 +404,11 @@ namespace SolarPower.Controllers
|
|||||||
V_BC.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_BC"]);
|
V_BC.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_BC"]);
|
||||||
V_BC.YaxesKey = "V_BC";
|
V_BC.YaxesKey = "V_BC";
|
||||||
V_BC.Values = new List<double>();
|
V_BC.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
V_BC.Values.Add(Math.Round(history.V_BC, 2));
|
V_BC.Values.Add(Math.Round(history.V_BC, 2));
|
||||||
}
|
}
|
||||||
@ -375,9 +423,11 @@ namespace SolarPower.Controllers
|
|||||||
V_CA.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_BC"]);
|
V_CA.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["V_BC"]);
|
||||||
V_CA.YaxesKey = "V_CA";
|
V_CA.YaxesKey = "V_CA";
|
||||||
V_CA.Values = new List<double>();
|
V_CA.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
V_CA.Values.Add(Math.Round(history.V_CA, 2));
|
V_CA.Values.Add(Math.Round(history.V_CA, 2));
|
||||||
}
|
}
|
||||||
@ -392,9 +442,11 @@ namespace SolarPower.Controllers
|
|||||||
I_A.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_A"]);
|
I_A.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_A"]);
|
||||||
I_A.YaxesKey = "I_A";
|
I_A.YaxesKey = "I_A";
|
||||||
I_A.Values = new List<double>();
|
I_A.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
I_A.Values.Add(Math.Round(history.I_A, 2));
|
I_A.Values.Add(Math.Round(history.I_A, 2));
|
||||||
}
|
}
|
||||||
@ -409,9 +461,11 @@ namespace SolarPower.Controllers
|
|||||||
I_B.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_B"]);
|
I_B.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_B"]);
|
||||||
I_B.YaxesKey = "I_B";
|
I_B.YaxesKey = "I_B";
|
||||||
I_B.Values = new List<double>();
|
I_B.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
I_B.Values.Add(Math.Round(history.I_B, 2));
|
I_B.Values.Add(Math.Round(history.I_B, 2));
|
||||||
}
|
}
|
||||||
@ -426,9 +480,11 @@ namespace SolarPower.Controllers
|
|||||||
I_C.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_C"]);
|
I_C.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["I_C"]);
|
||||||
I_C.YaxesKey = "I_C";
|
I_C.YaxesKey = "I_C";
|
||||||
I_C.Values = new List<double>();
|
I_C.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
I_C.Values.Add(Math.Round(history.I_C, 2));
|
I_C.Values.Add(Math.Round(history.I_C, 2));
|
||||||
}
|
}
|
||||||
@ -443,9 +499,11 @@ namespace SolarPower.Controllers
|
|||||||
P.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["P"]);
|
P.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["P"]);
|
||||||
P.YaxesKey = "P";
|
P.YaxesKey = "P";
|
||||||
P.Values = new List<double>();
|
P.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
P.Values.Add(Math.Round(history.P, 2));
|
P.Values.Add(Math.Round(history.P, 2));
|
||||||
}
|
}
|
||||||
@ -460,9 +518,11 @@ namespace SolarPower.Controllers
|
|||||||
F.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["F"]);
|
F.Name = string.Format("{0}:{1}", item.Key, analysisDevice.MultipleYaxes["F"]);
|
||||||
F.YaxesKey = "F";
|
F.YaxesKey = "F";
|
||||||
F.Values = new List<double>();
|
F.Values = new List<double>();
|
||||||
foreach (var history in temp_item)
|
foreach (var xa in XAxis)
|
||||||
{
|
{
|
||||||
if (XAxis.IndexOf(history.TIMESTAMP) > -1)
|
var history = temp_item.Where(x => xa == x.TIMESTAMP).FirstOrDefault();
|
||||||
|
|
||||||
|
if (history != null)
|
||||||
{
|
{
|
||||||
F.Values.Add(Math.Round(history.F, 2));
|
F.Values.Add(Math.Round(history.F, 2));
|
||||||
}
|
}
|
||||||
@ -483,13 +543,7 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
var result = await powerStationRepository.GetSensorAvgByDevices(post.SelectedDate, post.SearchType, devices.Value);
|
var result = await powerStationRepository.GetSensorAvgByDevices(post.SelectedDate, post.SearchType, devices.Value);
|
||||||
|
|
||||||
foreach (var rows in result)
|
var powerStation = await powerStationRepository.GetOneAsync(devices.Key);
|
||||||
{
|
|
||||||
var fields = rows as IDictionary<string, object>;
|
|
||||||
XAxis.Add(fields["TIMESTAMP"].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var device in devices.Value)
|
foreach (var device in devices.Value)
|
||||||
{
|
{
|
||||||
DeviceHistoryInfo deviceHistoryInfo = new DeviceHistoryInfo();
|
DeviceHistoryInfo deviceHistoryInfo = new DeviceHistoryInfo();
|
||||||
@ -525,7 +579,7 @@ namespace SolarPower.Controllers
|
|||||||
suffix = string.Empty;
|
suffix = string.Empty;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
deviceHistoryInfo.Name = string.Format("{0}:{1}", device.Name, suffix);
|
deviceHistoryInfo.Name = string.Format("{0}:{1}({2})", powerStation.Name, device.Name, suffix);
|
||||||
deviceHistoryInfo.YaxesKey = YaxesKey;
|
deviceHistoryInfo.YaxesKey = YaxesKey;
|
||||||
deviceHistoryInfo.Values = new List<double>();
|
deviceHistoryInfo.Values = new List<double>();
|
||||||
foreach (var rows in result)
|
foreach (var rows in result)
|
||||||
@ -546,10 +600,7 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
analysisDevice.XAxis = XAxis.Distinct().ToList();
|
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
|
||||||
apiResult.Data = analysisDevice;
|
apiResult.Data = analysisDevice;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -3289,6 +3289,20 @@ namespace SolarPower.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//檢查資料表是否有該欄位
|
||||||
|
var check_inv_col = await powerStationRepository.CheckInvTableColumn(powerStation.SiteDB, powerStation.Code);
|
||||||
|
var check_sensor_avg_col = await powerStationRepository.CheckSensorAvgTableColumn(powerStation.SiteDB, powerStation.Code);
|
||||||
|
|
||||||
|
if (check_inv_col != 1)
|
||||||
|
{
|
||||||
|
await powerStationRepository.AlertColInvTableColumn(powerStation.SiteDB, powerStation.Code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check_sensor_avg_col != 1)
|
||||||
|
{
|
||||||
|
await powerStationRepository.AlertColSensoravgTableColumn(powerStation.SiteDB, powerStation.Code);
|
||||||
|
}
|
||||||
|
|
||||||
await powerStationRepository.StationStatus(Id, 1);
|
await powerStationRepository.StationStatus(Id, 1);
|
||||||
await powerStationRepository.StationStatus(Id, 1, powerStation.SiteDB + ".");
|
await powerStationRepository.StationStatus(Id, 1, powerStation.SiteDB + ".");
|
||||||
apiResult.Msg = "電站啟用成功";
|
apiResult.Msg = "電站啟用成功";
|
||||||
|
|||||||
@ -793,7 +793,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
var end_date = DateTimeNow.AddDays(-1);
|
var end_date = DateTimeNow.AddDays(-1);
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】");
|
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】");
|
||||||
procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
|
procSensorSvc sensorSvc = new procSensorSvc(Connection_string);
|
||||||
procInvSvc invSvc = new procInvSvc(Connection_string);
|
procInvSvc invSvc = new procInvSvc(Connection_string, logger);
|
||||||
procStationSvc siteSvc = new procStationSvc(Connection_string);
|
procStationSvc siteSvc = new procStationSvc(Connection_string);
|
||||||
foreach (var powerStation in powerStations)
|
foreach (var powerStation in powerStations)
|
||||||
{
|
{
|
||||||
@ -869,196 +869,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");
|
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 寄送日月報
|
|
||||||
var users = userRepository.GetAllAsync();
|
|
||||||
var ttt = new List<string>() {
|
|
||||||
"s506488@gmail.com",
|
|
||||||
"cesarliuc@gmail.com"
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var user in users.Result)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始產生使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
|
||||||
|
|
||||||
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
|
|
||||||
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
|
|
||||||
if (powerstations.Count == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<Excelpowerstation> sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
|
||||||
List<Excelpowerstation> sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
|
||||||
|
|
||||||
Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository);
|
|
||||||
//日報表
|
|
||||||
if (sentdaypowerstations.Count != 0)
|
|
||||||
{
|
|
||||||
Excel dayexcel = new Excel()
|
|
||||||
{
|
|
||||||
FormType = 0,
|
|
||||||
PowerStation = sentdaypowerstations,
|
|
||||||
SearchType = 0,
|
|
||||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
|
|
||||||
Userid = user.Id
|
|
||||||
};
|
|
||||||
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
|
|
||||||
if (stationReportName != "")
|
|
||||||
{
|
|
||||||
NoticeSchedule DaySchedule = new NoticeSchedule()
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
EmailType = 0,
|
|
||||||
RecipientEmail = user.Email,
|
|
||||||
Subject = "日報表",
|
|
||||||
Attachment = stationReportName,
|
|
||||||
RecipientName = user.Name,
|
|
||||||
Type = 1
|
|
||||||
};
|
|
||||||
List<string> properties = new List<string>()
|
|
||||||
{
|
|
||||||
"UserId",
|
|
||||||
"EmailType",
|
|
||||||
"RecipientEmail",
|
|
||||||
"Subject",
|
|
||||||
"Attachment",
|
|
||||||
"RecipientName",
|
|
||||||
"Type"
|
|
||||||
};
|
|
||||||
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//綜合報表 每日
|
|
||||||
if (sentMaxpowerstations.Count != 0)
|
|
||||||
{
|
|
||||||
Select_table2 maxdayexcel = new Select_table2()
|
|
||||||
{
|
|
||||||
FormType = 0,
|
|
||||||
PowerStation = sentMaxpowerstations,
|
|
||||||
SearchType = 0,
|
|
||||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
|
|
||||||
Userid = user.Id
|
|
||||||
};
|
|
||||||
var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented));
|
|
||||||
NoticeSchedule MaxSchedule = new NoticeSchedule()
|
|
||||||
{
|
|
||||||
UserId = user.Id,
|
|
||||||
EmailType = 2,
|
|
||||||
RecipientEmail = user.Email,
|
|
||||||
Subject = "綜合報表",
|
|
||||||
Attachment = stationMaxReportName,
|
|
||||||
RecipientName = user.Name,
|
|
||||||
Type = 1
|
|
||||||
};
|
|
||||||
List<string> properties = new List<string>()
|
|
||||||
{
|
|
||||||
"UserId",
|
|
||||||
"EmailType",
|
|
||||||
"RecipientEmail",
|
|
||||||
"Subject",
|
|
||||||
"Attachment",
|
|
||||||
"RecipientName",
|
|
||||||
"Type"
|
|
||||||
};
|
|
||||||
await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties);
|
|
||||||
|
|
||||||
if (DateTime.Now.ToString("dd") == "01")
|
|
||||||
{
|
|
||||||
Select_table2 maxmonthexcel = new Select_table2()
|
|
||||||
{
|
|
||||||
FormType = 0,
|
|
||||||
PowerStation = sentMaxpowerstations,
|
|
||||||
SearchType = 0,
|
|
||||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
|
|
||||||
Userid = user.Id
|
|
||||||
};
|
|
||||||
var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented));
|
|
||||||
NoticeSchedule MaxmonthSchedule = new NoticeSchedule()
|
|
||||||
{
|
|
||||||
RecipientEmail = user.Email,
|
|
||||||
Subject = "綜合報表",
|
|
||||||
Attachment = stationReportmaxmonthName,
|
|
||||||
RecipientName = user.Name,
|
|
||||||
Type = 1,
|
|
||||||
UserId = user.Id,
|
|
||||||
EmailType = 2
|
|
||||||
};
|
|
||||||
List<string> properties2 = new List<string>()
|
|
||||||
{
|
|
||||||
"UserId",
|
|
||||||
"EmailType",
|
|
||||||
"RecipientEmail",
|
|
||||||
"Subject",
|
|
||||||
"Attachment",
|
|
||||||
"RecipientName",
|
|
||||||
"Type"
|
|
||||||
};
|
|
||||||
await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateTime.Now.ToString("dd") == "01")
|
|
||||||
{
|
|
||||||
List<Excelpowerstation> sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
|
||||||
if (sentmonthpowerstations.Count == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Excel monthexcel = new Excel()
|
|
||||||
{
|
|
||||||
FormType = 1,
|
|
||||||
PowerStation = sentmonthpowerstations,
|
|
||||||
SearchType = 2,
|
|
||||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
|
|
||||||
Userid = user.Id
|
|
||||||
};
|
|
||||||
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
|
|
||||||
if (stationReportmonthName != "")
|
|
||||||
{
|
|
||||||
NoticeSchedule MonthSchedule = new NoticeSchedule()
|
|
||||||
{
|
|
||||||
RecipientEmail = user.Email,
|
|
||||||
Subject = "月報表",
|
|
||||||
Attachment = stationReportmonthName,
|
|
||||||
RecipientName = user.Name,
|
|
||||||
Type = 1,
|
|
||||||
UserId = user.Id,
|
|
||||||
EmailType = 1
|
|
||||||
};
|
|
||||||
List<string> properties2 = new List<string>()
|
|
||||||
{
|
|
||||||
"UserId",
|
|
||||||
"EmailType",
|
|
||||||
"RecipientEmail",
|
|
||||||
"Subject",
|
|
||||||
"Attachment",
|
|
||||||
"RecipientName",
|
|
||||||
"Type"
|
|
||||||
};
|
|
||||||
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【產生完成使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
logger.LogError("【CalcAvgPowerStationJob】【產生失敗使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
|
||||||
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
|
|
||||||
if (exception.InnerException != null)
|
|
||||||
{
|
|
||||||
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var line = new StackTrace(exception, true).GetFrame(0).GetFileLineNumber();
|
|
||||||
logger.LogError("【CalcAvgPowerStationJob】[錯誤行數] - {0}", line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
logger.LogInformation("【CalcAvgPowerStationJob】【任務完成】");
|
logger.LogInformation("【CalcAvgPowerStationJob】【任務完成】");
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
|
|
||||||
if (this.environment.IsDevelopment())
|
if (this.environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
dateTime = "2021-08-16 09";
|
dateTime = "2021-11-02 10";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
logger.LogInformation("【CalcPowerStationJob】【任務開始】");
|
||||||
@ -107,12 +107,18 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
{
|
{
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||||
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, full_table_name);
|
var history = await powerStationRepository.GetPowerStationHistoryPerHour(dateTime, full_table_name);
|
||||||
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
// 當前用不到
|
||||||
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的每小時歷史資料】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(history));
|
// var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 0, dateTime);
|
||||||
var lastmoneyhistorybyhour = await powerStationRepository.GetLastMoneyAndCarbonInHour(powerStation.Id, 0, dateTime);
|
|
||||||
|
|
||||||
if (history != null)
|
if (history == null)
|
||||||
{
|
{
|
||||||
|
logger.LogWarning("【CalcPowerStationJob】【查無電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||||
|
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的每小時歷史資料】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(history));
|
||||||
|
|
||||||
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的每小時歷史資料】", powerStation.Code, dateTime);
|
||||||
history.PowerStationId = powerStation.Id;
|
history.PowerStationId = powerStation.Id;
|
||||||
history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
history.Timestamp = Convert.ToDateTime(history.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
@ -303,8 +309,12 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
//pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
//pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
//pyrheliometerHistory.PowerStationId = powerStation.Id;
|
//pyrheliometerHistory.PowerStationId = powerStation.Id;
|
||||||
//pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
//pyrheliometerHistoriesHour.Add(pyrheliometerHistory);
|
||||||
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogWarning("【CalcPowerStationJob】【查無結果電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime);
|
||||||
}
|
}
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -334,6 +344,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
|
|
||||||
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime);
|
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogWarning("【CalcPowerStationJob】【查無結果電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
using SolarPower.Models;
|
using SolarPower.Models;
|
||||||
using SolarPower.Repository.Interface;
|
using SolarPower.Repository.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -15,11 +17,24 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
{
|
{
|
||||||
private readonly ILogger<OperationScheduleJob> logger;
|
private readonly ILogger<OperationScheduleJob> logger;
|
||||||
private IOperationRepository operationRepository;
|
private IOperationRepository operationRepository;
|
||||||
|
private readonly IPowerStationRepository powerStationRepository;
|
||||||
|
private readonly IUserRepository userRepository;
|
||||||
|
private readonly INoticeScheduleRepository noticeScheduleRepository;
|
||||||
|
private readonly IStationReportRepository stationReportRepository;
|
||||||
|
|
||||||
public OperationScheduleJob(ILogger<OperationScheduleJob> logger, IOperationRepository operationRepository)
|
public OperationScheduleJob(ILogger<OperationScheduleJob> logger,
|
||||||
|
IOperationRepository operationRepository,
|
||||||
|
IPowerStationRepository powerStationRepository,
|
||||||
|
IUserRepository userRepository,
|
||||||
|
INoticeScheduleRepository noticeScheduleRepository,
|
||||||
|
IStationReportRepository stationReportRepository)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.operationRepository = operationRepository;
|
this.operationRepository = operationRepository;
|
||||||
|
this.powerStationRepository = powerStationRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
this.noticeScheduleRepository = noticeScheduleRepository;
|
||||||
|
this.stationReportRepository = stationReportRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext context)
|
public async Task Execute(IJobExecutionContext context)
|
||||||
@ -180,6 +195,197 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 寄送日月報
|
||||||
|
var users = userRepository.GetAllAsync();
|
||||||
|
var ttt = new List<string>() {
|
||||||
|
"s506488@gmail.com",
|
||||||
|
"cesarliuc@gmail.com"
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var user in users.Result)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger.LogInformation("【OperationScheduleJob】【開始產生使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
||||||
|
|
||||||
|
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
|
||||||
|
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
|
||||||
|
if (powerstations.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<Excelpowerstation> sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
||||||
|
List<Excelpowerstation> sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
||||||
|
|
||||||
|
Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository);
|
||||||
|
//日報表
|
||||||
|
if (sentdaypowerstations.Count != 0)
|
||||||
|
{
|
||||||
|
Excel dayexcel = new Excel()
|
||||||
|
{
|
||||||
|
FormType = 0,
|
||||||
|
PowerStation = sentdaypowerstations,
|
||||||
|
SearchType = 0,
|
||||||
|
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
|
||||||
|
Userid = user.Id
|
||||||
|
};
|
||||||
|
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
|
||||||
|
if (stationReportName != "")
|
||||||
|
{
|
||||||
|
NoticeSchedule DaySchedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
EmailType = 0,
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = "日報表",
|
||||||
|
Attachment = stationReportName,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
Type = 1
|
||||||
|
};
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Attachment",
|
||||||
|
"RecipientName",
|
||||||
|
"Type"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//綜合報表 每日
|
||||||
|
if (sentMaxpowerstations.Count != 0)
|
||||||
|
{
|
||||||
|
Select_table2 maxdayexcel = new Select_table2()
|
||||||
|
{
|
||||||
|
FormType = 0,
|
||||||
|
PowerStation = sentMaxpowerstations,
|
||||||
|
SearchType = 0,
|
||||||
|
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
|
||||||
|
Userid = user.Id
|
||||||
|
};
|
||||||
|
var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented));
|
||||||
|
NoticeSchedule MaxSchedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
EmailType = 2,
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = "綜合報表",
|
||||||
|
Attachment = stationMaxReportName,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
Type = 1
|
||||||
|
};
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Attachment",
|
||||||
|
"RecipientName",
|
||||||
|
"Type"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties);
|
||||||
|
|
||||||
|
if (DateTime.Now.ToString("dd") == "01")
|
||||||
|
{
|
||||||
|
Select_table2 maxmonthexcel = new Select_table2()
|
||||||
|
{
|
||||||
|
FormType = 0,
|
||||||
|
PowerStation = sentMaxpowerstations,
|
||||||
|
SearchType = 0,
|
||||||
|
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
|
||||||
|
Userid = user.Id
|
||||||
|
};
|
||||||
|
var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented));
|
||||||
|
NoticeSchedule MaxmonthSchedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = "綜合報表",
|
||||||
|
Attachment = stationReportmaxmonthName,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
Type = 1,
|
||||||
|
UserId = user.Id,
|
||||||
|
EmailType = 2
|
||||||
|
};
|
||||||
|
List<string> properties2 = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Attachment",
|
||||||
|
"RecipientName",
|
||||||
|
"Type"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DateTime.Now.ToString("dd") == "01")
|
||||||
|
{
|
||||||
|
List<Excelpowerstation> sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
||||||
|
if (sentmonthpowerstations.Count == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Excel monthexcel = new Excel()
|
||||||
|
{
|
||||||
|
FormType = 1,
|
||||||
|
PowerStation = sentmonthpowerstations,
|
||||||
|
SearchType = 2,
|
||||||
|
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
|
||||||
|
Userid = user.Id
|
||||||
|
};
|
||||||
|
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
|
||||||
|
if (stationReportmonthName != "")
|
||||||
|
{
|
||||||
|
NoticeSchedule MonthSchedule = new NoticeSchedule()
|
||||||
|
{
|
||||||
|
RecipientEmail = user.Email,
|
||||||
|
Subject = "月報表",
|
||||||
|
Attachment = stationReportmonthName,
|
||||||
|
RecipientName = user.Name,
|
||||||
|
Type = 1,
|
||||||
|
UserId = user.Id,
|
||||||
|
EmailType = 1
|
||||||
|
};
|
||||||
|
List<string> properties2 = new List<string>()
|
||||||
|
{
|
||||||
|
"UserId",
|
||||||
|
"EmailType",
|
||||||
|
"RecipientEmail",
|
||||||
|
"Subject",
|
||||||
|
"Attachment",
|
||||||
|
"RecipientName",
|
||||||
|
"Type"
|
||||||
|
};
|
||||||
|
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("【OperationScheduleJob】【產生完成使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
logger.LogError("【OperationScheduleJob】【產生失敗使用者[{0}({1})]的日月報】", user.Account, user.Name);
|
||||||
|
logger.LogError("【OperationScheduleJob】[Exception] - {0}", exception.Message);
|
||||||
|
if (exception.InnerException != null)
|
||||||
|
{
|
||||||
|
logger.LogError("【OperationScheduleJob】[InnerException] - {0}", exception.InnerException.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = new StackTrace(exception, true).GetFrame(0).GetFileLineNumber();
|
||||||
|
logger.LogError("【OperationScheduleJob】[錯誤行數] - {0}", line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2890,19 +2890,20 @@ namespace SolarPower.Repository.Implement
|
|||||||
var sql = $@"SELECT
|
var sql = $@"SELECT
|
||||||
s.TIMESTAMP,
|
s.TIMESTAMP,
|
||||||
s.INVERTERID,
|
s.INVERTERID,
|
||||||
a.KWH,
|
s.KWH,
|
||||||
s.TODAYKWH,
|
s.TODAYKWH,
|
||||||
i.Capacity,
|
i.Capacity,
|
||||||
a.KWH/(i.Capacity/4) AS KWHKWP
|
s.KWH/(i.Capacity/4) AS KWHKWP
|
||||||
FROM (SELECT
|
FROM (SELECT
|
||||||
MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
||||||
sub_inv.INVERTERID,
|
sub_inv.INVERTERID,
|
||||||
|
SUM(sub_inv.WH)/1000 AS KWH,
|
||||||
MAX(sub_inv.TODAYKWH) AS TODAYKWH
|
MAX(sub_inv.TODAYKWH) AS TODAYKWH
|
||||||
FROM {table_name} sub_inv
|
FROM {table_name} sub_inv
|
||||||
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
||||||
AND sub_inv.INVERTERID IN @InverterIds
|
AND sub_inv.INVERTERID IN @InverterIds
|
||||||
GROUP BY sub_inv.INVERTERID) s
|
GROUP BY sub_inv.INVERTERID) s
|
||||||
LEFT JOIN (
|
/*LEFT JOIN (
|
||||||
SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
|
||||||
sub_inv.INVERTERID,
|
sub_inv.INVERTERID,
|
||||||
SUM(sub_inv.WH)/1000 AS KWH
|
SUM(sub_inv.WH)/1000 AS KWH
|
||||||
@ -2910,10 +2911,10 @@ namespace SolarPower.Repository.Implement
|
|||||||
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
|
||||||
AND sub_inv.INVERTERID IN @InverterIds
|
AND sub_inv.INVERTERID IN @InverterIds
|
||||||
GROUP BY sub_inv.INVERTERID) a
|
GROUP BY sub_inv.INVERTERID) a
|
||||||
ON s.TIMESTAMP = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID
|
ON s.TIMESTAMP = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID*/
|
||||||
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = REPLACE(i.InverterId, 's', '');";
|
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = REPLACE(i.InverterId, 's', '');";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDateTime = stratDateTime, EndDateTime = dateTime, InverterIds = inverterIds })).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDateTime = stratDateTime, EndDateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -3008,14 +3009,14 @@ namespace SolarPower.Repository.Implement
|
|||||||
AVG(s.RA3) AS RA3,
|
AVG(s.RA3) AS RA3,
|
||||||
AVG(s.RA4) AS RA4,
|
AVG(s.RA4) AS RA4,
|
||||||
AVG(s.RA5) AS RA5,
|
AVG(s.RA5) AS RA5,
|
||||||
a.KWH,
|
SUM(s.WH)/1000 AS KWH,
|
||||||
MAX(s.TODAYKWH) AS TODAYKWH,
|
MAX(s.TODAYKWH) AS TODAYKWH,
|
||||||
MAX(s.TOTALKWH) AS TOTALKWH,
|
MAX(s.TOTALKWH) AS TOTALKWH,
|
||||||
i.Capacity,
|
i.Capacity,
|
||||||
(a.KWH/i.Capacity) AS KWHKWP
|
((SUM(s.WH)/1000) / i.Capacity) AS KWHKWP
|
||||||
FROM {table_name} s
|
FROM {table_name} s
|
||||||
-- 取得該時間區間的KWH
|
-- 取得該時間區間的KWH
|
||||||
LEFT JOIN (
|
/*LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
|
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
|
||||||
inv.INVERTERID,
|
inv.INVERTERID,
|
||||||
@ -3024,26 +3025,26 @@ namespace SolarPower.Repository.Implement
|
|||||||
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime
|
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime
|
||||||
AND inv.INVERTERID IN @InverterIds
|
AND inv.INVERTERID IN @InverterIds
|
||||||
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) a
|
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
|
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID*/
|
||||||
-- 取得整點值PR
|
-- 取得整點值PR
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
|
inv.CrdTime AS TIMESTAMP,
|
||||||
inv.INVERTERID,
|
inv.INVERTERID,
|
||||||
inv.PR
|
inv.PR
|
||||||
FROM {table_name} inv
|
FROM {table_name} inv
|
||||||
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H:%i') = CONCAT(@DateTime, ':55')
|
WHERE left(inv.CrdTime, 16) = CONCAT(@DateTime, ':55')
|
||||||
AND inv.INVERTERID IN @InverterIds
|
AND inv.INVERTERID IN @InverterIds
|
||||||
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) inv_pr
|
GROUP BY left(inv.CrdTime, 13), inv.INVERTERID) inv_pr
|
||||||
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = inv_pr.TIMESTAMP AND s.INVERTERID = inv_pr. INVERTERID
|
ON left(s.CrdTime, 13) = inv_pr.TIMESTAMP AND s.INVERTERID = inv_pr. INVERTERID
|
||||||
-- 取得逆變器容量
|
-- 取得逆變器容量
|
||||||
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = i.InverterId
|
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = i.InverterId
|
||||||
WHERE FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime
|
WHERE left(s.CrdTime, 13) = @DateTime
|
||||||
AND s.INVERTERID IN @InverterIds
|
AND s.INVERTERID IN @InverterIds
|
||||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d %H'), s.INVERTERID
|
GROUP BY left(s.CrdTime, 13), s.INVERTERID
|
||||||
";
|
";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds })).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -4402,7 +4403,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities)
|
public async Task<List<InverterHistory>> GetInverterHistoryRowData(long start_timestamp, long end_timestamp, List<StationCodeWithInverterIds> entities)
|
||||||
{
|
{
|
||||||
List<InverterHistory> result;
|
List<InverterHistory> result;
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
@ -4466,16 +4467,19 @@ namespace SolarPower.Repository.Implement
|
|||||||
inv.RA4,
|
inv.RA4,
|
||||||
inv.RA5
|
inv.RA5
|
||||||
FROM {table_name} inv
|
FROM {table_name} inv
|
||||||
LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
|
LEFT JOIN (select * from {sensor_table_name} where TIMESTAMP between @start_timestamp and @end_timestamp)sen
|
||||||
|
ON inv.CrdTime = sen.CrdTime
|
||||||
|
-- LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
|
||||||
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
||||||
WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
|
WHERE inv.`TIMESTAMP` between @start_timestamp and @end_timestamp
|
||||||
|
-- WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
|
||||||
AND inv.INVERTERID IN ('{inverterIds}')";
|
AND inv.INVERTERID IN ('{inverterIds}')";
|
||||||
|
|
||||||
sql_perSiteDB.Add(temp_sql);
|
sql_perSiteDB.Add(temp_sql);
|
||||||
}
|
}
|
||||||
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay }, commandTimeout: 300)).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { start_timestamp = start_timestamp, end_timestamp = end_timestamp }, commandTimeout: 300)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -5834,5 +5838,129 @@ namespace SolarPower.Repository.Implement
|
|||||||
return resule;
|
return resule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> CheckInvTableColumn (string dbname, string code)
|
||||||
|
{
|
||||||
|
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
var resule = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $@"SELECT count(*) FROM information_schema.columns WHERE table_schema='{dbname}' AND table_name = 's{code}01_inv' AND column_name = 'CrdTime'";
|
||||||
|
resule = await conn.QueryFirstOrDefaultAsync<int>(sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CheckSensorAvgTableColumn(string dbname, string code)
|
||||||
|
{
|
||||||
|
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
var resule = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $@"SELECT count(*) FROM information_schema.columns WHERE table_schema='{dbname}' AND table_name = 's{code}01_sensoravg' AND column_name = 'CrdTime'";
|
||||||
|
resule = await conn.QueryFirstOrDefaultAsync<int>(sql);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AlertColInvTableColumn(string dbname, string code)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $@"ALTER TABLE {dbname}.s{code}01_inv ADD COLUMN CrdTime datetime;
|
||||||
|
use {dbname};
|
||||||
|
create trigger trg01_s{code}01_inv
|
||||||
|
before insert on {dbname}.s{code}01_inv
|
||||||
|
FOR EACH ROW
|
||||||
|
begin
|
||||||
|
set new.CrdTime = FROM_UNIXTIME(new.`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
|
||||||
|
end;
|
||||||
|
use solar_master;
|
||||||
|
|
||||||
|
update {dbname}.s{code}01_inv set crdtime = FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
|
||||||
|
|
||||||
|
CREATE INDEX IDX02_s{code}01 ON {dbname}.s{code}01_inv(Inverterid, CrdTime);";
|
||||||
|
|
||||||
|
await conn.ExecuteAsync(sql);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AlertColSensoravgTableColumn(string dbname, string code)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $@"ALTER TABLE {dbname}.s{code}01_sensoravg ADD COLUMN CrdTime datetime;
|
||||||
|
use {dbname};
|
||||||
|
create trigger trg01_s{code}01_sensoravg
|
||||||
|
before insert on {dbname}.s{code}01_sensoravg
|
||||||
|
FOR EACH ROW
|
||||||
|
begin
|
||||||
|
set new.CrdTime = FROM_UNIXTIME(new.`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
|
||||||
|
end;
|
||||||
|
use solar_master;
|
||||||
|
|
||||||
|
update {dbname}.s{code}01_sensoravg set crdtime = FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
|
||||||
|
|
||||||
|
CREATE INDEX IDX{code}01_sensoravg ON {dbname}.s{code}01_sensoravg(CrdTime);";
|
||||||
|
await conn.ExecuteAsync(sql);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,10 +80,10 @@ namespace SolarPower.Repository.Implement
|
|||||||
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d'') = c.report_date
|
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d'') = c.report_date
|
||||||
left join
|
left join
|
||||||
(
|
(
|
||||||
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')report_date, irradiance, Temperature
|
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:00'')report_date, irradiance, Temperature
|
||||||
from sensor_history_hour
|
from sensor_history_hour
|
||||||
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}''
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}''
|
||||||
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = d.report_date
|
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:00'') = d.report_date
|
||||||
join
|
join
|
||||||
(
|
(
|
||||||
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
|
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
|
||||||
|
|||||||
@ -574,7 +574,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task<List<PowerStation>> GetPowerStationsByCompanyId(MyUser myUser);
|
Task<List<PowerStation>> GetPowerStationsByCompanyId(MyUser myUser);
|
||||||
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
|
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
|
||||||
Task<List<PowerStationDevice>> GetPowerStationDevice(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>> GetInverterHistoryRowData(long start_timestamp, long end_timestamp, List<StationCodeWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
||||||
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(MyUser myUser, string filter);
|
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(MyUser myUser, string filter);
|
||||||
@ -608,5 +608,9 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0);
|
Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0);
|
||||||
Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes);
|
Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes);
|
||||||
Task<Check4table> Check4table(string code, string dbname);
|
Task<Check4table> Check4table(string code, string dbname);
|
||||||
|
Task<int> CheckInvTableColumn(string dbname, string code);
|
||||||
|
Task<int> CheckSensorAvgTableColumn(string dbname, string code);
|
||||||
|
Task AlertColInvTableColumn(string dbname, string code);
|
||||||
|
Task AlertColSensoravgTableColumn(string dbname, string code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -388,15 +388,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#js_list_accordion').on("change", 'input[name="selectedInverterId[]"]', function (event) {
|
$('#js_list_accordion').on("change", 'input[name="selectedInverterId[]"]', function (event) {
|
||||||
|
var powerStationId = $(this).attr('data-power-station-id');
|
||||||
|
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
if ($.inArray(this.value, selected_inverter) < 0) {
|
if ($.map(selected_inverter, function (item, index) { return item.InverterId }).indexOf(this.value) < 0) {
|
||||||
var powerStationId = $(this).attr('data-power-station-id');
|
selected_inverter.push({ 'powerStationId': powerStationId, 'InverterId': this.value });
|
||||||
selected_inverter.push({ powerStationId: powerStationId, InverterId: this.value });
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($.inArray(this.value, selected_inverter) > -1) {
|
var result = $.map(selected_inverter, function (item, index) { return item.InverterId }).indexOf(this.value)
|
||||||
var powerStationId = $(this).attr('data-power-station-id');
|
if (result > -1) {
|
||||||
selected_inverter.splice($.inArray({ powerStationId: powerStationId, InverterId: this.value }, selected_inverter), 1);
|
selected_inverter.splice(result, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="GetAnalysisStationInfo()">查詢</button>
|
<button type="button" class="btn btn-secondary waves-effect waves-themed" id="btn-analysis-stationinfo" onclick="GetAnalysisStationInfo()">查詢</button>
|
||||||
@*<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="DataBackFill()">回填</button>*@
|
@*<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="DataBackFill()">回填</button>*@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -123,10 +123,10 @@
|
|||||||
var selected_device = [];
|
var selected_device = [];
|
||||||
var PWS_compare_col = [
|
var PWS_compare_col = [
|
||||||
{ key: "KWH", title: "發電量", default: true },
|
{ key: "KWH", title: "發電量", default: true },
|
||||||
{ key: "Irradiance", title: "日照度", default: false },
|
@*{ key: "Irradiance", title: "日照度", default: false },*@
|
||||||
{ key: "KWHKWP", title: "有效日照時數", default: false },
|
{ key: "KWHKWP", title: "有效日照時數", default: false },
|
||||||
{ key: "PR", title: "PR %", default: false },
|
{ key: "PR", title: "PR %", default: false },
|
||||||
{ key: "Temperature", title: "模組溫度", default: false },
|
@*{ key: "Temperature", title: "模組溫度", default: false },*@
|
||||||
{ key: "SolarHour", title: "日照小時", default: false },
|
{ key: "SolarHour", title: "日照小時", default: false },
|
||||||
]
|
]
|
||||||
var PWR_compare_col = [
|
var PWR_compare_col = [
|
||||||
@ -625,6 +625,13 @@
|
|||||||
DeviceIdInfos: selected_device
|
DeviceIdInfos: selected_device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected_device.length <= 0) {
|
||||||
|
toast_warning("請至少選擇一設備");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#btn-analysis-stationinfo").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
|
||||||
|
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
@ -641,6 +648,9 @@
|
|||||||
|
|
||||||
$('input[name="compare_col[]"]').trigger('change');
|
$('input[name="compare_col[]"]').trigger('change');
|
||||||
|
|
||||||
|
ReloadHighCharts()
|
||||||
|
$("#btn-analysis-stationinfo").html('查詢').attr("disabled", false);
|
||||||
|
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,9 +720,7 @@
|
|||||||
height: 600,
|
height: 600,
|
||||||
animation: false
|
animation: false
|
||||||
},
|
},
|
||||||
title: {
|
title: false,
|
||||||
text: '交叉分析圖表'
|
|
||||||
},
|
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: function () {
|
formatter: function () {
|
||||||
return '<b>' + this.series.name + '</b><br>' +
|
return '<b>' + this.series.name + '</b><br>' +
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto" style="width: 60%;">
|
<div class="col-md-8 col-sm-12">
|
||||||
<div id="panel-1" class="panel">
|
<div id="panel-1" class="panel">
|
||||||
<div class="panel-hdr">
|
<div class="panel-hdr">
|
||||||
<h2>電站分佈圖</h2>
|
<h2>電站分佈圖</h2>
|
||||||
@ -111,9 +111,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto" style="width: 40%;">
|
<div class="col-md-4 col-sm-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-6">
|
<div class="col-xl-6 mb-4">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
||||||
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> 電站總數</h4>
|
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> 電站總數</h4>
|
||||||
@ -125,7 +125,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xl-6">
|
<div class="col-xl-6 mb-4">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
||||||
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> 總裝置容量</h4>
|
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> 總裝置容量</h4>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-12 mt-4">
|
<div class="col-xl-12">
|
||||||
<div id="panel-1" class="panel">
|
<div id="panel-1" class="panel">
|
||||||
<div class="panel-hdr">
|
<div class="panel-hdr">
|
||||||
<h2>電站分佈小計</h2>
|
<h2>電站分佈小計</h2>
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
"BackgroundServiceCron": {
|
"BackgroundServiceCron": {
|
||||||
"CalcPowerStationJob": "0 5 * * * ?",
|
"CalcPowerStationJob": "0 5 * * * ?",
|
||||||
"CalcAvgPowerStationJob": "0 0 2 * * ?",
|
"CalcAvgPowerStationJob": "0 0 2 * * ?",
|
||||||
"OperationScheduleJob": "0 0 2 * * ?",
|
"OperationScheduleJob": "0 0 8 * * ?",
|
||||||
"CalcInverter15minJob": "0 2/15 * * * ?",
|
"CalcInverter15minJob": "0 2/15 * * * ?",
|
||||||
"SendEmailJob": "0 0/5 * * * ?",
|
"SendEmailJob": "0 0/5 * * * ?",
|
||||||
"ExceptionSchedule": "0 0/5 * * * ?"
|
"ExceptionSchedule": "0 0/5 * * * ?"
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
"BackgroundServiceCron": {
|
"BackgroundServiceCron": {
|
||||||
"CalcPowerStationJob": "0 5 * * * ?",
|
"CalcPowerStationJob": "0 5 * * * ?",
|
||||||
"CalcAvgPowerStationJob": "0 0 2 * * ?",
|
"CalcAvgPowerStationJob": "0 0 2 * * ?",
|
||||||
"OperationScheduleJob": "0 0 2 * * ?",
|
"OperationScheduleJob": "0 0 8 * * ?",
|
||||||
"CalcInverter15minJob": "0 2/15 * * * ?",
|
"CalcInverter15minJob": "0 2/15 * * * ?",
|
||||||
"SendEmailJob": "0 0/5 * * * ?",
|
"SendEmailJob": "0 0/5 * * * ?",
|
||||||
"ExceptionSchedule": "0 0/5 * * * ?"
|
"ExceptionSchedule": "0 0/5 * * * ?"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,12 +15,22 @@ namespace solarApp
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.MinimumLevel.Verbose() // 設定最低顯示層級 預設: Information
|
||||||
|
.WriteTo.File("Logs/solarApp/log-.log",
|
||||||
|
rollingInterval: RollingInterval.Day, // 每天一個檔案
|
||||||
|
outputTemplate: "{Timestamp:HH:mm:ss} [{Level:u5}] {Message:lj}{NewLine}{Exception}"
|
||||||
|
) // 輸出到檔案 檔名範例: log-20211005.log
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
//Application.Run(new fmExcel());
|
//Application.Run(new fmExcel());
|
||||||
Application.Run(new fmArchive());
|
Application.Run(new fmArchive());
|
||||||
//Application.Run(new fmMain());
|
//Application.Run(new fmMain());
|
||||||
|
|
||||||
|
Log.CloseAndFlush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,14 +6,16 @@ using Dapper;
|
|||||||
using solarApp.Model;
|
using solarApp.Model;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace solarApp.Service
|
namespace solarApp.Service
|
||||||
{
|
{
|
||||||
public class procInvSvc
|
public class procInvSvc
|
||||||
{
|
{
|
||||||
string Connection1 = string.Empty;
|
string Connection1 = string.Empty;
|
||||||
|
ILogger _logger;
|
||||||
|
|
||||||
public procInvSvc(string Connection_parame = null)
|
public procInvSvc(string Connection_parame = null, ILogger logger = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Connection_parame))
|
if (!string.IsNullOrEmpty(Connection_parame))
|
||||||
{
|
{
|
||||||
@ -23,6 +25,11 @@ namespace solarApp.Service
|
|||||||
{
|
{
|
||||||
Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString;
|
Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger != null)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string _siteID { get; set; }
|
public string _siteID { get; set; }
|
||||||
@ -37,29 +44,46 @@ namespace solarApp.Service
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
string sql = @"
|
string sql = @"
|
||||||
delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||||
delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||||
delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||||
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
|
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
|
||||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool archiveData(string siteID, string date1)
|
public bool archiveData(string siteID, string date1)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -67,7 +91,7 @@ namespace solarApp.Service
|
|||||||
_date1 = date1;
|
_date1 = date1;
|
||||||
get_siteInfo();
|
get_siteInfo();
|
||||||
clearData();
|
clearData();
|
||||||
insert_inv();
|
insert_inv();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -84,6 +108,12 @@ namespace solarApp.Service
|
|||||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
#region 取得 PowerStationID
|
#region 取得 PowerStationID
|
||||||
string sql = @" select id , `code` siteID, siteDB, `name` siteName
|
string sql = @" select id , `code` siteID, siteDB, `name` siteName
|
||||||
from solar_master.power_station where `code` = @siteID";
|
from solar_master.power_station where `code` = @siteID";
|
||||||
@ -94,6 +124,12 @@ namespace solarApp.Service
|
|||||||
_siteDB = item.SiteDB;
|
_siteDB = item.SiteDB;
|
||||||
_siteID01 = item.SiteID + "01";
|
_siteID01 = item.SiteID + "01";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器取得電站編號 - {2}", _siteID, _date1, _powerStationID);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
@ -101,6 +137,12 @@ namespace solarApp.Service
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -116,155 +158,233 @@ namespace solarApp.Service
|
|||||||
string ss = @"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));";
|
string ss = @"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));";
|
||||||
conn.Execute(ss);
|
conn.Execute(ss);
|
||||||
|
|
||||||
|
string sql = string.Empty;
|
||||||
#region 15 min
|
#region 15 min
|
||||||
string sql = @"
|
try
|
||||||
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
{
|
||||||
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
if (_logger != null)
|
||||||
(
|
{
|
||||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = @"
|
||||||
|
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||||
|
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||||
|
(
|
||||||
|
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||||
|
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||||
|
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||||
|
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||||
|
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||||
|
union
|
||||||
|
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
||||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||||
union
|
union
|
||||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
||||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||||
union
|
union
|
||||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
||||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
||||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||||
union
|
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
|
||||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
if (_logger != null)
|
||||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
{
|
||||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||||
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
}
|
||||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region hour
|
#region hour
|
||||||
sql = @"
|
try
|
||||||
insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
{
|
||||||
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
|
if (_logger != null)
|
||||||
PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = @"
|
||||||
|
insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||||
|
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
|
||||||
|
PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||||
|
|
||||||
|
SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||||
|
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
||||||
|
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
|
||||||
|
inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
|
||||||
|
((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
||||||
|
from
|
||||||
|
( -- 取得該時間區間的KWH
|
||||||
|
SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
|
||||||
|
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
||||||
|
AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
||||||
|
round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
||||||
|
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
||||||
|
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
||||||
|
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
|
||||||
|
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
|
||||||
|
AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
|
||||||
|
FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||||
|
WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
|
||||||
|
GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
|
||||||
|
) a
|
||||||
|
LEFT JOIN( -- 取得整點值PR
|
||||||
|
SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
||||||
|
FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
|
||||||
|
WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
|
||||||
|
and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
|
||||||
|
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
|
||||||
|
) inv_pr
|
||||||
|
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
|
||||||
|
-- 取得逆變器容量
|
||||||
|
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
||||||
|
-- 取日照度 ---------------------
|
||||||
|
left join (
|
||||||
|
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
|
||||||
|
from sensor_history_hour a
|
||||||
|
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||||
|
)irr on a.reportDate = irr.reportDate
|
||||||
|
order by a.INVERTERID, a.reportDate;";
|
||||||
|
int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
|
||||||
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
|
||||||
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
|
|
||||||
inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
|
|
||||||
((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
|
||||||
from
|
|
||||||
( -- 取得該時間區間的KWH
|
|
||||||
SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
|
|
||||||
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
|
||||||
AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
|
||||||
round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
|
||||||
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
|
||||||
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
|
||||||
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
|
|
||||||
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
|
|
||||||
AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
|
|
||||||
FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
|
|
||||||
WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
|
|
||||||
GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
|
|
||||||
) a
|
|
||||||
LEFT JOIN( -- 取得整點值PR
|
|
||||||
SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
|
||||||
FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
|
|
||||||
WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
|
|
||||||
and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
|
|
||||||
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
|
|
||||||
) inv_pr
|
|
||||||
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
|
|
||||||
-- 取得逆變器容量
|
|
||||||
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
|
||||||
-- 取日照度 ---------------------
|
|
||||||
left join (
|
|
||||||
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
|
|
||||||
from sensor_history_hour a
|
|
||||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
|
||||||
)irr on a.reportDate = irr.reportDate
|
|
||||||
order by a.INVERTERID, a.reportDate;";
|
|
||||||
int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
|
||||||
|
|
||||||
#endregion hour
|
#endregion hour
|
||||||
|
|
||||||
#region day
|
#region day
|
||||||
sql = @"
|
try
|
||||||
INSERT INTO solar_master.inverter_history_day(PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
{
|
||||||
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W,
|
if (_logger != null)
|
||||||
DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH, PR, RA1, RA2, RA3, RA4, RA5, `DCKW`, `ACKW`, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
SELECT @powerStationID powerStationID, a.INVERTERID, concat(a.reportDate,' 00:00:00') reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
sql = @"
|
||||||
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
INSERT INTO solar_master.inverter_history_day(PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||||
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH, a.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5,
|
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W,
|
||||||
DCKW, ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH, PR, RA1, RA2, RA3, RA4, RA5, `DCKW`, `ACKW`, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||||
from
|
|
||||||
( -- 取得該時間區間的KWH
|
SELECT @powerStationID powerStationID, a.INVERTERID, concat(a.reportDate,' 00:00:00') reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||||
SELECT DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') AS reportDate, a.INVERTERID,
|
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
||||||
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, SUM(a.AC1W) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH, a.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5,
|
||||||
AVG(a.AC2A) AS AC2A, SUM(a.AC2W) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
DCKW, ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
||||||
SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
from
|
||||||
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
( -- 取得該時間區間的KWH
|
||||||
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
SELECT DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') AS reportDate, a.INVERTERID,
|
||||||
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, max(PR) AS PR,
|
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, SUM(a.AC1W) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
||||||
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW,
|
AVG(a.AC2A) AS AC2A, SUM(a.AC2W) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
||||||
MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH
|
SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
||||||
FROM solar_master.inverter_history_hour a
|
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
||||||
WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') = @date1
|
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
||||||
GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d'), a.INVERTERID
|
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, max(PR) AS PR,
|
||||||
) a
|
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW,
|
||||||
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH
|
||||||
-- 取日照度 ----------------------
|
FROM solar_master.inverter_history_hour a
|
||||||
left join (
|
WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') = @date1
|
||||||
select DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') AS reportDate, Irradiance
|
GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d'), a.INVERTERID
|
||||||
from sensor_history_day a
|
) a
|
||||||
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') = @date1 and Irradiance <> 0 limit 1
|
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
||||||
)irr on a.reportDate = irr.reportDate ;";
|
-- 取日照度 ----------------------
|
||||||
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
left join (
|
||||||
|
select DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') AS reportDate, Irradiance
|
||||||
|
from sensor_history_day a
|
||||||
|
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') = @date1 and Irradiance <> 0 limit 1
|
||||||
|
)irr on a.reportDate = irr.reportDate ;";
|
||||||
|
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
#endregion day
|
#endregion day
|
||||||
|
|
||||||
#region month
|
#region month
|
||||||
sql = @"
|
try
|
||||||
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;
|
{
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器month補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
|
||||||
INSERT INTO solar_master.inverter_history_month (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
sql = @"
|
||||||
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W,
|
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;
|
||||||
DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH, PR, RA1, RA2, RA3, RA4, RA5, `DCKW`, `ACKW`, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
|
||||||
|
INSERT INTO solar_master.inverter_history_month (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||||
|
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W,
|
||||||
|
DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH, PR, RA1, RA2, RA3, RA4, RA5, `DCKW`, `ACKW`, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||||
|
|
||||||
|
SELECT @powerStationID powerStationID, a.INVERTERID, concat(a.reportDate,'-01 00:00:00') reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||||
|
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
||||||
|
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH, a.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, DCKW, ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH,
|
||||||
|
(a.KWH / i.Capacity) AS KWHKWP
|
||||||
|
from
|
||||||
|
( -- 取得該時間區間的KWH
|
||||||
|
SELECT DATE_FORMAT(a.TIMESTAMP, '%Y-%m') AS reportDate, a.INVERTERID,
|
||||||
|
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, SUM(a.AC1W) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
||||||
|
AVG(a.AC2A) AS AC2A, SUM(a.AC2W) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
||||||
|
SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
||||||
|
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
||||||
|
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
||||||
|
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, avg(PR) AS PR,
|
||||||
|
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW,
|
||||||
|
avg(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH
|
||||||
|
FROM solar_master.inverter_history_day a
|
||||||
|
WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1
|
||||||
|
GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m'), a.INVERTERID
|
||||||
|
) a
|
||||||
|
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
||||||
|
-- 取日照度 ----------------------
|
||||||
|
left join (
|
||||||
|
select DATE_FORMAT(a.TIMESTAMP, '%Y-%m') AS reportDate, Irradiance
|
||||||
|
from sensor_history_month a
|
||||||
|
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 and Irradiance <> 0
|
||||||
|
)irr on a.reportDate = irr.reportDate ;";
|
||||||
|
conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器month補償", _siteID, _date1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
SELECT @powerStationID powerStationID, a.INVERTERID, concat(a.reportDate,'-01 00:00:00') reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
|
||||||
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
|
||||||
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH, a.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, DCKW, ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH,
|
|
||||||
(a.KWH / i.Capacity) AS KWHKWP
|
|
||||||
from
|
|
||||||
( -- 取得該時間區間的KWH
|
|
||||||
SELECT DATE_FORMAT(a.TIMESTAMP, '%Y-%m') AS reportDate, a.INVERTERID,
|
|
||||||
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, SUM(a.AC1W) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
|
||||||
AVG(a.AC2A) AS AC2A, SUM(a.AC2W) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
|
||||||
SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
|
||||||
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
|
||||||
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
|
||||||
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, avg(PR) AS PR,
|
|
||||||
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW,
|
|
||||||
avg(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH
|
|
||||||
FROM solar_master.inverter_history_day a
|
|
||||||
WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1
|
|
||||||
GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m'), a.INVERTERID
|
|
||||||
) a
|
|
||||||
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
|
||||||
-- 取日照度 ----------------------
|
|
||||||
left join (
|
|
||||||
select DATE_FORMAT(a.TIMESTAMP, '%Y-%m') AS reportDate, Irradiance
|
|
||||||
from sensor_history_month a
|
|
||||||
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 and Irradiance <> 0
|
|
||||||
)irr on a.reportDate = irr.reportDate ;";
|
|
||||||
conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
|
|
||||||
#endregion month
|
#endregion month
|
||||||
|
|
||||||
conn.Close();
|
conn.Close();
|
||||||
@ -272,10 +392,10 @@ namespace solarApp.Service
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.0.90" />
|
<PackageReference Include="Dapper" Version="2.0.90" />
|
||||||
<PackageReference Include="MySql.Data" Version="8.0.26" />
|
<PackageReference Include="MySql.Data" Version="8.0.26" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue
Block a user