From 1dce8a2ad238624ea832e0418557b4a5b53dce23 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 13 四月 2026 17:44:55 +0800
Subject: [PATCH] 添加仓库的启用禁用状态,优化修改分区接口,优化提升机job,添加海康仓位到仓位接口

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |  313 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 304 insertions(+), 9 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 55e58ab..a939d58 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -198,6 +198,10 @@
                                 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
                             default:
                                 objects.Add(new
@@ -388,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 鍑箰澹�
@@ -452,11 +456,15 @@
                         initPriority = updateTaskPriority.taskPriority//浼樺厛绾�
                     };
                     Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(HIKROBOTTaskGrade));
-                    if (apiInfo == null) throw new Exception("鏈壘鍒板洓鍚戣溅AGV浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
-                    string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize());
+                    if (apiInfo == null) throw new Exception("鏈壘鍒版捣搴稟GV浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
+                    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);
@@ -514,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($"鏃犳晥鐨勪粨搴揑D锛歿wMSUpdateLocationArea.WarehouseId}锛屾湁鏁堝�间负锛�1-鎴愬搧搴擄紝2-闈㈡枡搴擄紝3-璐у簱锛�4-瑁佸壀搴�");
+                }
                 if (wMSUpdateLocationArea.WarehouseId == 1)
                 {
                     var rgvList = _rGVLocationInfoService.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.LocationCode)).ToList();
@@ -522,6 +540,7 @@
                         item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                     }
                     rgv.AddRange(rgvList);
+                    _rGVLocationInfoService.Repository.UpdateData(rgv);
                 }
                 if (wMSUpdateLocationArea.WarehouseId == 2)
                 {
@@ -532,6 +551,7 @@
                         item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
                     }
                     kls.AddRange(KLSLocationInfoList);
+                    _kLSLocationInfoService.Repository.UpdateData(kls);
                 }
                 if (wMSUpdateLocationArea.WarehouseId == 3)
                 {
@@ -541,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)
@@ -1207,6 +1233,25 @@
                     }
                     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
+                        });
+                    }
+                    content.OK(data: list);
+                }
             }
             catch (Exception ex)
             {
@@ -1280,7 +1325,9 @@
                 string dataJson = wMSReturn.result.ToString();
                 Exists? exists = JsonConvert.DeserializeObject<Exists>(dataJson);
                 if (exists == null) throw new Exception($"WMS杩斿洖缁撴灉鐨剅esult杞崲澶辫触");
+                //濡傛灉鎴愬姛灏变笉杩斿洖
                 if (exists.taskExists) return WebResponseContent.Instance.OK();
+                //濡傛灉澶辫触浜嗗氨杩斿洖exists.errorAreaCode
                 return WebResponseContent.Instance.OK(exists.errorAreaCode);
             }
             catch (Exception ex)
@@ -1565,5 +1612,253 @@
         }
 
 
+
+        /// <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}");
+            }
+        }
     }
 }

--
Gitblit v1.9.3