|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 派车台账查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="QuerySearch">派车台账查询请求</param>
|
|
|
|
|
/// <returns>返回结果</returns>
|
|
|
|
|
[HttpPost("/BookingTruck/GetPage")]
|
|
|
|
|
public async Task<SqlSugarPagedList<BookingTruckPageDto>> GetPageAsync([FromBody] QueryBookingTruckDto QuerySearch)
|
|
|
|
|
{
|
|
|
|
|
List<string> contaList = new List<string>();
|
|
|
|
|
|
|
|
|
|
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<BookingTruckDto, BookingTruck>(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<SqlSugarPagedList<BookingTruckPageDto>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BookingTruckDto InnerCreateTruckFromBookingOrder(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
BookingTruckDto model = null;
|
|
|
|
|