cjy 4 months ago
commit 7a43ada5f8

@ -26,7 +26,6 @@
<Folder Include="Finance\Dtos\" />
<Folder Include="Finance\Entity\" />
<Folder Include="TaskPlat\Interface\VGM\" />
<Folder Include="TaskPlat\Interface\TransplanHasChange\" />
<Folder Include="TaskPlat\Interface\POLContainerNotPickUp\" />
<Folder Include="TaskPlat\Interface\PODDischargeGateoutFull\" />
<Folder Include="TaskPlat\Interface\RollingNomination\" />

@ -1423,7 +1423,7 @@ namespace DS.WMS.Core.Op.Method
model = await tenantDb.Queryable<BookingSlotBase>().FirstAsync(x => x.SlotBookingNo == slotNO);
if (model == null)
{
//throw Oops.Bah($"未找到订舱编号为 {slotNO} 的数据");
throw new Exception($"未找到订舱编号为 {slotNO} 的数据");
}
id = model.Id;

@ -458,7 +458,42 @@ namespace DS.WMS.Core.TaskPlat.Dtos.Mapper
.Map(dest => dest.CBM, src => src.CBM)
.Map(dest => dest.GoodsDescription, src => src.Description)
.Map(dest => dest.KindPKGs, src => src.KindPkgs);
}
{
TypeAdapterConfig<TaskManageOrderTransportPlanHasChangeInfo, TaskTransPlanHasChange>.NewConfig()
.Map(dest => dest.BOOKING_NO, src => src.BookingNo)
.Map(dest => dest.MBL_NO, src => src.BillNo)
.Map(dest => dest.ORIG_MBL_NO, src => src.OrigBillNo)
.Map(dest => dest.CARRIER, src => src.Carrier)
.Map(dest => dest.CHANGE_REASON, src => src.ChangeReasonNotes)
.Map(dest => dest.PORTLOAD, src => src.PortLoad)
.Map(dest => dest.PORTLOAD_COUNTRY, src => src.PortLoadCountry)
.Map(dest => dest.PORTLOAD_TERMINAL, src => src.PortLoadTerminal)
.Map(dest => dest.PORTDISCHARGE, src => src.PortDischarge)
.Map(dest => dest.PORTDISCHARGE_COUNTRY, src => src.PortDischargeCountry)
.Map(dest => dest.PORTDISCHARGE_TERMINAL, src => src.PortDischargeTerminal)
.Map(dest => dest.VESSEL, src => src.Vessel)
.Map(dest => dest.VOYNO, src => src.Voyno)
.Map(dest => dest.SHIP_FLAG, src => src.ShipFlag)
.Map(dest => dest.ETD, src => src.ETD)
.Map(dest => dest.ETA, src => src.ETA)
.Map(dest => dest.GROUP_BATCH_NO, src => src.GroupBatchNo)
.Map(dest => dest.IS_LAST, src => src.IsLast);
}
{
TypeAdapterConfig<TaskTransPlanHasChange, TaskTransPlanHasChangeShowDto>.NewConfig()
.Map(dest => dest.BookingNo, src => src.BOOKING_NO)
.Map(dest => dest.BillNo, src => src.MBL_NO)
.Map(dest => dest.OrigBillNo, src => src.ORIG_MBL_NO)
.Map(dest => dest.Carrier, src => src.CARRIER)
.Map(dest => dest.ChangeReasonNotes, src => src.CHANGE_REASON)
.Map(dest => dest.TaskPkId, src => src.TASK_ID)
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.BookingId, src => src.BOOKING_ID)
.Map(dest => dest.GroupBatchNo, src => src.GROUP_BATCH_NO)
.Map(dest => dest.IsLast, src => src.IS_LAST);
}
}
}

@ -19,7 +19,7 @@ namespace DS.WMS.Core.TaskPlat.Dtos
/// <summary>
/// 业务主键
/// </summary>
public string PKId { get; set; }
public long Id { get; set; }
/// <summary>

