ningshuxia
2025-04-03 4917fb959e2befec07a693e72d7010c09494ec7c
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
 
namespace IStation.DAL
{
    /// <summary>
    /// 
    /// </summary>    
    public class CurveAnalyzePacket
    {
        #region Path
 
        /// <summary>
        /// 查询文件路径
        /// </summary> 
        public string GetRootFolder(long monitorDataSourcesId)
        {
            var monitorDataSourcesFolder = FileHelper.GetMonitorDataSourcesFolder(SettingsD.Project.ID, monitorDataSourcesId);
            if (!Directory.Exists(monitorDataSourcesFolder))
                Directory.CreateDirectory(monitorDataSourcesFolder);
            var monitorDataSetFolder = Path.Combine(monitorDataSourcesFolder, SettingsD.File.CurveAnalyzeDataFolder);
            if (!Directory.Exists(monitorDataSetFolder))
                Directory.CreateDirectory(monitorDataSetFolder);
            return monitorDataSetFolder;
        }
 
        #endregion
 
        #region Get
 
        /// <summary>
        /// 查询全部
        /// </summary> 
        public List<Model.CurveAnalyzePacket> GetAll(long monitorDataSourcesId)
        {
            var path = GetRootFolder(monitorDataSourcesId);
            var all = FileIdHelper<Model.CurveAnalyzePacket>.GetAll(path);
            var models = all?.ToList();
            return models;
        }
 
        /// <summary>
        /// 根据 Id 查询
        /// </summary> 
        public Model.CurveAnalyzePacket GetByID(long monitorDataSourcesId, long Id)
        {
            if (Id < 1)
                return default;
            var all = GetAll(monitorDataSourcesId);
            var models = all?.ToList();
            return models?.Find(t => t.ID == Id);
        }
 
        /// <summary>
        /// 根据 Id 集合查询
        /// </summary> 
        public List<Model.CurveAnalyzePacket> GetByIds(long monitorDataSourcesId, IEnumerable<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return default;
            var all = GetAll(monitorDataSourcesId);
            var models = all?.Where(x => Ids.Contains(x.ID)).ToList();
            return models;
        }
 
        /// <summary>
        /// 根据  EquipmentID 查询
        /// </summary> 
        public List<Model.CurveAnalyzePacket> GetByEquipmentID(long monitorDataSourcesId, long stationId, long equipmentId)
        {
            if (stationId < 1)
                return default;
            if (equipmentId < 1)
                return default;
            var all = GetAll(monitorDataSourcesId);
            var models = all?.Where(x => x.StationID == stationId && x.EquipmentID == equipmentId).ToList();
            return models;
        }
 
        /// <summary>
        /// 根据  CurveAnalyzeID 查询
        /// </summary> 
        public List<Model.CurveAnalyzePacket> GetByCurveAnalyzeID(long monitorDataSourcesId, long curveAnalyzeId)
        {
            if (curveAnalyzeId < 1)
                return default;
            var all = GetAll(monitorDataSourcesId);
            var models = all?.Where(x => x.CurveAnalyzeID == curveAnalyzeId).ToList();
            return models;
        }
 
        /// <summary>
        /// 根据  CurveAnalyzeIds 查询
        /// </summary> 
        public List<Model.CurveAnalyzePacket> GetByCurveAnalyzeIds(long monitorDataSourcesId, List<long> curveAnalyzeIds)
        {
            if (curveAnalyzeIds == null || curveAnalyzeIds.Count < 1)
                return default;
            var all = GetAll(monitorDataSourcesId);
            var models = all?.Where(x => curveAnalyzeIds.Contains(x.CurveAnalyzeID)).ToList();
            return models;
        }
        #endregion
 
        #region Insert
 
        /// <summary>
        /// 插入
        /// </summary>
        public long Insert(long monitorDataSourcesId, Model.CurveAnalyzePacket rhs)
        {
            if (rhs == null)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            return FileIdHelper<Model.CurveAnalyzePacket>.Insert(path, rhs);
        }
 
        /// <summary>
        /// 批量插入
        /// </summary>
        public bool Inserts(long monitorDataSourcesId, IEnumerable<Model.CurveAnalyzePacket> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            return FileIdHelper<Model.CurveAnalyzePacket>.Inserts(path, list);
        }
 
        /// <summary>
        /// 插入并返回
        /// </summary>
        public Model.CurveAnalyzePacket InsertR(long monitorDataSourcesId, Model.CurveAnalyzePacket rhs)
        {
            if (rhs == null)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var entities = FileIdHelper<Model.CurveAnalyzePacket>.InsertR(path, rhs);
            return entities;
        }
 
