This commit is contained in:
JiaHao Liu 2021-10-06 15:57:17 +08:00
commit b50d8a9eef
43 changed files with 1051 additions and 561 deletions

View File

@ -913,8 +913,15 @@ namespace SolarPower.Controllers
apiResult.Data = analysisInverter;
}
catch (Exception exception)
{
if(exception.Message == "Fatal error encountered during command execution.")
{
apiResult.Code = "9984";
}
else
{
apiResult.Code = "9999";
}
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}

View File

@ -46,7 +46,7 @@ namespace SolarPower.Controllers
where_entities.Add("Filter", filter);
}
//抓出 除了自建自用
var temp_solarType_where = $@" ps.SolarType != 2";
where.Add(temp_solarType_where);

View File

@ -177,7 +177,7 @@ namespace SolarPower.Controllers
myUser.myPowerStationGroupByCities = myPowerStations;
ViewBag.myPowerStationGroupByCities = myPowerStations;
if (controllerName == "PowerStation" && actionName == "Edit")
if (controllerName == "StationOverview" && actionName == "Info")
{
//電站資訊的各電站
string stationId_param = filterContext.HttpContext.Request.Query["stationId"];

View File

@ -47,7 +47,7 @@ namespace SolarPower.Controllers
where_entities.Add("Filter", filter);
}
var temp_solartype_where = @" ps.SolarType = 0";
var temp_solartype_where = @" ps.SolarType != 2";
where.Add(temp_solartype_where);
var powerStations = myPowerStationService.GetMyPowerStations(myUser, 1, null, where, where_entities);

View File

@ -420,7 +420,7 @@ namespace SolarPower.Controllers
"日發電量(kWh)",
"日發電量百分比(%)",
"日照小時(hr)",
"kWH/kWP",
"有效發電小時",
"PR%",
"日平均日照度(W/㎡)",
"日平均模組溫度(°C)"
@ -518,7 +518,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("kWH/kWP平均(日)");
cell.SetCellValue("平均有效發電小時(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -666,7 +666,7 @@ namespace SolarPower.Controllers
"月發電量(kWh)",
"月發電量百分比(%)",
"日照小時(hr)",
"kWH/kWP",
"有效發電小時",
"PR%",
"月平均日照度(W/㎡)",
"月平均模組溫度(°C)"
@ -764,7 +764,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("kWH/kWP平均(月)");
cell.SetCellValue("平均有效發電小時(月)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -1141,7 +1141,7 @@ namespace SolarPower.Controllers
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("kWH/kWP:");
cell.SetCellValue("有效發電小時:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(kWhkwp) ? Convert.ToDouble(kWhkwp) : 0);
@ -1220,7 +1220,7 @@ namespace SolarPower.Controllers
"日發電量(kWh)",
"日發電量百分比(%)",
"日照小時(hr)",
"kWH/kWP",
"有效發電小時",
"PR%",
"日平均日照度(W/㎡)",
"日平均模組溫度(°C)"
@ -1574,7 +1574,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.SolarHour,2));
cell.SetCellValue(Math.Round(form.AvgKWHKWP,2));
cell.CellStyle = styleLine12;
index++;
@ -1634,7 +1634,8 @@ namespace SolarPower.Controllers
City = form.CityName,
Count = 1,
Kwh = form.Kwh,
SolarHour = form.SolarHour
SolarHour = form.SolarHour,
Kwhkwp = form.AvgKWHKWP
};
if( cityArrays.Where(a=>a.City == form.CityName).Count() > 0)
{
@ -1642,6 +1643,7 @@ namespace SolarPower.Controllers
city.Count += cityinfo.Count;
city.Kwh += cityinfo.Kwh;
city.SolarHour += cityinfo.SolarHour;
city.Kwhkwp += cityinfo.Kwhkwp;
}
else
{
@ -1659,7 +1661,7 @@ namespace SolarPower.Controllers
"區域",
"電站名稱",
"發電量",
"發電小時",
"有效發電小時",
"平均日照",
"PR"
};
@ -1708,7 +1710,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round((cityArray.SolarHour / cityArray.Count), 2));
cell.SetCellValue(Math.Round((cityArray.Kwhkwp / cityArray.Count), 2));
cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -1742,7 +1744,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue("發電時間(小時)");
cell.SetCellValue("有效發電小時");
cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -1919,7 +1921,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.SolarHour, 2));
cell.SetCellValue(Math.Round(form.AvgKWHKWP, 2));
cell.CellStyle = styleLine12;
index++;
@ -1979,7 +1981,8 @@ namespace SolarPower.Controllers
City = form.CityName,
Count = 1,
Kwh = form.Kwh,
SolarHour = form.SolarHour
SolarHour = form.SolarHour,
Kwhkwp = form.AvgKWHKWP
};
if (cityArrays.Where(a => a.City == form.CityName).Count() > 0)
{
@ -1987,6 +1990,7 @@ namespace SolarPower.Controllers
city.Count += cityinfo.Count;
city.Kwh += cityinfo.Kwh;
city.SolarHour += cityinfo.SolarHour;
city.Kwhkwp += cityinfo.Kwhkwp;
}
else
{
@ -2004,7 +2008,7 @@ namespace SolarPower.Controllers
"區域",
"電站名稱",
"發電量",
"發電小時",
"有效發電小時",
"平均日照",
"PR"
};
@ -2053,7 +2057,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round((cityArray.SolarHour / cityArray.Count), 2));
cell.SetCellValue(Math.Round((cityArray.Kwhkwp / cityArray.Count), 2));
cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -2087,7 +2091,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue("發電時間(小時)");
cell.SetCellValue("有效發電小時");
cell.CellStyle = styleLine12;
region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -2182,6 +2186,46 @@ namespace SolarPower.Controllers
return Path.Combine("\\" + "upload", "report", Datename, "FIC太陽能監控平台" + "_" + "綜合報表" + "_" + postObject.Userid + Datename + ".xlsx");
}
public async Task<ApiResult<List<string>>> CheckExcel(Select_table2 post)
{
var ApiResult = new ApiResult<List<string>>();
var ErrorMessage = new List<string>();
foreach (var station in post.PowerStation)
{
var Id = Convert.ToInt32(station.Value);
var table = new Select_table()
{
FormType = post.FormType,
SearchType = post.SearchType,
PowerStation = Id,
Time = post.Time,
Userid = post.Userid
};
var checkinv = await stationReportRepository.Findhaveinv(table);
var getinvsql = checkinv[0] as IDictionary<string, object>;
if (getinvsql["mySelect"] == null)
{
ErrorMessage.Add(station.Name + "此時段無逆變器資料");
}
else
{
var cid = await stationReportRepository.CheckExcelAsync(table);
if (cid == 0)
{
ErrorMessage.Add(station.Name + "此時段資料未建立");
}
}
}
if(ErrorMessage.Count > 0)
{
ApiResult.Code = "9999";
ApiResult.Data = ErrorMessage;
}
else
{
ApiResult.Code = "0000";
}
return ApiResult;
}
}
}

View File

