From d09a1552e45e6cfc8f83c0249cd296b8706c0dc2 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期二, 20 五月 2025 09:33:27 +0800
Subject: [PATCH] 修改下发AGV任务接口,修改条码增加功能

---
 Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs |  286 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 182 insertions(+), 104 deletions(-)

diff --git a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
index 67ed85e..f497068 100644
--- a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -217,7 +217,7 @@
         /// <param name="lotNo">鎵规</param>
         /// <param name="userId">鎿嶄綔浜�</param>
         /// <exception cref="Exception"></exception>
-        public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,string url,int userId)
+        public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,string url, string bindUrl, int userId)
         {
             try
             {
@@ -306,7 +306,7 @@
                     {
                         throw new Exception("鏈壘鍒板搴旀《淇℃伅");
                     }
-                    resultYi = YikuTask(palletModel.PalletNo, taskNo, url);
+                    resultYi = YikuTask(palletModel.PalletNo, taskNo, url,bindUrl);
                 }
                 #endregion
                 //璧峰鍌ㄤ綅鍦板潃淇℃伅
@@ -358,29 +358,41 @@
                     string agvMsg = string.Empty;
                     //缁欎笅杞︿笅鍙戜换鍔�
                     logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                    var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
-                    if (agvResult)//鎴愬姛
+                    //涓嬪彂杞藉叿绫诲瀷
+                    var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, url, out string agvBindMsg);
+                    if (bind)
                     {
-                        //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                        logTaskEntry.IsSuccess = 1;
-                        logTaskEntry.IsSend = 0;
-                        //logTaskEntry.IsCancel = 0;
-                        logTaskEntry.BackDate = DateTime.Now;
-                        logTaskEntry.Status = "1";//姝e湪鎵ц
-                        Db.Insertable(logTaskEntry).ExecuteCommand();
+                        var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+                        if (agvResult)//鎴愬姛
+                        {
+                            //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                            logTaskEntry.IsSuccess = 1;
+                            logTaskEntry.IsSend = 0;
+                            //logTaskEntry.IsCancel = 0;
+                            logTaskEntry.BackDate = DateTime.Now;
+                            logTaskEntry.Status = "1";//姝e湪鎵ц
+                            Db.Insertable(logTaskEntry).ExecuteCommand();
 
-                        startLoction.Status = "3";//鍑哄簱涓�
-                        Db.Updateable(startLoction).ExecuteCommand();
+                            startLoction.Status = "3";//鍑哄簱涓�
+                            Db.Updateable(startLoction).ExecuteCommand();
 
-                        endLocateInfo.Status = "2";//鍏ュ簱涓�
-                        Db.Updateable(endLocateInfo).ExecuteCommand();
+                            endLocateInfo.Status = "2";//鍏ュ簱涓�
+                            Db.Updateable(endLocateInfo).ExecuteCommand();
+                        }
+                        else//澶辫触
+                        {
+                            logTaskEntry.IsSuccess = 0;
+                            logTaskEntry.Information = agvMsg;
+                            Db.Insertable(logTaskEntry).ExecuteCommand();
+                        }
                     }
-                    else//澶辫触
+                    else 
                     {
                         logTaskEntry.IsSuccess = 0;
-                        logTaskEntry.Information = agvMsg;
+                        logTaskEntry.Information = "璐ф灦涓庤揣浣嶇粦瀹氬け璐ワ紝鍘熷洜锛�"+agvBindMsg;
                         Db.Insertable(logTaskEntry).ExecuteCommand();
                     }
+                   
                 }
                 //鎻愪氦浜嬪姟
                 Db.CommitTran();
@@ -405,7 +417,7 @@
         /// <param name="lotNo">鎵规</param>
         /// <param name="userId">鎿嶄綔浜�</param>
         /// <exception cref="Exception"></exception>
