|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace HighWayIot.Repository.service.Impl
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BaseContentServiceImpl : IContentService
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly Lazy<BaseContentServiceImpl> lazy = new Lazy<BaseContentServiceImpl>(() => new BaseContentServiceImpl());
|
|
|
|
|
|
|
|
|
|
|
|
public static BaseContentServiceImpl Instance => lazy.Value;
|
|
|
|
|
|
|
|
|
|
|
|
private LogHelper log = LogHelper.Instance;
|
|
|
|
|
|
Repository<RFIDContent> _repository => new Repository<RFIDContent>("sqlite");
|
|
|
|
|
|
|
|
|
|
|
|
public List<RFIDContent> GetContentInfos(string lineNo)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
List<RFIDContent> deviceInfo = _repository.GetList(x => x.LineNo == lineNo);
|
|
|
|
|
|
return deviceInfo;
|
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息获取异常", ex);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<RFIDContent> GetContentInfos()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
List<RFIDContent> deviceInfo = _repository.GetList();
|
|
|
|
|
|
return deviceInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息获取异常", ex);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<RFIDContent> Get200Infos(string lineNo)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime UsefulTime = DateTime.Now - TimeSpan.FromDays(1);
|
|
|
|
|
|
List<RFIDContent> deviceInfo = _repository.GetList(x => x.LineNo == lineNo && x.LogTime >= UsefulTime).OrderByDescending(x => x.ID).Take(200).ToList();
|
|
|
|
|
|
return deviceInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息获取异常", ex);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<RFIDContent> Get200Infos()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime UsefulTime = DateTime.Now - TimeSpan.FromDays(1);
|
|
|
|
|
|
List<RFIDContent> deviceInfo = _repository.GetList(x => x.LogTime >= UsefulTime).OrderByDescending(x => x.ID).Take(200).ToList();
|
|
|
|
|
|
return deviceInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息获取异常", ex);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddContentInfo(RFIDContent content)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
_repository.Insert(content);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息插入异常", ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool DelBeforeMonthContent()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime time = DateTime.Now - TimeSpan.FromDays(90);
|
|
|
|
|
|
_repository.AsDeleteable().Where(x => x.LogTime <= time).ExecuteCommand();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error("RFID内容信息删除异常", ex);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|