using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net.Http; using System.Text; using System.Web; using System.Web.Http; using System.Collections.Concurrent; using Newtonsoft.Json.Linq; using System.Threading; using System.Net; using System.Net.Http.Headers; using System.IO; using MisDataSaveDate; using WebApi; namespace MisDataSaveDate { /// /// AGV接口控制器 /// public class WebController : ApiController { readonly string headUrl = "/"; /// /// AGV请求进入接口(接收方) /// 接收AGV的进入请求并存储到数据库 /// /// AGV请求数据 /// 处理结果 [HttpPost] [Route("web/WEB_Request")] public HttpResponseMessage WEB_Request([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(WEB_BusinessLogic.WEB_Request(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// AGV请求进入接口(接收方) /// 接收AGV的进入请求并存储到数据库 /// /// AGV请求数据 /// 处理结果 [HttpPost] [Route("web/WEB_SpotCheckResultUpload")] public HttpResponseMessage WEB_SpotCheckResultUpload([FromBody] SpotCheckResult request) { var result = new MsgResHeader { code = 200, message = "", Data = null }; try { if (request == null) { throw new Exception("请求体不能为空"); } var response = CALL_Inerface_DataHandle.CALL_Inerface_SpotCheckResultUpload(request); int.TryParse(response["code"]?.ToString() ?? "500", out int remoteCode); result.code = remoteCode; result.message = response["message"]?.ToString() ?? ""; result.Data = response["data"]; } catch (Exception ex) { result.code = 500; result.message = ex.Message; } return new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(result), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// 磨合转序接口 /// 调用AGV转序接口,成功后执行转序存储过程 /// /// 转序请求数据 /// 处理结果 [HttpPost] [Route("web/WEB_RunningInTransfer")] public HttpResponseMessage WEB_RunningInTransfer([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(WEB_BusinessLogic.WEB_RunningInTransfer(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// 临工AGV网页按钮调度接口。 /// /// 调度请求数据 /// 处理结果 [HttpPost] [Route("web/LGAGV_Dispatch")] public HttpResponseMessage LGAGV_Dispatch([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(LGWEB_BusinessLogic.WEB_DispatchAGV(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// 临工AGV网页按钮放行接口。 /// /// 放行请求数据 /// 处理结果 [HttpPost] [Route("web/LGAGV_AllowLeave")] public HttpResponseMessage LGAGV_AllowLeave([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(LGWEB_BusinessLogic.WEB_AllowLeave(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// 批量读取PLC点位值接口 /// 前端传递TagTypeCodeID数组和工位号,返回对应点位的值 /// /// 请求数据,包含OpName和TagTypeCodeIDs数组 /// 返回对应TagTypeCodeID的值列表 [HttpPost] [Route("web/WEB_ReadPLCValues")] public HttpResponseMessage WEB_ReadPLCValues([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(WEB_BusinessLogic.WEB_ReadPLCValues(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } /// /// 写入PLC接口 /// 前端传递TagTypeCodeID、工位号和值,写入到PLC /// /// 请求数据,包含TagTypeCodeID、OpName和TagValue /// 写入结果 [HttpPost] [Route("web/WEB_WritePLC")] public HttpResponseMessage WEB_WritePLC([FromBody] JObject jobj) { return new HttpResponseMessage { Content = new StringContent(WEB_BusinessLogic.WEB_WritePLC(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json") }; } } }