舱位管理相关

master
zhangxiaofeng 6 months ago
parent 3b490c5eb4
commit d62cb959d8

@ -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.DependencyInjection;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Myshipping.Application.Entity; using Myshipping.Application.Entity;
@ -16,18 +17,65 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 订舱标签服务 /// 订舱标签服务
/// </summary> /// </summary>
[ApiDescriptionSettings("Application", Name = "BookingLabel", Order = 1)]
public class BookingLabelService : IBookingLabelService, IDynamicApiController, ITransient public class BookingLabelService : IBookingLabelService, IDynamicApiController, ITransient
{ {
private readonly SqlSugarRepository<BookingLabel> _rep; private readonly SqlSugarRepository<BookingLabel> _rep;
private readonly SqlSugarRepository<BookingLabelAllocation> _repAllocation;
private readonly ISysCacheService _cache; private readonly ISysCacheService _cache;
public BookingLabelService(SqlSugarRepository<BookingLabel> rep, public BookingLabelService(SqlSugarRepository<BookingLabel> rep,
ISysCacheService cache) ISysCacheService cache,
SqlSugarRepository<BookingLabelAllocation> repAllocation)
{ {
_rep = rep; _rep = rep;
_cache = cache; _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>
/// 获取全部或指定范围类型的标签列表 /// 获取全部或指定范围类型的标签列表
/// </summary> /// </summary>

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

@ -124,6 +124,11 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 周数 /// 周数
/// </summary> /// </summary>
public string WEEK_AT { get; set; } public string WEEK_AT { get; set; }
/// <summary>
/// 标签Id列表
/// </summary>
public long[] LabelIdArray { get; set; }
} }
/// <summary> /// <summary>
@ -624,6 +629,6 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// <summary> /// <summary>
/// 修改标记,前端提供给后端判断是否更新 /// 修改标记,前端提供给后端判断是否更新
/// </summary> /// </summary>
public bool UpdateFlag { get; set; } public bool UpdateFlag { get; set; }
} }
} }

Loading…
Cancel
Save