From 0c30b9dff928396bf64df03835eb8957d931c468 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期六, 20 九月 2025 14:43:22 +0800
Subject: [PATCH] Merge branch 'master' of http://47.95.120.53:8083/r/JC34WMS

---
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs |  126 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 105 insertions(+), 21 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 0f6f459..95d16c8 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;
@@ -424,17 +427,62 @@
         //             .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
         //             .ToListAsync();
         //}
-        public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo, string boxNo)
+        public async Task<List<StockDetailWithQtyDto>> GetStockQueryList(string locatNo, string palletNo, string boxNo)
         {
-            return await Db.Queryable<DataStockDetail>()
-                         .LeftJoin<DataBoxInfo>((stk, box) => stk.LotNo == box.LotNo)
-                         .Where((stk, box) => stk.IsDel == "0")
-                         .WhereIF(!string.IsNullOrWhiteSpace(locatNo),(stk, box) => stk.LocatNo.Contains(locatNo))
-                         .WhereIF(!string.IsNullOrWhiteSpace(palletNo),(stk, box) => stk.PalletNo.Contains(palletNo))
-                         .WhereIF(!string.IsNullOrWhiteSpace(boxNo),(stk, box) => box.BoxNo.Contains(boxNo))
-                         .OrderBy((stk, box) => new { stk.LotNo, stk.LocatNo, stk.PalletNo, box.BoxNo })
-                         .Select((stk, box) => stk)
-                         .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
 
@@ -701,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;
         }
@@ -731,7 +779,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (models.WareHouseNo != "W04")
+                if (models.WareHouseNo != "W04" && models.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -741,11 +789,40 @@
                     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;
+        }
+        /// <summary>
+        /// 鏍规嵁鍖哄煙鍙疯幏鍙栧偍浣嶅湴鍧�闆嗗悎
+        /// </summary>
+        /// <param name="areaNo"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public List<string> GetLocatByArea(string areaNo)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(areaNo))
+                {
+                    throw new Exception("璇烽�夋嫨鍖哄煙");
+                }
+                var _list = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.AreaNo == areaNo && w.WareHouseNo == "W04").Select(s => s.LocatNo).ToList();
+
+                return _list;
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
         }
         /// <summary>
         /// 鑾峰彇宸插垎閰嶇殑鍑哄簱鍗曟嵁
@@ -839,7 +916,7 @@
                 {
                     throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                if (stockDetail.WareHouseNo != "W04")
+                if (stockDetail.WareHouseNo != "W04" && stockDetail.WareHouseNo != "W02")
                 {
                     throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
                 }
@@ -957,7 +1034,7 @@
             }
         }*/
 
-        public async Task AgvTransport(string palletNo, string areaNo, string ruku, string url, int userId)
+        public async Task AgvTransport(string palletNo, string areaNo,string locatNoEnd, string ruku, string url, int userId)
         {
             try
             {
@@ -992,7 +1069,14 @@
                     {
                         throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
                     }
-                    EndLocat = await GetLocat(areaNo);
+                    if (!string.IsNullOrEmpty(locatNoEnd))
+                    {
+                        EndLocat = locatNoEnd;//鎸囧畾鍌ㄤ綅鍦板潃
+                    }
+                    else
+                    {
+                        EndLocat = await GetLocat(areaNo);//绯荤粺鍒嗛厤鍌ㄤ綅鍦板潃
+                    }                    
                 }
                 else
                 {
@@ -1021,7 +1105,7 @@
                 //鐩爣鍌ㄤ綅淇℃伅
                 //var storageLocatEnd = new SysStorageLocat();
 
-                var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0");
+                var storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.WareHouseNo == "W04" && w.AreaNo == areaNo);
                 if (storageLocatEnd == null)
                 {
                     throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
@@ -1579,9 +1663,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("璇ョ鐮佷俊鎭敊璇紝瀛樺湪澶氫釜姝ょ鐮佷俊鎭�");

--
Gitblit v1.8.0