From 9753fb2756f6b4e30ff79d901a7bb86145517c8b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 18 十二月 2025 11:29:13 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 471 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 469 insertions(+), 2 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_OutboundService/OutboundService.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_OutboundService/OutboundService.cs"
index 6c5a0ce..ecc4177 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_OutboundService/OutboundService.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_OutboundService/OutboundService.cs"
@@ -1,7 +1,15 @@
锘縰sing AutoMapper;
+using Dm.filter;
+using MailKit.Search;
+using Mapster;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
+using Org.BouncyCastle.Asn1.Ocsp;
+using Org.BouncyCastle.Crypto;
using SqlSugar;
+using System.Reflection.Emit;
+using WIDESEA_BasicService;
+using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
@@ -10,6 +18,7 @@
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Basic;
using WIDESEA_DTO.CalcOut;
using WIDESEA_DTO.ReturnMES;
using WIDESEA_IBasicService;
@@ -45,8 +54,22 @@
private readonly IRepository<Dt_StockInfoDetail_Hty> _stockDetailHistoryRepository;
private readonly IFeedbackMesService _feedbackMesService;
private readonly IRepository<Dt_Task> _taskRepository;
+ private readonly ILocationInfoService _locationInfoService;
+ private readonly IESSApiService _eSSApiService;
- public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository)
+ private Dictionary<string, string> stations = new Dictionary<string, string>
+ {
+ {"2-1","2-9" },
+ {"3-1","3-9" },
+ };
+
+ private Dictionary<string, string> movestations = new Dictionary<string, string>
+ {
+ {"2-1","2-5" },
+ {"3-1","3-5" },
+ };
+
+ public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -65,6 +88,8 @@
_basicService = basicService;
_feedbackMesService = feedbackMesService;
_taskRepository = taskRepository;
+ _locationInfoService = locationInfoService;
+ _eSSApiService = eSSApiService;
}
#region 鍑哄簱鍒嗛厤
@@ -224,7 +249,7 @@
if (outboundOrder.IsBatch == 1)
{
- selectedDetails = _detailRepository.QueryData(x => x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode);
+ selectedDetails = _detailRepository.QueryData(x => x.OrderId == selectedDetails.First().OrderId && x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode);
}
@@ -813,6 +838,332 @@
}
#endregion
+
+
+ public WebResponseContent CompleteOutboundWithPallet(OutboundCompletePalletRequestDTO request)
+ {
+ WebResponseContent content = WebResponseContent.Instance;
+
+ OutboundCompleteResponseDTO response = new();
+ try
+ {
+ // 1. 鏍规嵁鎵樼洏鍙锋煡鎵惧簱瀛樹俊鎭�
+ Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == request.PalletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
+ {
+ response.Success = false;
+ response.Message = $"鎵樼洏鍙� {request.PalletCode} 瀵瑰簲鐨勫簱瀛樹笉瀛樺湪";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ if (!stockInfo.Details.Any())
+ {
+ response.Success = false;
+ response.Message = $"鎵樼洏 {request.PalletCode} 瀵瑰簲鐨勫簱瀛樻槑缁嗕笉瀛樺湪";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ bool isMatMixed = stockInfo.Details.GroupBy(x => new
+ {
+ x.MaterielCode,
+ x.MaterielName,
+ x.BatchNo,
+ x.SupplyCode,
+ x.WarehouseCode
+ }).Count() > 1;
+
+ if (isMatMixed)
+ {
+ response.Success = false;
+ response.Message = $"娣锋枡鎵樼洏 {request.PalletCode} 涓嶈兘鏁寸鍑哄簱";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ // 2. 鏌ユ壘鍑哄簱鍗曚俊鎭�
+ Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(o => o.OrderNo == request.OrderNo);
+ if (outboundOrder == null)
+ {
+ response.Success = false;
+ response.Message = $"鍑哄簱鍗� {request.OrderNo} 涓嶅瓨鍦�";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.First();
+
+ // 3. 鏌ユ壘閿佸畾璁板綍
+ Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
+ x.OrderNo == request.OrderNo &&
+ x.StockId == stockInfo.Id &&
+ x.MaterielCode == stockInfoDetail.MaterielCode &&
+ x.PalletCode == stockInfo.PalletCode);
+
+ if (lockInfo == null || lockInfo.AssignQuantity <= 0)
+ {
+ response.Success = false;
+ response.Message = $"璇ュ簱瀛樻病鏈夊垎閰嶅嚭搴撻噺锛屾墭鐩樺彿锛歿request.PalletCode}";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ // 鎵惧嚭宸插垎閰嶇殑璁㈠崟鏄庣粏Id
+ List<int> detailIds = new List<int>();
+ string[] ids = lockInfo.OrderDetailIds.Split(",");
+ foreach (string id in ids)
+ {
+ if (int.TryParse(id, out int detailId))
+ {
+ detailIds.Add(detailId);
+ }
+ }
+ // 4. 鏌ユ壘鍑哄簱鍗曟槑缁嗕俊鎭�
+ List<Dt_OutboundOrderDetail> outboundOrderDetails = FindMatchingOutboundDetails(outboundOrder.Id, stockInfoDetail, detailIds);
+ if (!outboundOrderDetails.Any())
+ {
+ response.Success = false;
+ response.Message = $"鏈壘鍒板尮閰嶇殑鍑哄簱鍗曟槑缁嗭紝鐗╂枡锛歿stockInfoDetail.MaterielCode}锛屾壒娆★細{stockInfoDetail.BatchNo}";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ decimal totalStockQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
+
+ // 5. 璁$畻瀹為檯鍑哄簱閲�
+ decimal actualOutboundQuantity = CalculateActualOutboundQuantity(stockInfo.Details, outboundOrderDetails, lockInfo);// 闇�鍑哄簱閲�
+
+ if (actualOutboundQuantity <= 0)
+ {
+ decimal totalAllocatedQuantity = lockInfo.AllocatedQuantity;
+ decimal availableOutboundQuantity = lockInfo.AssignQuantity - totalAllocatedQuantity;
+ decimal detailRemainingQuantity = outboundOrderDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity - x.MoveQty);
+
+ response.Success = false;
+ response.Message = $"鏃犳硶鍑哄簱锛屾墭鐩樺彿锛歿request.PalletCode}锛屽簱瀛橀噺锛歿totalStockQuantity}锛屽凡鍑哄簱锛歿totalAllocatedQuantity}锛屽垎閰嶉噺锛歿lockInfo.AssignQuantity}锛屾槑缁嗗墿浣欙細{detailRemainingQuantity}";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ if (lockInfo.AssignQuantity != totalStockQuantity)
+ {
+ response.Success = false;
+ response.Message = $"鏃犳硶鍑哄簱锛屾墭鐩樺彿锛歿request.PalletCode}锛屽簱瀛橀噺锛歿totalStockQuantity}锛屽垎閰嶉噺锛歿lockInfo.AssignQuantity}";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ // 6. 寮�鍚簨鍔�
+ _unitOfWorkManage.BeginTran();
+ try
+ {
+ // 鏁寸鍑哄簱鏃犻渶鎷嗗寘
+ PerformFullOutboundOperation(stockInfo, request, lockInfo.TaskNum.GetValueOrDefault());
+
+
+ decimal allocatedQuantity = actualOutboundQuantity;
+ List<Dt_OutboundOrderDetail> updateDetails = new();
+ foreach (var item in outboundOrderDetails)
+ {
+ if (allocatedQuantity <= 0) break;
+
+
+ //if (item.OrderQuantity - item.MoveQty - item.OverOutQuantity >= allocatedQuantity)
+ //{
+ // item.OverOutQuantity += allocatedQuantity;
+ // allocatedQuantity = 0;
+ //}
+ //else
+ //{
+ // allocatedQuantity -= (item.OrderQuantity - item.MoveQty - item.OverOutQuantity);
+ // item.OverOutQuantity = item.OrderQuantity - item.MoveQty;
+ //}
+ List<Barcodes> barcodesList = new List<Barcodes>();
+ List<Dt_StockInfoDetail> stockInfoDetails = stockInfo.Details.Where((x => x.StockQuantity > x.OutboundQuantity)).ToList();
+ foreach (var stockDetail in stockInfoDetails)
+ {
+ if (item.LockQuantity - item.OverOutQuantity >= stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity)
+ {
+ Barcodes barcodes = new Barcodes
+ {
+ Barcode = stockDetail.Barcode,
+ Qty = stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity,
+ SupplyCode = stockDetail?.SupplyCode ?? "",
+ BatchNo = stockDetail?.BatchNo ?? "",
+ Unit = stockDetail?.Unit ?? ""
+ };
+
+ stockDetail.StockQuantity = stockInfoDetail.OutboundQuantity;
+ barcodesList.Add(barcodes);
+ }
+ else
+ {
+ Barcodes barcodes = new Barcodes
+ {
+ Barcode = stockDetail.Barcode,
+ Qty = item.LockQuantity - item.OverOutQuantity,
+ SupplyCode = stockDetail?.SupplyCode ?? "",
+ BatchNo = stockDetail?.BatchNo ?? "",
+ Unit = stockDetail?.Unit ?? ""
+ };
+ stockInfoDetail.OutboundQuantity += item.LockQuantity - item.OverOutQuantity;
+ barcodesList.Add(barcodes);
+ }
+ }
+
+ decimal barcodeQuantity = allocatedQuantity;
+
+ if (item.LockQuantity - item.OverOutQuantity >= allocatedQuantity)
+ {
+ item.OverOutQuantity += allocatedQuantity;
+ item.CurrentDeliveryQty += allocatedQuantity;
+ allocatedQuantity = 0;
+ }
+ else
+ {
+ barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
+ allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
+ item.OverOutQuantity = item.LockQuantity;
+ item.CurrentDeliveryQty = item.LockQuantity;
+ }
+
+ updateDetails.Add(item);
+
+
+ if (!string.IsNullOrEmpty(item.ReturnJsonData))
+ {
+ barcodesList.AddRange(JsonConvert.DeserializeObject<List<Barcodes>>(item.ReturnJsonData) ?? new List<Barcodes>());
+ }
+
+ JsonSerializerSettings settings = new JsonSerializerSettings
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver()
+ };
+ item.ReturnJsonData = JsonConvert.SerializeObject(barcodesList, settings);
+ }
+
+ lockInfo.SortedQuantity = lockInfo.SortedQuantity + actualOutboundQuantity;
+
+ if (lockInfo.SortedQuantity == lockInfo.AssignQuantity)
+ {
+ _outboundLockInfoRepository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ }
+ else
+ {
+ // 鏇存柊閿佸畾璁板綍
+ _outboundLockInfoRepository.UpdateData(lockInfo);
+ }
+
+ // 鏇存柊鍑哄簱鍗曟槑缁嗙殑宸插嚭搴撴暟閲�
+ _detailRepository.UpdateData(updateDetails);
+
+ // 鏇存柊閿佸畾璁板綍鐨勭疮璁″凡鍑哄簱鏁伴噺锛堥渶瑕佹洿鏂拌鎵樼洏璇ョ墿鏂欑殑鎵�鏈夌浉鍏宠褰曪級
+ //UpdateLockInfoAllocatedQuantity(stockInfo.Id, stockDetail.MaterielCode, stockDetail.BatchNo, actualOutboundQuantity);
+
+ // 鎻愪氦浜嬪姟
+ _unitOfWorkManage.CommitTran();
+
+ response.Success = true;
+ response.Message = "鍑哄簱瀹屾垚";
+ response.UpdatedDetails = updateDetails;
+
+ // 妫�鏌ュ嚭搴撳崟鏄惁瀹屾垚
+ if (CheckOutboundOrderCompleted(request.OrderNo))
+ {
+ UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
+
+
+ //todo: 鍥炰紶MES
+ }
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ response.Success = false;
+ response.Message = $"鍑哄簱澶勭悊澶辫触锛歿ex.Message}";
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+
+ content = WebResponseContent.Instance.OK(data: response);
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error("澶勭悊鍑哄簱瀹屾垚澶辫触锛�" + ex.Message);
+ }
+ return content;
+ }
+
+ /// <summary>
+ /// 璁$畻瀹為檯鍑哄簱鏁伴噺
+ /// </summary>
+ private decimal CalculateActualOutboundQuantity(List<Dt_StockInfoDetail> stockDetails, List<Dt_OutboundOrderDetail> outboundDetails, Dt_OutStockLockInfo lockInfo)
+ {
+ decimal availableOutboundQuantity = lockInfo.AssignQuantity;
+ decimal detailRemainingQuantity = outboundDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity - x.MoveQty);//outboundDetail.OrderQuantity - outboundDetail.OverOutQuantity;
+
+ return Math.Min(
+ Math.Min(availableOutboundQuantity, detailRemainingQuantity),
+ stockDetails.Sum(x => x.StockQuantity));
+ }
+
+ /// <summary>
+ /// 鎵ц瀹屾暣鍑哄簱鎿嶄綔锛堜笉鎷嗗寘锛�
+ /// </summary>
+ private void PerformFullOutboundOperation(Dt_StockInfo stockInfo, OutboundCompletePalletRequestDTO request, int taskNum)
+ {
+ List<Dt_StockInfoDetail_Hty> historyRecords = new List<Dt_StockInfoDetail_Hty>();
+ List<Dt_StockQuantityChangeRecord> changeRecords = new List<Dt_StockQuantityChangeRecord>();
+ foreach (var item in stockInfo.Details)
+ {
+ // 淇濆瓨搴撳瓨鏄庣粏鍒板巻鍙茶褰�
+ Dt_StockInfoDetail_Hty historyRecord = new Dt_StockInfoDetail_Hty
+ {
+ SourceId = item.Id,
+ OperateType = "鍑哄簱瀹屾垚",
+ InsertTime = DateTime.Now,
+ StockId = item.StockId,
+ MaterielCode = item.MaterielCode,
+ MaterielName = item.MaterielName,
+ OrderNo = item.OrderNo,
+ BatchNo = item.BatchNo,
+ ProductionDate = item.ProductionDate,
+ EffectiveDate = item.EffectiveDate,
+ SerialNumber = item.SerialNumber,
+ StockQuantity = item.StockQuantity,
+ OutboundQuantity = item.StockQuantity,
+ Status = item.Status,
+ Unit = item.Unit,
+ InboundOrderRowNo = item.InboundOrderRowNo,
+ SupplyCode = item.SupplyCode,
+ FactoryArea = item.FactoryArea,
+ WarehouseCode = item.WarehouseCode,
+ Barcode = item.Barcode,
+ Remark = $"鏁寸鍑哄簱瀹屾垚鍒犻櫎锛屾潯鐮侊細{request.PalletCode}锛屽師鏁伴噺锛歿item.StockQuantity}锛屽嚭搴撴暟閲忥細{item.StockQuantity}锛屾搷浣滆�咃細{request.Operator}"
+ };
+ historyRecords.Add(historyRecord);
+
+ // 璁板綍搴撳瓨鍙樺姩
+ Dt_StockQuantityChangeRecord changeRecord = new Dt_StockQuantityChangeRecord
+ {
+ StockDetailId = item.Id,
+ PalleCode = stockInfo.PalletCode,
+ MaterielCode = item.MaterielCode,
+ MaterielName = item.MaterielName,
+ BatchNo = item.BatchNo,
+ OriginalSerilNumber = item.Barcode,
+ NewSerilNumber = "",
+ OrderNo = request.OrderNo,
+ TaskNum = taskNum,
+ ChangeType = (int)StockChangeTypeEnum.Outbound,
+ ChangeQuantity = -item.StockQuantity,
+ BeforeQuantity = item.StockQuantity,
+ AfterQuantity = 0,
+ SupplyCode = item.SupplyCode,
+ WarehouseCode = item.WarehouseCode,
+ Remark = $"鏁寸鍑哄簱瀹屾垚鍒犻櫎搴撳瓨鏄庣粏锛屾潯鐮侊細{request.PalletCode}锛屽嚭搴撴暟閲忥細{item.StockQuantity}锛屾搷浣滆�咃細{request.Operator}"
+ };
+ changeRecords.Add(changeRecord);
+ }
+ _stockDetailHistoryRepository.AddData(historyRecords);
+
+ // 鍒犻櫎搴撳瓨鏄庣粏璁板綍
+ _stockDetailRepository.DeleteData(stockInfo.Details);
+ _stockChangeRepository.AddData(changeRecords);
+ }
+
#region 鎷i��
/// <summary>
/// 鍑哄簱瀹屾垚澶勭悊锛堟壂鎻忔潯鐮佹墸鍑忓簱瀛橈級
@@ -1354,5 +1705,121 @@
}
#endregion
+
+ #region 鍙栫┖绠�
+ public async Task<WebResponseContent> EmptyBox(string palletCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x=>x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
+
+ if (stock == null)
+ {
+ return content.Error($"鏈壘鍒版墭鐩榹palletCode}搴撳瓨淇℃伅");
+ }
+ if (stock.Details.Count > 0)
+ {
+ return content.Error($"鎵樼洏{palletCode}杩樺瓨鍦ㄥ簱瀛樹俊鎭笉鍏佽鍙栬蛋");
+ }
+ Dt_StockInfo_Hty stockInfo_Hty = stock.Adapt<Dt_StockInfo_Hty>();
+ stockInfo_Hty.SourceId = stock.Id;
+ stockInfo_Hty.OperateType = "鍙栫┖绠�";
+ stockInfo_Hty.InsertTime = DateTime.Now;
+
+ _unitOfWorkManage.BeginTran();
+ await _outboundRepository.Db.InsertNav(stockInfo_Hty).IncludesAllFirstLayer().ExecuteCommandAsync();
+ await _stockInfoRepository.DeleteDataByIdAsync(stock.Id);
+ _unitOfWorkManage.CommitTran();
+ return content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return content.Error(ex.Message);
+ }
+ }
+
+ #endregion
+
+ #region
+ public async Task<WebResponseContent> ReturnToWarehouse(string palletCode, string OrderNo, string station)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
+
+ if (stock == null)
+ {
+ return content.Error($"鏈壘鍒版墭鐩榹palletCode}搴撳瓨淇℃伅涓嶅厑璁稿洖搴�");
+ }
+
+ if (stock.Details.Count <= 0)
+ {
+ stock.PalletType = (int)PalletTypeEnum.Empty;
+ stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+ stock.LocationCode = "";
+ }
+ else if (stock.Details.Count > 0)
+ {
+ Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
+ x.OrderNo == OrderNo &&
+ x.StockId == stock.Id &&
+ x.PalletCode == palletCode);
+
+ if (lockInfo != null && lockInfo.SortedQuantity != lockInfo.AssignQuantity)
+ {
+ return content.Error($"鎵樼洏{palletCode}搴撳瓨鏈嫞閫夊畬涓嶅厑璁稿洖搴�");
+ }
+ stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+ stock.LocationCode = "";
+ }
+
+ var task = await _taskRepository.Db.Queryable<Dt_Task>()
+ .Where(x => x.PalletCode == palletCode)
+ .FirstAsync();
+
+ if (task != null)
+ {
+ return content.Error($"鎵樼洏{palletCode}瀛樺湪浠诲姟鍥炲簱澶辫触!");
+ }
+
+ // 鍒嗛厤鏂拌揣浣�
+ var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
+
+ var newTask = new Dt_Task()
+ {
+ CurrentAddress = stations[station],
+ Grade = 0,
+ PalletCode = palletCode,
+ NextAddress = "",
+ OrderNo = OrderNo,
+ Roadway = newLocation.RoadwayNo,
+ SourceAddress = stations[station],
+ TargetAddress = newLocation.LocationCode,
+ TaskStatus = (int)TaskStatusEnum.New,
+ TaskType = stock.Details.Count > 0 ? (int)TaskTypeEnum.InPick : (int)TaskTypeEnum.InEmpty,
+ PalletType = stock.PalletType,
+ WarehouseId = stock.WarehouseId
+ };
+ _stockInfoRepository.UpdateData(stock);
+ _taskRepository.AddData(newTask);
+
+ //var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
+ //{
+ // slotCode = movestations[station],
+ // containerCode = palletCode
+ //});
+ return content.OK();
+
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+
+ #endregion
}
}
--
Gitblit v1.9.3