@ -382,9 +382,12 @@ namespace SolarPower.Controllers
}
#endregion
var website_url = await powerStationRepository.GetOneVariableByName("WebSiteUrl");
var sendSubject = "新增帳號成功";
var sendContent = $"您的新密碼為:{random_password}";
var sendContent = $@"您的新密碼為:{random_password}
<br><a href='{website_url}' target='_blank'>{website_url}</a>";
List<string> recipientEmails = new List<string>()
{

View File

@ -2212,6 +2212,9 @@ ALTER TABLE `power_station_exception`
CHANGE COLUMN `UpperLimit` `UpperLimit` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '上限值' AFTER `Type`,
CHANGE COLUMN `LowerLimit` `LowerLimit` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '下限值' AFTER `UpperLimit`;
-- 新增太陽能電站網址
INSERT INTO `solar_power_test`.`variable` (`Name`, `Value`, `Remark`) VALUES ('WebSiteUrl', 'http://green.fic.com.tw/', '太陽能電站管理系統網址');
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

View File

@ -17,6 +17,8 @@ namespace SolarPower.Models
public double All_PR { get; set; }//總平均PR
public double Now_Carbon { get; set; }//現減炭
public double All_Carbon { get; set; }//總減炭
public double All_irradiance { get; set; }
public double Now_irradiance { get; set; }
}
public class ChartInput
{

View File

@ -17,10 +17,11 @@ namespace SolarPower.Models
{
{ "0000", "OK" },
{ "0001", "傳入參數錯誤。" },
{ "0002","請先刪除相關逆變器"},
{ "0003","請先刪除相關設備"},
{ "0004","請先移除相關逆變器綁定"},
{ "9985","該電站尚無逆變器資料"},
{ "0002", "請先刪除相關逆變器"},
{ "0003", "請先刪除相關設備"},
{ "0004", "請先移除相關逆變器綁定"},
{ "9984", "連線逾時"},
{ "9985", "該電站尚無逆變器資料"},
{ "9986", "該帳號已被註冊,請重新輸入"},
{ "9987", "查無該運維作業記錄檔案"},
{ "9988", "查無該資料紀錄"},

View File

@ -99,11 +99,11 @@ namespace SolarPower.Models
public string UpdatedAt { get { return Convert.ToDateTime(updatedAt).ToString("yyyy-MM-dd HH:mm:ss"); } set { updatedAt = value; } } //修改時間
private string lastCreateTime;
public string LastCreateTime { get { return Convert.ToDateTime(lastCreateTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { lastCreateTime = value; } }
public string PowerStationName { get; set; }
}
public class OperationPlanTable : OperationCreatePlan
{
public string TypeName { get; set; }
public string PowerStationName { get; set; }
public string Schedule { get; set; }
public string EmailTypeName { get; set; }
public string CreatedPerson { get; set; }

View File

@ -199,7 +199,8 @@ namespace SolarPower.Models
public string errMsg { get; set; }//錯誤原因
public string PowerStationName { get; set; }//電站名稱
public int PowerStationId { get; set; }//電站流水號
public string normalTime { get; set; }
public string normalTime { get; set; }//賦歸時間
public string errMsgT { get; set; } //errMsgType
}
public class UserPowerStationTo

View File

@ -106,6 +106,7 @@ namespace SolarPower.Models
public double Kwh { get; set; }
public double SolarHour { get; set; }
public int Count { get; set; }
public double Kwhkwp { get; set; }
}

View File

@ -8,6 +8,7 @@ using SolarPower.Models.PowerStation;
using SolarPower.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
@ -870,9 +871,17 @@ namespace SolarPower.Quartz.Jobs
#region
var users = userRepository.GetAllAsync();
var ttt = new List<string>() {
"s506488@gmail.com",
"cesarliuc@gmail.com"
};
foreach (var user in users.Result)
{
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始產生使用者[{0}({1})]的日月報】", user.Account, user.Name);
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
if (powerstations.Count == 0)
@ -1032,6 +1041,21 @@ namespace SolarPower.Quartz.Jobs
}
}
logger.LogInformation("【CalcAvgPowerStationJob】【產生完成使用者[{0}({1})]的日月報】", user.Account, user.Name);
}
catch (Exception exception)
{
logger.LogError("【CalcAvgPowerStationJob】【產生失敗使用者[{0}({1})]的日月報】", user.Account, user.Name);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
var line = new StackTrace(exception, true).GetFrame(0).GetFileLineNumber();
logger.LogError("【CalcAvgPowerStationJob】[錯誤行數] - {0}", line);
}
}
#endregion

View File

