1.優化預設電站資訊 select table 數量

2.有效日照時數 改為 日均發電度數
This commit is contained in:
cesar liu 2022-05-16 12:45:44 +08:00
parent 1e2a74900d
commit ac0585055c
20 changed files with 127 additions and 43 deletions

1
.gitignore vendored
View File

@ -347,3 +347,4 @@ healthchecksdb
/SolarPower/SolarPower.zip
/SolarPower.zip
/SolarPower/wwwroot/upload/report/20220227
*.diagsession

View File

@ -661,9 +661,10 @@ namespace SolarPower.Controllers
if(post.Emailcheck == 1)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
if (post.WorkPersonIds != null)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
List<NoticeSchedule> noticeSchedules = new List<NoticeSchedule>();
foreach (var person in post.WorkPersonIds)
{
@ -703,7 +704,7 @@ namespace SolarPower.Controllers
if (post.FixFirm != 0)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
//var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
var fixtype = operationRecord.WorkType switch
{
0 => "清洗",
@ -711,7 +712,7 @@ namespace SolarPower.Controllers
2 => "維修",
_ => ""
};
var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
//var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync<OperationInfo>(post.FixFirm, powerstations.SiteDB, "operation_firm");
NoticeSchedule schedule = new NoticeSchedule()
{
@ -883,9 +884,9 @@ namespace SolarPower.Controllers
#endregion
if (post.Emailcheck == 1)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
if (post.WorkPersonIds != null)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
List<NoticeSchedule> noticeSchedules = new List<NoticeSchedule>();
foreach (var person in post.WorkPersonIds)
{
@ -924,7 +925,7 @@ namespace SolarPower.Controllers
}
if (post.FixFirm != 0)
{
var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
//var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId);
var fixtype = post.WorkType switch
{
0 => "清洗",
@ -932,7 +933,7 @@ namespace SolarPower.Controllers
2 => "維修",
_ => ""
};
var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
// var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId);
var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync<OperationInfo>(post.FixFirm, powerstations.SiteDB, "operation_firm");
NoticeSchedule schedule = new NoticeSchedule()
{

View File

@ -288,7 +288,8 @@ namespace SolarPower.Controllers
try
{
powerStation = await powerStationRepository.GetOneAsync(id);
//powerStation = await powerStationRepository.GetOneAsync(id);
powerStation = await powerStationRepository.GetStationExtraInfo(id);
if (powerStation == null)
{
@ -337,7 +338,7 @@ namespace SolarPower.Controllers
try
{
powerStation = await powerStationRepository.GetOneAsync(post.Id);
powerStation = await powerStationRepository.GetStationExtraInfo(post.Id);
//取得該公司DB Name
var company = await companyRepository.GetOneAsync(post.CompanyId);
@ -485,7 +486,8 @@ namespace SolarPower.Controllers
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
apiResult.Data = await powerStationRepository.GetOneAsync(id);
//apiResult.Data = await powerStationRepository.GetOneAsync(id);
apiResult.Data = await powerStationRepository.GetStationExtraInfo(id);
#endregion
}
else
@ -610,7 +612,8 @@ namespace SolarPower.Controllers
apiResult.Code = "0000";
apiResult.Msg = "儲存成功,請重新啟用電站";
apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
//apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
apiResult.Data = await powerStationRepository.GetStationExtraInfo(powerStation.Id);
#endregion
}
}
@ -734,7 +737,7 @@ namespace SolarPower.Controllers
}
//重新取得資料
powerStation = await powerStationRepository.GetOneAsync(powerStation.Id);
powerStation = await powerStationRepository.GetStationExtraInfo(powerStation.Id);
//替能源局換檔案路徑
if (!string.IsNullOrEmpty(powerStation.BoEFile))
@ -835,7 +838,7 @@ namespace SolarPower.Controllers
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
apiResult.Data = await powerStationRepository.GetStationExtraInfo(powerStation.Id);
#endregion
}
else
@ -871,7 +874,8 @@ namespace SolarPower.Controllers
apiResult.Code = "0000";
apiResult.Msg = "修改成功";
apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
//apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
apiResult.Data = await powerStationRepository.GetStationExtraInfo(powerStation.Id);
#endregion
}
}
@ -1346,7 +1350,7 @@ namespace SolarPower.Controllers
apiResult.Code = "0000";
apiResult.Msg = "刪除成功";
apiResult.Data = await powerStationRepository.GetOneAsync(landBuilding.PowerStationId);
apiResult.Data = await powerStationRepository.GetStationExtraInfo(landBuilding.PowerStationId);
}
catch (Exception exception)
{

View File

@ -514,7 +514,7 @@ namespace SolarPower.Controllers
try
{
powerStation = await powerStationRepository.GetOneAsync(post.Id);
// powerStation = await powerStationRepository.GetOneAsync(post.Id);
exceptionDataTable = await overviewRepository.GetExceptionTable(post);
foreach (ExceptionDataTable a in exceptionDataTable)
@ -794,8 +794,8 @@ namespace SolarPower.Controllers
{
var History = new List<HistoryTable>();
ApiResult<List<HistoryTable>> apiResult = new ApiResult<List<HistoryTable>>();
var powerStation = await powerStationRepository.GetOneAsync(post.PowerstationId);
// var powerStation = await powerStationRepository.GetOneAsync(post.PowerstationId);
//Logger.LogError("【 new add -------- " + controllerName + "/" + actionName + "】" + post);
try
{
History = await overviewRepository.GethistoryTable(post);

View File

@ -1842,7 +1842,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue("有效日照時數");
cell.SetCellValue("日均發電度數");
cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -2189,7 +2189,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue("有效日照時數");
cell.SetCellValue("日均發電度數");
cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region);

View File

@ -14,7 +14,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
}
},
"jsWebView2Debugging": true
},
"SolarPower": {
"commandName": "Project",

View File

@ -0,0 +1,8 @@
{
"dependencies": {
"appInsights1": {
"type": "appInsights",
"connectionId": null
}
}
}

View File

@ -0,0 +1,10 @@
{
"dependencies": {
"appInsights1": {
"resourceId": null,
"type": "appInsights.sdk",
"connectionId": null,
"secretStore": null
}
}
}

View File

@ -444,6 +444,49 @@ namespace SolarPower.Repository.Implement
{
//base.GetOneAsync(id);
PowerStation result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
try
{
var sql = @$"SELECT ps.*, c.Name AS CityName, a.Name AS AreaName, u.Name AS CreatorName FROM {tableName} ps
LEFT JOIN user u ON ps.CreatedBy = u.Id
LEFT JOIN city c ON ps.CityId = c.Id
LEFT JOIN area a ON ps.AreaId = a.Id
WHERE ps.Deleted = 0 AND ps.Id = @Id";
result = await conn.QueryFirstOrDefaultAsync<PowerStation>(sql, new { Id = id });
//if (result != null)
//{
// var db_name = result.SiteDB;
// var sql_operation_personnel = @$"SELECT UserId FROM power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
// result.OperationPersonnelIds = (await conn.QueryAsync<int>(sql_operation_personnel, new { PowerStationId = result.Id })).ToList();
// var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM {db_name}.land_building lb
// LEFT JOIN user u ON lb.CreatedBy = u.Id
// WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId";
// result.LandBuildings = (await conn.QueryAsync<LandBuilding>(sql_land_building, new { PowerStationId = result.Id })).ToList();
//}
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return result;
}
}
public async Task<PowerStation> GetStationExtraInfo(int id)
{
//base.GetOneAsync(id);
PowerStation result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
@ -483,6 +526,7 @@ namespace SolarPower.Repository.Implement
}
}
/// <summary>
/// 新增電站資料至 主、子資料庫
/// </summary>

