From c789e51bbf0dc8eea2689918c7c8cdb4309d3c6c Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期五, 05 十二月 2025 13:58:28 +0800
Subject: [PATCH] 11

---
 StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs |  476 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 434 insertions(+), 42 deletions(-)

diff --git a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
index 053c842..bfe59f7 100644
--- a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
+++ b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
@@ -10,7 +10,346 @@
 public class MesInvItemStocksManager : Repository<MesInvItemStocks>
 {
     /// <summary>
-    ///     鏌ヨ鍙互閫�璐х殑鐗╂枡
+    ///     鏌ヨ鍙互閫�璐х殑鐗╂枡(甯﹀垎椤靛拰鎼滅储)
+    /// </summary>
+    /// <param name="searchDto">鎼滅储璇锋眰鍙傛暟</param>
+    /// <returns>鍒嗛〉缁撴灉</returns>
+    public PagedResult<ReturnableStockDto> GetReturnableStocks(
+        ReturnableStockSearchDto searchDto)
+    {
+        // 鍙傛暟鏍¢獙
+        if (searchDto.PageIndex < 1)
+        {
+            throw new Exception("椤电爜蹇呴』澶т簬0");
+        }
+
+        if (!new[] { 10, 20, 50 }.Contains(searchDto.PageSize))
+        {
+            throw new Exception("姣忛〉鏉℃暟蹇呴』涓�10銆�20鎴�50");
+        }
+
+        // 1. 鏌ヨXB_RACKING_TASK_SYXT_LOG涓璉temBarcode鍜孭alletCode鐨勬槧灏勫叧绯�
+        var allRackingTaskData = Db.Queryable<XbRackingTaskSyxtLog>()
+            .Where(x => !string.IsNullOrEmpty(x.ItemBarcode))
+            .Select(x => new { x.ItemBarcode, x.PalletCode, x.Code, x.Id })
+            .ToList();
+
+        // ReturnableStockDto澧炲姞涓�涓簱瀛樼姸鎬佺殑瀛楁
+        // 褰揳llRackingTaskData涓殑Code涓簄ull鏃讹紝搴撳瓨鐘舵�佷负绔嬪簱鍏ュ簱涓�
+        // 褰揳llRackingTaskData涓殑Code涓�200鏃讹紝搴撳瓨鐘舵�佷负宸茬粡鍦ㄧ珛搴撳唴
+        // 瀵规瘡涓潯鐮侊紝鍙栨渶鏂癐D鐨勮褰曪紝骞惰繃婊ゆ帀Code涓�500锛堣〃绀哄け璐ワ級鐨勮褰�
+        var rackingTaskData = allRackingTaskData
+            .GroupBy(x => x.ItemBarcode) // 鎸夋潯鐮佸垎缁�
+            .Select(g => g.OrderByDescending(x => x.Id).First()) // 鍙栨瘡涓潯鐮佹渶鏂扮殑涓�鏉¤褰�
+            .Where(x => x.Code != "500") // 杩囨护鎺塁ode涓�500鐨勫け璐ヨ褰�
+            .ToList();
+
+        if (rackingTaskData == null || !rackingTaskData.Any())
+        {
+            return new PagedResult<ReturnableStockDto>
+            {
+                TbBillList = new List<ReturnableStockDto>(),
+                Pagination = new PaginationInfo
+                {
+                    CurrentPage = searchDto.PageIndex,
+                    PageSize = searchDto.PageSize,
+                    TotalRecords = 0,
+                    TotalPages = 0
+                }
+            };
+        }
+
+        // 1.1 鎻愬彇鍘婚噸鍚庣殑鏉$爜鍒楄〃鐢ㄤ簬鏌ヨ
+        var distinctBarcodes = rackingTaskData.Select(x => x.ItemBarcode)
+            .Distinct().ToList();
+
+        // 2. 鏋勫缓鏌ヨ鏉′欢
+        var query = Db.Queryable<MesInvItemStocks>()
+            .LeftJoin<MesItems>((stock, item) => stock.ItemId == item.Id)
+            .LeftJoin<MesDepots>((stock, item, depot) =>
+                stock.DepotsCode == depot.DepotCode)
+            .LeftJoin<Organize>((stock, item, depot, org) =>
+                item.UseOrg == org.Id.ToString())
+            .LeftJoin<MesUnit>((stock, item, depot, org, unit) =>
+                item.ItemUnit == unit.Id.ToString())
+            .Where((stock, item, depot, org, unit) =>
+                (distinctBarcodes.Contains(stock.ItemBarcode) ||
+                 distinctBarcodes.Contains(stock.StackCode)) &&
+                stock.Quantity > 0);
+
+        // 3. 搴旂敤鎼滅储鏉′欢
+        var conditions = searchDto.Conditions;
+        if (conditions != null)
+        {
+            //褰揷onditions.IqcStatus涓�1鏃舵煡璇㈢殑鍊煎氨瑕佹槸鐗归噰鐩存帴浣跨敤锛屽凡妫�锛屽厤妫�锛�1鐨勫��
+            // 绮剧‘鍖归厤鏉′欢
+            if (!string.IsNullOrEmpty(conditions.IqcStatus))
+            {
+                if (conditions.IqcStatus == "1")
+                {
+                    // 褰揑qcStatus涓�"1"鏃讹紝鏌ヨ鐗归噰鐩存帴浣跨敤銆佸凡妫�銆佸厤妫�鐘舵��
+                    query = query.Where((stock, item, depot, org, unit) =>
+                        stock.IqcStatus == "鐗归噰鐩存帴浣跨敤" ||
+                        stock.IqcStatus == "宸叉" ||
+                        stock.IqcStatus == "鍏嶆");
+                }
+                else
+                {
+                    // 鍏朵粬鎯呭喌鎸夊師鍊煎尮閰�
+                    query = query.Where((stock, item, depot, org, unit) =>
+                        stock.IqcStatus == conditions.IqcStatus);
+                }
+            }
+
+            if (conditions.Quantity.HasValue)
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    stock.Quantity == conditions.Quantity.Value);
+            }
+
+            // 妯$硦鍖归厤鏉′欢
+
+            if (!string.IsNullOrEmpty(conditions.DepotName))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    depot.DepotName != null &&
+                    depot.DepotName.Contains(conditions.DepotName));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.DepotSectionsCode))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    stock.DepotSectionsCode != null &&
+                    stock.DepotSectionsCode.Contains(conditions
+                        .DepotSectionsCode));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.ItemNo))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    item.ItemNo != null &&
+                    item.ItemNo.Contains(conditions.ItemNo));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.ItemName))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    item.ItemName != null &&
+                    item.ItemName.Contains(conditions.ItemName));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.ItemModel))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    item.ItemModel != null &&
+                    item.ItemModel.Contains(conditions.ItemModel));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.ItemUnitName))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    unit.Fname != null &&
+                    unit.Fname.Contains(conditions.ItemUnitName));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.OrgCode))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    org.Fnumber != null &&
+                    org.Fnumber.Contains(conditions.OrgCode));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.OrgName))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    org.Fname != null &&
+                    org.Fname.Contains(conditions.OrgName));
+            }
+
+            if (!string.IsNullOrEmpty(conditions.ItemBarcode))
+            {
+                query = query.Where((stock, item, depot, org, unit) =>
+                    stock.ItemBarcode != null &&
+                    stock.ItemBarcode.Contains(conditions.ItemBarcode));
+            }
+
+            // 鏃ユ湡鑼冨洿鏉′欢
+            if (!string.IsNullOrEmpty(conditions.IndepDateStart))
+            {
+                if (DateTime.TryParse(conditions.IndepDateStart,
+                        out var startDate))
+                {
+                    query = query.Where((stock, item, depot, org, unit) =>
+                        stock.IndepDate >= startDate);
+                }
+            }
+
+            if (!string.IsNullOrEmpty(conditions.IndepDateEnd))
+            {
+                if (DateTime.TryParse(conditions.IndepDateEnd, out var endDate))
+                {
+                    query = query.Where((stock, item, depot, org, unit) =>
+                        stock.IndepDate <= endDate);
+                }
+            }
+        }
+
+        // 4. 鏌ヨ鎵�鏈夌鍚堟潯浠剁殑鏁版嵁锛堜笉鍒嗛〉锛�
+        var queryResult = query
+            .OrderByDescending((stock, item, depot, org, unit) =>
+                stock.IndepDate)
+            .Select((stock, item, depot, org, unit) => new
+            {
+                stock.IqcStatus,
+                DepotCode = stock.DepotsCode,
+                depot.DepotName,
+                stock.DepotSectionsCode,
+                item.ItemNo,
+                item.ItemName,
+                item.ItemModel,
+                stock.Quantity,
+                item.ItemUnit,
+                ItemUnitName = unit.Fname,
+                stock.IndepDate,
+                OrgCode = org.Fnumber,
+                OrgName = org.Fname,
+                stock.ItemBarcode,
+                StockStackCode = stock.StackCode
+            })
+            .ToList();
+
+        // 5. 鍦ㄥ唴瀛樹腑杞崲涓篋TO锛屽叧鑱擯alletCode骞惰祴鍊糏temBarcode锛堜紭鍏堜娇鐢ㄧ鏉$爜StockStackCode锛�
+        var tempDataList = queryResult.Select(x =>
+        {
+            // 浼樺厛浣跨敤StockStackCode锛屽惁鍒欎娇鐢↖temBarcode鍘绘煡鎵綪alletCode
+            var barcodeToMatch = !string.IsNullOrEmpty(x.StockStackCode)
+                ? x.StockStackCode
+                : x.ItemBarcode;
+            var rackingTask = rackingTaskData
+                .Where(r => r.ItemBarcode == barcodeToMatch)
+                .FirstOrDefault();
+
+            // 鏍规嵁Code鍊肩‘瀹氬簱瀛樼姸鎬�: null涓虹珛搴撳叆搴撲腑(0), 200涓哄凡鍦ㄧ珛搴撳唴(1)
+            string stockStatus = "杩涘叆绔嬪簱鐨勮矾涓�"; // 榛樿涓虹珛搴撳叆搴撲腑
+            if (rackingTask?.Code != null)
+            {
+                stockStatus = rackingTask.Code == "200" ? "宸插湪绔嬪簱涓�" : "杩涘叆绔嬪簱鐨勮矾涓�";
+            }
+
+            return new
+            {
+                IqcStatus = x.IqcStatus == "宸叉" ? "1" : "0",
+                ItemType = x.DepotName == "鍘熸潗鏂欎粨" ? "0" : "1",
+                StackCode = rackingTask?.PalletCode, // 浣跨敤PalletCode浣滀负姣嶆墭鐩樼紪鍙�
+                x.DepotCode,
+                x.DepotName,
+                x.DepotSectionsCode,
+                x.ItemNo,
+                x.ItemName,
+                x.ItemModel,
+                x.Quantity,
+                x.ItemUnit,
+                x.ItemUnitName,
+                x.IndepDate,
+                x.OrgCode,
+                x.OrgName,
+                ItemBarcode = barcodeToMatch,
+                StockStatus = stockStatus // 娣诲姞搴撳瓨鐘舵��
+            };
+        }).ToList();
+
+        // 5.1 搴旂敤StackCode鎼滅储鏉′欢锛堝湪鍐呭瓨涓繃婊alletCode锛�
+        if (conditions != null && !string.IsNullOrEmpty(conditions.StackCode))
+        {
+            tempDataList = tempDataList
+                .Where(x =>
+                    x.StackCode != null &&
+                    x.StackCode.Contains(conditions.StackCode))
+                .ToList();
+        }
+
+        // 5.2 搴旂敤StockStatus鎼滅储鏉′欢锛堝湪鍐呭瓨涓繃婊わ級
+        if (conditions != null && !string.IsNullOrEmpty(conditions.StockStatus))
+        {
+            tempDataList = tempDataList
+                .Where(x => x.StockStatus == conditions.StockStatus)
+                .ToList();
+        }
+
+        // 5.3 鍒嗙粍骞跺悎璁uantity
+        var dataList = tempDataList
+            .GroupBy(x => new
+            {
+                x.IqcStatus,
+                x.ItemType,
+                x.StackCode,
+                x.DepotCode,
+                x.DepotName,
+                x.DepotSectionsCode,
+                x.ItemNo,
+                x.ItemName,
+                x.ItemModel,
+                x.ItemUnit,
+                x.ItemUnitName,
+                x.OrgCode,
+                x.OrgName,
+                x.ItemBarcode,
+                x.StockStatus // 娣诲姞搴撳瓨鐘舵�佸埌鍒嗙粍閿腑
+            })
+            .Select(g => new ReturnableStockDto
+            {
+                IqcStatus = g.Key.IqcStatus,
+                ItemType = g.Key.ItemType,
+                StackCode = g.Key.StackCode,
+                DepotCode = g.Key.DepotCode,
+                DepotName = g.Key.DepotName,
+                DepotSectionsCode = g.Key.DepotSectionsCode,
+                ItemNo = g.Key.ItemNo,
+                ItemName = g.Key.ItemName,
+                ItemModel = g.Key.ItemModel,
+                Quantity = g.Sum(x => x.Quantity),
+                ItemUnit = g.Key.ItemUnit,
+                ItemUnitName = g.Key.ItemUnitName,
+                IndepDate = g.Max(x => x.IndepDate),
+                OrgCode = g.Key.OrgCode,
+                OrgName = g.Key.OrgName,
+                ItemBarcode = g.Key.ItemBarcode,
+                StockStatus = g.Key.StockStatus // 娣诲姞搴撳瓨鐘舵�佸埌DTO涓�
+            }).ToList();
+
+        // 6. 搴旂敤ItemType绛涢��(鍦ㄥ唴瀛樹腑杩囨护)
+        if (conditions?.ItemType != null)
+        {
+            dataList = dataList.Where(x => x.ItemType == conditions.ItemType)
+                .ToList();
+        }
+
+        // 7. 璁$畻鎬昏褰曟暟鍜屽垎椤靛弬鏁帮紙鍩轰簬鏈�缁堢粨鏋滐級
+        var totalRecords = dataList.Count;
+        var totalPages =
+            (int)Math.Ceiling((double)totalRecords / searchDto.PageSize);
+        var skip = (searchDto.PageIndex - 1) * searchDto.PageSize;
+
+        // 8. 瀵规渶缁堢粨鏋滆繘琛屽垎椤�
+        var pagedDataList =
+            dataList.Skip(skip).Take(searchDto.PageSize).ToList();
+
+        // 9. 杩斿洖鍒嗛〉缁撴灉
+        return new PagedResult<ReturnableStockDto>
+        {
+            TbBillList = pagedDataList,
+            Pagination = new PaginationInfo
+            {
+                CurrentPage = searchDto.PageIndex,
+                PageSize = searchDto.PageSize,
+                TotalRecords = totalRecords,
+                TotalPages = totalPages
+            }
+        };
+    }
+
+    /// <summary>
+    ///     鏌ヨ鍙互閫�璐х殑鐗╂枡(鏃х増鏈�,淇濈暀鍏煎)
     /// </summary>
     /// <returns>鍙��璐х墿鏂欏簱瀛樺垪琛�</returns>
     public List<ReturnableStockDto> GetReturnableStocks()
