using WIDESEA_Common.LocationEnum; using WIDESEA_Common.StockEnum; using WIDESEA_Common.TaskEnum; using WIDESEA_Core; using WIDESEA_DTO.Task; namespace WIDESEA_TaskInfoService { public partial class TaskService { #region 移库任务 /// /// 移库任务完成:修改库存位置与状态,修改源/目标货位状态,删除任务数据 /// public async Task RelocationFinishTaskAsync(CreateTaskDto taskDto) { try { var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode && s.TaskType == TaskRelocationTypeEnum.Relocation.GetHashCode()); if (task == null) return WebResponseContent.Instance.Error("未找到对应的移库任务"); var sourceLocation = await _locationInfoService.GetLocationInfo(task.Roadway, task.SourceAddress); if (sourceLocation == null) return WebResponseContent.Instance.Error("未找到移库源货位"); var targetLocation = await _locationInfoService.GetLocationInfo(task.Roadway, task.TargetAddress); if (targetLocation == null) return WebResponseContent.Instance.Error("未找到移库目标货位"); var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode); if (stockInfo == null) return WebResponseContent.Instance.Error("未找到对应库存信息"); return await _unitOfWorkManage.BeginTranAsync(async () => { stockInfo.LocationCode = targetLocation.LocationCode; stockInfo.LocationId = targetLocation.Id; stockInfo.StockStatus = StockStatusEmun.入库完成.GetHashCode(); sourceLocation.LocationStatus = LocationStatusEnum.Free.GetHashCode(); targetLocation.LocationStatus = LocationStatusEnum.InStock.GetHashCode(); var updateSourceResult = await _locationInfoService.UpdateLocationInfoAsync(sourceLocation); var updateTargetResult = await _locationInfoService.UpdateLocationInfoAsync(targetLocation); var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo); if (!updateSourceResult || !updateTargetResult || !updateStockResult) return WebResponseContent.Instance.Error("移库任务完成失败"); return await CompleteTaskAsync(task, "移库完成"); }); } catch (Exception ex) { return WebResponseContent.Instance.Error($"完成任务失败: {ex.Message}"); } } #endregion 移库任务 } }