FIC_Solar/SolarPower/Views/StationOverview/Index.cshtml
2021-07-07 19:03:18 +08:00

406 lines
22 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 show">
<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">
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
新北市
<span class="badge bg-success-700 ml-2" id="acount">4</span>
</button>
</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" onclick="Allpowerstation()">全選</button>
</div>
<div class="col-11 p-2">
<div class="row frame-wrap" id="CheckPowerStation">
<div class="col-2 mb-2 custom-control custom-checkbox d-flex align-content-center">
<input type="checkbox" class="custom-control-input" id="defaultInline9" checked="">
<label class="custom-control-label" for="defaultInline9">設備正常 <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" id="defaultInline10" checked="">
<label class="custom-control-label" for="defaultInline10">設備斷線 <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" id="defaultInline11" checked="">
<label class="custom-control-label" for="defaultInline11">設備異常 <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" id="citytest">
<select class="form-control">
<option value="0">發電量 - 正序</option>
<option value="1">發電量 - 倒序</option>
</select>
</div>
</div>
<div class="pr-3">
<div class="frame-wrap" id="citytest">
<select class="form-control">
<option value="0">PR值 - 正序</option>
<option value="1">PR值 - 倒序</option>
</select>
</div>
</div>
</div>
<div id="area" class="tab-content p-3">
<div class="row mb-5">
<div class="card-columns">
<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-bolt mr-1"></span> 發電量</h4>
</div>
<div class="card-body" style="min-height: 148px;">
<div class="d-flex justify-content-between">
<p>今日發電量</p>
<p><span class="color-info-700" id="today_kwh">126,161.72</span> kWh</p>
</div>
<div class="d-flex justify-content-between">
<p>累積發電量</p>
<p><span class="color-info-700" id="total_kwh">4,069.73</span> kWh</p>
</div>
</div>
</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>
</div>
<div class="card-body" style="min-height: 148px;">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p><span class="color-info-700" id="today_irradiance">126,161.72</span> kW/m<sup>2</sup></p>
</div>
<div class="d-flex justify-content-between">
<p>平均日照度(30天)</p>
<p><span class="color-info-700" id="avg_irradiance">4,069.73</span> kW/m<sup>2</sup></p>
</div>
</div>
</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-bolt mr-1"></span> PR值</h4>
</div>
<div class="card-body" style="min-height: 148px;">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p><span class="color-info-700" id="today_PR">119.04</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均 PR 值(30天)</p>
<p><span class="color-info-700" id="avg_PR">3.84</span></p>
</div>
</div>
</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> kWh / kWp</h4>
</div>
<div class="card-body" style="min-height: 148px;">
<div class="d-flex justify-content-between">
<p>即時平均 kWh / kWp</p>
<p><span class="color-info-700" id="today_kwhkwp">140.39</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均 kWh / kWp (30天)</p>
<p><span class="color-info-700" id="avg_kwhkwp">4.53</span></p>
</div>
</div>
</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-bolt mr-1"></span> 減碳量</h4>
</div>
<div class="card-body" style="min-height: 148px;">
<div class="d-flex justify-content-between">
<p>今日減碳量</p>
<p><span class="color-info-700" id="today_carbon">6,091.78</span> kG</p>
</div>
<div class="d-flex justify-content-between">
<p>累積減碳量</p>
<p><span class="color-info-700" id="total_carbon">985.98</span> kG</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-content p-3">
<div class="col-12 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 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>
<ul class="list-group list-group-flush">
<li class="list-group-item px-2">
<div class=" d-flex justify-content-between">
<p>發電量</p>
<p><span class="color-primary-400" id="Capacity">185</span> kWh</p>
<p id="Temp">27°C</p>
</div>
<div class=" d-flex justify-content-between">
<p>發電金額</p>
<p><span class="color-primary-400" id="PowerRate">2,5840</span> NT</p>
<p><span class="color-primary-400" id="stationtype">65</span></p>
</div>
<div class=" d-flex justify-content-between">
<p>Pr值</p>
<p><span class="color-primary-400" id="PR">65</span> %</p>
<div style="text-align:right">
<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>
</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>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
@section Scripts{
<script>
var localurl = this.location.href;
var tablocation = "";
var ids = new Array(0);//當前選擇縣市
var powerids = new Array(0);//當前選擇電站
var Allids = new Array(0);//全部縣市
var Allpowerids = new Array(0);//全部電站
//#region Array.Remove
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
//#endregion
$(function () {
var Nurl = "/PowerStation/GetSolarCitySummary";
$.post(Nurl, 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].city +
"<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 Newpowerids = new Array(0);
var value = document.getElementById(clickid).className;
ids.sort(function (a, b) {
return a - b;
});
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');
ids.push(Number(classid[1]));
}
else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(Number(classid[1]));
}
getStation(ids);
})
function getStation(ids)
{
var status = [1,2,3];
var send_data = {
cityid: ids,
status: status,
};
//ids.sort(function (a, b) {
// return a - b;
//});
//ids.sort();
var Nurl = "/StationOverview/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#areaCard').empty();
$.each(rel.data, function (index, val) {
$('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard'));
$('#card_' + val.id).find('#solarName').html(val.name);
$('#card_' + val.id).find('#Temp').html(val.todayWeatherTemp);
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('#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('#Capacity').html(val.generatingCapacity);
$('#card_' + val.id).find('#PowerRate').html(val.generatingCapacity * val.powerRate);
$('#card_' + val.id).find('#PR').html(val.pr);
$('#card_' + val.id).find('#aria').attr('aria-valuenow', val.pr);
$('#card_' + val.id).find('#aria').attr('style', "width:" + val.pr + "%;");
powerids.push(val.id);
});
GetStationCard();
}, 'json');
}
function GetStationCard()
{
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);
$("#total_kwh").html(mapOverview.total_kwh);
$("#today_irradiance").html(mapOverview.today_irradiance);
$("#avg_irradiance").html(mapOverview.avg_irradiance);
$("#today_PR").html(mapOverview.today_PR);
$("#avg_PR").html(mapOverview.avg_PR);
$("#today_kwhkwp").html(mapOverview.today_kwhkwp);
$("#avg_kwhkwp").html(mapOverview.avg_kwhkwp);
$("#today_carbon").html(mapOverview.today_carbon);
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
$("#total_capacity").html(mapOverview.totalCapacity);
$("#update_at").html(mapOverview.updatedAt);
});
}
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>
}