tangxu
2023-04-21 473084031d410d95db66e81f4d1761f9a2d1b8e5
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IStation.RedisCache;
 
namespace IStation.Service
{
    /// <summary>
    /// 实时监测记录
    /// </summary>
    public partial class MonitorRecord
    {
        #region 最近一条记录
 
        /// <summary>
        /// 获取最近一条记录
        /// </summary>
        public Model.MonitorRecord GetLastRecord(long monitorPointId)
        {
            var redisHelper = new MonitorRecordCacheHelper();
            var record = redisHelper.GetLastRecord(monitorPointId);
            return record;
        }
 
        /// <summary>
        /// 获取最近一条记录
        /// </summary>
        public List<Model.MonitorRecord> GetLastRecord(IEnumerable<long> monitorPointIds)
        {
            if (monitorPointIds == null || monitorPointIds.Count() < 1)
                return default;
            var redisHelper = new MonitorRecordCacheHelper();
            var record = redisHelper.GetLastRecord(monitorPointIds);
            return record;
        }
 
        #endregion
 
 
 
 
        #region Insert
 
 
 
 
        /// <summary>
        /// 插入最近多条记录
        /// </summary>
        public bool InsertsLastRecord(List<Model.MonitorRecord> list)
        {
            if (list == null || list.Count() < 1)
                return default;
            var queueHelper = new RabbitMqQueueHelper();
            var bol = queueHelper.Push(ConfigHelper.StoreQueueName, list);
            if (bol)
            {
                var redisHelper = new MonitorRecordCacheHelper();
                redisHelper.SetLastRecord(list, out string info);
            }
            return bol;
        }
 
        #endregion
 
 
    }
}