This commit is contained in:
jl
2024-11-23 20:47:14 +08:00
parent 48afa11af7
commit 068fe0a148
11 changed files with 279 additions and 53 deletions

View File

@ -1,6 +1,7 @@
using Epost.Model; using Epost.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -9,18 +10,19 @@ namespace Epost.Common
{ {
public class AgvHelper public class AgvHelper
{ {
string agvUrl = ConfigurationManager.AppSettings["agvUrl"];
HttpHelper http = new HttpHelper(); HttpHelper http = new HttpHelper();
#region #region
public AgvResultModel genAgvSchedulingTask(AgvReqModel model) public AgvResultModel genAgvSchedulingTask(AgvSchedulingTaskModel model)
{ {
string url = string.Empty;
AgvResultModel resmodel = new AgvResultModel(); AgvResultModel resmodel = new AgvResultModel();
try try
{ {
string postData = JsonHelper.SerializeObject(model); string postData = JsonHelper.SerializeObject(model);
LogHelper.WriteLogInfo("调用AGV生成任务单接口请求参数" + postData, LogHelper.Log_Type.INFO); 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); LogHelper.WriteLogInfo("调用AGV生成任务单接口返回" + res, LogHelper.Log_Type.INFO);
if (!string.IsNullOrEmpty(res)) if (!string.IsNullOrEmpty(res))
{ {

View File

@ -123,6 +123,7 @@
<Compile Include="ModelConvertHelper.cs" /> <Compile Include="ModelConvertHelper.cs" />
<Compile Include="PingHelper.cs" /> <Compile Include="PingHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Time_TaskHelper.cs" />
<Compile Include="XmlHelper.cs" /> <Compile Include="XmlHelper.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

72
Common/Time_TaskHelper.cs Normal file
View File

@ -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;
}
}
}
}

View File

@ -37,11 +37,34 @@ namespace Epost.BLL
} }
#endregion #endregion
#region
public DataTable GetInOrderList(string strwhere)
{
return dal.GetInOrderList(strwhere);
}
#endregion
#region #region
public bool InsertOrder(DataTable dt, Dictionary<string, string> diclist) public bool InsertOrder(DataTable dt, Dictionary<string, string> diclist)
{ {
return dal.InsertOrders(dt, diclist); return dal.InsertOrders(dt, diclist);
} }
#endregion #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
} }
} }

View File

@ -79,5 +79,44 @@ namespace Epost.DAL
return db.UpdateData(dt, "InboundOrders", diclist); return db.UpdateData(dt, "InboundOrders", diclist);
} }
#endregion #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
} }
} }

View File