@ -162,7 +162,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.UpdateInvStatus(update_invStatusErr.Key, null, update_invStatusErr.Select(x => x.InverterId).ToList(), 2);
}
logger.LogError("【CalcInverter15minJob】檢測完成逆變器狀態");
logger.LogInformation("【CalcInverter15minJob】檢測完成逆變器狀態");
}
catch(Exception exception)
{

View File

@ -84,8 +84,6 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【{0}】{1}", "CalcPowerStationJob", ex.Message);
observation = null;
}
#endregion
#region step2. DB及電站編號找出該電站的控制器
@ -103,7 +101,7 @@ namespace SolarPower.Quartz.Jobs
if (string.IsNullOrEmpty(exist))
{
logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_station資料表】", powerStation.Code);
logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_station資料表】");
}
else
{
@ -131,16 +129,34 @@ namespace SolarPower.Quartz.Jobs
#endregion
#region
//發電金額
history.MONEY = history.KWH * powerStation.PowerRate;
history.TODAYMONEY = history.TodayKWh * powerStation.PowerRate;
history.TOTALMONEY = history.TotalKWH * powerStation.PowerRate;
//即時發電金額
switch (powerStation.SolarType)
{
case (int)SolarTypeEnum.SelfSold: //自建躉售
//if (lastmoneyhistorybyhour != null)
//{
// history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
//}
//else
//{
// history.TODAYMONEY = history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = history.KWH * powerStation.PowerRate;
//}
//今日發電金額 計算方式todaykWh * 授電費率
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
history.MONEY = history.KWH * powerStation.PowerRate;
//calcPowerStation.Today_Money = history.TODAYMONEY;
//總發電金額 計算方式totalkWh * 授電費率
////總發電金額 計算方式totalkWh * 授電費率
calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate;
//calcPowerStation.Total_Money = history.TOTALMONEY;
break;
case (int)SolarTypeEnum.HireSold: //租建躉售
//找出該電站的所有土地房屋資訊
@ -154,20 +170,48 @@ namespace SolarPower.Quartz.Jobs
}
//avgLeaseRate = sumLeaseRate / landBuildings.Count();
//今日發電金額計算方式todaykWh * 出借費率(各個土地房屋租借比率平均)
calcPowerStation.Today_Money = history.TodayKWh * sumLeaseRate;
//if (lastmoneyhistorybyhour != null)
//{
// history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
// //今日發電金額計算方式todaykWh * 出借費率(各個土地房屋租借比率平均)
// calcPowerStation.Today_Money = lastmoneyhistorybyhour.TODAYMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate);
// //總發電金額 計算方式totalkWh * 授電費率
// calcPowerStation.Total_Money = lastmoneyhistorybyhour.TOTALMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate);
//}
//else
//{
// history.TODAYMONEY = history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = history.KWH * powerStation.PowerRate;
// calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
// calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate;
//}
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate * sumLeaseRate;
calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate * sumLeaseRate;
history.MONEY = history.KWH * sumLeaseRate;
//總發電金額 計算方式totalkWh * 授電費率
calcPowerStation.Total_Money = history.TotalKWH * sumLeaseRate;
break;
case (int)SolarTypeEnum.SelfUse: //自建自用
//if (lastmoneyhistorybyhour != null)
//{
// history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
//}
//else
//{
// history.TODAYMONEY = history.KWH * powerStation.PowerRate;
// history.TOTALMONEY = history.KWH * powerStation.PowerRate;
//}
//今日發電金額 計算方式todaykWh * 授電費率
//calcPowerStation.Today_Money = history.TODAYMONEY;
calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate;
history.MONEY = history.KWH * powerStation.PowerRate;
//總發電金額 計算方式totalkWh * 授電費率
//calcPowerStation.Total_Money = history.TOTALMONEY;
calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate;
break;
}
@ -186,28 +230,28 @@ namespace SolarPower.Quartz.Jobs
#region
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
history.CARBON = history.KWH * carbonRate;
history.TODAYCARBON = history.TodayKWh * carbonRate;
history.TOTALCARBON = history.TotalKWH * carbonRate;
//if (lastmoneyhistorybyhour != null)
//{
// history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
// history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate;
//}
//else
//{
// history.TODAYCARBON = history.KWH * carbonRate;
// history.TOTALCARBON = history.KWH * carbonRate;
//}
//今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值]
//calcPowerStation.Today_Carbon = history.TODAYCARBON;
calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate;
history.CARBON = history.KWH * carbonRate;
//總減碳量(總發電量 * (0.554/1000)[抓資料庫值]
//calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate;
if (lastmoneyhistorybyhour != null)
{
history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate;
history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate;
history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate;
}
else
{
history.TODAYCARBON = history.KWH * carbonRate;
history.TOTALCARBON = history.KWH * carbonRate;
history.TODAYMONEY = history.KWH * powerStation.PowerRate;
history.TOTALMONEY = history.KWH * powerStation.PowerRate;
}
#endregion
#region
@ -228,7 +272,7 @@ namespace SolarPower.Quartz.Jobs
var sensoravg_table_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, sensoravg_table_name);
if (string.IsNullOrEmpty(sensoravg_table_exist))
{
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_sensoravg資料表】", powerStation.Code);
logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_sensoravg資料表】");
}
else
{
@ -493,7 +537,7 @@ namespace SolarPower.Quartz.Jobs
var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name);
if (string.IsNullOrEmpty(exist_meter_table))
{
logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_meter資料表】", powerStation.Code);
logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_meter資料表】");
}
else
{

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using Quartz;
using SolarPower.Models;
@ -21,38 +22,45 @@ namespace SolarPower.Quartz.Jobs
private readonly INoticeScheduleRepository noticeScheduleRepository;
private readonly IUserRepository userRepository;
private readonly IPowerStationRepository powerStationRepository;
private readonly IConfiguration Configuration;
public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository)
public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository, IConfiguration Configuration)
{
this.logger = logger;
this.overviewRepository = overviewRepository;
this.noticeScheduleRepository = noticeScheduleRepository;
this.userRepository = userRepository;
this.powerStationRepository = powerStationRepository;
this.Configuration = Configuration;
}
public async Task Execute(IJobExecutionContext context)
{
try
{
var ExceptionTimes = this.Configuration.GetValue<int>("ExceptionTimes");
var ExceptionList = await overviewRepository.GetEmailExceptionList();
if(ExceptionList.Count > 0 )
{
var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Hours >= 4).ToList();
var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Minutes >= ExceptionTimes).ToList();
foreach (var Exception in ExceptionListex)
{
var UserListWithPowerstation = await overviewRepository.GetUserListWithPowerstation(Exception.PowerStationId);
foreach (var user in UserListWithPowerstation)
{
var Content = $"電站名稱:{Exception.PowerStationName}" + "<br>" +
$"設備編號:{Exception.errDevice}" + "<br>" +
$"異常ID編號:{Exception.id}" + "<br>" +
$"異常類別:{Exception.alarmClassName}" + "<br>" +
$"設備訊息:{Exception.errMsg}" + "<br>" +
$"發生時間:{Exception.dev_time}" ;
$"設備訊息:{Exception.errMsg}" + "<br>";
if(Exception.errMsgT == "d")
{
Content += $"當前數值:{Exception.errValue}" + "<br>";
}
Content += $"發生時間:{Exception.dev_time}";
foreach (var user in UserListWithPowerstation)
{
NoticeSchedule DaySchedule = new NoticeSchedule()
{
UserId = user.Id,
@ -77,11 +85,14 @@ namespace SolarPower.Quartz.Jobs
};
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
if(powerstation.line_token != null)
{
CallLineToken(Content, powerstation.line_token);
}
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
if (powerstation.line_token != null)
{
Content = " %0D%0A " + Content.Replace("<br>", " %0D%0A ");
CallLineToken(Content, powerstation.line_token);
}
}
}

View File

@ -158,7 +158,7 @@ namespace SolarPower.Quartz.Jobs
{
//Get所有運維人員
var personal = await operationRepository.GetOperationPersonnel(a.PowerStationId);
var Title = $@"編號:{a.PlanId} - {WorkType}單 - 作業紀錄建立通知";
var Title = $@"電站:{a.PowerStationName} - {WorkType}單 - 編號:{a.PlanId}";
var content = $@" {noticeName} {Environment.NewLine} 內容描述:{a.Description}";
await operationRepository.InsertNoticeSchedule(personal, Title, content);

View File

@ -17,6 +17,8 @@ namespace SolarPower.Repository.Implement
tableName = "power_station";
}
public async Task<AnalysisStationCombine> GetPowerStationInfoList(ChartInput post)
{
var a = new AnalysisStationCombine();
@ -32,14 +34,33 @@ namespace SolarPower.Repository.Implement
{
case 0:
string timerange = Convert.ToDateTime(post.Timerange).ToString("yyyy-MM-dd");
sql = $@"SELECT m.*,n.*,o.* FROM
var today = "";
if(timerange == DateTime.Now.ToString("yyyy-MM-dd"))
{
today = @$" SELECT
AVG(a.today_irradiance) AS Now_irradiance
FROM
power_station a
WHERE a.Id IN @ids ";
}
else
{
today = $@" SELECT
AVG(a.Irradiance) AS Now_irradiance
FROM
sensor_history_day a
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP,'%Y-%m-%d') = '{timerange}'";
}
sql = $@"SELECT m.*,n.*,o.*,p.* FROM
(
SELECT
SUM(TOTALMONEY) AS All_money,
SUM(TOTALKWH) AS All_kwh,
SUM(TOTALCARBON) AS All_Carbon
from power_station_history_month
WHERE PowerStationId IN @ids
from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a
LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP
)
AS m,
(
@ -60,22 +81,47 @@ namespace SolarPower.Repository.Implement
(
SELECT
AVG(avg_kwhkwp) AS All_KWH_KWP,
AVG(avg_PR) AS All_PR
AVG(avg_PR) AS All_PR,
AVG(avg_irradiance) as All_irradiance
from power_station
WHERE Id IN @ids
)
AS o";
AS o,
(
{today}
) AS p";
break;
case 1:
var time = post.Timerange.Split('-');
sql = $@"SELECT m.*,n.*,o.* FROM
var ttot = "";
if(time[1].Replace(" ","") == DateTime.Now.ToString("yyyy/MM/dd"))
{
ttot = @$"SELECT
AVG(c.Now_irradiance) AS Now_irradiance
FROM
(SELECT AVG(a.today_irradiance) AS Now_irradiance FROM power_station a WHERE a.Id IN (1)
UNION
SELECT AVG(b.Irradiance) AS Now_irradiance FROM sensor_history_day b
WHERE b.PowerStationId IN (1) AND DATE_FORMAT(b.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{Convert.ToDateTime(time[1].Replace(" ", "")).AddDays(-1).ToString("yyyy/MM/dd")}') c";
}
else
{
ttot = @$" SELECT
AVG(a.Irradiance) AS Now_irradiance
FROM
sensor_history_day a
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{time[1].Replace(" ", "")}'";
}
sql = $@"SELECT m.*,n.*,o.*,p.* FROM
(
SELECT
SUM(TOTALMONEY) AS All_money,
SUM(TOTALKWH) AS All_kwh,
SUM(TOTALCARBON) AS All_Carbon
from power_station_history_month
WHERE PowerStationId IN @ids
from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a
LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP
)
AS m,
(
@ -92,21 +138,25 @@ namespace SolarPower.Repository.Implement
(
SELECT
AVG(avg_kwhkwp) AS All_KWH_KWP,
AVG(avg_PR) AS All_PR
AVG(avg_PR) AS All_PR,
AVG(avg_irradiance) as All_irradiance
from power_station
WHERE Id IN @ids
)
AS o";
AS o,
(
{ttot}
) AS p";
break;
case 2:
sql = $@"SELECT m.*,n.*,o.* FROM
sql = $@"SELECT m.*,n.*,o.*,p.* FROM
(
SELECT
SUM(TOTALMONEY) AS All_money,
SUM(TOTALKWH) AS All_kwh,
SUM(TOTALCARBON) AS All_Carbon
from power_station_history_month
WHERE PowerStationId IN @ids
from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a
LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP
)
AS m,
(
@ -123,21 +173,28 @@ namespace SolarPower.Repository.Implement
(
SELECT
AVG(avg_kwhkwp) AS All_KWH_KWP,
AVG(avg_PR) AS All_PR
AVG(avg_PR) AS All_PR,
AVG(avg_irradiance) as All_irradiance
from power_station
WHERE Id IN @ids
)
AS o";
AS o,
(
SELECT
AVG(a.Irradiance) AS Now_irradiance
from sensor_history_month a
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}'
) AS p";
break;
case 3:
sql = $@"SELECT m.*,n.*,o.* FROM
sql = $@"SELECT m.*,n.*,o.*,p.* FROM
(
SELECT
SUM(TOTALMONEY) AS All_money,
SUM(TOTALKWH) AS All_kwh,
SUM(TOTALCARBON) AS All_Carbon
from power_station_history_month
WHERE PowerStationId IN @ids
from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a
LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP
)
AS m,
(
@ -155,11 +212,18 @@ namespace SolarPower.Repository.Implement
(
SELECT
AVG(avg_kwhkwp) AS All_KWH_KWP,
AVG(avg_PR) AS All_PR
AVG(avg_PR) AS All_PR,
AVG(avg_irradiance) as All_irradiance
from power_station
WHERE Id IN @ids
)
AS o";
AS o,
(
SELECT
AVG(a.Irradiance) AS Now_irradiance
from sensor_history_month a
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}'
) AS p";
break;
}
@ -192,57 +256,51 @@ namespace SolarPower.Repository.Implement
switch (post.SeacrhType)
{
case 0:
sql = $@"SELECT DATE_FORMAT(ps.TIMESTAMP,'%h %p') AS `Time`,
SUM(ps.KWH) AS KWH,
SUM(sh.Irradiance) AS Irradiance,
AVG(sh.Temperature) AS Temperature
FROM power_station_history_hour ps
LEFT JOIN sensor_history_hour sh
ON sh.TIMESTAMP = ps.TIMESTAMP AND sh.PowerStationId = ps.PowerStationId
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}'
GROUP BY ps.TIMESTAMP";
sql = $@"SELECT DATE_FORMAT(p.TIMESTAMP,'%h %p') AS `Time`,
SUM(p.KWH) AS KWH,
SUM(s.Irradiance) AS Irradiance,
AVG(s.Temperature) AS Temperature
FROM (SELECT * FROM power_station_history_hour ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') p
LEFT JOIN (SELECT * FROM sensor_history_hour sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') s
ON p.TIMESTAMP = s.TIMESTAMP AND p.PowerStationId = s.PowerStationId
GROUP BY p.TIMESTAMP";
break;
case 1:
var time = post.Timerange.Replace(" ","").Split('-');
sql = $@"SELECT
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`,
SUM(ps.TODAYKWH) AS KWH,
SUM(sh.Irradiance) AS Irradiance,
AVG(sh.Temperature) AS Temperature
FROM power_station_history_day ps
LEFT JOIN sensor_history_day sh
ON sh.TIMESTAMP = ps.TIMESTAMP
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}'
GROUP BY ps.TIMESTAMP";
DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`,
SUM(p.TODAYKWH) AS KWH,
SUM(s.Irradiance) AS Irradiance,
AVG(s.Temperature) AS Temperature
FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') p
LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') s
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
GROUP BY p.TIMESTAMP";
break;
case 2:
sql = $@"SELECT
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`,
SUM(ps.TODAYKWH) AS KWH,
SUM(sh.Irradiance) AS Irradiance,
AVG(sh.Temperature) AS Temperature
FROM power_station_history_day ps
LEFT JOIN sensor_history_day sh
ON sh.TIMESTAMP = ps.TIMESTAMP
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}'
GROUP BY ps.TIMESTAMP";
DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`,
SUM(p.TODAYKWH) AS KWH,
SUM(s.Irradiance) AS Irradiance,
AVG(s.Temperature) AS Temperature
FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') = '{post.Timerange}') p
LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}') s
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
GROUP BY p.TIMESTAMP";
break;
case 3:
sql = $@"SELECT
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') AS `Time`,
SUM(ps.MONTHKWH) AS KWH,
SUM(sh.Irradiance) AS Irradiance,
AVG(sh.Temperature) AS Temperature
FROM power_station_history_month ps
LEFT JOIN sensor_history_month sh
ON sh.TIMESTAMP = ps.TIMESTAMP
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}'
GROUP BY ps.TIMESTAMP";
DATE_FORMAT(p.TIMESTAMP,'%Y-%m') AS `Time`,
SUM(p.MONTHKWH) AS KWH,
SUM(s.Irradiance) AS Irradiance,
AVG(s.Temperature) AS Temperature
FROM (SELECT * FROM power_station_history_month ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Timerange}') p
LEFT JOIN (SELECT * FROM sensor_history_month sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}') s
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
GROUP BY p.TIMESTAMP";
break;
}
a = (await conn.QueryAsync<Chartoutput>(sql,new { ids = post.StationIds})).ToList();
}
catch (Exception exception)
{

View File

@ -604,7 +604,8 @@ namespace SolarPower.Repository.Implement
{
try
{
var sql = @$"SELECT * FROM operation_plan_create opc
var sql = @$"SELECT opc.*,ps.Name AS PowerStationName FROM operation_plan_create opc
LEFT JOIN power_station ps ON opc.PowerStationId = ps.Id
WHERE opc.Deleted = 0";
result = (await conn.QueryAsync<OperationCreatePlan>(sql)).ToList();
}

View File

@ -605,7 +605,7 @@ namespace SolarPower.Repository.Implement
//range2 = $" DATE_FORMAT(C.TIMESTAMP,'%Y') = '{post.HistoryRange}'";
break;
case 3:
select = "DATE_FORMAT(V.TIMESTAMP,'%Y') AS TIMESTAMP, MAX(KWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, SUM(SOLARHOUR-PSValue) AS DiffSOLARHOUR, AVG(PR) AS PR, AVG(Irradiance) AS Irradiance, AVG(Temp) AS Temp";
select = "DATE_FORMAT(V.TIMESTAMP,'%Y') AS TIMESTAMP, MAX(KWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, SUM(SOLARHOUR-PSValue) AS DiffSOLARHOUR, AVG(PR) AS PR, AVG(Irradiance) AS Irradiance, AVG(Temp) AS Temp ,AVG(KWHKWP) AS KWHKWP ";
kwh = "C.TOTALKWH";
usedb = "power_station_history_month";
pyrdb = "sensor_history_month";
@ -663,7 +663,7 @@ namespace SolarPower.Repository.Implement
select a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,ps.Id as PowerStationId,
errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate,
case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg
case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg ,case when c.errMsg is null then d.errMsg else c.errMsg end errMsgT
from err_main a
join alarmorion_orionalarmclass b on a.alarmclass = b.id
left join ref_err_device c on trim(b.alarmClass) = c.deviceType

View File

@ -4420,6 +4420,7 @@ namespace SolarPower.Repository.Implement
var temp_sql = $@"SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP,
inv.INVERTERID,
i.InverterName AS INVERTERName,
sen.{entity.Sensor} AS Irradiance,
((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW,
((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW,
@ -4466,14 +4467,15 @@ namespace SolarPower.Repository.Implement
inv.RA5
FROM {table_name} inv
LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
AND INVERTERID IN ('{inverterIds}')";
AND inv.INVERTERID IN ('{inverterIds}')";
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay })).ToList();
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay }, commandTimeout: 300)).ToList();
}
catch (Exception exception)
{
@ -4502,7 +4504,8 @@ namespace SolarPower.Repository.Implement
var temp_sql = $@"SELECT
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
INVERTERID,
inv.INVERTERID,
i.InverterName AS INVERTERName,
inv.Irradiance,
inv.KWH,
inv.TODAYKWH,
@ -4513,13 +4516,14 @@ namespace SolarPower.Repository.Implement
inv.RA4,
inv.RA5
FROM inverter_history_day inv
LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId
WHERE inv.PowerStationId = {entity.PowerStationId}
AND inv.INVERTERID IN ('{inverterIds}')
AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay";
sql_perSiteDB.Add(temp_sql);
}
sql = string.Join(" UNION ", sql_perSiteDB);
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDay = startDay, EndDay = endDay })).ToList();
}
@ -4550,7 +4554,8 @@ namespace SolarPower.Repository.Implement
var temp_sql = $@"SELECT
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
INVERTERID,
inv.INVERTERID,
i.InverterName AS INVERTERName,
inv.KWH,
inv.TODAYKWH,
inv.PR,
@ -4560,6 +4565,7 @@ namespace SolarPower.Repository.Implement
inv.RA4,
inv.RA5
FROM inverter_history_month inv
LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId
WHERE inv.PowerStationId = {entity.PowerStationId}
AND inv.INVERTERID IN ('{inverterIds}')
AND DATE_FORMAT(inv.TIMESTAMP, '%Y') = @Year";
@ -5332,7 +5338,7 @@ namespace SolarPower.Repository.Implement
SELECT api.Item, api.ItemName
FROM apicall api
LEFT join
(SELECT * FROM {dbname}.power_station_exception ex WHERE ex.Deleted = 0) a
(SELECT * FROM {dbname}.power_station_exception ex WHERE ex.Deleted = 0 AND ex.PowerStationId = {powerStationId}) a
ON a.`Type` = api.Item
WHERE api.PowerStationId = {powerStationId}
AND ISNULL(a.Id)

