電站總覽-前頁

This commit is contained in:
b110212000 2021-07-08 11:09:13 +08:00
parent a9265f301d
commit 169498051e
3 changed files with 206 additions and 62 deletions

View File

@ -40,6 +40,8 @@ namespace SolarPower.Models
{ {
public List<int> Cityid { get; set; } //都市 public List<int> Cityid { get; set; } //都市
public List<int> Status { get; set; } //狀態 public List<int> Status { get; set; } //狀態
public int KwhOrder { get; set; }
public int PrOrder { get; set; }
} }
public class StationIds public class StationIds

View File

@ -128,6 +128,28 @@ namespace SolarPower.Repository.Implement
try try
{ {
var ids = ""; var ids = "";
var KWH = "";
var PR = "";
if(post.KwhOrder == 0)
{
KWH = " ORDER BY Today_kwh DESC";
}
else
{
KWH = " ORDER BY Today_kwh";
}
if (post.PrOrder == 0)
{
PR = ",today_PR DESC";
}
else
{
PR = ",today_PR";
}
foreach (var id in post.Cityid) foreach (var id in post.Cityid)
{ {
ids = ids + id + ","; ids = ids + id + ",";
@ -138,19 +160,19 @@ namespace SolarPower.Repository.Implement
} }
if (User.Role.Layer == 0 || User.Role.Layer == 1) if (User.Role.Layer == 0 || User.Role.Layer == 1)
{ {
var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND HealthStatus IN @Status"; var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND HealthStatus IN @Status"+ KWH + PR;
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, Status = post.Status})).ToList(); powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, Status = post.Status})).ToList();
trans.Commit(); trans.Commit();
} }
else if (User.Role.Layer == 2) else if (User.Role.Layer == 2)
{ {
var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND CompanyId=@CompanyId AND HealthStatus IN @Status"; var sql = "SELECT * FROM power_station WHERE CityId IN @IDs AND CompanyId=@CompanyId AND HealthStatus IN @Status" + KWH + PR;
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, CompanyId = User.CompanyId , Status = post.Status })).ToList(); powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, CompanyId = User.CompanyId , Status = post.Status })).ToList();
trans.Commit(); trans.Commit();
} }
else else
{ {
var sql = "SELECT power_station.* FROM power_station LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE CityId IN @IDs AND Userid = @UserId AND HealthStatus IN @Status"; var sql = "SELECT power_station.* FROM power_station LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE CityId IN @IDs AND Userid = @UserId AND HealthStatus IN @Status" + KWH + PR;
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, UserId = User.Id , Status = post.Status })).ToList(); powerstation = (await conn.QueryAsync<PowerStation>(sql, new { IDs = post.Cityid, UserId = User.Id , Status = post.Status })).ToList();
trans.Commit(); trans.Commit();
} }

View File

