From 24a228b7f12e2c840f084ee3b483889e99c780db Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期五, 26 九月 2025 14:51:33 +0800 Subject: [PATCH] 111 --- MES.Service/service/BasicData/ProductionOrderManager.cs | 66 ++++++++++++++++++++++++++++---- 1 files changed, 57 insertions(+), 9 deletions(-) diff --git a/MES.Service/service/BasicData/ProductionOrderManager.cs b/MES.Service/service/BasicData/ProductionOrderManager.cs index 28b494d..19fcc5e 100644 --- a/MES.Service/service/BasicData/ProductionOrderManager.cs +++ b/MES.Service/service/BasicData/ProductionOrderManager.cs @@ -21,7 +21,8 @@ public bool Save(ErpWYOrder wyOrder) { var erpProductionOrderDto = wyOrder.OrderDto; - var mesRohIn = ConvertErpToProductionOrder(erpProductionOrderDto, wyOrder.Items[0].FBILLNO); + var mesRohIn = ConvertErpToProductionOrder(erpProductionOrderDto, + wyOrder.Items[0].FBILLNO); var mesRohInDatas = ConvertErpToProductionOrderSub(wyOrder.Items); @@ -77,7 +78,9 @@ if (mesRohInDatas.Count > 0) db.Deleteable<ProductionOrderSub>() - .Where(s => s.ErpProductionEntryCode == mesRohIn.ErpProductionEntryCode).ExecuteCommand(); + .Where(s => + s.ErpProductionEntryCode == mesRohIn.ErpProductionEntryCode) + .ExecuteCommand(); var orUpdate = db.Insertable(mesRohIn) .IgnoreColumns(true).ExecuteCommand() > 0; @@ -86,7 +89,7 @@ var baOrUpdate = db.Insertable(mesRohInDatas).PageSize(1) .IgnoreColumnsNull() .ExecuteCommand() > 0; - + if (orUpdate && baOrUpdate) return true; throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�"); @@ -100,7 +103,7 @@ } private ProductionOrder ConvertErpToProductionOrder( - ErpProductionOrderDto erpDto,string SUBBOM) + ErpProductionOrderDto erpDto, string SUBBOM) { DateTime parsedDate; @@ -119,12 +122,11 @@ var productionOrder = new ProductionOrder { OrderNo = SUBBOM, - Warehouse = erpDto.FStockID, + OrderDate = ParseDateTime(erpDto.FDate) ?? null, OrderType = erpDto.FBillType, BusinessStatus = erpDto.FStatus, - ProductCode = erpDto.FMaterialId, - Unit = erpDto.FUnitID, + WorkOrderQty = Convert.ToDecimal(erpDto.FQty), PlanningGroup = erpDto.FWorkGroupId, Planner = erpDto.FPlannerID, @@ -142,7 +144,7 @@ ErpProductionOrderId = erpDto.FSUBID, ErpProductionOrderLineNo = erpDto.FSUBBILLNOSEQ, ErpProductionOrderNo = erpDto.FSUBBILLNO, - SourceOrderType = erpDto.FSrcBillType, + SourceOrderNo = erpDto.FSrcBillNo, SourceOrderEntryNo = erpDto.FSrcBillEntrySeq, DemandOrderNo = erpDto.FSALEORDERNO, @@ -166,7 +168,53 @@ Typea = erpDto.TypeA, }; - var single = base.GetSingle(it => it.ErpProductionEntryCode == erpDto.FSUBENTRYID); + productionOrder.SourceOrderType = erpDto.FSrcBillType switch + { + //SourceOrderType = erpDto.FSrcBillType, + "0" => "鏃犳潵婧�", + "1" => "閿�鍞鍗曡鍙�", + "2" => "棰勬祴", + "3" => "鍑哄彛璁㈠崟琛屽彿", + "4" => "闇�姹傚垎绫讳唬鍙�", + "5" => "閿�鍞鍗曞彿", + "6" => "鍑哄彛璁㈠崟鍙�", + "7" or "8" => "鐢熶骇璁㈠崟", + _ => "濮斿璁㈠崟" + }; + + //Unit = , + // CAA009 鍗曚綅 -> MES_UNIT.id + if (!string.IsNullOrEmpty(erpDto.FUnitID)) + { + var unit = Db.Queryable<MesUnit>() + .Where(u => u.Fnumber == erpDto.FUnitID) + .Select(u => u.Id) + .First(); + productionOrder.Unit = unit.ToString(); + } + + // CAA006 浜у搧缂栫爜 -> MES_ITEMS.id + if (!string.IsNullOrEmpty(erpDto.FMaterialId)) + { + var item = Db.Queryable<MesItems>() + .Where(i => i.ItemNo == erpDto.FMaterialId) + .Select(i => i.Id) + .First(); + productionOrder.ProductCode = item.ToString(); + } + + // Warehouse = erpDto.FStockID, + if (!string.IsNullOrEmpty(erpDto.FStockID)) + { + var depot = Db.Queryable<MesDepots>() + .Where(d => d.DepotCode == erpDto.FStockID) + .Select(d => d.DepotId) + .First(); + productionOrder.Warehouse = depot.ToString(); + } + + var single = base.GetSingle(it => + it.ErpProductionEntryCode == erpDto.FSUBENTRYID); if (single != null) productionOrder.Guid = single.Guid; return productionOrder; -- Gitblit v1.9.3