新增邮件解析船舶相关截止时间的通知

master
jianghaiqing 6 months ago
parent 5b1842335f
commit 75b7a7b73c

@ -0,0 +1,45 @@
using Myshipping.Application.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 航线船舶截止时间调整的通知处理明细
/// </summary>
[SugarTable("task_route_change_advisory_detail")]
[Description("航线船舶截止时间调整的通知处理明细")]
public class TaskRouteChangeAdvisoryDetailInfo : TaskManageDbEntity
{
/// <summary>
/// 父主键
/// </summary>
public string P_ID { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
public Nullable<long> BOOKING_ID { get; set; }
/// <summary>
/// 是否已转发客户 1-是 0-否
/// </summary>
public bool IS_TRANSFER_USER { get; set; }
/// <summary>
/// 最后转发客户邮件时间
/// </summary>
public Nullable<DateTime> LST_TRANSFER_USER_DATE { get; set; }
/// <summary>
/// 最后转发客户邮件结果
/// </summary>
public string LST_TRANSFER_NOTES { get; set; }
}
}

@ -0,0 +1,104 @@
using Myshipping.Application.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 航线船舶截止时间调整的通知
/// </summary>
[SugarTable("task_route_change_advisory")]
[Description("航线船舶截止时间调整的通知")]
public class TaskRouteChangeAdvisoryInfo : TaskManageDbEntity
{
/// <summary>
/// 任务主键
/// </summary>
public string TASK_ID { get; set; }
/// <summary>
/// 船名
/// </summary>
public string VESSEL { get; set; }
/// <summary>
/// 航次
/// </summary>
public string VOYNO { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string CARRIER { get; set; }
/// <summary>
/// 装货港提取
/// </summary>
public string READ_PORTLOAD { get; set; }
/// <summary>
/// 原ETD
/// </summary>
public Nullable<DateTime> ORIG_ETD { get; set; }
/// <summary>
/// MDGF提交截止时间
/// </summary>
public Nullable<DateTime> MDGF_CUT_DATE { get; set; }
/// <summary>
/// ETA(预计到港时间)
/// </summary>
public Nullable<DateTime> ETA { get; set; }
/// <summary>
/// ETD(预计离港时间)
/// </summary>
public Nullable<DateTime> ETD { get; set; }
/// <summary>
/// 样单截止日期
/// </summary>
public Nullable<DateTime> SI_CUT_DATE { get; set; }
/// <summary>
/// 码头移箱截止时间
/// </summary>
public Nullable<DateTime> TM_SHIFT_CUT_DATE { get; set; }
/// <summary>
/// 截VGM时间
/// </summary>
public Nullable<DateTime> VGM_CUTOFF_TIME { get; set; }
/// <summary>
/// 截港/场站收据截止
/// </summary>
public Nullable<DateTime> CY_CUT_DATE { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string ROUTE_CODE { get; set; }
/// <summary>
/// 邮件对应标题
/// </summary>
public string EMAIL_SUBJECT { get; set; }
/// <summary>
/// 装货港代码
/// </summary>
public string PORTLOADID { get; set; }
/// <summary>
/// 装货港
/// </summary>
public string PORTLOAD { get; set; }
}
}

@ -58,6 +58,11 @@ namespace Myshipping.Application
[Description("SI Submitted")]
SI_SUBMITTED,
/// <summary>
/// Advisory
/// </summary>
[Description("Advisory")]
ADVISORY,
/// <summary>
/// 空
/// </summary>
[Description("NONE")]

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskManageOrderRouteChangeAdvisoryInfo
{
/// <summary>
/// 船公司代码
/// </summary>
public string CarrierId { get; set; }
/// <summary>
/// 计费周
/// </summary>
public int Week { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyno { get; set; }
/// <summary>
/// 预计离港时间
/// </summary>
public DateTime origETD { get; set; }
/// <summary>
/// 完整 MDGF 截止时间/冻柜/开顶柜/框架箱/超限货物最晚提箱时间:
/// </summary>
public Nullable<DateTime> MDGFCutDate { get; set; }
/// <summary>
/// 预计到港
/// </summary>
public Nullable<DateTime> ETA { get; set; }
/// <summary>
/// 预计离港:
/// </summary>
public Nullable<DateTime> ETD { get; set; }
/// <summary>
/// 提单样本截止时间
/// </summary>
public Nullable<DateTime> SICutDate { get; set; }
/// <summary>
/// 码头移箱截止
/// </summary>
public Nullable<DateTime> TerminalShiftCutDate { get; set; }
/// <summary>
/// VGM截止时间
/// </summary>
public Nullable<DateTime> VGMCutDate { get; set; }
/// <summary>
/// 截港/场站收据截止
/// </summary>
public Nullable<DateTime> CYCutDate { get; set; }
/// <summary>
/// 启运港名称
/// </summary>
public string LoadPortName { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string RouteCode { get; set; }
/// <summary>
/// 邮件对应标题
/// </summary>
public string MailSubject { get; set; }
}
}

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskRouteChangeAdvisoryShowDto
{
/// <summary>
/// 主键
/// </summary>
public string PKId { get; set; }
/// <summary>
/// 任务ID
/// </summary>
public string TaskPKId { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public string CarrierId { get; set; }
/// <summary>
/// 计费周
/// </summary>
public int Week { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyno { get; set; }
/// <summary>
/// 预计离港时间
/// </summary>
public DateTime origETD { get; set; }
/// <summary>
/// 完整 MDGF 截止时间/冻柜/开顶柜/框架箱/超限货物最晚提箱时间:
/// </summary>
public Nullable<DateTime> MDGFCutDate { get; set; }
/// <summary>
/// 预计到港
/// </summary>
public Nullable<DateTime> ETA { get; set; }
/// <summary>
/// 预计离港:
/// </summary>
public Nullable<DateTime> ETD { get; set; }
/// <summary>
/// 提单样本截止时间
/// </summary>
public Nullable<DateTime> SICutDate { get; set; }
/// <summary>
/// 码头移箱截止
/// </summary>
public Nullable<DateTime> TerminalShiftCutDate { get; set; }
/// <summary>
/// VGM截止时间
/// </summary>
public Nullable<DateTime> VGMCutDate { get; set; }
/// <summary>
/// 截港/场站收据截止
/// </summary>
public Nullable<DateTime> CYCutDate { get; set; }
/// <summary>
/// 启运港名称
/// </summary>
public string LoadPortName { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string RouteCode { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateTime { get; set; }
}
}

@ -1166,6 +1166,22 @@ namespace Myshipping.Application
.Map(dest => dest.NOTIFY_EMAIL, src => src.Email)
.Map(dest => dest.NOTIFY_MOBILE, src => src.Mobile);
config.ForType<TaskManageOrderRouteChangeAdvisoryInfo, TaskRouteChangeAdvisoryInfo>()
.Map(dest => dest.VESSEL, src => src.Vessel)
.Map(dest => dest.VOYNO, src => src.Voyno)
.Map(dest => dest.CARRIER, src => src.CarrierId)
.Map(dest => dest.ORIG_ETD, src => src.origETD)
.Map(dest => dest.READ_PORTLOAD, src => src.LoadPortName)
.Map(dest => dest.MDGF_CUT_DATE, src => src.MDGFCutDate)
.Map(dest => dest.ETA, src => src.ETA)
.Map(dest => dest.ETD, src => src.ETD)
.Map(dest => dest.SI_CUT_DATE, src => src.SICutDate)
.Map(dest => dest.TM_SHIFT_CUT_DATE, src => src.TerminalShiftCutDate)
.Map(dest => dest.VGM_CUTOFF_TIME, src => src.VGMCutDate)
.Map(dest => dest.CY_CUT_DATE, src => src.CYCutDate)
.Map(dest => dest.ROUTE_CODE, src => src.RouteCode)
.Map(dest => dest.EMAIL_SUBJECT, src => src.MailSubject);
}
}
}

@ -239,5 +239,10 @@ namespace Myshipping.Application
/// 重要通知
/// </summary>
public TaskManageOrderCautionNoticeInfo CautionNoticeInfo { get; set; }
/// <summary>
/// 船舶相关截止时间的通知
/// </summary>
public TaskManageOrderRouteChangeAdvisoryInfo RouteChangeAdvisoryInfo { get; set; }
}
}

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 船舶相关截止时间的通知
/// </summary>
public interface IRouteChangeAdvisoryService
{
/// <summary>
/// 获取船舶相关截止时间的通知详情
/// </summary>
/// <param name="taskPkId">船舶相关截止时间的通知任务主键</param>
/// <returns>返回详情</returns>
Task<TaskRouteChangeAdvisoryShowDto> GetInfoByTaskId(string taskPkId);
/// <summary>
/// 自动转发船舶相关截止时间的通知
/// </summary>
/// <param name="taskPKId">船舶相关截止时间的通知任务主键</param>
/// <param name="tenantId">租户ID</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> AutoTransferNotice(string taskPKId, long tenantId);
/// <summary>
/// 检索同一航次对应的订舱订单(并对应记录)
/// </summary>
/// <param name="taskPKId">船舶相关截止时间的通知任务主键</param>
/// <param name="tenantId">租户ID</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> QueryVesselVoynoBookingOrder(string taskPKId, long tenantId);
}
}

