From bfc11f87e2b64420c9917c0b9881b3e327d6f796 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期二, 04 十一月 2025 22:19:59 +0800
Subject: [PATCH] 优化调拨出入库
---
新建文件夹/WIDESEA_WMSServer/ClassLibrary2/InventoryInfoService.cs | 105 ++++++----------------------------------------------
1 files changed, 13 insertions(+), 92 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/InventoryInfoService.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/InventoryInfoService.cs"
index 0859da2..876073f 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/InventoryInfoService.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/InventoryInfoService.cs"
@@ -25,82 +25,6 @@
}
public IRepository<Dt_InventoryInfo> Repository => BaseDal;
- public WebResponseContent GetExpiredAndlow()
- {
- try
- {
- // 鑾峰彇褰撳墠鏃堕棿锛堝彧鍙栨棩鏈熼儴鍒嗭紝蹇界暐鏃堕棿锛�
- DateTime currentDate = DateTime.Today;
- // 璁$畻30澶╁悗鐨勬棩鏈�
- DateTime thresholdDate = currentDate.AddDays(30);
-
- // 鏌ユ壘搴撳瓨涓墍鏈夊晢鍝�
- var inventoryList = BaseDal.QueryData();
- var expiredSoonList = new List<object>();
-
- foreach (var item in inventoryList)
- {
- // 妫�鏌alidityPeriod鏄惁涓虹┖
- if (string.IsNullOrEmpty(item.ValidityPeriod))
- continue;
-
- // 浣跨敤绮剧‘鏍煎紡瑙f瀽 "2037-10-02"
- if (DateTime.TryParseExact(item.ValidityPeriod.Trim(), "yyyy-MM-dd",
- System.Globalization.CultureInfo.InvariantCulture,
- System.Globalization.DateTimeStyles.None, out DateTime expiryDate))
- {
- // 璁$畻鍓╀綑澶╂暟锛堝彧姣旇緝鏃ユ湡閮ㄥ垎锛�
- double daysRemaining = (expiryDate - currentDate).TotalDays;
-
- // 妫�鏌ユ槸鍚﹀湪30澶╁唴锛堝寘鎷凡杩囨湡鐨勶級
- if (daysRemaining <= 30)
- {
- expiredSoonList.Add(new
- {
- MaterielCode = item.MaterielCode ?? "",
- BatchNo = item.BatchNo ?? "",
- ValidityPeriod = item.ValidityPeriod,
- ExpiryDate = expiryDate.ToString("yyyy-MM-dd"),
- });
- }
- }
- else
- {
- // 璁板綍瑙f瀽澶辫触鐨勮褰曪紙鐢ㄤ簬璋冭瘯锛�
- Console.WriteLine($"鏃犳硶瑙f瀽鏁堟湡: {item.ValidityPeriod}");
- }
- }
-
- // 鎸夊墿浣欏ぉ鏁板崌搴忔帓鍒楋紙鍗冲皢杩囨湡鐨勬帓鍓嶉潰锛�
- var sortedList = expiredSoonList.OrderBy(x =>
- {
- var days = (int)((dynamic)x).DaysRemaining;
- return days;
- }).ToList();
-
- return new WebResponseContent
- {
- Status = true,
- Message = $"鍙戠幇 {sortedList.Count} 涓晢鍝佸皢鍦�30澶╁唴杩囨湡",
- Data = new
- {
- TotalCount = sortedList.Count,
- ExpiredCount = sortedList.Count(x => ((dynamic)x).DaysRemaining < 0),
- WarningCount = sortedList.Count(x => ((dynamic)x).DaysRemaining >= 0),
- CheckDate = currentDate.ToString("yyyy-MM-dd"),
- Items = sortedList
- }
- };
- }
- catch (Exception ex)
- {
- return new WebResponseContent
- {
- Status = false,
- Message = $"鑾峰彇鏁堟湡鏁版嵁澶辫触: {ex.Message}"
- };
- }
- }
/// <summary>
/// 鑾峰彇搴撳瓨
@@ -114,33 +38,30 @@
List<object> lists = new List<object>();
#region 鍐峰喕搴�
string WareCodeLD = WarehouseEnum.鍐峰喕搴�.ObjToInt().ToString("000");
- List<Dt_InventoryInfo> inventoryInfosLD = BaseDal.QueryData(x => x.WarehouseCode == WareCodeLD);
- object LDQty = new
+ var LDQty = Convert.ToInt32(BaseDal.QueryData(x => x.WarehouseCode == WareCodeLD).Sum(x => x.StockQuantity));
+ lists.Add(new
{
name = WarehouseEnum.鍐峰喕搴�.ObjToString(),
- count = inventoryInfosLD.Sum(x => x.StockQuantity).ObjToInt()
- };
- lists.Add(LDQty);
+ count = LDQty
+ });
#endregion
#region 楹荤簿搴�
string WareCodeMJ = WarehouseEnum.楹荤簿搴�.ObjToInt().ToString("000");
- List<Dt_InventoryInfo> inventoryInfosMJ = BaseDal.QueryData(x => x.WarehouseCode == WareCodeMJ);
- object MJQty = new
+ var MJQty = Convert.ToInt32(BaseDal.QueryData(x => x.WarehouseCode == WareCodeMJ).Sum(x => x.StockQuantity));
+ lists.Add(new
{
name = WarehouseEnum.楹荤簿搴�.ObjToString(),
- count = inventoryInfosMJ.Sum(x => x.StockQuantity).ObjToInt()
- };
- lists.Add(MJQty);
+ count = MJQty
+ });
#endregion
#region 澶т欢搴�
string WareCodeDJ = WarehouseEnum.澶т欢搴�.ObjToInt().ToString("000");
- List<Dt_InventoryInfo> inventoryInfosDJ = BaseDal.QueryData(x => x.WarehouseCode == WareCodeDJ);
- object DJQty = new
+ var DJQty = Convert.ToInt32(BaseDal.QueryData(x => x.WarehouseCode == WareCodeDJ).Sum(x => x.StockQuantity));
+ lists.Add(new
{
name = WarehouseEnum.澶т欢搴�.ObjToString(),
- count = inventoryInfosDJ.Sum(x => x.StockQuantity).ObjToInt()
- };
- lists.Add(DJQty);
+ count = DJQty
+ });
#endregion
content.OK(data: lists);
}
@@ -152,6 +73,6 @@
}
-
+
}
}
--
Gitblit v1.9.3