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

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; return apiResult;
} }
/// <summary>
/// 取得運維人員
/// </summary>
/// <param name="powerStationId"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<OperationPersonnelSelectItemList>>> GetOperationPersonnelSelectOptionList(int powerStationId) 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 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 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(); result = (await conn.QueryAsync<CheckBox>(sql, new { PowerStationId = powerStationId })).ToList();
} }
@ -439,7 +439,7 @@ namespace SolarPower.Repository.Implement
{ {
DateTime start; DateTime start;
DateTime end; 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.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, 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 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 // LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId
// WHERE C.PowerStationId = {post.PowerstationId} // WHERE C.PowerStationId = {post.PowerstationId}
// GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; // 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 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} WHERE C.PowerStationId = {post.PowerstationId}
group by left(c.`TIMESTAMP`, 4) "; group by left(c.`TIMESTAMP`, 4) ";
break; break;

View File

@ -95,6 +95,14 @@ namespace SolarPower.Repository.Implement
GROUP BY w.LocationName GROUP BY w.LocationName
) A ) A
LEFT JOIN weather_forecast B ON A.aa = B.Id) wf ON c.Name = wf.LocationName"; 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) if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
{ //公司管理員 { //公司管理員

View File

@ -141,8 +141,9 @@ namespace SolarPower
#endregion #endregion
services.AddHostedService<QuartzHostedService>(); services.AddHostedService<QuartzHostedService>();
services.AddApplicationInsightsTelemetry();
#endregion #endregion
services.AddApplicationInsightsTelemetry();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // 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, "-"); var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(today_format); //$('#DateGet').val(today_format);
$('#date-range-history').val(today_format + ' - ' + today_format); $('#date-range-history').val(today_format + ' - ' + today_format);
groupType = 0;
} }
else else
{ // 昨天 { // 昨天
@ -2424,6 +2425,7 @@
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-"); var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(dateLimit_format); //$('#DateGet').val(dateLimit_format);
$('#date-range-history').val(dateLimit_format + ' - ' + dateLimit_format); $('#date-range-history').val(dateLimit_format + ' - ' + dateLimit_format);
groupType = 0;
} }
historyRange = $('#date-range-history').val(); historyRange = $('#date-range-history').val();
getTable(); getTable();
@ -2466,7 +2468,7 @@
} }
//#endregion //#endregion
console.log("date-range-history = " + $('#date-range-history').val()); //console.log("date-range-history = " + $('#date-range-history').val());
function Historyclick() { function Historyclick() {
switch (groupType) { switch (groupType) {
case 0: case 0:
@ -2485,7 +2487,11 @@
case 4: timeAll = $('#date-range-history').val().split('~'); case 4: timeAll = $('#date-range-history').val().split('~');
time1 = timeAll[0].trim(); time1 = timeAll[0].trim();
time2 = timeAll[1].trim(); time2 = timeAll[1].trim();
historyRange = time1 + ' - ' + time2; break; historyRange = time1 + ' - ' + time2;
if (time1 == time2){
groupType = 0;
}
break;
} }
getTable(); getTable();
} }
@ -2539,6 +2545,8 @@
var irradianceALL = 0; var irradianceALL = 0;
var pr = 0; var pr = 0;
var avgPR = 0; var avgPR = 0;
var irr_day = 0;
var avgIrr_day = 0;
var tempALL = 0; var tempALL = 0;
var listmonth = new Array(0); var listmonth = new Array(0);
var listkwh = new Array(0); var listkwh = new Array(0);
@ -2563,7 +2571,9 @@
kwhALL += val.kwh; kwhALL += val.kwh;
//diffSOLARHOURALL += val.diffSOLARHOUR; //diffSOLARHOURALL += val.diffSOLARHOUR;
irradianceALL += val.irradiance; irradianceALL += val.irradiance;
irr_day = val.irrDay; irr_day = val.irrDay;
avgIrr_day += val.irrDay; // 累計日照
pr = val.pr; pr = val.pr;
avgPR += val.pr; avgPR += val.pr;
//rowCT++; //rowCT++;
@ -2589,7 +2599,7 @@
kwhkwp = (ALLkwhkwp / times).toFixed(2); kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++; times++;
} }
console.log(val); // console.log(val);
diffSOLARHOURALL = val.solarhour; diffSOLARHOURALL = val.solarhour;
$('#HistoryDetailTable').append('<tr>' + $('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' + '<td>' + val.timestamp + '</td>' +
@ -2744,9 +2754,13 @@
}); });
if (groupType == 0) { if (groupType == 0) {
//日(hour) - 顯示當天最後一筆
avgPR = pr; avgPR = pr;
avgIrr_day = irr_day;
} else { } else {
//顯示多日 - 顯示平均值
avgPR = avgPR / rel.data.length; avgPR = avgPR / rel.data.length;
avgIrr_day = avgIrr_day / rel.data.length;
} }
//alert('avgPR = ' + avgPR + ' rowCT=' + rel.data.length); //alert('avgPR = ' + avgPR + ' rowCT=' + rel.data.length);
@ -2761,7 +2775,7 @@
'<td>' + kwhALL.toFixed(2) + '</td>' + '<td>' + kwhALL.toFixed(2) + '</td>' +
'<td>' + kwhkwp + '</td>' + '<td>' + kwhkwp + '</td>' +
//'<td>' + irradianceALL.toFixed(2) + '</td>' + // 改成累積日照 by jiahao 2022-04-30 00:444 //'<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>' + avgPR.toFixed(2) + '</td>' +
'<td>' + tempALL.toFixed(2) + '</td>' + '<td>' + tempALL.toFixed(2) + '</td>' +
'</tr>'); '</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;", "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": { "DBConfig": {
"Server": "MWAxcj1mgmbZ8tB6NgApnQ==", "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
"port": "CY1x+1WYXRCBab3wKnBCOQ==", "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
"Database": "CEyYZnO8B5+yTXQcFSsiBA==", "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
"Root": "4koIJVzfp6veImONCwQy3A==", "Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
"Password": "y4uPqlH9ncTgR/I07qpwaA==" "Password": "8WMHBEWuT0XoAB4kzduQHA=="
}, },
// FIC ¹wµo§GÀô¹Ò
//"DBConfig": {
// "Server": "MWAxcj1mgmbZ8tB6NgApnQ==",
// "port": "CY1x+1WYXRCBab3wKnBCOQ==",
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
// "Root": "4koIJVzfp6veImONCwQy3A==",
// "Password": "y4uPqlH9ncTgR/I07qpwaA=="
//},
"BackgroundServiceCron": { "BackgroundServiceCron": {
"CalcPowerStationJob": "0 5 * * * ?", "CalcPowerStationJob": "0 5 * * * ?",
"CalcAvgPowerStationJob": "0 0 2 * * ?", "CalcAvgPowerStationJob": "0 0 2 * * ?",

View File

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

View File

@ -2,8 +2,8 @@
<configuration> <configuration>
<connectionStrings> <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=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=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" />--> <!--<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 --> <!-- 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" />--> <!--<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> <UseWindowsForms>true</UseWindowsForms>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<EmbeddedResource Remove="fmArchive.resx" />
<EmbeddedResource Remove="fmExcel.resx" />
<EmbeddedResource Remove="fmMain.resx" />
<EmbeddedResource Remove="fmTest.resx" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<COMReference Include="Microsoft.Office.Interop.Excel"> <COMReference Include="Microsoft.Office.Interop.Excel">
<WrapperTool>tlbimp</WrapperTool> <WrapperTool>tlbimp</WrapperTool>