You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.6 KiB
C#
81 lines
2.6 KiB
C#
using HighWayIot.Repository.domain;
|
|
using HighWayIot.Repository.service.Impl;
|
|
using HighWayIot.TouchSocket;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace RFIDSocket
|
|
{
|
|
public class DataAnalysis
|
|
{
|
|
private static readonly Lazy<DataAnalysis> lazy = new Lazy<DataAnalysis>(() => new DataAnalysis());
|
|
|
|
public static DataAnalysis Instance => lazy.Value;
|
|
|
|
public List<RFIDContent> rFIDContents = new List<RFIDContent>();
|
|
public List<RFIDContent> NearContents = new List<RFIDContent>();
|
|
public List<RFIDHeartbeat> rFIDHeartbeats = new List<RFIDHeartbeat>();
|
|
public List<RFIDHeartbeat> HeartbeatsState = new List<RFIDHeartbeat>();
|
|
public List<RFIDState> rFIDStates = new List<RFIDState>();
|
|
public List<RFIDState> AlarmState = new List<RFIDState>();
|
|
BaseContentServiceImpl baseContentServiceImpl = new BaseContentServiceImpl();
|
|
BaseHeartbeatServiceImpl baseHeartbeatServiceImpl = new BaseHeartbeatServiceImpl();
|
|
BaseStateServiceImpl baseStateServiceImpl = new BaseStateServiceImpl();
|
|
|
|
public void GetData()
|
|
{
|
|
|
|
rFIDContents = baseContentServiceImpl.GetContentInfos();
|
|
|
|
NearContents = rFIDContents.Reverse<RFIDContent>().Take(200).ToList();
|
|
|
|
rFIDStates = baseStateServiceImpl.GetStateInfos();
|
|
|
|
var StateGroup = rFIDStates.GroupBy(x => x.IP);
|
|
|
|
AlarmState.Clear();
|
|
|
|
foreach (var a in StateGroup)
|
|
{
|
|
var b = a.LastOrDefault();
|
|
if (b.LogTime > rFIDContents.Where(x => x.IP == b.IP).LastOrDefault().LogTime)
|
|
{
|
|
AlarmState.Add(b);
|
|
}
|
|
}
|
|
|
|
rFIDHeartbeats = baseHeartbeatServiceImpl.GetHeartbeatInfos();
|
|
|
|
var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.IP);
|
|
|
|
HeartbeatsState.Clear();
|
|
|
|
foreach (var a in HeartBeatGroup)
|
|
{
|
|
var b = a.LastOrDefault();
|
|
if (DateTime.Now - b.BeatTime < TimeSpan.FromSeconds(10))
|
|
{
|
|
HeartbeatsState.Add(b);
|
|
}
|
|
}
|
|
}
|
|
|
|
private string SecondToTime(int t)
|
|
{
|
|
int m = t / 60;
|
|
int s = t % 60;
|
|
if (m == 0)
|
|
{
|
|
return "00 分 " + s.ToString("00") + " 秒";
|
|
}
|
|
return m.ToString("00") + " 分 " + s.ToString("00") + " 秒";
|
|
}
|
|
}
|
|
}
|