From b54877f2400f752f5b9a1c8aef39c4aa9e851ac5 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 11 三月 2026 09:54:19 +0800
Subject: [PATCH] docs: 添加WCS系统DDD重构设计文档
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 150 insertions(+), 9 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
index cfa497c..c48396e 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
@@ -1,6 +1,5 @@
-锘縰sing SqlSugar;
-using WIDESEA_Common.CommonEnum;
-using WIDESEA_Common.LocationEnum;
+锘縰sing WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -14,9 +13,14 @@
public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, IRepository<Dt_LocationInfo>>, ILocationInfoService
{
public IRepository<Dt_LocationInfo> Repository => BaseDal;
+ public IRepository<Dt_Task> _taskRepository { get; }
- public LocationInfoService(IRepository<Dt_LocationInfo> BaseDal) : base(BaseDal)
+ public IRepository<Dt_StockInfo> _stockInfoRepository { get; set; }
+
+ public LocationInfoService(IRepository<Dt_LocationInfo> BaseDal, IRepository<Dt_Task> taskRepository, IRepository<Dt_StockInfo> stockInfoRepository) : base(BaseDal)
{
+ _taskRepository = taskRepository;
+ _stockInfoRepository = stockInfoRepository;
}
/// <summary>
@@ -109,12 +113,10 @@
EnableStatus = EnableStatusEnum.Normal.GetHashCode(),
LocationStatus = LocationStatusEnum.Free.GetHashCode(),
LocationType = LocationTypeEnum.Undefined.GetHashCode(),
- LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}-{depth:D2}",
+ LocationCode = $"{row:D3}-{col:D3}-{layer:D3}", //$"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}-{depth:D2}"
LocationName = $"{roadwayNo}宸烽亾{row:D3}琛寋col:D3}鍒梴layer:D3}灞倇depth:D2}娣�"
};
}
-
-
/// <summary>
/// 鑾峰彇绌洪棽璐т綅淇℃伅(鏍规嵁宸烽亾鏌ヨ)
@@ -128,7 +130,7 @@
return locations?
.OrderBy(x => x.Layer)
- .ThenBy(x => x.Depth)
+ .ThenByDescending(x => x.Depth)
.ThenBy(x => x.Column)
.ThenBy(x => x.Row)
.FirstOrDefault();
@@ -142,6 +144,11 @@
return await BaseDal.QueryFirstAsync(x => x.RoadwayNo == roadwayNo && x.LocationCode == locationCode);
}
+ public async Task<Dt_LocationInfo> GetLocationInfoAsync(string locationCode)
+ {
+ return await BaseDal.QueryFirstAsync(x => x.LocationCode == locationCode);
+ }
+
/// <summary>
/// 鏇存柊璐т綅淇℃伅
/// </summary>
@@ -149,5 +156,139 @@
{
return await BaseDal.UpdateDataAsync(locationInfo);
}
+
+ /// <summary>
+ /// 妫�鏌ュ苟鐢熸垚绉诲簱浠诲姟鎴栬繑鍥炲嚭搴撲换鍔�
+ /// </summary>
+ /// <param name="locationID">浠诲姟鍙�</param>
+ /// <returns>浠诲姟瀵硅薄</returns>
+ public async Task<WebResponseContent> TransferCheckAsync(int taskNum)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ // 鏍规嵁浠诲姟鍙疯幏鍙栦换鍔�
+ var outboundTask = await _taskRepository.QueryFirstAsync(x => x.TaskNum == taskNum);
+ if (outboundTask == null)
+ return null;
+
+ var location = await BaseDal.QueryFirstAsync(x => x.LocationCode == outboundTask.SourceAddress);
+
+ // 妫�鏌ユ槸鍚﹂渶瑕佽繘琛岀Щ搴�
+ if (CheckForInternalTransfer(location))
+ {
+ // 璁$畻瀵瑰簲浣嶇疆鐨勭浉瀵瑰簱浣� 锛堝鏁拌鐨勪笅涓�琛屾垨鑰呭伓鏁拌鐨勪笂涓�琛岋級
+ var newLocationID = GetRelativeLocationID(location);
+
+ // 鑾峰彇鏂扮殑搴撲綅鐨勪换鍔�
+ var internalTransferTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == newLocationID && x.Roadway == outboundTask.Roadway);
+
+ // 濡傛灉鏂扮殑搴撲綅娌℃湁鎵惧埌瀵瑰簲鐨勪换鍔�
+ if (internalTransferTask == null)
+ {
+ return content.OK("鑾峰彇鍒扮Щ搴撲换鍔�", await HandleNoTaskAtLocation(outboundTask.SourceAddress, newLocationID, outboundTask));
+ }
+
+ // 鐩存帴杩斿洖涓�娣变綅鍑哄簱浠诲姟
+ return content.OK("鑾峰彇鍒颁竴娣变綅鍑哄簱浠诲姟", internalTransferTask);
+ }
+
+ // 杩斿洖褰撳墠搴撲綅鐨勫嚭搴撲换鍔�
+ return content.OK("褰撳墠鍑哄簱浠诲姟", outboundTask);
+ }
+ catch (Exception ex)
+ {
+ return content.Error($"鍙戠敓閿欒:{ex.Message}");
+ }
+ }
+
+ #region 绉诲簱鏂规硶
+
+ /// <summary>
+ /// 璁$畻鐩稿鐨勫簱浣岻D
+ /// </summary>
+ /// <param name="locationID">褰撳墠搴撲綅ID</param>
+ /// <returns>鐩稿鐨勫簱浣岻D</returns>
+ private string GetRelativeLocationID(Dt_LocationInfo locationInfo)
+ {
+ int line = locationInfo.Row;
+
+ // 璁$畻鐩稿鐨勮揣浣嶈鍊硷紝濂囨暟琛岀殑涓嬩竴琛屾垨鑰呭伓鏁拌鐨勪笂涓�琛�
+ int relativeLine = line % 2 == 1 ? line + 1 : line - 1;
+
+ // 鏋勫缓鏂扮殑搴撲綅ID
+ string[] newLocationParts = new string[] { relativeLine.ToString().PadLeft(3, '0'), locationInfo.Column.ToString(), locationInfo.Layer.ToString() };
+ return string.Join("-", newLocationParts);
+ }
+
+ /// <summary>
+ /// 澶勭悊娌℃湁浠诲姟鐨勫簱浣嶆儏鍐�
+ /// </summary>
+ /// <param name="originalLocationID">鍘熷搴撲綅ID</param>
+ /// <param name="newLocationID">鏂扮殑搴撲綅ID</param>
+ /// <param name="outboundTask">鍑哄簱浠诲姟</param>
+ /// <returns>鐢熸垚鐨勭Щ搴撲换鍔℃垨鍘熷鍑哄簱浠诲姟</returns>
+ private async Task<Dt_Task> HandleNoTaskAtLocation(string originalLocationID, string newLocationID, Dt_Task outboundTask)
+ {
+ // 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨
+ var stockInfo = await _stockInfoRepository.QueryFirstAsync(x => x.LocationCode == newLocationID);
+
+ if (stockInfo == null)
+ {
+ // 濡傛灉娌℃湁搴撳瓨锛岀洿鎺ヨ繑鍥炲綋鍓嶅嚭搴撲换鍔�
+ return outboundTask;
+ }
+ else
+ {
+ // 濡傛灉鏈夊簱瀛橈紝鐢熸垚绉诲簱浠诲姟
+ var emptyLocation = await GetTransferLocationEmptyAsync(outboundTask.Roadway);
+ var taskNo = await _taskRepository.GetTaskNo();
+ Dt_Task newTransferTask = new Dt_Task()
+ {
+ CreateDate = DateTime.Now,
+ Creater = App.User.UserName,
+ CurrentAddress = originalLocationID,
+ Grade = 99,
+ NextAddress = emptyLocation.LocationCode,
+ PalletCode = stockInfo.PalletCode,
+ Remark = "绉诲簱",
+ Roadway = stockInfo.LocationDetails.RoadwayNo,
+ SourceAddress = originalLocationID,
+ TaskNum = taskNo,
+ TargetAddress = emptyLocation.LocationCode,
+ TaskType = TaskTypeEnum.Relocation.GetHashCode(),
+ };
+
+ return await _taskRepository.Db.Insertable(newTransferTask).ExecuteReturnEntityAsync();
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁璐т綅鏄惁闇�瑕佺Щ搴�
+ /// </summary>
+ /// <param name="locationID">璐т綅ID</param>
+ /// <returns>鏄惁闇�瑕佺Щ搴�</returns>
+ private bool CheckForInternalTransfer(Dt_LocationInfo location)
+ {
+ return location.Depth == 2 ? true : false;
+ }
+
+ /// <summary>
+ /// 鏍规嵁宸烽亾鑾峰彇浜屾繁浣嶇殑绌哄簱浣�
+ /// </summary>
+ /// <param name="roadway">宸烽亾</param>
+ /// <returns>璐т綅瀵硅薄</returns>
+ private async Task<Dt_LocationInfo> GetTransferLocationEmptyAsync(string roadway)
+ {
+ return await BaseDal.QueryFirstAsync(x => x.Depth == 2 && x.LocationStatus == (LocationStatusEnum.Free.GetHashCode()) && x.RoadwayNo == roadway);
+
+ //Db.Queryable<Dt_LocationInfo>()
+ //.Where(x => x.Status == LocationEnum.Free.ObjToInt())
+ //.Where(x => x.Depth == 2.ToString())
+ //.Where(x => x.Roadway == roadway)
+ //.First();
+ }
+
+ #endregion 绉诲簱鏂规硶
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3