yanjinhui
2 天以前 0a62180f002d8a601b6b3c46af3a6b4583f9acf6
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -57,6 +57,7 @@
        private readonly IApiInfoService _apiInfoService;
        private readonly IStationMangerService _stationMangerService;
        private readonly IStationInfoService _stationInfo;
        private readonly ITaskErrorMessageService _taskErrorMessageService;
        private readonly IMapper _mapper;
        private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -76,7 +77,7 @@
        /// </summary>
        public IRepository<Dt_Task> Repository => BaseDal;
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo) : base(BaseDal)
        public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo, ITaskErrorMessageService taskErrorMessageService) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -89,6 +90,7 @@
            _trackloginfoService = trackloginfoService;
            _stationMangerService = stationMangerService;
            _stationInfo = stationInfo;
            _taskErrorMessageService = taskErrorMessageService;
        }
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
        {
@@ -189,11 +191,15 @@
                                content = HKF01Transport(task, item.taskType);
                                break;
                            case (int)TaskTypeEnum.F04:
                            case (int)TaskTypeEnum.F03:
                            case (int)TaskTypeEnum.F02:
                            case (int)TaskTypeEnum.RK3F:
                            case (int)TaskTypeEnum.F02:
                            case (int)TaskTypeEnum.F03:
                            case (int)TaskTypeEnum.CK3F:
                                content = CJCarryTaske(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.STUPTBY:
                                content = HKSTUPTP(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            #endregion
@@ -386,7 +392,7 @@
                bool isAGV = dt_Task.TaskType == (int)TaskTypeEnum.CPInbound || dt_Task.TaskType == (int)TaskTypeEnum.CPOutbound;
                //海康
                bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK;
                bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK||dt_Task.TaskType == (int)TaskTypeEnum.STUPTBY;
                //修改原本任务优先级
                dt_Task.Grade = updateTaskPriority.taskPriority;
                #region å‡¯ä¹å£«
@@ -450,11 +456,15 @@
                        initPriority = updateTaskPriority.taskPriority//优先级
                    };
                    Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(HIKROBOTTaskGrade));
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize());
                    if (apiInfo == null) throw new Exception("未找到海康AGV任务下发接口配置信息!请检查接口配置");
                    var headers = new Dictionary<string, string>
                    {
                        { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + dt_Task.WMSTaskNum }
                    };
                    string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize(), headers: headers);
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    content.OK(data: hIKROBOTReturn);
                    if (hIKROBOTReturn.code == "SUCCESS0" && hIKROBOTReturn.message == "成功")
                    if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
                        content.OK("修改{dt_Task.WMSTaskNum}任务优先级成功", dt_Task);
@@ -512,6 +522,16 @@
                var rgv = new List<Dt_RGVLocationInfo>();
                var kls = new List<Dt_KLSLocationInfo>();
                var hk = new List<Dt_HKLocationInfo>();
                List<Dt_StationInfo> pk = new List<Dt_StationInfo>();
                if (wMSUpdateLocationArea==null)
                {
                    return content.Error("请求参数不能为空");
                }
                var validWarehouseIds = new[] { 1, 2, 3, 4 };
                if (!validWarehouseIds.Contains(wMSUpdateLocationArea.WarehouseId))
                {
                    return content.Error($"无效的仓库ID:{wMSUpdateLocationArea.WarehouseId},有效值为:1-成品库,2-面料库,3-货库,4-裁剪库");
                }
                if (wMSUpdateLocationArea.WarehouseId == 1)
                {
                    var rgvList = _rGVLocationInfoService.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.LocationCode)).ToList();
@@ -520,6 +540,7 @@
                        item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                    }
                    rgv.AddRange(rgvList);
                    _rGVLocationInfoService.Repository.UpdateData(rgv);
                }
                if (wMSUpdateLocationArea.WarehouseId == 2)
                {
@@ -530,6 +551,7 @@
                        item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                    }
                    kls.AddRange(KLSLocationInfoList);
                    _kLSLocationInfoService.Repository.UpdateData(kls);
                }
                if (wMSUpdateLocationArea.WarehouseId == 3)
                {
@@ -539,12 +561,18 @@
                        item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                    }
                    hk.AddRange(hkList);
                    _hKLocationInfoService.Repository.UpdateData(hk);
                }
                Db.Ado.BeginTran();
                _rGVLocationInfoService.UpdateData(rgv);
                _kLSLocationInfoService.UpdateData(kls);
                _hKLocationInfoService.UpdateData(hk);
                Db.Ado.CommitTran();
                if (wMSUpdateLocationArea.WarehouseId == 4)
                {
                    var pkList = _stationInfo.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.StationCode)).ToList();
                    foreach (var item in pkList)
                    {
                        item.StationRegion = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                    }
                    pk.AddRange(pkList);
                    _stationInfo.Repository.UpdateData(pk);
                }
                content.OK();
            }
            catch (Exception ex)
