增加電站詳細資料 - 歷史資料查詢 - 日期範圍選擇

This commit is contained in:
cesar liu 2022-05-25 23:58:02 +08:00
parent b26baf574c
commit 7b99aaf6a6
9 changed files with 71 additions and 34 deletions

View File

@ -230,6 +230,11 @@ namespace SolarPower.Controllers
return apiResult;
}
/// <summary>
/// 取得運維人員
/// </summary>
/// <param name="powerStationId"></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<List<OperationPersonnelSelectItemList>>> GetOperationPersonnelSelectOptionList(int powerStationId)
{

View File

@ -314,7 +314,7 @@ namespace SolarPower.Repository.Implement
{
var sql = @$"SELECT i.Id AS Value, i.InverterName AS Name FROM {db_name}.inverter i
LEFT JOIN {db_name}.controller c ON i.ControllerId = c.Id AND c.Deleted = 0
WHERE i.Deleted = 0 AND c.PowerStationId = @PowerStationId";
WHERE i.Deleted = 0 AND c.PowerStationId = @PowerStationId order by i.Id ";
result = (await conn.QueryAsync<CheckBox>(sql, new { PowerStationId = powerStationId })).ToList();
}
@ -439,7 +439,7 @@ namespace SolarPower.Repository.Implement
{
DateTime start;
DateTime end;
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationId, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
case when c.errMsg_tw is null then
@ -731,8 +731,10 @@ namespace SolarPower.Repository.Implement
// LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId
// WHERE C.PowerStationId = {post.PowerstationId}
// GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` ";
sql = $@" select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR
sql = $@" select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR ,
ifnull(avg( P.IrrDay), 0) irrDay, avg(P.Temperature) AS Temp
FROM power_station_history_month C
LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y') = DATE_FORMAT(C.TIMESTAMP, '%Y') AND P.PowerStationId = C.PowerStationId
WHERE C.PowerStationId = {post.PowerstationId}
group by left(c.`TIMESTAMP`, 4) ";
break;

View File

@ -95,6 +95,14 @@ namespace SolarPower.Repository.Implement
GROUP BY w.LocationName
) A
LEFT JOIN weather_forecast B ON A.aa = B.Id) wf ON c.Name = wf.LocationName";
//var sql = $@"SELECT ps.*, c.Name AS CityName, wf.Wx
// FROM power_station ps
// LEFT JOIN city c ON ps.CityId = c.Id
// LEFT JOIN (
// SELECT LocationName, Wx FROM weather_forecast w
// WHERE '{now}' BETWEEN w.StartTime AND w.EndTime
// GROUP BY w.LocationName
// ) wf ON c.Name = wf.LocationName";
if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
{ //公司管理員

View File

@ -141,8 +141,9 @@ namespace SolarPower
#endregion
services.AddHostedService<QuartzHostedService>();
services.AddApplicationInsightsTelemetry();
#endregion
services.AddApplicationInsightsTelemetry();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@ -2416,6 +2416,7 @@
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(today_format);
$('#date-range-history').val(today_format + ' - ' + today_format);
groupType = 0;
}
else
{ // 昨天
@ -2424,6 +2425,7 @@
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(dateLimit_format);
$('#date-range-history').val(dateLimit_format + ' - ' + dateLimit_format);
groupType = 0;
}
historyRange = $('#date-range-history').val();
getTable();
@ -2466,7 +2468,7 @@
}
//#endregion
console.log("date-range-history = " + $('#date-range-history').val());
//console.log("date-range-history = " + $('#date-range-history').val());
function Historyclick() {
switch (groupType) {
case 0:
@ -2485,7 +2487,11 @@
case 4: timeAll = $('#date-range-history').val().split('~');
time1 = timeAll[0].trim();
time2 = timeAll[1].trim();
historyRange = time1 + ' - ' + time2; break;
historyRange = time1 + ' - ' + time2;
if (time1 == time2){
groupType = 0;
}
break;
}
getTable();
}
@ -2539,6 +2545,8 @@
var irradianceALL = 0;
var pr = 0;
var avgPR = 0;
var irr_day = 0;
var avgIrr_day = 0;
var tempALL = 0;
var listmonth = new Array(0);
var listkwh = new Array(0);
@ -2563,7 +2571,9 @@
kwhALL += val.kwh;
//diffSOLARHOURALL += val.diffSOLARHOUR;
irradianceALL += val.irradiance;
irr_day = val.irrDay;
avgIrr_day += val.irrDay; // 累計日照
pr = val.pr;
avgPR += val.pr;
//rowCT++;
@ -2589,7 +2599,7 @@
kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++;
}
console.log(val);
// console.log(val);
diffSOLARHOURALL = val.solarhour;
$('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' +
@ -2744,9 +2754,13 @@
});
if (groupType == 0) {
//日(hour) - 顯示當天最後一筆
avgPR = pr;
avgIrr_day = irr_day;
} else {
//顯示多日 - 顯示平均值
avgPR = avgPR / rel.data.length;
avgIrr_day = avgIrr_day / rel.data.length;
}
//alert('avgPR = ' + avgPR + ' rowCT=' + rel.data.length);
@ -2761,7 +2775,7 @@
'<td>' + kwhALL.toFixed(2) + '</td>' +
'<td>' + kwhkwp + '</td>' +
//'<td>' + irradianceALL.toFixed(2) + '</td>' + // 改成累積日照 by jiahao 2022-04-30 00:444
'<td>' + irr_day.toFixed(2) + '</td>' +
'<td>' + avgIrr_day.toFixed(2) + '</td>' +
'<td>' + avgPR.toFixed(2) + '</td>' +
'<td>' + tempALL.toFixed(2) + '</td>' +
'</tr>');

