From e9fbecd61a9ab8c5d906269150b6cdc8ca86dfdb Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期二, 31 三月 2026 09:09:45 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 102 insertions(+), 6 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs
index 6fad4e6..1b5d3d8 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs
@@ -6,6 +6,7 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common.OrderEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
@@ -16,6 +17,7 @@
 using WIDESEA_IBasicRepository;
 using WIDESEA_IBasicService;
 using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Inbound;
 
 namespace WIDESEA_BasicService
 {
@@ -40,7 +42,11 @@
 
         public override WebResponseContent UpdateData(SaveModel saveModel)
         {
-            return base.UpdateData(saveModel);
+            var id = saveModel.MainData["id"].ObjToInt();
+            var locationStatus = saveModel.MainData["locationStatus"].ObjToInt();
+            Dt_LocationInfo locationInfo = BaseDal.QueryFirst(x => x.Id == id);
+            locationInfo.LocationStatus = locationStatus;
+            return base.UpdateData(locationInfo);
         }
 
         public override WebResponseContent DeleteData(object[] keys)
@@ -216,16 +222,18 @@
                                 EnableStatus = EnableStatusEnum.Normal.ObjToInt(),
                                 Layer = k + 1,
                                 LocationStatus = LocationStatusEnum.Free.ObjToInt(),
-                                LocationType = LocationTypeEnum.Cube.ObjToInt(),
+                                //LocationType = LocationTypeEnum.Cube.ObjToInt(),
                                 RoadwayNo = initializationLocationDTO.Roadway,
                                 Row = i + 1,
+                                Creater="WMS",
+                                CreateDate = DateTime.Now,
                             };
 
                             if (initializationLocationDTO.IsSingleDepth)
                             {
                                 locationInfo.Depth = 1;
-                                locationInfo.LocationCode = $"R{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
-                                locationInfo.LocationName = $"R{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Column.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
+                                locationInfo.LocationCode = $"{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
+                                locationInfo.LocationName = $"{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Column.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
                             }
                             else
                             {
@@ -237,8 +245,8 @@
                                 {
                                     locationInfo.Depth = 2;
                                 }
-                                locationInfo.LocationCode = $"R{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
-                                locationInfo.LocationName = $"R{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Column.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
+                                locationInfo.LocationCode = $"{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
+                                locationInfo.LocationName = $"{initializationLocationDTO.Roadway.ToString().PadLeft(2, '0')}宸烽亾{locationInfo.Row.ToString().PadLeft(3, '0')}琛寋locationInfo.Column.ToString().PadLeft(3, '0')}鍒梴locationInfo.Layer.ToString().PadLeft(3, '0')}灞倇locationInfo.Depth.ToString().PadLeft(2, '0')}娣�";
                             }
 
                             locationInfos.Add(locationInfo);
@@ -255,6 +263,94 @@
             }
         }
 
+
+                /// <summary>
+        /// 鑾峰彇涓嶅悓娣卞害鐨勫悓缁勮揣浣嶄俊鎭�
+        /// </summary>
+        /// <param name="location"></param>
+        /// <returns></returns>
+        public List<Dt_LocationInfo> GetGroupLocations(Dt_LocationInfo location)
+        {
+            List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => x.RoadwayNo == location.RoadwayNo && x.WarehouseId == location.WarehouseId);
+
+            List<Dt_LocationInfo> groupLocations = new List<Dt_LocationInfo>() { location };
+            int maxDepth = locationInfos.Max(x => x.Depth);
+            int row = location.Row;
+            for (int j = location.Depth + 1; j <= maxDepth; j++)
+            {
+                Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.Depth == j && x.Column == location.Column && x.Layer == location.Layer && (x.Row == row + 1 || x.Row == row - 1));
+                if (locationInfo != null)
+                {
+                    groupLocations.Add(locationInfo);
+                }
+            }
+
+            for (int j = location.Depth - 1; j >= 1; j--)
+            {
+                Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.Depth == j && x.Column == location.Column && x.Layer == location.Layer && (x.Row == row + 1 || x.Row == row - 1));
+                if (locationInfo != null)
+                {
+                    groupLocations.Add(locationInfo);
+                }
+            }
+            return groupLocations;
+        }
+        /// <summary>
+        /// 璐т綅閲婃斁
+        /// </summary>
+        /// <param name="locationCodes"></param>
+        /// <returns></returns>
+        public WebResponseContent LocationRelease(List<string> locationCodes)
+        {
+            try
+            {
+                if (locationCodes == null || locationCodes.Count == 0)
+                {
+                    return WebResponseContent.Instance.Error("璇锋彁渚涜揣浣嶇紪鐮�");
+                }
+
+                List<Dt_LocationInfo> locationInfos = BaseDal.GetLocationInfos(locationCodes);
+                var matchedCodes = locationInfos.Select(x => x.LocationCode).ToList();
+                var unmatchedCode = locationCodes.Except(matchedCodes).ToList();
+
+                if (unmatchedCode.Any())
+                {
+                    return WebResponseContent.Instance.Error($"浠ヤ笅璐т綅缂栧彿{string.Join(",", unmatchedCode)}鏈壘鍒拌揣浣嶄俊鎭�");
+                }
+
+                foreach (var x in locationInfos)
+                {
+                    if (x.EnableStatus == EnableStatusEnum.Disable.ObjToInt()|| x.EnableStatus == LocationStatusEnum.InStock.ObjToInt())
+                    {
+                        return WebResponseContent.Instance.OK($"璐т綅閲婃斁鎿嶄綔宸茬粓姝�,璇ヨ揣浣峽x.LocationCode}宸茬鐢ㄦ垨澶勪簬鏈夎揣鐘舵��");
+                    }
+
+                    if (x.LocationStatus == LocationStatusEnum.Lock.ObjToInt())
+                    {
+                        Dt_ReturnOrder returnOrder = BaseDal.Db.Queryable<Dt_ReturnOrder>()
+                            .Where(y => y.LocationCode == x.LocationCode && y.OrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                            .First();
+
+                        if (returnOrder != null)
+                        {
+                            continue;
+                        }
+                        else
+                        {
+                            x.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+                        }
+                    }
+                }
+
+                Repository.UpdateData(locationInfos);
+                return WebResponseContent.Instance.OK("璐т綅閲婃斁鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
         public class LocationCache
         {
             public string LocationCode { get; set; }

--
Gitblit v1.9.3