diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs index 83ba5dfe..4259edc9 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs @@ -3,6 +3,7 @@ using DS.Module.Core.Data; using DS.Module.DjyServiceStatus; using DS.WMS.Core.Op.Dtos; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; @@ -38,6 +39,13 @@ namespace DS.WMS.Core.Op.Interface /// 返回详情 Task> Detail(long id); + // + /// 分页查询可用的舱位及箱子列表 + /// + /// 可选:舱位查询条件 + /// 可选:分页信息 + Task>> GetAvailableSlots(BookingSlotBaseDto input, PageWithTotal pageInfo); + /// /// 查询可用的舱位及箱子列表 /// @@ -216,5 +224,12 @@ namespace DS.WMS.Core.Op.Interface /// 舱位主键数组 /// 返回回执 Task Delete(long[] ids); + + /// + /// 查询指定舱位可用的箱子列表 + /// + /// 舱位主键 + /// 可用的箱子列表 + Task>> GetAvailableCtnsBySlot(long slotId); } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs index 621d959d..af8d4634 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs @@ -1849,8 +1849,7 @@ namespace DS.WMS.Core.Op.Method /// /// 可选:舱位查询条件 /// 可选:分页信息 - public async Task> GetAvailableSlots([FromQuery] BookingSlotBaseDto input, - [FromQuery] PageWithTotal pageInfo) + public async Task>> GetAvailableSlots(BookingSlotBaseDto input,PageWithTotal pageInfo) { var result = await GetAvailableSlots(input, null, pageInfo); @@ -1861,7 +1860,7 @@ namespace DS.WMS.Core.Op.Method TotalCount = pageInfo.Total, Items = result, }; - return pageResult; + return DataResult>.Success(pageResult); } #endregion @@ -1873,7 +1872,6 @@ namespace DS.WMS.Core.Op.Method /// 筛选条件2:舱位主键列表 /// 筛选条件3:分页 /// 可用的舱位列表(含可用的箱子列表) - [NonAction] public async Task> GetAvailableSlots(BookingSlotBaseDto slotInput = null, List slotIdListInput = null, PageWithTotal pageInfo = null) @@ -3762,6 +3760,86 @@ namespace DS.WMS.Core.Op.Method return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotDeleteSucc))); } #endregion + + /// + /// 查询指定舱位可用的箱子列表 + /// + /// 舱位主键 + /// 可用的箱子列表 + public async Task>> GetAvailableCtnsBySlot(long slotId) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (await tenantDb.Queryable().AnyAsync(x => x.Id == slotId && x.IsCancellation == false) == false) + { + //获取舱位失败,舱位不存在或已作废 + throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotCreateRecordDeletedOrNoExists))); + } + + // 1. 【舱位基础表】与【箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【总的箱量】,作为queryable1 + var queryable1 = tenantDb.Queryable((bas, ctn) => bas.Id == ctn.SlotId) + .Where(bas => bas.IsCancellation == false && bas.Id == slotId) + .GroupBy((bas, ctn) => new + { + bas.Id, + ctn.CtnCode + }) + .Select((bas, ctn) => new + { + id = bas.Id, + ctnCode = ctn.CtnCode, + numAll = SqlFunc.AggregateSum(ctn.CtnNum) + }) + .MergeTable(); + + // 2. 【已引入舱位表】与【已使用的箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【已使用的箱量】,作为queryable2 + var queryable2 = tenantDb.Queryable((alc, ctn) => alc.Id == ctn.SlotAllocId) + .Where((alc, ctn) => alc.BookingSlotId == slotId) + .GroupBy((alc, ctn) => new + { + alc.BookingSlotId, + ctn.CtnCode + }) + .Select((alc, ctn) => new + { + id = alc.BookingSlotId, + ctnCode = ctn.CtnCode, + numUse = SqlFunc.AggregateSum(ctn.CtnNum) + }) + .MergeTable(); + + // 3. 将queryable1 左连接 queryable2,使用【总的箱量】减去【已使用的箱量】,得到【剩余的箱量】,添加【剩余的箱量】> 0 的条件,作为queryable3 + var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode) + .Select((q1, q2) => new + { + q1.id, + q1.ctnCode, + numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll) + }) + .MergeTable() + .Where(r => r.numResidue > 0); + + // 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表 + var canUselist = await queryable3.ToListAsync(); + + List ctnCodeCache = new List(); + + var allCtnCodeList = await _codeCtnService.GetAllList(); + + if (allCtnCodeList.Succeeded) + { + ctnCodeCache = allCtnCodeList.Data; + } + + List result = canUselist.Select(c => new BookingSlotCtnDto() + { + CtnCode = c.ctnCode, + CtnNum = c.numResidue, + CtnAll = ctnCodeCache.FirstOrDefault(e => $"{e.CtnSize}{e.CtnType}" == c.ctnCode)?.CtnName ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"), + }).ToList(); + + return DataResult>.Success(result); + } } public static class LetterIndexUtil diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/BookingSlotServiceController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/BookingSlotServiceController.cs index 92554da8..9e08504e 100644 --- a/ds-wms-service/DS.WMS.OpApi/Controllers/BookingSlotServiceController.cs +++ b/ds-wms-service/DS.WMS.OpApi/Controllers/BookingSlotServiceController.cs @@ -59,17 +59,17 @@ namespace DS.WMS.OpApi.Controllers #region 查询可用的舱位及箱子列表 /// - /// 查询可用的舱位及箱子列表 + /// 分页查询可用的舱位及箱子列表 /// - /// 筛选条件1:舱位信息、箱型 - /// 筛选条件2:舱位主键列表 - /// 筛选条件3:分页 + /// 可选:舱位查询条件 + /// 可选:分页信息 /// 可用的舱位列表(含可用的箱子列表) - [HttpPost] + [HttpGet] [Route("GetAvailableSlots")] - public async Task>> GetAvailableSlots([FromBody] BookingSlotBaseDto slotInput ) + public async Task>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input, + [FromQuery] PageWithTotal pageInfo) { - return await _bookingSlotService.GetAvailableSlots(slotInput, null, null); + return await _bookingSlotService.GetAvailableSlots(input, pageInfo); } #endregion @@ -357,5 +357,19 @@ namespace DS.WMS.OpApi.Controllers return await _bookingSlotService.Delete(ids); } #endregion + + #region 查询指定舱位可用的箱子列表 + /// + /// 查询指定舱位可用的箱子列表 + /// + /// 舱位主键 + /// 可用的箱子列表 + [HttpGet] + [Route("GetAvailableCtnsBySlot")] + public async Task>> GetAvailableCtnsBySlot(long slotId) + { + return await _bookingSlotService.GetAvailableCtnsBySlot(slotId); + } + #endregion } } diff --git a/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt index 5e899ea5..a041aec7 100644 --- a/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt @@ -782,3 +782,17 @@ 2024-07-24 14:14:41.8726 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config 2024-07-24 14:14:41.8726 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-07-24 14:14:41.8863 Info Configuration initialized. +2024-07-24 17:43:01.5160 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-24 17:43:01.5361 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-24 17:43:01.5361 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-24 17:43:01.5528 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-24 17:43:01.5595 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config +2024-07-24 17:43:01.5595 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-24 17:43:01.5595 Info Configuration initialized. +2024-07-24 17:52:22.4155 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-07-24 17:52:22.4304 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-07-24 17:52:22.4304 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-07-24 17:52:22.4474 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-07-24 17:52:22.4474 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config +2024-07-24 17:52:22.4592 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-07-24 17:52:22.4592 Info Configuration initialized. diff --git a/ds-wms-service/DS.WMS.OpApi/Properties/PublishProfiles/FolderProfile.pubxml.user b/ds-wms-service/DS.WMS.OpApi/Properties/PublishProfiles/FolderProfile.pubxml.user index f23f532f..b53da925 100644 --- a/ds-wms-service/DS.WMS.OpApi/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/ds-wms-service/DS.WMS.OpApi/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -6,7 +6,7 @@ <_PublishTargetUrl>D:\Code\PublishCopy\ds8-opapi - True|2024-07-24T08:01:13.8217949Z||;True|2024-07-24T15:56:15.7589616+08:00||;True|2024-07-24T15:38:29.2442086+08:00||;True|2024-07-24T14:48:12.2303919+08:00||;True|2024-07-24T14:18:05.5309704+08:00||;True|2024-07-24T12:56:48.1663545+08:00||;True|2024-07-24T08:47:26.1616069+08:00||;True|2024-07-24T08:42:02.7606608+08:00||;True|2024-07-24T08:41:18.4678459+08:00||;False|2024-07-24T08:40:29.5381703+08:00||;False|2024-07-24T08:39:20.2230656+08:00||;True|2024-07-23T15:56:16.8305907+08:00||;True|2024-07-22T16:42:12.1933090+08:00||;True|2024-07-19T18:28:29.1420269+08:00||;True|2024-07-19T15:45:49.1068004+08:00||;True|2024-07-19T15:33:45.3242155+08:00||;False|2024-07-19T15:32:41.9604526+08:00||;True|2024-07-19T13:48:27.9722093+08:00||;False|2024-07-19T13:47:56.7900396+08:00||;True|2024-07-19T11:41:15.4223247+08:00||;True|2024-07-19T08:46:28.8014836+08:00||;True|2024-07-18T19:24:50.4184188+08:00||;True|2024-07-18T19:19:14.7056635+08:00||;True|2024-07-18T19:04:43.5615501+08:00||;True|2024-07-18T18:38:39.1976753+08:00||;True|2024-07-18T18:25:15.6833492+08:00||;True|2024-07-18T18:08:46.3114951+08:00||;True|2024-07-18T17:59:12.5292256+08:00||;True|2024-07-18T16:18:45.8049777+08:00||;True|2024-07-18T16:12:42.9723969+08:00||;True|2024-07-18T16:07:14.1432207+08:00||;True|2024-07-17T17:44:18.4741963+08:00||;True|2024-07-17T17:42:47.2735071+08:00||;True|2024-07-17T16:13:32.9037697+08:00||;True|2024-07-17T15:40:21.2550083+08:00||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||; + True|2024-07-24T10:10:14.9409342Z||;True|2024-07-24T17:52:10.3966338+08:00||;True|2024-07-24T16:01:13.8217949+08:00||;True|2024-07-24T15:56:15.7589616+08:00||;True|2024-07-24T15:38:29.2442086+08:00||;True|2024-07-24T14:48:12.2303919+08:00||;True|2024-07-24T14:18:05.5309704+08:00||;True|2024-07-24T12:56:48.1663545+08:00||;True|2024-07-24T08:47:26.1616069+08:00||;True|2024-07-24T08:42:02.7606608+08:00||;True|2024-07-24T08:41:18.4678459+08:00||;False|2024-07-24T08:40:29.5381703+08:00||;False|2024-07-24T08:39:20.2230656+08:00||;True|2024-07-23T15:56:16.8305907+08:00||;True|2024-07-22T16:42:12.1933090+08:00||;True|2024-07-19T18:28:29.1420269+08:00||;True|2024-07-19T15:45:49.1068004+08:00||;True|2024-07-19T15:33:45.3242155+08:00||;False|2024-07-19T15:32:41.9604526+08:00||;True|2024-07-19T13:48:27.9722093+08:00||;False|2024-07-19T13:47:56.7900396+08:00||;True|2024-07-19T11:41:15.4223247+08:00||;True|2024-07-19T08:46:28.8014836+08:00||;True|2024-07-18T19:24:50.4184188+08:00||;True|2024-07-18T19:19:14.7056635+08:00||;True|2024-07-18T19:04:43.5615501+08:00||;True|2024-07-18T18:38:39.1976753+08:00||;True|2024-07-18T18:25:15.6833492+08:00||;True|2024-07-18T18:08:46.3114951+08:00||;True|2024-07-18T17:59:12.5292256+08:00||;True|2024-07-18T16:18:45.8049777+08:00||;True|2024-07-18T16:12:42.9723969+08:00||;True|2024-07-18T16:07:14.1432207+08:00||;True|2024-07-17T17:44:18.4741963+08:00||;True|2024-07-17T17:42:47.2735071+08:00||;True|2024-07-17T16:13:32.9037697+08:00||;True|2024-07-17T15:40:21.2550083+08:00||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||; \ No newline at end of file