@@ -27,6 +366,17 @@
             return new List<ReturnableStockDto>();
         }
 
+        // 1.1 鏌ヨXB_RACKING_TASK_SYXT_LOG涓璉temBarcode鍜孭alletCode銆丆ode鐨勬槧灏勫叧绯�
+        var allRackingTaskData = Db.Queryable<XbRackingTaskSyxtLog>()
+            .Where(x => !string.IsNullOrEmpty(x.ItemBarcode))
+            .Select(x => new { x.ItemBarcode, x.PalletCode, x.Code, x.Id })
+            .ToList();
+
+        var rackingTaskData = allRackingTaskData
+            .GroupBy(x => x.ItemBarcode)
+            .Select(g => g.OrderByDescending(x => x.Id).First())
+            .ToList();
+
         // 2. 浣跨敤鏉$爜鏌ヨMES_INV_ITEM_STOCKS涓殑鏁版嵁,鍏宠仈MES_ITEMS銆丮ES_DEPOTS銆丱RGANIZE銆丮ES_UNIT琛�
         var queryResult = Db.Queryable<MesInvItemStocks>()
             .LeftJoin<MesItems>((stock, item) => stock.ItemId == item.Id)
@@ -41,43 +391,62 @@
                 stock.Quantity > 0)
             .Select((stock, item, depot, org, unit) => new
             {
-                IqcStatus = stock.IqcStatus,
-                StackCode = stock.StackCode,
+                stock.IqcStatus,
+                stock.StackCode,
                 DepotCode = stock.DepotsCode,
-                DepotName = depot.DepotName,
-                DepotSectionsCode = stock.DepotSectionsCode,
-                ItemNo = item.ItemNo,
-                ItemName = item.ItemName,
-                ItemModel = item.ItemModel,
-                Quantity = stock.Quantity,
-                ItemUnit = item.ItemUnit,
+                depot.DepotName,
+                stock.DepotSectionsCode,
+                item.ItemNo,
+                item.ItemName,
+                item.ItemModel,
+                stock.Quantity,
+                item.ItemUnit,
                 ItemUnitName = unit.Fname,
-                IndepDate = stock.IndepDate,
+                stock.IndepDate,
                 OrgCode = org.Fnumber,
                 OrgName = org.Fname,
-                ItemBarcode = stock.ItemBarcode
+                stock.ItemBarcode
             })
             .ToList();
 
         // 3. 鍦ㄥ唴瀛樹腑杩涜鏁版嵁杞崲
