You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
202 lines
7.9 KiB
C#
202 lines
7.9 KiB
C#
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;
|
|
using DS.Module.Core.Data;
|
|
using LanguageExt.Common;
|
|
using DS.WMS.Core.Op.Method.TaskInteraction;
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
{
|
|
public class TaskPOLContainerNotPickUpService : ITaskPOLContainerNotPickUpService
|
|
{
|
|
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();
|
|
|
|
public TaskPOLContainerNotPickUpService(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<List<TaskPOLContainerNotPickUpShowDto>>> GetInfoByTaskId(long taskPKId)
|
|
{
|
|
List<TaskPOLContainerNotPickUpShowDto> list = new List<TaskPOLContainerNotPickUpShowDto>();
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
//任务不考虑OrgId,这里去掉
|
|
tenantDb.QueryFilter.Clear<IOrgId>();
|
|
|
|
var queryList = await tenantDb.Queryable<TaskBaseInfo>()
|
|
.InnerJoin<TaskPolContainerNotPickup>((a, b) => a.Id == b.TASK_ID)
|
|
.Where((a, b) => a.Id == taskPKId)
|
|
.Select((a, b) => new { Base = a, Pol = b })
|
|
.ToListAsync();
|
|
|
|
//任务主键{taskPkId}无法获取业务信息
|
|
if (queryList.Count == 0)
|
|
throw new Exception(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskBaseInfoFromTaskIdNull)), taskPKId));
|
|
|
|
if (queryList.Count > 0)
|
|
{
|
|
list = queryList.Select(a => a.Pol.Adapt<TaskPOLContainerNotPickUpShowDto>()).ToList();
|
|
}
|
|
|
|
List<long> noList = new List<long>();
|
|
|
|
for (int i = 0; i < 2000; i++)
|
|
{
|
|
noList.Add(SnowFlakeSingle.Instance.NextId());
|
|
}
|
|
|
|
return DataResult<List<TaskPOLContainerNotPickUpShowDto>>.Success(list);
|
|
}
|
|
#endregion
|
|
|
|
#region 检索对应的订舱订单并保存订舱ID
|
|
/// <summary>
|
|
/// 检索对应的订舱订单并保存订舱ID
|
|
/// </summary>
|
|
/// <param name="taskPKId">起运港未提箱任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult<SeaExportOrderExtension>> SearchAndMarkBookingOrder(long taskPKId)
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
var entity = tenantDb.Queryable<TaskPolContainerNotPickup>().Filter(null, true).First(a => a.TASK_ID == taskPKId);
|
|
|
|
return await _seaExportService.SearchOrderInfo(entity.MBL_NO);
|
|
}
|
|
#endregion
|
|
|
|
#region 发送邮件通知给客户
|
|
/// <summary>
|
|
/// 发送邮件通知给客户
|
|
/// </summary>
|
|
/// <param name="taskPKId">起运港未提箱主键</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult> SendEmailToCustomer(long taskPKId)
|
|
{
|
|
//先匹配订单记录(这里可能关联的是拆票或者合票订单,如果是拆票需要所有拆票记录都要发邮件通知)
|
|
var searchInfo = SearchAndMarkBookingOrder(taskPKId).GetAwaiter().GetResult().Data;
|
|
|
|
|
|
//BusinessTaskMail? mailConfig = null;
|
|
//if (context.AdditionalData.TryGetValue(nameof(BusinessTaskMail) + "." + nameof(BusinessTaskMail.Id), out var id))
|
|
//{
|
|
// if (id == null)
|
|
// {
|
|
// await LogService.WriteLogAsync(context.TaskInfo, $"未配置【{context.TaskInfo.TaskType.GetDescription()}】任务的邮件设置");
|
|
// return;
|
|
// }
|
|
// var idVal = (long)Convert.ChangeType(id, typeof(long));
|
|
// mailConfig = (await taskMailService.GetAsync(idVal)).Data;
|
|
//}
|
|
|
|
//if (mailConfig == null)
|
|
//{
|
|
// //await LogService.WriteLogAsync(context.TaskInfo, $"未能根据任务配置值获取邮件模板设置");
|
|
// //return;
|
|
//}
|
|
|
|
//MailService mailService = new(_serviceProvider);
|
|
//var result3 = await mailService.SendAsync(mailConfig, model);
|
|
//if (!result3.Succeeded)
|
|
//{
|
|
// //await LogService.WriteLogAsync(context.TaskInfo, result.Message);
|
|
// //return;
|
|
//}
|
|
|
|
//var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(order)
|
|
//{
|
|
// BusinessId = context.TaskInfo.BusinessId,
|
|
// BusinessType = context.TaskInfo.BusinessType,
|
|
//};
|
|
//MailService mailService = new MailService(context.ServiceProvider);
|
|
//var result3 = await mailService.SendAsync(mailConfig, model);
|
|
//if (!result3.Succeeded)
|
|
//{
|
|
// await LogService.WriteLogAsync(context.TaskInfo, result.Message);
|
|
// return;
|
|
//}
|
|
|
|
//await SetTaskCompleteAsync(context.TaskInfo,
|
|
// context.ServiceProvider.GetRequiredService<ITaskService>(), LogService);
|
|
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region 发送邮件通知给客户(任务自动机调取)
|
|
/// <summary>
|
|
/// 发送邮件通知给客户(任务自动机调取)
|
|
/// </summary>
|
|
/// <param name="dataContext">数据上下文</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult> SendEmailToCustomerTask(TaskFlowDataContext dataContext)
|
|
{
|
|
var taskPKId = dataContext.Get<Nullable<long>>(TaskFlowDataNameConst.TaskPKId) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskPKId)}");
|
|
|
|
return await SendEmailToCustomer(taskPKId);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|