From 827880621d3d78b0c075c37751eeaab2fe1925b3 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期四, 26 十二月 2024 17:09:41 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs   |   63 ++++++++++++
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs                     |    8 +
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs                     |    2 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs                                |   14 ++
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs |    4 
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs                      |   94 ++++++++++++++++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs                                         |    7 +
 Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js                                                                |   12 ++
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs                        |   22 ++++
 Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx                           |   18 +++
 10 files changed, 234 insertions(+), 10 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index cf9d722..0bcc2a8 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -562,6 +562,13 @@
                     }
                     else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish)
                     {
+                        if (App.User.UserId > 0)
+                        {
+                            content = StackCraneTaskCompleted(task.TaskNum);
+                            return content;
+                        }
+
+
                         task.ModifyDate = DateTime.Now;
                         task.Modifier = "System";
 
diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js b/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js
index a9ded9d..7e2d3a4 100644
--- a/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js
+++ b/Code Management/WMS/WIDESEA_WMSClient/src/api/buttons.js
@@ -108,7 +108,7 @@
     // icon: 'el-icon-printer',
     type: 'primary',
     // plain: true,
-    color: '#529b2e',
+    // color: '#529b2e',
     value: 'TaskHandComplete',
     onClick: function () {
       
@@ -118,11 +118,19 @@
     // icon: 'el-icon-printer',
     type: 'primary',
     // plain: true,
-    color: '#529b2e',
+    // color: '#529b2e',
     value: 'OutBound',
     onClick: function () {
       
     }
+  },{
+    name: '鍒濆鍖栧簱浣�',
+    type: 'primary',
+    // color: '#529b2e',
+    value: 'initializeLocation',
+    onClick: function () {
+      
+    }
   }
 ]
 
diff --git a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx
index 981f67d..a9dcf94 100644
--- a/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx
+++ b/Code Management/WMS/WIDESEA_WMSClient/src/extension/widesea_wms/basicinfo/Dt_LocationInfo.jsx
@@ -33,6 +33,24 @@
         //       this.$Message.success('鐐瑰嚮浜嗘寜閽�');
         //     }
         //   });
+        var btninitializeLocation = this.buttons.find(x => x.value == "initializeLocation");
+        if (btninitializeLocation != null) {
+            btninitializeLocation.onClick = () => {
+                let rows = this.$refs.table.getSelected();
+                if (rows.length == 0) return this.$error("璇烽�夋嫨鏁版嵁!");
+                this.http
+                    .post("api/LocationInfo/initializeLocation?locationID="+rows[0].id, "","鏁版嵁澶勭悊涓�...")
+                    .then((x) => {
+                        if (x.status) {
+                            this.$Message.success('鎴愬姛.');
+                            this.refresh();
+                        } else {
+                            return this.$error(x.message);
+                        }
+                    });
+            }
+        }
+
         var btnEnableLocation = this.buttons.find(x => x.value == "EnableLocation");
             if (btnEnableLocation != null) {
                 btnEnableLocation.onClick = () => {
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs
index 70da6b7..9755f1d 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicRepository/Location/ILocationStatusChangeRecordRepository.cs
@@ -10,4 +10,8 @@
     /// <param name="changeRecordDto">鏁版嵁妯″瀷</param>
     /// <returns></returns>
     bool AddStatusChangeRecord(LocationChangeRecordDto changeRecordDto);
+
+    void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum);
+
+    void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums);
 }
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs
index 30134d3..316fa99 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStorageBasicService/Location/ILocationInfoService.cs
@@ -11,5 +11,7 @@
     /// <returns>浠诲姟瀵硅薄</returns>
     Task<Dt_Task> TransferCheckAsync(int taskNum);
 
+    Task<WebResponseContent> initializeLocation(int locationID);
+
     WebResponseContent CreateLocation(int x, int y, int z, int locType, int areaId);
 }
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
index 3221528..f91b37d 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
@@ -1,4 +1,6 @@
-锘縰sing WIDESEA_DTO;
+锘縰sing WIDESEA_Core;
+using WIDESEA_DTO;
+using WIDESEA_Model.Models;
 
 namespace WIDESEA_StorageBasicRepository
 {
@@ -27,5 +29,64 @@
             };
             return AddData(dtLocationStatusChangeRecord) > 0;
         }