@ -0,0 +1,45 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.TaskPlat.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.TaskPlat.Interface
{
/// <summary>
/// 运输计划变更
/// </summary>
public interface ITaskTransPlanHasChangeService
{
/// <summary>
/// 通过任务主键获取货物运输计划已变更详情
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
Task<DataResult<TaskTransPlanHasChangeShowDto>> GetInfoByTaskId(long taskPKId);
/// <summary>
/// 检索对应的订舱订单并保存订舱ID
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
Task<DataResult<SeaExportOrderExtension>> SearchAndMarkBookingOrder(long taskPKId);
/// <summary>
/// 自动转发
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
Task<DataResult> AutoTranmitToCustomer(long taskPKId);
/// <summary>
/// 发送邮件通知给客户
/// </summary>
/// <param name="taskPKId">货物运输计划已变更主键</param>
/// <returns>返回回执</returns>
Task<DataResult> SendEmailToCustomer(long taskPKId);
}
}

@ -0,0 +1,317 @@
using DS.Module.Core;
using DS.Module.RedisModule;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Code.Method;
using DS.WMS.Core.Map.Interface;
using DS.WMS.Core.Map.Method;
using DS.WMS.Core.Sys.Interface;
using DS.WMS.Core.Sys.Method;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mapster;
using DS.Module.DjyServiceStatus;
using Microsoft.AspNetCore.Identity;
using DS.WMS.Core.Op.Interface;
using Masuit.Tools;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Sys.Entity;
using HtmlAgilityPack;
using Microsoft.AspNetCore.Mvc;
using Amazon.Runtime.Internal.Util;
using Newtonsoft.Json;
using NLog;
using DS.Module.Core.Helpers;
using System.Text.Json.Nodes;
using LanguageExt.Pipes;
using DS.WMS.Core.Op.Entity;
using Org.BouncyCastle.Asn1.X9;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Code.Dtos;
namespace DS.WMS.Core.TaskPlat.Method
{
/// <summary>
///
/// </summary>
public class TaskTransPlanHasChangeService: ITaskTransPlanHasChangeService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
private readonly ISeaExportService _seaExportService;
private readonly IConfigService _configService;
private readonly IUserService _userService;
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
const string EMAIL_API_URL = "email_api_url";
public TaskTransPlanHasChangeService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
_seaExportService = _serviceProvider.GetRequiredService<ISeaExportService>();
_configService = _serviceProvider.GetRequiredService<IConfigService>();
_userService = _serviceProvider.GetRequiredService<IUserService>();
}
#region 通过任务主键获取货物运输计划已变更详情
/// <summary>
/// 通过任务主键获取货物运输计划已变更详情
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult<TaskTransPlanHasChangeShowDto>> GetInfoByTaskId(long taskPKId)
{
TaskTransPlanHasChangeShowDto dto = new TaskTransPlanHasChangeShowDto();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var queryList = await tenantDb.Queryable<TaskBaseInfo>()
.InnerJoin<TaskTransPlanHasChange>((a, b) => a.Id == b.TASK_ID)
.Where((a, b) => a.Id == taskPKId)
.Select((a, b) => new { Base = a, Plan = b })
.ToListAsync();
//任务主键{taskPkId}无法获取业务信息
if (queryList.Count == 0)
throw new Exception(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBaseInfoFromTaskIdNull)), taskPKId));
var parentIdList = queryList.Select(a => a.Plan.Id).ToList();
var detailList = await tenantDb.Queryable<TaskTransPlanHasChangeDetail>()
.Where(a => parentIdList.Contains(a.P_ID)).ToListAsync();
if (detailList.Count > 0)
{
var ctnList = detailList.Where(a => a.COLUMN_TYPE.Equals("CTN", StringComparison.OrdinalIgnoreCase)).ToList();
dto.ContaNoList = ctnList.Select(a => a.CONTA_NO).ToList();
var fromList = detailList.Where(a => !string.IsNullOrWhiteSpace(a.PLAN_TYPE) && a.PLAN_TYPE.Equals("FROM", StringComparison.OrdinalIgnoreCase)).ToList();
dto.From = new TaskTransportPlanHasChangeDetailShow
{
portList = new List<TaskTransPlanHasChangePortShow>(),
dateList = new List<TaskTransPlanHasChangeDateShow>(),
vesselList = new List<TaskTransPlanHasChangeVesselShow>()
};
dto.From.portList = fromList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("PORT", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangePortShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
PortName = a.PORTLOAD,
CountryCode = a.PORTLOAD_COUNTRY,
TerminalName = a.PORTLOAD_TERMINAL,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
dto.From.dateList = fromList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("EATD", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangeDateShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
DateVal = a.ETD,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
dto.From.vesselList = fromList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("VESSEL", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangeVesselShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
Vessel = a.VESSEL,
Voyno = a.VOYNO,
Flag = a.SHIP_FLAG,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
var toList = detailList.Where(a => !string.IsNullOrWhiteSpace(a.PLAN_TYPE) && a.PLAN_TYPE.Equals("TO", StringComparison.OrdinalIgnoreCase)).ToList();
dto.To = new TaskTransportPlanHasChangeDetailShow
{
portList = new List<TaskTransPlanHasChangePortShow>(),
dateList = new List<TaskTransPlanHasChangeDateShow>(),
vesselList = new List<TaskTransPlanHasChangeVesselShow>()
};
dto.To.portList = toList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("PORT", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangePortShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
PortName = a.PORTDISCHARGE,
CountryCode = a.PORTDISCHARGE_COUNTRY,
TerminalName = a.PORTDISCHARGE_TERMINAL,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
dto.To.dateList = toList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("EATD", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangeDateShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
DateVal = a.ETA,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
dto.To.vesselList = toList.Where(a => !string.IsNullOrWhiteSpace(a.COLUMN_TYPE) && a.COLUMN_TYPE.Equals("VESSEL", StringComparison.OrdinalIgnoreCase))
.Select(a =>
{
return new TaskTransPlanHasChangeVesselShow
{
Indx = a.SORT_NO.HasValue ? a.SORT_NO.Value : 0,
Vessel = a.VESSEL,
Voyno = a.VOYNO,
Flag = a.SHIP_FLAG,
IsRemoved = a.IS_REMOVED.HasValue ? a.IS_REMOVED.Value : false
};
}).OrderBy(a => a.Indx).ToList();
}
return DataResult<TaskTransPlanHasChangeShowDto>.Success(dto);
}
#endregion
#region 检索对应的订舱订单并保存订舱ID
/// <summary>
/// 检索对应的订舱订单并保存订舱ID
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult<SeaExportOrderExtension>> SearchAndMarkBookingOrder(long taskPKId)
{
SeaExportOrderExtension orderInfo = null;
try
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var queryList = await tenantDb.Queryable<TaskBaseInfo>()
.InnerJoin<TaskTransPlanHasChange>((a, b) => a.Id == b.TASK_ID)
.Where((a, b) => a.Id == taskPKId)
.Select((a, b) => new { Base = a, Cut = b })
.ToListAsync();
//任务主键{taskPkId}无法获取业务信息
if (queryList.Count == 0)
throw new Exception(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBaseInfoFromTaskIdNull)), taskPKId));
string mblNo = queryList.FirstOrDefault().Base.MBL_NO;
var orderRlt = await _seaExportService.SearchOrderInfo(mblNo);
if (!orderRlt.Succeeded)
{
// 提单号 {0} 检索海运出口订单失败
throw new Exception(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBaseSearchOrderFailMBLNo)), mblNo));
}
orderInfo = orderRlt.Data;
foreach (var item in queryList.Select(a => a.Cut).ToList())
{
item.BOOKING_ID = orderInfo.currOrder.Id;
item.UpdateTime = DateTime.Now;
item.UpdateBy = long.Parse(user.UserId);
item.UpdateUserName = user.UserName;
tenantDb.Updateable<TaskCutDateChangeInfo>(item).UpdateColumns(x => new
{
x.BOOKING_ID,
x.UpdateTime,
x.UpdateBy,
x.UpdateUserName
}).ExecuteCommand();
}
}
catch (Exception ex)
{
Logger.Log(NLog.LogLevel.Info, $"taskPKId={taskPKId} 检索货物运输计划已变更订舱记录 处理异常,原因:{ex.Message}");
return DataResult<SeaExportOrderExtension>.FailedData(orderInfo, $"检索失败,原因:{ex.Message}", MultiLanguageConst.Operation_Failed);
}
return DataResult<SeaExportOrderExtension>.Success(orderInfo);
}
#endregion
#region 自动转发
/// <summary>
/// 自动转发
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult> AutoTranmitToCustomer(long taskPKId)
{
SeaExportOrderExtension orderInfo = null;
try
{
var queryRlt = await SearchAndMarkBookingOrder(taskPKId);
if (!queryRlt.Succeeded)
{
throw new Exception(queryRlt.Message);
}
orderInfo = queryRlt.Data;
//如果没有配置批量,则按单票发送邮件
var rlt = await SendEmailToCustomer(taskPKId);
Logger.Log(NLog.LogLevel.Info, $"taskPKId={taskPKId} 推送邮件完成,结果:{JsonConvert.SerializeObject(rlt)}");
}
catch (Exception ex)
{
Logger.Log(NLog.LogLevel.Info, $"taskPKId={taskPKId} 自动更新订单的截单日期并转发失败异常,原因:{ex.Message}");
return DataResult.Failed($"自动更新订单的截单日期并转发失败,原因:{ex.Message}", MultiLanguageConst.Operation_Failed);
}
return DataResult.Successed(string.Empty, MultiLanguageConst.OperationSuccess);
}
#endregion
#region 发送邮件通知给客户
/// <summary>
/// 发送邮件通知给客户
/// </summary>
/// <param name="taskPKId">货物运输计划已变更主键</param>
/// <returns>返回回执</returns>
public async Task<DataResult> SendEmailToCustomer(long taskPKId)
{
return null;
}
#endregion
}
}

