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

View File

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

View File

@ -2,6 +2,7 @@
using Newtonsoft.Json;
using Quartz;
using SolarPower.Models;
using SolarPower.Models.User;
using SolarPower.Repository.Interface;
using System;
using System.Collections.Generic;
@ -198,10 +199,25 @@ namespace SolarPower.Quartz.Jobs
#region
var users = userRepository.GetAllAsync();
var ttt = new List<string>() {
"s506488@gmail.com",
"cesarliuc@gmail.com"
};
//var usertest = new List<User>();
//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)
{
@ -294,9 +310,9 @@ namespace SolarPower.Quartz.Jobs
{
Select_table2 maxmonthexcel = new Select_table2()
{
FormType = 0,
FormType = 1,
PowerStation = sentMaxpowerstations,
SearchType = 0,
SearchType = 1,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id
};

View File

@ -393,7 +393,7 @@ namespace SolarPower.Repository.Implement
GROUP BY a.Id,a.time
) n ON n.Id = ps.Id
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)
{
@ -597,7 +597,7 @@ namespace SolarPower.Repository.Implement
break;
}
a = await conn.QueryAsync<dynamic>(sql);
a = await conn.QueryAsync<dynamic>(sql,commandTimeout: 300);
}
catch (Exception exception)
{

View File

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