@ -303,5 +303,13 @@ namespace Myshipping.Application
/// <param name="jsonData">截单回执任务详情JSON</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CreateSISubmittedTaskJob(IFormFile file, IFormFile modifyFile, string jsonData);
/// <summary>
/// 创建Advisory任务
/// </summary>
/// <param name="file">文件</param>
/// <param name="jsonData">Advisory任务详情JSON</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CreateAdvisoryTaskJob(IFormFile file, IFormFile modifyFile, string jsonData);
}
}

@ -0,0 +1,123 @@
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Myshipping.Application.Entity;
using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using Myshipping.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Furion.FriendlyException;
namespace Myshipping.Application
{
/// <summary>
/// 船舶相关截止时间的通知
/// </summary>
[ApiDescriptionSettings("Application", Name = "RouteChangeAdvisory", Order = 10)]
public class RouteChangeAdvisoryService : IRouteChangeAdvisoryService, IDynamicApiController, ITransient
{
private readonly ISysCacheService _cache;
private readonly ILogger<TaskCautionNoticeService> _logger;
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
private readonly SqlSugarRepository<TaskRouteChangeAdvisoryInfo> _taskRouteChangeAdvisoryInfoRepository;
private readonly SqlSugarRepository<TaskRouteChangeAdvisoryDetailInfo> _taskRouteChangeAdvisoryDetailInfoRepository;
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
public RouteChangeAdvisoryService(ISysCacheService cache, ILogger<TaskCautionNoticeService> logger,
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
SqlSugarRepository<TaskRouteChangeAdvisoryInfo> taskRouteChangeAdvisoryInfoRepository,
SqlSugarRepository<TaskRouteChangeAdvisoryDetailInfo> taskRouteChangeAdvisoryDetailInfoRepository,
SqlSugarRepository<DjyUserMailAccount> djyUserMailAccount)
{
_cache = cache;
_logger = logger;
_taskBaseRepository = taskBaseRepository;
_taskRouteChangeAdvisoryInfoRepository = taskRouteChangeAdvisoryInfoRepository;
_taskRouteChangeAdvisoryDetailInfoRepository = _taskRouteChangeAdvisoryDetailInfoRepository;
_djyUserMailAccount = djyUserMailAccount;
}
/// <summary>
/// 获取船舶相关截止时间的通知详情
/// </summary>
/// <param name="taskPkId">船舶相关截止时间的通知任务主键</param>
/// <returns>返回详情</returns>
public async Task<TaskRouteChangeAdvisoryShowDto> GetInfoByTaskId(string taskPkId)
{
TaskRouteChangeAdvisoryShowDto dto = new TaskRouteChangeAdvisoryShowDto();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var advisoryInfo = _taskRouteChangeAdvisoryInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (advisoryInfo == null)
throw Oops.Oh($"船舶相关截止时间的通知主键{taskPkId}无法获取业务信息");
dto = new TaskRouteChangeAdvisoryShowDto
{
PKId = advisoryInfo.PK_ID,
TaskPKId = advisoryInfo.TASK_ID,
CarrierId = advisoryInfo.CARRIER,
CreateTime = advisoryInfo.CreatedTime,
};
return dto;
}
/// <summary>
/// 自动转发船舶相关截止时间的通知
/// </summary>
/// <param name="taskPKId">船舶相关截止时间的通知任务主键</param>
/// <param name="tenantId">租户ID</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> AutoTransferNotice(string taskPKId, long tenantId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
}
catch(Exception ex)
{
}
return result;
}
/// <summary>
/// 检索同一航次对应的订舱订单(并对应记录)
/// </summary>
/// <param name="taskPKId">船舶相关截止时间的通知任务主键</param>
/// <param name="tenantId">租户ID</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> QueryVesselVoynoBookingOrder(string taskPKId, long tenantId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
}
catch (Exception ex)
{
}
return result;
}
}
}

