From 75e3bca44b111c167b9389e4e51b2ce577a9f9e0 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期日, 10 八月 2025 10:35:50 +0800
Subject: [PATCH] 优化更新
---
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs | 233 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 180 insertions(+), 53 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
index 7e52a74..3591fee 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -60,18 +60,20 @@
{
Dt_Task task = new()
{
+ PalletType = stockInfo.PalletType,
OrderNo = stockInfoDetail.OrderNo,
- CurrentAddress = "0",
+ CurrentAddress = locationInfo.LocationCode,
Grade = 0,
Creater = "WMS",
PalletCode = stockInfo.PalletCode,
- NextAddress = "",
+ NextAddress = roadwayInfo.OutSCStationCode,
Roadway = locationInfo.RoadwayNo,
- SourceAddress = stockInfo.LocationCode,
- TargetAddress = roadwayInfo.OutStationCode,
+ SourceAddress = locationInfo.LocationCode,
+ TargetAddress = "",
TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
TaskType = TaskTypeEnum.Outbound.ObjToInt(),
Depth = locationInfo.Depth,
+ WarehouseId = stockInfo.WarehouseId,
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
};
tasks.Add(task);
@@ -80,8 +82,84 @@
}
}
- BaseDal.AddData(tasks);
return tasks;
+ }
+
+
+
+ /// <summary>
+ /// 鍑哄簱浠诲姟鏁版嵁澶勭悊
+ /// </summary>
+ /// <param name="orderDetailId"></param>
+ /// <param name="stockSelectViews"></param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys)
+ {
+ List<Dt_Task> tasks = new List<Dt_Task>();
+ List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id));
+
+ if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
+ {
+ throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+ }
+ if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null)
+ {
+ throw new Exception("鎵�閫夊嚭搴撳崟鏄庣粏瀛樺湪鍑哄簱涓垨宸插畬鎴�");
+ }
+ List<Dt_StockInfo>? stockInfos = null;
+ List<Dt_OutboundOrderDetail>? orderDetails = null;
+ List<Dt_OutStockLockInfo>? outStockLockInfos = null;
+ List<Dt_LocationInfo>? locationInfos = null;
+ //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+ {
+ (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+ if (result.Item1 != null && result.Item1.Count > 0)
+ {
+ Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+ TaskTypeEnum typeEnum = outboundOrder.OrderType switch
+ {
+ (int)OutOrderTypeEnum.work => TaskTypeEnum.Outbound,
+ (int)OutOrderTypeEnum.Allocate => TaskTypeEnum.OutAllocate,
+ (int)OutOrderTypeEnum.Quality => TaskTypeEnum.OutQuality,
+ _ => new TaskTypeEnum()
+ };
+ tasks = GetTasks(result.Item1);
+ tasks.ForEach(x =>
+ {
+ x.OrderNo = outboundOrder.UpperOrderNo;
+ });
+ result.Item2.ForEach(x =>
+ {
+ x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+ });
+ result.Item3.ForEach(x =>
+ {
+
+ x.Status = OutStockStatus.鍑哄簱涓�.ObjToInt();
+ });
+
+ stockInfos = result.Item1;
+ orderDetails = result.Item2;
+ outStockLockInfos = result.Item3;
+ locationInfos = result.Item4;
+ }
+ else
+ {
+ throw new Exception("鏃犲簱瀛�");
+ }
+ }
+ //else
+ //{
+ // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.宸插垎閰�);
+ // if (stockLockInfos != null && stockLockInfos.Count > 0)
+ // {
+ // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
+ // tasks = GetTasks(stocks);
+ // }
+ //}
+
+ return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
}
/// <summary>
@@ -157,45 +235,90 @@
WebResponseContent content = new();
try
{
- OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
- orderAddDTO1.OrderNo = orderAddDTO.No;
- orderAddDTO1.UpperOrderNo = orderAddDTO.No;
- orderAddDTO1.OutWareHouse = orderAddDTO.OutWareHouse;
- orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode;
- orderAddDTO1.InoutType = orderAddDTO.OrderType;
- orderAddDTO1.OrderType = orderAddDTO.InoutType.ObjToInt();
- IEnumerable<int> inOrderTypes = Enum.GetValues<OrderTypeEmun>().Cast<int>();
- //orderAddDTO1.OrderType = orderAddDTO.OrderType.ObjToInt();
- orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
- #region 楠岃瘉鏁版嵁
- (bool, string, object?) result = CheckOutboundOrderAddData(orderAddDTO1);
- if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
- #endregion
- Dt_OutboundOrder inboundOrder = _mapper.Map<Dt_OutboundOrder>(orderAddDTO1);
- inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
- inboundOrder.Creater = "WMS";
- inboundOrder.CreateDate = DateTime.Now;
-
-
- Dt_OutboundOrder oldOutboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO1.OrderNo).Includes(x => x.Details).First();
- Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == oldOutboundOrder.Id);
- List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>();
- StockSelectViewDTO stockSelectViewDTO = new()
+ Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseCode == orderAddDTO.OutWareHouse);
+ if (warehouse == null)
{
- OrderNo = orderAddDTO1.OrderNo,
- MaterielCode = outboundOrderDetail.MaterielCode,
- MaterielName = outboundOrderDetail.MaterielName,
- UseableQuantity = outboundOrderDetail.OrderQuantity,
- BatchNo = outboundOrderDetail.BatchNo,
- LinId = outboundOrderDetail.LinId,
- PalletCode = outboundOrderDetail.LPNNo,
- };
- _unitOfWorkManage.BeginTran();
- bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
- stockSelectViews.Add(stockSelectViewDTO);
- GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews);
- _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌浠撳簱淇℃伅");
+ }
+ Dt_OutboundOrder oldOuboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO.No).Includes(x => x.Details).First();
+ if (oldOuboundOrder != null)
+ {
+ //if (oldOuboundOrder.Details.FirstOrDefault(x => x.LinId == Convert.ToInt32(orderAddDTO.LinId)) != null)
+ //{
+ // return WebResponseContent.Instance.Error($"璇ユ槑缁嗚鍙峰凡瀛樺湪");
+ //}
+ if (oldOuboundOrder.OutWareHouse != warehouse.WarehouseCode)
+ {
+ return WebResponseContent.Instance.Error($"浠撳簱涓嶄竴鑷�");
+ }
+ else
+ {
+ OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
+ orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
+ var details = orderAddDTO1.Details.FirstOrDefault();
+ Dt_OutboundOrderDetail outboundOrderDetail = new Dt_OutboundOrderDetail()
+ {
+ LPNNo = details.LPNNo,
+ BatchNo = details.BatchNo,
+ MaterielCode = details.MaterielCode,
+ MaterielName = details.MaterielName,
+ MaterieSpec = details.MaterieSpec,
+ OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
+ OrderQuantity = details.OrderQuantity,
+ OrderId = oldOuboundOrder.Id,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ };
+ _outboundOrderDetailRepository.AddData(outboundOrderDetail);
+ //_outboundOrderDetailRepository.AddData(outboundOrderDetail);
+ }
+ }
+ else
+ {
+ OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO();
+ orderAddDTO1.OrderNo = orderAddDTO.No;
+ orderAddDTO1.UpperOrderNo = orderAddDTO.No;
+ orderAddDTO1.OutWareHouse = orderAddDTO.OutWareHouse;
+ orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode;
+ orderAddDTO1.InoutType = orderAddDTO.OrderType;
+ orderAddDTO1.OrderType = orderAddDTO.InoutType.ObjToInt();
+ IEnumerable<int> inOrderTypes = Enum.GetValues<OrderTypeEmun>().Cast<int>();
+ //orderAddDTO1.OrderType = orderAddDTO.OrderType.ObjToInt();
+ orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>();
+ #region 楠岃瘉鏁版嵁
+ (bool, string, object?) result = CheckOutboundOrderAddData(orderAddDTO1);
+ if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+ #endregion
+
+ Dt_OutboundOrder inboundOrder = _mapper.Map<Dt_OutboundOrder>(orderAddDTO1);
+ inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
+ inboundOrder.Creater = "WMS";
+ inboundOrder.CreateDate = DateTime.Now;
+ _unitOfWorkManage.BeginTran();
+ bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+ //Dt_OutboundOrder oldOutboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO1.OrderNo).Includes(x => x.Details).First();
+ //Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == oldOutboundOrder.Id);
+ //List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>();
+ //StockSelectViewDTO stockSelectViewDTO = new()
+ //{
+ // OrderNo = orderAddDTO1.OrderNo,
+ // MaterielCode = outboundOrderDetail.MaterielCode,
+ // MaterielName = outboundOrderDetail.MaterielName,
+ // UseableQuantity = outboundOrderDetail.OrderQuantity,
+ // BatchNo = outboundOrderDetail.BatchNo,
+ // LinId = outboundOrderDetail.LinId,
+ // PalletCode = outboundOrderDetail.LPNNo,
+ //};
+
+
+ //stockSelectViews.Add(stockSelectViewDTO);
+ //GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews);
+
+ _unitOfWorkManage.CommitTran();
+ }
+
+
content = WebResponseContent.Instance.OK();
}
catch (Exception ex)
@@ -338,6 +461,8 @@
{
WebResponseContent content = new WebResponseContent();
_unitOfWorkManage.BeginTran();
+
+ BaseDal.AddData(tasks);
//鍒ゆ柇绉诲簱
//content = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
//if (content.Status)
@@ -350,19 +475,19 @@
// return content;
//}
//BaseDal.AddData(tasks);
+
if (stockInfos != null && outboundOrderDetails != null && outStockLockInfos != null && locationInfos != null)
{
+ Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+ outboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
+ _outboundService.OutboundOrderService.Repository.UpdateData(outboundOrder);
content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks);
- if (content.Status)
- {
- _unitOfWorkManage.CommitTran();
- }
- else
+ if (!content.Status)
{
_unitOfWorkManage.RollbackTran();
+ return content;
}
- return content;
}
else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0)
{
@@ -374,6 +499,8 @@
_outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
}
_unitOfWorkManage.CommitTran();
+ //灏嗕换鍔℃帹閫佸埌WCS
+ PushTasksToWCS(tasks);
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
@@ -478,7 +605,7 @@
{
PalletCode = dt_StockInfo.PalletCode,
Roadway = locationInfos.RoadwayNo,
- TaskType = TaskTypeEnum.RelocationIn.ObjToInt(),
+ //TaskType = TaskTypeEnum.RelocationIn.ObjToInt(),
TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
SourceAddress = locationInfos.LocationCode,
TargetAddress = newLocation.LocationCode,
@@ -533,7 +660,7 @@
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
- public WebResponseContent GenerateOutboundTask(int[] keys)
+ public WebResponseContent WMSGenerateOutboundTask(int[] keys)
{
try
{
@@ -546,7 +673,7 @@
foreach (int key in keys)
{
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(key, stockSelectViews);
+ (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
if (result.Item2 != null && result.Item2.Count > 0)
{
stockInfos.AddRange(result.Item2);
@@ -592,7 +719,7 @@
Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
if (task != null)
{
- if (task.TaskType == (int)TaskTypeEnum.Outbound || task.TaskType == (int)TaskTypeEnum.PalletOutbound)
+ if (task.TaskType == (int)TaskTypeEnum.Outbound || task.TaskType == (int)TaskTypeEnum.EmptyProductBack)
{
//澶勭悊鍑哄簱鐨勯�昏緫
Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
@@ -620,7 +747,7 @@
return content = WebResponseContent.Instance.Error($"鍑哄簱浠诲姟鍙栨秷鎴愬姛");
}
- else if (task.TaskType == (int)TaskTypeEnum.Inbound || task.TaskType == (int)TaskTypeEnum.PalletInbound)
+ else if (task.TaskType == (int)TaskTypeEnum.Inbound || task.TaskType == (int)TaskTypeEnum.Inbound)
{
//澶勭悊鍑哄簱鐨勯�昏緫
Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
--
Gitblit v1.9.3