From 89d6d6d3d884ad22b590d03d58da0917110ae0fd Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 17 Apr 2023 16:09:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BE=E8=BD=A6=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=B0=E8=B4=A6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/Entity/BookingTruck.cs | 5 + .../Enum/BookingTruckStatus.cs | 41 +++++ .../BookingTruck/BookingTruckService.cs | 159 ++++++++++++++++ .../BookingTruck/Dtos/BookingTruckPageDto.cs | 16 ++ .../Dtos/BookingTruckShowBaseDto.cs | 171 ++++++++++++++++++ .../BookingTruck/Dtos/BookingTruckShowDto.cs | 159 +--------------- .../BookingTruck/Dtos/QueryBookingTruckDto.cs | 118 ++++++++++++ .../Interface/IBookingTruckService.cs | 10 +- 8 files changed, 521 insertions(+), 158 deletions(-) create mode 100644 Myshipping.Application/Enum/BookingTruckStatus.cs create mode 100644 Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckPageDto.cs create mode 100644 Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowBaseDto.cs create mode 100644 Myshipping.Application/Service/BookingTruck/Dtos/QueryBookingTruckDto.cs diff --git a/Myshipping.Application/Entity/BookingTruck.cs b/Myshipping.Application/Entity/BookingTruck.cs index d848dd80..a7f58a81 100644 --- a/Myshipping.Application/Entity/BookingTruck.cs +++ b/Myshipping.Application/Entity/BookingTruck.cs @@ -206,5 +206,10 @@ namespace Myshipping.Application.Entity /// [Description("调度名称")] public string DispatcherName { get; set; } + /// + /// 派车流水号 + /// + [Description("派车流水号")] + public string TruckFlowNo { get; set; } } } diff --git a/Myshipping.Application/Enum/BookingTruckStatus.cs b/Myshipping.Application/Enum/BookingTruckStatus.cs new file mode 100644 index 00000000..56199095 --- /dev/null +++ b/Myshipping.Application/Enum/BookingTruckStatus.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 派车状态枚举 + /// + public enum BookingTruckStatus + { + /// + /// 暂存 + /// + [Description("暂存")] + TEMP, + /// + /// 已提交 + /// + [Description("已提交")] + SUBMITED, + /// + /// 已撤销 + /// + [Description("已撤销")] + CANCELED, + /// + /// 已发派车 + /// + [Description("已撤销")] + SEND_DISPATCH, + /// + /// 已撤销派车 + /// + [Description("已撤销")] + CANCEL_DISPATCH + } +} diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index 18818075..34d1d715 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -9,6 +9,7 @@ using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Myshipping.Application.Entity; +using Myshipping.Application.Helper; using Myshipping.Core; using Myshipping.Core.Entity; using Myshipping.Core.Service; @@ -17,6 +18,7 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Myshipping.Application @@ -193,6 +195,163 @@ namespace Myshipping.Application return result; } + /// + /// 派车台账查询 + /// + /// 派车台账查询请求 + /// 返回结果 + [HttpPost("/BookingTruck/GetPage")] + public async Task> GetPageAsync([FromBody] QueryBookingTruckDto QuerySearch) + { + List contaList = new List(); + + if (!string.IsNullOrWhiteSpace(QuerySearch.ContaNo)) + { + if (Regex.IsMatch(QuerySearch.ContaNo, "(\\t|\\n\\r|\\n)")) + { + contaList = Regex.Replace(QuerySearch.ContaNo, "(\\t |\\n\\r |\\n)", "#").Split(new char[] { '#' }).Select(t => t?.Trim()).ToList(); + } + else + { + contaList.Add(QuerySearch.ContaNo.Trim()); + } + } + //制单日期 + DateTime createBegin = DateTime.MinValue; + DateTime createEnd = DateTime.MinValue; + //派车日期 + DateTime truckDateBegin = DateTime.MinValue; + DateTime truckDateEnd = DateTime.MinValue; + //截单日期 + DateTime closeDateBegin = DateTime.MinValue; + DateTime closeDateEnd = DateTime.MinValue; + //提货日期 + DateTime pickUpTimeBegin = DateTime.MinValue; + DateTime pickUpTimeEnd = DateTime.MinValue; + //返场时间 + DateTime returnTimeBegin = DateTime.MinValue; + DateTime returnTimeEnd = DateTime.MinValue; + //要求到达时间 + DateTime needArriveTimeBegin = DateTime.MinValue; + DateTime needArriveTimeEnd = DateTime.MinValue; + + #region 查询条件 + + //制单日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.CreateBegin)) + { + if (!DateTime.TryParse(QuerySearch.CreateBegin, out createBegin)) + throw Oops.Oh($"创建起始日期格式错误,{QuerySearch.CreateBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.CreateEnd)) + { + if (!DateTime.TryParse(QuerySearch.CreateEnd, out createEnd)) + throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateEnd}"); + + createEnd = createEnd.AddDays(1); + } + //派车日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.TruckTimeBegin)) + { + if (!DateTime.TryParse(QuerySearch.TruckTimeBegin, out truckDateBegin)) + throw Oops.Oh($"派车起始日期格式错误,{QuerySearch.TruckTimeBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.TruckTimeEnd)) + { + if (!DateTime.TryParse(QuerySearch.TruckTimeEnd, out truckDateEnd)) + throw Oops.Oh($"派车结束日期格式错误,{QuerySearch.TruckTimeEnd}"); + + truckDateEnd = truckDateEnd.AddDays(1); + } + //截单日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.ClosingTimeBegin)) + { + if (!DateTime.TryParse(QuerySearch.ClosingTimeBegin, out closeDateBegin)) + throw Oops.Oh($"截单起始日期格式错误,{QuerySearch.ClosingTimeBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.ClosingTimeEnd)) + { + if (!DateTime.TryParse(QuerySearch.ClosingTimeEnd, out closeDateEnd)) + throw Oops.Oh($"截单结束日期格式错误,{QuerySearch.ClosingTimeEnd}"); + + closeDateEnd = closeDateEnd.AddDays(1); + } + //提货日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.PickUpTimeBegin)) + { + if (!DateTime.TryParse(QuerySearch.PickUpTimeBegin, out pickUpTimeBegin)) + throw Oops.Oh($"提货起始日期格式错误,{QuerySearch.PickUpTimeBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.PickUpTimeEnd)) + { + if (!DateTime.TryParse(QuerySearch.ClosingTimeEnd, out pickUpTimeEnd)) + throw Oops.Oh($"提货结束日期格式错误,{QuerySearch.PickUpTimeEnd}"); + + pickUpTimeEnd = pickUpTimeEnd.AddDays(1); + } + //返场时间 + if (!string.IsNullOrWhiteSpace(QuerySearch.ReturnTimeBegin)) + { + if (!DateTime.TryParse(QuerySearch.ReturnTimeBegin, out returnTimeBegin)) + throw Oops.Oh($"返场起始日期格式错误,{QuerySearch.ReturnTimeBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.ReturnTimeEnd)) + { + if (!DateTime.TryParse(QuerySearch.ReturnTimeEnd, out returnTimeEnd)) + throw Oops.Oh($"返场结束日期格式错误,{QuerySearch.ReturnTimeEnd}"); + + returnTimeEnd = returnTimeEnd.AddDays(1); + } + //要求到达时间 + if (!string.IsNullOrWhiteSpace(QuerySearch.NeedArriveTimeBegin)) + { + if (!DateTime.TryParse(QuerySearch.NeedArriveTimeBegin, out needArriveTimeBegin)) + throw Oops.Oh($"返场起始日期格式错误,{QuerySearch.NeedArriveTimeBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.NeedArriveTimeEnd)) + { + if (!DateTime.TryParse(QuerySearch.NeedArriveTimeEnd, out needArriveTimeEnd)) + throw Oops.Oh($"返场结束日期格式错误,{QuerySearch.NeedArriveTimeEnd}"); + + needArriveTimeEnd = needArriveTimeEnd.AddDays(1); + } + #endregion + + string entityOrderCol = "CreatedTime"; + + //这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段 + if (!string.IsNullOrWhiteSpace(QuerySearch.SortField)) + entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); + + var entities = await _bookingTruckRepository.AsQueryable() + .WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value >= createBegin) + .WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime.HasValue && t.CreatedTime.Value < createEnd) + .WhereIF(truckDateBegin != DateTime.MinValue, t => t.TruckTime.HasValue && t.TruckTime.Value >= truckDateBegin) + .WhereIF(truckDateEnd != DateTime.MinValue, t => t.TruckTime.HasValue && t.TruckTime.Value < truckDateEnd) + .WhereIF(closeDateBegin != DateTime.MinValue, t => t.ClosingTime.HasValue && t.ClosingTime.Value >= closeDateBegin) + .WhereIF(closeDateEnd != DateTime.MinValue, t => t.ClosingTime.HasValue && t.ClosingTime.Value < closeDateEnd) + .WhereIF(pickUpTimeBegin != DateTime.MinValue, t => t.PickUpTime.HasValue && t.PickUpTime.Value >= pickUpTimeBegin) + .WhereIF(pickUpTimeEnd != DateTime.MinValue, t => t.PickUpTime.HasValue && t.PickUpTime.Value < pickUpTimeEnd) + .WhereIF(returnTimeBegin != DateTime.MinValue, t => t.ReturnTime.HasValue && t.ReturnTime.Value >= returnTimeBegin) + .WhereIF(returnTimeEnd != DateTime.MinValue, t => t.ReturnTime.HasValue && t.ReturnTime.Value < returnTimeEnd) + .WhereIF(needArriveTimeBegin != DateTime.MinValue, t => t.NeedArriveTime.HasValue && t.NeedArriveTime.Value >= needArriveTimeBegin) + .WhereIF(needArriveTimeEnd != DateTime.MinValue, t => t.NeedArriveTime.HasValue && t.NeedArriveTime.Value < needArriveTimeEnd) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.Yard), t => t.YARDID.Contains(QuerySearch.Yard) || t.YARD.Contains(QuerySearch.Yard)) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.InYard), t => t.InYardID.Contains(QuerySearch.Yard) || t.InYard.Contains(QuerySearch.Yard)) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.Status), t => t.Status == QuerySearch.Status) + .OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc ")) + .ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize); + + + return entities.Adapt>(); + } + private BookingTruckDto InnerCreateTruckFromBookingOrder(long bookingId) { BookingTruckDto model = null; diff --git a/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckPageDto.cs b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckPageDto.cs new file mode 100644 index 00000000..75649a19 --- /dev/null +++ b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckPageDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + public class BookingTruckPageDto: BookingTruckShowBaseDto + { + + } +} diff --git a/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowBaseDto.cs b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowBaseDto.cs new file mode 100644 index 00000000..a8b70431 --- /dev/null +++ b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowBaseDto.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + public class BookingTruckShowBaseDto + { + /// + /// 主键 + /// + public long Id { get; set; } + /// + /// 车队ID + /// + public Nullable TruckId { get; set; } + /// + /// 车队代码 + /// + public string TruckCode { get; set; } + /// + /// 车队代码 + /// + public string TruckName { get; set; } + /// + /// TO + /// + public string ToName { get; set; } + /// + /// ATTN + /// + public string Attn { get; set; } + /// + /// ATTN电话 + /// + public string AttnTel { get; set; } + /// + /// ATTN邮箱 + /// + public string AttnMail { get; set; } + /// + /// FROM + /// + public string FromName { get; set; } + /// + /// FROM电话 + /// + public string FromTel { get; set; } + /// + /// FROM邮箱 + /// + public string FromMail { get; set; } + /// + /// 吨数 + /// + public Nullable KGS { get; set; } + /// + /// 陆运费 + /// + public Nullable Fee { get; set; } + /// + /// 支付方式 + /// + public string PayMethod { get; set; } + /// + /// 支付方式名称 + /// + public string PayMethodName { get; set; } + /// + /// 派车日期 + /// + public Nullable TruckTime { get; set; } + /// + /// 提箱场站ID + /// + public string YARDID { get; set; } + /// + /// 提箱场站 + /// + public string YARD { get; set; } + /// + /// 场站联系人 + /// + public string YARDCONTRACT { get; set; } + /// + /// 场站联系人电话 + /// + public string YARDCONTRACTTEL { get; set; } + /// + /// 工厂ID + /// + public Nullable FactoryId { get; set; } + /// + /// 工厂代码 + /// + public string FactoryCode { get; set; } + /// + /// 工厂名称 + /// + public string FactoryName { get; set; } + /// + /// 工厂联系人 + /// + public string FactoryContact { get; set; } + /// + /// 工厂联系电话 + /// + public string FactoryTel { get; set; } + /// + /// 返场时间 + /// + public Nullable ReturnTime { get; set; } + /// + /// 入货场站ID + /// + public string InYardID { get; set; } + /// + /// 入货场站 + /// + public string InYard { get; set; } + /// + /// 入货联系人 + /// + public string InYardContact { get; set; } + /// + /// 入货联系人电话 + /// + public string InYardContractTel { get; set; } + /// + /// 要求到达时间 + /// + public Nullable NeedArriveTime { get; set; } + /// + /// 截港日期 + /// + public Nullable ClosingTime { get; set; } + /// + /// 提货日期 + /// + public Nullable PickUpTime { get; set; } + /// + /// 是否挂机 + /// + public bool IsGuaJi { get; set; } + /// + /// 状态 + /// + public string Status { get; set; } + /// + /// 注意事项 + /// + public string Attention { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 调度ID + /// + public Nullable DispatcherId { get; set; } + /// + /// 调度名称 + /// + public string DispatcherName { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowDto.cs b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowDto.cs index c4a5cc7c..50c1b3c1 100644 --- a/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowDto.cs +++ b/Myshipping.Application/Service/BookingTruck/Dtos/BookingTruckShowDto.cs @@ -9,164 +9,9 @@ namespace Myshipping.Application /// /// /// - public class BookingTruckShowDto + public class BookingTruckShowDto: BookingTruckShowBaseDto { - /// - /// 主键 - /// - public long Id { get; set; } - /// - /// 车队ID - /// - public Nullable TruckId { get; set; } - /// - /// 车队代码 - /// - public string TruckCode { get; set; } - /// - /// 车队代码 - /// - public string TruckName { get; set; } - /// - /// TO - /// - public string ToName { get; set; } - /// - /// ATTN - /// - public string Attn { get; set; } - /// - /// ATTN电话 - /// - public string AttnTel { get; set; } - /// - /// ATTN邮箱 - /// - public string AttnMail { get; set; } - /// - /// FROM - /// - public string FromName { get; set; } - /// - /// FROM电话 - /// - public string FromTel { get; set; } - /// - /// FROM邮箱 - /// - public string FromMail { get; set; } - /// - /// 吨数 - /// - public Nullable KGS { get; set; } - /// - /// 陆运费 - /// - public Nullable Fee { get; set; } - /// - /// 支付方式 - /// - public string PayMethod { get; set; } - /// - /// 支付方式名称 - /// - public string PayMethodName { get; set; } - /// - /// 派车日期 - /// - public Nullable TruckTime { get; set; } - /// - /// 提箱场站ID - /// - public string YARDID { get; set; } - /// - /// 提箱场站 - /// - public string YARD { get; set; } - /// - /// 场站联系人 - /// - public string YARDCONTRACT { get; set; } - /// - /// 场站联系人电话 - /// - public string YARDCONTRACTTEL { get; set; } - /// - /// 工厂ID - /// - public Nullable FactoryId { get; set; } - /// - /// 工厂代码 - /// - public string FactoryCode { get; set; } - /// - /// 工厂名称 - /// - public string FactoryName { get; set; } - /// - /// 工厂联系人 - /// - public string FactoryContact { get; set; } - /// - /// 工厂联系电话 - /// - public string FactoryTel { get; set; } - /// - /// 返场时间 - /// - public Nullable ReturnTime { get; set; } - /// - /// 入货场站ID - /// - public string InYardID { get; set; } - /// - /// 入货场站 - /// - public string InYard { get; set; } - /// - /// 入货联系人 - /// - public string InYardContact { get; set; } - /// - /// 入货联系人电话 - /// - public string InYardContractTel { get; set; } - /// - /// 要求到达时间 - /// - public Nullable NeedArriveTime { get; set; } - /// - /// 截港日期 - /// - public Nullable ClosingTime { get; set; } - /// - /// 提货日期 - /// - public Nullable PickUpTime { get; set; } - /// - /// 是否挂机 - /// - public bool IsGuaJi { get; set; } - /// - /// 状态 - /// - public string Status { get; set; } - /// - /// 注意事项 - /// - public string Attention { get; set; } - /// - /// 备注 - /// - public string Remark { get; set; } - /// - /// 调度ID - /// - public Nullable DispatcherId { get; set; } - /// - /// 调度名称 - /// - public string DispatcherName { get; set; } + /// /// 集装箱列表 /// diff --git a/Myshipping.Application/Service/BookingTruck/Dtos/QueryBookingTruckDto.cs b/Myshipping.Application/Service/BookingTruck/Dtos/QueryBookingTruckDto.cs new file mode 100644 index 00000000..31891c19 --- /dev/null +++ b/Myshipping.Application/Service/BookingTruck/Dtos/QueryBookingTruckDto.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 派车台账查询 + /// + public class QueryBookingTruckDto: QueryTaskManageBaseDto + { + /// + /// 派车单号 + /// + public int TruckFlowNo { get; set; } + + /// + /// 创建日期起始 + /// + /// + public string CreateBegin { get; set; } + + /// + /// 创建日期结束 + /// + /// + public string CreateEnd { get; set; } + + /// + /// 支付方式 + /// + public string PayMethod { get; set; } + + /// + /// 派车日期起始 + /// + public string TruckTimeBegin { get; set; } + + /// + /// 派车日期结束 + /// + public string TruckTimeEnd { get; set; } + + /// + /// 返场时间起始 + /// + public string ReturnTimeBegin { get; set; } + + /// + /// 返场时间结束 + /// + public string ReturnTimeEnd { get; set; } + + /// + /// 要求到达时间起始 + /// + public string NeedArriveTimeBegin { get; set; } + + /// + /// 要求到达时间结束 + /// + public string NeedArriveTimeEnd { get; set; } + + /// + /// 截港日期起始 + /// + public string ClosingTimeBegin { get; set; } + + /// + /// 截港日期结束 + /// + public string ClosingTimeEnd { get; set; } + + /// + /// 提货日期起始 + /// + public string PickUpTimeBegin { get; set; } + + /// + /// 提货日期结束 + /// + public string PickUpTimeEnd { get; set; } + + /// + /// 车队ID + /// + public Nullable TruckId { get; set; } + + /// + /// 集装箱号 + /// + public string ContaNo { get; set; } + + /// + /// 工厂ID + /// + public Nullable FactoryId { get; set; } + + /// + /// 提箱场站代码 + /// + public string Yard { get; set; } + + /// + /// 入货场站代码 + /// + public string InYard { get; set; } + + /// + /// 状态 + /// + public string Status { get; set; } + + } +} diff --git a/Myshipping.Application/Service/BookingTruck/Interface/IBookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/Interface/IBookingTruckService.cs index fca13849..2e53ee43 100644 --- a/Myshipping.Application/Service/BookingTruck/Interface/IBookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/Interface/IBookingTruckService.cs @@ -1,4 +1,5 @@ -using System; +using Myshipping.Core; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -40,6 +41,13 @@ namespace Myshipping.Application /// 返回派车集装箱初始信息 Task PullInBookingOrderConta(long bookingId); + /// + /// 派车台账查询 + /// + /// 派车台账查询请求 + /// 返回结果 + Task> GetPageAsync(QueryBookingTruckDto QuerySearch); + /// /// 获取派车详情 ///