From 6641d42d35d7b9739c64fe578d69e43a39e26c16 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期六, 29 十一月 2025 09:46:49 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs | 107 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 85 insertions(+), 22 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_InboundService/InboundOrderService.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_InboundService/InboundOrderService.cs"
index 7e48a6a..f65373c 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_InboundService/InboundOrderService.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_InboundService/InboundOrderService.cs"
@@ -37,10 +37,11 @@
private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository;
private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
+ private readonly IRepository<Dt_LocationType> _locationTypeRepository;
private readonly IRepository<Dt_StockInfo> _stockRepository;
public IRepository<Dt_InboundOrder> Repository => BaseDal;
- public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository,IRepository<Dt_StockInfo> stockRepository) : base(BaseDal)
+ public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_StockInfo> stockRepository, IRepository<Dt_LocationType> locationTypeRepository) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -53,6 +54,7 @@
_inboundOrderRepository = inboundOrderRepository;
_warehouseAreaRepository = warehouseAreaRepository;
_stockRepository = stockRepository;
+ _locationTypeRepository = locationTypeRepository;
}
public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType)
@@ -94,8 +96,11 @@
item.Unit = purchaseToStockResult.Unit;
item.OrderQuantity = purchaseToStockResult.Quantity;
}
+ if (model.OrderType != InOrderTypeEnum.AllocatInbound.ObjToInt())
+ {
+ model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
+ }
- model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule));
Db.InsertNav(model).Include(x => x.Details).ExecuteCommand();
}
return WebResponseContent.Instance.OK();
@@ -119,6 +124,10 @@
if (inboundOrder.Details == null || inboundOrder.Details.Count == 0)
{
return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
+ }
+ if (inboundOrder.OrderStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璇ヨ鍗曠姸鎬佷笉鍏佽淇敼");
}
List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>();
List<Dt_InboundOrderDetail> updateInboundOrderDetails = new List<Dt_InboundOrderDetail>();
@@ -168,7 +177,9 @@
inboundOrderDetail.BarcodeUnit = item.BarcodeUnit;
inboundOrderDetail.BarcodeQty = item.BarcodeQty;
inboundOrderDetail.OrderQuantity = item.OrderQuantity;
-
+ var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty);
+ inboundOrderDetail.Unit = purchaseToStockResult.Unit;
+ inboundOrderDetail.OrderQuantity = purchaseToStockResult.Quantity;
updateInboundOrderDetails.Add(inboundOrderDetail);
detailIds.Add(inboundOrderDetail.Id);
@@ -186,7 +197,8 @@
_unitOfWorkManage.BeginTran();
foreach (var item in deletePurchaseOrderDetails)
{
- _inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
+ _inboundOrderDetailRepository.DeleteData(item);
+ //_inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
}
_inboundOrderDetailRepository.UpdateData(updateInboundOrderDetails);
@@ -221,13 +233,19 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
}
+ if (inboundOrder.OrderStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璇ヨ鍗曠姸鎬佷笉鍏佽鍒犻櫎");
+ }
//Db.DeleteNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
_unitOfWorkManage.BeginTran();
- BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.鑷姩鍒犻櫎);
+ //BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.鑷姩鍒犻櫎);
foreach (var item in inboundOrder.Details)
{
- _inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
+ _inboundOrderDetailRepository.DeleteData(item);
+ //_inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
}
+ BaseDal.DeleteData(inboundOrder);
_unitOfWorkManage.CommitTran();
}
return WebResponseContent.Instance.OK();
@@ -323,12 +341,12 @@
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))
+ 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}缂栧彿銆�");
}
-
+
Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo);
@@ -350,10 +368,10 @@
if (stockInfo == null)
{
- stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None,LocationType=materielGroupDTO.locationType.ObjToInt() };
+ stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() };
stockInfo.Details = new List<Dt_StockInfoDetail>();
}
-
+
foreach (var item in dbinboundOrderDetails)
{
stockInfo.Details.Add(new Dt_StockInfoDetail
@@ -367,15 +385,15 @@
SupplyCode = item.SupplyCode,
WarehouseCode = materielGroupDTO.WarehouseType,
StockQuantity = item.OrderQuantity,
- BarcodeQty=item.BarcodeQty,
- BarcodeUnit=item.BarcodeUnit,
- FactoryArea= inboundOrder.FactoryArea,
- Status = 0,
+ BarcodeQty = item.BarcodeQty,
+ BarcodeUnit = item.BarcodeUnit,
+ FactoryArea = inboundOrder.FactoryArea,
+ Status = 0,
OrderNo = inboundOrder.InboundOrderNo,
BusinessType = inboundOrder.BusinessType,
-
+
});
-
+
item.ReceiptQuantity = item.BarcodeQty;
item.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
item.WarehouseCode = materielGroupDTO.WarehouseType;
@@ -426,13 +444,14 @@
(bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO);
if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2);
- var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseCode).Select(x => x.Code).First();
- if (string.IsNullOrEmpty(code))
+ bool code = _locationTypeRepository.Db.Queryable<Dt_LocationType>().Where(x => x.LocationType == materielGroupDTO.WarehouseCode).Any();
+ if (!code)
{
- return content = WebResponseContent.Instance.Error($"浠撳簱涓病鏈夎{materielGroupDTO.WarehouseCode}缂栧彿銆�");
+ return content = WebResponseContent.Instance.Error($"鍖哄煙涓病鏈夎{materielGroupDTO.WarehouseCode}缂栧彿銆�");
}
- if(_stockRepository.QueryFirst(x=>x.PalletCode == materielGroupDTO.PalletCode)!=null){
+ if (_stockRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
+ {
return WebResponseContent.Instance.Error("璇ユ墭鐩樺凡缁忕粍杩囩洏");
}
@@ -451,13 +470,14 @@
{
if (stockInfo == null)
{
- stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode,LocationType=1 };
+ stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = materielGroupDTO.PalletCode, LocationType = materielGroupDTO.WarehouseCode.ObjToInt() };
stockInfo.Details = new List<Dt_StockInfoDetail>();
}
else
{
stockInfo.PalletType = PalletTypeEnum.Empty.ObjToInt();
stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ stockInfo.LocationType = materielGroupDTO.WarehouseCode.ObjToInt();
}
_unitOfWorkManage.BeginTran();
@@ -625,5 +645,48 @@
}
}
+ public WebResponseContent UndoPalletGroup(string palletCode)
+ {
+ if (string.IsNullOrWhiteSpace(palletCode))
+ {
+ return WebResponseContent.Instance.Error("鎵樼洏鍙蜂笉鑳戒负绌�");
+ }
+ var stock = _stockRepository.Db.Queryable<Dt_StockInfo>().Includes(o => o.Details).First(x => x.PalletCode == palletCode && x.StockStatus == (int)StockStatusEmun.缁勭洏鏆傚瓨);
+ if (stock == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺彿{palletCode}瀵瑰簲鐨勫簱瀛樿褰�");
+ }
+
+ if (stock.Details == null || !stock.Details.Any())
+ {
+ _stockRepository.DeleteData(stock);
+ return WebResponseContent.Instance.OK();
+ }
+ // 鑾峰彇搴撳瓨璇︽儏鍏宠仈鐨勬墍鏈夊叆搴撳崟鍙�
+ var relatedOrderNos = stock.Details.Select(d => d.OrderNo).First();
+ // 鏌ヨ鎵�鏈夊叧鑱旂殑鍏ュ簱鍗曪紙鍚鎯咃級
+ var inboundOrders = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>()
+ .Includes(x => x.Details)
+ .Where(x => relatedOrderNos == x.InboundOrderNo)
+ .First();
+
+ var barcodes = stock.Details.Select(d => d.Barcode).ToList();
+
+ // 鍖归厤搴撳瓨鏉$爜瀵瑰簲鐨勫叆搴撳崟鏄庣粏
+ var matchedInboundDetails = inboundOrders.Details
+ ?.Where(d => barcodes.Contains(d.Barcode))
+ .ToList();
+ foreach (var detail in matchedInboundDetails)
+ {
+ detail.ReceiptQuantity = 0;
+ detail.OrderDetailStatus = 0;
+ _inboundOrderDetailRepository.UpdateData(detail);
+ }
+ _stockDetailRepository.DeleteData(stock.Details);
+ _stockRepository.DeleteData(stock);
+
+
+ return WebResponseContent.Instance.OK("鎵樼洏鎾ら攢鎴愬姛");
+ }
}
}
--
Gitblit v1.9.3