-        public void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight,  string skuNo, string lotNo, string url,int userId)
+        public void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight,  string skuNo, string lotNo, string url,string bindUrl,int userId)
         {
             try
             {
@@ -550,29 +562,42 @@
                 string agvMsg = string.Empty;
                 //缁欎笅杞︿笅鍙戜换鍔�
                 logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
-                if (agvResult)//鎴愬姛
+                //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+                var bind = RcsHelper.BindPalletAndSite(plnNo, StartLocate, bindUrl, out string agvBindMsg);
+                if (bind)
                 {
-                    //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                    logTaskEntry.IsSuccess = 1;
-                    logTaskEntry.IsSend = 0;
-                    //logTaskEntry.IsCancel = 0;
-                    logTaskEntry.BackDate = DateTime.Now;
-                    logTaskEntry.Status = "1";//姝e湪鎵ц
-                    Db.Insertable(logTaskEntry).ExecuteCommand();
+                    var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+                    if (agvResult)//鎴愬姛
+                    {
+                        //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                        logTaskEntry.IsSuccess = 1;
+                        logTaskEntry.IsSend = 0;
+                        //logTaskEntry.IsCancel = 0;
+                        logTaskEntry.BackDate = DateTime.Now;
+                        logTaskEntry.Status = "1";//姝e湪鎵ц
+                        Db.Insertable(logTaskEntry).ExecuteCommand();
 
-                    startLoction.Status = "3";//鍑哄簱涓�
-                    Db.Updateable(startLoction).ExecuteCommand();
+                        startLoction.Status = "3";//鍑哄簱涓�
+                        Db.Updateable(startLoction).ExecuteCommand();
 
-                    endLocatInfo.Status = "2";//鍏ュ簱涓�
-                    Db.Updateable(endLocatInfo).ExecuteCommand();
+                        endLocatInfo.Status = "2";//鍏ュ簱涓�
+                        Db.Updateable(endLocatInfo).ExecuteCommand();
+                    }
+                    else//澶辫触
+                    {
+                        logTaskEntry.IsSuccess = 0;
+                        logTaskEntry.Information = agvMsg;
+                        Db.Insertable(logTaskEntry).ExecuteCommand();
+                    }
+
                 }
-                else//澶辫触
+                else
                 {
                     logTaskEntry.IsSuccess = 0;
-                    logTaskEntry.Information = agvMsg;
+                    logTaskEntry.Information = "璐ф灦涓庤揣浣嶇粦瀹氬け璐ワ紝鍘熷洜锛�"+agvBindMsg;
                     Db.Insertable(logTaskEntry).ExecuteCommand();
                 }
+                
 
                 //鎻愪氦浜嬪姟
                 Db.CommitTran();
@@ -727,7 +752,7 @@
         /// <param name="deviceStation">鍙枡鐐逛綅锛氣�漣nput鈥�-鍏ュ彛锛堝彨鑴忔《锛夛紝鈥漮utput鈥�-鍑哄彛锛堝噣妗剁敵璇峰偍浣嶏級</param>
         /// <param name="status"></param>
         /// <exception cref="Exception"></exception>
-        public void RCSCleanRequest(string deviceID,string deviceStation,string status,string url)
+        public void RCSCleanRequest(string deviceID,string deviceStation,string status,string url,string bindUrl)
         {
             try
             {
@@ -859,29 +884,41 @@
                 string agvMsg = string.Empty;
                 //缁欎笅杞︿笅鍙戜换鍔�
                 logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
-                if (agvResult)//鎴愬姛
+                //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+                var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, bindUrl, out string agvBindMsg);
+                if (bind)
                 {
-                    //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                    logTaskEntry.IsSuccess = 1;
-                    logTaskEntry.IsSend = 0;
-                    //logTaskEntry.IsCancel = 0;
-                    logTaskEntry.BackDate = DateTime.Now;
-                    logTaskEntry.Status = "1";//姝e湪鎵ц
-                    Db.Insertable(logTaskEntry).ExecuteCommand();
+                    var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+                    if (agvResult)//鎴愬姛
+                    {
+                        //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                        logTaskEntry.IsSuccess = 1;
+                        logTaskEntry.IsSend = 0;
+                        //logTaskEntry.IsCancel = 0;
+                        logTaskEntry.BackDate = DateTime.Now;
+                        logTaskEntry.Status = "1";//姝e湪鎵ц
+                        Db.Insertable(logTaskEntry).ExecuteCommand();
 
-                    startLoction.Status = "3";//鍑哄簱涓�
-                    Db.Updateable(startLoction).ExecuteCommand();
+                        startLoction.Status = "3";//鍑哄簱涓�
+                        Db.Updateable(startLoction).ExecuteCommand();
 
-                    endLoction.Status = "2";//鍏ュ簱涓�
-                    Db.Updateable(endLoction).ExecuteCommand();
+                        endLoction.Status = "2";//鍏ュ簱涓�
+                        Db.Updateable(endLoction).ExecuteCommand();
+                    }
+                    else//澶辫触
+                    {
+                        logTaskEntry.IsSuccess = 0;
+                        logTaskEntry.Information = agvMsg;
+                        Db.Insertable(logTaskEntry).ExecuteCommand();
+                    }
                 }
-                else//澶辫触
+                else
                 {
                     logTaskEntry.IsSuccess = 0;
-                    logTaskEntry.Information = agvMsg;
+                    logTaskEntry.Information = agvBindMsg;
                     Db.Insertable(logTaskEntry).ExecuteCommand();
                 }
+                
                 //鎻愪氦浜嬪姟
                 Db.CommitTran();
             }
@@ -893,7 +930,7 @@
             }
         }
 
-        private bool YikuTask(string palletNo, string taskNo, string url)
+        private bool YikuTask(string palletNo, string taskNo, string url,string bindUrl)
         {
             try
             {
@@ -985,33 +1022,47 @@
                         string agvMsg = string.Empty;
                         //缁欎笅杞︿笅鍙戜换鍔�
                         logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                        var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
-                        if (agvResult)//鎴愬姛
+                                                             //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+                        var bind = RcsHelper.BindPalletAndSite(palletInfoYi.LocatNo, palletInfoYi.PalletNo, bindUrl, out string agvBindMsg);
+                        if (bind)
                         {
-                            //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                            logTaskEntry.IsSuccess = 1;
-                            logTaskEntry.IsSend = 0;
-                            //logTaskEntry.IsCancel = 0;
-                            logTaskEntry.BackDate = DateTime.Now;
-                            logTaskEntry.Status = "1";//姝e湪鎵ц
-                            Db.Insertable(logTaskEntry).ExecuteCommand();
+                            var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
+                            if (agvResult)//鎴愬姛
+                            {
+                                //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                                logTaskEntry.IsSuccess = 1;
+                                logTaskEntry.IsSend = 0;
+                                //logTaskEntry.IsCancel = 0;
+                                logTaskEntry.BackDate = DateTime.Now;
+                                logTaskEntry.Status = "1";//姝e湪鎵ц
+                                Db.Insertable(logTaskEntry).ExecuteCommand();
 
-                            //淇敼绉诲嚭鍌ㄤ綅鐘舵��
-                            locatInfo.Status = "5";//绉诲嚭涓�
-                            Db.Updateable(locatInfo).ExecuteCommand();
+                                //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+                                locatInfo.Status = "5";//绉诲嚭涓�
+                                Db.Updateable(locatInfo).ExecuteCommand();
 
-                            //淇敼绉诲叆鍌ㄤ綅鐘舵��
-                            transferLocat.Status = "4";//绉诲叆涓�
-                            Db.Updateable(transferLocat).ExecuteCommand();
+                                //淇敼绉诲叆鍌ㄤ綅鐘舵��
+                                transferLocat.Status = "4";//绉诲叆涓�
+                                Db.Updateable(transferLocat).ExecuteCommand();
+                            }
+                            else//澶辫触
+                            {
+                                logTaskEntry.IsSuccess = 0;
+                                logTaskEntry.Information = agvMsg;
+                                Db.Insertable(logTaskEntry).ExecuteCommand();
+
+                                throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
+                            }
                         }
-                        else//澶辫触
+                        else
                         {
                             logTaskEntry.IsSuccess = 0;
-                            logTaskEntry.Information = agvMsg;
+                            logTaskEntry.Information = agvBindMsg;
                             Db.Insertable(logTaskEntry).ExecuteCommand();
 
                             throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
                         }
+                        
                     }
                 }
                 return true;
@@ -1027,7 +1078,7 @@
         /// <param name="taskNo"></param>
         /// <param name="url"></param>
         /// <exception cref="Exception"></exception>
-        public void OutBinAgv(string taskNo,string url)
+        public void OutBinAgv(string taskNo,string url, string bindUrl)
         {
             try
             {
@@ -1080,33 +1131,47 @@
                     string agvMsg = string.Empty;
                     //缁欎笅杞︿笅鍙戜换鍔�
                     logTaskInfoZ.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                    var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
-                    if (agvResult)//鎴愬姛
+                    //涓嬪彂杞藉叿涓庤揣浠粦瀹�
+                    var bind = RcsHelper.BindPalletAndSite(logTaskInfoZ.PalletNo, logTaskInfoZ.StartLocat, bindUrl, out string agvBindMsg);
+                    if (bind)
                     {
-                        //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                        logTaskInfoZ.IsSuccess = 1;
-                        logTaskInfoZ.IsSend = 0;
-                        //logTaskEntry.IsCancel = 0;
-                        logTaskInfoZ.BackDate = DateTime.Now;
-                        logTaskInfoZ.Status = "1";//姝e湪鎵ц
-                        Db.Insertable(logTaskInfoZ).ExecuteCommand();
+                        var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
+                        if (agvResult)//鎴愬姛
+                        {
+                            //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                            logTaskInfoZ.IsSuccess = 1;
+                            logTaskInfoZ.IsSend = 0;
+                            //logTaskEntry.IsCancel = 0;
+                            logTaskInfoZ.BackDate = DateTime.Now;
+                            logTaskInfoZ.Status = "1";//姝e湪鎵ц
+                            Db.Insertable(logTaskInfoZ).ExecuteCommand();
 
-                        //淇敼绉诲嚭鍌ㄤ綅鐘舵��
-                        startLocatInfoZ.Status = "5";//绉诲嚭涓�
-                        Db.Updateable(startLocatInfoZ).ExecuteCommand();
+                            //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+                            startLocatInfoZ.Status = "5";//绉诲嚭涓�
+                            Db.Updateable(startLocatInfoZ).ExecuteCommand();
 
-                        //淇敼绉诲叆鍌ㄤ綅鐘舵��
-                        endLocatInfoZ.Status = "4";//绉诲叆涓�
-                        Db.Updateable(endLocatInfoZ).ExecuteCommand();
+                            //淇敼绉诲叆鍌ㄤ綅鐘舵��
+                            endLocatInfoZ.Status = "4";//绉诲叆涓�
+                            Db.Updateable(endLocatInfoZ).ExecuteCommand();
+                        }
+                        else//澶辫触
+                        {
+                            logTaskInfoZ.IsSuccess = 0;
+                            logTaskInfoZ.Information = agvMsg;
+                            Db.Insertable(logTaskInfoZ).ExecuteCommand();
+
+                            throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
+                        }
                     }
-                    else//澶辫触
+                    else
                     {
                         logTaskInfoZ.IsSuccess = 0;
-                        logTaskInfoZ.Information = agvMsg;
+                        logTaskInfoZ.Information = agvBindMsg;
                         Db.Insertable(logTaskInfoZ).ExecuteCommand();
 
                         throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
                     }
+                    
                 }
             }
             catch (Exception e)
@@ -1122,7 +1187,7 @@
         /// </summary>
         /// <param name="url"></param>
         /// <exception cref="Exception"></exception>
-        public void TransferBackTimer(string url)
+        public void TransferBackTimer(string url,string bindUrl)
         {
             try
             {
@@ -1197,34 +1262,47 @@
                         string agvMsg = string.Empty;
                         //缁欎笅杞︿笅鍙戜换鍔�
                         logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
-                        var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
-                        if (agvResult)//鎴愬姛
+                        //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+                        var bind = RcsHelper.BindPalletAndSite(detailInfo.PalletNo, detailInfo.LocatNo, bindUrl, out string agvBindMsg);
+                        if (bind)
                         {
-                            //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
-                            logTaskEntry.IsSuccess = 1;
-                            logTaskEntry.IsSend = 0;
-                            //logTaskEntry.IsCancel = 0;
-                            logTaskEntry.BackDate = DateTime.Now;
-                            logTaskEntry.Status = "1";//姝e湪鎵ц
-                            Db.Insertable(logTaskEntry).ExecuteCommand();
+                            var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+                            if (agvResult)//鎴愬姛
+                            {
+                                //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+                                logTaskEntry.IsSuccess = 1;
+                                logTaskEntry.IsSend = 0;
+                                //logTaskEntry.IsCancel = 0;
+                                logTaskEntry.BackDate = DateTime.Now;
+                                logTaskEntry.Status = "1";//姝e湪鎵ц
+                                Db.Insertable(logTaskEntry).ExecuteCommand();
 
-                            //淇敼绉诲嚭鍌ㄤ綅鐘舵��
-                            locatModel.Status = "5";//绉诲嚭涓�
-                            Db.Updateable(locatModel).ExecuteCommand();
+                                //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+                                locatModel.Status = "5";//绉诲嚭涓�
+                                Db.Updateable(locatModel).ExecuteCommand();
 
-                            //淇敼绉诲叆鍌ㄤ綅鐘舵��
-                            endLocatInfo.Status = "4";//绉诲叆涓�
-                            Db.Updateable(endLocatInfo).ExecuteCommand();
+                                //淇敼绉诲叆鍌ㄤ綅鐘舵��
+                                endLocatInfo.Status = "4";//绉诲叆涓�
+                                Db.Updateable(endLocatInfo).ExecuteCommand();
+                            }
+                            else//澶辫触
+                            {
+                                logTaskEntry.IsSuccess = 0;
+                                logTaskEntry.Information = agvMsg;
+                                Db.Insertable(logTaskEntry).ExecuteCommand();
+
+                                throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
+                            }
                         }
-                        else//澶辫触
+                        else
                         {
                             logTaskEntry.IsSuccess = 0;
-                            logTaskEntry.Information = agvMsg;
+                            logTaskEntry.Information = agvBindMsg;
                             Db.Insertable(logTaskEntry).ExecuteCommand();
 
                             throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
                         }
-
+                        
                     }
                 }
                 //鎻愪氦浜嬪姟

--
Gitblit v1.8.0