From 679893ee68e2f7d422431bb22b665e9217f23410 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期四, 16 四月 2026 16:41:11 +0800
Subject: [PATCH] 深库位与浅库位出库时,进行浅货位移库不可直接出库
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 214 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 199 insertions(+), 15 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs"
index d8f37f8..0225954 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs"
@@ -21,6 +21,7 @@
private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
private readonly IDt_WheelsStockRepository _WheelsStockRepository;
+ private readonly IDt_ZdpStockRepository _zdpStockRepository;
private readonly IMapper _mapper;
public LocationInfoService(ILocationInfoRepository BaseDal,
@@ -33,7 +34,8 @@
IStockInfoDetailRepository stockInfoDetailRepository,
IMapper mapper,
IDt_TaskService taskService,
- IDt_WheelsStockRepository wheelsStockRepository) : base(BaseDal)
+ IDt_WheelsStockRepository wheelsStockRepository,
+ IDt_ZdpStockRepository zdpStockRepository) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_taskRepository = taskRepository;
@@ -45,6 +47,7 @@
_mapper = mapper;
_taskService = taskService;
_WheelsStockRepository = wheelsStockRepository;
+ _zdpStockRepository = zdpStockRepository;
}
/// <summary>
@@ -82,11 +85,72 @@
var internalTransferTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == newLocationID && x.Roadway == outboundTask.Roadway && x.TaskState == (int)TaskOutStatusEnum.OutNew);
LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鏂板簱浣嶇殑浠诲姟", $"鏂板簱浣嶄换鍔★細{internalTransferTask}");
+
+
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $"");
+ return await HandleNoTaskAtLocation(outboundTask.SourceAddress, newLocationID, outboundTask);
+ // 濡傛灉鏂扮殑搴撲綅娌℃湁鎵惧埌瀵瑰簲鐨勪换鍔�
+ /*if (internalTransferTask == null)
+ {
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $"");
+ return await HandleNoTaskAtLocation(outboundTask.SourceAddress, newLocationID, outboundTask);
+ }
+
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鍒版柊搴撲綅浠诲姟鐩存帴杩斿洖", $"鏂板簱浣嶄换鍔★細{internalTransferTask}");
+ // 鐩存帴杩斿洖涓�娣变綅鍑哄簱浠诲姟
+ return internalTransferTask;*/
+ }
+
+ // 杩斿洖褰撳墠搴撲綅鐨勫嚭搴撲换鍔�
+ return outboundTask;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+
+ /// <summary>
+ /// 妫�鏌ュ苟鐢熸垚绉诲簱浠诲姟鎴栬繑鍥炲叆搴撲换鍔�
+ /// </summary>
+ /// <param name="locationID">浠诲姟鍙�</param>
+ /// <returns>浠诲姟瀵硅薄</returns>
+ public virtual async Task<Dt_Task> InTransferCheckAsync(RequestTaskDto input)
+ {
+ try
+ {
+ int taskNum = input.taskNum;
+
+ // 鏍规嵁浠诲姟鍙疯幏鍙栧叆搴撲换鍔�
+ var inboundTask = await _taskRepository.QueryFirstAsync(x => x.TaskNum == taskNum);
+ if (inboundTask == null)
+ return null;
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鏍规嵁浠诲姟鍙疯幏鍙栦换鍔�", $"浠诲姟鍙凤細{taskNum}锛屼换鍔℃暟鎹細{inboundTask}");
+
+ var location = await BaseDal.QueryFirstAsync(x => x.LocationCode == inboundTask.TargetAddress);
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鑾峰彇鎸囧畾搴撲綅鐨勮揣浣嶆暟鎹�", $"璐т綅鍙凤細{inboundTask.TargetAddress}锛岃揣浣嶆暟鎹細{location}");
+
+ // 妫�鏌ユ槸鍚﹂渶瑕佽繘琛岀Щ搴�
+ if (CheckForInternalTransfer(location))
+ {
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�", $"璐т綅鍙凤細{inboundTask.TargetAddress}锛岃揣浣嶆暟鎹細{location}");
+ // 璁$畻瀵瑰簲浣嶇疆鐨勭浉瀵瑰簱浣� 锛堝鏁拌鐨勪笅涓�琛屾垨鑰呭伓鏁拌鐨勪笂涓�琛岋級
+ var newLocationID = GetRelativeLocationID(location);
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,缁勫缓闇�瑕佺Щ搴撹揣浣嶅彿", $"鏂扮殑搴撲綅ID锛歿newLocationID}");
+
+ var relocationTask = await _taskRepository.QueryFirstAsync(x => x.TargetAddress == newLocationID && x.Roadway == inboundTask.Roadway && x.TaskType == (int)TaskTypeEnum.Relocation);
+ if (relocationTask != null) return relocationTask;
+
+ // 鑾峰彇鏂扮殑搴撲綅鐨勪换鍔�
+ var internalTransferTask = await _taskRepository.QueryFirstAsync(x => x.TargetAddress == newLocationID && x.Roadway == inboundTask.Roadway && x.TaskState == (int)TaskOutStatusEnum.OutNew);
+
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鏂板簱浣嶇殑浠诲姟", $"鏂板簱浣嶄换鍔★細{internalTransferTask}");
// 濡傛灉鏂扮殑搴撲綅娌℃湁鎵惧埌瀵瑰簲鐨勪换鍔�
if (internalTransferTask == null)
{
LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $"");
- return await HandleNoTaskAtLocation(outboundTask.SourceAddress, newLocationID, outboundTask);
+ return await InHandleLocation(inboundTask.TargetAddress, newLocationID, inboundTask);
}
LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鍒版柊搴撲綅浠诲姟鐩存帴杩斿洖", $"鏂板簱浣嶄换鍔★細{internalTransferTask}");
// 鐩存帴杩斿洖涓�娣变綅鍑哄簱浠诲姟
@@ -94,7 +158,7 @@
}
// 杩斿洖褰撳墠搴撲綅鐨勫嚭搴撲换鍔�
- return outboundTask;
+ return inboundTask;
}
catch (Exception)
{
@@ -253,6 +317,43 @@
#endregion 鍚敤绂佺敤璐т綅
+ #region 澶у睆搴撲綅鐘舵�佽幏鍙�
+ public WebResponseContent LocationStatuskt()
+ {
+ WebResponseContent content = new WebResponseContent();
+
+ // 鑾峰彇鎵�鏈夊簱浣嶆暟鎹�
+ List<DtLocationInfo> locations = BaseDal.QueryData();
+
+ // 瀹氫箟鎵�鏈夊彲鑳界殑鐘舵�佸強鍏跺搴旂殑鏄剧ず鏂囨湰
+ var allStatuses = new Dictionary<int, string>
+{
+ { 0, "绌鸿揣浣�" },
+ { 1, "閿佸畾" },
+ { 2, "鏈夎揣" },
+ { 3, "鏈夎揣绂佺敤" }
+};
+
+ // 鎸塋ocationStatus鍒嗙粍缁熻
+ var statusGroups = allStatuses
+ .GroupJoin(locations.GroupBy(l => l.LocationStatus),
+ status => status.Key,
+ group => group.Key,
+ (status, groups) => new
+ {
+ Status = status.Value,
+ Count = groups.SelectMany(g => g).Any() ? groups.First().Count() : 0
+ })
+ .ToList();
+
+ // 灏嗙粺璁$粨鏋滄斁鍏ュ搷搴斿唴瀹�
+ content.Data = statusGroups;
+
+ return content;
+ }
+ #endregion
+
+
#region 鍐呴儴鏂规硶
#region 绉诲簱鏂规硶
@@ -284,15 +385,95 @@
/// <returns>鐢熸垚鐨勭Щ搴撲换鍔℃垨鍘熷鍑哄簱浠诲姟</returns>
private async Task<Dt_Task> HandleNoTaskAtLocation(string originalLocationID, string newLocationID, Dt_Task outboundTask)
{
+ try
+ {
+ // 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨
+ var stockInfo = await _WheelsStockRepository.QueryFirstAsync(x => x.Wheels_Location == newLocationID);
+
+ // 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨
+ var zdpInfo = await _zdpStockRepository.QueryFirstAsync(x => x.Zdp_Location == newLocationID);
+
+
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鑾峰彇鐨勫簱瀛樹俊鎭�", $"鏍规嵁璐т綅缂栧彿锛歿newLocationID}锛岃浣嶇疆鏄惁鏈夊簱瀛橈細{stockInfo.ToJson()}");
+ if (stockInfo == null && zdpInfo == null)
+ {
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌搴撳瓨鏁版嵁", $"鐩存帴杩斿洖鍘熷厛鍑哄簱浠诲姟锛歿outboundTask}");
+ // 濡傛灉娌℃湁搴撳瓨锛岀洿鎺ヨ繑鍥炲綋鍓嶅嚭搴撲换鍔�
+ return outboundTask;
+ }
+ else
+ {
+ // 濡傛灉鏈夊簱瀛橈紝鐢熸垚绉诲簱浠诲姟
+ var emptyLocation = RequestLocation("SC1");
+ if (emptyLocation == null) throw new Exception("鏆傛棤绌哄簱");
+
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏌ユ壘鑳界Щ搴撹揣浣�", $"璐т綅鏁版嵁锛歿emptyLocation}");
+ var taskNo = await _taskRepository.GetTaskNo();
+ Dt_Task newTransferTask = new Dt_Task()
+ {
+ CreateDate = DateTime.Now,
+ Creater = App.User.UserName == null ? "admin" : App.User.UserName,
+ CurrentAddress = stockInfo != null ? stockInfo.Wheels_Location : zdpInfo.Zdp_Location,
+ Grade = 99,
+ MaterialNo = stockInfo != null ? stockInfo.Wheels_Type : "2",
+ NextAddress = emptyLocation.LocationCode,
+ PalletCode = stockInfo != null ? stockInfo.Wheels_Num : zdpInfo.Zdp_code,
+ Remark = "绉诲簱",
+ Roadway = "SC1",
+ SourceAddress = stockInfo != null ? stockInfo.Wheels_Location : zdpInfo.Zdp_Location,
+ TaskNum = taskNo,
+ TargetAddress = emptyLocation.LocationCode,
+ TaskState = (int)TaskStatus.Created,
+ TaskType = (int)TaskTypeEnum.Relocation,
+ Dispatchertime = DateTime.Now,
+ };
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏂板缓绉诲簱浠诲姟", $"绉诲簱浠诲姟鏁版嵁锛歿newTransferTask.ToJson()}");
+
+ // 鑾峰彇鏂扮殑搴撲綅鐨勪换鍔�
+ var internalTransferTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == newLocationID && x.Roadway == outboundTask.Roadway && x.TaskState == (int)TaskOutStatusEnum.OutNew);
+ if (internalTransferTask != null)
+ {
+ internalTransferTask.SourceAddress = emptyLocation.LocationCode;
+ internalTransferTask.CurrentAddress = emptyLocation.LocationCode;
+ await _taskRepository.Update(internalTransferTask);
+ }
+
+ //淇敼搴撲綅鐘舵��
+ emptyLocation.LocationStatus = (int)LocationEnum.FreeDisable;
+ BaseDal.UpdateData(emptyLocation);
+
+ return await _taskRepository.Create(newTransferTask);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鏂规硶锛欻andleNoTaskAtLocation", $"鍑洪敊锛屽師鍥狅細{ex.ToJson()}");
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// 澶勭悊鍏ュ簱娌℃湁浠诲姟鐨勫簱浣嶆儏鍐�
+ /// </summary>
+ /// <param name="originalLocationID">鍘熷搴撲綅ID</param>
+ /// <param name="newLocationID">鏂扮殑搴撲綅ID</param>
+ /// <param name="outboundTask">鍑哄簱浠诲姟</param>
+ /// <returns>鐢熸垚鐨勭Щ搴撲换鍔℃垨鍘熷鍑哄簱浠诲姟</returns>
+ private async Task<Dt_Task> InHandleLocation(string originalLocationID, string newLocationID, Dt_Task inboundTask)
+ {
// 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨
var stockInfo = await _WheelsStockRepository.QueryFirstAsync(x => x.Wheels_Location == newLocationID);
+ // 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨
+ var zdpInfo = await _zdpStockRepository.QueryFirstAsync(x => x.Zdp_Location == newLocationID);
+
+
LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $"璇ヤ綅缃槸鍚︽湁搴撳瓨锛歿stockInfo}");
- if (stockInfo == null)
+ if (stockInfo == null && zdpInfo == null)
{
- LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌搴撳瓨鏁版嵁", $"鐩存帴杩斿洖鍘熷厛鍑哄簱浠诲姟锛歿outboundTask}");
+ LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌搴撳瓨鏁版嵁", $"鐩存帴杩斿洖鍘熷厛鍑哄簱浠诲姟锛歿inboundTask}");
// 濡傛灉娌℃湁搴撳瓨锛岀洿鎺ヨ繑鍥炲綋鍓嶅嚭搴撲换鍔�
- return outboundTask;
+ return inboundTask;
}
else
{
@@ -306,14 +487,14 @@
{
CreateDate = DateTime.Now,
Creater = App.User.UserName == null ? "admin" : App.User.UserName,
- CurrentAddress = stockInfo.Wheels_Location,
+ CurrentAddress = stockInfo != null ? stockInfo.Wheels_Location : zdpInfo.Zdp_Location,
Grade = 99,
- MaterialNo = stockInfo.Wheels_Type,
+ MaterialNo = stockInfo != null ? stockInfo.Wheels_Type : "2",
NextAddress = emptyLocation.LocationCode,
- PalletCode = stockInfo.Wheels_Num,
+ PalletCode = stockInfo != null ? stockInfo.Wheels_Num : zdpInfo.Zdp_code,
Remark = "绉诲簱",
Roadway = "SC1",
- SourceAddress = stockInfo.Wheels_Location,
+ SourceAddress = stockInfo != null ? stockInfo.Wheels_Location : zdpInfo.Zdp_Location,
TaskNum = taskNo,
TargetAddress = emptyLocation.LocationCode,
TaskState = (int)TaskStatus.Created,
@@ -360,17 +541,20 @@
//List<DtLocationInfo> locations = new List<DtLocationInfo>();
if (locationInfos == null || locationInfos.Count == 0)
{
- locationInfos = BaseDal.QueryData(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == "SC1" && x.EnalbeStatus == 1 && x.LocationType == 1);
+ locationInfos = BaseDal.QueryData(x => x.LocationStatus == 0 && x.RoadwayNo == "SC1" && x.EnalbeStatus == 1 && x.LocationType == 1);
+
}
- var location = GetEmptyLocation(locationInfos);
+ var location = GetEmptyLocation(locationInfos); //鎵惧嚭璐т綅
if (location != null)
{
if (location.Depth == 2)
{
int row = location.Row;
- int relativeLine = row % 2 == 1 ? row + 1 : row - 1;
+ //int relativeLine = row % 2 == 1 ? row + 1 : row - 1;
+
+ int relativeLine = row == 1 ? row + 1 : row - 1;
var insideLocation = BaseDal.QueryFirst(x => x.Row == relativeLine && x.Layer == location.Layer && x.Column == location.Column);
@@ -378,7 +562,7 @@
{
locationInfos.Remove(location);
if (locationInfos.Count == 0) return null;
- RequestLocation(RoadWayNo, locationInfos);
+ return RequestLocation(RoadWayNo, locationInfos);
}
}
}
@@ -399,7 +583,7 @@
}
private DtLocationInfo GetEmptyLocation(List<DtLocationInfo> dtLocationInfos)
{
- var locationinfo = dtLocationInfos.Where(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == "SC1" && x.EnalbeStatus == 1 && x.LocationType == 1).OrderBy(x => x.Layer).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ThenBy(x => x.Column).FirstOrDefault();
+ var locationinfo = dtLocationInfos.Where(x => x.LocationStatus == 0 && x.RoadwayNo == "SC1" && x.EnalbeStatus == 1 && x.LocationType == 1).OrderBy(x => x.Layer).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ThenBy(x => x.Column).FirstOrDefault();
return locationinfo;
}
--
Gitblit v1.9.3