FIC_Solar/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml
2023-08-28 23:58:00 +08:00

3387 lines
147 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
ViewData["MainNum"] = "2";
//ViewData["SubNum"] = "2";
ViewData["Title"] = "電站總覽";
}
@using SolarPower.Models.Role
@model RoleLayerEnum
@*<ol class="breadcrumb page-breadcrumb" >
<li class="breadcrumb-item"><a href="javascript:void(0);">總覽</a></li>
<li class="breadcrumb-item">@ViewData["Title"]</li>
<li class="breadcrumb-item city-name" id="breadcrumbcity">新竹市</li>
<li class="breadcrumb-item power-station-name active" id="breadcrumbname">新竹巨城站</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol>*@
<div class="d-flex justify-content-center text-secondary" style="top: 10%; transform: translateY(50%); z-index: 100; position: relative;">
<div class="spinner-border" role="status" style="width: 3rem; height: 3rem; display:none;" id="loading"></div>
</div>
<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="row subheader d-flex justify-content-between">
<div class="col-xl-4">
<h1 class="subheader-title">
<span id="power-station-healthStatus"></span>
<span id="power-station-title">電站名稱</span>
</h1>
</div>
<div class="col-xl-3 d-flex justify-content-start">
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x" id="weather-icon"></i></p>
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨機率: 0%</p>
</div>
</div>
<ul class="nav nav-tabs mb-5" role="tablist">
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_UpToDate"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4 active" data-toggle="tab" href="#tab-overview-uptodate" role="tab">
<i class="fal fa-monitor-heart-rate text-success"></i> <span class="hidden-sm-down ml-1" id="page_UpToDate">即時資訊</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Info"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-info" role="tab">
<i class="fal fa-info-square text-success"></i> <span class="hidden-sm-down ml-1" id="page_Info">基本資料</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_InverterInfo"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-InverterInfo" role="tab">
<i class="fal fa-digital-tachograph text-success"></i> <span class="hidden-sm-down ml-1" id="page_InverterInfo">逆變器監控</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Inverter"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-inverter" role="tab">
<i class="fal fa-analytics text-success"></i> <span class="hidden-sm-down ml-1" id="page_Inverter">逆變器分析</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_History"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-history" role="tab">
<i class="fal fa-history text-success"></i> <span class="hidden-sm-down ml-1" id="page_History">歷史資料</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Exception"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-exception" role="tab">
<i class="fal fa-sensor-alert text-success"></i> <span class="hidden-sm-down ml-1" id="page_Exception">異常記錄</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_OperationRecord"))
{
<li class="nav-item">
<a class="nav-link fs-lg px-4" data-toggle="tab" href="#tab-overview-operationRecord" role="tab">
<i class="fal fa-digital-tachograph text-success"></i> <span class="hidden-sm-down ml-1" id="page_OperationRecord">運維記錄</span>
</a>
</li>
}
</ul>
<div class="tab-content p-3">
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_UpToDate"))
{
<div class="tab-pane fade show active" id="tab-overview-uptodate" role="tabpanel" aria-labelledby="tab-overview-uptodate">
@Html.Partial("_UpToDate")
</div>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Info"))
{
<div class="tab-pane fade" id="tab-overview-info" role="tabpanel" aria-labelledby="tab-overview-info">
@Html.Partial("_Info")
</div>
}
<div class="tab-pane fade" id="tab-overview-InverterInfo" role="tabpanel" aria-labelledby="tab-overview-InverterInfo">
@Html.Partial("_InverterInfo")
</div>
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Inverter"))
{
<div class="tab-pane fade" id="tab-overview-inverter" role="tabpanel" aria-labelledby="tab-overview-inverter">
@Html.Partial("_Inverter")
</div>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_History"))
{
<div class="tab-pane fade" id="tab-overview-history" role="tabpanel" aria-labelledby="tab-overview-history">
@Html.Partial("_History")
</div>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Exception"))
{
<div class="tab-pane fade" id="tab-overview-exception" role="tabpanel" aria-labelledby="tab-overview-exception">
@Html.Partial("_Exception")
</div>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_OperationRecord"))
{
<div class="tab-pane fade" id="tab-overview-operationRecord" role="tabpanel" aria-labelledby="tab-overview-operationRecord">
@Html.Partial("_OperationRecord")
</div>
}
</div>
</div>
</div>
</div>
</div>
</div>
@section Scripts{
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script>
var localurl = this.location.href;
var powerids = new Array(0);//當前選擇電站
var Type = 0; // //程式中 會自動-1 工作項目, 0:清洗 1:巡檢 2:維修
var OperationStatus = 0; //運維 - 完成狀態
var stationId;
var errortoID;
var powerStationData;
var stationOverview;
var record;
var selected_work_type = -1;
var err_status = 1;//異常紀錄1:未解決 0:已解決
var groupType = 0; //0:日 1:月 2:年 3:歷年
var historyRange = "";
var selectInverterkwhBarType = 0;
var HeapMapXAxis = [];
var countOperationRecordFile = 0;
var isloadingdone_uptodate = false;
var isloadingdone_info = false;
var isloadingdone_inverterinfo = false;
var isloadingdone_inverter = false;
var isloadingdone_history = false;
var isloadingdone_exception = false;
var isloadingdone_operation = false;
var datepicker_record;
var datepicker_history;
var datepicker_exception;
function showLoading() {
var i = document.getElementById("loading");
i.style.display = "block";
}
function hideLoading() {
var i = document.getElementById("loading");
if (isloadingdone_uptodate && isloadingdone_info && isloadingdone_inverterinfo && isloadingdone_inverter && isloadingdone_history && isloadingdone_exception && isloadingdone_operation)
{
i.style.display = "none";
}
}
function checkPage() {
isloadingdone_uptodate = true;
isloadingdone_info = true;
isloadingdone_inverterinfo = true;
isloadingdone_inverter = true;
isloadingdone_history = true;
isloadingdone_exception = true;
isloadingdone_operation = true;
var i1 = document.getElementById("page_UpToDate");
var i2 = document.getElementById("page_Info");
var i3 = document.getElementById("page_InverterInfo");
var i4 = document.getElementById("page_Inverter");
var i5 = document.getElementById("page_History");
var i6 = document.getElementById("page_Exception");
var i7 = document.getElementById("page_OperationRecord");
if (i1 != null)
{
isloadingdone_uptodate = false;
}
if (i2 != null) {
isloadingdone_info = false;
}
if (i3 != null) {
isloadingdone_inverterinfo = false;
}
if (i4 != null) {
isloadingdone_inverter = false;
}
if (i5 != null) {
isloadingdone_history = false;
}
if (i6 != null) {
isloadingdone_exception = false;
}
if (i7 != null) {
isloadingdone_operation = false;
}
}
$(function () {
checkPage();
var url = new URL(location.href);
stationId = url.searchParams.get('stationId');
@*GetPowerStationCollapse();
$('#js_list_accordion_filter').change(function () {
var filter = $(this).val();
GetPowerStationCollapse(filter);
});*@
//#region Date-Picker add by jiahao 2022-05-21
if(document.getElementById('date-range-history') != null) {
datepicker_history = $('#date-range-history').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY-MM-DD' },
//miniDate: new Date(Date.setDate(Date.getDate() - 30)),
//maxDate: Date.getDate(),
opens: 'left'
}, function (start, end, label) {
});
}
$('#date-range-history').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ~ ' + picker.endDate.format('YYYY-MM-DD'));
$(this).trigger('change');
});
$('#date-range-history').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region 預設近今天
var today = new Date();
//var dateLimit = new Date(new Date().setDate(today.getDate() - 7));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
//var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
//datepicker.data('daterangepicker').setStartDate(dateLimit_format);
if(datepicker_history != undefined && datepicker_history != null) {
datepicker_history.data('daterangepicker').setStartDate(today_format);
datepicker_history.data('daterangepicker').setEndDate(today_format);
}
//$('#date-range-history').val(dateLimit_format + ' - ' + today_format);
$('#date-range-history').val(today_format + ' ~ ' + today_format);
//alert(" date-range-history = "+$('#date-range-history').val());
//#endregion
//#region 預先載入公司下拉式選單select_option
showLoading();
var url_company_select_option = "/Company/GetCompanySelectOptionList";
$.get(url_company_select_option, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$("#select_power_station_company").empty();
$.each(rel.data, function (index, val) {
$("#select_power_station_company").append($("<option />").val(val.value).text(val.text));
});
//預設查詢自己的公司
$("#select_power_station_company").val(@ViewBag.myUser.CompanyId).trigger('change');
hideLoading();
});
//#endregion
//#region 即時資訊tab
showLoading();
var url = "/StationOverview/GetOneStationUpToDateInfo";
var send_data = {
ids: [stationId]
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_uptodate = true;
hideLoading();
toast_error(rel.msg);
return;
}
stationOverview = rel.data;
$("#today_kwh").html(toThousands(stationOverview.today_kwh.toFixed(2)));
$("#total_kwh").html(toThousands(stationOverview.total_kwh.toFixed(2)));
$("#today_irradiance").html(toThousands(stationOverview.today_irradiance.toFixed(2)));
$("#avg_irradiance").html(toThousands(stationOverview.avg_irradiance.toFixed(2)));
$("#today_PR").html(toThousands(stationOverview.today_PR.toFixed(2)));
$("#avg_PR").html(toThousands(stationOverview.avg_PR.toFixed(2)));
$("#today_kwhkwp").html(toThousands(stationOverview.today_kwhkwp.toFixed(2)));
$("#avg_kwhkwp").html(toThousands(stationOverview.avg_kwhkwp.toFixed(2)));
$("#total_money").html(toThousands(stationOverview.total_money.toFixed()));
$("#today_money").html(toThousands(stationOverview.today_money.toFixed()));
$("#today_carbon").html(toThousands(stationOverview.today_carbon.toFixed(2)));
$("#total_carbon").html(toThousands(stationOverview.total_carbon.toFixed(2)));
$("#update_at").html(stationOverview.updatedAt);
var statusicon;
switch (stationOverview.healthStatus) {
case 1: statusicon = "<i class='btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check'></i>"; break;
case 2: statusicon = "<i class='btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation'></i>"; break;
case 3: statusicon = "<i class='btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule'></i>"; break;
default:
statusicon = ''; break;
}
$('#power-station-healthStatus').html(statusicon);
$('#power-station-title').html(stationOverview.stationName);
$('#weather-temp').html(stationOverview.todayWeatherTemp + '°C <br>降雨機率: ' + stationOverview.rateOfRain + '%');
$('#weather-icon')[0].setAttribute("class", 'fal fa-' + stationOverview.todayWeather + ' fa-3x');
$('#breadcrumbname').html(stationOverview.stationName);
$('#breadcrumbcity').html(stationOverview.cityName);
if (stationOverview.isShowMoney == 1) {
$(".money-card").show();
$(".irradiance-card").hide();
} else {
$(".money-card").hide();
$(".irradiance-card").show();
}
if (stationOverview.solarType == 0) {
$("#money-card-title").html("發電金額");
$("#money-card-subtitle-total").html("總計");
$("#money-card-subtitle-avg").html("今日");
} else if (stationOverview.solarType == 1) {
$("#money-card-title").html("租金收入");
$("#money-card-subtitle-total").html("總計");
$("#money-card-subtitle-avg").html("今日");
} else {
$("#money-card-title").html("省電費用");
$("#money-card-subtitle-total").html("總計");
$("#money-card-subtitle-avg").html("今日");
}
isloadingdone_uptodate = true;
hideLoading();
}, 'json');
//#region 載入電站圖片
showLoading();
var url_image = "/PowerStation/GetAllPowerStationsALLImage";
var send_data = {
powerStationId: stationId
};
$.post(url_image, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
carouselExampleIndicators = $("#carouselExampleIndicators");
carouselExampleIndicators.find(".carousel-indicators").empty();
carouselExampleIndicators.find(".carousel-inner").empty();
rel.data.forEach(function (value, index) {
CreatePowerStationImagecarousel(carouselExampleIndicators, value, index);
});
carouselExampleIndicators.find(".carousel-indicators > li").first().addClass("active");
carouselExampleIndicators.find(".carousel-inner > .carousel-item").first().addClass("active");
hideLoading();
}, 'json');
//#endregion
//#region 載入圖表資料
showLoading();
var url = "/StationOverview/GetChartUpToDate";
var send_data = {
id: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
var chartToday = rel.data.chartToday;
var chart7day = rel.data.chart7day;
var chartMonth = rel.data.chartMonth;
var chartYear = rel.data.chartYear;
//#region 今日
var ctx_chartToday = document.getElementById('chartToday').getContext('2d');
var myChartToday = new Chart(ctx_chartToday, {
type: 'bar',
data: {
labels: chartToday.labels,
datasets: [{
type: 'bar',
label: '發電量',
yAxisID: 'A',
backgroundColor: 'rgb(103, 180, 172)',
order: 3,
data: chartToday.powerDatas
}, {
type: 'line',
label: '累積日照量',
yAxisID: 'B',
borderColor: 'rgb(190, 45, 45)',
pointBackgroundColor: 'rgb(190, 45, 45)',
pointBorderColor: 'rgb(190, 45, 45)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
fill: false,
order: 2,
data: chartToday.irradianceDatas,
}, {
type: 'line',
label: '模組溫度',
yAxisID: 'C',
borderColor: 'rgb(255, 192, 0)',
pointBackgroundColor: 'rgb(255, 192, 0)',
pointBorderColor: 'rgb(255, 192, 0)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
fill: false,
order: 1,
data: chartToday.temperatureDatas,
}]
},
options: {
title: {
display: true,
text: '今日發電量'
},
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'kWh'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'Wh/㎡'
}
}, {
id: 'C',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: '℃'
}
}]
}
}
});
//#endregion
//#region 7日
var ctx_chart7day = document.getElementById('chart7day').getContext('2d');
var myChart7day = new Chart(ctx_chart7day, {
type: 'bar',
data: {
labels: chart7day.labels,
datasets: [{
type: 'bar',
label: '發電量',
yAxisID: 'A',
backgroundColor: 'rgb(103, 180, 172)',
order: 3,
data: chart7day.powerDatas
}, {
type: 'line',
label: '累積日照量',
yAxisID: 'B',
borderColor: 'rgb(190, 45, 45)',
pointBackgroundColor: 'rgb(190, 45, 45)',
pointBorderColor: 'rgb(190, 45, 45)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
order: 2,
fill: false,
data: chart7day.irradianceDatas,
}, {
type: 'line',
label: '模組溫度',
yAxisID: 'C',
borderColor: 'rgb(255, 192, 0)',
pointBackgroundColor: 'rgb(255, 192, 0)',
pointBorderColor: 'rgb(255, 192, 0)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
fill: false,
order: 1,
data: chart7day.temperatureDatas,
}]
},
options: {
title: {
display: true,
text: '7日發電量'
},
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'kWh'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'Wh/㎡'
}
}, {
id: 'C',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: '℃'
}
}]
}
}
});
//#endregion
//#region 本月
var ctx_chartMonth = document.getElementById('chartMonth').getContext('2d');
var myChartMonth = new Chart(ctx_chartMonth, {
type: 'bar',
data: {
labels: chartMonth.labels,
datasets: [{
type: 'bar',
label: '發電量',
yAxisID: 'A',
backgroundColor: 'rgb(103, 180, 172)',
order: 3,
data: chartMonth.powerDatas
}, {
type: 'line',
label: '累積日照量',
yAxisID: 'B',
borderColor: 'rgb(190, 45, 45)',
pointBackgroundColor: 'rgb(190, 45, 45)',
pointBorderColor: 'rgb(190, 45, 45)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
order: 2,
fill: false,
data: chartMonth.irradianceDatas,
}, {
type: 'line',
label: '模組溫度',
yAxisID: 'C',
borderColor: 'rgb(255, 192, 0)',
pointBackgroundColor: 'rgb(255, 192, 0)',
pointBorderColor: 'rgb(255, 192, 0)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
fill: false,
order: 1,
data: chartMonth.temperatureDatas,
}]
},
options: {
title: {
display: true,
text: '本月發電量'
},
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'kWh'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'Wh/㎡'
}
}, {
id: 'C',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: '℃'
}
}]
}
}
});
//#endregion
//#region 本年
var ctx_chartYear = document.getElementById('chartYear').getContext('2d');
var myChartYear = new Chart(ctx_chartYear, {
type: 'bar',
data: {
labels: chartYear.labels,
datasets: [{
type: 'bar',
label: '發電量',
yAxisID: 'A',
backgroundColor: 'rgb(103, 180, 172)',
order: 2,
data: chartYear.powerDatas
}, {
type: 'line',
label: '累積日照量',
yAxisID: 'B',
borderColor: 'rgb(190, 45, 45)',
pointBackgroundColor: 'rgb(190, 45, 45)',
pointBorderColor: 'rgb(190, 45, 45)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
order: 1,
fill: false,
data: chartYear.irradianceDatas,
}, {
type: 'line',
label: '模組溫度',
yAxisID: 'C',
borderColor: 'rgb(255, 192, 0)',
pointBackgroundColor: 'rgb(255, 192, 0)',
pointBorderColor: 'rgb(255, 192, 0)',
pointBorderWidth: 1,
borderWidth: 2,
pointRadius: 4,
pointHoverRadius: 5,
fill: false,
order: 1,
data: chartYear.temperatureDatas,
}]
},
options: {
title: {
display: true,
text: '本年發電量'
},
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'kWh'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: 'Wh/㎡'
}
}, {
id: 'C',
type: 'linear',
position: 'right',
ticks: {
min: 0
},
scaleLabel: {
display: true,
labelString: '℃'
}
}]
}
}
});
//#endregion
hideLoading();
}, 'json');
//#endregion
$('#carouselExampleIndicators').carousel({
interval: 11000
})
$('#carousel-chart').carousel({
interval: 11000
})
//#endregion
//#region 基本資料tab
showLoading();
var url = "/PowerStation/GetOnePowerStation"
var send_data = {
id: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_info = true;
hideLoading();
toast_error(rel.msg);
return;
}
powerStationData = rel.data;
$(".city-name").html(powerStationData.cityName);
$(".power-station-name").html(powerStationData.name);
$("#power-station-title").html(powerStationData.name);
//#region 電站基本資料
SetStationInfo();
//#endregion
//#region 能源局與台電資料
SetBoETPCInfo();
//#endregion
//#region 土地與房屋資料
SetLandBuildingInfo();
//#endregion
$("#power_station_select_modal").append($("<option />").val(stationId).text(powerStationData.name));
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
isloadingdone_info = true;
hideLoading();
}, 'json');
//#region 載入單線圖
showLoading();
var url_image = "/PowerStation/GetAllPowerStationSingleLine";
var send_data = {
powerStationId: stationId
};
$.post(url_image, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
var powerStationSingleLines = rel.data;
countPowerStationSingleLine = powerStationSingleLines.length;
powerStationSingleLineCard = $("#power-station-single-line-card > .row");
powerStationSingleLineCard.empty();
rel.data.forEach(function (value, index) {
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
});
hideLoading();
}, 'json');
//#endregion
//#region 預先載入運維人員下拉式選單select_option
showLoading();
var url_user_select_option = "/PowerStation/GetUserSelectOptionList";
var send_data = {
powerStationId: stationId
}
$.get(url_user_select_option, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$("#power_station_operation_personnel").empty();
$.each(rel.data, function (index, val) {
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
});
if (powerStationData) {
$("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds);
}
hideLoading();
});
$('.js-example-basic-multiple').select2();
//#endregion
//#endregion
//#region Date Picker record
if(document.getElementById('date-range-record') != null) {
datepicker_record = $('#date-range-record').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
}, function (start, end, label) {
@* console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
});
}
$('#date-range-record').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' ~ ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#date-range-record').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region Date Picker exception
if(document.getElementById('date-range-exception') != null) {
datepicker_exception = $('#date-range-exception').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
}, function (start, end, label) {
@* console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
});
}
$('#date-range-exception').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#date-range-exception').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region 運維作業記錄 DataTable
powerids.push(stationId);
showLoading();
operationRecordTable = $("#operation_record_table").DataTable({
"pageLength": 20,
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": false,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[9, "desc"]],
"columns": [{
"data": "powerStationName"
}, {
"data": "formId"
}, {
"data": "workTypeText"
}, {
"data": "fixDo"
}, {
"data": "statusText"
}, {
"data": "workPersonName"
}, {
"data": "operationPredict"
}, {
"data": "recordFiles"
}, {
"data": "finishTime"
}, {
"data": "createdAt"
}],
"columnDefs": [{
'targets': 7,
'searchable': false,
'orderable': false,
'className': 'dt-body-center img-zoom-div',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).empty();
$(td).append('<div class="row"></div>');
if (cellData != null) {
cellData.forEach(function (value, index) {
CreateRecordFileBox($(td).children(".row"), value, false);
});
}
}
}],
"language": {
"emptyTable": "查無資料",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
$(row).attr('data-work-type', data.workType);
},
"ajax": {
"url": "/Operation/OperationRecordList",
"type": "POST",
"data": function (d) {
d.PowerStationIds = powerids;
d.WorkType = Type;
d.Status = OperationStatus;
d.Range = $('#date-range').val();
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
hideLoading();
toast_error(rel.data.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
$('#operation_record_table_wrapper').show();
hideLoading();
return data;
}
},
"error": function (xhr, error, thrown) {
hideLoading();
console.log(xhr);
}
});
//#endregion
//#region 切換電站時,載入該電站運維人員
$("#power_station_select_modal").change(function () {
//查詢該電站的運維人員
showLoading();
var url_power_station_operation_personnel = "/PowerStation/GetOperationPersonnelSelectOptionList";
send_data = {
PowerStationId: stationId
}
$.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$("#work_person_select_modal").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
});
if (record != null || record != undefined) {
$("#work_person_select_modal").val(record.workPersonId);
}
}
$("#work_person_select_modal").select2({ dropdownParent: $('#record-form-modal') });
hideLoading();
});
//查詢該電站的廠商
showLoading();
var url_power_station_firm = "/PowerStation/GetFirmSelectOptionList";
$.post(url_power_station_firm, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$("#fix_firm_select_modal").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#fix_firm_select_modal").append($("<option />").val(val.value).text(val.text));
});
}
$("#fix_firm_select_modal").val($("#fix_firm_select_modal option:first").val()).trigger('change');
if (record != undefined && record != null) {
$("#fix_firm_select_modal").val(record.fixFirm)
}
hideLoading();
});
});
//#endregion
//#region 逆變器分析 tab
ChangeInverterDateToday();
if(document.getElementById('InverterResult') != null) {
LoadInvertAnalysisHeatMap();
}
ChangeInverterkwhBarDaily('');
if(document.getElementById('inverter-kWh-convas-div') != null) {
LoadInvertAnalysiskwhBar();
}
//#region 載入電站逆變器資料
showLoading();
var url = "/StationOverview/GetInverterCheckBox";
var send_data = {
id: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$('#CheckInverter').empty();
$.each(rel.data, function (index, val) {
var str = '<div class="col-2 mb-2 custom-control custom-checkbox custom-control-inline">' +
'<input type="checkbox" class="custom-control-input" name="selectedInverter[]" id="check_invert_' + val.value + '" value="' + val.value + '">' +
'<label class="custom-control-label" for="check_invert_' + val.value + '">' + val.name + '</label>' +
'</div>';
$('#CheckInverter').append(str);
});
SelectAllInvert();
hideLoading();
}, 'json');
//#endregion
//#endregion
//#region 維修單運維人員(異常紀錄)
showLoading();
var url_power_station_operation_personnel = "/PowerStation/GetOperationPersonnelSelectOptionList";
send_data = {
PowerStationId: stationId
}
$.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_operation = true;
hideLoading();
toast_error(rel.msg);
return;
}
$("#work_person_select_modal_exc").empty();
if (rel.data.length > 0) {
$.each(rel.data, function (index, val) {
$("#work_person_select_modal_exc").append($("<option />").val(val.value).text(val.text));
});
if (record != null || record != undefined) {
$("#work_person_select_modal_exc").val(record.workPersonId);
}
}
isloadingdone_operation = true;
hideLoading();
});
//#endregion
//#region 異常table
ExceptionTable = $("#Exception_Table").DataTable({
"pageLength": 20,
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
"order": [[2, "desc"]],
"columns": [{
"data": "powerStationName"
}, {
"data": "id"
}, {
"data": "dev_time"
},{
"data": "normalTime"
}, {
"data": "alarmClassName"
}, {
"data": "errDevice"
}, {
"data": "errMsg"
}, {
"data": "function"
}],
"language": {
"emptyTable": "查無資料",
"processing": "處理中...",
"loadingRecords": "載入中...",
"lengthMenu": "顯示 _MENU_ 項結果",
"zeroRecords": "沒有符合的結果",
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
"infoPostFix": "",
"search": "搜尋:",
"paginate": {
"first": "第一頁",
"previous": "上一頁",
"next": "下一頁",
"last": "最後一頁"
},
"aria": {
"sortAscending": ": 升冪排列",
"sortDescending": ": 降冪排列"
}
},
'createdRow': function (row, data, dataIndex) {
$(row).attr('data-id', data.id);
$(row).attr('data-error', data.errorID);
},
"ajax": {
"url": "/StationOverview/GetExceptionTable",
"type": "POST",
"data": function (d) {
d.id = stationId,
d.status = err_status,
d.range = $('#date-range-exception').val()
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
toast_error(rel.data.msg);
return;
}
data = rel.data.data;
if (data == null || data.length == 0) {
this.data = [];
}
$("#Exception_Table_wrapper").show();
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
return data;
}
},
"error": function (xhr, error, thrown) {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
console.log(xhr);
}
});
//#endregion
//歷史第一個table
getTable();
$('#to30day').trigger('click');
GetInverterCard(stationId);
if (typeof (Worker) !== "undefined") {
var worker = new Worker('../js/workers/workers.js');
worker.onmessage = function (event) {
if (event.data == "ok") {
GetInverterCard(stationId);
}
else {
$('.hold-time-change').html(event.data);
}
}
}
});
//#region 變更左邊電站Collapse選單箭頭
function ChangePowerStationCollapse(div) {
var className = $(div).children("i").attr("class");
if (className == "fal fa-angle-left fa-lg py-3") {
$(div).children("i").attr("class", "fal fa-angle-right fa-lg py-3");
}
else {
$(div).children("i").attr("class", "fal fa-angle-left fa-lg py-3");
}
}
//#endregion
function GetPowerStationCollapse(filter) {
showLoading();
var url = "/StationOverview/GetPowerStationCollapse"
var send_data = {
Filter: filter
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.data.msg);
return;
}
$('#js_list_accordion').empty();
if (rel.data.length <= 0) {
$('#js_list_accordion').append("<div>查無結果</div>");
}
var str = "";
$.each(rel.data, function (index, item) {
str += '<div class="card border-top-left-radius-0 border-top-right-radius-0" id="templateCard">' +
'<div class="card-header">' +
'<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-' + index + '" aria-expanded="false" data-filter-tags="settings">' +
'<i class="fal fa-globe width-2 fs-xl"></i>' +
'<span class="city-name">' + item.cityName + '</span>' +
'<span class="ml-auto">' +
'<span class="collapsed-reveal"><i class="fal fa-chevron-up fs-xl"></i></span>' +
'<span class="collapsed-hidden"><i class="fal fa-chevron-down fs-xl"></i></span>' +
'</span>' +
'</a>' +
'</div>' +
'<div id="js_list_accordion-' + index + '" class="collapse" data-parent="#js_list_accordion" style="">' +
'<div class="card-body">' +
'<ul class="list-group">';
$.each(item.myPowerStations, function (index, power_station) {
str += '<li class="list-group-item">' +
'<a href="/StationOverview/Info?stationId=' + power_station.powerStationId + '">' + power_station.powerStationName + '</a>' +
'</li>';
});
str += '</ul>';
str += '</div>';
str += '</div>';
});
$('#js_list_accordion').append(str);
$('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0");
hideLoading();
}, 'json');
}
//#region 產生檔案html
function CreateRecordFileBox(dom, value, show_del_btn) {
var str = "";
str += '<div class="col-2 px-0 py-2 mx-2">';
var split = value.fileName.split(".");
var excel_format = ["xls", "xlsx"];
var word_format = ["doc", "docx"];
if (split[split.length - 1].toLowerCase() == "pdf") {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-pdf" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else if (excel_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-excel" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else if (word_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-word" style="font-size: 1.5em; line-height: 2;"></i></a>';
} else {
str += '<img src="' + value.fileName + '" class="img-zoom" width="100%" />';
}
if (show_del_btn) {
str += '<a href="javascript:;" class="del-operation-record-file-btn" data-id="' + value.id + '">';
str += '<span class="badge border border-light rounded-pill bg-danger-500 position-absolute pos-top pos-right"><i class="fal fa-times"></i></span>';
str += '</a>';
}
str += '</div>';
dom.append(str);
}
//#endregion
//#region 刪除檔案
$('#record_files_div').on("click", "a.del-operation-record-file-btn", function () {
var selectedFileId = $(this).attr("data-id");
var div = $(this).parents(".col-auto");
Swal.fire({
title: "刪除",
text: "你確定是否刪除此筆資料?",
type: "warning",
icon: 'warning',
showCancelButton: true,
confirmButtonText: "是",
cancelButtonText: "否"
}).then(function (result) {
if (result.value) {
var url = "/Operation/DeleteOperationRecordFile";
var send_data = {
ReocdeId: selected_id,
SelectedId: selectedFileId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
operationRecordTable.ajax.reload();
toast_ok(rel.msg);
div.remove();
}, 'json');
}
});
});
//#endregion
//#region 異常
//#region 改變日期(異常)
$('#date-range-exception').on('change', function () {
showLoading();
ExceptionTable.ajax.reload();
});
//#endregion
//#region 匯出excel(異常)
function ExportExcelToExc() {
//showLoading();
$("#exportBtn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var url = "/StationOverview/GetExceptionTable";
var send_data = {
id: stationId,
status: err_status,
range: $('#date-range-exception').val()
};
$.post(url, send_data, function (rel) {
if (rel.data.code != "0000") {
//hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
toast_error(rel.data.msg);
return;
}
$('#NOSEEBODY').empty();
var powerStationName = powerStationData.name.trim();
var range_str_arr = $('#date-range-exception').val().replace(/\//g, "").split('-');
var str = "";
rel.data.data.forEach(function (value, index) {
str += "<tr>" +
"<td>" + value.powerStationName + "</td>" +
"<td>" + value.id + "</td>" +
"<td>" + value.dev_time + "</td>" +
"<td>" + value.normalTime + "</td>" +
"<td>" + value.alarmClassName + "</td>" +
"<td>" + value.errDevice + "</td>" +
"<td>" + value.errMsg + "</td>";
});
$('#NOSEEBODY').append(str);
$("#NOSEE").table2excel({
// 匯出的Excel文件的名稱
name: "檔案",
// Excel檔案的名稱
filename: "異常記錄-" + powerStationName + "_" + range_str_arr[0].trim() + '_' + range_str_arr[1].trim(),
//檔案字尾名
fileext: ".xls",
});
//hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
}, 'json');
}
//#endregion
//#region 編輯異常表單內容(異常)
$('#Exception_Table').on("click", "a.edit-btn", function () {
$("#exception-form-modal .modal-title .main-title").html("維修單 - ");
selected_id = $(this).parents('tr').attr('data-id');
errortoID = $(this).parents('tr').attr('data-error');
//取得單一記錄表單
showLoading();
var url = "/Operation/GetOneOperationRecord/";
var send_data = {
id: errortoID
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
record = rel.data;
countOperationRecordFile = record.recordFiles.length;
$("#exception-form-modal .modal-title .sub-title").html(powerStationData.name);
$("#power_station_select_modal_exc").val(powerStationData.name);
$("#power_station_select_modal_exc").attr("disabled", true);
$("#work_time_modal").val(record.workTime);
var status = -1;
if (record.status == 0 || record.status == 2) {
status = 0;
} else if (record.status == 1 || record.status == 3) {
status = 1;
}
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal_exc').val(record.workPersonId);
$(".fix-div").show();
$("#error_code_modal_exc").val(record.errorCode);
$("#error_code_modal_exc").attr("disabled", true);
$("#fix_do_modal_exc").val(record.fixDo);
$("#notice_textarea_modal_exc").val(record.notice);
$("#description_textarea_modal_exc").val(record.description);
var str = "";
RecordFileBox = $("#record_files_div_exc > .row");
RecordFileBox.empty();
record.recordFiles.forEach(function (value, index) {
CreateRecordFileBox(RecordFileBox, value, true);
});
$("#exception-form-modal").modal();
hideLoading();
}, 'json');
});
//#endregion
//#region 派工新增表單(異常)
$('#Exception_Table').on("click", "a.add-btn", function () {
$("#exception-form-modal .modal-title .main-title").html("維修單 - ");
$("#exception-form-modal .modal-title .sub-title").html(powerStationData.name);
$("#record-form-exc").trigger("reset");
$("#power_station_select_modal_exc").val(powerStationData.name);
$("#power_station_select_modal_exc").attr("disabled", true);
selected_id = $(this).parents('tr').attr('data-id');
errortoID = $(this).parents('tr').attr('data-error');
$("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態
$("#error_code_modal_exc").val(selected_id);
$("#error_code_modal_exc").attr("disabled", true);
$("#exception-form-modal").modal();
});
//#endregion
//#region 查詢近30天(異常)
function ChangeDate30exception() {
$("#Exception_Table_wrapper").hide();
$("#to30day").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker_exception.data('daterangepicker').setStartDate(dateLimit_format);
datepicker_exception.data('daterangepicker').setEndDate(today_format);
$('#date-range-exception').val(dateLimit_format + ' - ' + today_format);
$('#date-range-exception').trigger('change');
}
//#endregion
//#region 儲存表單資料(異常)
function SaveException() {
if ($("#record-form-exc").valid()) {
showLoading();
var url = "/Operation/SaveOperationRecord";
var formData = new FormData();
formData.append("Id", errortoID);
formData.append("PowerStationId", stationId);
formData.append("WorkType", 2);
formData.append("ErrorCode", $("#error_code_modal_exc").val());
formData.append("FixDo", $("#fix_do_modal_exc").val());
formData.append("Status", $("input[name=status_modal]:checked").val());
formData.append("WorkPersonId", $("#work_person_select_modal_exc").val());
formData.append("WorkTime", $("#work_time_modal_exc").val());
formData.append("Notice", $("#notice_textarea_modal_exc").val());
formData.append("Description", $("#description_textarea_modal_exc").val());
$.ajax({
type: "POST",
url: url,
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
var myDropzone = Dropzone.forElement("#record-file-form_exc");
if (myDropzone.files.length > 0) {
selected_id = rel.data;
myDropzone.processQueue();
myDropzone.on("successmultiple", function (file, rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
$('#exception-form-modal').modal('hide');
recordFileDropzone.removeAllFiles();
ExceptionTable.ajax.reload();
});
} else {
$('#exception-form-modal').modal('hide');
myDropzone.removeAllFiles();
ExceptionTable.ajax.reload();
}
hideLoading();
}
});
}
}
//#endregion
//#region 表單檔案資料(異常)
Dropzone.autoDiscover = false;
recordFileDropzone = new Dropzone("#record-file-form_exc", {
url: "/Operation/SaveOperationRecordFile",
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
autoProcessQueue: false,
parallelUploads: 5,
maxFiles: 5,
addRemoveLinks: true,
uploadMultiple: true,
dictRemoveFile: "移除",
init: function (e) {
var myDropzone = this;
myDropzone.on("sending", function (file, xhr, data) {
if ((countOperationRecordFile + myDropzone.files.length) > 5) {
toast_warning("檔案總數量不可超過 5 張");
myDropzone.removeFile(file);
return;
} else {
data.append("Id", selected_id);
data.append("RecordFiles", file);
}
});
}
});
//#endregion
//#region 改變異常紀錄狀態
function ChangeStatus(type) {
$("#Exception_Table_wrapper").hide();
err_status = type;
var name;
var name2;
if (type == 0) {
$("#errbutton0").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "0";
name2 = "errbutton" + "1";
} else {
$("#errbutton1").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "1";
name2 = "errbutton" + "0";
}
document.getElementById(name).setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById(name2).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
ExceptionTable.ajax.reload();
}
//#endregion
//#endregion
//#region 運維
//#region 編輯表單內容(運維)
$('#operation_record_table').on("click", "a.edit-btn", function () {
work_type = $(this).parents('tr').attr('data-work-type');
if (work_type == 0) {
$("#record-form-modal .modal-title .main-title").html("清洗單 - ");
} else if (work_type == 1) {
$("#record-form-modal .modal-title .main-title").html("巡檢單 - ");
} else {
$("#record-form-modal .modal-title .main-title").html("維修單 - ");
}
selected_id = $(this).parents('tr').attr('data-id');
//取得單一記錄表單
showLoading();
var url = "/Operation/GetOneOperationRecord/";
var send_data = {
id: selected_id
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
record = rel.data;
countOperationRecordFile = record.recordFiles.length;
$("#record-form-modal .modal-title .sub-title").html(record.powerStationName);
$("#power_station_select_modal").val(record.powerStationId);
$("#power_station_select_modal").attr("disabled", true);
$("#work_time_modal").val(record.workTime);
var status = -1;
if (record.status == 0 || record.status == 2) {
status = 0;
} else if (record.status == 1 || record.status == 3) {
status = 1;
}
$("input[name=status_modal_opRecord][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal').val(record.workPersonIds).trigger("change");
if (work_type != 2) {
$(".fix-div").hide();
} else {
$(".fix-div").show();
$("#error_code_modal").val(record.errorCode);
$("#fix_do_modal").val(record.fixDo);
}
$("#fix_firm_select_modal").val(record.fixFirm).trigger("change");
$("#notice_textarea_modal").val(record.notice);
$("#description_textarea_modal").val(record.description);
var str = "";
RecordFileBox = $("#record_files_div > .row");
RecordFileBox.empty();
record.recordFiles.forEach(function (value, index) {
CreateRecordFileBox(RecordFileBox, value, true);
});
$("#EmailcheckBox").prop("checked", false);
$("#record-form-modal").modal();
hideLoading();
}, 'json');
});
//#endregion
//#region 表單驗證
$("#record-form").validate({
rules: {
work_time_modal: {
required: true
}
},
});
//#endregion
//#region 表單檔案資料(運維)
Dropzone.autoDiscover = false;
recordFileDropzone = new Dropzone("#record-file-form", {
url: "/Operation/SaveOperationRecordFile",
acceptedFiles: "image/*, application/pdf,.doc,.docx,.xls,.xlsx",
autoProcessQueue: false,
parallelUploads: 5,
maxFiles: 5,
addRemoveLinks: true,
uploadMultiple: true,
dictRemoveFile: "移除",
init: function (e) {
var myDropzone = this;
myDropzone.on("sending", function (file, xhr, data) {
if ((countOperationRecordFile + myDropzone.files.length) > 5) {
toast_warning("檔案總數量不可超過 5 張");
myDropzone.removeFile(file);
return;
} else {
data.append("Id", selected_id);
data.append("RecordFiles", file);
}
});
}
});
//#endregion
//#region 查詢近30天(運維)
function ChangeDate30() {
$('#operation_record_table_wrapper').hide();
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker_record.data('daterangepicker').setStartDate(dateLimit_format);
datepicker_record.data('daterangepicker').setEndDate(today_format);
$('#date-range-record').val(dateLimit_format + ' - ' + today_format);
$('#date-range-record').trigger('change');
}
//#endregion
$('#work_person_select_modal').change(function () {
if ($('#work_person_select_modal').val().length == 0) {
$('#work_person_select_modal-error').show();
} else {
$('#work_person_select_modal-error').hide();
}
});
$('#work_time_modal').change(function () {
$("#work_time_modal-error").hide();
});
//#region 儲存表單資料(運維)
function SaveRecord() {
if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "")
{
if ($("#record-form").valid()) {
// 鎖定按鈕
$("#save-record-op-btn").attr('disabled', true);
showLoading();
var url = "/Operation/SaveOperationRecord";
var formData = new FormData();
formData.append("Id", selected_id);
formData.append("PowerStationId", $("#power_station_select_modal").val());
formData.append("WorkType", selected_work_type);
formData.append("ErrorCode", $("#error_code_modal").val());
formData.append("FixDo", $("#fix_do_modal").val());
formData.append("FixFirm", $("#fix_firm_select_modal").val());
formData.append("Status", $("input[name=status_modal_opRecord]:checked").val());
$("#work_person_select_modal").val().forEach(function (item) {
formData.append("WorkPersonIds", parseInt(item));
});
formData.append("WorkTime", $("#work_time_modal").val());
formData.append("Notice", $("#notice_textarea_modal").val());
formData.append("Description", $("#description_textarea_modal").val());
if (document.querySelector('[id=EmailcheckBox]:checked')) {
formData.append("Emailcheck", 1);
}
else {
formData.append("Emailcheck", 0);
}
$.ajax({
type: "POST",
url: url,
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
var myDropzone = Dropzone.forElement("#record-file-form");
if (myDropzone.files.length > 0) {
selected_id = rel.data;
myDropzone.processQueue();
myDropzone.on("successmultiple", function (file, rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);
$('#record-form-modal').modal('hide');
recordFileDropzone.removeAllFiles();
operationRecordTable.ajax.reload();
});
} else {
$('#record-form-modal').modal('hide');
myDropzone.removeAllFiles();
operationRecordTable.ajax.reload();
}
toast_ok("修改完成");
// 取消鎖定按鈕
$("#save-record-op-btn").attr('disabled', false);
hideLoading();
}
});
}
}
else {
if ($('#work_person_select_modal').val().length == 0) {
$('#work_person_select_modal-error').show();
}
if ($("#work_time_modal").val() == "") {
$("#work_time_modal-error").show();
}
}
}
//#endregion
//#region 點擊圖片放大(運維)
$('#operation_record_table').on("click", "img.img-zoom", function () {
var _this = $(this);//將當前的pimg元素作為_this傳入函式
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
});
//#endregion
//#region 匯出excel(運維)
function ExportExcel() {
showLoading();
var url = "/Operation/ExportOperationRecordExcel";
var send_data = {
WorkType: Type,
PowerStationIds: powerids
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$('#NoViewbody').empty();
var powerStationName = powerStationData.name.trim();
var range_str_arr = $('#date-range-exception').val().replace(/\//g, "").split('-');
var str = "";
rel.data.forEach(function (value, index) {
str += "<tr>" +
"<td>" + value.powerStationName + "</td>" +
"<td>" + value.formId + "</td>" +
"<td>" + value.workTypeText + "</td>" +
"<td>" + value.fixDo + "</td>" +
"<td>" + value.statusText + "</td>" +
"<td>" + value.workPersonName + "</td>" +
"<td>" + value.operationPredict + "</td>";
str += "<td>";
if (value.hyperLinks != undefined || value.hyperLinks != null) {
value.hyperLinks.forEach(function (value2, index) {
str += value2 + "<br>";
});
}
str += "</td>";
str += "<td>";
if (value.finishTime != undefined && value.finishTime != null & value.finishTime != "") {
str += value.finishTime;
} else {
str += "";
}
str += "</td>";
str += "</tr>";
});
$('#NoViewbody').append(str);
$("#NoView").table2excel({
// 匯出的Excel文件的名稱
name: "abc",
// Excel檔案的名稱
filename: "運維紀錄-" + powerStationName,
//檔案字尾名
fileext: ".xls",
});
hideLoading();
}, 'json');
}
//#endregion
//#region 改變日期(運維)
$('#date-range-record').on('change', function () {
operationRecordTable.ajax.reload();
});
//#endregion
//#region 改狀態
function CheckStatus(type, e) {
$('#operation_record_table_wrapper').hide();
OperationStatus = type;
if ($(".status-type").hasClass("btn-success")) {
$(".status-type").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
//if (OperationStatus == 2) {
// operationRecordTable.column(10).visible(true);
//}
//else {
// operationRecordTable.column(10).visible(false);
//}
operationRecordTable.ajax.reload();
}
//#endregion
//#region 改變項目(運維)
function ChangeType(type) {
$('#operation_record_table_wrapper').hide();
Type = type;
for (var i = 0; i < 4; i++) {
var name = "button" + i;
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
operationRecordTable.ajax.reload();
}
//#endregion
//#endregion
//#region 設定電站基本資料
function SetStationInfo() {
$("#select_solar_tpye").val(powerStationData.solarType);
$("#select_solar_tpye").attr("disabled", true);
//#region 電站基本資料 文字
$("#city_name_text").html(powerStationData.cityName);
$("#area_name_text").html(powerStationData.areaName);
$("#address_detail_text").html(powerStationData.address);
$("#power_station_code_text").html(powerStationData.code);
$("#power_station_name_text").html(powerStationData.name);
$("#escrow_name_text").html(powerStationData.escrowName);
$("#created_by_text").html(powerStationData.creatorName);
$("#generating_capacity_text").html(toThousands(powerStationData.generatingCapacity.toFixed(3)));
$("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime);
$("#coordinate_text").html(powerStationData.coordinate);
$("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds).trigger("change");
$("#power_station_operation_personnel").attr("disabled", true);
$("#line_token_text").html(powerStationData.line_token);
$("#estimate_kwh_text").html(toThousands(powerStationData.estimate_kwh));
$("#estimate_efficacy_text").html(toThousands(powerStationData.estimateEfficacy));
$("#created_at_text").html(powerStationData.createdAt);
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
{
<text>
$("#select_power_station_company_title").show();
$("#select_power_station_company").show();
$("#select_power_station_company").attr("disabled", true);
$("#select_power_station_company").val(powerStationData.companyId).trigger("change");
</text>
}
else
{
<text>
$("#select_power_station_company_title").hide();
$("#select_power_station_company").hide();
$("#select_power_station_company").attr("disabled", true);
$("#select_power_station_company").val(powerStationData.companyId).trigger("change");
</text>
}
//光電板
$("#photovoltaic_panel_brand_text").html(powerStationData.photovoltaicPanelBrand);
$("#photovoltaic_panel_product_model_text").html(powerStationData.photovoltaicPanelProductModel);
$("#photovoltaic_panel_specification_text").html(powerStationData.photovoltaicPanelSpecification);
$("#photovoltaic_panel_amount_text").html(toThousands(powerStationData.photovoltaicPanelAmount));
//#endregion
//#region 電站基本資料 input
$("#check_escrow").attr("checked", powerStationData.isEscrow == 1 ? true : false);
$("#check_escrow_label").html(powerStationData.isEscrow == 1 ? "Yes" : "No");
//#endregion
}
//#endregion
//#region 設定能源局與台電資料
function SetBoETPCInfo() {
$("#link-boe-file").html(powerStationData.boEFileName).attr("href", powerStationData.boEFile);
@*$("#BoE_discount_rate_text").html(powerStationData.boEDiscountRate);*@
$("#BoE_register_post_at_text").html(powerStationData.boERegisterPostAt);
$("#BoE_device_register_number_text").html(powerStationData.boEDeviceRegisterNumber);
@*$("#BoE_rent_ratio_text").html(powerStationData.boERentRatio);*@
$("#TPC_contract_number_text").html(powerStationData.tpcContractNumber);
$("#TPC_contract_at_text").html(powerStationData.tpcContractAt);
$("#TPC_sell_deadline_text").html(powerStationData.tpcSellDeadline);
$("#electricity_meter_at_text").html(powerStationData.electricityMeterAt);
$("#power_rate_text").html(powerStationData.powerRate);
$("#TPC_meter_reading_text").html(powerStationData.tpcMeterReading);
$("#TPC_purchase_electricity_at_text").html(powerStationData.tpcPurchaseElectricityAt);
$("#TPC_sell_electricity_at_text").html(powerStationData.tpcSellElectricityAt);
$("#TPC_invoice_buyer_text").html(powerStationData.tpcInvoiceBuyer);
$("#GUI_number_text").html(powerStationData.guiNumber);
$("#TPC_invoice_address_text").html(powerStationData.tpcInvoiceAddress);
$("#TPC_meter_number_text").html(powerStationData.tpcMeterNumber);
$("#BOE_TPC_created_by_text").html(powerStationData.creatorName);
$("#BOE_TPC_created_at_text").html(powerStationData.createdAt);
}
//#endregion
//#region 設定土地與房屋資料
function SetLandBuildingInfo() {
var landBuildingCard = $("#land_buildingPart");
landBuildingCard.empty();
powerStationData.landBuildings.forEach(function (value, index) {
CreateLandBuildingCard(landBuildingCard, value);
});
}
//#endregion
//#region 創建每份土地房屋資訊卡片
function CreateLandBuildingCard(dom, value) {
//資料重整
value.address = value.address ? value.address : '';
value.coordinate = value.coordinate ? value.coordinate : '';
value.leaseNotarizationAt = value.leaseNotarizationAt ? value.leaseNotarizationAt : '';
value.leaseRate = value.leaseRate ? value.leaseRate : 0;
value.landowner = value.landowner ? value.landowner : '';
value.phone = value.phone ? value.phone : '';
value.purpose = value.purpose ? value.purpose : '';
var appendStr = "";
appendStr += '<div class="card border mb-g w-100" data-land-building-id="' + value.id + '">' +
'<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap justify-content-between">' +
'<div class="card-title font-weight-bold">土地房屋資料</div>' +
'</div>';
appendStr += '<div class="card-body">' +
'<div class="row d-flex justify-content-between card-land-building" data-id="' + value.id + '">' +
'<div class="col-xl">' +
'<div class="row mb-3">' +
'<label class="col-xl-4 form-label">地址</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_address_text_' + value.id + '" class="color-info-600">' + value.address + '</label>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<label class="col-xl-4 form-label">租金比例 (%)</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_lease_Rate_text_' + value.id + '" class="color-info-600">' + value.leaseRate + '</label>' +
'</div>' +
'</div>' +
@*'<div class="row">' +
'<label class="col-xl-4 form-label">經緯度</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_coordinate_text_' + value.id + '" class="color-info-600">' + value.coordinate + '</label>' +
'</div>' +
'</div>' +*@
'</div>' +
'<div class="col-xl">' +
'<div class="row mb-3">' +
'<label class="col-xl-4 form-label">租約公證日期</label>' +
'<div class="col-xl-8">' +
'<label id="lease_notarization_at_text_' + value.id + '" class="color-info-600">' + value.leaseNotarizationAt + '</label>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="col-xl">' +
'<div class="row mb-3">' +
'<label class="col-xl-4 form-label">出租人</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_landowner_text_' + value.id + '" class="color-info-600">' + value.landowner + '</label>' +
'</div>' +
'</div>' +
@*'<div class="row">' +
'<label class="col-xl-4 form-label">電話</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_phone_text_' + value.id + '" class="color-info-600">' + value.phone + '</label>' +
'</div>' +
'</div>' +*@
'</div>' +
'<div class="col-xl">' +
@*'<div class="row mb-3">' +
'<label class="col-xl-4 form-label">房屋用途</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_purpose_text_' + value.id + '" class="color-info-600">' + value.purpose + '</label>' +
'</div>' +
'</div>' +*@
'</div>' +
'<div class="col-xl">' +
'<div class="row mb-3">' +
'<label class="col-xl-4 form-label">資料建立</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_created_by_text_' + value.id + '" class="color-info-600">' + value.creatorName + '</label>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<label class="col-xl-4 form-label">建立時間</label>' +
'<div class="col-xl-8">' +
'<label id="land_building_created_at_text_' + value.id + '" class="color-info-600">' + value.createdAt + '</label>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
dom.append(appendStr);
}
//#endregion
//#region 創建單線圖box
function CreatePowerStationSingleLineBox(dom, value) {
var str = '<div class="col-xl" style="max-width: 20%;">' +
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
'<img src="' + value.image + '" class="card-img-top img-zoom" alt="...">' +
'</div>' +
'</div>';
dom.append(str);
}
//#endregion
//#region 創建電站圖片box
function CreatePowerStationImagecarousel(dom, value, index) {
var indicators = '<li data-target="#carouselExampleIndicators" data-slide-to="' + index + '"></li>'
var carousel_item = '<div class="carousel-item">' +
'<img class="d-block w-100" src="' + value.image + '">' +
'</div>'
dom.find(".carousel-indicators").append(indicators);
dom.find(".carousel-inner").append(carousel_item);
}
//#endregion
//#region 全選逆變器
function SelectAllInvert() {
$("input[name='selectedInverter[]']").prop('checked', true)
}
//#endregion
//#region 變更逆變器選擇日期(今日)
function ChangeInverterDateToday() {
var today = new Date().toISOString().substring(0, 10);
$('#inverter-selected-heatmap-date').val(today);
}
//#endregion
//#region 變更逆變器選擇日期(昨日)
function ChangeInverterDateYesterday() {
var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().substring(0, 10);
$('#inverter-selected-heatmap-date').val(yesterday);
}
//#endregion
//#region 載入逆便器分析HeatMap資料
function LoadInvertAnalysisHeatMap() {
$('#InverterResult').attr("style", "display:none !important;");
var checkInverts = $("input[name='selectedInvert[]']:checked").map(function () {
return $(this).val();
}).get();
//#region HeatMap
showLoading();
var url = "/StationOverview/GetInverterHeatMapAnalysis";
var send_data = {
PowerStationId: stationId,
SelectedDate: $("#inverter-selected-heatmap-date").val()
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
HeatMap = rel.data;
HeapMapXAxis = HeatMap.xAxis
myseries = Object.keys(HeatMap.series).map(function (key) {
var ser = {
name: key,
//borderWidth: 1,
data: HeatMap.series[key],
showInLegend: true
}
return ser;
});
Highcharts.chart('container', {
chart: {
type: 'heatmap',
height: 600
},
accessibility: {
enabled: false
},
title: {
text: '各逆變器當日日均發電度數'
},
xAxis: {
categories: HeatMap.xAxis,
labels: {
step: 1,
formatter: function () {
var aa = this.value.substr(-2);
if (aa == "00") {
return '<span>' + this.value + '</span>';
} else {
return '<span style="display:none">' + this.value + '</span>';
}
}
}
},
yAxis: {
categories: HeatMap.yAxis,
title: { text: "逆變器編號" },
},
colorAxis: {
min: 0,
max: 1,
minColor: '#0000FF',
maxColor: '#FF0000',
stops: [
[0, '#0000FF'],
[0.5, '#ebb434'],
[1, '#FF0000']
],
},
@*legend: {
align: 'right',
layout: 'vertical',
verticalAlign: 'top',
},*@
tooltip: {
formatter: function () {
return '<b>' + getPointCategoryName(this.point, 'y') + '</b><br>' +
'<span>' + getPointCategoryName(this.point, 'x') + '</span><br>' +
'<b style = "color:rgb(103, 180, 172);" >' + this.point.value + '</b>';
}
},
series: myseries,
});
$('#InverterResult').removeAttr("style", "display:none !important;");
hideLoading();
}, 'json');
//#endregion
}
//#endregion
function getPointCategoryName(point, dimension) {
var series = point.series,
isY = dimension === 'y',
axis = series[isY ? 'yAxis' : 'xAxis'];
if (!isY) {
axis.categories = HeapMapXAxis;
}
return axis.categories[point[isY ? 'y' : 'x']];
}
function ChangeInverterkwhBarDaily(e) {
if ($(".btn-change-inverter-kwhbar").hasClass("btn-success")) {
$(".btn-change-inverter-kwhbar").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
selectInverterkwhBarType = 0;
$('#inverter-selected-kwhbar-date').prop('type', 'date');
var today = new Date().toISOString().substring(0, 10);
$('#inverter-selected-kwhbar-date').val(today).trigger('change');
$('#inverter-selected-kwhbar-quaryerly').hide().val(0);
}
function ChangeInverterkwhBarMonthly(e) {
if ($(".btn-change-inverter-kwhbar").hasClass("btn-success")) {
$(".btn-change-inverter-kwhbar").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
selectInverterkwhBarType = 1;
$('#inverter-selected-kwhbar-date').prop('type', 'month');
var now_month = new Date().toISOString().substring(0, 7);
$('#inverter-selected-kwhbar-date').val(now_month).trigger('change');
$('#inverter-selected-kwhbar-quaryerly').hide().val(0).trigger('change');
}
function ChangeInverterkwhBarQuaryerly(e) {
if ($(".btn-change-inverter-kwhbar").hasClass("btn-success")) {
$(".btn-change-inverter-kwhbar").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
selectInverterkwhBarType = 2;
var now_year = new Date().toISOString().substring(0, 4);
$('#inverter-selected-kwhbar-date').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
$('#inverter-selected-kwhbar-date').val(now_year);
$('#inverter-selected-kwhbar-quaryerly').show().val(0);
}
function ChangeInverterkwhBarAnnual(e) {
if ($(".btn-change-inverter-kwhbar").hasClass("btn-success")) {
$(".btn-change-inverter-kwhbar").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
selectInverterkwhBarType = 3;
var now_year = new Date().toISOString().substring(0, 4);
$('#inverter-selected-kwhbar-date').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
$('#inverter-selected-kwhbar-date').val(now_year);
$('#inverter-selected-kwhbar-quaryerly').hide().val(0).trigger('change');
}
function LoadInvertAnalysiskwhBar() {
$('#inverter-kWh-convas-div').hide();
var url = "/StationOverview/GetInverterkwhBarAnalysis";
showLoading();
var send_data = {
PowerStationId: stationId,
SelectedType: selectInverterkwhBarType,
SelectedDate: $("#inverter-selected-kwhbar-date").val(),
SelectedQuaryerly: $('#inverter-selected-kwhbar-quaryerly').val()
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_inverter = true;
hideLoading();
toast_error(rel.msg);
return;
}
kwhBar = rel.data;
var bgColorlist = [];
for (let i = 0; i < Object.keys(kwhBar.datasets).length; i++) {
var bgColorlist = bgColorlist.concat(rgba(0.4));
}
mydatasets = Object.keys(kwhBar.datasets).map(function (key, index) {
var dataset = {
label: key,
borderWidth: 1,
data: kwhBar.datasets[key],
backgroundColor: bgColorlist[index],
}
return dataset;
});
$('#inverter-kWh-convas-div').empty();
$('#inverter-kWh-convas-div').append('<canvas id="inverter-kWh"></canvas>');
var ctx_inverter_kWh = document.getElementById('inverter-kWh').getContext('2d');
var myInverterkwh = new Chart(ctx_inverter_kWh, {
type: 'bar',
data: {
labels: kwhBar.labels,
datasets: mydatasets
},
options: {
title: {
display: true,
text: '逆變器發電量'
},
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: '發電量(kWh)'
}
}]
}
},
});
//#endregion
$('#inverter-kWh-convas-div').show();
isloadingdone_inverter = true;
hideLoading();
}, 'json');
}
//rgb颜色随机
function rgba(a) {
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
var rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
return rgba;
}
//#region 歷史
//#region 改選擇族群(日 月 年 歷年)
function ChangeGroup(type) {
for (var i = 0; i <= 3; i++)
{
document.getElementById("Group" + i).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("Group" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
document.getElementById("Historybtn").style.display = "";//隱藏
switch (type)
{
case 0:
document.getElementById("Today").style.display = "";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
//document.getElementById("DateGet").style.display = "";//隱藏
document.getElementById("date-range-history").style.display = "";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
var today = new Date();
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(today_format);
//historyRange = $('#DateGet').val();
$('#date-range-history').val(today_format + ' - ' + today_format);
historyRange = $('#date-range-history').val();
groupType = type;
getTable();
break;
case 1:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
//document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("date-range-history").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
var today = new Date();
var today_format = today.toISOString().slice(0, 7).replace(/-/g, "-");
$('#MonthGet').val(today_format);
groupType = type;
historyRange = $('#MonthGet').val();
getTable();
break;
case 2:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "";//隱藏
//document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("date-range-history").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "";//隱藏
var today = new Date();
var today_format = today.toISOString().slice(0, 4).replace(/-/g, "-");
$('#YearGet').val(today_format);
groupType = type;
historyRange = $('#YearGet').val();
getTable();
break;
case 3:
document.getElementById("Today").style.display = "none";//隱藏
document.getElementById("ToMonth").style.display = "none";//隱藏
document.getElementById("ToYear").style.display = "none";//隱藏
//document.getElementById("DateGet").style.display = "none";//隱藏
document.getElementById("date-range-history").style.display = "none";//隱藏
document.getElementById("MonthGet").style.display = "none";//隱藏
document.getElementById("YearGet").style.display = "none";//隱藏
document.getElementById("Historybtn").style.display = "none";//隱藏
groupType = type;
historyRange = '';
getTable();
break;
default:
console.log('壞掉了');
}
}
//#endregion
//#region 選擇今昨日
function getday(post)
{
if (post == 0) { //今天
var today = new Date();
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
{ // 昨天
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 1));
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();
}
//#endregion
//#region 選擇這上個月
function getmonth(post) {
if (post == 0) {
var today = new Date();
var today_format = today.toISOString().slice(0, 7).replace(/-/g, "-");
$('#MonthGet').val(today_format);
}
else {
var today = new Date();
today.setMonth(new Date().getMonth() - 1);
var dateLimit_format = today.toISOString().slice(0, 7).replace(/-/g, "-");
$('#MonthGet').val(dateLimit_format);
}
historyRange = $('#MonthGet').val();
getTable();
}
//#endregion
//#region 選擇今去年
function getyear(post) {
if (post == 0) {
var today = new Date();
var today_format = today.toISOString().slice(0, 4).replace(/-/g, "-");
$('#YearGet').val(today_format);
}
else {
var today = new Date();
today.setFullYear(new Date().getFullYear() - 1);
var dateLimit_format = today.toISOString().slice(0, 4).replace(/-/g, "-");
$('#YearGet').val(dateLimit_format);
}
historyRange = $('#YearGet').val();
getTable();
}
//#endregion
//console.log("date-range-history = " + $('#date-range-history').val());
function Historyclick() {
switch (groupType) {
case 0:
timeAll = $('#date-range-history').val().split('~');
time1 = timeAll[0].trim();
time2 = timeAll[1].trim();
historyRange = time1 + ' - ' + time2;
//alert("historyRange = " + historyRange);
if (time1 != time2) {
groupType = 4; // 採用 月報格式
// alert("groupType = " + groupType);
}
break;
case 1: historyRange = $('#MonthGet').val(); break;
case 2: historyRange = $('#YearGet').val(); break;
case 4: timeAll = $('#date-range-history').val().split('~');
time1 = timeAll[0].trim();
time2 = timeAll[1].trim();
historyRange = time1 + ' - ' + time2;
if (time1 == time2){
groupType = 0;
}
break;
}
getTable();
}
//$('#DateGet').on('change', function () {
// console.log(" in onChange event");
// historyRange = $('#DateGet').val();
// getTable();
//});
//$('#MonthGet').on('change', function () {
// historyRange = $('#MonthGet').val();
// getTable();
//});
//$('#YearGet').on('change', function () {
// historyRange = $('#YearGet').val();
// getTable();
//});
function getTable()
{
$('#all').hide();
if (historyRange == "")
{
var today = new Date();
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
//$('#DateGet').val(today_format);
//historyRange = $('#DateGet').val();
$('#date-range-history').val(today_format + ' - ' + today_format);
historyRange = $('#date-range-history').val();
}
var send_data = {
GroupType: groupType,
HistoryRange: historyRange,
PowerstationId: stationId
}
//0:日 1:月 2:年 3:歷年 4:dateRange 選擇不同天(採用月的方式顯示)
showLoading();
var Nurl = "/StationOverview/GetTotalTableToHistory";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_history = true;
hideLoading();
toast_error(rel.msg);
return;
}
$('#HistoryTotalTable').empty();
$('#HistoryDetailTable').empty();
var TimestampALL;
var kwhALL = 0;
var diffSOLARHOURALL = 0;
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);
var listcolor = new Array(0);
var listcolor2 = new Array(0);
var listirradiance = new Array(0);
var listtemperature = new Array(0);
var listsolarhour = new Array(0);
var listpr = new Array(0);
var color = rgba(1);
var color2 = rgba(2);
var listkwhkwp = new Array(0);
var times = 1;
var ALLkwhkwp = 0;
var kwhkwp = 0;
var ALLDays = 0;
var ALLavgdaykwh = 0;
$.each(rel.data, function (index, val) {
// console.log('回傳 = ' + val);
TimestampALL = val.totaltime;
kwhALL += val.kwh;
//diffSOLARHOURALL += val.diffSOLARHOUR;
irradianceALL += val.irradiance;
irr_day = val.irrDay;
avgIrr_day += val.irrDay; // 累計日照
pr = val.pr;
avgPR += val.pr;
//rowCT++;
//console.log('avgPR = ' + avgPR) + ' rowCT = ' + rowCT;;
//if (typeof (val) == 'object') {
//if (val && typeof (val) != "undefined") {
// alert('val.PR = ' + val.pr);
// avgPR += val.pr;
// rowCT++;
//}
tempALL += val.temp;
//暫時先執行到這--->取kwhkwp
var nowDisplayIrrDay = 0;
var avgdaykwh = 0;
if (val.length != 0) {
if (groupType != 6) {
if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) {
kwhkwp = val.kwhkwp.toFixed(2);
}
if (groupType != 0 && groupType != 3) {
ALLkwhkwp += val.kwhkwp;
kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++;
}
if (groupType == 0) {
nowDisplayIrrDay = val.irrDayHour.toFixed(2);
}
else {
nowDisplayIrrDay = val.irrDay.toFixed(2);
}
if (groupType == 3)
{
ALLDays += val.days;
avgdaykwh = (val.kwh / val.generatingCapacity / val.days);
ALLavgdaykwh += avgdaykwh;
}
else
{
avgdaykwh = val.kwhkwp;
}
// console.log(val);
diffSOLARHOURALL = val.solarhour;
$('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' +
'<td>' + (toThousands(val.kwh.toFixed(2))) + '</td>' +
'<td>' + (toThousands(avgdaykwh.toFixed(2))) + '</td>' +//val.kwhkwp
'<td>' + (toThousands(nowDisplayIrrDay)) + '</td>' +
'<td>' + (toThousands(val.pr.toFixed(2))) + '</td>' +
'<td>' + (toThousands(val.temp.toFixed(2))) + '</td>' +
'</tr>');
listmonth.push(val.timestamp);
listkwh.push(parseFloat(val.kwh.toFixed(2)));
listcolor.push(color);
listcolor2.push(color2);
//listirradiance.push(parseFloat(val.irradiance.toFixed(2)));
listirradiance.push(parseFloat(nowDisplayIrrDay));
listtemperature.push(parseFloat(val.temp.toFixed(2)));
listsolarhour.push(parseFloat(val.solarhour.toFixed(2)));
listpr.push(parseFloat(val.pr.toFixed(2)));
listkwhkwp.push(parseFloat(avgdaykwh));//val.kwhkwp
}
else
{
if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) {
kwhkwp = val.kwhkwp.toFixed(2);
}
if (groupType != 0 && groupType != 3) {
ALLkwhkwp += val.kwhkwp;
kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++;
}
if (groupType == 3) {
ALLDays += val.days;
avgdaykwh = (val.kwh / val.generatingCapacity / val.days);
ALLavgdaykwh += avgdaykwh;
}
else {
avgdaykwh = val.kwhkwp;
}
diffSOLARHOURALL += val.diffSOLARHOUR;
$('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' +
'<td>' + (toThousands(val.kwh.toFixed(2))) + '</td>' +
'<td>' + (toThousands(avgdaykwh.toFixed(2))) + '</td>' +//val.kwhkwp
'<td>' + (toThousands(val.irrDay.toFixed(2))) + '</td>' +
'<td>' + (toThousands(val.pr.toFixed(2))) + '</td>' +
'<td>' + (toThousands(val.temp.toFixed(2))) + '</td>' +
'</tr>');
listmonth.push(val.timestamp);
listkwh.push(parseFloat(val.kwh.toFixed(2)));
listcolor.push(color);
listcolor2.push(color2);
//listirradiance.push(parseFloat(val.irradiance.toFixed(2)));
listirradiance.push(parseFloat(nowDisplayIrrDay));
listtemperature.push(parseFloat(val.temp.toFixed(2)));
listsolarhour.push(parseFloat(val.solarhour.toFixed(2)));
listpr.push(parseFloat(val.pr.toFixed(2)));
listkwhkwp.push(parseFloat(avgdaykwh));//val.kwhkwp
}
}
})
tempALL = tempALL / rel.data.length;
$('#history-kWh-convas-div').empty();
$('#history-kWh-convas-div').append('<figure class="highcharts-figure"><div id="history-kWh" ></div></figure>');
chart = new Highcharts.Chart({
lang: { //匯出相關中文名稱配置
printChart: '列印圖表',
downloadJPEG: '下載JPEG檔案',
downloadPDF: '下載PDF檔案',
downloadPNG: '下載PNG檔案',
downloadSVG: '下載SVG檔案',
downloadCSV: '下載CSV檔案',
downloadXLS: '下載XLS檔案',
viewData: '檢視資料表格',
viewFullscreen: '全屏檢視'
},
accessibility: {
enabled: false
},
chart: {
renderTo: 'history-kWh',
height: 600,
animation: false
},
title: {
text: '發電量及累積日照量'
},
xAxis: {
categories: listmonth,
},
yAxis: [{
title: {
text: "kWh"
},
id: "A",
opposite: false,
showEmpty: false
}, {
title: {
text: "Wh/㎡"
},
id: "B",
opposite: true,
showEmpty: false
}, {
title: {
text: "hr"
},
id: "C",
opposite: true,
showEmpty: false
}, {
title: {
text: "PR(%)"
},
id: "D",
opposite: true,
showEmpty: false
}, {
title: {
text: "溫度(℃)"
},
id: "E",
opposite: true,
showEmpty: false
}],
series: [{
type: 'spline',
name: "溫度(℃)",
data: listtemperature,
yAxis: "E",
color: "rgb(255, 192, 0)",
zIndex: 4
}, {
type: 'spline',
name: "累積日照(Wh/㎡)",
data: listirradiance,
yAxis: "B",
color: "rgb(190, 45, 45)",
zIndex: 3
}, {
type: 'column',
name: "PR(%)",
data: listpr,
yAxis: "D",
color: 'rgb(68, 114, 196)'
}, {
type: 'column',
name: "日均發電度數",
data: listkwhkwp,
yAxis: "C",
color: "rgb(165, 165, 165)"
}, {
type: 'column',
name: "發電量(kWh)",
data: listkwh,
yAxis: "A",
color: "rgb(103, 180, 172)"
}],
});
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);
if (rel.data.length == 0) {
$('#HistoryTotalTable').append('<tr>' + '<td colspan="6" style="text-align:center;">' + '無資料' + '</td>' + '</tr>');
$('#HistoryDetailTable').append('<tr>' + '<td colspan="6" style="text-align:center;">' + '無資料' + '</td>' + '</tr>');
}
else
{
var avgK = 0;
if (groupType == 3) {
avgK = (ALLavgdaykwh / rel.data.length).toFixed(2);//(kwhALL / rel.data[0].generatingCapacity / ALLDays).toFixed(2);
}
else {
avgK = kwhkwp;
}
$('#HistoryTotalTable').append('<tr>' +
'<td>' + TimestampALL + '</td>' +
'<td>' + (toThousands(kwhALL.toFixed(2))) + '</td>' +
'<td>' + (toThousands(avgK)) + '</td>' +
//'<td>' + irradianceALL.toFixed(2) + '</td>' + // 改成累積日照 by jiahao 2022-04-30 00:444
'<td>' + (toThousands(avgIrr_day.toFixed(2))) + '</td>' +
'<td>' + (toThousands(avgPR.toFixed(2))) + '</td>' +
'<td>' + (toThousands(tempALL.toFixed(2))) + '</td>' +
'</tr>');
}
$('#all').show();
isloadingdone_history = true;
hideLoading();
})
}
//#endregion
function GetInverterCard(stationId) {
showLoading();
var url = "/PowerStation/GetOnePowerStation/";
var send_data = {
id: stationId
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
hideLoading();
toast_error(rel.msg);
return;
}
$("#Invertercard-Name").html(rel.data.name);
$("#Invertercard-kwh").html(toThousands(rel.data.today_kWh.toFixed(2)));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<text>
$("#Invertercard-money").html(toThousands(rel.data.today_Money.toFixed()));
</text>
}
$("#Invertercard-Capacity").html(toThousands(rel.data.generatingCapacity.toFixed(3)));
$("#Invertercard-pr").html(toThousands(rel.data.today_PR.toFixed(2)));
var str = "<div class='progress progress-sm ' id='prbar'>" +
"<div class='progress-bar bg-info' role = 'progressbar' style = 'width: " + rel.data.today_PR + "%;' aria - valuenow='" + rel.data.today_PR + "' aria - valuemin='0' aria - valuemax='100' ></div > </div >"
$('#prbar').remove();
$("#Invertercard").append(str);
var TypeName = "";
switch (rel.data.solarType) {
case 0:
TypeName = "自建躉售";
break;
case 1:
TypeName = "租建躉售";
break;
case 2:
TypeName = "自建自用";
break;
}
$("#Invertercard-type").html(TypeName);
@*var time = new Date(rel.data.createdAt);
$("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@
$("#Invertercard-date").html(rel.data.electricityMeterAt);
var urlPath = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay;
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();//其他浏览器
}
else if (window.ActiveXObject) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");//旧版IE
}
catch (e) { }
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//新版IE
}
catch (e) { }
if (!xmlhttp) {
// window.alert("");
}
}
xmlhttp.open("GET", urlPath, false);
xmlhttp.send();
var roadtourl;
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
roadtourl = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay;
} //url存在
else if (xmlhttp.status == 404) {
roadtourl = "../img/blank.gif";
} //url不存在
else {
roadtourl = "";
}//其他狀態
}
$("#Invertercard").find('.card-img-top').attr('src', roadtourl);
$('#Invertercard-Temp').html(rel.data.todayWeatherTemp + '°C');
$('#Invertercard-weathericon').attr("class", 'fal fa-' + rel.data.todayWeather + ' fa-2x');
stationDB = rel.data.siteDB;
InverterInfoList();
hideLoading();
}, 'json');
};
function InverterInfoList() {
showLoading();
var url = "/PowerStation/GetInverterInfoList/";
var send_data = {
id: stationId,
siteDB: stationDB
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
isloadingdone_inverterinfo = true;
hideLoading();
toast_error(rel.msg);
return;
}
if (rel.code == "0001") {
isloadingdone_inverterinfo = true;
hideLoading();
toast_warning(rel.msg);
return;
}
$("#ullist").empty();
var long = rel.data.length <= 4 ? rel.data.length : 4;
for (var a = 0; a < long; a++) {
var str = "<li class='col-xl-3' id='li_" + a + "'>";
str += '<div class="card border m-auto m-lg-0">';
str += '<div class="card-body d-flex justify-content-between pb-0 px-2 bg-fusion-25">';
str += '<p class="font-weight-bold"> <i class="fal fa-ballot-check"></i> ' + rel.data[a].name + '</p>';
str += '<p class="card-text hold-time-change">0分鐘前</p>';
str += '</div>';
str += '<div class="list-group list-group-flush">';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">設備狀態</p>';
if (rel.data[a].type == 1) {
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold">正常</span></p>';
}
else {
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold" style="color:red;">異常</span></p>';
}
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold"><a href="javascript:;" OnClick="InverterInfoDetail(' + rel.data[a].id + ',' + rel.data[a].timestamp + ',\'' + rel.data[a].useDB + '\',\'' + rel.data[a].useTable +'\')">詳細資料</a></span></p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2 bg-info-20">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">輸出功率</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].output.toFixed(2)) + '</p>';
str += '<p class="mb-0">kw</p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">輸入功率</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].input.toFixed(2)) + '</p>';
str += '<p class="mb-0">kw</p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2 bg-info-20">';
str += '<div class="d-flex">';
str += 'PR <span class="d-inline-block ml-auto">' + toThousands(rel.data[a].pr.toFixed(2)) + '%</span>';
str += '</div>';
str += '<div class="progress progress-sm mb-3">';
str += '<div class="progress-bar bg-info-400" role="progressbar" style="width: ' + toThousands(rel.data[a].pr.toFixed(2)) + '%;" aria-valuenow="' + toThousands(rel.data[a].pr.toFixed(2)) + '" aria-valuemin="0" aria-valuemax="100"></div>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">日發電量</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].todaykwh.toFixed(2)) + '</p>';
str += '<p class="mb-0">kWh</p>';
str += '</div>';
str += '</div>';
str += '</div>';
str += '</div>';
str += '</li>';
$("#ullist").append(str);
}
if (rel.data.length >= 4) {
for (var a = 4; a < rel.data.length; a++) {
var str = '<ul>';
str += '<div class="card border m-auto m-lg-0">';
str += '<div class="card-body d-flex justify-content-between pb-0 px-2 bg-fusion-25">';
str += '<p class="font-weight-bold"> <i class="fal fa-ballot-check"></i> ' + rel.data[a].name + '</p>';
str += '<p class="card-text hold-time-change">0分鐘前</p>';
str += '</div>';
str += '<div class="list-group list-group-flush">';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">設備狀態</p>';
if (rel.data[a].type == 1) {
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold">正常</span></p>';
}
else {
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold" style="color:red;">異常</span></p>';
}
str += '<p class="mb-0"><span class="color-info-700 font-weight-bold"><a href="javascript:;" OnClick="InverterInfoDetail(' + rel.data[a].id + ',' + rel.data[a].timestamp + ',\'' + rel.data[a].useDB + '\',\'' + rel.data[a].useTable +'\')">詳細資料</a></span></p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2 bg-info-20">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">輸出功率</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].output.toFixed(2)) + '</p>';
str += '<p class="mb-0">kw</p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">輸入功率</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].input.toFixed(2)) + '</p>';
str += '<p class="mb-0">kw</p>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2 bg-info-20">';
str += '<div class="d-flex">';
str += 'PR <span class="d-inline-block ml-auto">' + toThousands(rel.data[a].pr.toFixed(2)) + '%</span>';
str += '</div>';
str += '<div class="progress progress-sm mb-3">';
str += '<div class="progress-bar bg-info-400" role="progressbar" style="width: ' + toThousands(rel.data[a].pr.toFixed(2)) + '%;" aria-valuenow="' + toThousands(rel.data[a].pr.toFixed(2)) + '" aria-valuemin="0" aria-valuemax="100"></div>';
str += '</div>';
str += '</div>';
str += '<div class="list-group-item px-2">';
str += '<div class=" d-flex justify-content-between">';
str += '<p class="mb-0">日發電量</p>';
str += '<p class="mb-0">' + toThousands(rel.data[a].todaykwh.toFixed(2)) + '</p>';
str += '<p class="mb-0">kWh</p>';
str += '</div>';
str += '</div>';
str += '</div>';
str += '</div>';
str += '</ul>';
$("#li_" + a % 4).append(str);
}
};
isloadingdone_inverterinfo = true;
hideLoading();
});
}
function InverterInfoDetail(id, time, db, table) {
showLoading();
var url = "/PowerStation/GetInverterInfoModal/";
var send_data = {
Id: id,
Time: time,
UseDB: db,
UseTable: table
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
hideLoading();
toast_error(rel.msg);
return;
}
var info = "<tr>";
info += "<td>" + rel.data.model + "</td>";
info += "<td>" + rel.data.brand + "</td>";
info += "<td>" + ((rel.data.brandNum == null) ? '' : rel.data.brandNum) + "</td>";
info += "</tr>";
$('#inverterInfo-Detail').empty();
$('#inverterInfo-Detail').append(info);
var ACDetail = "";
for (var a = 1; a < 4; a++)
{
ACDetail += "<tr>";
ACDetail += "<td>" + a + "</td>";
ACDetail += "<td>" + toThousands(rel.data['aC' + a + 'V'].toFixed(2)) + "</td>";
ACDetail += "<td>" + toThousands(rel.data['aC' + a + 'A'].toFixed(2)) + "</td>";
ACDetail += "</tr>";
}
ACDetail += "<tr>";
ACDetail += "<td colspan='3'>輸出功率 <span class='color-info-700 font-weight-bold'>" + ((rel.data.aC1W + rel.data.aC2W + rel.data.aC3W) / 1000).toFixed(2) + "</span> KW</td>";
ACDetail += "</tr>";
ACDetail += "<tr>";
ACDetail += "<td colspan='3'>PR <span class='color-info-700 font-weight-bold'>" + toThousands(rel.data.pr.toFixed(2)) + "</span> %</td>";
ACDetail += "</tr>";
$('#inverterInfo-AC').empty();
$('#inverterInfo-AC').append(ACDetail);
var DCDetail = "";
var DCTOTAL = 0;
for (var a = 1; a < 6; a++) {
DCDetail += "<tr>";
DCDetail += "<td>" + a + "</td>";
DCDetail += "<td>" + toThousands(rel.data['dC' + a + 'V'].toFixed(2)) + "</td>";
DCDetail += "<td>" + toThousands(rel.data['dC' + a + 'A'].toFixed(2)) + "</td>";
DCDetail += "<td>" + toThousands(rel.data['dC' + a + 'KW'].toFixed(2)) + "</td>";
DCDetail += "<td>" + toThousands(rel.data['rA' + a ].toFixed(2)) + "</td>";
DCDetail += "</tr>";
DCTOTAL += rel.data['dC' + a + 'W'];
}
DCDetail += "<tr>";
DCDetail += "<td colspan='5'>直流功率 <span class='color-info-700 font-weight-bold'>" + (DCTOTAL / 1000).toFixed(2) + "</span> KW</td>";
DCDetail += "</tr>";
$('#inverterInfo-DC').empty();
$('#inverterInfo-DC').append(DCDetail);
$('#inverterInfo-name').html(rel.data.inverterName);
$("#inverterdetailmodal").modal();
hideLoading();
})
}
</script>
}