From f80d5cdf701b3d3f2e21bffaff6e99a2a240fc0e Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期五, 12 七月 2024 11:25:54 +0800
Subject: [PATCH] 调整erp接口

---
 MES.Service/service/BasicData/MesRohInManager.cs |  488 ++++++++++++++++++++++++-----------------------------
 1 files changed, 223 insertions(+), 265 deletions(-)

diff --git a/MES.Service/service/BasicData/MesRohInManager.cs b/MES.Service/service/BasicData/MesRohInManager.cs
index 32dbef1..5ad7b39 100644
--- a/MES.Service/service/BasicData/MesRohInManager.cs
+++ b/MES.Service/service/BasicData/MesRohInManager.cs
@@ -4,286 +4,244 @@
 using MES.Service.util;
 using SqlSugar;
 
-namespace MES.Service.service.BasicData;
-
-public class MesRohInManager : Repository<MesRohIn>
+namespace MES.Service.service.BasicData
 {
-    //褰撳墠绫诲凡缁忕户鎵夸簡 Repository 澧炪�佸垹銆佹煡銆佹敼鐨勬柟娉�
-
-    private readonly MesRohInDataManager rohInDataManager = new();
-
-    //杩欓噷闈㈠啓鐨勪唬鐮佷笉浼氱粰瑕嗙洊,濡傛灉瑕侀噸鏂扮敓鎴愯鍒犻櫎 MesRohInManager.cs
-
-    public bool Save(RohIn rohIn)
+    public class MesRohInManager : Repository<MesRohIn>
     {
-        var rohInErpRohIn = rohIn.ErpRohIn;
-        var mesRohIn = GetMesRohIn(rohInErpRohIn);
-        var mesRohInDatas =
-            GetMesRohInDatas(rohIn.ErpRohinDatas, rohInErpRohIn.Type);
-        switch (rohInErpRohIn.Type)
+        private readonly MesRohInDataManager rohInDataManager = new();
+
+        // Save 鏂规硶鐢ㄤ簬淇濆瓨鍗曚釜 RohIn 璁板綍锛屾牴鎹被鍨嬫墽琛屼笉鍚岀殑鎿嶄綔
+        public bool Save(RohIn rohIn)
         {
-            case "1":
-                var insert = base.Insert(mesRohIn);
-                var insertRange = rohInDataManager.InsertRange(mesRohInDatas);
+            var rohInErpRohIn = rohIn.ErpRohIn;
+            var mesRohIn = GetMesRohIn(rohInErpRohIn);
+            var mesRohInDatas =
+                GetMesRohInDatas(rohIn.ErpRohinDatas, rohInErpRohIn.Type);
 
-                if (insert && insertRange) return true;
-                throw new NotImplementedException("鎻掑叆澶辫触");
-            case "2":
-                var update = base.Update(mesRohIn);
-                var insertOrUpdate =
-                    rohInDataManager.InsertOrUpdate(mesRohInDatas);
-
-                if (update && insertOrUpdate) return true;
-                throw new NotImplementedException("鏇存柊澶辫触");
-            case "4":
-                var orUpdate = SaveOrUpdate(mesRohIn);
-                var baOrUpdate =
-                    rohInDataManager.InsertOrUpdate(mesRohInDatas);
-                if (orUpdate && baOrUpdate) return true;
-                throw new NotImplementedException("鎻掑叆澶辫触");
-            default:
-                throw new NotImplementedException("type娌℃湁" +
-                                                  rohInErpRohIn.Type + "杩欎釜绫诲瀷");
-        }
-    }
-
-    private bool SaveOrUpdate(MesRohIn mesRohIn)
-    {
-        var mesRohIns = base.GetList(it => it.EbelnK3id == mesRohIn.EbelnK3id);
-
-        if (CollectionUtil.IsNullOrEmpty(mesRohIns))
-        {
-            return base.Insert(mesRohIn);
-        }
-
-        return base.Update(mesRohIn);
-    }
-
-    public bool SaveList(List<RohIn> rohIns)
-    {
-        var result = new List<bool>();
-        rohIns.ForEach(s =>
-        {
-            var save = Save(s);
-            result.Add(save);
-        });
-        return result.All(b => b);
-    }
-
-    public MesRohIn GetMesRohIn(ErpRohIn rohIn)
-    {
-        var eid = Convert.ToDecimal(rohIn.id);
-        var mesRohIn = new MesRohIn();
-        if (!"1".Equals(rohIn.Type))
-        {
-            var single = base.GetSingle(it => it.EbelnK3id == eid);
-            if (single != null) mesRohIn.Id = single.Id;
-        }
-
-        mesRohIn.EbelnK3id = eid;
-
-        mesRohIn.BillNo = rohIn.FBillNo;
-        mesRohIn.DocumentStatus = rohIn.FDocumentStatus;
-        mesRohIn.DocumentType = rohIn.FBillTypeID;
-        mesRohIn.BusinessType = rohIn.FBusinessType;
-
-        if (rohIn.FDate != null)
-            mesRohIn.PurchaseDate = DateTime.ParseExact(
-                rohIn.FDate, "yyyy-MM-dd HH:mm:ss", null);
-
-        mesRohIn.Supplier = rohIn.FSupplierId;
-        mesRohIn.CloseStatus = rohIn.FCloseStatus;
-        mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId;
-        mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId;
-        mesRohIn.PurchaseGroup = rohIn.FPurchaserGroupId;
-        mesRohIn.QtyAcceptance = rohIn.Facctype;
-        mesRohIn.Purchaser = rohIn.FPurchaserId;
-        mesRohIn.QualityReq = rohIn.F_UNW_Remarks_zlyq;
-        // mesRohIn.SupplierContact = rohIn.F_UNW_GYSLXR;
-        // mesRohIn.ContactPhone = rohIn.F_UNW_LXRDH;
-        // mesRohIn.Position = rohIn.FProviderJob;
-        // mesRohIn.OfficePhone = rohIn.FProviderPhone;
-        // mesRohIn.SupplierAddress = rohIn.FProviderAddress;
-        mesRohIn.SettlementParty = rohIn.FSettleId;
-        mesRohIn.PaymentParty = rohIn.FChargeId;
-        mesRohIn.Email = rohIn.FProviderEMail;
-        mesRohIn.TransportMethod = rohIn.F_UNW_Text_ysfs;
-        mesRohIn.Remarks = rohIn.F_UNW_BZ;
-        mesRohIn.FixtureMoldProcurement = rohIn.F_UNW_Combo_zjmj;
-        mesRohIn.CancellationStatus = rohIn.FCancelStatus;
-        mesRohIn.CancellationPerson = rohIn.FCancellerId;
-        if (rohIn.FCancelDate != null)
-            mesRohIn.CancellationDate = DateTime.ParseExact(
-                rohIn.FCancelDate, "yyyy-MM-dd HH:mm:ss", null);
-
-        mesRohIn.CreateBy = rohIn.FCreatorId;
-
-        if (rohIn.FCreateDate != null)
-            mesRohIn.CreateDate = DateTime.ParseExact(
-                rohIn.FCreateDate, "yyyy-MM-dd HH:mm:ss", null);
-
-        mesRohIn.LastupdateBy = rohIn.FModifierId;
-
-        if (rohIn.FModifyDate != null)
-            mesRohIn.LastupdateDate = DateTime.ParseExact(
-                rohIn.FModifyDate, "yyyy-MM-dd HH:mm:ss", null);
-
-        mesRohIn.ErpCheckBy = rohIn.FApproverId;
-        mesRohIn.ErpCheckDate = rohIn.FApproveDate;
-
-
-        return mesRohIn;
-    }
-
-    public List<MesRohInData> GetMesRohInDatas(List<ErpRohinData> ErpRohinDatas,
-        string type)
-    {
-        var list = new List<MesRohInData>();
-        ErpRohinDatas.ForEach(s =>
-        {
-            var entity = new MesRohInData();
-
-            var eid = Convert.ToDecimal(s.id);
-
-            if (!"1".Equals(type))
+            return UseTransaction(db =>
             {
-                var single =
-                    rohInDataManager.GetSingle(it => it.EbelnK3id == eid);
-                if (single != null) entity.Id = single.Id;
+                switch (rohInErpRohIn.Type)
+                {
+                    case "2":
+                        return InsertData(db, mesRohIn, mesRohInDatas,
+                            rohInErpRohIn.FBILLTYPE)
+                            ? 1
+                            : 0;
+                    case "3":
+                        return UpdateData(db, mesRohIn, mesRohInDatas) ? 1 : 0;
+                    case "4":
+                        return SaveOrUpdateData(db, mesRohIn, mesRohInDatas)
+                            ? 1
+                            : 0;
+                    default:
+                        throw new NotImplementedException(
+                            $"type娌℃湁{rohInErpRohIn.Type}杩欎釜绫诲瀷");
+                }
+            }) > 0;
+        }
+
+        // 鎻掑叆鏁版嵁鐨勬柟娉�
+        private bool InsertData(SqlSugarScope db, MesRohIn mesRohIn,
+            List<MesRohInData> mesRohInDatas, string FBILLTYPE)
+        {
+            switch (FBILLTYPE)
+            {
+                case "A":
+                {
+                    var insert = base.Insert(mesRohIn);
+                    var insertRange =
+                        rohInDataManager.InsertRange(mesRohInDatas);
+
+                    if (insert && insertRange) return true;
+                    throw new NotImplementedException("鎻掑叆澶辫触");
+                }
+                case "B":
+                {
+                    var decimals = mesRohInDatas.Select(s => s.Id).ToArray();
+                    if (base.DeleteById(mesRohIn.Id) && db
+                            .Deleteable<MesRohInData>().In(decimals)
+                            .ExecuteCommand() > 0)
+                    {
+                        var insert = base.Insert(mesRohIn);
+                        var insertRange =
+                            rohInDataManager.InsertRange(mesRohInDatas);
+
+                        if (insert && insertRange) return true;
+                        throw new NotImplementedException("鎻掑叆澶辫触");
+                    }
+
+                    break;
+                }
             }
 
-            entity.EbelnK3id = Convert.ToDecimal(s.id);
-            entity.ErpId = Convert.ToDecimal(s.Eid);
+            throw new NotImplementedException("閲囪喘璁㈠崟绫诲瀷閿欒");
+        }
 
-            entity.BillNo = s.FBillNo;
-            entity.SalesOrderId = s.F_UNW_Text_xsddh;
-            entity.ItemId = s.FMaterialId;
-            entity.PurchaseUnit = s.FUnitId;
-            entity.PurchaseQty = Convert.ToDecimal(s.FQty);
-            entity.InventoryUnit = s.FStockUnitID;
-            entity.PricingUnit = s.FPriceUnitId;
-            entity.PricingQty = Convert.ToDecimal(s.FPriceUnitQty);
-
-            if (s.FDeliveryDate != null)
-                entity.DeliveryDate = DateTime.ParseExact(
-                    s.FDeliveryDate, "yyyy-MM-dd HH:mm:ss", null);
-
-            if (s.FDeliveryEarlyDate != null)
-                entity.EarliestDeliveryDate = DateTime.ParseExact(
-                    s.FDeliveryEarlyDate, "yyyy-MM-dd HH:mm:ss", null);
-
-            if (s.FDeliveryLastDate != null)
-                entity.LatestDeliveryDate = DateTime.ParseExact(
-                    s.FDeliveryLastDate, "yyyy-MM-dd HH:mm:ss", null);
-
-            entity.IsGift = s.FGiveAway;
-            entity.Remarks = s.FEntryNote;
-            entity.SupplierItemCode = s.FSupMatId;
-            entity.SupplierItemName = s.FSupMatName;
-            entity.OutsourcingOrderId = s.FSUBREQBILLNO;
-            entity.BatchNumber = s.FLot;
-            entity.BusinessClose = s.FMRPCloseStatus;
-            entity.BusinessFreeze = s.FMRPFreezeStatus;
-            entity.Freezer = s.FFreezerId;
-
-            if (s.FFreezeDate != null)
-                entity.FreezeTime = DateTime.ParseExact(
-                    s.FFreezeDate, "yyyy-MM-dd HH:mm:ss", null);
-
-            entity.BusinessTerminate = s.FMRPTerminateStatus;
-            entity.Terminator = s.FTerminaterId;
-
-            if (s.FTerminateDate != null)
-                entity.TerminateTime = DateTime.ParseExact(
-                    s.FTerminateDate, "yyyy-MM-dd HH:mm:ss", null);
-
-            entity.TotalReceivedQty = Convert.ToDecimal(s.FReceiveQty);
-            entity.RemainingReceivedQty =
-                Convert.ToDecimal(s.FRemainReceiveQty);
-            entity.TotalStoredQty = Convert.ToDecimal(s.FStockInQty);
-            entity.RemainingStoredQty = Convert.ToDecimal(s.FRemainStockINQty);
-            entity.TotalReturnedQty = Convert.ToDecimal(s.FMrbQty);
-            entity.ReturnableReceivedQty = Convert.ToDecimal(s.FCHECKRETQTY);
-            entity.ReturnableStoredQty = Convert.ToDecimal(s.FSTOCKRETQTY);
-            entity.SourceDocumentType = s.FSrcBillTypeId;
-            entity.SourceDocumentId = s.FSrcBillNo;
-            entity.DemandTrackingId = s.FReqTraceNo;
-            entity.PlanTrackingId = s.FMtoNo;
-            entity.ChangeFlag = s.FChangeFlag;
-            entity.DemandSource = s.FDEMANDTYPE;
-            entity.DemandDocumentId = s.FDEMANDBILLNO;
-            entity.DemandDocumentLineId = s.FDEMANDBILLENTRYSEQ;
-            entity.PurchaseOrderLineNumber = s.PurchaseOrderLineNumber;
-            entity.Demand = s.Demand;
-            entity.Receiving = s.Receiving;
-            entity.Settlement = s.Settlement;
-            list.Add(entity);
-        });
-        return list;
-    }
-
-    #region 鏁欏鏂规硶
-
-    /// <summary>
-    ///     浠撳偍鏂规硶婊¤冻涓嶄簡澶嶆潅涓氬姟闇�姹傦紝涓氬姟浠g爜璇峰湪杩欓噷闈㈠畾涔夋柟娉�
-    /// </summary>
-    public void Study()
-    {
-        /*********鏌ヨ*********/
-
-        var data1 = base.GetById(1); //鏍规嵁ID鏌ヨ
-        var data2 = base.GetList(); //鏌ヨ鎵�鏈�
-        var data3 = base.GetList(it => 1 == 1); //鏍规嵁鏉′欢鏌ヨ  
-        //var data4 = base.GetSingle(it => 1 == 1);//鏍规嵁鏉′欢鏌ヨ涓�鏉�,濡傛灉瓒呰繃涓�鏉′細鎶ラ敊
-
-        var p = new PageModel { PageIndex = 1, PageSize = 2 }; // 鍒嗛〉鏌ヨ
-        var data5 = base.GetPageList(it => 1 == 1, p);
-        Console.Write(p.TotalCount); //杩斿洖鎬绘暟
-
-        var data6 =
-            base.GetPageList(it => 1 == 1, p,
-                it => SqlFunc.GetRandom()); // 鍒嗛〉鏌ヨ鍔犳帓搴�
-        Console.Write(p.TotalCount); //杩斿洖鎬绘暟
-
-        var conModels = new List<IConditionalModel>(); //缁勮鏉′欢鏌ヨ浣滀负鏉′欢瀹炵幇 鍒嗛〉鏌ヨ鍔犳帓搴�
-        conModels.Add(new ConditionalModel
+        // 鏇存柊鏁版嵁鐨勬柟娉�
+        private bool UpdateData(SqlSugarScope db, MesRohIn mesRohIn,
+            List<MesRohInData> mesRohInDatas)
         {
-            FieldName = typeof(MesRohIn).GetProperties()[0].Name,
-            ConditionalType = ConditionalType.Equal, FieldValue = "1"
-        }); //id=1
-        var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom());
+            var update = base.Insert(mesRohIn);
+            var insertOrUpdate = rohInDataManager.InsertRange(mesRohInDatas);
 