@ -0,0 +1,77 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.TaskApi.Controllers
{
/// <summary>
/// 货物运输计划已变更
/// </summary>
public class TaskTransPlanHasChangeController : ApiController
{
private readonly ITaskTransPlanHasChangeService _taskTransPlanHasChangeService;
/// <summary>
///
/// </summary>
/// <param name="taskManageCutDateChangeService"></param>
public TaskTransPlanHasChangeController(ITaskTransPlanHasChangeService taskTransPlanHasChangeService)
{
_taskTransPlanHasChangeService = taskTransPlanHasChangeService;
}
#region 通过任务主键获取货物运输计划已变更详情
/// <summary>
/// 通过任务主键获取货物运输计划已变更详情
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("GetInfoByTaskId")]
public async Task<DataResult<TaskTransPlanHasChangeShowDto>> GetInfoByTaskId(long taskPKId)
{
return await _taskTransPlanHasChangeService.GetInfoByTaskId(taskPKId);
}
#endregion
#region 检索对应的订舱订单并保存订舱ID
/// <summary>
/// 检索对应的订舱订单并保存订舱ID
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("SearchAndMarkBookingOrder")]
public async Task<DataResult<SeaExportOrderExtension>> SearchAndMarkBookingOrder(long taskPKId)
{
return await _taskTransPlanHasChangeService.SearchAndMarkBookingOrder(taskPKId);
}
#endregion
#region 自动转发
/// <summary>
/// 自动转发
/// </summary>
/// <param name="taskPKId">货物运输计划已变更任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("AutoTranmitToCustomer")]
public async Task<DataResult> AutoTranmitToCustomer(long taskPKId)
{
return await _taskTransPlanHasChangeService.AutoTranmitToCustomer(taskPKId);
}
#endregion
#region 发送邮件通知给客户
/// <summary>
/// 发送邮件通知给客户
/// </summary>
/// <param name="taskPKId">货物运输计划已变更主键</param>
/// <returns>返回回执</returns>
[HttpGet("SendEmailToCustomer")]
public async Task<DataResult> SendEmailToCustomer(long taskPKId)
{
return await _taskTransPlanHasChangeService.SendEmailToCustomer(taskPKId);
}
#endregion
}
}
Loading…
Cancel
Save