From 4cfeced9bc8985cdd89fdb540e6fe984f8469481 Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期四, 21 十一月 2024 11:02:40 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |  110 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 89 insertions(+), 21 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
index 58ada7c..62a7adc 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
@@ -21,6 +21,7 @@
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using Quartz;
+using SqlSugar;
 using StackExchange.Profiling.Internal;
 using System;
 using System.Collections.Generic;
@@ -75,7 +76,15 @@
                     {
                         RequestInbound(conveyorLine);   //涓�妤糃,B鍖轰笟鍔�
                     }
-                    
+                    if (conveyorLine.DeviceCode == "1003")
+                    {
+                        _taskService.RequestWMSTask3("FK240711D2",1, "R02-002-027-011-01");
+                    }
+                    if (conveyorLine.DeviceCode == "1004")
+                    {
+                        RequestInbound3(conveyorLine);   //涓�妤糃,B鍖轰笟鍔�
+                    }
+
 
 
                 }
@@ -97,11 +106,13 @@
         public void RequestInbound(CommonConveyorLine conveyorLine)
         {
             //1妤艰緭閫佺嚎鍒ゆ柇
-            HandleEvent(conveyorLine, "PLC_WCS_B._03_PLC_EVENT", "PLC_WCS_B._03_PLC_LPN", "WCS_PLC_B._03_WCS_TO");  //鍒ゆ柇宸烽亾
-            HandleEvent(conveyorLine, "PLC_WCS_C._02_PLC_EVENT", "PLC_WCS_C._02_PLC_LPN", "WCS_PLC_C._02_WCS_TO");  //鍒ゆ柇宸烽亾
+            HandleEvent2(conveyorLine, "PLC_WCS_B._03_PLC_EVENT", "PLC_WCS_B._03_PLC_LPN", "WCS_PLC_B._03_WCS_TO");  //鍒ゆ柇宸烽亾
+            HandleEvent2(conveyorLine, "PLC_WCS_C._02_PLC_EVENT", "PLC_WCS_C._02_PLC_LPN", "WCS_PLC_C._02_WCS_TO");  //鍒ゆ柇宸烽亾
             CheckForEmptyPallet(conveyorLine, "PLC_WCS_B._02_PLC_EVENT", "PLC_WCS_B._02_PLC_LPN", "PLC_WCS_B._02_PLC_PUT", "R02-002-027-001-01"); //鍒ゆ柇鏄惁鍙栫┖鎵樺嚭搴�
             CheckForEmptyPallet(conveyorLine, "PLC_WCS_C._01_PLC_EVENT", "PLC_WCS_C._01_PLC_LPN", "PLC_WCS_C._01_PLC_PUT", "R01-002-041-001-01"); //鍒ゆ柇鏄惁鍙栫┖鎵樺嚭搴�
-            ProcessConveyorEvent(conveyorLine, "PLC_WCS_B._01_PLC_EVENT", "PLC_WCS_B._01_PLC_LPN", "R02-003-027-001-01", "WCS_PLC_B._03_WCS_TO");// 澶勭悊 B 绔欏彴浜嬩欢 //鍒ゆ柇杈撻�佺嚎鍒拌揪淇″彿
+
+
+            ProcessConveyorEvent(conveyorLine, "PLC_WCS_B._01_PLC_EVENT", "PLC_WCS_B._01_PLC_LPN", "R02-003-027-001-01", "WCS_PLC_B._03_WCS_TO");// 澶勭悊 B 
             ProcessConveyorEvent(conveyorLine, "PLC_WCS_C._03_PLC_EVENT", "PLC_WCS_C._03_PLC_LPN", "R01-003-041-001-01", "WCS_PLC_C._02_WCS_TO");// 澶勭悊 C
         }
 
@@ -120,11 +131,11 @@
 
         public void RequestInbound3(CommonConveyorLine conveyorLine)
         {
-            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "R02-003-043-011-01", "WCS_PLC_A._02_WCS_TO");// 澶勭悊 A21 绔欏彴浜嬩欢鍏ュ簱
+            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "R01-002-043-001-01", "WCS_PLC_A._02_WCS_TO");// 澶勭悊 A21 绔欏彴浜嬩欢鍏ュ簱
 
-            ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._03_PLC_EVENT", "PLC_WCS_A._03_PLC_LPN", "R01-003-042-011-01", "WCS_PLC_A._03_WCS_TO");// 澶勭悊 A22 绔欏彴浜嬩欢 鍏ユ枡
+            //ProcessConveyorEvent(conveyorLine, "PLC_WCS_A._03_PLC_EVENT", "PLC_WCS_A._03_PLC_LPN", "R01-002-042-001-01", "WCS_PLC_A._03_WCS_TO");// 澶勭悊 A22 绔欏彴浜嬩欢 鍏ユ枡
             
