From a7102aa065e07730509b4f16533dbe0934b075e1 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Wed, 13 Mar 2024 11:53:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E8=AE=A2=E8=88=B1=E5=AE=A1=E6=A0=B8=E9=9C=80=E6=B1=82=E5=90=8E?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E4=B8=9C=E8=83=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingCustomerOrderService.cs | 109 +++++++++--------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs index 643d78bc..7314a381 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs @@ -965,6 +965,61 @@ namespace Myshipping.Application return bkOrder.Id; } + + // 接收到订舱需求审核后推送东胜 + _ = Task.Run(() => + { + try + { + var body = new + { + Type = recModel.Accept ? "CustOrderStatusAccept" : "CustOrderStatusReject", + Data = new + { + model.BSNO, + BSSTATUS = recModel.Accept ? "已审核" : "已驳回", + BookingOrderId = recModel.Accept ? (long?)model.BookingId : null, + COMMENT = recModel.Accept ? null: recModel.Comment + } + }; + var json = body.ToJsonString(); + + var mqUrl = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "AuditBookingMqUrl")?.Value ?? throw new Exception("需配置接收订舱需求审核后推送东胜MQ连接串:[AuditBookingMqUrl]"); + + const string MqActionExchangeName = "amq.direct"; + const string MqActionQueueName = "auditbooking.output.ds"; + + ConnectionFactory factory = new ConnectionFactory(); + factory.Uri = new Uri(mqUrl); + + using (IConnection conn = factory.CreateConnection()) + using (IModel mqModel = conn.CreateModel()) + { + mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct, true); + + var queueName = $"{MqActionQueueName}.{model.TenantId}"; + mqModel.QueueDeclare(queueName, false, false, false, null); + + mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); + + IBasicProperties props = mqModel.CreateBasicProperties(); + props.DeliveryMode = 2; + + byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json)); + + mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); + + conn.Close(); + + _logger.LogInformation($"接收到订舱需求审核后推送东胜,已发送数据到消息队列【{mqUrl}】,数据内容:【{json}】"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "接收到订舱需求审核后推送东胜时发生异常"); + } + }); + return 0; } #endregion @@ -1448,60 +1503,6 @@ namespace Myshipping.Application SaveAuditLog($"{(accept ? "审核通过" : "审核驳回")},审核意见:{comment}", id); - // 订舱需求审核后推送东胜 - _ = Task.Run(() => - { - try - { - var body = new - { - Type = accept ? "CustOrderStatusAccept" : "CustOrderStatusReject", - Data = new - { - model.BSNO, - BSSTATUS = accept ? "已审核" : "已驳回", - BookingOrderId = accept ? jobjRtn.GetLongValue("data") as long? : null - } - }; - var json = body.ToJsonString(); - - var mqUrl = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "AuditBookingMqUrl")?.Value ?? throw new Exception("需配置订舱需求审核后推送东胜MQ连接串:[AuditBookingMqUrl]"); - - const string MqActionExchangeName = "amq.direct"; - const string MqActionQueueName = "auditbooking.output.ds"; - - ConnectionFactory factory = new ConnectionFactory(); - factory.Uri = new Uri(mqUrl); - - using (IConnection conn = factory.CreateConnection()) - using (IModel mqModel = conn.CreateModel()) - { - mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct, true); - - var queueName = $"{MqActionQueueName}.{model.BookingCompanyId}"; - mqModel.QueueDeclare(queueName, false, false, false, null); - - mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); - - IBasicProperties props = mqModel.CreateBasicProperties(); - props.DeliveryMode = 2; - - byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json)); - - mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); - - conn.Close(); - - _logger.LogInformation($"订舱需求审核后推送东胜,已发送数据到消息队列【{mqUrl}】,数据内容:【{json}】"); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "订舱需求审核后推送东胜时发生异常"); - } - }); - - //进入订舱台账 if (accept) {