旧版报表、仓库
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.
 
 
 
 
 

86 lines
4.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Warehouse.DAL.LCL;
using Warehouse.Models.whMS;
using Z.EntityFramework.Plus;
namespace Warehouse.DAL.PalletChange
{
public class PalletChangeMSDal
{
public List<dynamic> QueryLot(string Pallet)
{
using (var context = new whMSModel())
{
var Res = context.tcontainerpallets.Where(b => b.palletno == Pallet).ToList();
if (Res.Count == 0) return null;
return new LCLMSDal().QueryPalletinfoAndStockInfo(Res.FirstOrDefault().containerno);
}
}
public string Change(string Old, string New)
{
using (var context = new whMSModel())
{
var OldPalletRes = from a in context.tcontainerpallets
from b in context.tstockinlogs.Where(b => b.palletno == a.palletno).DefaultIfEmpty()
where (a.palletno==Old && b.id == context.tstockinlogs.Where(c => c.palletno == Old).Max(a => a.id))
select new { a.containerno, b.status };
var OldPallet = OldPalletRes.FirstOrDefault();
if (OldPallet == null)
{
return "托盘:" + Old + "没有拼柜";
}
//入库的柜号也能替换 modify by xue lei on 2019-11-11
if (OldPallet.status != null && Convert.ToInt16(OldPallet.status) == 2)
{
return "托盘:" + Old + "已经入库";
}
if (OldPallet.status != null && Convert.ToInt16(OldPallet.status) == 3)
{
return "托盘:" + Old + "已经出货";
}
if (context.tcontainerpallets.Any(a => a.palletno == New) == true)
{
return "托盘:" + New + "已经拼柜";
}
var NewPallet = context.tstockinlogs.Where(a => a.id == context.tstockinlogs.Where(c => c.palletno == New).Max(b => b.id)).FirstOrDefault();
if (NewPallet != null)
{
if (NewPallet.status == 2)
return "托盘:" + New + "已经入库";
if (NewPallet.status==3)
return "托盘:" + New + "已经出货";
}
//检查新旧条件是否一致
var OldCondiction = context.tcontainers.Where(a => a.containerno == context.tcontainerpallets.Where(b => b.palletno == Old).FirstOrDefault().containerno).FirstOrDefault();
var NewCondiction = new LCLMSDal().QueryPalletAndProduct(New).FirstOrDefault();
if (NewCondiction == null) return "新托盘" + New + "不存在";
if ((OldCondiction.powergrade != null) && OldCondiction.powergrade != NewCondiction.powergrade.ToString())
return "旧托盘与新托盘的柜号功率不一致";
if ((OldCondiction.igrade != null) && OldCondiction.igrade != NewCondiction.igrade.ToString())
return "旧托盘与新托盘的柜号电流不一致";
if ((OldCondiction.color != null) && OldCondiction.color != NewCondiction.color.ToString())
return "旧托盘与新托盘的柜号颜色不一致";
if ((OldCondiction.finalgrade != null) && OldCondiction.finalgrade != NewCondiction.finalgrade.ToString())
return "旧托盘与新托盘的柜号最终等级不一致";
if ((OldCondiction.cellqty != null) && OldCondiction.cellqty != NewCondiction.cellqty.ToString())
return "旧托盘与新托盘的柜号电池数量不一致";
if ((OldCondiction.bartype != null) && OldCondiction.bartype != NewCondiction.bartype.ToString())
return "旧托盘与新托盘的柜号晶体类型不一致";
if ((OldCondiction.modulespec != null) && OldCondiction.modulespec != NewCondiction.modulespec.ToString())
return "旧托盘与新托盘的柜号组件规格不一致";
context.tcontainerpallets.Where(a => a.palletno == Old).Update(x => new tcontainerpallet { palletno = New });
return "success";
}
}
}
}