From 90a811e92481b86581460da8c330ff407bf531fe Mon Sep 17 00:00:00 2001
From: admin <qiutairan163@163.com>
Date: 星期一, 15 十二月 2025 17:09:45 +0800
Subject: [PATCH] 托盘明细导出GetBindListDaoChu

---
 Wms/WMS.BLL/DataServer/StockDetailServer.cs |  242 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 213 insertions(+), 29 deletions(-)

diff --git a/Wms/WMS.BLL/DataServer/StockDetailServer.cs b/Wms/WMS.BLL/DataServer/StockDetailServer.cs
index e8699c6..7b7b936 100644
--- a/Wms/WMS.BLL/DataServer/StockDetailServer.cs
+++ b/Wms/WMS.BLL/DataServer/StockDetailServer.cs
@@ -1,11 +1,13 @@
-锘縰sing System;
+锘縰sing Model.ModelDto.DataDto;
+using Model.ModelDto.SysDto;
+using SqlSugar;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using Model.ModelDto.DataDto;
-using SqlSugar;
 using WMS.BLL.LogServer;
 using WMS.DAL;
+using WMS.Entity.BllAsnEntity;
 using WMS.Entity.BllQualityEntity;
 using WMS.Entity.Context;
 using WMS.Entity.DataEntity;
