Files
T-DAS/Epost.TestToolsWeb/Global.asax.cs
2024-12-27 16:54:02 +08:00

96 lines
3.7 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 Epost.BLL;
using Epost.Common;
using Epost.Model;
using Epost.TestToolsWeb.App_Start;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Timers;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.WebSockets;
namespace Epost.TestToolsWeb
{
public class MvcApplication : System.Web.HttpApplication
{
InboundOrdersBLL inboundBLL = new InboundOrdersBLL();
AgvHelper agv = new AgvHelper();
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
Time_TaskHelper.Instance().ExecuteTask += new System.Timers.ElapsedEventHandler(Global_ExecuteTask);
Time_TaskHelper.Instance().Interval = 1000 * 10;//表示间隔
Time_TaskHelper.Instance().Start();
}
void Global_ExecuteTask(object sender, System.Timers.ElapsedEventArgs e)
{
//在这里编写需要定时执行的逻辑代码
LogHelper.WriteLogInfo("任务执行中");
DataTable dt = inboundBLL.GetInOrderList(" and state =0 order by priority,id");
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows) {
AgvSchedulingTaskModel reqmodel = new AgvSchedulingTaskModel();
reqmodel.reqCode = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()+ row["id"].ToString();;
List<Positioncodepath> positionList = new List<Positioncodepath>();
Positioncodepath pathModel = new Positioncodepath();
string type = string.Empty;
pathModel.positionCode = inboundBLL.GetLocation(" and wmsloc ='"+ row["spositionCode"].ToString() + "'",out type);
#region --
if (type == "1")
{
LogHelper.WriteLogInfo("绑定点位"+ pathModel.positionCode);
agv.bindCtnrAndBin(pathModel.positionCode, type);
}
#endregion
pathModel.type = "05";//agv提供
positionList.Add(pathModel);
Positioncodepath pathModel2 = new Positioncodepath();
pathModel2.positionCode = inboundBLL.GetLocation(" and wmsloc = '"+ row["dpositionCode"].ToString() + "'",out type );
pathModel2.type = "05";
positionList.Add(pathModel2);
reqmodel.positionCodePath = positionList;
reqmodel.taskTyp = "ZY01";//agv提供
reqmodel.ctnrTyp = "1";
AgvResultModel res= agv.genAgvSchedulingTask(reqmodel);
if (res.code == "0")
{
//调用agv成功 更新订单状态
inboundBLL.UpInOrderList(row["id"].ToString(), "1", res.data);
}
else if (res.code == "1")
{
inboundBLL.UpInOrder(row["id"].ToString(),"AGV告警"+res.message);
}
}
}
}
protected void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码
}
}
}