This commit is contained in:
cesar liu 2022-03-28 00:46:11 +08:00
commit 894f8f03e4
5 changed files with 92 additions and 62 deletions

View File

@ -1046,6 +1046,10 @@ namespace SolarPower.Controllers
} }
var sheet = workbook.CreateSheet(powerstationid.Name); var sheet = workbook.CreateSheet(powerstationid.Name);
var Formbody = GetForm(select_Table);//取body var Formbody = GetForm(select_Table);//取body
if(Formbody.Result.Data.Count == 0)
{
continue;
}
var Formhead = GetTableHead(select_Table);//取head var Formhead = GetTableHead(select_Table);//取head
int RowPosition = 0; int RowPosition = 0;
@ -1099,6 +1103,7 @@ namespace SolarPower.Controllers
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = ""; var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
{ {
index = 0; index = 0;
var dbody = body as IDictionary<string, object>; var dbody = body as IDictionary<string, object>;
thour = Checknull(Math.Round(Convert.ToDouble(dbody["tothour"]), 2).ToString()); thour = Checknull(Math.Round(Convert.ToDouble(dbody["tothour"]), 2).ToString());

View File

@ -57,7 +57,7 @@ namespace SolarPower.Quartz.Jobs
logger.LogInformation("【CalcInverter15minJob】【開始取得電站資料】"); logger.LogInformation("【CalcInverter15minJob】【開始取得電站資料】");
var powerStations = await powerStationRepository.GetAllAsync(); var powerStations = await powerStationRepository.GetAllAsync();
logger.LogInformation("【CalcInverter15minJob】【取得成功電站資料】"); logger.LogInformation("【CalcInverter15minJob】【取得成功電站資料】");
logger.LogInformation("【CalcInverter15minJob】【電站資料】 - {0}", System.Text.Json.JsonSerializer.Serialize(powerStations)); //logger.LogInformation("【CalcInverter15minJob】【電站資料】 - {0}", System.Text.Json.JsonSerializer.Serialize(powerStations));
#endregion #endregion
List<InverterHistory> calcInverter15mins = new List<InverterHistory>(); List<InverterHistory> calcInverter15mins = new List<InverterHistory>();
@ -78,7 +78,8 @@ namespace SolarPower.Quartz.Jobs
#region step2. DB及電站編號找出該電站的控制器 #region step2. DB及電站編號找出該電站的控制器
foreach (var powerStation in powerStations) foreach (var powerStation in powerStations)
{ {
try
{
//取得所有該電站的逆變器 //取得所有該電站的逆變器
logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime); logger.LogInformation("【CalcInverter15minJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateNowTime);
var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB); var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB);
@ -108,11 +109,12 @@ namespace SolarPower.Quartz.Jobs
} }
} }
} }
}
catch (Exception ex)
{
logger.LogError("【CalcInverter15minJob】【電站[{0}]計算失敗】 - {1}", powerStation.Code, ex.ToString());
}
#endregion #endregion
} }
#endregion #endregion
@ -127,7 +129,14 @@ namespace SolarPower.Quartz.Jobs
"KWHKWP", "KWHKWP",
}; };
try
{
await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties); await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties);
}
catch (Exception ex)
{
logger.LogError("【CalcInverter15minJob】【儲存15分鐘歷史紀錄失敗】 - {0}", ex.ToString());
}
#endregion #endregion
// } // }
//} //}

View File

@ -2,6 +2,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Quartz; using Quartz;
using SolarPower.Models; using SolarPower.Models;
using SolarPower.Models.User;
using SolarPower.Repository.Interface; using SolarPower.Repository.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -198,10 +199,25 @@ namespace SolarPower.Quartz.Jobs
#region #region
var users = userRepository.GetAllAsync(); var users = userRepository.GetAllAsync();
var ttt = new List<string>() {
"s506488@gmail.com", //var usertest = new List<User>();
"cesarliuc@gmail.com" //var oneuser = new User()
}; //{
// Account = "cesarliuc@gmail.com",
// Password = "np/F0eliIy3lPJe1tU18oiG7dzKRrpVw16/XZpHOph8=",
// Id = 13,
// Email = "cesarliuc@gmail.com",
// Status = 1,
// Name = "TEST"
//};
//usertest.Add(oneuser);
//var ttt = new List<string>() {
// "s506488@gmail.com",
// "cesarliuc@gmail.com"
//};
foreach (var user in users.Result) foreach (var user in users.Result)
{ {
@ -294,9 +310,9 @@ namespace SolarPower.Quartz.Jobs
{ {
Select_table2 maxmonthexcel = new Select_table2() Select_table2 maxmonthexcel = new Select_table2()
{ {
FormType = 0, FormType = 1,
PowerStation = sentMaxpowerstations, PowerStation = sentMaxpowerstations,
SearchType = 0, SearchType = 1,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"), Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id Userid = user.Id
}; };

View File

@ -393,7 +393,7 @@ namespace SolarPower.Repository.Implement
GROUP BY a.Id,a.time GROUP BY a.Id,a.time
) n ON n.Id = ps.Id ) n ON n.Id = ps.Id
WHERE ps.Id IN @ids ORDER BY ps.CityId"; WHERE ps.Id IN @ids ORDER BY ps.CityId";
result = (await conn.QueryAsync<MaxFormbody>(sql,new { ids = ids})).ToList(); result = (await conn.QueryAsync<MaxFormbody>(sql,new { ids = ids}, commandTimeout: 300)).ToList();
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -597,7 +597,7 @@ namespace SolarPower.Repository.Implement
break; break;
} }
a = await conn.QueryAsync<dynamic>(sql); a = await conn.QueryAsync<dynamic>(sql,commandTimeout: 300);
} }
catch (Exception exception) catch (Exception exception)
{ {

View File

@ -53,7 +53,7 @@ namespace SolarPower.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
//_log.LogError("【SendEmailSMSService】 " + noticeInfo.Recipient_email + "寄送信件失敗"); throw ex;
return false; return false;
} }