namespace IStation.Service
{
///
///
///
public partial class AnalysisParameter
{
///
///
///
///
public static Dictionary> GetDictCache()
{
return AnalysisParameterCacheHelper.GetSet(() =>
{
var dal = DALCreateHelper.CreateDAL();
var entity_dict = dal.GetAllTable();
if (entity_dict == null || !entity_dict.Any())
{
return new Dictionary>();
}
var model_dict = new Dictionary>();
for (int i = 0; i < entity_dict.Count; i++)
{
var entity_item = entity_dict.ElementAt(i);
model_dict[entity_item.Key] = Entity2Models(entity_item.Value);
}
return model_dict;
}, ConfigHelper.CacheKeepTime, ConfigHelper.CacheRandomTime);
}
///
/// 查询
///
public List GetList(string run_flag)
{
var dal = DALCreateHelper.CreateDAL();
var tableName = dal.GetTableName(run_flag);
var dict = GetDictCache();
if (!dict.ContainsKey(tableName))
return default;
return dict[tableName]?.OrderBy(x => x.Power).ToList();
}
///
/// 查询
///
public List GetList(string run_flag, double pressure_diff)
{
var dal = DALCreateHelper.CreateDAL();
var tableName = dal.GetTableName(run_flag);
var dict = GetDictCache();
if (!dict.ContainsKey(tableName))
return default;
for (int i = 0; i < 3; i++)
{
pressure_diff += i * 0.1;
var list = dict[tableName]?
.Where(x => x.PressureDiff == pressure_diff)
.OrderBy(x => x.Power)
.ToList();
if (list != null && list.Any())
{
return list;
}
}
return null;
}
///
/// 查询
///
public List GetList(string run_flag, double min_hz, double max_hz, double pressure_diff)
{
var dal = DALCreateHelper.CreateDAL();
var tableName = dal.GetTableName(run_flag);
var dict = GetDictCache();
if (!dict.ContainsKey(tableName))
return default;
for (int i = 0; i < 3; i++)
{
pressure_diff += i * 0.1;
var list = dict[tableName]?
.Where(x => x.Hz >= min_hz && x.Hz <= max_hz && x.PressureDiff == pressure_diff)
.OrderBy(x => x.Power)
.ToList();
if (list == null || !list.Any())
{
}
if (list != null && list.Any())
{
return list;
}
}
return null;
}
///
/// 查询
///
public Model.AnalysisParameter GetMinPressureDiff(string run_flag)
{
var dal = DALCreateHelper.CreateDAL();
var tableName = dal.GetTableName(run_flag);
var dict = GetDictCache();
if (!dict.ContainsKey(tableName))
return default;
return dict[tableName]?.OrderBy(x => x.PressureDiff).FirstOrDefault();
}
}
}