修改BC变更任务

master
jianghaiqing 7 months ago
parent d178c8e2a3
commit 06050ad093

@ -105,6 +105,9 @@ namespace Myshipping.Application.EDI
{
return new KeyValuePair<bool, string>(false, "冻柜的【冷藏通风量】校验不通过,要求:必填、数字格式、不能含有+或-");
}
//增加货描里的温度、湿度、通风与单个填写项的比对,必需一致才能提交 2024-04-17 JHQ
}
//2023年7月12日下货纸为危险品时需填写等级和编号
@ -1434,5 +1437,14 @@ namespace Myshipping.Application.EDI
return portDischargeEdiCode;
}
/// <summary>
/// 校验货描里的温度、湿度、通风与单个填写项进行比对
/// </summary>
/// <param name="order">订舱详情</param>
public static void CheckGoodsDescriptionWithInput(BookingOrder order)
{
}
}
}

@ -228,7 +228,7 @@ namespace Myshipping.Application
/// 舱位接收保存、取消接口
/// </summary>
/// <returns></returns>
[HttpPost("/BookingSlot/ApiReceive"), AllowAnonymous, ApiUser]
[HttpPost("/BookingSlot/ApiReceive"), AllowAnonymous, ApiUser(ApiCode = "BCTaskManage")]
public async Task<TaskManageOrderResultDto> ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();

@ -22,7 +22,7 @@ namespace Myshipping.Application
public string BCPkId { get; set; }
/// <summary>
/// 生成方式GEN_BOOKING_SLOT-生成舱位和订舱;GEN_BOOKING-只生成订舱GEN_SLOT-只生成舱位GEN_EXIST_BOOKING-匹配指定的订舱
/// 生成方式GEN_BOOKING_SLOT-生成舱位和订舱;GEN_BOOKING-只生成订舱GEN_SLOT-只生成舱位GEN_EXIST_BOOKING-匹配指定的订舱;UPD_BOOKING-更新订舱
/// </summary>
public string GenerateMethod { get; set; }

@ -113,5 +113,13 @@ namespace Myshipping.Application
/// <param name="taskPKId">BC任务主键</param>
/// <returns></returns>
Task ReCompareResult(string taskPKId);
/// <summary>
/// 获取BC关联的订舱详情
/// </summary>
/// <param name="taskPkId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetBookingOrder(string taskPkId);
}
}

@ -72,7 +72,7 @@ namespace Myshipping.Application
/// <param name="file">请求文件</param>
/// <param name="jsonData">邮件Draft比对请求报文</param>
/// <returns>返回回执</returns>
[AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailDraftCompare"), ApiUser(ApiCode = "ExcuteEmailDraftCompare")]
[AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailDraftCompare"), ApiUser(ApiCode = "BCTaskManage")]
public async Task<TaskManageExcuteResultDto> ExcuteEmailDraftCompareAsync(IFormFile file, [FromForm] string jsonData)
{
string batchNo = IDGen.NextID().ToString();
@ -606,7 +606,7 @@ namespace Myshipping.Application
/// <param name="fileAttach">请求附件文件</param>
/// <param name="jsonData">邮件Draft比对请求报文</param>
/// <returns>返回回执</returns>
[AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailAttachedSheetDraftCompare"), ApiUser(ApiCode = "ExcuteEmailDraftCompare")]
[AllowAnonymous, HttpPost("/TaskDraftCompare/ExcuteEmailAttachedSheetDraftCompare"), ApiUser(ApiCode = "BCTaskManage")]
public async Task<TaskManageExcuteResultDto> ExcuteEmailAttachedSheetDraftCompareAsync(IFormFile file, IFormFile fileAttach, string jsonData)
{
string batchNo = IDGen.NextID().ToString();

@ -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>

@ -243,7 +243,7 @@ namespace Myshipping.Application
/// </summary>
/// <param name="info">任务详情</param>
/// <returns>返回回执</returns>
[AllowAnonymous, HttpPost("/TaskManage/CreateTaskJob")]
[HttpPost("/TaskManage/CreateTaskJob"), AllowAnonymous, ApiUser(ApiCode = "BCTaskManage")]
public async Task<TaskManageOrderResultDto> CreateTaskJob(TaskManageOrderMessageInfo info)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();

Loading…
Cancel
Save