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;
using NPOI.POIFS.Storage;
using Yitter.IdGenerator;
using Furion.DistributedIDGenerator;
using System.Text.RegularExpressions;
using Furion;
using Myshipping.Application.Helper;
using HtmlAgilityPack;
using Myshipping.Application.ConfigOption;
using Myshipping.Application.Enum;
using System.IO;
using StackExchange.Profiling.Internal;
using Furion.JsonSerialization;
using MySqlX.XDevAPI.Common;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using System.Net.Http;
using NPOI.Util;
namespace Myshipping.Application
{
///
/// 货物运输计划已变更
///
[ApiDescriptionSettings("Application", Name = "TaskTransPlanHasChange", Order = 10)]
public class TaskTransPlanHasChangeService : ITaskTransPlanHasChangeService, IDynamicApiController, ITransient
{
private readonly ISysCacheService _cache;
private readonly ILogger _logger;
private readonly SqlSugarRepository _taskBaseRepository;
private readonly SqlSugarRepository _taskTransPlanHasChangeInfoRepository;
private readonly SqlSugarRepository _taskTransPlanHasChangeDetailInfoRepository;
private readonly SqlSugarRepository _djyUserMailAccount;
private readonly SqlSugarRepository _bookingOrderRepository;
private readonly SqlSugarRepository _bookingOrderContactRepository;
private readonly SqlSugarRepository _sysUserRepository;
private readonly SqlSugarRepository _repPrintTemplate;
private readonly SqlSugarRepository _taskFileRepository;
public TaskTransPlanHasChangeService(ISysCacheService cache, ILogger logger,
SqlSugarRepository taskBaseRepository,
SqlSugarRepository taskTransPlanHasChangeInfoRepository,
SqlSugarRepository taskTransPlanHasChangeDetailInfoRepository,
SqlSugarRepository djyUserMailAccount,
SqlSugarRepository bookingOrderContactRepository,
SqlSugarRepository sysUserRepository,
SqlSugarRepository repPrintTemplate,
SqlSugarRepository taskFileRepository,
SqlSugarRepository bookingOrderRepository)
{
_cache = cache;
_logger = logger;
_taskBaseRepository = taskBaseRepository;
_taskTransPlanHasChangeInfoRepository = taskTransPlanHasChangeInfoRepository;
_taskTransPlanHasChangeDetailInfoRepository = taskTransPlanHasChangeDetailInfoRepository;
_djyUserMailAccount = djyUserMailAccount;
_bookingOrderRepository = bookingOrderRepository;
_bookingOrderContactRepository = bookingOrderContactRepository;
_sysUserRepository = sysUserRepository;
_repPrintTemplate = repPrintTemplate;
_taskFileRepository = taskFileRepository;
}
#region 获取货物运输计划已变更详情
///
/// 获取货物运输计划已变更详情
///
/// 货物运输计划已变更任务主键
/// 返回详情
[HttpGet("/TaskTransPlanHasChange/GetInfoByTaskId")]
public async Task GetInfoByTaskId(string taskPkId)
{
TaskTransPlanHasChangeShowDto dto = new TaskTransPlanHasChangeShowDto();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var entityInfo = _taskTransPlanHasChangeInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (entityInfo == null)
throw Oops.Oh($"货物运输计划已变更主键{taskPkId}无法获取业务信息");
var detailList = _taskTransPlanHasChangeDetailInfoRepository.AsQueryable()
.Where(a => a.P_ID == entityInfo.PK_ID).ToList();
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(),
dateList = new List(),
vesselList = new List()
};
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,
PortName = a.PORTLOAD,
//CountryCode = a.
};
}).ToList();
var toList = detailList.Where(a => !string.IsNullOrWhiteSpace(a.PLAN_TYPE) && a.PLAN_TYPE.Equals("TO", StringComparison.OrdinalIgnoreCase)).ToList();
}
return dto;
}
#endregion
#region 自动转发货物运输计划已变更
///
/// 自动转发货物运输计划已变更
///
/// 货物运输计划已变更任务主键
/// 返回回执
public async Task AutoTransferNotice(string taskPKId)
{
return null;
}
#endregion
#region 检索对应的订舱订单
///
/// 检索对应的订舱订单
///
/// 货物运输计划已变更任务主键
/// 返回回执
public async Task QueryVBookingOrder(string taskPKId)
{
return null;
}
#endregion
#region 发送邮件通知给客户
///
/// 发送邮件通知给客户
///
/// 货物运输计划已变更主键
/// 返回回执
public async Task SendEmailToCustomer(string taskPKId)
{
return null;
}
#endregion
}
}