|
|
|
@ -1,16 +1,21 @@
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Npoi.Mapper;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using RabbitMQ.Client;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
|
using System;
|
|
|
|
@ -20,6 +25,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -39,8 +45,18 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _bookingCtnRepository;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingFileRepository;
|
|
|
|
|
|
|
|
|
|
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
|
|
|
|
|
private readonly IBookingOrderService _bookingOrderService;
|
|
|
|
|
private readonly IBookingSlotService _bookingSlotService;
|
|
|
|
|
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,
|
|
|
|
@ -49,7 +65,10 @@ namespace Myshipping.Application
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
|
|
|
SqlSugarRepository<BookingCtn> bookingCtnRepository,
|
|
|
|
|
SqlSugarRepository<SysUser> sysUserRepository,
|
|
|
|
|
IServiceWorkFlowBaseService serviceWorkFlowBaseService)
|
|
|
|
|
SqlSugarRepository<BookingFile> bookingFileRepository,
|
|
|
|
|
IServiceWorkFlowBaseService serviceWorkFlowBaseService,
|
|
|
|
|
IBookingOrderService bookingOrderService,
|
|
|
|
|
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService)
|
|
|
|
|
{
|
|
|
|
|
_taskBaseRepository = taskBaseRepository;
|
|
|
|
|
_taskBCInfoRepository = taskBCInfoRepository;
|
|
|
|
@ -59,6 +78,11 @@ namespace Myshipping.Application
|
|
|
|
|
_bookingCtnRepository = bookingCtnRepository;
|
|
|
|
|
_sysUserRepository = sysUserRepository;
|
|
|
|
|
_serviceWorkFlowBaseService = serviceWorkFlowBaseService;
|
|
|
|
|
_bookingOrderService = bookingOrderService;
|
|
|
|
|
_bookingSlotService = bookingSlotService;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_bookingValueAddedService = bookingValueAddedService;
|
|
|
|
|
_bookingFileRepository = bookingFileRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取BC详情
|
|
|
|
@ -598,10 +622,21 @@ namespace Myshipping.Application
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
1、推送舱位生成方法。
|
|
|
|
|
2、推送舱位暂存方法。
|
|
|
|
|
3、推送舱位分配方法。
|
|
|
|
|
4、更新任务状态位完成。
|
|
|
|
|
1、GEN_BOOKING_SLOT-生成舱位和订舱
|
|
|
|
|
(1)生成舱位
|
|
|
|
|
(2)生成海运订舱
|
|
|
|
|
(3)更新舱位库存
|
|
|
|
|
(4)更新BC任务
|
|
|
|
|
2、GEN_BOOKING-只生成订舱
|
|
|
|
|
(1)生成海运订舱
|
|
|
|
|
(4)更新BC任务
|
|
|
|
|
3、GEN_SLOT-只生成舱位
|
|
|
|
|
(1)生成舱位
|
|
|
|
|
(4)更新BC任务
|
|
|
|
|
3、GEN_SLOT-只生成舱位
|
|
|
|
|
(1)查找订舱记录
|
|
|
|
|
(3)更新舱位库存
|
|
|
|
|
(4)更新BC任务
|
|
|
|
|
*/
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.BCTaskId))
|
|
|
|
|
throw Oops.Oh($"BC任务主键不能为空");
|
|
|
|
@ -623,13 +658,188 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
var bcCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == bcOrder.PK_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == bcTaskInfo.PK_ID).ToList();
|
|
|
|
|
|
|
|
|
|
if ((bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value>0)
|
|
|
|
|
|| (bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"当前BC任务已生成订舱或舱位,不能重复生成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.GenerateMethod == "GEN_BOOKING_SLOT")
|
|
|
|
|
{
|
|
|
|
|
#region 推送舱位、推送订舱
|
|
|
|
|
//推送舱位
|
|
|
|
|
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;
|
|
|
|
|
result.msg = "成功";
|
|
|
|
@ -644,6 +854,293 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 生成舱位
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskBCInfo">BC任务详情</param>
|
|
|
|
|
/// <param name="taskBCCtnList">BC任务集装箱列表</param>
|
|
|
|
|
/// <param name="taskFileList">BC任务附件列表</param>
|
|
|
|
|
/// <returns>返回舱位ID</returns>
|
|
|
|
|
private async Task<long> GenerateBookingSlot(TaskBCInfo taskBCInfo, List<TaskBCCTNInfo> taskBCCtnList, List<TaskFileInfo> taskFileList)
|
|
|
|
|
{
|
|
|
|
|
long id = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var carrierInfo = _cache.GetAllCodeCarrier().GetAwaiter().GetResult()
|
|
|
|
|
.Where(t => t.Code.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
|| t.EnName.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
|| t.CnName.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BookingSlotBaseApiDto slotModel = new BookingSlotBaseApiDto
|
|
|
|
|
{
|
|
|
|
|
DataObj = new BookingSlotBaseApiSaveDto
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
VESSEL = taskBCInfo.VESSEL,
|
|
|
|
|
VOYNO = taskBCInfo.VOYNO,
|
|
|
|
|
VGM_SUBMISSION_CUT_DATE = taskBCInfo.VGM_CUTOFF_TIME,
|
|
|
|
|
WEEK_AT = taskBCInfo.WEEK_AT,
|
|
|
|
|
CARRIAGE_TYPE = taskBCInfo.CARRIAGE_TYPE,
|
|
|
|
|
CARRIAGE_TYPE_NAME = taskBCInfo.CARRIAGE_TYPE_NAME,
|
|
|
|
|
CONTRACT_NO = taskBCInfo.CONTRACTNO,
|
|
|
|
|
CTN_STAT = taskBCInfo.CTN_STAT,
|
|
|
|
|
CY_CUT_DATE = taskBCInfo.CY_CUTOFF_TIME,
|
|
|
|
|
DETENSION_FREE_DAYS = taskBCInfo.DETENSION_FREE_DAYS,
|
|
|
|
|
ETD = taskBCInfo.ETD,
|
|
|
|
|
ETA = taskBCInfo.ETA,
|
|
|
|
|
LANECODE = taskBCInfo.LANECODE,
|
|
|
|
|
LANENAME = taskBCInfo.LANENAME,
|
|
|
|
|
MANIFEST_CUT_DATE = taskBCInfo.MANIFEST_CUT_DATE,
|
|
|
|
|
MDGF_CUT_DATE = taskBCInfo.MDGF_CUT_DATE,
|
|
|
|
|
PLACEDELIVERY = taskBCInfo.PLACEDELIVERY,
|
|
|
|
|
PLACERECEIPT = taskBCInfo.PLACERECEIPT,
|
|
|
|
|
PORTDISCHARGE = taskBCInfo.PORTDISCHARGE,
|
|
|
|
|
PORTLOAD = taskBCInfo.PORTLOAD,
|
|
|
|
|
SI_CUT_DATE = taskBCInfo.SI_CUT_DATE,
|
|
|
|
|
TRANSFER_PORT_1 = taskBCInfo.TRANSFER_PORT_1,
|
|
|
|
|
TRANSFER_PORT_2 = taskBCInfo.TRANSFER_PORT_2,
|
|
|
|
|
CtnList = new List<BookingSlotCtnSaveInput>()
|
|
|
|
|
},
|
|
|
|
|
OpType = "add"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
|
|
|
|
|
|
if (taskBCCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
taskBCCtnList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
BookingSlotCtnSaveInput ctn = new BookingSlotCtnSaveInput
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = ctnCode?.Code,
|
|
|
|
|
CTNALL = t.CTNALL,
|
|
|
|
|
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
slotModel.DataObj.CtnList.Add(ctn);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id = await _bookingSlotService.ApiReceive(slotModel);
|
|
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
//成功后写入附件
|
|
|
|
|
if (id > 0)
|
|
|
|
|
{
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成舱位异常,原因:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 生成订舱
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成订舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskBCInfo">BC任务详情</param>
|
|
|
|
|
/// <param name="taskBCCtnList">BC任务集装箱列表</param>
|
|
|
|
|
/// <param name="taskFileList">BC任务附件列表</param>
|
|
|
|
|
/// <param name="generateModel">订舱请求详情</param>
|
|
|
|
|
/// <returns>返回订舱ID</returns>
|
|
|
|
|
private async Task<long> GenerateBookingOrder(TaskBCInfo taskBCInfo, List<TaskBCCTNInfo> taskBCCtnList, List<TaskFileInfo> taskFileList,
|
|
|
|
|
BookingOrSlotGenerateDto generateModel)
|
|
|
|
|
{
|
|
|
|
|
long id = 0;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
1、新增订舱
|
|
|
|
|
2、推送服务项目
|
|
|
|
|
3、推送附件
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var carrierInfo = _cache.GetAllCodeCarrier().GetAwaiter().GetResult()
|
|
|
|
|
.Where(t => t.Code.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
|| t.EnName.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
|| t.CnName.Equals(taskBCInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
SaveBookingOrderInput bkModel = new SaveBookingOrderInput
|
|
|
|
|
{
|
|
|
|
|
CUSTOMERID = generateModel.CustomerId,
|
|
|
|
|
CUSTOMERNAME = generateModel.CustomerName,
|
|
|
|
|
CARRIERID = carrierInfo.Code?.Trim(),
|
|
|
|
|
CARRIER = carrierInfo.CnName?.Trim(),
|
|
|
|
|
MBLNO = taskBCInfo.MBL_NO.ToUpper().Trim(),
|
|
|
|
|
CONTRACTNO = !string.IsNullOrWhiteSpace(taskBCInfo.CONTRACTNO) ? taskBCInfo.CONTRACTNO : "",
|
|
|
|
|
VESSEL = taskBCInfo.VESSEL.ToUpper().Trim(),
|
|
|
|
|
VOYNO = taskBCInfo.VOYNO.ToUpper().Trim(),
|
|
|
|
|
VOYNOINNER = taskBCInfo.VOYNO.ToUpper().Trim(),
|
|
|
|
|
ETD = taskBCInfo.ETD,
|
|
|
|
|
ETA = taskBCInfo.ETA,
|
|
|
|
|
SALEID = generateModel.SaleId.ToString(),
|
|
|
|
|
SALE = generateModel.SaleName,
|
|
|
|
|
OPID = generateModel.OpId.ToString(),
|
|
|
|
|
OP = generateModel.OpName,
|
|
|
|
|
DOCID = generateModel.DocId.ToString(),
|
|
|
|
|
DOC = generateModel.DocName,
|
|
|
|
|
ROUTEID = generateModel.RouteID.ToString(),
|
|
|
|
|
ROUTE = generateModel.Route,
|
|
|
|
|
CZRemark = generateModel.CZRemark,
|
|
|
|
|
ShenQingXiangShi = generateModel.ShenQingXiangShi,
|
|
|
|
|
LineManageID = generateModel.LineManageID.ToString(),
|
|
|
|
|
LineName = generateModel.LineManage,
|
|
|
|
|
CLOSEVGMDATE = taskBCInfo.VGM_CUTOFF_TIME,
|
|
|
|
|
CLOSINGDATE = taskBCInfo.CY_CUTOFF_TIME,
|
|
|
|
|
CLOSEDOCDATE = taskBCInfo.CUT_SINGLE_TIME,
|
|
|
|
|
ctnInputs = new List<BookingCtnDto>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
|
|
|
|
|
|
if (taskBCCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
taskBCCtnList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
BookingCtnDto ctn = new BookingCtnDto
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = ctnCode?.Code,
|
|
|
|
|
CTNALL = t.CTNALL,
|
|
|
|
|
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bkModel.ctnInputs.Add(ctn);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bkRlt = await _bookingOrderService.Save(bkModel);
|
|
|
|
|
|
|
|
|
|
id = bkRlt.Id;
|
|
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"推送订舱的服务项目完成 id={id} rlt={JSON.Serialize(prjRlt)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
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).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").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}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成订舱异常,原因:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 取消任务
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 取消任务
|
|
|
|
@ -706,5 +1203,41 @@ namespace Myshipping.Application
|
|
|
|
|
return await _serviceWorkFlowBaseService.GetEnableProjectList(UserManager.TENANT_ID.ToString());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 异步写入附件表
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异步写入附件表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="boookId">订舱ID</param>
|
|
|
|
|
/// <param name="FilePath">文件路径</param>
|
|
|
|
|
/// <param name="fileName">文件名</param>
|
|
|
|
|
/// <param name="tenantId">租户ID</param>
|
|
|
|
|
/// <param name="fileTypeCode">附件类型代码</param>
|
|
|
|
|
/// <param name="fileTypeName">附件类型名称</param>
|
|
|
|
|
/// <param name="moudle">附件模块代码</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
|
|
|
|
|
string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation",string moudle = "BookingSlot")
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
直接将附件信息写入附件表
|
|
|
|
|
*/
|
|
|
|
|
//EDI文件
|
|
|
|
|
var bookFile = new BookingFile
|
|
|
|
|
{
|
|
|
|
|
Id = YitIdHelper.NextId(),
|
|
|
|
|
FileName = fileName,
|
|
|
|
|
FilePath = FilePath,
|
|
|
|
|
TypeCode = fileTypeCode,
|
|
|
|
|
TypeName = fileTypeName,
|
|
|
|
|
BookingId = boookId,
|
|
|
|
|
TenantId = tenantId,
|
|
|
|
|
Moudle = moudle
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _bookingFileRepository.InsertAsync(bookFile);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|