From b2be08ed3f369fc7ada79209d4bb2f8a98c03a61 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期三, 03 十二月 2025 13:40:09 +0800
Subject: [PATCH] 111
---
StandardPda/MES.Service/Dto/webApi/ReturnableStockSearchDto.cs | 5 +
StandardPda/MES.Service/Dto/webApi/ReturnableStockDto.cs | 5 +
StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs | 126 +++++++++++++++++++++++++++++------------
3 files changed, 99 insertions(+), 37 deletions(-)
diff --git a/StandardPda/MES.Service/Dto/webApi/ReturnableStockDto.cs b/StandardPda/MES.Service/Dto/webApi/ReturnableStockDto.cs
index c57192b..8bf3bdb 100644
--- a/StandardPda/MES.Service/Dto/webApi/ReturnableStockDto.cs
+++ b/StandardPda/MES.Service/Dto/webApi/ReturnableStockDto.cs
@@ -84,4 +84,9 @@
/// 鐗╂枡鏉$爜
/// </summary>
public string? ItemBarcode { get; set; }
+
+ /// <summary>
+ /// 搴撳瓨鐘舵�� (绔嬪簱鍏ュ簱涓�=0, 宸插湪绔嬪簱鍐�=1)
+ /// </summary>
+ public string? StockStatus { get; set; }
}
diff --git a/StandardPda/MES.Service/Dto/webApi/ReturnableStockSearchDto.cs b/StandardPda/MES.Service/Dto/webApi/ReturnableStockSearchDto.cs
index 1b812b1..dc4ee68 100644
--- a/StandardPda/MES.Service/Dto/webApi/ReturnableStockSearchDto.cs
+++ b/StandardPda/MES.Service/Dto/webApi/ReturnableStockSearchDto.cs
@@ -100,4 +100,9 @@
/// 鐗╂枡鏉$爜
/// </summary>
public string? ItemBarcode { get; set; }
+
+ /// <summary>
+ /// 搴撳瓨鐘舵�� (绔嬪簱鍏ュ簱涓�=0, 宸插湪绔嬪簱鍐�=1, 杩涘叆绔嬪簱鐨勮矾涓�=2)
+ /// </summary>
+ public string? StockStatus { get; set; }
}
diff --git a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
index a9e4995..38a879e 100644
--- a/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
+++ b/StandardPda/MES.Service/service/Warehouse/MesInvItemStocksManager.cs
@@ -33,10 +33,14 @@
.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")
+ .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())
@@ -71,10 +75,23 @@
var conditions = searchDto.Conditions;
if (conditions != null)
{
+ //褰揷onditions.IqcStatus涓�1鏃舵煡璇㈢殑鍊煎氨瑕佹槸鐗归噰鐩存帴浣跨敤锛屽凡妫�锛屽厤妫�锛�1鐨勫��
// 绮剧‘鍖归厤鏉′欢
if (!string.IsNullOrEmpty(conditions.IqcStatus))
{
- query = query.Where((stock, item, depot, org, unit) => stock.IqcStatus == 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)
@@ -184,16 +201,22 @@
{
// 浼樺厛浣跨敤StockStackCode锛屽惁鍒欎娇鐢↖temBarcode鍘绘煡鎵綪alletCode
var barcodeToMatch = !string.IsNullOrEmpty(x.StockStackCode) ? x.StockStackCode : x.ItemBarcode;
- var palletCode = rackingTaskData
+ var rackingTask = rackingTaskData
.Where(r => r.ItemBarcode == barcodeToMatch)
- .Select(r => r.PalletCode)
.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 = palletCode, // 浣跨敤PalletCode浣滀负姣嶆墭鐩樼紪鍙�
+ StackCode = rackingTask?.PalletCode, // 浣跨敤PalletCode浣滀负姣嶆墭鐩樼紪鍙�
x.DepotCode,
x.DepotName,
x.DepotSectionsCode,
@@ -206,23 +229,24 @@
x.IndepDate,
x.OrgCode,
x.OrgName,
- ItemBarcode = barcodeToMatch
+ ItemBarcode = barcodeToMatch,
+ StockStatus = stockStatus // 娣诲姞搴撳瓨鐘舵��
};
}).ToList();
- // 5.1 搴旂敤IqcStatus鎼滅储鏉′欢锛堝湪鍐呭瓨涓繃婊わ級
- if (conditions != null && !string.IsNullOrEmpty(conditions.IqcStatus))
- {
- tempDataList = tempDataList
- .Where(x => x.IqcStatus == conditions.IqcStatus)
- .ToList();
- }
-
- // 5.2 搴旂敤StackCode鎼滅储鏉′欢锛堝湪鍐呭瓨涓繃婊alletCode锛�
+ // 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();
}
@@ -243,7 +267,8 @@
x.ItemUnitName,
x.OrgCode,
x.OrgName,
- x.ItemBarcode
+ x.ItemBarcode,
+ x.StockStatus // 娣诲姞搴撳瓨鐘舵�佸埌鍒嗙粍閿腑
})
.Select(g => new ReturnableStockDto
{
@@ -262,7 +287,8 @@
IndepDate = g.Max(x => x.IndepDate),
OrgCode = g.Key.OrgCode,
OrgName = g.Key.OrgName,
- ItemBarcode = g.Key.ItemBarcode
+ ItemBarcode = g.Key.ItemBarcode,
+ StockStatus = g.Key.StockStatus // 娣诲姞搴撳瓨鐘舵�佸埌DTO涓�
}).ToList();
// 6. 搴旂敤ItemType绛涢��(鍦ㄥ唴瀛樹腑杩囨护)
@@ -311,6 +337,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)
@@ -344,24 +381,39 @@
.ToList();
// 3. 鍦ㄥ唴瀛樹腑杩涜鏁版嵁杞崲
- var result = queryResult.Select(x => 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
+ var result = queryResult.Select(x => {
+ // 鏍规嵁鏉$爜鏌ユ壘瀵瑰簲鐨勭珛搴撲换鍔′俊鎭�
+ 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;
--
Gitblit v1.9.3