修改派车

optimize
jianghaiqing 2 years ago
parent e471f5ce52
commit 52ebd5cd8f

@ -115,7 +115,7 @@ namespace Myshipping.Application.Entity
/// 工厂ID /// 工厂ID
/// </summary> /// </summary>
[Description("工厂ID")] [Description("工厂ID")]
public string FactoryId { get; set; } public Nullable<long> FactoryId { get; set; }
/// <summary> /// <summary>
/// 工厂代码 /// 工厂代码
/// </summary> /// </summary>
@ -200,7 +200,7 @@ namespace Myshipping.Application.Entity
/// 调度ID /// 调度ID
/// </summary> /// </summary>
[Description("调度ID")] [Description("调度ID")]
public string DispatcherId { get; set; } public Nullable<long> DispatcherId { get; set; }
/// <summary> /// <summary>
/// 调度名称 /// 调度名称
/// </summary> /// </summary>

@ -32,16 +32,23 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingTruck> _bookingTruckRepository; private readonly SqlSugarRepository<BookingTruck> _bookingTruckRepository;
private readonly SqlSugarRepository<BookingTruckCtn> _bookingTruckContaRepository; private readonly SqlSugarRepository<BookingTruckCtn> _bookingTruckContaRepository;
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
private readonly SqlSugarRepository<BookingCtn> _bookingCtnRepository;
public BookingTruckService(ISysCacheService cache, ILogger<BookingTruckService> logger, public BookingTruckService(ISysCacheService cache, ILogger<BookingTruckService> logger,
SqlSugarRepository<BookingTruck> bookingTruckRepository, SqlSugarRepository<BookingTruck> bookingTruckRepository,
SqlSugarRepository<BookingTruckCtn> bookingTruckContaRepository) SqlSugarRepository<BookingTruckCtn> bookingTruckContaRepository,
SqlSugarRepository<BookingOrder> bookingOrderRepository,
SqlSugarRepository<BookingCtn> bookingCtnRepository)
{ {
_cache = cache; _cache = cache;
_logger = logger; _logger = logger;
_bookingTruckRepository = bookingTruckRepository; _bookingTruckRepository = bookingTruckRepository;
_bookingTruckContaRepository = bookingTruckContaRepository; _bookingTruckContaRepository = bookingTruckContaRepository;
_bookingOrderRepository = bookingOrderRepository;
_bookingCtnRepository = bookingCtnRepository;
} }
/// <summary> /// <summary>
@ -49,15 +56,266 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="info">派车信息</param> /// <param name="info">派车信息</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpPost("/BookingTruck/Save")]
public async Task<TaskManageOrderResultDto> Save(BookingTruckDto info) public async Task<TaskManageOrderResultDto> Save(BookingTruckDto info)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try 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) catch (Exception ex)
{
result.succ = false;
result.msg = $"获取派车详情异常,原因:{ex.Message}";
}
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> /// </summary>
/// <param name="info">派车信息</param> /// <param name="info">派车信息</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpPost("/BookingTruck/Submit")]
public async Task<TaskManageOrderResultDto> Submit(BookingTruckDto info) public async Task<TaskManageOrderResultDto> Submit(BookingTruckDto info)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -91,7 +350,8 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="ids">派车主键组</param> /// <param name="ids">派车主键组</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> SubmitBatch(long[] ids) [HttpPost("/BookingTruck/SubmitBatch")]
public async Task<TaskManageOrderResultDto> SubmitBatch([FromBody] long[] ids)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -112,6 +372,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="id">派车主键</param> /// <param name="id">派车主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpGet("/BookingTruck/Cancel")]
public async Task<TaskManageOrderResultDto> Cancel(long id) public async Task<TaskManageOrderResultDto> Cancel(long id)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -133,7 +394,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="ids">派车主键组</param> /// <param name="ids">派车主键组</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> CancelBatch(long[] ids) public async Task<TaskManageOrderResultDto> CancelBatch([FromBody] long[] ids)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -154,6 +415,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="id">派车主键</param> /// <param name="id">派车主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpGet("/BookingTruck/Print")]
public async Task<TaskManageOrderResultDto> Print(long id) public async Task<TaskManageOrderResultDto> Print(long id)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -175,7 +437,8 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="ids">派车主键组</param> /// <param name="ids">派车主键组</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> SendDispatchBatch(long[] ids) [HttpPost("/BookingTruck/SendDispatchBatch")]
public async Task<TaskManageOrderResultDto> SendDispatchBatch([FromBody] long[] ids)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -196,6 +459,7 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="id">派车主键</param> /// <param name="id">派车主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpGet("/BookingTruck/CancelDispatch")]
public async Task<TaskManageOrderResultDto> CancelDispatch(long id) public async Task<TaskManageOrderResultDto> CancelDispatch(long id)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -217,7 +481,8 @@ namespace Myshipping.Application
/// </summary> /// </summary>
/// <param name="ids">派车主键组</param> /// <param name="ids">派车主键组</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> CancelDispatchBatch(long[] ids) [HttpPost("/BookingTruck/CancelDispatchBatch")]
public async Task<TaskManageOrderResultDto> CancelDispatchBatch([FromBody] long[] ids)
{ {
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -233,20 +498,8 @@ namespace Myshipping.Application
return result; return result;
} }
public async Task<TaskManageOrderResultDto> GetInfo(long id)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
}
catch (Exception ex)
{
}
return result;
}
} }
} }

