From ae03ec7001b6ba415fa5ccac7c6ff06c81578eb1 Mon Sep 17 00:00:00 2001
From: test <15284381150@163.com>
Date: 星期五, 19 九月 2025 08:02:38 +0800
Subject: [PATCH] Merge branch 'djp'

---
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs |  826 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 776 insertions(+), 50 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index ba7f4bd..5ce43ae 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -1,6 +1,8 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
+using System.Reflection.Metadata;
 using System.Security.Cryptography.X509Certificates;
 using System.Text;
 using System.Threading.Tasks;
@@ -9,6 +11,7 @@
 using Model.ModelDto;
 using Model.ModelDto.BllCheckDto;
 using Model.ModelDto.PdaDto;
+using Model.ModelDto.SysDto;
 using Newtonsoft.Json;
 using SqlSugar;
 using Utility;
@@ -417,15 +420,70 @@
         /// <param name="locatNo">鍌ㄤ綅缂栧彿</param>
         /// <param name="palletNo">鎵樼洏鍙�</param> 
         /// <returns></returns>
-        public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
+        //public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
+        //{
+        //    return await Db.Queryable<DataStockDetail>()
+        //             .Where(s => s.IsDel == "0" && s.LocatNo.Contains(locatNo) || s.PalletNo.Contains(palletNo))
+        //             .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
+        //             .ToListAsync();
+        //}
+        public async Task<List<StockDetailWithQtyDto>> GetStockQueryList(string locatNo, string palletNo, string boxNo)
         {
-            return await Db.Queryable<DataStockDetail>()
-                     .Where(s => s.IsDel == "0" && s.LocatNo.Contains(locatNo) && s.PalletNo.Contains(palletNo))
-                     .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
-                     .ToListAsync();
-
+                return await Db.Queryable<DataStockDetail>("a")
+                    .InnerJoin<DataBoxInfo>((a, b) => a.LotNo == b.LotNo)
+                    .Where((a, b) => a.IsDel == "0")
+                    .WhereIF(!string.IsNullOrWhiteSpace(locatNo), (a, b) => a.LocatNo.Contains(locatNo))
+                    .WhereIF(!string.IsNullOrWhiteSpace(palletNo), (a, b) => a.PalletNo.Contains(palletNo))
+                    .WhereIF(!string.IsNullOrWhiteSpace(boxNo), (a, b) => b.BoxNo.Contains(boxNo))
+                    .OrderBy((a, b) => new { a.LotNo, a.LocatNo, a.PalletNo })
+                    .Select((a, b) => new StockDetailWithQtyDto
+                    {
+                        LotNo = a.LotNo,
+                        LotText = a.LotText,
+                        SupplierLot = a.SupplierLot,
+                        OwnerNo = a.OwnerNo,
+                        OwnerName = a.OwnerName,
+                        SupplierNo = a.SupplierNo,
+                        SupplierName = a.SupplierName,
+                        SkuNo = a.SkuNo,
+                        SkuName = a.SkuName,
+                        Standard = a.Standard,
+                        Qty = b.Qty,  // DataBoxInfo鐨凲ty瀛楁
+                        LockQty = a.LockQty,
+                        FrozenQty = a.FrozenQty,
+                        InspectQty = a.InspectQty,
+                        ASNNo = a.ASNNo,
+                        ASNDetailNo = a.ASNDetailNo,
+                        SONo = a.SONo,
+                        WareHouseNo = a.WareHouseNo,
+                        RoadwayNo = a.RoadwayNo,
+                        AreaNo = a.AreaNo,
+                        LocatNo = a.LocatNo,
+                        PalletNo = a.PalletNo,
+                        PalletNo2 = a.PalletNo2,
+                        PalletNo3 = a.PalletNo3,
+                        PalletTags = a.PalletTags,
+                        CompleteTime = a.CompleteTime,
+                        ProductionTime = a.ProductionTime,
+                        ExpirationTime = a.ExpirationTime,
+                        Status = a.Status,
+                        InspectMark = a.InspectMark,
+                        BitPalletMark = a.BitPalletMark,
+                        InspectStatus = a.InspectStatus,
+                        InspectTime = a.InspectTime,
+                        PackagNo = a.PackagNo,
+                        IsBale = a.IsBale,
+                        IsBelt = a.IsBelt,
+                        UDF5 = a.UDF5,
+                        IsDel = a.IsDel,
+                        CreateTime = a.CreateTime,
+                        CreateUser = a.CreateUser,
+                        UpdateTime = a.UpdateTime,
+                        UpdateUser = a.UpdateUser,
+                        Demo = a.Demo
+                    })
+                    .ToListAsync();
         }
