wanghaomei 1 year ago
commit 161d6f6612

@ -1987,37 +1987,40 @@ namespace Myshipping.Application
public async Task<dynamic> SendLetterYard(long bookingId) public async Task<dynamic> SendLetterYard(long bookingId)
{ {
var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId); var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId);
var json = entity.ToJsonString(); if (entity!=null) {
try var json = entity.ToJsonString();
{ try
const string MqActionExchangeName = "djy.output.dingcang.ds6"; {
const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang"; const string MqActionExchangeName = "djy.output.dingcang.ds6";
ConnectionFactory factory = new ConnectionFactory(); const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang";
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()); ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
using (IConnection conn = factory.CreateConnection()) using (IConnection conn = factory.CreateConnection())
{
IModel mqModel = conn.CreateModel();
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
mqModel.QueueDeclare(queueName, false, false, false, null);
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2;
mqModel.BasicPublish(MqActionExchangeName,
queueName, props,
messageBodyBytes);
conn.Close();
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
}
}
catch (Exception ex)
{ {
IModel mqModel = conn.CreateModel(); _logger.LogError(ex.Message);
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct); _logger.LogError(ex.StackTrace);
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
mqModel.QueueDeclare(queueName, false, false, false, null);
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2;
mqModel.BasicPublish(MqActionExchangeName,
queueName, props,
messageBodyBytes);
conn.Close();
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
} }
} }
catch (Exception ex)
{
_logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace);
}
return null; return null;
} }
@ -7752,10 +7755,10 @@ namespace Myshipping.Application
[NonAction] [NonAction]
public async Task<dynamic> SendBookingOrder(long[] ids) public async Task<dynamic> SendBookingOrder(long[] ids)
{ {
var itemcode = App.Configuration["ITEMCODE"]; var itemcode = App.Configuration["ITEMCODE"].ToString() ;
var BookingOrderMQUri= App.Configuration["SendBookingOrderMQUri"]; var BookingOrderMQUri= App.Configuration["SendBookingOrderMQUri"];
_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri); _logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri+ itemcode);
if (!string.IsNullOrEmpty(itemcode) && itemcode == "true") if (!string.IsNullOrEmpty(itemcode) && itemcode == "True")
{ {
if (ids.Count() == 0) if (ids.Count() == 0)
{ {

Loading…
Cancel
Save