增加生产订单信息输出
This commit is contained in:
@@ -7,13 +7,18 @@ namespace NX.ERP.U8.Mom
|
||||
{
|
||||
public class MomOrderDAL
|
||||
{
|
||||
|
||||
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.CreateDate as date,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";
|
||||
string strSQL = @"select
|
||||
a.MoId as ProductOrderId,a.moCode as ProductOrderNo,a.CreateDate as ProductDate,a.CreateUser as PreparedBy,
|
||||
b.MoId as id ,b.MoDId as ProductOrderDtlId,b.MoId as ProductOrderId,a.MoCode as ProductOrderNo,a.CreateDate as ProductOrderDate,b.InvCode as ProductCode,b.Qty as Qty,
|
||||
c.AllocateId as id ,c.AllocateId as AllocateId,c.MoDId as ProductOrderDtlId,c.InvCode as MaterialCode,b.MoId as ProductOrderId, c.IssQty as IssQty,c.Qty
|
||||
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} ";
|
||||
@@ -23,9 +28,9 @@ namespace NX.ERP.U8.Mom
|
||||
// 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))
|
||||
if (!lookupOrder.TryGetValue(Order.ProductOrderId, out var _order))
|
||||
{
|
||||
lookupOrder.Add(Order.Id, Order);
|
||||
lookupOrder.Add(Order.ProductOrderId, Order);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -33,17 +38,17 @@ namespace NX.ERP.U8.Mom
|
||||
Order = _order;
|
||||
}
|
||||
|
||||
if (!lookupDetail.TryGetValue(OrderDetail.Id, out var momDetail))
|
||||
if (!lookupDetail.TryGetValue(OrderDetail.ProductOrderDtlId, out var momDetail))
|
||||
{
|
||||
lookupDetail.Add(OrderDetail.Id, OrderDetail);
|
||||
Order.Details.Add(OrderDetail);
|
||||
lookupDetail.Add(OrderDetail.ProductOrderDtlId, OrderDetail);
|
||||
Order.ProductDtlLst.Add(OrderDetail);
|
||||
}
|
||||
else
|
||||
{
|
||||
OrderDetail = momDetail;
|
||||
}
|
||||
Order.Allocates.Add(MoAllocate);
|
||||
OrderDetail.moAllocates.Add(MoAllocate);
|
||||
OrderDetail.ProductAllocateOrderLst.Add(MoAllocate);
|
||||
return Order;
|
||||
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||
return lookupOrder.Values;
|
||||
@@ -52,6 +57,126 @@ namespace NX.ERP.U8.Mom
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Model.MOM.MomOrder> QueryOrders(NX.ERP.Model.Request.MomOrder Params)
|
||||
{
|
||||
if (Params == null)
|
||||
{
|
||||
return this.GetOrders();
|
||||
}
|
||||
List<string> where = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(Params.ProductCode))
|
||||
{
|
||||
where.Add(" b.InvCode like @ ProductCode");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Params.ProductOrderNo))
|
||||
{
|
||||
where.Add(" a.moCode like @ProductOrderNo ");
|
||||
}
|
||||
return this.GetOrders(string.Join(" and ", where.ToArray()), new
|
||||
{
|
||||
ProductCode = $"%{Params.ProductCode}%",
|
||||
ProductOrderNo = $"{Params.ProductOrderNo}"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Model.MOM.MomOrder> GetOrders(string strWhere = "", object Param = null)
|
||||
{
|
||||
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
|
||||
{
|
||||
string strSQL = @"select
|
||||
a.MoId as ProductOrderId,a.moCode as ProductOrderNo,a.CreateDate as ProductDate,a.CreateUser as PreparedBy,
|
||||
b.MoId as id ,b.MoDId as ProductOrderDtlId,b.MoId as ProductOrderId,a.MoCode as ProductOrderNo,a.CreateDate as ProductOrderDate,b.InvCode as ProductCode,b.Qty as Qty
|
||||
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.MomOrder>(strSQL, (Order, OrderDetail) =>
|
||||
{
|
||||
if (!lookupOrder.TryGetValue(Order.ProductOrderId, out var _order))
|
||||
{
|
||||
lookupOrder.Add(Order.ProductOrderId, Order);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Order = _order;
|
||||
}
|
||||
Order.ProductDtlLst.Add(OrderDetail);
|
||||
return Order;
|
||||
}, Param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||
return lookupOrder.Values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Model.MOM.MomDetail> QueryDetails(NX.ERP.Model.Request.MomOrder Params)
|
||||
{
|
||||
if (Params == null)
|
||||
{
|
||||
return this.GetDetails();
|
||||
}
|
||||
List<string> where = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(Params.ProductCode))
|
||||
{
|
||||
where.Add(" b.InvCode like @ ProductCode");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Params.ProductOrderNo))
|
||||
{
|
||||
where.Add(" a.moCode like @ProductOrderNo ");
|
||||
}
|
||||
return this.GetDetails(string.Join(" and ", where.ToArray()), new
|
||||
{
|
||||
ProductCode = $"%{Params.ProductCode}%",
|
||||
ProductOrderNo = $"{Params.ProductOrderNo}"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Model.MOM.MomDetail> GetDetails(string strWhere = "", object Param = null)
|
||||
{
|
||||
var strSql = @"select
|
||||
b.MoId as id ,b.MoDId as ProductOrderDtlId,b.MoId as ProductOrderId,a.MoCode as ProductOrderNo,a.CreateDate as ProductOrderDate,b.InvCode as ProductCode,b.Qty as Qty,
|
||||
c.AllocateId as id ,c.AllocateId as AllocateId,c.MoDId as ProductOrderDtlId,c.InvCode as MaterialCode,b.MoId as ProductOrderId, c.IssQty as IssQty,c.Qty
|
||||
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 ";
|
||||
var lookup = new Dictionary<int, Model.MOM.MomDetail>();
|
||||
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
|
||||
{
|
||||
|
||||
|
||||
conn.Query<Model.MOM.MomDetail, Model.MOM.MoAllocate, Model.MOM.MomDetail>(strSql, (OrderDetail, MoAllocate) =>
|
||||
{
|
||||
if (!lookup.TryGetValue(OrderDetail.ProductOrderDtlId, out var _OrderDetail))
|
||||
{
|
||||
lookup.Add(OrderDetail.ProductOrderDtlId, OrderDetail);
|
||||
}
|
||||
else
|
||||
{
|
||||
OrderDetail = _OrderDetail;
|
||||
}
|
||||
OrderDetail.ProductAllocateOrderLst.Add(MoAllocate);
|
||||
|
||||
return OrderDetail;
|
||||
}, Param, null, true, "id", 100, System.Data.CommandType.Text);
|
||||
|
||||
}
|
||||
return lookup.Values;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Model.MOM.MomOrder GetModel(string Code)
|
||||
{
|
||||
return this.GetList("a.moCode=@Code", new { Code }).FirstOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user