View File

@ -516,6 +516,13 @@ namespace SolarPower.Repository.Interface
/// <returns></returns>
Task<List<PowerstationOption>> GetPowerstationPyrheliometerAsync(string db_name, int stationId);
/// <summary>
/// 取得完整電站資訊:包含維護人員及土地資訊
/// </summary>
/// <param name="powerStationId"></param>
/// <returns></returns>
Task<PowerStation> GetStationExtraInfo(int powerStationId);
Task<List<DeviceInfo>> GetListPyrheliometerByPowerStationId(int powerStationId, string db_name);
Task<List<DeviceInfo>> GetListTempByPowerStationId(int powerStationId, string db_name);
Task<List<DeviceInfo>> GetDeviceListByPowerStationIdAndType(int powerStationId, string type, string db_name);

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
@ -8,9 +8,13 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Compile Remove="Views\NewFolder\**" />
<Content Remove="Logs\**" />
<Content Remove="Views\NewFolder\**" />
<EmbeddedResource Remove="Logs\**" />
<EmbeddedResource Remove="Views\NewFolder\**" />
<None Remove="Logs\**" />
<None Remove="Views\NewFolder\**" />
</ItemGroup>
@ -25,6 +29,7 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.17" />
<PackageReference Include="MySql.Data" Version="8.0.26" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
@ -35,7 +40,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Logs\" />
<Folder Include="wwwroot\upload\company_logo\" />
<Folder Include="wwwroot\upload\power_station\boe_file\" />
</ItemGroup>

View File