@@ -1127,7 +1155,8 @@
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                            PalletCode = item.PalletCode,
                            AreaCode=item.WarehouseId
                        });
                    }
@@ -1147,7 +1176,8 @@
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                            PalletCode = item.PalletCode,
                            AreaCode = item.WarehouseId
                        });
                    }
                    content.OK(data: list);
@@ -1181,7 +1211,8 @@
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus,
                            PalletCode = item.PalletCode
                            PalletCode = item.PalletCode,
                            AreaCode = item.WarehouseId
                        });
                    }
                    content.OK(data: list);
@@ -1201,6 +1232,27 @@
                            LoctionCode = item.StationCode,
                            LocationStatus = value ? 100 : 0,
                            EnableStatus = 0,
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 6)
                {
                    List<Dt_StationInfo> StationInfo = new List<Dt_StationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        StationInfo = _stationInfo.Repository.QueryData(x => x.StationRegion == getLocationInfo.AreaCode.ObjToInt());
                    else
                        StationInfo = _stationInfo.Repository.QueryData();
                    foreach (var item in StationInfo)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.StationCode,
                            LocationStatus = item.StationStatus,
                            EnableStatus = item.IsOccupied,
                            PalletCode = item.PalletCode,
                            AreaCode = item.StationRegion
                        });
                    }
                    content.OK(data: list);
@@ -1237,11 +1289,11 @@
        public WebResponseContent InboundElevatorExit(string LocationCode, string containerCode)
        {
            WebResponseContent content = new WebResponseContent();
            inboundElevatorExitDTO inboundElevator=new inboundElevatorExitDTO();
            inboundElevatorExitDTO inboundElevator = new inboundElevatorExitDTO();
            try
            {
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundElevatorExitDTO)) ?? throw new Exception("未找到4F提升机出口托盘号上报WMS接口配置信息!请检查接口配置");
                inboundElevator.containerCode= containerCode;
                inboundElevator.containerCode = containerCode;
                inboundElevator.toLocationCode = LocationCode;
                string response = HttpHelper.Post(apiInfo.ApiAddress, inboundElevator.Serialize());
                content.OK(data: response);
@@ -1278,6 +1330,9 @@
                string dataJson = wMSReturn.result.ToString();
                Exists? exists = JsonConvert.DeserializeObject<Exists>(dataJson);
                if (exists == null) throw new Exception($"WMS返回结果的result转换失败");
                //如果成功就不返回
                if (exists.taskExists) return WebResponseContent.Instance.OK();
                //如果失败了就返回exists.errorAreaCode
                return WebResponseContent.Instance.OK(exists.errorAreaCode);
            }
            catch (Exception ex)
@@ -1299,6 +1354,41 @@
            throw new NotImplementedException();
        }
        /// <summary>
        /// å¹³åº“货位上下架容器
        /// </summary>
        /// <param name="wMSUpOrDown"></param>
        /// <returns></returns>
        public WebResponseContent UpOrDownContainer(WMSUpOrDownContainerDTO wMSUpOrDown)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StationInfo stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationCode == wMSUpOrDown.locationCode) ?? throw new Exception($"未找到货位【{wMSUpOrDown.locationCode}】信息");
                if (wMSUpOrDown.direction == 1)
                {
                    stationInfo.StationStatus = LocationStatusEnum.InStock.ObjToInt();
                    stationInfo.PalletCode = wMSUpOrDown.containerCode;
                }
                else
                {
                    stationInfo.StationStatus = LocationStatusEnum.Free.ObjToInt();
                    stationInfo.PalletCode = "";
                }
                _stationInfo.UpdateData(stationInfo);
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(wMSUpOrDown, content, "平库货位上下架容器", "", "");
            }
            return content;
        }
        /// <summary>
        /// å®¹å™¨æµåŠ¨è¯·æ±‚
        /// </summary>
        /// <param name="wMSContainerFlow"></param>
