From f7c36a9444bf8d93bff7b8e481eacd70f1053540 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期五, 12 九月 2025 17:29:26 +0800
Subject: [PATCH] 销售出库:条码拆分更改为存储过程实现

---
 service/Warehouse/MesXsckManager.cs |  539 ++++++-----------------------------------------------------
 1 files changed, 54 insertions(+), 485 deletions(-)

diff --git a/service/Warehouse/MesXsckManager.cs b/service/Warehouse/MesXsckManager.cs
index 77f98b2..b85bfd2 100644
--- a/service/Warehouse/MesXsckManager.cs
+++ b/service/Warehouse/MesXsckManager.cs
@@ -119,7 +119,7 @@
         using (var conn = new SqlConnection(DbHelperSQL.strConn))
         {
             if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
-            if (query.daa001.IsNullOrEmpty()) throw new Exception("鍙戣揣閫氱煡鍗曞彿涓嶅厑璁镐负绌�");
+            if (query.billNo.IsNullOrEmpty()) throw new Exception("鍙戣揣閫氱煡鍗曞彿涓嶅厑璁镐负绌�");
             if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
 
             using (var cmd = new SqlCommand("[prc_pda_XSCK]", conn))
@@ -135,7 +135,7 @@
                         new("@barcode_num", SqlDbType.NVarChar, 300),
                         new("@split_num", SqlDbType.NVarChar, 300),
                         new("@c_User", query.userName),
-                        new("@p_biLL_no", query.daa001),
+                        new("@p_biLL_no", query.billNo),
                         new("@p_item_barcode", query.barcode)
                     };
                     parameters[0].Direction = ParameterDirection.Output;
@@ -191,499 +191,68 @@
     ///     - Num: 鍙戞枡鏁伴噺(蹇呭~,蹇呴』澶т簬0)
     ///     - blNo: 鍙戣揣閫氱煡鍗曞彿(蹇呭~)
     /// </remarks>
