From d01658c63cd541fe4ea5cec5c4bd7f23b9408cdb Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 18 十月 2025 15:04:56 +0800
Subject: [PATCH] 前端,pda,后端接口更改,新增,优化
---
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs | 399 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 346 insertions(+), 53 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
index b855baa..2448941 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -23,6 +23,9 @@
using WIDESEA_Core.Utilities;
using System.Transactions;
using Microsoft.Data.SqlClient;
+using WIDESEA_Model.Models.Outbound;
+using WIDESEA_Common.OrderEnum;
+using WIDESEA_Core.CodeConfigEnum;
namespace WIDESEA_TaskInfoService
{
@@ -34,7 +37,7 @@
/// </summary>
/// <param name="stockInfos"></param>
/// <returns></returns>
- public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos)
+ public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
{
List<Dt_Task> tasks = new List<Dt_Task>();
for (int i = 0; i < stockInfos.Count; i++)
@@ -60,29 +63,112 @@
{
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(),
+ TaskType = taskType.ObjToInt(),
Depth = locationInfo.Depth,
+ WarehouseId = stockInfo.WarehouseId,
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
};
+ if (taskType != TaskTypeEnum.OutEmpty)
+ {
+ task.MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+ task.Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+ }
tasks.Add(task);
- //var responses = HttpHelper.Post<WebResponseContent>(ReceiveTask, tasks, "绔嬪簱鍑哄簱鏁伴噺鍥炰紶WMS");
}
}
}
- 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)OrderTypeEnum.鐢熶骇鍑哄簱鍗� => TaskTypeEnum.Outbound,
+ (int)OrderTypeEnum.璋冩嫧鍑哄簱鍗� => TaskTypeEnum.OutAllocate,
+ (int)OrderTypeEnum.鍙嶆嫞鍑哄簱鍗� => TaskTypeEnum.ReverseOut,
+ _ => new TaskTypeEnum()
+ };
+ tasks = GetTasks(result.Item1,typeEnum);
+ tasks.ForEach(x =>
+ {
+ x.OrderNo = outboundOrder.OrderNo;
+ });
+ 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>
/// 鍑哄簱浠诲姟鏁版嵁澶勭悊
@@ -114,12 +200,15 @@
(List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetail, stockSelectViews);
if (result.Item1 != null && result.Item1.Count > 0)
{
- tasks = GetTasks(result.Item1);
- int task = tasks[0].TaskNum;
- result.Item3.ForEach(x =>
+ Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
+ TaskTypeEnum typeEnum = outboundOrder.OrderType switch
{
- x.TaskNum = task;
- });
+ (int)OrderTypeEnum.鐢熶骇鍑哄簱鍗� => TaskTypeEnum.Outbound,
+ (int)OrderTypeEnum.璋冩嫧鍑哄簱鍗� => TaskTypeEnum.OutAllocate,
+ (int)OrderTypeEnum.鍙嶆嫞鍥炲簱鍗� => TaskTypeEnum.ReverseIn,
+ _ => new TaskTypeEnum()
+ };
+ tasks = GetTasks(result.Item1, typeEnum);
result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
result.Item3.ForEach(x =>
{
@@ -141,12 +230,14 @@
if (stockLockInfos != null && stockLockInfos.Count > 0)
{
List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
- tasks = GetTasks(stocks);
+ tasks = GetTasks(stocks, TaskTypeEnum.Outbound);
}
}
return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_OutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos);
}
+
+
/// <summary>
/// 绔嬪簱鍑哄簱鎸囦护涓婁紶锛屽嚭搴撲换鍔′笅鍙�
/// </summary>
@@ -164,12 +255,9 @@
return WebResponseContent.Instance.Error($"鏈壘鍒拌浠撳簱淇℃伅");
}
Dt_OutboundOrder oldOuboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO.No).Includes(x => x.Details).First();
+ Dt_Production production = new Dt_Production();
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($"浠撳簱涓嶄竴鑷�");
@@ -188,12 +276,72 @@
MaterieSpec = details.MaterieSpec,
OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
OrderQuantity = details.OrderQuantity,
+ LinId = details.LinId,
OrderId = oldOuboundOrder.Id,
Creater = "WMS",
- CreateDate= DateTime.Now,
+ CreateDate = DateTime.Now,
+ Remark = details.Remark,
+ SupplierBatch = details.SupplierBatch
};
_outboundOrderDetailRepository.AddData(outboundOrderDetail);
- //_outboundOrderDetailRepository.AddData(outboundOrderDetail);
+ foreach (var item in orderAddDTO1.Details)
+ {
+ if (string.IsNullOrWhiteSpace(item.Remark))
+ {
+ continue;
+ }
+ string[] remarkEntries = item.Remark.Split(
+ new[] { ';' },
+ StringSplitOptions.RemoveEmptyEntries
+ );
+
+ foreach (var entry in remarkEntries)
+ {
+ string[] keyValuePairs = entry.Split(
+ new[] { ',' },
+ StringSplitOptions.RemoveEmptyEntries
+ );
+
+ foreach (var kvp in keyValuePairs)
+ {
+ int colonIndex = kvp.IndexOf(':');
+ if (colonIndex <= 0 || colonIndex >= kvp.Length - 1)
+ {
+ continue;
+ }
+
+ string key = kvp.Substring(0, colonIndex).Trim();
+ string value = kvp.Substring(colonIndex + 1).Trim();
+
+ switch (key)
+ {
+ case "鍒堕�犲崟鍙�":
+ production.ProductionNo = value;
+ break;
+ case "鍒堕�犻儴浠�":
+ production.ManufacturingCo = value;
+ break;
+ case "鍑哄簱鏁伴噺":
+ if (decimal.TryParse(value, out decimal outQuantity))
+ {
+ production.OutQuantity = outQuantity;
+ }
+ else
+ {
+ Console.WriteLine($"鍑哄簱鏁伴噺鏍煎紡閿欒锛歿value}锛堝簲涓烘暟鍊硷紝濡�14.0000锛�");
+ }
+ break;
+ default:
+ Console.WriteLine($"鏈煡閿悕锛歿key}锛堝搴斿�硷細{value}锛岃烦杩囪閿�煎锛�");
+ break;
+ }
+
+ }
+ production.Creater = "WMS";
+ production.OrderId = outboundOrderDetail.Id;
+ _productionRepository.AddData(production);
+ }
+ }
}
}
else
@@ -202,40 +350,82 @@
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();
+ orderAddDTO1.TransactionCode = orderAddDTO.TransactionCode?? "宸ュ崟鍙戞枡";
+ orderAddDTO1.InoutType = orderAddDTO.OrderType ?? InoutTypeEnum.WorkFeed.ToString();
+ orderAddDTO1.OrderType = orderAddDTO.InoutType;
+ orderAddDTO1.System = orderAddDTO.System;
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;
- 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,
- };
+ inboundOrder.CreateType = CreateType.UpperSystemPush.ObjToInt();
_unitOfWorkManage.BeginTran();
+ bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+
+ foreach (var item in orderAddDTO1.Details)
+ {
+ if (string.IsNullOrWhiteSpace(item.Remark))
+ {
+ continue;
+ }
+ string[] remarkEntries = item.Remark.Split(
+ new[] { ';' },
+ StringSplitOptions.RemoveEmptyEntries
+ );
- stockSelectViews.Add(stockSelectViewDTO);
- GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews);
+ foreach (var entry in remarkEntries)
+ {
+ string[] keyValuePairs = entry.Split(
+ new[] { ',' },
+ StringSplitOptions.RemoveEmptyEntries
+ );
+
+ foreach (var kvp in keyValuePairs)
+ {
+ int colonIndex = kvp.IndexOf(':');
+ if (colonIndex <= 0 || colonIndex >= kvp.Length - 1)
+ {
+ continue;
+ }
+
+ string key = kvp.Substring(0, colonIndex).Trim();
+ string value = kvp.Substring(colonIndex + 1).Trim();
+
+ switch (key)
+ {
+ case "鍒堕�犲崟鍙�":
+ production.ProductionNo = value;
+ break;
+ case "鍒堕�犻儴浠�":
+ production.ManufacturingCo = value;
+ break;
+ case "鍑哄簱鏁伴噺":
+ if (decimal.TryParse(value, out decimal outQuantity))
+ {
+ production.OutQuantity = outQuantity;
+ }
+ else
+ {
+ Console.WriteLine($"鍑哄簱鏁伴噺鏍煎紡閿欒锛歿value}锛堝簲涓烘暟鍊硷紝濡�14.0000锛�");
+ }
+ break;
+ default:
+ Console.WriteLine($"鏈煡閿悕锛歿key}锛堝搴斿�硷細{value}锛岃烦杩囪閿�煎锛�");
+ break;
+ }
+
+ }
+ production.Creater = "WMS";
+ production.OrderId = inboundOrder.Details.FirstOrDefault().Id;
+ _productionRepository.AddData(production);
+ }
+ }
_unitOfWorkManage.CommitTran();
}
@@ -382,6 +572,8 @@
{
WebResponseContent content = new WebResponseContent();
_unitOfWorkManage.BeginTran();
+
+ BaseDal.AddData(tasks);
//鍒ゆ柇绉诲簱
//content = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
//if (content.Status)
@@ -394,19 +586,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)
{
@@ -418,6 +610,8 @@
_outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
}
_unitOfWorkManage.CommitTran();
+ //灏嗕换鍔℃帹閫佸埌WCS
+ PushTasksToWCS(tasks);
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
@@ -522,7 +716,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,
@@ -577,7 +771,7 @@
/// </summary>
/// <param name="keys"></param>
/// <returns></returns>
- public WebResponseContent GenerateOutboundTask(int[] keys)
+ public WebResponseContent WMSGenerateOutboundTask(int[] keys)
{
try
{
@@ -590,7 +784,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);
@@ -636,7 +830,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);
@@ -664,7 +858,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);
@@ -695,5 +889,104 @@
return content = WebResponseContent.Instance.Error($"鏈壘鍒颁换鍔″彿");
}
}
+
+ /// <summary>
+ /// 閫夊畾搴撳瓨鐢熸垚鐩樼偣鍗曞嚭搴�
+ /// </summary>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public WebResponseContent TakeOutbound(List<StockViewDTO> stockViews)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (stockViews.Select(x => x.WarehouseId).Distinct().Count() >= 2)
+ {
+ return content.Error($"璇烽�夋嫨鍚屼竴浠撳簱搴撳瓨杩涜鐩樼偣");
+ }
+ List<int> ids = stockViews.Select(x => x.StockId).ToList();
+ //鑾峰彇搴撳瓨
+ List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.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).ToList().Contains(x.PalletCode));
+ return content.Error($"鏈壘鍒皗stockViewDTO?.PalletCode}搴撳瓨");
+ }
+ //鑾峰彇璐т綅
+ List<string> locStrs = stockInfos.Select(x => x.LocationCode).ToList();
+ List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => locStrs.Contains(x.LocationCode));
+ if (stockInfos.Count != locationInfos.Count)
+ {
+ string? locStr = locStrs.FirstOrDefault(x => !locationInfos.Select(x => x.LocationCode).ToList().Contains(x));
+ return content.Error($"鏈壘鍒皗locStr}璐т綅鏁版嵁");
+ }
+ Dt_TakeStockOrder takeStockOrder = new Dt_TakeStockOrder()
+ {
+ WarehouseId = stockInfos.FirstOrDefault().WarehouseId,
+ TakeStockStatus = TakeStockStatusEnum.鐩樼偣涓�.ObjToInt(),
+ OrderNo = _outboundService.OutboundOrderService.CreateCodeByRule(nameof(RuleCode.PDCodeRule)),
+ Details = new List<Dt_TakeStockOrderDetail>()
+ };
+ foreach (var item in stockInfos)
+ {
+ if (item.Details.Count <= 0)
+ {
+ return content.Error($"鏈壘鍒皗item.PalletCode}搴撳瓨鏄庣粏鏁版嵁");
+ }
+ Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode);
+ if (locationInfo != null && (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && item.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
+ {
+ //鍒涘缓鏄庣粏
+ Dt_TakeStockOrderDetail takeStockOrderDetail = new Dt_TakeStockOrderDetail()
+ {
+ MaterielCode = item.Details.FirstOrDefault().MaterielCode,
+ MaterielName = item.Details.FirstOrDefault().MaterielName ?? "鏃犵墿鏂欏悕绉�",
+ BatchNo = item.Details.FirstOrDefault().BatchNo,
+ MaterielSpec = item.Details.FirstOrDefault().MaterieSpec ?? "鏃犵墿鏂欒鏍�",
+ LocationCode = item.LocationCode,
+ TakePalletCode = item.PalletCode,
+ TakeDetalStatus = TakeStockDetailStatusEnum.鐩樼偣鍑哄簱涓�.ObjToInt(),
+ SysQty = item.Details.Sum(x => x.StockQuantity),
+ Qty = 0
+ };
+ takeStockOrder.Details.Add(takeStockOrderDetail);
+ }
+ else
+ {
+ content.Error($"璐т綅鎴栧簱瀛樼姸鎬佷笉婊¤冻鍑哄簱鏉′欢");
+ }
+ }
+ List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutInventory);
+ if (tasks == null || tasks.Count <= 0)
+ {
+ return content.Error($"鐢熸垚浠诲姟澶辫触");
+ }
+ stockInfos.ForEach(x =>
+ {
+ x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+ });
+ tasks.ForEach(x =>
+ {
+ x.OrderNo = takeStockOrder.OrderNo;
+ });
+ LocationStatusEnum locationStatus = LocationStatusEnum.Lock;
+ _unitOfWorkManage.BeginTran();
+ //鏇存柊搴撳瓨鐘舵��
+ _stockRepository.StockInfoRepository.UpdateData(stockInfos);
+ BaseDal.Db.InsertNav(takeStockOrder).Include(x => x.Details).ExecuteCommand();
+ //鏂板缓浠诲姟
+ BaseDal.AddData(tasks);
+ _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus);
+ _unitOfWorkManage.CommitTran();
+ PushTasksToWCS(tasks);
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
}
}
--
Gitblit v1.9.3