Files
T-DAS/Epost.TestToolsWeb/Global.asax.cs

96 lines
3.7 KiB
C#
Raw Normal View History

2024-11-23 20:47:14 +08:00
using Epost.BLL;
using Epost.Common;
using Epost.Model;
2023-01-13 15:30:20 +08:00
using Epost.TestToolsWeb.App_Start;
using System;
using System.Collections.Generic;
2024-11-23 20:47:14 +08:00
using System.Data;
2023-01-13 15:30:20 +08:00
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;
2024-11-23 20:47:14 +08:00
using System.Web.WebSockets;
2023-01-13 15:30:20 +08:00
namespace Epost.TestToolsWeb
{
public class MvcApplication : System.Web.HttpApplication
{
2024-12-03 10:55:54 +08:00
InboundOrdersBLL inboundBLL = new InboundOrdersBLL();
AgvHelper agv = new AgvHelper();
2023-01-13 15:30:20 +08:00
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
2024-11-23 20:47:14 +08:00
Time_TaskHelper.Instance().ExecuteTask += new System.Timers.ElapsedEventHandler(Global_ExecuteTask);
Time_TaskHelper.Instance().Interval = 1000 * 10;//表示间隔
Time_TaskHelper.Instance().Start();
2023-01-13 15:30:20 +08:00
}
2024-11-23 20:47:14 +08:00
void Global_ExecuteTask(object sender, System.Timers.ElapsedEventArgs e)
{
//在这里编写需要定时执行的逻辑代码
LogHelper.WriteLogInfo("任务执行中");
2024-12-27 16:54:02 +08:00
DataTable dt = inboundBLL.GetInOrderList(" and state =0 order by priority,id");
2024-11-23 20:47:14 +08:00
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows) {
2024-12-03 10:55:54 +08:00
2024-11-23 20:47:14 +08:00
AgvSchedulingTaskModel reqmodel = new AgvSchedulingTaskModel();
2024-12-04 17:04:16 +08:00
reqmodel.reqCode = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()+ row["id"].ToString();;
2024-11-23 20:47:14 +08:00
List<Positioncodepath> positionList = new List<Positioncodepath>();
Positioncodepath pathModel = new Positioncodepath();
2024-12-05 14:36:37 +08:00
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
2024-11-23 20:47:14 +08:00
pathModel.type = "05";//agv提供
positionList.Add(pathModel);
Positioncodepath pathModel2 = new Positioncodepath();
2024-12-05 14:36:37 +08:00
pathModel2.positionCode = inboundBLL.GetLocation(" and wmsloc = '"+ row["dpositionCode"].ToString() + "'",out type );
2024-11-23 20:47:14 +08:00
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成功 更新订单状态
2024-12-02 13:53:56 +08:00
inboundBLL.UpInOrderList(row["id"].ToString(), "1", res.data);
}
else if (res.code == "1")
{
inboundBLL.UpInOrder(row["id"].ToString(),"AGV告警"+res.message);
2024-11-23 20:47:14 +08:00
}
}
}
}
protected void Session_Start(object sender, EventArgs e)
{
2023-01-13 15:30:20 +08:00
2024-11-23 20:47:14 +08:00
// 在新会话启动时运行的代码
2023-01-13 15:30:20 +08:00
2024-11-23 20:47:14 +08:00
}
2023-01-13 15:30:20 +08:00
}
}