|
|
|
@ -32,16 +32,23 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingTruck> _bookingTruckRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingTruckCtn> _bookingTruckContaRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _bookingCtnRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BookingTruckService(ISysCacheService cache, ILogger<BookingTruckService> logger,
|
|
|
|
|
SqlSugarRepository<BookingTruck> bookingTruckRepository,
|
|
|
|
|
SqlSugarRepository<BookingTruckCtn> bookingTruckContaRepository)
|
|
|
|
|
SqlSugarRepository<BookingTruckCtn> bookingTruckContaRepository,
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
|
|
|
SqlSugarRepository<BookingCtn> bookingCtnRepository)
|
|
|
|
|
{
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
|
|
_bookingTruckRepository = bookingTruckRepository;
|
|
|
|
|
_bookingTruckContaRepository = bookingTruckContaRepository;
|
|
|
|
|
_bookingOrderRepository = bookingOrderRepository;
|
|
|
|
|
_bookingCtnRepository = bookingCtnRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -49,15 +56,266 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">派车信息</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingTruck/Save")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> Save(BookingTruckDto info)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BookingTruck entity = info.Adapt<BookingTruck>();
|
|
|
|
|
|
|
|
|
|
if(entity == null)
|
|
|
|
|
throw Oops.Oh($"派车信息不能为空");
|
|
|
|
|
|
|
|
|
|
List<BookingTruckCtn> entityCtnList = info.ContaList.Adapt<List<BookingTruckCtn>>();
|
|
|
|
|
|
|
|
|
|
if (entity.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
_bookingTruckRepository.Insert(entity);
|
|
|
|
|
|
|
|
|
|
if (entityCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
entityCtnList.ForEach(async ctn =>
|
|
|
|
|
{
|
|
|
|
|
ctn.TruckId = entity.Id;
|
|
|
|
|
|
|
|
|
|
await _bookingTruckContaRepository.InsertAsync(ctn);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await _bookingTruckRepository.AsUpdateable(entity).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName,
|
|
|
|
|
it.IsDeleted,
|
|
|
|
|
it.BookingId,
|
|
|
|
|
it.TruckId,
|
|
|
|
|
it.TruckName,
|
|
|
|
|
it.TruckCode,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (entityCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
entityCtnList.ForEach(async ctn =>
|
|
|
|
|
{
|
|
|
|
|
ctn.TruckId = entity.Id;
|
|
|
|
|
|
|
|
|
|
await _bookingTruckContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.TenantId,
|
|
|
|
|
it.CreatedTime,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName,
|
|
|
|
|
it.IsDeleted,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "保存成功";
|
|
|
|
|
result.ext = entity.Id;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"保存派车异常,原因:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取派车详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">派车主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/GetInfo")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetInfo(long id)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var truckOrder = _bookingTruckRepository.AsQueryable().First(a => a.Id == id);
|
|
|
|
|
|
|
|
|
|
if (truckOrder == null)
|
|
|
|
|
throw Oops.Oh($"派车主键{id}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
var truckCtnList = _bookingTruckContaRepository.AsQueryable().Where(a => a.TruckId == id).ToList();
|
|
|
|
|
|
|
|
|
|
BookingTruckShowDto model = truckOrder.Adapt<BookingTruckShowDto>();
|
|
|
|
|
|
|
|
|
|
if (truckCtnList.Count > 0)
|
|
|
|
|
model.ContaList = truckCtnList.Adapt<List<BookingTruckCtnDto>>();
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.ext = model;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"获取派车详情异常,原因:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱生成派车初始信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId">订舱主键</param>
|
|
|
|
|
/// <returns>返回派车初始信息</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/InitFromBookingOrder")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> InitFromBookingOrder(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var model = InnerCreateTruckFromBookingOrder(bookingId);
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.ext = model;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"订舱生成派车初始信息异常,原因:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BookingTruckDto InnerCreateTruckFromBookingOrder(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
BookingTruckDto model = null;
|
|
|
|
|
|
|
|
|
|
//取订舱主信息
|
|
|
|
|
var orderInfo = _bookingOrderRepository.AsQueryable()
|
|
|
|
|
.First(a => a.Id == bookingId);
|
|
|
|
|
|
|
|
|
|
if (orderInfo == null)
|
|
|
|
|
throw Oops.Oh($"订舱主键{bookingId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
model = new BookingTruckDto();
|
|
|
|
|
|
|
|
|
|
model.YARDID = orderInfo.YARDID;
|
|
|
|
|
model.YARD = orderInfo.YARD;
|
|
|
|
|
model.ClosingTime = orderInfo.CLOSINGDATE;
|
|
|
|
|
model.InYardID = orderInfo.YARDID;
|
|
|
|
|
model.InYard = orderInfo.YARD;
|
|
|
|
|
|
|
|
|
|
model.FromName = UserManager.Name;
|
|
|
|
|
model.FromTel = UserManager.TEl;
|
|
|
|
|
model.FromMail = UserManager.Email;
|
|
|
|
|
|
|
|
|
|
if (orderInfo.KGS.HasValue)
|
|
|
|
|
{
|
|
|
|
|
//计算总吨数
|
|
|
|
|
model.KGS = Math.Round(orderInfo.KGS.Value / 1000m, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//取订舱箱列表
|
|
|
|
|
var ctnList = _bookingCtnRepository.AsQueryable()
|
|
|
|
|
.Where(a => a.BILLID == bookingId).ToList();
|
|
|
|
|
|
|
|
|
|
if (ctnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
model.ContaList = new List<BookingTruckCtnDto>();
|
|
|
|
|
|
|
|
|
|
ctnList.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
if (b.CTNNUM == 1)
|
|
|
|
|
{
|
|
|
|
|
model.ContaList.Add(new BookingTruckCtnDto
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = b.CTNCODE,
|
|
|
|
|
CTNALL = b.CTNALL,
|
|
|
|
|
KGS = b.KGS,
|
|
|
|
|
PKGS = b.PKGS,
|
|
|
|
|
CBM = b.CBM,
|
|
|
|
|
TAREWEIGHT = b.TAREWEIGHT,
|
|
|
|
|
CNTRNO = b.CNTRNO,
|
|
|
|
|
KINDPKGS = b.KINDPKGS,
|
|
|
|
|
SEALNO = b.SEALNO,
|
|
|
|
|
TEU = b.TEU,
|
|
|
|
|
CTNNUM = b.CTNNUM,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < b.CTNNUM; i++)
|
|
|
|
|
{
|
|
|
|
|
model.ContaList.Add(new BookingTruckCtnDto
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = b.CTNCODE,
|
|
|
|
|
CTNALL = b.CTNALL,
|
|
|
|
|
KGS = b.KGS,
|
|
|
|
|
PKGS = b.PKGS,
|
|
|
|
|
CBM = b.CBM,
|
|
|
|
|
TAREWEIGHT = b.TAREWEIGHT,
|
|
|
|
|
CNTRNO = b.CNTRNO,
|
|
|
|
|
KINDPKGS = b.KINDPKGS,
|
|
|
|
|
SEALNO = b.SEALNO,
|
|
|
|
|
TEU = b.TEU,
|
|
|
|
|
CTNNUM = b.CTNNUM,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 引入订舱详情生成派车信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId">订舱主键</param>
|
|
|
|
|
/// <returns>返回派车初始信息</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/PullInBookingOrder")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> PullInBookingOrder(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var model = InnerCreateTruckFromBookingOrder(bookingId);
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.ext = model;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"引入订舱详情生成派车信息异常,原因:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 引入订舱集装箱详情生成派车信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingId">订舱主键</param>
|
|
|
|
|
/// <returns>返回派车集装箱初始信息</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/PullInBookingOrderConta")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> PullInBookingOrderConta(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -70,6 +328,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">派车信息</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingTruck/Submit")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> Submit(BookingTruckDto info)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
@ -91,7 +350,8 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">派车主键组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SubmitBatch(long[] ids)
|
|
|
|
|
[HttpPost("/BookingTruck/SubmitBatch")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SubmitBatch([FromBody] long[] ids)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -112,6 +372,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">派车主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/Cancel")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> Cancel(long id)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
@ -133,7 +394,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">派车主键组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelBatch(long[] ids)
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelBatch([FromBody] long[] ids)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -154,6 +415,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">派车主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/Print")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> Print(long id)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
@ -175,7 +437,8 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">派车主键组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SendDispatchBatch(long[] ids)
|
|
|
|
|
[HttpPost("/BookingTruck/SendDispatchBatch")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SendDispatchBatch([FromBody] long[] ids)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -196,6 +459,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">派车主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/CancelDispatch")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelDispatch(long id)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
@ -217,7 +481,8 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">派车主键组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelDispatchBatch(long[] ids)
|
|
|
|
|
[HttpPost("/BookingTruck/CancelDispatchBatch")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelDispatchBatch([FromBody] long[] ids)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -233,20 +498,8 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetInfo(long id)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|