From f2392d984123a1402d6c9bab9e5452c7becc8d22 Mon Sep 17 00:00:00 2001
From: 雷神教育集团 <2244205553@qq.com>
Date: 星期五, 06 三月 2026 09:10:48 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhiHuiQiCe/LongDeLiLiKu

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs |  180 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 142 insertions(+), 38 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
index f018f52..7938b29 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Reloaction.cs"
@@ -132,84 +132,188 @@
         //}
         public WebResponseContent RelocationTaskCompleted(Dt_Task task)
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
-                if (stockInfo == null)
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId);
+                if (warehouse.WarehouseCode == WarehouseEnum.LLDCP.ToString() || warehouse.WarehouseCode == WarehouseEnum.LLDFL.ToString()) //鎴愬搧/杈呮枡瀹屾垚
                 {
-                    return WebResponseContent.Instance.Error($"鏈壘鍒板搴旇揣浣嶇殑搴撳瓨淇℃伅");
+                    Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode && x.LocationCode == task.SourceAddress).Includes(x => x.proStockInfoDetails).First();
+                    if (proStockInfo == null)
+                    {
+                        return content.Error($"鏈壘鍒板搴旂殑搴撳瓨淇℃伅");
+                    }
+                    Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+                    if (locationInfoStart == null)
+                    {
+                        return content.Error($"鏈壘鍒板搴旂殑璧风偣璐т綅淇℃伅");
+                    }
+                    Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+                    if (locationInfoEnd == null)
+                    {
+                        return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+                    }
+                    task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+                    _unitOfWorkManage.BeginTran();
+                    proStockInfo.LocationCode = locationInfoEnd.LocationCode;
+                    proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                    _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
+                    _basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, proStockInfo.PalletType, LocationStatusEnum.Free, proStockInfo.WarehouseId);
+                    _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId);
+                    BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+                    _unitOfWorkManage.CommitTran();
                 }
+                else
+                {
+                    Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode && x.LocationCode == task.SourceAddress);
+                    if (stockInfo == null)
+                    {
+                        return content.Error($"鏈壘鍒板搴旂殑搴撳瓨淇℃伅");
+                    }
 
-                Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
-                if (locationInfoStart == null)
-                {
-                    return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑璧风偣璐т綅淇℃伅");
-                }
+                    Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+                    if (locationInfoStart == null)
+                    {
+                        return content.Error($"鏈壘鍒板搴旂殑璧风偣璐т綅淇℃伅");
+                    }
 
-                Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
-                if (locationInfoEnd == null)
-                {
-                    return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+                    Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+                    if (locationInfoEnd == null)
+                    {
+                        return content.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();
                 }
-                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();
-                return WebResponseContent.Instance.OK();
+                content.OK();
             }
             catch (Exception ex)
             {
                 _unitOfWorkManage.RollbackTran();
-                return WebResponseContent.Instance.Error(ex.Message);
+                return content.Error(ex.Message);
             }
+            return content;
         }
-        public WebResponseContent IsRelocation(string startAddress,string endAddress,string roadWay)
+        /// <summary>
+        /// 绉诲簱
+        /// </summary>
+        /// <param name="startAddress"></param>
+        /// <param name="endAddress"></param>
+        /// <param name="roadWay"></param>
+        /// <returns></returns>
+        public WebResponseContent IsRelocation(RelocationDTO relocation)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
                 //鑾峰彇璐т綅
