From 56538e602b927c232ac5b991ef84175edd2ce3ce Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期五, 24 四月 2026 14:20:20 +0800
Subject: [PATCH] feat(WMS/WCS): 增加机器人历史信息记录 fix(WMS/WCS): 修复前端bug
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs | 96 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 92 insertions(+), 4 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
index 0fd9881..227c7cf 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>
@@ -191,7 +197,7 @@
/// <returns>搴撳瓨淇℃伅</returns>
public async Task<Dt_StockInfo> GetStockInfoAsync(string palletCode, string locationCode)
{
- return await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode && x.LocationCode == locationCode);
+ return await BaseDal.QueryDataNavFirstAsync(x => x.PalletCode == palletCode && x.LocationCode == locationCode);
}
/// <summary>
@@ -251,12 +257,12 @@
// 绌烘墭鐩樹篃鏈夊簱瀛樿褰曪紝鍙槸涓嶅寘鍚槑缁�
item.PalletCode = stockInfo.PalletCode;
item.StockStatus = stockInfo.StockStatus; // 鐩存帴浣跨敤鍚庣搴撳瓨鐘舵��
-
+
// 鍙湁褰揇etails涓嶄负null涓旀湁鏁版嵁鏃舵墠澶勭悊搴撳瓨鏄庣粏
if (stockInfo.Details != null && stockInfo.Details.Any())
{
item.StockQuantity = stockInfo.Details.Sum(d => d.StockQuantity);
-
+ item.OutboundDate = stockInfo.OutboundDate;
// 鑾峰彇绗竴涓槑缁嗙殑鐗╂枡淇℃伅锛堝鏋滃瓨鍦級
var firstDetail = stockInfo.Details.FirstOrDefault();
if (firstDetail != null)
@@ -272,6 +278,7 @@
Id = d.Id,
MaterielCode = d.MaterielCode,
MaterielName = d.MaterielName,
+ SerialNumber = d.SerialNumber,
BatchNo = d.BatchNo,
StockQuantity = d.StockQuantity,
Unit = d.Unit,
@@ -316,5 +323,86 @@
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}");
+ }
+ }
+ /// <summary>
+ /// 鏇存柊MES涓婁紶鐘舵��
+ /// </summary>
+ /// <param name="palletCode">鎵樼洏鍙�</param>
+ /// <param name="status">MES涓婁紶鐘舵�佸��</param>
+ /// <returns>鏇存柊鏄惁鎴愬姛</returns>
+ public async Task<bool> UpdateMesUploadStatusAsync(string palletCode, int status)
+ {
+ try
+ {
+ var stockInfo = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
+ if (stockInfo == null)
+ return false;
+
+ stockInfo.MesUploadStatus = status;
+ return await BaseDal.UpdateDataAsync(stockInfo);
+ }
+ catch
+ {
+ return false;
+ }
+ }
}
}
--
Gitblit v1.9.3