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);
|
}
|
}
|
}
|