修正無逆變器於 日報表中bug

This commit is contained in:
b110212000 2021-08-09 18:32:39 +08:00
parent 78af08320a
commit 2562ca3a17
7 changed files with 691 additions and 27 deletions

View File

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SolarPower.Controllers
{
public class PowerGenerationController : MyBaseController<OperationController>
{
public IActionResult Index()
{
return View();
}
}
}

View File

@ -740,6 +740,11 @@ namespace SolarPower.Controllers
PowerStation = Convert.ToInt32(powerstationid.Value),
Userid = postObject.Userid
};
var k = stationReportRepository.Findhaveinv(select_Table);
if(k.Result[0].values == null)
{
return "";
}
var Formbody = GetForm(select_Table);//取body
var Formhead = GetTableHead(select_Table);//取head
int RowPosition = 0;

View File

@ -39,6 +39,8 @@ namespace SolarPower.Quartz.Jobs
foreach (var user in users.Result)
{
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
if(powerstations.Count == 0)
@ -61,6 +63,8 @@ namespace SolarPower.Quartz.Jobs
Userid = user.Id
};
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
if(stationReportName != "")
{
NoticeSchedule DaySchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
@ -78,8 +82,7 @@ namespace SolarPower.Quartz.Jobs
"Type"
};
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
}
}
//綜合報表 每日
if(sentMaxpowerstations.Count != 0)
@ -159,6 +162,8 @@ namespace SolarPower.Quartz.Jobs
Userid = user.Id
};
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
if (stationReportmonthName != "")
{
NoticeSchedule MonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
@ -178,6 +183,8 @@ namespace SolarPower.Quartz.Jobs
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
}
}
}

View File

@ -324,5 +324,173 @@ namespace SolarPower.Repository.Implement
return result;
}
}
public async Task<dynamic> Findhaveinv(Select_table post)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
dynamic a;
conn.Open();
try
{
string sql = "";
switch (post.FormType)
{
case 0:
sql = @$"
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 4), '''')
) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation};
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
', b.KWH hourKWH, round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}'' and powerstationid = {post.PowerStation}))*100,2) ''hourKWHp'', d.irradiance ''irradiance'', d.Temperature ''temperature'',
b.money ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(b.PR, 2) as pr
FROM inverter_history_hour a left join
( # inv
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH,
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
from power_station_history_hour
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = b.report_date
left join
( # day
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
from power_station_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = c.report_date
left join
(
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')report_date, irradiance, Temperature
from sensor_history_hour
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = d.report_date
join
(
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
GROUP BY DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') ');
select @sql as 'mySelect'; #
#PREPARE stmt FROM @sql;
#EXECUTE stmt;
#DEALLOCATE PREPARE stmt;";
break;
case 1:
if (post.SearchType == 2)
{
sql = @$"
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 4), '''')
) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation};
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB
FROM inverter_history_day a left join
( # inv
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH,
round(todayKWH, 2) todayKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, ifnull(round(money, 2),0) money, round(SOLARHOUR, 2) SOLARHOUR
from power_station_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = b.report_date
left join
( # month
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m'') report_date, sitetype, round(monthKWH, 2) monthKWH,round(KWHKWP, 2) KWHKWP
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
from power_station_history_month
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = c.report_date
left join
(
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature
from sensor_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date
join
(
select id, name stationName, powerRate,SolarType,SiteDB from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id
where DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = ''{post.Time}''
GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'')
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') ');
select @sql as 'mySelect'; #
#PREPARE stmt FROM @sql;
#EXECUTE stmt;
#DEALLOCATE PREPARE stmt;";
}
else
{
var times = post.Time.Replace('-', 'a').Replace('/', '-').Replace(" ", "").Split('a');
sql = @$"SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 4), '''')
) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation};
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB
FROM inverter_history_day a left join
( # inv
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH,
round(todayKWH, 2) todayKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, ifnull(round(money, 2),0) money, round(SOLARHOUR, 2) SOLARHOUR
from power_station_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = b.report_date
left join
( # month
SELECT powerStationid, ROUND(AVG(TODAYKWH),2) AS monthKWH,
ROUND(AVG(KWHKWP),2) AS KWHKWP,
ROUND(AVG(PR),2) AS PR,
ROUND(SUM(MONEY),2) AS money,
ROUND(SUM(SOLARHOUR),2) AS SOLARHOUR
FROM power_station_history_day where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
) c on a.powerStationid = c.powerStationid
left join
(
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature
from sensor_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date
join
(
select id, name stationName, powerRate, SolarType, SiteDB from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'')
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') ');
select @sql as 'mySelect'; #
#PREPARE stmt FROM @sql;
#EXECUTE stmt;
#DEALLOCATE PREPARE stmt;";
}
break;
}
a = await conn.QueryAsync<dynamic>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return a;
}
}
}
}

View File

@ -12,5 +12,6 @@ namespace SolarPower.Repository.Interface
Task<dynamic> Gettablebody(Select_table post);
Task<List<Landinfo>> GetHire(PsIdAndSiteDB post);
Task<List<MaxFormbody>> GetMaxtablebody(Select_table2 post);
Task<dynamic> Findhaveinv(Select_table post);
}
}

