This commit is contained in:
cesar liu 2022-08-24 10:01:42 +08:00
commit b84b7cc180
9 changed files with 113 additions and 17 deletions

View File

@ -55,7 +55,10 @@ namespace SolarPower.Quartz.Jobs
attachments = notice.Attachment.Split(',').ToList();
}
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments);
var getCompany = noticeScheduleRepository.GetCompanyNameById(notice.Id);
string companyName = getCompany.Result;
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments, companyName);
if (result.CompareTo("成功") == 0)
{
@ -96,7 +99,7 @@ namespace SolarPower.Quartz.Jobs
}
}
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments)
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments, string companyName)
{
var reason = string.Empty;
var CanDoSend = true;
@ -105,7 +108,8 @@ namespace SolarPower.Quartz.Jobs
MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼
MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼
MyMail.IsBodyHtml = true; //是否使用html格式
var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>";
//var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>";
var kkk = companyName + $" 太陽能電站管理系統通知 <{smtp.UserName}>";
MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人
foreach (var email in recipientEmails)
{

View File

@ -160,5 +160,36 @@ namespace SolarPower.Repository.Implement
}
}
}
public async Task<string> GetCompanyNameById(int noticeId)
{
string result;
using (IDbConnection conn = _databaseHelper.GetConnection())
{
conn.Open();
try
{
var sql = @$"select c.Name
from notice_schedule ns
left join user u on ns.UserId = u.id
left join company c on u.CompanyId = c.id
where ns.id = {noticeId}";
result = await conn.QueryFirstOrDefaultAsync<string>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return result;
}
}
}
}

View File

@ -418,7 +418,7 @@ namespace SolarPower.Repository.Implement
{
PowerStationId = post.Id,
Status = post.Status,
})).ToList();
}, commandTimeout: 600)).ToList();
}
catch (Exception exception)
{

View File

@ -12,5 +12,6 @@ namespace SolarPower.Repository.Interface
Task UpdateList(List<NoticeSchedule> noticeSchedules, List<string> properties);
Task<List<OperationPersonnel>> GetPowerStationOperationPersonnel(int Userid);
Task<List<NoticeScheduleTable>> GetNoticeTable(NoticeTableSearch info);
Task<string> GetCompanyNameById(int noticeId);
}
}

View File

@ -175,6 +175,13 @@
var selectInverterkwhBarType = 0;
var HeapMapXAxis = [];
var countOperationRecordFile = 0;
var isloadingdone_uptodate = false;
var isloadingdone_info = false;
var isloadingdone_inverterinfo = false;
var isloadingdone_inverter = false;
var isloadingdone_history = false;
var isloadingdone_exception = false;
var isloadingdone_operation = false;
function showLoading() {
var i = document.getElementById("loading");
@ -183,7 +190,10 @@
function hideLoading() {
var i = document.getElementById("loading");
i.style.display = "none";
if (isloadingdone_uptodate && isloadingdone_info && isloadingdone_inverterinfo && isloadingdone_inverter && isloadingdone_history && isloadingdone_exception && isloadingdone_operation)
{
i.style.display = "none";
}
}
$(function () {
@ -262,6 +272,7 @@
};
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_uptodate = true;
hideLoading();
toast_error(rel.msg);
return;
@ -320,6 +331,7 @@
$("#money-card-subtitle-total").html("總計");
$("#money-card-subtitle-avg").html("今日");
}
isloadingdone_uptodate = true;
hideLoading();
}, 'json');
@ -757,6 +769,7 @@
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_info = true;
hideLoading();
toast_error(rel.msg);
return;
@ -781,6 +794,7 @@
$("#power_station_select_modal").append($("<option />").val(stationId).text(powerStationData.name));
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
isloadingdone_info = true;
hideLoading();
}, 'json');
@ -1101,6 +1115,7 @@
}
$.post(url_power_station_operation_personnel, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_operation = true;
hideLoading();
toast_error(rel.msg);
return;
@ -1117,12 +1132,12 @@
$("#work_person_select_modal_exc").val(record.workPersonId);
}
}
isloadingdone_operation = true;
hideLoading();
});
//#endregion
//#region 異常table
showLoading();
ExceptionTable = $("#Exception_Table").DataTable({
"pageLength": 20,
"paging": true,
@ -1186,6 +1201,10 @@
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
toast_error(rel.data.msg);
return;
@ -1195,11 +1214,19 @@
this.data = [];
}
$("#Exception_Table_wrapper").show();
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
return data;
}
},
"error": function (xhr, error, thrown) {
isloadingdone_exception = true;
$("#errbutton1").html('未解決').attr("disabled", false);
$("#errbutton0").html('已解決').attr("disabled", false);
$("#to30day").html('近30天').attr("disabled", false);
hideLoading();
console.log(xhr);
}
@ -1366,13 +1393,15 @@
//#region 改變日期(異常)
$('#date-range-exception').on('change', function () {
showLoading();
ExceptionTable.ajax.reload();
});
//#endregion
//#region 匯出excel(異常)
function ExportExcelToExc() {
showLoading();
//showLoading();
$("#exportBtn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var url = "/StationOverview/GetExceptionTable";
var send_data = {
id: stationId,
@ -1381,7 +1410,8 @@
};
$.post(url, send_data, function (rel) {
if (rel.data.code != "0000") {
hideLoading();
//hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
toast_error(rel.data.msg);
return;
}
@ -1412,7 +1442,8 @@
//檔案字尾名
fileext: ".xls",
});
hideLoading();
//hideLoading();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
}, 'json');
}
//#endregion
@ -1494,6 +1525,7 @@
//#region 查詢近30天(異常)
function ChangeDate30exception() {
$("#Exception_Table_wrapper").hide();
$("#to30day").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
@ -1613,9 +1645,11 @@
var name;
var name2;
if (type == 0) {
$("#errbutton0").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "0";
name2 = "errbutton" + "1";
} else {
$("#errbutton1").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
name = "errbutton" + "1";
name2 = "errbutton" + "0";
}
@ -2378,6 +2412,7 @@
}
$.post(url, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_inverter = true;
hideLoading();
toast_error(rel.msg);
return;
@ -2432,6 +2467,7 @@
//#endregion
$('#inverter-kWh-convas-div').show();
isloadingdone_inverter = true;
hideLoading();
}, 'json');
@ -2658,6 +2694,7 @@
var Nurl = "/StationOverview/GetTotalTableToHistory";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
isloadingdone_history = true;
hideLoading();
toast_error(rel.msg);
return;
@ -2944,6 +2981,7 @@
'</tr>');
}
$('#all').show();
isloadingdone_history = true;
hideLoading();
})
}
@ -3051,11 +3089,13 @@
}
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
isloadingdone_inverterinfo = true;
hideLoading();
toast_error(rel.msg);
return;
}
if (rel.code == "0001") {
isloadingdone_inverterinfo = true;
hideLoading();
toast_warning(rel.msg);
return;
@ -3181,6 +3221,7 @@
}
};
isloadingdone_inverterinfo = true;
hideLoading();
});
}

