修改新增拆票生成单号方法

master
jianghaiqing 5 months ago
parent 84e035522c
commit ce37db338b

@ -1078,5 +1078,10 @@ namespace Myshipping.Application.Entity
/// 分单操作
/// </summary>
public string SubOp { get; set; }
/// <summary>
/// 拆票或合票标记 1-拆票 2-合票
/// </summary>
public int SPLIT_OR_MERGE_FLAG { get; set; }
}
}

@ -13017,6 +13017,85 @@ namespace Myshipping.Application
}
#endregion
#region 获取舱位拆票或者合票后新单号结果
/// <summary>
/// 获取舱位拆票或者合票后新单号结果
/// </summary>
/// <param name="model">舱位拆票或者合票请求</param>
/// <returns>返回舱位拆票或者合票结果</returns>
[HttpPost("/BookingOrder/GetBookingSlotMergeOrSplitResult")]
public async Task<BookingSlotMergeOrSplitResultDto> GetBookingSlotMergeOrSplitResult(BookingSlotMergeOrSplitRequestDto model)
{
BookingSlotMergeOrSplitResultDto rlt = null;
/*
1
1
2+A-Z
2
1
2
*/
if (string.IsNullOrWhiteSpace(model.OperType))
throw Oops.Oh($"操作类型不能为空");
if (model.OperType.Equals("split", StringComparison.OrdinalIgnoreCase))
{
var checkResult = await bookingSlotService.CheckImportSlots(model.Slots, 0);
// 如果该票订舱没有引入过舱位,判断余量是否充足
if (!checkResult.isEnough)
{
throw Oops.Bah(checkResult.message);
}
var reqSlot = model.Slots.FirstOrDefault();
var slotInfo = await bookingSlotService.GetInfo(reqSlot.Id);
//获取所有订舱编号是舱位提单号,并且是已经拆单的订舱记录
var orderList = _rep.AsQueryable().Where(a => a.CUSTNO == slotInfo.SLOT_BOOKING_NO && a.SPLIT_OR_MERGE_FLAG == 1 && a.IsDeleted == false).ToList();
rlt = new BookingSlotMergeOrSplitResultDto();
if (orderList.Count == 0)
{
rlt.NewMBlNo = $"{slotInfo.SLOT_BOOKING_NO}A";
rlt.BookingReferNo = slotInfo.SLOT_BOOKING_NO;
rlt.NewSubBlNo = slotInfo.SLOT_BOOKING_NO;
}
else
{
var maxChar = orderList.Select(a =>
{
var startIndx = a.CUSTNO.Length;
return a.MBLNO.Substring(startIndx);
}).Max();
if (maxChar.Length != 1 || !Regex.IsMatch(maxChar, "[A-Z]{1}"))
throw Oops.Oh($"获取的历史拆票后缀异常maxChar={maxChar}");
rlt.NewMBlNo = $"{slotInfo.SLOT_BOOKING_NO}{LetterIndexUtil.GetNextLetter(maxChar[0])}";
rlt.BookingReferNo = slotInfo.SLOT_BOOKING_NO;
rlt.NewSubBlNo = slotInfo.SLOT_BOOKING_NO;
}
}
else if(model.OperType.Equals("merge", StringComparison.OrdinalIgnoreCase))
{
}
else
{
throw Oops.Oh($"操作类型不能识别");
}
return rlt;
}
#endregion
}

@ -0,0 +1,62 @@
using Myshipping.Application.Service.BookingSlot.Dto;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 舱位拆合票的请求
/// </summary>
public class BookingSlotMergeOrSplitRequestDto
{
/// <summary>
/// 引入的舱位列表
/// </summary>
public List<BookingSlotBaseWithCtnDto> Slots { get; set; }
/// <summary>
/// 操作类型 split-拆票 merge-合票
/// </summary>
public string OperType { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
public Nullable<long> bookingId { get; set; }
/// <summary>
/// 合票最终选择舱位ID OperType=merge
/// </summary>
public Nullable<long> mergeSlotId { get; set; }
/// <summary>
/// 舱位提单号 选择舱位提单号 OperType=merge
/// </summary>
public string slotBookingNo { get; set; }
}
/// <summary>
/// 舱位拆合票的回执
/// </summary>
public class BookingSlotMergeOrSplitResultDto
{
/// <summary>
/// 订舱编号
/// </summary>
public string BookingReferNo { get; set; }
/// <summary>
/// 新提单号
/// </summary>
public string NewMBlNo { get; set; }
/// <summary>
/// 新分单号
/// </summary>
public string NewSubBlNo { get; set; }
}
}

@ -5,6 +5,7 @@ using Myshipping.Application.Entity;
using Myshipping.Application.Service.BookingOrder.Dto;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using Myshipping.Application.Service.BookingSlot.Dto;
namespace Myshipping.Application
{
@ -155,5 +156,12 @@ namespace Myshipping.Application
/// <param name="dto">请求参数</param>
/// <returns></returns>
Task BatchUpdateOrder(BatchUpdate dto);
/// <summary>
/// 获取舱位拆票或者合票后新单号结果
/// </summary>
/// <param name="model">舱位拆票或者合票请求</param>
/// <returns>返回舱位拆票或者合票结果</returns>
Task<BookingSlotMergeOrSplitResultDto> GetBookingSlotMergeOrSplitResult(BookingSlotMergeOrSplitRequestDto model);
}
}

@ -3894,6 +3894,28 @@ namespace Myshipping.Application
return id;
}
#endregion
#region 获取舱位详情
/// <summary>
/// 获取舱位详情
/// </summary>
/// <param name="id">舱位ID</param>
/// <returns>返回舱位详情</returns>
public async Task<BookingSlotBaseSaveOutput> GetInfo(long id)
{
var slotBase = await _repBase.FirstOrDefaultAsync(u => u.Id == id);
if (slotBase == null)
{
throw Oops.Oh("未查询到此舱位信息,可能已被删除,请重新查询后重试");
}
var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync();
var rtn = slotBase.Adapt<BookingSlotBaseSaveOutput>();
rtn.CtnList = ctns.Adapt<List<BookingSlotCtnSaveInput>>();
return rtn;
}
#endregion
}

@ -153,5 +153,12 @@ namespace Myshipping.Application
/// <param name="CarrierId">船公司ID</param>
/// <returns></returns>
Task<long> QueryBookingSlot(string slotBookingNo, string CarrierId);
/// <summary>
/// 获取舱位详情
/// </summary>
/// <param name="id">舱位ID</param>
/// <returns>返回舱位详情</returns>
Task<BookingSlotBaseSaveOutput> GetInfo(long id);
}
}
Loading…
Cancel
Save