|
|
|
@ -60,6 +60,8 @@ using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using LanguageExt;
|
|
|
|
|
using Masuit.Tools.Models;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method
|
|
|
|
|
{
|
|
|
|
@ -1509,12 +1511,55 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
back-返还舱位
|
|
|
|
|
1、(如果有对应舱位)删除舱位与订单的关系
|
|
|
|
|
*/
|
|
|
|
|
var slotNO = dto.DataObj.SlotBookingNo;
|
|
|
|
|
model = await tenantDb.Queryable<BookingSlotBase>().FirstAsync(x => x.SlotBookingNo == slotNO);
|
|
|
|
|
var bookingId = dto.BookingId.Value;
|
|
|
|
|
var allocList = tenantDb.Queryable<BookingSlotAllocation>().Where(x => x.BookingId == bookingId).ToList();
|
|
|
|
|
|
|
|
|
|
if(model != null)
|
|
|
|
|
if (allocList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//删除关系,并标记舱位状态
|
|
|
|
|
foreach (var alloc in allocList)
|
|
|
|
|
{
|
|
|
|
|
alloc.Deleted = true;
|
|
|
|
|
alloc.DeleteBy = long.Parse(user.UserId);
|
|
|
|
|
alloc.DeleteTime = DateTime.Now;
|
|
|
|
|
alloc.DeleteUserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable(alloc).UpdateColumns(x=>new {
|
|
|
|
|
x.Deleted,
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
x.DeleteTime,
|
|
|
|
|
x.DeleteUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var checkList = allocList.Select(a => a.BookingSlotId).Distinct().ToList();
|
|
|
|
|
//查询所有舱位相关联的记录
|
|
|
|
|
var slotLinkList = tenantDb.Queryable<BookingSlotBase>().Where(x => checkList.Contains(x.Id) && x.Deleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
//更新舱位状态
|
|
|
|
|
if (slotLinkList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var slot in slotLinkList)
|
|
|
|
|
{
|
|
|
|
|
slot.Status = BookingSlotStatusEnum.CUSTOMERBACK.ToString();
|
|
|
|
|
slot.StatusName = BookingSlotStatusEnum.CUSTOMERBACK.GetDescription();
|
|
|
|
|
slot.UpdateTime = DateTime.Now;
|
|
|
|
|
slot.UpdateBy = long.Parse(user.UserId);
|
|
|
|
|
slot.UpdateUserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable(slot).UpdateColumns(x => new {
|
|
|
|
|
x.Status,
|
|
|
|
|
x.StatusName,
|
|
|
|
|
x.UpdateTime,
|
|
|
|
|
x.UpdateBy,
|
|
|
|
|
x.UpdateUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"未找到当前订舱关联的舱位信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (dto.OpType == "backcreate")
|
|
|
|
@ -1524,7 +1569,155 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
1、(如果有对应舱位)删除舱位与订单的关系
|
|
|
|
|
2、(如果没有舱位)根据订单数据,反向生成舱位信息(主信息、箱信息、附件)
|
|
|
|
|
*/
|
|
|
|
|
var bookingId = dto.BookingId.Value;
|
|
|
|
|
var allocList = tenantDb.Queryable<BookingSlotAllocation>().Where(x => x.BookingId == bookingId).ToList();
|
|
|
|
|
|
|
|
|
|
if (allocList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//删除关系,并标记舱位状态
|
|
|
|
|
foreach (var alloc in allocList)
|
|
|
|
|
{
|
|
|
|
|
alloc.Deleted = true;
|
|
|
|
|
alloc.DeleteBy = long.Parse(user.UserId);
|
|
|
|
|
alloc.DeleteTime = DateTime.Now;
|
|
|
|
|
alloc.DeleteUserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable(alloc).UpdateColumns(x => new {
|
|
|
|
|
x.Deleted,
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
x.DeleteTime,
|
|
|
|
|
x.DeleteUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var checkList = allocList.Select(a => a.BookingSlotId).Distinct().ToList();
|
|
|
|
|
//查询所有舱位相关联的记录
|
|
|
|
|
var slotLinkList = tenantDb.Queryable<BookingSlotBase>().Where(x => checkList.Contains(x.Id) && x.Deleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
//更新舱位状态
|
|
|
|
|
if (slotLinkList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var slot in slotLinkList)
|
|
|
|
|
{
|
|
|
|
|
slot.Status = BookingSlotStatusEnum.CUSTOMERBACK.ToString();
|
|
|
|
|
slot.StatusName = BookingSlotStatusEnum.CUSTOMERBACK.GetDescription();
|
|
|
|
|
slot.UpdateTime = DateTime.Now;
|
|
|
|
|
slot.UpdateBy = long.Parse(user.UserId);
|
|
|
|
|
slot.UpdateUserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable(slot).UpdateColumns(x => new {
|
|
|
|
|
x.Status,
|
|
|
|
|
x.StatusName,
|
|
|
|
|
x.UpdateTime,
|
|
|
|
|
x.UpdateBy,
|
|
|
|
|
x.UpdateUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//这里根据订舱详情自动生成舱位
|
|
|
|
|
var bookingOrder = await tenantDb.Queryable<SeaExport>().FirstAsync(b => b.Id == dto.BookingId);
|
|
|
|
|
|
|
|
|
|
var bookingCtnList = await tenantDb.Queryable<OpCtn>().Where(b => b.BSNO == dto.BookingId.ToString()).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var c = tenantDb.Queryable<BookingSlotBase>().Where(x => x.SlotBookingNo == dto.DataObj.SlotBookingNo).Count();
|
|
|
|
|
if (c > 0)
|
|
|
|
|
{
|
|
|
|
|
//订舱提单号已存在
|
|
|
|
|
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotSlotBookingNoExists)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 订舱对应舱位
|
|
|
|
|
|
|
|
|
|
model = new BookingSlotBase
|
|
|
|
|
{
|
|
|
|
|
CarrierCode = bookingOrder.Carrier,
|
|
|
|
|
CarrierId = bookingOrder.CarrierId,
|
|
|
|
|
Carrier = bookingOrder.Carrier,
|
|
|
|
|
SlotBookingNo = bookingOrder.MBLNO,
|
|
|
|
|
ContractNo = bookingOrder.ContractNo,
|
|
|
|
|
|
|
|
|
|
Vessel = bookingOrder.Vessel?.ToUpper()?.Trim(),
|
|
|
|
|
Voyno = bookingOrder.InnerVoyno?.ToUpper()?.Trim(),
|
|
|
|
|
ETD = bookingOrder.ETD,
|
|
|
|
|
ETA = bookingOrder.ETA,
|
|
|
|
|
|
|
|
|
|
VGMSubmissionCutDate = bookingOrder.VGMCloseDate,
|
|
|
|
|
CYCutDate = bookingOrder.ClosingDate,
|
|
|
|
|
SICutDate = bookingOrder.CloseDocDate,
|
|
|
|
|
PortLoadId = bookingOrder.LoadPortId,
|
|
|
|
|
PortLoadCode = bookingOrder.LoadPortCode,
|
|
|
|
|
PortLoad = bookingOrder.LoadPort,
|
|
|
|
|
|
|
|
|
|
PortDischargeId = bookingOrder.DischargePortId,
|
|
|
|
|
PortDischargeCode = bookingOrder.DischargePortCode,
|
|
|
|
|
PortDischarge = bookingOrder.DischargePort,
|
|
|
|
|
};
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (bookingCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await tenantDb.Insertable<BookingSlotBase>(model).ExecuteReturnEntityAsync();
|
|
|
|
|
|
|
|
|
|
id = model.Id;
|
|
|
|
|
|
|
|
|
|
foreach (var ctn in dto.DataObj.CtnList)
|
|
|
|
|
{
|
|
|
|
|
var newCtn = ctn.Adapt<BookingSlotCtn>();
|
|
|
|
|
|
|
|
|
|
newCtn.SlotId = model.Id;
|
|
|
|
|
await tenantDb.Insertable<BookingSlotCtn>(newCtn).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//await InsLog("Add", model.Id, "新增舱位");
|
|
|
|
|
|
|
|
|
|
string batchNo = GuidHelper.GetSnowflakeId();
|
|
|
|
|
|
|
|
|
|
//处理附件
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"请求文件名:{file.FileName}");
|
|
|
|
|
|
|
|
|
|
var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), file.FileBytes, batchNo, file.FileName, "bcfiles");
|
|
|
|
|
|
|
|
|
|
var fileFullPath = fileRlt.Data.Item2;
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"保存文件路径:{fileFullPath}");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
await SaveEDIFile(id, fileFullPath, file.FileName, long.Parse(user.TenantId), file.FileBytes.Length,
|
|
|
|
|
CONST_BC_FILE_CODE, CONST_BC_FILE_NAME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (modifyFile != null)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"请求文件名(变更文件):{modifyFile.FileName}");
|
|
|
|
|
|
|
|
|
|
var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), modifyFile.FileBytes, batchNo, modifyFile.FileName, "bcnoticefiles");
|
|
|
|
|
|
|
|
|
|
var fileFullPath = fileRlt.Data.Item2;
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"保存文件路径(变更文件):{fileFullPath}");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
await SaveEDIFile(id, fileFullPath, modifyFile.FileName, long.Parse(user.TenantId), modifyFile.FileBytes.Length,
|
|
|
|
|
CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//触发标签自动绑定
|
|
|
|
|
await GenerateSlotLabel(dto, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|