From 96a77e69b0577c50adfaacd5fd8b89009242d3bd Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期日, 07 十二月 2025 18:25:00 +0800
Subject: [PATCH] 更新
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 534 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 412 insertions(+), 122 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..4d3922f 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,46 +67,33 @@
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)
+ 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); //D鍖轰笟鍔�
+ }
+ if (conveyorLine.DeviceCode == "1004")
+ {
+ RequestInbound3(conveyorLine); //A鍖轰笟鍔�
}
- Task.WaitAll(tasks.ToArray());
- }
+
+ }
+
}
catch (Exception ex)
{
- //Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
+ WriteLog.Write_Log("杈撻�佺嚎浜や簰", "閿欒淇℃伅", "閿欒", new { 淇℃伅 = ex.Message });
}
finally
{
@@ -102,122 +102,412 @@
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)
+ try
{
-
- /*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
+ }
+ catch (Exception ex)
+ {
- _taskService.UpdateTaskStatusToNext(task);
+ throw;
+ }
+ }
+
+ 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宸烽亾 绔欏彴浜嬩欢 鍏ョ┖
+ }
+
+ public void RequestInbound3(CommonConveyorLine conveyorLine)
+ {
+
+
+ HandleEvent2(conveyorLine, "PLC_WCS_A._05_PLC_EVENT", "PLC_WCS_A._05_PLC_LPN", "WCS_PLC_A._05_WCS_TO", "鎴愬搧U鍨嬪集鎵爜绔欏彴"); //鍒ゆ柇宸烽亾
+
+ CheckForEmptyPallet(conveyorLine, "PLC_WCS_A._02_PLC_EVENT", "PLC_WCS_A._02_PLC_LPN", "PLC_WCS_A._02_PLC_PUT", "R01-002-043-001-01"); //鍒ゆ柇鏄惁鍙栫┖鎵樺嚭搴�
+
+ 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._05_WCS_TO");// 澶勭悊 A22 绔欏彴浜嬩欢 鍏ユ枡
+
+ //鍒ゆ柇鏄惁鏈�1妤煎嚭绌烘墭浠诲姟
+ MassiveOutboundShipments(conveyorLine, "WCS_PLC_A._01_WCS_TYPE");
+ }
+
+ public void MassiveOutboundShipments(CommonConveyorLine conveyorLine, string OutPLCAddress)
+ {
+ try
+ {
+ bool WetiOuttaskinfo = _taskService.ObtainOutTaskInfo();
+ if (WetiOuttaskinfo)
+ {
+ bool result = conveyorLine.Communicator.Write(OutPLCAddress, (byte)1); //鍐欏叆鍘诲悜涓虹煭宸烽亾
+ if (result)
+ {
+ WriteLog.Write_Log("U鍨嬫垚鍝佸嚭搴�", "鎴愬搧鍑哄簱鍐欏叆淇℃伅", "鎴愬姛", new { 淇℃伅 = "鍐欏叆浜や簰淇℃伅锛屽啓鍏ユ垚鍔燂紝鍐欏叆鍊硷細1" });
+ return;
+ }
+ else
+ {
+ WriteLog.Write_Log("U鍨嬫垚鍝佸嚭搴�", "鎴愬搧鍑哄簱鍐欏叆淇℃伅", "澶辫触", new { 淇℃伅 = $"鍐欏叆澶辫触锛屽湴鍧�锛歿OutPLCAddress}" });
+ return;
+ }
+ }
+ else
+ {
+ bool result = conveyorLine.Communicator.Write(OutPLCAddress, (byte)0); //鍐欏叆鍘诲悜涓虹煭宸烽亾
+ if (result)
+ {
+ WriteLog.Write_Log("U鍨嬫垚鍝佸嚭搴�", "鎴愬搧鍑哄簱鍐欏叆淇℃伅", "鎴愬姛", new { 淇℃伅 = "鍐欏叆娓呴櫎淇℃伅锛屽啓鍏ユ垚鍔燂紝鍐欏叆鍊硷細0" });
+ return;
+ }
+ else
+ {
+ WriteLog.Write_Log("U鍨嬫垚鍝佸嚭搴�", "鎴愬搧鍑哄簱鍐欏叆淇℃伅", "澶辫触", new { 淇℃伅 = $"鍐欏叆澶辫触锛屽湴鍧�锛歿OutPLCAddress}" });
+ return;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ WriteLog.Write_Log("U鍨嬫垚鍝佸嚭搴�", "鎴愬搧鍑哄簱鍐欏叆淇℃伅", "澶辫触", new { 淇℃伅 = $"绯荤粺閿欒淇℃伅锛屽啓鍏ュけ璐ワ紝鍦板潃锛歿OutPLCAddress}" });
+ throw;
+ }
+ }
+
+ public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, string SCAddress)
+ {
+ try
+ {
+ 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);
+
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ throw;
+ }
+
+ }
+ //鑾峰彇杈撻�佺嚎瀹炰緥
+ public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine, string SCAddress, string Interactivet)
+ {
+ return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet);
+ }
+
+
+
+ //鏂扮殑宸烽亾鍒ゆ柇
+ private void HandleEvent2(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string writeTag,string Platform)
+ {
+ try
+ {
+ byte events = conveyorLine.Communicator.Read<byte>(eventTag); // 璇诲彇浜嬩欢
+ string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim(); // 璇诲彇鏉$爜
+ if (events == 1 && barcode != "NoRead" && barcode != "" && barcode != null)
+ {
+ WebResponseContent content = _taskService.ToPlatform(barcode);
+ if (content != null)
+ {
+ if (content.Status)
+ {
+ if (content.Data != null)
+ {
+
+ if (Platform == "鎴愬搧U鍨嬪集鎵爜绔欏彴")
+ {
+ // 鍐欏叆鍘诲悜2鍙峰爢鍨涙満
+ bool result = conveyorLine.Communicator.Write(writeTag, (byte)3); //鍐欏叆鍘诲悜涓虹煭宸烽亾
+ if (result)
+ {
+ wcs_PLCto01(Platform + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鏉$爜{barcode},鍐欏叆鍘诲悜锛�3");
+ return;
+ }
+ }
+
+
+ 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)
+ {
+ wcs_PLCto01(Platform + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鏉$爜{barcode},鍐欏叆鍘诲悜锛�1");
+ }
+ }
+ else
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿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)
+ {
+ wcs_PLCto01(Platform + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鏉$爜{barcode},鍐欏叆鍘诲悜锛�3");
+ }
+ }
+ else
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿barcode}锛屽師鍥狅細褰撳墠闇�鍐欏叆鍘诲悜锛�3锛屼絾璇诲彇杈撻�佺嚎鈥滃爢鍨涙満鍙栬揣绔欏彴鈥濇湁鏉$爜锛屼笉鍙啓鍏ュ幓鍚�");
+ }
+ }
+ else
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿barcode}锛岀敵璇峰叆搴撳け璐ワ細鏈幏鍙栧埌鍘诲悜");
+ }
+ }
+ }
+ else
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿barcode}锛岀敵璇峰叆搴撳け璐ワ細{content.Message}");
+ }
+ }
+ }
+ /*else
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"璇诲彇鍒拌緭閫佺嚎,鐢宠锛歿events},鏉$爜锛歿barcode}");
}*/
}
+ catch (Exception ex)
+ {
+ wcs_PLCto01(Platform + "锛氶敊璇俊鎭�", "閿欒", $"鏁呴殰淇℃伅锛歿ex.Message}");
+ throw;
+ }
}
- /// <summary>
- /// 杈撻�佺嚎璇锋眰鍏ュ簱涓嬩竴鍦板潃
- /// </summary>
- /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
- /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
- /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
- public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
+ //鐢ㄤ簬鍒ゆ柇鏄惁琛ョ┖鎵� A鍖�
+ private void CheckForEmptyPallet(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string plcput, string Loc)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
- if (task != null)
+
+ try
{
- Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
- if (newTask != null)
+ Byte events = conveyorLine.Communicator.Read<Byte>(eventTag); // 璇诲彇浜嬩欢
+ if (events == 1) //1涓虹┖锛�0涓烘湁
{
- ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
- taskCommand.InteractiveSignal = command.InteractiveSignal;
- conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ WebResponseContent content = _taskService.RequestWMSTask2("", Loc);
+ // 鐢熸垚鍫嗗灈鏈哄彇绌烘墭浠诲姟
+ if (content.Status)
+ {
+ wcs_PLCto02(Loc + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"宸茬敓鎴愮┖鎵樺嚭搴撲换鍔�");
+ }
+ else
+ {
+ wcs_PLCto02(Loc + "锛氶敊璇俊鎭�", "閿欒", $"鏈敓鎴愮┖鎵樺嚭搴撲换鍔★紝閿欒淇℃伅锛歿content.Message}");
+ }
+ }
+ /*else
+ {
+ wcs_PLCto02(Loc + "锛氶敊璇俊鎭�", "閿欒", $"璇诲彇鍒拌緭閫佺嚎,鐢宠锛歿events}");
+ }*/
+ }
+ catch (Exception ex)
+ {
+
+ throw;
+ }
+ }
+
+
+ //鐢ㄤ簬鍒ゆ柇鍏ュ簱绔欏彴
+ private void ProcessConveyorEvent(CommonConveyorLine conveyorLine, string eventTag, string barcodeTag, string taskCode, string writeTag)
+ {
+ try
+ {
+ byte eventStatus = conveyorLine.Communicator.Read<byte>(eventTag);
+ if ((eventStatus == 1 && taskCode != "R01-002-043-001-01") || (eventStatus == 6 && taskCode== "R01-002-043-001-01"))
+ {
+ string barcode = conveyorLine.Communicator.Read<string>(barcodeTag).Trim();
+ if (barcode != null && barcode != "0")
+ {
+ bool result = conveyorLine.Communicator.Write(writeTag, (byte)0);
+ wcs_PLCto03("鍘诲悜娓呴櫎", "鎴愬姛", $"鍦板潃锛歿writeTag}锛屽幓鍚戞竻闄や负锛�0");
+ WebResponseContent content = _taskService.RequestWMSTask(barcode, taskCode); // 鐢宠鍏ュ簱锛岀敓鎴愬爢鍨涙満浠诲姟
+ if (content != null)
+ {
+ if (content.Status)
+ {
+ wcs_PLCto03(taskCode + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鏉$爜锛歿barcode}锛岀敵璇峰叆搴撴垚鍔�");
+ }
+ else
+ {
+ wcs_PLCto03(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿barcode}锛岀敵璇峰叆搴撳け璐ワ紝閿欒淇℃伅锛歿content.Message}");
+ }
+ }
+ else
+ {
+ wcs_PLCto03(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鏉$爜锛歿barcode}锛岀敵璇峰叆搴撳け璐ワ紝閿欒淇℃伅content杩斿洖鍊间负绌�");
+ }
+ }
+ else
+ {
+ wcs_PLCto03(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"璇诲彇鍒拌緭閫佺嚎淇℃伅鏉$爜淇℃伅涓虹┖鎴栦负0锛岃鍙栧埌杈撻�佺嚎淇℃伅锛歿barcode}");
+ }
+ }
+ else if (eventStatus == 6 && taskCode != "R01-002-043-001-01")
+ {
+ //if (taskCode == "R02-003-027-011-01" ) 涔嬪墠鐗堟湰閰嶅悎else杩涜浣跨敤
+ if (taskCode == "R01-003-041-011-01" || taskCode == "R02-003-027-011-01")
+ {
+ WebResponseContent content = _taskService.RequestWMSTask4();
+ if (content != null)
+ {
+ if (content.Status && content.Data != null)
+ {
+ if (content.Data.ToString() == "1")
+ {
+ if (conveyorLine.Communicator.Write(writeTag, (byte)1))
+ {
+ wcs_PLCto04(taskCode + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鍐欏叆鎴愬姛锛屽幓鍚戯細1");
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鍐欏叆澶辫触锛屽幓鍚戯細1");
+ }
+ }
+ else if (content.Data.ToString() == "3")
+ {
+
+ if (conveyorLine.Communicator.Write(writeTag, (byte)3))
+ {
+ wcs_PLCto04(taskCode + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鍐欏叆鎴愬姛锛屽幓鍚戯細3");
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鍐欏叆澶辫触锛屽幓鍚戯細3");
+ }
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鏈壘鍒板啓鍏ュ幓鍚�");
+ }
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鐢宠鍏ュ簱澶辫触锛岄敊璇俊鎭細{content.Message}");
+ }
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鐢宠鍏ュ簱澶辫触锛岄敊璇俊鎭細content杩斿洖鍊间负绌�");
+ }
+
+ }
+ /*else if (taskCode == "R01-003-041-011-01")
+ {
+ if (conveyorLine.Communicator.Write(writeTag, (byte)1))
+ {
+ wcs_PLCto04(taskCode + "锛氭垚鍔熶俊鎭�", "鎴愬姛", $"鍐欏叆鎴愬姛锛屽幓鍚戯細1");
+ }
+ else
+ {
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鍐欏叆澶辫触锛屽幓鍚戯細1");
+ }
+
+ }*/
}
}
- }
-
- /// <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)
+ catch (Exception ex)
{
- conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
- WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
- Console.Out.WriteLine(content.Serialize());
+ wcs_PLCto04(taskCode + "锛氶敊璇俊鎭�", "閿欒", $"鍘熷洜锛歿ex.Message}");
+ throw;
}
}
-
- /// <summary>
- /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
- /// </summary>
- /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
- /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
- /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
- public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
+ public bool SetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock, byte Pali)
{
- 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);
- }
+ return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
+ }
+ public bool SetLinestring(CommonConveyorLine conveyorLine, string DeviceProDataBlock, string Pali)
+ {
+ return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
}
- /// <summary>
- /// 杈撻�佺嚎璇锋眰鍑哄簱涓嬩竴鍦板潃
- /// </summary>
- /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
- /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
- /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
- public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
+ public byte GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock)
{
- Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
- if (task != null)
- {
- Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
- if (newTask != null)
- {
- ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(newTask);
- taskCommand.InteractiveSignal = command.InteractiveSignal;
- conveyorLine.SendCommand(taskCommand, childDeviceCode);
- }
- }
+ return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock);
+ }
+ private void LogSignalStatus(string message, string sourceAddress)
+ {
+ WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"绔欏彴缂栧彿锛歿sourceAddress},淇℃伅锛歿message}", $"{sourceAddress}");
}
- /// <summary>
- /// 杈撻�佺嚎鍑哄簱瀹屾垚
- /// </summary>
- /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
- /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
- /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
- public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
+
+
+
+ public void wcs_PLCto01(string SCLLinStack, string Logtype, string Magessadd)
{
- 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());
- }
+ WriteLog.Write_Log("涓�妤兼壂鐮佺珯鍙�", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
}
+
+ public void wcs_PLCto02(string SCLLinStack, string Logtype, string Magessadd)
+ {
+ WriteLog.Write_Log("涓�妤艰ˉ绌烘墭", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
+ }
+ public void wcs_PLCto03(string SCLLinStack, string Logtype, string Magessadd)
+ {
+ WriteLog.Write_Log("鍏ュ簱绔欏彴", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
+ }
+ public void wcs_PLCto04(string SCLLinStack, string Logtype, string Magessadd)
+ {
+ WriteLog.Write_Log("椤舵ゼ绌烘墭鍥炲簱", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
+ }
+
}
}
--
Gitblit v1.9.3