@ -6,9 +6,7 @@ using System.Threading.Tasks;
namespace Epost.Model namespace Epost.Model
{ {
public class AgvReqModel
{
}
#region #region
public class AgvSchedulingTaskModel public class AgvSchedulingTaskModel
@ -74,31 +72,57 @@ namespace Epost.Model
#region #region
public class agvCallbackModel public class agvCallbackModel
{ {
public string reqCode { get; set; } public string action { get; set; }
public string reqTime { get; set; } public string areaCode { get; set; }
public string cooX { get; set; } public string berthCode { get; set; }
public string cooY { 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 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 mapCode { get; set; }
public string mapDataCode { get; set; } public string mapDataCode { get; set; }
public string stgBinCode { get; set; } public string mapShortName { 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 materialLot { get; set; } public string materialLot { get; set; }
public string materialType { get; set; } public string materialType { get; set; }
public string ctnrCode { get; set; } public string method { get; set; }
public string ctnrType { 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 roadWayCode { get; set; }
public string robotCode { get; set; }
public string seq { 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 #endregion
} }

View File

@ -1,4 +1,5 @@
using Epost.Common; using Epost.BLL;
using Epost.Common;
using Epost.DAL.Cache; using Epost.DAL.Cache;
using Epost.Model; using Epost.Model;
using System; using System;
@ -14,33 +15,50 @@ namespace Epost.DPS.Controllers
[RoutePrefix("api/AgvTaskApi")] [RoutePrefix("api/AgvTaskApi")]
public class AgvTaskApiController : ApiController public class AgvTaskApiController : ApiController
{ {
JobDownCacheDAL JobCache = new JobDownCacheDAL(); InboundOrdersBLL inboundBLL = new InboundOrdersBLL();
[Route("agvCallback")] [Route("agvCallback")]
[HttpPost] [HttpPost]
public AgvResultModel agvCallback([FromBody] agvCallbackModel model) public AgvResultModel agvCallback([FromBody]agvCallbackModel data)
{ {
AgvResultModel retModel = new AgvResultModel(); AgvResultModel retModel = new AgvResultModel();
try 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(); inboundBLL.UpInOrderListByAgvid(data.taskCode,state);
data.Parameter = model.reqCode; //ResultMessageModel data = new ResultMessageModel();
data.Status = model.method; //data.Parameter = model.reqCode;
data.Address = model.taskCode; //data.Status = model.method;
JobCache.UpdateJobDownModelList(new List<ResultMessageModel>() { data }, EdownCommend.Create); //data.Address = model.taskCode;
//JobCache.UpdateJobDownModelList(new List<ResultMessageModel>() { data }, EdownCommend.Create);
retModel.message = "成功!"; retModel.message = "成功!";
retModel.code = "0"; retModel.code = "0";
retModel.reqCode = model.reqCode; retModel.reqCode = data.reqCode;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.WriteLogInfo("agvPutTask异常" + ex.ToString(), LogHelper.Log_Type.ERROR); LogHelper.WriteLogInfo("agvPutTask异常" + ex.ToString(), LogHelper.Log_Type.ERROR);
retModel.message = "请求接口异常!"; retModel.message = "请求接口异常!";
retModel.code = "-1"; retModel.code = "-1";
retModel.reqCode = model.reqCode; retModel.reqCode = data.reqCode;
} }
return retModel; return retModel;
} }
} }

View File

@ -11,7 +11,7 @@
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected> <WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth> <WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
<NameOfLastUsedPublishProfile>E:\WORK\代码管理\T系列\播种\Epost.TestToolsWeb\Properties\PublishProfiles\Toolsweb.pubxml</NameOfLastUsedPublishProfile> <NameOfLastUsedPublishProfile>E:\WORK\代码管理\T系列\播种\Epost.TestToolsWeb\Properties\PublishProfiles\Toolsweb.pubxml</NameOfLastUsedPublishProfile>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig> <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<Use64BitIISExpress /> <Use64BitIISExpress />
<IISExpressSSLPort /> <IISExpressSSLPort />
<IISExpressAnonymousAuthentication /> <IISExpressAnonymousAuthentication />

View File

@ -1,7 +1,10 @@
using Epost.Common; using Epost.BLL;
using Epost.Common;
using Epost.Model;
using Epost.TestToolsWeb.App_Start; using Epost.TestToolsWeb.App_Start;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -12,11 +15,13 @@ using System.Web.Http;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Optimization; using System.Web.Optimization;
using System.Web.Routing; using System.Web.Routing;
using System.Web.WebSockets;
namespace Epost.TestToolsWeb namespace Epost.TestToolsWeb
{ {
public class MvcApplication : System.Web.HttpApplication public class MvcApplication : System.Web.HttpApplication
{ {
InboundOrdersBLL inboundBLL = new InboundOrdersBLL();
protected void Application_Start() protected void Application_Start()
{ {
AreaRegistration.RegisterAllAreas(); AreaRegistration.RegisterAllAreas();
@ -25,12 +30,52 @@ namespace Epost.TestToolsWeb
RouteConfig.RegisterRoutes(RouteTable.Routes); RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles); 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<Positioncodepath> positionList = new List<Positioncodepath>();
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)
{
// 在新会话启动时运行的代码
} }
} }
} }

View File

@ -33,19 +33,19 @@
<publishTime>04/04/2018 15:45:12</publishTime> <publishTime>04/04/2018 15:45:12</publishTime>
</File> </File>
<File Include="bin/App_global.asax.compiled"> <File Include="bin/App_global.asax.compiled">
<publishTime>11/22/2024 14:00:36</publishTime> <publishTime>11/22/2024 17:47:09</publishTime>
</File> </File>
<File Include="bin/App_global.asax.dll"> <File Include="bin/App_global.asax.dll">
<publishTime>11/22/2024 14:00:36</publishTime> <publishTime>11/22/2024 17:47:09</publishTime>
</File> </File>
<File Include="bin/BouncyCastle.Crypto.dll"> <File Include="bin/BouncyCastle.Crypto.dll">
<publishTime>02/24/2020 15:29:24</publishTime> <publishTime>02/24/2020 15:29:24</publishTime>
</File> </File>
<File Include="bin/Common.dll"> <File Include="bin/Common.dll">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:58</publishTime>
</File> </File>
<File Include="bin/Common.pdb"> <File Include="bin/Common.pdb">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:58</publishTime>
</File> </File>
<File Include="bin/ComposerSDK.dll"> <File Include="bin/ComposerSDK.dll">
<publishTime>04/29/2020 16:50:14</publishTime> <publishTime>04/29/2020 16:50:14</publishTime>
@ -63,31 +63,31 @@
<publishTime>10/23/2017 13:15:20</publishTime> <publishTime>10/23/2017 13:15:20</publishTime>
</File> </File>
<File Include="bin/Epost.BLL.dll"> <File Include="bin/Epost.BLL.dll">
<publishTime>11/22/2024 14:00:21</publishTime> <publishTime>11/22/2024 17:46:59</publishTime>
</File> </File>
<File Include="bin/Epost.BLL.pdb"> <File Include="bin/Epost.BLL.pdb">
<publishTime>11/22/2024 14:00:21</publishTime> <publishTime>11/22/2024 17:46:59</publishTime>
</File> </File>
<File Include="bin/Epost.BLL.XmlSerializers.dll"> <File Include="bin/Epost.BLL.XmlSerializers.dll">
<publishTime>08/26/2020 18:09:48</publishTime> <publishTime>08/26/2020 18:09:48</publishTime>
</File> </File>
<File Include="bin/Epost.DAL.dll"> <File Include="bin/Epost.DAL.dll">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:59</publishTime>
</File> </File>
<File Include="bin/Epost.DAL.pdb"> <File Include="bin/Epost.DAL.pdb">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:59</publishTime>
</File> </File>
<File Include="bin/Epost.DPS.dll"> <File Include="bin/Epost.DPS.dll">
<publishTime>11/22/2024 14:00:23</publishTime> <publishTime>11/22/2024 17:47:02</publishTime>
</File> </File>
<File Include="bin/Epost.DPS.pdb"> <File Include="bin/Epost.DPS.pdb">
<publishTime>11/22/2024 14:00:23</publishTime> <publishTime>11/22/2024 17:47:02</publishTime>
</File> </File>
<File Include="bin/Epost.Model.dll"> <File Include="bin/Epost.Model.dll">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:58</publishTime>
</File> </File>
<File Include="bin/Epost.Model.pdb"> <File Include="bin/Epost.Model.pdb">
<publishTime>11/22/2024 14:00:20</publishTime> <publishTime>11/22/2024 17:46:58</publishTime>
</File> </File>
<File Include="bin/Epost.TestToolsWeb.dll"> <File Include="bin/Epost.TestToolsWeb.dll">
<publishTime>09/06/2018 11:57:11</publishTime> <publishTime>09/06/2018 11:57:11</publishTime>
@ -5652,7 +5652,7 @@
<publishTime>05/30/2022 16:58:47</publishTime> <publishTime>05/30/2022 16:58:47</publishTime>
</File> </File>
<File Include="PrecompiledApp.config"> <File Include="PrecompiledApp.config">
<publishTime>11/22/2024 14:00:24</publishTime> <publishTime>11/22/2024 17:47:03</publishTime>
</File> </File>
<File Include="Scripts/ai.0.22.9-build00167.js"> <File Include="Scripts/ai.0.22.9-build00167.js">
<publishTime>04/04/2018 15:45:12</publishTime> <publishTime>04/04/2018 15:45:12</publishTime>
@ -7572,7 +7572,7 @@
<publishTime>07/04/2022 14:22:38</publishTime> <publishTime>07/04/2022 14:22:38</publishTime>
</File> </File>
<File Include="Web.config"> <File Include="Web.config">
<publishTime>11/01/2024 16:24:56</publishTime> <publishTime>11/22/2024 16:17:44</publishTime>
</File> </File>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -11,7 +11,7 @@
</configSections> </configSections>
<connectionStrings> <connectionStrings>
<add name="weijie_dpsEntities" connectionString="metadata=res://*/WJDB.csdl|res://*/WJDB.ssdl|res://*/WJDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=weijie_dps;user id=sa;password=123456;min pool size=4;max pool size=4;packet size=3072;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> <add name="weijie_dpsEntities" connectionString="metadata=res://*/WJDB.csdl|res://*/WJDB.ssdl|res://*/WJDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=weijie_dps;user id=sa;password=123456;min pool size=4;max pool size=4;packet size=3072;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
<add name="SqlLocDPSConnection" connectionString="server=139.196.36.200;user id=EpostTest;password=antion;database=WuXi_DingShi_DAS;min pool size=512;max pool size=512;packet size=3072" providerName="System.Data.SqlClient" /> <add name="SqlLocDPSConnection" connectionString="server=139.196.36.200;user id=EpostTest;password=antion;database=zhuyou_wcs;min pool size=512;max pool size=512;packet size=3072" providerName="System.Data.SqlClient" />
<add name="MysqlLocDPSConnection" connectionString="Server=localhost;Port=3306;Database=world;User=root; Password=antion;SslMode=None;Pooling=true;Allow User Variables=True;" /> <add name="MysqlLocDPSConnection" connectionString="Server=localhost;Port=3306;Database=world;User=root; Password=antion;SslMode=None;Pooling=true;Allow User Variables=True;" />
<add name="WMSConnection" connectionString="data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=139.196.36.200)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=EpostDB)));user id=C##Test;password=test" /> <add name="WMSConnection" connectionString="data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=139.196.36.200)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=EpostDB)));user id=C##Test;password=test" />
@ -33,6 +33,8 @@
<add key="CARID" value="HT01" /> <add key="CARID" value="HT01" />
<add key="ServerAPIURL" value="http://192.168.0.20:8045/api/WebAPI" /> <add key="ServerAPIURL" value="http://192.168.0.20:8045/api/WebAPI" />
<add key="SleepTime" value="1" /> <add key="SleepTime" value="1" />
<add key="agvUrl" value="http://192.168.0.20:8045/api/WebAPI/ProcessingResult"/>
</appSettings> </appSettings>
<!-- <!--
有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。 有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。