wanghaomei 1 year ago
commit 161d6f6612

@ -1987,37 +1987,40 @@ namespace Myshipping.Application
public async Task<dynamic> SendLetterYard(long bookingId)
{
var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId);
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())
if (entity!=null) {
var json = entity.ToJsonString();
try
{
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}】");
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();
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)
{
_logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace);
catch (Exception ex)
{
_logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace);
}
}
return null;
}
@ -7752,10 +7755,10 @@ namespace Myshipping.Application
[NonAction]
public async Task<dynamic> SendBookingOrder(long[] ids)
{
var itemcode = App.Configuration["ITEMCODE"];
var itemcode = App.Configuration["ITEMCODE"].ToString() ;
var BookingOrderMQUri= App.Configuration["SendBookingOrderMQUri"];
_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri);
if (!string.IsNullOrEmpty(itemcode) && itemcode == "true")
_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri+ itemcode);
if (!string.IsNullOrEmpty(itemcode) && itemcode == "True")
{
if (ids.Count() == 0)
{

Loading…
Cancel
Save