FIC_Solar/SolarPower/Views/StationOverview/Index.cshtml
Kai ccd68d6bf4 1. 加入 company viewer Modal
2. 修改電站總覽 紅黃燈名詞
3. 檢測逆變器狀態
2021-09-14 13:09:00 +08:00

612 lines
33 KiB
Plaintext

@{
ViewData["MainNum"] = "1";
ViewData["SubNum"] = "2";
ViewData["Title"] = "電站總覽";
}
<ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">總覽</a></li>
<li class="breadcrumb-item active">@ViewData["Title"]</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>
<!-- Your main content goes below here: -->
<div class="row">
<div class="col-xl-12">
<div id="panel-5" class="panel">
<div class="panel-container">
<div class="panel-content">
<div class="subheader">
<h1 class="subheader-title"> 電站分佈區域 </h1>
</div>
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全選</button>
</div>
<div class="pr-3">
<div class="frame-wrap" id="citytest"></div>
</div>
</div>
<div class="row mb-3 d-flex align-items-top px-3">
<div class="col-1 p-0">
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-checked="true" id="status-all-check">全選</button>
</div>
<div class="col-11 p-2">
<div class="row frame-wrap" id="CheckStatus">
<div class="col-2 mb-2 custom-control custom-checkbox d-flex align-content-center">
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_1" value="1" checked>
<label class="custom-control-label" for="Status_1">設備正常 <i class="btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check"></i></label>
</div>
<div class=" col-2 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_2" value="2" checked>
<label class="custom-control-label" for="Status_2">設備異常 <i class="btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation"></i></label>
</div>
<div class="col-2 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_3" value="3" checked>
<label class="custom-control-label" for="Status_3">設備斷線 <i class="btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule"></i></label>
</div>
</div>
</div>
</div>
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
<label>排序條件</label>
</div>
<div class="pr-3">
<div class="frame-wrap">
<select class="form-control" id="kwh_order">
<option value="0">發電量 - 正序</option>
<option value="1">發電量 - 倒序</option>
</select>
</div>
</div>
<div class="pr-3">
<div class="frame-wrap">
<select class="form-control" id="pr_order">
<option value="0">PR值 - 正序</option>
<option value="1">PR值 - 倒序</option>
</select>
</div>
</div>
</div>
<div class="row mb-5 px-3">
<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-bolt mr-1"></span> 發電量</h4>
<div class="ml-auto">kW h</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日發電量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwh">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>累積發電量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwh">0.00</span></p>
</div>
</div>
</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>
<div class="ml-auto">k W/㎡</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均日照度(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_irradiance">0.00</span></p>
</div>
</div>
</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-bolt mr-1"></span> PR值</h4>
<div class="ml-auto">%</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均 PR 值(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_PR">0.00</span></p>
</div>
</div>
</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>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</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><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div>
</div>
</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-bolt mr-1"></span> 減碳量</h4>
<div class="ml-auto">kG</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日減碳量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_carbon">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>累積減碳量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_carbon">0.00</span></p>
</div>
</div>
</div>
</div>
<div class="p-3">
<div class="row mb-5 d-flex justify-content-between">
<div class="col-12 text-right">
<a href="javascript:TableDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed mr-1" style="width: 47px;"><span class="fal fa-list fa-2x mt-2"></span></a>
<a href="javascript:CardDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed mr-1" style="width: 47px;"><span class="fal fa-grip-horizontal fa-2x mt-2"></span></a>
</div>
</div>
<div id="templateCard" style="display:none">
<div class="col-xl-3 mb-3">
<div class="card border m-auto m-lg-0">
<a id="editSolarUrl" href="0station.html">
<img id="Solarimg" src="img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="...">
</a>
<div class="card-body d-flex justify-content-between pb-0 px-2">
<h4 id="solarName" class="font-weight-bold" style="line-height: 27px;">
新竹巨城站
</h4>
<div class="d-flex">
<p id="Temp" class="mr-2">27°C</p><i class="fal fa-cloud-sun-rain fa-2x" id="weathericon"></i>
</div>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item px-2">
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>發電量</p>
<p><span class="color-primary-400" id="today_kwh">0.00</span> kWh</p>
</div>
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<div class="d-flex justify-content-end" style="width:40%">
@*<p>發電金額</p>*@
<p><span class="color-primary-400" id="PowerRate">0</span> NT</p>
</div>
}
</div>
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>裝置容量</p>
<p><span class="color-primary-400" id="Capacity">0.00</span> kWp</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p><span class="color-primary-400" id="stationtype">65</span></p>
</div>
</div>
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>PR值</p>
<p><span class="color-primary-400" id="PR">65</span> %</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p class="small" id="date">06-30 17:50</p>
</div>
</div>
</li>
</ul>
<div class="progress progress-sm">
<div class="progress-bar bg-info" id="aria" role="progressbar" style="width: 90%;" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
</div>
<div style="">
<div class="row mb-5" id="areaCard">
</div>
</div>
<div class="TableArea" id="tablearea" style="display:none">
<div class="p-3">
<table id="solarTable" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>編號</th>
<th>電站名稱</th>
<th>裝置容量(kWp)</th>
<th>累積發電量</th>
<th>今日發電量</th>
<th>發電小時</th>
<th>PR</th>
<th>日照</th>
<th>平均日照</th>
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<th>今日收入</th>
}
<th>掛表日期</th>
<th>狀況</th>
<th>功能</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="templateArea" hidden="hidden">
<div class="tab-pane" id="tab-name" role="tabpanel" aria-labelledby="tab-name">
<div class="row mb-5 d-flex justify-content-between">
<div class="col-6 text-right">
<a href="javascript:TableDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed"><span class="fal fa-list mr-1"></span></a>
<a href="javascript:CardDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed"><span class="fal fa-grip-horizontal mr-1"></span></a>
</div>
</div>
<div class="row solarCard" id="solarCard">
</div>
<div class="TableArea">
<table id="solarTable" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>編號</th>
<th>電站名稱</th>
<th>裝置容量(kWp)</th>
<th>累積發電量</th>
<th>今日發電量</th>
<th>發電小時</th>
<th>PR</th>
<th>日照</th>
<th>平均日照</th>
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<th>今日收入</th>
}
<th>掛表日期</th>
<th>狀況</th>
<th>功能</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
@section Scripts{
<script>
var localurl = this.location.href;
var ids = new Array(0);//當前選擇縣市
var powerids = new Array(0);//當前選擇電站
var Allids = new Array(0);//全部縣市
var status123 = new Array(0);//狀態
var AllidsType = true;
var StatusType = true;
$(function () {
status123 = [];
var city_url = "/StationOverview/GetMyCities";
$.post(city_url, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#citytest').empty();
for (var i = 0; i < rel.data.length; i++) {
$('#citytest').append("<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id='" + 'cityID_' + rel.data[i].cityId + "'>" +
rel.data[i].cityName +
"<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
"</button >");
ids.push(rel.data[i].cityId);
Allids.push(rel.data[i].cityId);
}
getStation(ids);
}, 'json');
});
$('#citytest').on("click", "button", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var value = document.getElementById(clickid).className;
if (value == 'btn btn-outline-success waves-effect waves-themed ml-2') { //選擇
document.getElementById(clickid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
if ($.inArray(parseInt(classid[1]), ids) < 0) {
ids.push(parseInt(classid[1]));
}
}
else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
if ($.inArray(parseInt(classid[1]), ids) > -1) {
ids.splice($.inArray(parseInt(classid[1]), ids), 1);
}
}
getStation(ids);
})
function getStation(ids) {
@*var kwh = $('#kwh_order').val();
var pr = $('#pr_order').val();
var send_data = {
cityid: ids,
status: status123,
kwhOrder: kwh,
prOrder: pr
};*@
var selectedStatus = $("input[name='powerStationStatus[]']:checked").map(function () {
return $(this).val();
}).get();
var send_data = {
cityIds: ids,
status: selectedStatus,
kwhOrderBy: $('#kwh_order').val(),
prOrderBy: $('#pr_order').val()
}
@*ids.sort(function (a, b) {
return a - b;
});
ids.sort();*@
if (ids.length == 0 || selectedStatus.length == 0) {
$('#areaCard').empty();
$('#solarTable').find('tbody').empty();
$("#today_kwh").html(0);
$("#total_kwh").html(0);
$("#today_irradiance").html(0);
$("#avg_irradiance").html(0);
$("#today_PR").html(0);
$("#avg_PR").html(0);
$("#today_kwhkwp").html(0);
$("#avg_kwhkwp").html(0);
$("#today_carbon").html(0);
$("#total_carbon").html(0);
$("#update_at").html(0);
}
else {
var Nurl = "/StationOverview/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#areaCard').empty();
$('#solarTable').find('tbody').empty();
powerids = [];
$.each(rel.data.powerStations, function (index, val) {
$('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard'));
var statusicon;
switch (val.healthStatus) {
case 1: statusicon = "<i class='btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check mr-2'></i>"; break;
case 2: statusicon = "<i class='btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation mr-2'></i>"; break;
case 3: statusicon = "<i class='btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule mr-2'></i>"; break;
default:
statusicon = 'NULL'; break;
}
$('#card_' + val.id).find('#solarName').html(statusicon + val.name);
$('#card_' + val.id).find('#weathericon')[0].setAttribute("class", 'fal fa-' + val.todayWeather + ' fa-2x');
$('#card_' + val.id).find('#Temp').html((val.todayWeatherTemp == -99)? "": val.todayWeatherTemp + '°C');
var type = "";
switch (val.solarType) {
case 0: type = "自建躉售"; break;
case 1: type = "租建躉售"; break;
case 2: type = "自建自用"; break;
default:
console.log(`Sorry, we are out of ${val.solarType}.`);
}
$('#card_' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', val.mainDisplay);
$('#card_' + val.id).find('#editSolarUrl').find('#Solarimg').attr('style', "width: 100%;height: 210.5px;");
$('#card_' + val.id).find('#stationtype').html(type);
var time = new Date(val.createdAt);
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id);
$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
$('#card_' + val.id).find('#today_kwh').html(val.today_kWh.toFixed(2));
$('#card_' + val.id).find('#Capacity').html(val.generatingCapacity.toFixed(3));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<text>
$('#card_' + val.id).find('#PowerRate').html((val.today_kWh * val.powerRate).toFixed());
</text>
}
$('#card_' + val.id).find('#PR').html(val.today_PR);
$('#card_' + val.id).find('#aria').attr('aria-valuenow', val.today_PR);
$('#card_' + val.id).find('#aria').attr('style', "width:" + val.today_PR + "%;");
powerids.push(val.id);
var statusName;
switch (val.healthStatus) {
case 1:
statusName = "設備正常";
break;
case 2:
statusName = "設備斷線";
break;
case 3:
statusName = "設備異常";
break;
default:
statusName = "NULL";
}
$('#solarTable').find('tbody').append('<tr>' +
'<td>' + val.code + '</td>' +
'<td>' + val.name + '</td>' +
'<td>' + val.generatingCapacity.toFixed(3) + '</td>' +
'<td>' + val.total_kWh.toFixed(2) + '</td>' +
'<td>' + val.today_kWh.toFixed(2) + '</td>' +
'<td>' + val.solarHour.toFixed(2) + '</td>' +
'<td>' + val.today_PR + '</td>' +
'<td>' + val.today_irradiance.toFixed(2) + '</td>' +
'<td>' + val.avg_irradiance.toFixed(2) + '</td>' +
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<text>
'<td>' + val.today_Money.toFixed() + '</td>' +
</text>
}
'<td>' + val.electricityMeterAt + '</td>' +
'<td>' + statusName + '</td>' +
'<td><button type="button" class="btn btn-primary btn-pills waves-effect waves-themed" onclick="location.href=\'' + localurl + '/Info?stationId=' + val.id + '\'">選擇</button></td>' +
'</tr>');
});
GetStationCard(rel.data);
}, 'json');
}
}
function GetStationCard(powerStationSummary) {
@*var send_data = {
ids: powerids
};
var url = "/StationOverview/GetStationCard";
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
mapOverview = rel.data;
$("#today_kwh").html(mapOverview.today_kwh.toFixed(2));
$("#total_kwh").html(mapOverview.total_kwh.toFixed(2));
$("#today_irradiance").html(mapOverview.today_irradiance.toFixed(2));
$("#avg_irradiance").html(mapOverview.avg_irradiance.toFixed(2));
$("#today_PR").html(mapOverview.today_PR.toFixed(2));
$("#avg_PR").html(mapOverview.avg_PR.toFixed(2));
$("#today_kwhkwp").html(mapOverview.today_kwhkwp.toFixed(2));
$("#avg_kwhkwp").html(mapOverview.avg_kwhkwp.toFixed(2));
$("#today_carbon").html(mapOverview.today_carbon.toFixed(2));
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
$("#total_capacity").html(mapOverview.totalCapacity.toFixed(2));
$("#update_at").html(mapOverview.updatedAt);
});*@
$("#today_kwh").html(powerStationSummary.today_kwh.toFixed(2));
$("#total_kwh").html(powerStationSummary.total_kwh.toFixed(2));
$("#today_irradiance").html(powerStationSummary.today_irradiance.toFixed(2));
$("#avg_irradiance").html(powerStationSummary.avg_irradiance.toFixed(2));
$("#today_PR").html(powerStationSummary.today_PR.toFixed(2));
$("#avg_PR").html(powerStationSummary.avg_PR.toFixed(2));
$("#today_kwhkwp").html(powerStationSummary.today_kwhkwp.toFixed(2));
$("#avg_kwhkwp").html(powerStationSummary.avg_kwhkwp.toFixed(2));
$("#today_carbon").html(powerStationSummary.today_carbon.toFixed(2));
$("#total_carbon").html(powerStationSummary.total_carbon.toFixed(2));
$("#update_at").html(powerStationSummary.updatedAt);
}
//#region 選擇狀態checkbox
$('#CheckStatus').on("click", "input", function () {
@*var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
status123.push(Number(classid[1]));
}
else {
status123.remove(Number(classid[1]));
}*@
getStation(ids);
})
//#endregion
$('#kwh_order').change(function () {
getStation(ids);
})
$('#pr_order').change(function () {
getStation(ids);
})
//#region 縣市全選
function Allcity() {
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
if (AllidsType) {
document.getElementById(cityid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids = [];
}
else {
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
}
});
if (AllidsType) {
AllidsType = false;
AllpoweridsType = false;
} else {
AllidsType = true;
}
getStation(ids);
}
//#endregion
//#region 狀態全選
$("#status-all-check").click(function (e) {
@* status123 =[];
if (StatusType) {
for (var i = 1; i <= 3; i++) {
$('#Status_' + i).prop("checked", false);
}
StatusType = false;
} else {
for (var i = 1; i <= 3; i++) {
$('#Status_' + i).prop("checked", true);
status123.push(i);
}
StatusType = true;
}*@
var checked = $(this).attr("data-checked") == "true";
if (checked) {
$(this).attr("data-checked", false);
$("input[name='powerStationStatus[]']").prop('checked', false);
}
else {
$(this).attr("data-checked", true);
$("input[name='powerStationStatus[]']").prop('checked', true);
}
getStation(ids);
});
//#endregion
function CardDisplay() {
document.getElementById("tablearea").style.display = "none";
document.getElementById("areaCard").style.display = "";
//$("#tablearea").hide();
//$("#templateCard").show();
}
function TableDisplay() {
document.getElementById("areaCard").style.display = "none";
document.getElementById("tablearea").style.display = "";
//$('#tablearea').show();
//$('#templateCard').hide();
}
</script>
}