+        /// <summary>
+        /// 娣诲姞璐т綅鍙樺姩璁板綍
+        /// </summary>
+        /// <param name="locationInfo">鏇存柊瀹炰綋</param>
+        /// <param name="lastStatus">鍙樺姩鍓嶇姸鎬�</param>
+        /// <param name="changeType">鍙樺姩绫诲瀷</param>
+        /// <param name="taskNum">浠诲姟鍙�</param>
+        /// <exception cref="Exception"></exception>
+        public void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum)
+        {
+            try
+            {
+                DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
+                {
+                    AfterStatus = locationInfo.LocationStatus,
+                    BeforeStatus = lastStatus,
+                    ChangeType = changeType,
+                    LocationCode = locationInfo.LocationCode,
+                    LocationId = locationInfo.Id,
+                    TaskNum = taskNum,
+                    Creater = "System",
+                    CreateDate = DateTime.Now,
+                };
+
+                base.AddData(locationStatusChangeRecord);
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"{ex.Message}");
+            }
+        }
+
+        public void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums)
+        {
+            try
+            {
+                List<DtLocationStatusChangeRecord> records = new List<DtLocationStatusChangeRecord>();
+                for (int i = 0; i < locationInfos.Count; i++)
+                {
+                    DtLocationInfo locationInfo = locationInfos[i];
+                    int? taskNum = (taskNums != null && taskNums.Count > 0 && taskNums.Count == locationInfos.Count) ? taskNums[i] : null;
+                    DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
+                    {
+                        AfterStatus = newStatus,
+                        BeforeStatus = locationInfo.LocationStatus,
+                        ChangeType = changeType,
+                        LocationCode = locationInfo.LocationCode,
+                        LocationId = locationInfo.Id,
+                        TaskNum = taskNum,
+                    };
+                    records.Add(locationStatusChangeRecord);
+                }
+                AddData(records);
+            }
+            catch (Exception ex)
+            {
+                throw new Exception($"{ex.Message}");
+            }
+        }
     }
 }
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
index 587b9ad..3d56886 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs
@@ -1,5 +1,10 @@
-锘縰sing WIDESEA_Common;
+锘縰sing AngleSharp.Dom;
+using Mapster;
+using System.Threading.Tasks;
+using WIDESEA_Common;
+using WIDESEA_Core;
 using WIDESEA_DTO;
+using WIDESEA_Model.Models;
 
 namespace WIDESEA_StorageBasicService;
 
@@ -8,11 +13,14 @@
     private readonly LogFactory LogFactory = new LogFactory();
     private readonly IUnitOfWorkManage _unitOfWorkManage;
     private readonly IDt_TaskRepository _taskRepository;
+    private readonly IDt_TaskService _taskService;
     private readonly IStockInfoRepository _stockInfoRepository;
+    private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
     private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository;
     private readonly IPointStackerRelationRepository _pointStackerRelationRepository;
     private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
     private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
+    private readonly IMapper _mapper;
 
     public LocationInfoService(ILocationInfoRepository BaseDal,
                                     IUnitOfWorkManage unitOfWorkManage,
@@ -21,7 +29,10 @@
                                     IDt_WareAreaInfoRepository wareAreaInfoRepository,
                                     IPointStackerRelationRepository pointStackerRelationRepository,
                                     ITaskExecuteDetailRepository taskExecuteDetailRepository,
-                                    ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
+                                    ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository,
+                                    IStockInfoDetailRepository stockInfoDetailRepository,
+                                    IMapper mapper,
+                                    IDt_TaskService taskService) : base(BaseDal)
     {
         _unitOfWorkManage = unitOfWorkManage;
         _taskRepository = taskRepository;
@@ -30,6 +41,9 @@
         _pointStackerRelationRepository = pointStackerRelationRepository;
         _taskExecuteDetailRepository = taskExecuteDetailRepository;
         _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
+        _stockInfoDetailRepository = stockInfoDetailRepository;
+        _mapper = mapper;
+        _taskService = taskService;
     }
 
     /// <summary>
@@ -103,6 +117,52 @@
 
         return base.UpdateData(saveModel);
     }
