修改BC引入

optimize
jianghaiqing 2 years ago
parent 72dc4d553b
commit 5b1a25c35e

@ -1275,6 +1275,7 @@ namespace Myshipping.Application
Voyage = currBC.Voyage?.Trim().ToUpper(), Voyage = currBC.Voyage?.Trim().ToUpper(),
ClosingDate = currBC.CutSingleTime, ClosingDate = currBC.CutSingleTime,
CYCutOffTime = currBC.CYCutOffTime, CYCutOffTime = currBC.CYCutOffTime,
VGMCutOffTime = currBC.VGMCutOffTime,
ETD = currBC.ETD ETD = currBC.ETD
}; };
@ -1289,6 +1290,40 @@ namespace Myshipping.Application
VOYNO = bookingOrder.VOYNO, VOYNO = bookingOrder.VOYNO,
}; };
/*
*/
//读取文件配置
var opt = App.GetOptions<TempFileOptions>().Path;
string filePath = $"{Path.Combine(App.WebHostEnvironment.WebRootPath, opt)}\\bcfilestemp\\{bookingOrder.Id}\\";
string fileFullName = $"{filePath}\\{file.FileName}";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
filePath = filePath.Replace("\\", "/");
fileFullName = fileFullName.Replace("\\", "/");
}
_logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath, RuntimeInformation.OSDescription);
//预先创建目录
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
using (var fileStream = File.Create(fileFullName))
{
await file.CopyToAsync(fileStream);
}
_logger.LogInformation("批次={no} 完成文件保存 filepath={path}", batchNo, fileFullName);
singleBCDto.FileTempPath = fileFullName;
result.succ = true; result.succ = true;
result.ext = singleBCDto; result.ext = singleBCDto;
} }
@ -1308,6 +1343,7 @@ namespace Myshipping.Application
return result; return result;
} }
#region 请求BC解析
/// <summary> /// <summary>
/// 请求BC解析 /// 请求BC解析
/// </summary> /// </summary>
@ -1350,6 +1386,7 @@ namespace Myshipping.Application
} }
return model; return model;
} }
#endregion
/// <summary> /// <summary>
/// 单票BC更新订舱 /// 单票BC更新订舱
@ -1375,30 +1412,92 @@ namespace Myshipping.Application
if(bookingOrder == null) if(bookingOrder == null)
throw Oops.Bah($"订舱信息获取失败,订舱信息不存在或已作废"); throw Oops.Bah($"订舱信息获取失败,订舱信息不存在或已作废");
//截单日期
if (model.ClosingDate.HasValue) if (model.ClosingDate.HasValue)
bookingOrder.CLOSINGDATE = model.ClosingDate; {
_logger.LogInformation("批次={no} id={id} 更新截单日期 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.CLOSEDOCDATE, model.ClosingDate);
bookingOrder.CLOSEDOCDATE = model.ClosingDate;
}
//截VGM时间
if (model.VGMCutOffTime.HasValue) if (model.VGMCutOffTime.HasValue)
{
_logger.LogInformation("批次={no} id={id} 更新截VGM日期 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.CLOSEVGMDATE, model.VGMCutOffTime);
bookingOrder.CLOSEVGMDATE = model.VGMCutOffTime; bookingOrder.CLOSEVGMDATE = model.VGMCutOffTime;
}
//截港日期
if (model.CYCutOffTime.HasValue) if (model.CYCutOffTime.HasValue)
bookingOrder.CLOSEDOCDATE = model.CYCutOffTime; {
_logger.LogInformation("批次={no} id={id} 更新截港日期 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.CLOSINGDATE, model.CYCutOffTime);
bookingOrder.CLOSINGDATE = model.CYCutOffTime;
}
//开船日期
if (model.ETD.HasValue) if (model.ETD.HasValue)
{
_logger.LogInformation("批次={no} id={id} 更新截港日期 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.CLOSINGDATE, model.CYCutOffTime);
bookingOrder.ETD = model.ETD; bookingOrder.ETD = model.ETD;
}
//船名
if(!string.IsNullOrWhiteSpace(model.Vessel)) if(!string.IsNullOrWhiteSpace(model.Vessel))
{
_logger.LogInformation("批次={no} id={id} 更新船名 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.VESSEL, model.Vessel);
bookingOrder.VESSEL = model.Vessel; bookingOrder.VESSEL = model.Vessel;
}
//航次
if (!string.IsNullOrWhiteSpace(model.Voyage)) if (!string.IsNullOrWhiteSpace(model.Voyage))
bookingOrder.VOYNO = model.Voyage; {
_logger.LogInformation("批次={no} id={id} 更新航次 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.VOYNO, model.Voyage);
if (!string.IsNullOrWhiteSpace(model.Voyage))
bookingOrder.VOYNO = model.Voyage; bookingOrder.VOYNO = model.Voyage;
}
//提单号
if (!string.IsNullOrWhiteSpace(model.BLNo))
{
_logger.LogInformation("批次={no} id={id} 更新提单号 原:{date1} 变更为 {date2}", batchNo, bookingOrder.Id,
bookingOrder.MBLNO, model.BLNo);
bookingOrder.MBLNO = model.BLNo;
}
bookingOrder.UpdatedTime = DateTime.Now;
bookingOrder.UpdatedUserId = UserManager.UserId;
bookingOrder.UpdatedUserName = UserManager.Name;
await _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new
{
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName,
it.CLOSEDOCDATE,
it.CLOSEVGMDATE,
it.CLOSINGDATE,
it.ETD,
it.VESSEL,
it.VOYNO,
it.MBLNO
}).ExecuteCommandAsync();
_logger.LogInformation("批次={no} id={id} BC引入更新订舱完成", batchNo, bookingOrder.Id);
if (model.IsLetterYard) if (model.IsLetterYard)
{ {
_logger.LogInformation("批次={no} 单票BC更新订舱后用户选择了转为入货通知开始发送入货通知", batchNo); _logger.LogInformation("批次={no} id={id} 单票BC更新订舱后用户选择转为入货通知开始执行入货通知", batchNo
, bookingOrder.Id);
var letterYardDto = new UpdateBookingLetteryardInput(); var letterYardDto = new UpdateBookingLetteryardInput();
@ -1407,17 +1506,44 @@ namespace Myshipping.Application
if(model.LetterYardId.HasValue) if(model.LetterYardId.HasValue)
{ {
letterYardDto.Id = model.LetterYardId.Value; letterYardDto.Id = model.LetterYardId.Value;
_logger.LogInformation("批次={no} id={id} 单票BC更新订舱后存在放舱记录 LetterYardId={LetterYardId}", batchNo
, bookingOrder.Id, letterYardDto.Id);
} }
//放舱保存 //放舱保存
var letterYardId = await _bookingOrderService.LetteryardSave(letterYardDto); var letterYardId = await _bookingOrderService.LetteryardSave(letterYardDto);
// _logger.LogInformation("批次={no} id={id} 已完放舱记录保存 返回结果{rlt}", batchNo
, bookingOrder.Id, letterYardId);
_logger.LogInformation("批次={no} id={id} templateid={tempid} 开始发送放舱", batchNo
, bookingOrder.Id, model.TemplateId);
//发送放舱
await _bookingOrderService.SendLetterYard(model.BookingOrderId, model.TemplateId);
_logger.LogInformation("批次={no} id={id} templateid={tempid} 完成发送放舱", batchNo
, bookingOrder.Id, model.TemplateId);
string fileTypeCode = "bc";
string fileTypeName = "Booking Confirmation";
//将BC引入的文件写入订舱的附件
await SaveEDIFile(bookingOrder.Id, model.FileTempPath, new System.IO.FileInfo(model.FileTempPath).Name,
fileTypeCode, fileTypeName);
_logger.LogInformation("批次={no} id={id} 完成写入附件表 {filepath}", batchNo
, bookingOrder.Id, model.FileTempPath);
} }
result.succ = true;
result.msg = "执行成功";
} }
catch (Exception ex) catch (Exception ex)
{ {
result.succ = false;
result.msg = ex.Message;
} }
return result; return result;

@ -17,6 +17,11 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public long BookingOrderId { get; set; } public long BookingOrderId { get; set; }
/// <summary>
/// 放舱模板ID
/// </summary>
public long TemplateId { get; set; }
/// <summary> /// <summary>
/// 放舱主键(入货通知保存后的主键) /// 放舱主键(入货通知保存后的主键)
/// </summary> /// </summary>

@ -54,5 +54,13 @@ namespace Myshipping.Application
/// <param name="input">放舱详情</param> /// <param name="input">放舱详情</param>
/// <returns>返回放舱主键</returns> /// <returns>返回放舱主键</returns>
Task<long> LetteryardSave(UpdateBookingLetteryardInput input); Task<long> LetteryardSave(UpdateBookingLetteryardInput input);
/// <summary>
/// 放舱发送
/// </summary>
/// <param name="bookingId">订舱ID</param>
/// <param name="templateId">放舱选择模板</param>
/// <returns></returns>
Task SendLetterYard(long bookingId, long templateId);
} }
} }
Loading…
Cancel
Save