1. 修改電站抓取方式 part4

This commit is contained in:
Kai 2021-09-02 14:30:46 +08:00
parent e958ebf918
commit 7fa16df8fe
21 changed files with 737 additions and 464 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

@ -110,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"))
{
//只有電站總覽 且未包含 電站管理
}
else if(controllerName == "User" && (actionName == "ChangePassword" || actionName == "GetPersonalInfo" || actionName == "SavePersonalInfo"))
else if (controllerName == "User" && (actionName == "ChangePassword" || actionName == "GetPersonalInfo" || actionName == "SavePersonalInfo"))
{
//查詢個人 資訊 及密碼
}

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

@ -87,7 +87,7 @@ namespace SolarPower.Controllers
}
order.Add(temp_pr_order_by);
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser, filter.CityIds, where, order);
var myPowerStations = myPowerStationService.GetMyPowerStations(myUser, filter.CityIds, where, null, order);
foreach(var powerStation in myPowerStations)
{

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

@ -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)
string Wheresql = "";
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++;
}
return result;
}
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())
@ -206,7 +218,7 @@ namespace SolarPower.Repository.Implement
try
{
string where = "";
if(filter.Status == 2 )
if (filter.Status == 2)
{
where = $"opr.Deleted = 1 ";
}

View File

@ -62,7 +62,7 @@ namespace SolarPower.Repository.Implement
}
}
public List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds, List<string> wheres = null, List<string> orderBy = null)
public List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null)
{
var results = new List<PowerStation>();
@ -88,7 +88,7 @@ namespace SolarPower.Repository.Implement
sql += @" WHERE ps.Deleted = 0";
}
if(cityIds != null && cityIds.Count > 0)
if (cityIds != null)
{
sql += @" AND c.Id IN @CityIds";
}
@ -111,7 +111,20 @@ namespace SolarPower.Repository.Implement
sql += $" ORDER BY c.Priority";
}
results = conn.Query<PowerStation>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, CityIds = cityIds }).ToList();
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)
@ -2654,20 +2667,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 });
}
@ -3115,7 +3145,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,
@ -3123,7 +3153,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
@ -3251,8 +3282,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
@ -5274,71 +5306,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

@ -24,7 +24,7 @@ namespace SolarPower.Repository.Interface
/// <param name="myUser"></param>
/// <returns></returns>
//List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "");
List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, List<string> orderBy = null);
List<PowerStation> GetMyPowerStationList(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, Dictionary<string, object> where_entities = null, List<string> orderBy = null);
/// <summary>
/// 查詢縣市列表
@ -598,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);
}

View File

@ -26,19 +26,19 @@ namespace SolarPower.Services.Implement
return myCities;
}
public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> cityIds = null, List<string> wheres = null, List<string> orderBy = null)
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, orderBy);
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, List<string> orderBy = null)
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, orderBy);
powerStations = powerStationRepository.GetMyPowerStationList(myUser, cityIds, wheres, where_entities, orderBy);
var myPowerStations_group = powerStations.GroupBy(x => x.CityId);

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() {
//#region DataTable
ExceptionTable = $("#Exception_Table").DataTable({
"pageLength": 20,
"paging": true,
@ -555,8 +394,8 @@
"type": "POST",
"data": function (d) {
d.id = powerids,
d.status = Type,
d.range = $('#date-range').val()
d.status = Type,
d.range = $('#date-range').val()
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
@ -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

@ -180,7 +180,7 @@
<div class="col-lg-6">
<div class="">
<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>
</div>
</div>
@ -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

@ -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>';
}