@@ -1306,6 +1396,7 @@
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent ContainerRequest(WMSContainerFlow wMSContainerFlow)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == wMSContainerFlow.slotCode) ?? throw new Exception($"未找到站台【{wMSContainerFlow.slotCode}】信息");
@@ -1313,20 +1404,26 @@
                if (wMSContainerFlow.direction == "200")
                {
                    stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt();
                    stationManger.Remark = "";
                    FOURBOToccupyStation fOURBOToccupyStation = new FOURBOToccupyStation()
                    {
                        stationCode = wMSContainerFlow.slotCode,
                    };
                    string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    content.OK(data: fOURBOTReturn);
                    if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
                    _stationMangerService.UpdateData(stationManger);
                }
                return WebResponseContent.Instance.OK();
                return content.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
                return content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(wMSContainerFlow, content, "容器流动请求", "", "");
            }
        }
        /// <summary>
@@ -1379,11 +1476,21 @@
                //task.TaskState = (int)TaskStatusEnum.Execut;
                //BaseDal.UpdateData(task);
                #endregion
                #region ä¸Šæž¶ä¸­éœ€è¦å°†ç«™å°çŠ¶æ€æ”¹ä¸ºå ç”¨ ç»‘定容器编码
                stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt();
                stationManger.Remark = iQC.ContainerCode;
                _stationMangerService.UpdateData(stationManger);
                #endregion
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(iQC, content, "IQC质检结果反馈", "", "");
            }
        }
@@ -1395,6 +1502,7 @@
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent multiSetNodeStatus(FOURBOTStorageStatusNotify fOURBOTStorageStatusNotify)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var Agvlocation = _rGVLocationInfoService.Repository.QueryData(x => fOURBOTStorageStatusNotify.storageCode.Contains(x.LocationCode));
@@ -1403,12 +1511,16 @@
                    item.EnableStatus = (int)(fOURBOTStorageStatusNotify.disable == 0 ? EnableStatusEnum.Normal : EnableStatusEnum.Disable);
                }
                _rGVLocationInfoService.UpdateData(Agvlocation);
                return WebResponseContent.Instance.OK();
                return content.OK();
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(fOURBOTStorageStatusNotify, content, "批量更新储位状态", "", "");
            }
        }
