Files
T-DAS/Epost.TestToolsWeb/Controllers/WebAPIController.cs

115 lines
4.0 KiB
C#
Raw Permalink Normal View History

2023-01-13 15:30:20 +08:00
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();
2025-06-30 10:14:05 +08:00
data.Info = sdt.Rows[0]["info"].ToString();
2023-01-13 15:30:20 +08:00
}
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<ResultMessageModel>() { data }, EdownCommend.Create);
}
if (data.Command == "JOB_DONE")
{
data.Status = "0";
data.Port = data.Loc;
data.IsChange =data.Result;
data.Parameter =data.Quantity;
2025-06-28 09:40:33 +08:00
JobCache.UpdateJobDownModelList(new List<ResultMessageModel>() { data }, EdownCommend.Create);
2023-01-13 15:30:20 +08:00
}
2025-06-28 09:40:33 +08:00
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);
}
2023-01-13 15:30:20 +08:00
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("设备返回异常:" + ex.Message);
}
string sendStr = "OK";
return sendStr;
}
}
}