-    public (bool success, List<MesItemBlDetail> pendingList) SplitBarcode(
-        WarehouseQuery query)
+    public ProductionPickDto SplitBarcode(WarehouseQuery query)
     {
-        if (string.IsNullOrEmpty(query.userName))
-            throw new Exception("鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒");
+        if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+        if (query.billNo.IsNullOrEmpty()) throw new Exception("鐢宠鍗曞彿涓嶅厑璁镐负绌�");
+        if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
 
-        if (string.IsNullOrEmpty(query.billNo))
-            throw new Exception("璇烽�夊彇鍗曟嵁鍙凤紒");
+        if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0");
 
-        if (string.IsNullOrEmpty(query.barcode))
-            throw new Exception("璇锋壂鎻忔潯鐮侊紒");
-
-        if ((query.Num ?? 0) <= 0)
-            throw new Exception("璇疯緭鍏ユ纭殑鍙戞枡鏁伴噺锛�");
-
-        if (string.IsNullOrEmpty(query.blNo))
-            throw new Exception("鍙戣揣閫氱煡鍗曞彿涓嶈兘涓虹┖锛�");
-
-
-        // 妫�楠屾槸鍚﹂噸澶嶆壂鎻�
-        var exists = Db.Queryable<MesInvItemOutCDetails>()
-            .Where(b => b.ItemBarcode == query.barcode)
-            .Any();
-
-        if (exists)
-            throw new Exception("姝ゆ潯鐮佸凡鎵弿,鍕块噸澶嶆壂鐮侊紒");
-
-        // 鏌ヨ鏉$爜搴撳瓨淇℃伅
-        var stockBarcode = Db.Queryable<MesInvItemStocks>()
-            .Where(t => t.ItemBarcode == query.barcode && t.Quantity > 0)
-            .First();
-
-        if (stockBarcode == null)
-            throw new Exception($"搴撳瓨涓棤姝ゆ潯鐮�,璇锋牳瀵癸紒{query.barcode}");
-
-        var totalQty = stockBarcode.Quantity;
-        string newBarcode = null;
-
-        var outNoType = "";
-        if (query.Type == "鐢熶骇琛ユ枡")
+        var _strMsg = "";
+        var _intSum = "";
+        var _cfBar = "";//鎷嗗垎鍚庢潯鐮�
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
         {
-            outNoType = "SCBL(鐢熶骇琛ユ枡)";
-        }
-        else
-        {
-            outNoType = "SCCL(鐢熶骇瓒呴)";
-        }
-
-        // 寮�鍚簨鍔″鐞�
-        var success = UseTransaction(db =>
-        {
-            var executeCommand = 0;
-
-            // 鎷嗗垎鏉$爜
-            if (totalQty > query.Num)
+            using (var cmd = new SqlCommand("[prc_pda_XSCK_CF_new]", conn))
             {
-                var mesItems = db.Queryable<MesItems>()
-                    .Where(s => s.Id == stockBarcode.ItemId).First();
-
-                // 鐢熸垚鏂版潯鐮佸彿
-                newBarcode = BillNo.GetBillNo("TM(鏉$爜)", mesItems.ItemNo);
-
-                // 鍐欏叆鏂版潯鐮�
-                executeCommand += db.Insertable(new MesInvItemBarcodes
+                try
                 {
-                    Guid = Guid.NewGuid(),
-                    ItemBarcode = newBarcode,
-                    CustNo = stockBarcode.CustomerNo,
-                    // ProductCode = stockBarcode.ProductCode, 
-                    // ItemBarcode2 = stockBarcode.ItemBarcode2,
-                    // ItemCode = stockBarcode.ItemCode,
-                    ItemNo = stockBarcode.ItemNo,
-                    LotNo = stockBarcode.LotNo,
-                    Quantity = query.Num,
-                    EpFlag = true,
-                    TaskNo = stockBarcode.TaskNo,
-                    CreateBy = query.userName,
-                    CreateDate = DateTime.Now,
-                    LastupdateBy = query.userName,
-                    LastupdateDate = DateTime.Now,
-                    OldItemBarcode = query.barcode,
-                    // Mblnr = stockBarcode.Mblnr,
-                    // Zeile = stockBarcode.Zeile,
-                    // RohInId = stockBarcode.RohInId,
-                    Barcodestatus = false,
-                    Oldqty = query.Num as long?,
-                    // Unit = stockBarcode.Unit,
-                    // WeightUnit = stockBarcode.WeightUnit,
-                    Factory = stockBarcode.Factory,
-                    Company = stockBarcode.Company,
-                    BillNo = stockBarcode.BillNo,
-                    BoardStyle = stockBarcode.BoardStyle,
-                    // ColorName = stockBarcode.ColorName,
-                    WorkNo = stockBarcode.WorkNo,
-                    WorkLine = stockBarcode.WorkLine,
-                    // MemoBad = stockBarcode.MemoBad,
-                    ComeFlg = 5,
-                    // Memo = stockBarcode.Memo,
-                    SuppId = stockBarcode.SuppId,
-                    SuppNo = stockBarcode.SuppNo,
-                    InsDate = stockBarcode.IndepDate, // Added InsDate
-                    ItemId = stockBarcode.ItemId
-                    // ItemUnit = stockBarcode.ItemUnit // Added ItemUnit
-                }).IgnoreColumns(true).ExecuteCommand();
-
-                // 鏇存柊鍘熸潯鐮佹暟閲�
-                executeCommand += db.Updateable<MesInvItemBarcodes>()
-                    .SetColumns(it => it.Quantity == it.Quantity - query.Num)
-                    .Where(it => it.ItemBarcode == query.barcode)
-                    .ExecuteCommand();
-
-                // 鏇存柊鍘熸潯鐮佹暟閲�
-                executeCommand += db.Updateable<MesInvItemStocks>()
-                    .SetColumns(it => it.Quantity == it.Quantity - query.Num)
-                    .Where(it => it.ItemBarcode == query.barcode)
-                    .ExecuteCommand();
-
-                //// 鍒犻櫎鍘熸潯鐮佸簱瀛樿褰�
-                //executeCommand += db.Deleteable<MesInvItemStocks>()
-                //    .Where(it => it.ItemBarcode == query.barcode)
-                //    .ExecuteCommand();
-
-                // 鎻掑叆鍓╀綑鏉$爜鏁伴噺鐨勬柊搴撳瓨璁板綍
-                executeCommand += db.Insertable(new MesInvItemStocks
-                {
-                    Guid = Guid.NewGuid(),
-                    TaskNo = stockBarcode.TaskNo,
-                    ItemBarcode = newBarcode,
-                    ItemNo = stockBarcode.ItemNo,
-                    LotNo = stockBarcode.LotNo,
-                    Quantity = query.Num,
-                    EpFlag = stockBarcode.EpFlag,
-                    CustomerNo = stockBarcode.CustomerNo,
-                    ItemWt = stockBarcode.ItemWt,
-                    DepotsCode = stockBarcode.DepotsCode,
-                    DepotsId = stockBarcode.DepotsId,
-                    DepotSectionsCode = stockBarcode.DepotSectionsCode,
-                    CheckDate = stockBarcode.CheckDate,
-                    ItemType = stockBarcode.ItemType,
-                    IndepDate = stockBarcode.IndepDate,
-                    Factory = stockBarcode.Factory,
-                    Company = stockBarcode.Company,
-                    IqcStatus = stockBarcode.IqcStatus,
-                    BoardStyle = stockBarcode.BoardStyle,
-                    WorkNo = stockBarcode.WorkNo,
-                    WorkLine = stockBarcode.WorkLine,
-                    SuppNo = stockBarcode.SuppNo,
-                    ItemId = stockBarcode.ItemId
-                    // UnitId = stockBarcode.ItemUnit
-                }).IgnoreColumns(true).ExecuteCommand();
-
-                // 鍐欏叆鏂版潯鐮佺殑浜ゆ槗璁板綍
-                executeCommand += db.Insertable(new MesInvBusiness2
-                {
-                    Guid = Guid.NewGuid(),
-                    Status = 1,
-                    BillTypeId = 200, // p_bill_type_id
-                    TransactionCode = "209", // p_transaction_no
-                    BusinessType = 0,
-                    ItemBarcode = newBarcode,
-                    ItemNo = stockBarcode.ItemNo,
-                    LotNo = stockBarcode.LotNo,
-                    EpFlag = true,
-                    Quantity = query.Num,
-                    FromInvDepotsCode = null,
-                    FromInvDepotSectionsCode = null,
-                    ToInvDepotsCode = stockBarcode.DepotsCode,
-                    ToInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
-                    Description = query.Type + "鎷嗗垎鐢熸垚",
-                    CreateBy = query.userName,
-                    CreateDate = DateTime.Now,
-                    LastupdateBy = query.userName,
-                    LastupdateDate = DateTime.Now,
-                    Factory = stockBarcode.Factory,
-                    Company = stockBarcode.Company,
-                    TaskNo = stockBarcode.TaskNo,
-                    BillNo = stockBarcode.BillNo,
-                    WorkNo = stockBarcode.WorkNo,
-                    WorkLine = stockBarcode.WorkLine,
-                    SuppNo = stockBarcode.SuppNo,
-                    SuppId = stockBarcode.SuppId,
-                    ItemId = stockBarcode.ItemId
-                    // CkDepot = stockBarcode.DepotsId
-                }).IgnoreColumns(true).ExecuteCommand();
-            }
-            else if (totalQty < query.Num)
-            {
-                throw new Exception("鍙戞枡鏁伴噺澶т簬鏉$爜鏁�,璇锋牳瀵癸紒");
-            }
-
-            //if (string.IsNullOrEmpty(newBarcode)) newBarcode = query.barcode;
-
-            // 妫�鏌ュ彂璐ч�氱煡鍗曠姸鎬�
-            var mesItemBl = Db.Queryable<MesItemBl>()
-                .Where(a => a.BlNo == query.blNo && (a.Bl018 ?? false) == true)
-                .First();
-
-            if (mesItemBl == null)
-                throw new Exception($"鐢宠鍗� {query.blNo} 宸叉挙鍥烇紒");
-
-            if (mesItemBl.Bl018 != true)
-                throw new Exception($"鐢宠鍗� {query.blNo} 鏈鏍革紒");
-
-            if (mesItemBl.Bl019 == true)
-                throw new Exception($"鐢宠鍗� {query.blNo} 宸插畬缁擄紒");
-
-            // 鑾峰彇鍙戣揣閫氱煡鍗曟槑缁嗗苟鏍¢獙
-            var blDetail = Db.Queryable<MesItemBlDetail>()
-                .Where(b =>
-                    b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId)
-                .First();
-
-            if (blDetail == null)
-                throw new Exception($"鐢宠鍗曚笉瀛樺湪姝ょ墿鏂� {stockBarcode.ItemNo} 璇风‘璁わ紒");
-
-            var remainingQty = (blDetail.Bld007 ?? 0) - (blDetail.Bld008 ?? 0);
-            if (remainingQty == 0)
-                throw new Exception("鐗╂枡宸叉壂鐮佸畬鎴愶紝璇锋牳瀵癸紒");
-
-            if (query.Num > remainingQty)
-                throw new Exception(
-                    $"鎷嗗垎鏁伴噺锛歿query.Num} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
-
-            // 妫�鏌ュ伐鍗曚俊鎭�
-            var womdaa = Db.Queryable<Womdaa>()
-                .Where(a => a.Daa001 == query.billNo)
-                .First();
-
-            if (womdaa == null)
-                throw new Exception($"宸ュ崟 {query.billNo} 涓嶅瓨鍦紝璇风‘璁わ紒");
-
-            var womdab = Db.Queryable<Womdab>()
-                .Where(b =>
-                    b.Dab001 == query.billNo && b.Erpid == blDetail.Bld014)
-                .First();
-
-            if (womdab == null)
-                throw new Exception($"澶囨枡鏄庣粏涓嶅瓨鍦ㄦ鐗╂枡 {stockBarcode.ItemNo} 璇风‘璁わ紒");
-
-            // 妫�鏌ュ凡鍙戞枡鏁伴噺鏄惁瓒呰繃寰呭彂鏂欐暟閲�
-            var sumQty = db.Queryable<MesInvItemOutCDetails>()
-                .Where(it =>
-                    it.TaskNo == query.blNo && it.ItemId == stockBarcode.ItemId)
-                .Sum(it => it.Quantity);
-
-            //if (sumQty > remainingQty)
-            //    throw new Exception(
-            //        $"鎷嗗垎鏁伴噺锛歿sumQty} 澶т簬寰呭彂鏂欐暟閲忥細{remainingQty}锛岃鏍稿锛�");
-
-
-            var depots = Db.Queryable<MesDepots>()
-                .Where(t => t.DepotId == stockBarcode.DepotId)
-                .First();
-
-            // 鑾峰彇鎴栧垱寤哄嚭搴撳崟
-            var itemOut = db.Queryable<MesInvItemOuts>()
-                .Where(a => a.TaskNo == query.blNo
-                            && a.DepotId == stockBarcode.DepotId
-                            && a.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
-                            DateTime.Now.Date.ToString("yyyy-MM-dd")
-                            && a.BillTypeId == 200
-                            && a.TransactionNo == 209
-                            && a.Status == 0)
-                .First();
-
-            var outId = new Guid();
-            var outNo = "";
-            if (itemOut == null)
-            {
-                // 鍒涘缓鏂扮殑鍑哄簱鍗�
-                outId = Guid.NewGuid();
-                outNo = BillNo.GetBillNo(outNoType);
-
-                // 鎻掑叆鍑哄簱鍗曚富琛�
-                executeCommand += db.Insertable(new MesInvItemOuts
-                {
-                    Guid = outId,
-                    ItemOutNo = outNo,
-                    TaskNo = query.blNo,
-                    CreateBy = query.userName,
-                    CreateDate = DateTime.Now,
-                    LastupdateBy = query.userName,
-                    LastupdateDate = DateTime.Now,
-                    BillTypeId = 200,
-                    TransactionNo = 209,
-                    Remark = mesItemBl.Bl007,
-                    DepotCode = depots.DepotCode,
-                    OutPart = womdaa.Daa013,
-                    FType = 0,
-                    Factory = stockBarcode.Factory,
-                    Company = stockBarcode.Company,
-                    WorkNo = womdaa.Daa021,
-                    BoardItem = womdaa.Daa002,
-                    PbillNo = womdaa.Daa001,
-                    OutDate = DateTime.Now,
-                    Status = 0,
-                    DepotId = stockBarcode.DepotId,
-                    THORGID = stockBarcode.StockOrgId,
-                    OutType = query.Type,
-                    //BbillNo = query.blNo
-                }).IgnoreColumns(true).ExecuteCommand();
-            }
-            else
-            {
-                outId = itemOut.Guid;
-                outNo = itemOut.ItemOutNo;
-            }
-
-            // 妫�鏌ユ槸鍚﹀凡瀛樺湪鍑哄簱鍗曟槑缁�
-            var itemOutItemCount = db.Queryable<MesInvItemOutItems>()
-                .Where(it =>
-                    it.ItemOutId == outId &&
-                    it.ItemId == stockBarcode.ItemId &&
-                    it.DepotId == stockBarcode.DepotId.ToString())
-                .Count();
-
-            if (itemOutItemCount == 0)
-                // 鎻掑叆鏂扮殑鍑哄簱鍗曟槑缁�
-                executeCommand += db.Insertable(new MesInvItemOutItems
-                {
-                    Guid = Guid.NewGuid(),
-                    ItemOutId = outId,
-                    ItemNo = blDetail.Bld002,
-                    Quantity = query.Num,
-                    TlQty = query.Num,
-                    CreateBy = query.userName,
-                    CreateDate = DateTime.Now,
-                    LastupdateBy = query.userName,
-                    LastupdateDate = DateTime.Now,
-                    Factory = stockBarcode.Factory,
-                    Company = stockBarcode.Company,
-                    DepotCode = depots.DepotCode,
-                    TaskNo = query.blNo,
-                    WorkNo = womdaa.Daa021,
-                    WorkLine = blDetail.Bld013,
-                    ErpItemNo = womdab.Dab003,
-                    ErpId = womdab.Eid,
-                    ErpAutoid = womdab.Erpid,
-                    PbillNo = query.billNo,
-                    ItemId = blDetail.Bld012,
-                    DepotId = stockBarcode.DepotId.ToString(),
-                    ItemDabid = womdab.Guid,
-                    // Unit = blDetail.Bld009,
-                    // DepotId = (int)stockBarcode.DepotsId
-                }).IgnoreColumns(true).ExecuteCommand();
-            else
-                // 鏇存柊宸叉湁鍑哄簱鍗曟槑缁嗘暟閲�
-                executeCommand += db.Updateable<MesInvItemOutItems>()
-                    .SetColumns(it => it.TlQty == (it.TlQty ?? 0) + query.Num)
-                    .Where(it =>
-                    it.ItemOutId == outId &&
-                    it.ItemId == stockBarcode.ItemId &&
-                    it.DepotId == stockBarcode.DepotId.ToString())
-                    .ExecuteCommand();
-
-            // 鎻掑叆鍑哄簱鏉$爜鏄庣粏
-            executeCommand += db.Insertable(new MesInvItemOutCDetails
-            {
-                Guid = Guid.NewGuid(),
-                ItemOutId = outId,
-                ItemBarcode = newBarcode ?? query.barcode,
-                ItemNo = stockBarcode.ItemNo,
-                LotNo = stockBarcode.LotNo,
-                Quantity = query.Num,
-                ForceOutFlag = 0,
-                CreateBy = query.userName,
-                CreateDate = DateTime.Now,
-                LastupdateBy = query.userName,
-                LastupdateDate = DateTime.Now,
-                DepotCode = depots.DepotCode,
-                DepotSectionCode = stockBarcode.DepotSectionsCode,
-                Remark = blDetail.Bld010,
-                Factory = stockBarcode.Factory,
-                Company = stockBarcode.Company,
-                TaskNoy = mesItemBl.Bl013,
-                BoardStyle = mesItemBl.Bl002,
-                TaskNo = query.blNo,
-                WorkNo = blDetail.Bld001,
-                WorkLine = blDetail.Bld013,
-                SuppNo = stockBarcode.SuppNo,
-                PbillNo = query.billNo,
-                ItemId = blDetail.Bld012,
-                Unit = blDetail.Bld009,
-                DepotId = (int)stockBarcode.DepotsId,
-                Dabid = womdab.Guid,
-            }).IgnoreColumns(true).ExecuteCommand();
-
-            // 鎻掑叆涓氬姟娴佹按
-            executeCommand += db.Insertable(new MesInvBusiness2
-            {
-                Guid = Guid.NewGuid(),
-                Status = 1,
-                BillTypeId = 200, // p_bill_type_id
-                TransactionCode = "209", // p_transaction_no 
-                BusinessType = 1,
-                ItemBarcode = newBarcode ?? query.barcode,
-                ItemNo = stockBarcode.ItemNo,
-                LotNo = stockBarcode.LotNo,
-                EpFlag = true,
-                Quantity = query.Num,
-                FromInvDepotsCode = stockBarcode.DepotsCode,
-                FromInvDepotSectionsCode = stockBarcode.DepotSectionsCode,
-                Description = query.Type,
-                CreateBy = query.userName,
-                CreateDate = DateTime.Now,
-                LastupdateBy = query.userName,
-                LastupdateDate = DateTime.Now,
-                Factory = stockBarcode.Factory,
-                Company = stockBarcode.Company,
-                TaskNo = mesItemBl.Bl012,
-                BillNo = query.blNo,
-                WorkNo = blDetail.Bld001,
-                WorkLine = blDetail.Bld013,
-                SuppNo = stockBarcode.SuppNo,
-                ItemId = stockBarcode.ItemId
-                // CkDepot = stockBarcode.DepotsId
-            }).IgnoreColumns(true).ExecuteCommand();
-
-            // 鏇存柊宸ュ崟琛ㄦ暟閲�
-            executeCommand += db.Updateable<Womdab>()
-                .SetColumns(it => new Womdab
-                {
-                    Dab007 = (it.Dab007 ?? 0) + query.Num, // 宸ュ崟鏁伴噺
-                    Dab020 = (it.Dab020 ?? 0) + query.Num, // 宸插彂鏂欐暟閲�
-                    Dab021 = (it.Dab021 ?? 0) + query.Num // 宸插彂鏂欐暟閲�
-                })
-                .Where(it => it.Guid == womdab.Guid && it.Dab003 == womdab.Dab003)
-                .ExecuteCommand();
-
-            // 鏇存柊鍙戣揣閫氱煡鍗曟槑缁嗗凡琛ユ暟閲�
-            executeCommand += db.Updateable<MesItemBlDetail>()
-                .SetColumns(it => new MesItemBlDetail
-                {
-                    Bld008 = (it.Bld008 ?? 0) + (int)query.Num
-                })
-                .Where(it => it.Id == blDetail.Id)
-                .ExecuteCommand();
-
-            // 鑾峰彇鏇存柊鍚庣殑鍙戣揣閫氱煡鍗曟槑缁嗘暟閲�
-            var updatedDetail = db.Queryable<MesItemBlDetail>()
-                .Where(it => it.Id == blDetail.Id)
-                .Select(it => new { it.Bld007, it.Bld008 })
-                .First();
-
-            if ((updatedDetail.Bld007 ?? 0) <= (updatedDetail.Bld008 ?? 0))
-                // 鏇存柊鏄庣粏瀹屾垚鐘舵��
-                executeCommand += db.Updateable<MesItemBlDetail>()
-                    .SetColumns(it => new MesItemBlDetail { Bld011 = 1 })
-                    .Where(it => it.Id == blDetail.Id)
-                    .ExecuteCommand();
-
-            // 妫�鏌ユ槸鍚﹁繕鏈夋湭瀹屾垚鐨勬槑缁�
-
-            var unfinishedDetail = db.Queryable<MesItemBlDetail>()
-                .Where(it => it.Mid == mesItemBl.Id && (it.Bld011 ?? 0) == 0)
-                .First();
-
-            if (unfinishedDetail == null)
-                // 濡傛灉娌℃湁鎵惧埌鏈畬鎴愭槑缁嗭紝鍒欐洿鏂板彂璐ч�氱煡鍗曠姸鎬佷负宸插畬鎴�
-                executeCommand += db.Updateable<MesItemBl>()
-                    .SetColumns(it => new MesItemBl
+                    conn.Open();
+                    cmd.CommandType = CommandType.StoredProcedure;
+                    SqlParameter[] parameters =
                     {
-                        Bl019 = true,
-                        WcUser = query.userName,
-                        WcTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
-                    })
-                    .Where(it => it.Id == mesItemBl.Id)
-                    .ExecuteCommand();
+                        new("@outMsg", SqlDbType.NVarChar, 2000),
+                        new("@outSum", SqlDbType.NVarChar, 300),
+                        new("@outCfBar", SqlDbType.NVarChar, 300),
+                        new("@c_user", query.userName),
+                        new("@p_biLL_no", query.billNo),
+                        new("@p_item_barcode", query.barcode),
+                        new("@NUM", query.Num)
+                    };
+                    parameters[0].Direction = ParameterDirection.Output;
+                    parameters[1].Direction = ParameterDirection.Output;
+                    parameters[2].Direction = ParameterDirection.Output;
+                    foreach (var parameter in parameters)
+                        cmd.Parameters.Add(parameter);
+                    cmd.ExecuteNonQuery();
+                    _strMsg = parameters[0].Value.ToString();
+                    _intSum = parameters[1].Value.ToString();
+                    _cfBar = parameters[2].Value.ToString();
 
-            if (executeCommand <= 1) throw new Exception("鏇存柊澶辫触");
 
-            return executeCommand;
-        }) > 0;
+                    var result = Convert.ToInt32(_intSum);
+                    if (result <= 0) throw new Exception(_strMsg);
 
-        // 鑾峰彇鏈�缁堢殑寰呭彂鏂欐槑缁嗗垪琛�
-        var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) =>
-                new JoinQueryInfos(JoinType.Left, a.Id == b.Mid))
-            .Where((a, b) => a.BlNo == query.blNo
-                             && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0)
-            .Select((a, b) => new MesItemBlDetail
-            {
-                Bld012 = b.Bld012,
-                Bld002 = b.Bld002,
-                Bld003 = b.Bld003,
-                Bld004 = b.Bld004,
-                Bld007 = b.Bld007,
-                Bld008 = b.Bld008
-            })
-            .ToList();
+                    var dto = new ProductionPickDto
+                    {
+                        daa001 = query.billNo,
+                        barcode = query.barcode,//鍘熸潯鐮�
+                        cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮�
+                    };
 
-        return (success, pendingList);
+                    return dto;
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+        }
     }
-
-    #endregion
-
+        #endregion
 }
\ No newline at end of file

--
Gitblit v1.9.3