From 461524a7a1def4532b9af4ab40733f899f360db7 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 09 四月 2026 14:39:45 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 143 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 143 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 37dcbc7..10ebb01 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -1441,6 +1441,149 @@
}
}
}
+
+ /// <summary>
+ /// 閫夊畾搴撳瓨璺ㄥ尯鍩熺Щ搴�
+ /// </summary>
+ /// <param name="stockViews"></param>
+ /// <param name="targetLocationType">鐩爣璐т綅绫诲瀷</param>
+ /// <returns></returns>
+ public async Task<WebResponseContent> CrossAreaOutbound(List<StockViewDTO> stockViews, int targetLocationType)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if(targetLocationType == (int)LocationTypeEnum.Electronic)
+ {
+ return content.Error("鐢靛瓙浠撲笉鍏佽璺ㄥ尯鍩熺Щ搴�");
+ }
+ List<int> ids = stockViews.Select(x => x.StockId).ToList();
+ List<Dt_StockInfo> stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList();
+
+ if (stockInfos.Count != stockViews.Count)
+ {
+ StockViewDTO? stockViewDTO = stockViews.FirstOrDefault(x => !stockInfos.Select(x => x.PalletCode).Contains(x.PalletCode));
+ return content.Error($"鏈壘鍒皗stockViewDTO?.PalletCode}搴撳瓨");
+ }
+
+ List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList();
+ List<Dt_LocationInfo> locationInfos = _locationInfoService.Db.Queryable<Dt_LocationInfo>().Where(x => locStrs.Contains(x.LocationCode)).ToList();
+
+ if (stockInfos.Count != locationInfos.Count)
+ {
+ string? locStr = locStrs.FirstOrDefault(x => !locationInfos.Select(x => x.LocationCode).Contains(x));
+ return content.Error($"鏈壘鍒皗locStr}璐т綅鏁版嵁");
+ }
+
+ foreach (var item in stockInfos)
+ {
+ if (item.PalletType != PalletTypeEnum.Empty.ObjToInt())
+ {
+ return content.Error($"鎵樼洏銆恵item.PalletCode}銆戦潪绌虹锛屼粎绌虹鍏佽璺ㄥ尯鍩熺Щ搴擄紒");
+ }
+ Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
+ if (locationInfo == null || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt() || item.StockStatus != StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
+ {
+ return content.Error($"{item.PalletCode}璐т綅鎴栧簱瀛樼姸鎬佷笉婊¤冻鍑哄簱鏉′欢");
+ }
+ }
+
+ List<Dt_Task> tasks = CrossAreaGetTasks(stockInfos, targetLocationType, TaskTypeEnum.CrossAreaRelocation);
+
+ if (tasks == null || tasks.Count <= 0)
+ {
+ return content.Error("鐢熸垚璺ㄥ尯鍩熺Щ搴撲换鍔″け璐�");
+ }
+
+ stockInfos.ForEach(x =>
+ {
+ x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+ });
+
+ tasks.ForEach(x =>
+ {
+ x.OrderNo = "璺ㄥ尯鍩熺Щ搴�";
+ });
+
+ locationInfos.ForEach(x =>
+ {
+ x.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
+ });
+
+ _unitOfWorkManage.BeginTran();
+ _stockRepository.UpdateData(stockInfos);
+ BaseDal.AddData(tasks);
+ _locationInfoService.UpdateData(locationInfos);
+ _unitOfWorkManage.CommitTran();
+
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
+ }
+ return content;
+ }
+
+
+ /// <summary>
+ /// 鐢熸垚璺ㄥ尯鍩熺Щ搴撲换鍔�
+ /// </summary>
+ /// <param name="stockInfos">搴撳瓨鍒楄〃</param>
+ /// <param name="targetAreaCode">鐩爣鍖哄煙缂栫爜</param>
+ /// <param name="taskType">浠诲姟绫诲瀷</param>
+ /// <returns></returns>
+ public List<Dt_Task> CrossAreaGetTasks(List<Dt_StockInfo> stockInfos, int targetLocationType, TaskTypeEnum taskType)
+ {
+ using (var scope = new TransactionScope(TransactionScopeOption.Required,
+ new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
+ {
+ try
+ {
+ List<Dt_Task> tasks = new List<Dt_Task>();
+
+ foreach (var stockInfo in stockInfos)
+ {
+ Dt_LocationInfo newLocation = _locationInfoService.AssignLocation(targetLocationType);
+
+ if (newLocation == null)
+ {
+ throw new Exception($"{stockInfo.PalletCode} 娌℃湁绌洪棽璐т綅鍙繘琛岃法鍖哄煙绉诲簱");
+ }
+
+ if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
+ {
+ Dt_Task task = new()
+ {
+ CurrentAddress = stockInfo.LocationCode,
+ Grade = 0,
+ PalletCode = stockInfo.PalletCode,
+ NextAddress = "",
+ Roadway = newLocation.RoadwayNo,
+ SourceAddress = stockInfo.LocationCode,
+ TargetAddress = newLocation.LocationCode,
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ TaskType = taskType.ObjToInt(),
+ PalletType = stockInfo.PalletType,
+ WarehouseId = stockInfo.WarehouseId,
+ };
+ tasks.Add(task);
+ }
+
+ newLocation.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
+ _locationInfoService.UpdateData(newLocation);
+ }
+
+ scope.Complete();
+ return tasks;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+ }
}
}
--
Gitblit v1.9.3