using ComposerSDK; using Epost.BLL; using Epost.Common; using Epost.DAL.Cache; using Epost.DAL.Enum; using Epost.DPS.Controllers; using Epost.Model; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Net; using System.Net.Http; using System.Threading; using System.Web.Http; using static Epost.Common.LogHelper; using static Epost.DAL.Enum.ShowViewType; namespace Epost.TestToolsWeb.Controllers { [RoutePrefix("api/WebAPI")] public class WebAPIController : ApiController { BLL.OrderBLL orderBLL = new BLL.OrderBLL(); BLL.CommandBLL combll = new BLL.CommandBLL(); BLL.AddressstorageBLL addrbll = new BLL.AddressstorageBLL(); JobModelCacheDAL cache = new JobModelCacheDAL(); ScanModelCacheDAL ScanCache = new ScanModelCacheDAL(); UserModelCacheDAL userCache = new UserModelCacheDAL(); JobDownCacheDAL downCache = new JobDownCacheDAL(); OrdersQueueBLL qubll = new OrdersQueueBLL(); XgateCacheDAL xageDAL = new XgateCacheDAL(); BoxQueueBLL quboxbll = new BoxQueueBLL(); JobDownCacheDAL JobCache = new JobDownCacheDAL(); HttpHelper http = new HttpHelper(); [Route("ProcessingResult")] [HttpPost] public string ProcessingResult([FromBody]ResultMessageModel data) { try { LogHelper.WriteLogInfo(JsonHelper.SerializeObject(data)); LogHelper.WriteLogInfo("设备拍下:IP:" + data.IP + "Address:" + data.Address + "Command:" + data.Command + "Uid:" + data.Uid +"===Loc:" + data.Loc+"===Quantity:" + data.Quantity + "===W_Quanitty:" + data.W_Quantity + "===RFcode:" + data.Rfcode+ "===Result:" + data.Result+ "===Parameter:" + data.Parameter, Log_Type.JOB_DONE); DataTable sdt = orderBLL.getArea(data.Address,data.IP); if (sdt != null && sdt.Rows.Count > 0) { data.Area = sdt.Rows[0]["area"].ToString(); data.Block = sdt.Rows[0]["Block"].ToString(); data.Type = sdt.Rows[0]["type"].ToString(); data.Way = sdt.Rows[0]["way"].ToString(); data.Info = sdt.Rows[0]["info"].ToString(); } if (data.Command == "QUERY_SPECIAL_STATUS")//扫描枪返回 { LogHelper.WriteLogInfo("*************Command:" + data.Command + "Parameter:" + data.Parameter, Log_Type.JOB_DONE); string scanStr = data.Parameter.Trim(); data.Parameter = scanStr; data.ScanCode = scanStr; // JobDownCacheDAL JobCache = new JobDownCacheDAL(); data.Status = "0"; JobCache.UpdateJobDownModelList(new List() { data }, EdownCommend.Create); } if (data.Command == "JOB_DONE") { data.Status = "0"; data.Port = data.Loc; data.IsChange =data.Result; data.Parameter =data.Quantity; JobCache.UpdateJobDownModelList(new List() { data }, EdownCommend.Create); } if (data.Command == "JOB_Fail") { LogHelper.WriteLogInfo("设备报错:" + JsonHelper.SerializeObject(data), Log_Type.ERROR); ErrorLogModel errmodel = new ErrorLogModel(); errmodel.Address = data.Address; errmodel.ControlIP = data.IP; addrbll.UpdateErrorState(data.Address, data.IP); } } catch (Exception ex) { LogHelper.WriteLogInfo("设备返回异常:" + ex.Message); } string sendStr = "OK"; return sendStr; } } }