From 695571c6009ecbc12e7d4a4fb147df7967a1260e Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 07 七月 2025 20:21:19 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 115 insertions(+), 3 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 1574e33..98f3311 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -20,6 +20,7 @@
using WIDESEA_Core.CodeConfigEnum;
using Microsoft.AspNetCore.Mvc;
using WIDESEA_DTO.ERP;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
namespace WIDESEA_TaskInfoService
{
@@ -73,6 +74,107 @@
}
catch (Exception ex)
{
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <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(RuleCodeEnum.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().MaterielSpec ?? "鏃犵墿鏂欒鏍�",
+ LocationCode=item.LocationCode,
+ TakePalletCode=item.PalletCode,
+ TakeDetalStatus=TakeStockDetailStatusEnum.鐩樼偣鍑哄簱涓�.ObjToInt(),
+ Unit=item.Details.FirstOrDefault().Unit ?? "鏃犲崟浣�",
+ 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);
+ _inboundRepository.TakeStockOrderRepository.Db.InsertNav(takeStockOrder).Include(x=>x.Details).ExecuteCommand();
+ //鏂板缓浠诲姟
+ BaseDal.AddData(tasks);
+ //鍔犲叆璐т綅鍙樺姩璁板綍
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList());
+ _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus);
+ _unitOfWorkManage.CommitTran();
+ PushTasksToWCS(tasks);
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
content.Error(ex.Message);
}
return content;
@@ -504,13 +606,14 @@
public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
{
List<Dt_Task> tasks = new List<Dt_Task>();
+ List<Dt_LocationInfo> locationInfos = _basicService.LocationInfoService.Repository.QueryData(x => stockInfos.Select(x=>x.LocationCode).Contains(x.LocationCode));
for (int i = 0; i < stockInfos.Count; i++)
{
Dt_StockInfo stockInfo = stockInfos[i];
if (stockInfo != null)
{
- Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+ Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode);
if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
{
Dt_Task task = new()
@@ -531,8 +634,8 @@
};
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).FirstOrDefault()?.StockQuantity;
+ 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);
}
if (stockInfo.StockLength>0)
{
@@ -884,6 +987,15 @@
{
x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
});
+ outboundOrderDetails.ForEach(x =>
+ {
+ x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
+ });
+ Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+ if (outboundOrder.OrderStatus != OutOrderStatusEnum.鍑哄簱涓�.ObjToInt())
+ {
+ _outboundRepository.OutboundOrderRepository.UpdateData(outboundOrder);
+ }
WebResponseContent content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks);
if (!content.Status)
--
Gitblit v1.9.3