View File

@ -243,7 +243,7 @@ namespace SolarPower.Repository.Implement
break;
}
a = await conn.QueryAsync<dynamic>(sql);
a = await conn.QueryAsync<dynamic>(sql, commandTimeout: 300);
}
catch (Exception exception)
{
@ -257,6 +257,52 @@ namespace SolarPower.Repository.Implement
}
}
public async Task<int> CheckExcelAsync(Select_table post)
{
using (IDbConnection conn = _databaseHelper.GetConnection())
{
int a;
conn.Open();
try
{
string sql = "";
switch ( post.FormType )
{
case 0:
sql = @$"select Id from power_station_history_day where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{post.Time}'";
break;
case 1:
if(post.SearchType == 2)
{
sql = @$"select Id from power_station_history_month where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}'";
}
else
{
var times = post.Time.Replace('-', 'a').Replace('/', '-').Replace(" ", "").Split('a');
sql = @$"select Id from power_station_history_day where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}'";
}
break;
case 3:
sql = @$"select Id from power_station_history_month where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}'";
break;
}
a = await conn.QueryFirstOrDefaultAsync<int>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return a;
}
}
public async Task<List<Landinfo>> GetHire (PsIdAndSiteDB post)
{
List<Landinfo> result = new List<Landinfo>();

View File

@ -437,7 +437,7 @@ namespace SolarPower.Repository.Implement
END AS EscrowName
FROM power_station ps
LEFT JOIN company c ON ps.CompanyId = c.Id
WHERE ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0)";
WHERE ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0) AND ps.Deleted = 0 ";
if (!isPlatformLayer)
{

View File

@ -13,5 +13,6 @@ namespace SolarPower.Repository.Interface
Task<List<Landinfo>> GetHire(PsIdAndSiteDB post);
Task<List<MaxFormbody>> GetMaxtablebody(Select_table2 post);
Task<dynamic> Findhaveinv(Select_table post);
Task<int> CheckExcelAsync(Select_table post);
}
}

View File

