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.
366 lines
16 KiB
366 lines
16 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Data.Linq;
|
|
using System.Data;
|
|
|
|
namespace ICSSoft.Frame.Common
|
|
{
|
|
public static class TranOutClass
|
|
{
|
|
static DataTable dt ;
|
|
|
|
//物料拣料表
|
|
public static DataTable TranOut(string putCode)
|
|
{
|
|
dt = new DataTable();
|
|
dt.Columns.Add("MoCode", typeof(string));
|
|
dt.Columns.Add("LineNo", typeof(string));
|
|
dt.Columns.Add("BInvCode", typeof(string));
|
|
dt.Columns.Add("BInvName", typeof(string));
|
|
dt.Columns.Add("LotNo", typeof(string));
|
|
dt.Columns.Add("WHCode", typeof(string));
|
|
dt.Columns.Add("BinCode", typeof(string));
|
|
dt.Columns.Add("INVUOM", typeof(string));
|
|
dt.Columns.Add("QTY", typeof(string));
|
|
dt.Columns.Add("LotQty", typeof(string));
|
|
dt.Columns.Add("User", typeof(string));
|
|
dt.Columns.Add("Approver", typeof(string));
|
|
FramDataContext context = new FramDataContext(AppConfig.AppConnectString);
|
|
List<TranOut> trans = new List<TranOut>();
|
|
|
|
//查询工单子件信息
|
|
var puts = context.ICSPACKINGINPUT.Where(a => a.TransferNO == putCode).OrderBy(a=>a.TransferLineNo).ToList();
|
|
if (puts == null) return dt;
|
|
|
|
//循环查询库存子件信息
|
|
foreach (ICSPACKINGINPUT put in puts)
|
|
{
|
|
decimal qty = 0;
|
|
List<ICSWareHouseLotInfo> whs = new List<ICSWareHouseLotInfo>();
|
|
var putitem = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == put.MOBITEMCODE);
|
|
if (putitem.INVTYPE != "原材料" && putitem.INVTYPE != "采购原料")
|
|
{
|
|
whs = context.ICSWareHouseLotInfo.Where(a => a.INVCode == put.MOBITEMCODE && a.WHCode != "02" && a.LotQty > 0).OrderBy(b => b.MTIME).ToList();
|
|
}
|
|
else
|
|
{
|
|
whs = (from a in context.ICSWareHouseLotInfo
|
|
join b in context.ICSITEMLot on a.INVCode equals b.MCODE
|
|
where a.INVCode == put.MOBITEMCODE && a.WHCode != "02" && a.LotQty > 0
|
|
orderby b.PRODUCTDATE ascending
|
|
select a).ToList();
|
|
}
|
|
foreach (ICSWareHouseLotInfo info in whs)
|
|
{
|
|
if (qty >= put.MOBITEMQTY)//如果数量满足了,继续下一个子件
|
|
{
|
|
break;
|
|
}
|
|
TranOut tran = new TranOut();
|
|
tran.MoCode = putCode;
|
|
tran.LineNo = put.TransferLineNo;
|
|
tran.BInvCode = put.MOBITEMCODE;
|
|
var item = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == put.MOBITEMCODE);
|
|
if (item == null) throw new Exception("料品:" + put.MOBITEMCODE + "不存在!");
|
|
tran.BInvName = item.INVNAME;
|
|
tran.LotNo = info.LotNO;
|
|
tran.WHCode = info.WHCode;
|
|
tran.BinCode = info.BinCode;
|
|
tran.INVUOM = item.INVUOM;
|
|
tran.LotQty = info.LotQty.ToString();
|
|
tran.User = put.MUSERName;
|
|
tran.Approver = put.Approver;
|
|
//应领数量
|
|
if (put.MOBITEMQTY - qty < info.LotQty)
|
|
{
|
|
tran.QTY = (put.MOBITEMQTY - qty).ToString();
|
|
}
|
|
else
|
|
tran.QTY = info.LotQty.ToString();
|
|
trans.Add(tran);
|
|
qty += decimal.Parse(tran.QTY);
|
|
}
|
|
}
|
|
#region
|
|
if (puts.Count == 0)
|
|
{
|
|
var pouts = context.ICSTransferNO.Where(a => a.TransferNO == putCode).OrderBy(a => a.TransLine).ToList();
|
|
if (pouts == null) return dt;
|
|
foreach (ICSTransferNO pout in pouts)
|
|
{
|
|
decimal qty = 0;
|
|
List<ICSWareHouseLotInfo> whs = new List<ICSWareHouseLotInfo>();
|
|
var putitem = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == pout.INVCode);
|
|
#region
|
|
if (putitem.INVTYPE != "原材料" && putitem.INVTYPE != "采购原料")
|
|
{
|
|
whs = context.ICSWareHouseLotInfo.Where(a => a.INVCode == pout.INVCode && a.WHCode != "02" && a.LotQty > 0).OrderBy(b => b.MTIME).ToList();
|
|
}
|
|
else
|
|
{
|
|
whs = (from a in context.ICSWareHouseLotInfo
|
|
join b in context.ICSITEMLot on a.INVCode equals b.MCODE
|
|
where a.INVCode == pout.INVCode && a.WHCode != "02" && a.LotQty > 0
|
|
orderby b.PRODUCTDATE ascending
|
|
select a).ToList();
|
|
}
|
|
#endregion
|
|
foreach (ICSWareHouseLotInfo info in whs)
|
|
{
|
|
if (qty >= pout.QTY)//如果数量满足了,继续下一个子件
|
|
{
|
|
break;
|
|
}
|
|
TranOut tran = new TranOut();
|
|
tran.MoCode = putCode;
|
|
tran.LineNo = pout.TransLine;
|
|
tran.BInvCode = pout.INVCode;
|
|
var item = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == pout.INVCode);
|
|
if (item == null) throw new Exception("料品:" + pout.INVCode + "不存在!");
|
|
tran.BInvName = item.INVNAME;
|
|
tran.LotNo = info.LotNO;
|
|
tran.WHCode = info.WHCode;
|
|
tran.BinCode = info.BinCode;
|
|
tran.INVUOM = item.INVUOM;
|
|
tran.LotQty = info.LotQty.ToString();
|
|
tran.User = pout.MUSERName;
|
|
tran.Approver = pout.Approver;
|
|
//应领数量
|
|
if (pout.QTY - qty < info.LotQty)
|
|
{
|
|
tran.QTY = (pout.QTY - qty).ToString();
|
|
}
|
|
else
|
|
tran.QTY = info.LotQty.ToString();
|
|
trans.Add(tran);
|
|
qty += decimal.Parse(tran.QTY);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
//输出到表
|
|
foreach (TranOut tran in trans)
|
|
{
|
|
DataRow dw = dt.NewRow();
|
|
dw["MoCode"] = tran.MoCode;
|
|
dw["LineNo"] = tran.LineNo;
|
|
dw["BInvCode"] = tran.BInvCode;
|
|
dw["BInvName"] = tran.BInvName;
|
|
dw["LotNo"] = tran.LotNo;
|
|
dw["WHCode"] = tran.WHCode;
|
|
dw["BinCode"] = tran.BinCode;
|
|
dw["INVUOM"] = tran.INVUOM;
|
|
dw["QTY"] = tran.QTY;
|
|
dw["LotQty"] = tran.QTY;
|
|
dw["User"] = tran.User;
|
|
dw["Approver"] = tran.Approver;
|
|
dt.Rows.Add(dw);
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
//销售拣货表
|
|
public static DataTable TranOutX(string putCode)
|
|
{
|
|
dt = new DataTable();
|
|
dt.Columns.Add("MoCode", typeof(string));
|
|
dt.Columns.Add("LineNo", typeof(string));
|
|
dt.Columns.Add("BInvCode", typeof(string));
|
|
dt.Columns.Add("BInvName", typeof(string));
|
|
dt.Columns.Add("LotNo", typeof(string));
|
|
dt.Columns.Add("WHCode", typeof(string));
|
|
dt.Columns.Add("BinCode", typeof(string));
|
|
dt.Columns.Add("INVUOM", typeof(string));
|
|
dt.Columns.Add("QTY", typeof(string));
|
|
dt.Columns.Add("LotQty", typeof(string));
|
|
dt.Columns.Add("User", typeof(string));
|
|
|
|
FramDataContext context = new FramDataContext(AppConfig.AppConnectString);
|
|
List<TranOut> trans = new List<TranOut>();
|
|
|
|
//查询工单子件信息
|
|
var puts = context.ICSSODispatch.Where(a =>a.DispatchCode == putCode).OrderBy(a => a.DispatchRow).ToList();
|
|
if (puts == null) return dt;
|
|
|
|
//循环查询库存子件信息
|
|
foreach (ICSSODispatch put in puts)
|
|
{
|
|
decimal qty = 0;
|
|
|
|
List<ICSWareHouseLotInfo> whs=new List<ICSWareHouseLotInfo>() ;
|
|
var putitem=context.ICSINVENTORY.SingleOrDefault(a=>a.INVCODE==put.InvCode);
|
|
if (putitem.INVTYPE != "原材料" && putitem.INVTYPE != "采购原料")
|
|
{
|
|
whs = context.ICSWareHouseLotInfo.Where(a => a.INVCode == put.InvCode && a.WHCode != "02" && a.LotQty > 0).OrderBy(b => b.MTIME).ToList();
|
|
}
|
|
else
|
|
{
|
|
whs = (from a in context.ICSWareHouseLotInfo
|
|
join b in context.ICSITEMLot on a.INVCode equals b.MCODE
|
|
where a.INVCode == put.InvCode && a.WHCode != "02" && a.LotQty > 0
|
|
orderby b.PRODUCTDATE ascending
|
|
select a).ToList();
|
|
}
|
|
foreach (ICSWareHouseLotInfo info in whs)
|
|
{
|
|
if (qty >= put.Quantity)//如果数量满足了,继续下一个子件
|
|
{
|
|
break;
|
|
}
|
|
TranOut tran = new TranOut();
|
|
tran.MoCode = putCode;
|
|
tran.LineNo = put.DispatchRow;
|
|
tran.BInvCode = put.InvCode;
|
|
var item = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == put.InvCode);
|
|
if (item == null) throw new Exception("料品:" + put.InvCode + "不存在!");
|
|
tran.BInvName = item.INVNAME;
|
|
tran.LotNo = info.LotNO;
|
|
tran.WHCode = info.WHCode;
|
|
tran.BinCode = info.BinCode;
|
|
tran.INVUOM = item.INVUOM;
|
|
tran.LotQty = info.LotQty.ToString();
|
|
tran.User = put.MUSERName;
|
|
//应领数量
|
|
if (put.Quantity - qty < info.LotQty)
|
|
{
|
|
tran.QTY = (put.Quantity - qty).ToString();
|
|
}
|
|
else
|
|
tran.QTY = info.LotQty.ToString();
|
|
trans.Add(tran);
|
|
|
|
qty += decimal.Parse(tran.QTY);
|
|
}
|
|
}
|
|
//输出到表
|
|
foreach (TranOut tran in trans)
|
|
{
|
|
DataRow dw = dt.NewRow();
|
|
dw["MoCode"] = tran.MoCode;
|
|
dw["LineNo"] = tran.LineNo;
|
|
dw["BInvCode"] = tran.BInvCode;
|
|
dw["BInvName"] = tran.BInvName;
|
|
dw["LotNo"] = tran.LotNo;
|
|
dw["WHCode"] = tran.WHCode;
|
|
dw["BinCode"] = tran.BinCode;
|
|
dw["INVUOM"] = tran.INVUOM;
|
|
dw["QTY"] = tran.QTY;
|
|
dw["LotQty"] = tran.QTY;
|
|
dw["User"] = tran.User;
|
|
dt.Rows.Add(dw);
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
public static DataTable TranBack(string putCode)
|
|
{
|
|
dt = new DataTable();
|
|
dt.Columns.Add("MoCode", typeof(string));
|
|
dt.Columns.Add("LineNo", typeof(string));
|
|
dt.Columns.Add("BInvCode", typeof(string));
|
|
dt.Columns.Add("BInvName", typeof(string));
|
|
dt.Columns.Add("LotNo", typeof(string));
|
|
dt.Columns.Add("WHCode", typeof(string));
|
|
dt.Columns.Add("BinCode", typeof(string));
|
|
dt.Columns.Add("INVUOM", typeof(string));
|
|
dt.Columns.Add("QTY", typeof(string));
|
|
dt.Columns.Add("LotQty", typeof(string));
|
|
dt.Columns.Add("User", typeof(string));
|
|
dt.Columns.Add("Approver", typeof(string));
|
|
FramDataContext context = new FramDataContext(AppConfig.AppConnectString);
|
|
List<TranOut> trans = new List<TranOut>();
|
|
|
|
var pouts = context.ICSTransferNOBack.Where(a => a.TransferNO == putCode).OrderBy(a => a.TransLine).ToList();
|
|
if (pouts == null) return dt;
|
|
foreach (ICSTransferNOBack pout in pouts)
|
|
{
|
|
decimal qty = 0;
|
|
List<ICSWareHouseLotInfo> whs = new List<ICSWareHouseLotInfo>();
|
|
var putitem = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == pout.INVCode);
|
|
#region
|
|
if (putitem.INVTYPE != "原材料" && putitem.INVTYPE != "采购原料")
|
|
{
|
|
whs = context.ICSWareHouseLotInfo.Where(a => a.INVCode == pout.INVCode && a.WHCode != "02" && a.LotQty > 0).OrderBy(b => b.MTIME).ToList();
|
|
}
|
|
else
|
|
{
|
|
whs = (from a in context.ICSWareHouseLotInfo
|
|
join b in context.ICSITEMLot on a.INVCode equals b.MCODE
|
|
where a.INVCode == pout.INVCode && a.WHCode != "02" && a.LotQty > 0
|
|
orderby b.PRODUCTDATE ascending
|
|
select a).ToList();
|
|
}
|
|
#endregion
|
|
foreach (ICSWareHouseLotInfo info in whs)
|
|
{
|
|
if (qty >= pout.QTY)//如果数量满足了,继续下一个子件
|
|
{
|
|
break;
|
|
}
|
|
TranOut tran = new TranOut();
|
|
tran.MoCode = putCode;
|
|
tran.LineNo = pout.TransLine;
|
|
tran.BInvCode = pout.INVCode;
|
|
var item = context.ICSINVENTORY.SingleOrDefault(a => a.INVCODE == pout.INVCode);
|
|
if (item == null) throw new Exception("料品:" + pout.INVCode + "不存在!");
|
|
tran.BInvName = item.INVNAME;
|
|
tran.LotNo = info.LotNO;
|
|
tran.WHCode = info.WHCode;
|
|
tran.BinCode = info.BinCode;
|
|
tran.INVUOM = item.INVUOM;
|
|
tran.LotQty = info.LotQty.ToString();
|
|
tran.User = pout.MUSERName;
|
|
tran.Approver = pout.Approver;
|
|
//应领数量
|
|
if (pout.QTY - qty < info.LotQty)
|
|
{
|
|
tran.QTY = (pout.QTY - qty).ToString();
|
|
}
|
|
else
|
|
tran.QTY = info.LotQty.ToString();
|
|
trans.Add(tran);
|
|
qty += decimal.Parse(tran.QTY);
|
|
}
|
|
}
|
|
//输出到表
|
|
foreach (TranOut tran in trans)
|
|
{
|
|
DataRow dw = dt.NewRow();
|
|
dw["MoCode"] = tran.MoCode;
|
|
dw["LineNo"] = tran.LineNo;
|
|
dw["BInvCode"] = tran.BInvCode;
|
|
dw["BInvName"] = tran.BInvName;
|
|
dw["LotNo"] = tran.LotNo;
|
|
dw["WHCode"] = tran.WHCode;
|
|
dw["BinCode"] = tran.BinCode;
|
|
dw["INVUOM"] = tran.INVUOM;
|
|
dw["QTY"] = tran.QTY;
|
|
dw["LotQty"] = tran.QTY;
|
|
dw["User"] = tran.User;
|
|
dw["Approver"] = tran.Approver;
|
|
dt.Rows.Add(dw);
|
|
}
|
|
return dt;
|
|
}
|
|
}
|
|
|
|
public class TranOut
|
|
{
|
|
public string MoCode { get; set; }
|
|
public string LineNo { get; set; }
|
|
public string BInvCode { get; set; }
|
|
public string BInvName { get; set; }
|
|
public string LotNo { get; set; }
|
|
public string WHCode { get; set; }
|
|
public string BinCode { get; set; }
|
|
public string INVUOM { get; set; }
|
|
public string QTY { get; set; }
|
|
public string LotQty { get; set; }
|
|
public string User { get; set; }
|
|
public string Approver { get; set; }
|
|
}
|
|
}
|