衝突合併

This commit is contained in:
Kai 2021-09-02 14:38:47 +08:00
commit ad87214345
28 changed files with 1365 additions and 672 deletions

View File

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

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SolarPower.Models;
using SolarPower.Models.PowerStation;
using SolarPower.Repository.Interface;
using System;
using System.Collections.Generic;
@ -27,6 +28,45 @@ namespace SolarPower.Controllers
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)
{
ApiResult<AnalysisStationCombine> apiResult = new ApiResult<AnalysisStationCombine>();

View File

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

View File

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using SolarPower.Models;
using SolarPower.Models.PowerStation;
using System;
using System.Collections.Generic;
using System.Linq;
@ -12,5 +14,42 @@ namespace SolarPower.Controllers
{
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.Role;
using SolarPower.Repository.Interface;
using SolarPower.Services.Implement;
using System;
using System.Collections.Generic;
using System.IO;
@ -41,20 +42,24 @@ namespace SolarPower.Controllers
MapOverview mapOverview = new MapOverview();
try
{
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
//List<int> powerStationIds = await powerStationRepository.GetPowerStationIdsByUserRole(myUser);
List<int> powerStationIds = myUser.PowerStationSummaries.SelectMany(x => x.MyPowerStations.Select(y=> y.PowerStationId)).ToList();
var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds);
mapOverview.Today_kwh = overview.Today_kwh;
mapOverview.Total_kwh = overview.Total_kwh;
mapOverview.Today_irradiance = overview.Today_irradiance;
mapOverview.Avg_irradiance = overview.Avg_irradiance;
mapOverview.Today_PR = overview.Today_PR;
mapOverview.Avg_PR = overview.Avg_PR;
mapOverview.Today_kwhkwp = overview.Today_kwhkwp;
mapOverview.Avg_kwhkwp = overview.Avg_kwhkwp;
mapOverview.Today_carbon = overview.Today_carbon;
mapOverview.Total_carbon = overview.Total_carbon;
List<int> powerStationIds = myPowerStations.SelectMany(x => x.MyPowerStations.Select(y => y.Id)).ToList();
var powerStations = myPowerStations.SelectMany(x => x.MyPowerStations).ToList();
var powerStationSummary = myPowerStationService.GetMyPowerStationsSummary(powerStations);
//var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds);
mapOverview.Today_kwh = powerStationSummary.Today_kwh;
mapOverview.Total_kwh = powerStationSummary.Total_kwh;
mapOverview.Today_irradiance = powerStationSummary.Today_irradiance;
mapOverview.Avg_irradiance = powerStationSummary.Avg_irradiance;
mapOverview.Today_PR = powerStationSummary.Today_PR;
mapOverview.Avg_PR = powerStationSummary.Avg_PR;
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);
@ -70,7 +75,8 @@ namespace SolarPower.Controllers
mapOverview.TotalPowerStationCount = totalPowerStationCount;
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");

View File

@ -22,6 +22,7 @@ using Newtonsoft.Json;
using SolarPower.Models.Company;
using SolarPower.Models.Role;
using Microsoft.AspNetCore.Routing;
using SolarPower.Services.Implement;
namespace SolarPower.Controllers
{
@ -42,6 +43,7 @@ namespace SolarPower.Controllers
public string baseURL => HttpContext?.Request.Scheme + "://" + HttpContext?.Request.Host + "/";
public ErrorCode errorCode = new ErrorCode();
public MyPowerStationService myPowerStationService;
public MyBaseController()
{
@ -51,6 +53,8 @@ namespace SolarPower.Controllers
{
//base.OnActionExecuting(filterContext);
this.myPowerStationService = new MyPowerStationService(powerStationRepository);
EDFunction edFunction = new EDFunction();
var myAccount = edFunction.AESDecrypt(HttpContext.Session.GetString("MyAccount")); //取得登入後該位使用者的Account
@ -106,7 +110,10 @@ 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"))
@ -131,9 +138,11 @@ namespace SolarPower.Controllers
//取得當前使用者可以查看的電站
var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
myUser.PowerStationSummaries = myPowerStationSummaries;
ViewBag.myPowerStationSummaries = myPowerStationSummaries;
MyPowerStationService myPowerStationService = new MyPowerStationService(powerStationRepository);
var myPowerStations = myPowerStationService.GetMyPowerStationsGroupByCity(myUser);
//var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
myUser.myPowerStationGroupByCities = myPowerStations;
ViewBag.myPowerStationGroupByCities = myPowerStations;
if (controllerName == "PowerStation" && actionName == "Edit")
{
@ -146,16 +155,16 @@ namespace SolarPower.Controllers
{
var hasSubTagNum = false;
int i = 0;
foreach(var myPowerStationSummary in myPowerStationSummaries)
foreach (var myPowerStation in myPowerStations)
{
if (hasSubTagNum)
{
break;
}
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["TagNum"] = j;

View File

@ -44,6 +44,43 @@ namespace SolarPower.Controllers
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>
/// 取得電站Option
/// </summary>

View File

@ -31,6 +31,50 @@ namespace SolarPower.Controllers
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]
public async Task<ApiResult<List<Generation>>> GetGenerationList (SearchGeneration post)
{

View File

@ -4,6 +4,7 @@ using Newtonsoft.Json;
using SolarPower.Models;
using SolarPower.Models.PowerStation;
using SolarPower.Repository.Interface;
using SolarPower.Services.Implement;
using System;
using System.Collections.Generic;
using System.Globalization;
@ -36,52 +37,13 @@ namespace SolarPower.Controllers
return View("~/Views/StationOverview/StationOverviewInfo.cshtml");
}
/// <summary>
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<List<PowerStation>>> GetSolarByCity(UseStatusCityGetPowerStation post)
public ApiResult<List<MyCity>> GetMyCities()
{
ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
List<PowerStation> solaramount = new List<PowerStation>();
ApiResult<List<MyCity>> apiResult = new ApiResult<List<MyCity>>();
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;
apiResult.Data = myPowerStationService.GetMyCities(myUser);
}
catch (Exception exception)
{
@ -92,16 +54,169 @@ namespace SolarPower.Controllers
return apiResult;
}
[HttpPost]
public ApiResult<List<MyPowerStationSummary>> GetPowerStationCollapse(string filter)
public ApiResult<StationOverview> GetPowerStationByFilter(GetPowerStationsByFilter 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
{
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)
{

View File

@ -36,25 +36,25 @@ namespace SolarPower.Controllers
return View();
}
[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
{
var powerStations = new List<PowerStationIdAndCity>();
if (IsPlatformLayer(myUser.Role.Layer))
List<string> where = new List<string>();
Dictionary<string, object> where_entities = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(filter))
{
powerStations = await powerStationRepository.GetPowerStationsAllWithfilter(filter);
}
else
{
powerStations = await powerStationRepository.GetPowerStationsByCompanyIdWithfilter(myUser,filter);
var temp_psname_where = $@" ps.Name LIKE CONCAT('%', @Filter, '%')";
where.Add(temp_psname_where);
where_entities.Add("Filter", 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();
foreach (var stations in powerStation_Group)
@ -77,48 +77,6 @@ namespace SolarPower.Controllers
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)
{
ApiResult<InvAndMoney> apiResult = new ApiResult<InvAndMoney>();

View File

@ -2178,6 +2178,19 @@ COLLATE='utf8mb4_unicode_ci'
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, '') */;

View File

@ -51,7 +51,7 @@ namespace SolarPower.Models
public string Email { get; set; }
public MyCompany Company { get; set; } //公司資訊
public MyRole Role { get; set; } //角色資訊
public List<MyPowerStationSummary> PowerStationSummaries { get; set; }
public List<MyPowerStationGroupByCity> myPowerStationGroupByCities { get; set; }
}
/// <summary>
@ -83,12 +83,20 @@ namespace SolarPower.Models
public string Name { get; set; }
}
public class MyPowerStationSummary
public class MyCity
{
public int CityId { get; set; }
public string CityName { 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
@ -108,4 +116,20 @@ namespace SolarPower.Models
public int Value { get; set; } //通常放id
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 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 List<int> Ids { get; set; }
@ -63,6 +71,7 @@ namespace SolarPower.Models
public string StationName { get; set; }
public string CityName { get; set; }
public byte HealthStatus { get; set; }
public List<PowerStation.PowerStation> PowerStations { get; set; }
}
public class ChartUptoDate

View File

@ -103,7 +103,7 @@ namespace SolarPower.Quartz.Jobs
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
{

View File

@ -60,29 +60,41 @@ namespace SolarPower.Repository.Implement
}
public async Task<List<OperationPlanTable>> OperationPlanTable(List<int> id, int Type)
{
List<OperationPlanTable> result;
List<OperationPlanTable> result = new List<OperationPlanTable>();
var count = 0;
string Wheresql = "oc.PowerStationId = ";
if (id.Count > 0)
{
foreach (int too in id)
{
if (count == id.Count - 1)
string Wheresql = "";
if (id.Count() <= 0)
{
Wheresql += too.ToString();
}
else
{
Wheresql += too.ToString() + " OR oc.PowerStationId = ";
}
count++;
return result;
}
//if (id.Count > 0)
//{
// foreach (int too in id)
// {
}
else
// 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())

View File

@ -23,16 +23,15 @@ namespace SolarPower.Repository.Implement
tableName = "power_station";
}
public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
public List<MyCity> GetMyCities(MyUser myUser)
{
List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
var results = new List<MyCity>();
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
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
LEFT JOIN city c ON ps.CityId = c.Id";
@ -50,35 +49,9 @@ namespace SolarPower.Repository.Implement
sql += @" WHERE ps.Deleted = 0";
}
if (!string.IsNullOrEmpty(filter))
{
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
}
sql += @" GROUP BY c.Id ORDER BY c.Priority";
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.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);
}
results = conn.Query<MyCity>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id }).ToList();
}
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>
@ -2547,20 +2657,37 @@ namespace SolarPower.Repository.Implement
{
try
{
var sql = $@"SELECT
PowerStationId,
DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
AVG(p.Irradiance) AS Irradiance,
AVG(p.Temperature) AS Temperature,
AVG(p.EnvTemperature) AS EnvTemperature,
AVG(p.Humidity) AS Humidity,
AVG(p.Vane) AS Vane,
AVG(p.Dust) AS Dust
FROM sensor_history_hour p
WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay
AND PowerStationId = @PowerStationId
GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d')
";
//var sql = $@"SELECT
// PowerStationId,
// DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
// AVG(p.Irradiance) AS Irradiance,
// AVG(p.Temperature) AS Temperature,
// AVG(p.EnvTemperature) AS EnvTemperature,
// AVG(p.Humidity) AS Humidity,
// AVG(p.Vane) AS Vane,
// AVG(p.Dust) AS Dust
// FROM sensor_history_hour p
// WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay
// AND PowerStationId = @PowerStationId
// 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 });
}
@ -3008,7 +3135,7 @@ namespace SolarPower.Repository.Implement
AVG(inv.DC5A) AS DC5A,
AVG(inv.DC5W) AS DC5W,
AVG(inv.DC5WH) AS DC5WH,
AVG(inv.PR) AS PR,
MAX(inv.PR) AS PR,
AVG(inv.RA1) AS RA1,
AVG(inv.RA2) AS RA2,
AVG(inv.RA3) AS RA3,
@ -3016,7 +3143,8 @@ namespace SolarPower.Repository.Implement
AVG(inv.RA5) AS RA5,
SUM(inv.KWH) AS KWH,
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
LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId
WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') = @NowDay
@ -3144,8 +3272,9 @@ namespace SolarPower.Repository.Implement
AVG(inv.RA4) AS RA4,
AVG(inv.RA5) AS RA5,
SUM(inv.KWH) AS KWH,
SUM(inv.TODAYKWH) AS TODAYKWH,
SUM(inv.TODAYKWH) / i.Capacity AS KWHKWP
AVG(inv.TODAYKWH) AS TODAYKWH,
MAX(inv.TOTALKWH) AS TOTALKWH
SUM(inv.KWH) / i.Capacity AS KWHKWP
FROM inverter_history_day inv
LEFT JOIN {db_name}.inverter i ON CONCAT('s', inv.INVERTERID) = i.InverterId
WHERE DATE_FORMAT(inv.TIMESTAMP, '%Y-%m') = @Month
@ -5167,71 +5296,6 @@ namespace SolarPower.Repository.Implement
}
}
public async Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilterForGeneration(string filter)
{
List<PowerStationIdAndCity> result;
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try
{
var sql = @$"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,city.Name AS CityName FROM {tableName} ps
LEFT JOIN city ON city.Id = ps.CityId WHERE ps.Deleted = 0 AND SolarType = 0";
if (!string.IsNullOrEmpty(filter))
{
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
}
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;

View File

@ -11,13 +11,20 @@ namespace SolarPower.Repository.Interface
{
public interface IPowerStationRepository : IRepositoryBase<PowerStation>
{
/// <summary>
/// 取得當前使用者可操作電站的縣市
/// </summary>
/// <param name="myUser"></param>
/// <returns></returns>
List<MyCity> GetMyCities(MyUser myUser);
/// <summary>
/// 取得當前使用者可操作的電站
/// </summary>
/// <param name="myUser"></param>
/// <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>
/// 查詢縣市列表
@ -591,8 +598,6 @@ namespace SolarPower.Repository.Interface
Task<List<InverterHistory>> GetAllInverterRowData(string date, string table_name);
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<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilterForGeneration(string filter);
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilterForGeneration(MyUser myUser, string filter);
Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId, string dbname);
Task<List<ApicallList>> GetApicallList(int PowerStationId, string Type);
Task<List<string>> GetShareDevicePowerstationName(int Id, string DBname);

View File

@ -17,10 +17,99 @@ namespace SolarPower.Services.Implement
this.powerStationRepository = powerStationRepository;
}
//public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> CityIds = null, List<string> Where = null, List<OrderBy> Order_by = null)
//{
// List<PowerStation> powerStations = new List<PowerStation>();
// return powerStations;
//}
public List<MyCity> GetMyCities(MyUser myUser)
{
List<MyCity> myCities = new List<MyCity>();
myCities = powerStationRepository.GetMyCities(myUser);
return myCities;
}
public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, 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.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 class="panel-container show">
<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="pr-3">
<div class="btn-group btn-group-md">
@ -618,7 +590,8 @@
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList"
@*var url = "/StationReport/GetPowerStationNameList"*@
var url = "/AnalysisStationCombine/GetPowerStationCollapse"
var send_data = {
Filter: filter
@ -659,9 +632,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + powerStation.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + powerStation.name + '</h5>' +
'</div>' +
'</li>';
});

View File

@ -341,7 +341,7 @@
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList"
var url = "/StationReport/GetPowerStationCollapse"
var send_data = {
Filter: filter
@ -396,9 +396,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}
@ -406,9 +406,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}

View File

@ -274,7 +274,28 @@
//#endregion
//#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) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -309,192 +330,10 @@
datatable();
//operationRecordTable.ajax.reload();
})
})
//#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
//#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({
"pageLength": 20,
"paging": true,
@ -574,9 +413,223 @@
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
//#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 派工新增表單(異常)
$('#Exception_Table').on("click", "a.add-btn", function () {
powerStationData_name = $(this).parents('tr').attr('data-name');

View File

@ -449,7 +449,7 @@
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList"
var url = "/StationReport/GetPowerStationCollapse"
var send_data = {
Filter: filter
@ -500,9 +500,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}
@ -510,9 +510,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}

View File

@ -244,7 +244,29 @@
$(function () {
//#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) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -284,7 +306,7 @@
OperationPlanTable.ajax.reload();
})
})
})*@
//#endregion
//#region 定時計畫列表 DataTable
@ -398,7 +420,10 @@
} else {
AllidsType = true;
}
var send_data = {
getPowerStationCheckBox()
@*var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
@ -426,7 +451,7 @@
powerids = [];
powerids = Newpowerids;
})
OperationPlanTable.ajax.reload();
OperationPlanTable.ajax.reload();*@
}
//#endregion
@ -458,19 +483,22 @@
var classid = clickid.split("_");
var Newpowerids = new Array(0);
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') { //選擇
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 { //取消
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 = {
cityid: ids
}
@ -500,10 +528,50 @@
powerids = [];
powerids = Newpowerids;
})
OperationPlanTable.ajax.reload();
OperationPlanTable.ajax.reload();*@
})
//#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
$('#CheckPowerStation').on("click", "input", function () {
var clickid = $(this).attr('id');

View File

@ -312,7 +312,51 @@
//#endregion
//#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) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -366,7 +410,7 @@
operationRecordTable.ajax.reload();
})
})
})*@
//#endregion
//#region 切換電站時,載入該電站運維人員
@ -553,6 +597,48 @@
//#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 改變項目
function ChangeType(type)
{
@ -623,7 +709,10 @@
} else {
AllidsType = true;
}
var send_data = {
getPowerStationCheckBox();
@*var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
@ -657,7 +746,7 @@
else {
operationRecordTable.column(10).visible(false);
}
operationRecordTable.ajax.reload();
operationRecordTable.ajax.reload();*@
}
function Allcity2() {
@ -682,7 +771,10 @@
} else {
AllidsType = true;
}
var send_data = {
getPowerStationCheckBox()
@*var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
@ -734,7 +826,7 @@
operationRecordTable.column(10).visible(false);
}
operationRecordTable.ajax.reload();
})
})*@
}
//#endregion
@ -772,21 +864,22 @@
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]);
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');
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";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
@ -818,7 +911,7 @@
else {
operationRecordTable.column(10).visible(false);
}
operationRecordTable.ajax.reload();
operationRecordTable.ajax.reload();*@
})
//#endregion

