optimize
wet 2 years ago
parent 063ba1c428
commit ec8e8317b7

@ -193,7 +193,9 @@ namespace Myshipping.Application
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
#region
var entities = await _rep.AsQueryable()
var entities = await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!input.ISDel, x => x.IsDeleted == false)
.WhereIF(input.ISDel, x => x.IsDeleted == true)
.WhereIF(input.firstFlag, x => x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null)
.WhereIF(string.IsNullOrWhiteSpace(input.HBLNO), x => x.ParentId == 0 || x.ParentId == null)
.WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id))
@ -463,7 +465,7 @@ namespace Myshipping.Application
}
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
var et = await _rep.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
if (et != null)
{
@ -475,7 +477,6 @@ namespace Myshipping.Application
if (input.Id == 0)
{
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
await _rep.InsertAsync(entity);
if (input.ctnInputs != null)
{
@ -537,7 +538,7 @@ namespace Myshipping.Application
it.LstShipOrderCompareRlt,
it.LstShipOrderCompareRltName,
}).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
var ctnlist = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == input.Id && x.IsDeleted == false).Select(x => x.Id).ToListAsync();
await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
if (input.ctnInputs != null)
@ -836,9 +837,107 @@ namespace Myshipping.Application
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 + "删除成功!");
}
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);
}
}
else
{
throw Oops.Bah("请上传正确参数");
}
}
/// <summary>
/// 恢复删除
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/RecoverDelete")]
public async Task RecoverDelete(string Ids)
{
var arr = Ids.Split(",");
if (arr.Count() > 0)
{
foreach (var ar in arr)
{
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 = false });
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = false });
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = false });
await _bookingEDIExt.UpdateAsync(x => x.BookingId == Id, x => new BookingEDIExt { IsDeleted = false });
_logger.LogInformation(Id + "恢复删除成功!");
}
try
{
const string MqActionExchangeName = "djy.output.dingcang.ds6";
const string MqActionQueueName = "djy.output.dingcang.ds6_recoverdelete";
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);
}
}
else
{
@ -5438,7 +5537,11 @@ namespace Myshipping.Application
return obj;
}
/// <summary>
/// 推送东胜
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[NonAction]
public async Task<dynamic> SendBookingOrder(long[] ids)
{
@ -5524,7 +5627,7 @@ namespace Myshipping.Application
const string MqActionQueueName = "djy.output.dingcang.ds6";
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();
@ -5539,7 +5642,7 @@ namespace Myshipping.Application
queueName, props,
messageBodyBytes);
conn.Close();
_logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{ConfigurationManager.AppSettings["BookingFeedbackMQUri"]}】,数据内容:【{json}】");
_logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
}
}
catch (Exception ex)
@ -5551,6 +5654,11 @@ namespace Myshipping.Application
}
return dto;
}
#endregion

@ -13,7 +13,10 @@ namespace Myshipping.Application
{
/// <summary>
/// 查询已删除
/// </summary>
public virtual bool ISDel { get; set; } = false;
/// <summary>
/// 首次查询标识
/// </summary>

@ -544,6 +544,8 @@ namespace Myshipping.Application
entity.CreatedUserId = user.Id;
entity.CreatedUserName = user.Name.ToString();
entity.CreatedTime = DateTime.Now;
entity.TenantId = UserManager.TENANT_ID;
entity.TenantName = UserManager.TENANT_NAME;
entity.ParentId = 0;
await _rep.InsertAsync(entity);
if (model.ctnInputs != null)
@ -555,6 +557,11 @@ namespace Myshipping.Application
ctnentity.CreatedUserId = user.Id;
ctnentity.CreatedUserName = user.Name;
ctnentity.CTNCODE = ctncode.Where(x => x.Name == ctnentity.CTNALL).Select(x => x.Code).FirstOrDefault();
ctnentity.CreatedUserId = user.Id;
ctnentity.CreatedUserName = user.Name.ToString();
ctnentity.CreatedTime = DateTime.Now;
ctnentity.TenantId = UserManager.TENANT_ID;
await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息
@ -566,6 +573,11 @@ namespace Myshipping.Application
ctndetail.CTNID = ctnentity.Id;
ctndetail.CreatedUserId = user.Id;
ctndetail.CreatedUserName = user.Name;
ctndetail.CreatedUserId = user.Id;
ctndetail.CreatedUserName = user.Name.ToString();
ctndetail.CreatedTime = DateTime.Now;
ctndetail.TenantId = UserManager.TENANT_ID;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
@ -578,12 +590,10 @@ namespace Myshipping.Application
var ediExtEntity = model.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
ediExtEntity.CreatedUserId = user.Id;
ediExtEntity.CreatedUserName = user.Name;
ediExtEntity.CreatedTime = DateTime.Now;
ediExtEntity.CreatedUserId = user.Id;
ediExtEntity.CreatedUserName = user.Name;
ediExtEntity.TenantId = UserManager.TENANT_ID;
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
////添加booking日志
@ -708,6 +718,8 @@ namespace Myshipping.Application
fdentity.CreatedUserId = user.Id;
fdentity.CreatedUserName = user.Name;
fdentity.CreatedTime = DateTime.Now;
fdentity.TenantId = UserManager.TENANT_ID;
fdentity.TenantName = UserManager.TENANT_NAME;
fdentity.ParentId = entity.Id;
await _rep.InsertAsync(fdentity);
@ -967,12 +979,12 @@ namespace Myshipping.Application
});
}
}
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{
it.BOOKINGNO,
it.ParentId,
it.TenantId,
it.TenantName,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
@ -1293,9 +1305,14 @@ namespace Myshipping.Application
it.BOOKINGNO,
it.ParentId,
it.TenantId,
it.TenantName,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
it.CreatedUserName,
it.LstShipOrderCompareId,
it.LstShipOrderCompareDate,
it.LstShipOrderCompareRltName,
it.LstShipOrderCompareMode
}).ExecuteCommandAsync();
var fdctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == fdmain.Id).Select(x => x.Id).ToListAsync();
await _repCtn.DeleteAsync(x => x.BILLID == fdmain.Id);

Loading…
Cancel
Save