You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/InterfaceDocking/HttpResponse.cs

98 lines
2.8 KiB
C#

using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.InterfaceDocking
{
public class HttpResponse
{
1 year ago
public string PostResponse(TankIsDischargedSyncEntity taskIsDisChargedSyncEntity)
{
return Post("http://192.168.202.23:5001/api/ReceivingAndFeedingMaterials/TankIsDischargedSync", taskIsDisChargedSyncEntity.JsonTo());
1 year ago
}
public string PostUsed(int deCode, string used)
{
string stry = new LGusedEntity(deCode, used).JsonTo();
return Post("http://192.168.202.34:8080/mes/wcsInterface/saveLGusedLog", stry);
}
1 year ago
public Dictionary<int, string> GetLGInfo()
1 year ago
{
Dictionary<int, string> dic = new Dictionary<int, string>();
12 months ago
for (int i = 1; i <= 8; i++)
{
dic.Add(i, "");
}
try
{
12 months ago
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")
{
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;
}
1 year ago
}
1 year ago
private string Post(string url,string postData)
{
HttpItem item = new HttpItem()
{
1 year ago
1 year ago
URL = url, //URL 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/json",//返回类型 可选项有默认值
PostDataType = PostDataType.String,
PostEncoding = Encoding.UTF8,
1 year ago
Postdata = postData,
ResultType = ResultType.String
};
try
{
HttpResult httpResult = new HttpHelper().GetHtml(item);
return httpResult.Html;
}
catch (Exception ex)
{
string message = $" url:{item.URL} {Environment.NewLine} Data:{item.Postdata} {Environment.NewLine} 异常信息:{ex.Message}";
1 year ago
return message;
}
}
1 year ago
}
}