修改马士基API订舱

master
jianghaiqing 8 months ago
parent ed908f11d7
commit dcb307705b

@ -520,6 +520,8 @@ namespace Myshipping.Application.Service.BookingOrder
result.succ = false;
result.msg = $"MSK API订舱失败{ex.Message}";
throw Oops.Bah($"MSK API订舱失败{ex.Message}");
}
return result;

@ -80,6 +80,7 @@ namespace Myshipping.Application
private readonly IBookingValueAddedService _bookingValueAddedService;
private readonly IDjyCustomerService _djyCustomerService;
private readonly INamedServiceProvider<IBookingMSKAPIService> _namedBookingMSKAPIServiceProvider;
private readonly IDjyTenantParamService _djyTenantParamService;
private readonly INamedServiceProvider<IBookingSlotService> _namedBookingSlotServiceProvider;
@ -89,6 +90,17 @@ namespace Myshipping.Application
const string CONST_BC_NOTICE_FILE_CODE = "bc_notice";
const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice";
//租户BC默认转发KEY
const string CONST_BC_DEFAULT_PARAM = "BC_TASK_AUTO_TRANSMIT";
//租户AMENDMENT默认转发KEY
const string CONST_AMENDMENT_DEFAULT_PARAM = "AMENDMENT_TASK_AUTO_TRANSMIT";
//租户CANCELLATION默认转发KEY
const string CONST_CANCELLATION_DEFAULT_PARAM = "CANCELLATION_TASK_AUTO_TRANSMIT";
//租户AMENDMENT默认钉钉消息KEY
const string CONST_AMENDMENT_DING_DEFAULT_PARAM = "AMENDMENT_TASK_DING_NOTICE";
//租户CANCELLATION默认钉钉消息KEY
const string CONST_CANCELLATION_DING_DEFAULT_PARAM = "CANCELLATION_TASK_DING_NOTICE";
public TaskManageBCService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
SqlSugarRepository<TaskBCCTNInfo> taskBCCTNInfoRepository,
@ -104,6 +116,7 @@ namespace Myshipping.Application
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService,
INamedServiceProvider<IBookingSlotService> namedBookingSlotServiceProvider,
INamedServiceProvider<IBookingMSKAPIService> namedBookingMSKAPIServiceProvider,
IDjyTenantParamService djyTenantParamService,
SqlSugarRepository<BookingSlotBase> bookingSlotBaseRepository,
SqlSugarRepository<BookingSlotCtn> bookingSlotBaseCtnRepository,
SqlSugarRepository<BookingSlotAllocation> bookingSlotAllocationRepository,
@ -135,6 +148,7 @@ namespace Myshipping.Application
_bookingSlotAllocationCtnRepository = bookingSlotAllocationCtnRepository;
_namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider;
_namedBookingSlotServiceProvider = namedBookingSlotServiceProvider;
_djyTenantParamService = djyTenantParamService;
_logger = logger;
}
@ -2308,66 +2322,161 @@ namespace Myshipping.Application
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
/*
1
2
3@
* Amendment
1
2
3
4
5
* Cancellation
1
2
3
4
*/
try
{
var baseTask = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
if (baseTask == null)
throw Oops.Oh($"主任务获取失败,不存在或已作废");
var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId);
if (bcOrder == null)
throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息");
throw Oops.Oh($"BC任务获取失败不存在或已作废");
if(bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0)
if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0)
{
var slotInfo = await _bookingSlotBaseRepository.AsQueryable()
.FirstAsync(t => t.Id == bcOrder.BOOKING_SLOT_ID.Value);
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO).GetAwaiter().GetResult();
if(slotInfo != null)
if (slotModel != null && slotModel.BookingSlotId > 0)
{
//查询对应的订舱信息
var slotAlloc = await _bookingSlotAllocationRepository.AsQueryable()
.FirstAsync(a => a.BOOKING_SLOT_ID == slotInfo.Id && a.IsDeleted == false);
if (slotModel.HasBookingOrder)
{
bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId;
bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
bcOrder.UpdatedTime = DateTime.Now;
bcOrder.UpdatedUserId = UserManager.UserId;
bcOrder.UpdatedUserName = UserManager.Name;
if (slotAlloc != null && slotAlloc.BOOKING_ID > 0)
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
{
it.BOOKING_SLOT_ID,
it.BOOKING_ORDER_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
else
{
//查询订舱记录
var bookingInfo = _bookingOrderRepository.AsQueryable()
.FirstAsync(a => a.Id == slotAlloc.BOOKING_ID && a.IsDeleted == false);
bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId;
bcOrder.UpdatedTime = DateTime.Now;
bcOrder.UpdatedUserId = UserManager.UserId;
bcOrder.UpdatedUserName = UserManager.Name;
//如果订舱记录推送客户邮件
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
{
it.BOOKING_SLOT_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
if (baseTask != null)
{
if (baseTask.IS_PUBLIC == 1)
{
baseTask.IS_PUBLIC = 0;
baseTask.RealUserId = UserManager.UserId;
baseTask.RealUserName = UserManager.Name;
baseTask.UpdatedTime = DateTime.Now;
baseTask.UpdatedUserId = UserManager.UserId;
baseTask.UpdatedUserName = UserManager.Name;
//更新任务台,将当前任务变更为个人任务
await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new
{
it.IS_PUBLIC,
it.RealUserId,
it.RealUserName,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
}
}
else
{
throw Oops.Oh($"无法获取舱位信息");
}
}
/*
OP
*/
DjyTenantParamValueOutput paramConfig = null;
DjyTenantParamValueOutput dingdingConfig = null;
var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_AMENDMENT_DEFAULT_PARAM,
CONST_CANCELLATION_DEFAULT_PARAM,
CONST_AMENDMENT_DING_DEFAULT_PARAM,
CONST_CANCELLATION_DING_DEFAULT_PARAM }).GetAwaiter().GetResult();
//如果有舱位只能推送钉钉消息
//var bcCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == bcOrder.PK_ID).ToList();
if (baseTask.TASK_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString())
{
if (paramList != null && paramList.Count > 0)
{
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
//var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskPKId).ToList();
dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
}
}
else if (baseTask.TASK_TYPE == TaskBaseTypeEnum.CANCELLATION.ToString())
{
if (paramList != null && paramList.Count > 0)
{
paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
//推送舱位
//var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList,"update").GetAwaiter().GetResult();
dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase));
}
}
_logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}");
//如果值是ENABLE表示可以自动发送
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
var emailRlt = await SendEmail(taskPKId);
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
}
else
{
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
}
if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
var emailRlt = await SendEmail(taskPKId);
//检索是否有差异
//var compareResult = _bookingSlotCompareRepository.AsQueryable().Filter(null, true)
// .Where(x => x.SLOT_ID == bookingSlotId && x.IsDeleted == false && x.TenantId ==
// bcOrder.TenantId).OrderByDescending(a=>a.CreatedTime).First();
_logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
//if(compareResult != null && compareResult.COMPARE_DIFF_NUM > 0)
//{
// //准备推送邮件
// await GenerateSendEmail(bcOrder);
//}
}
else
{
throw Oops.Oh($"未检索到对应的舱位信息");
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
}
result.succ = true;
result.msg = "执行成功";
}
catch (Exception ex)
{
@ -2614,6 +2723,7 @@ namespace Myshipping.Application
}
#endregion
#region 重新比对
/// <summary>
/// 重新比对
/// </summary>
@ -2693,6 +2803,27 @@ namespace Myshipping.Application
it.UpdatedUserName
}).ExecuteCommandAsync();
}
if (baseTask.IS_PUBLIC == 1)
{
baseTask.IS_PUBLIC = 0;
baseTask.RealUserId = UserManager.UserId;
baseTask.RealUserName = UserManager.Name;
baseTask.UpdatedTime = DateTime.Now;
baseTask.UpdatedUserId = UserManager.UserId;
baseTask.UpdatedUserName = UserManager.Name;
//更新任务台,将当前任务变更为个人任务
await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new {
it.IS_PUBLIC,
it.RealUserId,
it.RealUserName,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
}
}
}
@ -2739,7 +2870,6 @@ namespace Myshipping.Application
if (modifyBCReadInfo == null)
throw Oops.Oh($"重新读取BC变更文件详情失败");
TaskBCInfoReadDto BCReadInfo = await GetBCReaderInfo(bcFileFullPath, bcFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BCReadWebApiUrl"]);
@ -2785,6 +2915,7 @@ namespace Myshipping.Application
_logger.LogInformation($"触发比对差异结束reqBatchNo={reqBatchNo}");
}
#endregion
#region 读BC详情详情
/// <summary>
@ -2926,7 +3057,6 @@ namespace Myshipping.Application
}
#endregion
}
/// <summary>

