From 521864dc19d2ed47fccd99957dac9332ec0552f5 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 22 Jan 2021 11:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=9F=E4=BA=A7=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=BF=A1=E6=81=AF=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.BLL/Model/MomOrder.cs | 16 ++ NX.ERP.BLL/NX.ERP.BLL.csproj | 1 + NX.ERP.BLL/Store/SotreIn.cs | 5 + NX.ERP.BLL/Store/SotreOut.cs | 4 +- NX.ERP.Model/NX.ERP.Model.csproj | 1 + NX.ERP.Model/Request/MomOrder.cs | 16 ++ NX.ERP.Model/Request/ProductStoreIn.cs | 3 +- NX.ERP.Model/Response/MOM/MoAllocate.cs | 13 +- NX.ERP.Model/Response/MOM/MomDetail.cs | 29 +++- NX.ERP.Model/Response/MOM/MomOrder.cs | 15 +- NX.ERP.U8/Mom/MomOrderDAL.cs | 143 ++++++++++++++++-- NX.ERP.U8/Store/MaterielStoreOutDAL.cs | 12 +- NX.ERP.U8/Store/ProductInDAL.cs | 8 +- NX.ERP.U8/VT.cs | 4 - .../Controllers/MOM/MomOrderController.cs | 18 +++ 15 files changed, 249 insertions(+), 39 deletions(-) create mode 100644 NX.ERP.BLL/Model/MomOrder.cs create mode 100644 NX.ERP.Model/Request/MomOrder.cs diff --git a/NX.ERP.BLL/Model/MomOrder.cs b/NX.ERP.BLL/Model/MomOrder.cs new file mode 100644 index 0000000..f0a348b --- /dev/null +++ b/NX.ERP.BLL/Model/MomOrder.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.BLL.Model +{ + public class MomOrder + { + + public string product_order_no { get; set; } + public string product_code { get; set; } + + + } +} diff --git a/NX.ERP.BLL/NX.ERP.BLL.csproj b/NX.ERP.BLL/NX.ERP.BLL.csproj index af74560..f3c79a9 100644 --- a/NX.ERP.BLL/NX.ERP.BLL.csproj +++ b/NX.ERP.BLL/NX.ERP.BLL.csproj @@ -42,6 +42,7 @@ + diff --git a/NX.ERP.BLL/Store/SotreIn.cs b/NX.ERP.BLL/Store/SotreIn.cs index 6a3b77b..315da40 100644 --- a/NX.ERP.BLL/Store/SotreIn.cs +++ b/NX.ERP.BLL/Store/SotreIn.cs @@ -18,6 +18,7 @@ namespace NX.ERP.BLL.Store var dal = new NX.ERP.U8.Store.PuStoreInDAL(); ID = dal.AddVocher(new ERP.Model.Request.PuStoreIn() { + Code = "190700000050", Date = inbound.InboundDate, Source = inbound.SourceName, SourceCode = inbound.SourceNo, @@ -44,6 +45,9 @@ namespace NX.ERP.BLL.Store var dal = new NX.ERP.U8.Store.ProductInDAL(); ID = dal.AddVoucher(new ERP.Model.Request.ProductStoreIn() { + Code= "19100002", + + Date = inbound.InboundDate, Source = inbound.SourceName, SourceCode = inbound.SourceNo, @@ -68,6 +72,7 @@ namespace NX.ERP.BLL.Store var dal = new NX.ERP.U8.Store.OtherStoreInDAL(); ID = dal.AddVocher(new ERP.Model.Request.OtherStoreInOut() { + Code= "19100028", Date = inbound.InboundDate, WhCode = inbound.WarehouseCode, Maker = inbound.Maker, diff --git a/NX.ERP.BLL/Store/SotreOut.cs b/NX.ERP.BLL/Store/SotreOut.cs index 29f17c0..5125d1f 100644 --- a/NX.ERP.BLL/Store/SotreOut.cs +++ b/NX.ERP.BLL/Store/SotreOut.cs @@ -17,6 +17,7 @@ namespace NX.ERP.BLL.Store var dal = new U8.Store.MaterielStoreOutDAL(); ID = dal.AddVocher(new ERP.Model.Request.MaterielStoreOut() { + Code= "191000000007", Date = outBound.OutboundDate, Maker = outBound.Maker, Source = outBound.SourceName, @@ -43,6 +44,7 @@ namespace NX.ERP.BLL.Store var dal = new U8.Store.SaleOutDAL(); ID = dal.AddVoucher(new ERP.Model.Request.SaleStoreOut() { + Code = "191000000003", Date = outBound.OutboundDate, WhCode = outBound.Maker, Source = outBound.SourceName, @@ -68,7 +70,7 @@ namespace NX.ERP.BLL.Store { Date = outBound.OutboundDate, WhCode = outBound.Maker, - + Code= "19100032", Maker = outBound.Maker, details = outBound.OutboundDtlLst.ConvertAll(m => { diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 73b6b82..6e23d62 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -67,6 +67,7 @@ + diff --git a/NX.ERP.Model/Request/MomOrder.cs b/NX.ERP.Model/Request/MomOrder.cs new file mode 100644 index 0000000..8debc25 --- /dev/null +++ b/NX.ERP.Model/Request/MomOrder.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Request +{ + public class MomOrder: BaseModel + { + + public string ProductOrderNo { get; set; } + public string ProductCode { get; set; } + + + } +} diff --git a/NX.ERP.Model/Request/ProductStoreIn.cs b/NX.ERP.Model/Request/ProductStoreIn.cs index 8394fc0..10694e0 100644 --- a/NX.ERP.Model/Request/ProductStoreIn.cs +++ b/NX.ERP.Model/Request/ProductStoreIn.cs @@ -5,8 +5,9 @@ using System.Text; namespace NX.ERP.Model.Request { - public class ProductStoreIn + public class ProductStoreIn: BaseModel { + public string Code { get; set; } public string Maker { get; set; } public string Deptcode { get; set; } public DateTime Date { get; set; } diff --git a/NX.ERP.Model/Response/MOM/MoAllocate.cs b/NX.ERP.Model/Response/MOM/MoAllocate.cs index b3c3fce..d82f6d6 100644 --- a/NX.ERP.Model/Response/MOM/MoAllocate.cs +++ b/NX.ERP.Model/Response/MOM/MoAllocate.cs @@ -5,16 +5,21 @@ using System.Text; namespace NX.ERP.Model.MOM { - public class MoAllocate + public class MoAllocate:BaseModel { private int id; private string invCode; private double qty; private int modid; - public int Id { get => id; set => id = value; } - public string InvCode { get => invCode; set => invCode = value; } + public int ProductOrderDtlId { get; set; } + + public int AllocateId { get => id; set => id = value; } + public string MaterialCode { get => invCode; set => invCode = value; } public double Qty { get => qty; set => qty = value; } - public int ModId { get => modid; set => modid = value; } + public int ProductOrderId { get => modid; set => modid = value; } + //public string UnitCode { get; set; } + + public double Issqty { get; set; } } } diff --git a/NX.ERP.Model/Response/MOM/MomDetail.cs b/NX.ERP.Model/Response/MOM/MomDetail.cs index c4a43c0..5c89aec 100644 --- a/NX.ERP.Model/Response/MOM/MomDetail.cs +++ b/NX.ERP.Model/Response/MOM/MomDetail.cs @@ -6,15 +6,34 @@ using System.Text; namespace NX.ERP.Model.MOM { - public class MomDetail + + public class MomDetail: BaseModel { private int id; private double qty; private int modid; - [JsonIgnore] - public ICollection moAllocates { get; set; } = new List(); - public int Id { get => id; set => id = value; } + + public ICollection ProductAllocateOrderLst { get; set; } = new List(); + public int ProductOrderDtlId { get => id; set => id = value; } + public int ProductOrderId { get => modid; set => modid = value; } + + public string ProductOrderNo { get; set; } + + + public DateTime ProductOrderDate { get; set; } + + public string ProductCode { get; set; } + + + //public string BatchNo { get; set; } + + + public double Qty { get => qty; set => qty = value; } - public int Modid { get => modid; set => modid = value; } + + + + + } } diff --git a/NX.ERP.Model/Response/MOM/MomOrder.cs b/NX.ERP.Model/Response/MOM/MomOrder.cs index 1e50ff6..67a1de7 100644 --- a/NX.ERP.Model/Response/MOM/MomOrder.cs +++ b/NX.ERP.Model/Response/MOM/MomOrder.cs @@ -5,18 +5,23 @@ using System.Text; using Newtonsoft.Json; namespace NX.ERP.Model.MOM { - public class MomOrder + public class MomOrder: BaseModel { private int id; private string code; - public DateTime Date { get; set; } + //public DateTime Date { get; set; } /// /// /// - public ICollection Details { get; set; } = new List(); - public int Id { get => id; set => id = value; } - public string Code { get => code; set => code = value; } + public ICollection ProductDtlLst { get; set; } = new List(); + + public int ProductOrderId { get => id; set => id = value; } + public string ProductOrderNo { get => code; set => code = value; } + + public DateTime ProductDate { get; set; } + public string PreparedBy { get; set; } + [Newtonsoft.Json.JsonIgnore] public ICollection Allocates { get; set; } = new List(); diff --git a/NX.ERP.U8/Mom/MomOrderDAL.cs b/NX.ERP.U8/Mom/MomOrderDAL.cs index 2bfda29..e3929a6 100644 --- a/NX.ERP.U8/Mom/MomOrderDAL.cs +++ b/NX.ERP.U8/Mom/MomOrderDAL.cs @@ -7,13 +7,18 @@ namespace NX.ERP.U8.Mom { public class MomOrderDAL { + public IEnumerable 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(strSQL,null); var list = conn.Query(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 QueryOrders(NX.ERP.Model.Request.MomOrder Params) + { + if (Params == null) + { + return this.GetOrders(); + } + List where = new List(); + + 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 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(); + var lookupOrder = new Dictionary(); + // return conn.Query(strSQL,null); + var list = conn.Query(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 QueryDetails(NX.ERP.Model.Request.MomOrder Params) + { + if (Params == null) + { + return this.GetDetails(); + } + List where = new List(); + + 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 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(); + using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net)) + { + + + conn.Query(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(); diff --git a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs index 0fa8232..fde88a0 100644 --- a/NX.ERP.U8/Store/MaterielStoreOutDAL.cs +++ b/NX.ERP.U8/Store/MaterielStoreOutDAL.cs @@ -59,8 +59,8 @@ namespace NX.ERP.U8.Store { throw new Exception($"未知订单:{storeOut.SourceCode}"); } - headXml.setAttribute("iproorderid", Order.Id); - headXml.setAttribute("cmpocode", Order.Code); + headXml.setAttribute("iproorderid", Order.ProductOrderId); + headXml.setAttribute("cmpocode", Order.ProductOrderNo); headXml.setAttribute("cpspcode", ""); headXml.setAttribute("crdname", "材料出库"); headXml.setAttribute("cdepcode", "24"); @@ -69,20 +69,20 @@ namespace NX.ERP.U8.Store for (var n = 0; n < storeOut.Details.Count(); n++) { var detail = storeOut.Details[n]; - var alllocate = Order.Allocates.FirstOrDefault(m => { return m.Id == detail.SorceDetailId; }); + var alllocate = Order.Allocates.FirstOrDefault(m => { return m.AllocateId == detail.SorceDetailId; }); if (alllocate == null) { throw new Exception($"未知订单明细行:{detail.SorceDetailId}"); } - if (alllocate.InvCode != detail.InvCode) + if (alllocate.MaterialCode != detail.InvCode) { throw new Exception($"订单明细存货编号与出库存货编号不符:{detail.InvCode}"); } - var moomDetail = Order.Details.FirstOrDefault(m => { return m.Id == alllocate.ModId; }); + var moomDetail = Order.ProductDtlLst.FirstOrDefault(m => { return m.ProductOrderDtlId == alllocate.ProductOrderId; }); bodyXml = domBody.createElement("z:row"); bodyXml.setAttribute("autoid", n); bodyXml.setAttribute("cinvcode", detail.InvCode); @@ -97,7 +97,7 @@ namespace NX.ERP.U8.Store bodyXml.setAttribute("id", storeOut.Id); bodyXml.setAttribute("impoids", detail.SorceDetailId); - bodyXml.setAttribute("cmocode", Order.Code); + bodyXml.setAttribute("cmocode", Order.ProductOrderNo); bodyXml.setAttribute("invcode", "904008");//产品编码 bodyXml.setAttribute("cwhcode", storeOut.Whcode); bodyXml.setAttribute("imoseq", 1); diff --git a/NX.ERP.U8/Store/ProductInDAL.cs b/NX.ERP.U8/Store/ProductInDAL.cs index f3e4282..476c8f7 100644 --- a/NX.ERP.U8/Store/ProductInDAL.cs +++ b/NX.ERP.U8/Store/ProductInDAL.cs @@ -33,7 +33,7 @@ namespace NX.ERP.U8.Store headXml.setAttribute("bomfirst", "0"); headXml.setAttribute("biafirst", "0"); headXml.setAttribute("brdflag", 1); - headXml.setAttribute("ccode", "11"); + headXml.setAttribute("ccode", storeIn.Code); headXml.setAttribute("ddate", storeIn.Date); headXml.setAttribute("cmaker", storeIn.Maker); headXml.setAttribute("vt_id", new VT().GetDefaltVTID("0411")); @@ -63,9 +63,9 @@ namespace NX.ERP.U8.Store bodyXml.setAttribute("editprop", "A"); bodyXml.setAttribute("cbatch", detail.Batch); bodyXml.setAttribute("cposition", detail.Position); - var momOrderDetail = momOrder.Details.First(m => { return m.Id == detail.SourceDetailId; }); - headXml.setAttribute("cmpocode", momOrder.Code); - headXml.setAttribute("iproorderid", momOrder.Id); + var momOrderDetail = momOrder.ProductDtlLst.First(m => { return m.ProductOrderDtlId == detail.SourceDetailId; }); + headXml.setAttribute("cmpocode", momOrder.ProductOrderNo); + headXml.setAttribute("iproorderid", momOrder.ProductOrderId); domBody.selectSingleNode("//rs:data").appendChild(bodyXml); } } diff --git a/NX.ERP.U8/VT.cs b/NX.ERP.U8/VT.cs index bf8359e..b48f8b1 100644 --- a/NX.ERP.U8/VT.cs +++ b/NX.ERP.U8/VT.cs @@ -13,11 +13,7 @@ namespace NX.ERP.U8 { var strSql= "select DEF_ID from vouchers_base where CardNumber=@CardNumber"; return conn.ExecuteScalar(strSql, new { CardNumber }, null, 100, System.Data.CommandType.Text); - - } - - } } } diff --git a/NX.ERP.WebAPi/Controllers/MOM/MomOrderController.cs b/NX.ERP.WebAPi/Controllers/MOM/MomOrderController.cs index 8b8829a..7ea9589 100644 --- a/NX.ERP.WebAPi/Controllers/MOM/MomOrderController.cs +++ b/NX.ERP.WebAPi/Controllers/MOM/MomOrderController.cs @@ -34,5 +34,23 @@ namespace NX.ERP.WebAPi.Controllers.MOM return customerDAL.GetModel(Code); } + [Route("api/ProductOrder/QueryOrders")] + [HttpPost] + public IEnumerable OrderQuery(NX.ERP.Model.Request.MomOrder momOrder) + { + var customerDAL = new NX.ERP.U8.Mom.MomOrderDAL(); + return customerDAL.QueryOrders(momOrder); + } + + [Route("api/ProductOrder/QueryDetails")] + [HttpPost] + public IEnumerable OrderDetails(NX.ERP.Model.Request.MomOrder momOrder) + { + var customerDAL = new NX.ERP.U8.Mom.MomOrderDAL(); + return customerDAL.QueryDetails(momOrder); + } + + + } } \ No newline at end of file