-        AsQueryable().Where(x => 1 == 1)
-            .ToList(); //鏀寔浜嗚浆鎹㈡垚queryable,鎴戜滑鍙互鐢╭ueryable瀹炵幇澶嶆潅鍔熻兘
+            if (update && insertOrUpdate) return true;
+            throw new NotImplementedException("鏇存柊澶辫触");
+        }
 
+        // 鎻掑叆鎴栨洿鏂版暟鎹殑鏂规硶
+        private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn,
+            List<MesRohInData> mesRohInDatas)
+        {
+            var orUpdate = base.Insert(mesRohIn);
+            var baOrUpdate = rohInDataManager.InsertRange(mesRohInDatas);
+            if (orUpdate && baOrUpdate) return true;
+            throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�");
+        }
 
-        /*********鎻掑叆*********/
-        var insertData = new MesRohIn(); //娴嬭瘯鍙傛暟
-        var insertArray = new[] { insertData };
-        base.Insert(insertData); //鎻掑叆
-        base.InsertRange(insertArray); //鎵归噺鎻掑叆
-        var id = base.InsertReturnIdentity(insertData); //鎻掑叆杩斿洖鑷鍒�
-        AsInsertable(insertData).ExecuteCommand(); //鎴戜滑鍙互杞垚 Insertable瀹炵幇澶嶆潅鎻掑叆
+        // 鎵归噺淇濆瓨璁板綍鐨勬柟娉�
+        public bool SaveList(List<RohIn> rohIns)
+        {
+            var result = rohIns.Select(Save).ToList();
+            return result.All(b => b);
+        }
 
