From 008e1327f186c793508cb6f61b11ef6b5323ad89 Mon Sep 17 00:00:00 2001 From: chengsc <Demo@DESKTOP-CPA90BF> Date: 星期五, 13 九月 2024 14:28:22 +0800 Subject: [PATCH] 修改输送线交互问题 --- Admin.NET/WCS.Application/PLC/PLCCommon.cs | 460 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 450 insertions(+), 10 deletions(-) diff --git a/Admin.NET/WCS.Application/PLC/PLCCommon.cs b/Admin.NET/WCS.Application/PLC/PLCCommon.cs index 7faf0c6..7407266 100644 --- a/Admin.NET/WCS.Application/PLC/PLCCommon.cs +++ b/Admin.NET/WCS.Application/PLC/PLCCommon.cs @@ -1,4 +1,5 @@ -锘縰sing Microsoft.AspNetCore.SignalR; +锘縰sing Elastic.Clients.Elasticsearch.Tasks; +using Microsoft.AspNetCore.SignalR; using RazorEngine.Compilation.ImpromptuInterface.Dynamic; using System; using System.Collections.Generic; @@ -215,33 +216,32 @@ /// </summary> /// <param name="startStation"></param> /// <returns></returns> - public static PlcTaskInfo GetPlcIp(string startStation) + public static PLCUtil GetPlcIp(string startStation) { - PlcTaskInfo taskInfo = new PlcTaskInfo(); - + string strIp = ""; var conveyList1 = new List<string>() { "147", "145", "139", "137", "129", "127", "121", "119", "111", "109", "103", "101", "093", "091", "085", "083", "075", "073", "067", "065" }; var conveyList2 = new List<string>() { "252", "254", "260", "262", "272", "272", "278", "280", "288", "290", "294", "301", "307", "309", "315", "317", "325", "327", "331", "337" }; var conveyList3 = new List<string>() { "401", "402", "405", "406", "409", "410", "413", "414", "417", "418", "421", "422", "425", "426", "429", "430", "433", "434", "437", "438" }; if (conveyList1.Contains(startStation)) { - taskInfo.Ip = "10.18.51.110"; + strIp = "10.18.51.110"; } else if (conveyList2.Contains(startStation)) { - taskInfo.Ip = "10.18.51.120"; + strIp = "10.18.51.120"; } else if (conveyList3.Contains(startStation)) { - taskInfo.Ip = "10.18.51.130"; + strIp = "10.18.51.130"; } else { - throw new Exception("宸ヤ綅鏈煡璇㈠埌"); + throw Oops.Bah("宸ヤ綅鏈煡璇㈠埌"); } - - return taskInfo; + var plcConveyorConn = PLCTaskAction.listPlcConn.First(m => m.PlcIP == strIp); + return plcConveyorConn; } /// <summary> @@ -323,4 +323,444 @@ return taskInfo; } + + /// <summary> + /// 鏍规嵁宸烽亾鍜屽眰鏁扮‘瀹氬贩閬撳彛鍏ュ簱宸ヤ綅 + /// </summary> + /// <param name="endRoadway"></param> + /// <param name="ceng"></param> + /// <returns></returns> + public static string RoadwayToStationNum(string endRoadway, string ceng) + { + string stationNum = ""; + switch (endRoadway) + { + case "R01": + if (ceng == "1") + { + stationNum = "145"; + } + if (ceng == "2") + { + stationNum = "252"; + } + if (ceng == "3") + { + stationNum = "401"; + } + break; + case "R02": + if (ceng == "1") + { + stationNum = "137"; + } + if (ceng == "2") + { + stationNum = "260"; + } + if (ceng == "3") + { + stationNum = "405"; + } + break; + case "R03": + if (ceng == "1") + { + stationNum = "127"; + } + if (ceng == "2") + { + stationNum = "270"; + } + if (ceng == "3") + { + stationNum = "409"; + } + break; + case "R04": + if (ceng == "1") + { + stationNum = "119"; + } + if (ceng == "2") + { + stationNum = "278"; + } + if (ceng == "3") + { + stationNum = "413"; + } + break; + case "R05": + if (ceng == "1") + { + stationNum = "109"; + } + if (ceng == "2") + { + stationNum = "288"; + } + if (ceng == "3") + { + stationNum = "417"; + } + break; + case "R06": + if (ceng == "1") + { + stationNum = "101"; + } + if (ceng == "2") + { + stationNum = "301"; + } + if (ceng == "3") + { + stationNum = "421"; + } + break; + case "R07": + if (ceng == "1") + { + stationNum = "091"; + } + if (ceng == "2") + { + stationNum = "307"; + } + if (ceng == "3") + { + stationNum = "425"; + } + break; + case "R08": + if (ceng == "1") + { + stationNum = "83"; + } + if (ceng == "2") + { + stationNum = "315"; + } + if (ceng == "3") + { + stationNum = "429"; + } + break; + case "R09": + if (ceng == "1") + { + stationNum = "73"; + } + if (ceng == "2") + { + stationNum = "325"; + } + if (ceng == "3") + { + stationNum = "433"; + } + break; + case "R10": + if (ceng == "1") + { + stationNum = "65"; + } + if (ceng == "2") + { + stationNum = "337"; + } + if (ceng == "3") + { + stationNum = "437"; + } + break; + } + + return stationNum; + } + + + /// <summary> + /// 鏍规嵁宸ヤ綅鍙疯幏鍙栧搴斿贩閬� + /// </summary> + /// <param name="StationNum">鍏ュ嚭宸ヤ綅鍙�</param> + /// <returns>璺烘満鑱旀満</returns> + public static string GetRoadwayByStation(string StationNum) + { + string value = ""; + var conveyList1 = new List<string>() { "147", "145", "252", "254", "401", "402", }; + var conveyList2 = new List<string>() { "139", "137", "260", "262", "405", "406", }; + var conveyList3 = new List<string>() { "129", "127", "272", "270", "409", "410", }; + var conveyList4 = new List<string>() { "121", "119", "278", "280", "413", "414", }; + var conveyList5 = new List<string>() { "111", "109", "288", "290", "417", "418", }; + var conveyList6 = new List<string>() { "103", "101", "294", "301", "421", "422", }; + var conveyList7 = new List<string>() { "093", "091", "307", "309", "425", "426", }; + var conveyList8 = new List<string>() { "085", "083", "315", "317", "429", "430", }; + var conveyList9 = new List<string>() { "075", "073", "325", "327", "433", "434", }; + var conveyList10 = new List<string>() { "067", "065", "331", "337", "437", "438", }; + + if (conveyList1.Contains(StationNum)) + { + value = "R01"; + } + else if (conveyList2.Contains(StationNum)) + { + value = "R02"; + } + else if (conveyList3.Contains(StationNum)) + { + value = "R03"; + } + else if (conveyList4.Contains(StationNum)) + { + value = "R04"; + } + else if (conveyList5.Contains(StationNum)) + { + value = "R05"; + } + else if (conveyList6.Contains(StationNum)) + { + value = "R06"; + } + else if (conveyList7.Contains(StationNum)) + { + value = "R07"; + } + else if (conveyList8.Contains(StationNum)) + { + value = "R08"; + } + else if (conveyList9.Contains(StationNum)) + { + value = "R09"; + } + else if (conveyList10.Contains(StationNum)) + { + value = "R10"; + } + + return value; + } + + /// <summary> + /// 鏍规嵁宸烽亾鍙e嚭鍏ュ簱宸ヤ綅鍙疯幏鍙栧搴旀ゼ灞� + /// </summary> + /// <param name="StationNum">鍏ュ嚭宸ヤ綅鍙�</param> + /// <returns>璺烘満鑱旀満</returns> + public static string GetRoadwayByStationNew(string StationNum) + { + string value = ""; + //var conveyList1 = new List<string>() { "147", "145", "139", "137", "129", "127", "121", "119", "111", "109", "103", "101", "093", "091", "085", "083", "075", "073", "067", "065" }; + //var conveyList2 = new List<string>() { "252", "254", "260", "262", "272", "270", "278", "280", "288", "290", "294", "301", "307", "309", "315", "317", "325", "327", "331", "337" }; + //var conveyList3 = new List<string>() { "401", "402", "405", "406", "409", "410", "413", "414", "417", "418", "421", "422", "425", "426", "429", "430", "433", "434", "437", "438" }; + + var ipInfo = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine || s.Type == PLCTypeEnum.BoxConveyorLine); + var ip1 = ipInfo.First(m=>m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + var ip2 = ipInfo.First(m=>m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + var ip3 = ipInfo.First(m=>m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + + var dev1 = PLCTaskAction.plcDevices.Where(m => m.IsDelete == false && m.PlcId == ip1.Id).Select(m=>m.StationNum).ToList(); + var dev2 = PLCTaskAction.plcDevices.Where(m => m.IsDelete == false && m.PlcId == ip2.Id).Select(m => m.StationNum).ToList(); + var dev3 = PLCTaskAction.plcDevices.Where(m => m.IsDelete == false && m.PlcId == ip3.Id).Select(m => m.StationNum).ToList(); + + if (dev1.Contains(StationNum)) + { + value = "1"; + } + else if (dev2.Contains(StationNum)) + { + value = "2"; + } + else if (dev3.Contains(StationNum)) + { + value = "3"; + } + else + { + throw new Exception("宸ヤ綅鏈煡璇㈠埌"); + } + + return value; + } + + /// <summary> + /// 鏍规嵁宸烽亾鍙枫�佸眰鏁� 鑾峰彇瀵瑰簲鐨勮泛鏈篒P鍙婂叆搴撳伐浣嶆帓鍒楀眰淇℃伅 + /// </summary> + /// <param name="roadway">宸烽亾鍙�</param> + /// <param name="ceng">杩炴帴闆嗗悎</param> + /// <returns></returns> + public static StokInfo GetStokePlc(string roadway, string ceng) + { + + StokInfo sInfo = new StokInfo(); + sInfo.Pai = "2"; + + + switch (roadway) + { + case "R01": + sInfo.Ip = "10.18.51.10"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R02": + sInfo.Ip = "10.18.51.20"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R03": + sInfo.Ip = "10.18.51.30"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R04": + sInfo.Ip = "10.18.51.40"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R05": + sInfo.Ip = "10.18.51.50"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R06": + sInfo.Ip = "10.18.51.60"; + if (ceng == "2" || ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R07": + sInfo.Ip = "10.18.51.70"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R08": + sInfo.Ip = "10.18.51.80"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R09": + sInfo.Ip = "10.18.51.90"; + if (ceng == "1") + { + sInfo.Pai = "3"; + } + break; + case "R10": + sInfo.Ip = "10.18.51.100"; + if (ceng == "2" || ceng == "1") + { + sInfo.Pai = "3"; + } + break; + } + + sInfo.Lie = "65"; + sInfo.Ceng = "1"; + + if (ceng == "2") + { + sInfo.Ceng = "2"; + } + if (ceng == "3") + { + sInfo.Ceng = "3"; + } + return sInfo; + } + + + /// <summary> + /// 鏍规嵁鍌ㄤ綅鎺掕幏鍙栬泛鏈哄搴旂殑鍦板潃鎺� + /// </summary> + /// <param name="road">鎺�</param> + /// <param name="pai">鎺�</param> + /// <param name="dept">娣卞害</param> + /// <returns></returns> + public static int GetDjAdress(string road, string pai, string dept) + { + var roadNum = int.Parse(road); + var paiNum = int.Parse(pai); + var deptNum = int.Parse(dept); + + var paiVal = 0; + // 鍒ゆ柇宸烽亾濂囧伓鏁� + if (roadNum % 2 == 0)// 鍋舵暟 + { + // 鍒ゆ柇鎺掑鍋舵暟 + if (paiNum % 2 == 0) + { + if (deptNum == 1) + { + paiVal = 3; + } + else + { + paiVal = 4; + } + } + else + { + if (deptNum == 1) + { + paiVal = 1; + } + else + { + paiVal = 2; + } + } + + } + else // 濂囨暟 + { + // 鍒ゆ柇鎺掑鍋舵暟 + if (paiNum % 2 == 0) + { + if (deptNum == 1) + { + paiVal = 3; + } + else + { + paiVal = 4; + } + } + else + { + if (deptNum == 1) + { + paiVal = 2; + + } + else + { + paiVal = 1; + + } + } + } + + return paiVal; + + } + + } -- Gitblit v1.8.0