Merge branch 'Willy'

This commit is contained in:
b110212000 2021-08-13 10:51:01 +08:00
commit c2a84e7059
6 changed files with 191 additions and 180 deletions

View File

@ -2280,7 +2280,8 @@ namespace SolarPower.Controllers
ControllerId = post.ControllerId,
SerialNumber = Newnum,
InverterId = deviceController.ControllerId + Newnum,
CreatedBy = myUser.Id
CreatedBy = myUser.Id,
BrandNum = post.BrandNum
};
List<string> properties = new List<string>()
{
@ -2295,7 +2296,8 @@ namespace SolarPower.Controllers
"ControllerId",
"SerialNumber",
"CreatedBy",
"InverterId"
"InverterId",
"BrandNum"
};
await powerStationRepository.AddInverter(inverter, properties, powerStation.SiteDB);
apiResult.Code = "0000";
@ -2322,7 +2324,8 @@ namespace SolarPower.Controllers
InverterName = post.InverterName,
Pyrheliometer = post.Pyrheliometer,
ControllerId = post.ControllerId,
UpdatedBy = myUser.Id
UpdatedBy = myUser.Id,
BrandNum = post.BrandNum
};
List<string> properties = new List<string>()
{
@ -2336,7 +2339,8 @@ namespace SolarPower.Controllers
"InverterName",
"Pyrheliometer",
"ControllerId",
"UpdatedBy"
"UpdatedBy",
"BrandNum"
};
await powerStationRepository.UpdateInverter(inverter, properties, powerStation.SiteDB);
apiResult.Code = "0000";

View File

@ -553,6 +553,7 @@ namespace SolarPower.Models.PowerStation
public int Status { get; set; }//狀態
public string SerialNumber { get; set; }//流水號
public string InverterId { get; set; }//逆變器id
public string BrandNum { get; set; }//廠商序號
}
/// <summary>
/// 控制器datatable

View File

@ -36,180 +36,6 @@ namespace SolarPower.Quartz.Jobs
{
logger.LogInformation("【CalcAvgPowerStationJob】【任務開始】");
#region
var users = userRepository.GetAllAsync();
foreach (var user in users.Result)
{
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
if (powerstations.Count == 0)
{
continue;
}
List<Excelpowerstation> sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
List<Excelpowerstation> sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository);
//日報表
if (sentdaypowerstations.Count != 0)
{
Excel dayexcel = new Excel()
{
FormType = 0,
PowerStation = sentdaypowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
Userid = user.Id
};
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
if(stationReportName != "")
{
NoticeSchedule DaySchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 0,
RecipientEmail = user.Email,
Subject = "日報表",
Attachment = stationReportName,
RecipientName = user.Name,
Type = 1
};
List<string> properties = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
}
}
//綜合報表 每日
if (sentMaxpowerstations.Count != 0)
{
Select_table2 maxdayexcel = new Select_table2()
{
FormType = 0,
PowerStation = sentMaxpowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
Userid = user.Id
};
var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented));
NoticeSchedule MaxSchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 2,
RecipientEmail = user.Email,
Subject = "綜合報表",
Attachment = stationMaxReportName,
RecipientName = user.Name,
Type = 1
};
List<string> properties = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties);
if (DateTime.Now.ToString("dd") == "01")
{
Select_table2 maxmonthexcel = new Select_table2()
{
FormType = 0,
PowerStation = sentMaxpowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id
};
var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented));
NoticeSchedule MaxmonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "綜合報表",
Attachment = stationReportmaxmonthName,
RecipientName = user.Name,
Type = 1,
UserId = user.Id,
EmailType = 2
};
List<string> properties2 = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2);
}
}
if (DateTime.Now.ToString("dd") == "01")
{
List<Excelpowerstation> sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
if (sentmonthpowerstations.Count == 0)
{
break;
}
Excel monthexcel = new Excel()
{
FormType = 1,
PowerStation = sentmonthpowerstations,
SearchType = 2,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id
};
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
if (stationReportmonthName != "")
{
NoticeSchedule MonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "月報表",
Attachment = stationReportmonthName,
RecipientName = user.Name,
Type = 1,
UserId = user.Id,
EmailType = 1
};
List<string> properties2 = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
}
}
}
#endregion
#region step1.
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得電站資料】");
var powerStations = await powerStationRepository.GetAllAsync();
@ -917,7 +743,178 @@ namespace SolarPower.Quartz.Jobs
}
#endregion
#region
var users = userRepository.GetAllAsync();
foreach (var user in users.Result)
{
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
if (powerstations.Count == 0)
{
continue;
}
List<Excelpowerstation> sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
List<Excelpowerstation> sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository);
//日報表
if (sentdaypowerstations.Count != 0)
{
Excel dayexcel = new Excel()
{
FormType = 0,
PowerStation = sentdaypowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
Userid = user.Id
};
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
if (stationReportName != "")
{
NoticeSchedule DaySchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 0,
RecipientEmail = user.Email,
Subject = "日報表",
Attachment = stationReportName,
RecipientName = user.Name,
Type = 1
};
List<string> properties = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
}
}
//綜合報表 每日
if (sentMaxpowerstations.Count != 0)
{
Select_table2 maxdayexcel = new Select_table2()
{
FormType = 0,
PowerStation = sentMaxpowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
Userid = user.Id
};
var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented));
NoticeSchedule MaxSchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 2,
RecipientEmail = user.Email,
Subject = "綜合報表",
Attachment = stationMaxReportName,
RecipientName = user.Name,
Type = 1
};
List<string> properties = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties);
if (DateTime.Now.ToString("dd") == "01")
{
Select_table2 maxmonthexcel = new Select_table2()
{
FormType = 0,
PowerStation = sentMaxpowerstations,
SearchType = 0,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id
};
var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented));
NoticeSchedule MaxmonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "綜合報表",
Attachment = stationReportmaxmonthName,
RecipientName = user.Name,
Type = 1,
UserId = user.Id,
EmailType = 2
};
List<string> properties2 = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2);
}
}
if (DateTime.Now.ToString("dd") == "01")
{
List<Excelpowerstation> sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
if (sentmonthpowerstations.Count == 0)
{
break;
}
Excel monthexcel = new Excel()
{
FormType = 1,
PowerStation = sentmonthpowerstations,
SearchType = 2,
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
Userid = user.Id
};
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
if (stationReportmonthName != "")
{
NoticeSchedule MonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "月報表",
Attachment = stationReportmonthName,
RecipientName = user.Name,
Type = 1,
UserId = user.Id,
EmailType = 1
};
List<string> properties2 = new List<string>()
{
"UserId",
"EmailType",
"RecipientEmail",
"Subject",
"Attachment",
"RecipientName",
"Type"
};
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
}
}
}
#endregion
}
catch (Exception exception)

