77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Unity;
|
|
using System.Linq;
|
|
using Cowain.Bake.BLL;
|
|
using Cowain.Bake.Model;
|
|
using Cowain.Bake.Common.Core;
|
|
using Cowain.Bake.Model.Entity;
|
|
|
|
namespace Cowain.Bake.BLL
|
|
{
|
|
public class BatteryNGService : ServiceBase
|
|
{
|
|
public BatteryNGService(IUnityContainer unityContainer) : base(unityContainer)
|
|
{
|
|
|
|
}
|
|
|
|
public List<TBatteryNG> GetAllNGCell( )
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
return Context.Set<TBatteryNG>().ToList().OrderByDescending(x=>x.Id).Take(200).ToList();
|
|
}
|
|
}
|
|
|
|
public TBatteryNG GetCurrentNGBattery(string batteryCode) //存在多次复投
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
return (from n in Context.Set<TBatteryNG>()
|
|
join b in Context.Set<TBatteryInfo>() on n.BatteryCode equals b.BatteryCode
|
|
where b.BatteryCode == batteryCode
|
|
orderby b.Id descending
|
|
select n).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public List<TBatteryNG> QueryNGCell(DateTime startTime, DateTime endTime, string batteryCode)
|
|
{
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
if(string.IsNullOrEmpty(batteryCode))
|
|
{
|
|
return (from n in Context.Set<TBatteryNG>()
|
|
where n.CreateTime > startTime && n.CreateTime < endTime
|
|
select n).ToList();
|
|
}
|
|
else
|
|
{
|
|
return (from n in Context.Set<TBatteryNG>()
|
|
where n.CreateTime > startTime && n.CreateTime < endTime && n.BatteryCode == batteryCode
|
|
select n).ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int Insert(string palletCode, string batteryCode, string desc)
|
|
{
|
|
TBatteryNG NG = new TBatteryNG()
|
|
{
|
|
PalletCode = palletCode,
|
|
BatteryCode = batteryCode,
|
|
CreateTime = DateTime.Now,
|
|
Desc = desc,
|
|
};
|
|
|
|
using (var Context = new BakingEntities())
|
|
{
|
|
Context.Set<TBatteryNG>().Add(NG);
|
|
return Context.SaveChanges();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|