-                Dt_LocationInfo startLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == startAddress);
-                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.LocationCode == startAddress);
-                Dt_LocationInfo endLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == endAddress);
-                //鍒ゆ柇鏉′欢
-                if (startLocationInfo != null && startLocationInfo.LocationStatus==LocationStatusEnum.InStock.ObjToInt() && endLocationInfo != null && endLocationInfo.LocationStatus==LocationStatusEnum.Free.ObjToInt() && endLocationInfo.EnableStatus==EnableStatusEnum.Normal.ObjToInt() && stockInfo!=null)
+                Dt_LocationInfo startLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.Row == relocation.StartRow && x.Columns == relocation.StartColumn && x.Layer == relocation.StartLayer && x.RoadwayNo == relocation.RoadWay);
+                Dt_LocationInfo endLocationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.Row == relocation.TargetRow && x.Columns == relocation.TargetColumn && x.Layer == relocation.TargetLayer && x.RoadwayNo == relocation.RoadWay);
+                if (startLocationInfo==null || endLocationInfo==null)
                 {
+                    return content.Error("璧峰璐т綅鎴栫粓鐐硅揣浣嶄笉瀛樺湪");
+                }
+                //鍒ゆ柇鏉′欢
+                if (startLocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && startLocationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && endLocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt() && endLocationInfo.EnableStatus == EnableStatusEnum.Normal.ObjToInt())
+                {
+                    Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.LocationCode == startLocationInfo.LocationCode);
+                    Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.LocationCode == startLocationInfo.LocationCode);
+                    bool IsCPRoadway = relocation.RoadWay.Contains("CP");
+                    bool IsYLRoadway = relocation.RoadWay.Contains("YL");
+                    if ((IsCPRoadway && proStockInfo==null) || (IsYLRoadway && stockInfo == null))
+                    {
+                        throw new Exception($"鏈壘鍒皗relocation.RoadWay}绉诲簱搴撳瓨");
+                    }
+                    Dt_StockInfo stockInfoEnd = _stockRepository.StockInfoRepository.QueryFirst(x => x.LocationCode == endLocationInfo.LocationCode);
+                    Dt_ProStockInfo proStockEnd = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.LocationCode == endLocationInfo.LocationCode);
+                    if ((IsCPRoadway && proStockEnd != null) || (IsYLRoadway && stockInfoEnd != null))
+                    {
+                        throw new Exception($"{relocation.RoadWay}鐩爣搴撳瓨宸插瓨鍦�");
+                    }
+                    if (relocation.RoadWay.Contains("YLDual"))
+                    {
+                        if (startLocationInfo.LocationType != endLocationInfo.LocationType)
+                        {
+                            throw new Exception($"娣峰悎宸烽亾{relocation.RoadWay}璧峰涓庣洰鏍囪揣浣嶇被鍨嬩笉绗�,璇锋煡鐪嬭揣浣嶇姸鎬�");
+                        }
+                        if (stockInfo.PalletType != endLocationInfo.LocationType)
+                        {
+                            throw new Exception($"娣峰悎宸烽亾{relocation.RoadWay}绉诲簱搴撳瓨涓庣洰鏍囪揣浣嶇被鍨嬩笉绗�,璇锋煡鐪嬭揣浣嶇姸鎬�");
+                        }
+                        if ((relocation.TargetLayer == 7 || relocation.TargetLayer == 8) && stockInfo.CheckThickness>700)
+                        {
+                            throw new Exception($"鐩爣璐т綅闄愰珮700,绉诲簱搴撳瓨楂樺害{stockInfo.CheckThickness}瓒呭嚭");
+                        }
+
+                        if (relocation.TargetColumn >= 7 && relocation.TargetLayer != 7 && relocation.TargetLayer != 8 && endLocationInfo.LocationType==LocationTypeEnum.MediumPallet.ObjToInt())
+                        {
+                            ////鑾峰彇鏇存敼搴撲綅
+                            Dt_LocationInfo? nearLocation1;
+                            Dt_LocationInfo? nearLocation2;
+
+                            nearLocation1 = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && x.Row == endLocationInfo.Row && x.Layer == endLocationInfo.Layer && x.Columns == endLocationInfo.Columns - 1);
+                            nearLocation2 = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus != EnableStatusEnum.Disable.ObjToInt() && x.Row == endLocationInfo.Row && x.Layer == endLocationInfo.Layer && x.Columns == endLocationInfo.Columns + 1);
+                            if (nearLocation1 == null || nearLocation2 == null)
+                            {
+                                throw new Exception($"鐩爣璐т綅{endLocationInfo.LocationCode}涓哄ぇ璐х被鍨�,涓や晶灏忚揣浣嶅瓨鍦ㄥ崰鐢ㄦ垨绂佺敤鐘舵��,璇锋煡鐪嬭揣浣嶇姸鎬�");
+                            }
+                        }
+                    }
+                    else if (relocation.RoadWay.Contains("YL"))
+                    {
+                        if ((endLocationInfo.Columns < 56 && startLocationInfo.Columns>=56) && stockInfo.CheckThickness > 1300)
+                        {
+                            throw new Exception($"绉诲簱璐т綅鐗╂枡楂樺害{stockInfo.CheckThickness}瓒呭嚭1300,鐩爣璐т綅瀛樻斁瑙勫垯瓒呭嚭");
+                        }
+                    }
                     //鐢熸垚浠诲姟
                     Dt_Task newTask = new Dt_Task()
                     {
-                        Roadway = roadWay,
-                        WarehouseId = stockInfo.WarehouseId,
+                        Roadway = relocation.RoadWay,
+                        WarehouseId = IsCPRoadway ? proStockInfo.WarehouseId:stockInfo.WarehouseId,
                         CurrentAddress = startLocationInfo.LocationCode,
                         Grade = 99,
                         NextAddress = endLocationInfo.LocationCode,
                         OrderNo = "",
-                        PalletCode = stockInfo.PalletCode,
-                        PalletType = stockInfo.PalletType,
+                        PalletCode = IsCPRoadway ? proStockInfo.PalletCode : stockInfo.PalletCode,
+                        PalletType = IsCPRoadway ? proStockInfo.PalletType : stockInfo.PalletType,
                         SourceAddress = startLocationInfo.LocationCode,
                         TargetAddress = endLocationInfo.LocationCode,
                         TaskNum = Repository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                         TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(),
                         TaskType = TaskTypeEnum.Relocation.ObjToInt()
                     };
