From 595b44f79c7580b3d95c63194b1df4f00600f926 Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期六, 18 四月 2026 15:08:14 +0800
Subject: [PATCH] Revert "fix(WMS): 修复货位状态变动记录"
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs | 67 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
index 0fd9881..9a84608 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -30,6 +30,8 @@
/// </summary>
private readonly IWarehouseService _warehouseService;
private readonly IRecordService _recordService;
+ private readonly IUnitOfWorkManage _unitOfWorkManage;
+ private readonly IStockInfoDetailService _stockInfoDetailService;
/// <summary>
/// 鏋勯�犲嚱鏁�
@@ -39,11 +41,15 @@
IRepository<Dt_StockInfo> baseDal,
ILocationInfoService locationInfoService,
IWarehouseService warehouseService,
- IRecordService recordService) : base(baseDal)
+ IRecordService recordService,
+ IUnitOfWorkManage unitOfWorkManage,
+ IStockInfoDetailService stockInfoDetailService) : base(baseDal)
{
_locationInfoService = locationInfoService;
_warehouseService = warehouseService;
_recordService = recordService;
+ _unitOfWorkManage = unitOfWorkManage;
+ _stockInfoDetailService = stockInfoDetailService;
}
/// <summary>
@@ -316,5 +322,64 @@
Locations = locationItems
};
}
+
+ /// <summary>
+ /// 浣跨敤浜嬪姟鍒犻櫎搴撳瓨鍜屾槑缁嗕俊鎭紙鍏堟煡璇㈠啀鍒犻櫎锛�
+ /// </summary>
+ /// <param name="stockId">搴撳瓨ID</param>
+ /// <returns>鍒犻櫎缁撴灉</returns>
+ public async Task<WebResponseContent> DeleteStockWithDetailsAsync(int stockId)
+ {
+ if (stockId <= 0)
+ return WebResponseContent.Instance.Error("搴撳瓨ID鏃犳晥");
+
+ _unitOfWorkManage.BeginTran();
+ try
+ {
+ // 鍏堟煡璇㈠簱瀛樹俊鎭紙鍖呭惈鏄庣粏锛�
+ var stockInfo = await BaseDal.QueryDataNavFirstAsync(x => x.Id == stockId);
+ if (stockInfo == null)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error("搴撳瓨璁板綍涓嶅瓨鍦�");
+ }
+
+ // 鏌ヨ骞跺垹闄ゅ簱瀛樻槑缁嗚褰�
+ var existingDetails = await _stockInfoDetailService.Repository.QueryDataAsync(x => x.StockId == stockId);
+ if (existingDetails != null && existingDetails.Any())
+ {
+ var deleteDetailResult = await _stockInfoDetailService.Repository.DeleteDataAsync(existingDetails);
+ if (!deleteDetailResult)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error("鍒犻櫎搴撳瓨鏄庣粏璁板綍澶辫触");
+ }
+ }
+
+ // 鍒犻櫎搴撳瓨涓昏褰�
+ var deleteStockResult = await BaseDal.DeleteDataAsync(stockInfo);
+ if (!deleteStockResult)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error("鍒犻櫎搴撳瓨涓昏褰曞け璐�");
+ }
+
+ _unitOfWorkManage.CommitTran();
+
+ // 璁板綍搴撳瓨鍙樻洿鏃ュ織
+ var saveRecordResult = await _recordService.AddStockChangeRecordAsync(stockInfo, null, StockChangeTypeEnum.Outbound, remark: "搴撳瓨鍒犻櫎");
+ if (!saveRecordResult)
+ {
+ return WebResponseContent.Instance.Error("搴撳瓨鍙樻洿璁板綍淇濆瓨澶辫触");
+ }
+
+ return WebResponseContent.Instance.OK("搴撳瓨鍒犻櫎鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error($"鍒犻櫎搴撳瓨鍜屾槑缁嗘椂鍙戠敓寮傚父: {ex.Message}");
+ }
+ }
}
}
--
Gitblit v1.9.3