From d62cb959d8aeee06faabdb6591fc5e164aa5708a Mon Sep 17 00:00:00 2001
From: zhangxiaofeng <1939543722@qq.com>
Date: Fri, 17 May 2024 15:42:33 +0800
Subject: [PATCH] =?UTF-8?q?=E8=88=B1=E4=BD=8D=E7=AE=A1=E7=90=86=E7=9B=B8?=
=?UTF-8?q?=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/BookingLabelAllocation.cs | 30 +++++++++++
.../BookingLabel/BookingLabelService.cs | 50 ++++++++++++++++++-
.../BookingLabel/Dto/BookingLabelBaseDto.cs | 19 +++++--
.../Service/BookingSlot/BookingSlotService.cs | 40 ++++++++++-----
.../BookingSlot/Dto/BookingSlotBaseDto.cs | 7 ++-
5 files changed, 127 insertions(+), 19 deletions(-)
create mode 100644 Myshipping.Application/Entity/BookingLabelAllocation.cs
diff --git a/Myshipping.Application/Entity/BookingLabelAllocation.cs b/Myshipping.Application/Entity/BookingLabelAllocation.cs
new file mode 100644
index 00000000..62a8cee7
--- /dev/null
+++ b/Myshipping.Application/Entity/BookingLabelAllocation.cs
@@ -0,0 +1,30 @@
+using Myshipping.Core;
+using Myshipping.Core.Entity;
+using SqlSugar;
+using System.ComponentModel;
+namespace Myshipping.Application.Entity
+{
+ ///
+ ///
+ ///
+ [SugarTable("booking_label_allocation")]
+ [Description("订舱标签关联表")]
+ [Tenant(CommonConst.MasterDb)]
+ public class BookingLabelAllocation : PrimaryKeyEntity
+ {
+ ///
+ /// 标签主键
+ ///
+ public long LabelId { get; set; }
+
+ ///
+ /// 业务主键
+ ///
+ public long BusinessId { get; set; }
+
+ ///
+ /// 租户id
+ ///
+ public long TenantId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs b/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs
index 22e49869..011c24de 100644
--- a/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs
+++ b/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs
@@ -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
///
/// 订舱标签服务
///
+ [ApiDescriptionSettings("Application", Name = "BookingLabel", Order = 1)]
public class BookingLabelService : IBookingLabelService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
+ private readonly SqlSugarRepository _repAllocation;
private readonly ISysCacheService _cache;
public BookingLabelService(SqlSugarRepository rep,
- ISysCacheService cache)
+ ISysCacheService cache,
+ SqlSugarRepository repAllocation)
{
_rep = rep;
_cache = cache;
+ _repAllocation = repAllocation;
}
+
+ ///
+ /// 为舱位分配标签
+ ///
+ ///
+ [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 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;
+ }
+ }
///
/// 获取全部或指定范围类型的标签列表
///
diff --git a/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs b/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs
index 7648a202..88af57a9 100644
--- a/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs
+++ b/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs
@@ -13,8 +13,19 @@
///
public int Scope { get; set; }
}
- //public class BookingLabelCacheDto : BookingLabelBaseDto
- //{
- // public long TenantId { get; set; }
- //}
+
+ ///
+ /// 标签绑定Dto类
+ ///
+ public class BindLabelDto
+ {
+ ///
+ /// 标签主键列表
+ ///
+ public long[] LabelIdArray { get; set; }
+ ///
+ /// 业务主键列表
+ ///
+ public long[] BusinessIdArray { get; set; }
+ }
}
diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
index d209d965..057271b4 100644
--- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
@@ -44,6 +44,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository _repCtn;
private readonly SqlSugarRepository _repStock;
private readonly SqlSugarRepository _repAllocation;
+ private readonly SqlSugarRepository _repLabelAllocation;
private readonly SqlSugarRepository _repAllocationCtn;
private readonly SqlSugarRepository _bookingFileRepository;
private readonly SqlSugarRepository _bookingSlotCompareRepository;
@@ -90,7 +91,8 @@ namespace Myshipping.Application
SqlSugarRepository bookingOrderContactRepository,
INamedServiceProvider namedBookingOrderServiceProvider,
IBookingValueAddedService bookingValueAddedService,
- SqlSugarRepository repBookingOrder)
+ SqlSugarRepository repBookingOrder,
+ SqlSugarRepository 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) =>
- //{
- bookingOrderService.SaveLog(bookingOrder, oldBookingOrder, "舱位关联更新");
+ Parallel.For(0, 1, (n) =>
+ {
+ bookingOrderService.SaveLog(bookingOrder, oldBookingOrder, "舱位关联更新");
- // 推送东胜
- bookingOrderService.SendBookingOrder(new long[] { allocation.BOOKING_ID });
- //});
+ // 推送东胜
+ 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 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()
+ .Where(x => x.BusinessId == u.Id && input.LabelIdArray.Contains(x.LabelId))
+ .Any());
if (ctnCodeArr != null && ctnCodeArr.Length > 0)
{
var tempSelect = select as ISugarQueryable;
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);
diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs
index e5422ec4..7722bd79 100644
--- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs
+++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs
@@ -124,6 +124,11 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 周数
///
public string WEEK_AT { get; set; }
+
+ ///
+ /// 标签Id列表
+ ///
+ public long[] LabelIdArray { get; set; }
}
///
@@ -624,6 +629,6 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
///
/// 修改标记,前端提供给后端判断是否更新
///
- public bool UpdateFlag { get; set; }
+ public bool UpdateFlag { get; set; }
}
}