        /// <summary>
        /// 批量插入并返回
        /// </summary>
        public List<Model.CurveAnalyzePacket> InsertRs(long monitorDataSourcesId, IEnumerable<Model.CurveAnalyzePacket> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var models = FileIdHelper<Model.CurveAnalyzePacket>.InsertRs(path, list);
            return models;
        }
 
        #endregion
 
        #region Update
 
        /// <summary>
        /// 更新
        /// </summary>
        public bool Update(long monitorDataSourcesId, Model.CurveAnalyzePacket rhs)
        {
            if (rhs == null)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            return FileIdHelper<Model.CurveAnalyzePacket>.Update(path, rhs);
        }
 
        /// <summary>
        /// 批量更新
        /// </summary>
        public bool Updates(long monitorDataSourcesId, IEnumerable<Model.CurveAnalyzePacket> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            return FileIdHelper<Model.CurveAnalyzePacket>.Updates(path, list);
        }
 
        #endregion
 
        #region Delete 
 
        /// <summary>
        /// 根据 Id删除
        /// </summary>
        public bool DeleteByID(long monitorDataSourcesId, long Id)
        {
            if (Id < 0)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByID(path, Id);
            return bol;
        }
 
 
        /// <summary>
        /// 根据 Id删除
        /// </summary>
        public bool DeleteByCurveAnalyzeID(long monitorDataSourcesId, long curveAnalyzeId)
        {
            if (curveAnalyzeId < 0)
                return default;
            var list = GetByCurveAnalyzeID(monitorDataSourcesId, curveAnalyzeId);
            if (list == null || !list.Any())
                return true;
            var ids = list.Select(x => x.ID).ToList();
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByIds(path, ids);
            return bol;
        }
 
        /// <summary>
        /// 根据  CurveAnalyzeIds 删除
        /// </summary>
        public bool DeleteByCurveAnalyzeIds(long monitorDataSourcesId, List<long> curveAnalyzeIds)
        {
            if (curveAnalyzeIds == null || curveAnalyzeIds.Count < 0)
                return default;
            var list = GetByCurveAnalyzeIds(monitorDataSourcesId, curveAnalyzeIds);
            if (list == null || !list.Any())
                return true;
            var ids = list.Select(x => x.ID).ToList();
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByIds(path, ids);
            return bol;
        }
 
 
        /// <summary>
        /// 根据 Id集合删除
        /// </summary>
        public bool DeleteByIds(long monitorDataSourcesId, IEnumerable<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByIds(path, Ids);
            return bol;
        }
 
        /// <summary>
        /// 删除
        /// </summary>
        public bool Delete(long monitorDataSourcesId, Model.CurveAnalyzePacket rhs)
        {
            if (rhs == null)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByID(path, rhs.ID);
            return bol;
        }
 
        /// <summary>
        /// 批量删除
        /// </summary> 
        public bool Deletes(long monitorDataSourcesId, IEnumerable<Model.CurveAnalyzePacket> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var path = GetRootFolder(monitorDataSourcesId);
            var Ids = list.Select(x => x.ID).ToList();
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteByIds(path, Ids);
            return bol;
        }
 
        /// <summary>
        /// 删除全部
        /// </summary>
        public bool DeleteAll(long monitorDataSourcesId)
        {
            var path = GetRootFolder(monitorDataSourcesId);
            var bol = FileIdHelper<Model.CurveAnalyzePacket>.DeleteAll(path);
            return bol;
        }
 
        #endregion 
 
        #region Exist
 
        /// <summary>
        /// 是否存在文件
        /// </summary>
        public bool IsExist(long monitorDataSourcesId)
        {
            var path = GetRootFolder(monitorDataSourcesId);
            return FileIdHelper<Model.CurveAnalyzePacket>.IsExist(path);
        }
 
        /// <summary>
        /// 是否存在对象
        /// </summary>
        public bool ExistByCurveAnalyzeID(long monitorDataSourcesId, long curveAnalyzeId)
        {
            if (curveAnalyzeId < 1)
                return default;
            var list = GetAll(monitorDataSourcesId);
            if (list == null || list.Count < 1)
                return default;
            return list.Exists(x => x.CurveAnalyzeID == curveAnalyzeId);
        }
 
 
        /// <summary>
        /// 是否存在对象
        /// </summary>
        public bool Exist(long monitorDataSourcesId, long id)
        {
            if (id < 1)
                return default;
            var list = GetAll(monitorDataSourcesId);
            if (list == null || list.Count < 1)
                return default;
            return list.Exists(x => x.ID == id);
        }
 
        #endregion
 
    }
}