From 877d01790a997d4488addf09284efcf98bbd1934 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期二, 19 十一月 2024 10:22:00 +0800
Subject: [PATCH] 修改货位状态

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicService/Base/LocationInfoService.cs |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicService/Base/LocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicService/Base/LocationInfoService.cs"
index fe37263..bd969e6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicService/Base/LocationInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicService/Base/LocationInfoService.cs"
@@ -1,7 +1,9 @@
 锘縰sing SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common.CommonEnum;
@@ -30,7 +32,12 @@
 
         public override WebResponseContent AddData(SaveModel saveModel)
         {
+            saveModel.MainData.Add(nameof(Dt_LocationInfo.EnableStatus), EnableStatusEnum.Normal.ObjToInt());
+            saveModel.MainData.Add(nameof(Dt_LocationInfo.LocationStatus), LocationStatusEnum.Free.ObjToInt());
             Dt_LocationInfo locationInfo = saveModel.MainData.DicToModel<Dt_LocationInfo>();
+            locationInfo.LocationCode = $"R{locationInfo.RoadwayNo.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{locationInfo.RoadwayNo.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')}娣�";
+
             return base.AddData(locationInfo);
         }
 
@@ -78,6 +85,58 @@
             return LocationDisableStatus(new int[] { key });
         }
 
+        public WebResponseContent GetLocationStatusDic()
+        {
+            try
+            {
+                List<object> data = new List<object>();
+                Type type = typeof(LocationStatusEnum);
+                List<int> enums = Enum.GetValues(typeof(LocationStatusEnum)).Cast<int>().ToList();
+                foreach (var item in enums)
+                {
+                    FieldInfo? fieldInfo = typeof(LocationStatusEnum).GetField(((LocationStatusEnum)item).ToString());
+                    if (fieldInfo != null)
+                    {
+                        DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
+                        if (description != null)
+                        {
+                            data.Add(new { value = item.ToString(), label = description.Description });
+                        }
+                        else
+                        {
+                            data.Add(new { value = item.ToString(), label = item.ToString() });
+                        }
+                    }
+                }
+                return WebResponseContent.Instance.OK(data: data);
+            }
+            catch (Exception e)
+            {
+                return WebResponseContent.Instance.Error(e.Message);
+            }
+
+        }
+
+        public WebResponseContent UpdateLocationStatus(int key, int locationStatus)
+        {
+            try
+            {
+                Dt_LocationInfo locationInfo = Repository.QueryFirst(x => x.Id == key);
+                if (locationInfo == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒拌揣浣嶄俊鎭�");
+                }
+                locationInfo.LocationStatus = locationStatus;
+                Repository.UpdateData(locationInfo);
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+
+        }
+
         public WebResponseContent InitializationLocation(InitializationLocationDTO initializationLocationDTO)
         {
             try

--
Gitblit v1.9.3