-            ConveyorLineInFinish(conveyorLine,"R01-002-044-001-01"); //鐢ㄤ簬鍐欏叆杈撻�佺嚎鏉$爜淇℃伅锛岀敤浜庡嚭搴�
+            //ConveyorLineInFinish(conveyorLine,"R01-002-044-001-01"); //鐢ㄤ簬鍐欏叆杈撻�佺嚎鏉$爜淇℃伅锛岀敤浜庡嚭搴�
         }
 
         public void ConveyorLineInFinish(CommonConveyorLine conveyorLine,string SCAddress)
@@ -196,11 +207,14 @@
                     {
                         if ((_taskService.ToPlatform(barcode)).Status)
                         {
-                            // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
-                            bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //鍘熸潗鏂欏幓鍚�
-                            if (result)
-                            {   
-                                WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�3", "鍘诲悜");
+                            if(conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN")=="")
+                            {
+                                // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
+                                bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //鍘熸潗鏂欏幓鍚�
+                                if (result)
+                                {
+                                    WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�3", "鍘诲悜");
+                                }
                             }
                         }
                     }
@@ -235,7 +249,63 @@
             }
         }
 
-        //鐢ㄤ簬鍒ゆ柇鏄惁琛ョ┖鎵�
+        //鏂扮殑宸烽亾鍒ゆ柇
+        private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
+        {
+            byte events = conveyorLine.Communicator.Read<byte>(eventTag); // 璇诲彇浜嬩欢
+            if (events == 1)
+            {
+                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // 璇诲彇鏉$爜
+                if (barcode != "1" || barcode != "0")
+                {
+                    WebResponseContent content = _taskService.ToPlatform(barcode);
+                    if(content != null)
+                    {
+                        if (content.Status)
+                        {
+                            if(content.Data != null)
+                            {
+                                if (content.Data.ToString() == "1")
+                                {
+                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_C._03_PLC_LPN") == "")
+                                    {
+                                        // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
+                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //鍐欏叆鍘诲悜涓洪暱宸烽亾
+                                        if (result)
+                                        {
+                                            WriteLog.GetLog("PLC鏃ュ織").Write($"鏉$爜{barcode}锛屽啓鍏ュ幓鍚戯細1", "鍘诲悜");
+                                        }
+                                    }
+                                }
+                                else if (content.Data.ToString() == "3")
+                                {
+
+                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_B._01_PLC_LPN") == "") 
+                                    {
+                                        // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
+                                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)3);   //鍐欏叆鍘诲悜涓虹煭宸烽亾
+                                        if (result)
+                                        {
+                                            WriteLog.GetLog("PLC鏃ュ織").Write($"鏉$爜{barcode},鍐欏叆鍘诲悜锛�3", "鍘诲悜");
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                else if (barcode == "1")
+                {
+                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //绌烘墭鍘诲悜
+                    if (result)
+                    {
+                        WriteLog.GetLog("PLC鏃ュ織").Write("绌烘墭鍏ュ簱锛屽啓鍏ュ幓鍚戯細1", "鍘诲悜");
+                    }
+                }
+            }
+        }
+        
+        //鐢ㄤ簬鍒ゆ柇鏄惁琛ョ┖鎵� A鍖�
         private void CheckForEmptyPallet(CommonConveyorLine conveyorLine,string eventTag, string barcodeTag,string plcput,string Loc)
         {
 
@@ -262,8 +332,6 @@
                             }
                         }
                     }
-                    
-                    
                 }
             }
             catch (Exception ex)
@@ -273,7 +341,7 @@
             }
         }
 
-        //鐢ㄤ簬鍒ゆ柇鏄惁鍑虹┖鎵�
+        //鐢ㄤ簬鍒ゆ柇鏄惁鍑虹┖鎵� D鍖�
         private void CheckForEmptyPallet2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
         {
             Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // 璇诲彇浜嬩欢
@@ -306,23 +374,23 @@
             if (eventStatus == 1)
             {
                 WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"璇诲彇鍒拌緭閫佺嚎鐢宠鍏ュ簱淇℃伅EVENT涓猴細{eventStatus}锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
-                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag);
-                if(barcode == "1")
+                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim();
+                /*if(barcode == "1")
                 {
                     string currentTime = DateTime.Now.ToString("HHmmss");
                     barcode = "KTP" + currentTime;
 
-                }
+                }*/
                 if (barcode != null)
                 {
                     bool result = conveyorLine.Communicator.Write(writeTag, (byte)0);
-                    if(taskCode== "R01-003-042-011-01")
+                    /*if(taskCode== "R01-003-042-001-01")
                     {
                         if ((_taskService.ToPlatform(barcode)).Status)
                         {
                             WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"缁勭洏鎴愬姛锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
                         }
-                    }
+                    }*/
                     // 鎷垮彇鎵樼洏鏉$爜鐢宠鍏ュ簱淇℃伅
                     WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // 鐢宠鍏ュ簱锛岀敓鎴愬爢鍨涙満浠诲姟
                     if (content !=null)

--
Gitblit v1.9.3