View File

@ -0,0 +1,462 @@
@{
ViewData["MainNum"] = "4";
ViewData["SubNum"] = "3";
ViewData["Title"] = "電站發電收入";
}
@using SolarPower.Models.Role
@model RoleLayerEnum
<div class="container-fluid">
<div class="row flex-nowrap wrapper">
<div class="col-md-2 col-1 pl-0 pr-0 collapse width border-right sidebar vh-100">
<div class="list-group border-0 card text-center text-md-left" id="sidebar">
<div class="border bg-light rounded-top">
<div class="form-group p-2 m-0 rounded-top">
<input type="text" class="form-control form-control-lg shadow-inset-2 m-0" id="js_list_accordion_filter" placeholder="">
</div>
<div id="js_list_accordion" class="accordion accordion-hover accordion-clean js-list-filter">
<div class="card border-top-left-radius-0 border-top-right-radius-0">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-a" aria-expanded="true" data-filter-tags="settings">
<i class="fal fa-globe width-2 fs-xl"></i>
新北市
<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-a" class="collapse" data-parent="#js_list_accordion" style="">
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹交大站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-tachometer-alt-slow"></i> 電錶 R001</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-sun"></i> 日照計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-thermometer-half"></i> 環境溫度計 R003</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-wind"></i> 風速計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-sun-dust"></i> 落塵計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-tint"></i> 濕度計 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
<li class="list-group-item pr-0 d-flex justify-content-between">
<a href="#"><i class="fal fa-server"></i> 逆變器 R002</a>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</li>
</ul>
</li>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹動物園站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹火車站</h4>
<div class="">
<input type="checkbox" class="" id="defaultUnchecked">
</div>
</div>
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-b" aria-expanded="false" data-filter-tags="merge">
<i class="fal fa-globe width-2 fs-xl"></i>
台南市
<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-b" class="collapse" data-parent="#js_list_accordion">
<div class="card-body">
放台南市list
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-c" aria-expanded="false" data-filter-tags="backup">
<i class="fal fa-globe width-2 fs-xl"></i>
屏東縣
<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-c" class="collapse" data-parent="#js_list_accordion">
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">
<span data-filter-tags="reports file">Reports</span>
</li>
<li class="list-group-item">
<span data-filter-tags="analytics graphs">Analytics</span>
</li>
<li class="list-group-item">
<span data-filter-tags="export download">Export</span>
</li>
<li class="list-group-item">
<span data-filter-tags="storage">Storage</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<span class="filter-message js-filter-message"></span>
</div>
</div>
</div>
<div class="col-auto px-0">
<a href="javascript:;" id="collapse" data-target=".sidebar" data-toggle="collapse" class="btn btn-default btn-xs btn-icon waves-effect waves-themed" style="border-radius: 0;" aria-expanded="true">
<span class="collapsed-reveal"><i class="fal fa-angle-left fa-lg py-3"></i></span>
<span class="collapsed-hidden"><i class="fal fa-angle-right fa-lg py-3"></i></span>
</a>
</div>
<main class="col px-5 pl-md-2 main">
<div class="subheader">
<h1 class="subheader-title">
<i class="subheader-icon fal fa-file-chart-line"></i> @ViewData["Title"]
</h1>
</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="mb-3 d-flex justify-content-start">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" onclick="changeType(0, this)">月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" onclick="changeType(1, this)">年</button>
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-quickSearch1" onclick="quickSearch(0)">上月</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-quickSearch2" onclick="quickSearch(1)">上上月</button>
</div>
<div class="pr-3">
<div class="btn-group" id="js-demo-nesting" role="group" aria-label="Button group with nested dropdown">
<input type="month" class="form-control" id="DateGet" />
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1">查詢</button>
</div>
<div class="pr-3">
<button type="button" class="btn btn-primary waves-effect waves-themed"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="panel-5" class="panel">
<div class="panel-container show">
<div class="panel-content">
<div class="row mb-5">
<div class="col-md-12 d-flex overflow-auto justify-content-end">
<table class="table table-bordered text-center" style="width: 80.02%">
<thead>
<tr>
<th class="bg-warning-100" colspan="3">預估值 CBA</th>
<th class="bg-info-100" colspan="2">監控系統</th>
<th class="bg-success-100" colspan="2">台電售電記錄</th>
<th class="bg-primary-50" colspan="5">平均發電度數小計<br>(/kW)</th>
</tr>
<tr>
<th style="width: 6.66%">發電效能</th>
<th style="width: 6.66%">總發電量(度數)</th>
<th style="width: 6.66%">總售電收入(NT$)</th>
<th style="width: 6.66%">總發電量(度數)</th>
<th style="width: 6.66%">總售電收入(NT$)</th>
<th style="width: 6.66%">總發電量(度數)</th>
<th style="width: 6.66%">總售電收入(NT$)</th>
<th style="width: 6.66%">CBA</th>
<th style="width: 6.66%">監控系統</th>
<th style="width: 6.66%">v.s CBA</th>
<th style="width: 6.66%">Actual</th>
<th style="width: 6.66%">v.s CBA</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="col-md-12 overflow-auto">
<table class="table table-bordered text-center w-100">
<thead>
<tr>
<th class="bg-primary-50" style="width: 6.66%">起日</th>
<th class="bg-primary-50" style="width: 6.66%">起訖</th>
<th class="bg-primary-50" style="width: 6.66%">天數</th>
<th class="bg-warning-100" style="width: 6.66%">發電效能</th>
<th class="bg-warning-100" style="width: 6.66%">總發電量(度數)</th>
<th class="bg-warning-100" style="width: 6.66%">總售電收入(NT$)</th>
<th class="bg-info-100" style="width: 6.66%">總發電量(度數)</th>
<th class="bg-info-100" style="width: 6.66%">總售電收入(NT$)</th>
<th class="bg-success-100" style="width: 6.66%">總發電量(度數)</th>
<th class="bg-success-100" style="width: 6.66%">總售電收入(NT$)</th>
<th class="bg-primary-50" colspan="5">平均發電度數明細<br>(/kW/日)</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
@section Scripts{
<script>
var selecterd_powerstationId = [];
$(function () {
$('#collapse').trigger("click");
//#region 載入左邊選單列表
GetPowerStationCollapse("");
//#endregion
})
//#region 左邊的搜索欄位
//function myfunc(div) {
// var className = div.getAttribute("class");
// if (className == "fal fa-angle-left fa-lg py-3") {
// div.className = "fal fa-angle-right fa-lg py-3";
// }
// else {
// div.className = "fal fa-angle-left fa-lg py-3";
// }
//}
$("#js_list_accordion_filter").change(function (e) {
GetPowerStationCollapse($(this).val());
});
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
var getstation =
{
name: $(this).attr('valuename'),
value: this.value
}
if (this.checked) {
selecterd_powerstationId.push(getstation);
} else {
var a = selecterd_powerstationId.filter(function (n, i) {
if (n.name === getstation.name && n.value === getstation.value) {
selecterd_powerstationId.splice(i, 1);
}
});
}
$('#PowerStationId_modal').empty();
$("#PowerStationId_modal").attr("disabled", false);
$.each(selecterd_powerstationId, function (index, val) {
$("#PowerStationId_modal").append($("<option />").val(parseInt(val.value)).text(val.name));
});
if (selecterd_powerstationId.length == 0) {
$("#PowerStationId_modal").append($("<option />").val(0).text("請先選擇電站"));
$("#PowerStationId_modal").attr("disabled", true);
}
console.log(selecterd_powerstationId);
});
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList"
var send_data = {
Filter: filter
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.data.msg);
return;
}
var inverterCollapse = rel.data;
$('#js_list_accordion').empty();
if (inverterCollapse.length <= 0) {
$('#js_list_accordion').append("<div>查無結果</div>");
}
var str = "";
Object.keys(inverterCollapse).map(function (key, index) {
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">' + key + '</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-' + index + '" style="">' +
'<div class="card-body">' +
'<ul class="list-group list-group-flush">';
$.each(inverterCollapse[key], function (index, inverter) {
var getstation =
{
name: inverter.powerStationName,
value: String(inverter.powerStationId)
}
var on = false;
var a = selecterd_powerstationId.find(function (n, i) {
if (n.name === getstation.name && n.value === getstation.value) {
on = true;
}
});
if (on == true) {
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-between">' +
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + inverter.powerStationName + '</h4>' +
'<div class="">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' +
'</div>' +
'</div>' +
'</li>';
}
else {
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-between">' +
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + inverter.powerStationName + '</h4>' +
'<div class="">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' +
'</div>' +
'</div>' +
'</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");
$('input[name="selectedInverterLayer2[]"]').each(function () {
if ($.inArray(this.value, selecterd_powerstationId) > -1) {
$(this).prop('checked', true);
}
});
$("#js_list_accordion .collapse").collapse('show');
}, 'json');
}
//#endregion
//#region 更換搜尋條件(日,日區間,月,年)
function changeType(type, e) {
searchType = type;
if ($(".btn-change-searchType").hasClass("btn-success")) {
$(".btn-change-searchType").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
switch (type) {
case 0: $('#DateGet').prop({ 'type': 'month' });
$(".btn-change-quickSearch1").html("上月");
$(".btn-change-quickSearch2").html("上上月");
var dateLimit = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().substring(0, 7);
$('#DateGet').val(dateLimit);
break;
case 1:
var year = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString().substring(0, 4);
$('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': dateLimit, 'step': 1 });
$(".btn-change-quickSearch1").html("去年");
$(".btn-change-quickSearch2").html("前年");
$('#DateGet').val(year);
break;
}
}
//#endregion
</script>
}

View File

@ -271,6 +271,11 @@
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">台電售電記錄</span>
</a>
</li>
<li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"].ToString() == "3" ? "active" : "")">
<a asp-controller="PowerGeneration" asp-action="Index" title="電站發電收入" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電廠發電效能統計</span>
</a>
</li>
<li class="">
<a href="javascript:void(0);" title="報告發送記錄" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">報告發送記錄</span>