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.
189 lines
7.5 KiB
C#
189 lines
7.5 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 NLog;
|
|
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;
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
{
|
|
/// <summary>
|
|
/// 截止时间变更
|
|
/// </summary>
|
|
public class TaskManageCutDateChangeService: ITaskManageCutDateChangeService
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly ISqlSugarClient db;
|
|
private readonly IUser user;
|
|
private readonly ISaasDbService saasService;
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
public TaskManageCutDateChangeService(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
}
|
|
|
|
#region 通过任务主键获取截止时间变更详情
|
|
/// <summary>
|
|
/// 通过任务主键获取截止时间变更详情
|
|
/// </summary>
|
|
/// <param name="taskPkId">截止时间变更任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult<List<TaskCutDateChangeShowDto>>> GetInfoByTaskId(long taskPKId)
|
|
{
|
|
List<TaskCutDateChangeShowDto> list = new List<TaskCutDateChangeShowDto>();
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var queryList = await tenantDb.Queryable<TaskBaseInfo>()
|
|
.InnerJoin<TaskCutDateChangeInfo>((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));
|
|
|
|
var parentIdList = queryList.Select(a => a.Cut.Id).ToList();
|
|
|
|
var detailList = await tenantDb.Queryable<TaskCutDateChangeDetailInfo>()
|
|
.Where(a => parentIdList.Contains(a.P_ID)).ToListAsync();
|
|
|
|
if (detailList.Count > 0)
|
|
{
|
|
list = detailList.OrderBy(p => p.MBL_NO).Select(p =>
|
|
{
|
|
TaskCutDateChangeShowDto model = p.Adapt<TaskCutDateChangeShowDto>();
|
|
|
|
model.NoticeDate = queryList.FirstOrDefault().Cut.NOTICE_DATE;
|
|
model.Carrier = queryList.FirstOrDefault().Cut.CARRIER;
|
|
|
|
return model;
|
|
}).ToList();
|
|
}
|
|
|
|
return DataResult<List<TaskCutDateChangeShowDto>>.Success(list);
|
|
}
|
|
#endregion
|
|
|
|
#region 检索对应的订舱订单并保存订舱ID
|
|
/// <summary>
|
|
/// 检索对应的订舱订单并保存订舱ID
|
|
/// </summary>
|
|
/// <param name="taskPKId">截止时间变更任务主键</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult> SearchAndMarkBookingOrder(long taskPKId)
|
|
{
|
|
try
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
var queryList = await tenantDb.Queryable<TaskBaseInfo>()
|
|
.InnerJoin<TaskCutDateChangeInfo>((a, b) => a.Id == b.TASK_ID)
|
|
.Where((a, b) => a.Id == taskPKId)
|
|
.Select((a, b) => new { Base = a, Cut = b })
|
|
.ToListAsync();
|
|
|
|
//调取海运出口的检索匹配订单方法
|
|
|
|
//通过船名航次取是主单的订舱记录列表
|
|
//var bookingInfo = _bookingOrderRepository.AsQueryable().Filter(null, true).First(a => a.MBLNO == entityInfo.MBL_NO
|
|
// && a.IsDeleted == false && (a.ParentId == null || a.ParentId == 0) && a.TenantId == UserManager.TENANT_ID);
|
|
|
|
//if (bookingInfo != null)
|
|
//{
|
|
// entityInfo.BOOKING_ID = bookingInfo.Id;
|
|
|
|
// entityInfo.UpdatedTime = DateTime.Now;
|
|
// entityInfo.UpdatedUserId = UserManager.UserId;
|
|
// entityInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
// await _taskCutDateChangeInfoRepository.AsUpdateable(entityInfo).UpdateColumns(x => new
|
|
// {
|
|
// x.BOOKING_ID,
|
|
// x.UpdatedTime,
|
|
// x.UpdatedUserId,
|
|
// x.UpdatedUserName
|
|
// }).ExecuteCommandAsync();
|
|
|
|
// var list = _taskCutDateChangeDetailInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == entityInfo.PK_ID).ToList();
|
|
|
|
// if (list != null && list.Count > 0)
|
|
// {
|
|
// list.ForEach(async p =>
|
|
// {
|
|
// if (p.MBL_NO.Equals(entityInfo.MBL_NO, StringComparison.OrdinalIgnoreCase))
|
|
// {
|
|
// p.BOOKING_ID = bookingInfo.Id;
|
|
// p.UpdatedTime = DateTime.Now;
|
|
// p.UpdatedUserId = UserManager.UserId;
|
|
// p.UpdatedUserName = UserManager.Name;
|
|
|
|
// await _taskCutDateChangeDetailInfoRepository.AsUpdateable(p).UpdateColumns(x => new
|
|
// {
|
|
// x.BOOKING_ID,
|
|
// x.UpdatedTime,
|
|
// x.UpdatedUserId,
|
|
// x.UpdatedUserName
|
|
// }).ExecuteCommandAsync();
|
|
// }
|
|
// });
|
|
// }
|
|
|
|
// result.succ = true;
|
|
// result.msg = "检索对应成功";
|
|
//}
|
|
//else
|
|
//{
|
|
// result.succ = false;
|
|
// result.msg = $"检索对应失败,提单号:{entityInfo.MBL_NO} 没有对应的订舱记录";
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//result.succ = false;
|
|
//result.msg = $"检索失败,原因:{ex.Message}";
|
|
|
|
//_logger.LogInformation($"taskPKId={taskPKId} 检索截止时间变更订舱记录 处理异常,原因:{ex.Message}");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region 发送邮件通知给客户
|
|
/// <summary>
|
|
/// 发送邮件通知给客户
|
|
/// </summary>
|
|
/// <param name="taskPKId">截止时间变更主键</param>
|
|
/// <returns>返回回执</returns>
|
|
public async Task<DataResult> SendEmailToCustomer(long taskPKId)
|
|
{
|
|
return null;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|