|
|
@ -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";
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IModel mqModel = conn.CreateModel();
|
|
|
|
const string MqActionExchangeName = "djy.output.dingcang.ds6";
|
|
|
|
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
|
|
|
|
const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang";
|
|
|
|
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
|
|
|
|
ConnectionFactory factory = new ConnectionFactory();
|
|
|
|
mqModel.QueueDeclare(queueName, false, false, false, null);
|
|
|
|
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
|
|
|
|
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
|
|
|
|
|
|
|
|
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
using (IConnection conn = factory.CreateConnection())
|
|
|
|
IBasicProperties props = mqModel.CreateBasicProperties();
|
|
|
|
{
|
|
|
|
props.DeliveryMode = 2;
|
|
|
|
IModel mqModel = conn.CreateModel();
|
|
|
|
mqModel.BasicPublish(MqActionExchangeName,
|
|
|
|
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
|
|
|
|
queueName, props,
|
|
|
|
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
|
|
|
|
messageBodyBytes);
|
|
|
|
mqModel.QueueDeclare(queueName, false, false, false, null);
|
|
|
|
conn.Close();
|
|
|
|
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
|
|
|
|
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
|
|
|
|
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)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError(ex.Message);
|
|
|
|
_logger.LogError(ex.Message);
|
|
|
|
_logger.LogError(ex.StackTrace);
|
|
|
|
_logger.LogError(ex.StackTrace);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|