From b489f865bab00bedfce5e8f772095600b8034ac0 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 23 九月 2025 03:03:20 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Reloaction.cs |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 112 insertions(+), 4 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Reloaction.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
index b1ed752..b58fb65 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
@@ -10,6 +10,7 @@
 using WIDESEA_Common.TaskEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Basic;
 using WIDESEA_DTO.Task;
 using WIDESEA_Model.Models;
 
@@ -49,7 +50,7 @@
                 }
                 else
                 {
-                    Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == needRelocationItem.LocationCode);
+                    Dt_StockInfo stockInfo = _stockService.StockInfoService.Db.Queryable<Dt_StockInfo>().Where(x => x.LocationCode == needRelocationItem.LocationCode).Includes(x => x.Details).First();
                     if (stockInfo == null)
                     {
                         return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇揣浣嶇殑搴撳瓨淇℃伅");
@@ -61,7 +62,21 @@
                         return WebResponseContent.Instance.OK(data: _mapper.Map<WMSTaskDTO>(taskTemp));
                     }
 
-                    Dt_LocationInfo? newLocation = _basicService.LocationInfoService.AssignLocation(needRelocationItem.RoadwayNo, task.PalletType, task.WarehouseId);
+                    int heightType = 0;
+                    if(needRelocationItem.Layer == 5)
+                    {
+                        heightType = 2;
+                    }
+                    //else if(needRelocationItem.Layer == 4)
+                    //{
+                    //    heightType = 2;
+                    //}
+                    else if(needRelocationItem.Layer <= 4 && needRelocationItem.Layer >= 1)
+                    {
+                        heightType = 1;
+                    }
+
+                    Dt_LocationInfo? newLocation = _basicService.LocationInfoService.AssignLocation(needRelocationItem.RoadwayNo, stockInfo.PalletType, task.WarehouseId, needRelocationItem.LocationCode, heightType);
                     if (newLocation != null)
                     {
                         Dt_Task newTask = new Dt_Task()
@@ -78,9 +93,21 @@
                             TargetAddress = newLocation.LocationCode,
                             TaskNum = Repository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                             TaskStatus = 0,
-                            TaskType = 0
+                            TaskType = TaskTypeEnum.Relocation.ObjToInt()
                         };
-
+                        string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                        float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                        string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo;
+                        if (MaterielCode != null && Quantity != null && BatchNo != null)
+                        {
+                            newTask.MaterielCode = MaterielCode;
+                            newTask.Quantity = Quantity;
+                            newTask.BatchNo = BatchNo;
+                        }
+                        if (stockInfo.StockLength>0)
+                        {
+                            newTask.TaskLength = stockInfo.StockLength;
+                        }
                         _unitOfWorkManage.BeginTran();
                         Repository.AddData(newTask);
                         {
@@ -112,6 +139,84 @@
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
+        /// <summary>
+        /// 鎵嬪姩绉诲簱
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent ManualRelocation(RelocationDTO relocationDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == relocationDTO.warehouseId);
+                if (warehouse == null)
+                {
+                    return content.Error($"鏈壘鍒板搴旂殑{relocationDTO.warehouseId}浠撳簱淇℃伅");
+                }
+                Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == relocationDTO.locationStart && x.WarehouseId== warehouse.WarehouseId && x.RoadwayNo == relocationDTO.locationRoadway && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt());
+                Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == relocationDTO.locationEnd && x.WarehouseId == warehouse.WarehouseId && x.RoadwayNo== relocationDTO.locationRoadway && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus==EnableStatusEnum.Normal.ObjToInt());
+                if (locationInfoStart == null || locationInfoEnd==null)
+                {
+                    return content.Error($"鏈壘鍒板搴旂殑璐т綅淇℃伅鎴栬捣鐐瑰強缁堢偣璐т綅鏉′欢涓嶆弧瓒�");
+                }
+                if (locationInfoStart.Column!= locationInfoEnd.Column || locationInfoStart.Layer != locationInfoEnd.Layer || locationInfoStart.Depth>= locationInfoEnd.Depth)
+                {
+                    return content.Error($"璧风偣鍜岀粓鐐圭Щ搴撹揣浣嶉渶瑕佹弧瓒冲悓鍒楀悓灞傜粓鐐硅揣浣嶆繁浣嶉渶瑕佸ぇ浜庤捣鐐硅揣浣�");
+                }
+                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == locationInfoStart.LocationCode);
+                if (stockInfo == null)
+                {
+                    return content.Error($"鏈壘鍒板搴旇揣浣嶇殑搴撳瓨淇℃伅");
+                }
+
+                Dt_Task taskTemp = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+                if (taskTemp != null)
+                {
+                    return content.Error($"鎵樼洏{stockInfo.PalletCode}浠诲姟宸插瓨鍦�");
+                }
+                Dt_Task newTask = new Dt_Task()
+                {
+                    Roadway = locationInfoStart.RoadwayNo,
+                    WarehouseId = locationInfoStart.WarehouseId,
+                    CurrentAddress = locationInfoStart.LocationCode,
+                    Grade = 99,
+                    NextAddress = locationInfoEnd.LocationCode,
+                    OrderNo = "",
+                    PalletCode = stockInfo.PalletCode,
+                    PalletType = stockInfo.PalletType,
+                    SourceAddress = locationInfoStart.LocationCode,
+                    TargetAddress = locationInfoEnd.LocationCode,
+                    TaskNum = Repository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(),
+                    TaskType = TaskTypeEnum.Relocation.ObjToInt()
+                };
+
+                if (stockInfo.StockLength > 0)
+                {
+                    newTask.TaskLength = stockInfo.StockLength;
+                }
+                _unitOfWorkManage.BeginTran();
+                Repository.AddData(newTask);
+                LocationStatusEnum lastStatusEnd = (LocationStatusEnum)locationInfoEnd.LocationStatus;
+                _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, newTask.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoEnd, lastStatusEnd, LocationStatusEnum.Lock, LocationChangeType.RelocationAssignLocation, taskNum: newTask.TaskNum);
+
+                LocationStatusEnum lastStatusStart = (LocationStatusEnum)locationInfoStart.LocationStatus;
+                _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, newTask.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoStart, lastStatusStart, LocationStatusEnum.Lock, LocationChangeType.RelocationAssignLocation, taskNum: newTask.TaskNum);
+                stockInfo.StockStatus = StockStatusEmun.绉诲簱閿佸畾.ObjToInt();
+                _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+                _unitOfWorkManage.CommitTran();
+                //鎺ㄩ�佷换鍔�
+                PushTasksToWCS(new List<Dt_Task> { newTask });
+                return content.OK(data: _mapper.Map<WMSTaskDTO>(newTask));
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                return content.Error(ex.Message);
+            }
+        }
 
         public WebResponseContent RelocationTaskCompleted(Dt_Task task)
         {
@@ -135,13 +240,16 @@
                     return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
                 }
                 task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+                
                 _unitOfWorkManage.BeginTran();
                 stockInfo.LocationCode = locationInfoEnd.LocationCode;
+                stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                 _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                 _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
                 _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
                 BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
                 _unitOfWorkManage.CommitTran();
+                FeedBackWCSTaskCompleted(task.TaskNum);
                 return WebResponseContent.Instance.OK();
             }
             catch (Exception ex)

--
Gitblit v1.9.3