optimize
wet 1 year ago
parent a1cdbb74bf
commit 6b3d0bc1a6

@ -1374,54 +1374,92 @@ namespace Myshipping.Application
var arr = Ids.Split(","); var arr = Ids.Split(",");
if (arr.Count() > 0) if (arr.Count() > 0)
{ {
var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToListAsync();
var url = "http://123.235.27.122:8966/CommMng/PublicInterface/DJYDELBILL";// _cache.GetAllDictData().Result.Where(x => x.Code == "bookingorder_delete").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(url))
{
throw Oops.Bah("未获取到相关url,请联系管理员!");
}
foreach (var ar in arr) foreach (var ar in arr)
{ {
long Id = Convert.ToInt64(ar); long Id = Convert.ToInt64(ar);
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true });
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id, x => new BookingEDIExt { IsDeleted = true });
_logger.LogInformation(Id + "删除成功!");
}
var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault(); var mblno = order.Where(x => x.Id == Id).Select(x => x.MBLNO).FirstOrDefault();
if (!string.IsNullOrEmpty(itemcode)) BookingOrderDelete bookingOrderDelete = new BookingOrderDelete();
{ List<BookingOrderDeleteDetail> deletelist = new List<BookingOrderDeleteDetail>();
if (itemcode == "true") deletelist.Add(new BookingOrderDeleteDetail
{
Id = Id,
MBLNO = mblno
});
bookingOrderDelete.Delete = deletelist;
try var stn = await url.SetBody(bookingOrderDelete).PostAsStringAsync();
var jobj = stn.ToJObject();
if (jobj.GetIntValue("Code") == 200)
{
JObject data = jobj.GetValue("Data") as JObject;
JArray NoDeleted = data.GetValue("NoDeleted") as JArray;
if (NoDeleted == null || NoDeleted.Count() == 0)
{ {
const string MqActionExchangeName = "djy.output.dingcang.ds6"; var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
const string MqActionQueueName = "djy.output.dingcang.ds6_delete"; await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
ConnectionFactory factory = new ConnectionFactory(); await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()); await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true });
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id, x => new BookingEDIExt { IsDeleted = true });
_logger.LogInformation(Id + "删除成功!");
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(Ids);
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()}】,数据内容:【{Ids}】");
}
} }
catch (Exception ex) else
{ {
_logger.LogError(ex.Message); var re = NoDeleted[0] as JObject;
_logger.LogError(ex.StackTrace); string result = re.GetStringValue("Result");
throw Oops.Bah(result);
} }
}
else {
throw Oops.Bah("接口调用异常");
}
} }
#region 消息队列推送删除信息
//var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault();
//if (!string.IsNullOrEmpty(itemcode))
//{
// if (itemcode == "true")
// try
// {
// const string MqActionExchangeName = "djy.output.dingcang.ds6";
// const string MqActionQueueName = "djy.output.dingcang.ds6_delete";
// 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(Ids);
// 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()}】,数据内容:【{Ids}】");
// }
// }
// catch (Exception ex)
// {
// _logger.LogError(ex.Message);
// _logger.LogError(ex.StackTrace);
// }
//}
#endregion
} }
else else
{ {
@ -8153,7 +8191,7 @@ namespace Myshipping.Application
}).Take(10).ToList(); }).Take(10).ToList();
}); });
var TemplateIds = _repPrintTemplateShare.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.ShareToId == UserManager.UserId).Select(x => x.TemplateId).ToList(); var TemplateIds = _repPrintTemplateShare.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.ShareToId == UserManager.UserId).Select(x => x.TemplateId).ToList();
var STemplate = _bookingTemplate.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && (TemplateIds.Contains(x.Id) || x.CreatedUserId == UserManager.UserId)&& var STemplate = _bookingTemplate.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && (TemplateIds.Contains(x.Id) || x.CreatedUserId == UserManager.UserId) &&
x.Type == "10" && x.CreatedUserId == UserManager.UserId).Take(10).ToList(); x.Type == "10" && x.CreatedUserId == UserManager.UserId).Take(10).ToList();
var FTemplate = _bookingTemplate.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && (TemplateIds.Contains(x.Id) || x.CreatedUserId == UserManager.UserId) && var FTemplate = _bookingTemplate.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && (TemplateIds.Contains(x.Id) || x.CreatedUserId == UserManager.UserId) &&
x.Type == "20" && x.CreatedUserId == UserManager.UserId).Take(10).ToList(); x.Type == "20" && x.CreatedUserId == UserManager.UserId).Take(10).ToList();

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Myshipping.Core;
namespace Myshipping.Application
{
/// <summary>
/// 订舱主表输出参数
/// </summary>
public class BookingOrderDelete
{
public List<BookingOrderDeleteDetail> Delete { get; set; }
}
public class BookingOrderDeleteDetail
{
public long Id { get; set; }
public string MBLNO { get; set; }
}
}

@ -159,6 +159,24 @@ namespace Myshipping.Application
} }
/// <summary>
/// 获取分享列表
/// </summary>
/// <returns></returns>
[HttpGet("/BookingTemplate/GetTemplateShareList")]
public async Task<dynamic> GetTemplateShareList(long Id)
{
var list = _repPrintTemplateShare.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.ShareToId == UserManager.UserId&&x.TemplateId==Id).ToList();
return list;
}
/// <summary> /// <summary>
/// 删除分享 /// 删除分享
/// </summary> /// </summary>

Loading…
Cancel
Save