修改電站抓取方式 step1
This commit is contained in:
parent
562e8cc28c
commit
b5fec530b5
@ -107,4 +107,10 @@ namespace SolarPower.Models
|
||||
public int Value { get; set; } //通常放id
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class OrderBy
|
||||
{
|
||||
public string Col { get; set; }
|
||||
public string Sort { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
|
||||
if (string.IsNullOrEmpty(exist))
|
||||
{
|
||||
logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_station資料表】", powerStation.Code);
|
||||
logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_station資料表】", powerStation.Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -23,16 +23,15 @@ namespace SolarPower.Repository.Implement
|
||||
tableName = "power_station";
|
||||
}
|
||||
|
||||
|
||||
public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
|
||||
public List<PowerStation> GetMyPowerStationSummary(MyUser myUser, List<string> wheres = null, List<string> orderBy = null)
|
||||
{
|
||||
List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
|
||||
var results = new List<PowerStation>();
|
||||
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @"SELECT ps.Id, ps.CityId, c.Name AS CityName, ps.Name
|
||||
var sql = @"SELECT ps.*, c.Name AS CityName
|
||||
FROM power_station ps
|
||||
LEFT JOIN city c ON ps.CityId = c.Id";
|
||||
|
||||
@ -43,19 +42,28 @@ namespace SolarPower.Repository.Implement
|
||||
else if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser || myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser)
|
||||
{
|
||||
sql += @" LEFT JOIN power_station_operation_personnel op ON ps.Id = op.PowerStationId
|
||||
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
||||
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql += @" WHERE ps.Deleted = 0";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter))
|
||||
if (wheres != null && wheres.Count > 0)
|
||||
{
|
||||
sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||
var temp_where = "";
|
||||
temp_where = string.Join(" AND ", wheres);
|
||||
sql += string.Join(" AND ", wheres);
|
||||
}
|
||||
|
||||
sql += " ORDER BY c.Priority";
|
||||
if (orderBy != null && orderBy.Count > 0)
|
||||
{
|
||||
var temp_order = "";
|
||||
temp_order = string.Join(" , ", orderBy);
|
||||
sql += $" ORDER BY c.Priority, {temp_order}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
var myPowerStationInfos = conn.Query<MyPowerStationInfo>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter }).ToList();
|
||||
|
||||
@ -88,6 +96,71 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//public List<MyPowerStationSummary> GetMyPowerStationSummary(MyUser myUser, string filter = "")
|
||||
//{
|
||||
// List<MyPowerStationSummary> results = new List<MyPowerStationSummary>();
|
||||
|
||||
// using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var sql = @"SELECT ps.Id, ps.CityId, c.Name AS CityName, ps.Name
|
||||
// FROM power_station ps
|
||||
// LEFT JOIN city c ON ps.CityId = c.Id";
|
||||
|
||||
// if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
|
||||
// { //公司管理員
|
||||
// sql += @" WHERE ps.Deleted = 0 AND ps.CompanyId = @CompanyId";
|
||||
// }
|
||||
// else if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser || myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser)
|
||||
// {
|
||||
// sql += @" LEFT JOIN power_station_operation_personnel op ON ps.Id = op.PowerStationId
|
||||
// WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sql += @" WHERE ps.Deleted = 0";
|
||||
// }
|
||||
|
||||
// if (!string.IsNullOrEmpty(filter))
|
||||
// {
|
||||
// sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')";
|
||||
// }
|
||||
|
||||
// sql += " ORDER BY c.Priority";
|
||||
|
||||
// var myPowerStationInfos = conn.Query<MyPowerStationInfo>(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter }).ToList();
|
||||
|
||||
// var myPowerStationInfos_group = myPowerStationInfos.GroupBy(x => x.CityId);
|
||||
|
||||
// foreach (var myPowerStationInfo in myPowerStationInfos_group)
|
||||
// {
|
||||
// MyPowerStationSummary myPowerStationSummary = new MyPowerStationSummary();
|
||||
// myPowerStationSummary.CityName = myPowerStationInfo.First().CityName;
|
||||
// myPowerStationSummary.Amount = myPowerStationInfo.Count();
|
||||
// myPowerStationSummary.MyPowerStations = new List<MyPowerStation>();
|
||||
// foreach (var info in myPowerStationInfo)
|
||||
// {
|
||||
// MyPowerStation myPowerStation = new MyPowerStation();
|
||||
// myPowerStation.PowerStationId = info.Id;
|
||||
// myPowerStation.PowerStationName = info.Name;
|
||||
|
||||
// myPowerStationSummary.MyPowerStations.Add(myPowerStation);
|
||||
// }
|
||||
|
||||
// results.Add(myPowerStationSummary);
|
||||
// }
|
||||
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// throw exception;
|
||||
// }
|
||||
// return results;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 查詢縣市列表
|
||||
/// </summary>
|
||||
@ -4798,7 +4871,7 @@ namespace SolarPower.Repository.Implement
|
||||
try
|
||||
{
|
||||
var purge_sql = $"DELETE FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate}, trans);
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
var insert_sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour");
|
||||
count = await conn.ExecuteAsync(insert_sql, entity, trans);
|
||||
@ -4991,7 +5064,7 @@ namespace SolarPower.Repository.Implement
|
||||
try
|
||||
{
|
||||
var table_name = "inverter_history_15min";
|
||||
|
||||
|
||||
var purge_sql = $"DELETE FROM {table_name} WHERE DATE_FORMAT(TIMESTAMP, '%Y-%m-%d') BETWEEN @StartDate AND @EndDate";
|
||||
await conn.ExecuteAsync(purge_sql, new { StartDate = startDate, EndDate = endDate }, trans);
|
||||
|
||||
@ -5121,7 +5194,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<InverterHistory>> GetAllInverterInfo(List<string> post,string site_table, string site_db)
|
||||
public async Task<List<InverterHistory>> GetAllInverterInfo(List<string> post, string site_table, string site_db)
|
||||
{
|
||||
List<InverterHistory> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -5149,7 +5222,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
|
||||
public async Task<InverterDetailModal> GetInverterInfoModal (int Id, string Time,string DB ,string Table)
|
||||
public async Task<InverterDetailModal> GetInverterInfoModal(int Id, string Time, string DB, string Table)
|
||||
{
|
||||
InverterDetailModal result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -5233,7 +5306,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId,string dbname)
|
||||
public async Task<List<AreaSelectItemList>> GetApicallItemList(int powerStationId, string dbname)
|
||||
{
|
||||
List<AreaSelectItemList> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
@ -5265,7 +5338,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<ApicallList>> GetApicallList(int PowerStationId,string Type)
|
||||
public async Task<List<ApicallList>> GetApicallList(int PowerStationId, string Type)
|
||||
{
|
||||
List<ApicallList> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
|
||||
@ -17,10 +17,10 @@ namespace SolarPower.Services.Implement
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
}
|
||||
|
||||
//public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> CityIds = null, List<string> Where = null, List<OrderBy> Order_by = null)
|
||||
//{
|
||||
// List<PowerStation> powerStations = new List<PowerStation>();
|
||||
// return powerStations;
|
||||
//}
|
||||
public List<PowerStation> GetMyPowerStations(MyUser myUser, List<int> CityIds = null, List<string> wheres = null, List<OrderBy> orderBy = null)
|
||||
{
|
||||
List<PowerStation> powerStations = new List<PowerStation>();
|
||||
return powerStations;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user