電站檢查

This commit is contained in:
b110212000 2021-11-02 10:13:36 +08:00
parent 02c60eaf7d
commit c238552432
4 changed files with 83 additions and 4 deletions

View File

@ -3231,6 +3231,7 @@ namespace SolarPower.Controllers
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
@ -3245,6 +3246,42 @@ namespace SolarPower.Controllers
{
var powerStation = await powerStationRepository.GetOneAsync(Id);
status = await powerStationRepository.CheckStationStatus(powerStation.Code, powerStation.SiteDB);
if(status.Count > 0)
{
apiResult.Code = "0099";
apiResult.Data = status;
}
else
{
var sitecheck = await powerStationRepository.Check4table(powerStation.Code, powerStation.SiteDB);
if(powerStation.Code != sitecheck.Avg && sitecheck.Avg != null)
{
status.Add($"s{powerStation.Code}01_avg SITEID錯誤");
}
if (powerStation.Code != sitecheck.Inv_site && sitecheck.Inv_site != null)
{
status.Add($"s{powerStation.Code}01_inv SITEID錯誤");
}
if (powerStation.Code + "01" != sitecheck.Inv_inveter.Substring(0,11) && sitecheck.Inv_inveter != null)
{
status.Add($"s{powerStation.Code}01_Inv inveter格式錯誤");
}
if (powerStation.Code != sitecheck.Station && sitecheck.Station != null)
{
status.Add($"s{powerStation.Code}01_station SITEID錯誤");
}
if (powerStation.Code != sitecheck.Sensor && sitecheck.Sensor != null)
{
status.Add($"s{powerStation.Code}01_sensor SITEID錯誤");
}
if(sitecheck.Inv_inveter != null)
{
if (sitecheck.Inv_inveter.Length != 15)
{
status.Add($"s{powerStation.Code}01_Inv inveter格式錯誤");
}
}
if(status.Count > 0)
{
apiResult.Code = "0099";
@ -3257,11 +3294,13 @@ namespace SolarPower.Controllers
apiResult.Msg = "電站啟用成功";
apiResult.Code = "0000";
}
}
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
@ -3285,6 +3324,7 @@ namespace SolarPower.Controllers
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}

View File

@ -1051,5 +1051,13 @@ namespace SolarPower.Models.PowerStation
public string Site_id { get; set; }
public string InverterId { get; set; }
}
public class Check4table
{
public string Avg { get; set; }
public string Inv_site { get; set; }
public string Inv_inveter { get; set; }
public string Station { get; set; }
public string Sensor { get; set; }
}
}

View File

@ -5803,6 +5803,36 @@ namespace SolarPower.Repository.Implement
}
}
public async Task<Check4table> Check4table(string code,string dbname)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
var resule = new Check4table();
try
{
var sql = $@"SELECT * FROM
(SELECT a.SITEID AS Avg FROM {dbname}.s{code}01_sensoravg a ORDER BY a.ID DESC LIMIT 1) a,
(SELECT a.SITEID AS Inv_site,a.INVERTERID as Inv_inveter FROM {dbname}.s{code}01_inv a ORDER BY a.ID DESC LIMIT 1) b,
(SELECT a.SITEID AS Station FROM {dbname}.s{code}01_station a ORDER BY a.ID DESC LIMIT 1) c,
(SELECT a.SITEID AS Sensor FROM {dbname}.s{code}01_sensor a ORDER BY a.ID DESC LIMIT 1) d
";
resule = await conn.QueryFirstOrDefaultAsync<Check4table>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return resule;
}
}
}
}

View File

@ -607,5 +607,6 @@ namespace SolarPower.Repository.Interface
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);
Task<Check4table> Check4table(string code, string dbname);
}
}