@ -111,22 +111,25 @@
</div>
</div>
}
else
{
<div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>有效日照時數</h4>
<div class="ml-auto">hr</div>
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span> 日照度</h4>
<div class="ml-auto">k W/m<sup>2</sup></div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p id="today_kwhkwp_label">當日有效日照時數 </p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
<p id="today_irradiance_label">當日日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwhkwp">0.00</span></p>
<p>平均日照度(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_irradiance">0.00</span></p>
</div>
</div>
</div>
}
<div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
<h4 class="mb-0 font-weight-bold"><span class="fal fa-bolt mr-1"></span> PR值</h4>
@ -143,7 +146,22 @@
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
<h4 class="mb-0 font-weight-bold"><span class="fal fa-sun mr-1"></span>有效日照時數</h4>
<div class="ml-auto">hr</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p id="today_kwhkwp_label">當日有效日照時數 </p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
<p>平均有效日照時數(30天)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="total_kwhkwp">0.00</span></p>
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-fusion-25 pr-3 d-flex align-items-center flex-wrap">
<h4 class="mb-0 font-weight-bold"><span class="fal fa-cow mr-1"></span> 減碳量</h4>
@ -310,7 +328,7 @@
$("#today_kwhkwp_label").html(timename + "有效日照時數");
$("#today_PR_label").html(timename + "PR值");
$("#today_carbon_label").html(timename + "減碳量");
$("#today_irradiance_label").html(timename + "日照度");
if (type == 1) {
timerange = $('#DateGettext').val();
@ -412,7 +430,7 @@
$('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2));
$('#total_PR').html(rel.data.all_PR.toFixed(2));
$('#total_carbon').html(rel.data.all_Carbon.toFixed(2));
$('#total_irradiance').html(rel.data.all_Carbon.toFixed(2));
$('#total_irradiance').html(rel.data.all_irradiance.toFixed(2));
$('#today_kwh').html(rel.data.now_kwh.toFixed(2));
@ -420,7 +438,7 @@
$('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2));
$('#today_PR').html(rel.data.now_PR.toFixed(2));
$('#today_carbon').html(rel.data.now_Carbon.toFixed(2));
$('#today_irradiance').html(rel.data.now_Carbon.toFixed(2));
$('#today_irradiance').html(rel.data.now_irradiance.toFixed(2));
chart();
})

View File

@ -124,10 +124,10 @@
var PWS_compare_col = [
{ key: "KWH", title: "發電量", default: true },
{ key: "Irradiance", title: "日照度", default: false },
{ key: "KWHKWP", title: "發電小時", default: false },
{ key: "KWHKWP", title: "有效日照時數", default: false },
{ key: "PR", title: "PR %", default: false },
{ key: "Temperature", title: "模組溫度", default: false },
{ key: "SolarHour", title: "日照小時", default: false }
{ key: "SolarHour", title: "日照小時", default: false },
]
var PWR_compare_col = [
{ key: "OUTPUT_KWH", title: "輸出發電量(kWh)", default: true },

View File

@ -250,6 +250,9 @@
'render': function (data, type, full, meta) {
return '<img src="' + data + '?v=' + Date.now() + '" width="200px" height="40px">';
}
},{
'targets': 8,
'visible': false
}],
"language": {
"emptyTable": "查無資料",

View File

@ -1,7 +1,7 @@
@{
ViewData["MainNum"] = "5";
ViewData["SubNum"] = "1";
ViewData["Title"] = "異常記錄查詢";
ViewData["Title"] = "即時告警管理";
}
@using SolarPower.Models.Role
@model RoleLayerEnum

View File

@ -36,7 +36,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p>即時日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -52,7 +52,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p>今日 PR 值</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -68,7 +68,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p>
<p>今日有效日照時數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -278,10 +278,10 @@
'<div id="bodyContent">' +
'<div class="row">' +
'<div class="col-12">' +
'<div>即時總發電量:' + item.today_kWh + '</div>'+
'<div>即時平均日照度:' + item.today_irradiance + '</div>'+
'<div>發電小時:' + item.solarHour + '</div>' +
'<div>裝置容量:' + item.generatingCapacity.toFixed(3) + '</div>' +
'<div>今日發電量(kW h)' + item.today_kWh.toFixed(2) + '</div>'+
'<div>即時日照度(k W/m<sup>2</sup>)' + item.today_irradiance + '</div>'+
'<div>有效日照時數(kwh/kwp)' + item.today_kwhkwp.toFixed(2) + '</div>' +
'<div>裝置容量(kWp)' + item.generatingCapacity.toFixed(3) + '</div>' +
'<div>掛錶日期:' + item.electricityMeterAt + '</div>' +
'<div>天氣:' + item.wx + '</div>'+
'</div>' +

View File

@ -148,15 +148,16 @@
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="power_station_select_modal">電站</label>
<label class="form-label" for="power_station_select_modal"><span class="text-danger">*</span>電站</label>
<select class="form-control" id="power_station_select_modal">
</select>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="work_time_modal">作業日期</label>
<label class="form-label" for="work_time_modal"><span class="text-danger">*</span>作業日期</label>
<input class="form-control" id="work_time_modal" type="date" name="work_time_modal" />
<label id="work_time_modal-error" class="" style="z-index:1;color:red;display:none">此為必填欄位</label>
</div>
</div>
</div>
@ -164,7 +165,7 @@
<div class="row mb-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="example-select">狀態</label>
<label class="form-label" for="example-select"><span class="text-danger">*</span>狀態</label>
<div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input ml-auto" id="status_none_complete" name="status_modal" value="0" />
@ -179,9 +180,10 @@
</div>
<div class="col-lg-6">
<div class="">
<label class="form-label" for="work_person_select_modal">執行人員</label>
<label class="form-label" for="work_person_select_modal"><span class="text-danger">*</span>執行人員</label>
<select class="form-control" id="work_person_select_modal" multiple="multiple">
</select>
<label id="work_person_select_modal-error" class="" style="z-index:1;color:red;display:none">此為必填欄位</label>
</div>
</div>
</div>
@ -291,6 +293,7 @@
$(function () {
//#region Date-Picker
datepicker = $('#date-range').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
@ -597,6 +600,20 @@
//#endregion
});
$('#work_person_select_modal').change(function () {
if ($('#work_person_select_modal').val().length == 0) {
$('#work_person_select_modal-error').show();
} else {
$('#work_person_select_modal-error').hide();
}
});
$('#work_time_modal').change(function () {
$("#work_time_modal-error").hide();
});
function getPowerStationCheckBox() {
var send_data = {
cityIds: ids
@ -675,15 +692,19 @@
//#region 新增維修單
function AddRecord() {
selected_id = 0;
selected_work_type = 2;
record = undefined;
$("#record-form-modal .modal-title .main-title").html("維修單");
$("#record-form-modal .modal-title .sub-title").html("");
$("#power_station_select_modal").attr("disabled", false);
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
$(".fix-div").show();
$("#record-form").trigger("reset");
$("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態
$("#record_files_div > .row").empty();
$('#work_person_select_modal-error').hide();
$("#work_time_modal-error").hide();
@ -994,6 +1015,8 @@
}
$("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態
$('#work_person_select_modal').val(record.workPersonIds).trigger("change");
selected_work_type = work_type;
if (work_type != 2) {
$(".fix-div").hide();
} else {
@ -1024,7 +1047,7 @@
//#region 表單驗證
$("#record-form").validate({
rules: {
work_person_select_modal: {
work_time_modal: {
required: true
}
},
@ -1033,6 +1056,7 @@
//#region 儲存表單資料
function SaveRecord() {
if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "") {
Swal.fire(
{
title: "儲存",
@ -1121,12 +1145,19 @@
}
}
});
}
else
{
if ($('#work_person_select_modal').val().length == 0)
{
$('#work_person_select_modal-error').show();
}
if ($("#work_time_modal").val() == "")
{
$("#work_time_modal-error").show();
}
}
}
//#endregion

View File

@ -1,5 +1,5 @@
@{
ViewData["MainNum"] = "6";
ViewData["MainNum"] = "8";
ViewData["SubNum"] = "1";
ViewData["Title"] = "電站管理";
}
@ -135,7 +135,6 @@
<table id="solarTable" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
<tr>
<th>編號</th>
<th>電站名稱</th>
<th>裝置容量(kWp)</th>
<th>逆變器數量</th>
@ -353,8 +352,7 @@
}
$('#solarTable' + val.cityId).find('tbody').append('<tr data-id="' + val.id + '" datacity-id="' + val.cityId + '"">' +
'<td>' + val.id + '</td>' +
'<td>' + val.name + '</td>' +
'<td><a href="' + localurl + '/edit?stationId=' + val.id +'">' + val.name + '</td>' +
'<td>' + val.generatingCapacity.toFixed(3) + '</td>' +
'<td>' + val.inverterAmount + '</td>' +

View File

@ -1,5 +1,5 @@
@{
ViewData["MainNum"] = "6";
ViewData["MainNum"] = "8";
ViewData["SubNum"] = "1";
ViewData["Title"] = "電站管理";
}

View File

@ -151,7 +151,7 @@
<div class="col-xl-3 row justify-content-center align-items-center">
<label class="col-xl-4 form-label" id="coordinate_label" for="coordinate">Line Token</label>
<div class="col-xl-8">
<label id="line_token_text" class="color-info-600"></label>
<label id="line_token_text" class="color-info-600" style="word-break: break-all"></label>
<input type="text" id="line_token" name="line_token" class="form-control">
</div>
</div>

View File

@ -348,8 +348,23 @@
</ul>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation") || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord"))
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationManager"))
{
<li class="@(ViewData["MainNum"] == "8" ? "active open" : "")">
<a href="#" title="電站管理" data-filter-tags="category">
<i class="fal fa-cogs"></i>
<span class="nav-link-text" data-i18n="nav.category">電站管理</span>
</a>
<ul>
<li class="@(ViewData["MainNum"] == "8" && ViewData["SubNum"].ToString() == "1" ? "active" : "")">
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
</a>
</li>
</ul>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord"))
{
<li class="@(ViewData["MainNum"] == "6" ? "active open" : "")">
<a href="#" title="運維管理" data-filter-tags="category">
@ -357,14 +372,7 @@
<span class="nav-link-text" data-i18n="nav.category">運維管理</span>
</a>
<ul>
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation"))
{
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"].ToString() == "1" ? "active" : "")">
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
</a>
</li>
}
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation"))
{
<li class="@(ViewData["MainNum"] == "6" && ViewData["SubNum"] == "2" ? "active" : "")">

View File

@ -94,7 +94,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p>即時日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -110,7 +110,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p>今日 PR 值</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -126,7 +126,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p>
<p>今日有效日照時數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -425,13 +425,14 @@
$('#card_' + val.id).find('#stationtype').html(type);
var time = new Date(val.createdAt);
$('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id);
$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
@*$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@
$('#card_' + val.id).find('#date').html(val.electricityMeterAt);
$('#card_' + val.id).find('#today_kwh').html(val.today_kWh.toFixed(2));
$('#card_' + val.id).find('#Capacity').html(val.generatingCapacity.toFixed(3));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<text>
$('#card_' + val.id).find('#PowerRate').html((val.today_kWh * val.powerRate).toFixed());
$('#card_' + val.id).find('#PowerRate').html((val.today_Money).toFixed());
</text>
}
$('#card_' + val.id).find('#PR').html(val.today_PR);

View File

@ -1,11 +1,10 @@
@{
ViewData["MainNum"] = "1";
ViewData["SubNum"] = "2";
ViewData["MainNum"] = "2";
//ViewData["SubNum"] = "2";
ViewData["Title"] = "電站總覽";
}
@using SolarPower.Models.Role
@model RoleLayerEnum
@*<ol class="breadcrumb page-breadcrumb" >
<li class="breadcrumb-item"><a href="javascript:void(0);">總覽</a></li>
<li class="breadcrumb-item">@ViewData["Title"]</li>
@ -20,15 +19,15 @@
<div class="panel-container show">
<div class="panel-content">
<div class="row subheader d-flex justify-content-between">
<div class="col-xl-2">
<div class="col-xl-4">
<h1 class="subheader-title">
<span id="power-station-healthStatus"></span>
<span id="power-station-title">新竹巨城站</span>
<span id="power-station-title">電站名稱</span>
</h1>
</div>
<div class="col-xl-3 d-flex justify-content-start">
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x" id="weather-icon"></i></p>
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨幾率: 15%</p>
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨幾率: 0%</p>
</div>
</div>
<ul class="nav nav-tabs mb-5" role="tablist">
@ -1186,7 +1185,7 @@
//#region 產生檔案html
function CreateRecordFileBox(dom, value, show_del_btn) {
var str = "";
str += '<div class="col-auto px-0 py-2 mx-2">';
str += '<div class="col-2 px-0 py-2 mx-2">';
var split = value.fileName.split(".");
var excel_format = ["xls", "xlsx"];
var word_format = ["doc", "docx"];
@ -2184,8 +2183,16 @@
legend: {
display: true,
position: 'bottom'
},
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: '發電量(kWh)'
}
}]
}
},
});
//#endregion
@ -2390,6 +2397,12 @@
var listpr = new Array(0);
var color = rgba(1);
var color2 = rgba(2);
var listkwhkwp = new Array(0);
var times = 1;
var ALLkwhkwp = 0;
var kwhkwp = 0;
$.each(rel.data, function (index, val) {
TimestampALL = val.totaltime;
kwhALL += val.kwh;
@ -2398,49 +2411,68 @@
prALL = val.pr;
tempALL += val.temp;
//暫時先執行到這--->取kwhkwp
if (val.length != 0) {
if (groupType != 6) {
if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) {
kwhkwp = val.kwhkwp.toFixed(2);
}
if (groupType != 0) {
ALLkwhkwp += val.kwhkwp;
kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++;
}
diffSOLARHOURALL = val.solarhour;
$('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' +
'<td>' + val.kwh.toFixed(2) + '</td>' +
'<td>' + val.solarhour.toFixed(2) + '</td>' +
'<td>' + val.kwhkwp.toFixed(2) + '</td>' +
'<td>' + val.irradiance.toFixed(2) + '</td>' +
'<td>' + val.pr.toFixed(2) + '</td>' +
'<td>' + val.temp.toFixed(2) + '</td>' +
'</tr>');
listmonth.push(val.timestamp);
listkwh.push(val.kwh.toFixed(2));
listkwh.push(parseFloat(val.kwh.toFixed(2)));
listcolor.push(color);
listcolor2.push(color2);
listirradiance.push(val.irradiance.toFixed(2));
listtemperature.push(val.temp.toFixed(2));
listsolarhour.push(val.solarhour.toFixed(2));
listpr.push(val.pr.toFixed(2));
listirradiance.push(parseFloat(val.irradiance.toFixed(2)));
listtemperature.push(parseFloat(val.temp.toFixed(2)));
listsolarhour.push(parseFloat(val.solarhour.toFixed(2)));
listpr.push(parseFloat(val.pr.toFixed(2)));
listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2)));
}
else
{
if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) {
kwhkwp = val.kwhkwp.toFixed(2);
}
if (groupType != 0) {
ALLkwhkwp += val.kwhkwp;
kwhkwp = (ALLkwhkwp / times).toFixed(2);
times++;
}
diffSOLARHOURALL += val.diffSOLARHOUR;
$('#HistoryDetailTable').append('<tr>' +
'<td>' + val.timestamp + '</td>' +
'<td>' + val.kwh.toFixed(2) + '</td>' +
'<td>' + val.diffSOLARHOUR.toFixed(2) + '</td>' +
'<td>' + val.kwhkwp.toFixed(2) + '</td>' +
'<td>' + val.irradiance.toFixed(2) + '</td>' +
'<td>' + val.pr.toFixed(2) + '</td>' +
'<td>' + val.temp.toFixed(2) + '</td>' +
'</tr>');
listmonth.push(val.timestamp);
listkwh.push(val.kwh.toFixed(2));
listkwh.push(parseFloat(val.kwh.toFixed(2)));
listcolor.push(color);
listcolor2.push(color2);
listirradiance.push(val.irradiance.toFixed(2));
listtemperature.push(val.temp.toFixed(2));
listsolarhour.push(val.solarhour.toFixed(2));
listpr.push(val.pr.toFixed(2));
listirradiance.push(parseFloat(val.irradiance.toFixed(2)));
listtemperature.push(parseFloat(val.temp.toFixed(2)));
listsolarhour.push(parseFloat(val.solarhour.toFixed(2)));
listpr.push(parseFloat(val.pr.toFixed(2)));
listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2)));
}
@ -2451,7 +2483,105 @@
tempALL = tempALL / rel.data.length;
$('#history-kWh-convas-div').empty();
$('#history-kWh-convas-div').append('<figure class="highcharts-figure"><div id="history-kWh" ></div></figure>');
chart = new Highcharts.Chart({
lang: { //匯出相關中文名稱配置
printChart: '列印圖表',
downloadJPEG: '下載JPEG檔案',
downloadPDF: '下載PDF檔案',
downloadPNG: '下載PNG檔案',
downloadSVG: '下載SVG檔案',
downloadCSV: '下載CSV檔案',
downloadXLS: '下載XLS檔案',
viewData: '檢視資料表格',
viewFullscreen: '全屏檢視'
},
chart: {
renderTo: 'history-kWh',
height: 600,
animation: false
},
title: {
text: '發電量及日照度'
},
xAxis: {
categories: listmonth,
},
yAxis: [{
title: {
text: "kWh"
},
id: "A",
opposite: false,
showEmpty: false
}, {
title: {
text: "kWh/㎡"
},
id: "B",
opposite: true,
showEmpty: false
}, {
title: {
text: "hr"
},
id: "C",
opposite: true,
showEmpty: false
}, {
title: {
text: "PR(%)"
},
id: "D",
opposite: true,
showEmpty: false
}, {
title: {
text: "溫度(℃)"
},
id: "E",
opposite: true,
showEmpty: false
}],
series: [{
type: 'spline',
name: "溫度(℃)",
data: listtemperature,
yAxis: "E",
color: "rgb(255, 192, 0)",
zIndex: 4
}, {
type: 'spline',
name: "日照度(kWh/㎡)",
data: listirradiance,
yAxis: "B",
color: "rgb(190, 45, 45)",
zIndex: 3
}, {
type: 'column',
name: "PR(%)",
data: listpr,
yAxis: "D",
color: 'rgb(68, 114, 196)'
}, {
type: 'column',
name: "有效日照時數",
data: listkwhkwp,
yAxis: "C",
color: "rgb(165, 165, 165)"
}, {
type: 'column',
name: "發電量(kWh)",
data: listkwh,
yAxis: "A",
color: "rgb(103, 180, 172)"
}],
});
@*$('#history-kWh-convas-div').empty();
$('#history-kWh-convas-div').append('<canvas id="history-kWh"></canvas>');
var ctx_history_kWh = document.getElementById('history-kWh').getContext('2d');
var myhistorykwh = new Chart(ctx_history_kWh, {
@ -2494,11 +2624,11 @@
data: listpr
},{
type: 'bar',
label: '發電小時',
label: '有效日照時數',
yAxisID: 'C',
backgroundColor: 'rgba(165, 165, 165)',
borderWidth: 1,
data: listsolarhour
data: listkwhkwp
},{
type: 'bar',
backgroundColor: 'rgba(103, 180, 172, 1)',
@ -2576,7 +2706,7 @@
}]
}
}
});
});*@
@ -2589,7 +2719,7 @@
$('#HistoryTotalTable').append('<tr>' +
'<td>' + TimestampALL + '</td>' +
'<td>' + kwhALL.toFixed(2) + '</td>' +
'<td>' + diffSOLARHOURALL.toFixed(2) + '</td>' +
'<td>' + kwhkwp + '</td>' +
'<td>' + irradianceALL.toFixed(2) + '</td>' +
'<td>' + prALL.toFixed(2) + '</td>' +
'<td>' + tempALL.toFixed(2) + '</td>' +
@ -2614,9 +2744,15 @@
return;
}
$("#Invertercard-Name").html(rel.data.name);
$("#Invertercard-kwh").html(rel.data.kwh);
$("#Invertercard-kwh").html(rel.data.kwh.toFixed(2));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<text>
$("#Invertercard-money").html(rel.data.today_Money.toFixed());
$("#Invertercard-pr").html(rel.data.today_PR);
</text>
}
$("#Invertercard-Capacity").html(rel.data.generatingCapacity.toFixed(3));
$("#Invertercard-pr").html(rel.data.today_PR.toFixed(2));
var str = "<div class='progress progress-sm ' id='prbar'>" +
"<div class='progress-bar bg-info' role = 'progressbar' style = 'width: " + rel.data.today_PR + "%;' aria - valuenow='" + rel.data.today_PR + "' aria - valuemin='0' aria - valuemax='100' ></div > </div >"
$('#prbar').remove();
@ -2634,9 +2770,9 @@
break;
}
$("#Invertercard-type").html(TypeName);
var time = new Date(rel.data.createdAt);
$("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());
@*var time = new Date(rel.data.createdAt);
$("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@
$("#Invertercard-date").html(rel.data.electricityMeterAt);
var urlPath = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay;
var xmlhttp;

View File

@ -60,7 +60,7 @@
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>發電小時</th>
<th>有效日照時數</th>
<th>日照度(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
@ -84,7 +84,7 @@
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>發電小時</th>
<th>有效日照時數</th>
<th>日照度(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>

View File

@ -6,25 +6,43 @@
<div class="card border m-auto m-lg-0" id="Invertercard">
<div> <img src="img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="..."> </div>
<div class="card-body d-flex justify-content-between pb-0 px-2">
<h4 class="font-weight-bold" style="line-height: 27px;" id="Invertercard-Name"> <a href="javascript:void(0);" class="btn btn-success btn-sm btn-icon rounded-circle waves-effect waves-themed"> <i class="fal fa-check"></i> </a> 新竹巨城站</h4>
<p class="card-text"><i class="fal fa-cloud-sun-rain fa-2x" id="Invertercard-weathericon"></i></p>
<h4 class="font-weight-bold" style="line-height: 27px;" id="Invertercard-Name">新竹巨城站</h4>
<div class="d-flex">
<p id="Temp" class="mr-2">27°C</p><i class="fal fa-cloud-sun-rain fa-2x" id="weathericon"></i>
</div>
</div>
<div class="list-group list-group-flush">
<div class="list-group-item px-2">
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>發電量</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-kwh">185</span> kWh</p>
<p id="Invertercard-Temp">27°C</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-kwh">0.00</span> kWh</p>
</div>
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{
<div class="d-flex justify-content-end" style="width:40%">
@*<p>發電金額</p>*@
<p><span class="color-info-700 font-weight-bold" id="Invertercard-money">0</span> NT</p>
</div>
}
</div>
<div class=" d-flex justify-content-between">
<p>發電金額</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-money">2,5840</span> NT</p>
<p class="color-info-700 font-weight-bold" id="Invertercard-type">自建躉售</p>
<div class="d-flex justify-content-between" style="width:60%">
<p>裝置容量</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-Capacity">0.00</span> kWp</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p><span class="color-info-700 font-weight-bold" id="Invertercard-type">自建躉售</span></p>
</div>
</div>
<div class=" d-flex justify-content-between">
<div class="d-flex justify-content-between" style="width:60%">
<p>PR值</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-pr">90</span> %</p>
<p class="small" id="Invertercard-date">17:50:36</p>
<p><span class="color-info-700 font-weight-bold" id="Invertercard-pr">0</span> %</p>
</div>
<div class="d-flex justify-content-end" style="width:40%">
<p class="small" id="Invertercard-date">06-30 17:50</p>
</div>
</div>
</div>
</div>
@ -32,7 +50,6 @@
</div>
</div>
<ul id="ullist">
</ul>
</li>
</ul>

View File

@ -39,7 +39,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均日照度</p>
<p>即時日照度</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_irradiance">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -55,7 +55,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均 PR 值</p>
<p>今日 PR 值</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_PR">0.00</span></p>
</div>
<div class="d-flex justify-content-between">
@ -71,7 +71,7 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<p>即時平均有效日照時數</p>
<p>今日有效日照時數(kwh/kwp)</p>
<p><span class="color-info-700 fs-xl font-weight-bold" id="today_kwhkwp">0.00</span></p>
</div>
<div class="d-flex justify-content-between">

View File

@ -266,7 +266,7 @@
<tr>
<th>縣市</th>
<th>平均發電量(kWp)</th>
<th>發電時間(小時)</th>
<th>有效發電小時</th>
</tr>
</thead>
<tbody id="maxtableBody">
@ -303,7 +303,7 @@
var haveinvertName = [];
var nowform;
var xxx;
var button;
$(function () {
//#region 預設初始值
$('#collapse').trigger("click");
@ -533,7 +533,7 @@
}
$(e).removeClass("btn-outline-success").addClass("btn-success");
if (nowform != null && nowform != 2) {
Dateform(nowform);
Dateform(nowform, button);
}
}
//#endregion
@ -783,7 +783,7 @@
str += "<th>日<br />發電量<br />(kWh)</th>";
str += "<th>日<br />發電量<br />百分比<br />(%)</th>";
str += "<th>日照小時(hr)</th>";
str += "<th>kWH/kWP</th>";
str += "<th>有效發電小時</th>";
str += "<th>PR%</th>";
str += "<th>日<br />平均<br />日照度<br />(W/㎡)</th>";
str += "<th>日<br />平均<br />模組溫度<br />(°C)</th>";
@ -795,7 +795,7 @@
str += "<th>區域</th>";
str += "<th>電站名稱</th>";
str += "<th>發電量</th>";
str += "<th>發電小時</th>";
str += "<th>有效發電小時</th>";
str += "<th>平均日照</th>";
str += "<th>PR</th>";
if (rel.data.showMoney == 1) {
@ -813,7 +813,7 @@
str += "<th>月<br />發電量<br />(kWh)</th>";
str += "<th>月<br />發電量<br />百分比<br />(%)</th>";
str += "<th>日照小時(hr)</th>";
str += "<th>kWH/kWP</th>";
str += "<th>有效發電小時</th>";
str += "<th>PR%</th>";
str += "<th>月<br />平均<br />日照度<br />(W/㎡)</th>";
str += "<th>月<br />平均<br />模組溫度<br />(°C)</th>";
@ -838,7 +838,7 @@
$(".btn-report").removeClass("btn-success").addClass("btn-primary");
}
$(e).removeClass("btn-primary").addClass("btn-success");
button = e;
$('#hiretable').hide();
@ -897,11 +897,12 @@
}
$('#TableBody').empty();
$('#totbody').empty();
haveinvertName = [];
return;
}
var sta = "";
$('#TableBody').empty();
//var sta = "";
$('#totbody').empty();
$('#tothead').empty();
if (form == 0) {//日報表
@ -911,7 +912,7 @@
var kWhkwp = 0;
var ntd = 0;
var ntdone = 0;
var sta = "";
$.each(rel.data, function (index, inverter) {
sta += "<tr>";
sta += "<td>" + inverter.report_date + "</td>";
@ -939,7 +940,7 @@
})
var stc = "<tr>";
stc += "<th>" + '日照小時' + "</th>";
stc += "<th>" + 'kWH/kWP' + "</th>";
stc += "<th>" + '有效發電小時' + "</th>";
stc += "<th>" + 'PR%' + "</th>";
stc += "<th>" + '日發電量(kWh)' + "</th>";
if (showmoney == 1) {
@ -961,6 +962,7 @@
stb += "</tr>";
$('#TableBody').empty();
$('#TableBody').append(sta);
$('#totbody').append(stb);
$('#tothead').append(stc);
@ -974,7 +976,7 @@
var monthmoney = 0;
var monthmoneyone = 0;
var monthday = 0;
var sta = "";
var check_hire = false;
var sitedb = "";
$.each(rel.data, function (index, inverter) {
@ -988,10 +990,10 @@
}
});
sta += "<td>" + inverter.dayKWH + "</td>";
sta += "<td>" + inverter.dayKWHp + "</td>";
sta += "<td>" + ((inverter.dayKWHp == null) ? 0 : inverter.dayKWHp) + "</td>";
sta += "<td>" + inverter.tothour + "</td>";
sta += "<td>" + inverter.KWHKWP + "</td>";
sta += "<td>" + inverter.PR.toFixed(2) + "</td>";
sta += "<td>" + ((inverter.PR == null) ? 0 : inverter.PR.toFixed(2)) + "</td>";
sta += "<td>" + inverter.irradiance + "</td>";
sta += "<td>" + inverter.temperature + "</td>";
if (showmoney == 1) {
@ -1016,7 +1018,7 @@
var stc = "<tr>";
stc += "<th>" + '日照平均(日)' + "</th>";
stc += "<th>" + 'kWH/kWP(日)' + "</th>";
stc += "<th>" + '有效發電小時(日)' + "</th>";
stc += "<th>" + '發電量平均(kWh)(日)' + "</th>";
stc += "<th>" + '發電量(kWh)(月)' + "</th>";
if (showmoney == 1) {
@ -1078,7 +1080,7 @@
})
}
$('#TableBody').empty();
$('#TableBody').append(sta);
$('#totbody').append(stb);
$('#tothead').append(stc);
@ -1094,7 +1096,7 @@
var monthmoney = 0;
var monthmoneyone = 0;
var monthday = 0;
var sta = "";
var check_hire = false;
var sitedb = "";
$.each(rel.data, function (index, inverter) {
@ -1136,7 +1138,7 @@
var stc = "<tr>";
stc += "<th>" + '日照平均(月)' + "</th>";
stc += "<th>" + 'kWH/kWP(月)' + "</th>";
stc += "<th>" + '有效發電小時(月)' + "</th>";
stc += "<th>" + '發電量平均(kWh)(月)' + "</th>";
stc += "<th>" + '發電量(kWh)(年)' + "</th>";
if (showmoney == 1) {
@ -1198,7 +1200,7 @@
})
}
$('#TableBody').empty();
$('#TableBody').append(sta);
$('#totbody').append(stb);
$('#tothead').append(stc);
@ -1223,7 +1225,25 @@
PowerStation: selecterd_invert
}
if (send_data.FormType != null && send_data.PowerStation.length != 0 && send_data.FormType != 2) {
$.post("/StationReport/CheckExcel", send_data, function (rel) {
if (rel.code == "0000") {
window.location = "/StationReport/ExportExcel?post=" + JSON.stringify(send_data);
return;
}
else
{
var text = "原因如下:<br\>";
$.each(rel.data, function (index, val) {
text += index + 1 + "." + val + "<br\>";
});
Swal.fire(
{
title: "Excel匯出失敗",
icon: 'warning',
html: text,
});
}
}, 'json');
}
else
{
@ -1295,6 +1315,7 @@
city: data.cityName,
kwp: data.kwh,
hour: data.solarHour,
kwhkwp: data.avgKWHKWP,
count : 1
}
if (CityArray.length == 0) {
@ -1308,6 +1329,7 @@
n.kwp += cityinfo.kwp;
n.hour += cityinfo.hour;
n.count += cityinfo.count;
n.kwhkwp += cityinfo.kwhkwp
npush = false;
}
});
@ -1321,7 +1343,7 @@
StrInfoBody += "<td>" + data.cityName + data.areaName + "</td>";
StrInfoBody += "<td>" + data.powerstationName + "</td>";
StrInfoBody += "<td>" + data.kwh.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.solarHour.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgKWHKWP.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgIrradiance.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgPR.toFixed(2) + "</td>";
if (showmoney == 1) {
@ -1344,7 +1366,7 @@
CityInfoBody += "<tr>";
CityInfoBody += "<td>" + data.city + "</td>";
CityInfoBody += "<td>" + (data.kwp / data.count).toFixed(2) + "</td>";
CityInfoBody += "<td>" + (data.hour / data.count).toFixed(2) + "</td>";
CityInfoBody += "<td>" + (data.kwhkwp / data.count).toFixed(2) + "</td>";
CityInfoBody += "</tr>";
})
//上面