-        var result = queryResult.Select(x => new ReturnableStockDto
+        var result = queryResult.Select(x =>
         {
-            IqcStatus = x.IqcStatus == "宸叉" ? "1" : "0",
-            ItemType = x.DepotName == "鍘熸潗鏂欎粨" ? "0" : "1",
-            StackCode = x.StackCode,
-            DepotCode = x.DepotCode,
-            DepotName = x.DepotName,
-            DepotSectionsCode = x.DepotSectionsCode,
-            ItemNo = x.ItemNo,
-            ItemName = x.ItemName,
-            ItemModel = x.ItemModel,
-            Quantity = x.Quantity,
-            ItemUnit = x.ItemUnit,
-            ItemUnitName = x.ItemUnitName,
-            IndepDate = x.IndepDate,
-            OrgCode = x.OrgCode,
-            OrgName = x.OrgName,
-            ItemBarcode = x.ItemBarcode
+            // 鏍规嵁鏉$爜鏌ユ壘瀵瑰簲鐨勭珛搴撲换鍔′俊鎭�
+            var rackingTask = rackingTaskData
+                .Where(r => r.ItemBarcode == x.ItemBarcode)
+                .FirstOrDefault();
+
+            // 鏍规嵁Code鍊肩‘瀹氬簱瀛樼姸鎬�: null涓虹珛搴撳叆搴撲腑(0), 200涓哄凡鍦ㄧ珛搴撳唴(1)
+            string stockStatus = "0"; // 榛樿涓虹珛搴撳叆搴撲腑
+            if (rackingTask?.Code != null)
+            {
+                stockStatus =
+                    rackingTask.Code == "200"
+                        ? "1"
+                        : "2"; // 200瀵瑰簲宸插湪绔嬪簱涓�(1)锛屽叾浠栭潪500鍊间负杩涘叆绔嬪簱鐨勮矾涓�(2)
+            }
+
+            return new ReturnableStockDto
+            {
+                IqcStatus = x.IqcStatus == "宸叉" ? "1" : "0",
+                ItemType = x.DepotName == "鍘熸潗鏂欎粨" ? "0" : "1",
+                StackCode = x.StackCode,
+                DepotCode = x.DepotCode,
+                DepotName = x.DepotName,
+                DepotSectionsCode = x.DepotSectionsCode,
+                ItemNo = x.ItemNo,
+                ItemName = x.ItemName,
+                ItemModel = x.ItemModel,
+                Quantity = x.Quantity,
+                ItemUnit = x.ItemUnit,
+                ItemUnitName = x.ItemUnitName,
+                IndepDate = x.IndepDate,
+                OrgCode = x.OrgCode,
+                OrgName = x.OrgName,
+                ItemBarcode = x.ItemBarcode,
+                StockStatus = stockStatus // 娣诲姞搴撳瓨鐘舵��
+            };
         }).ToList();
 
         return result;
@@ -103,8 +472,29 @@
             // 瀵规瘡涓潯鐮佸崟鐙鐞�
             foreach (var barcode in dto.ItemBarcodes)
             {
+                // 妫�鏌ユ渶杩戜袱鍒嗛挓鍐呮槸鍚﹀凡缁忓瓨鍦ㄧ浉鍚岀殑 barcode 琚鐞嗚繃
+                var twoMinutesAgo = DateTime.Now.AddMinutes(-2);
+                var recentTask = Db.Queryable<XbRackingTaskSyxtLog>()
+                    .Where(x =>
+                        x.ItemBarcode == barcode &&
+                        x.CreateDate >= twoMinutesAgo)
+                    .First();
+
+                if (recentTask != null)
+                {
+                    throw new Exception(
+                        $"鐗╂枡鏉$爜 {barcode} 鍦ㄤ袱鍒嗛挓鍐呭凡琚壂鎻忓鐞嗭紝璇峰嬁閲嶅鎿嶄綔銆備负閬垮厤绔嬪簱绯荤粺浠诲姟閲嶅涓嬪彂锛岀郴缁熼檺鍒跺悓涓�鐗╂枡鏉$爜鍦ㄤ袱鍒嗛挓鍐呭彧鑳藉鐞嗕竴娆°��");
+                }
+
                 decimal messageId = 0;
                 string taskCode = "";
+
+                // 鏍规嵁鏉$爜鏌ヨXB_RACKING_TASK_SYXT_LOG琛紝鏌ヨmax(PALLETCODE)鍜屽搴旂殑widthType
+                var rackingTaskInfo = Db.Queryable<XbRackingTaskSyxtLog>()
+                    .Where(x => x.ItemBarcode == barcode)
+                    .OrderByDescending(x => x.Id)
+                    .Select(x => new { x.PalletCode, x.WidthType })
+                    .First();
 
                 try
                 {
@@ -113,7 +503,8 @@
                         .LeftJoin<MesItems>((stock, item) =>
                             stock.ItemId == item.Id)
                         .Where((stock, item) =>
-                            stock.ItemBarcode == barcode && stock.Quantity > 0)
+                            (stock.ItemBarcode == barcode ||
+                             stock.StackCode == barcode) && stock.Quantity > 0)
                         .GroupBy((stock, item) =>
                             new { stock.ItemId, stock.LotNo })
                         .Select((stock, item) => new
@@ -122,7 +513,8 @@
                             ItemName = SqlFunc.AggregateMax(item.ItemName),
                             LotNo = stock.LotNo ?? "",
                             Quantity = SqlFunc.AggregateSum(stock.Quantity),
-                            StackCode = SqlFunc.AggregateMax(stock.DepotSectionsCode)
+                            StackCode =
+                                SqlFunc.AggregateMax(stock.DepotSectionsCode)
                         })
                         .ToList();
 
@@ -144,17 +536,18 @@
                     {
                         taskCode = taskCode,
                         taskType = "1",
-                        palletCode = firstStock.StackCode ?? "",
-                        widthType = "180",
-                        station = "3"
+                        palletCode = rackingTaskInfo?.PalletCode ?? "",
+                        widthType = rackingTaskInfo?.WidthType?.ToString() ??
+                                    "2000",
+                        station = dto.Station
                     };
                     var requestList = new[] { requestData };
                     var jsonRequest = JsonConvert.SerializeObject(requestList);
 
                     // 5. 璁板綍鍒癕essageCenter琛�(璇锋眰鍓�)
-                     
+
                     var messageCenter = new MessageCenter
-                    { 
+                    {
                         TableName = "XB_RACKING_TASK_SYXT_LOG",
                         Url =
                             "http://172.20.5.5:50080/Services/Wmcs/RetrieveTask",
@@ -168,7 +561,8 @@
                         Data = jsonRequest,
                         DataInserted = jsonRequest
                     };
-                    messageId = Db.Insertable(messageCenter).ExecuteReturnIdentity();
+                    messageId = Db.Insertable(messageCenter)
+                        .ExecuteReturnIdentity();
 
                     // 6. 璋冪敤HTTP鎺ュ彛
                     var apiUrl =
@@ -211,17 +605,15 @@
                             CreateDate = DateTime.Now,
                             TaskCode = taskCode,
                             TaskType = "绔嬪簱鍑哄簱璇锋眰",
-                            PalletCode = firstStock.StackCode,
-                            WidthType = 180,
+                            PalletCode = rackingTaskInfo?.PalletCode ?? "",
+                            WidthType = rackingTaskInfo?.WidthType ?? 2000,
                             MaterialName = firstStock.ItemName,
                             MaterialCode = firstStock.ItemNo,
                             BatchNo = firstStock.LotNo,
                             Quantity = firstStock.Quantity,
                             WarehousingJson = responseStr,
                             QcStatus = 2,
-                            ItemBarcode = barcode,
-                            Code = "200",
-                            JsonMessage = jsonMessage ?? "鎴愬姛"
+                            ItemBarcode = barcode
                         };
                         Db.Insertable(taskLog).ExecuteCommand();
 

--
Gitblit v1.9.3