添加舱位取消配套逻辑

master
zhangxiaofeng 8 months ago
parent fe9ad59461
commit ce833c625a

@ -351,7 +351,6 @@ namespace Myshipping.Application
/// </summary>
[SugarColumn(ColumnName = "CANCELLATION_DATE")]
[Description("Cancellation时间")]
public string CANCELLATION_DATE { get; set; }
public DateTime? CANCELLATION_DATE { get; set; }
}
}

@ -54,6 +54,7 @@ namespace Myshipping.Application.Event
var baseList = await _repBase.AsQueryable().Filter(null, true)
.Where(x => !x.IsDeleted
&& !x.IS_CANCELLATION
&& x.VESSEL == paraObj.VESSEL
&& x.VOYNO == paraObj.VOYNO
&& x.CONTRACT_NO == paraObj.CONTRACT_NO

@ -264,7 +264,7 @@ namespace Myshipping.Application
result.msg = "成功";
result.ext = id;
}
catch(Exception ex)
catch (Exception ex)
{
result.succ = false;
result.msg = $"失败,原因:{ex.Message}";
@ -297,7 +297,7 @@ namespace Myshipping.Application
|| t.EnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)
|| t.CnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if(carrierInfo != null)
if (carrierInfo != null)
{
dto.DataObj.CARRIER = carrierInfo.CnName?.Trim();
}
@ -311,7 +311,7 @@ namespace Myshipping.Application
dto.DataObj.CtnList.ForEach(t =>
{
if(!string.IsNullOrWhiteSpace(t.CTNALL) && string.IsNullOrWhiteSpace(t.CTNCODE))
if (!string.IsNullOrWhiteSpace(t.CTNALL) && string.IsNullOrWhiteSpace(t.CTNCODE))
{
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
@ -399,13 +399,17 @@ namespace Myshipping.Application
.Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID
&& x.SLOT_ID == model.Id).ToList();
if(ctnList != null)
if (ctnList != null)
{
bcSrcDto.CtnList = ctnList.GroupBy(x => x.CTNALL)
.Select(x =>
{
return new TaskBCCTNInfoDto { CtnALL = x.Key, CTNNUM = x.ToList()
.Sum(a => a.CTNNUM) };
return new TaskBCCTNInfoDto
{
CtnALL = x.Key,
CTNNUM = x.ToList()
.Sum(a => a.CTNNUM)
};
}).ToList();
}
@ -473,7 +477,7 @@ namespace Myshipping.Application
}
//一般更新数据指的是Booking Amendment,需要与舱位进行数据比对
await PushCompareBCInfo(bcSrcDto, bcTargetDto,id, dto.BatchNo);
await PushCompareBCInfo(bcSrcDto, bcTargetDto, id, dto.BatchNo);
}
else if (dto.OpType == "del")
{
@ -500,7 +504,40 @@ namespace Myshipping.Application
}
else if (dto.OpType == "cancellation")
{
// 更新标志
var slotNO = dto.DataObj.SLOT_BOOKING_NO;
model = await _repBase.AsQueryable().Filter(null, true).FirstAsync(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID && x.SLOT_BOOKING_NO == slotNO);
if (model == null)
{
throw Oops.Bah($"未找到订舱编号为 {slotNO} 的数据");
}
id = model.Id;
model.IS_CANCELLATION = true;
model.CANCELLATION_DATE = DateTime.Now;
await _repBase.UpdateAsync(model);
// 删除该舱位相关的订舱关联关系
var slotList = await _repAllocation.AsQueryable().Where(a => a.BOOKING_SLOT_ID == id).ToListAsync();
var slotIdList = slotList.Select(s => s.Id);
await _repAllocation.Context.Updateable<BookingSlotAllocation>()
.SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.Id))
.ExecuteCommandAsync();
await _repAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>()
.SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID))
.ExecuteCommandAsync();
await InsLog("Cancellation", model.Id, "取消舱位");
}
//更新库存
@ -703,6 +740,7 @@ namespace Myshipping.Application
// 1. 【舱位基础表】与【箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【总的箱量】作为queryable1
var queryable1 = _repBase.Context.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SLOT_ID)
.Where(bas => bas.IS_CANCELLATION == false)
.WhereIF(!string.IsNullOrEmpty(slotInput.PORTLOAD), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD))
.WhereIF(!string.IsNullOrEmpty(slotInput.PORTDISCHARGE), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD))
.WhereIF(!string.IsNullOrEmpty(slotInput.VESSEL), bas => bas.VESSEL.Contains(slotInput.VESSEL))
@ -1004,7 +1042,7 @@ namespace Myshipping.Application
/// <param name="slotId">舱位主键</param>
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns>
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId,string reqBatchNo)
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
{
string batchNo = IDGen.NextID().ToString();
@ -1027,7 +1065,7 @@ namespace Myshipping.Application
{
SLOT_ID = slotId,
COMPARE_BATCHNO = reqBatchNo,
COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff? compareResult.extra.ShowDetailList.Count : 0,
COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0,
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId,
@ -1117,8 +1155,8 @@ namespace Myshipping.Application
[HttpGet("/BookingSlot/GetSlotCompareResult")]
public async Task<List<CompareResultDetailInfo>> GetSlotCompareResult([FromQuery] long id, [FromQuery] string batchNo)
{
var compareInfo = await _bookingSlotCompareRepository.AsQueryable()
.FirstAsync(t => t.SLOT_ID == id && t.COMPARE_BATCHNO == batchNo);
var compareInfo = await _bookingSlotCompareRepository.AsQueryable()
.FirstAsync(t => t.SLOT_ID == id && t.COMPARE_BATCHNO == batchNo);
if (compareInfo == null)
{
@ -1154,7 +1192,7 @@ namespace Myshipping.Application
result.succ = true;
result.msg = "导入成功";
}
catch(Exception ex)
catch (Exception ex)
{
_logger.LogError($"导入舱位异常,原因:{ex.Message}");
@ -1186,7 +1224,7 @@ namespace Myshipping.Application
throw Oops.Oh($"舱位信息不存在或已作废");
// 判断是否已存在引用关系
if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
&& a.BOOKING_ID > 0 && a.IsDeleted == false))
{
throw Oops.Oh($"舱位已有对应的订舱订单,不能重复执行");
@ -1217,7 +1255,7 @@ namespace Myshipping.Application
/// <param name="bookingSlotFileList">舱位附件列表</param>
/// <param name="generateModel">订舱请求详情</param>
/// <returns>返回订舱ID</returns>
private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase, List<BookingSlotCtn> bookingSlotCtnList,
private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase, List<BookingSlotCtn> bookingSlotCtnList,
List<BookingFile> bookingSlotFileList,
BookingGenerateDto generateModel)
{
@ -1441,7 +1479,7 @@ namespace Myshipping.Application
/// 文件名称
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 文件二进制流
/// </summary>

@ -311,7 +311,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
[Description("舱单截止时间")]
public DateTime? MANIFEST_CUT_DATE { get; set; }
/// <summary>
/// 是否Cancellation
/// </summary>
[Description("是否Cancellation")]
public bool IS_CANCELLATION { get; set; }
/// <summary>
/// Cancellation时间
/// </summary>
[Description("Cancellation时间")]
public DateTime? CANCELLATION_DATE { get; set; }
}
/// <summary>

Loading…
Cancel
Save