From 885bd60ed54a0642c48c57a3d685cba24e4c763b Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期日, 08 十二月 2024 11:33:07 +0800
Subject: [PATCH] 1

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs |  535 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 405 insertions(+), 130 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 e3b70dc..6bcbc52 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"
@@ -16,23 +16,36 @@
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using AutoMapper;
+using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using OfficeOpenXml.Packaging.Ionic.Zip;
 using Quartz;
+using SqlSugar;
+using StackExchange.Profiling.Internal;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
+using System.Reflection.Metadata;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common.Log;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Communicator;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
+using WIDESEAWCS_Tasks.StackerCraneJob;
+using static Microsoft.IO.RecyclableMemoryStreamManager;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -54,41 +67,32 @@
 
         public Task Execute(IJobExecutionContext context)
         {
-            //Console.Out.WriteLine(DateTime.Now);
+
             try
             {
                 CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
                 if (conveyorLine != null)
                 {
-                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
-                    List<Task> tasks = new List<Task>();
-                    foreach (string childDeviceCode in childDeviceCodes)
+                    WriteLog.GetLog("Job鏃ュ織杩愯").Write(conveyorLine.DeviceCode + "杩愯鏃ュ織锛屽紑濮嬫椂闂�" + DateTime.Now, "Job鏃ュ織杩愯");
+                    if (conveyorLine.DeviceCode == "1002")
                     {
-                        //Task task = Task.Run(() =>
-                        //{
-                            ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(childDeviceCode);
-                            if (command != null)
-                            {
-                                DeviceProtocolDetailDTO? deviceProtocolDetail = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == command.InteractiveSignal.ToString() && x.DeviceProParamName == nameof(ConveyorLineTaskCommand.InteractiveSignal));
-                                if (deviceProtocolDetail != null)
-                                {
-                                    MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType);
-                                    if (method != null)
-                                    {
-                                        method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode });
-                                    }
-                                    else
-                                    {
-                                        //todo 鏈壘鍒版柟娉曟椂
-                                    }
-                                }
-                            }
-                        //});
-                        //tasks.Add(task);
+                        RequestInbound(conveyorLine);   //涓�妤糃,B鍖轰笟鍔�
+                    }
+                    if (conveyorLine.DeviceCode == "1003")
+                    {
+                        RequestInbound2(conveyorLine);
+                    }
+                    if (conveyorLine.DeviceCode == "1004")
+                    {
+                        RequestInbound3(conveyorLine);   //涓�妤糃,B鍖轰笟鍔�
                     }
 
-                    Task.WaitAll(tasks.ToArray());
+
+
                 }
+                WriteLog.GetLog("Job鏃ュ織杩愯").Write(conveyorLine.DeviceCode + "杩愯鏃ュ織锛岀粨鏉熸椂闂�" + DateTime.Now, "Job鏃ュ織杩愯");
+                //RequestInNextAddress(conveyorLine);
+
 
             }
             catch (Exception ex)