View File

@ -363,7 +363,7 @@
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameListForGeneration"
var url = "/PowerGeneration/GetPowerStationCollapse"
var send_data = {
Filter: filter
@ -418,9 +418,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}
@ -428,9 +428,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}

View File

@ -199,23 +199,23 @@
<span class="nav-link-text" data-i18n="nav.category">電站資訊</span>
</a>
<ul>
@foreach (var myPowerStationSummary in ViewBag.myPowerStationSummaries)
@foreach (var MyPowerStationGroupByCity in ViewBag.myPowerStationGroupByCities)
{
<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">
<span class="nav-link-text" data-i18n="nav.category">@myPowerStationSummary.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="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-@MyPowerStationGroupByCity.CityId">@MyPowerStationGroupByCity.Amount</span>
</a>
<ul>
@foreach (var myPowerStation in myPowerStationSummary.MyPowerStations)
@foreach (var myPowerStation in MyPowerStationGroupByCity.MyPowerStations)
{
<li class="@(ViewData["MainNum"].ToString() == "2" &&
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() &&
ViewData["TagNum"].ToString() == myPowerStationSummary.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")" id="li-List-@myPowerStation.PowerStationId">
<a asp-controller="StationOverview" asp-action="Info" asp-route-stationId="@myPowerStation.PowerStationId" 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>
ViewData["SubNum"].ToString() == ViewBag.myPowerStationGroupByCities.IndexOf(MyPowerStationGroupByCity).ToString() &&
ViewData["TagNum"].ToString() == MyPowerStationGroupByCity.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")" id="li-List-@myPowerStation.PowerStationId">
<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.Name</span>
</a>
</li>

View File

@ -34,20 +34,20 @@
</div>
<div class="row mb-3 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="AllStatus()">全選</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-checked="true" id="status-all-check">全選</button>
</div>
<div class="col-11 p-2">
<div class="row frame-wrap" id="CheckStatus">
<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>
</div>
<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>
</div>
<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>
</div>
</div>
@ -74,8 +74,7 @@
</div>
</div>
</div>
<div id="area" class="tab-content p-3">
<div class="row mb-5">
<div class="row mb-5 d-flex px-3">
<div class="card-columns">
<div class="card">
<div class="card-header bg-fusion-25 py-2 pr-3 d-flex align-items-center flex-wrap">
@ -93,7 +92,7 @@
</div>
</div>
</div>
<div class="card">
<div class="card irradiance-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">k W/㎡</div>
@ -159,7 +158,6 @@
</div>
</div>
</div>
</div>
<div class="tab-content p-3">
<div class="row mb-5 d-flex justify-content-between">
<div class="col-12 text-right">
@ -310,7 +308,29 @@
$(function () {
status123 = [];
var Nurl = "/PowerStation/GetSolarCitySummary";
var city_url = "/StationOverview/GetMyCities";
$.post(city_url, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#citytest').empty();
for (var i = 0; i < rel.data.length; i++) {
$('#citytest').append("<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id='" + 'cityID_' + rel.data[i].cityId + "'>" +
rel.data[i].cityName +
"<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
"</button >");
ids.push(rel.data[i].cityId);
Allids.push(rel.data[i].cityId);
}
getStation(ids);
}, 'json');
@*var Nurl = "/PowerStation/GetSolarCitySummary";
$.post(Nurl, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -329,7 +349,7 @@
status123.push(2);
status123.push(3);
getStation(ids);
}, 'json');
}, 'json');*@
});
@ -350,19 +370,31 @@
})
function getStation(ids) {
var kwh = $('#kwh_order').val();
@*var kwh = $('#kwh_order').val();
var pr = $('#pr_order').val();
var send_data = {
cityid: ids,
status: status123,
kwhOrder: kwh,
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;
});
ids.sort();
if (ids.length == 0 || status123.length == 0) {
ids.sort();*@
if (ids.length == 0 || selectedStatus.length == 0) {
$('#areaCard').empty();
$('#solarTable').find('tbody').empty();
$("#today_kwh").html(0);
@ -379,7 +411,7 @@
$("#update_at").html(0);
}
else {
var Nurl = "/StationOverview/GetSolarByCity";
var Nurl = "/StationOverview/GetPowerStationByFilter";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -388,7 +420,7 @@
$('#areaCard').empty();
$('#solarTable').find('tbody').empty();
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'));
var statusicon;
switch (val.healthStatus) {
@ -462,13 +494,13 @@
'</tr>');
});
GetStationCard();
GetStationCard(rel.data);
}, 'json');
}
}
function GetStationCard() {
var send_data = {
function GetStationCard(powerStationSummary) {
@*var send_data = {
ids: powerids
};
var url = "/StationOverview/GetStationCard";
@ -490,12 +522,24 @@
$("#total_power_station_count").html(mapOverview.totalPowerStationCount);
$("#total_capacity").html(mapOverview.totalCapacity.toFixed(2));
$("#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
$('#CheckStatus').on("click", "input", function () {
var clickid = $(this).attr('id');
@*var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
@ -503,7 +547,7 @@
}
else {
status123.remove(Number(classid[1]));
}
}*@
getStation(ids);
})
//#endregion
@ -541,8 +585,8 @@
//#endregion
//#region 狀態全選
function AllStatus() {
status123 = [];
$("#status-all-check").click(function (e) {
@* status123 =[];
if (StatusType) {
for (var i = 1; i <= 3; i++) {
@ -555,9 +599,19 @@
status123.push(i);
}
StatusType = true;
}*@
var checked = $(this).attr("data-checked");
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);
}
});
//#endregion
function CardDisplay() {

View File

@ -557,7 +557,7 @@
function GetPowerStationCollapse(filter) {
var url = "/StationReport/GetPowerStationNameList"
var url = "/StationReport/GetPowerStationCollapse"
var send_data = {
Filter: filter
@ -612,9 +612,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}
@ -622,9 +622,9 @@
str += '<li class="list-group-item">' +
'<div class="d-flex justify-content-start">' +
'<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>' +
'<h5 class="font-weight-bold">' + inverter.powerStationName + '</h5>' +
'<h5 class="font-weight-bold">' + inverter.name + '</h5>' +
'</div>' +
'</li>';
}