From 8330291df8b7b7ce051b7f3a0c68fc2dc5f70bc7 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 26 十二月 2024 16:54:14 +0800 Subject: [PATCH] 更新货位变动信息记录,WCS堆垛机入库执行中下一步 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 94 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 2 deletions(-) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs index 587b9ad..3d56886 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs @@ -1,5 +1,10 @@ -锘縰sing WIDESEA_Common; +锘縰sing AngleSharp.Dom; +using Mapster; +using System.Threading.Tasks; +using WIDESEA_Common; +using WIDESEA_Core; using WIDESEA_DTO; +using WIDESEA_Model.Models; namespace WIDESEA_StorageBasicService; @@ -8,11 +13,14 @@ private readonly LogFactory LogFactory = new LogFactory(); private readonly IUnitOfWorkManage _unitOfWorkManage; private readonly IDt_TaskRepository _taskRepository; + private readonly IDt_TaskService _taskService; private readonly IStockInfoRepository _stockInfoRepository; + private readonly IStockInfoDetailRepository _stockInfoDetailRepository; private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository; private readonly IPointStackerRelationRepository _pointStackerRelationRepository; private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; + private readonly IMapper _mapper; public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, @@ -21,7 +29,10 @@ IDt_WareAreaInfoRepository wareAreaInfoRepository, IPointStackerRelationRepository pointStackerRelationRepository, ITaskExecuteDetailRepository taskExecuteDetailRepository, - ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal) + ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, + IStockInfoDetailRepository stockInfoDetailRepository, + IMapper mapper, + IDt_TaskService taskService) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; _taskRepository = taskRepository; @@ -30,6 +41,9 @@ _pointStackerRelationRepository = pointStackerRelationRepository; _taskExecuteDetailRepository = taskExecuteDetailRepository; _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; + _stockInfoDetailRepository = stockInfoDetailRepository; + _mapper = mapper; + _taskService = taskService; } /// <summary> @@ -103,6 +117,52 @@ return base.UpdateData(saveModel); } + #region 鍒濆鍖栧簱浣� + public async Task<WebResponseContent> initializeLocation(int locationID) + { + WebResponseContent content = new WebResponseContent(); + try + { + DtLocationInfo? location = BaseDal.QueryData(x => x.Id == locationID).FirstOrDefault(); + int LastStatus = location.LocationStatus; + if (location == null) + { + return content.Error("鏈壘鍒拌揣浣嶄俊鎭�!"); + } + DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id); + if(stock == null) + { + location.LocationStatus= (int)LocationEnum.Lock; + BaseDal.UpdateData(location); + } + else + { + _unitOfWorkManage.BeginTran(); + DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); + stockInfo_Hty.ModifyDate = DateTime.Now; + await DeleteStockInfoAsync(stock.Id); + List<DtStockInfoDetail> detail = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id).ToList(); + if (detail != null && detail.Count() > 0) + { + await DeleteStockInfoDetailsAsync(detail); + } + await AddStockInfoHtyAsync(stockInfo_Hty); + + location.LocationStatus = (int)LocationEnum.Lock; + BaseDal.UpdateData(location); + + _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, LastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0); + _unitOfWorkManage.CommitTran(); + } + return content.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return content.Error(ex.Message); + } + } + #endregion #region 鍒涘缓鍘熷璐т綅鏁版嵁 @@ -325,5 +385,35 @@ #endregion 鍒涘缓鍒濆璐т綅鏂规硶 + #region 搴撳瓨绉诲叆鍘嗗彶 + private async Task DeleteStockInfoAsync(int stockId) + { + var isStockUpdated = await _stockInfoRepository.DeleteDataByIdAsync(stockId); + if (!isStockUpdated) + { + throw new Exception("搴撳瓨淇℃伅鏇存柊澶辫触"); + } + } + + private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock) + { + var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync(); + if (!isStockAdd) + { + throw new Exception("搴撳瓨鍘嗗彶淇℃伅娣诲姞澶辫触"); + } + } + + private async Task DeleteStockInfoDetailsAsync(IEnumerable<DtStockInfoDetail> details) + { + var ids = details.Select(x => (object)x.Id).ToArray(); + var isStockDetailUpdated = await _stockInfoDetailRepository.DeleteDataByIdsAsync(ids); + if (!isStockDetailUpdated) + { + throw new Exception("搴撳瓨璇︽儏淇℃伅鏇存柊澶辫触"); + } + } + #endregion + #endregion 鍐呴儴鏂规硶 } \ No newline at end of file -- Gitblit v1.9.3