From a6567eda2a1bfb040b3b6ef0aaae3af30aebb960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 8 Dec 2023 16:48:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9C=89=E7=83=9F=E6=97=A0=E7=83=9F?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterfaceDocking/GetLGInfoEntity.cs | 4 ++ .../InterfaceDocking/HttpResponse.cs | 37 ++++++++++++++++++- .../Test/TestAction.cs | 6 +-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/GetLGInfoEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/GetLGInfoEntity.cs index 29b0a4d..bc45cc9 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/GetLGInfoEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/GetLGInfoEntity.cs @@ -16,6 +16,10 @@ namespace Mesnac.Action.ChemicalWeighing.InterfaceDocking } + + + + public class GetLGResJson { public int code { get; set; } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs index 8201713..2cbb254 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs @@ -1,4 +1,8 @@ using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + using System; using System.Collections.Generic; using System.Linq; @@ -24,10 +28,39 @@ namespace Mesnac.Action.ChemicalWeighing.InterfaceDocking } - public string GetLGInfo() + public Dictionary GetLGInfo() { + Dictionary dic = new Dictionary(); + for (int i = 1; i <=8; i++) + { + dic.Add(i, ""); + } string stry = new GetLGInfoEntity().JsonTo(); - return Post("http://192.168.202.34:30000/prod-api/open/openInterface/getLGInfo", stry); + var str= Post("http://192.168.202.34:30000/prod-api/open/openInterface/getLGInfo", stry); + + try + { + var job = JObject.Parse(str); + if (job["code"].ToString()== "200") + { + JArray arr = job["data"] as JArray; + foreach (JObject item in arr) + { + var key = Convert.ToInt32(item["bucketCode"].ToString().Replace("L", "")); + var value = item["materialCode"].ToString() == "mix01" ? "有烟" : "无烟"; + dic[key] = value; + + } + } + + return dic; + + } + catch (Exception ex) + { + + return dic; + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs index c0a4367..ee0d65f 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs @@ -16,7 +16,7 @@ using ICSharpCode.Core; using log4net; using Mesnac.Action.Base; - +using Mesnac.Action.ChemicalWeighing.InterfaceDocking; using Mesnac.Action.ChemicalWeighing.LjReport.OpenDoor; using Mesnac.Action.ChemicalWeighing.MinAn; using Mesnac.Action.ChemicalWeighing.Report; @@ -43,7 +43,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test public void theout(object source, EventArgs e) { - + // ReportReadDb.Read(); } public void Run(RuntimeParameter runtime) @@ -81,7 +81,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test private void MCButton_Click(object sender, EventArgs e) { - ReportReadDb.Read(); + new HttpResponse().GetLGInfo(); } } } From 71e4afb05d3b2c7d6ae3521b64f8931a743465db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 8 Dec 2023 16:56:42 +0800 Subject: [PATCH 2/2] GetLGInfo --- .../InterfaceDocking/HttpResponse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs index 2cbb254..f5024f8 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs @@ -31,15 +31,15 @@ namespace Mesnac.Action.ChemicalWeighing.InterfaceDocking public Dictionary GetLGInfo() { Dictionary dic = new Dictionary(); - for (int i = 1; i <=8; i++) + for (int i = 1; i <= 8; i++) { dic.Add(i, ""); } - string stry = new GetLGInfoEntity().JsonTo(); - var str= Post("http://192.168.202.34:30000/prod-api/open/openInterface/getLGInfo", stry); try { + string stry = new GetLGInfoEntity().JsonTo(); + var str = Post("http://192.168.202.34:30000/prod-api/open/openInterface/getLGInfo", stry); var job = JObject.Parse(str); if (job["code"].ToString()== "200") {