View File

@ -37,7 +37,9 @@
"UserName": "shanghohui@gmail.com",
"Password": "wswgnluvoodfexrb",
"EnableSsl": true
}
},
"ExceptionTimes": 240 //()
//"SMTPConfig": {
// "Host": "smtp.gmail.com",
// "Port": 25,

View File

@ -38,5 +38,6 @@
"UserName": "ficgreen01@gmail.com",
"Password": "qwe2015qwe",
"EnableSsl": true
}
},
"ExceptionTimes": 240 //()
}

View File

@ -129,7 +129,7 @@ namespace solarApp.Service
string sql = @" select id as PowerStationID from solar_master.power_station where `code` = @siteID";
var ds = conn.Query<string>(sql, new { siteID = _siteID }).AsList<string>();
_powerStationID = (ds.Count > 0) ? ds[0][0].ToString() : "0";
_powerStationID = (ds.Count > 0) ? ds[0].ToString() : "0";
#region hour -- solar_type 0 1 2 ------------ 1
@ -158,21 +158,21 @@ namespace solarApp.Service
select b.id PowerStationId, concat(FROM_UNIXTIME(`TIMESTAMP`/1000, '%Y-%m-%d %H'), ':00:00') reportdate, a.siteid, a.siteType,
a.KWH, TODAYKWH, TOTALKWH, KWHKWP , PR, MP, a.SOLARHOUR ,
CASE
WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate
/* CASE
WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate
ELSE a.KWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate
WHEN b.SolarType = 1 THEN a.TODAYKWH * PowerRate * c.LeaseRate
ELSE a.TODAYKWH * PowerRate
END TODAYMONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (a.KWH * PowerRate) MONEY,
-- (a.TODAYKWH * PowerRate) TODAYMONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
END TOTALMONEY,*/
(a.KWH * PowerRate) MONEY,
(a.TODAYKWH * PowerRate) TODAYMONEY,
(a.TOTALKWH * PowerRate) TOTALMONEY,
(a.KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 3) TOTALCARBON
from " + _siteDB + ".s" + _siteID01 + @"_station a join
(select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
@ -187,7 +187,7 @@ namespace solarApp.Service
GROUP BY lb.PowerStationId
) c ON a.siteID = c.siteID
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and a.SITEID = @siteID ";
int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
//int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
#endregion hour
@ -196,16 +196,16 @@ namespace solarApp.Service
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
CASE
WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate
/*CASE
WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate
ELSE a.KWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (KWH * PowerRate) MONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
END TOTALMONEY,*/
(KWH * PowerRate) MONEY,
(a.TOTALKWH * PowerRate) TOTALMONEY,
(KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from
(
@ -229,7 +229,7 @@ namespace solarApp.Service
WHERE ps.Code = @siteID
GROUP BY lb.PowerStationId
) c ON a.siteID = c.siteID";
conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
//conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
#endregion day
#region month
@ -240,16 +240,16 @@ namespace solarApp.Service
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, TODAYKWH as monthKwh , a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
CASE
/*CASE
WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate
ELSE a.TODAYKWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (TODAYKWH * PowerRate) MONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
END TOTALMONEY,*/
(TODAYKWH * PowerRate) MONEY,
(a.TOTALKWH * PowerRate) TOTALMONEY,
(TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from
(