From ddd9612ed7cefe12c8ea33ced0711a0b9a3feb99 Mon Sep 17 00:00:00 2001 From: liudl <673013083@qq.com> Date: 星期日, 16 二月 2025 18:18:42 +0800 Subject: [PATCH] 修改接口 --- Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs index 8890284..b6d1173 100644 --- a/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs +++ b/Admin.NET/WCS.Application/OpenApi/DemoOpenApi.cs @@ -416,35 +416,41 @@ Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port+"鍏ュ簱鍙�"); var portno = ""; + var layer = "3"; switch (models.Port) { case "033": portno = "33"; + layer = "1"; break; case "039": portno = "39"; + layer = "1"; break; case "044": portno = "44"; + layer = "1"; break; case "051": portno = "51"; + layer = "1"; break; } //妫�娴嬪叆搴撳彛鐘舵�侊紝120涓哄彲鏀撅紝鍗犵敤鍒欎慨鏀逛负130 - - WcsDeviceDto mod = new WcsDeviceDto(); - var plcConn = mod.PLCUtil; + var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First(); + if (modPlc == null) + throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC"); + PLCUtil plcConn = new PLCUtil(modPlc); //鑾峰彇宸ヤ綅鐐逛綅淇℃伅 var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First(); - var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "PLC娴佺▼瀛�").First(); + var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "PLC").First(); var (res1, val) = plcConn.GetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos); if (val.ToString() == "120") { //璇诲彇鎴愬姛鍚庡啓鍏�130 - modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First(); + modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First(); var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "130");//鍗犵敤姝ゅ伐浣� if (ret.IsSucceed) { @@ -476,30 +482,37 @@ Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�"); var portno = ""; + var layer = "3"; switch (models.Port) { case "033": portno = "33"; + layer = "1"; break; case "039": portno = "39"; + layer = "1"; break; case "044": portno = "44"; + layer = "1"; break; case "051": portno = "51"; + layer = "1"; break; } - WcsDeviceDto mod = new WcsDeviceDto(); - var plcConn = mod.PLCUtil; + var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First(); + if (modPlc == null) + throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC"); + PLCUtil plcConn = new PLCUtil(modPlc); //鑾峰彇宸ヤ綅鐐逛綅淇℃伅 var listPlcDevice = _db.Queryable<WcsDevice>().Where(s=>s.LedIP != null && s.StationNum == portno).First(); var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "浠诲姟鍙�").First(); plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, models.TaskNo);//鍐欏叆浠诲姟鍙� // - modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First(); + modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First(); var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "140");//鍐欏叆寮�濮嬫斁璐т俊鍙� if (ret.IsSucceed) { @@ -532,27 +545,34 @@ Log.Information("鎺ユ敹WMS鍏ュ簱鏀捐揣纭锛屾斁璐у彛锛�" + models.Port + "鍏ュ簱鍙�"); var portno = ""; + var layer = "3"; switch (models.Port) { case "033": portno = "33"; + layer = "1"; break; case "039": portno = "39"; + layer = "1"; break; case "044": portno = "44"; + layer = "1"; break; case "051": portno = "51"; + layer = "1"; break; } - WcsDeviceDto mod = new WcsDeviceDto(); - var plcConn = mod.PLCUtil; + var modPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.Text == (layer + "灞傛墭鐩樿緭閫佺嚎")).First(); + if (modPlc == null) + throw Oops.Bah("鏈壘鍒拌緭閫佺嚎PLC"); + PLCUtil plcConn = new PLCUtil(modPlc); //鑾峰彇宸ヤ綅鐐逛綅淇℃伅 var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.LedIP != null && s.StationNum == portno).First(); - var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS娴佺▼瀛�").First(); + var modDevice = _db.Queryable<WcsPosition>().Where(s => s.StationNum == portno && s.Text == "WCS").First(); var ret = plcConn.SetPlcDBValue(modDevice.PosType, listPlcDevice.DbNumber, modDevice.PlcPos, "160");//鏀惧畬鎴� if (ret.IsSucceed) -- Gitblit v1.8.0