@@ -1438,7 +1550,320 @@
            }
        }
        /// <summary>
        /// æ ¡éªŒä»»åŠ¡ç›¸å…³çš„åº“ä½çŠ¶æ€å’Œç»‘å®šå…³ç³»
        /// </summary>
        /// <param name="taskType">任务类型</param>
        /// <param name="taskDTO">任务DTO</param>
        /// <returns>返回起点库位和终点库位信息</returns>
        /// <exception cref="Exception">校验失败时抛出异常</exception>
        private WebResponseContent ValidateLocationForTask(int taskType, TaskDTO taskDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                #region
                // å…¥åº“类任务(需要校验终点库位)
                if (taskType == (int)TaskTypeEnum.CK3F || taskType == (int)TaskTypeEnum.F03)
                {
                    var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode)
                          ?? throw new Exception($"未找到终点库位【{taskDTO.toLocationCode}】!");
                    if (toStation.StationStatus != (int)LocationStatusEnum.Free)
                        throw new Exception($"终点库位【{taskDTO.toLocationCode}】库位状态不可入库!");
                }
                // å‡ºåº“类任务(需要校验起点库位)
                else if (taskType == (int)TaskTypeEnum.RK3F || taskType == (int)TaskTypeEnum.F04)
                {
                    var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode)
                        ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                    if (fromStation.StationStatus != (int)LocationStatusEnum.InStock)
                        throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                    if (fromStation.PalletCode != taskDTO.containerCode)
                        throw new Exception($"起点库位【{taskDTO.fromLocationCode}】绑定料箱号【{fromStation.PalletCode}】与任务料箱号【{taskDTO.containerCode}】不匹配!");
                }
                // ç§»åº“类任务(需要同时校验起点和终点)
                else if (taskType == (int)TaskTypeEnum.F02)
                {
                    // æ ¡éªŒç»ˆç‚¹åº“位
                    var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode)
                        ?? throw new Exception($"未找到终点库位【{taskDTO.toLocationCode}】!");
                    if (toStation.StationStatus != (int)LocationStatusEnum.Free)
                        throw new Exception($"终点库位【{taskDTO.toLocationCode}】库位状态不可入库!");
                    // æ ¡éªŒèµ·ç‚¹åº“位
                    var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode)
                        ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                    if (fromStation.StationStatus != (int)LocationStatusEnum.InStock)
                        throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                    if (fromStation.PalletCode != taskDTO.containerCode)
                        throw new Exception($"起点库位【{taskDTO.fromLocationCode}】绑定料箱号【{fromStation.PalletCode}】与任务料箱号【{taskDTO.containerCode}】不匹配!");
                }
                #endregion
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
        /// <summary>
        /// æ›´æ–°åº“位启用禁用状态
        /// </summary>
        /// <param name="upLocationStatusDTO"></param>
        /// <returns></returns>
        public WebResponseContent UpLocationStatus(UpLocationStatusDTO upLocationStatusDTO)
        {
            WebResponseContent content = new WebResponseContent();
            List<object> resultList = new List<object>();
            try
            {
                // å‚数验证
                if (upLocationStatusDTO == null)
                {
                    return content.Error("请求参数不能为空");
                }
                if (upLocationStatusDTO.LocationNubList == null || upLocationStatusDTO.LocationNubList.Length == 0)
                {
                    return content.Error("货位编号列表不能为空");
                }
                // æ ¹æ® EnableStatus çš„值判断是启用还是禁用
                // 0=启用,3=禁用
                bool isEnable = (upLocationStatusDTO.EnableStatus == 0);
                int targetStatus = isEnable ? (int)EnableStatusEnum.Normal : (int)EnableStatusEnum.Disable;
                var updatedList = new List<object>();  // ç”¨äºŽæ‰¹é‡æ›´æ–°
                var notFoundLocations = new List<string>();
                // æˆå“åº“ (WarehouseId = 1)
                if (upLocationStatusDTO.WarehouseId == 1)
                {
                    var locationsToUpdate = new List<Dt_RGVLocationInfo>();
                    foreach (var locationCode in upLocationStatusDTO.LocationNubList)
                    {
                        var agv = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
                        if (agv != null)
                        {
                            agv.EnableStatus = targetStatus;
                            locationsToUpdate.Add(agv);
                            resultList.Add(new
                            {
                                LoctionCode = agv.LocationCode,
                                EnableStatus = agv.EnableStatus,
                            });
                        }
                        else
                        {
                            notFoundLocations.Add(locationCode);
                        }
                    }
                    if (locationsToUpdate.Any())
                    {
                        _rGVLocationInfoService.UpdateData(locationsToUpdate);
                        string message = $"成功更新 {locationsToUpdate.Count} ä¸ªè´§ä½çš„状态";
                        if (notFoundLocations.Any())
                        {
                            message += $",未找到货位:{string.Join(",", notFoundLocations)}";
                        }
                        content.OK(data: resultList, message: message);
                    }
                    else
                    {
                        return content.Error($"未找到任何可更新的货位。未找到的货位:{string.Join(",", notFoundLocations)}");
                    }
                }
                // é¢æ–™åº“ (WarehouseId = 2)
                else if (upLocationStatusDTO.WarehouseId == 2)
                {
                    var locationsToUpdate = new List<Dt_KLSLocationInfo>();
                    foreach (var locationCode in upLocationStatusDTO.LocationNubList)
                    {
                        var kls = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
                        if (kls != null)
                        {
                            kls.EnableStatus = targetStatus;
                            locationsToUpdate.Add(kls);
                            resultList.Add(new
                            {
                                LoctionCode = kls.LocationCode,
                                EnableStatus = kls.EnableStatus,
                            });
                        }
                        else
                        {
                            notFoundLocations.Add(locationCode);
                        }
                    }
                    if (locationsToUpdate.Any())
                    {
                        _kLSLocationInfoService.UpdateData(locationsToUpdate);
                        string message = $"成功更新 {locationsToUpdate.Count} ä¸ªè´§ä½çš„状态";
                        if (notFoundLocations.Any())
                        {
                            message += $",未找到货位:{string.Join(",", notFoundLocations)}";
                        }
                        content.OK(data: resultList, message: message);
                    }
                    else
                    {
                        return content.Error($"未找到任何可更新的货位。未找到的货位:{string.Join(",", notFoundLocations)}");
                    }
                }
                // è£å‰ªåº“ (WarehouseId = 3)
                else if (upLocationStatusDTO.WarehouseId == 3)
                {
                    var locationsToUpdate = new List<Dt_HKLocationInfo>();
                    foreach (var locationCode in upLocationStatusDTO.LocationNubList)
                    {
                        var hk = _hKLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
                        if (hk != null)
                        {
                            hk.EnableStatus = targetStatus;
                            locationsToUpdate.Add(hk);
                            resultList.Add(new
                            {
                                LoctionCode = hk.LocationCode,
                                EnableStatus = hk.EnableStatus,
                            });
                        }
                        else
                        {
                            notFoundLocations.Add(locationCode);
                        }
                    }
                    if (locationsToUpdate.Any())
                    {
                        _hKLocationInfoService.UpdateData(locationsToUpdate);
                        string message = $"成功更新 {locationsToUpdate.Count} ä¸ªè´§ä½çš„状态";
                        if (notFoundLocations.Any())
                        {
                            message += $",未找到货位:{string.Join(",", notFoundLocations)}";
                        }
                        content.OK(data: resultList, message: message);
                    }
                    else
                    {
                        return content.Error($"未找到任何可更新的货位。未找到的货位:{string.Join(",", notFoundLocations)}");
                    }
                }
                // 3-4平库
                else if (upLocationStatusDTO.WarehouseId == 4)
                {
                    var locationsToUpdate = new List<Dt_StationInfo>();
                    foreach (var locationCode in upLocationStatusDTO.LocationNubList)
                    {
                        var station = _stationInfo.Repository.QueryFirst(x => x.StationCode == locationCode);
                        if (station != null)
                        {
                            station.IsOccupied = upLocationStatusDTO.EnableStatus==0?0:1;
                            locationsToUpdate.Add(station);
                            resultList.Add(new
                            {
                                LoctionCode = station.StationCode,
                                EnableStatus = station.IsOccupied,
                            });
                        }
                        else
                        {
                            notFoundLocations.Add(locationCode);
                        }
                    }
                    if (locationsToUpdate.Any())
                    {
                        _stationInfo.UpdateData(locationsToUpdate);
                        string message = $"成功更新 {locationsToUpdate.Count} ä¸ªè´§ä½çš„状态";
                        if (notFoundLocations.Any())
                        {
                            message += $",未找到货位:{string.Join(",", notFoundLocations)}";
                        }
                        content.OK(data: resultList, message: message);
                    }
                    else
                    {
                        return content.Error($"未找到任何可更新的货位。未找到的货位:{string.Join(",", notFoundLocations)}");
                    }
                }
                else if (upLocationStatusDTO.WarehouseId == 5)
                {
                    var locationsToUpdate = new List<Dt_StationManger>();
                    foreach (var locationCode in upLocationStatusDTO.LocationNubList)
                    {
                        var station = _stationMangerService.Repository.QueryFirst(x => x.StationCode == locationCode);
                        if (station != null)
                        {
                            station.IsOccupied = upLocationStatusDTO.EnableStatus == 0 ? 0 : 1;
                            locationsToUpdate.Add(station);
                            resultList.Add(new
                            {
                                LoctionCode = station.StationCode,
                                EnableStatus = station.IsOccupied,
                            });
                        }
                        else
                        {
                            notFoundLocations.Add(locationCode);
                        }
                    }
                    if (locationsToUpdate.Any())
                    {
                        _stationMangerService.UpdateData(locationsToUpdate);
                        string message = $"成功更新 {locationsToUpdate.Count} ä¸ªè´§ä½çš„状态";
                        if (notFoundLocations.Any())
                        {
                            message += $",未找到站台:{string.Join(",", notFoundLocations)}";
                        }
                        content.OK(data: resultList, message: message);
                    }
                    else
                    {
                        return content.Error($"未找到任何可更新的站台。未找到的站台:{string.Join(",", notFoundLocations)}");
                    }
                }
                else
                {
                    return content.Error($"不支持的仓库类型:{upLocationStatusDTO.WarehouseId}");
                }
                return content;
            }
            catch (Exception ex)
            {
                return content.Error($"更新站台状态失败:{ex.Message}");
            }
        }
    }
}