@ -87,6 +87,7 @@ namespace SolarPower
{
options.IdleTimeout = TimeSpan.FromMinutes(loginExpireMinute);
});
services.AddApplicationInsightsTelemetry();
#region
//services.AddHostedService<OperationScheduleBackgroundService>();
@ -140,6 +141,7 @@ namespace SolarPower
#endregion
services.AddHostedService<QuartzHostedService>();
services.AddApplicationInsightsTelemetry();
#endregion
}

View File

@ -148,16 +148,16 @@
</div>
<div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>有效日照時數</h4>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>日均發電度數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p id="today_kwhkwp_label">當日有效日照時數 </p>
<p id="today_kwhkwp_label">當日日均發電度數 </p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p>平均日均發電度數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwhkwp">0.00</span></p>
</div>
</div>
@ -325,7 +325,7 @@
$("#today_kwh_label").html(timename + "發電量");
$("#today_money_label").html(timename + "發電金額");
$("#today_kwhkwp_label").html(timename + "有效日照時數");
$("#today_kwhkwp_label").html(timename + "日均發電度數");
$("#today_PR_label").html(timename + "PR值");
$("#today_carbon_label").html(timename + "減碳量");
$("#today_irradiance_label").html(timename + "日照度");

View File

@ -124,7 +124,7 @@
var PWS_compare_col = [
{ key: "KWH", title: "發電量", default: true },
@*{ key: "Irradiance", title: "日照度", default: false },*@
{ key: "KWHKWP", title: "有效日照時數", default: false },
{ key: "KWHKWP", title: "日均發電度數", default: false },
{ key: "PR", title: "PR %", default: false },
@*{ key: "Temperature", title: "模組溫度", default: false },*@
{ key: "SolarHour", title: "日照小時", default: false },

View File

@ -63,16 +63,16 @@
</div>
<div class="card">
<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-sun mr-1"></span>有效日照時數</h4>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>日均發電度數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日有效日照時數(kwh/kwp)</p>
<p>今日日均發電度數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數 (30天)</p>
<p>平均日均發電度數 (30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div>
</div>
@ -284,7 +284,7 @@
'<div class="col-12">' +
'<div>今日發電量(kW h)' + item.today_kWh.toFixed(2) + '</div>'+
'<div>今日日照度(k W/m<sup>2</sup>)' + item.today_irradiance + '</div>'+
'<div>有效日照時數(kwh/kwp)' + item.today_kwhkwp.toFixed(2) + '</div>' +
'<div>日均發電度數(kwh/kwp)' + item.today_kwhkwp.toFixed(2) + '</div>' +
'<div>裝置容量(kWp)' + item.generatingCapacity.toFixed(3) + '</div>' +
'<div>掛錶日期:' + item.electricityMeterAt + '</div>' +
'<div>天氣:' + item.wx + '</div>'+

View File

@ -121,16 +121,16 @@
</div>
<div class="col card px-0 mx-2">
<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-sun mr-1"></span>有效日照時數</h4>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>日均發電度數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日有效日照時數(kwh/kwp)</p>
<p>今日日均發電度數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p>平均日均發電度數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div>
</div>

View File

@ -2084,7 +2084,7 @@
},
title: {
text: '各逆變器當日有效日照時數'
text: '各逆變器當日日均發電度數'
},
xAxis: {
categories: HeatMap.xAxis,
@ -2421,7 +2421,9 @@
}
//#endregion
console.log(" before onChange event");
$('#DateGet').on('change', function () {
console.log(" in onChange event");
historyRange = $('#DateGet').val();
getTable();
});
@ -2646,7 +2648,7 @@
color: 'rgb(68, 114, 196)'
}, {
type: 'column',
name: "有效日照時數",
name: "日均發電度數",
data: listkwhkwp,
yAxis: "C",
color: "rgb(165, 165, 165)"
@ -2702,7 +2704,7 @@
data: listpr
},{
type: 'bar',
label: '有效日照時數',
label: '日均發電度數',
yAxisID: 'C',
backgroundColor: 'rgba(165, 165, 165)',
borderWidth: 1,

View File

@ -59,7 +59,7 @@
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>有效日照時數</th>
<th>日均發電度數</th>
<th>累積日照量(W/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>

View File

@ -66,16 +66,16 @@
</div>
<div class="card">
<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-sun mr-1"></span>有效日照時數</h4>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>日均發電度數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日有效日照時數(kwh/kwp)</p>
<p>今日日均發電度數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p>平均日均發電度數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div>
</div>

View File

@ -1389,7 +1389,7 @@
TotalHead += "<tr>";
TotalHead += "<th>" + "時間" + "</th>";
TotalHead += "<th>" + "發電量" + "</th>";
TotalHead += "<th>" + "有效日照時數" + "</th>";
TotalHead += "<th>" + "日均發電度數" + "</th>";
TotalHead += "</tr>";
//#endregion
//#region TotalBody