-                    stockInfo.StockStatus = StockStatusEmun.绉诲簱閿佸畾.ObjToInt();
+                    
                     _unitOfWorkManage.BeginTran();
                     Repository.AddData(newTask);
-                    _basicService.LocationInfoService.UpdateLocationStatus(startLocationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
-                    _basicService.LocationInfoService.UpdateLocationStatus(endLocationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
-                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+                    if (!IsCPRoadway)
+                    {
+                        stockInfo.StockStatus = StockStatusEmun.绉诲簱閿佸畾.ObjToInt();
+                        _basicService.LocationInfoService.UpdateLocationStatus(startLocationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
+                        _basicService.LocationInfoService.UpdateLocationStatus(endLocationInfo, stockInfo.PalletType, LocationStatusEnum.Lock, stockInfo.WarehouseId);
+                        _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+                    }
+                    else
+                    {
+                        proStockInfo.StockStatus = StockStatusEmun.绉诲簱閿佸畾.ObjToInt();
+                        _basicService.LocationInfoService.UpdateLocationStatus(startLocationInfo, proStockInfo.PalletType, LocationStatusEnum.Lock, proStockInfo.WarehouseId);
+                        _basicService.LocationInfoService.UpdateLocationStatus(endLocationInfo, proStockInfo.PalletType, LocationStatusEnum.Lock, proStockInfo.WarehouseId);
+                        _stockService.ProStockInfoService.Repository.UpdateData(proStockInfo);
+                    }
                     _unitOfWorkManage.CommitTran();
                     PushTasksToWCS(new List<Dt_Task> { newTask });
                     content.OK("鎴愬姛");
                 }
                 else
                 {
-                    content.Error("搴撳瓨璐т綅淇℃伅涓虹┖");
+                    content.Error("绉诲簱鎴栫洰鏍囪揣浣嶄笉婊¤冻绉诲簱鏉′欢,璇锋煡鐪嬩袱璐т綅鐘舵��");
                 }
             }
             catch (Exception ex)

--
Gitblit v1.9.3