@ -0,0 +1,37 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceProjectSyncWin.Entities
{
[Tenant("db_master")]
[SugarTable("task_bc_info")]
public class TaskBCEntity
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
public string PK_ID { get; set; }
public string MBL_NO { get; set; }
public string BUSI_TYPE { get; set; }
public Nullable<DateTime> SI_CUT_DATE { get; set; }
public Nullable<DateTime> ETD { get; set; }
public Nullable<DateTime> ETA { get; set; }
public Nullable<DateTime> VGM_CUTOFF_TIME { get; set; }
public string TASK_ID { get; set; }
}
}

@ -8,6 +8,7 @@ using Furion.RemoteRequest.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ServiceProjectSyncWin;
using ServiceProjectSyncWin.Entities;
using SqlSugar;
using System.Text;
using System.Text.RegularExpressions;
@ -420,10 +421,12 @@ public class SyncHisRecord: ISyncHisRecord,ITransient
public void SyncServiceProjectRecord4()
{
string s = "\n预期运输计划\nFrom To Mode Vessel Voy No. ETD ETA\nTianjin PAC Intl Cntr PELABUHAN TANJUNG MVS MERETE MAERSK 351W 2023-12-25 2024-01-10\nTerminal PELEPAS TERMINAL\nPELABUHAN TANJUNG SYDNEY DPW TERMINAL MVS RIO MADEIRA 402S 2024-01-14 2024-01-27\nPELEPAS TERMINAL\n";
string s1 = Regex.Match(s, "(?<=ETD\\sETA\\\\n)(\\w|\\s)+(?=\\\\n)").Value;
/*
SI
1
2
*/
//_db.Queryable<TaskBCEntity>().Max(a => a.ORG_STATUS_ID);
}

Loading…
Cancel
Save