diff --git a/Common/AgvHelper.cs b/Common/AgvHelper.cs
index 4abcc97..7040b18 100644
--- a/Common/AgvHelper.cs
+++ b/Common/AgvHelper.cs
@@ -1,6 +1,7 @@
using Epost.Model;
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,18 +10,19 @@ namespace Epost.Common
{
public class AgvHelper
{
+ string agvUrl = ConfigurationManager.AppSettings["agvUrl"];
HttpHelper http = new HttpHelper();
#region 生成任务单
- public AgvResultModel genAgvSchedulingTask(AgvReqModel model)
+ public AgvResultModel genAgvSchedulingTask(AgvSchedulingTaskModel model)
{
- string url = string.Empty;
+
AgvResultModel resmodel = new AgvResultModel();
try
- {
+ {
string postData = JsonHelper.SerializeObject(model);
LogHelper.WriteLogInfo("调用AGV生成任务单接口请求参数" + postData, LogHelper.Log_Type.INFO);
- string res = http.HttpPost_Old(url, postData);
+ string res = http.HttpPost_Old(agvUrl, postData);
LogHelper.WriteLogInfo("调用AGV生成任务单接口返回" + res, LogHelper.Log_Type.INFO);
if (!string.IsNullOrEmpty(res))
{
diff --git a/Common/Epost.Common.csproj b/Common/Epost.Common.csproj
index 4fd6707..db918ce 100644
--- a/Common/Epost.Common.csproj
+++ b/Common/Epost.Common.csproj
@@ -123,6 +123,7 @@
+
diff --git a/Common/Time_TaskHelper.cs b/Common/Time_TaskHelper.cs
new file mode 100644
index 0000000..0c442ce
--- /dev/null
+++ b/Common/Time_TaskHelper.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Epost.Common
+{
+ public class Time_TaskHelper
+ {
+ public event System.Timers.ElapsedEventHandler ExecuteTask;
+
+ private static readonly Time_TaskHelper _task = null;
+ private System.Timers.Timer _timer = null;
+ //定义时间
+ private int _interval = 1000;
+ public int Interval
+ {
+ set
+ {
+ _interval = value;
+ }
+ get
+ {
+ return _interval;
+ }
+ }
+
+ static Time_TaskHelper()
+ {
+ _task = new Time_TaskHelper();
+ }
+
+ public static Time_TaskHelper Instance()
+ {
+ return _task;
+ }
+
+ //开始
+ public void Start()
+ {
+ if (_timer == null)
+ {
+ _timer = new System.Timers.Timer(_interval);
+ _timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed);
+ _timer.Enabled = true;
+ _timer.Start();
+ }
+ }
+
+ protected void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ if (null != ExecuteTask)
+ {
+ ExecuteTask(sender, e);
+ }
+ }
+
+ //停止
+ public void Stop()
+ {
+ if (_timer != null)
+ {
+ _timer.Stop();
+ _timer.Dispose();
+ _timer = null;
+ }
+ }
+
+ }
+}
diff --git a/Epost.BLL/InboundOrdersBLL.cs b/Epost.BLL/InboundOrdersBLL.cs
index a234607..f07c26a 100644
--- a/Epost.BLL/InboundOrdersBLL.cs
+++ b/Epost.BLL/InboundOrdersBLL.cs
@@ -37,11 +37,34 @@ namespace Epost.BLL
}
#endregion
+
+ #region 查询订单信息
+ public DataTable GetInOrderList(string strwhere)
+ {
+ return dal.GetInOrderList(strwhere);
+ }
+ #endregion
#region 添加订单
public bool InsertOrder(DataTable dt, Dictionary diclist)
{
return dal.InsertOrders(dt, diclist);
}
#endregion
+
+ #region 更新订单状态
+ public bool UpInOrderList(string id, string state,string data="")
+ {
+
+ return dal.UpInOrderList(id,state,data);
+ }
+ #endregion
+
+ #region 根据agv单号更新订单状态
+ public bool UpInOrderListByAgvid(string agvid, string state)
+ {
+
+ return dal.UpInOrderListByAgvid(agvid, state);
+ }
+ #endregion
}
}
diff --git a/Epost.DAL/InboundOrdersDAL.cs b/Epost.DAL/InboundOrdersDAL.cs
index fa8831b..76a90ac 100644
--- a/Epost.DAL/InboundOrdersDAL.cs
+++ b/Epost.DAL/InboundOrdersDAL.cs
@@ -79,5 +79,44 @@ namespace Epost.DAL
return db.UpdateData(dt, "InboundOrders", diclist);
}
#endregion
+
+ #region 查询订单信息
+ public DataTable GetInOrderList(string strwhere)
+ {
+ string sql = string.Format("select * from InboundOrders where 1=1 "+strwhere);
+ return db.GetsqlForDT(sql);
+ }
+ #endregion
+
+ #region 更新订单状态
+ public bool UpInOrderList(string id,string state,string data)
+ {
+ string upstr = string.Empty;
+ if (string.IsNullOrEmpty(data))
+ {
+ upstr = ",agvid='"+data+"'";
+ }
+ string sql = string.Format("update InboundOrders set state ='{0}'"+ upstr + " where id ='{1}'",
+ state,id);
+ long x= db.UpdateSql(sql);
+ if (x > 0)
+ return true;
+ return false;
+ }
+ #endregion
+
+ #region 根据agv单号更新订单状态
+ public bool UpInOrderListByAgvid(string agvid, string state)
+ {
+
+ string sql = string.Format("update InboundOrders set state ='{0}' where agvid = '{1}'",
+ state, agvid);
+ long x = db.UpdateSql(sql);
+ LogHelper.WriteLogInfo(x+"更新agv状态"+sql);
+ if (x > 0)
+ return true;
+ return false;
+ }
+ #endregion
}
}
diff --git a/Epost.Model/AgvReqModel.cs b/Epost.Model/AgvReqModel.cs
index 969cefc..a2caf12 100644
--- a/Epost.Model/AgvReqModel.cs
+++ b/Epost.Model/AgvReqModel.cs
@@ -6,9 +6,7 @@ using System.Threading.Tasks;
namespace Epost.Model
{
- public class AgvReqModel
- {
- }
+
#region 生成任务单
public class AgvSchedulingTaskModel
@@ -74,31 +72,57 @@ namespace Epost.Model
#region 任务执行通知
+
public class agvCallbackModel
{
- public string reqCode { get; set; }
- public string reqTime { get; set; }
- public string cooX { get; set; }
- public string cooY { get; set; }
+ public string action { get; set; }
+ public string areaCode { get; set; }
+ public string berthCode { get; set; }
+ public string callCode { get; set; }
+ public string callTyp { get; set; }
+ public string clientCode { get; set; }
+ public float cooX { get; set; }
+ public float cooY { get; set; }
+ public string ctnrCode { get; set; }
+ public string ctnrTyp { get; set; }
+ public string currentCallCode { get; set; }
public string currentPositionCode { get; set; }
- public string data { get; set; }
+ public Data data { get; set; }
+ public string dstBinCode { get; set; }
+ public string eqpCode { get; set; }
+ public string indBind { get; set; }
+ public string layer { get; set; }
public string mapCode { get; set; }
public string mapDataCode { get; set; }
- public string stgBinCode { get; set; }
- public string method { get; set; }
- public string podCode { get; set; }
- public string podDir { get; set; }
- public string robotCode { get; set; }
- public string taskCode { get; set; }
- public string wbCode { get; set; }
+ public string mapShortName { get; set; }
public string materialLot { get; set; }
public string materialType { get; set; }
- public string ctnrCode { get; set; }
- public string ctnrType { get; set; }
+ public string method { get; set; }
+ public string orgCode { get; set; }
+ public string podCode { get; set; }
+ public string podDir { get; set; }
+ public string podNum { get; set; }
+ public string podTyp { get; set; }
+ public string relatedArea { get; set; }
+ public string reqCode { get; set; }
+ public string reqTime { get; set; }
public string roadWayCode { get; set; }
+ public string robotCode { get; set; }
public string seq { get; set; }
- public string eqpCode { get; set; }
+ public string stgBinCode { get; set; }
+ public string subTaskNum { get; set; }
+ public string taskCode { get; set; }
+ public string taskTyp { get; set; }
+ public string tokenCode { get; set; }
+ public string username { get; set; }
+ public string wbCode { get; set; }
+ public string whCode { get; set; }
}
+ public class Data
+ {
+ }
+
+
#endregion
}
diff --git a/Epost.TestToolsWeb/Controllers/AgvTaskApiController.cs b/Epost.TestToolsWeb/Controllers/AgvTaskApiController.cs
index ab86ea0..611e9e7 100644
--- a/Epost.TestToolsWeb/Controllers/AgvTaskApiController.cs
+++ b/Epost.TestToolsWeb/Controllers/AgvTaskApiController.cs
@@ -1,4 +1,5 @@
-using Epost.Common;
+using Epost.BLL;
+using Epost.Common;
using Epost.DAL.Cache;
using Epost.Model;
using System;
@@ -14,33 +15,50 @@ namespace Epost.DPS.Controllers
[RoutePrefix("api/AgvTaskApi")]
public class AgvTaskApiController : ApiController
{
- JobDownCacheDAL JobCache = new JobDownCacheDAL();
+ InboundOrdersBLL inboundBLL = new InboundOrdersBLL();
[Route("agvCallback")]
[HttpPost]
- public AgvResultModel agvCallback([FromBody] agvCallbackModel model)
+ public AgvResultModel agvCallback([FromBody]agvCallbackModel data)
{
AgvResultModel retModel = new AgvResultModel();
try
{
- LogHelper.WriteLogInfo("请求报文" + JsonHelper.SerializeObject(model));
+ LogHelper.WriteLogInfo("请求报文" + JsonHelper.SerializeObject(data));
+ string state = string.Empty;
+ if (data.method == "start")
+ {
+ state = "2";//任务开始启动
+ }
+ else if (data.method == "outbin") {
+ state = "3";//走出储位
+ }
+ else if (data.method == "end")
+ {
+ state = "4";
+ //更新任务已完成
+ }
+ else if (data.method == "cancel") { }
+ else { }
- ResultMessageModel data = new ResultMessageModel();
- data.Parameter = model.reqCode;
- data.Status = model.method;
- data.Address = model.taskCode;
- JobCache.UpdateJobDownModelList(new List() { data }, EdownCommend.Create);
+ inboundBLL.UpInOrderListByAgvid(data.taskCode,state);
+ //ResultMessageModel data = new ResultMessageModel();
+ //data.Parameter = model.reqCode;
+ //data.Status = model.method;
+ //data.Address = model.taskCode;
+ //JobCache.UpdateJobDownModelList(new List() { data }, EdownCommend.Create);
retModel.message = "成功!";
retModel.code = "0";
- retModel.reqCode = model.reqCode;
+ retModel.reqCode = data.reqCode;
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("agvPutTask异常:" + ex.ToString(), LogHelper.Log_Type.ERROR);
retModel.message = "请求接口异常!";
retModel.code = "-1";
- retModel.reqCode = model.reqCode;
+ retModel.reqCode = data.reqCode;
}
+
return retModel;
}
}
diff --git a/Epost.TestToolsWeb/Epost.DPS.csproj.user b/Epost.TestToolsWeb/Epost.DPS.csproj.user
index 4d10158..2eaafac 100644
--- a/Epost.TestToolsWeb/Epost.DPS.csproj.user
+++ b/Epost.TestToolsWeb/Epost.DPS.csproj.user
@@ -11,7 +11,7 @@
False
600
E:\WORK\代码管理\T系列\播种\Epost.TestToolsWeb\Properties\PublishProfiles\Toolsweb.pubxml
- Release|Any CPU
+ Debug|Any CPU
diff --git a/Epost.TestToolsWeb/Global.asax.cs b/Epost.TestToolsWeb/Global.asax.cs
index 7005b80..3b18649 100644
--- a/Epost.TestToolsWeb/Global.asax.cs
+++ b/Epost.TestToolsWeb/Global.asax.cs
@@ -1,7 +1,10 @@
-using Epost.Common;
+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;
@@ -12,11 +15,13 @@ 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();
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
@@ -25,12 +30,52 @@ namespace Epost.TestToolsWeb
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");
+ if (dt != null && dt.Rows.Count > 0)
+ {
+ foreach (DataRow row in dt.Rows) {
+ AgvHelper agv = new AgvHelper();
+ AgvSchedulingTaskModel reqmodel = new AgvSchedulingTaskModel();
+ reqmodel.reqCode =DateTime.Now.Month+DateTime.Now.Day+ row["id"].ToString();;
+ List positionList = new List();
+ Positioncodepath pathModel = new Positioncodepath();
+ pathModel.positionCode = row["spositionCode"].ToString();
+ pathModel.type = "05";//agv提供
+ positionList.Add(pathModel);
+ Positioncodepath pathModel2 = new Positioncodepath();
+ pathModel2.positionCode = row["dpositionCode"].ToString();
+ 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);
+ }
+ }
+ }
+ }
+ protected void Session_Start(object sender, EventArgs e)
+ {
+
+ // 在新会话启动时运行的代码
-
+ }
+
+
+
}
}
diff --git a/Epost.TestToolsWeb/Properties/PublishProfiles/Toolsweb.pubxml.user b/Epost.TestToolsWeb/Properties/PublishProfiles/Toolsweb.pubxml.user
index 23a1964..ea819e5 100644
--- a/Epost.TestToolsWeb/Properties/PublishProfiles/Toolsweb.pubxml.user
+++ b/Epost.TestToolsWeb/Properties/PublishProfiles/Toolsweb.pubxml.user
@@ -33,19 +33,19 @@
04/04/2018 15:45:12
- 11/22/2024 14:00:36
+ 11/22/2024 17:47:09
- 11/22/2024 14:00:36
+ 11/22/2024 17:47:09
02/24/2020 15:29:24
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:58
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:58
04/29/2020 16:50:14
@@ -63,31 +63,31 @@
10/23/2017 13:15:20
- 11/22/2024 14:00:21
+ 11/22/2024 17:46:59
- 11/22/2024 14:00:21
+ 11/22/2024 17:46:59
08/26/2020 18:09:48
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:59
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:59
- 11/22/2024 14:00:23
+ 11/22/2024 17:47:02
- 11/22/2024 14:00:23
+ 11/22/2024 17:47:02
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:58
- 11/22/2024 14:00:20
+ 11/22/2024 17:46:58
09/06/2018 11:57:11
@@ -5652,7 +5652,7 @@
05/30/2022 16:58:47
- 11/22/2024 14:00:24
+ 11/22/2024 17:47:03
04/04/2018 15:45:12
@@ -7572,7 +7572,7 @@
07/04/2022 14:22:38
- 11/01/2024 16:24:56
+ 11/22/2024 16:17:44
\ No newline at end of file
diff --git a/Epost.TestToolsWeb/Web.config b/Epost.TestToolsWeb/Web.config
index 0322702..5c71a5c 100644
--- a/Epost.TestToolsWeb/Web.config
+++ b/Epost.TestToolsWeb/Web.config
@@ -11,7 +11,7 @@
-
+
@@ -33,6 +33,8 @@
+
+