1. 加入 company viewer Modal
2. 修改電站總覽 紅黃燈名詞 3. 檢測逆變器狀態
This commit is contained in:
parent
e19ac35e78
commit
ccd68d6bf4
@ -1045,4 +1045,11 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Item { get; set; }
|
||||
}
|
||||
|
||||
public class InvStatusErr
|
||||
{
|
||||
public string SiteDB { get; set; }
|
||||
public string Site_id { get; set; }
|
||||
public string InverterId { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
#endregion
|
||||
|
||||
List<InverterHistory> calcInverter15mins = new List<InverterHistory>();
|
||||
List<string> updateInvPowerStationDBName = new List<string>();
|
||||
|
||||
var DateTimeNow = DateTime.Now;
|
||||
|
||||
@ -108,15 +109,15 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_15min 資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region step3. 將 inverter INSERT 到 inverter_history_15min 資料表
|
||||
List<string> inverter_history_properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"INVERTERID",
|
||||
@ -127,9 +128,47 @@ namespace SolarPower.Quartz.Jobs
|
||||
};
|
||||
|
||||
await powerStationRepository.AddInverter15minHistory(calcInverter15mins, inverter_history_properties);
|
||||
#endregion
|
||||
#endregion
|
||||
// }
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
logger.LogInformation("【CalcInverter15minJob】開始檢測逆變器狀態");
|
||||
var ps_groupby_SitDB = powerStations.GroupBy(x => x.SiteDB).ToList();
|
||||
|
||||
var updateInvStatusList = new Dictionary<string, List<string>>();
|
||||
var psCodes = new List<string>();
|
||||
|
||||
foreach (var ps in ps_groupby_SitDB)
|
||||
{
|
||||
//updateInvStatusList.Add(ps.Key, ps.Select(x => x.Code).ToList());
|
||||
await powerStationRepository.UpdateInvStatus(ps.Key, ps.Select(x => x.Code).ToList(), null, 1);
|
||||
psCodes.AddRange(ps.Select(x => x.Code).ToList());
|
||||
}
|
||||
|
||||
//foreach(var list in updateInvStatusList)
|
||||
//{
|
||||
// await powerStationRepository.UpdateInvStatus(list.Key, list.Value, null, 1);
|
||||
// psCodes.AddRange(list.Value);
|
||||
//}
|
||||
|
||||
var invStatusErr = await powerStationRepository.GetInvStatusErr(psCodes);
|
||||
|
||||
var invStatusErr_Group = invStatusErr.GroupBy(x => x.SiteDB).ToList();
|
||||
|
||||
foreach (var update_invStatusErr in invStatusErr_Group)
|
||||
{
|
||||
await powerStationRepository.UpdateInvStatus(update_invStatusErr.Key, null, update_invStatusErr.Select(x => x.InverterId).ToList(), 2);
|
||||
}
|
||||
|
||||
logger.LogError("【CalcInverter15minJob】檢測完成逆變器狀態");
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
logger.LogError("【CalcInverter15minJob】檢測逆變器狀態失敗 - [Exception] {0}", exception.Message);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -732,7 +732,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sub_sql = $@"select '{db_name}' AS `dbName`,(`{db_name}`.`inverter`.`InverterId` collate utf8mb4_unicode_ci) AS `InverterId`,
|
||||
(`{db_name}`.`inverter`.`Brand` collate utf8mb4_unicode_ci) AS `Brand`,`{db_name}`.`inverter`.`Enabled` AS `enabled`,
|
||||
`{db_name}`.`inverter`.`Status` AS status
|
||||
`{db_name}`.`inverter`.`Status` AS status, (`{db_name}`.`inverter`.`Model` collate utf8mb4_unicode_ci) AS `Model`
|
||||
from `{db_name}`.`inverter`";
|
||||
|
||||
temp_sub_sql.Add(sub_sql);
|
||||
|
||||
@ -34,7 +34,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var show_enable_str = " AND ps.Status = 1";
|
||||
|
||||
if(showEnable != 1)
|
||||
if (showEnable != 1)
|
||||
{
|
||||
show_enable_str = "";
|
||||
}
|
||||
@ -5369,7 +5369,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetShareDevicePowerstationName (int Id , string DBname)
|
||||
public async Task<List<string>> GetShareDevicePowerstationName(int Id, string DBname)
|
||||
{
|
||||
List<string> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -5391,7 +5391,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DropShareDevice(int powerstationId ,string DBname)
|
||||
public async Task DropShareDevice(int powerstationId, string DBname)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -5449,14 +5449,14 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> CheckStationStatus (string code , string DBname)
|
||||
public async Task<List<string>> CheckStationStatus(string code, string DBname)
|
||||
{
|
||||
List<string> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
List<PowerstationOption> devices = new List<PowerstationOption>
|
||||
List<PowerstationOption> devices = new List<PowerstationOption>
|
||||
{
|
||||
new PowerstationOption{Text="日照計",Value="PYR"},
|
||||
new PowerstationOption{Text="模組溫度計",Value="MTR"}
|
||||
@ -5698,7 +5698,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task StationStatus(int stationId , int status , string subDB = "")
|
||||
public async Task StationStatus(int stationId, int status, string subDB = "")
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
@ -5728,6 +5728,75 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var sql = $@"UPDATE {siteDB}.inverter SET Status = {status} WHERE Enabled = 1 AND Deleted = 0 ";
|
||||
|
||||
if(codes != null && codes.Count > 0)
|
||||
{
|
||||
sql += " AND LEFT(InverterId, 9) IN @Codes";
|
||||
}
|
||||
|
||||
if(inverterIds != null && inverterIds.Count > 0)
|
||||
{
|
||||
sql += " AND InverterId IN @InverterIds";
|
||||
}
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Codes = codes, InverterIds = inverterIds }, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
var resule = new List<InvStatusErr>();
|
||||
try
|
||||
{
|
||||
|
||||
var sql = $@"select b.DBName AS SiteDB, site_id, INVERTERID
|
||||
from err_main a join v_company_inv b on a.errDevice = b.INVERTERID
|
||||
where site_id IN @Codes and sourceState = 1
|
||||
group by b.DBName, site_id, INVERTERID";
|
||||
resule = (await conn.QueryAsync<InvStatusErr>(sql, new { Codes = codes })).ToList();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return resule;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,5 +605,7 @@ namespace SolarPower.Repository.Interface
|
||||
Task DeleteALLPowerStationOperationPersonnel(int stationId);
|
||||
Task<List<string>> CheckStationStatus(string code, string DBname);
|
||||
Task StationStatus(int stationId, int status, string subDB = "");
|
||||
Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0);
|
||||
Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,11 +39,11 @@
|
||||
</div>
|
||||
<div class=" col-2 mb-2 custom-control custom-checkbox align-content-center">
|
||||
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_2" value="2" checked>
|
||||
<label class="custom-control-label" for="Status_2">設備斷線 <i class="btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation"></i></label>
|
||||
<label class="custom-control-label" for="Status_2">設備異常 <i class="btn btn-warning btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-exclamation"></i></label>
|
||||
</div>
|
||||
<div class="col-2 mb-2 custom-control custom-checkbox align-content-center">
|
||||
<input type="checkbox" class="custom-control-input" name="powerStationStatus[]" id="Status_3" value="3" checked>
|
||||
<label class="custom-control-label" for="Status_3">設備異常 <i class="btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule"></i></label>
|
||||
<label class="custom-control-label" for="Status_3">設備斷線 <i class="btn btn-danger btn-sm btn-icon rounded-circle waves-effect waves-themed fal fa-horizontal-rule"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user