From f7e91120bed67bf81f3e873056b147c8df2d68c0 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 23 四月 2025 15:38:15 +0800
Subject: [PATCH] 修复了一些已知问题

---
 Tiger.Business.WMS/Transaction/In_SemiProd.cs |  519 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 448 insertions(+), 71 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/In_SemiProd.cs b/Tiger.Business.WMS/Transaction/In_SemiProd.cs
index 0b9a3bf..8b103a4 100644
--- a/Tiger.Business.WMS/Transaction/In_SemiProd.cs
+++ b/Tiger.Business.WMS/Transaction/In_SemiProd.cs
@@ -16,6 +16,11 @@
 using Tiger.Model.MES.Yada;
 using Apache.NMS.ActiveMQ.Commands;
 using System.Diagnostics;
+using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser;
+using Tiger.Model.Entitys.MES.U9C;
+using Tiger.Model.Entitys.MES.BizPrintInstoreDoc;
+using Tiger.Model.Entitys.MES.Position;
+using IronPython.Runtime.Operations;
 
 namespace Tiger.Business.WMS.Transaction
 {
@@ -24,12 +29,15 @@
     /// </summary>
     public class In_SemiProd : WMSTransactionBase, IIn_SemiProd
     {
-        public IIn_SemiProd Init(string id, string userCode, string apiHost, string orgCode)
+        private readonly IMES_U9C _IMES_U9C = DI.Resolve<IMES_U9C>();
+        public IIn_SemiProd Init(string id, string apiHost, InstoreDocInput input)
         {
             TransID = id;
-            UserCode = userCode;
+            UserCode = input.UserCode;
             ApiHost = apiHost;
-            OrgCode = orgCode;
+            OrgCode = input.OrgCode;
+            pageSize = input.pageSize;
+            _GetScannedList();
             Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
             return this;
         }
@@ -38,9 +46,18 @@
         public string UserCode { get; set; }
         public long UserId { get; set; }
         public string OrgCode { get; set; }
-        public string LocationCode { get; set; }
-        public List<V_WMS_ITEM> Vitem { get; set; } = new();
-        public ScanShelfInfo CurScanShelf { get; set; }
+        public List<V_WMS_ITEM> Vitem { get; set; } = new(); 
+        public int pageSize { get; set; }
+        public RcvRptDocCreateInput RcvRptInput { get; set; } = new RcvRptDocCreateInput();
+        public List<ProdInBatch> ProdInBatchs { get; set; } = new List<ProdInBatch>();
+        public List<BIZ_ERP_PROD_IN_BTH> ErpProdInBths { get; set; } = new List<BIZ_ERP_PROD_IN_BTH>();
+        public List<BIZ_ERP_PROD_IN> ErpProdIns { get; set; } = new List<BIZ_ERP_PROD_IN>();
+        /// <summary>
+        /// 鎵弿鍒楄〃 
+        /// </summary>
+        public List<InStoreScanInfo> InStoreScanInfos { get; set; } = new List<InStoreScanInfo>();
+        public List<BIZ_ERP_PROD_IN_SN> ErpProdInSns { get; set; } = new List<BIZ_ERP_PROD_IN_SN>();
+        public InStoreInfos inStoreInfos { get; set; }
 
         #endregion
 
@@ -48,7 +65,7 @@
         /// <summary>
         /// 鎵弿鍏ュ彛
         /// </summary>
-        public async Task<ApiAction<ScanOutput>> Scan(BaseInput input)
+        public async Task<ApiAction<ScanOutput>> Submit(BaseInput input)
         {
             var action = new ApiAction<ScanOutput>(new ScanOutput());
             try
@@ -56,72 +73,161 @@
                 if (input.SN.IsNullOrEmpty())
                 {
                     action.IsSuccessed = false;
-                    action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.SnEmptyFailure");
+                    action.LocaleMsg = Biz.L("WMS.InSemiProd.ScanItem.SnEmptyFailure");
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
-                var LotNos = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_WhLotCodeQtyInfo>($"select *,'' as ID from mes_WhLotCodeQtyInfo where Bin = '{input.SN}'"); 
-                //Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList();
-                CurScanShelf = new ScanShelfInfo();
-                // 鏌ヨ璐ф灦淇℃伅
-                var whUnit = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
-                if (!whUnit.IsNullOrEmpty() && whUnit.LOCATION_CODE == input.SN)
+                var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == input.SN).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q._ItemInfos).FirstAsync();
+                if (wo == null)
                 {
-                    if (whUnit.IS_ACTIVE == "N")
-                    {
-                        action.IsSuccessed = false;
-                        //action.LocaleMsg = Biz.L("鎵弿鐨勫偍浣峓{0}]鏈惎鐢�");
-                        action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfOrLocationDisabled", input.SN);
-                        return action;
-                    }
-                    if (whUnit.Shelf.IsLightShelf || whUnit.Location.IS_SINGLE == "Y")
-                    {
-                        var locationData = Biz.Db.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == whUnit.LOCATION_ID && q.AUTH_ORG == OrgCode).First();
-                        if (!locationData.IsNullOrEmpty())
-                        {
-                            action.IsSuccessed = false;
-                            //action.LocaleMsg = Biz.L("鍌ㄤ綅[{0}]宸插瓨鏈夌墿鏂橻{1}]锛岃妫�鏌ョ郴缁熷簱瀛樹俊鎭�");
-                            action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", input.SN, locationData.SN);
-                            return action;
-                        }
-                    }
-                    CurScanShelf.Shelf = whUnit.Shelf;
-                    CurScanShelf.Location = whUnit.Location;
-                    CurScanShelf.WarehouseCode = whUnit.WH_CODE;
-                    CurScanShelf.RegionCode = whUnit.REGION_CODE;
-                    CurScanShelf.ShelfCode = whUnit.SHELF_CODE;
-                    CurScanShelf.LocationCode = whUnit.LOCATION_CODE;
-                    CurScanShelf.IsSmartRack = false;
-                    LocationCode = whUnit.LOCATION_CODE;
-                }
-                else {
                     action.IsSuccessed = false;
-                    //action.LocaleMsg = Biz.L("璇疯緭鍏ユ垨鎵弿鏈夋晥鐨勮揣鏋�/鍌ㄤ綅鐮�");
-                    action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty");
-                    return action;
-                }
-                var temps = new List<TemplateInput>();
-                foreach (var item in LotNos)
-                {
-                    var temp = new TemplateInput
-                    {
-                        custCode="",
-                        itemCode= item.ItemCode,
-                        itemDesc= item.Description,
-                        sapItemCode= item.SapCode,
-                        WoBatch = item.LotCode,
-                        batchQty= item.StoreQty,
-                        qrCode="",
-                    };
-                    temps.Add(temp);
+                    action.LocaleMsg = Biz.L("WMS.InSemiProd.ScanItem.WoEmptyFailure", input.SN); // $"宸ュ崟[{input.SN}]涓嶅瓨鍦�"
+                    return SetOutPutMqttMsg(action, input.Locale);
                 }
 
-                var y = Biz.Db.Storageable(LotNos, UserCode)
-                               .WhereColumns(t => new { t.ItemCode, t.LotCode })
-                               .ToStorage();
-                y.AsInsertable.ExecuteCommand();
-                y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                action.Data.Data = temps;
-                action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.ScanSuccessed");
+                var semiTemplateQty = (input.Data ?? "").JsonToObject<SemiTemplateQty>() ?? new SemiTemplateQty();
+
+                InStoreInfo Info = new()
+                {
+                    ErpProdInBth = new()
+                    {
+                        WORK_ORDER = wo.ORDER_NO,
+                        BATCH_NO = "",
+                        SALES_ORDER = wo.SALES_ORDER,
+                        ITEM_CODE = wo.ITEM_CODE,
+                        ITEM_NAME = wo.ItemInfo?.ITEM_DESC,
+                        SapCode = wo.ItemInfo?.ExtInfo?.SapCode,
+                        SCAN_QTY = semiTemplateQty.PackQty,
+                        CompleteQty = semiTemplateQty.CompleteQty,
+                        IS_HANDLED = "N" //Y-宸茬敓鎴愶紝N-鏈敓鎴愶紝F-澶辫触
+                    },
+                    InStoreScanInfo = new()
+                    {
+                        SN = "",
+                        SALES_ORDER = wo.SALES_ORDER,
+                        WORK_ORDER = wo.ORDER_NO,
+                        BATCH_NO = "",
+                        SCAN_QTY = semiTemplateQty.PackQty.ToDouble()
+                    }
+                };
+
+                //瑕佸瓨鍏ョ殑鎵规鍏ュ簱鍗曟暟鎹� 
+                int n = InStoreScanInfos.Where(q => q.WORK_ORDER == Info.ErpProdInBth.WORK_ORDER).Count();
+                if (!ErpProdInBths.Any(q => q.WORK_ORDER == Info.ErpProdInBth.WORK_ORDER))
+                {
+                    Info.ErpProdInBth.AUTH_ORG = OrgCode;
+                    Info.ErpProdInBth.BATCH_NO = "";
+                    Info.ErpProdInBth.CREATE_USER = UserCode;
+                    Info.ErpProdInBth.CREATE_TIME = DateTime.Now;
+                    Info.ErpProdInBth.SCANED_DATE = DateTime.Now;
+                    Info.ErpProdInBth.HANDLED_DATE = DateTime.Now;
+                    Info.ErpProdInBth.IS_SCANED = "Y";
+                    Info.ErpProdInBth.ORDER_NO = UserCode;
+                    Info.ErpProdInBth.IS_HANDLED = "N";
+                    Info.ErpProdInBth.CartonQty = n == 0 ? 1 : n;
+                    BIZ_ERP_PROD_IN prodIn = new()
+                    {
+                        AUTH_ORG = OrgCode,
+                        BILLCODE = UserCode,
+                        BILLDATE = DateTime.Now,
+                        STATUS = 0,
+                        HANDLED = -1,
+                        WAREHOUSECODE = "",
+                        SOURCECODE = Info.ErpProdInBth.WORK_ORDER,
+                        HANDLED_DATE = DateTime.Now,
+                    };
+                    ErpProdInBths.Add(Info.ErpProdInBth);
+                    ErpProdIns.Add(prodIn);
+                }
+                //else
+                //{
+                //    if (!InStoreScanInfos.Any(q => q.WORK_ORDER == Info?.ErpProdInBth.WORK_ORDER && q.SN == CurSN))
+                //    {
+                //        var erpbth = ErpProdInBths.Where(q => q.WORK_ORDER == Info.ErpProdInBth.WORK_ORDER).FirstOrDefault();
+                //        if (!erpbth.IsNullOrEmpty())
+                //        {
+                //            erpbth.SCAN_QTY += Info.InStoreScanInfo.SCAN_QTY.ToDouble();
+                //            erpbth.CartonQty = n + 1;
+                //        }
+                //    }
+                //}
+
+                //鐢熸垚鎵撳嵃瀹炰綋
+                if (RcvRptInput.PrintJsons.Count == 0)
+                {
+                    RcvRptInput.PrintJsons.Add(new()
+                    {
+                        ID = Guid.NewGuid().ToString("N"),
+                        Items = new() {
+                            Info.ErpProdInBth
+                        }
+                    });
+                }
+                else
+                {
+                    //鎷煎垎椤�
+                    bool isAdded = false;
+                    foreach (var item in RcvRptInput.PrintJsons)
+                    {
+                        if (!item.Items.Any(q => q.WORK_ORDER == Info.ErpProdInBth.WORK_ORDER))
+                        {
+                            if (item.Items.Count < pageSize)
+                            {
+                                item.Items.Add(Info.ErpProdInBth);
+                                isAdded = true;
+                            }
+                        }
+                        else
+                        {
+                            isAdded = true;
+                        }
+                    }
+                    if (!isAdded)
+                    {
+                        RcvRptInput.PrintJsons.Add(new()
+                        {
+                            ID = Guid.NewGuid().ToString("N"),
+                            Items = new() {
+                            Info.ErpProdInBth
+                        }
+                        });
+                    }
+                }
+
+                //淇濆瓨鏁版嵁搴�
+                var db = Business.Biz.Db;
+                var dbTran = db.UseTran(() =>
+                {
+                    var x = db.Storageable(ErpProdInBths, $"InStoreOrderNo_{UserCode}")
+                             .WhereColumns(t => new { t.ORDER_NO, t.WORK_ORDER, t.GHOST_ROW })
+                             .ToStorage();
+                    x.AsInsertable.ExecuteCommand();
+                    x.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+
+                    //var s = db.Storageable(ErpProdInSns, $"InStoreOrderNo_{UserCode}")
+                    //            .WhereColumns(t => new { t.CARTONNO, t.SN, t.GHOST_ROW })
+                    //            .ToStorage();
+                    //s.AsInsertable.ExecuteCommand();
+                    //s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                });
+                if (!dbTran.IsSuccess)
+                {
+                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
+                    this.Close(!dbTran.IsSuccess);
+                    throw dbTran.ErrorException;
+                }
+                RcvRptInput.RcvRptDocBases = new();
+                RcvRptInput.labels = new();
+                RcvRptInput.ErpProdInBths = ErpProdInBths;
+                RcvRptInput.userId = UserCode;
+                inStoreInfos = new()
+                {
+                    ErpProdInBths = ErpProdInBths,
+                    InStoreScanInfos = InStoreScanInfos,
+                };
+
+                action.Data.Data = inStoreInfos;
+                action.Data.Command = "";
+                action.LocaleMsg = Biz.L("WMS.InSemiProd.ScanItem.ScanSuccessed", input.SN); //$"宸ュ崟鏉$爜[{input.SN}]鎵弿鎴愬姛锛岃濉叆宸ュ崟鏁伴噺鍚庣偣鎻愪氦"
             }
             catch (Exception ex)
             {
@@ -131,16 +237,287 @@
             return SetOutPutMqttMsg(action, input.Locale);
         }
 
-        public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
+        public ApiAction<InStoreInfos> GetInStoreInfos()
         {
-            var action = new ApiAction<ScanOutput>(new ScanOutput());
+            return new() { Data = inStoreInfos };
+        }
+
+
+        /// <summary>
+        /// 鏌ヨ宸叉壂鎻忓垪琛�
+        /// </summary>
+        /// <returns></returns>
+        public async Task<ApiAction<InStoreInfos>> GetScannedList()
+        {
+            var action = new ApiAction<InStoreInfos>();
             try
             {
-                
+                _GetScannedList();
+                action.Data = inStoreInfos;
             }
             catch (Exception ex)
             {
-                action.CatchExceptionWithLog(ex, Biz.L("鍗婃垚鍝佸叆搴撳け璐�"));
+                action.CatchExceptionWithLog(ex, $"鏌ヨ宸叉壂鎻忓垪琛ㄥ紓甯�");
+            }
+            return action;
+        }
+
+        /// <summary>
+        /// 浠庢暟鎹簱璇诲洖鎿嶄綔鑰呭師鏈搷浣滅殑璁板綍
+        /// </summary>
+        /// <returns></returns>
+        private RcvRptDocCreateInput _GetScannedList()
+        {
+            RcvRptInput.RcvRptDocBases = new();
+            RcvRptInput.ErpProdInBths = new();
+            RcvRptInput.PrintJsons = new();
+            RcvRptInput.labels = new();
+            RcvRptInput.userId = UserCode;
+            ErpProdInSns.Clear();
+            ErpProdIns.Clear();
+            ErpProdInBths.Clear();
+            InStoreScanInfos.Clear();
+            RcvRptInput.ErpProdInBths = Biz.Db.Queryable<BIZ_ERP_PROD_IN_BTH>()
+                .Where(q => q.BATCH_NO == SqlFunc.Subqueryable<BIZ_ERP_PROD_IN_BTH>().Where(s => s.ORDER_NO == UserCode && s.GHOST_ROW == false).Select(s => s.BATCH_NO) && q.IS_HANDLED == "N")
+                .IncludesAllFirstLayer().ToList();
+            foreach (var item in RcvRptInput.ErpProdInBths)
+            {
+                var values = item.ProdInSns.GroupBy(x => x.CARTONNO)
+                    .Select(g => new InStoreScanInfo() { SN = g.Key, SALES_ORDER = item.SALES_ORDER, BATCH_NO = item.BATCH_NO, WORK_ORDER = item.WORK_ORDER, SCAN_QTY = g.Sum(x => x.Qty).ToDouble() });
+                foreach (var t in values)
+                {
+                    InStoreScanInfos.Add(t);
+                }
+                item.CartonQty = values.Count();
+
+                ErpProdIns.Add(new()
+                {
+                    AUTH_ORG = OrgCode,
+                    BILLCODE = UserCode,
+                    BILLDATE = DateTime.Now,
+                    STATUS = 0,
+                    HANDLED = -1,
+                    WAREHOUSECODE = "",
+                    SOURCECODE = item.WORK_ORDER,
+                    HANDLED_DATE = DateTime.Now,
+                });
+                ErpProdInSns.AddRange(item.ProdInSns);
+
+                //鐢熸垚鎵撳嵃瀹炰綋
+                if (RcvRptInput.PrintJsons.Count == 0)
+                {
+                    RcvRptInput.PrintJsons.Add(new()
+                    {
+                        ID = Guid.NewGuid().ToString("N"),
+                        Items = new() {
+                            item
+                        }
+                    });
+                }
+                else
+                {
+                    //鎷煎垎椤�
+                    bool isAdded = false;
+                    foreach (var p in RcvRptInput.PrintJsons)
+                    {
+                        if (!p.Items.Any(q => q.WORK_ORDER == item.WORK_ORDER))
+                        {
+                            if (p.Items.Count < pageSize)
+                            {
+                                p.Items.Add(item);
+                                isAdded = true;
+                            }
+                        }
+                        else
+                        {
+                            isAdded = true;
+                        }
+                    }
+                    if (!isAdded)
+                    {
+                        RcvRptInput.PrintJsons.Add(new()
+                        {
+                            ID = Guid.NewGuid().ToString("N"),
+                            Items = new() {
+                            item
+                        }
+                        });
+                    }
+                }
+            }
+            ErpProdInBths = RcvRptInput.ErpProdInBths;
+
+            inStoreInfos = new()
+            {
+                ErpProdInBths = ErpProdInBths,
+                InStoreScanInfos = InStoreScanInfos,
+            };
+            return RcvRptInput;
+        }
+
+        /// <summary>
+        /// 璋冪敤U9C鎺ュ彛鐢熸垚鍏ュ簱鍗�
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public async Task<ApiAction<RcvRptDocCreateInput>> GenerateInStoreOrder()
+        {
+            var action = new ApiAction<RcvRptDocCreateInput>();
+            try
+            {
+                //濡傛灉鎵弿璁板綍涓�0
+                if (!RcvRptInput.ErpProdInBths.Any(q => q.IS_HANDLED == "N"))
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"娌℃湁瑕佸叆搴撶殑浜у搧鏁版嵁锛岃鎵弿宸ュ崟閲嶆柊鐢熸垚鍏ュ簱鍗曟嵁锛�");
+                    return action;
+                }
+                if (RcvRptInput.RcvRptDocBases.IsNullOrEmpty() || RcvRptInput.RcvRptDocBases.Count == 0)
+                {
+                    foreach (var item in RcvRptInput.ErpProdInBths)
+                    {
+                        var DocBase = new RcvRptDocBase()
+                        {
+                            WorkOrder = item.WORK_ORDER,
+                            ItemCode = item.ITEM_CODE,
+                            WhCode = "10105",
+                            PkgQty = item.SCAN_QTY,
+                            CompleteQty = item.CompleteQty,
+                            OutputType = 0,
+                            StorageType = 4,
+                            DocState = 1,
+                            Status = "N"
+                        };
+                        if (!RcvRptInput.RcvRptDocBases.Any(q => q.WorkOrder == item.WORK_ORDER))
+                        {
+                            RcvRptInput.RcvRptDocBases.Add(DocBase);
+                        }
+                    }
+                }
+                else
+                {
+                    action.IsSuccessed = false;
+                    action.LocaleMsg = Biz.L($"鏈夊瓨鍦ㄦ湭鎻愪氦鐨勫叆搴撳崟锛屼笉鑳界敓鎴愬叆搴撳崟");
+                    return action;
+                }
+                action = await _IMES_U9C.RcvRptDocCreate(RcvRptInput);
+                if (action.IsSuccessed)
+                {
+                    foreach (var sn in ErpProdInSns)
+                    {
+                        var d = action.Data.ErpProdInBths.Where(q => q.WORK_ORDER == sn.SOURCECODE).FirstOrDefault();
+                        if (!d.IsNullOrEmpty())
+                        {
+                            sn.BUSINESSCODE = d.ORDER_NO;
+                            sn.UPDATE_USER = UserCode;
+                            sn.UPDATE_TIME = DateTime.Now;
+                        }
+                    }
+                    foreach (var p in ErpProdIns)
+                    {
+                        var d = action.Data.ErpProdInBths.Where(q => q.WORK_ORDER == p.SOURCECODE).FirstOrDefault();
+                        if (!d.IsNullOrEmpty())
+                        {
+                            p.BILLCODE = d.ORDER_NO;
+                            p.UPDATE_USER = UserCode;
+                            p.UPDATE_TIME = DateTime.Now;
+                            p.HANDLED = 0;
+                        }
+                    }
+                    //淇濆瓨鏁版嵁搴�
+                    var db = Business.Biz.Db;
+                    var dbTran = db.UseTran(() =>
+                    {
+                        db.Updateable(ErpProdInSns, $"InStoreOrderNo_{UserCode}").UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.BUSINESSCODE }).ExecuteCommand();
+
+                        var x = db.Storageable(ErpProdIns, $"InStoreOrderNo_{UserCode}")
+                                 .WhereColumns(t => new { t.BILLCODE, t.SOURCECODE, t.GHOST_ROW })
+                                 .ToStorage();
+                        x.AsInsertable.ExecuteCommand();
+                        x.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                    });
+                    if (!dbTran.IsSuccess)
+                    {
+                        Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
+                        this.Close(!dbTran.IsSuccess);
+                        throw dbTran.ErrorException;
+                    }
+                }
+
+            }
+            catch (Exception ex)
+            {
+                action.CatchExceptionWithLog(ex, $"璋冪敤U9C鎺ュ彛鐢熸垚鍏ュ簱鍗曞紓甯�");
+            }
+            return action;
+        }
+
+        /// <summary>
+        /// 娓呴櫎
+        /// </summary>
+        /// <returns></returns>
+        public async Task<ApiAction> Clear()
+        {
+            var action = new ApiAction();
+            try
+            {
+                RcvRptInput = new();
+                ProdInBatchs = new() { };
+                ErpProdInBths = new() { };
+                ErpProdIns = new();
+                /// <summary>
+                /// 鎵弿鍒楄〃 
+                /// </summary>
+                InStoreScanInfos = new() { };
+                ErpProdInSns = new();
+                inStoreInfos = new() { };
+
+                //涓存椂浠g爜锛屾祴璇曠敤
+                //DbClient _db = Biz.DataSource["YadaU9C"].Client;
+                //var items = Biz.Db.Queryable<WMS_ITEM>().Where(q => SqlFunc.IsNullOrEmpty(q.SUPP_LOTNO)).ToList();
+                //var snlist = items.Select(q => q.SN).ToList();
+                ////var list = _db.Ado.SqlQuery<mes_MaterialBarCodeByBin>($"select *,cast('{DateTime.Now.ToString("yyyy-MM-dd")}' as DATETIME) as PROD_DATE,'' as Unit,'' as LotNo from mes_MaterialBarCodeByBin where Code in ({string.Join(',', snlist.Select(x=> $"'{x}'"))})");
+                //var list = _db.Queryable<mes_MaterialBarCode>().Where(q => snlist.Contains(q.Code)).ToList();
+                //foreach (var item in list)
+                //{
+                //    var wmsitem = items.Where(q => q.SN == item.Code).FirstOrDefault();
+                //    if (!wmsitem.IsNullOrEmpty())
+                //    {
+                //        wmsitem.SUPP_LOTNO = item.Segment7;
+                //    }
+                //}
+
+
+                ////淇濆瓨鏁版嵁搴�
+                //var db = Business.Biz.Db;
+                //var dbTran = db.UseTran(() =>
+                //{
+                //    db.Updateable(items).UpdateColumns(q => new { q.SUPP_LOTNO }).ExecuteCommand();
+                //});
+                //if (!dbTran.IsSuccess)
+                //{
+                //    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
+                //    this.Close(!dbTran.IsSuccess);
+                //    throw dbTran.ErrorException;
+                //}
+
+                //淇濆瓨鏁版嵁搴�
+                var db = Business.Biz.Db;
+                var dbTran = db.UseTran(() =>
+                {
+                    db.Deleteable<BIZ_ERP_PROD_IN_BTH>().Where(x => x.ORDER_NO == UserCode && x.IS_HANDLED == "N").ExecuteCommand();
+                    db.Deleteable<BIZ_ERP_PROD_IN_SN>().Where(x => x.BUSINESSCODE == UserCode).ExecuteCommand();
+                });
+                if (!dbTran.IsSuccess)
+                {
+                    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
+                    this.Close(!dbTran.IsSuccess);
+                    throw dbTran.ErrorException;
+                }
+            }
+            catch (Exception ex)
+            {
+                action.CatchExceptionWithLog(ex, $"鏌ヨ宸叉壂鎻忓垪琛ㄥ紓甯�");
             }
             return action;
         }

--
Gitblit v1.9.3