修改電站抓取方式 part3
This commit is contained in:
parent
b6df06db6c
commit
bb3bd49bc2
@ -42,8 +42,7 @@ namespace SolarPower.Controllers
|
|||||||
MapOverview mapOverview = new MapOverview();
|
MapOverview mapOverview = new MapOverview();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MyPowerStationService myPowerStationService = new MyPowerStationService(powerStationRepository);
|
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
|
||||||
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser);
|
|
||||||
|
|
||||||
List<int> powerStationIds = myPowerStations.SelectMany(x => x.MyPowerStations.Select(y => y.Id)).ToList();
|
List<int> powerStationIds = myPowerStations.SelectMany(x => x.MyPowerStations.Select(y => y.Id)).ToList();
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,7 @@ namespace SolarPower.Controllers
|
|||||||
public string baseURL => HttpContext?.Request.Scheme + "://" + HttpContext?.Request.Host + "/";
|
public string baseURL => HttpContext?.Request.Scheme + "://" + HttpContext?.Request.Host + "/";
|
||||||
|
|
||||||
public ErrorCode errorCode = new ErrorCode();
|
public ErrorCode errorCode = new ErrorCode();
|
||||||
|
public MyPowerStationService myPowerStationService;
|
||||||
|
|
||||||
public MyBaseController()
|
public MyBaseController()
|
||||||
{
|
{
|
||||||
@ -52,6 +53,8 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
//base.OnActionExecuting(filterContext);
|
//base.OnActionExecuting(filterContext);
|
||||||
|
|
||||||
|
this.myPowerStationService = new MyPowerStationService(powerStationRepository);
|
||||||
|
|
||||||
EDFunction edFunction = new EDFunction();
|
EDFunction edFunction = new EDFunction();
|
||||||
var myAccount = edFunction.AESDecrypt(HttpContext.Session.GetString("MyAccount")); //取得登入後,該位使用者的Account
|
var myAccount = edFunction.AESDecrypt(HttpContext.Session.GetString("MyAccount")); //取得登入後,該位使用者的Account
|
||||||
|
|
||||||
@ -133,7 +136,7 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
//取得當前使用者可以查看的電站
|
//取得當前使用者可以查看的電站
|
||||||
MyPowerStationService myPowerStationService = new MyPowerStationService(powerStationRepository);
|
MyPowerStationService myPowerStationService = new MyPowerStationService(powerStationRepository);
|
||||||
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser);
|
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
|
||||||
//var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
|
//var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
|
||||||
myUser.myPowerStationGroupByCities = myPowerStations;
|
myUser.myPowerStationGroupByCities = myPowerStations;
|
||||||
ViewBag.myPowerStationGroupByCities = myPowerStations;
|
ViewBag.myPowerStationGroupByCities = myPowerStations;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
|||||||
using SolarPower.Models;
|
using SolarPower.Models;
|
||||||
using SolarPower.Models.PowerStation;
|
using SolarPower.Models.PowerStation;
|
||||||
using SolarPower.Repository.Interface;
|
using SolarPower.Repository.Interface;
|
||||||
|
using SolarPower.Services.Implement;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@ -36,52 +37,13 @@ namespace SolarPower.Controllers
|
|||||||
return View("~/Views/StationOverview/StationOverviewInfo.cshtml");
|
return View("~/Views/StationOverview/StationOverviewInfo.cshtml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public ApiResult<List<MyCity>> GetMyCities()
|
||||||
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<ApiResult<List<PowerStation>>> GetSolarByCity(UseStatusCityGetPowerStation post)
|
|
||||||
{
|
{
|
||||||
ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
|
ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
|
||||||
List<PowerStation> solaramount = new List<PowerStation>();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
solaramount = await overviewRepository.GetSolarByCity(myUser, post);
|
apiResult.Data = myPowerStationService.GetMyCities(myUser);
|
||||||
|
|
||||||
foreach (var solar in solaramount)
|
|
||||||
{
|
|
||||||
//判斷該檔案是否存在
|
|
||||||
if (!string.IsNullOrEmpty(solar.MainDisplay))
|
|
||||||
{
|
|
||||||
var fullFilePath = Directory.GetCurrentDirectory() + "/wwwroot" + Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay;
|
|
||||||
if (System.IO.File.Exists(fullFilePath))
|
|
||||||
{
|
|
||||||
solar.MainDisplay = Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
solar.MainDisplay = Path.Combine("img", "blank.gif");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
solar.MainDisplay = Path.Combine("img", "blank.gif");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (myUser.Role.Auths.Contains("ShowMoney"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
solar.Total_Money = 0;
|
|
||||||
solar.Today_Money = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apiResult.Data = solaramount;
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -92,6 +54,157 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiResult<StationOverview> GetPowerStationByFilter(GetPowerStationsByFilter filter)
|
||||||
|
{
|
||||||
|
ApiResult<StationOverview> apiResult = new ApiResult<StationOverview>();
|
||||||
|
StationOverview stationOverview = new StationOverview();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var temp_status_where = $@" ps.HealthStatus IN ({string.Join(",", filter.Status)})";
|
||||||
|
List<string> where = new List<string>();
|
||||||
|
where.Add(temp_status_where);
|
||||||
|
|
||||||
|
List<string> order = new List<string>();
|
||||||
|
var temp_kwh_order_by = "";
|
||||||
|
if (filter.KwhOrderBy == 0)
|
||||||
|
{
|
||||||
|
temp_kwh_order_by = @"Today_kwh DESC";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp_kwh_order_by = @"Today_kwh";
|
||||||
|
}
|
||||||
|
order.Add(temp_kwh_order_by);
|
||||||
|
|
||||||
|
var temp_pr_order_by = "";
|
||||||
|
if (filter.PrOrderBy == 0)
|
||||||
|
{
|
||||||
|
temp_pr_order_by = @"today_PR DESC";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp_pr_order_by = @"today_PR";
|
||||||
|
}
|
||||||
|
order.Add(temp_pr_order_by);
|
||||||
|
|
||||||
|
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser, filter.CityIds, where, order);
|
||||||
|
|
||||||
|
foreach(var powerStation in myPowerStations)
|
||||||
|
{
|
||||||
|
//判斷該檔案是否存在
|
||||||
|
if (!string.IsNullOrEmpty(powerStation.MainDisplay))
|
||||||
|
{
|
||||||
|
var fullFilePath = Directory.GetCurrentDirectory() + "/wwwroot" + Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + powerStation.MainDisplay;
|
||||||
|
if (System.IO.File.Exists(fullFilePath))
|
||||||
|
{
|
||||||
|
powerStation.MainDisplay = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + powerStation.MainDisplay;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerStation.MainDisplay = Path.Combine("img", "blank.gif");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerStation.MainDisplay = Path.Combine("img", "blank.gif");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stationOverview.PowerStations = myPowerStations;
|
||||||
|
|
||||||
|
var temp_PowerStationsSummary = myPowerStationService.GetMyPowerStationsSummary(myPowerStations);
|
||||||
|
stationOverview.Today_kwh = temp_PowerStationsSummary.Today_kwh;
|
||||||
|
stationOverview.Total_kwh = temp_PowerStationsSummary.Total_kwh;
|
||||||
|
stationOverview.Today_irradiance = temp_PowerStationsSummary.Today_irradiance;
|
||||||
|
stationOverview.Avg_irradiance = temp_PowerStationsSummary.Avg_irradiance;
|
||||||
|
stationOverview.Today_PR = temp_PowerStationsSummary.Today_PR;
|
||||||
|
stationOverview.Avg_PR = temp_PowerStationsSummary.Avg_PR;
|
||||||
|
stationOverview.Today_kwhkwp = temp_PowerStationsSummary.Today_kwhkwp;
|
||||||
|
stationOverview.Avg_kwhkwp = temp_PowerStationsSummary.Avg_kwhkwp;
|
||||||
|
if (myUser.Role.Auths.Contains("ShowMoney"))
|
||||||
|
{
|
||||||
|
stationOverview.IsShowMoney = 1;
|
||||||
|
stationOverview.Today_money = temp_PowerStationsSummary.Today_money;
|
||||||
|
stationOverview.Total_money = temp_PowerStationsSummary.Total_money;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stationOverview.IsShowMoney = 0;
|
||||||
|
stationOverview.Today_money = 0;
|
||||||
|
stationOverview.Total_money = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stationOverview.Today_carbon = temp_PowerStationsSummary.Today_carbon;
|
||||||
|
stationOverview.Total_carbon = temp_PowerStationsSummary.Total_carbon;
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = stationOverview;
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量(old:改為統一Function 取得電站資訊而註解)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//[HttpPost]
|
||||||
|
//public async Task<ApiResult<List<PowerStation>>> GetSolarByCity(UseStatusCityGetPowerStation post)
|
||||||
|
//{
|
||||||
|
// ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
|
||||||
|
// List<PowerStation> solaramount = new List<PowerStation>();
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// apiResult.Code = "0000";
|
||||||
|
// solaramount = await overviewRepository.GetSolarByCity(myUser, post);
|
||||||
|
|
||||||
|
// foreach (var solar in solaramount)
|
||||||
|
// {
|
||||||
|
// //判斷該檔案是否存在
|
||||||
|
// if (!string.IsNullOrEmpty(solar.MainDisplay))
|
||||||
|
// {
|
||||||
|
// var fullFilePath = Directory.GetCurrentDirectory() + "/wwwroot" + Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay;
|
||||||
|
// if (System.IO.File.Exists(fullFilePath))
|
||||||
|
// {
|
||||||
|
// solar.MainDisplay = Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// solar.MainDisplay = Path.Combine("img", "blank.gif");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// solar.MainDisplay = Path.Combine("img", "blank.gif");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if (myUser.Role.Auths.Contains("ShowMoney"))
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// solar.Total_Money = 0;
|
||||||
|
// solar.Today_Money = 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// apiResult.Data = solaramount;
|
||||||
|
// }
|
||||||
|
// catch (Exception exception)
|
||||||
|
// {
|
||||||
|
// apiResult.Code = "9999";
|
||||||
|
// apiResult.Msg = exception.ToString();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return apiResult;
|
||||||
|
//}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ApiResult<List<MyPowerStationGroupByCity>> GetPowerStationCollapse(string filter)
|
public ApiResult<List<MyPowerStationGroupByCity>> GetPowerStationCollapse(string filter)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -83,6 +83,14 @@ namespace SolarPower.Models
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MyCity
|
||||||
|
{
|
||||||
|
public int CityId { get; set; }
|
||||||
|
public string CityName { get; set; }
|
||||||
|
public int Amount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class MyPowerStationGroupByCity
|
public class MyPowerStationGroupByCity
|
||||||
{
|
{
|
||||||
public string CityName { get; set; }
|
public string CityName { get; set; }
|
||||||
|
|||||||
@ -47,6 +47,14 @@ namespace SolarPower.Models
|
|||||||
public int PrOrder { get; set; }
|
public int PrOrder { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GetPowerStationsByFilter
|
||||||
|
{
|
||||||
|
public List<int> CityIds { get; set; }
|
||||||
|
public List<int> Status { get; set; } //狀態
|
||||||
|
public int KwhOrderBy { get; set; }
|
||||||
|
public int PrOrderBy { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class StationIds
|
public class StationIds
|
||||||
{
|
{
|
||||||
public List<int> Ids { get; set; }
|
public List<int> Ids { get; set; }
|
||||||
@ -63,6 +71,7 @@ namespace SolarPower.Models
|
|||||||
public string StationName { get; set; }
|
public string StationName { get; set; }
|
||||||
public string CityName { get; set; }
|
public string CityName { get; set; }
|
||||||
public byte HealthStatus { get; set; }
|
public byte HealthStatus { get; set; }
|
||||||
|
public List<PowerStation.PowerStation> PowerStations { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChartUptoDate
|
public class ChartUptoDate
|
||||||
|
|||||||
@ -23,6 +23,45 @@ namespace SolarPower.Repository.Implement
|
|||||||
tableName = "power_station";
|
tableName = "power_station";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MyCity> GetMyCities(MyUser myUser)
|
||||||
|
{
|
||||||
|
var results = new List<MyCity>();
|
||||||
|
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = @"SELECT c.Id AS CityId, c.Name AS CityName, COUNT(*) AS Amount
|
||||||
|
FROM power_station ps
|
||||||
|
LEFT JOIN city c ON ps.CityId = c.Id";
|
||||||
|
|
||||||
|
if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
|
||||||
|
{ //公司管理員
|
||||||
|
sql += @" WHERE ps.Deleted = 0 AND ps.CompanyId = @CompanyId";
|
||||||
|
}
|
||||||
|
else if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser || myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser)
|
||||||
|
{
|
||||||
|
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 ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql += @" WHERE ps.Deleted = 0";
|
||||||
|
}
|
||||||
|
|
||||||
|
sql += @" GROUP BY c.Id ORDER BY c.Priority";
|
||||||
|
|
||||||
|
results = conn.Query<MyCity>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id }).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds, List<string> wheres = null, List<string> orderBy = null)
|
public List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds, List<string> wheres = null, List<string> orderBy = null)
|
||||||
{
|
{
|
||||||
var results = new List<PowerStation>();
|
var results = new List<PowerStation>();
|
||||||
@ -58,14 +97,14 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
var temp_where = "";
|
var temp_where = "";
|
||||||
temp_where = string.Join(" AND ", wheres);
|
temp_where = string.Join(" AND ", wheres);
|
||||||
sql += string.Join(" AND ", wheres);
|
sql += " AND " + string.Join(" AND ", wheres);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderBy != null && orderBy.Count > 0)
|
if (orderBy != null && orderBy.Count > 0)
|
||||||
{
|
{
|
||||||
var temp_order = "";
|
var temp_order = "";
|
||||||
temp_order = string.Join(" , ", orderBy);
|
temp_order = string.Join(" , ", orderBy);
|
||||||
sql += $" ORDER BY c.Priority, {temp_order}";
|
sql += $" ORDER BY {temp_order}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -83,7 +122,6 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
|
//public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
|
||||||
//{
|
//{
|
||||||
// List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
|
// List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
|
||||||
|
|||||||
@ -11,6 +11,12 @@ namespace SolarPower.Repository.Interface
|
|||||||
{
|
{
|
||||||
public interface IPowerStationRepository : IRepositoryBase<PowerStation>
|
public interface IPowerStationRepository : IRepositoryBase<PowerStation>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 取得當前使用者可操作電站的縣市
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="myUser"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<MyCity> GetMyCities(MyUser myUser);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 取得當前使用者可操作的電站
|
/// 取得當前使用者可操作的電站
|
||||||
|
|||||||
@ -17,7 +17,24 @@ namespace SolarPower.Services.Implement
|
|||||||
this.powerStationRepository = powerStationRepository;
|
this.powerStationRepository = powerStationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MyPowerStationGroupByCity> GetMyPowerStations(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, List<string> orderBy = null)
|
public List<MyCity> GetMyCities(MyUser myUser)
|
||||||
|
{
|
||||||
|
List<MyCity> myCities = new List<MyCity>();
|
||||||
|
|
||||||
|
myCities = powerStationRepository.GetMyCities(myUser);
|
||||||
|
|
||||||
|
return myCities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, List<string> orderBy = null)
|
||||||
|
{
|
||||||
|
List<PowerStation> powerStations = new List<PowerStation>();
|
||||||
|
powerStations = powerStationRepository.GetMyPowerStationList(myUser, cityIds, wheres, orderBy);
|
||||||
|
|
||||||
|
return powerStations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MyPowerStationGroupByCity> GetMyPowerStationsGroupByCity(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, List<string> orderBy = null)
|
||||||
{
|
{
|
||||||
List<PowerStation> powerStations = new List<PowerStation>();
|
List<PowerStation> powerStations = new List<PowerStation>();
|
||||||
|
|
||||||
|
|||||||
@ -39,15 +39,15 @@
|
|||||||
<div class="col-11 p-2">
|
<div class="col-11 p-2">
|
||||||
<div class="row frame-wrap" id="CheckStatus">
|
<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="Status_1" checked="">
|
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_1" value="1" checked>
|
||||||
<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>
|
<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="Status_2" checked="">
|
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_2" value="2" checked>
|
||||||
<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>
|
<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="Status_3" checked="">
|
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_3" value="3" checked>
|
||||||
<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>
|
<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>
|
||||||
@ -93,6 +93,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card money-card">
|
||||||
|
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
||||||
|
<h4 class="mb-0 font-weight-bold"><span class="fal fa-dollar-sign mr-1"></span> <span id="money-card-title">發電金額</span></h4>
|
||||||
|
<div class="ml-auto">NTD</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<p id="money-card-subtitle-total">總發金額</p>
|
||||||
|
<p><span class="color-info-700" id="total_money">0.00</span></p>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between">
|
||||||
|
<p id="money-card-subtitle-avg">今日發電金額</p>
|
||||||
|
<p><span class="color-info-700" id="today_money">0.00</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
|
||||||
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span> 日照度</h4>
|
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span> 日照度</h4>
|
||||||
@ -310,7 +326,29 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
status123 = [];
|
status123 = [];
|
||||||
|
|
||||||
var Nurl = "/PowerStation/GetSolarCitySummary";
|
var city_url = "/StationOverview/GetMyCities";
|
||||||
|
$.post(city_url, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#citytest').empty();
|
||||||
|
for (var i = 0; i < rel.data.length; i++) {
|
||||||
|
$('#citytest').append("<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id='" + 'cityID_' + rel.data[i].cityId + "'>" +
|
||||||
|
rel.data[i].cityName +
|
||||||
|
"<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
|
||||||
|
"</button >");
|
||||||
|
ids.push(rel.data[i].cityId);
|
||||||
|
Allids.push(rel.data[i].cityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
getStation(ids);
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@*var Nurl = "/PowerStation/GetSolarCitySummary";
|
||||||
$.post(Nurl, function (rel) {
|
$.post(Nurl, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
@ -329,7 +367,7 @@
|
|||||||
status123.push(2);
|
status123.push(2);
|
||||||
status123.push(3);
|
status123.push(3);
|
||||||
getStation(ids);
|
getStation(ids);
|
||||||
}, 'json');
|
}, 'json');*@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -350,19 +388,31 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
function getStation(ids) {
|
function getStation(ids) {
|
||||||
var kwh = $('#kwh_order').val();
|
@*var kwh = $('#kwh_order').val();
|
||||||
var pr = $('#pr_order').val();
|
var pr = $('#pr_order').val();
|
||||||
var send_data = {
|
var send_data = {
|
||||||
cityid: ids,
|
cityid: ids,
|
||||||
status: status123,
|
status: status123,
|
||||||
kwhOrder: kwh,
|
kwhOrder: kwh,
|
||||||
prOrder: pr
|
prOrder: pr
|
||||||
};
|
};*@
|
||||||
ids.sort(function (a, b) {
|
|
||||||
|
var selectedStatus = $("input[name='powerStationStatus[]']:checked").map(function () {
|
||||||
|
return $(this).val();
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
var send_data = {
|
||||||
|
cityIds: ids,
|
||||||
|
status: selectedStatus,
|
||||||
|
kwhOrderBy: $('#kwh_order').val(),
|
||||||
|
prOrderBy: $('#pr_order').val()
|
||||||
|
}
|
||||||
|
|
||||||
|
@*ids.sort(function (a, b) {
|
||||||
return a - b;
|
return a - b;
|
||||||
});
|
});
|
||||||
ids.sort();
|
ids.sort();*@
|
||||||
if (ids.length == 0 || status123.length == 0) {
|
if (ids.length == 0 || selectedStatus.length == 0) {
|
||||||
$('#areaCard').empty();
|
$('#areaCard').empty();
|
||||||
$('#solarTable').find('tbody').empty();
|
$('#solarTable').find('tbody').empty();
|
||||||
$("#today_kwh").html(0);
|
$("#today_kwh").html(0);
|
||||||
@ -379,7 +429,7 @@
|
|||||||
$("#update_at").html(0);
|
$("#update_at").html(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var Nurl = "/StationOverview/GetSolarByCity";
|
var Nurl = "/StationOverview/GetPowerStationByFilter";
|
||||||
$.post(Nurl, send_data, function (rel) {
|
$.post(Nurl, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
@ -388,7 +438,7 @@
|
|||||||
$('#areaCard').empty();
|
$('#areaCard').empty();
|
||||||
$('#solarTable').find('tbody').empty();
|
$('#solarTable').find('tbody').empty();
|
||||||
powerids = [];
|
powerids = [];
|
||||||
$.each(rel.data, function (index, val) {
|
$.each(rel.data.powerStations, function (index, val) {
|
||||||
$('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard'));
|
$('#templateCard').find('.col-xl-3').clone().attr('id', 'card_' + val.id).appendTo($('#areaCard'));
|
||||||
var statusicon;
|
var statusicon;
|
||||||
switch (val.healthStatus) {
|
switch (val.healthStatus) {
|
||||||
@ -462,13 +512,13 @@
|
|||||||
|
|
||||||
'</tr>');
|
'</tr>');
|
||||||
});
|
});
|
||||||
GetStationCard();
|
GetStationCard(rel.data);
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
function GetStationCard() {
|
function GetStationCard(powerStationSummary) {
|
||||||
var send_data = {
|
@*var send_data = {
|
||||||
ids: powerids
|
ids: powerids
|
||||||
};
|
};
|
||||||
var url = "/StationOverview/GetStationCard";
|
var url = "/StationOverview/GetStationCard";
|
||||||
@ -490,7 +540,22 @@
|
|||||||
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
|
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
|
||||||
$("#total_capacity").html(mapOverview.totalCapacity.toFixed(2));
|
$("#total_capacity").html(mapOverview.totalCapacity.toFixed(2));
|
||||||
$("#update_at").html(mapOverview.updatedAt);
|
$("#update_at").html(mapOverview.updatedAt);
|
||||||
});
|
});*@
|
||||||
|
|
||||||
|
|
||||||
|
$("#today_kwh").html(powerStationSummary.today_kwh.toFixed(2));
|
||||||
|
$("#total_kwh").html(powerStationSummary.total_kwh.toFixed(2));
|
||||||
|
$("#today_irradiance").html(powerStationSummary.today_irradiance.toFixed(2));
|
||||||
|
$("#avg_irradiance").html(powerStationSummary.avg_irradiance.toFixed(2));
|
||||||
|
$("#today_PR").html(powerStationSummary.today_PR.toFixed(2));
|
||||||
|
$("#avg_PR").html(powerStationSummary.avg_PR.toFixed(2));
|
||||||
|
$("#today_kwhkwp").html(powerStationSummary.today_kwhkwp.toFixed(2));
|
||||||
|
$("#avg_kwhkwp").html(powerStationSummary.avg_kwhkwp.toFixed(2));
|
||||||
|
$("#today_carbon").html(powerStationSummary.today_carbon.toFixed(2));
|
||||||
|
$("#total_carbon").html(powerStationSummary.total_carbon.toFixed(2));
|
||||||
|
$("#today_carbon").html(powerStationSummary.today_carbon.toFixed(2));
|
||||||
|
$("#total_carbon").html(powerStationSummary.total_carbon.toFixed(2));
|
||||||
|
$("#update_at").html(powerStationSummary.updatedAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region 選擇狀態checkbox
|
//#region 選擇狀態checkbox
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user