材料出库单
This commit is contained in:
64
NX.ERP.U8/Mom/MomOrderDetailDAL.cs
Normal file
64
NX.ERP.U8/Mom/MomOrderDetailDAL.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dapper;
|
||||
namespace NX.ERP.U8.Mom
|
||||
{
|
||||
public class MomOrderDetailDAL
|
||||
{
|
||||
public IEnumerable<Model.MOM.MomOrder> GetList(string strWhere = "", object param = null)
|
||||
{
|
||||
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
|
||||
{
|
||||
string strSQL = @"select a.MoId as id,a.moCode as Code,a.*,b.MoDId as id ,b.*,c.AllocateId as id ,c.* from mom_order as a
|
||||
left join mom_orderdetail as b on a.MoId=b.MoId
|
||||
left join mom_moallocate as c on b.MoDId=c.MoDId
|
||||
";
|
||||
if (!string.IsNullOrEmpty(strWhere))
|
||||
{
|
||||
strSQL += $" where {strWhere} ";
|
||||
}
|
||||
var lookupDetail = new Dictionary<int, Model.MOM.MomDetail>();
|
||||
var lookupOrder = new Dictionary<int, Model.MOM.MomOrder>();
|
||||
|
||||
// return conn.Query<Model.Purchase.Arrival>(strSQL,null);
|
||||
var list = conn.Query<Model.MOM.MomOrder, Model.MOM.MomDetail, Model.MOM.MoAllocate, Model.MOM.MomOrder>(strSQL, (Order, OrderDetail, MoAllocate) =>
|
||||
{
|
||||
if (!lookupOrder.TryGetValue(Order.Id, out var _order))
|
||||
{
|
||||
lookupOrder.Add(Order.Id, Order);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Order = _order;
|
||||
}
|
||||
|
||||
if (!lookupDetail.TryGetValue(OrderDetail.Id, out var momDetail))
|
||||
{
|
||||
lookupDetail.Add(OrderDetail.Id, OrderDetail);
|
||||
Order.momDetails.Add(OrderDetail);
|
||||
}
|
||||
else
|
||||
{
|
||||
OrderDetail = momDetail;
|
||||
}
|
||||
Order.moAllocates.Add(MoAllocate);
|
||||
OrderDetail.moAllocates.Add(MoAllocate);
|
||||
return Order;
|
||||
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||
return lookupOrder.Values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Model.MOM.MomOrder GetModel(string Code)
|
||||
{
|
||||
return this.GetList("a.moCode=@Code", new { Code }).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user