From ab01d75a3fbc8467d81a895cba5d6dde76fbe053 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期二, 16 九月 2025 23:29:30 +0800 Subject: [PATCH] 1111 --- MES.Service/service/BasicData/MesRohInManager.cs | 153 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 107 insertions(+), 46 deletions(-) diff --git a/MES.Service/service/BasicData/MesRohInManager.cs b/MES.Service/service/BasicData/MesRohInManager.cs index c1be11a..e7de8e2 100644 --- a/MES.Service/service/BasicData/MesRohInManager.cs +++ b/MES.Service/service/BasicData/MesRohInManager.cs @@ -94,7 +94,6 @@ if (single != null) mesRohIn.Guid = single.Guid; mesRohIn.EbelnK3id = eid; mesRohIn.BillNo = rohIn.FBillNo; - mesRohIn.DocumentStatus = rohIn.FDocumentStatus; mesRohIn.DocumentType = rohIn.FBillTypeID; mesRohIn.BusinessType = rohIn.FBusinessType; /*if (rohIn.FDate != null) @@ -104,10 +103,12 @@ // 1. 澶勭悊 fDate锛堥噰璐棩鏈燂級 if (!rohIn.FDate.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime purchaseDate)) { - throw new FormatException($"閲囪喘鏃ユ湡锛團Date锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"閲囪喘鏃ユ湡锛團Date锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } mesRohIn.PurchaseDate = purchaseDate; @@ -118,41 +119,60 @@ } - mesRohIn.Supplier = rohIn.FSupplierId; - mesRohIn.CloseStatus = rohIn.FCloseStatus; - mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId; - mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId; + var mesSupplier = Db.Queryable<MesSupplier>() + .Where(s => s.SuppNo == rohIn.FSupplierId) + .First(); + + if (mesSupplier != null) + { + mesRohIn.Supplier = mesSupplier.Id.ToString(); + } + + // SETTLEMENT_PARTY -> MesSupplier.id + if (!string.IsNullOrEmpty(rohIn.FSettleId)) + { + var settlementSupplier = Db.Queryable<MesSupplier>() + .Where(s => s.SuppNo == rohIn.FSettleId) + .Select(s => s.Id) + .First(); + if (settlementSupplier != null) + { + mesRohIn.SettlementParty = settlementSupplier.ToString(); + } + } + + // PURCHASE_DEPT -> SYS_DEPARTMENT.DEPARTMENTID + if (!string.IsNullOrEmpty(rohIn.FPurchaseDeptId)) + { + var department = Db.Queryable<SysDepartment>() + .Where(d => d.Departmentcode == rohIn.FPurchaseDeptId) + .Select(d => d.Id) + .First(); + if (department != null) + { + mesRohIn.PurchaseDept = department.ToString(); + } + } + + + // mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId; + mesRohIn.PurchaseOrg = "1"; mesRohIn.PurchaseGroup = rohIn.FPurchaserGroupId; mesRohIn.Purchaser = rohIn.FPurchaserId; - mesRohIn.SettlementParty = rohIn.FSettleId; mesRohIn.PaymentParty = rohIn.FChargeId; mesRohIn.Email = rohIn.FProviderEMail; mesRohIn.Remarks = rohIn.Remarks; - mesRohIn.CancellationStatus = rohIn.FCancelStatus; mesRohIn.CancellationPerson = rohIn.FCancellerId; - /*if (rohIn.FCancelDate != null) - if (!mesRohIn.CancellationPerson.IsNullOrEmpty()) - mesRohIn.CancellationDate = - DateTime.ParseExact(rohIn.FCancelDate, - "yyyy-MM-d H:m:s", null); - mesRohIn.CreateBy = rohIn.FCreatorId; - if (rohIn.FCreateDate != null) - mesRohIn.CreateDate = DateTime.ParseExact(rohIn.FCreateDate, - "yyyy-MM-d H:m:s", null); - mesRohIn.LastupdateBy = rohIn.FModifierId; - if (rohIn.FModifyDate != null) - mesRohIn.LastupdateDate = DateTime.ParseExact(rohIn.FModifyDate, - "yyyy-MM-d H:m:s", null); - mesRohIn.Prearrivaldate = rohIn.Prearrivaldate != null - ? DateTime.ParseExact(rohIn.Prearrivaldate, - "yyyy-MM-d H:m:s", null) - : null;*/ - if (!rohIn.FCancelDate.IsNullOrEmpty() && !mesRohIn.CancellationPerson.IsNullOrEmpty()) + + if (!rohIn.FCancelDate.IsNullOrEmpty() && + !mesRohIn.CancellationPerson.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime cancelDate)) { - throw new FormatException($"鍙栨秷鏃ユ湡锛團CancelDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCancelDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"鍙栨秷鏃ユ湡锛團CancelDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCancelDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } mesRohIn.CancellationDate = cancelDate; @@ -165,10 +185,12 @@ // 3. 澶勭悊 fCreateDate锛堝垱寤烘棩鏈燂級 if (!rohIn.FCreateDate.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime createDate)) { - throw new FormatException($"鍒涘缓鏃ユ湡锛團CreateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCreateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"鍒涘缓鏃ユ湡锛團CreateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCreateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } mesRohIn.CreateDate = createDate; @@ -181,10 +203,12 @@ // 4. 澶勭悊 fModifyDate锛堜慨鏀规棩鏈燂級 if (!rohIn.FModifyDate.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime modifyDate)) { - throw new FormatException($"淇敼鏃ユ湡锛團ModifyDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FModifyDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"淇敼鏃ユ湡锛團ModifyDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FModifyDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } mesRohIn.LastupdateDate = modifyDate; @@ -198,7 +222,8 @@ // 6. 澶勭悊 prearrivaldate锛堥璁″埌璐ф棩鏈燂級 if (!rohIn.Prearrivaldate.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime preArrivalDate)) { throw new FormatException( @@ -224,6 +249,17 @@ mesRohIn.Address = rohIn.Address; mesRohIn.Acctype = rohIn.Acctype; mesRohIn.SynchronousDate = DateTime.Now; + mesRohIn.DocumentStatus = "C"; + mesRohIn.CancellationStatus = "A"; + + if (rohIn.FCloseStatus.IsNullOrEmpty()) + { + mesRohIn.CloseStatus = "A"; + } + else + { + mesRohIn.CloseStatus = rohIn.FCloseStatus == "1" ? "B" : "A"; + } return mesRohIn; } @@ -261,7 +297,8 @@ */ // 1. 澶勭悊 fDeliveryDate锛堜氦璐ф棩鏈燂級 DeliveryDate = !s.FDeliveryDate.IsNullOrEmpty() - ? (DateTime.TryParseExact(s.FDeliveryDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + ? (DateTime.TryParseExact(s.FDeliveryDate, + "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime deliveryDate) ? deliveryDate : throw new FormatException( @@ -270,7 +307,8 @@ // 2. 澶勭悊 fDeliveryEarlyDate锛堟渶鏃╀氦璐ф棩鏈燂級 EarliestDeliveryDate = !s.FDeliveryEarlyDate.IsNullOrEmpty() - ? (DateTime.TryParseExact(s.FDeliveryEarlyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + ? (DateTime.TryParseExact(s.FDeliveryEarlyDate, + "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime earlyDate) ? earlyDate : throw new FormatException( @@ -279,7 +317,8 @@ // 3. 澶勭悊 fDeliveryLastDate锛堟渶鏅氫氦璐ф棩鏈燂級 LatestDeliveryDate = !s.FDeliveryLastDate.IsNullOrEmpty() - ? (DateTime.TryParseExact(s.FDeliveryLastDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + ? (DateTime.TryParseExact(s.FDeliveryLastDate, + "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime lastDate) ? lastDate : throw new FormatException( @@ -291,10 +330,13 @@ SupplierItemName = s.FSupMatName, OutsourcingOrderId = s.FSUBREQBILLNO, BatchNumber = s.FLot, - BusinessClose = s.FMRPCloseStatus, - BusinessFreeze = s.FMRPFreezeStatus, + // BusinessClose = s.FMRPCloseStatus, + // BusinessFreeze = s.FMRPFreezeStatus, + BusinessClose = "A", + BusinessFreeze = "A", Freezer = s.FFreezerId, - BusinessTerminate = s.FMRPTerminateStatus, + // BusinessTerminate = s.FMRPTerminateStatus, + BusinessTerminate = "A", Terminator = s.FTerminaterId, TotalReceivedQty = Convert.ToDecimal(s.FReceiveQty), //绱鏀舵枡鏁� RemainingReceivedQty = @@ -314,7 +356,8 @@ DemandDocumentId = s.FDEMANDBILLNO, DemandDocumentLineId = s.FDEMANDBILLENTRYSEQ, DemandOrg = s.FRequireOrgId, - ReceivingOrg = s.FReceiveOrgId, + // ReceivingOrg = s.FReceiveOrgId, + ReceivingOrg = "1", SettlementOrg = s.FEntrySettleOrgId, PurchaseOrderLineNumber = s.FSEQ, Demand = s.FRequireOrgId, @@ -341,10 +384,12 @@ // 4. 澶勭悊 fFreezeDate锛堝喕缁撴棩鏈燂級 if (!s.FFreezeDate.IsNullOrEmpty() && !s.FFreezerId.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime freezeTime)) { - throw new FormatException($"鍐荤粨鏃ユ湡锛團FreezeDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FFreezeDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"鍐荤粨鏃ユ湡锛團FreezeDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FFreezeDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } entity.FreezeTime = freezeTime; @@ -355,12 +400,15 @@ } // 5. 澶勭悊 fTerminateDate锛堢粓姝㈡棩鏈燂級 - if (!s.FTerminateDate.IsNullOrEmpty() && !s.FTerminaterId.IsNullOrEmpty()) + if (!s.FTerminateDate.IsNullOrEmpty() && + !s.FTerminaterId.IsNullOrEmpty()) { - if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture, + if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s", + CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime terminateTime)) { - throw new FormatException($"缁堟鏃ユ湡锛團TerminateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FTerminateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); + throw new FormatException( + $"缁堟鏃ユ湡锛團TerminateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FTerminateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s"); } entity.TerminateTime = terminateTime; @@ -370,6 +418,19 @@ entity.TerminateTime = null; } + //ItemId + var mesItems = Db.Queryable<MesItems>() + .Where(s => s.ItemNo == entity.ItemId) + .First(); + + if (mesItems != null) + { + entity.ItemId = mesItems.Id.ToString(); + } + + //BUSINESS_TERMINATE = 'A',RECEIVING_ORG = 1 + + var single = rohInDataManager.GetSingle(it => it.EbelnK3id == entity.EbelnK3id); if (single != null) entity.Guid = single.Guid; -- Gitblit v1.9.3