+        // 灏� ErpRohIn 瀵硅薄杞崲涓� MesRohIn 瀵硅薄鐨勬柟娉�
+        public MesRohIn GetMesRohIn(ErpRohIn rohIn)
+        {
+            var eid = Convert.ToDecimal(rohIn.id);
+            var mesRohIn = new MesRohIn();
 
-        /*********鏇存柊*********/
-        var updateData = new MesRohIn(); //娴嬭瘯鍙傛暟
-        var updateArray = new[] { updateData }; //娴嬭瘯鍙傛暟
-        base.Update(updateData); //鏍规嵁瀹炰綋鏇存柊
-        base.UpdateRange(updateArray); //鎵归噺鏇存柊
-        //base.Update(it => new MesRohIn() { ClassName = "a", CreateTime = DateTime.Now }, it => it.id==1);// 鍙洿鏂癈lassName鍒楀拰CreateTime鍒楋紝鍏跺畠鍒椾笉鏇存柊锛屾潯浠秈d=1
-        AsUpdateable(updateData).ExecuteCommand(); //杞垚Updateable鍙互瀹炵幇澶嶆潅鐨勬彃鍏�
+            var single = base.GetSingle(it => it.EbelnK3id == eid);
+            if (single != null) mesRohIn.Id = single.Id;
 
+            mesRohIn.EbelnK3id = eid;
+            mesRohIn.BillNo = rohIn.FBillNo;
+            mesRohIn.DocumentStatus = rohIn.FDocumentStatus;
+            mesRohIn.DocumentType = rohIn.FBillTypeID;
+            mesRohIn.BusinessType = rohIn.FBusinessType;
 
-        /*********鍒犻櫎*********/
-        var deldata = new MesRohIn(); //娴嬭瘯鍙傛暟
-        base.Delete(deldata); //鏍规嵁瀹炰綋鍒犻櫎
-        base.DeleteById(1); //鏍规嵁涓婚敭鍒犻櫎
-        base.DeleteById(new[] { 1, 2 }); //鏍规嵁涓婚敭鏁扮粍鍒犻櫎
-        base.Delete(it => 1 == 2); //鏍规嵁鏉′欢鍒犻櫎
-        AsDeleteable().Where(it => 1 == 2)
-            .ExecuteCommand(); //杞垚Deleteable瀹炵幇澶嶆潅鐨勬搷浣�
+            if (rohIn.FDate != null)
+                mesRohIn.PurchaseDate = DateTime.ParseExact(rohIn.FDate,
+                    "yyyy-MM-dd HH:mm:ss", null);
+
+            mesRohIn.Supplier = rohIn.FSupplierId;
+            mesRohIn.CloseStatus = rohIn.FCloseStatus;
+            mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId;
+            mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId;
+            mesRohIn.PurchaseGroup = rohIn.FPurchaserGroupId;
+            mesRohIn.QtyAcceptance = rohIn.Facctype;
+            mesRohIn.Purchaser = rohIn.FPurchaserId;
+            mesRohIn.QualityReq = rohIn.F_UNW_Remarks_zlyq;
+            mesRohIn.SettlementParty = rohIn.FSettleId;
+            mesRohIn.PaymentParty = rohIn.FChargeId;
+            mesRohIn.Email = rohIn.FProviderEMail;
+            mesRohIn.TransportMethod = rohIn.F_UNW_Text_ysfs;
+            mesRohIn.Remarks = rohIn.F_UNW_BZ;
+            mesRohIn.FixtureMoldProcurement = rohIn.F_UNW_Combo_zjmj;
+            mesRohIn.CancellationStatus = rohIn.FCancelStatus;
+            mesRohIn.CancellationPerson = rohIn.FCancellerId;
+
+            if (rohIn.FCancelDate != null)
+                mesRohIn.CancellationDate =
+                    DateTime.ParseExact(rohIn.FCancelDate,
+                        "yyyy-MM-dd HH:mm:ss", null);
+
+            mesRohIn.CreateBy = rohIn.FCreatorId;
+
+            if (rohIn.FCreateDate != null)
+                mesRohIn.CreateDate = DateTime.ParseExact(rohIn.FCreateDate,
+                    "yyyy-MM-dd HH:mm:ss", null);
+
+            mesRohIn.LastupdateBy = rohIn.FModifierId;
+
+            if (rohIn.FModifyDate != null)
+                mesRohIn.LastupdateDate = DateTime.ParseExact(rohIn.FModifyDate,
+                    "yyyy-MM-dd HH:mm:ss", null);
+
+            mesRohIn.ErpCheckBy = rohIn.FApproverId;
+            mesRohIn.ErpCheckDate = rohIn.FApproveDate;
+            mesRohIn.Changereason = rohIn.FCHANGEREASON;
+
+            return mesRohIn;
+        }
+
+        // 灏� ErpRohinData 瀵硅薄杞崲涓� MesRohInData 瀵硅薄鐨勬柟娉�
+        public List<MesRohInData> GetMesRohInDatas(
+            List<ErpRohinData> erpRohinDatas, string type)
+        {
+            return erpRohinDatas.Select(s =>
+            {
+                var entity = new MesRohInData
+                {
+                    EbelnK3id = Convert.ToDecimal(s.id),
+                    ErpId = Convert.ToDecimal(s.Eid),
+                    BillNo = s.FBillNo,
+                    SalesOrderId = s.F_UNW_Text_xsddh,
+                    ItemId = s.FMaterialId,
+                    PurchaseUnit = s.FUnitId,
+                    PurchaseQty = Convert.ToDecimal(s.FQty),
+                    InventoryUnit = s.FStockUnitID,
+                    PricingUnit = s.FPriceUnitId,
+                    PricingQty = Convert.ToDecimal(s.FPriceUnitQty),
+                    DeliveryDate = s.FDeliveryDate != null
+                        ? DateTime.ParseExact(s.FDeliveryDate,
+                            "yyyy-MM-dd HH:mm:ss", null)
+                        : null,
+                    EarliestDeliveryDate = s.FDeliveryEarlyDate != null
+                        ? DateTime.ParseExact(s.FDeliveryEarlyDate,
+                            "yyyy-MM-dd HH:mm:ss", null)
+                        : null,
+                    LatestDeliveryDate = s.FDeliveryLastDate != null
+                        ? DateTime.ParseExact(s.FDeliveryLastDate,
+                            "yyyy-MM-dd HH:mm:ss", null)
+                        : null,
+                    IsGift = s.FGiveAway,
+                    Remarks = s.FEntryNote,
+                    SupplierItemCode = s.FSupMatId,
+                    SupplierItemName = s.FSupMatName,
+                    OutsourcingOrderId = s.FSUBREQBILLNO,
+                    BatchNumber = s.FLot,
+                    BusinessClose = s.FMRPCloseStatus,
+                    BusinessFreeze = s.FMRPFreezeStatus,
+                    Freezer = s.FFreezerId,
+                    FreezeTime = s.FFreezeDate != null
+                        ? DateTime.ParseExact(s.FFreezeDate,
+                            "yyyy-MM-dd HH:mm:ss", null)
+                        : null,
+                    BusinessTerminate = s.FMRPTerminateStatus,
+                    Terminator = s.FTerminaterId,
+                    TerminateTime = s.FTerminateDate != null
+                        ? DateTime.ParseExact(s.FTerminateDate,
+                            "yyyy-MM-dd HH:mm:ss", null)
+                        : null,
+                    TotalReceivedQty = Convert.ToDecimal(s.FReceiveQty),
+                    RemainingReceivedQty =
+                        Convert.ToDecimal(s.FRemainReceiveQty),
+                    TotalStoredQty = Convert.ToDecimal(s.FStockInQty),
+                    RemainingStoredQty = Convert.ToDecimal(s.FRemainStockINQty),
+                    TotalReturnedQty = Convert.ToDecimal(s.FMrbQty),
+                    ReturnableReceivedQty = Convert.ToDecimal(s.FCHECKRETQTY),
+                    ReturnableStoredQty = Convert.ToDecimal(s.FSTOCKRETQTY),
+                    SourceDocumentType = s.FSrcBillTypeId,
+                    SourceDocumentId = s.FSrcBillNo,
+                    DemandTrackingId = s.FReqTraceNo,
+                    PlanTrackingId = s.FMtoNo,
+                    ChangeFlag = s.FChangeFlag,
+                    DemandSource = s.FDEMANDTYPE,
+                    DemandDocumentId = s.FDEMANDBILLNO,
+                    DemandDocumentLineId = s.FDEMANDBILLENTRYSEQ,
+                    PurchaseOrderLineNumber = s.PurchaseOrderLineNumber,
+                    Demand = s.Demand,
+                    Receiving = s.Receiving,
+                    Settlement = s.Settlement
+                };
+
+                var single = rohInDataManager.GetSingle(it =>
+                    it.EbelnK3id == entity.EbelnK3id);
+                if (single != null) entity.Id = single.Id;
+
+                return entity;
+            }).ToList();
+        }
     }
-
-    #endregion
 }
\ No newline at end of file

--
Gitblit v1.9.3