tangxu
2022-10-08 a36faf95b4bee06626f33a82448f93e364b29ec5
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IStation.Untity;
 
namespace IStation.Server
{
    /// <summary>
    /// 
    /// </summary>
    public class MonitorRealRecordHelper
    {
        internal class Result<T>
        { 
            public int Code { get; set; }
            public string Message { get; set; } 
            public T Data { get; set; }
        }
 
        private static readonly string _token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOjEsIkxvZ2luTmFtZSI6Inl3YWRtaW4iLCJMb2dpblB3ZCI6ImFkbWluIiwiQ29ycElEIjoxLCJJc0FkbWluIjp0cnVlLCJpYXQiOjE2NTM3MDkyMjksIm5iZiI6MTY1MzcwOTIyOSwiZXhwIjoxNjUzNzk1NjI5LCJpc3MiOiJpc3RhdGlvbiIsImF1ZCI6ImlzdGF0aW9uIn0.ldShpA_pNRpPSxkADrBpXhDk8Lj0jffPgulwB5xJu2E";
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CorpID"></param>
        /// <param name="MonitorPointIds"></param>
        /// <returns></returns>
        public static List<Model.MonitorRealRecordPure> GetLastNormalRealRecord(long CorpID,List<long> MonitorPointIds)
        {
            if (MonitorPointIds == null || MonitorPointIds.Count < 1)
                return default;
            if (Settings.Eta.Debug.IsDebug)
            {
                var url = "http://101.133.133.173:9019/Run/MonitorRealRecord/GetLastRecordByMonitorPointIds@Debug";
                url = $"{url}?CorpID={CorpID}&MonitorPointIds={LongListHelper.ToString(MonitorPointIds)}";
                string responsetext = string.Empty;
                using (var httpClient = new HttpClient())
                using (var request = new HttpRequestMessage(HttpMethod.Get, url))
                {
                    request.Headers.Add("KeepAlive", "false");
                    request.Headers.Add("Authorization", "Bearer "+ _token);
                    var response = httpClient.SendAsync(request).Result;
                    response.EnsureSuccessStatusCode();
                    responsetext = response.Content.ReadAsStringAsync().Result;
                }
                var list = JsonHelper.Json2Object< Result <List<Model.MonitorRealRecordPure>>>(responsetext);
                if (list == null)
                    return null;
                return list.Data;
            }
            return new RedisCache.MonitorRecordCacheHelper().GetLastNormalRealRecord(CorpID,MonitorPointIds);
        }
    }
}