76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using Cowain.Preheat.Model;
|
|
using Cowain.Preheat.Model.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Unity;
|
|
|
|
namespace Cowain.Preheat.BLL
|
|
{
|
|
public class BatteryNGService : ServiceBase
|
|
{
|
|
public BatteryNGService(IUnityContainer unityContainer) : base(unityContainer)
|
|
{
|
|
|
|
}
|
|
|
|
public List<TBatteryNG> GetAllNGCell( )
|
|
{
|
|
using (var Context = new PreheatEntities())
|
|
{
|
|
return Context.Set<TBatteryNG>().ToList();
|
|
}
|
|
}
|
|
|
|
public TBatteryNG GetCurrentNGBattery(string batteryCode) //存在多次复投
|
|
{
|
|
using (var Context = new PreheatEntities())
|
|
{
|
|
return Context.Set<TBatteryNG>().Where(x=> x.BatteryCode.Contains(batteryCode)).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public List<TBatteryNG> QueryNGCell(DateTime startTime, DateTime endTime, string batteryCode)
|
|
{
|
|
using (var Context = new PreheatEntities())
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(batteryCode))
|
|
{
|
|
return Context.Set<TBatteryNG>().Where(x => x.CreateTime > startTime && x.CreateTime < endTime).ToList();
|
|
}
|
|
else
|
|
{
|
|
return Context.Set<TBatteryNG>().Where(x => x.BatteryCode.Contains(batteryCode)).ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Insert(string reason , string batteryCode, string desc)
|
|
{
|
|
TBatteryNG NG = new TBatteryNG()
|
|
{
|
|
Reason = reason,
|
|
BatteryCode = batteryCode,
|
|
CreateTime = DateTime.Now,
|
|
Desc = desc,
|
|
};
|
|
|
|
using (var Context = new PreheatEntities())
|
|
{
|
|
Context.Set<TBatteryNG>().Add(NG);
|
|
return Context.SaveChanges();
|
|
}
|
|
}
|
|
|
|
//public List<TBatteryNG> GetBatteryInfo(int[] batteryIds)
|
|
//{
|
|
// using (var Context = new PreheatEntities())
|
|
// {
|
|
// return Context.Set<TBatteryNG>().Where(x => batteryIds.Contains(x.BatteryId)).ToList();
|
|
// }
|
|
//}
|
|
}
|
|
}
|