jianghaiqing 6 months ago
commit 8fd88a9c96

@ -0,0 +1,30 @@
using Myshipping.Core;
using Myshipping.Core.Entity;
using SqlSugar;
using System.ComponentModel;
namespace Myshipping.Application.Entity
{
/// <summary>
///
/// </summary>
[SugarTable("booking_label_allocation")]
[Description("订舱标签关联表")]
[Tenant(CommonConst.MasterDb)]
public class BookingLabelAllocation : PrimaryKeyEntity
{
/// <summary>
/// 标签主键
/// </summary>
public long LabelId { get; set; }
/// <summary>
/// 业务主键
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long TenantId { get; set; }
}
}

@ -1,5 +1,6 @@
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Myshipping.Application.Entity;
@ -16,18 +17,65 @@ namespace Myshipping.Application
/// <summary>
/// 订舱标签服务
/// </summary>
[ApiDescriptionSettings("Application", Name = "BookingLabel", Order = 1)]
public class BookingLabelService : IBookingLabelService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<BookingLabel> _rep;
private readonly SqlSugarRepository<BookingLabelAllocation> _repAllocation;
private readonly ISysCacheService _cache;
public BookingLabelService(SqlSugarRepository<BookingLabel> rep,
ISysCacheService cache)
ISysCacheService cache,
SqlSugarRepository<BookingLabelAllocation> repAllocation)
{
_rep = rep;
_cache = cache;
_repAllocation = repAllocation;
}
/// <summary>
/// 为舱位分配标签
/// </summary>
/// <returns></returns>
[HttpPost("/BookingLabel/Bind")]
public async Task SetLabel(BindLabelDto input)
{
if (input.BusinessIdArray?.Any() != true)
{
throw Oops.Oh("请检查参数");
}
_rep.CurrentBeginTran();
try
{
await _repAllocation.DeleteAsync(x => input.BusinessIdArray.Contains(x.BusinessId));
if (input.LabelIdArray != null && input.LabelIdArray.Length > 0)
{
List<BookingLabelAllocation> list = new();
foreach (var item in input.LabelIdArray)
{
foreach (var businessId in input.BusinessIdArray)
{
list.Add(new BookingLabelAllocation
{
LabelId = item,
BusinessId = businessId,
//TenantId = UserManager.TENANT_ID
});
}
}
await _repAllocation.InsertAsync(list);
}
_rep.CurrentCommitTran();
}
catch (Exception)
{
_rep.CurrentRollbackTran();
throw;
}
}
/// <summary>
/// 获取全部或指定范围类型的标签列表
/// </summary>

@ -13,8 +13,19 @@
/// </summary>
public int Scope { get; set; }
}
//public class BookingLabelCacheDto : BookingLabelBaseDto
//{
// public long TenantId { get; set; }
//}
/// <summary>
/// 标签绑定Dto类
/// </summary>
public class BindLabelDto
{
/// <summary>
/// 标签主键列表
/// </summary>
public long[] LabelIdArray { get; set; }
/// <summary>
/// 业务主键列表
/// </summary>
public long[] BusinessIdArray { get; set; }
}
}

@ -44,6 +44,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingSlotCtn> _repCtn;
private readonly SqlSugarRepository<BookingSlotStock> _repStock;
private readonly SqlSugarRepository<BookingSlotAllocation> _repAllocation;
private readonly SqlSugarRepository<BookingLabelAllocation> _repLabelAllocation;
private readonly SqlSugarRepository<BookingSlotAllocationCtn> _repAllocationCtn;
private readonly SqlSugarRepository<BookingFile> _bookingFileRepository;
private readonly SqlSugarRepository<BookingSlotCompare> _bookingSlotCompareRepository;
@ -90,7 +91,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
IBookingValueAddedService bookingValueAddedService,
SqlSugarRepository<BookingOrder> repBookingOrder)
SqlSugarRepository<BookingOrder> repBookingOrder,
SqlSugarRepository<BookingLabelAllocation> repLabelAllocation)
{
_repBase = repBase;
_repCtn = repCtn;
@ -112,6 +114,7 @@ namespace Myshipping.Application
_bookingOrderContactRepository = bookingOrderContactRepository;
_bookingValueAddedService = bookingValueAddedService;
_repBookingOrder = repBookingOrder;
_repLabelAllocation = repLabelAllocation;
}
#region 舱位
@ -243,13 +246,13 @@ namespace Myshipping.Application
x.UpdatedTime,
}).ExecuteCommandAsync();
//Parallel.For(0, 1, (n) =>
//{
Parallel.For(0, 1, (n) =>
{
bookingOrderService.SaveLog(bookingOrder, oldBookingOrder, "舱位关联更新");
// 推送东胜
bookingOrderService.SendBookingOrder(new long[] { allocation.BOOKING_ID });
//});
});
}
_repAllocation.CurrentCommitTran();
}
@ -262,12 +265,12 @@ namespace Myshipping.Application
}
#endregion
//Parallel.For(0, 1, (n) =>
//{
InsLog("Update", model.Id, typeof(BookingSlotBaseSaveInput), oldObj, input,
Parallel.For(0, 1, (n) =>
{
_ = InsLog("Update", model.Id, typeof(BookingSlotBaseSaveInput), oldObj, input,
nameof(BookingSlotBaseApiSaveDto.CtnList),
nameof(BookingSlotBaseApiSaveDto.BookingSlotSaleInfoList));
//});
});
}
else
{
@ -984,7 +987,8 @@ namespace Myshipping.Application
var fieldName = descriptor.Name;
if (!string.IsNullOrWhiteSpace(descriptor.Description))
{
fieldName = descriptor.Description;
//fieldName = descriptor.Description;
continue;
}
waitInsertLogList.Add(new BookingLogDetail
{
@ -1368,6 +1372,8 @@ namespace Myshipping.Application
input.WEEK_AT = "W" + input.WEEK_AT;
}
ISugarQueryable<BookingSlotBase> select = null;
// 箱型筛选
string[] ctnCodeArr = null;
if (!string.IsNullOrEmpty(input.CTN_STAT))
{
@ -1403,13 +1409,21 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrEmpty(input.BOOKING_SLOT_TYPE), u => u.BOOKING_SLOT_TYPE == input.BOOKING_SLOT_TYPE)
.WhereIF(!string.IsNullOrEmpty(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
.WhereIF(!string.IsNullOrEmpty(input.WEEK_AT), u => u.WEEK_AT == input.WEEK_AT);
.WhereIF(!string.IsNullOrEmpty(input.WEEK_AT), u => u.WEEK_AT == input.WEEK_AT)
// 标签筛选
.WhereIF(input.LabelIdArray != null && input.LabelIdArray.Length > 0,
u => SqlFunc.Subqueryable<BookingLabelAllocation>()
.Where(x => x.BusinessId == u.Id && input.LabelIdArray.Contains(x.LabelId))
.Any());
if (ctnCodeArr != null && ctnCodeArr.Length > 0)
{
var tempSelect = select as ISugarQueryable<BookingSlotBase, BookingSlotCtn>;
tempSelect.Where((u, c) => ctnCodeArr.Contains(c.CTNCODE));
}
//var sql = select.OrderByDescending(u => u.CreatedTime).ToSqlString();
var entities = await select.OrderByDescending(u => u.CreatedTime)
.ToPagedListAsync(input.PageNo, input.PageSize);

@ -124,6 +124,11 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 周数
/// </summary>
public string WEEK_AT { get; set; }
/// <summary>
/// 标签Id列表
/// </summary>
public long[] LabelIdArray { get; set; }
}
/// <summary>

Loading…
Cancel
Save