-
         #endregion
 
         #region 鎵樼洏鍙樻洿锛堟墭鐩樿В缁戠粦瀹氾級
@@ -691,9 +749,9 @@
             {
                 throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
             }
-            if (models.WareHouseNo != "W04")
+            if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
             {
-                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴鎴栬揣鏋跺簱鍐�,璇锋鏌�!");
             }
             return models.LocatNo;
         }
@@ -721,7 +779,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (models.WareHouseNo != "W04")
+                if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -731,8 +789,14 @@
                     throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
 
-                
-                storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+                if (models.WareHouseNo == "W02")
+                {
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04" && (w.AreaNo == "B01" || w.AreaNo == "B02")).OrderBy(o => o.AreaNo).ToListAsync();
+                }
+                else
+                {
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo != storageLocat.AreaNo && w.WareHouseNo == "W04").OrderBy(o => o.AreaNo).ToListAsync();
+                }
                 
             }
             return storageArea;
@@ -779,7 +843,7 @@
         /// <param name="palletNo"></param>
         /// <param name="areaNo"></param>
         /// <param name="ruku"></param>
-        public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
+        /*public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
         {
             try
             {
@@ -829,7 +893,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (stockDetail.WareHouseNo != "W04")
+                if (stockDetail.WareHouseNo != "W04" && stockDetail.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -927,6 +991,339 @@
                     if (wcsModel.code == 200)
                     {
                        // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+                        new TaskServer().EditTaskIssueOk(list2, time1, time2);
+                    }
+                    else
+                    {
+                        new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.message);
+                        throw new Exception(wcsModel.message);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }*/
+
+        public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(palletNo))
+                {
+                    throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+                }
+                if (string.IsNullOrEmpty(areaNo) && string.IsNullOrEmpty(ruku))
+                {
+                    throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�");
+                }
+                if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku))
+                {
+                    throw Oops.Bah("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�");
+                }
+                string EndLocat = string.Empty;//鐩爣浣嶇疆                
+
+                var log = await Db.Queryable<LogTask>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+                if (log != null)
+                {
+                    throw Oops.Bah("璇ユ墭鐩樺凡鏈夌瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+                }
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (stockDetail == null)
+                {
+                    throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!");
+                }
+                if (!string.IsNullOrEmpty(areaNo))
+                {
+                    var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+                    if (storageArea == null)
+                    {
+                        throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+                    }
+                    EndLocat = await GetLocat(areaNo);
+                }
+                else
+                {
+                    EndLocat = ruku;
+                }
+                var stock = await Db.Queryable<DataStock>().FirstAsync(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
+                if (stock == null)
+                {
+                    throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+                }
+                if (string.IsNullOrEmpty(stockDetail.LocatNo))
+                {
+                    throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                if (stockDetail.WareHouseNo != "W04")
+                {
+                    throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+                }
+
+                //璧峰鍌ㄤ綅淇℃伅
+                var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+                if (storageLocat == null)
+                {
+                    throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                //鐩爣鍌ㄤ綅淇℃伅
+                //var storageLocatEnd = new SysStorageLocat();
+
+                var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
+                if (storageLocatEnd == null)
+                {
+                    throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+
+
+                //娣诲姞鍑哄簱浠诲姟
+                var taskNo = new Common().GetMaxNo("TK");
+                var moveTask = new LogTask
+                {
+                    TaskNo = taskNo,
+                    Sender = "WMS",
+                    Receiver = "WCS",
+                    IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+                    StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+                    EndLocat = EndLocat,//鐩爣浣嶇疆
+                    PalletNo = palletNo,//鎵樼洏鐮�
+                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", stockDetail.LocatNo, EndLocat),
+                    IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+                    IsCancel = 1,//鏄惁鍙彇娑�
+                    IsFinish = 1,//鏄惁鍙畬鎴�
+                    Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
+                    Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+                    OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
+
+                    CreateTime = DateTime.Now
+                };
+                await Db.Insertable(moveTask).ExecuteCommandAsync();
+
+                //淇敼搴撳瓨鏄庣粏淇℃伅
+                //stockDetail.Status = "4";//绉诲簱閿佸畾
+                //stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
+                //await Db.Updateable(stockDetail).ExecuteCommandAsync();
+                ////淇敼搴撳瓨淇℃伅
+                //stock.LockQty += (decimal)stockDetail.Qty;
+                //await Db.Updateable(stock).ExecuteCommandAsync();
+
+                //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
+                storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                await Db.Updateable(storageLocat).ExecuteCommandAsync();
+
+                //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
+                if (storageLocatEnd != null)
+                {
+                    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                    await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+                }
+                //娣诲姞鎿嶄綔鏃ュ織璁板綍
+                var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+
+                var outDto = new List<OutCommandDto>
+                {
+                    new OutCommandDto()
+                    {
+                        TaskNo = moveTask.TaskNo, // 浠诲姟鍙�
+                        TaskType = "2",// 浠诲姟绫诲瀷 0鍏� 1鍑� 2绉� 
+                        PalletNo = moveTask.PalletNo,//鎵樼洏鍙�
+
+                        StartLocate = moveTask.StartLocat, // 璧峰浣嶇疆
+                        EndLocate = EndLocat, // 鐩爣浣嶇疆 
+
+                        Order = 999,
+                        Type = PLCTypeEnum.AGV
+
+                    }
+                };
+
+                // 姝e紡杩愯绋嬪簭鏀惧紑
+                var list2 = outDto.Select(m => m.TaskNo).ToList();
+                var jsonData = JsonConvert.SerializeObject(outDto);
+                string response = "";
+
+                try
+                {
+                    var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+                    response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+                    var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+
+                    //瑙f瀽杩斿洖鏁版嵁 
+                    var wcsModel = JsonConvert.DeserializeObject<WcsModel2>(response);
+                    if (wcsModel.code == 200)
+                    {
+                        // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+                        new TaskServer().EditTaskIssueOk(list2, time1, time2);
+                    }
+                    else
+                    {
+                        new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.message);
+                        throw new Exception(wcsModel.message);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+        /// <summary>
+        /// 鍛煎彨agv杞繍绌烘墭鐩�
+        /// </summary>
+        /// <param name="palletNo"></param>
+        /// <param name="areaNo"></param>
+        /// <param name="locatNo"></param>
+        /// <param name="url"></param>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public async Task AgvNullPallet(string palletNo, string areaNo, string locatNo, string url, int userId)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(palletNo))
+                {
+                    throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+                }
+                if (string.IsNullOrEmpty(locatNo))
+                {
+                    throw Oops.Bah("璇锋壂鎻忚捣濮嬪湴鐮侊紒");
+                }
+                if (string.IsNullOrEmpty(areaNo))
+                {
+                    throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙锛�");
+                }
+                string EndLocat = string.Empty;//鐩爣浣嶇疆                
+
+                var log = await Db.Queryable<LogTask>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+                if (log != null)
+                {
+                    throw Oops.Bah("璇ユ墭鐩樺凡鏈夌瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+                }
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (stockDetail != null)
+                {
+                    throw Oops.Bah("鎵樼洏涓婄墿鏂欏瓨鍦ㄥ簱瀛樻槑缁嗕俊鎭�,璇锋鏌�!");
+                }
+
+                var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+                if (storageArea == null)
+                {
+                    throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+                }
+                var palletInfo = await Db.Queryable<SysPallets>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (palletInfo == null)
+                {
+                    throw Oops.Bah("璇ユ墭鐩樹俊鎭笉瀛樺湪!");
+                }
+                if (palletInfo.Status!="0")
+                {
+                    throw Oops.Bah("璇ユ墭鐩樹笉鏄┖鎵樼洏!");
+                }
+                //鏍规嵁鐩爣鍖哄煙鑾峰彇鐩爣鍌ㄤ綅鍦板潃
+                EndLocat = await GetLocat(areaNo);
+                if (string.IsNullOrEmpty(EndLocat))
+                {
+                    throw Oops.Bah("鑾峰彇鐩爣鍌ㄤ綅澶辫触!");
+                }
+                
+                //璧峰鍌ㄤ綅淇℃伅
+                var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == locatNo);
+                if (storageLocat == null)
+                {
+                    throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                //鐩爣鍌ㄤ綅淇℃伅
+                //var storageLocatEnd = new SysStorageLocat();
+
+                var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
+                if (storageLocatEnd == null)
+                {
+                    throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+
+                //娣诲姞鍑哄簱浠诲姟
+                var taskNo = new Common().GetMaxNo("TK");
+                var moveTask = new LogTask
+                {
+                    TaskNo = taskNo,
+                    Sender = "WMS",
+                    Receiver = "WCS",
+                    IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+                    StartLocat = storageLocat.LocatNo,//璧峰浣嶇疆
+                    EndLocat = EndLocat,//鐩爣浣嶇疆
+                    PalletNo = palletNo,//鎵樼洏鐮�
+                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", storageLocat.LocatNo, EndLocat),
+                    IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+                    IsCancel = 1,//鏄惁鍙彇娑�
+                    IsFinish = 1,//鏄惁鍙畬鎴�
+                    Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
+                    Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+                    OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
+
+                    CreateTime = DateTime.Now
+                };
+                await Db.Insertable(moveTask).ExecuteCommandAsync();
+
+                //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
+                storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                await Db.Updateable(storageLocat).ExecuteCommandAsync();
+
+                //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
+                //if (storageLocatEnd != null)
+                //{
+                //    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                //    await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+                //}
+                //娣诲姞鎿嶄綔鏃ュ織璁板綍
+                var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV绌烘墭杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+
+                var outDto = new List<OutCommandDto>
+                {
+                    new OutCommandDto()
+                    {
+                        TaskNo = moveTask.TaskNo, // 浠诲姟鍙�
+                        TaskType = "2",// 浠诲姟绫诲瀷 0鍏� 1鍑� 2绉� 
+                        PalletNo = moveTask.PalletNo,//鎵樼洏鍙�
+
+                        StartLocate = moveTask.StartLocat, // 璧峰浣嶇疆
+                        EndLocate = EndLocat, // 鐩爣浣嶇疆 
+
+                        Order = 999,
+                        Type = PLCTypeEnum.AGV
+
+                    }
+                };
+
+                // 姝e紡杩愯绋嬪簭鏀惧紑
+                var list2 = outDto.Select(m => m.TaskNo).ToList();
+                var jsonData = JsonConvert.SerializeObject(outDto);
+                string response = "";
+
+                try
+                {
+                    var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+                    response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+                    var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+
+                    //瑙f瀽杩斿洖鏁版嵁 
+                    var wcsModel = JsonConvert.DeserializeObject<WcsModel2>(response);
+                    if (wcsModel.code == 200)
+                    {
+                        // 鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
                         new TaskServer().EditTaskIssueOk(list2, time1, time2);
                     }
                     else
@@ -1105,9 +1502,18 @@
             string endLocat = string.Empty;//鐩爣鍌ㄤ綅
             //褰撳墠鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
             var storageLocatList = await Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W04" && w.AreaNo == areaNo).ToListAsync();
-           
-            var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+
+            var locatInfo2 = new SysStorageLocat();
+            if (areaNo == "B10")
+            {
+                locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0")
                            .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+            }
+            else
+            {
+                locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+                               .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+            }            
 
             if (locatInfo2 != null)
             {
@@ -1217,7 +1623,7 @@
         /// <param name="boxNo"></param>
         /// <param name="devanQty"></param>
         /// <param name="userId"></param>
-        public void AddLableByDevanning(string boxNo, decimal devanQty, int userId)
+        public BoxListInfoDto AddLableByDevanning(string boxNo, decimal devanQty, int userId)
         {
             try
             {
@@ -1227,9 +1633,9 @@
                 }
                 //寮�鍚簨鍔�
                 Db.BeginTran();
-                
+
                 //搴撳瓨绠辨敮鏄庣粏淇℃伅
-                var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == boxNo).ToList();
+                var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == boxNo && w.Status == "2").ToList();
                 if (boxList.Count != 1)
                 {
                     throw new Exception("璇ョ鐮佷俊鎭敊璇紝瀛樺湪澶氫釜姝ょ鐮佷俊鎭�");
@@ -1293,6 +1699,23 @@
                 new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鎷嗙璐存爣锛氬師绠辩爜锛歿boxNo}鎷嗙锛屾坊鍔犳柊绠辩爜{boxNoNew}", userId);
                 //鎻愪氦浜嬪姟
                 Db.CommitTran();
+
+                #region 鑾峰彇鎷嗙鐨勪俊鎭墦鍗�
+
+                
+                var data = new BoxListInfoDto()
+                {
+                    SkuNo = boxInfo.SkuNo,
+                    SkuName = boxInfo.SkuName,
+                    LotNo = boxInfo.LotNo,
+                    BoxNoList = new List<string>() { boxNoNew } ,
+                    Date1 = boxInfo.ProductionTime == null ? "" : Convert.ToDateTime(boxInfo.ProductionTime).ToString("yyyy-MM-dd"),
+                    Date2 = boxInfo.ExpirationTime == null ? "" : Convert.ToDateTime(boxInfo.ExpirationTime).ToString("yyyy-MM-dd"),
+                };
+                
+                #endregion
+
+                return data;
             }
             catch (Exception e)
             {
@@ -1321,15 +1744,15 @@
                 {
                     throw new Exception("鎵樼洏娌℃湁鍑哄簱鍗曚俊鎭�");
                 }
-                var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
-                if (task == null)
-                {
-                    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
-                }
-                if (task.Status != "5")
-                {
-                    throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
-                }
+                //var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
+                //if (task == null)
+                //{
+                //    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+                //}
+                //if (task.Status != "5")
+                //{
+                //    throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
+                //}
                 return detail;
             }
             catch (Exception e)
@@ -1349,20 +1772,26 @@
             try
             {
                 Db.BeginTran();
-                var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
-                if (task == null)
+                //var task = Db.Queryable<LogTask>().First(m => m.PalletNo == palletNo && m.IsDel == "0" && m.Status == "5");
+                //if (task == null)
+                //{
+                //    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+                //}
+                //if (task.Status != "5")
+                //{
+                //    throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
+                //}
+                ////浠诲姟鐘舵�佸彉鏇翠负鎵ц瀹屾垚
+                //task.Status = "2";
+                //Db.Updateable(task).ExecuteCommand();
+                var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+                if (stockDetail.Count == 0)
                 {
-                    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹换鍔′俊鎭�");
+                    throw new Exception("搴撳瓨鎵樼洏娌℃湁淇℃伅");
                 }
-                if (task.Status != "5")
-                {
-                    throw new Exception("浠诲姟鐘舵�佷笉鏄瓑寰呯‘璁�");
-                }
-                //浠诲姟鐘舵�佸彉鏇翠负鎵ц瀹屾垚
-                task.Status = "2";
-                Db.Updateable(task).ExecuteCommand();
-                var locatList = Db.Queryable<SysStorageLocat>().Where(m=>m.WareHouseNo == "W04" && (m.AreaNo == "B06" || m.AreaNo == "B07") && m.IsDel == "0").ToList();
-                var locat = locatList.FirstOrDefault(m => m.LocatNo == task.EndLocat);
+                var locate = stockDetail.First().LocatNo;
+                var locatList = Db.Queryable<SysStorageLocat>().Where(m=>m.WareHouseNo == "W04" && (m.AreaNo == "B06" || m.AreaNo == "B07" || m.AreaNo == "B09") && m.IsDel == "0").ToList();
+                var locat = locatList.FirstOrDefault(m => m.LocatNo == locate);
                 //鍒ゆ柇鎵樼洏鍌ㄤ綅鏄惁鍦ㄨ溅闂�
                 if (locat == null)
                 {
@@ -1371,7 +1800,7 @@
                 locat.Status = "0";
                 Db.Updateable(locat).ExecuteCommand();
                 //鍒ゆ柇鎵樼洏淇℃伅
-                var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+                
                 foreach (var item in stockDetail)
                 {
                     if (item.UDF5 != "1" || string.IsNullOrWhiteSpace(item.SONo))
@@ -1383,7 +1812,7 @@
                     //item.RoadwayNo = "";
                     //item.AreaNo = "";
                     item.LocatNo = "";
-                    item.PalletNo = "";
+                    //item.PalletNo = "";
                     item.LockQty = 0; // 閿佸畾鏁伴噺鏇翠负0
                     item.Status = "0"; // 鐘舵�佸彉涓哄緟鍒嗛厤
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.StockDetailId == item.Id).ToList();
@@ -1396,15 +1825,15 @@
                 }
                 Db.Updateable(stockDetail).ExecuteCommand();
                 //鎵樼洏鍙樻洿鐘舵��
-                var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
-                if (pallet == null)
-                {
-                    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹俊鎭�");
-                }
-                pallet.Status = "0";
-                Db.Updateable(pallet).ExecuteCommand();
+                //var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                //if (pallet == null)
+                //{
+                //    throw new Exception("娌℃湁鏌ヨ鍒版墭鐩樹俊鎭�");
+                //}
+                //pallet.Status = "0";
+                //Db.Updateable(pallet).ExecuteCommand();
                 //娣诲姞鎿嶄綔鏃ュ織
-                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", palletNo, "缂栬緫", $"杞﹂棿鏀惰揣锛歿palletNo}鎵樼洏鏀惰揣", userId);
+                new OperationCrServer().AddLogOperationCr("PDA妯″潡", "杞﹂棿鏀惰揣", palletNo, "瀹屾垚", $"杞﹂棿鏀惰揣锛歿palletNo}鎵樼洏鏀惰揣", userId);
                 Db.CommitTran();
             }
             catch (Exception e)
@@ -1418,5 +1847,302 @@
 
         #endregion
 
+        #region 鐗╂枡鎷嗘墭 锛堟爣绛俱�佹暟閲忥級
+
+        /// <summary>
+        /// 鏌ヨ绠变俊鎭�
+        /// </summary>
+        /// <param name="boxNo"></param>
+        /// <param name="pallNo"></param>
+        public void GetBoxInfo(string boxNo,string pallNo)
+        {
+            try
+            {
+                var boxInfo = Db.Queryable<DataBoxInfo>().Where(m=>m.IsDel == "0" && m.BoxNo == boxNo).ToList();
+                if (!string.IsNullOrWhiteSpace(pallNo))
+                {
+                    boxInfo = boxInfo.Where(m=>m.PalletNo == pallNo).ToList();
+                }
+                if (boxInfo.Count!=1)
+                {
+                    throw new Exception("鏍囩淇℃伅閿欒锛岃鑱旂郴绠$悊鍛�");
+                }
+                
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+
+        public void UpPalletByBox(string boxNo,string pallet,string palletNew,int userId)
+        {
+            try
+            {
+                Db.BeginTran();
+                if (string.IsNullOrWhiteSpace(boxNo) || string.IsNullOrWhiteSpace(pallet) || string.IsNullOrWhiteSpace(palletNew))
+                {
+                    throw new Exception("鍙傛暟閿欒锛屾墭鐩樸�佹柊鎵樼洏銆佺鐮佸潎涓嶈兘涓虹┖");
+                }
+                var boxInfoList = Db.Queryable<DataBoxInfo>().Where(m=>m.IsDel == "0" && m.BoxNo == boxNo).ToList();
+                if (boxInfoList.Count != 1)
+                {
+                    throw new Exception("鏍囩淇℃伅鏁伴噺涓嶆槸1鏉�");
+                }
+                var boxInfo = boxInfoList.First();
+                var detail1 = Db.Queryable<DataStockDetail>().First(m=>m.IsDel == "0" && m.PalletNo == pallet && m.Id == boxInfo.StockDetailId );
+                if (detail1 == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鎵樼洏鍜岀鐮佺殑搴撳瓨鏄庣粏");
+                }
+                var palletInfoNew = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNew);
+                if (palletInfoNew == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鏂版墭鐩樹俊鎭�");
+                }
+                var detailNewBl = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNew && (m.SkuNo != boxInfo.SkuNo || m.LotNo != boxInfo.LotNo));
+                if (detailNewBl!=null)
+                {
+                    throw new Exception("鏂版墭鐩樹笂宸叉湁鍏朵粬鐗╂枡绠变俊鎭�");
+                }
+                //娣诲姞/鏇存柊搴撳瓨鎵樼洏淇℃伅
+                var detailNew1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNew && m.SkuNo == boxInfo.SkuNo && m.LotNo == boxInfo.LotNo);
+                var newId = 0;
+                if (detailNew1 == null)//add
+                {
+                    var detailNew = new DataStockDetail();
+                    detailNew.SkuNo = detail1.SkuNo;
+                    detailNew.SkuName = detail1.SkuName;
+                    detailNew.LotNo = detail1.LotNo;
+                    detailNew.LotText = detail1.LotText;
+                    detailNew.SupplierLot = detail1.SupplierLot;
+                    detailNew.SupplierNo = detail1.SupplierNo;
+                    detailNew.SupplierName = detail1.SupplierName;
+                    detailNew.Standard = detail1.Standard;
+                    detailNew.Qty = boxInfo.Qty;
+                    detailNew.LockQty = 0;
+                    detailNew.FrozenQty = 0;
+                    detailNew.InspectQty = 0; 
+                    detailNew.ASNNo = "";
+
+                    detailNew.PalletNo = palletNew;
+                    detailNew.ProductionTime = detail1.ProductionTime;
+                    detailNew.ExpirationTime = detail1.ExpirationTime;
+                    detailNew.PalletTags = "0";
+                    detailNew.CompleteTime = DateTime.Now;
+                    detailNew.Status = "0";
+                    detailNew.InspectMark = detail1.InspectMark;
+                    detailNew.BitPalletMark = "1";
+                    detailNew.InspectStatus = detail1.InspectStatus;
+                    detailNew.PackagNo = detail1.PackagNo;
+                    detailNew.IsBale = detail1.IsBale;
+                    detailNew.IsBelt = detail1.IsBelt;
+                    detailNew.IsDel = "0";
+                    detailNew.CreateTime = DateTime.Now;
+                    detailNew.CreateUser = 0;
+
+
+                    newId = Db.Insertable(detailNew).ExecuteReturnIdentity();
+                }
+                else //update
+                {
+                    detailNew1.Qty += boxInfo.Qty;
+                    detailNew1.PalletNo = palletNew;
+
+                    Db.Updateable(detailNew1).ExecuteCommand();
+                    newId = detailNew1.Id;
+                }
+                //鏇存柊鎵樼洏鐘舵��
+                palletInfoNew.Status = "1";
+                Db.Updateable(palletInfoNew).ExecuteCommand();
+
+                //鏇存敼鍘熸墭鐩樹俊鎭�
+                detail1.Qty -= boxInfo.Qty;
+                detail1.BitPalletMark = "1";
+                if (detail1.Qty <= 0)
+                {
+                    //鏇存柊鍘熸墭鐩樼姸鎬�
+                    var palletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == pallet);
+                    palletInfo.Status = "0";
+                    Db.Updateable(palletInfo).ExecuteCommand();
+
+                    Db.Deleteable(detail1).ExecuteCommand();
+                }
+                else
+                {
+                    Db.Updateable(detail1).ExecuteCommand();
+                }
+
+                //鏇存柊搴撳瓨绠变俊鎭�
+                boxInfo.StockDetailId = newId;
+                boxInfo.BindNo = 0;
+                boxInfo.PalletNo = palletNew;
+                Db.Updateable(boxInfo).ExecuteCommand();
+                //娣诲姞鎿嶄綔鏃ュ織
+                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鐗╂枡鎷嗘墭锛氱鐮侊細{boxNo}鎹㈡墭锛屽師鎵樼洏{pallet}锛屾柊鎵樼洏{palletNew}", userId);
+
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                Db.RollbackTran();
+                throw new Exception(e.Message);
+            }
+        }
+
+        //鏁伴噺椤电-----------------------------------------------------------------------------------------------------------------------------------------
+
+        /// <summary>
+        /// 鏍规嵁鎵樼洏鑾峰彇鎵樼洏涓婄殑鐗╂枡鎵规淇℃伅
+        /// </summary>
+        /// <param name="palletNo"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public List<SelectSkuLotNo> GetSelectSkuLotNo(string palletNo)
+        {
+            try
+            {
+                var data = new List<SelectSkuLotNo>();
+                var detailList = Db.Queryable<DataStockDetail>().Where(m=>m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+
+                foreach (var item in detailList)
+                {
+                    if (data.Count(m=>m.DetailId == item.Id.ToString()) == 0)
+                    {
+                        data.Add(new SelectSkuLotNo()
+                        {
+                            SkuNo = item.SkuNo,
+                            SkuName = item.SkuName,
+                            LotNo = item.LotNo,
+                            DetailId = item.Id.ToString(),
+                        });
+                    }
+                }
+                return data;
+
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+
+
+        /// <summary>
+        /// 鎷嗘墭-鏁伴噺
+        /// </summary>
+        /// <param name="palletNo"></param>
+        /// <param name="palletNoNew"></param>
+        /// <param name="detailId"></param>
+        /// <param name="qty"></param>
+        /// <param name="userId"></param>
+        /// <exception cref="Exception"></exception>
+        public void UpPalletByQty(string palletNo,string palletNoNew,string detailId,decimal qty,int userId)
+        {
+            try
+            {
+                Db.BeginTran();
+                if (string.IsNullOrWhiteSpace(detailId) || string.IsNullOrWhiteSpace(palletNo) || string.IsNullOrWhiteSpace(palletNoNew))
+                {
+                    throw new Exception("鍙傛暟閿欒锛屾墭鐩樸�佹柊鎵樼洏銆佺墿鏂欐壒娆″潎涓嶈兘涓虹┖");
+                }
+                if (qty<=0)
+                {
+                    throw new Exception("鍙傛暟鏁伴噺涓嶈兘涓哄皬绛�0");
+                }
+                 var detailId2 = int.Parse(detailId);
+                var detail1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id == detailId2);
+                if (detail1 == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鎵樼洏搴撳瓨鏄庣粏");
+                }
+                var palletInfoNew = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
+                if (palletInfoNew == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鏂版墭鐩樹俊鎭�");
+                }
+                
+                //娣诲姞/鏇存柊搴撳瓨鎵樼洏淇℃伅
+                var detailNew1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.SkuNo == detail1.SkuNo && m.LotNo == detail1.LotNo);
+                var newId = 0;
+                if (detailNew1 == null)//add
+                {
+                    var detailNew = new DataStockDetail();
+                    detailNew.SkuNo = detail1.SkuNo;
+                    detailNew.SkuName = detail1.SkuName;
+                    detailNew.LotNo = detail1.LotNo;
+                    detailNew.LotText = detail1.LotText;
+                    detailNew.SupplierLot = detail1.SupplierLot;
+                    detailNew.SupplierNo = detail1.SupplierNo;
+                    detailNew.SupplierName = detail1.SupplierName;
+                    detailNew.Standard = detail1.Standard;
+                    detailNew.Qty = qty;
+                    detailNew.LockQty = 0;
+                    detailNew.FrozenQty = 0;
+                    detailNew.InspectQty = 0;
+                    detailNew.ASNNo = "";
+
+                    detailNew.PalletNo = palletNoNew;
+                    detailNew.ProductionTime = detail1.ProductionTime;
+                    detailNew.ExpirationTime = detail1.ExpirationTime;
+                    detailNew.PalletTags = "0";
+                    detailNew.CompleteTime = DateTime.Now;
+                    detailNew.Status = "0";
+                    detailNew.InspectMark = detail1.InspectMark;
+                    detailNew.BitPalletMark = "1";
+                    detailNew.InspectStatus = detail1.InspectStatus;
+                    detailNew.PackagNo = detail1.PackagNo;
+                    detailNew.IsBale = detail1.IsBale;
+                    detailNew.IsBelt = detail1.IsBelt;
+                    detailNew.IsDel = "0";
+                    detailNew.CreateTime = DateTime.Now;
+                    detailNew.CreateUser = 0;
+
+
+                    newId = Db.Insertable(detailNew).ExecuteReturnIdentity();
+                }
+                else //update
+                {
+                    detailNew1.Qty += qty;
+                    detailNew1.PalletNo = palletNoNew;
+
+                    Db.Updateable(detailNew1).ExecuteCommand();
+                    newId = detailNew1.Id;
+                }
+                //鏇存柊鎵樼洏鐘舵��
+                palletInfoNew.Status = "1";
+                Db.Updateable(palletInfoNew).ExecuteCommand();
+
+                //鏇存敼鍘熸墭鐩樹俊鎭�
+                detail1.Qty -= qty;
+                detail1.BitPalletMark = "1";
+                if (detail1.Qty <= 0)
+                {
+                    //鏇存柊鍘熸墭鐩樼姸鎬�
+                    var palletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    palletInfo.Status = "0";
+                    Db.Updateable(palletInfo).ExecuteCommand();
+
+                    Db.Deleteable(detail1).ExecuteCommand();
+                }
+                else
+                {
+                    Db.Updateable(detail1).ExecuteCommand();
+                }
+
+                
+                //娣诲姞鎿嶄綔鏃ュ織
+                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", palletNo, "缂栬緫", $"鐗╂枡鎷嗘墭:{detail1.SkuName}鐗╂枡鎹㈡墭锛屽師鎵樼洏{palletNo}锛屾柊鎵樼洏{palletNoNew}", userId);
+
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+
+        #endregion
+
     }
 }

--
Gitblit v1.8.0