|
|
|
@ -50,8 +50,13 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
|
|
|
|
|
private readonly IBookingOrderService _bookingOrderService;
|
|
|
|
|
private readonly IBookingSlotService _bookingSlotService;
|
|
|
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
|
|
|
|
|
|
const string CONST_BC_FILE_CODE = "bc";
|
|
|
|
|
const string CONST_BC_FILE_NAME = "Booking Confirmation";
|
|
|
|
|
|
|
|
|
|
const string CONST_BC_NOTICE_FILE_CODE = "bc_notice";
|
|
|
|
|
const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice";
|
|
|
|
|
|
|
|
|
|
public TaskManageBCService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
|
|
|
|
@ -661,14 +666,179 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"当前BC任务已生成订舱或舱位,不能重复生成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.GenerateMethod == "GEN_BOOKING_SLOT")
|
|
|
|
|
{
|
|
|
|
|
#region 推送舱位、推送订舱
|
|
|
|
|
//推送舱位
|
|
|
|
|
GenerateBookingSlot(bcOrder, bcCtnList, fileList).GetAwaiter().GetResult();
|
|
|
|
|
var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//推送订舱
|
|
|
|
|
var bookingOrderId = GenerateBookingOrder(bcOrder, bcCtnList, fileList, model).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if (bookingSlotId > 0 || bookingOrderId > 0)
|
|
|
|
|
{
|
|
|
|
|
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcTaskInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (bcEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (bookingOrderId > 0)
|
|
|
|
|
bcEntity.BOOKING_ORDER_ID = bookingOrderId;
|
|
|
|
|
|
|
|
|
|
if (bookingSlotId > 0)
|
|
|
|
|
bcEntity.BOOKING_SLOT_ID = bookingSlotId;
|
|
|
|
|
|
|
|
|
|
bcEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBCInfoRepository.AsUpdateable(bcEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID);
|
|
|
|
|
|
|
|
|
|
if(taskEntity != null && taskEntity.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
taskEntity.IS_PUBLIC = 0;
|
|
|
|
|
taskEntity.CreatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.CreatedUserName = UserManager.Name;
|
|
|
|
|
taskEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
taskEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBaseRepository.AsUpdateable(taskEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else if (model.GenerateMethod == "GEN_BOOKING")
|
|
|
|
|
{
|
|
|
|
|
#region 推送订舱
|
|
|
|
|
//推送订舱
|
|
|
|
|
var bookingOrderId = GenerateBookingOrder(bcOrder, bcCtnList, fileList, model).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if (bookingOrderId > 0)
|
|
|
|
|
{
|
|
|
|
|
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcTaskInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (bcEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (bookingOrderId > 0)
|
|
|
|
|
bcEntity.BOOKING_ORDER_ID = bookingOrderId;
|
|
|
|
|
|
|
|
|
|
bcEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBCInfoRepository.AsUpdateable(bcEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID);
|
|
|
|
|
|
|
|
|
|
if (taskEntity != null && taskEntity.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
taskEntity.IS_PUBLIC = 0;
|
|
|
|
|
taskEntity.CreatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.CreatedUserName = UserManager.Name;
|
|
|
|
|
taskEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
taskEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBaseRepository.AsUpdateable(taskEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else if (model.GenerateMethod == "GEN_BOOKING_SLOT")
|
|
|
|
|
{
|
|
|
|
|
#region 推送舱位
|
|
|
|
|
//推送舱位
|
|
|
|
|
var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if (bookingSlotId > 0)
|
|
|
|
|
{
|
|
|
|
|
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcTaskInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (bcEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (bookingSlotId > 0)
|
|
|
|
|
bcEntity.BOOKING_SLOT_ID = bookingSlotId;
|
|
|
|
|
|
|
|
|
|
bcEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBCInfoRepository.AsUpdateable(bcEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.BOOKING_SLOT_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID);
|
|
|
|
|
|
|
|
|
|
if (taskEntity != null && taskEntity.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
taskEntity.IS_PUBLIC = 0;
|
|
|
|
|
taskEntity.CreatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.CreatedUserName = UserManager.Name;
|
|
|
|
|
taskEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
taskEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_taskBaseRepository.AsUpdateable(taskEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.CreatedUserId,
|
|
|
|
|
it.CreatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
@ -710,6 +880,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
CARRIERID = taskBCInfo.CARRIERID,
|
|
|
|
|
CARRIER = carrierInfo.CnName?.Trim(),
|
|
|
|
|
SLOT_BOOKING_NO = taskBCInfo.MBL_NO,
|
|
|
|
|
BOOKING_PARTY = taskBCInfo.BOOKING_PARTY,
|
|
|
|
|
BOOKING_SLOT_TYPE = taskBCInfo.BOOKING_SLOT_TYPE,
|
|
|
|
|
BOOKING_SLOT_TYPE_NAME = taskBCInfo.BOOKING_SLOT_TYPE_NAME,
|
|
|
|
@ -768,15 +939,44 @@ namespace Myshipping.Application
|
|
|
|
|
//成功后写入附件
|
|
|
|
|
if (id > 0)
|
|
|
|
|
{
|
|
|
|
|
taskFileList.ForEach(async file =>
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
//System.IO.FileStream file = new System.IO.FileStream(file, FileMode.Open, FileAccess.Read);
|
|
|
|
|
//附件暂存
|
|
|
|
|
//var fileFullName = await FileAttachHelper.SaveFile(id, file, batchNo, "bc");
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taskFileList.ForEach(file =>
|
|
|
|
|
{
|
|
|
|
|
if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString())
|
|
|
|
|
{
|
|
|
|
|
var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
if (File.Exists(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//如果确认文件读取成功
|
|
|
|
|
var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo, false, "bcfiles", true).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
|
|
|
|
|
CONST_BC_FILE_CODE, CONST_BC_FILE_NAME).GetAwaiter();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC_NOTICE.ToString())
|
|
|
|
|
{
|
|
|
|
|
var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
if (File.Exists(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//如果确认文件读取成功
|
|
|
|
|
var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo,false,"bcnoticefile",true).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
|
|
|
|
|
CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME).GetAwaiter();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -871,29 +1071,62 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
id = bkRlt.Id;
|
|
|
|
|
|
|
|
|
|
//附件暂存
|
|
|
|
|
//var fileFullName = await FileAttachHelper.SaveFile(id, file, batchNo, CONST_DRAFT_FILE_CODE);
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
//如果确认文件读取成功
|
|
|
|
|
//var bookFilePath = await FileAttachHelper.MoveFile(bookingOrder.Id.ToString(), fileFullName, batchNo);
|
|
|
|
|
if (id > 0)
|
|
|
|
|
{
|
|
|
|
|
if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ModifyServiceProjectDto projectDto = new ModifyServiceProjectDto
|
|
|
|
|
{
|
|
|
|
|
BookingId = id,
|
|
|
|
|
ProjectCodes = generateModel.ProjectList.Distinct().ToArray(),
|
|
|
|
|
};
|
|
|
|
|
//写入服务项目
|
|
|
|
|
var prjRlt = await _bookingValueAddedService.SaveServiceProject(projectDto);
|
|
|
|
|
|
|
|
|
|
//写入附件
|
|
|
|
|
//await SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(fileFullName).Name, entity.TenantId.Value,
|
|
|
|
|
// CONST_DRAFT_FILE_CODE, CONST_DRAFT_FILE_NAME);
|
|
|
|
|
_logger.LogInformation($"推送订舱的服务项目完成 id={id} rlt={JSON.Serialize(prjRlt)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ModifyServiceProjectDto projectDto = new ModifyServiceProjectDto
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taskFileList.ForEach(file =>
|
|
|
|
|
{
|
|
|
|
|
BookingId = id,
|
|
|
|
|
ProjectCodes = generateModel.ProjectList.Distinct().ToArray(),
|
|
|
|
|
};
|
|
|
|
|
//写入服务项目
|
|
|
|
|
var prjRlt = await _bookingValueAddedService.SaveServiceProject(projectDto);
|
|
|
|
|
if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString())
|
|
|
|
|
{
|
|
|
|
|
var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
if (File.Exists(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//如果确认文件读取成功
|
|
|
|
|
var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
|
|
|
|
|
CONST_BC_FILE_CODE, CONST_BC_FILE_NAME).GetAwaiter();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC_NOTICE.ToString())
|
|
|
|
|
{
|
|
|
|
|
var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"推送订舱的服务项目完成 id={id} rlt={JSON.Serialize(prjRlt)}");
|
|
|
|
|
if (File.Exists(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
//如果确认文件读取成功
|
|
|
|
|
var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo, false, "bcnoticefile").GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//将格式单附件写入订舱的附件
|
|
|
|
|
SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
|
|
|
|
|
CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME).GetAwaiter();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成订舱成功 id={id}");
|
|
|
|
|
|
|
|
|
|