+    #region 鍒濆鍖栧簱浣�
+    public async Task<WebResponseContent> initializeLocation(int locationID)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            DtLocationInfo? location = BaseDal.QueryData(x => x.Id == locationID).FirstOrDefault();
+            int LastStatus = location.LocationStatus;
+            if (location == null)
+            {
+                return content.Error("鏈壘鍒拌揣浣嶄俊鎭�!");
+            }
+            DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id);
+            if(stock == null)
+            {
+                location.LocationStatus= (int)LocationEnum.Lock;
+                BaseDal.UpdateData(location);
+            }
+            else
+            {
+                _unitOfWorkManage.BeginTran();
+                DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
+                stockInfo_Hty.ModifyDate = DateTime.Now;
+                await DeleteStockInfoAsync(stock.Id);
+                List<DtStockInfoDetail> detail = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id).ToList();
+                if (detail != null && detail.Count() > 0)
+                {
+                    await DeleteStockInfoDetailsAsync(detail);
+                }
+                await AddStockInfoHtyAsync(stockInfo_Hty);
+
+                location.LocationStatus = (int)LocationEnum.Lock;
+                BaseDal.UpdateData(location);
+
+                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, LastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0);
+                _unitOfWorkManage.CommitTran();
+            }
+            return content.OK();
+        }
+        catch (Exception ex)
+        {
+            _unitOfWorkManage.RollbackTran();
+            return content.Error(ex.Message);
+        }
+    }
+    #endregion
 
     #region 鍒涘缓鍘熷璐т綅鏁版嵁
 
@@ -325,5 +385,35 @@
 
     #endregion 鍒涘缓鍒濆璐т綅鏂规硶
 
+    #region 搴撳瓨绉诲叆鍘嗗彶
+    private async Task DeleteStockInfoAsync(int stockId)
+    {
+        var isStockUpdated = await _stockInfoRepository.DeleteDataByIdAsync(stockId);
+        if (!isStockUpdated)
+        {
+            throw new Exception("搴撳瓨淇℃伅鏇存柊澶辫触");
+        }
+    }
+
+    private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock)
+    {
+        var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync();
+        if (!isStockAdd)
+        {
+            throw new Exception("搴撳瓨鍘嗗彶淇℃伅娣诲姞澶辫触");
+        }
+    }
+
+    private async Task DeleteStockInfoDetailsAsync(IEnumerable<DtStockInfoDetail> details)
+    {
+        var ids = details.Select(x => (object)x.Id).ToArray();
+        var isStockDetailUpdated = await _stockInfoDetailRepository.DeleteDataByIdsAsync(ids);
+        if (!isStockDetailUpdated)
+        {
+            throw new Exception("搴撳瓨璇︽儏淇℃伅鏇存柊澶辫触");
+        }
+    }
+    #endregion
+
     #endregion 鍐呴儴鏂规硶
 }
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index e9ae1ae..6fe56dc 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,4 +1,5 @@
 锘縰sing AngleSharp.Dom;
+using log4net.Core;
 using Mapster;
 using Masuit.Tools;
 using SixLabors.Fonts.Tables.AdvancedTypographic;
@@ -10,6 +11,7 @@
 using WIDESEA_DTO.WMS;
 using WIDESEA_IServices;
 using WIDESEA_IStoragIntegrationServices;
+using WIDESEA_StorageBasicRepository;
 using WIDESEA_StoragIntegrationServices;
 using WIDESEAWCS_BasicInfoRepository;
 
@@ -268,11 +270,13 @@
     {
         var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway);
         //var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id);
-
+        int lastStatus = location.LocationStatus;
         location.LocationStatus = (int)LocationEnum.Free;
         task.TaskState = (int)TaskOutStatusEnum.OutFinish;
         //task.CurrentAddress = task.NextAddress;
         //task.NextAddress = task.TargetAddress;
+
+        _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery,task.TaskNum);
 
         LogFactory.GetLog("浠诲姟瀹屾垚").Info(true, "鏇存柊搴撳瓨鐘舵�佷笌浠诲姟鐘舵��");
         return (location, task);
@@ -348,7 +352,7 @@
         try
         {
             // 鏇存柊璐т綅鍜屽簱瀛樹俊鎭�
-            (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task);
+           (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task);
             var taskHty = CreateHistoricalTask(task);
             LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "绉诲簱浠诲姟瀹屾垚", $"璐т綅鍦板潃锛歿task.TargetAddress},淇敼鍚庡簱瀛樻暟鎹細{JsonConvert.SerializeObject(updateStock)}锛屽師鍏堣揣浣嶆暟鎹細{locationInForm}");
 
@@ -405,6 +409,7 @@
             var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
             var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress && x.RoadwayNo == task.Roadway);
 
