From d7451e4894136cbe8f7160e76f0f9fe328c740b4 Mon Sep 17 00:00:00 2001
From: hao <86whm@163.com>
Date: Wed, 21 Feb 2024 16:36:21 +0800
Subject: [PATCH] =?UTF-8?q?=E8=88=B1=E5=8D=95=E7=8A=B6=E6=80=81=E5=9B=9E?=
=?UTF-8?q?=E6=8E=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JobPingTaiWork/JobPingTaiWork.csproj | 3 ++
JobPingTaiWork/Job_WLXX.cs | 45 +++++++++++++++++++++++++---
JobPingTaiWork/packages.config | 4 +++
3 files changed, 48 insertions(+), 4 deletions(-)
create mode 100644 JobPingTaiWork/packages.config
diff --git a/JobPingTaiWork/JobPingTaiWork.csproj b/JobPingTaiWork/JobPingTaiWork.csproj
index 1d90ff1d..7a73153e 100644
--- a/JobPingTaiWork/JobPingTaiWork.csproj
+++ b/JobPingTaiWork/JobPingTaiWork.csproj
@@ -64,6 +64,9 @@
..\packages\Quartz.2.6.2\lib\net40\Quartz.dll
+
+ ..\packages\RabbitMQ.Client.3.6.9\lib\net45\RabbitMQ.Client.dll
+
diff --git a/JobPingTaiWork/Job_WLXX.cs b/JobPingTaiWork/Job_WLXX.cs
index f57131dd..08de91f9 100644
--- a/JobPingTaiWork/Job_WLXX.cs
+++ b/JobPingTaiWork/Job_WLXX.cs
@@ -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(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);
+ }
+ }
}
}
diff --git a/JobPingTaiWork/packages.config b/JobPingTaiWork/packages.config
new file mode 100644
index 00000000..32020e47
--- /dev/null
+++ b/JobPingTaiWork/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file