@@ -13,11 +15,11 @@
 
 namespace WMS.BLL.DataServer
 {
-    public class StockDetailServer:DbHelper<DataStockDetail>,IStockDetailServer
+    public class StockDetailServer : DbHelper<DataStockDetail>, IStockDetailServer
     {
         private static readonly SqlSugarScope Db = DataContext.Db;
 
-        public StockDetailServer():base(Db)
+        public StockDetailServer() : base(Db)
         {
         }
 
@@ -36,17 +38,21 @@
         /// <param name="bitPalletMark">闆舵墭鏍囪</param>
         /// <param name="bitBoxMark">闆剁鏍囪</param>
         /// <param name="inspectStatus">璐ㄩ噺鐘舵��</param>
+        /// <param name="ownerNo">璐т富缂栫爜</param>
+        /// <param name="ownerName">璐т富鍚嶇О</param>
+        /// <param name="startTime">寮�濮嬫椂闂�</param>
+        /// <param name="endTime">缁撴潫鏃堕棿</param>
+        /// <param name="WareHouseNo">鎵�灞炰粨搴�</param>
+        /// <param name="AreaNo">鎵�灞炲尯鍩�</param>
         /// <returns></returns>
-        public List<StockDetailDto> GetBindList(string skuNo, string skuName, string palletNo, string lotNo, string boxNo, string status, 
-            string inspectMark, string bitPalletMark, string bitBoxMark, string inspectStatus, string ownerNo, string ownerName, string startTime, string endTime)
+        public List<StockDetailDto> GetBindList(string skuNo, string skuName, string palletNo, string lotNo, string boxNo, string status, string inspectMark, string bitPalletMark, string bitBoxMark, string inspectStatus, string ownerNo, string ownerName, string startTime, string endTime, string WareHouseNo, string AreaNo)
         {
-            string str = "select detail.*,house.WareHouseNo + '-' + house.WareHouseName as WareHouseName,roadway.RoadwayNo + '-' + roadway.RoadwayName as RoadwayName," +
-                "area.AreaNo + '-' + area.AreaName as AreaName " +
-                "from DataStockDetail detail " +
-                "left join SysStorageRoadway roadway on detail.RoadwayNo = roadway.RoadwayNo " +
-                "left join SysWareHouse house on detail.WareHouseNo = house.WareHouseNo " +
-                "left join SysStorageArea area on detail.AreaNo = area.AreaNo " +
-                "where detail.IsDel = @isdel";
+            string str = $@"select detail.*,house.WareHouseNo+'-'+house.WareHouseName as WareHouseName,roadway.RoadwayNo+'-'+roadway.RoadwayName as RoadwayName,area.AreaNo+'-'+area.AreaName as AreaName 
+from DataStockDetail detail 
+left join SysStorageRoadway roadway on detail.RoadwayNo=roadway.RoadwayNo 
+left join SysWareHouse house on detail.WareHouseNo=house.WareHouseNo 
+left join SysStorageArea area on detail.AreaNo=area.AreaNo 
+where detail.IsDel=@isdel";
             //鍒ゆ柇鐗╂枡鍙锋槸鍚︿负绌�
             if (!string.IsNullOrEmpty(skuNo))
             {
@@ -70,7 +76,7 @@
             //鍒ゆ柇闆舵墭鏍囪鏄惁涓虹┖
             if (!string.IsNullOrEmpty(bitPalletMark))
             {
-                str += " and detail.BitPalletMark = @bitpalletmark";
+                str += " and detail.BitPalletMark=@bitpalletmark";
             }
             //鍒ゆ柇璐т富缂栫爜鏄惁涓虹┖
             if (!string.IsNullOrEmpty(ownerNo))
@@ -84,17 +90,30 @@
             }
             if (!string.IsNullOrEmpty(startTime))
             {
-                str += $" and detail.CompleteTime >= '{startTime}'";
+                str += $" and detail.CompleteTime>='{startTime}'";
             }
             if (!string.IsNullOrEmpty(endTime))
             {
                 endTime = Convert.ToDateTime(endTime).AddDays(1).ToString();
-                str += $" and detail.CompleteTime < '{endTime}'";
+                str += $" and detail.CompleteTime<'{endTime}'";
+            }
+            //閲嶅鏉′欢
+            //if (!string.IsNullOrEmpty(WareHouseNo)) 
+            //{
+            //    str += $" and detail.WareHouseNo = '{WareHouseNo}'";
+            //}
+            if (!string.IsNullOrEmpty(WareHouseNo))
+            {
+                str += $" and detail.WareHouseNo='{WareHouseNo}'";
+            }
+            if (!string.IsNullOrEmpty(AreaNo))
+            {
+                str += $" and detail.AreaNo='{AreaNo}'";
             }
 
             int i = 0;
             //鍦ㄧ鐮佹槑缁嗕腑鑾峰彇鐩稿簲鏁版嵁
-            string boxstr = "select StockDetailId from DataBoxInfo Where IsDel = @isdel";
+            string boxstr = "select StockDetailId from DataBoxInfo Where IsDel=@isdel";
             //鍒ゆ柇绠辩爜鏄惁涓虹┖
             if (!string.IsNullOrEmpty(boxNo))
             {
@@ -104,27 +123,27 @@
             //鍒ゆ柇绠辨敮鐘舵�佹槸鍚︿负绌�
             if (!string.IsNullOrEmpty(status))
             {
-                boxstr += " and Status = @status";
+                boxstr += " and Status=@status";
                 i = 1;
             }
             //鍒ゆ柇妫�楠屾爣璁版槸鍚︿负绌�
             if (!string.IsNullOrEmpty(inspectMark))
             {
-                boxstr += " and InspectMark = @inspectmark";
-                str += " and detail.InspectMark = @inspectmark";
+                boxstr += " and InspectMark=@inspectmark";
+                str += " and detail.InspectMark=@inspectmark";
                 i = 1;
             }
             //鍒ゆ柇闆剁鏍囪鏄惁涓虹┖
             if (!string.IsNullOrEmpty(bitBoxMark))
             {
-                boxstr += " and BitBoxMark = @bitboxmark";
+                boxstr += " and BitBoxMark=@bitboxmark";
                 i = 1;
             }
             //鍒ゆ柇璐ㄩ噺鐘舵�佹槸鍚︿负绌�
             if (!string.IsNullOrEmpty(inspectStatus))
             {
-                boxstr += " and InspectStatus = @inspectstatus";
-                str += " and detail.InspectStatus = @inspectstatus";
+                boxstr += " and InspectStatus=@inspectstatus";
+                str += " and detail.InspectStatus=@inspectstatus";
                 i = 1;
             }
             //灏嗙鐮佹暟鎹繘琛屾帓搴�
@@ -160,11 +179,11 @@
                 }
                 if (!string.IsNullOrEmpty(arr))
                 {
-                    str += $" and Id in ({arr})";
+                    str += $" and detail.Id in ({arr})";
                 }
                 else
                 {
-                    str += " and Id = ''";
+                    str += " and detail.Id=''";
                 }
             }
 
@@ -187,13 +206,44 @@
 
             return boxInforList;
         }
+        /// <summary>
+        /// 鎵樼洏鏄庣粏澶囨敞
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="demo"></param>
+        /// <param name="userId"></param>
+        /// <exception cref="Exception"></exception>
+        public void EditStockDetailDemo(int id, string demo, int userId)
+        {
+            try
+            {
+                var detail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == id);
+                if (detail == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌搴撳瓨鏄庣粏淇℃伅");
+                }
+                detail.Demo = demo + "".Trim();
+                detail.UpdateUser = userId;
+                detail.UpdateTime = DateTime.Now;
 
+                int i = Db.Updateable(detail).ExecuteCommand();
+                if (i > 0)
+                {
+                    //娣诲姞鎿嶄綔鏃ュ織
+                    new OperationASNServer().AddLogOperationAsn("搴撳瓨缁熻", "鎵樼洏鏄庣粏", detail.PalletNo, "缂栬緫", $"缂栬緫浜嗘墭鐩樺彿涓簕detail.PalletNo}鐨勫娉ㄤ俊鎭�", userId);
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+        }
 
         #endregion
 
         #region 瀵煎嚭鎵樼洏鏄庣粏
         /// <summary>
-        /// 鑾峰彇鎵樼洏鏄庣粏
+        /// 瀵煎嚭鎵樼洏鏄庣粏
         /// </summary>
         /// <param name="skuNo">鐗╂枡鍙�</param>
         /// <param name="skuName">鐗╂枡鍚嶇О</param>
@@ -205,10 +255,17 @@
         /// <param name="bitPalletMark">闆舵墭鏍囪</param>
         /// <param name="bitBoxMark">闆剁鏍囪</param>
         /// <param name="inspectStatus">璐ㄩ噺鐘舵��</param>
+        /// <param name="ownerNo">璐т富缂栫爜</param>
+        /// <param name="ownerName">璐т富鍚嶇О</param>
+        /// <param name="startTime">寮�濮嬫椂闂�</param>
+        /// <param name="endTime">缁撴潫鏃堕棿</param>
+        /// <param name="wareHouseNo">鎵�灞炰粨搴�</param>
+        /// <param name="areaNo">鎵�灞炲尯鍩�</param>
         /// <returns></returns>
-        public List<DataStockDetail> GetBindListDaoChu(string skuNo, string skuName, string palletNo, string lotNo, string boxNo, 
-            string status, string inspectMark, string bitPalletMark, string bitBoxMark, string inspectStatus)
+        public List<StockDetailDto> GetBindListDaoChu(string skuNo, string skuName, string palletNo, string lotNo, string boxNo, string status, string inspectMark, string bitPalletMark, string bitBoxMark, string inspectStatus, string ownerNo, string ownerName, string startTime, string endTime, string wareHouseNo, string areaNo)
         {
+            #region GetBindListDaoChu
+            /*
             string str = "select Id,LotNo,LotText,SupplierLot,SkuNo,SkuName,Qty,LockQty,FrozenQty,AreaNo,LocatNo,PalletNo,PalletNo2," +
                 "PalletNo3,InspectMark,BitPalletMark from DataStockDetail where IsDel = @isdel";
             //鍒ゆ柇鐗╂枡鍙锋槸鍚︿负绌�
@@ -341,6 +398,133 @@
                 }
             }
             return boxInforList;
+            */
+            #endregion
+            string listWhere = "a.IsDel='0'";
+            //鐗╂枡鍙�
+            if (!string.IsNullOrEmpty(skuNo))
+            {
+                listWhere += $@" and a.SkuNo like'%{skuNo}%'";
+            }
+            //鐗╂枡鍚嶇О
+            if (!string.IsNullOrEmpty(skuName))
+            {
+                listWhere += $@" and a.SkuName like'%{skuName}%'";
+            }
+
+            //鎵樼洏鍙�
+            if (!string.IsNullOrEmpty(palletNo))
+            {
+                listWhere += $@" and a.PalletNo like'%{palletNo}%'";
+            }
+
+            //鎵规
+            if (!string.IsNullOrEmpty(lotNo))
+            {
+                listWhere += $@" and a.LotNo like'%{lotNo}%'";
+            }
+
+            //闆舵墭鏍囪
+            if (!string.IsNullOrEmpty(bitPalletMark))
+            {
+                listWhere += $@" and a.BitPalletMark='{bitPalletMark}'";
+            }
+
+            //璐т富缂栫爜
+            if (!string.IsNullOrEmpty(ownerNo))
+            {
+                listWhere += $@" and a.OwnerNo like'%{ownerNo}%'";
+            }
+            //璐т富鍚嶇О
+            if (!string.IsNullOrEmpty(ownerName))
+            {
+                listWhere += $@" and a.OwnerName like'%{ownerName}%'";
+            }
+
+            //寮�濮嬫椂闂�
+            if (!string.IsNullOrEmpty(startTime))
+            {
+                listWhere += $" and a.CompleteTime>='{startTime}'";
+            }
+            //缁撴潫鏃堕棿
+            if (!string.IsNullOrEmpty(endTime))
+            {
+                endTime = Convert.ToDateTime(endTime).AddDays(1).ToString();
+                listWhere += $" and a.CompleteTime<'{endTime}'";
+            }
+
+            //浠撳簱
+            if (!string.IsNullOrEmpty(wareHouseNo))
+            {
+                listWhere += $" and a.WareHouseNo='{wareHouseNo}'";
+            }
+            //鍖哄煙
+            if (!string.IsNullOrEmpty(areaNo))
+            {
+                listWhere += $" and a.AreaNo='{areaNo}'";
+            }
+
+            //绠辩爜鏄庣粏鏉′欢
+            string boxWhere = "IsDel='0'";
+            //绠辩爜
+            if (!string.IsNullOrEmpty(boxNo))
+            {
+                boxWhere += $@" and BoxNo like'%{boxNo}%'";
+            }
+            //绠辨敮鐘舵��
+            if (!string.IsNullOrEmpty(status))
+            {
+                boxWhere += $@" and Status='{status}'";
+            }
+            //妫�楠屾爣璁�
+            if (!string.IsNullOrEmpty(inspectMark))
+            {
+                boxWhere += $@" and InspectMark='{inspectMark}'";
+                listWhere += $@" and a.InspectMark='{inspectMark}'";
+            }
+            //闆剁鏍囪
+            if (!string.IsNullOrEmpty(bitBoxMark))
+            {
+                boxWhere += $@" and BitBoxMark='{bitBoxMark}'";
+            }
+            //璐ㄩ噺鐘舵��
+            if (!string.IsNullOrEmpty(inspectStatus))
+            {
+                boxWhere += $@" and InspectStatus='{inspectStatus}'";
+                listWhere += $@" and a.InspectStatus='{inspectStatus}'";
+            }
+
+            //鍒ゆ柇鏄惁鏈夋煡绠辩爜淇℃伅
+            if (boxWhere != "IsDel='0'")
+            {
+                listWhere += $@" and a.Id in (select StockDetailId from DataBoxInfo Where {boxWhere} group by StockDetailId)";
+            }
+
+            string listSql = $@"select a.Id,c.WareHouseNo+'-'+c.WareHouseName as WareHouseName,b.RoadwayNo+'-'+b.RoadwayName as RoadwayName,d.AreaNo+'-'+d.AreaName as AreaName,a.LocatNo,a.PalletNo,a.SkuNo,a.SkuName,a.LotNo,a.SupplierLot,a.Qty,a.LockQty,a.FrozenQty,e.DictName as Status,f.DictName as InspectStatus,a.InspectMark,case a.BitPalletMark when 0 then '鍚�' when 1 then '鏄�' else '' end BitPalletMark,a.ProductionTime,a.ExpirationTime,a.OwnerNo,a.OwnerName,a.SupplierNo,a.SupplierName,a.Demo
+	from DataStockDetail a
+	left join SysStorageRoadway b on b.RoadwayNo=a.RoadwayNo
+	left join SysWareHouse c on c.WareHouseNo=a.WareHouseNo
+	left join SysStorageArea d on d.AreaNo=a.AreaNo
+	left join (select DictNo,DictName from SysDictionary where ParentNo='DataStockDetailStatus') e on e.DictNo=a.Status
+	left join (select DictNo,DictName from SysDictionary where ParentNo='InspectStatus') f on f.DictNo=a.InspectStatus
+	where {listWhere}
+	order by a.PalletNo,a.SkuNo,a.LotNo";
+            List<StockDetailDto> boxInforList = Db.Ado.SqlQuery<StockDetailDto>(listSql);
+
+            foreach (var item in boxInforList)
+            {
+                //鍌ㄤ綅鍦板潃锛屽姞涓婂崟寮曞彿鏄槻姝㈠鍑哄埌excel鑷姩鎶婂墠闈㈢殑0缁欏幓鎺�
+                if (!string.IsNullOrEmpty(item.LocatNo) && item.LocatNo.Substring(0, 1) == "0")
+                {
+                    item.LocatNo = $@"'{item.LocatNo}";
+                }
+                //鐗╂枡缂栫爜
+                if (!string.IsNullOrEmpty(item.SkuNo) && item.SkuNo.Substring(0, 1) == "0")
+                {
+                    item.SkuNo = $@"'{item.SkuNo}";
+                }
+            }
+            return boxInforList;
         }
         #endregion
 

--
Gitblit v1.8.0