@ -99,7 +99,7 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 工厂ID /// 工厂ID
/// </summary> /// </summary>
public string FactoryId { get; set; } public Nullable<long> FactoryId { get; set; }
/// <summary> /// <summary>
/// 工厂代码 /// 工厂代码
/// </summary> /// </summary>
@ -167,7 +167,7 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 调度ID /// 调度ID
/// </summary> /// </summary>
public string DispatcherId { get; set; } public Nullable<long> DispatcherId { get; set; }
/// <summary> /// <summary>
/// 调度名称 /// 调度名称
/// </summary> /// </summary>

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingTruck.Dtos namespace Myshipping.Application
{ {
/// <summary> /// <summary>
/// ///
@ -94,7 +94,7 @@ namespace Myshipping.Application.Service.BookingTruck.Dtos
/// <summary> /// <summary>
/// 工厂ID /// 工厂ID
/// </summary> /// </summary>
public string FactoryId { get; set; } public Nullable<long> FactoryId { get; set; }
/// <summary> /// <summary>
/// 工厂代码 /// 工厂代码
/// </summary> /// </summary>
@ -162,7 +162,7 @@ namespace Myshipping.Application.Service.BookingTruck.Dtos
/// <summary> /// <summary>
/// 调度ID /// 调度ID
/// </summary> /// </summary>
public string DispatcherId { get; set; } public Nullable<long> DispatcherId { get; set; }
/// <summary> /// <summary>
/// 调度名称 /// 调度名称
/// </summary> /// </summary>

@ -18,6 +18,28 @@ namespace Myshipping.Application
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> Save(BookingTruckDto info); Task<TaskManageOrderResultDto> Save(BookingTruckDto info);
/// <summary>
/// 订舱生成派车初始信息
/// </summary>
/// <param name="bookingId">订舱主键</param>
/// <returns>返回派车初始信息</returns>
Task<TaskManageOrderResultDto> InitFromBookingOrder(long bookingId);
/// <summary>
/// 引入订舱详情生成派车信息
/// </summary>
/// <param name="bookingId">订舱主键</param>
/// <returns>返回派车初始信息</returns>
Task<TaskManageOrderResultDto> PullInBookingOrder(long bookingId);
/// <summary>
/// 引入订舱集装箱详情生成派车信息
/// </summary>
/// <param name="bookingId">订舱主键</param>
/// <returns>返回派车集装箱初始信息</returns>
Task<TaskManageOrderResultDto> PullInBookingOrderConta(long bookingId);
/// <summary> /// <summary>
/// 获取派车详情 /// 获取派车详情
/// </summary> /// </summary>

Loading…
Cancel
Save