舱单状态回推

master
hao 9 months ago
parent 6284b11ac6
commit d7451e4894

@ -64,6 +64,9 @@
<Reference Include="Quartz, Version=2.6.2.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.2.6.2\lib\net40\Quartz.dll</HintPath>
</Reference>
<Reference Include="RabbitMQ.Client, Version=3.6.9.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.3.6.9\lib\net45\RabbitMQ.Client.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />

@ -13,6 +13,7 @@ using System.Text;
using HcUtility.Core;
using HcUtility.Comm;
using System.Data.Entity;
using RabbitMQ.Client;
namespace JobPingTaiWork
{
@ -145,6 +146,7 @@ namespace JobPingTaiWork
connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
var mqConnStr = context.JobDetail.JobDataMap.GetString("RabbitConnectString");
log.Debug($"连接字符串:{connStr}");
log.Debug($"请求URL{reqUrl}");
@ -196,7 +198,7 @@ namespace JobPingTaiWork
}
else
{
var needPushStatus = false;
var PortResult = Newtonsoft.Json.JsonConvert.DeserializeObject<RepWLXXModel>(rtn);
var portstatus = PortResult.message[0];
@ -232,7 +234,7 @@ namespace JobPingTaiWork
//result = SaveStatus(newStatusRecord, headdata.MFNO);
upd = true;
EdiStatusDAL.Update(newStatusRecord);
needPushStatus = true;
}
else {
newStatusRecord = status;
@ -253,14 +255,49 @@ namespace JobPingTaiWork
newStatusRecord.SetValue("mblno", MBLNO);
EdiStatusDAL.Insert(newStatusRecord);
needPushStatus= true;
}
}
DelMinMblno(connStr);
}
if(needPushStatus)
{
//回推舱单状态
try
{
if (string.IsNullOrEmpty(mqConnStr))
{
log.Warn($"未配置舱单回推消息队列,不会回推状态:{MFNO}");
}
else
{
log.Debug($"准备推送舱单状态回推到消息队列:{string.Join(",", MFNO)}");
//推送消息
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = mqConnStr;
var mqConn = factory.CreateConnection("JobPingTaiWork");
var exchangeName = "myshiping.feedback.status.cangdan";
IModel model = mqConn.CreateModel();
model.ExchangeDeclare(exchange: exchangeName, type: ExchangeType.Fanout);
model.BasicPublish(exchange: exchangeName,
routingKey: "",
basicProperties: null,
body: Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { MfnoList = new string[] { MFNO } })));
mqConn.Close();
log.Debug($"推送舱单状态回推消息完成");
}
}
catch (Exception ex)
{
log.Error($"推送舱单状态回推消息失败:{ex.Message}");
log.Error(ex.StackTrace);
}
}
}
}

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RabbitMQ.Client" version="3.6.9" targetFramework="net45" />
</packages>
Loading…
Cancel
Save