衝突合併
This commit is contained in:
commit
ebb8db668a
@ -1,4 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SolarPower.Models;
|
||||||
|
using SolarPower.Models.PowerStation;
|
||||||
|
using SolarPower.Repository.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -8,9 +12,109 @@ namespace SolarPower.Controllers
|
|||||||
{
|
{
|
||||||
public class StationReportController : MyBaseController<StationReportController>
|
public class StationReportController : MyBaseController<StationReportController>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private readonly IPowerStationRepository powerStationRepository;
|
||||||
|
private readonly IStationReportRepository stationReportRepository;
|
||||||
|
|
||||||
|
public StationReportController(IPowerStationRepository powerStationRepository, IStationReportRepository stationReportRepository) : base()
|
||||||
|
{
|
||||||
|
this.powerStationRepository = powerStationRepository;
|
||||||
|
this.stationReportRepository = stationReportRepository;
|
||||||
|
}
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<Dictionary<string,List<PowerStationIdAndCity>>>> GetPowerStationNameList(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.GetPowerStationsAllWithfilter(filter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
powerStations = await powerStationRepository.GetPowerStationsByCompanyIdWithfilter(myUser.CompanyId,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<List<string>>> GetTableHead(Select_table post)
|
||||||
|
{
|
||||||
|
ApiResult<List<string>> apiResult = new ApiResult<List<string>>();
|
||||||
|
List<string> inverter = new List<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var powerStation = await powerStationRepository.GetOneAsync(post.PowerStation);
|
||||||
|
if(powerStation == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "0001";
|
||||||
|
apiResult.Msg = "需加入查詢電站";
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
inverter = await stationReportRepository.GetInverterId(powerStation.SiteDB,post);
|
||||||
|
for (int i = 0;i<inverter.Count;i++)
|
||||||
|
{
|
||||||
|
inverter[i] = "inv_" + inverter[i].Substring(inverter[i].Length - 4, 4);
|
||||||
|
}
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = inverter;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】");
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<dynamic>> GetForm(Select_table post)
|
||||||
|
{
|
||||||
|
ApiResult<dynamic> apiResult = new ApiResult<dynamic>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var a = await stationReportRepository.Gettablebody(post);
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = a;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】");
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace SolarPower.Helper
|
|||||||
var rootStr = ed.AESDecrypt(dbConfig.Root);
|
var rootStr = ed.AESDecrypt(dbConfig.Root);
|
||||||
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
||||||
|
|
||||||
var connStr = $"server={serverStr};port={portStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
var connStr = $"server={serverStr};port={portStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;Allow User Variables=True;";
|
||||||
|
|
||||||
this._connectionString = connStr;
|
this._connectionString = connStr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SolarPower.Models
|
|
||||||
{
|
|
||||||
public class ExceptionRecord
|
|
||||||
{
|
|
||||||
public string asd { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
29
SolarPower/Models/StationReport.cs
Normal file
29
SolarPower/Models/StationReport.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SolarPower.Models
|
||||||
|
{
|
||||||
|
public class StationReport
|
||||||
|
{
|
||||||
|
public string asd { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PowerStationIdAndCity
|
||||||
|
{
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public string CityName { get; set; }
|
||||||
|
public string PowerStationName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Select_table
|
||||||
|
{
|
||||||
|
public int SearchType { get; set; }
|
||||||
|
public string Time { get; set; }
|
||||||
|
public int PowerStation { get; set; }
|
||||||
|
public int FormType { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,18 +0,0 @@
|
|||||||
using SolarPower.Helper;
|
|
||||||
using SolarPower.Models;
|
|
||||||
using SolarPower.Repository.Interface;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SolarPower.Repository.Implement
|
|
||||||
{
|
|
||||||
public class ExceptionRecordRepository : RepositoryBase<ExceptionRecord>, IExceptionRecordRepository
|
|
||||||
{
|
|
||||||
public ExceptionRecordRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
|
||||||
{
|
|
||||||
tableName = "power_station";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3901,5 +3901,55 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(int companyId,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 ps.CompanyId = @CompanyId ";
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter))
|
||||||
|
{
|
||||||
|
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||||
|
}
|
||||||
|
result = (await conn.QueryAsync<PowerStationIdAndCity>(sql, new { CompanyId = companyId, Filter = filter })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilter(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";
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(filter))
|
||||||
|
{
|
||||||
|
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||||
|
}
|
||||||
|
result = (await conn.QueryAsync<PowerStationIdAndCity>(sql, new { Filter = filter })).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
175
SolarPower/Repository/Implement/StationReportRepository.cs
Normal file
175
SolarPower/Repository/Implement/StationReportRepository.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
using Dapper;
|
||||||
|
using SolarPower.Helper;
|
||||||
|
using SolarPower.Models;
|
||||||
|
using SolarPower.Repository.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SolarPower.Repository.Implement
|
||||||
|
{
|
||||||
|
public class StationReportRepository : RepositoryBase<StationReport>, IStationReportRepository
|
||||||
|
{
|
||||||
|
public StationReportRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
||||||
|
{
|
||||||
|
tableName = "power_station";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<string>> GetInverterId(string DBname, Select_table post)
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = @$"SELECT InverterId from {DBname}.inverter i left JOIN {DBname}.controller c ON i.ControllerId = c.Id
|
||||||
|
WHERE i.Deleted != 1 AND c.PowerStationId = {post.PowerStation}";
|
||||||
|
result = (await conn.QueryAsync<string>(sql)).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> Gettablebody(Select_table post)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
dynamic a;
|
||||||
|
conn.Open();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = "";
|
||||||
|
switch(post.FormType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
sql = @$"
|
||||||
|
SET @sql = NULL;
|
||||||
|
SELECT
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 4), '''')
|
||||||
|
) INTO @sql
|
||||||
|
FROM inverter_history_hour;
|
||||||
|
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
|
||||||
|
', b.KWH hourKWH, round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}'' and powerstationid = {post.PowerStation}))*100,2) ''hourKWHp'', d.irradiance ''irradiance'', d.Temperature ''temperature'',
|
||||||
|
b.money ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(b.PR, 2) as pr
|
||||||
|
FROM inverter_history_hour a left join
|
||||||
|
( # 每小時加總 inv
|
||||||
|
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH,
|
||||||
|
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
|
||||||
|
from power_station_history_hour
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
|
||||||
|
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = b.report_date
|
||||||
|
left join
|
||||||
|
( # day
|
||||||
|
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP
|
||||||
|
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
|
||||||
|
from power_station_history_day
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
|
||||||
|
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = c.report_date
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')report_date, irradiance, Temperature
|
||||||
|
from sensor_history_hour
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
|
||||||
|
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = d.report_date
|
||||||
|
join
|
||||||
|
(
|
||||||
|
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
|
||||||
|
)z on a.powerstationid = z.id
|
||||||
|
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
|
||||||
|
GROUP BY DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')
|
||||||
|
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') ');
|
||||||
|
|
||||||
|
#select @sql as 'mySelect'; #顯示動態語法
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(post.SearchType == 2)
|
||||||
|
{
|
||||||
|
sql = @$"
|
||||||
|
SET @sql = NULL;
|
||||||
|
SELECT
|
||||||
|
GROUP_CONCAT(DISTINCT
|
||||||
|
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 4), '''')
|
||||||
|
) INTO @sql
|
||||||
|
FROM inverter_history_hour;
|
||||||
|
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
|
||||||
|
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
|
||||||
|
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
|
||||||
|
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone''
|
||||||
|
FROM inverter_history_day a left join
|
||||||
|
( # 每日加總 inv
|
||||||
|
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH,
|
||||||
|
round(todayKWH, 2) todayKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, ifnull(round(money, 2),0) money, round(SOLARHOUR, 2) SOLARHOUR
|
||||||
|
from power_station_history_day
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
|
||||||
|
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = b.report_date
|
||||||
|
left join
|
||||||
|
( # month
|
||||||
|
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m'') report_date, sitetype, round(monthKWH, 2) monthKWH,round(KWHKWP, 2) KWHKWP
|
||||||
|
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
|
||||||
|
from power_station_history_month
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
|
||||||
|
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = c.report_date
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature
|
||||||
|
from sensor_history_day
|
||||||
|
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
|
||||||
|
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date
|
||||||
|
join
|
||||||
|
(
|
||||||
|
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
|
||||||
|
)z on a.powerstationid = z.id
|
||||||
|
where DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = ''{post.Time}''
|
||||||
|
GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'')
|
||||||
|
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') ');
|
||||||
|
|
||||||
|
# select @sql as 'mySelect'; #顯示動態語法
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a = await conn.QueryAsync<dynamic>(sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using SolarPower.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SolarPower.Repository.Interface
|
|
||||||
{
|
|
||||||
public interface IExceptionRecordRepository : IRepositoryBase<ExceptionRecord>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -552,5 +552,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
||||||
|
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(int companyId,string filter);
|
||||||
|
Task<List<PowerStationIdAndCity>> GetPowerStationsAllWithfilter(string filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
SolarPower/Repository/Interface/IStationReportRepository.cs
Normal file
14
SolarPower/Repository/Interface/IStationReportRepository.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using SolarPower.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SolarPower.Repository.Interface
|
||||||
|
{
|
||||||
|
public interface IStationReportRepository : IRepositoryBase<StationReport>
|
||||||
|
{
|
||||||
|
Task<List<string>> GetInverterId(string DBname, Select_table post);
|
||||||
|
Task<dynamic> Gettablebody(Select_table post);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -77,7 +77,7 @@ namespace SolarPower
|
|||||||
services.AddTransient<IOperationRepository, OperationRepository>();
|
services.AddTransient<IOperationRepository, OperationRepository>();
|
||||||
services.AddTransient<IOverviewRepository, OverviewRepository>();
|
services.AddTransient<IOverviewRepository, OverviewRepository>();
|
||||||
services.AddTransient<IAnalysisStationCombineRepository,AnalysisStationCombineRepository>();
|
services.AddTransient<IAnalysisStationCombineRepository,AnalysisStationCombineRepository>();
|
||||||
services.AddTransient<IExceptionRecordRepository, ExceptionRecordRepository>();
|
services.AddTransient<IStationReportRepository, StationReportRepository>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");
|
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");
|
||||||
|
|||||||
@ -204,20 +204,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3" id="quickSearchOption">
|
<div class="pr-3" id="quickSearchOption">
|
||||||
<button type="button" class="btn btn-primary waves-effect waves-themed btn-change-quickSearch1 ml-6" onclick="quickSearch(0)">日報表</button>
|
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1" onclick="Dateform(0)" id="daybtn">日報表</button>
|
||||||
<button type="button" class="btn btn-primary waves-effect waves-themed btn-change-quickSearch2 ml-6" onclick="quickSearch(1)">月報表</button>
|
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1" onclick="Dateform(1)" id="monthbtn">月報表</button>
|
||||||
<button type="button" class="btn btn-primary waves-effect waves-themed btn-change-quickSearch2 ml-6" onclick="quickSearch(1)">綜合報表</button>
|
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1" onclick="Dateform(2)" id="yearbtn">綜合報表</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 d-flex justify-content-start">
|
<div class="mb-3 d-flex justify-content-start">
|
||||||
<div class="pr-3">
|
<div class="pr-3">
|
||||||
<button type="button" class="btn btn-primary waves-effect waves-themed btn-change-quickSearch1" onclick="quickSearch(0)"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
|
<button type="button" class="btn btn-primary waves-effect waves-themed"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="pr-3" id="selectOneStation">
|
||||||
</div>
|
</div>
|
||||||
<div class="pr-3">
|
|
||||||
<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id=''>新竹交大站</button>
|
|
||||||
<button type='button' class='btn btn-outline-success waves-effect waves-themed ml-2' id=''>新竹巨城站</button>
|
|
||||||
<button type='button' class='btn btn-outline-success waves-effect waves-themed ml-2' id=''>新竹交大站</button>
|
|
||||||
<button type='button' class='btn btn-outline-success waves-effect waves-themed ml-2' id=''>新竹交大站</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -226,9 +224,573 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="card p-3 w-100 overflow-auto">
|
||||||
|
<table class="table m-0">
|
||||||
|
<thead id="tothead">
|
||||||
|
</thead>
|
||||||
|
<tbody id="totbody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-5">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="card p-3 w-100 overflow-auto">
|
||||||
|
|
||||||
|
<table class="table m-0">
|
||||||
|
<thead id="TableHead">
|
||||||
|
</thead>
|
||||||
|
<tbody id="TableBody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@section Scripts{
|
||||||
|
<script>
|
||||||
|
var searchType = 0;//搜尋條件(日,日區間,月,年)
|
||||||
|
var datepicker;
|
||||||
|
var timerange;//選取時間
|
||||||
|
var selecterd_invert = [];
|
||||||
|
var nowpowerstation;//選擇電站
|
||||||
|
var haveinvertName = [];
|
||||||
|
$(function () {
|
||||||
|
//#region 預設初始值
|
||||||
|
$('#DateGet').val(new Date().toISOString().substring(0, 10));
|
||||||
|
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
|
||||||
|
$('#DateGet').attr('style', 'width:205px');
|
||||||
|
$('#DateGettext').attr('style', 'width:205px');
|
||||||
|
timerange = $('#DateGet').val();
|
||||||
|
document.getElementById("monthbtn").disabled = true;//月報表鎖定
|
||||||
|
document.getElementById("yearbtn").disabled = true;//綜合報表鎖定
|
||||||
|
document.getElementById("daybtn").disabled = false;//日報表鎖定
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 載入左邊選單列表
|
||||||
|
GetPowerStationCollapse("");
|
||||||
|
//#endregion
|
||||||
|
})
|
||||||
|
|
||||||
|
//#region 更換搜尋條件(日,日區間,月,年)
|
||||||
|
function changeType(type, e) {
|
||||||
|
searchType = type;
|
||||||
|
if ($(".btn-change-searchType").hasClass("btn-success")) {
|
||||||
|
$(".btn-change-searchType").removeClass("btn-success").addClass("btn-secondary");
|
||||||
|
}
|
||||||
|
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
|
||||||
|
document.getElementById("DateGet").style.display = "";//隱藏
|
||||||
|
$(e).removeClass("btn-secondary").addClass("btn-success");
|
||||||
|
switch (type) {
|
||||||
|
case 0: $('#DateGet').prop({ 'type': 'date' });
|
||||||
|
$(".btn-change-quickSearch1").html("今天");
|
||||||
|
$(".btn-change-quickSearch2").html("昨天");
|
||||||
|
var today = new Date().toISOString().substring(0, 10);
|
||||||
|
$('#DateGet').val(today);
|
||||||
|
document.getElementById("monthbtn").disabled = true;//月報表鎖定
|
||||||
|
document.getElementById("yearbtn").disabled = true;//綜合報表鎖定
|
||||||
|
document.getElementById("daybtn").disabled = false;//日報表鎖定
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
|
||||||
|
//#region Date-Picker
|
||||||
|
datepicker = $('#DateGettext').daterangepicker({
|
||||||
|
autoUpdateInput: false,
|
||||||
|
locale: { format: 'YYYY/MM/DD' },
|
||||||
|
opens: 'left'
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#DateGettext').on('apply.daterangepicker', function (ev, picker) {
|
||||||
|
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
|
||||||
|
$(this).trigger('change');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#DateGettext').on('cancel.daterangepicker', function (ev, picker) {
|
||||||
|
$(this).val('');
|
||||||
|
$(this).trigger('change');
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
$(".btn-change-quickSearch1").html("近7天");
|
||||||
|
$(".btn-change-quickSearch2").html("近30天");
|
||||||
|
//#region 預設近7天
|
||||||
|
var today = new Date();
|
||||||
|
var dateLimit = new Date(new Date().setDate(today.getDate() - 7));
|
||||||
|
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);
|
||||||
|
document.getElementById("DateGettextdiv").style.display = "";//隱藏
|
||||||
|
document.getElementById("DateGet").style.display = "none";//隱藏
|
||||||
|
//#endregion
|
||||||
|
$('#DateGettext').val(dateLimit_format + ' - ' + today_format);
|
||||||
|
document.getElementById("daybtn").disabled = true;//日報表鎖定
|
||||||
|
document.getElementById("monthbtn").disabled = false;//月報表鎖定
|
||||||
|
document.getElementById("yearbtn").disabled = false;//綜合報表鎖定
|
||||||
|
break;
|
||||||
|
case 2: $('#DateGet').prop({ 'type': 'month' });
|
||||||
|
$(".btn-change-quickSearch1").html("本月");
|
||||||
|
$(".btn-change-quickSearch2").html("上個月");
|
||||||
|
var now_month = new Date().toISOString().substring(0, 7);
|
||||||
|
$('#DateGet').val(now_month);
|
||||||
|
document.getElementById("daybtn").disabled = true;//日報表鎖定
|
||||||
|
document.getElementById("monthbtn").disabled = false;//月報表鎖定
|
||||||
|
document.getElementById("yearbtn").disabled = false;//綜合報表鎖定
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$(".btn-change-quickSearch1").html("今年");
|
||||||
|
$(".btn-change-quickSearch2").html("去年");
|
||||||
|
var now_year = new Date().toISOString().substring(0, 4);
|
||||||
|
$('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
|
||||||
|
$('#DateGet').val(now_year);
|
||||||
|
document.getElementById("daybtn").disabled = true;//日報表鎖定
|
||||||
|
document.getElementById("monthbtn").disabled = true;//月報表鎖定
|
||||||
|
document.getElementById("yearbtn").disabled = false;//綜合報表鎖定
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (type == 1) {
|
||||||
|
timerange = $('#DateGettext').val();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timerange = $('#DateGet').val();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 快速填入條件(EX.今昨天)
|
||||||
|
function quickSearch(day) {
|
||||||
|
switch (searchType) {
|
||||||
|
case 0:
|
||||||
|
if (day == 0) {
|
||||||
|
var today = new Date().toISOString().substring(0, 10);
|
||||||
|
$('#DateGet').val(today).trigger('change');
|
||||||
|
} else {
|
||||||
|
var dateLimit = new Date(new Date().setDate(new Date().getDate() - 1)).toISOString().substring(0, 10);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (day == 0) {
|
||||||
|
//#region 預設近7天
|
||||||
|
var today = new Date();
|
||||||
|
var dateLimit = new Date(new Date().setDate(today.getDate() - 7));
|
||||||
|
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);
|
||||||
|
//#endregion
|
||||||
|
$('#DateGettext').val(dateLimit_format + ' - ' + today_format).trigger('change');
|
||||||
|
} else {
|
||||||
|
//#region 預設近30天
|
||||||
|
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);
|
||||||
|
//#endregion
|
||||||
|
$('#DateGettext').val(dateLimit_format + ' - ' + today_format).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (day == 0) {
|
||||||
|
var now_month = new Date().toISOString().substring(0, 7);
|
||||||
|
$('#DateGet').val(now_month).trigger('change');
|
||||||
|
} else {
|
||||||
|
var dateLimit = new Date(new Date().setMonth(new Date().getMonth() - 1)).toISOString().substring(0, 7);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (day == 0) {
|
||||||
|
var now_year = new Date().toISOString().substring(0, 4);
|
||||||
|
$('#DateGet').val(now_year).trigger('change');
|
||||||
|
} else {
|
||||||
|
var dateLimit = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString().substring(0, 4);
|
||||||
|
$('#DateGet').val(dateLimit).trigger('change');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 更換input
|
||||||
|
$('#DateGet').on('change', function () {
|
||||||
|
timerange = $('#DateGet').val();
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 更換inputtext
|
||||||
|
$('#DateGettext').on('change', function () {
|
||||||
|
timerange = $('#DateGettext').val();
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 顯示動態選取電站
|
||||||
|
function AddButtonWithStation()
|
||||||
|
{
|
||||||
|
$('#selectOneStation').empty();
|
||||||
|
var stri = '';
|
||||||
|
$.each(selecterd_invert, function (index, inverter) {
|
||||||
|
if (inverter.value == nowpowerstation)
|
||||||
|
{
|
||||||
|
stri += '<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="' + inverter.value + '" onclick="selectPowerStation(' + inverter.value + ',this) ">' + inverter.name + '</button>';
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stri += '<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="' + inverter.value + '" onclick="selectPowerStation(' + inverter.value + ',this) ">' + inverter.name + '</button>';
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$('#selectOneStation').append(stri);
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 選擇動態選取電站
|
||||||
|
function selectPowerStation(a,e)
|
||||||
|
{
|
||||||
|
nowpowerstation = a;
|
||||||
|
if ($('#selectOneStation').find('.btn-station').hasClass("btn-success")) {
|
||||||
|
$('#selectOneStation').find('.btn-station').removeClass("btn-success").addClass("btn-outline-success");
|
||||||
|
}
|
||||||
|
$(e).removeClass("btn-outline-success").addClass("btn-success");
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 左邊的搜索欄位
|
||||||
|
function myfunc(div) {
|
||||||
|
var className = div.getAttribute("class");
|
||||||
|
if (className == "fal fa-angle-left fa-lg py-3") {
|
||||||
|
div.className = "fal fa-angle-right fa-lg py-3";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
div.className = "fal fa-angle-left fa-lg py-3";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#js_list_accordion_filter").change(function (e) {
|
||||||
|
GetPowerStationCollapse($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
|
||||||
|
var getstation =
|
||||||
|
{
|
||||||
|
name: $(this).attr('valuename'),
|
||||||
|
value: this.value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.checked) {
|
||||||
|
selecterd_invert.push(getstation);
|
||||||
|
} else {
|
||||||
|
//var ss = $.inArray(getstation, selecterd_invert);
|
||||||
|
//var a = 0;
|
||||||
|
var a = selecterd_invert.filter(function (n, i) {
|
||||||
|
|
||||||
|
if (n.name === getstation.name && n.value === getstation.value) {
|
||||||
|
if (nowpowerstation == getstation.value) {
|
||||||
|
nowpowerstation = null;
|
||||||
|
}
|
||||||
|
console.log(n);
|
||||||
|
selecterd_invert.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
AddButtonWithStation();
|
||||||
|
console.log(selecterd_invert);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function GetPowerStationCollapse(filter) {
|
||||||
|
var url = "/StationReport/GetPowerStationNameList"
|
||||||
|
|
||||||
|
var send_data = {
|
||||||
|
Filter: filter
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.data.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var inverterCollapse = rel.data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#js_list_accordion').empty();
|
||||||
|
|
||||||
|
if (inverterCollapse.length <= 0) {
|
||||||
|
$('#js_list_accordion').append("<div>查無結果</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
var str = "";
|
||||||
|
|
||||||
|
Object.keys(inverterCollapse).map(function (key, index) {
|
||||||
|
str += '<div class="card border-top-left-radius-0 border-top-right-radius-0" id="templateCard">' +
|
||||||
|
'<div class="card-header">' +
|
||||||
|
'<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-' + index + '" aria-expanded="false" data-filter-tags="settings">' +
|
||||||
|
'<i class="fal fa-globe width-2 fs-xl"></i>' +
|
||||||
|
'<span class="city-name">' + key + '</span>' +
|
||||||
|
'<span class="ml-auto">' +
|
||||||
|
'<span class="collapsed-reveal"><i class="fal fa-chevron-up fs-xl"></i></span>' +
|
||||||
|
'<span class="collapsed-hidden"><i class="fal fa-chevron-down fs-xl"></i></span>' +
|
||||||
|
'</span>' +
|
||||||
|
'</a>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div id="js_list_accordion-' + index + '" class="collapse" data-parent="#js_list_accordion-'+ index +'" style="">' +
|
||||||
|
'<div class="card-body">' +
|
||||||
|
'<ul class="list-group list-group-flush">';
|
||||||
|
$.each(inverterCollapse[key], function (index, inverter) {
|
||||||
|
str += '<li class="list-group-item">' +
|
||||||
|
'<div class="d-flex justify-content-between">' +
|
||||||
|
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + inverter.powerStationName + '</h4>' +
|
||||||
|
'<div class="">' +
|
||||||
|
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName+'">' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'</li>';
|
||||||
|
});
|
||||||
|
|
||||||
|
str += '</ul>';
|
||||||
|
str += '</div>';
|
||||||
|
str += '</div>';
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#js_list_accordion').append(str);
|
||||||
|
$('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0");
|
||||||
|
|
||||||
|
$('input[name="selectedInverterLayer2[]"]').each(function () {
|
||||||
|
if ($.inArray(this.value, selecterd_invert) > -1) {
|
||||||
|
$(this).prop('checked', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#js_list_accordion .collapse").collapse('show');
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
function tablehand(form) {
|
||||||
|
var send_data =
|
||||||
|
{
|
||||||
|
SearchType: searchType,
|
||||||
|
Time: timerange,
|
||||||
|
FormType: form,
|
||||||
|
PowerStation: nowpowerstation
|
||||||
|
}
|
||||||
|
var url = "/StationReport/GetTableHead";
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_warning(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#TableHead').empty();
|
||||||
|
var str = "<tr>";
|
||||||
|
str += "<th>Date</th>";
|
||||||
|
$.each(rel.data, function (index, inverter) {
|
||||||
|
haveinvertName.push(inverter);
|
||||||
|
str += "<th>" + inverter + "</th>";
|
||||||
|
})
|
||||||
|
switch (form)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
str += "<th>小時<br />發電量<br />(kWh)</th>";
|
||||||
|
str += "<th>小時<br />發電量<br />百分比<br />(%)</th>";
|
||||||
|
str += "<th>小時<br />平均<br />日照度<br />(W/㎡)</th>";
|
||||||
|
str += "<th>小時<br />平均<br />模組<br />溫度<br />(°C)</th>";
|
||||||
|
str += "<th>小時<br />售電<br />金額<br />(NTD)</th>";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
str += "<th>日<br />發電量<br />(kWh)</th>";
|
||||||
|
str += "<th>日<br />發電量<br />百分比<br />(%)</th>";
|
||||||
|
str += "<th>日照小時(hr)</th>";
|
||||||
|
str += "<th>kWH/kWP</th>";
|
||||||
|
str += "<th>PR%</th>";
|
||||||
|
str += "<th>日<br />平均<br />日照度<br />(W/㎡)</th>";
|
||||||
|
str += "<th>日<br />平均<br />模組溫度<br />(°C)</th>";
|
||||||
|
str += "<th>日<br />售電金額<br />(NTD)</th>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
str += "</tr>";
|
||||||
|
$('#TableHead').append(str);
|
||||||
|
|
||||||
|
tablebody(form);
|
||||||
|
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Dateform(form) {
|
||||||
|
tablehand(form);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function tablebody(form)
|
||||||
|
{
|
||||||
|
var send_data =
|
||||||
|
{
|
||||||
|
SearchType: searchType,
|
||||||
|
Time: timerange,
|
||||||
|
FormType: form,
|
||||||
|
PowerStation: nowpowerstation
|
||||||
|
}
|
||||||
|
var url = "/StationReport/GetForm";
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.data.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var sta = "";
|
||||||
|
$('#TableBody').empty();
|
||||||
|
$('#totbody').empty();
|
||||||
|
$('#tothead').empty();
|
||||||
|
|
||||||
|
if (form == 0) {//日報表
|
||||||
|
var thour = 0;
|
||||||
|
var tpr = 0;
|
||||||
|
var tkwh = 0;
|
||||||
|
var kWhkwp = 0;
|
||||||
|
var ntd = 0;
|
||||||
|
var ntdone = 0;
|
||||||
|
|
||||||
|
$.each(rel.data, function (index, inverter) {
|
||||||
|
sta += "<tr>";
|
||||||
|
sta += "<td>" + inverter.report_date + "</td>";
|
||||||
|
$.each(haveinvertName, function (item, i) {
|
||||||
|
if (inverter[i] == null) {
|
||||||
|
sta += "<td>" + 0 + "</td>";
|
||||||
|
} else {
|
||||||
|
sta += "<td>" + inverter[i] + "</td>";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sta += "<td>" + inverter.hourKWH + "</td>";
|
||||||
|
sta += "<td>" + inverter.hourKWHp + "</td>";
|
||||||
|
sta += "<td>" + inverter.irradiance + "</td>";
|
||||||
|
sta += "<td>" + inverter.temperature + "</td>";
|
||||||
|
sta += "<td>" + inverter.hourmoney + "</td>";
|
||||||
|
sta += "</tr>";
|
||||||
|
thour = inverter.tothour ? inverter.tothour.toFixed(2) : 0;
|
||||||
|
tpr = inverter.pr ? inverter.pr.toFixed(2) : 0;
|
||||||
|
tkwh = inverter.totKWH ? inverter.totKWH.toFixed(2) : 0;
|
||||||
|
kWhkwp = inverter.totKWHKWP ? inverter.totKWHKWP.toFixed(2) : 0;
|
||||||
|
ntd = inverter.totmoney ? inverter.totmoney.toFixed(2) : 0;
|
||||||
|
ntdone = inverter.totmoney / inverter.totKWH ? (inverter.totmoney / inverter.totKWH).toFixed(2) : 0;
|
||||||
|
})
|
||||||
|
var stc = "<tr>";
|
||||||
|
stc += "<th>" + '日照小時' + "</th>";
|
||||||
|
stc += "<th>" + 'kWH/kWP' + "</th>";
|
||||||
|
stc += "<th>" + 'PR%' + "</th>";
|
||||||
|
stc += "<th>" + '日發電量(kWh)' + "</th>";
|
||||||
|
stc += "<th>" + '日售電金額(NTD)' + "</th>";
|
||||||
|
stc += "<th>" + '日售電單價(NTD)' + "</th>";
|
||||||
|
stc += "</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
var stb = "<tr>";
|
||||||
|
stb += "<td>" + thour + "</td>";
|
||||||
|
stb += "<td>" + kWhkwp + "</td>";
|
||||||
|
stb += "<td>" + tpr + "</td>";
|
||||||
|
stb += "<td>" + tkwh + "</td>";
|
||||||
|
stb += "<td>" + ntd + "</td>";
|
||||||
|
stb += "<td>" + ntdone + "</td>";
|
||||||
|
stb += "</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
$('#TableBody').append(sta);
|
||||||
|
$('#totbody').append(stb);
|
||||||
|
$('#tothead').append(stc);
|
||||||
|
haveinvertName = [];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var avghour = 0;
|
||||||
|
var avgKWHKWP = 0;
|
||||||
|
var avgdayKWH = 0;
|
||||||
|
var monthKWH = 0;
|
||||||
|
var monthmoney = 0;
|
||||||
|
var monthmoneyone = 0;
|
||||||
|
var monthday = 0;
|
||||||
|
$.each(rel.data, function (index, inverter) {
|
||||||
|
sta += "<tr>";
|
||||||
|
sta += "<td>" + inverter.report_date + "</td>";
|
||||||
|
$.each(haveinvertName, function (item, i) {
|
||||||
|
if (inverter[i] == null) {
|
||||||
|
sta += "<td>" + 0 + "</td>";
|
||||||
|
} else {
|
||||||
|
sta += "<td>" + inverter[i] + "</td>";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sta += "<td>" + inverter.dayKWH + "</td>";
|
||||||
|
sta += "<td>" + inverter.dayKWHp + "</td>";
|
||||||
|
sta += "<td>" + inverter.tothour + "</td>";
|
||||||
|
sta += "<td>" + inverter.KWHKWP + "</td>";
|
||||||
|
sta += "<td>" + inverter.PR + "</td>";
|
||||||
|
sta += "<td>" + inverter.irradiance + "</td>";
|
||||||
|
sta += "<td>" + inverter.temperature + "</td>";
|
||||||
|
sta += "<td>" + inverter.soldmoney + "</td>";
|
||||||
|
sta += "</tr>";
|
||||||
|
avghour += inverter.tothour ? inverter.tothour : 0;
|
||||||
|
avgKWHKWP += inverter.KWHKWP ? inverter.KWHKWP : 0;
|
||||||
|
avgdayKWH += inverter.dayKWH ? inverter.dayKWH : 0;
|
||||||
|
monthKWH = inverter.monthKWH ? inverter.monthKWH : 0;
|
||||||
|
monthmoney = inverter.monthmoney ? inverter.monthmoney : 0;
|
||||||
|
monthmoneyone += inverter.monthmoneyone ? inverter.monthmoneyone : 0;
|
||||||
|
})
|
||||||
|
monthday = rel.data.length;
|
||||||
|
|
||||||
|
|
||||||
|
var stc = "<tr>";
|
||||||
|
stc += "<th>" + '日日照小時平均' + "</th>";
|
||||||
|
stc += "<th>" + '日kWH/kWP平均' + "</th>";
|
||||||
|
stc += "<th>" + '日發電量平均(kWh)' + "</th>";
|
||||||
|
stc += "<th>" + '月發電量(kWh)' + "</th>";
|
||||||
|
stc += "<th>" + '月售電金額(NTD)' + "</th>";
|
||||||
|
stc += "<th>" + '月售電單價(NTD)' + "</th>";
|
||||||
|
stc += "<th>" + '月售電天數' + "</th>";
|
||||||
|
stc += "</tr>";
|
||||||
|
|
||||||
|
var stb = "<tr>";
|
||||||
|
if (monthday == 0) {
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "<td>" + 0 + "</td>";
|
||||||
|
stb += "</tr>";
|
||||||
|
} else {
|
||||||
|
stb += "<td>" + (avghour / monthday).toFixed(2) + "</td>";
|
||||||
|
stb += "<td>" + (avgKWHKWP / monthday).toFixed(2) + "</td>";
|
||||||
|
stb += "<td>" + (avgdayKWH / monthday).toFixed(2) + "</td>";
|
||||||
|
stb += "<td>" + monthKWH + "</td>";
|
||||||
|
stb += "<td>" + monthmoney + "</td>";
|
||||||
|
stb += "<td>" + (monthmoneyone / monthday).toFixed(2) + "</td>";
|
||||||
|
stb += "<td>" + monthday + "</td>";
|
||||||
|
stb += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#TableBody').append(sta);
|
||||||
|
$('#totbody').append(stb);
|
||||||
|
$('#tothead').append(stc);
|
||||||
|
haveinvertName = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user