From f9bbf203d91e76b71be613b5db5d6a667b18253c Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Wed, 15 May 2024 16:00:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=88=B1=E4=BD=8D=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingSlot/BookingSlotService.cs | 75 ++++++++++++------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 34f2e770..f846fa95 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1345,34 +1345,55 @@ namespace Myshipping.Application [HttpPost("/BookingSlot/page")] public async Task Page(BookingSlotBasePageInput input) { - var entities = await _repBase.AsQueryable() - .WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO)) - .WhereIF(input.STATUS == 1, u => !u.IS_CANCELLATION) - .WhereIF(input.STATUS == 2, u => u.IS_CANCELLATION) - .WhereIF(!string.IsNullOrEmpty(input.VESSEL), u => u.VESSEL.Contains(input.VESSEL)) - .WhereIF(!string.IsNullOrEmpty(input.VOYNO), u => u.VOYNO.Contains(input.VOYNO)) - .WhereIF(!string.IsNullOrEmpty(input.PORTLOAD), u => u.PORTLOAD.Contains(input.PORTLOAD)) - .WhereIF(!string.IsNullOrEmpty(input.PORTDISCHARGE), u => u.PORTDISCHARGE.Contains(input.PORTDISCHARGE)) - - .WhereIF(input.ETD_START.HasValue, u => u.ETD >= input.ETD_START.Value) - .WhereIF(input.ETD_END.HasValue, u => u.ETD < input.ETD_END.Value.AddDays(1)) - .WhereIF(input.ETA_START.HasValue, u => u.ETA >= input.ETA_START.Value) - .WhereIF(input.ETA_END.HasValue, u => u.ETA < input.ETA_END.Value.AddDays(1)) - .WhereIF(!string.IsNullOrEmpty(input.CreatedUserName), u => u.CreatedUserName.Contains(input.CreatedUserName)) - .WhereIF(!string.IsNullOrEmpty(input.UpdatedUserName), u => u.UpdatedUserName.Contains(input.UpdatedUserName)) - - .WhereIF(!string.IsNullOrEmpty(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER)) - .WhereIF(!string.IsNullOrEmpty(input.CONTRACT_NO), u => u.CONTRACT_NO.Contains(input.CONTRACT_NO)) - .WhereIF(!string.IsNullOrEmpty(input.SI_RLT_STAT), u => u.SI_RLT_STAT == input.SI_RLT_STAT) - .WhereIF(!string.IsNullOrEmpty(input.VGM_RLT_STAT), u => u.VGM_RLT_STAT == input.VGM_RLT_STAT) - .WhereIF(!string.IsNullOrEmpty(input.CARRIAGE_TYPE), u => u.CARRIAGE_TYPE == input.CARRIAGE_TYPE) - .WhereIF(!string.IsNullOrEmpty(input.BOOKING_SLOT_TYPE), u => u.BOOKING_SLOT_TYPE == input.BOOKING_SLOT_TYPE) + if (!string.IsNullOrEmpty(input.WEEK_AT)) + { + input.WEEK_AT = "W" + input.WEEK_AT; + } + ISugarQueryable select = null; + string[] ctnCodeArr = null; + if (!string.IsNullOrEmpty(input.CTN_STAT)) + { + ctnCodeArr = input.CTN_STAT.Split(','); + select = _repBase.AsQueryable().InnerJoin((u, c) => u.Id == c.SLOT_ID); + } + else + { + select = _repBase.AsQueryable(); + } - .WhereIF(!string.IsNullOrEmpty(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME)) - .WhereIF(!string.IsNullOrEmpty(input.CTN_STAT), u => u.CTN_STAT.Contains(input.CTN_STAT)) - .WhereIF(!string.IsNullOrEmpty(input.WEEK_AT), u => u.WEEK_AT.Contains(input.WEEK_AT)) - .OrderByDescending(u => u.CreatedTime) - .ToPagedListAsync(input.PageNo, input.PageSize); + select = select.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO)) + .WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO)) + .WhereIF(input.STATUS == 1, u => !u.IS_CANCELLATION) + .WhereIF(input.STATUS == 2, u => u.IS_CANCELLATION) + .WhereIF(!string.IsNullOrEmpty(input.VESSEL), u => u.VESSEL.Contains(input.VESSEL)) + .WhereIF(!string.IsNullOrEmpty(input.VOYNO), u => u.VOYNO.Contains(input.VOYNO)) + .WhereIF(!string.IsNullOrEmpty(input.PORTLOAD), u => u.PORTLOAD.Contains(input.PORTLOAD)) + .WhereIF(!string.IsNullOrEmpty(input.PORTDISCHARGE), u => u.PORTDISCHARGE.Contains(input.PORTDISCHARGE)) + + .WhereIF(input.ETD_START.HasValue, u => u.ETD >= input.ETD_START.Value) + .WhereIF(input.ETD_END.HasValue, u => u.ETD < input.ETD_END.Value.AddDays(1)) + .WhereIF(input.ETA_START.HasValue, u => u.ETA >= input.ETA_START.Value) + .WhereIF(input.ETA_END.HasValue, u => u.ETA < input.ETA_END.Value.AddDays(1)) + .WhereIF(!string.IsNullOrEmpty(input.CreatedUserName), u => u.CreatedUserName.Contains(input.CreatedUserName)) + .WhereIF(!string.IsNullOrEmpty(input.UpdatedUserName), u => u.UpdatedUserName.Contains(input.UpdatedUserName)) + + .WhereIF(!string.IsNullOrEmpty(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER)) + .WhereIF(!string.IsNullOrEmpty(input.CONTRACT_NO), u => u.CONTRACT_NO.Contains(input.CONTRACT_NO)) + .WhereIF(!string.IsNullOrEmpty(input.SI_RLT_STAT), u => u.SI_RLT_STAT == input.SI_RLT_STAT) + .WhereIF(!string.IsNullOrEmpty(input.VGM_RLT_STAT), u => u.VGM_RLT_STAT == input.VGM_RLT_STAT) + .WhereIF(!string.IsNullOrEmpty(input.CARRIAGE_TYPE), u => u.CARRIAGE_TYPE == input.CARRIAGE_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.WEEK_AT), u => u.WEEK_AT == input.WEEK_AT); + + if (ctnCodeArr != null && ctnCodeArr.Length > 0) + { + var tempSelect = select as ISugarQueryable; + tempSelect.Where((u, c) => ctnCodeArr.Contains(c.CTNCODE)); + } + var entities = await select.OrderByDescending(u => u.CreatedTime) + .ToPagedListAsync(input.PageNo, input.PageSize); var result = entities.Adapt>(); From 067131ed327a1ff98e7fb5857920cf6c8b8fdc1f Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Thu, 16 May 2024 10:07:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E8=88=B1=E4=BD=8D=E5=8F=8A=E7=AE=B1=E5=AD=90=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E6=95=B4=E4=B8=BA=E5=88=86=E9=A1=B5=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingSlot/BookingSlotService.cs | 30 +++++++++++++++---- .../BookingSlot/Dto/BookingGenerateDto.cs | 19 ++++++++++++ .../BookingSlot/IBookingSlotService.cs | 13 ++++++-- Myshipping.Core/Extension/InputBase.cs | 8 ++++- Myshipping.Core/Myshipping.Core.xml | 5 ++++ 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index f846fa95..549ab7a3 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1087,9 +1087,17 @@ namespace Myshipping.Application /// 查询可用的舱位及箱子 /// [HttpGet("/BookingSlot/getAvailableSlots")] - public async Task> GetAvailableSlots([FromQuery] BookingSlotBaseDto input) + public async Task> GetAvailableSlots([FromQuery] BookingSlotBaseDto input, [FromQuery] PageWithTotal pageInfo) { - return await GetAvailableSlots(input, null); + var result = await GetAvailableSlots(input, null, pageInfo); + SqlSugarPagedList pageResult = new() + { + PageIndex = pageInfo.PageNo, + PageSize = pageInfo.PageSize, + TotalCount = pageInfo.Total, + Items = result, + }; + return pageResult; } /// @@ -1097,9 +1105,12 @@ namespace Myshipping.Application /// /// 筛选条件1:舱位信息、箱型 /// 筛选条件2:舱位主键列表 + /// 筛选条件3:分页 /// 可用的舱位列表(含可用的箱子列表) [NonAction] - public async Task> GetAvailableSlots(BookingSlotBaseDto slotInput = null, List slotIdListInput = null) + public async Task> GetAvailableSlots(BookingSlotBaseDto slotInput = null, + List slotIdListInput = null, + PageWithTotal pageInfo = null) { slotInput ??= new(); slotIdListInput ??= new(); @@ -1113,6 +1124,7 @@ namespace Myshipping.Application // 1. 【舱位基础表】与【箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【总的箱量】,作为queryable1 var queryable1 = _repBase.Context.Queryable((bas, ctn) => bas.Id == ctn.SLOT_ID) .Where(bas => bas.IS_CANCELLATION == false) + .WhereIF(!string.IsNullOrEmpty(slotInput.SLOT_BOOKING_NO), bas => bas.SLOT_BOOKING_NO == slotInput.SLOT_BOOKING_NO) .WhereIF(!string.IsNullOrEmpty(slotInput.PORTLOAD), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD)) .WhereIF(!string.IsNullOrEmpty(slotInput.PORTDISCHARGE), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD)) .WhereIF(!string.IsNullOrEmpty(slotInput.VESSEL), bas => bas.VESSEL.Contains(slotInput.VESSEL)) @@ -1161,7 +1173,15 @@ namespace Myshipping.Application .Where(r => r.numResidue > 0); // 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表 - var canUselist = await queryable3.ToListAsync(); + RefAsync total = 0; + var canUselist = pageInfo == null + ? await queryable3.ToListAsync() + : await queryable3.ToPageListAsync(pageInfo.PageNo, pageInfo.PageSize, total); + + if (pageInfo != null) + { + pageInfo.Total = total; + } // 查询舱位列表 var baseIdList = canUselist.Select(c => c.id); @@ -1340,8 +1360,6 @@ namespace Myshipping.Application /// /// 分页查询订舱舱位 /// - /// - /// [HttpPost("/BookingSlot/page")] public async Task Page(BookingSlotBasePageInput input) { diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs index 42580ad8..6dd3f4f1 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs @@ -107,5 +107,24 @@ namespace Myshipping.Application /// 客服名称 /// public string CustServiceName { get; set; } + /// + /// 销售日期 + /// + public DateTime? SALE_TIME { get; set; } + + /// + /// 发货人 + /// + public string SHIPPER { get; set; } + + /// + /// 品名 + /// + public string GOODSNAME { get; set; } + + /// + /// 卖价 + /// + public decimal? SELLING_PRICE { get; set; } } } diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index 6495174c..b5278c81 100644 --- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Myshipping.Application.Entity; using Myshipping.Application.Event; using Myshipping.Application.Service.BookingSlot.Dto; +using Myshipping.Core; using System.Collections.Generic; using System.Threading.Tasks; @@ -21,15 +22,21 @@ namespace Myshipping.Application Task ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null); Task Detail(long id); - Task> GetAvailableSlots(BookingSlotBaseDto input); + /// + /// 查询可用的舱位及箱子 + /// + Task> GetAvailableSlots(BookingSlotBaseDto input, PageWithTotal pageInfo); /// /// 查询可用的舱位及箱子列表 /// /// 筛选条件1:舱位信息、箱型 /// 筛选条件2:舱位主键列表 + /// 筛选条件3:分页 /// 可用的舱位列表(含可用的箱子列表) - Task> GetAvailableSlots(BookingSlotBaseDto slotInput = null, List slotIdListInput = null); + Task> GetAvailableSlots(BookingSlotBaseDto slotInput = null, + List slotIdListInput = null, + PageWithTotal pageInfo = null); /// /// 检查指定订舱记录,是否可以引入舱位列表 @@ -113,7 +120,7 @@ namespace Myshipping.Application /// 租户ID /// 返回回执 - Task SearchBookingSlotWithOrderByNo(string slotBookingNo,long tenantId); + Task SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId); /// /// 校验是否可以生成订舱订单 diff --git a/Myshipping.Core/Extension/InputBase.cs b/Myshipping.Core/Extension/InputBase.cs index 4bc90283..8a762797 100644 --- a/Myshipping.Core/Extension/InputBase.cs +++ b/Myshipping.Core/Extension/InputBase.cs @@ -65,7 +65,13 @@ public class PageInputBase public List MultiSort { get; set; } } - +/// +/// 分页参数-含总数 +/// +public class PageWithTotal : PageInputBase +{ + public virtual int Total { get; set; } +} /// /// 查询排序 /// diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index eb4578c6..87d016ef 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -6156,6 +6156,11 @@ 排序方法,默认降序 + + + 分页参数-含总数 + + 查询排序