From e1380da7b356326c8444ba6189c59963a2c10232 Mon Sep 17 00:00:00 2001 From: gcw_MV9p2JJN Date: Wed, 28 Jan 2026 21:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Into/PlcIntoStationService_Common.cs | 8 ++--- .../Into/PlcIntoStationService_OP70_01.cs | 6 ++-- .../Into/PlcIntoStationService_OP80_01.cs | 33 +++++++------------ .../Into/PlcIntoStationService_OP80_03.cs | 8 ++--- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_Common.cs b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_Common.cs index 2d8b5d1..eefe2fd 100644 --- a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_Common.cs +++ b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_Common.cs @@ -63,10 +63,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into try { //心跳检测 "DB1010.DBW0" - await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, 1); + await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, (short)1); // 轮询进站请求信号/工位开始查询请求 "DB1001.DBW2000" - int intoStationAsk = await _plcService.ReadAsync(plcSetting.intoStation.IntoStationAsk); + short intoStationAsk = await _plcService.ReadAsync(plcSetting.intoStation.IntoStationAsk); if (intoStationAsk == 1) { // 处理进站请求 @@ -91,7 +91,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into { ProductSN = productSN, WorkstationCode = WorkstationCode, - Routingcode = processOperations.First().FkRoutingCode, + Routingcode = processOperations?.First()?.FkRoutingCode??"", OperationCode = WorkstationCode, OperationName= plcSetting.WorkStationName, ProductionLifeStage = 1, // 1表示生产中 @@ -104,7 +104,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into //判断该产品是否允许进站 EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations); // "DB1010.DBW2000" - await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (int)result); + await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (short)result); } await Task.Delay(_pollingInterval, stoppingToken); diff --git a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP70_01.cs b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP70_01.cs index f35d459..8359cab 100644 --- a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP70_01.cs +++ b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP70_01.cs @@ -61,10 +61,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into try { //心跳检测 "DB1010.DBW0" - await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, 1); + await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, (short)1); // 轮询进站请求信号/工位开始查询请求 "DB1001.DBW2000" - int intoStationAsk = await _plcService.ReadAsync(plcSetting.intoStation.IntoStationAsk); + short intoStationAsk = await _plcService.ReadAsync(plcSetting.intoStation.IntoStationAsk); if (intoStationAsk == 1) { // 处理进站请求 @@ -102,7 +102,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into //判断该产品是否允许进站 EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations); // "DB1010.DBW2000" - await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (int)result); + await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (short)result); } await Task.Delay(_pollingInterval, stoppingToken); diff --git a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_01.cs b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_01.cs index 0ea0ab9..be6f804 100644 --- a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_01.cs +++ b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_01.cs @@ -30,7 +30,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into private string WorkstationCode; private readonly SqlSugarClient Context; - + public PlcIntoStationService_OP80_01() { Context = DbScoped.SugarScope.CopyNew(); @@ -55,10 +55,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into try { //心跳检测 - await _plcService.WriteAsync("DB1020.DBW0", 1); + await _plcService.WriteAsync("DB1020.DBW0", (short)1); // 轮询进站请求信号/工位开始查询请求 - int intoStationAsk = await _plcService.ReadAsync("DB1017.DBW2000"); + short intoStationAsk = await _plcService.ReadAsync("DB1017.DBW2000"); if (intoStationAsk == 1) { // 处理进站请求 @@ -67,11 +67,11 @@ namespace RIZO.Service.PLCBackground.Stations.Into //获取产品SN码 string productModel = await _plcService.ReadStringAsync("DB1017.DBB1000"); string productSN = await _plcService.ReadStringAsync("DB1017.DBB1054"); - int ReWorkFlag = await _plcService.ReadAsync("DB1017.DBW8"); + short ReWorkFlag = await _plcService.ReadAsync("DB1017.DBW8"); //判断改产品是正常件还是返工件 if (ReWorkFlag == 2) - { - + { + } // 获取工单 @@ -79,21 +79,13 @@ namespace RIZO.Service.PLCBackground.Stations.Into List processOperations = await Context.Queryable().LeftJoin((r, o) => r.RoutingCode == o.FkRoutingCode) .Where((r, o) => r.FkProductMaterialCode == productModel && r.Status == 1) .Select((r, o) => o).ToListAsync(); - var routingcode = string.Empty; - try - { - routingcode = processOperations.First().FkRoutingCode; - } - catch - { } - if (routingcode == null || routingcode.Length == 0) - return; + //插入入站请求ASK过站记录 ProductPassStationRecord ASKintoStation = new ProductPassStationRecord { ProductSN = productSN, WorkstationCode = WorkstationCode, - Routingcode = routingcode, + Routingcode = processOperations?.FirstOrDefault()?.FkRoutingCode ?? "", OperationCode = WorkstationCode, ProductionLifeStage = 1, // 1表示生产中 PasstationType = 0, // 0表示入站请求 @@ -105,9 +97,8 @@ namespace RIZO.Service.PLCBackground.Stations.Into //判断该产品是否允许进站 EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations); //进站请求结果 - await _plcService.WriteAsync2("DB1317.DBW2000", (int)result); - //设别使能1 - await _plcService.WriteAsync2("DB1317.DBW0", 1); + await _plcService.WriteAsync("DB1317.DBW2000", (short)result); + } await Task.Delay(_pollingInterval, stoppingToken); @@ -227,7 +218,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into //OK 准许进站 result = EntryPermissionResult.AllowIntoStation; goto InsertPassrecord; - InsertPassrecord: + InsertPassrecord: //插入入站请求Resp过站记录 ProductPassStationRecord RespintoStation = new ProductPassStationRecord { @@ -252,7 +243,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into { return EntryPermissionResult.PreviousStationDataAbnormal; } - + } diff --git a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_03.cs b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_03.cs index ada68f1..51cf5c0 100644 --- a/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_03.cs +++ b/RIZO.Service/PLCBackground/Stations/Into/PlcIntoStationService_OP80_03.cs @@ -52,10 +52,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into try { //心跳检测 - await _plcService.WriteAsync("DB1020.DBW0", 1); + await _plcService.WriteAsync("DB1020.DBW0", (short)1); // 轮询进站请求信号/工位开始查询请求 - int intoStationAsk = await _plcService.ReadAsync("DB1021.DBW2000"); + short intoStationAsk = await _plcService.ReadAsync("DB1021.DBW2000"); if (intoStationAsk == 1) { // 处理进站请求 @@ -79,7 +79,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into { ProductSN = productSN, WorkstationCode = WorkstationCode, - Routingcode = processOperations.First().FkRoutingCode, + Routingcode = Routingcode = processOperations?.FirstOrDefault()?.FkRoutingCode ?? "", OperationCode = WorkstationCode, ProductionLifeStage = 1, // 1表示生产中 PasstationType = 0, // 0表示入站请求 @@ -90,7 +90,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into await Context.Insertable(ASKintoStation).ExecuteCommandAsync(); //判断该产品是否允许进站 EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations); - await _plcService.WriteAsync("DB1020.DBW2000", (int)result); + await _plcService.WriteAsync("DB1020.DBW2000", (short)result); } await Task.Delay(_pollingInterval, stoppingToken);