View File

@ -17,21 +17,21 @@
//},
"mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;",
//¥¿¦¡Àô¹Ò
//"DBConfig": {
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
// "Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
// "Password": "8WMHBEWuT0XoAB4kzduQHA=="
//},
// FIC ¹wµo§GÀô¹Ò
"DBConfig": {
"Server": "MWAxcj1mgmbZ8tB6NgApnQ==",
"port": "CY1x+1WYXRCBab3wKnBCOQ==",
"Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
"port": "CrEmevYrUsSo7Mkb7Gxn8A==",
"Database": "CEyYZnO8B5+yTXQcFSsiBA==",
"Root": "4koIJVzfp6veImONCwQy3A==",
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
"Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
"Password": "8WMHBEWuT0XoAB4kzduQHA=="
},
// FIC ¹wµo§GÀô¹Ò
//"DBConfig": {
// "Server": "MWAxcj1mgmbZ8tB6NgApnQ==",
// "port": "CY1x+1WYXRCBab3wKnBCOQ==",
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
// "Root": "4koIJVzfp6veImONCwQy3A==",
// "Password": "y4uPqlH9ncTgR/I07qpwaA=="
//},
"BackgroundServiceCron": {
"CalcPowerStationJob": "0 5 * * * ?",
"CalcAvgPowerStationJob": "0 0 2 * * ?",

View File

@ -19,21 +19,21 @@
// "Password": "y4uPqlH9ncTgR/I07qpwaA=="
//},
// FIC ¹wµo§GÀô¹Ò
"DBConfig": {
"Server": "MWAxcj1mgmbZ8tB6NgApnQ==",
"port": "CY1x+1WYXRCBab3wKnBCOQ==",
"Database": "CEyYZnO8B5+yTXQcFSsiBA==",
"Root": "pBX64+ALGFnLiHGRFXNh7w==",
"Password": "bOlWkSFsV3qNLkZTJ3UPog=="
},
// ¥¿¦¡
//"DBConfig": {
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
// "Server": "MWAxcj1mgmbZ8tB6NgApnQ==",
// "port": "CY1x+1WYXRCBab3wKnBCOQ==",
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
// "Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
// "Password": "8WMHBEWuT0XoAB4kzduQHA=="
// "Root": "pBX64+ALGFnLiHGRFXNh7w==",
// "Password": "bOlWkSFsV3qNLkZTJ3UPog=="
//},
// ¥¿¦¡
"DBConfig": {
"Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
"port": "CrEmevYrUsSo7Mkb7Gxn8A==",
"Database": "CEyYZnO8B5+yTXQcFSsiBA==",
"Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
"Password": "8WMHBEWuT0XoAB4kzduQHA=="
},
"BackgroundServiceCron": {
"CalcPowerStationJob": "0 5 * * * ?",
"CalcAvgPowerStationJob": "0 0 2 * * ?",

View File

@ -2,8 +2,8 @@
<configuration>
<connectionStrings>
<!--<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />-->
<add name="mySql" connectionString="server=localhost;user=root;Database=solar_master;Port=11306;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />
<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />
<!--<add name="mySql" connectionString="server=localhost;user=root;Database=solar_master;Port=11306;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />-->
<!--<add name="mySql" connectionString="server=localhost;user=root;Database=solar_master;Port=3306;password=zxcvb123;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->
<!-- kai -->
<!--<add name="mySql" connectionString="server=210.61.91.43;port=10068;user=idafenweb;Database=solar_power_test;Port=3306;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->

View File

@ -6,6 +6,13 @@
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Remove="fmArchive.resx" />
<EmbeddedResource Remove="fmExcel.resx" />
<EmbeddedResource Remove="fmMain.resx" />
<EmbeddedResource Remove="fmTest.resx" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Microsoft.Office.Interop.Excel">
<WrapperTool>tlbimp</WrapperTool>