This commit is contained in:
b110212000 2021-09-03 11:51:04 +08:00
commit fc1483d580
39 changed files with 1480 additions and 810 deletions

View File

@ -32,14 +32,8 @@ namespace SolarPower.Controllers
try try
{ {
var powerStations = new List<PowerStation>(); var powerStations = new List<PowerStation>();
if (IsPlatformLayer(myUser.Role.Layer))
{ powerStations = myPowerStationService.GetMyPowerStations(myUser);
powerStations = await powerStationRepository.GetAllAsync();
}
else
{
powerStations = await powerStationRepository.GetPowerStationsByCompanyId(myUser);
}
var siteDBNamePowerStationId = new Dictionary<string, List<int>>(); var siteDBNamePowerStationId = new Dictionary<string, List<int>>();

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SolarPower.Models; using SolarPower.Models;
using SolarPower.Models.PowerStation;
using SolarPower.Repository.Interface; using SolarPower.Repository.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -27,6 +28,45 @@ namespace SolarPower.Controllers
return View(); return View();
} }
public ApiResult<Dictionary<string, List<PowerStation>>> GetPowerStationCollapse(string filter)
{
ApiResult<Dictionary<string, List<PowerStation>>> apiResult = new ApiResult<Dictionary<string, List<PowerStation>>>();
try
{
List<string> where = new List<string>();
Dictionary<string, object> where_entities = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(filter))
{
var temp_psname_where = $@" ps.Name LIKE CONCAT('%', @Filter, '%')";
where.Add(temp_psname_where);
where_entities.Add("Filter", filter);
}
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser, null, where, where_entities);
var siteDBNamePowerStationId = new Dictionary<string, List<PowerStation>>();
foreach (var powerStation in myPowerStations)
{
siteDBNamePowerStationId.Add(powerStation.CityName, powerStation.MyPowerStations.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<AnalysisStationCombine>> GetStationsCard(ChartInput post) public async Task<ApiResult<AnalysisStationCombine>> GetStationsCard(ChartInput post)
{ {
ApiResult<AnalysisStationCombine> apiResult = new ApiResult<AnalysisStationCombine>(); ApiResult<AnalysisStationCombine> apiResult = new ApiResult<AnalysisStationCombine>();
@ -44,14 +84,14 @@ namespace SolarPower.Controllers
apiResult.Msg = errorCode.GetString(apiResult.Code); apiResult.Msg = errorCode.GetString(apiResult.Code);
} }
return apiResult; return apiResult;
} }
public async Task<ApiResult<List<Chartoutput>>> GetChart(ChartInput post) public async Task<ApiResult<List<Chartoutput>>> GetChart(ChartInput post)
{ {
ApiResult<List<Chartoutput>> apiResult = new ApiResult<List<Chartoutput>>(); ApiResult<List<Chartoutput>> apiResult = new ApiResult<List<Chartoutput>>();
try try
{ {
var GetCharts = new List<Chartoutput>(); var GetCharts = new List<Chartoutput>();

View File

@ -32,14 +32,8 @@ namespace SolarPower.Controllers
try try
{ {
var powerStations = new List<PowerStation>(); var powerStations = new List<PowerStation>();
if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin)
{ powerStations = myPowerStationService.GetMyPowerStations(myUser);
powerStations = await powerStationRepository.GetAllAsync();
}
else
{
powerStations = await powerStationRepository.GetPowerStationsByCompanyId(myUser);
}
var siteDBNamePowerStationId = new Dictionary<string, List<int>>(); var siteDBNamePowerStationId = new Dictionary<string, List<int>>();

View File

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SolarPower.Models;
using SolarPower.Models.PowerStation;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,5 +14,42 @@ namespace SolarPower.Controllers
{ {
return View(); return View();
} }
public ApiResult<List<MyCity>> GetMyCities()
{
ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
try
{
apiResult.Code = "0000";
apiResult.Data = myPowerStationService.GetMyCities(myUser);
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
public ApiResult<List<PowerStation>> GetPowerStationByFilter(List<int> cityIds)
{
ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
try
{
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser, cityIds);
apiResult.Code = "0000";
apiResult.Data = myPowerStations;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
} }
} }

View File

@ -4,6 +4,7 @@ using SolarPower.Models;
using SolarPower.Models.PowerStation; using SolarPower.Models.PowerStation;
using SolarPower.Models.Role; using SolarPower.Models.Role;
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.IO; using System.IO;
@ -41,20 +42,24 @@ namespace SolarPower.Controllers
MapOverview mapOverview = new MapOverview(); MapOverview mapOverview = new MapOverview();
try try
{ {
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
//List<int> powerStationIds = await powerStationRepository.GetPowerStationIdsByUserRole(myUser); List<int> powerStationIds = myPowerStations.SelectMany(x => x.MyPowerStations.Select(y => y.Id)).ToList();
List<int> powerStationIds = myUser.PowerStationSummaries.SelectMany(x => x.MyPowerStations.Select(y=> y.PowerStationId)).ToList();
var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds); var powerStations = myPowerStations.SelectMany(x => x.MyPowerStations).ToList();
mapOverview.Today_kwh = overview.Today_kwh; var powerStationSummary = myPowerStationService.GetMyPowerStationsSummary(powerStations);
mapOverview.Total_kwh = overview.Total_kwh;
mapOverview.Today_irradiance = overview.Today_irradiance; //var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds);
mapOverview.Avg_irradiance = overview.Avg_irradiance; mapOverview.Today_kwh = powerStationSummary.Today_kwh;
mapOverview.Today_PR = overview.Today_PR; mapOverview.Total_kwh = powerStationSummary.Total_kwh;
mapOverview.Avg_PR = overview.Avg_PR; mapOverview.Today_irradiance = powerStationSummary.Today_irradiance;
mapOverview.Today_kwhkwp = overview.Today_kwhkwp; mapOverview.Avg_irradiance = powerStationSummary.Avg_irradiance;
mapOverview.Avg_kwhkwp = overview.Avg_kwhkwp; mapOverview.Today_PR = powerStationSummary.Today_PR;
mapOverview.Today_carbon = overview.Today_carbon; mapOverview.Avg_PR = powerStationSummary.Avg_PR;
mapOverview.Total_carbon = overview.Total_carbon; mapOverview.Today_kwhkwp = powerStationSummary.Today_kwhkwp;
mapOverview.Avg_kwhkwp = powerStationSummary.Avg_kwhkwp;
mapOverview.Today_carbon = powerStationSummary.Today_carbon;
mapOverview.Total_carbon = powerStationSummary.Total_carbon;
mapOverview.CapacityDataTables = await overviewRepository.GetCapacityDataTableByPowerStationIds(powerStationIds); mapOverview.CapacityDataTables = await overviewRepository.GetCapacityDataTableByPowerStationIds(powerStationIds);
@ -70,7 +75,8 @@ namespace SolarPower.Controllers
mapOverview.TotalPowerStationCount = totalPowerStationCount; mapOverview.TotalPowerStationCount = totalPowerStationCount;
mapOverview.TotalCapacity = totalCapacity / 1000; // kWp -> MWp mapOverview.TotalCapacity = totalCapacity / 1000; // kWp -> MWp
mapOverview.PowerStations = await overviewRepository.GetListPowerStationByPowerStationIds(powerStationIds); //mapOverview.PowerStations = await overviewRepository.GetListPowerStationByPowerStationIds(powerStationIds);
mapOverview.PowerStations = powerStations;
mapOverview.UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); mapOverview.UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

View File

@ -22,6 +22,7 @@ using Newtonsoft.Json;
using SolarPower.Models.Company; using SolarPower.Models.Company;
using SolarPower.Models.Role; using SolarPower.Models.Role;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using SolarPower.Services.Implement;
namespace SolarPower.Controllers namespace SolarPower.Controllers
{ {
@ -42,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()
{ {
@ -51,12 +53,14 @@ 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
controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱 controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱 actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
bool isAjaxCall = filterContext.HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest"; bool isAjaxCall = filterContext.HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest";
if (string.IsNullOrEmpty(myAccount)) if (string.IsNullOrEmpty(myAccount))
@ -106,14 +110,17 @@ namespace SolarPower.Controllers
} }
} }
if (myUser.Role.Layer != (int)RoleLayerEnum.PlatformAdmin && !auth_arr.Contains(controllerName)) //只排除畫面的情況
var judgeActionName = new List<string>() { "Index", "Info", "Record", "Edit" };
if (myUser.Role.Layer != (int)RoleLayerEnum.PlatformAdmin && !auth_arr.Contains(controllerName) && judgeActionName.Contains(actionName))
{ {
//排除條件 //排除條件
if (auth_arr.Contains("StationOverview") && !auth_arr.Contains("PowerStation")) if (auth_arr.Contains("StationOverview") && !auth_arr.Contains("PowerStation"))
{ {
//只有電站總覽 且未包含 電站管理 //只有電站總覽 且未包含 電站管理
} }
else if(controllerName == "User" && (actionName == "ChangePassword" || actionName == "GetPersonalInfo" || actionName == "SavePersonalInfo")) else if (controllerName == "User" && (actionName == "ChangePassword" || actionName == "GetPersonalInfo" || actionName == "SavePersonalInfo"))
{ {
//查詢個人 資訊 及密碼 //查詢個人 資訊 及密碼
} }
@ -131,9 +138,11 @@ namespace SolarPower.Controllers
//取得當前使用者可以查看的電站 //取得當前使用者可以查看的電站
var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser); MyPowerStationService myPowerStationService = new MyPowerStationService(powerStationRepository);
myUser.PowerStationSummaries = myPowerStationSummaries; var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
ViewBag.myPowerStationSummaries = myPowerStationSummaries; //var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
myUser.myPowerStationGroupByCities = myPowerStations;
ViewBag.myPowerStationGroupByCities = myPowerStations;
if (controllerName == "PowerStation" && actionName == "Edit") if (controllerName == "PowerStation" && actionName == "Edit")
{ {
@ -146,16 +155,16 @@ namespace SolarPower.Controllers
{ {
var hasSubTagNum = false; var hasSubTagNum = false;
int i = 0; int i = 0;
foreach(var myPowerStationSummary in myPowerStationSummaries) foreach (var myPowerStation in myPowerStations)
{ {
if (hasSubTagNum) if (hasSubTagNum)
{ {
break; break;
} }
int j = 0; int j = 0;
foreach(var myPowerStation in myPowerStationSummary.MyPowerStations) foreach (var station in myPowerStation.MyPowerStations)
{ {
if(myPowerStation.PowerStationId == stationId) if (station.Id == stationId)
{ {
ViewData["SubNum"] = i; ViewData["SubNum"] = i;
ViewData["TagNum"] = j; ViewData["TagNum"] = j;

View File

@ -44,6 +44,43 @@ namespace SolarPower.Controllers
return View("~/Views/Operation/OperationRecord.cshtml"); return View("~/Views/Operation/OperationRecord.cshtml");
} }
public ApiResult<List<MyCity>> GetMyCities()
{
ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
try
{
apiResult.Code = "0000";
apiResult.Data = myPowerStationService.GetMyCities(myUser);
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
public ApiResult<List<PowerStation>> GetPowerStationByFilter(List<int> cityIds)
{
ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
try
{
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser, cityIds);
apiResult.Code = "0000";
apiResult.Data = myPowerStations;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = exception.ToString();
}
return apiResult;
}
/// <summary> /// <summary>
/// 取得電站Option /// 取得電站Option
/// </summary> /// </summary>

View File

@ -31,6 +31,50 @@ namespace SolarPower.Controllers
return View(); return View();
} }
[HttpPost]
public ApiResult<Dictionary<string, List<PowerStation>>> GetPowerStationCollapse(string filter)
{
ApiResult<Dictionary<string, List<PowerStation>>> apiResult = new ApiResult<Dictionary<string, List<PowerStation>>>();
try
{
List<string> where = new List<string>();
Dictionary<string, object> where_entities = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(filter))
{
var temp_psname_where = $@" ps.Name LIKE CONCAT('%', @Filter, '%')";
where.Add(temp_psname_where);
where_entities.Add("Filter", filter);
}
var temp_solartype_where = @" ps.SolarType = 0";
where.Add(temp_solartype_where);
var powerStations = myPowerStationService.GetMyPowerStations(myUser, null, where, where_entities);
var siteDBNamePowerStationId = new Dictionary<string, List<PowerStation>>();
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;
}
[HttpPost] [HttpPost]
public async Task<ApiResult<List<Generation>>> GetGenerationList (SearchGeneration post) public async Task<ApiResult<List<Generation>>> GetGenerationList (SearchGeneration post)
{ {

View File

@ -2172,14 +2172,16 @@ namespace SolarPower.Controllers
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量 /// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<ApiResult<List<SolarCityAmount>>> GetSolarCitySummary() public async Task<ApiResult<List<MyCity>>> GetSolarCitySummary()
{ {
ApiResult<List<SolarCityAmount>> apiResult = new ApiResult<List<SolarCityAmount>>(); ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
List<SolarCityAmount> solaramount = new List<SolarCityAmount>(); List<MyCity> solaramount = new List<MyCity>();
try try
{ {
apiResult.Code = "0000"; apiResult.Code = "0000";
solaramount = await powerStationRepository.GetSolarCitySummary(myUser); //solaramount = await powerStationRepository.GetSolarCitySummary(myUser);
solaramount = myPowerStationService.GetMyCities(myUser);
apiResult.Data = solaramount; apiResult.Data = solaramount;
} }
catch (Exception exception) catch (Exception exception)
@ -2202,7 +2204,9 @@ namespace SolarPower.Controllers
try try
{ {
apiResult.Code = "0000"; apiResult.Code = "0000";
solaramount = await powerStationRepository.GetSolarByCity(myUser, cityid); //solaramount = await powerStationRepository.GetSolarByCity(myUser, cityid);
solaramount = myPowerStationService.GetMyPowerStations(myUser, cityid);
foreach (var solar in solaramount) foreach (var solar in solaramount)
{ {

View File

@ -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,16 +54,169 @@ namespace SolarPower.Controllers
return apiResult; return apiResult;
} }
[HttpPost] public ApiResult<StationOverview> GetPowerStationByFilter(GetPowerStationsByFilter filter)
public ApiResult<List<MyPowerStationSummary>> GetPowerStationCollapse(string filter)
{ {
ApiResult<List<MyPowerStationSummary>> apiResult = new ApiResult<List<MyPowerStationSummary>>(); 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, null, 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]
public ApiResult<List<MyPowerStationGroupByCity>> GetPowerStationCollapse(string filter)
{
ApiResult<List<MyPowerStationGroupByCity>> apiResult = new ApiResult<List<MyPowerStationGroupByCity>>();
try try
{ {
apiResult.Code = "0000"; apiResult.Code = "0000";
var powerStationSummary = powerStationRepository.GetMyPowerStationSummary(myUser, filter); //var powerStationSummary = powerStationRepository.GetMyPowerStationSummary(myUser);
apiResult.Data = powerStationSummary; //TODO
//apiResult.Data = powerStationSummary;
apiResult.Data = null;
} }
catch (Exception exception) catch (Exception exception)
{ {

View File

@ -36,25 +36,25 @@ namespace SolarPower.Controllers
return View(); return View();
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<Dictionary<string,List<PowerStationIdAndCity>>>> GetPowerStationNameList(string filter) public ApiResult<Dictionary<string,List<PowerStation>>> GetPowerStationCollapse(string filter)
{ {
ApiResult<Dictionary<string, List<PowerStationIdAndCity>>> apiResult = new ApiResult<Dictionary<string, List<PowerStationIdAndCity>>>(); ApiResult<Dictionary<string, List<PowerStation>>> apiResult = new ApiResult<Dictionary<string, List<PowerStation>>>();
try try
{ {
var powerStations = new List<PowerStationIdAndCity>(); List<string> where = new List<string>();
if (IsPlatformLayer(myUser.Role.Layer)) Dictionary<string, object> where_entities = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(filter))
{ {
powerStations = await powerStationRepository.GetPowerStationsAllWithfilter(filter); var temp_psname_where = $@" ps.Name LIKE CONCAT('%', @Filter, '%')";
} where.Add(temp_psname_where);
else
{ where_entities.Add("Filter", filter);
powerStations = await powerStationRepository.GetPowerStationsByCompanyIdWithfilter(myUser,filter);
} }
var siteDBNamePowerStationId = new Dictionary<string, List<PowerStationIdAndCity>>(); var powerStations = myPowerStationService.GetMyPowerStations(myUser, null, where, where_entities);
var siteDBNamePowerStationId = new Dictionary<string, List<PowerStation>>();
var powerStation_Group = powerStations.GroupBy(x => x.CityName).ToList(); var powerStation_Group = powerStations.GroupBy(x => x.CityName).ToList();
foreach (var stations in powerStation_Group) foreach (var stations in powerStation_Group)
@ -77,48 +77,6 @@ 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>();

View File

@ -2178,6 +2178,19 @@ COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB ENGINE=InnoDB
; ;
-- 修改電站資料型態 20210901
ALTER TABLE `power_station`
CHANGE COLUMN `today_kwhkwp` `today_kwhkwp` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '今日kwhkwp' AFTER `Total_kwh`,
CHANGE COLUMN `avg_kwhkwp` `avg_kwhkwp` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '30天平均kwhkwp' AFTER `today_kwhkwp`,
CHANGE COLUMN `today_money` `today_money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '今日金額' AFTER `avg_kwhkwp`,
CHANGE COLUMN `total_money` `total_money` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '總金額' AFTER `today_money`,
CHANGE COLUMN `today_PR` `today_PR` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '電站Pr值' AFTER `total_money`,
CHANGE COLUMN `avg_PR` `avg_PR` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '平均Pr值' AFTER `today_PR`,
CHANGE COLUMN `today_carbon` `today_carbon` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '今日減碳量' AFTER `avg_PR`,
CHANGE COLUMN `total_carbon` `total_carbon` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '總減碳量' AFTER `today_carbon`,
CHANGE COLUMN `today_irradiance` `today_irradiance` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '今日日照度' AFTER `total_carbon`,
CHANGE COLUMN `avg_irradiance` `avg_irradiance` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '平均日照度' AFTER `today_irradiance`;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

View File

@ -51,7 +51,7 @@ namespace SolarPower.Models
public string Email { get; set; } public string Email { get; set; }
public MyCompany Company { get; set; } //公司資訊 public MyCompany Company { get; set; } //公司資訊
public MyRole Role { get; set; } //角色資訊 public MyRole Role { get; set; } //角色資訊
public List<MyPowerStationSummary> PowerStationSummaries { get; set; } public List<MyPowerStationGroupByCity> myPowerStationGroupByCities { get; set; }
} }
/// <summary> /// <summary>
@ -83,12 +83,20 @@ namespace SolarPower.Models
public string Name { get; set; } public string Name { get; set; }
} }
public class MyPowerStationSummary public class MyCity
{ {
public int CityId { get; set; } public int CityId { get; set; }
public string CityName { get; set; } public string CityName { get; set; }
public int Amount { get; set; } public int Amount { get; set; }
public List<MyPowerStation> MyPowerStations { get; set; }
}
public class MyPowerStationGroupByCity
{
public int CityId { get; set; }
public string CityName { get; set; }
public int Amount { get; set; }
public List<PowerStation.PowerStation> MyPowerStations { get; set; }
} }
public class MyPowerStation public class MyPowerStation
@ -108,4 +116,20 @@ namespace SolarPower.Models
public int Value { get; set; } //通常放id public int Value { get; set; } //通常放id
public string Name { get; set; } public string Name { get; set; }
} }
public class PowerStationsSummary
{
public double Today_kwh { get; set; } //今日總發電量
public double Total_kwh { get; set; } //累計總發電量
public double Today_irradiance { get; set; } //即時平均日照度
public double Avg_irradiance { get; set; } //平均日照度(30天)
public double Today_PR { get; set; } //即時平均 PR 值
public double Avg_PR { get; set; } //平均 PR 值(30天)
public double Today_kwhkwp { get; set; } //即時平均 kWh / kWp
public double Avg_kwhkwp { get; set; } //平均 kWh / kWp (30天)
public double Today_money { get; set; } //今日金額
public double Total_money { get; set; } //總金額
public double Today_carbon { get; set; } //今日減碳量
public double Total_carbon { get; set; } //累積減碳量
}
} }

View File

@ -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

View File

@ -4,7 +4,7 @@
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:57957/", "applicationUrl": "http://localhost:57957/",
"sslPort": 44361 "sslPort": 0
} }
}, },
"profiles": { "profiles": {

View File

@ -311,8 +311,6 @@ namespace SolarPower.Quartz.Jobs
}; };
await powerStationRepository.AddWeatherForecast(weatherForecasts, weather_forecast_properties); await powerStationRepository.AddWeatherForecast(weatherForecasts, weather_forecast_properties);
#region 60operation_record #region 60operation_record
var OperationDeletes = await powerStationRepository.GetAllDataList<OperationRecord>("operation_record", "Deleted = 1"); var OperationDeletes = await powerStationRepository.GetAllDataList<OperationRecord>("operation_record", "Deleted = 1");
List<int> deleteoperations = new List<int>(); List<int> deleteoperations = new List<int>();
@ -510,7 +508,6 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddMeterHistoryDayList(meterHistoriesDays, meter_history_properties); await powerStationRepository.AddMeterHistoryDayList(meterHistoriesDays, meter_history_properties);
#endregion #endregion
#region step5. #region step5.
foreach (var powerStation in powerStations) foreach (var powerStation in powerStations)
{ {
@ -941,17 +938,17 @@ namespace SolarPower.Quartz.Jobs
} }
} }
} }
#endregion #endregion
logger.LogInformation("【CalcAvgPowerStationJob】【任務完成】");
} }
catch (Exception exception) catch (Exception exception)
{ {
logger.LogError("【{0}】{1}", "CalcAvgPowerStationJob", exception.Message); logger.LogError("【CalcAvgPowerStationJob】[Exception] - {1}", "", exception.Message);
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {1}", "", exception.InnerException.Message);
} }
} }
} }

View File

@ -103,7 +103,7 @@ namespace SolarPower.Quartz.Jobs
if (string.IsNullOrEmpty(exist)) if (string.IsNullOrEmpty(exist))
{ {
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_station資料表】", powerStation.Code); logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_station資料表】", powerStation.Code);
} }
else else
{ {

View File

@ -60,29 +60,41 @@ namespace SolarPower.Repository.Implement
} }
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id, int Type) public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id, int Type)
{ {
List<OperationPlanTable> result; List<OperationPlanTable> result = new List<OperationPlanTable>();
var count = 0; var count = 0;
string Wheresql = "oc.PowerStationId = ";
if (id.Count > 0) string Wheresql = "";
if (id.Count() <= 0)
{ {
foreach (int too in id) return result;
{
if (count == id.Count - 1)
{
Wheresql += too.ToString();
}
else
{
Wheresql += too.ToString() + " OR oc.PowerStationId = ";
}
count++;
}
} }
else //if (id.Count > 0)
//{
// foreach (int too in id)
// {
// if (count == id.Count - 1)
// {
// Wheresql += too.ToString();
// }
// else
// {
// Wheresql += too.ToString() + " OR oc.PowerStationId = ";
// }
// count++;
// }
//}
//else
//{
// Wheresql += "0";
//}
if (id.Count() > 0)
{ {
Wheresql += "0"; var temp_sql = string.Join(',', id);
Wheresql = $"oc.PowerStationId IN ({temp_sql}) ";
} }
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())
@ -206,7 +218,7 @@ namespace SolarPower.Repository.Implement
try try
{ {
string where = ""; string where = "";
if(filter.Status == 2 ) if (filter.Status == 2)
{ {
where = $"opr.Deleted = 1 "; where = $"opr.Deleted = 1 ";
} }

View File

@ -23,16 +23,15 @@ namespace SolarPower.Repository.Implement
tableName = "power_station"; tableName = "power_station";
} }
public List<MyCity> GetMyCities(MyUser myUser)
public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
{ {
List<MyPowerStationSummary> results = new List<MyPowerStationSummary>(); var results = new List<MyCity>();
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())
{ {
try try
{ {
var sql = @"SELECT ps.Id, ps.CityId, c.Name AS CityName, ps.Name var sql = @"SELECT c.Id AS CityId, c.Name AS CityName, COUNT(*) AS Amount
FROM power_station ps FROM power_station ps
LEFT JOIN city c ON ps.CityId = c.Id"; LEFT JOIN city c ON ps.CityId = c.Id";
@ -43,42 +42,16 @@ namespace SolarPower.Repository.Implement
else if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser || myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser) 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 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 "; WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
} }
else else
{ {
sql += @" WHERE ps.Deleted = 0"; sql += @" WHERE ps.Deleted = 0";
} }
if (!string.IsNullOrEmpty(filter)) sql += @" GROUP BY c.Id ORDER BY c.Priority";
{
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
}
sql += " ORDER BY c.Priority"; results = conn.Query<MyCity>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id }).ToList();
var myPowerStationInfos = conn.Query<MyPowerStationInfo>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter }).ToList();
var myPowerStationInfos_group = myPowerStationInfos.GroupBy(x => x.CityId);
foreach (var myPowerStationInfo in myPowerStationInfos_group)
{
MyPowerStationSummary myPowerStationSummary = new MyPowerStationSummary();
myPowerStationSummary.CityId = myPowerStationInfo.First().CityId;
myPowerStationSummary.CityName = myPowerStationInfo.First().CityName;
myPowerStationSummary.Amount = myPowerStationInfo.Count();
myPowerStationSummary.MyPowerStations = new List<MyPowerStation>();
foreach (var info in myPowerStationInfo)
{
MyPowerStation myPowerStation = new MyPowerStation();
myPowerStation.PowerStationId = info.Id;
myPowerStation.PowerStationName = info.Name;
myPowerStationSummary.MyPowerStations.Add(myPowerStation);
}
results.Add(myPowerStationSummary);
}
} }
catch (Exception exception) catch (Exception exception)
@ -89,6 +62,143 @@ namespace SolarPower.Repository.Implement
} }
} }
public List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null)
{
var results = new List<PowerStation>();
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
var sql = @"SELECT ps.*, c.Name AS CityName
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";
}
if (cityIds != null)
{
sql += @" AND c.Id IN @CityIds";
}
if (wheres != null && wheres.Count > 0)
{
var temp_where = "";
temp_where = string.Join(" AND ", wheres);
sql += " AND " + string.Join(" AND ", wheres);
}
if (orderBy != null && orderBy.Count > 0)
{
var temp_order = "";
temp_order = string.Join(" , ", orderBy);
sql += $" ORDER BY {temp_order}";
}
else
{
sql += $" ORDER BY c.Priority";
}
Dictionary<string, object> pairs = new Dictionary<string, object>();
pairs.Add("CompanyId", myUser.CompanyId);
pairs.Add("UserId", myUser.Id);
pairs.Add("CityIds", cityIds);
if (where_entities != null && where_entities.Count() > 0)
{
foreach (var entity in where_entities)
{
pairs.Add(entity.Key, entity.Value);
}
}
results = conn.Query<PowerStation>(sql, pairs).ToList();
}
catch (Exception exception)
{
throw exception;
}
return results;
}
}
//public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
//{
// List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
// using (IDbConnection conn = this._databaseHelper.GetConnection())
// {
// try
// {
// var sql = @"SELECT ps.Id, ps.CityId, c.Name AS CityName, ps.Name
// 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";
// }
// if (!string.IsNullOrEmpty(filter))
// {
// sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
// }
// sql += " ORDER BY c.Priority";
// var myPowerStationInfos = conn.Query<MyPowerStationInfo>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter }).ToList();
// var myPowerStationInfos_group = myPowerStationInfos.GroupBy(x => x.CityId);
// foreach (var myPowerStationInfo in myPowerStationInfos_group)
// {
// MyPowerStationSummary myPowerStationSummary = new MyPowerStationSummary();
// myPowerStationSummary.CityName = myPowerStationInfo.First().CityName;
// myPowerStationSummary.Amount = myPowerStationInfo.Count();
// myPowerStationSummary.MyPowerStations = new List<MyPowerStation>();
// foreach (var info in myPowerStationInfo)
// {
// MyPowerStation myPowerStation = new MyPowerStation();
// myPowerStation.PowerStationId = info.Id;
// myPowerStation.PowerStationName = info.Name;
// myPowerStationSummary.MyPowerStations.Add(myPowerStation);
// }
// results.Add(myPowerStationSummary);
// }
// }
// catch (Exception exception)
// {
// throw exception;
// }
// return results;
// }
//}
/// <summary> /// <summary>
/// 查詢縣市列表 /// 查詢縣市列表
/// </summary> /// </summary>
@ -2547,20 +2657,37 @@ namespace SolarPower.Repository.Implement
{ {
try try
{ {
var sql = $@"SELECT //var sql = $@"SELECT
PowerStationId, // PowerStationId,
DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, // DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
AVG(p.Irradiance) AS Irradiance, // AVG(p.Irradiance) AS Irradiance,
AVG(p.Temperature) AS Temperature, // AVG(p.Temperature) AS Temperature,
AVG(p.EnvTemperature) AS EnvTemperature, // AVG(p.EnvTemperature) AS EnvTemperature,
AVG(p.Humidity) AS Humidity, // AVG(p.Humidity) AS Humidity,
AVG(p.Vane) AS Vane, // AVG(p.Vane) AS Vane,
AVG(p.Dust) AS Dust // AVG(p.Dust) AS Dust
FROM sensor_history_hour p // FROM sensor_history_hour p
WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay // WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay
AND PowerStationId = @PowerStationId // AND PowerStationId = @PowerStationId
GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') // GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d')
"; // ";
//TODO
var sql = $@" select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust from
(
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
envTemperature, humidity, Vane, Dust
from solar_master.sensor_history_hour
where PowerStationId = @PowerStationId and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @NowDay
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
) a left join
( --
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Irradiance), 2) Irradiance
from solar_master.sensor_history_hour
where PowerStationId = @PowerStationId
and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @NowDay and Irradiance <> 0 # 0
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
)b on a.reportdate = b.reportdate";
result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { NowDay = nowDay, PowerStationId = powerStationId }); result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { NowDay = nowDay, PowerStationId = powerStationId });
} }
@ -3008,7 +3135,7 @@ namespace SolarPower.Repository.Implement
AVG(inv.DC5A) AS DC5A, AVG(inv.DC5A) AS DC5A,
AVG(inv.DC5W) AS DC5W, AVG(inv.DC5W) AS DC5W,
AVG(inv.DC5WH) AS DC5WH, AVG(inv.DC5WH) AS DC5WH,
AVG(inv.PR) AS PR, MAX(inv.PR) AS PR,
AVG(inv.RA1) AS RA1, AVG(inv.RA1) AS RA1,
AVG(inv.RA2) AS RA2, AVG(inv.RA2) AS RA2,
AVG(inv.RA3) AS RA3, AVG(inv.RA3) AS RA3,
@ -3016,7 +3143,8 @@ namespace SolarPower.Repository.Implement
AVG(inv.RA5) AS RA5, AVG(inv.RA5) AS RA5,
SUM(inv.KWH) AS KWH, SUM(inv.KWH) AS KWH,
MAX(inv.TODAYKWH) AS TODAYKWH, MAX(inv.TODAYKWH) AS TODAYKWH,
MAX(inv.TODAYKWH) / i.Capacity AS KWHKWP MAX(inv.TOTALKWH) AS TOTALKWH,
SUM(inv.KWH) / i.Capacity AS KWHKWP
FROM inverter_history_hour inv FROM inverter_history_hour inv
LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId
WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') = @NowDay WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') = @NowDay
@ -3144,8 +3272,9 @@ namespace SolarPower.Repository.Implement
AVG(inv.RA4) AS RA4, AVG(inv.RA4) AS RA4,
AVG(inv.RA5) AS RA5, AVG(inv.RA5) AS RA5,
SUM(inv.KWH) AS KWH, SUM(inv.KWH) AS KWH,
SUM(inv.TODAYKWH) AS TODAYKWH, AVG(inv.TODAYKWH) AS TODAYKWH,
SUM(inv.TODAYKWH) / i.Capacity AS KWHKWP MAX(inv.TOTALKWH) AS TOTALKWH,
SUM(inv.KWH) / i.Capacity AS KWHKWP
FROM inverter_history_day inv FROM inverter_history_day inv
LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId
WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m') = @Month WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m') = @Month
@ -4793,7 +4922,7 @@ namespace SolarPower.Repository.Implement
try try
{ {
var purge_sql = $"DELETE FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate"; var purge_sql = $"DELETE FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate}, trans); await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour"); var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour");
count = await conn.ExecuteAsync(insert_sql, entity, trans); count = await conn.ExecuteAsync(insert_sql, entity, trans);
@ -4986,7 +5115,7 @@ namespace SolarPower.Repository.Implement
try try
{ {
var table_name = "inverter_history_15min"; var table_name = "inverter_history_15min";
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate"; var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans); await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
@ -5116,7 +5245,7 @@ namespace SolarPower.Repository.Implement
} }
} }
public async Task<List<InverterHistory>> GetAllInverterInfo(List<string> post,string site_table, string site_db) public async Task<List<InverterHistory>> GetAllInverterInfo(List<string> post, string site_table, string site_db)
{ {
List<InverterHistory> result; List<InverterHistory> result;
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())
@ -5144,7 +5273,7 @@ namespace SolarPower.Repository.Implement
} }
public async Task<InverterDetailModal> GetInverterInfoModal (int Id, string Time,string DB ,string Table) public async Task<InverterDetailModal> GetInverterInfoModal(int Id, string Time, string DB, string Table)
{ {
InverterDetailModal result; InverterDetailModal result;
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())
@ -5167,72 +5296,7 @@ namespace SolarPower.Repository.Implement
} }
} }
public async Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId, string dbname)
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, '%')";
}
sql += @" ORDER BY city.Priority";
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, '%')";
}
sql += @" ORDER BY city.Priority";
result = (await conn.QueryAsync<PowerStationIdAndCity>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter })).ToList();
}
catch (Exception exception)
{
throw exception;
}
return result;
}
}
public async Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId,string dbname)
{ {
List<AreaSelectItemList> result; List<AreaSelectItemList> result;
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())
@ -5264,7 +5328,7 @@ namespace SolarPower.Repository.Implement
} }
} }
public async Task<List<ApicallList>> GetApicallList(int PowerStationId,string Type) public async Task<List<ApicallList>> GetApicallList(int PowerStationId, string Type)
{ {
List<ApicallList> result; List<ApicallList> result;
using (IDbConnection conn = this._databaseHelper.GetConnection()) using (IDbConnection conn = this._databaseHelper.GetConnection())

View File

@ -11,13 +11,20 @@ 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>
/// 取得當前使用者可操作的電站 /// 取得當前使用者可操作的電站
/// </summary> /// </summary>
/// <param name="myUser"></param> /// <param name="myUser"></param>
/// <returns></returns> /// <returns></returns>
List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = ""); //List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "");
List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null);
/// <summary> /// <summary>
/// 查詢縣市列表 /// 查詢縣市列表
@ -591,8 +598,6 @@ namespace SolarPower.Repository.Interface
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);
Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId, string dbname); Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId, string dbname);
Task<List<ApicallList>> GetApicallList(int PowerStationId, string Type); Task<List<ApicallList>> GetApicallList(int PowerStationId, string Type);
Task<List<string>> GetShareDevicePowerstationName(int Id, string DBname); Task<List<string>> GetShareDevicePowerstationName(int Id, string DBname);

View File

@ -17,10 +17,100 @@ namespace SolarPower.Services.Implement
this.powerStationRepository = powerStationRepository; this.powerStationRepository = powerStationRepository;
} }
//public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> CityIds = null, List<string> Where = null, List<OrderBy> Order_by = null) public List<MyCity> GetMyCities(MyUser myUser)
//{ {
// List<PowerStation> powerStations = new List<PowerStation>(); List<MyCity> myCities = new List<MyCity>();
// return powerStations;
//} myCities = powerStationRepository.GetMyCities(myUser);
}
return myCities;
}
public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null)
{
List<PowerStation> powerStations = new List<PowerStation>();
powerStations = powerStationRepository.GetMyPowerStationList(myUser, cityIds, wheres, where_entities, orderBy);
return powerStations;
}
public List<MyPowerStationGroupByCity> GetMyPowerStationsGroupByCity(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null)
{
List<PowerStation> powerStations = new List<PowerStation>();
powerStations = powerStationRepository.GetMyPowerStationList(myUser, cityIds, wheres, where_entities, orderBy);
var myPowerStations_group = powerStations.GroupBy(x => x.CityId);
List<MyPowerStationGroupByCity> myPowerStationGroupByCities = new List<MyPowerStationGroupByCity>();
foreach (var powerStations_group_item in myPowerStations_group)
{
MyPowerStationGroupByCity myPowerStationGroupByCity = new MyPowerStationGroupByCity();
myPowerStationGroupByCity.CityId = powerStations_group_item.Key;
myPowerStationGroupByCity.CityName = powerStations_group_item.First().CityName;
myPowerStationGroupByCity.Amount = powerStations_group_item.Count();
myPowerStationGroupByCity.MyPowerStations = powerStations_group_item.ToList();
myPowerStationGroupByCities.Add(myPowerStationGroupByCity);
}
return myPowerStationGroupByCities;
}
public PowerStationsSummary GetMyPowerStationsSummary(List<PowerStation> powerStations)
{
PowerStationsSummary powerStationsSummary = new PowerStationsSummary();
if(powerStations.Count() <= 0)
{
return powerStationsSummary;
}
var sum_Today_kwh = 0.0;
var sum_Total_kwh = 0.0;
var sum_Today_irradiance = 0.0;
var sum_Avg_irradiance = 0.0;
var sum_Today_PR = 0.0;
var sum_Avg_PR = 0.0;
var sum_Today_kwhkwp = 0.0;
var sum_Avg_kwhkwp = 0.0;
var sum_Today_money = 0.0;
var sum_Total_money = 0.0;
var sum_Today_carbon = 0.0;
var sum_Total_carbon = 0.0;
var count_powerStation = powerStations.Count();
foreach (var powerStation in powerStations)
{
sum_Today_kwh += powerStation.Today_kWh;
sum_Total_kwh += powerStation.Total_kWh;
sum_Today_irradiance += powerStation.Today_irradiance;
sum_Avg_irradiance += powerStation.Avg_irradiance;
sum_Today_PR += powerStation.Today_PR;
sum_Avg_PR += powerStation.Avg_PR;
sum_Today_kwhkwp += powerStation.Today_kwhkwp;
sum_Avg_kwhkwp += powerStation.Avg_kwhkwp;
sum_Today_money += powerStation.Today_Money;
sum_Total_money += powerStation.Total_Money;
sum_Today_carbon += powerStation.Today_Carbon;
sum_Total_carbon += powerStation.Total_Carbon;
}
powerStationsSummary.Today_kwh = sum_Today_kwh;
powerStationsSummary.Total_kwh = sum_Total_kwh;
powerStationsSummary.Today_irradiance = sum_Today_irradiance / count_powerStation;
powerStationsSummary.Avg_irradiance = sum_Avg_irradiance / count_powerStation;
powerStationsSummary.Today_PR = sum_Today_PR / count_powerStation;
powerStationsSummary.Avg_PR = sum_Avg_PR / count_powerStation;
powerStationsSummary.Today_kwhkwp = sum_Today_kwhkwp / count_powerStation;
powerStationsSummary.Avg_kwhkwp = sum_Avg_kwhkwp / count_powerStation;
powerStationsSummary.Today_money = sum_Today_money;
powerStationsSummary.Total_money = sum_Total_money;
powerStationsSummary.Today_carbon = sum_Today_carbon;
powerStationsSummary.Total_carbon = sum_Total_carbon;
return powerStationsSummary;
}
}
} }

View File

@ -48,34 +48,6 @@
<div id="panel-5" class="panel"> <div id="panel-5" class="panel">
<div class="panel-container show"> <div class="panel-container show">
<div class="panel-content"> <div class="panel-content">
@*<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全部縣市</button>
</div>
<div class="pr-3">
<div class="frame-wrap" id="citytest" style="display:none">
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
新北市
<span class="badge bg-success-700 ml-2" id="acount">4</span>
</button>
</div>
<div class="frame-wrap" id="city">
</div>
</div>
</div>
<div class="row mb-5 d-flex align-items-top px-3">
<div class="col-1 p-0">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allpowerstation()">全選</button>
</div>
<div class="col-11">
<div class="row frame-wrap" id="CheckPowerStation">
</div>
</div>
</div>*@
<div class="row mb-5 d-flex align-items-top px-3"> <div class="row mb-5 d-flex align-items-top px-3">
<div class="pr-3"> <div class="pr-3">
<div class="btn-group btn-group-md"> <div class="btn-group btn-group-md">
@ -112,11 +84,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日發電量</p> <p>今日發電量</p>
<p><span class="color-info-700" id="today_kwh">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwh">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>總發電量</p> <p>總發電量</p>
<p><span class="color-info-700" id="total_kwh">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwh">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -130,14 +102,14 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p id="money-card-subtitle-avg">今日發電金額</p> <p id="money-card-subtitle-avg">今日發電金額</p>
<p><span class="color-info-700" id="today_money">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_money">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p id="money-card-subtitle-total">總發金額</p> <p id="money-card-subtitle-total">總發金額</p>
<p><span class="color-info-700" id="total_money">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_money">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
} }
<div class="card"> <div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap"> <div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
@ -147,11 +119,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日有效日照時數 </p> <p>今日有效日照時數 </p>
<p><span class="color-info-700" id="today_kwhkwp">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>平均有效日照時數</p> <p>平均有效日照時數</p>
<p><span class="color-info-700" id="total_kwhkwp">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwhkwp">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -163,11 +135,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日PR值</p> <p>今日PR值</p>
<p><span class="color-info-700" id="today_PR">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>平均 PR 值</p> <p>平均 PR 值</p>
<p><span class="color-info-700" id="total_PR">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_PR">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -180,11 +152,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日減碳量</p> <p>今日減碳量</p>
<p><span class="color-info-700" id="today_carbon">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_carbon">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>總減碳量</p> <p>總減碳量</p>
<p><span class="color-info-700" id="total_carbon">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_carbon">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -426,6 +398,7 @@
$('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2)); $('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2));
$('#total_PR').html(rel.data.all_PR.toFixed(2)); $('#total_PR').html(rel.data.all_PR.toFixed(2));
$('#total_carbon').html(rel.data.all_Carbon.toFixed(2)); $('#total_carbon').html(rel.data.all_Carbon.toFixed(2));
$('#total_irradiance').html(rel.data.all_Carbon.toFixed(2));
$('#today_kwh').html(rel.data.now_kwh.toFixed(2)); $('#today_kwh').html(rel.data.now_kwh.toFixed(2));
@ -433,6 +406,7 @@
$('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2)); $('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2));
$('#today_PR').html(rel.data.now_PR.toFixed(2)); $('#today_PR').html(rel.data.now_PR.toFixed(2));
$('#today_carbon').html(rel.data.now_Carbon.toFixed(2)); $('#today_carbon').html(rel.data.now_Carbon.toFixed(2));
$('#today_irradiance').html(rel.data.now_Carbon.toFixed(2));
chart(); chart();
}) })
@ -618,7 +592,8 @@
function GetPowerStationCollapse(filter) { function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList" @*var url = "/StationReport/GetPowerStationNameList"*@
var url = "/AnalysisStationCombine/GetPowerStationCollapse"
var send_data = { var send_data = {
Filter: filter Filter: filter
@ -659,9 +634,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="">' + '<div class="">' +
'<input type="checkbox" class="mr-2" name="selectedPowerStationLayer2[]" value="' + powerStation.powerStationId + '" valueName ="' + powerStation.powerStationName + '">' + '<input type="checkbox" class="mr-2" name="selectedPowerStationLayer2[]" value="' + powerStation.id + '" valueName ="' + powerStation.name + '">' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + powerStation.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + powerStation.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
}); });

View File

@ -341,7 +341,7 @@
function GetPowerStationCollapse(filter) { function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList" var url = "/StationReport/GetPowerStationCollapse"
var send_data = { var send_data = {
Filter: filter Filter: filter
@ -396,9 +396,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '" checked>' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }
@ -406,9 +406,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '">' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }

View File

@ -232,15 +232,6 @@
var AllpoweridsType = true; var AllpoweridsType = true;
var AllidsType = true; var AllidsType = true;
//#region Array.Remove
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
//#endregion
$(function () { $(function () {
//#region Date-Picker //#region Date-Picker
@ -274,7 +265,28 @@
//#endregion //#endregion
//#region 預設載入該使用者可以選擇的電站 //#region 預設載入該使用者可以選擇的電站
var Nurl = "/PowerStation/GetSolarCitySummary"; var city_url = "/Operation/GetMyCities";
$.post(city_url, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#city').empty();
for (var i = 0; i < rel.data.length; i++) {
$('#city').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);
}
getPowerStationCheckBox();
}, '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);
@ -309,192 +321,10 @@
datatable(); datatable();
//operationRecordTable.ajax.reload(); //operationRecordTable.ajax.reload();
}) })
}) })*@
//#endregion //#endregion
//#region DataTable
})
//#region 改變項目
function ChangeType(type) {
Type = type;
for (var i = 0; i < 2; i++) {
var name = "button" + i;
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
ExceptionTable.ajax.reload();
}
//#endregion
//#region 改變日期
$('#date-range').on('change', function () {
ExceptionTable.ajax.reload();
});
//#endregion
//#region 縣市全選
function Allcity() {
var Newpowerids = new Array(0);
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
if (AllidsType) {
document.getElementById(cityid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids = [];
powerids = [];
}
else {
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
}
});
if (AllidsType) {
AllidsType = false;
AllpoweridsType = false;
} else {
AllidsType = true;
}
var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})
ExceptionTable.ajax.reload();
}
//#endregion
//#region 查詢近30天
function ChangeDate30() {
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
$('#date-range').val(dateLimit_format + ' - ' + today_format);
$('#date-range').trigger('change');
}
//#endregion
//#region 電站全選
function Allpowerstation() {
if (AllpoweridsType) {
AllpoweridsType = false;
} else {
AllpoweridsType = true;
}
powerids = [];
$.each(Allpowerids, function (index, val) {
if (AllpoweridsType) {
$('#check_' + val).prop("checked", true);
powerids.push(val);
} else {
$('#check_' + val).prop("checked", false);
powerids = [];
}
})
ExceptionTable.ajax.reload();
}
//#endregion
//#region 選擇縣市
$('#city').on("click", "button", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var Newpowerids = new Array(0);
var value = document.getElementById(clickid).className;
ids.sort(function (a, b) {
return a - b;
});
var send_data = {
cityid: ids
}
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');
ids.push(classid[1]);
}
else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(classid[1]);
}
ids.sort();
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})
ExceptionTable.ajax.reload();
})
//#endregion
//#region 選擇電站checkbox
$('#CheckPowerStation').on("click", "input", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
powerids.push(classid[1]);
}
else {
powerids.remove(classid[1]);
}
ExceptionTable.ajax.reload();
})
//#endregion
//#region DataTable
function datatable() {
ExceptionTable = $("#Exception_Table").DataTable({ ExceptionTable = $("#Exception_Table").DataTable({
"pageLength": 20, "pageLength": 20,
"paging": true, "paging": true,
@ -555,8 +385,8 @@
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.id = powerids, d.id = powerids,
d.status = Type, d.status = Type,
d.range = $('#date-range').val() d.range = $('#date-range').val()
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.data.code == "9999") { if (rel.data.code == "9999") {
@ -574,9 +404,223 @@
console.log(xhr); console.log(xhr);
} }
}); });
//#endregion
})
//#region 改變項目
function ChangeType(type) {
Type = type;
for (var i = 0; i < 2; i++) {
var name = "button" + i;
document.getElementById(name).setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
document.getElementById("button" + type).setAttribute("class", "btn btn-success waves-effect waves-themed");
ExceptionTable.ajax.reload();
} }
//#endregion //#endregion
//#region 改變日期
$('#date-range').on('change', function () {
ExceptionTable.ajax.reload();
});
//#endregion
//#region 縣市全選
function Allcity() {
var Newpowerids = new Array(0);
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
if (AllidsType) {
document.getElementById(cityid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids = [];
powerids = [];
}
else {
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
}
});
if (AllidsType) {
AllidsType = false;
AllpoweridsType = false;
} else {
AllidsType = true;
}
getPowerStationCheckBox();
@*var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})*@
ExceptionTable.ajax.reload();
}
//#endregion
//#region 查詢近30天
function ChangeDate30() {
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
$('#date-range').val(dateLimit_format + ' - ' + today_format);
$('#date-range').trigger('change');
}
//#endregion
//#region 電站全選
function Allpowerstation() {
if (AllpoweridsType) {
AllpoweridsType = false;
} else {
AllpoweridsType = true;
}
powerids = [];
$.each(Allpowerids, function (index, val) {
if (AllpoweridsType) {
$('#check_' + val).prop("checked", true);
powerids.push(val);
} else {
$('#check_' + val).prop("checked", false);
powerids = [];
}
})
ExceptionTable.ajax.reload();
}
//#endregion
//#region 選擇縣市
$('#city').on("click", "button", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var Newpowerids = new Array(0);
var value = document.getElementById(clickid).className;
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');
if ($.inArray(parseInt(classid[1]), ids) < 0 ) {
ids.push(parseInt(classid[1]));
}
}
else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
if ($.inArray(parseInt(classid[1]), ids) > -1) {
ids.splice($.inArray(parseInt(classid[1]), ids), 1);
}
}
getPowerStationCheckBox();
@*ids.sort();
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})*@
ExceptionTable.ajax.reload();
})
//#endregion
//#region 選擇電站checkbox
$('#CheckPowerStation').on("click", "input", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
powerids.push(classid[1]);
}
else {
powerids.remove(classid[1]);
}
ExceptionTable.ajax.reload();
})
//#endregion
function getPowerStationCheckBox() {
var send_data = {
cityIds: ids
}
var Nurl = "/ExceptionRecord/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
powerids = [];
$.each(rel.data, function (index, val) {
if ($.inArray(parseInt(val.cityId), ids) > -1) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
powerids.push(String(val.id));
} else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
if ($.inArray(parseInt(val.id), powerids) > -1) {
powerids.splice($.inArray(parseInt(val.id), powerids), 1);
}
}
Allpowerids.push(String(val.id));
});
ExceptionTable.ajax.reload();
})
}
//#region 派工新增表單(異常) //#region 派工新增表單(異常)
$('#Exception_Table').on("click", "a.add-btn", function () { $('#Exception_Table').on("click", "a.add-btn", function () {
powerStationData_name = $(this).parents('tr').attr('data-name'); powerStationData_name = $(this).parents('tr').attr('data-name');
@ -616,7 +660,7 @@
$("#exception-form-modal").modal(); $("#exception-form-modal").modal();
}); });
//#endregion //#endregion
}); });
//#endregion //#endregion
@ -697,7 +741,7 @@
$("#exception-form-modal").modal(); $("#exception-form-modal").modal();
}); });
//#endregion //#endregion
}, 'json'); }, 'json');
}); });
//#endregion //#endregion
@ -823,7 +867,7 @@
dom.append(str); dom.append(str);
} }
//#endregion //#endregion
</script> </script>
} }

View File

@ -449,7 +449,7 @@
function GetPowerStationCollapse(filter) { function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList" var url = "/StationReport/GetPowerStationCollapse"
var send_data = { var send_data = {
Filter: filter Filter: filter
@ -500,9 +500,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '" checked>' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }
@ -510,9 +510,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '">' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }

View File

@ -238,13 +238,35 @@
if (index > -1) { if (index > -1) {
this.splice(index, 1); this.splice(index, 1);
} }
}; };
//#endregion //#endregion
$(function () { $(function () {
//#region 載入縣市 //#region 載入縣市
var Nurl = "/PowerStation/GetSolarCitySummary"; var city_url = "/Operation/GetMyCities";
$.post(city_url, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#city').empty();
for (var i = 0; i < rel.data.length; i++) {
$('#city').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);
}
$('#Allcity').trigger("click");
getPowerStationCheckBox();
}, '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);
@ -282,9 +304,9 @@
Allpowerids.push(String(val.id)); Allpowerids.push(String(val.id));
}); });
OperationPlanTable.ajax.reload(); OperationPlanTable.ajax.reload();
}) })
}) })*@
//#endregion //#endregion
//#region 定時計畫列表 DataTable //#region 定時計畫列表 DataTable
@ -370,7 +392,7 @@
}); });
//#endregion //#endregion
}) })
//#region 縣市全選 //#region 縣市全選
@ -389,7 +411,7 @@
else { else {
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2'); document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val); ids.push(val);
} }
}); });
if (AllidsType) { if (AllidsType) {
@ -398,7 +420,10 @@
} else { } else {
AllidsType = true; AllidsType = true;
} }
var send_data = {
getPowerStationCheckBox()
@*var send_data = {
cityid: ids cityid: ids
} }
var Nurl = "/PowerStation/GetSolarByCity"; var Nurl = "/PowerStation/GetSolarByCity";
@ -426,7 +451,7 @@
powerids = []; powerids = [];
powerids = Newpowerids; powerids = Newpowerids;
}) })
OperationPlanTable.ajax.reload(); OperationPlanTable.ajax.reload();*@
} }
//#endregion //#endregion
@ -458,19 +483,22 @@
var classid = clickid.split("_"); var classid = clickid.split("_");
var Newpowerids = new Array(0); 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(classid[1]); if ($.inArray(parseInt(classid[1]), ids) < 0) {
ids.push(parseInt(classid[1]));
}
} }
else { //取消 else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2'); document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(classid[1]); if ($.inArray(parseInt(classid[1]), ids) > -1) {
ids.splice($.inArray(parseInt(classid[1]), ids), 1);
}
} }
ids.sort();
getPowerStationCheckBox();
@*ids.sort();
var send_data = { var send_data = {
cityid: ids cityid: ids
} }
@ -500,10 +528,50 @@
powerids = []; powerids = [];
powerids = Newpowerids; powerids = Newpowerids;
}) })
OperationPlanTable.ajax.reload(); OperationPlanTable.ajax.reload();*@
}) })
//#endregion //#endregion
function getPowerStationCheckBox() {
var send_data = {
cityIds: ids
}
var Nurl = "/Operation/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
powerids = [];
$.each(rel.data, function (index, val) {
$("#operation_powerStationselect_modal").empty();
$.each(rel.data, function (index, val) {
$("#operation_powerStationselect_modal").append($("<option />").val(val.id).text(val.name));
});
if ($.inArray(parseInt(val.cityId), ids) > -1) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
powerids.push(String(val.id));
} else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
if ($.inArray(parseInt(val.id), powerids) > -1) {
powerids.splice($.inArray(parseInt(val.id), powerids), 1);
}
}
Allpowerids.push(String(val.id));
});
OperationPlanTable.ajax.reload();
})
}
//#region 選擇電站checkbox //#region 選擇電站checkbox
$('#CheckPowerStation').on("click", "input", function () { $('#CheckPowerStation').on("click", "input", function () {
var clickid = $(this).attr('id'); var clickid = $(this).attr('id');
@ -703,7 +771,7 @@
}); });
}, 'json'); }, 'json');
} }
//#endregion //#endregion

View File

@ -180,7 +180,7 @@
<div class="col-lg-6"> <div class="col-lg-6">
<div class=""> <div class="">
<label class="form-label" for="work_person_select_modal">執行人員</label> <label class="form-label" for="work_person_select_modal">執行人員</label>
<select class="form-control" id="work_person_select_modal" multiple="multiple" > <select class="form-control" id="work_person_select_modal" multiple="multiple">
</select> </select>
</div> </div>
</div> </div>
@ -312,7 +312,51 @@
//#endregion //#endregion
//#region 預設載入該使用者可以選擇的電站 //#region 預設載入該使用者可以選擇的電站
var Nurl = "/PowerStation/GetSolarCitySummary"; var city_url = "/Operation/GetMyCities";
$.post(city_url, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#city').empty();
for (var i = 0; i < rel.data.length; i++) {
$('#city').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);
}
var send_data = {
cityIds: ids
}
var Nurl = "/Operation/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
//modal 電站 下拉式選單
$("#power_station_select_modal").empty();
$.each(rel.data, function (index, val) {
$("#power_station_select_modal").append($("<option />").val(val.id).text(val.name));
});
//預設查詢第一個
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
})
$('#Allcity').trigger("click");
getPowerStationCheckBox();
}, '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);
@ -366,7 +410,7 @@
operationRecordTable.ajax.reload(); operationRecordTable.ajax.reload();
}) })
}) })*@
//#endregion //#endregion
//#region 切換電站時,載入該電站運維人員 //#region 切換電站時,載入該電站運維人員
@ -553,6 +597,48 @@
//#endregion //#endregion
}); });
function getPowerStationCheckBox() {
var send_data = {
cityIds: ids
}
var Nurl = "/Operation/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
powerids = [];
$.each(rel.data, function (index, val) {
if ($.inArray(parseInt(val.cityId), ids) > -1) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
powerids.push(String(val.id));
} else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
if ($.inArray(parseInt(val.id), powerids) > -1) {
powerids.splice($.inArray(parseInt(val.id), powerids), 1);
}
}
Allpowerids.push(String(val.id));
});
if (status == 2) {
operationRecordTable.column(10).visible(true);
}
else {
operationRecordTable.column(10).visible(false);
}
operationRecordTable.ajax.reload();
})
}
//#region 改變項目 //#region 改變項目
function ChangeType(type) function ChangeType(type)
{ {
@ -623,7 +709,10 @@
} else { } else {
AllidsType = true; AllidsType = true;
} }
var send_data = {
getPowerStationCheckBox();
@*var send_data = {
cityid: ids cityid: ids
} }
var Nurl = "/PowerStation/GetSolarByCity"; var Nurl = "/PowerStation/GetSolarByCity";
@ -657,7 +746,7 @@
else { else {
operationRecordTable.column(10).visible(false); operationRecordTable.column(10).visible(false);
} }
operationRecordTable.ajax.reload(); operationRecordTable.ajax.reload();*@
} }
function Allcity2() { function Allcity2() {
@ -682,7 +771,10 @@
} else { } else {
AllidsType = true; AllidsType = true;
} }
var send_data = {
getPowerStationCheckBox()
@*var send_data = {
cityid: ids cityid: ids
} }
var Nurl = "/PowerStation/GetSolarByCity"; var Nurl = "/PowerStation/GetSolarByCity";
@ -734,7 +826,7 @@
operationRecordTable.column(10).visible(false); operationRecordTable.column(10).visible(false);
} }
operationRecordTable.ajax.reload(); operationRecordTable.ajax.reload();
}) })*@
} }
//#endregion //#endregion
@ -772,21 +864,22 @@
var classid = clickid.split("_"); var classid = clickid.split("_");
var Newpowerids = new Array(0); 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;
});
var send_data = {
cityid: ids
}
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(classid[1]); if ($.inArray(parseInt(classid[1]), ids) < 0) {
ids.push(parseInt(classid[1]));
}
} }
else { //取消 else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2'); document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(classid[1]); if ($.inArray(parseInt(classid[1]), ids) > -1) {
ids.splice($.inArray(parseInt(classid[1]), ids), 1);
}
} }
ids.sort();
getPowerStationCheckBox();
@*ids.sort();
var Nurl = "/PowerStation/GetSolarByCity"; var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) { $.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -818,7 +911,7 @@
else { else {
operationRecordTable.column(10).visible(false); operationRecordTable.column(10).visible(false);
} }
operationRecordTable.ajax.reload(); operationRecordTable.ajax.reload();*@
}) })
//#endregion //#endregion

View File

@ -363,7 +363,7 @@
function GetPowerStationCollapse(filter) { function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameListForGeneration" var url = "/PowerGeneration/GetPowerStationCollapse"
var send_data = { var send_data = {
Filter: filter Filter: filter
@ -418,9 +418,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '" checked>' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }
@ -428,9 +428,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '">' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }

View File

@ -437,7 +437,7 @@
$('#templateAreaTab').find('li').attr('id', 'AreaTab' + val.cityId).clone().appendTo($('#areaTab')); $('#templateAreaTab').find('li').attr('id', 'AreaTab' + val.cityId).clone().appendTo($('#areaTab'));
$('#AreaTab' + val.cityId).find('a').attr('href', '#tab-' + val.cityId); $('#AreaTab' + val.cityId).find('a').attr('href', '#tab-' + val.cityId);
$('#AreaTab' + val.cityId).find('a').attr('class', 'nav-link fs-lg px-4'); $('#AreaTab' + val.cityId).find('a').attr('class', 'nav-link fs-lg px-4');
$('#AreaTab' + val.cityId).find('#areaName').html(val.city) $('#AreaTab' + val.cityId).find('#areaName').html(val.cityName)
$('#AreaTab' + val.cityId).find('#solarCount').html(val.amount) $('#AreaTab' + val.cityId).find('#solarCount').html(val.amount)
//alert(val.cityId+val.city + val.amount); //alert(val.cityId+val.city + val.amount);
//電站區域內容 //電站區域內容
@ -455,12 +455,12 @@
} }
function addPowerStationCard(idsd) { function addPowerStationCard(ids) {
//alert(ids); //alert(ids);
var url = "/PowerStation/GetSolarByCity"; var url = "/PowerStation/GetSolarByCity";
var send_data = { var send_data = {
cityid: idsd cityid: ids
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -473,6 +473,11 @@
}); });
$.each(rel.data, function (index, val) { $.each(rel.data, function (index, val) {
//電站卡片 //電站卡片
if (val.electricityMeterAt == undefined || val.electricityMeterAt == null) {
val.electricityMeterAt = "";
}
$('#templateCard').find('.col-xl-2').attr('id', 'card' + val.id).clone().appendTo($('#solarCard' + val.cityId)); $('#templateCard').find('.col-xl-2').attr('id', 'card' + val.id).clone().appendTo($('#solarCard' + val.cityId));
$('#card' + val.id).find('#editSolarUrl').attr('href', localurl + '/edit?stationId=' + val.id); $('#card' + val.id).find('#editSolarUrl').attr('href', localurl + '/edit?stationId=' + val.id);
$('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', val.mainDisplay); $('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', val.mainDisplay);
@ -487,6 +492,7 @@
'<td>' + val.name + '</td>' + '<td>' + val.name + '</td>' +
'<td>' + val.generatingCapacity.toFixed(2) + '</td>' + '<td>' + val.generatingCapacity.toFixed(2) + '</td>' +
'<td>' + val.inverterAmount + '</td>' + '<td>' + val.inverterAmount + '</td>' +
'<td>' + val.electricityMeterAt + '</td>' + '<td>' + val.electricityMeterAt + '</td>' +
'<td> <button type="button" class="btn btn-primary btn-pills waves-effect waves-themed" onclick="location.href=\'' + localurl + '/edit?stationId=' + val.id + '\'">選擇</button> <button type="button" class="btn btn-danger btn-pills waves-effect waves-themed del-btnto">刪除</button></td>' + '<td> <button type="button" class="btn btn-primary btn-pills waves-effect waves-themed" onclick="location.href=\'' + localurl + '/edit?stationId=' + val.id + '\'">選擇</button> <button type="button" class="btn btn-danger btn-pills waves-effect waves-themed del-btnto">刪除</button></td>' +

View File

@ -122,7 +122,12 @@
}); });
//預設查詢自己的公司 //預設查詢自己的公司
$("#select_power_station_company").val(@ViewBag.myUser.CompanyId).trigger('change'); if (powerStationData == undefined || powerStationData == null) {
$("#select_power_station_company").val(@ViewBag.myUser.CompanyId).trigger('change');
}
else {
$("#select_power_station_company").val(powerStationData.companyId).trigger('change');
}
}); });
//#endregion //#endregion
@ -1074,15 +1079,7 @@
if ($('#power_station_operation_personnel').val().length == 0) { if ($('#power_station_operation_personnel').val().length == 0) {
$('#power_station_operation_personnel-error').show(); $('#power_station_operation_personnel-error').show();
} }
} }
} }
//#endregion //#endregion

View File

@ -23,7 +23,7 @@
<label class="col-xl-4 form-label" id="city_label"><span class="text-danger">*</span>縣市</label> <label class="col-xl-4 form-label" id="city_label"><span class="text-danger">*</span>縣市</label>
<div class="col-xl-8"> <div class="col-xl-8">
<select class="form-control" id="select_city"> <select class="form-control" id="select_city">
<option value="0" selected>全部</option> <option value="0" selected>請選擇</option>
</select> </select>
</div> </div>
</div> </div>
@ -31,7 +31,7 @@
<label class="col-xl-4 form-label" id="area_label"><span class="text-danger">*</span>地區</label> <label class="col-xl-4 form-label" id="area_label"><span class="text-danger">*</span>地區</label>
<div class="col-xl-8"> <div class="col-xl-8">
<select class="form-control" id="select_area"> <select class="form-control" id="select_area">
<option value="0" selected>全部</option> <option value="0" selected>請選擇</option>
</select> </select>
</div> </div>
</div> </div>
@ -178,7 +178,7 @@
</div> </div>
<div class="row align-items-end"> <div class="row align-items-end">
<div class="col-xl-8"> <div class="col-xl-10">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5> <h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5>
<div class="row d-flex justify-content-between px-5"> <div class="row d-flex justify-content-between px-5">
<div class="col-xl-3 mb-3 row"> <div class="col-xl-3 mb-3 row">

View File

@ -199,23 +199,23 @@
<span class="nav-link-text" data-i18n="nav.category">電站資訊</span> <span class="nav-link-text" data-i18n="nav.category">電站資訊</span>
</a> </a>
<ul> <ul>
@foreach (var myPowerStationSummary in ViewBag.myPowerStationSummaries) @foreach (var MyPowerStationGroupByCity in ViewBag.myPowerStationGroupByCities)
{ {
<li class="@(ViewData["MainNum"].ToString() == "2" && <li class="@(ViewData["MainNum"].ToString() == "2" &&
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() ? "active open" : "")"> ViewData["SubNum"].ToString() == ViewBag.myPowerStationGroupByCities.IndexOf(MyPowerStationGroupByCity).ToString() ? "active open" : "")">
<a href="javascript:void(0);" title="Category" data-filter-tags="utilities menu child sublevel item"> <a href="javascript:void(0);" title="Category" data-filter-tags="utilities menu child sublevel item">
<span class="nav-link-text" data-i18n="nav.category">@myPowerStationSummary.CityName</span> <span class="nav-link-text" data-i18n="nav.category">@MyPowerStationGroupByCity.CityName</span>
<span class="dl-ref bg-primary-500 hidden-nav-function-minify hidden-nav-function-top" id="ul-List-@myPowerStationSummary.CityId">@myPowerStationSummary.Amount</span> <span class="dl-ref bg-primary-500 hidden-nav-function-minify hidden-nav-function-top" id="ul-List-@MyPowerStationGroupByCity.CityId">@MyPowerStationGroupByCity.Amount</span>
</a> </a>
<ul> <ul>
@foreach (var myPowerStation in myPowerStationSummary.MyPowerStations) @foreach (var myPowerStation in MyPowerStationGroupByCity.MyPowerStations)
{ {
<li class="@(ViewData["MainNum"].ToString() == "2" && <li class="@(ViewData["MainNum"].ToString() == "2" &&
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() && ViewData["SubNum"].ToString() == ViewBag.myPowerStationGroupByCities.IndexOf(MyPowerStationGroupByCity).ToString() &&
ViewData["TagNum"].ToString() == myPowerStationSummary.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")" id="li-List-@myPowerStation.PowerStationId"> ViewData["TagNum"].ToString() == MyPowerStationGroupByCity.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")" id="li-List-@myPowerStation.Id">
<a asp-controller="StationOverview" asp-action="Info" asp-route-stationId="@myPowerStation.PowerStationId" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item"> <a asp-controller="StationOverview" asp-action="Info" asp-route-stationId="@myPowerStation.Id" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item">
<span class="nav-link-text" data-i18n="nav.utilities_menu_child_sublevel_item">@myPowerStation.PowerStationName</span> <span class="nav-link-text" data-i18n="nav.utilities_menu_child_sublevel_item">@myPowerStation.Name</span>
</a> </a>
</li> </li>

View File

@ -14,7 +14,7 @@
<div class="row"> <div class="row">
<div class="col-xl-12"> <div class="col-xl-12">
<div id="panel-5" class="panel"> <div id="panel-5" class="panel">
<div class="panel-container show"> <div class="panel-container">
<div class="panel-content"> <div class="panel-content">
<div class="subheader"> <div class="subheader">
<h1 class="subheader-title"> 電站分佈區域 </h1> <h1 class="subheader-title"> 電站分佈區域 </h1>
@ -24,30 +24,25 @@
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全選</button> <button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全選</button>
</div> </div>
<div class="pr-3"> <div class="pr-3">
<div class="frame-wrap" id="citytest"> <div class="frame-wrap" id="citytest"></div>
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
新北市
<span class="badge bg-success-700 ml-2" id="acount">4</span>
</button>
</div>
</div> </div>
</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="AllStatus()">全選</button> <button type="button" class="btn btn-secondary waves-effect waves-themed" data-checked="true" id="status-all-check">全選</button>
</div> </div>
<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>
@ -74,93 +69,91 @@
</div> </div>
</div> </div>
</div> </div>
<div id="area" class="tab-content p-3"> <div class="row mb-5 px-3">
<div class="row mb-5">
<div class="card-columns"> <div class="col card px-0 mx-2">
<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-bolt mr-1"></span> 發電量</h4>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> 發電量</h4> <div class="ml-auto">kW h</div>
<div class="ml-auto">kW h</div> </div>
</div> <div class="card-body">
<div class="card-body"> <div class="d-flex justify-content-between">
<div class="d-flex justify-content-between"> <p>今日發電量</p>
<p>今日發電量</p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwh">0.00</span></p>
<p><span class="color-info-700" id="today_kwh">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>累積發電量</p>
<p><span class="color-info-700" id="total_kwh">0.00</span></p>
</div>
</div>
</div> </div>
<div class="card"> <div class="d-flex justify-content-between">
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap"> <p>累積發電量</p>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span> 日照度</h4> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwh">0.00</span></p>
<div class="ml-auto">k W/㎡</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p><span class="color-info-700" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均日照度(30天)</p>
<p><span class="color-info-700" id="avg_irradiance">0.00</span></p>
</div>
</div>
</div>
<div class="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-bolt mr-1"></span> PR值</h4>
<div class="ml-auto">%</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p><span class="color-info-700" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均 PR 值(30天)</p>
<p><span class="color-info-700" id="avg_PR">0.00</span></p>
</div>
</div>
</div>
<div class="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-sun mr-1"></span>有效日照時數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p>
<p><span class="color-info-700" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p><span class="color-info-700" id="avg_kwhkwp">0.00</span></p>
</div>
</div>
</div>
<div class="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-bolt mr-1"></span> 減碳量</h4>
<div class="ml-auto">kG</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日減碳量</p>
<p><span class="color-info-700" id="today_carbon">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>累積減碳量</p>
<p><span class="color-info-700" id="total_carbon">0.00</span></p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="col card px-0 mx-2">
<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>
<div class="ml-auto">k W/㎡</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均日照度(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_irradiance">0.00</span></p>
</div>
</div>
</div>
<div class="col card px-0 mx-2">
<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-bolt mr-1"></span> PR值</h4>
<div class="ml-auto">%</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均 PR 值(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_PR">0.00</span></p>
</div>
</div>
</div>
<div class="col card px-0 mx-2">
<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>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div>
</div>
</div>
<div class="col card px-0 mx-2">
<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-bolt mr-1"></span> 減碳量</h4>
<div class="ml-auto">kG</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>今日減碳量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_carbon">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>累積減碳量</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_carbon">0.00</span></p>
</div>
</div>
</div>
</div> </div>
<div class="tab-content p-3"> <div class="p-3">
<div class="row mb-5 d-flex justify-content-between"> <div class="row mb-5 d-flex justify-content-between">
<div class="col-12 text-right"> <div class="col-12 text-right">
<a href="javascript:TableDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed mr-1" style="width: 47px;"><span class="fal fa-list fa-2x mt-2"></span></a> <a href="javascript:TableDisplay();" class="btn btn-secondary btn-icon waves-effect waves-themed mr-1" style="width: 47px;"><span class="fal fa-list fa-2x mt-2"></span></a>
@ -177,27 +170,40 @@
<h4 id="solarName" class="font-weight-bold" style="line-height: 27px;"> <h4 id="solarName" class="font-weight-bold" style="line-height: 27px;">
新竹巨城站 新竹巨城站
</h4> </h4>
<p class="card-text"><i class="fal fa-cloud-sun-rain fa-2x" id="weathericon"></i></p> <div class="d-flex">
<p id="Temp" class="mr-2">27°C</p><i class="fal fa-cloud-sun-rain fa-2x" id="weathericon"></i>
</div>
</div> </div>
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
<li class="list-group-item px-2"> <li class="list-group-item px-2">
<div class=" d-flex justify-content-between"> <div class=" d-flex justify-content-between">
<p>發電量</p> <div class="d-flex justify-content-between" style="width:60%">
<p><span class="color-primary-400" id="Capacity">185</span> kWh</p> <p>發電量</p>
<p id="Temp">27°C</p> <p><span class="color-primary-400" id="today_kwh">0.00</span> kWh</p>
</div> </div>
<div class=" d-flex justify-content-between">
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{ {
<p>發電金額</p> <div class="d-flex justify-content-end" style="width:40%">
<p><span class="color-primary-400" id="PowerRate">2,5840</span> NT</p> @*<p>發電金額</p>*@
<p><span class="color-primary-400" id="PowerRate">0</span> NT</p>
</div>
} }
<p><span class="color-primary-400" id="stationtype">65</span></p>
</div> </div>
<div class=" d-flex justify-content-between"> <div class=" d-flex justify-content-between">
<p>PR值</p> <div class="d-flex justify-content-between" style="width:60%">
<p><span class="color-primary-400" id="PR">65</span> %</p> <p>裝置容量</p>
<div style="text-align:right"> <p><span class="color-primary-400" id="Capacity">0.00</span> kWp</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p><span class="color-primary-400" id="stationtype">65</span></p>
</div>
</div>
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>PR值</p>
<p><span class="color-primary-400" id="PR">65</span> %</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p class="small" id="date">06-30 17:50</p> <p class="small" id="date">06-30 17:50</p>
</div> </div>
</div> </div>
@ -291,46 +297,35 @@
@section Scripts{ @section Scripts{
<script> <script>
var localurl = this.location.href; var localurl = this.location.href;
var tablocation = "";
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 status123 = new Array(0);//狀態 var status123 = new Array(0);//狀態
var AllidsType = true; var AllidsType = true;
var StatusType = true; var StatusType = true;
//#region Array.Remove
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
//#endregion
$(function () { $(function () {
status123 = []; status123 = [];
var Nurl = "/PowerStation/GetSolarCitySummary"; var city_url = "/StationOverview/GetMyCities";
$.post(Nurl, function (rel) { $.post(city_url, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
toast_error(rel.msg); toast_error(rel.msg);
return; return;
} }
$('#citytest').empty(); $('#citytest').empty();
for (var i = 0; i < rel.data.length; i++) { 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 + "'>" + $('#citytest').append("<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id='" + 'cityID_' + rel.data[i].cityId + "'>" +
rel.data[i].city + rel.data[i].cityName +
"<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" + "<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
"</button >"); "</button >");
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');
}); });
@ -340,29 +335,46 @@
var value = document.getElementById(clickid).className; var value = document.getElementById(clickid).className;
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])); if ($.inArray(parseInt(classid[1]), ids) < 0) {
ids.push(parseInt(classid[1]));
}
} }
else { //取消 else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2'); document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(Number(classid[1])); if ($.inArray(parseInt(classid[1]), ids) > -1) {
ids.splice($.inArray(parseInt(classid[1]), ids), 1);
}
} }
getStation(ids); getStation(ids);
}) })
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);
@ -374,12 +386,11 @@
$("#today_kwhkwp").html(0); $("#today_kwhkwp").html(0);
$("#avg_kwhkwp").html(0); $("#avg_kwhkwp").html(0);
$("#today_carbon").html(0); $("#today_carbon").html(0);
$("#total_power_station_count").html(0); $("#total_carbon").html(0);
$("#total_capacity").html(0);
$("#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 +399,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) {
@ -399,7 +410,7 @@
statusicon = 'NULL'; break; statusicon = 'NULL'; break;
} }
$('#card_' + val.id).find('#solarName').html(statusicon + val.name); $('#card_' + val.id).find('#solarName').html(statusicon + val.name);
$('#card_' + val.id).find('#weathericon')[0].setAttribute("class", 'fal fa-' + val.todayWeather + ' fa-2x'); @*$('#card_' + val.id).find('#weathericon')[0].setAttribute("class", 'fal fa-' + val.todayWeather + ' fa-2x');*@
$('#card_' + val.id).find('#Temp').html((val.todayWeatherTemp == -99)? "": val.todayWeatherTemp + '°C'); $('#card_' + val.id).find('#Temp').html((val.todayWeatherTemp == -99)? "": val.todayWeatherTemp + '°C');
var type = ""; var type = "";
switch (val.solarType) { switch (val.solarType) {
@ -415,7 +426,8 @@
var time = new Date(val.createdAt); var time = new Date(val.createdAt);
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id); $('#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('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
$('#card_' + val.id).find('#Capacity').html(val.today_kWh.toFixed(2)); $('#card_' + val.id).find('#today_kwh').html(val.today_kWh.toFixed(2));
$('#card_' + val.id).find('#Capacity').html(val.generatingCapacity.toFixed(2));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{ {
<text> <text>
@ -443,7 +455,7 @@
$('#solarTable').find('tbody').append('<tr>' + $('#solarTable').find('tbody').append('<tr>' +
'<td>' + val.code + '</td>' + '<td>' + val.code + '</td>' +
'<td>' + val.name + '</td>' + '<td>' + val.name + '</td>' +
'<td>' + val.generatingCapacity + '</td>' + '<td>' + val.generatingCapacity.toFixed(2) + '</td>' +
'<td>' + val.total_kWh.toFixed(2) + '</td>' + '<td>' + val.total_kWh.toFixed(2) + '</td>' +
'<td>' + val.today_kWh.toFixed(2) + '</td>' + '<td>' + val.today_kWh.toFixed(2) + '</td>' +
'<td>' + val.solarHour.toFixed(2) + '</td>' + '<td>' + val.solarHour.toFixed(2) + '</td>' +
@ -462,13 +474,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,12 +502,24 @@
$("#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));
$("#update_at").html(powerStationSummary.updatedAt);
} }
//#region 選擇狀態checkbox //#region 選擇狀態checkbox
$('#CheckStatus').on("click", "input", function () { $('#CheckStatus').on("click", "input", function () {
var clickid = $(this).attr('id'); @*var clickid = $(this).attr('id');
var classid = clickid.split("_"); var classid = clickid.split("_");
var job = document.getElementById(clickid); var job = document.getElementById(clickid);
if (job.checked == true) { if (job.checked == true) {
@ -503,7 +527,7 @@
} }
else { else {
status123.remove(Number(classid[1])); status123.remove(Number(classid[1]));
} }*@
getStation(ids); getStation(ids);
}) })
//#endregion //#endregion
@ -541,8 +565,8 @@
//#endregion //#endregion
//#region 狀態全選 //#region 狀態全選
function AllStatus() { $("#status-all-check").click(function (e) {
status123 = []; @* status123 =[];
if (StatusType) { if (StatusType) {
for (var i = 1; i <= 3; i++) { for (var i = 1; i <= 3; i++) {
@ -555,9 +579,19 @@
status123.push(i); status123.push(i);
} }
StatusType = true; StatusType = true;
}*@
var checked = $(this).attr("data-checked") == "true";
if (checked) {
$(this).attr("data-checked", false);
$("input[name='powerStationStatus[]']").prop('checked', false);
}
else {
$(this).attr("data-checked", true);
$("input[name='powerStationStatus[]']").prop('checked', true);
} }
getStation(ids); getStation(ids);
} });
//#endregion //#endregion
function CardDisplay() { function CardDisplay() {

View File

@ -151,7 +151,7 @@
</div> </div>
<div class="row align-items-end"> <div class="row align-items-end">
<div class="col-xl-8"> <div class="col-xl-10">
<h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5> <h5 class="border-bottom font-weight-bold mb-3 pl-5 pb-3">光電板</h5>
<div class="row d-flex justify-content-between px-5"> <div class="row d-flex justify-content-between px-5">
<div class="col-xl-3 mb-3 row"> <div class="col-xl-3 mb-3 row">

View File

@ -8,11 +8,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日發電量</p> <p>今日發電量</p>
<p><span class="color-info-700" id="today_kwh">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwh">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>累積發電量</p> <p>累積發電量</p>
<p><span class="color-info-700" id="total_kwh">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwh">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -23,12 +23,12 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p id="money-card-subtitle-total">總發金額</p> <p id="money-card-subtitle-avg">發電金額</p>
<p><span class="color-info-700" id="total_money">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_money">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p id="money-card-subtitle-avg">平均發電金額</p> <p id="money-card-subtitle-total">總發電金額</p>
<p><span class="color-info-700" id="today_money">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_money">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -40,11 +40,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>即時平均日照度</p> <p>即時平均日照度</p>
<p><span class="color-info-700" id="today_irradiance">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>平均日照度(30天)</p> <p>平均日照度(30天)</p>
<p><span class="color-info-700" id="avg_irradiance">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="avg_irradiance">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -56,11 +56,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>即時平均 PR 值</p> <p>即時平均 PR 值</p>
<p><span class="color-info-700" id="today_PR">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>平均 PR 值(30天)</p> <p>平均 PR 值(30天)</p>
<p><span class="color-info-700" id="avg_PR">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="avg_PR">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -72,11 +72,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p> <p>即時平均有效日照時數</p>
<p><span class="color-info-700" id="today_kwhkwp">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p> <p>平均有效日照時數(30天)</p>
<p><span class="color-info-700" id="avg_kwhkwp">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="avg_kwhkwp">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>
@ -88,11 +88,11 @@
<div class="card-body"> <div class="card-body">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>今日減碳量</p> <p>今日減碳量</p>
<p><span class="color-info-700" id="today_carbon">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="today_carbon">0.00</span></p>
</div> </div>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<p>累積減碳量</p> <p>累積減碳量</p>
<p><span class="color-info-700" id="total_carbon">0.00</span></p> <p><span class="color-info-700 fs-xl font-weight-bold" id="total_carbon">0.00</span></p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -557,7 +557,7 @@
function GetPowerStationCollapse(filter) { function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList" var url = "/StationReport/GetPowerStationCollapse"
var send_data = { var send_data = {
Filter: filter Filter: filter
@ -612,9 +612,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '" checked>' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }
@ -622,9 +622,9 @@
str += '<li class="list-group-item">' + str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' + '<div class="d-flex justify-content-start">' +
'<div class="mr-2">' + '<div class="mr-2">' +
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' + '<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.id + '" valueName ="' + inverter.name + '">' +
'</div>' + '</div>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' + '<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' + '</div>' +
'</li>'; '</li>';
} }

View File

@ -238,9 +238,9 @@ namespace solarApp.Service
SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W, SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V, SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W, AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, max(PR) AS PR, SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, avg(PR) AS PR,
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW, AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW,
MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH avg(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH
FROM solar_master.inverter_history_day a FROM solar_master.inverter_history_day a
WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1
GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m'), a.INVERTERID GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m'), a.INVERTERID
@ -264,7 +264,6 @@ namespace solarApp.Service
throw ex; throw ex;
} }
return result; return result;
} }
} }
} }

View File

@ -207,7 +207,7 @@ namespace solarApp.Service
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
) a left join ) a left join
( (
select concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + irrCol + @"), 2) irrAvg select concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + irrCol + @"), 6) irrAvg
from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 " + irrNot0 + @" # 0 where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 " + irrNot0 + @" # 0
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
@ -229,7 +229,7 @@ namespace solarApp.Service
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
) a left join ) a left join
( (
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Irradiance), 2) Irradiance select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Irradiance), 6) Irradiance
from solar_master.sensor_history_hour from solar_master.sensor_history_hour
where powerstationID = @powerstationID where powerstationID = @powerstationID
and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and Irradiance <> 0 # 0 and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and Irradiance <> 0 # 0
@ -253,7 +253,7 @@ namespace solarApp.Service
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m') group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')
) a left join ) a left join
( (
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Irradiance), 2) Irradiance select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Irradiance), 6) Irradiance
from solar_master.sensor_history_day from solar_master.sensor_history_day
where powerstationID = @powerstationID where powerstationID = @powerstationID
and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and Irradiance <> 0 # 0 and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and Irradiance <> 0 # 0
@ -284,7 +284,7 @@ namespace solarApp.Service
{ {
sql += @" update sensoravg_history_hour a join sql += @" update sensoravg_history_hour a join
( (
select @powerstationID powerstationID, concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg select @powerstationID powerstationID, concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg
from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 # 0 where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 # 0
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
@ -317,7 +317,7 @@ namespace solarApp.Service
{ {
sql += @" update solar_master.sensoravg_history_day a join sql += @" update solar_master.sensoravg_history_day a join
( (
select @powerstationID powerstationID, concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg select @powerstationID powerstationID, concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg
from solar_master.sensoravg_history_hour from solar_master.sensoravg_history_hour
where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 # 0 where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 # 0
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
@ -352,7 +352,7 @@ namespace solarApp.Service
{ {
sql += @" update solar_master.sensoravg_history_month a join sql += @" update solar_master.sensoravg_history_month a join
( (
select @powerstationID powerstationID, concat( DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg select @powerstationID powerstationID, concat( DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg
from solar_master.sensoravg_history_day from solar_master.sensoravg_history_day
where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and " + item.colname + @" <> 0 # 0 where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and " + item.colname + @" <> 0 # 0
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')

View File

@ -166,9 +166,9 @@ namespace solarApp.Service
(KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from from
( (
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 4) KWH, select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 6) KWH,
round((max(TODAYKWH)), 4) TODAYKWH, round((max(TOTALKWH)), 4) TOTALKWH, round((max(KWHKWP)), 4) KWHKWP, round((max(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((max(KWHKWP)), 6) KWHKWP,
round((max(PR)), 4) PR, round((max(MP)), 4) as MP, round((max(SOLARHOUR)), 4) SOLARHOUR round((max(PR)), 6) PR, round((max(MP)), 6) as MP, round((max(SOLARHOUR)), 6) SOLARHOUR
from solar_master.power_station_history_hour a from solar_master.power_station_history_hour a
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1 where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1
group by a.siteid, DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') group by a.siteid, DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
@ -183,20 +183,20 @@ namespace solarApp.Service
#region month #region month
sql = @" sql = @"
delete from power_station_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ; delete from power_station_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = @date1 ;
INSERT INTO solar_master.power_station_history_month(PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TOTALKWH, KWHKWP, INSERT INTO solar_master.power_station_history_month(PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, monthKwh , TOTALKWH, KWHKWP,
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, TODAYKWH as monthKwh , a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
(KWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, (TODAYKWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY,
(KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON (TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from from
( (
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 4) KWH, select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00:00') reportdate, siteid, siteType,
round((max(TODAYKWH)), 4) TODAYKWH, round((max(TOTALKWH)), 4) TOTALKWH, round((max(KWHKWP)), 4) KWHKWP, round((sum(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((avg(KWHKWP)), 6) KWHKWP,
round((max(PR)), 4) PR, round((max(MP)), 4) as MP, round((max(SOLARHOUR)), 4) SOLARHOUR round((avg(PR)), 6) PR, round((avg(MP)), 6) as MP, round((avg(SOLARHOUR)), 6) SOLARHOUR
from solar_master.power_station_history_hour a from solar_master.power_station_history_day a
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`, '%Y-%m') = @date1 where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`, '%Y-%m') = @date1
group by a.siteid, DATE_FORMAT(`TIMESTAMP`, '%Y-%m') group by a.siteid, DATE_FORMAT(`TIMESTAMP`, '%Y-%m')
)a join )a join