@ -34,21 +34,21 @@
</div> </div>
<div class="row mb-3 d-flex align-items-top px-3"> <div class="row mb-3 d-flex align-items-top px-3">
<div class="col-1 p-0"> <div class="col-1 p-0">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allpowerstation()">全選</button> <button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="AllStatus()">全選</button>
</div> </div>
<div class="col-11 p-2"> <div class="col-11 p-2">
<div class="row frame-wrap" id="CheckPowerStation"> <div class="row frame-wrap" id="CheckStatus">
<div class="col-2 mb-2 custom-control custom-checkbox d-flex align-content-center"> <div class="col-2 mb-2 custom-control custom-checkbox d-flex align-content-center">
<input type="checkbox" class="custom-control-input" id="defaultInline9" checked=""> <input type="checkbox" class="custom-control-input" id="Status_1" checked="">
<label class="custom-control-label" for="defaultInline9">設備正常 <i class="btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check"></i></label> <label class="custom-control-label" for="Status_1">設備正常 <i class="btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check"></i></label>
</div> </div>
<div class=" col-2 mb-2 custom-control custom-checkbox align-content-center"> <div class=" col-2 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" id="defaultInline10" checked=""> <input type="checkbox" class="custom-control-input" id="Status_2" checked="">
<label class="custom-control-label" for="defaultInline10">設備斷線 <i class="btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation"></i></label> <label class="custom-control-label" for="Status_2">設備斷線 <i class="btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation"></i></label>
</div> </div>
<div class="col-2 mb-2 custom-control custom-checkbox align-content-center"> <div class="col-2 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" id="defaultInline11" checked=""> <input type="checkbox" class="custom-control-input" id="Status_3" checked="">
<label class="custom-control-label" for="defaultInline11">設備異常 <i class="btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule"></i></label> <label class="custom-control-label" for="Status_3">設備異常 <i class="btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule"></i></label>
</div> </div>
</div> </div>
</div> </div>
@ -58,16 +58,16 @@
<label>排序條件</label> <label>排序條件</label>
</div> </div>
<div class="pr-3"> <div class="pr-3">
<div class="frame-wrap" id="citytest"> <div class="frame-wrap" >
<select class="form-control"> <select class="form-control" id="kwh_order">
<option value="0">發電量 - 正序</option> <option value="0">發電量 - 正序</option>
<option value="1">發電量 - 倒序</option> <option value="1">發電量 - 倒序</option>
</select> </select>
</div> </div>
</div> </div>
<div class="pr-3"> <div class="pr-3">
<div class="frame-wrap" id="citytest"> <div class="frame-wrap" >
<select class="form-control"> <select class="form-control" id="pr_order">
<option value="0">PR值 - 正序</option> <option value="0">PR值 - 正序</option>
<option value="1">PR值 - 倒序</option> <option value="1">PR值 - 倒序</option>
</select> </select>
@ -210,9 +210,15 @@
<th>編號</th> <th>編號</th>
<th>電站名稱</th> <th>電站名稱</th>
<th>裝置容量(kWp)</th> <th>裝置容量(kWp)</th>
<th>逆變器數量</th> <th>累積發電量</th>
<th>台電掛表日</th> <th>今日發電量</th>
<th></th> <th>發電小時</th>
<th>PR</th>
<th>日照</th>
<th>平均日照</th>
<th>今日收入</th>
<th>狀況</th>
<th>功能</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -244,9 +250,15 @@
<th>編號</th> <th>編號</th>
<th>電站名稱</th> <th>電站名稱</th>
<th>裝置容量(kWp)</th> <th>裝置容量(kWp)</th>
<th>逆變器數量</th> <th>累積發電量</th>
<th>台電掛表日</th> <th>今日發電量</th>
<th></th> <th>發電小時</th>
<th>PR</th>
<th>日照</th>
<th>平均日照</th>
<th>今日收入</th>
<th>狀況</th>
<th>功能</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -264,7 +276,7 @@
var ids = new Array(0);//當前選擇縣市 var ids = new Array(0);//當前選擇縣市
var powerids = new Array(0);//當前選擇電站 var powerids = new Array(0);//當前選擇電站
var Allids = new Array(0);//全部縣市 var Allids = new Array(0);//全部縣市
var Allpowerids = new Array(0);//全部電站 var status123 = new Array(0);//狀態
//#region Array.Remove //#region Array.Remove
Array.prototype.remove = function (val) { Array.prototype.remove = function (val) {
var index = this.indexOf(val); var index = this.indexOf(val);
@ -275,6 +287,8 @@
//#endregion //#endregion
$(function () { $(function () {
status123 = [];
var Nurl = "/PowerStation/GetSolarCitySummary"; var Nurl = "/PowerStation/GetSolarCitySummary";
$.post(Nurl, function (rel) { $.post(Nurl, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -290,6 +304,9 @@
ids.push(rel.data[i].cityId); ids.push(rel.data[i].cityId);
Allids.push(rel.data[i].cityId); Allids.push(rel.data[i].cityId);
} }
status123.push(1);
status123.push(2);
status123.push(3);
getStation(ids); getStation(ids);
}, 'json'); }, 'json');
@ -299,11 +316,7 @@
$('#citytest').on("click", "button", function () { $('#citytest').on("click", "button", function () {
var clickid = $(this).attr('id'); var clickid = $(this).attr('id');
var classid = clickid.split("_"); var classid = clickid.split("_");
var Newpowerids = new Array(0);
var value = document.getElementById(clickid).className; var value = document.getElementById(clickid).className;
ids.sort(function (a, b) {
return a - b;
});
if (value == 'btn btn-outline-success waves-effect waves-themed ml-2') { //選擇 if (value == 'btn btn-outline-success waves-effect waves-themed ml-2') { //選擇
document.getElementById(clickid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2'); document.getElementById(clickid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(Number(classid[1])); ids.push(Number(classid[1]));
@ -317,47 +330,109 @@
function getStation(ids) function getStation(ids)
{ {
var status = [1,2,3]; var kwh = $('#kwh_order').val();
var pr = $('#pr_order').val();
var send_data = { var send_data = {
cityid: ids, cityid: ids,
status: status, status: status123,
kwhOrder: kwh,
prOrder: pr
}; };
//ids.sort(function (a, b) { ids.sort(function (a, b) {
// return a - b; return a - b;
//}); });
//ids.sort(); ids.sort();
var Nurl = "/StationOverview/GetSolarByCity"; if (ids.length == 0 || status123.length == 0) {
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#areaCard').empty(); $('#areaCard').empty();
$.each(rel.data, function (index, val) { $('#solarTable').find('tbody').empty();
$('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard')); $("#today_kwh").html(0);
$('#card_' + val.id).find('#solarName').html(val.name); $("#total_kwh").html(0);
$('#card_' + val.id).find('#Temp').html(val.todayWeatherTemp); $("#today_irradiance").html(0);
var type = ""; $("#avg_irradiance").html(0);
switch (val.solarType) { $("#today_PR").html(0);
case 0: type = "自建躉售"; break; $("#avg_PR").html(0);
case 1: type = "租建躉售"; break; $("#today_kwhkwp").html(0);
case 2: type = "自建自用"; break; $("#avg_kwhkwp").html(0);
default: $("#today_carbon").html(0);
console.log(`Sorry, we are out of ${val.solarType}.`); $("#total_power_station_count").html(0);
$("#total_capacity").html(0);
$("#update_at").html(0);
}
else
{
var Nurl = "/StationOverview/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
} }
$('#card_' + val.id).find('#stationtype').html(type); $('#areaCard').empty();
var time = new Date(val.createdAt); $('#solarTable').find('tbody').empty();
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id); powerids = [];
$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes()); $.each(rel.data, function (index, val) {
$('#card_' + val.id).find('#Capacity').html(val.generatingCapacity); $('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard'));
$('#card_' + val.id).find('#PowerRate').html(val.generatingCapacity * val.powerRate); var statusicon;
$('#card_' + val.id).find('#PR').html(val.pr); switch (val.healthStatus) {
$('#card_' + val.id).find('#aria').attr('aria-valuenow', val.pr); case 1: statusicon = "<i class='btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-check'></i>"; break;
$('#card_' + val.id).find('#aria').attr('style', "width:" + val.pr + "%;"); case 2: statusicon = "<i class='btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation'></i>"; break;
powerids.push(val.id); case 3: statusicon = "<i class='btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule'></i>"; break;
}); default:
GetStationCard(); statusicon = 'NULL'; break;
}, 'json'); }
$('#card_' + val.id).find('#solarName').html(statusicon + val.name);
$('#card_' + val.id).find('#Temp').html(val.todayWeatherTemp);
var type = "";
switch (val.solarType) {
case 0: type = "自建躉售"; break;
case 1: type = "租建躉售"; break;
case 2: type = "自建自用"; break;
default:
console.log(`Sorry, we are out of ${val.solarType}.`);
}
$('#card_' + val.id).find('#stationtype').html(type);
var time = new Date(val.createdAt);
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id);
$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
$('#card_' + val.id).find('#Capacity').html(val.today_kWh);
$('#card_' + val.id).find('#PowerRate').html(val.today_kWh * val.powerRate);
$('#card_' + val.id).find('#PR').html(val.today_PR);
$('#card_' + val.id).find('#aria').attr('aria-valuenow', val.today_PR);
$('#card_' + val.id).find('#aria').attr('style', "width:" + val.today_PR + "%;");
powerids.push(val.id);
var statusName;
switch (val.healthStatus) {
case 1:
statusName = "設備正常";
break;
case 2:
statusName = "設備斷線";
break;
case 3:
statusName = "設備異常";
break;
default:
statusName = "NULL";
}
$('#solarTable').find('tbody').append('<tr>' +
'<td>' + val.code + '</td>' +
'<td>' + val.name + '</td>' +
'<td>' + val.generatingCapacity + '</td>' +
'<td>' + val.total_kWh + '</td>' +
'<td>' + val.today_kWh + '</td>' +
'<td>' + val.solarHour + '</td>' +
'<td>' + val.today_PR + '</td>' +
'<td>' + val.today_irradiance + '</td>' +
'<td>' + val.avg_irradiance + '</td>' +
'<td>' + val.today_Monery + '</td>' +
'<td>' + statusName + '</td>' +
'<td><button type="button" class="btn btn-primary btn-pills waves-effect waves-themed" onclick="location.href=\'' + localurl + '/Info?stationId=' + val.id + '\'">選擇</button></td>' +
'</tr>');
});
GetStationCard();
}, 'json');
}
} }
function GetStationCard() function GetStationCard()
{ {
@ -386,7 +461,52 @@
}); });
} }
//#region 選擇狀態checkbox
$('#CheckStatus').on("click", "input", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
status123.push(Number(classid[1]));
}
else {
status123.remove(Number(classid[1]));
}
getStation(ids);
})
//#endregion
$('#kwh_order').change(function () {
getStation(ids);
})
$('#pr_order').change(function () {
getStation(ids);
})
//#region 縣市全選
function Allcity() {
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
});
getStation(ids);
}
//#endregion
//#region 狀態全選
function AllStatus() {
status123 = [];
for (var i = 1; i <= 3; i++)
{
$('#Status_' + i).prop("checked", true);
status123.push(i);
}
getStation(ids);
}
//#endregion
function CardDisplay() { function CardDisplay() {