Files
T-DAS/Epost.TestToolsWeb/Controllers/WebAPIController.cs
2025-06-19 16:50:57 +08:00

114 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
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;
JobCache.UpdateJobDownModelList(new List<ResultMessageModel>() { data }, EdownCommend.Create);
}
if (data.Command == "JOB_Fail")
{
LabelParamModel lbmodel = new LabelParamModel();
lbmodel.Address = data.Address;
lbmodel.Uid = data.Address;
lbmodel.Type = data.Type;
combll.FORMAT_DEVICE(lbmodel);
LogHelper.WriteLogInfo("设备报错:"+JsonHelper.SerializeObject(data), Log_Type.ERROR);
}
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("设备返回异常:" + ex.Message);
}
string sendStr = "OK";
return sendStr;
}
}
}