2302 lines
96 KiB
Plaintext
2302 lines
96 KiB
Plaintext
@{
|
||
ViewData["MainNum"] = "1";
|
||
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="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-2">
|
||
<h1 class="subheader-title">
|
||
<span class="icon-stack fa-1x">
|
||
<i class="base-7 icon-stack-3x color-info-500"></i>
|
||
<i class="base-7 icon-stack-2x color-info-700"></i>
|
||
<i class="ni ni-graph icon-stack-1x text-white"></i>
|
||
</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>降雨幾率: 15%</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">即時資訊</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">基本資料</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">歷史資料</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">逆變器分析</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">異常記錄</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">運維記錄</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>
|
||
}
|
||
|
||
@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_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_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/highcharts.js"></script>
|
||
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
|
||
|
||
<script>
|
||
var localurl = this.location.href;
|
||
var powerids = new Array(0);//當前選擇電站
|
||
var Type = 0; // 項目
|
||
var stationId;
|
||
var errortoID;
|
||
var powerStationData;
|
||
var stationOverview;
|
||
var recode;
|
||
var selected_work_type = -1;
|
||
var err_status = 1;//異常紀錄,1:未解決 0:已解決
|
||
var err_status = 1;//異常紀錄,1:未解決 0:已解決
|
||
var groupType = 0; //0:日 1:月 2:年 3:歷年
|
||
var historyRange = "";
|
||
var selectInverterkwhBarType = 0;
|
||
|
||
$(function () {
|
||
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 即時資訊tab
|
||
var url = "/StationOverview/GetOneStationUpToDateInfo";
|
||
var send_data = {
|
||
ids: [stationId]
|
||
};
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
stationOverview = rel.data;
|
||
$("#today_kwh").html(stationOverview.today_kwh.toFixed(2));
|
||
$("#total_kwh").html(stationOverview.total_kwh.toFixed(2));
|
||
$("#today_irradiance").html(stationOverview.today_irradiance.toFixed(2));
|
||
$("#avg_irradiance").html(stationOverview.avg_irradiance.toFixed(2));
|
||
$("#today_PR").html(stationOverview.today_PR.toFixed(2));
|
||
$("#avg_PR").html(stationOverview.avg_PR.toFixed(2));
|
||
$("#today_kwhkwp").html(stationOverview.today_kwhkwp.toFixed(2));
|
||
$("#avg_kwhkwp").html(stationOverview.avg_kwhkwp.toFixed(2));
|
||
$("#total_money").html(stationOverview.total_money.toFixed(2));
|
||
$("#today_money").html(stationOverview.today_money.toFixed(2));
|
||
$("#today_carbon").html(stationOverview.today_carbon.toFixed(2));
|
||
$("#total_carbon").html(stationOverview.total_carbon.toFixed(2));
|
||
$("#update_at").html(stationOverview.updatedAt);
|
||
$('#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("今日省電費用");
|
||
}
|
||
|
||
}, 'json');
|
||
|
||
//#region 載入電站圖片
|
||
var url_image = "/PowerStation/GetAllPowerStationImage";
|
||
var send_data = {
|
||
powerStationId: stationId
|
||
};
|
||
|
||
$.post(url_image, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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");
|
||
|
||
}, 'json');
|
||
//#endregion
|
||
|
||
//#region 載入圖表資料
|
||
var url = "/StationOverview/GetChartUpToDate";
|
||
var send_data = {
|
||
id: stationId
|
||
}
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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: 2,
|
||
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: 1,
|
||
data: chartToday.irradianceDatas,
|
||
}]
|
||
},
|
||
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: 'W/㎡'
|
||
}
|
||
}]
|
||
}
|
||
}
|
||
});
|
||
//#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)',
|
||
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,
|
||
fill: false,
|
||
data: chart7day.irradianceDatas,
|
||
}]
|
||
},
|
||
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: 'W/㎡'
|
||
}
|
||
}]
|
||
}
|
||
}
|
||
});
|
||
//#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)',
|
||
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,
|
||
fill: false,
|
||
data: chartMonth.irradianceDatas,
|
||
}]
|
||
},
|
||
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: 'W/㎡'
|
||
}
|
||
}]
|
||
}
|
||
}
|
||
});
|
||
//#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)',
|
||
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,
|
||
fill: false,
|
||
data: chartYear.irradianceDatas,
|
||
}]
|
||
},
|
||
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: 'W/㎡'
|
||
}
|
||
}]
|
||
}
|
||
}
|
||
});
|
||
//#endregion
|
||
}, 'json');
|
||
//#endregion
|
||
|
||
$('#carouselExampleIndicators').carousel({
|
||
interval: 10000
|
||
})
|
||
|
||
$('#carousel-chart').carousel({
|
||
interval: 10000
|
||
})
|
||
|
||
//#endregion
|
||
|
||
//#region 基本資料tab
|
||
var url = "/PowerStation/GetOnePowerStation"
|
||
var send_data = {
|
||
id: stationId
|
||
}
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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');
|
||
|
||
}, 'json');
|
||
|
||
//#region 載入單線圖
|
||
var url_image = "/PowerStation/GetAllPowerStationSingleLine";
|
||
var send_data = {
|
||
powerStationId: stationId
|
||
};
|
||
|
||
$.post(url_image, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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);
|
||
});
|
||
|
||
|
||
|
||
}, 'json');
|
||
//#endregion
|
||
|
||
//#region 預先載入運維人員下拉式選單select_option
|
||
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") {
|
||
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);
|
||
}
|
||
});
|
||
|
||
$('.js-example-basic-multiple').select2();
|
||
//#endregion
|
||
//#endregion
|
||
|
||
//#region Date Picker record
|
||
datepicker = $('#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
|
||
datepicker = $('#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);
|
||
operationRecodeTable = $("#operation_recode_table").DataTable({
|
||
"pageLength": 20,
|
||
"paging": true,
|
||
"lengthChange": false,
|
||
"searching": false,
|
||
"ordering": false,
|
||
"info": true,
|
||
"autoWidth": false,
|
||
"responsive": true,
|
||
"columns": [{
|
||
"data": "powerStationName"
|
||
}, {
|
||
"data": "formId"
|
||
}, {
|
||
"data": "workTypeText"
|
||
}, {
|
||
"data": "fixDo"
|
||
}, {
|
||
"data": "statusText"
|
||
}, {
|
||
"data": "workPersonName"
|
||
}, {
|
||
"data": "operationPredict"
|
||
}, {
|
||
"data": "recodeFiles"
|
||
}, {
|
||
"data": "finishTime"
|
||
}],
|
||
"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) {
|
||
CreateRecodeFileBox($(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/OperationRecodeList",
|
||
"type": "POST",
|
||
"data": function (d) {
|
||
d.PowerStationIds = powerids;
|
||
d.WorkType = Type;
|
||
d.Range = $('#date-range').val();
|
||
},
|
||
"dataSrc": function (rel) {
|
||
if (rel.data.code == "9999") {
|
||
toast_error(rel.data.msg);
|
||
return;
|
||
}
|
||
|
||
data = rel.data.data;
|
||
|
||
if (data == null || data.length == 0) {
|
||
this.data = [];
|
||
}
|
||
|
||
return data;
|
||
}
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
//#region 切換電站時,載入該電站運維人員
|
||
$("#power_station_select_modal").change(function () {
|
||
|
||
//查詢該電站的運維人員
|
||
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") {
|
||
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 (recode != null || recode != undefined) {
|
||
$("#work_person_select_modal").val(recode.workPersonId);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
//#endregion
|
||
|
||
//#region 逆變器分析 tab
|
||
|
||
ChangeInverterDateToday();
|
||
LoadInvertAnalysisHeatMap();
|
||
|
||
ChangeInverterkwhBarDaily('');
|
||
LoadInvertAnalysiskwhBar();
|
||
|
||
//#region 載入電站逆變器資料
|
||
var url = "/StationOverview/GetInverterCheckBox";
|
||
var send_data = {
|
||
id: stationId
|
||
}
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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();
|
||
|
||
|
||
}, 'json');
|
||
//#endregion
|
||
//#endregion
|
||
|
||
//#region 維修單運維人員(異常紀錄)
|
||
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") {
|
||
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 (recode != null || recode != undefined) {
|
||
$("#work_person_select_modal_exc").val(recode.workPersonId);
|
||
}
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
//#region 異常table
|
||
ExceptionTable = $("#Exception_Table").DataTable({
|
||
"pageLength": 20,
|
||
"paging": true,
|
||
"lengthChange": false,
|
||
"searching": false,
|
||
"ordering": true,
|
||
"info": true,
|
||
"autoWidth": false,
|
||
"responsive": true,
|
||
"order": [[7, "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") {
|
||
toast_error(rel.data.msg);
|
||
return;
|
||
}
|
||
data = rel.data.data;
|
||
if (data == null || data.length == 0) {
|
||
this.data = [];
|
||
}
|
||
return data;
|
||
}
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
//歷史第一個table
|
||
getTable();
|
||
});
|
||
|
||
//#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) {
|
||
var url = "/StationOverview/GetPowerStationCollapse"
|
||
|
||
var send_data = {
|
||
Filter: filter
|
||
}
|
||
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
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");
|
||
|
||
|
||
}, 'json');
|
||
}
|
||
|
||
|
||
//#region 產生檔案html
|
||
function CreateRecodeFileBox(dom, value, show_del_btn) {
|
||
var str = "";
|
||
str += '<div class="col-auto 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-recode-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 異常
|
||
|
||
//#region 改變日期(異常)
|
||
$('#date-range-exception').on('change', function () {
|
||
ExceptionTable.ajax.reload();
|
||
});
|
||
//#endregion
|
||
|
||
//#region 匯出excel(異常)
|
||
function ExportExcelToExc() {
|
||
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") {
|
||
toast_error(rel.data.msg);
|
||
return;
|
||
}
|
||
$('#NOSEEBODY').empty();
|
||
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: "test",
|
||
//檔案字尾名
|
||
fileext: ".xls",
|
||
});
|
||
}, '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');
|
||
//取得單一記錄表單
|
||
var url = "/Operation/GetOneOperationRecode/";
|
||
|
||
var send_data = {
|
||
id: errortoID
|
||
}
|
||
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
recode = rel.data;
|
||
|
||
countOperationRecodeFile = recode.recodeFiles.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(recode.workTime);
|
||
var status = -1;
|
||
if (recode.status == 0 || recode.status == 2) {
|
||
status = 0;
|
||
} else if (recode.status == 1 || recode.status == 3) {
|
||
status = 1;
|
||
}
|
||
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
|
||
$('#work_person_select_modal_exc').val(recode.workPersonId);
|
||
$(".fix-div").show();
|
||
$("#error_code_modal_exc").val(recode.errorCode);
|
||
$("#error_code_modal_exc").attr("disabled", true);
|
||
$("#fix_do_modal_exc").val(recode.fixDo);
|
||
$("#notice_textarea_modal_exc").val(recode.notice);
|
||
$("#description_textarea_modal_exc").val(recode.description);
|
||
|
||
var str = "";
|
||
|
||
RecodeFileBox = $("#recode_files_div_exc > .row");
|
||
RecodeFileBox.empty();
|
||
recode.recodeFiles.forEach(function (value, index) {
|
||
CreateRecodeFileBox(RecodeFileBox, value, true);
|
||
});
|
||
|
||
$("#exception-form-modal").modal();
|
||
}, '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);
|
||
$("#recode-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() {
|
||
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.data('daterangepicker').setStartDate(dateLimit_format);
|
||
datepicker.data('daterangepicker').setEndDate(today_format);
|
||
|
||
$('#date-range-exception').val(dateLimit_format + ' - ' + today_format);
|
||
$('#date-range-exception').trigger('change');
|
||
}
|
||
//#endregion
|
||
|
||
//#region 儲存表單資料(異常)
|
||
function SaveException() {
|
||
|
||
if ($("#recode-form-exc").valid()) {
|
||
var url = "/Operation/SaveOperationRecode";
|
||
|
||
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") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
var myDropzone = Dropzone.forElement("#recode-file-form_exc");
|
||
|
||
if (myDropzone.files.length > 0) {
|
||
selected_id = rel.data;
|
||
myDropzone.processQueue();
|
||
|
||
myDropzone.on("successmultiple", function (file, rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
toast_ok(rel.msg);
|
||
$('#exception-form-modal').modal('hide');
|
||
recodeFileDropzone.removeAllFiles();
|
||
|
||
ExceptionTable.ajax.reload();
|
||
});
|
||
} else {
|
||
$('#exception-form-modal').modal('hide');
|
||
myDropzone.removeAllFiles();
|
||
|
||
ExceptionTable.ajax.reload();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
//#endregion
|
||
|
||
//#region 表單檔案資料(異常)
|
||
Dropzone.autoDiscover = false;
|
||
recodeFileDropzone = new Dropzone("#recode-file-form_exc", {
|
||
url: "/Operation/SaveOperationRecodeFile",
|
||
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 ((countOperationRecodeFile + myDropzone.files.length) > 5) {
|
||
toast_warning("檔案總數量不可超過 5 張");
|
||
myDropzone.removeFile(file);
|
||
return;
|
||
} else {
|
||
|
||
data.append("Id", selected_id);
|
||
data.append("RecodeFiles", file);
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
//#region 改變異常紀錄狀態
|
||
function ChangeStatus(type) {
|
||
err_status = type;
|
||
var name;
|
||
var name2;
|
||
if (type == 0) {
|
||
name = "errbutton" + "0";
|
||
name2 = "errbutton" + "1";
|
||
} else {
|
||
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_recode_table').on("click", "a.edit-btn", function () {
|
||
|
||
work_type = $(this).parents('tr').attr('data-work-type');
|
||
|
||
if (work_type == 0) {
|
||
$("#recode-form-modal .modal-title .main-title").html("清洗單 - ");
|
||
} else if (work_type == 1) {
|
||
$("#recode-form-modal .modal-title .main-title").html("巡檢單 - ");
|
||
} else {
|
||
$("#recode-form-modal .modal-title .main-title").html("維修單 - ");
|
||
}
|
||
|
||
selected_id = $(this).parents('tr').attr('data-id');
|
||
|
||
//取得單一記錄表單
|
||
var url = "/Operation/GetOneOperationRecode/";
|
||
|
||
var send_data = {
|
||
id: selected_id
|
||
}
|
||
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
recode = rel.data;
|
||
|
||
countOperationRecodeFile = recode.recodeFiles.length;
|
||
|
||
$("#recode-form-modal .modal-title .sub-title").html(recode.powerStationName);
|
||
|
||
$("#power_station_select_modal").val(recode.powerStationId);
|
||
$("#power_station_select_modal").attr("disabled", true);
|
||
|
||
$("#work_time_modal").val(recode.workTime);
|
||
var status = -1;
|
||
if (recode.status == 0 || recode.status == 2) {
|
||
status = 0;
|
||
} else if (recode.status == 1 || recode.status == 3) {
|
||
status = 1;
|
||
}
|
||
$("input[name=status_modal_opRecord][value='" + status + "']").prop('checked', true); //狀態
|
||
$('#work_person_select_modal').val(recode.workPersonId);
|
||
if (work_type != 2) {
|
||
$(".fix-div").hide();
|
||
} else {
|
||
$(".fix-div").show();
|
||
$("#error_code_modal").val(recode.errorCode);
|
||
$("#fix_do_modal").val(recode.fixDo);
|
||
}
|
||
$("#notice_textarea_modal").val(recode.notice);
|
||
$("#description_textarea_modal").val(recode.description);
|
||
|
||
var str = "";
|
||
|
||
RecodeFileBox = $("#recode_files_div > .row");
|
||
RecodeFileBox.empty();
|
||
recode.recodeFiles.forEach(function (value, index) {
|
||
CreateRecodeFileBox(RecodeFileBox, value, true);
|
||
});
|
||
|
||
$("#recode-form-modal").modal();
|
||
}, 'json');
|
||
});
|
||
//#endregion
|
||
|
||
//#region 表單檔案資料(運維)
|
||
Dropzone.autoDiscover = false;
|
||
recodeFileDropzone = new Dropzone("#recode-file-form", {
|
||
url: "/Operation/SaveOperationRecodeFile",
|
||
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 ((countOperationRecodeFile + myDropzone.files.length) > 5) {
|
||
toast_warning("檔案總數量不可超過 5 張");
|
||
myDropzone.removeFile(file);
|
||
return;
|
||
} else {
|
||
|
||
data.append("Id", selected_id);
|
||
data.append("RecodeFiles", file);
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
//#region 查詢近30天(運維)
|
||
function ChangeDate30() {
|
||
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.data('daterangepicker').setStartDate(dateLimit_format);
|
||
datepicker.data('daterangepicker').setEndDate(today_format);
|
||
|
||
$('#date-range-record').val(dateLimit_format + ' - ' + today_format);
|
||
$('#date-range-record').trigger('change');
|
||
}
|
||
//#endregion
|
||
|
||
//#region 儲存表單資料(運維)
|
||
function SaveRecode() {
|
||
|
||
if ($("#recode-form").valid()) {
|
||
var url = "/Operation/SaveOperationRecode";
|
||
|
||
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("Status", $("input[name=status_modal_opRecord]:checked").val());
|
||
formData.append("WorkPersonId", $("#work_person_select_modal").val());
|
||
formData.append("WorkTime", $("#work_time_modal").val());
|
||
formData.append("Notice", $("#notice_textarea_modal").val());
|
||
formData.append("Description", $("#description_textarea_modal").val());
|
||
|
||
$.ajax({
|
||
type: "POST",
|
||
url: url,
|
||
data: formData,
|
||
cache: false,
|
||
contentType: false,
|
||
processData: false,
|
||
success: function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
var myDropzone = Dropzone.forElement("#recode-file-form");
|
||
|
||
if (myDropzone.files.length > 0) {
|
||
selected_id = rel.data;
|
||
myDropzone.processQueue();
|
||
|
||
myDropzone.on("successmultiple", function (file, rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
toast_ok(rel.msg);
|
||
$('#recode-form-modal').modal('hide');
|
||
recodeFileDropzone.removeAllFiles();
|
||
|
||
operationRecodeTable.ajax.reload();
|
||
});
|
||
} else {
|
||
$('#recode-form-modal').modal('hide');
|
||
myDropzone.removeAllFiles();
|
||
|
||
operationRecodeTable.ajax.reload();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
//#endregion
|
||
|
||
//#region 點擊圖片放大(運維)
|
||
$('#operation_recode_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() {
|
||
var url = "/Operation/ExportOperationRecodeExcel";
|
||
var send_data = {
|
||
CityIds: [3],
|
||
PowerStationIds: powerids
|
||
};
|
||
$.post(url, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
$('#NoViewbody').empty();
|
||
|
||
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 != "") {
|
||
//value.hyperLinks.forEach(function (value3, index) {
|
||
// str += value3;
|
||
//});
|
||
str += value.finishTime;
|
||
}
|
||
str += "</td>";
|
||
|
||
str += "</tr>";
|
||
});
|
||
|
||
$('#NoViewbody').append(str);
|
||
|
||
$("#NoView").table2excel({
|
||
// 匯出的Excel文件的名稱
|
||
name: "abc",
|
||
// Excel檔案的名稱
|
||
filename: "test",
|
||
//檔案字尾名
|
||
fileext: ".xls",
|
||
});
|
||
}, 'json');
|
||
}
|
||
//#endregion
|
||
|
||
//#region 改變日期(運維)
|
||
$('#date-range-record').on('change', function () {
|
||
operationRecodeTable.ajax.reload();
|
||
});
|
||
//#endregion
|
||
|
||
//#region 改變項目(運維)
|
||
function ChangeType(type) {
|
||
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");
|
||
operationRecodeTable.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);
|
||
$("#electricity_meter_at_text").html(powerStationData.electricityMeterAt);
|
||
$("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime);
|
||
$("#created_by_text").html(powerStationData.creatorName);
|
||
|
||
$("#generating_capacity_text").html(powerStationData.generatingCapacity);
|
||
$("#escrow_name_text").html(powerStationData.escrowName);
|
||
$("#power_rate_text").html(powerStationData.powerRate);
|
||
$("#coordinate_text").html(powerStationData.coordinate);
|
||
$("#created_at_text").html(powerStationData.createdAt);
|
||
$("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds).trigger("change");
|
||
$("#power_station_operation_personnel").attr("disabled", true);
|
||
|
||
//光電板
|
||
$("#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(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_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);
|
||
$("#TPC_meter_reading_text").html(powerStationData.tpcMeterReading);
|
||
$("#TPC_purchase_electricity_at_text").html(powerStationData.tpcPurchaseElectricityAt);
|
||
$("#TPC_sell_electricity_at_text").html(powerStationData.tpcSellElectricityAt);
|
||
$("#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-50 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_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 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>' +
|
||
'<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() {
|
||
|
||
var checkInverts = $("input[name='selectedInvert[]']:checked").map(function () {
|
||
return $(this).val();
|
||
}).get();
|
||
|
||
//#region HeatMap
|
||
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") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
|
||
HeatMap = rel.data;
|
||
|
||
|
||
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',
|
||
},
|
||
|
||
title: {
|
||
text: '逆變器單日kWhkWp'
|
||
},
|
||
|
||
xAxis: {
|
||
categories: HeatMap.xAxis
|
||
},
|
||
yAxis: {
|
||
categories: HeatMap.yAxis,
|
||
title: { text: "逆變器編號" },
|
||
},
|
||
colorAxis: {
|
||
min: 0,
|
||
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, 'x') + '</b> sold <br><b>' +
|
||
this.point.value + '</b> items on <br><b>' + getPointCategoryName(this.point, 'y') + '</b>';
|
||
}
|
||
},
|
||
|
||
series: myseries,
|
||
});
|
||
}, 'json');
|
||
//#endregion
|
||
|
||
|
||
}
|
||
//#endregion
|
||
|
||
function getPointCategoryName(point, dimension) {
|
||
var series = point.series,
|
||
isY = dimension === 'y',
|
||
axis = series[isY ? 'yAxis' : 'xAxis'];
|
||
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() {
|
||
var url = "/StationOverview/GetInverterkwhBarAnalysis";
|
||
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") {
|
||
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'
|
||
}
|
||
}
|
||
});
|
||
//#endregion
|
||
|
||
}, '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");
|
||
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("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();
|
||
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("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("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("MonthGet").style.display = "none";//隱藏
|
||
document.getElementById("YearGet").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);
|
||
}
|
||
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);
|
||
}
|
||
historyRange = $('#DateGet').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
|
||
|
||
$('#DateGet').on('change', function () {
|
||
historyRange = $('#DateGet').val();
|
||
getTable();
|
||
});
|
||
|
||
$('#MonthGet').on('change', function () {
|
||
historyRange = $('#MonthGet').val();
|
||
getTable();
|
||
});
|
||
|
||
$('#YearGet').on('change', function () {
|
||
historyRange = $('#YearGet').val();
|
||
getTable();
|
||
});
|
||
|
||
function getTable()
|
||
{
|
||
if (historyRange == "")
|
||
{
|
||
var today = new Date();
|
||
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-");
|
||
$('#DateGet').val(today_format);
|
||
historyRange = $('#DateGet').val();
|
||
}
|
||
|
||
|
||
var send_data = {
|
||
GroupType: groupType,
|
||
HistoryRange: historyRange,
|
||
PowerstationId: stationId
|
||
}
|
||
//0:日 1:月 2:年 3:歷年
|
||
var Nurl = "/StationOverview/GetTotalTableToHistory";
|
||
$.post(Nurl, send_data, function (rel) {
|
||
if (rel.code != "0000") {
|
||
toast_error(rel.msg);
|
||
return;
|
||
}
|
||
$('#HistoryTotalTable').empty();
|
||
$('#HistoryDetailTable').empty();
|
||
var TimestampALL;
|
||
var kwhALL = 0;
|
||
var diffSOLARHOURALL = 0;
|
||
var irradianceALL = 0;
|
||
var prALL;
|
||
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 color = rgba(1);
|
||
var color2 = rgba(2);
|
||
$.each(rel.data, function (index, val) {
|
||
TimestampALL = val.totaltime;
|
||
kwhALL += val.kwh;
|
||
//diffSOLARHOURALL += val.diffSOLARHOUR;
|
||
irradianceALL += val.irradiance;
|
||
prALL = val.pr;
|
||
tempALL += val.temp;
|
||
|
||
|
||
|
||
if (val.length != 0) {
|
||
if (groupType != 0) {
|
||
diffSOLARHOURALL += val.solarhour;
|
||
$('#HistoryDetailTable').append('<tr>' +
|
||
'<td>' + val.timestamp + '</td>' +
|
||
'<td>' + val.kwh.toFixed(2) + '</td>' +
|
||
'<td>' + val.solarhour.toFixed(2) + '</td>' +
|
||
|
||
'<td>' + val.irradiance.toFixed(2) + '</td>' +
|
||
'<td>' + val.pr.toFixed(2) + '</td>' +
|
||
'<td>' + val.temp.toFixed(2) + '</td>' +
|
||
'</tr>');
|
||
listmonth.push(val.timestamp);
|
||
listkwh.push(val.kwh);
|
||
listcolor.push(color);
|
||
listcolor2.push(color2);
|
||
listirradiance.push(val.irradiance);
|
||
}
|
||
else
|
||
{
|
||
diffSOLARHOURALL += val.diffSOLARHOUR;
|
||
$('#HistoryDetailTable').append('<tr>' +
|
||
'<td>' + val.timestamp + '</td>' +
|
||
'<td>' + val.kwh.toFixed(2) + '</td>' +
|
||
'<td>' + val.diffSOLARHOUR.toFixed(2) + '</td>' +
|
||
|
||
'<td>' + val.irradiance.toFixed(2) + '</td>' +
|
||
'<td>' + val.pr.toFixed(2) + '</td>' +
|
||
'<td>' + val.temp.toFixed(2) + '</td>' +
|
||
'</tr>');
|
||
listmonth.push(val.timestamp);
|
||
listkwh.push(val.kwh);
|
||
listcolor.push(color);
|
||
listcolor2.push(color2);
|
||
listirradiance.push(val.irradiance);
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
})
|
||
|
||
|
||
tempALL = tempALL / rel.data.length;
|
||
$('#history-kWh-convas-div').empty();
|
||
$('#history-kWh-convas-div').append('<canvas id="history-kWh"></canvas>');
|
||
var ctx_history_kWh = document.getElementById('history-kWh').getContext('2d');
|
||
var myhistorykwh = new Chart(ctx_history_kWh, {
|
||
type: 'bar',
|
||
data: {
|
||
labels: listmonth,
|
||
datasets: [{
|
||
type: 'line',
|
||
label: '日照度(kWh/㎡)',
|
||
borderColor: 'rgba(190, 45, 45,1)',
|
||
pointRadius: 4,
|
||
yAxisID: 'B',
|
||
fill: false,
|
||
data: listirradiance
|
||
}, {
|
||
type: 'bar',
|
||
backgroundColor: 'rgba(103, 180, 172, 1)',
|
||
borderWidth: 1,
|
||
label: '發電量(kWh)',
|
||
yAxisID: 'A',
|
||
data: listkwh
|
||
}]
|
||
},
|
||
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: 'kWh/㎡'
|
||
}
|
||
}]
|
||
}
|
||
}
|
||
});
|
||
|
||
|
||
|
||
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
|
||
{
|
||
$('#HistoryTotalTable').append('<tr>' +
|
||
'<td>' + TimestampALL + '</td>' +
|
||
'<td>' + kwhALL.toFixed(2) + '</td>' +
|
||
'<td>' + diffSOLARHOURALL.toFixed(2) + '</td>' +
|
||
'<td>' + irradianceALL.toFixed(2) + '</td>' +
|
||
'<td>' + prALL.toFixed(2) + '</td>' +
|
||
'<td>' + tempALL.toFixed(2) + '</td>' +
|
||
'</tr>');
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
//#endregion
|
||
|
||
|
||
</script>
|
||
}
|