View File

@ -368,6 +368,7 @@ namespace SolarPower.Quartz.Jobs
break;
}
}
weatherObservations.Add(weatherObservation);
}
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime);
@ -379,7 +380,7 @@ namespace SolarPower.Quartz.Jobs
calcPowerStation.RateOfRain = weather.PoP;
}
weatherObservations.Add(weatherObservation);
}
#endregion

View File

@ -317,6 +317,8 @@
"data": "installDate"
}, {
"data": "brand"
}, {
"data": "brandNum"
}, {
"data": "model"
}, {
@ -2256,6 +2258,7 @@
InverterName: $("#Inverter_InverterName_modal").val(),
InstallDate: $("#Inverter_InstallDate_modal").val(),
Brand: $("#Inverter_Brand_modal").val(),
BrandNum: $("#Inverter_BrandNum_modal").val(),
Model: $("#Inverter_Model_modal").val(),
Capacity: $("#Inverter_Capacity_modal").val(),
Pyrheliometer: $("#Inverter_Pyrheliometer_modal").val(),
@ -2386,6 +2389,7 @@
$("#Inverter_InverterName_modal").val(rel.data.inverterName);
$("#Inverter_InstallDate_modal").val(rel.data.installDate);
$("#Inverter_Brand_modal").val(rel.data.brand);
$("#Inverter_BrandNum_modal").val(rel.data.brandNum);
$("#Inverter_Model_modal").val(rel.data.model);
$("#Inverter_Capacity_modal").val(rel.data.capacity);
$("#Inverter_Pyrheliometer_modal").val(rel.data.pyrheliometer);

View File

@ -49,6 +49,7 @@
<th>狀態</th>
<th>安裝日期</th>
<th>廠牌</th>
<th>廠商序號</th>
<th>型號</th>
<th>裝置容量 kWp</th>
<th>日照計編號</th>
@ -199,6 +200,10 @@
<label class="form-label" for="Inverter_Brand_modal"><span class="text-danger">*</span>廠牌</label>
<input type="text" id="Inverter_Brand_modal" name="Inverter_Brand_modal" class="form-control">
</div>
<div class="form-group col-lg-6">
<label class="form-label" for="Inverter_BrandNum_modal"><span class="text-danger">*</span>廠商序號</label>
<input type="text" id="Inverter_BrandNum_modal" name="Inverter_BrandNum_modal" class="form-control">
</div>
<div class="form-group col-lg-6">
<label class="form-label" for="Inverter_Model_modal"><span class="text-danger">*</span>型號</label>
<input type="text" id="Inverter_Model_modal" name="Inverter_Model_modal" class="form-control">
@ -215,7 +220,6 @@
<div class="form-group col-lg-3">
<label class="form-label" for="Inverter_Status_modal">狀態</label>
<select class="form-control" id="Inverter_Status_modal" disabled>
<option value="0" action>未啟用</option>
<option value="1">正常</option>
<option value="2">異常</option>
</select>