From 07774c70a65bed6bacf936bdd66f756ba9c7f266 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期二, 02 十二月 2025 10:15:48 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 451 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 406 insertions(+), 45 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/OutboundPickingService.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/OutboundPickingService.cs"
index 0fb6e2d..e31d56d 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/OutboundPickingService.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/OutboundPickingService.cs"
@@ -20,16 +20,20 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
+using WIDESEA_Core.Utilities;
using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Outbound;
using WIDESEA_IAllocateService;
using WIDESEA_IBasicService;
+using WIDESEA_ICheckService;
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Basic;
+using WIDESEA_Model.Models.Check;
namespace WIDESEA_OutboundService
{
@@ -56,8 +60,8 @@
private readonly IAllocateService _allocateService;
private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
private readonly IInboundOrderDetailService _inboundOrderDetailService;
-
-
+ private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
+ private readonly IReCheckOrderService _reCheckOrderService;
private readonly ILogger<OutboundPickingService> _logger;
private Dictionary<string, string> stations = new Dictionary<string, string>
@@ -77,7 +81,7 @@
public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService,
IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService,
IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService,
- IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository,IInboundOrderDetailService inboundOrderDetailService) : base(BaseDal)
+ IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService, IDailySequenceService dailySequenceService, IAllocateService allocateService, IRepository<Dt_InboundOrder> inboundOrderRepository, IInboundOrderDetailService inboundOrderDetailService, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IReCheckOrderService reCheckOrderService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -96,6 +100,8 @@
_allocateService = allocateService;
_inboundOrderRepository = inboundOrderRepository;
_inboundOrderDetailService = inboundOrderDetailService;
+ _warehouseAreaRepository = warehouseAreaRepository;
+ _reCheckOrderService = reCheckOrderService;
}
@@ -747,13 +753,13 @@
PickTime = DateTime.Now,
Operator = App.User.UserName,
OutStockLockId = result.FinalLockInfo.Id,
- BarcodeUnit=result.FinalLockInfo.BarcodeUnit,
- BarcodeQty=result.FinalLockInfo.BarcodeQty,
- BatchNo= result.FinalLockInfo.BatchNo,
- lineNo= result.FinalLockInfo.lineNo ,
- SupplyCode= result.FinalLockInfo.SupplyCode ,
- WarehouseCode = result.FinalLockInfo.WarehouseCode ,
-
+ BarcodeUnit = result.FinalLockInfo.BarcodeUnit,
+ BarcodeQty = result.FinalLockInfo.BarcodeQty,
+ BatchNo = result.FinalLockInfo.BatchNo,
+ lineNo = result.FinalLockInfo.lineNo,
+ SupplyCode = result.FinalLockInfo.SupplyCode,
+ WarehouseCode = result.FinalLockInfo.WarehouseCode,
+
};
@@ -1383,7 +1389,7 @@
.SetColumns(it => new Dt_OutStockLockInfo
{
Status = (int)OutLockStockStatusEnum.宸查噴鏀�, // 闇�瑕佹柊澧炶繖涓姸鎬�
- // ReleaseTime = DateTime.Now,
+ // ReleaseTime = DateTime.Now,
Operator = App.User.UserName
})
.Where(it => lockIds.Contains(it.Id))
@@ -1670,7 +1676,7 @@
// 鍒犻櫎鍘熷鍑哄簱浠诲姟
_taskRepository.DeleteAndMoveIntoHty(originalTask, OperateTypeEnum.鑷姩瀹屾垚);
- // await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
+ await _taskRepository.Db.Deleteable(originalTask).ExecuteCommandAsync();
@@ -1777,7 +1783,7 @@
{
newStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚;
}
- else if (hasPartial )
+ else if (hasPartial)
{
newStatus = (int)OutOrderStatusEnum.鍑哄簱涓�;
}
@@ -1852,7 +1858,7 @@
.SetColumns(it => new Dt_OutboundOrderDetail
{
OrderDetailStatus = newStatus,
-
+
})
.Where(it => it.Id == orderDetailId)
.ExecuteCommandAsync();
@@ -1934,13 +1940,13 @@
ReqCode = Guid.NewGuid().ToString(),
ReqTime = DateTime.Now.ToString(),
BusinessType = "3",
-
+
FactoryArea = outboundOrder.FactoryArea,
OperationType = 1,
Operator = App.User.UserName,
OrderNo = outboundOrder.UpperOrderNo,
- // documentsNO = outboundOrder.OrderNo,
- // status = outboundOrder.OrderStatus,
+ // documentsNO = outboundOrder.OrderNo,
+ // status = outboundOrder.OrderStatus,
fromWarehouse = allocate?.FromWarehouse ?? "",
toWarehouse = allocate?.ToWarehouse ?? "",
Details = new List<AllocateDtoDetail>()
@@ -1958,7 +1964,7 @@
LineNo = group.Key.lineNo,
WarehouseCode = group.Key.WarehouseCode,
Qty = group.Sum(x => x.PickedQty),
-
+
Unit = group.Key.Unit,
Barcodes = group.Select(row => new BarcodeInfo
{
@@ -1969,13 +1975,13 @@
Qty = row.PickedQty
}).ToList()
-
+
}).ToList();
allocatefeedmodel.Details = groupedData;
var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel);
if (result != null && result.code == 200)
- {
+ {
await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
.SetColumns(x => x.ReturnToMESStatus == 1)
.Where(x => x.OrderId == outboundOrder.Id).ExecuteCommandAsync();
@@ -2015,22 +2021,22 @@
.Where(x => x.OrderNo == orderNo && x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
.ToListAsync();
- var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode })
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
.Select(group => new FeedbackOutboundDetailsModel
{
materialCode = group.Key.MaterielCode,
lineNo = group.Key.lineNo,
warehouseCode = group.Key.WarehouseCode,
- qty = group.Sum(x => x.PickedQty),
- currentDeliveryQty = group.Sum(x => x.PickedQty),
- unit = group.Key.Unit,
+ qty = group.Sum(x => x.BarcodeQty),
+ currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+ unit = group.Key.BarcodeUnit,
barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
{
barcode = row.CurrentBarcode,
supplyCode = row.SupplyCode,
batchNo = row.BatchNo,
- unit = row.Unit,
- qty = row.PickedQty
+ unit = row.BarcodeUnit,
+ qty = row.BarcodeQty
}).ToList()
}).ToList();
@@ -2436,8 +2442,8 @@
FactoryArea = originalLock.FactoryArea,
lineNo = originalLock.lineNo,
WarehouseCode = originalLock.WarehouseCode,
- BarcodeQty=originalLock.BarcodeQty,
- BarcodeUnit=originalLock.BarcodeUnit,
+ BarcodeQty = originalLock.BarcodeQty,
+ BarcodeUnit = originalLock.BarcodeUnit,
};
@@ -2550,7 +2556,7 @@
{
List<Dt_InboundOrder> InOders = _inboundOrderRepository.QueryData().Where(x => x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).ToList();
List<string> InOderCodes = InOders.Select(x => x.UpperOrderNo).ToList();
- return WebResponseContent.Instance.OK("鎴愬姛",data: InOderCodes);
+ return WebResponseContent.Instance.OK("鎴愬姛", data: InOderCodes);
}
public WebResponseContent GetAvailablePickingOrders()
@@ -2566,7 +2572,7 @@
try
{
Dt_InboundOrder inboundOrder = Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOut.inOder && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
- if(inboundOrder == null)
+ if (inboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒伴噰璐崟锛歿noStockOut.inOder}");
}
@@ -2593,7 +2599,7 @@
//鍓╀綑鍏ュ簱鏁伴噺鍗宠櫄鎷熷嚭鍏ュ簱鍓╀綑鍙嚭鏁伴噺
decimal outQuantity = matchedDetail.OrderQuantity - matchedDetail.ReceiptQuantity;
- if(outQuantity == 0)
+ if (outQuantity == 0)
{
return WebResponseContent.Instance.Error($"璇ラ噰璐崟涓殑鏉$爜瀵瑰簲鐨勫彲鍑烘暟閲忎负0");
}
@@ -2607,7 +2613,7 @@
if ((matchedCode.LockQuantity + matchedCode.NoStockOutQty) > matchedCode.OrderQuantity)
{
- return WebResponseContent.Instance.Error($"鍑哄簱鍗曟槑缁嗘暟閲忔孩鍑簕matchedCode.LockQuantity - matchedCode.OrderQuantity}");
+ return WebResponseContent.Instance.Error($"鍑哄簱鍗曟槑缁嗘暟閲忔孩鍑簕matchedCode.LockQuantity - matchedCode.OrderQuantity}");
}
matchedDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
matchedCode.OrderDetailStatus = OrderDetailStatusEnum.AssignOver.ObjToInt();
@@ -2618,7 +2624,7 @@
_unitOfWorkManage.CommitTran();
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
@@ -2643,7 +2649,7 @@
}
matchedDetail.NoStockOutQty = 0;
- if(matchedDetail.ReceiptQuantity==0 && matchedDetail.OverInQuantity==0)
+ if (matchedDetail.ReceiptQuantity == 0 && matchedDetail.OverInQuantity == 0)
{
matchedDetail.OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt();
}
@@ -2671,23 +2677,23 @@
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
}
}
- public WebResponseContent NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit)
+ public async Task<WebResponseContent> NoStockOutSubmit(NoStockOutSubmit noStockOutSubmit)
{
try
{
- Dt_InboundOrder inboundOrder = Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.InOderSubmit && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
+ Dt_InboundOrder inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.InOderSubmit && x.OrderStatus != InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
if (inboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒伴噰璐崟锛歿noStockOutSubmit.InOderSubmit}");
}
- Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.OutOderSubmit && x.OrderStatus != OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
+ Dt_OutboundOrder outboundOrder = _inboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == noStockOutSubmit.OutOderSubmit && x.OrderStatus != OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt()).Includes(x => x.Details).First();
if (outboundOrder == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撳崟锛歿noStockOutSubmit.OutOderSubmit}");
@@ -2696,9 +2702,9 @@
List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
foreach (var BarCode in noStockOutSubmit.BarCodeSubmit)
{
- var inboundOrderDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == BarCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt());
+ var inboundOrderDetail = inboundOrder.Details.FirstOrDefault(detail => detail.Barcode == BarCode && detail.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt());
- if(inboundOrderDetail == null)
+ if (inboundOrderDetail == null)
{
return WebResponseContent.Instance.Error($"鍦ㄩ噰璐崟 {noStockOutSubmit.InOderSubmit} 涓湭鎵惧埌鏉$爜涓� {BarCode} 鐨勬槑缁嗐��");
}
@@ -2715,7 +2721,7 @@
outboundOrderDetail.LockQuantity += outboundOrderDetail.NoStockOutQty;
outboundOrderDetail.OverOutQuantity = outboundOrderDetail.LockQuantity;
- if(outboundOrderDetail.OrderQuantity == outboundOrderDetail.OverOutQuantity)
+ if (outboundOrderDetail.OrderQuantity == outboundOrderDetail.OverOutQuantity)
{
outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
}
@@ -2723,16 +2729,26 @@
}
//鍒ゆ柇鍏ュ簱鍗曟嵁鏄庣粏鏄惁鍏ㄩ儴鏄畬鎴愮姸鎬�
- bool inoderOver = inboundOrder.Details.Count() == inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
+ int e = inboundOrder.Details.Count();
+ int w = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
+ bool inoderOver = inboundOrder.Details.Count() == inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
if (inoderOver)
{
inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
}
+ else
+ {
+ inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ }
//鍒ゆ柇鍑哄簱鍗曟嵁鏄庣粏鏄惁鍏ㄩ儴鏄畬鎴愮姸鎬�
- bool outOderOver = outboundOrder.Details.Count() == outboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
+ bool outOderOver = outboundOrder.Details.Count() == outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
if (outOderOver)
{
outboundOrder.OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+ }
+ else
+ {
+ outboundOrder.OrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
}
//鏁版嵁澶勭悊
_unitOfWorkManage.BeginTran();
@@ -2742,9 +2758,116 @@
_outboundOrderService.UpdateData(outboundOrder);
_unitOfWorkManage.CommitTran();
+ if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+ {
+ var feedmodel = new FeedbackInboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString(),
+ business_type = inboundOrder.BusinessType,
+ factoryArea = inboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = inboundOrder.Operator,
+ orderNo = inboundOrder.UpperOrderNo,
+ status = inboundOrder.OrderStatus,
+ details = new List<FeedbackInboundDetailsModel>()
+
+ };
+
+ var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackInboundDetailsModel
+ {
+ materialCode = group.Key.MaterielCode,
+ supplyCode = group.Key.SupplyCode,
+ batchNo = group.Key.BatchNo,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.BarcodeQty),
+ // warehouseCode= "1072",
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(row => new FeedbackBarcodesModel
+ {
+ barcode = row.Barcode,
+ qty = row.BarcodeQty
+ }).ToList()
+ }).ToList();
+ feedmodel.details = groupedData;
+
+ var result = await _invokeMESService.FeedbackInbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ _inboundOrderRepository.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 })
+ .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
+ _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
+ .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
+ }
+ }
+ if (outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+ {
+ var feedmodel = new FeedbackOutboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ business_type = outboundOrder.BusinessType,
+ factoryArea = outboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = outboundOrder.Operator,
+ orderNo = outboundOrder.UpperOrderNo,
+ documentsNO = outboundOrder.OrderNo,
+ status = outboundOrder.OrderStatus,
+ details = new List<FeedbackOutboundDetailsModel>()
+ };
+
+
+ foreach (var detail in outboundOrder.Details)
+ {
+ // 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
+ var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderNo == outboundOrder.OrderNo &&
+ x.OrderDetailId == detail.Id &&
+ x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
+ .ToListAsync();
+
+ var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackOutboundDetailsModel
+ {
+
+ materialCode = group.Key.MaterielCode,
+ lineNo = group.Key.lineNo,
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.BarcodeQty),
+ currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.BarcodeUnit,
+ qty = lockInfo.BarcodeQty
+ }).ToList()
+ }).ToList();
+ feedmodel.details.AddRange(groupdata);
+ }
+ var result = await _invokeMESService.FeedbackOutbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ExecuteCommandAsync();
+
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(x => x.ReturnToMESStatus == 1)
+ .Where(x => x.Id == outboundOrder.Id)
+ .ExecuteCommandAsync();
+ }
+ }
+
+
return WebResponseContent.Instance.OK();
}
- catch(Exception ex)
+ catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
return WebResponseContent.Instance.Error(ex.Message);
@@ -2752,11 +2875,241 @@
}
#endregion
+ public WebResponseContent UnPalletQuantity(string orderNo)
+ {
+ // 鍒濆鍖栬繑鍥濪TO锛堥粯璁ゅ�奸兘涓�0锛岄伩鍏峮ull锛�
+ var resultDTO = new PalletSumQuantityDTO
+ {
+ StockSumQuantity = 0,
+ StockCount = 0,
+ UniqueUnit = ""
+ };
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (string.IsNullOrWhiteSpace(orderNo))
+ {
+ return content.Error("浼犲叆鐨勮鍗曞彿orderNo涓虹┖鎴栫┖鐧�");
+ }
+ var orderDetail = Db.Queryable<Dt_PickingRecord>().Where(s => s.OrderNo == orderNo).ToList();
+ if (orderDetail == null)
+ {
+ return content.Error("鏈壘鍒板崟鎹�");
+ }
+ var unitGroups = orderDetail.GroupBy(d => d.BarcodeUnit).ToList();
+ if (unitGroups.Count == 1)
+ {
+ resultDTO.UniqueUnit = unitGroups.First().Key;
+ }
+ else
+ {
+ resultDTO.UniqueUnit = "";
+ }
+ var validDetails = _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList();
+ resultDTO.StockSumQuantity = orderDetail.Sum(d => d.PickQuantity);
+ resultDTO.StockCount = orderDetail.Count;
+ if (validDetails.Any())
+ {
+ resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity);
+ // 鏄庣粏璁板綍鏁帮細绗﹀悎鏉′欢鐨勬湁鏁堣褰曟潯鏁�
+ resultDTO.StockCount -= validDetails.Count;
+ }
+ return content.OK("", resultDTO);
+ }
+ catch (Exception ex)
+ {
+ return content.Error("SumQuantity 缁熻搴撳瓨鏁伴噺澶辫触锛岃鍗曞彿锛歿OrderNo}");
+ }
+ }
+
+ public WebResponseContent BarcodeMaterielGroup(BarcodeMaterielGroupDTO materielGroupDTO)
+ {
+
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
+ if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
+
+ // materielGroupDTO.WarehouseCode
+ var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x => x.Code).First();
+ if (string.IsNullOrEmpty(code))
+ {
+ return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseType}缂栧彿銆�");
+ }
+
+ if (materielGroupDTO.orderTypes == InOrderTypeEnum.ReCheck.ObjToInt())
+ {
+ var dborder = _reCheckOrderService.Db.Queryable<Dt_ReCheckOrder>().First(x => x.OrderNo == materielGroupDTO.OrderNo);
+ if (dborder != null && dborder.SignSeq == 0)
+ {
+ return content.Error("鍙湁鎷垮埌閲嶆缁撴灉鎵嶈兘鍏ュ簱锛�");
+ }
+ else
+ {
+ return content.Error("娌℃湁鎵惧埌閲嶆鍗曟嵁鏁版嵁銆�");
+ }
+ }
+ // Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
+
+ var dbinboundOrderDetails = Db.Queryable<Dt_PickingRecord>().Where(x => x.OrderNo == materielGroupDTO.OrderNo && !x.IsCancelled && x.Barcode == materielGroupDTO.Barcodes).ToList();
+
+ if (dbinboundOrderDetails != null && !dbinboundOrderDetails.Any())
+ {
+ return content = WebResponseContent.Instance.Error($"鍗曟嵁涓病鏈夎{materielGroupDTO.Barcodes}鏉$爜鏁版嵁銆�");
+ }
+
+ List<string?> materielCodes = dbinboundOrderDetails.GroupBy(x => x.Barcode).Select(x => x.Key).ToList();
+
+ Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode);
+
+
+
+ (bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, materielCodes, stockInfo);
+ if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+
+ if (stockInfo == null)
+ {
+ stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() };
+ stockInfo.Details = new List<Dt_StockInfoDetail>();
+ }
+ var inboindId = 0; Dt_InboundOrder dt_InboundOrder = null;
+ var dbinbound = _inboundOrderRepository.QueryData(x => x.InboundOrderNo == dbinboundOrderDetails.First().OrderNo).First();
+ if (dbinbound == null)
+ {
+ dt_InboundOrder = new Dt_InboundOrder
+ {
+ WarehouseId = 0,
+ InboundOrderNo = dbinboundOrderDetails.First()?.OrderNo,
+ UpperOrderNo = dbinboundOrderDetails.First()?.OrderNo,
+ SupplierId = dbinboundOrderDetails.First()?.SupplyCode,
+ OrderType = materielGroupDTO.orderTypes,
+
+ BusinessType = materielGroupDTO.orderTypes.ToString(),
+
+ FactoryArea = dbinboundOrderDetails.First()?.FactoryArea,
+ Remark = "",
+ Details = new List<Dt_InboundOrderDetail>()
+ };
+ inboindId = _inboundOrderRepository.AddData(dt_InboundOrder);
+ }
+ else
+ {
+ dt_InboundOrder = new Dt_InboundOrder { Details = new List<Dt_InboundOrderDetail>() };
+ inboindId = dbinbound.Id;
+ }
+
+ foreach (var item in dbinboundOrderDetails)
+ {
+ stockInfo.Details.Add(new Dt_StockInfoDetail
+ {
+ StockId = stockInfo == null ? 0 : stockInfo.Id,
+ Barcode = item.Barcode,
+ MaterielCode = item.MaterielCode,
+ BatchNo = item.BatchNo,
+ Unit = item.BarcodeUnit,
+ InboundOrderRowNo = item.lineNo,
+ SupplyCode = item.SupplyCode,
+ WarehouseCode = materielGroupDTO.WarehouseType,
+ StockQuantity = item.PickQuantity,
+ BarcodeQty = item.BarcodeQty,
+ BarcodeUnit = item.BarcodeUnit,
+ FactoryArea = item.FactoryArea,
+ Status = 0,
+ OrderNo = item.OrderNo,
+ BusinessType = InOrderTypeEnum.InternalAllocat.ObjToInt().ToString()
+
+ });
+ item.WarehouseCode = item.WarehouseCode;
+
+ dt_InboundOrder.Details.Add(new Dt_InboundOrderDetail
+ {
+ OrderId = inboindId,
+ MaterielCode = item.MaterielCode,
+ MaterielName = "",
+ BatchNo = item.BatchNo,
+ OrderQuantity = item.PickQuantity,
+ ReceiptQuantity = 0,
+ OverInQuantity = 0,
+ Unit = item.BarcodeUnit,
+ RowNo = 0,
+ lineNo = item.lineNo,
+ SupplyCode = item.SupplyCode,
+ WarehouseCode = item.WarehouseCode,
+ Barcode = item.Barcode,
+ OutBoxbarcodes = "",
+ BarcodeQty = (decimal)item.BarcodeQty,
+ BarcodeUnit = item.BarcodeUnit
+ });
+ }
+
+ _inboundOrderDetailService.Db.Insertable<Dt_InboundOrderDetail>(dt_InboundOrder.Details);
+ if (stockInfo.Id == 0)
+ {
+ stockInfo.PalletCode = materielGroupDTO.PalletCode;
+ stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ }
+ stockInfo.PalletType = (int)PalletTypeEnum.None;
+
+ List<int> updateDetailIds = dbinboundOrderDetails.Select(x => x.Id).ToList();
+
+ try
+ {
+ _unitOfWorkManage.BeginTran();
+
+ _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+
+ }
+ return content;
+
+ }
+
+
+ public (bool, string, object?) CheckMaterielGroupParam(BarcodeMaterielGroupDTO materielGroupDTO, List<string> barcodeCodes, Dt_StockInfo stockInfo)
+ {
+ (bool, string, object?) result = ModelValidate.ValidateModelData(materielGroupDTO);
+ if (!result.Item1) return result;
+
+ if (_taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
+ {
+ return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟", materielGroupDTO);
+ }
+
+ if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ return (false, "宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏", materielGroupDTO);
+ }
+
+ if (_stockService.StockInfoDetailService.ExistBarcodes(barcodeCodes))
+ {
+ return (false, $"{barcodeCodes[0]} 鏉$爜鍦ㄥ簱瀛樹腑宸插瓨鍦�", materielGroupDTO);
+ }
+
+
+
+ return (true, "鎴愬姛", materielGroupDTO);
+ }
+
#endregion
}
-
+
#region 鏀寔绫诲畾涔�
@@ -2821,12 +3174,20 @@
public bool HasSplitRecords { get; set; }
public decimal RemainingLocksReturnQty { get; set; }
public decimal PalletStockReturnQty { get; set; }
+
public decimal SplitReturnQty { get; set; }
public decimal TotalReturnQty { get; set; }
+
+ // 鏈垎閰嶇殑閿佸畾璁板綍锛堝鑷姩鎷嗗寘浜х敓鐨勶級
+ public bool HasUnallocatedLocks { get; set; }
+ public List<Dt_OutStockLockInfo> UnallocatedLocks { get; set; } = new List<Dt_OutStockLockInfo>();
+ public decimal UnallocatedLocksReturnQty { get; set; }
+
public List<Dt_OutStockLockInfo> RemainingLocks { get; set; } = new List<Dt_OutStockLockInfo>();
public List<Dt_StockInfoDetail> PalletStockGoods { get; set; } = new List<Dt_StockInfoDetail>();
public List<Dt_SplitPackageRecord> SplitRecords { get; set; } = new List<Dt_SplitPackageRecord>();
+ public List<string> AllBarcodes { get; set; } = new List<string>();
// 绌烘墭鐩樼浉鍏冲睘鎬�
public bool IsEmptyPallet { get; set; }
public bool HasActiveTasks { get; set; }
--
Gitblit v1.9.3