ningshuxia
9 天以前 b24092beff11a75a3fec392dcedd475b407ebdc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
namespace IStation.Service
{
    /// <summary>
    /// 
    /// </summary>
    public partial class AnalysisParameter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, List<Model.AnalysisParameter>> GetDictCache()
        {
            return AnalysisParameterCacheHelper.GetSet(() =>
            {
                var dal = DALCreateHelper.CreateDAL<IStation.DAL.IAnalysisParameter>();
                var entity_dict = dal.GetAllTable();
                if (entity_dict == null || !entity_dict.Any())
                {
                    return new Dictionary<string, List<Model.AnalysisParameter>>();
                }
 
                var model_dict = new Dictionary<string, List<Model.AnalysisParameter>>();
                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);
        }
 
 
        /// <summary>
        /// 查询
        /// </summary>
        public List<Model.AnalysisParameter> GetList(string run_flag)
        {
            var dal = DALCreateHelper.CreateDAL<IStation.DAL.IAnalysisParameter>();
            var tableName = dal.GetTableName(run_flag);
            var dict = GetDictCache();
            if (!dict.ContainsKey(tableName))
                return default;
 
            return dict[tableName]?.OrderBy(x => x.Power).ToList();
        }
 
        /// <summary>
        /// 查询
        /// </summary>
        public List<Model.AnalysisParameter> GetList(string run_flag, double pressure_diff)
        {
            var dal = DALCreateHelper.CreateDAL<IStation.DAL.IAnalysisParameter>();
            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;
        }
 
        /// <summary>
        /// 查询
        /// </summary>
        public List<Model.AnalysisParameter> GetList(string run_flag, double min_hz, double max_hz, double pressure_diff)
        {
            var dal = DALCreateHelper.CreateDAL<IStation.DAL.IAnalysisParameter>();
            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;
        }
 
 
        /// <summary>
        /// 查询
        /// </summary>
        public Model.AnalysisParameter GetMinPressureDiff(string run_flag)
        {
            var dal = DALCreateHelper.CreateDAL<IStation.DAL.IAnalysisParameter>();
            var tableName = dal.GetTableName(run_flag);
            var dict = GetDictCache();
            if (!dict.ContainsKey(tableName))
                return default;
            return dict[tableName]?.OrderBy(x => x.PressureDiff).FirstOrDefault();
        }
         
    }
}