|
|
|
@ -728,9 +728,12 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
if (model.GenerateMethod != "UPD_BOOKING")
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"当前BC任务已生成订舱订单,不能重复生成");
|
|
|
|
|
if (bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"当前BC任务已生成订舱订单,不能重复生成");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.GenerateMethod == "GEN_BOOKING_SLOT")
|
|
|
|
@ -1077,8 +1080,71 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else if (model.GenerateMethod != "UPD_BOOKING")
|
|
|
|
|
{
|
|
|
|
|
//推送订舱订单
|
|
|
|
|
var bookingOrderId = await UpdateBookingOrder(bcOrder, bcCtnList, fileList, model);
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcOrder.TASK_ID);
|
|
|
|
|
|
|
|
|
|
if (taskEntity == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未获取有效任务记录,更新失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 更新任务
|
|
|
|
|
//如果是公共任务,需要变成个人任务 RealUserId = 当前操作人
|
|
|
|
|
if (taskEntity.IS_PUBLIC == 1)
|
|
|
|
|
{
|
|
|
|
|
taskEntity.IS_PUBLIC = 0;
|
|
|
|
|
taskEntity.RealUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.RealUserName = UserManager.Name;
|
|
|
|
|
taskEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
taskEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBaseRepository.AsUpdateable(taskEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.IS_PUBLIC,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName,
|
|
|
|
|
it.RealUserId,
|
|
|
|
|
it.RealUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskEntity.UpdatedTime = DateTime.Now;
|
|
|
|
|
taskEntity.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
taskEntity.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBaseRepository.AsUpdateable(taskEntity).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var currBCOrder = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcOrder.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (currBCOrder != null && model.IsDirectSend)
|
|
|
|
|
{
|
|
|
|
|
//异步推送邮件
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
|
|
|
|
|
|
|
|
|
|
if (!mailRlt.succ)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"邮件推送失败,原因:{mailRlt.msg},可以任务编辑页面重新发送邮件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "成功";
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -1217,7 +1283,6 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 生成订舱
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成订舱
|
|
|
|
@ -3088,6 +3153,286 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取BC关联的订舱详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取BC关联的订舱详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPkId">BC任务主键</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/TaskManageBC/ReCompareResult")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> GetBookingOrder(string taskPkId)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
var baseTask = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
|
|
|
|
|
|
|
|
|
|
if (baseTask == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未提取有效的任务信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bcTaskInfo = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPkId);
|
|
|
|
|
|
|
|
|
|
if (bcTaskInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未提取有效的BC任务信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bcTaskInfo.BOOKING_ORDER_ID.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
|
|
|
|
|
var slotModel = server.SearchBookingSlotWithOrderByNo(bcTaskInfo.MBL_NO, bcTaskInfo.TenantId.Value).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
if (slotModel != null && slotModel.BookingSlotId > 0)
|
|
|
|
|
{
|
|
|
|
|
if (slotModel.HasBookingOrder)
|
|
|
|
|
{
|
|
|
|
|
bcTaskInfo.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
|
|
|
|
|
bcTaskInfo.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcTaskInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcTaskInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcTaskInfo).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bcTaskInfo.BOOKING_ORDER_ID.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var bkRlt = await _bookingOrderService.Get(bcTaskInfo.BOOKING_ORDER_ID.Value);
|
|
|
|
|
|
|
|
|
|
if (bkRlt != null)
|
|
|
|
|
{
|
|
|
|
|
var BookingSubmitResultModel = new BookingOrSlotGenerateDto
|
|
|
|
|
{
|
|
|
|
|
CustomerId = bkRlt.CUSTOMERID,
|
|
|
|
|
CustomerName = bkRlt.CUSTOMERNAME,
|
|
|
|
|
CustServiceId = !string.IsNullOrWhiteSpace(bkRlt.CUSTSERVICEID)? long.Parse(bkRlt.CUSTSERVICEID):null,
|
|
|
|
|
CustServiceName = bkRlt.CUSTSERVICE,
|
|
|
|
|
SaleId = !string.IsNullOrWhiteSpace(bkRlt.SALEID) ? long.Parse(bkRlt.SALEID) : null,
|
|
|
|
|
SaleName = bkRlt.SALE,
|
|
|
|
|
OpId = !string.IsNullOrWhiteSpace(bkRlt.OPID) ? long.Parse(bkRlt.OPID) : null,
|
|
|
|
|
OpName = bkRlt.OP,
|
|
|
|
|
DocId = !string.IsNullOrWhiteSpace(bkRlt.DOCID) ? long.Parse(bkRlt.DOCID) : null,
|
|
|
|
|
DocName = bkRlt.DOC,
|
|
|
|
|
RouteID = !string.IsNullOrWhiteSpace(bkRlt.ROUTEID) ? long.Parse(bkRlt.ROUTEID) : null,
|
|
|
|
|
Route = bkRlt.ROUTE,
|
|
|
|
|
LineManageID = !string.IsNullOrWhiteSpace(bkRlt.LineManageID) ? long.Parse(bkRlt.LineManageID) : null,
|
|
|
|
|
LineManage = bkRlt.LineManage
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
result.ext = BookingSubmitResultModel;
|
|
|
|
|
result.succ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#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> UpdateBookingOrder(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
|
|
|
|
|
{
|
|
|
|
|
Id = taskBCInfo.BOOKING_ORDER_ID.Value,
|
|
|
|
|
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,
|
|
|
|
|
CUSTSERVICEID = generateModel.CustServiceId.HasValue ? generateModel.CustServiceId.Value.ToString() : null,
|
|
|
|
|
CUSTSERVICE = generateModel.CustServiceName,
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
var hisList = _bookingOrderContactRepository.AsQueryable().Where(a => a.BookingId == id && a.IsDeleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
if (hisList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//批量作废
|
|
|
|
|
hisList.ForEach(async a =>
|
|
|
|
|
{
|
|
|
|
|
a.IsDeleted = true;
|
|
|
|
|
a.UpdatedTime = DateTime.Now;
|
|
|
|
|
a.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
a.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _bookingOrderContactRepository.UpdateAsync(a);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人
|
|
|
|
|
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var bookingContactList = _bookingOrderContactRepository.AsQueryable()
|
|
|
|
|
.Where(a => a.BookingId == id && !a.IsDeleted).ToList();
|
|
|
|
|
|
|
|
|
|
var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value })
|
|
|
|
|
.GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
generateModel.CustomerContactList.ForEach(contact =>
|
|
|
|
|
{
|
|
|
|
|
DjyCustomerContactOutput djyCustomerContactMan = null;
|
|
|
|
|
|
|
|
|
|
if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a =>
|
|
|
|
|
a.Id == contact.CustomerContactId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (djyCustomerContactMan != null)
|
|
|
|
|
{
|
|
|
|
|
var bookingContact = bookingContactList
|
|
|
|
|
.FirstOrDefault(x => x.Email.Equals(djyCustomerContactMan.Email, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (bookingContact == null)
|
|
|
|
|
{
|
|
|
|
|
bookingContact = new BookingOrderContact
|
|
|
|
|
{
|
|
|
|
|
Name = djyCustomerContactMan.Name,
|
|
|
|
|
BookingId = id,
|
|
|
|
|
Email = djyCustomerContactMan.Email,
|
|
|
|
|
Remark = djyCustomerContactMan.Remark,
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_bookingOrderContactRepository.Insert(bookingContact);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bookingContact.Name = djyCustomerContactMan.Name;
|
|
|
|
|
bookingContact.Email = djyCustomerContactMan.Email;
|
|
|
|
|
bookingContact.Remark = djyCustomerContactMan.Remark;
|
|
|
|
|
bookingContact.UpdatedTime = DateTime.Now;
|
|
|
|
|
bookingContact.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bookingContact.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
_bookingOrderContactRepository.AsUpdateable(bookingContact).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.Name,
|
|
|
|
|
it.Email,
|
|
|
|
|
it.Remark,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成订舱成功 id={id}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成订舱异常,原因:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|