You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
5.4 KiB
110 lines
5.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Warehouse.DAL.StockIn;
|
|
using Warehouse.Models.whMS;
|
|
using Z.EntityFramework.Plus;
|
|
using Warehouse.DAL.ReturnStock;
|
|
|
|
namespace Warehouse.DAL.DelContainer
|
|
{
|
|
public class DelContainerMSDal
|
|
{
|
|
//托盘信息
|
|
public IEnumerable<dynamic> QueryStockInfoByPallet(string Pallet)
|
|
{
|
|
using (var context = new whMSModel())
|
|
{
|
|
var res = from a in context.tcontainerpallets
|
|
from b in context.tstockinlogs.Where(b => b.palletno == a.palletno).DefaultIfEmpty()
|
|
from c in context.tstoragelocations.Where(c => c.id == b.storagelocationid).DefaultIfEmpty()
|
|
where (b.id == context.tstockinlogs.Where(d => d.palletno == a.palletno).Max(d => d.id) && a.palletno == Pallet)
|
|
select new { container = a.containerno, a.palletno, palletstatus = a.status, location = c.locationname ?? "", stockintime = (DateTime?)b.createtime, stockinstatus = b.status };
|
|
if (res != null)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
//柜号信息
|
|
public IEnumerable<dynamic> QueryStockInfoByContianer(string Container)
|
|
{
|
|
using (var context = new whMSModel())
|
|
{
|
|
var res = from a in context.tcontainerpallets
|
|
from b in context.tstockinlogs.Where(b => b.palletno == a.palletno).DefaultIfEmpty()
|
|
from c in context.tstoragelocations.Where(c => c.id == b.storagelocationid).DefaultIfEmpty()
|
|
where (b.id == context.tstockinlogs.Where(d => d.palletno == a.palletno).Max(d => d.id) && a.containerno == Container)
|
|
select new { container = a.containerno, a.palletno, palletstatus = a.status, location = c.locationname ?? "", stockintime = (DateTime?)b.createtime, stockinstatus = b.status };
|
|
|
|
if (res != null)
|
|
{
|
|
return res.ToList();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
//删除托盘
|
|
public void DelPallet(string Pallet)
|
|
{
|
|
using (var context = new whMSModel())
|
|
{
|
|
//删除托盘
|
|
var ContainerPallets= context.tcontainerpallets.Where(a => a.palletno == Pallet);
|
|
var Container = ContainerPallets.FirstOrDefault().containerno;
|
|
ContainerPallets.Delete();
|
|
//柜号变成doing状态
|
|
//var res=context.tcontainers.Join(context.tcontainerpallets, tcontainer => tcontainer.containerno, tcontainerpallet => tcontainerpallet.containerno, (tcontainer, tcontainerpallet) => new { ContainerStatus = tcontainer.state,PalletStatus=tcontainerpallet.status }).ToList();
|
|
//res.ForEach(x => { x.ContainerStatus = "doing
|
|
context.tcontainers.Where(a => a.containerno == Container).Update(x => new tcontainer { state = "doing" });
|
|
context.tcontainerpallets.Where(a => a.containerno == Container).Update(x => new tcontainerpallet { status = "doing" });
|
|
//柜号是否删除
|
|
context.tcontainers.Where(a => context.tcontainerpallets.Any(b => b.containerno == Container)==false && a.containerno==Container).Delete();
|
|
//托盘入库记录状态设置为退库-1
|
|
var PalletStockInLog = context.tstockinlogs.Where(a => a.status==2 && a.id == context.tstockinlogs.Where(b => b.palletno == Pallet).Max(c => c.id));
|
|
if (PalletStockInLog.FirstOrDefault() != null)
|
|
{
|
|
int LocationId = PalletStockInLog.FirstOrDefault().storagelocationid;
|
|
PalletStockInLog.Update(x => new tstockinlog() { status = -1 });
|
|
//退库日志
|
|
List<treturnstocklog> ListReturnStockLog = new List<treturnstocklog>();
|
|
ListReturnStockLog.Add(new treturnstocklog
|
|
{
|
|
pallet = Pallet,
|
|
storagelocationid = LocationId,
|
|
createtime = System.DateTime.Now,
|
|
createuser = System.Web.HttpContext.Current.Request.Cookies["userid"].Value
|
|
});
|
|
new ReturnStockMSDal().ReturnStockLog(ListReturnStockLog);
|
|
//更新MES托盘状态为封箱状态1
|
|
new StockInMSDal().UpdatePalletStatus(1, Pallet);
|
|
//库位条件是否清空
|
|
context.tlocationconditions.Where(a => context.tstockinlogs.Where(b => b.status == 2 && b.storagelocationid == LocationId).Any() == false && a.storagelocationid == LocationId).Update(x => new tlocationcondition { status = "N" });
|
|
}
|
|
//删柜记录 add by xue lei on 2019-9-18
|
|
context.tdelcontainerlogs.Add(new tdelcontainerlog { container = Container, pallet = Pallet, createtime = System.DateTime.Now, createuser = System.Web.HttpContext.Current.Request.Cookies["userid"].Value });
|
|
context.SaveChanges();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|