diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs index d4359422..ac7f1b6d 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs @@ -16,11 +16,12 @@ using Myshipping.Application.Enum; using Myshipping.Application.Service.BookingOrder.Dto; using Myshipping.Core; using Myshipping.Core.Entity; +using Myshipping.Core.Extension; using Myshipping.Core.Helper; using Myshipping.Core.Service; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using NPOI.Util; +using RabbitMQ.Client; using System; using System.Collections.Generic; using System.IO; @@ -1447,6 +1448,61 @@ 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) { diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index beaa2fd7..59cf6b32 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -11585,7 +11585,7 @@ namespace Myshipping.Application /// - /// 设置货物状态 + /// 查询货物状态 /// /// 订舱id ///