View File

@ -15,7 +15,7 @@
</div>
</div>
<div class="row d-flex justify-content-end">
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="ExportExcelToExc()">
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="ExportExcelToExc()" id="exportBtn">
<span class="fal fa-file-excel mr-1"></span>
匯出
</button>

View File

@ -270,6 +270,10 @@ namespace solarApp.Service
{
IrrDayHour = IrrDay - twoHourAgoIrrDay;// 前一小時的IrrDay - 前兩小時的IrrDay
}
if(IrrDayHour < 0)
{
IrrDayHour = 0;
}
string ss = $@"UPDATE solar_master.sensor_history_hour
SET IrrDayHour = {IrrDayHour}

View File

@ -762,7 +762,7 @@ namespace solarApp
this.ClientSize = new System.Drawing.Size(1782, 953);
this.Controls.Add(this.tabControl1);
this.Name = "fmArchive";
this.Text = "fmArchive";
this.Text = "fmArchive 0822";
this.Load += new System.EventHandler(this.fmArchive_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);

View File

@ -46,7 +46,7 @@ namespace solarApp
{
//string d1 = day.ToString("yyyy-MM-dd");
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.archiveSensorHistoryHourData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));/////要改
sensorSvc.archiveSensorHistoryHourData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.isFirst = false;
}
//sensorSvc._siteDB = lbSiteDB_sensor.Text;
@ -321,7 +321,7 @@ namespace solarApp
//for sensor_history_hour
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));/////要改
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.isFirst = false;
}
}
@ -491,7 +491,7 @@ namespace solarApp
//}
var site_list = stationSvc.get_station_list();
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
procSensorSvc sensorSvc = new procSensorSvc();
@ -500,7 +500,7 @@ namespace solarApp
int i = 0;
foreach (var item in site_list)
{
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
@ -509,8 +509,20 @@ namespace solarApp
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
i++;
}
// MessageBox.Show("OK");
}
sensorSvc.isFirst = true;
foreach (var item in site_list)
{
//for sensor_history_hour
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.isFirst = false;
}
}
// MessageBox.Show("OK");
lbMsgTitle.Text = DateTime.Now.ToString() + " sensor_lackData OK";
}
@ -546,9 +558,12 @@ namespace solarApp
//foreach (var item in site_list)
//{
sensorSvc.isFirst = true;
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.archiveSensorHistoryHourData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
sensorSvc.isFirst = false;
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));