From 3b4ab19a4b05e098e971746c692a0d012fde7445 Mon Sep 17 00:00:00 2001 From: liudl <673013083@qq.com> Date: 星期五, 26 九月 2025 17:49:12 +0800 Subject: [PATCH] 修改问题 --- Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 129 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 121 insertions(+), 8 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs index c0c19d2..b27be3b 100644 --- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs +++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs @@ -6,6 +6,7 @@ using System.Drawing.Drawing2D; using WCS.Application.Entity; using WCS.Application.Service.WcsDevice.Dto; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinComponentApiGetAuthorizerInfoResponse.Types.Authorizer.Types; namespace WCS.Application; @@ -52,7 +53,7 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; break; case "2": modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); @@ -64,7 +65,7 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; break; default: throw Oops.Bah("妤煎眰淇℃伅閿欒"); @@ -115,7 +116,7 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB1100"; break; case "2": modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); @@ -127,7 +128,7 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB1100"; break; default: throw Oops.Bah("妤煎眰淇℃伅閿欒"); @@ -167,6 +168,11 @@ data.EndLie = value10.ToString(); var (result11, value11) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48"); data.EndCeng = value11.ToString(); + + var (result12, value12) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Byte, DbNum, "50"); + data.ChanMo = value12.ToString(); + var (result13, value13) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Byte, DbNum, "51"); + data.ChaiMo = value13.ToString(); modUtil.Close(); return data; @@ -477,7 +483,8 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; + TaskDbNum = "DB1100"; break; case "2": modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); @@ -490,7 +497,8 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; + TaskDbNum = "DB1100"; break; default: throw Oops.Bah("妤煎眰淇℃伅閿欒"); @@ -543,6 +551,11 @@ Thread.Sleep(1000); modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.2", "false"); break; + case "applyTask": + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.1", "true"); + Thread.Sleep(1000); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.1", "false"); + break; default: break; @@ -573,7 +586,71 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌1妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; + PLCUtil modUtil = new PLCUtil(modPlc); + switch (input.Type) + { + case "OnePalletStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "OnePalletStop": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "OneBoxStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.2", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.2", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "OneBoxStop": + + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.3", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.3", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + default: + break; + } + modUtil.Close(); } else if (input.Layer == "2") { @@ -707,7 +784,42 @@ modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); if (modPlc == null) throw Oops.Bah($"鏈煡璇㈠埌3妤煎眰PLC淇℃伅"); - DbNum = ""; + DbNum = "DB91"; + PLCUtil modUtil = new PLCUtil(modPlc); + switch (input.Type) + { + case "ThreePalletStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "ThreePalletStop": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + default: + break; + } + modUtil.Close(); } else { @@ -742,6 +854,7 @@ .WhereIF(input.PlcId > 0, u => u.PlcId == input.PlcId) .WhereIF(!string.IsNullOrWhiteSpace(input.StationNum), u => u.StationNum.Contains(input.StationNum.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.Text), u => u.Text.Contains(input.Text.Trim())) + .WhereIF(input.DeviceType.HasValue, u => u.DeviceType == input.DeviceType) //澶勭悊澶栭敭鍜孴reeSelector鐩稿叧瀛楁鐨勮繛鎺� .LeftJoin<WcsPlc>((u, plcid) => u.PlcId == plcid.Id) .Select((u, plcid) => new WcsDeviceOutput -- Gitblit v1.8.0