From c4b7483bb96d813e4f2f4bccf8bbfe89f3f9b08c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期日, 29 十二月 2024 10:54:44 +0800
Subject: [PATCH] 更新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs |  101 ++++++++++++++++++++++++++++----------------------
 1 files changed, 57 insertions(+), 44 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
index f071b2d..b7724a4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
@@ -1,10 +1,14 @@
-锘縰sing SqlSugar;
+锘縰sing HslCommunication.WebSocket;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common.LocationEnum;
 using WIDESEA_Core;
+using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
@@ -18,30 +22,22 @@
 {
     public partial class LocationInfoService : ServiceBase<Dt_LocationInfo, ILocationInfoRepository>, ILocationInfoService
     {
+        private readonly IUnitOfWorkManage _unitOfWorkManage;
         private readonly IBasicRepository _basicRepository;
+
         public ILocationInfoRepository Repository => BaseDal;
 
-        public LocationInfoService(ILocationInfoRepository BaseDal, IBasicRepository basicRepository) : base(BaseDal)
+        public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository) : base(BaseDal)
         {
+            _unitOfWorkManage = unitOfWorkManage;
             _basicRepository = basicRepository;
         }
 
-        public override WebResponseContent AddData(SaveModel saveModel)
-        {
-            Dt_LocationInfo locationInfo = saveModel.MainData.DicToModel<Dt_LocationInfo>();
-            return base.AddData(locationInfo);
-        }
-
-        public override WebResponseContent UpdateData(SaveModel saveModel)
-        {
-            return base.UpdateData(saveModel);
-        }
-
-        public override WebResponseContent DeleteData(object[] keys)
-        {
-            return base.DeleteData(keys);
-        }
-
+        /// <summary>
+        /// 鎵归噺鍚敤璐т綅
+        /// </summary>
+        /// <param name="keys">璐т綅涓婚敭鏁扮粍</param>
+        /// <returns></returns>
         public WebResponseContent LocationEnableStatus(int[] keys)
         {
             List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => keys.Contains(x.Id));
@@ -54,6 +50,11 @@
             return WebResponseContent.Instance.OK();
         }
 
+        /// <summary>
+        /// 鎵归噺绂佺敤璐т綅
+        /// </summary>
+        /// <param name="keys">璐т綅涓婚敭鏁扮粍</param>
+        /// <returns></returns>
         public WebResponseContent LocationDisableStatus(int[] keys)
         {
             List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => keys.Contains(x.Id));
@@ -66,16 +67,31 @@
             return WebResponseContent.Instance.OK();
         }
 
+        /// <summary>
+        /// 鍗曚釜鍚敤璐т綅
+        /// </summary>
+        /// <param name="key">璐т綅涓婚敭</param>
+        /// <returns></returns>
         public WebResponseContent LocationEnableStatus(int key)
         {
             return LocationEnableStatus(new int[] { key });
         }
 
+        /// <summary>
+        /// 鍗曚釜绂佺敤璐т綅
+        /// </summary>
+        /// <param name="key">璐т綅涓婚敭</param>
+        /// <returns></returns>
         public WebResponseContent LocationDisableStatus(int key)
         {
             return LocationDisableStatus(new int[] { key });
         }
 
+        /// <summary>
+        /// 鍒濆鍖栬揣浣�
+        /// </summary>
+        /// <param name="initializationLocationDTO"></param>
+        /// <returns></returns>
         public WebResponseContent InitializationLocation(InitializationLocationDTO initializationLocationDTO)
         {
             try
@@ -83,51 +99,48 @@
                 (bool, string, object?) result = ModelValidate.ValidateModelData(initializationLocationDTO);
                 if (!result.Item1) return WebResponseContent.Instance.Error(result.Item2);
 
-                int side = 1;
+                int depth = initializationLocationDTO.Depth;
                 List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
                 for (int i = 0; i < initializationLocationDTO.MaxRow; i++)
                 {
+                    if ((i + 1) % initializationLocationDTO.MaxRow == 1)
+                    {
+                        depth = initializationLocationDTO.Depth;
+                    }
+                    else if ((i + 1) % initializationLocationDTO.MaxRow == initializationLocationDTO.Depth + 1)
+                    {
+                        depth = 1;
+                    }
+                    else if ((i + 1) % initializationLocationDTO.MaxRow > 1 && (i + 1) % initializationLocationDTO.MaxRow <= initializationLocationDTO.Depth)
+                    {
+                        depth -= 1;
+                    }
+                    else
+                    {
+                        depth += 1;
+                    }
                     for (int j = 0; j < initializationLocationDTO.MaxColumn; j++)
                     {
                         for (int k = 0; k < initializationLocationDTO.MaxLayer; k++)
                         {
                             Dt_LocationInfo locationInfo = new Dt_LocationInfo()
                             {
-                                AreaId = 0,
+                                WarehouseId = 0,
                                 Column = j + 1,
                                 EnableStatus = EnableStatusEnum.Normal.ObjToInt(),
                                 Layer = k + 1,
                                 LocationStatus = LocationStatusEnum.Free.ObjToInt(),
-                                LocationType = LocationTypeEnum.Cube.ObjToInt(),
-                                RoadwayNo = initializationLocationDTO.Roadway,
+                                LocationType = LocationTypeEnum.Undefined.ObjToInt(),
+                                RoadwayNo = $"{initializationLocationDTO.Roadway.ToString()}",
                                 Row = i + 1,
+                                Depth = depth,
                             };
-
-                            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')}娣�";
-                            }
-                            else
-                            {
-                                if (initializationLocationDTO.FirstDepthRows.Contains(i + 1))
-                                {
-                                    locationInfo.Depth = 1;
-                                }
-                                else
-                                {
-                                    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 = $"{locationInfo.RoadwayNo}-{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 = $"{locationInfo.RoadwayNo}宸烽亾{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);
                         }
                     }
                 }
-
                 BaseDal.AddData(locationInfos);
                 return WebResponseContent.Instance.OK();
             }

--
Gitblit v1.9.3