@@ -102,122 +106,393 @@
             return Task.CompletedTask;
         }
 
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍏ュ簱
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command,string childDeviceCode)
+        public void RequestInbound(CommonConveyorLine conveyorLine)
         {
-            if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
-            {
-                
-                /*Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-                if (task != null)
-                {
-                    ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
-                    taskCommand.InteractiveSignal = command.InteractiveSignal;
-                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
+            //1妤艰緭閫佺嚎鍒ゆ柇
+            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_C._03_PLC_EVENT", "PLC_WCS_C._03_PLC_LPN", "R01-003-041-001-01", "WCS_PLC_C._02_WCS_TO");// 澶勭悊 C
+        }
 
-                    _taskService.UpdateTaskStatusToNext(task);
+        public void RequestInbound2(CommonConveyorLine conveyorLine)
+        {
+            //椤舵ゼ妤艰緭閫佺嚎鍒ゆ柇
+
+            ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._01_PLC_EVENT", "PLC_WCS_D._01_PLC_LPN", "R01-003-041-011-01", "WCS_PLC_D._01_WCS_TO");// 澶勭悊 1宸烽亾 绔欏彴浜嬩欢鍏ョ┖
+            ProcessConveyorEvent(conveyorLine, "PLC_WCS_D._03_PLC_EVENT", "PLC_WCS_D._03_PLC_LPN", "R02-003-027-011-01", "WCS_PLC_D._03_WCS_TO");// 澶勭悊 2宸烽亾 绔欏彴浜嬩欢 鍏ョ┖
+
+            //ConveyorLineInFinish(conveyorLine, "R02-002-027-011-01"); //鍐欏叆杈撻�佺嚎鍘诲悜
+
+            //CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._02_PLC_EVENT", "PLC_WCS_D._02_PLC_LPN", "PLC_WCS_D._02_PLC_PUT", "R02-002-027-011-01"); //鍘熸潗鏂欏嚭搴�    璇诲彇鏉$爜閫夊簱鍖哄嚭搴�
+            //CheckForEmptyPallet2(conveyorLine, "PLC_WCS_D._04_PLC_EVENT", "PLC_WCS_D._04_PLC_LPN", "PLC_WCS_D._04_PLC_PUT", "R01-002-041-011-01"); //鍘熸潗鏂欏嚭搴�    璇诲彇鏉$爜閫夊簱鍖哄嚭搴�
+        }
+
+        public void RequestInbound3(CommonConveyorLine conveyorLine)
+        {
+            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-002-042-001-01", "WCS_PLC_A._03_WCS_TO");// 澶勭悊 A22 绔欏彴浜嬩欢 鍏ユ枡
+        }
+
+        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, string SCAddress)
+        {
+            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, SCAddress, "R_StackerCraneLowered");    //璇诲彇杈撻�佺嚎 鈥滃爢鍨涙満鏀句笅鈥� 淇″彿
+            if (deviceProDTO2 != null)
+            {
+                byte strsd = GetLine(conveyorLine, deviceProDTO2.DeviceChildCode);
+                if (strsd == 1)
+                {
+                    Dt_Task task = _taskService.IngStackerCraneTask2(conveyorLine.DeviceCode);
+                    if (task != null && task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+                    {
+                        byte PLCtypeTo = 1;
+                        if (task.TargetAddress == "R02-002-027-011-01")
+                        {
+                            PLCtypeTo = 2;
+                        }
+                        DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletBarcode");          //鍐欏叆鏉$爜
+                        DeviceProDTO? deviceProDTO4 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletLayers");           //灞傛暟
+                        DeviceProDTO? deviceProDTO5 = GetDeviceProDTO(conveyorLine, SCAddress, "W_PalletType");           //绫诲瀷
+                        DeviceProDTO? deviceProDTO6 = GetDeviceProDTO(conveyorLine, SCAddress, "W_Destination");           //绫诲瀷
+                        if (deviceProDTO3 != null && deviceProDTO4 != null && deviceProDTO5 != null && deviceProDTO6 != null)
+                        {
+                            if (SetLinestring(conveyorLine, deviceProDTO3.DeviceProDataBlock, task.PalletCode) && SetLine(conveyorLine, deviceProDTO4.DeviceProDataBlock, (byte)task.PalletCodequantity) && SetLine(conveyorLine, deviceProDTO5.DeviceProDataBlock, PLCtypeTo) && SetLine(conveyorLine, deviceProDTO6.DeviceProDataBlock, (byte)task.PLCTo))
+                            {
+
+                                LogSignalStatus($"鍐欏叆鏀捐揣瀹屾垚淇℃伅锛屾墭鐩樻潯鐮侊紝灞傛暟锛岀被鍨嬩俊鎭垚鍔�", deviceProDTO2.DeviceChildCode);
+
+                            }
+                            else
+                            {
+                                LogSignalStatus($"鍐欏叆鏀捐揣瀹屾垚淇℃伅锛屾墭鐩樻潯鐮侊紝灞傛暟锛岀被鍨嬩俊鎭け璐�", deviceProDTO2.DeviceChildCode);
+
+                            }
+                        }
+                        else
+                        {
+                            LogSignalStatus($"鏈壘鍒拌緭閫佺嚎鍗忚淇℃伅", task.TargetAddress);
+
+                        }
+                    }
+                }
+            }
+
+        }
+        //鑾峰彇杈撻�佺嚎瀹炰緥
+        public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string SCAddress, string Interactivet)
+        {
+            return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet);
+        }
+
+        /// <summary>
+        /// 鐢ㄤ簬鍏ュ簱鍒ゆ柇宸烽亾
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="eventTag"></param>
+        /// <param name="barcodeTag"></param>
+        /// <param name="writeTag"></param>
+        private void HandleEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag)
+        {
+            try
+            {
+                byte events = conveyorLine.Communicator.Read<byte>(eventTag); // 璇诲彇浜嬩欢
+                if (events == 1)
+                {
+                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // 璇诲彇鏉$爜
+                    if (barcode != "1" || barcode != "0")
+                    {
+                        if ((_taskService.ToPlatform(barcode)).Status)
+                        {
+                            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", "鍘诲悜");
+                                }
+                            }
+                        }
+                    }
+
+
+                    if (barcode == "1")
+                    {
+                        // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
+                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);   //绌烘墭鍘诲悜
+                        if (result)
+                        {
+                            WriteLog.GetLog("PLC鏃ュ織").Write("绌烘墭鍏ュ簱锛屽啓鍏ュ幓鍚戯細1", "鍘诲悜");
+                        }
+                    }
+                    /*else
+                    {
+                        // 鍐欏叆鍘诲悜1鍙峰爢鍨涙満
+                        bool result = conveyorLine.Communicator.Write(writeTag, (byte)1);
+                        if (result)
+                        {
+                            WriteLog.GetLog("PLC鏃ュ織").Write("鍐欏叆鍘诲悜锛�2", "鍘诲悜");
+                        }
+
+                        WriteLog.GetLog("PLC鏃ュ織").Write("鍏ュ簱澶辫触", "鍏ュ簱缁勭洏");
+                    }*/
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw;
+            }
+        }
+
+        //鏂扮殑宸烽亾鍒ゆ柇
+        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
+                        {
+                            WriteLog.GetLog("PLC鏃ュ織").Write($"澶辫触淇℃伅锛歿content.Message}", "鍘诲悜澶辫触淇℃伅");
+                        }
+                    }
+                }
+                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)
+        {
+
+            try
+            {
+                Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // 璇诲彇浜嬩欢
+                if (events == 1)        //1涓虹┖锛�0涓烘湁
+                {
+                    string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // 璇诲彇鏉$爜
+                    if (barcode == "")
+                    {
+                        WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"璇诲彇鍒板嚭搴撳彛琛ョ┖鎵樹俊鍙凤細{events}", "闇�瑕佺┖鎵�");
+                        // 鐢熸垚鍫嗗灈鏈哄彇绌烘墭浠诲姟
+                        byte plcputts = conveyorLine.Communicator.Read<byte>(plcput);
+                        if (plcputts != 1)
+                        {
+                            if ((_taskService.RequestWMSTask2("", Loc)).Status)
+                            {
+                                WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"宸茬敓鎴愮┖鎵樺嚭搴撲换鍔★細{events}", "闇�瑕佺┖鎵�");
+                            }
+                            else
+                            {
+                                WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"鏈敓鎴愮┖鎵樺嚭搴撲换鍔★細{events}", "闇�瑕佺┖鎵�");
+                            }
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw;
+            }
+        }
+
+        //鐢ㄤ簬鍒ゆ柇鏄惁鍑虹┖鎵� D鍖�
+        private void CheckForEmptyPallet2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
+        {
+            Byte events = conveyorLine.Communicator.Read<Byte>(eventTag);  // 璇诲彇浜嬩欢
+            if (events == 1)        //1涓虹┖锛�0涓烘湁
+            {
+                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag); // 璇诲彇鏉$爜
+                if (barcode != "1" || barcode != "0")
+                {
+                    WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"璇诲彇鍒板師鏉愭枡鍑哄簱淇℃伅锛屾潯鐮佷俊鎭細{barcode}", "鍘熸潗鏂欏嚭搴�");
+
+                    byte outCount = conveyorLine.Communicator.Read<byte>(plcput);
+                    if ((_taskService.RequestWMSTask3(barcode, outCount, Loc)).Status)
+                    {
+                        //鍐欏叆杈撻�佺嚎娓呴櫎淇℃伅
+                        WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"宸茬敓鎴愬師鏉愭枡鍑哄簱浠诲姟锛屾潯鐮佷俊鎭細{barcode}", "鍘熸潗鏂欏嚭搴�");
+                    }
+                    else
+                    {
+                        WriteLog.GetLog("PLC鏃ュ織鍑哄簱鏃ュ織").Write($"鏈敓鎴愬師鏉愭枡鍑哄簱浠诲姟锛屾潯鐮佷俊鎭細{barcode}", "鍘熸潗鏂欏嚭搴�");
+                    }
+                }
+            }
+
+        }
+
+        //鐢ㄤ簬鍒ゆ柇鍏ュ簱绔欏彴
+        private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode, string writeTag)
+        {
+            byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag);
+            if (eventStatus == 1)
+            {
+                WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"璇诲彇鍒拌緭閫佺嚎鐢宠鍏ュ簱淇℃伅EVENT涓猴細{eventStatus}锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
+                string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim();
+                /*if(barcode == "1")
+                {
+                    string currentTime = DateTime.Now.ToString("HHmmss");
+                    barcode = "KTP" + currentTime;
+
                 }*/
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍏ュ簱涓嬩竴鍦板潃
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
-                if (newTask != null)
+                if (barcode != null)
                 {
-                    ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
-                    taskCommand.InteractiveSignal = command.InteractiveSignal;
-                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                    bool result = conveyorLine.Communicator.Write(writeTag, (byte)0);
+                    /*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)
+                    {
+                        if (content.Status)
+                        {
+                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鐢宠鍏ュ簱鎴愬姛锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
+                        }
+                        else
+                        {
+                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鐢宠鍏ュ簱澶辫触锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
+                        }
+                    }
+                }
+                else
+                {
+                    WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"璇诲彇鍒拌緭閫佺嚎淇℃伅涓虹┖锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绔欏彴淇℃伅");
                 }
             }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎鍏ュ簱瀹屾垚
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
+            else if (eventStatus == 6)
             {
-                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                Console.Out.WriteLine(content.Serialize());
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
-            if (task != null)
-            {
-                ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
-                taskCommand.InteractiveSignal = command.InteractiveSignal;
-                conveyorLine.SendCommand(taskCommand, childDeviceCode);
-
-                _taskService.UpdateTaskStatusToNext(task);
-            }
-        }
-
-        /// <summary>
-        /// 杈撻�佺嚎璇锋眰鍑哄簱涓嬩竴鍦板潃
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
-        {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
-                if (newTask != null)
+                if (taskCode == "R02-003-027-011-01")
                 {
-                    ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
-                    taskCommand.InteractiveSignal = command.InteractiveSignal;
-                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
+                    WebResponseContent content = _taskService.RequestWMSTask4();
+                    if (content != null)
+                    {
+                        if (content.Status)
+                        {
+                            if (content.Data != null)
+                            {
+                                if (content.Data.ToString() == "1")
+                                {
+                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._01_PLC_LPN") == "")
+                                    {
+                                        if (conveyorLine.Communicator.Write(writeTag, (byte)1))
+                                        {
+                                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆鎴愬姛锛屽幓鍚戯細1锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                                        }
+                                        else
+                                        {
+                                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆澶辫触锛屽幓鍚戯細1锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                                        }
+                                    }
+                                }
+                                else if (content.Data.ToString() == "3")
+                                {
+
+                                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._03_PLC_LPN") == "")
+                                    {
+                                        if (conveyorLine.Communicator.Write(writeTag, (byte)3))
+                                        {
+                                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆鎴愬姛锛屽幓鍚戯細3锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                                        }
+                                        else
+                                        {
+                                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆澶辫触锛屽幓鍚戯細3锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+
                 }
+                else if (taskCode == "R01-003-041-011-01")
+                {
+                    if (conveyorLine.Communicator.Read<string>("PLC_WCS_D._03_PLC_LPN") == "")
+                    {
+                        if (conveyorLine.Communicator.Write(writeTag, (byte)1))
+                        {
+                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆鎴愬姛锛屽幓鍚戯細1锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                        }
+                        else
+                        {
+                            WriteLog.GetLog("PLC鍏ュ簱绔欏彴鏃ュ織").Write($"鍐欏叆澶辫触锛屽幓鍚戯細1锛岀珯鍙扮紪鍙蜂负锛歿taskCode}", "绌烘墭鍏ュ簱鍘诲悜");
+                        }
+                    }
+                    
+                }
+
+
             }
         }
-
-        /// <summary>
-        /// 杈撻�佺嚎鍑哄簱瀹屾垚
-        /// </summary>
-        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
-        /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
-        /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
-        public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
+        public bool SetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock, byte Pali)
         {
-            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
-            if (task != null)
-            {
-                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
-                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
-                Console.Out.WriteLine(content.Serialize());
-            }
+            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
+        }
+        public bool SetLinestring(CommonConveyorLine conveyorLine, string DeviceProDataBlock, string Pali)
+        {
+            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
+        }
+
+        public byte GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock)
+        {
+            return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock);
+        }
+        private void LogSignalStatus(string message, string sourceAddress)
+        {
+            WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"绔欏彴缂栧彿锛歿sourceAddress},淇℃伅锛歿message}", $"{sourceAddress}");
         }
     }
 }

--
Gitblit v1.9.3