+            int lastStatus = locationInf.LocationStatus;
             // 鏇存柊鐩爣浣嶇疆鐘舵�佷负搴撳瓨涓�
             locationInf.LocationStatus = (int)LocationEnum.InStock;
 
@@ -416,6 +421,10 @@
                 await _locationRepository.UpdateDataAsync(locationInf);
                 await _task_HtyRepository.AddDataAsync(taskHty);
                 await BaseDal.DeleteDataAsync(task);
+
+                //璁板綍璐т綅鍙樺姩淇℃伅
+                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
+
                 return content.OK("鍏ュ簱浠诲姟瀹屾垚鎴愬姛");
             }
             // 鏍规嵁鏄惁鏈夌粍鐩樹俊鎭垱寤哄簱瀛樺疄渚嬫ā鍨�
@@ -425,6 +434,7 @@
             bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId, boxing);
             if (isResult)
             {
+                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
                 content.OK("鍏ュ簱浠诲姟瀹屾垚鎴愬姛");
             }
             else
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 85c1e58..e6b102d 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -387,10 +387,13 @@
             TaskNum = await BaseDal.GetTaskNo(),
             Creater = "Systeam"
         };
-        ConsoleHelper.WriteSuccessLine($"淇敼鍓嶏細" + locationInfo.LocationStatus.ToString());
+        int lastStatus = locationInfo.LocationStatus;
+        ConsoleHelper.WriteSuccessLine($"淇敼鍓嶏細" + lastStatus.ToString());
         locationInfo.LocationStatus = (int)LocationEnum.FreeDisable;
         ConsoleHelper.WriteSuccessLine($"淇敼鍚庯細" + locationInfo.LocationStatus.ToString());
         await UpdateLocationAsync(locationInfo);
+
+        _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
 
         return task;
     }
@@ -672,10 +675,15 @@
 
             var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
 
-            ConsoleHelper.WriteSuccessLine($"淇敼鍓嶏細" + locationInfo.LocationStatus.ToString());
+            int lastStatus = locationInfo.LocationStatus;
+
+            ConsoleHelper.WriteSuccessLine($"淇敼鍓嶏細" + lastStatus.ToString());
             locationInfo.LocationStatus = (int)LocationEnum.FreeDisable;
             ConsoleHelper.WriteSuccessLine($"淇敼鍚庯細" + locationInfo.LocationStatus.ToString());
             await UpdateLocationAsync(locationInfo);
+
+            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum);
+
             return task;
         }
         catch (Exception ex)
@@ -784,10 +792,13 @@
                             var content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                             if (content.Status)
                             {
+                                int lastStatus = item.LocationInfo.LocationStatus;
                                 await BaseDal.AddDataAsync(task);
                                 // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢�
                                 item.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
                                 await _locationRepository.UpdateDataAsync(item.LocationInfo);
+
+                                _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(item.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
                             }
                         }
                     }
@@ -833,6 +844,7 @@
                     WMSTaskDTO wmsTask = CreateTaskDTO(task);
 
                     // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢�
+                    int lastStatus = location.LocationStatus;
                     stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
                     location.LocationStatus = (int)LocationEnum.Distribute;
                     await _unitOfWorkManage.UseTranAsync(async () =>
@@ -841,6 +853,8 @@
                         await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo);
                         await _locationRepository.UpdateDataAsync(location);
                     });
+
+                    _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
 
                     // 杩斿洖鎴愬姛鍝嶅簲
                     return content.OK(data: wmsTask);
@@ -901,10 +915,14 @@
 
             WMSTaskDTO taskDTO = CreateTaskDTO(task);
 
+            int lastStatus = locationInfo.LocationStatus;
+
             BaseDal.AddData(task);
             stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
             _locationRepository.UpdateData(stockInfo.LocationInfo);
 
+            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
+
             return content.OK(data: taskDTO);
         }
         catch (Exception ex)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs
index 7dbcade..627e3e0 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/LocationInfoController.cs
@@ -1,4 +1,5 @@
-锘縰sing WIDESEA_DTO;
+锘縰sing Masuit.Tools.Models;
+using WIDESEA_DTO;
 
 namespace WIDESEA_WMSServer.Controllers;
 
@@ -24,4 +25,9 @@
     {
         return Service.CreateLocation(x, y, z, locType, areaId);
     }
+    [HttpPost, AllowAnonymous, Route("initializeLocation")]
+    public async Task<WebResponseContent> initializeLocation(int locationID)
+    {
+        return await Service.initializeLocation(locationID);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3