Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
e60a82eaeb
@ -1,16 +1,52 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SolarPower.Repository.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using SolarPower.Models;
|
||||||
|
using SolarPower.Models.PowerStation;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace SolarPower.Controllers
|
namespace SolarPower.Controllers
|
||||||
{
|
{
|
||||||
public class PowerGenerationController : MyBaseController<OperationController>
|
public class PowerGenerationController : MyBaseController<PowerGenerationController>
|
||||||
{
|
{
|
||||||
|
private readonly IElectricitySoldRecordRepository electricitySoldRecordRepository;
|
||||||
|
private readonly IPowerStationRepository powerStationRepository;
|
||||||
|
|
||||||
|
public PowerGenerationController(IElectricitySoldRecordRepository electricitySoldRecordRepository, IPowerStationRepository powerStationRepository) : base()
|
||||||
|
{
|
||||||
|
this.electricitySoldRecordRepository = electricitySoldRecordRepository;
|
||||||
|
this.powerStationRepository = powerStationRepository;
|
||||||
|
}
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<List<Generation>>> GetGenerationList (SearchGeneration post)
|
||||||
|
{
|
||||||
|
ApiResult<List<Generation>> apiResult = new ApiResult<List<Generation>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var GenerationList = await electricitySoldRecordRepository.GetGenerationList(post);
|
||||||
|
apiResult.Data = GenerationList;
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "info=" + System.Text.Json.JsonSerializer.Serialize(post));
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,48 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<Dictionary<string, List<PowerStationIdAndCity>>>> GetPowerStationNameListForGeneration(string filter)
|
||||||
|
{
|
||||||
|
ApiResult<Dictionary<string, List<PowerStationIdAndCity>>> apiResult = new ApiResult<Dictionary<string, List<PowerStationIdAndCity>>>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var powerStations = new List<PowerStationIdAndCity>();
|
||||||
|
if (IsPlatformLayer(myUser.Role.Layer))
|
||||||
|
{
|
||||||
|
powerStations = await powerStationRepository.GetPowerStationsAllWithfilterForGeneration(filter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerStations = await powerStationRepository.GetPowerStationsByCompanyIdWithfilterForGeneration(myUser, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
var siteDBNamePowerStationId = new Dictionary<string, List<PowerStationIdAndCity>>();
|
||||||
|
|
||||||
|
var powerStation_Group = powerStations.GroupBy(x => x.CityName).ToList();
|
||||||
|
foreach (var stations in powerStation_Group)
|
||||||
|
{
|
||||||
|
siteDBNamePowerStationId.Add(stations.Key, stations.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
|
||||||
|
apiResult.Data = siteDBNamePowerStationId;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】");
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<ApiResult<InvAndMoney>> GetTableHead(Select_table post)
|
public async Task<ApiResult<InvAndMoney>> GetTableHead(Select_table post)
|
||||||
{
|
{
|
||||||
ApiResult<InvAndMoney> apiResult = new ApiResult<InvAndMoney>();
|
ApiResult<InvAndMoney> apiResult = new ApiResult<InvAndMoney>();
|
||||||
|
|||||||
@ -52,4 +52,28 @@ namespace SolarPower.Models
|
|||||||
public string PowerName { get; set; }
|
public string PowerName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Generation
|
||||||
|
{
|
||||||
|
private string startAt;
|
||||||
|
public string StartAt { get { return Convert.ToDateTime(startAt).ToString("yyyy/MM/dd"); } set { startAt = value; } }
|
||||||
|
private string endAt;
|
||||||
|
public string EndAt { get { return Convert.ToDateTime(endAt).ToString("yyyy/MM/dd"); } set { endAt = value; } }
|
||||||
|
public double actualkwh { get; set; }
|
||||||
|
public double actualMoney { get; set; }
|
||||||
|
public double realKWH { get; set; }
|
||||||
|
public double realMoney { get; set; }
|
||||||
|
public double CBAkwh { get; set; }
|
||||||
|
public double CBAeff { get; set; }
|
||||||
|
public double capacity { get; set; }
|
||||||
|
public double rate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SearchGeneration
|
||||||
|
{
|
||||||
|
public int DateType { get; set; }
|
||||||
|
public string Date { get; set; }
|
||||||
|
public int PowerstationId { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -100,5 +100,38 @@ namespace SolarPower.Repository.Implement
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<Generation>> GetGenerationList (SearchGeneration info)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
List<Generation> a = new List<Generation>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlwhere = (info.DateType) switch
|
||||||
|
{
|
||||||
|
0 => $"DATE_FORMAT(er.StartAt,'%Y-%m') = '{info.Date}'",//月
|
||||||
|
_ => $"DATE_FORMAT(er.StartAt,'%Y') = '{info.Date}'"//年
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var sql = @$"SELECT aa.StartAt,aa.EndAt,aa.Kwh actualkwh,aa.Money actualMoney,SUM(pd.TODAYKWH) realKWH,SUM(pd.MONEY) realMoney,ps.Estimate_kwh CBAkwh,ps.EstimateEfficacy CBAeff ,ps.GeneratingCapacity capacity ,ps.PowerRate rate
|
||||||
|
FROM power_station_history_day pd
|
||||||
|
LEFT JOIN ( SELECT er.* FROM electricity_sold_record er WHERE {sqlwhere} AND er.Deleted = 0 ) aa
|
||||||
|
ON aa.PowerstationId = pd.PowerStationId
|
||||||
|
LEFT JOIN power_station ps ON ps.Id = pd.PowerStationId
|
||||||
|
WHERE pd.TIMESTAMP BETWEEN aa.StartAt AND aa.EndAt AND ps.Id = {info.PowerstationId} GROUP BY aa.Id";
|
||||||
|
|
||||||
|
|
||||||
|
a = (await conn.QueryAsync<Generation>(sql)).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5089,5 +5089,64 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilterForGeneration(string filter)
|
||||||
|
{
|
||||||
|
List<PowerStationIdAndCity> result;
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @$"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,city.Name AS CityName FROM {tableName} ps
|
||||||
|
LEFT JOIN city ON city.Id = ps.CityId WHERE ps.Deleted = 0 AND SolarType = 0";
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter))
|
||||||
|
{
|
||||||
|
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||||
|
}
|
||||||
|
result = (await conn.QueryAsync<PowerStationIdAndCity>(sql, new { Filter = filter })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilterForGeneration(MyUser myUser, string filter)
|
||||||
|
{
|
||||||
|
List<PowerStationIdAndCity> result;
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $@"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,city.Name AS CityName FROM {tableName} ps
|
||||||
|
LEFT JOIN city ON city.Id = ps.CityId";
|
||||||
|
|
||||||
|
if (myUser.Role.Layer == 2)
|
||||||
|
{
|
||||||
|
sql += " WHERE ps.Deleted = 0 AND ps.CompanyId = @CompanyId AND SolarType = 0 ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql += @" LEFT JOIN power_station_operation_personnel op ON ps.Id = op.PowerStationId
|
||||||
|
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId AND SolarType = 0 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter))
|
||||||
|
{
|
||||||
|
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||||
|
}
|
||||||
|
result = (await conn.QueryAsync<PowerStationIdAndCity>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
{
|
{
|
||||||
Task<List<ElectricitySoldRecordTable>> RecordTable(ElectricitySoldRecordTablePost post);
|
Task<List<ElectricitySoldRecordTable>> RecordTable(ElectricitySoldRecordTablePost post);
|
||||||
Task<BillInfo> GetBill(int id);
|
Task<BillInfo> GetBill(int id);
|
||||||
|
Task<List<Generation>> GetGenerationList(SearchGeneration info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -587,8 +587,9 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task AddAfterPurgeSensorAvgHistory(string startDate, string endDate, byte type, List<SensorAvgHistory> entity, List<string> properties);
|
Task AddAfterPurgeSensorAvgHistory(string startDate, string endDate, byte type, List<SensorAvgHistory> entity, List<string> properties);
|
||||||
Task<bool> CheckShowMoney(int userid);
|
Task<bool> CheckShowMoney(int userid);
|
||||||
Task<List<InverterHistory>> GetAllInverterRowData(string date, string table_name);
|
Task<List<InverterHistory>> GetAllInverterRowData(string date, string table_name);
|
||||||
|
|
||||||
Task<List<InverterHistory>> GetAllInverterInfo(List<string> post, string site_table, string site_db);
|
Task<List<InverterHistory>> GetAllInverterInfo(List<string> post, string site_table, string site_db);
|
||||||
Task<InverterDetailModal> GetInverterInfoModal(int Id, string Time, string DB, string Table);
|
Task<InverterDetailModal> GetInverterInfoModal(int Id, string Time, string DB, string Table);
|
||||||
|
Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilterForGeneration(string filter);
|
||||||
|
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilterForGeneration(MyUser myUser, string filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,7 +188,7 @@
|
|||||||
<div class="mb-3 d-flex justify-content-start">
|
<div class="mb-3 d-flex justify-content-start">
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<div class="btn-group btn-group-md">
|
<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(0, this)" id="firstclick">月</button>
|
||||||
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" onclick="changeType(1, this)">年</button>
|
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" onclick="changeType(1, this)">年</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -202,13 +202,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1">查詢</button>
|
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1" onclick="Search()">查詢</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 d-flex justify-content-start">
|
||||||
<div class="pr-3">
|
<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>
|
<button type="button" class="btn btn-primary waves-effect waves-themed" onclick="ExportExcel()"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="pr-3" id="selectOneStation">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -229,13 +234,13 @@
|
|||||||
<th class="bg-primary-50" colspan="5">平均發電度數小計<br>(/kW)</th>
|
<th class="bg-primary-50" colspan="5">平均發電度數小計<br>(/kW)</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 6.66%">發電效能</th>
|
<th style="width: 6.66%">建置容量(kW)</th>
|
||||||
<th style="width: 6.66%">總發電量(度數)</th>
|
<th style="width: 6.66%">總發電量(度數)</th>
|
||||||
<th style="width: 6.66%">總售電收入(NT$)</th>
|
<th style="width: 6.66%">售電單價(NT$/度)</th>
|
||||||
<th style="width: 6.66%">總發電量(度數)</th>
|
<th style="width: 6.66%">建置容量(kW)</th>
|
||||||
<th style="width: 6.66%">總售電收入(NT$)</th>
|
<th style="width: 6.66%">售電單價(NT$/度)</th>
|
||||||
<th style="width: 6.66%">總發電量(度數)</th>
|
<th style="width: 6.66%">建置容量(kW)</th>
|
||||||
<th style="width: 6.66%">總售電收入(NT$)</th>
|
<th style="width: 6.66%">售電單價(NT$/度)</th>
|
||||||
<th style="width: 6.66%">CBA</th>
|
<th style="width: 6.66%">CBA</th>
|
||||||
<th style="width: 6.66%">監控系統</th>
|
<th style="width: 6.66%">監控系統</th>
|
||||||
<th style="width: 6.66%">v.s CBA</th>
|
<th style="width: 6.66%">v.s CBA</th>
|
||||||
@ -243,7 +248,7 @@
|
|||||||
<th style="width: 6.66%">v.s CBA</th>
|
<th style="width: 6.66%">v.s CBA</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody id="totalbody">
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -264,7 +269,7 @@
|
|||||||
<th class="bg-primary-50" colspan="5">平均發電度數明細<br>(/kW/日)</th>
|
<th class="bg-primary-50" colspan="5">平均發電度數明細<br>(/kW/日)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody id="asbody">
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -278,27 +283,46 @@
|
|||||||
</div>
|
</div>
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script>
|
<script>
|
||||||
|
var nowpowerstation = null;//選擇電站
|
||||||
var selecterd_powerstationId = [];
|
var selecterd_powerstationId = [];
|
||||||
|
var searchType;
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#collapse').trigger("click");
|
$('#collapse').trigger("click");
|
||||||
|
$('#firstclick').trigger("click");
|
||||||
//#region 載入左邊選單列表
|
//#region 載入左邊選單列表
|
||||||
GetPowerStationCollapse("");
|
GetPowerStationCollapse("");
|
||||||
//#endregion
|
//#endregion
|
||||||
})
|
})
|
||||||
|
//#region 顯示動態選取電站
|
||||||
|
function AddButtonWithStation() {
|
||||||
|
$('#selectOneStation').empty();
|
||||||
|
var stri = '';
|
||||||
|
$.each(selecterd_powerstationId, function (index, inverter) {
|
||||||
|
if (inverter.value == nowpowerstation) {
|
||||||
|
stri += '<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="' + inverter.value + '" onclick="selectPowerStation(' + inverter.value + ',this) ">' + inverter.name + '</button>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stri += '<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="' + inverter.value + '" onclick="selectPowerStation(' + inverter.value + ',this) ">' + inverter.name + '</button>';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$('#selectOneStation').append(stri);
|
||||||
|
if (nowpowerstation == null && selecterd_powerstationId.length > 0) {
|
||||||
|
document.getElementById(selecterd_powerstationId[0].value).onclick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 選擇動態選取電站
|
||||||
|
function selectPowerStation(a, e) {
|
||||||
|
nowpowerstation = a;
|
||||||
|
if ($('#selectOneStation').find('.btn-station').hasClass("btn-success")) {
|
||||||
|
$('#selectOneStation').find('.btn-station').removeClass("btn-success").addClass("btn-outline-success");
|
||||||
|
}
|
||||||
|
$(e).removeClass("btn-outline-success").addClass("btn-success");
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region 左邊的搜索欄位
|
//#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) {
|
$("#js_list_accordion_filter").change(function (e) {
|
||||||
GetPowerStationCollapse($(this).val());
|
GetPowerStationCollapse($(this).val());
|
||||||
});
|
});
|
||||||
@ -316,29 +340,20 @@
|
|||||||
var a = selecterd_powerstationId.filter(function (n, i) {
|
var a = selecterd_powerstationId.filter(function (n, i) {
|
||||||
|
|
||||||
if (n.name === getstation.name && n.value === getstation.value) {
|
if (n.name === getstation.name && n.value === getstation.value) {
|
||||||
|
if (nowpowerstation == getstation.value) {
|
||||||
|
nowpowerstation = null;
|
||||||
|
}
|
||||||
selecterd_powerstationId.splice(i, 1);
|
selecterd_powerstationId.splice(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
AddButtonWithStation();
|
||||||
$('#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) {
|
function GetPowerStationCollapse(filter) {
|
||||||
var url = "/StationReport/GetPowerStationNameList"
|
var url = "/StationReport/GetPowerStationNameListForGeneration"
|
||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
Filter: filter
|
Filter: filter
|
||||||
@ -458,5 +473,123 @@
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 快速填入條件(EX.今昨天)
|
||||||
|
function quickSearch(day) {
|
||||||
|
switch (searchType) {
|
||||||
|
case 0:
|
||||||
|
if (day == 0) {
|
||||||
|
var dateLimit = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().substring(0, 7);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
} else {
|
||||||
|
var dateLimit = new Date(new Date().setMonth(new Date().getMonth() - 2)).toISOString().substring(0, 7);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (day == 0) {
|
||||||
|
var dateLimit = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString().substring(0, 4);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
} else {
|
||||||
|
var dateLimit = new Date(new Date().setFullYear(new Date().getFullYear() - 2)).toISOString().substring(0, 4);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
function Search() {
|
||||||
|
var url = "/PowerGeneration/GetGenerationList"
|
||||||
|
var send_data = {
|
||||||
|
PowerstationId: nowpowerstation,
|
||||||
|
DateType: searchType,
|
||||||
|
Date: $('#DateGet').val()
|
||||||
|
}
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var str = "";
|
||||||
|
var totaldays = 0;
|
||||||
|
var capacity = 0;
|
||||||
|
var rate = 0;
|
||||||
|
var totalcbAkwh = 0;
|
||||||
|
var totalactualkwh = 0;
|
||||||
|
var totalrealKWH = 0;
|
||||||
|
$('#totalbody').empty();
|
||||||
|
$('#asbody').empty();
|
||||||
|
|
||||||
|
|
||||||
|
if (rel.data.length == 0)
|
||||||
|
{
|
||||||
|
str += "<tr>";
|
||||||
|
str += "<td colspan='15'>" + "查無資料" + "</td>";
|
||||||
|
str += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(rel.data, function (index, val) {
|
||||||
|
var day1 = new Date(val.startAt);
|
||||||
|
var day2 = new Date(val.endAt);
|
||||||
|
var difference = Math.abs(day2 - day1);
|
||||||
|
var days = difference / (1000 * 3600 * 24) + 1;
|
||||||
|
totaldays += days;
|
||||||
|
capacity = val.capacity;
|
||||||
|
totalcbAkwh += val.cbAkwh;
|
||||||
|
rate = val.rate;
|
||||||
|
totalactualkwh += val.actualkwh;
|
||||||
|
totalrealKWH += val.realKWH;
|
||||||
|
|
||||||
|
str += "<tr>";
|
||||||
|
str += "<td>" + val.startAt + "</td>";
|
||||||
|
str += "<td>" + val.endAt + "</td>";
|
||||||
|
str += "<td>" + days + "天" + "</td>";
|
||||||
|
str += "<td>" + val.cbAeff + "%" + "</td>";
|
||||||
|
str += "<td>" + val.cbAkwh + "</td>";
|
||||||
|
str += "<td>" + val.rate * val.cbAkwh + "</td>";
|
||||||
|
str += "<td>" + val.realKWH.toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + val.realMoney.toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + val.actualkwh.toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + val.actualMoney.toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + (val.cbAkwh / days / val.capacity).toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + (val.realKWH / days / val.capacity).toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + ((val.cbAkwh == 0) ? 0 :((val.realKWH / days / val.capacity) / (val.cbAkwh / days / val.capacity)).toFixed(2) - 1) + "%" + "</td>";
|
||||||
|
str += "<td>" + (val.actualkwh / days / val.capacity).toFixed(2) + "</td>";
|
||||||
|
str += "<td>" + ((val.cbAkwh == 0) ? 0 : ((val.actualkwh / days / val.capacity) / (val.cbAkwh / days / val.capacity)).toFixed(2) - 1) + "%" + "</td>";
|
||||||
|
str += "</tr>";
|
||||||
|
})
|
||||||
|
var checkvalue = false;
|
||||||
|
if (totalcbAkwh == 0 || totaldays == 0 || capacity == 0)
|
||||||
|
{
|
||||||
|
checkvalue = true;
|
||||||
|
}
|
||||||
|
var stra = "";
|
||||||
|
stra += "<tr>";
|
||||||
|
stra += "<td>" + capacity + "</td>";
|
||||||
|
stra += "<td>" + totalcbAkwh + "</td>";
|
||||||
|
stra += "<td>" + rate + "</td>";
|
||||||
|
stra += "<td>" + capacity + "</td>";
|
||||||
|
stra += "<td>" + rate + "</td>";
|
||||||
|
stra += "<td>" + capacity + "</td>";
|
||||||
|
stra += "<td>" + rate + "</td>";
|
||||||
|
stra += "<td>" + (checkvalue ? 0 : (totalcbAkwh / totaldays / capacity).toFixed(2)) + "</td>";
|
||||||
|
stra += "<td>" + ((totaldays == 0) ? 0 : (totalrealKWH / totaldays / capacity).toFixed(2)) + "</td>";
|
||||||
|
stra += "<td>" + (checkvalue ? 0 : ((totalrealKWH / totaldays / capacity) / (totalcbAkwh / totaldays / capacity)).toFixed(2) - 1) + "%" + "</td>";
|
||||||
|
stra += "<td>" + ((totaldays == 0) ? 0 : (totalactualkwh / totaldays / capacity).toFixed(2)) + "</td>";
|
||||||
|
stra += "<td>" + (checkvalue ? 0 : ((totalactualkwh / totaldays / capacity) / (totalcbAkwh / totaldays / capacity)).toFixed(2) - 1) + "%" + "</td>";
|
||||||
|
stra += "</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
$('#totalbody').append(stra);
|
||||||
|
$('#asbody').append(str);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@
|
|||||||
<div class="row mb-5 d-flex justify-content-between ">
|
<div class="row mb-5 d-flex justify-content-between ">
|
||||||
<div class="col-xl-3 row justify-content-center align-items-center">
|
<div class="col-xl-3 row justify-content-center align-items-center">
|
||||||
<label class="col-xl-4 form-label" id="coordinate_label" for="coordinate">
|
<label class="col-xl-4 form-label" id="coordinate_label" for="coordinate">
|
||||||
預估發電度數(kW/日)
|
預估發電效能
|
||||||
</label>
|
</label>
|
||||||
<div class="col-xl-8">
|
<div class="col-xl-8">
|
||||||
<label id="estimate_efficacy_text" class="color-info-600"></label>
|
<label id="estimate_efficacy_text" class="color-info-600"></label>
|
||||||
|
|||||||
@ -55,6 +55,14 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</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_History"))
|
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_History"))
|
||||||
{
|
{
|
||||||
@ -65,14 +73,7 @@
|
|||||||
</li>
|
</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"))
|
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Exception"))
|
||||||
{
|
{
|
||||||
@ -113,6 +114,13 @@
|
|||||||
@Html.Partial("_InverterInfo")
|
@Html.Partial("_InverterInfo")
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Inverter"))
|
||||||
|
{
|
||||||
|
<div class="tab-pane fade" id="tab-overview-inverter" role="tabpanel" aria-labelledby="tab-overview-inverter">
|
||||||
|
@Html.Partial("_Inverter")
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_History"))
|
@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">
|
<div class="tab-pane fade" id="tab-overview-history" role="tabpanel" aria-labelledby="tab-overview-history">
|
||||||
@ -121,13 +129,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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"))
|
@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">
|
<div class="tab-pane fade" id="tab-overview-exception" role="tabpanel" aria-labelledby="tab-overview-exception">
|
||||||
@ -2607,8 +2608,45 @@
|
|||||||
}
|
}
|
||||||
$("#Invertercard-type").html(TypeName);
|
$("#Invertercard-type").html(TypeName);
|
||||||
var time = new Date(rel.data.createdAt);
|
var time = new Date(rel.data.createdAt);
|
||||||
$("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes())
|
$("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
|
||||||
$("#Invertercard").find('.card-img-top').attr('src', "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay);
|
|
||||||
|
|
||||||
|
var urlPath = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay;
|
||||||
|
var xmlhttp;
|
||||||
|
if (window.XMLHttpRequest) {
|
||||||
|
xmlhttp = new XMLHttpRequest();//其他浏览器
|
||||||
|
}
|
||||||
|
else if (window.ActiveXObject) {
|
||||||
|
try {
|
||||||
|
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");//旧版IE
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
try {
|
||||||
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//新版IE
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
if (!xmlhttp) {
|
||||||
|
window.alert("不能创建XMLHttpRequest对象");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmlhttp.open("GET", urlPath, false);
|
||||||
|
xmlhttp.send();
|
||||||
|
var roadtourl;
|
||||||
|
if (xmlhttp.readyState == 4) {
|
||||||
|
if (xmlhttp.status == 200) {
|
||||||
|
roadtourl = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay;
|
||||||
|
} //url存在
|
||||||
|
else if (xmlhttp.status == 404) {
|
||||||
|
roadtourl = "../img/blank.gif";
|
||||||
|
} //url不存在
|
||||||
|
else {
|
||||||
|
roadtourl = "";
|
||||||
|
}//其他狀態
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#Invertercard").find('.card-img-top').attr('src', roadtourl);
|
||||||
$('#Invertercard-Temp').html(rel.data.todayWeatherTemp + '°C');
|
$('#Invertercard-Temp').html(rel.data.todayWeatherTemp + '°C');
|
||||||
$('#Invertercard-weathericon').attr("class", 'fal fa-' + rel.data.todayWeather + ' fa-2x');
|
$('#Invertercard-weathericon').attr("class", 'fal fa-' + rel.data.todayWeather + ' fa-2x');
|
||||||
stationDB = rel.data.siteDB;
|
stationDB = rel.data.siteDB;
|
||||||
|
|||||||
@ -127,7 +127,7 @@
|
|||||||
<div class="row mb-5 d-flex justify-content-between ">
|
<div class="row mb-5 d-flex justify-content-between ">
|
||||||
<div class="col-xl-3 row justify-content-center align-items-center">
|
<div class="col-xl-3 row justify-content-center align-items-center">
|
||||||
<label class="col-xl-4 form-label" id="coordinate_label" for="coordinate">
|
<label class="col-xl-4 form-label" id="coordinate_label" for="coordinate">
|
||||||
預估發電度數(kW/日)
|
預估發電效能
|
||||||
</label>
|
</label>
|
||||||
<div class="col-xl-8">
|
<div class="col-xl-8">
|
||||||
<label id="estimate_efficacy_text" class="color-info-600"></label>
|
<label id="estimate_efficacy_text" class="color-info-600"></label>
|
||||||
|
|||||||
@ -151,9 +151,17 @@ namespace solarApp.Service
|
|||||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
string sql = @" select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg
|
//string sql = @" select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg
|
||||||
|
// from sensor_history_day a join power_station b on a.PowerStationId = b.id
|
||||||
|
// where left(`TIMESTAMP`, 10) between '" + date1 + "' and '"+date2+"' and b.`code` = @siteID";
|
||||||
|
string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H') reportdate, b.`code` siteid, round(Irradiance, 2) irrAvg, round(Temperature, 2) modelTempAvg, c.count
|
||||||
from sensor_history_day a join power_station b on a.PowerStationId = b.id
|
from sensor_history_day a join power_station b on a.PowerStationId = b.id
|
||||||
where left(`TIMESTAMP`, 10) between '" + date1 + "' and '"+date2+"' and b.`code` = @siteID";
|
join (
|
||||||
|
select PowerStationId, left(a.`TIMESTAMP`, 10) reportDate, count(*) count from sensor_history_hour a join power_station b on a.PowerStationId = b.id
|
||||||
|
where b.`code` = @siteID and left(`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"'
|
||||||
|
group by PowerStationId, left(a.`TIMESTAMP`, 10)
|
||||||
|
)c on a.PowerStationId = c.PowerStationId and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = c.reportDate
|
||||||
|
where left(a.`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"' and b.`code` = @siteID";
|
||||||
List<sensor_hour> ds = conn.Query<sensor_hour>(sql, new { siteID = siteID }).AsList<sensor_hour>();
|
List<sensor_hour> ds = conn.Query<sensor_hour>(sql, new { siteID = siteID }).AsList<sensor_hour>();
|
||||||
conn.Close();
|
conn.Close();
|
||||||
return ds;
|
return ds;
|
||||||
|
|||||||
3
solarApp/fmMain.Designer.cs
generated
3
solarApp/fmMain.Designer.cs
generated
@ -1409,6 +1409,7 @@ namespace solarApp
|
|||||||
this.gv_web_sensor_day.RowTemplate.Height = 25;
|
this.gv_web_sensor_day.RowTemplate.Height = 25;
|
||||||
this.gv_web_sensor_day.Size = new System.Drawing.Size(666, 253);
|
this.gv_web_sensor_day.Size = new System.Drawing.Size(666, 253);
|
||||||
this.gv_web_sensor_day.TabIndex = 4;
|
this.gv_web_sensor_day.TabIndex = 4;
|
||||||
|
this.gv_web_sensor_day.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gv_web_sensor_day_CellFormatting);
|
||||||
//
|
//
|
||||||
// panel12
|
// panel12
|
||||||
//
|
//
|
||||||
@ -1649,7 +1650,7 @@ namespace solarApp
|
|||||||
this.Controls.Add(this.tabControl1);
|
this.Controls.Add(this.tabControl1);
|
||||||
this.Name = "fmMain";
|
this.Name = "fmMain";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "太陽能電站數據檢核 V0729";
|
this.Text = "太陽能電站數據檢核 V0817";
|
||||||
this.Load += new System.EventHandler(this.fmMain_Load);
|
this.Load += new System.EventHandler(this.fmMain_Load);
|
||||||
this.tabControl1.ResumeLayout(false);
|
this.tabControl1.ResumeLayout(false);
|
||||||
this.tb_inv.ResumeLayout(false);
|
this.tb_inv.ResumeLayout(false);
|
||||||
|
|||||||
@ -267,5 +267,16 @@ namespace solarApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void gv_web_sensor_day_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
||||||
|
{
|
||||||
|
if (gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value != null && !string.IsNullOrWhiteSpace(gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value.ToString()))
|
||||||
|
{
|
||||||
|
if (gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Value.ToString() != "24")
|
||||||
|
{
|
||||||
|
gv_web_sensor_day.Rows[e.RowIndex].Cells["count"].Style = new DataGridViewCellStyle { ForeColor = Color.Red, BackColor = Color.White };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user