From b593c2d4ada3244f4a256ca18a23c3fef609f234 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期日, 18 一月 2026 17:31:48 +0800
Subject: [PATCH] 最新

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   97 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 73 insertions(+), 24 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index f6716a1..f4d430c 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -18,6 +18,7 @@
 using AutoMapper;
 using Microsoft.Extensions.Logging;
 using Org.BouncyCastle.Math.EC;
+using SixLabors.ImageSharp;
 using SqlSugar;
 using System.ComponentModel;
 using System.Net;
@@ -129,8 +130,8 @@
                 switch (wcsTaskType)
                 {
                     case 1:
-                        
-                        if(task.TargetAddress == "")
+
+                        if (string.IsNullOrEmpty(task.TargetAddress))
                         {
                             int loctype = 0;
                             if (task.Roadway == "1" || task.Roadway == "2")
@@ -149,8 +150,16 @@
                             if (ShallowCargoHold == null) return content.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{dt_Location.LocationCode}鐨勬祬璐т綅");
                             if (ShallowCargoHold.LocationStatus != (int)LocationStatusEnum.Free) return content.Error($"浠诲姟鍙凤細{task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},鏌ユ壘鐨勮揣浣嶆祬璐т綅鏈夎揣锛岃揣浣嶇紪鍙凤細{ShallowCargoHold.LocationCode}");
 
+                            if (task.PalletCode[0] == 1 && (dt_Location.RoadwayNo == "1" || dt_Location.RoadwayNo == "2") && dt_Location.Column < 4)
+                            {
+                                return content.Error($"鏉$爜涓洪珮鎵樼洏锛屼絾鏄煡鎵剧殑璐т綅瑕佸叆鍦ㄤ綆鎵樼洏涓嬶紝鏁呴殰,鎵樼洏鏉$爜锛歿task.PalletCode},璐т綅缂栧彿:{dt_Location.LocationCode}");
+                            }
+
+
+                            Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(task.Roadway);
+
                             task.TargetAddress = dt_Location.LocationCode;
-                            task.CurrentAddress = task.NextAddress;
+                            task.CurrentAddress = _Roadwayinfo.InSCStationCode;
                             task.NextAddress = dt_Location.LocationCode;
                             task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
 
@@ -174,6 +183,8 @@
                         }
                         else
                         {
+                            //鍒ゆ柇鏄惁鏈夎绔欏彴
+
                             string Resultplc = MesInTaskStatusEnum.鍏ュ簱瀹屾垚.GetDescription();
                             MES_parameter mES_PCLParameter = InStoreDocCallback(task.TaskNum, Resultplc, "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
                             if (mES_PCLParameter.Result == "Y")
@@ -193,7 +204,7 @@
                         string Resultsc = MesInTaskStatusEnum.鍏ュ簱瀹屾垚.GetDescription();
                         //涓婃姤MES浠诲姟瀹屾垚
                         MES_parameter mES_Parameter = InStoreDocCallback(task.TaskNum, Resultsc, "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
-                        if (mES_Parameter.Result == "Y")
+                        if (mES_Parameter.Result != "Y")
                         {
                             Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
                             Dt_LocationInfo dt_LocationInfo=_locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
@@ -235,7 +246,7 @@
                         string Resultplc = MesOutTaskStatusEnum.鍒拌揪鐩殑鍦�.GetDescription();
                         //涓婃姤MES浠诲姟瀹屾垚
                         MES_parameter mES_Parameter = OutStoreDocCallback(task.TaskNum, Resultplc, "鎿嶄綔鎴愬姛");
-                        if (mES_Parameter.Result == "Y")
+                        if (mES_Parameter.Result != "Y")
                         {
                             task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
                             BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
@@ -254,15 +265,24 @@
 
                         Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
                         Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
+                        dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Free;
 
-                        _unitOfWorkManage.BeginTran();
-                        _stockInfoService.DeleteData(dt_Stockowc);
-                        _locationInfoService.DeleteData(dt_LocationInfo);
-                        BaseDal.UpdateData(task);
-                        _unitOfWorkManage.CommitTran();
-
-
-                        return content.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+                        string Result = MesOutTaskStatusEnum.鍑哄簱瀹屾垚.GetDescription();
+                        //璋冨彇涓婃父绯荤粺鍙嶉寮�濮嬩换鍔�
+                        MES_parameter mES_SCParameter = OutStoreDocCallback(task.TaskNum, Result, "鎿嶄綔鎴愬姛");
+                        if (mES_SCParameter.Result != "Y")
+                        {
+                            _unitOfWorkManage.BeginTran();
+                            _stockInfoService.DeleteData(dt_Stockowc);
+                            _locationInfoService.UpdateData(dt_LocationInfo);
+                            BaseDal.UpdateData(task);
+                            _unitOfWorkManage.CommitTran();
+                            return content.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+                        }
+                        else
+                        {
+                            return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_SCParameter.ResultMsg);
+                        }
                     default:
                         return content.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
                 }
@@ -277,24 +297,53 @@
         private WebResponseContent HandleRelocationTask(Dt_Task task, int wcsTaskType)
         {
             WebResponseContent responseContent = new WebResponseContent();
-            if (wcsTaskType == 2)
+            try
             {
-                //涓婃姤MES鍫嗗灈鏈虹Щ搴撲换鍔�
-                string Resultplc = MesOutTaskStatusEnum.鍒拌揪鐩殑鍦�.GetDescription();
-                //涓婃姤MES浠诲姟瀹屾垚
-                MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
-                if (mES_Parameter.Result == "Y")
+                if (wcsTaskType == 2)
                 {
-                    task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
-                    BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
-                    return WebResponseContent.Instance.OK($"宸叉帴鏀剁Щ搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+                    //涓婃姤MES浠诲姟瀹屾垚
+                    MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
+                    if (mES_Parameter.Result == "Y")
+                    {
+                        Dt_LocationInfo OriginalLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.SourceAddress).FirstOrDefault();
+                        Dt_LocationInfo NewLocation = _locationInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault();
+                        Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.LocationCode == task.TargetAddress).FirstOrDefault();
+
+                        List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>();
+
+                        OriginalLocation.LocationStatus = (int)LocationStatusEnum.Free;
+                        NewLocation.LocationStatus = (int)LocationStatusEnum.InStock;
+                        dt_StockInfo.LocationCode = NewLocation.LocationCode;
+                        dt_StockInfo.StockStatus = (int)StockStatusEmun.宸插叆搴�;
+                        task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
+
+                        dt_Locations.Add(OriginalLocation);
+                        dt_Locations.Add(NewLocation);
+
+                        _unitOfWorkManage.BeginTran();
+                        _locationInfoService.UpdateData(dt_Locations);
+                        _stockInfoService.UpdateData(dt_StockInfo);
+                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+                        _unitOfWorkManage.CommitTran();
+
+                        return WebResponseContent.Instance.OK($"宸叉帴鏀剁Щ搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+                    }
+                    else
+                    {
+                        return responseContent.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+                    }
                 }
                 else
                 {
-                    return responseContent.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+                    return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
                 }
             }
-            return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                return WebResponseContent.Instance.Error($"WMS绯荤粺閿欒锛屽師鍥狅細{ex.Message}");
+            }
+            
         }
 
 

--
Gitblit v1.9.3