@ -171,6 +171,12 @@ namespace Myshipping.Application
a.STATUS = emailRlt.succ ? "SUCC" : "FAILURE";
a.STATUS_NAME = emailRlt.succ ? "成功" : "失败";
_taskCautionNoticeDetailInfoRepository.AsUpdateable(a).UpdateColumns(p => new
{
p.STATUS,
p.STATUS_NAME
}).ExecuteCommand();
}
}
else if (a.NOTIFY_METHOD == CautionNoticeMethodEnum.DingDing.ToString())
@ -183,6 +189,12 @@ namespace Myshipping.Application
a.STATUS = "SUCC";
a.STATUS_NAME = "成功";
_taskCautionNoticeDetailInfoRepository.AsUpdateable(a).UpdateColumns(p => new
{
p.STATUS,
p.STATUS_NAME
}).ExecuteCommand();
}
});
}

@ -119,6 +119,10 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<TaskCautionNoticeInfo> _taskCautionNoticeInfoRepository;
private readonly SqlSugarRepository<TaskCautionNoticeDetailInfo> _taskCautionNoticeDetailInfoRepository;
private readonly SqlSugarRepository<TaskRouteChangeAdvisoryInfo> _taskRouteChangeAdvisoryInfoRepository;
private readonly SqlSugarRepository<TaskRouteChangeAdvisoryDetailInfo> _taskRouteChangeAdvisoryDetailInfoRepository;
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
private readonly ISysCacheService _cache;
private readonly ILogger<BookingOrderService> _logger;
@ -182,6 +186,8 @@ namespace Myshipping.Application
SqlSugarRepository<TaskPODDischargeGateoutFullDetailInfo> taskPODDischargeGateoutFullDetailInfoRepository,
SqlSugarRepository<TaskCautionNoticeInfo> taskCautionNoticeInfoRepository,
SqlSugarRepository<TaskCautionNoticeDetailInfo> taskCautionNoticeDetailInfoRepository,
SqlSugarRepository<TaskRouteChangeAdvisoryInfo> taskRouteChangeAdvisoryInfoRepository,
SqlSugarRepository<TaskRouteChangeAdvisoryDetailInfo> taskRouteChangeAdvisoryDetailInfoRepository,
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
IDjyWebsiteAccountConfigService webAccountConfig,
ISysCacheService cache,
@ -250,6 +256,9 @@ namespace Myshipping.Application
_taskCautionNoticeInfoRepository = taskCautionNoticeInfoRepository;
_taskCautionNoticeDetailInfoRepository = taskCautionNoticeDetailInfoRepository;
_taskRouteChangeAdvisoryInfoRepository = taskRouteChangeAdvisoryInfoRepository;
_taskRouteChangeAdvisoryDetailInfoRepository = taskRouteChangeAdvisoryDetailInfoRepository;
}
#region 创建任务
@ -476,6 +485,12 @@ namespace Myshipping.Application
fileCategory = TaskFileCategoryEnum.SI_SUBMITTED.ToString();
}
else if (TaskBaseTypeEnum.ROUTE_CUT_CHANGE.ToString() == taskInfo.TASK_BASE_TYPE)
{
attachFileType = "advisoryfiles";
fileCategory = TaskFileCategoryEnum.ADVISORY.ToString();
}
var noExtensionFileName = Path.GetFileNameWithoutExtension(file.FileName);
var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, noExtensionFileName,
@ -1495,7 +1510,36 @@ namespace Myshipping.Application
#region 航线船舶截止时间调整的通知
if (info.Main.TaskType == TaskBaseTypeEnum.ROUTE_CUT_CHANGE)
{
TaskRouteChangeAdvisoryInfo taskRouteChangeAdvisoryInfo = info.Main.RouteChangeAdvisoryInfo.Adapt<TaskRouteChangeAdvisoryInfo>();
taskRouteChangeAdvisoryInfo.PK_ID = IDGen.NextID().ToString();
taskRouteChangeAdvisoryInfo.TASK_ID = taskInfo.PK_ID;
taskRouteChangeAdvisoryInfo.CreatedTime = taskInfo.CreatedTime;
taskRouteChangeAdvisoryInfo.UpdatedTime = taskInfo.CreatedTime;
taskRouteChangeAdvisoryInfo.CreatedUserId = taskInfo.CreatedUserId;
taskRouteChangeAdvisoryInfo.CreatedUserName = taskInfo.CreatedUserName;
taskRouteChangeAdvisoryInfo.TenantId = taskInfo.TenantId;
taskRouteChangeAdvisoryInfo.TenantName = taskInfo.TenantName;
if (!string.IsNullOrWhiteSpace(taskRouteChangeAdvisoryInfo.READ_PORTLOAD))
{
var portList = _cache.GetAllCodePortLoad().GetAwaiter().GetResult();
if (portList != null && portList.Count > 0)
{
var portInfo = portList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.EnName) && a.EnName.Equals(taskRouteChangeAdvisoryInfo.READ_PORTLOAD,StringComparison.OrdinalIgnoreCase));
if (portInfo != null)
{
taskRouteChangeAdvisoryInfo.PORTLOADID = portInfo?.EdiCode;
taskRouteChangeAdvisoryInfo.PORTLOAD = portInfo?.EnName;
}
}
}
await _taskRouteChangeAdvisoryInfoRepository.InsertAsync(taskRouteChangeAdvisoryInfo);
}
#endregion
@ -5951,6 +5995,42 @@ namespace Myshipping.Application
}
#endregion
#region 创建Advisory任务
/// <summary>
/// 创建Advisory任务
/// </summary>
/// <param name="file">文件</param>
/// <param name="jsonData">BC任务详情JSON</param>
/// <returns>返回回执</returns>
[HttpPost("/TaskManage/CreateAdvisoryTaskJob"), AllowAnonymous, ApiUser(ApiCode = "BCTaskManage")]
public async Task<TaskManageOrderResultDto> CreateAdvisoryTaskJob(IFormFile file, IFormFile modifyFile, string jsonData)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
_logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, jsonData);
try
{
TaskManageOrderMessageInfo info = JSON.Deserialize<TaskManageOrderMessageInfo>(jsonData);
if (info == null)
throw Oops.Bah("jsonData请求内容错误无法反序列化报文");
result = await InitTaskJob(info, batchNo, file, null);
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"请求任务异常,{ex.Message}";
}
return result;
}
#endregion
#region 获取文件类型
/// <summary>
/// 获取文件类型

Loading…
Cancel
Save