zhangxiaofeng 8 months ago
commit 6500fcbd50

@ -52,7 +52,6 @@
<ItemGroup>
<Folder Include="Entity\Fee\" />
<Folder Include="Service\TaskManagePlat\Dtos\Draft\" />
</ItemGroup>
</Project>

@ -1469,6 +1469,80 @@ namespace Myshipping.Application
return id;
}
#endregion
#region 检索舱位对应的订舱订单(BY 舱位主键)
/// <summary>
/// 检索舱位对应的订舱订单(BY 舱位主键)
/// </summary>
/// <param name="id"></param>
/// <returns>返回回执</returns>
public async Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderById(long id)
{
BookingSlotWithOrderDto dto = null;
var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id);
if (slotInfo == null)
{
_logger.LogInformation($"id={id} 获取舱位失败,舱位不存在或已作废");
return dto;
}
var list =_repAllocation.AsQueryable().Where(a => a.BOOKING_SLOT_ID == id).ToList();
dto = new BookingSlotWithOrderDto
{
BookingSlotId = slotInfo.Id,
};
if (list.Count > 0)
{
dto.HasBookingOrder = true;
dto.BookingOrderList = list.Select(x => x.Id).ToList();
}
return dto;
}
#endregion
#region 检索舱位对应的订舱订单(BY 订舱编号)
/// <summary>
/// 检索舱位对应的订舱订单(BY 订舱编号)
/// </summary>
/// <param name="slotBookingNo">订舱编号</param>
/// <returns>返回回执</returns>
public async Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderByNo(string slotBookingNo)
{
BookingSlotWithOrderDto dto = null;
var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.SLOT_BOOKING_NO == slotBookingNo);
if (slotInfo == null)
{
_logger.LogInformation($"slotBookingNo={slotBookingNo} 获取舱位失败,舱位不存在或已作废");
return dto;
}
var list = _repAllocation.AsQueryable().Where(a => a.BOOKING_SLOT_ID == slotInfo.Id).ToList();
dto = new BookingSlotWithOrderDto
{
BookingSlotId = slotInfo.Id,
};
if (list.Count > 0)
{
dto.HasBookingOrder = true;
dto.BookingOrderList = list.Select(x => x.Id).ToList();
}
return dto;
}
#endregion
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
///
/// </summary>
public class BookingSlotWithOrderDto
{
/// <summary>
/// 舱位主键
/// </summary>
public long BookingSlotId { get; set; }
/// <summary>
/// 舱位对应的订舱主键组
/// </summary>
public List<long> BookingOrderList { get; set; }
/// <summary>
/// 是否有对应的订舱订单
/// </summary>
public bool HasBookingOrder { get; set; } = false;
}
}

@ -96,5 +96,21 @@ namespace Myshipping.Application
/// <param name="model">生成订舱订单请求</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CreateBookingOrder(BookingGenerateDto model);
/// <summary>
/// 检索舱位对应的订舱订单(BY 舱位主键)
/// </summary>
/// <param name="id"></param>
/// <returns>返回回执</returns>
Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderById(long id);
/// <summary>
/// 检索舱位对应的订舱订单(BY 订舱编号)
/// </summary>
/// <param name="slotBookingNo">订舱编号</param>
/// <returns>返回回执</returns>
Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderByNo(string slotBookingNo);
}
}

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskDraftDto
{
/// <summary>
/// 主键
/// </summary>
public string PKId { get; set; }
/// <summary>
/// 任务主键
/// </summary>
public string TaskId { get; set; }
/// <summary>
/// 主单号
/// </summary>
public string MBlNo { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string Carrier { get; set; }
/// <summary>
/// 通知接收时间
/// </summary>
public Nullable<DateTime> NoticeDate { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
public Nullable<long> BookingId { get; set; }
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TaskDraftShowDto: TaskDraftDto
{
/// <summary>
/// 是否已完成
/// </summary>
public bool IsComplete { get; set; }
/// <summary>
/// 完成时间
/// </summary>
public Nullable<DateTime> CompleteTime { get; set; }
}
}

@ -96,5 +96,13 @@ namespace Myshipping.Application
/// <param name="taskPKId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SyncBookingSlotChange(string taskPKId);
/// <summary>
/// 重新处理BC任务
/// 对未匹配订舱订单的任务记录重新对应订舱订单
/// </summary>
/// <param name="taskPkId">BC任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId);
}
}

@ -14,14 +14,14 @@ namespace Myshipping.Application
/// </summary>
/// <param name="pkId">DRAFT主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetInfo(string pkId);
Task<TaskDraftShowDto> GetInfo(string pkId);
/// <summary>
/// 通过任务主键获取DRAFT详情
/// </summary>
/// <param name="taskPkId">DRAFT任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetInfoByTaskId(string taskPkId);
Task<TaskDraftShowDto> GetInfoByTaskId(string taskPkId);
/// <summary>
/// 任务ID下载附件
@ -29,7 +29,7 @@ namespace Myshipping.Application
/// <param name="taskPKId">DRAFT任务主键</param>
/// <param name="fileCategory">附件分类代码</param>
/// <returns>返回数据流</returns>
Task<IActionResult> DownloadFile(string taskPKId, string fileCategory = "BC");
Task<IActionResult> DownloadFile(string taskPKId, string fileCategory = "DRAFT");
/// <summary>
/// 发送邮件
@ -37,5 +37,13 @@ namespace Myshipping.Application
/// <param name="taskPKId">DRAFT任务主键</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SendEmail(string taskPKId);
/// <summary>
/// 重新处理DRAFT任务
/// 对未匹配订舱订单的任务记录重新对应订舱订单
/// </summary>
/// <param name="taskPkId">DRAFT任务主键</param>
/// <returns></returns>
Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId);
}
}

@ -1,4 +1,5 @@
using Furion;
using Furion.DependencyInjection;
using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.FriendlyException;
@ -20,6 +21,7 @@ using Newtonsoft.Json;
using Npoi.Mapper;
using NPOI.HPSF;
using NPOI.SS.Formula.Functions;
using NPOI.XWPF.UserModel;
using Org.BouncyCastle.Asn1.Tsp;
using RabbitMQ.Client;
using SqlSugar;
@ -74,6 +76,8 @@ namespace Myshipping.Application
private readonly IBookingValueAddedService _bookingValueAddedService;
private readonly IDjyCustomerService _djyCustomerService;
private readonly INamedServiceProvider<IBookingSlotService> _namedBookingSlotServiceProvider;
const string CONST_BC_FILE_CODE = "bc";
const string CONST_BC_FILE_NAME = "Booking Confirmation";
@ -93,6 +97,7 @@ namespace Myshipping.Application
IBookingOrderService bookingOrderService, ILogger<TaskManageBCService> logger,
IDjyCustomerService djyCustomerService,
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService,
INamedServiceProvider<IBookingSlotService> namedBookingSlotServiceProvider,
SqlSugarRepository<BookingSlotBase> bookingSlotBaseRepository,
SqlSugarRepository<BookingSlotCtn> bookingSlotBaseCtnRepository,
SqlSugarRepository<BookingSlotAllocation> bookingSlotAllocationRepository,
@ -1665,7 +1670,7 @@ namespace Myshipping.Application
_logger.LogInformation($"推送邮件失败,异常:{ex.Message}");
result.succ = false;
result.msg = $"推送邮件失败,异常:{ex.Message}";
result.msg = $"推送邮件失败,{ex.Message}";
}
return result;
@ -1724,7 +1729,11 @@ namespace Myshipping.Application
baseHtml = baseHtml.Replace("#opemail#", "");
}
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Phone))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Phone);
}
else if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Tel);
}
@ -1821,7 +1830,6 @@ namespace Myshipping.Application
}
#endregion
#region 通过邮件模板生成HTML
/// <summary>
/// 通过邮件模板生成HTML
@ -1874,7 +1882,11 @@ namespace Myshipping.Application
baseHtml = baseHtml.Replace("#opemail#", "");
}
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Phone))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Phone);
}
else if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Tel);
}
@ -2194,6 +2206,185 @@ namespace Myshipping.Application
return result;
}
#endregion
#region 重试处理BC任务
/// <summary>
/// 重试处理BC任务
/// 对未匹配舱位、订舱订单的任务记录重新对应舱位、订舱订单
/// </summary>
/// <param name="taskPkId">BC任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageBC/SearchAndConnectBookingInfo")]
public async Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId)
{
/*
BCBC
1BC
2BC
*/
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var taskBCInfo = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (taskBCInfo == null)
throw Oops.Oh($"BC任务主键{taskPkId}无法获取业务信息");
if (taskBCInfo.BOOKING_SLOT_ID.HasValue)
throw Oops.Oh($"当前BC任务已有匹配的舱位");
string mblNo = taskBCInfo.MBL_NO.ToUpper().Trim();
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo);
if (slotInfo == null)
throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息");
taskBCInfo.BOOKING_SLOT_ID = slotInfo.BookingSlotId;
taskBCInfo.UpdatedUserId = UserManager.UserId;
taskBCInfo.UpdatedUserName = UserManager.Name;
//更新任务BC
await _taskBCInfoRepository.AsUpdateable(taskBCInfo).UpdateColumns(it => new
{
it.BOOKING_SLOT_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
_logger.LogInformation($"提单号{mblNo} 提取到舱位ID,更新完成");
//取消舱位
if (taskBCInfo.BUSI_TYPE == TaskBusiTypeEnum.CANCELLATION.ToString())
{
BookingSlotBaseApiDto slotModel = new BookingSlotBaseApiDto
{
DataObj = new BookingSlotBaseApiSaveDto
{
CARRIERID = taskBCInfo.CARRIERID,
SLOT_BOOKING_NO = taskBCInfo.MBL_NO,
CtnList = new List<BookingSlotCtnSaveInput>()
},
OpType = "cancellation"
};
_logger.LogInformation($"提单号{mblNo} 推送舱位取消");
var pushRlt = await server.ApiReceive(JSON.Serialize(slotModel));
_logger.LogInformation($"提单号{mblNo} 推送舱位取消,结果={JSON.Serialize(pushRlt)}");
}
else if (taskBCInfo.BUSI_TYPE == TaskBusiTypeEnum.BC_MODIFY.ToString())
{
BookingSlotBaseApiDto slotModel = new BookingSlotBaseApiDto
{
DataObj = new BookingSlotBaseApiSaveDto
{
CARRIERID = taskBCInfo.CARRIERID,
SLOT_BOOKING_NO = taskBCInfo.MBL_NO,
BOOKING_PARTY = taskBCInfo.BOOKING_PARTY,
BOOKING_SLOT_TYPE = taskBCInfo.BOOKING_SLOT_TYPE,
BOOKING_SLOT_TYPE_NAME = taskBCInfo.BOOKING_SLOT_TYPE_NAME,
VESSEL = taskBCInfo.VESSEL,
VOYNO = taskBCInfo.VOYNO,
VGM_SUBMISSION_CUT_DATE = taskBCInfo.VGM_CUTOFF_TIME,
WEEK_AT = taskBCInfo.WEEK_AT,
CARRIAGE_TYPE = taskBCInfo.CARRIAGE_TYPE,
CARRIAGE_TYPE_NAME = taskBCInfo.CARRIAGE_TYPE_NAME,
CONTRACT_NO = taskBCInfo.CONTRACTNO,
CTN_STAT = taskBCInfo.CTN_STAT,
CY_CUT_DATE = taskBCInfo.CY_CUTOFF_TIME,
DETENSION_FREE_DAYS = taskBCInfo.DETENSION_FREE_DAYS,
ETD = taskBCInfo.ETD,
ETA = taskBCInfo.ETA,
LANECODE = taskBCInfo.LANECODE,
LANENAME = taskBCInfo.LANENAME,
MANIFEST_CUT_DATE = taskBCInfo.MANIFEST_CUT_DATE,
MDGF_CUT_DATE = taskBCInfo.MDGF_CUT_DATE,
PLACEDELIVERY = taskBCInfo.PLACEDELIVERY,
PLACERECEIPT = taskBCInfo.PLACERECEIPT,
PORTDISCHARGE = taskBCInfo.PORTDISCHARGE,
PORTLOAD = taskBCInfo.PORTLOAD,
SI_CUT_DATE = taskBCInfo.SI_CUT_DATE,
TRANSFER_PORT_1 = taskBCInfo.TRANSFER_PORT_1,
TRANSFER_PORT_2 = taskBCInfo.TRANSFER_PORT_2,
CtnList = new List<BookingSlotCtnSaveInput>()
},
OpType = "add"
};
var ctnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == taskBCInfo.PK_ID).ToList();
if (ctnList.Count > 0)
{
ctnList.ForEach(t =>
{
BookingSlotCtnSaveInput ctn = new BookingSlotCtnSaveInput
{
CTNALL = t.CTNALL,
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
};
slotModel.DataObj.CtnList.Add(ctn);
});
}
var opt = App.GetOptions<BookingAttachOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
var taskFileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID).ToList();
DynameFileInfo dynameFile = null;
DynameFileInfo dynameNoticeFile = null;
if (taskFileList.Any(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString()))
{
var fileInfo = taskFileList.FirstOrDefault(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString());
var fileFullPath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
dynameFile = new DynameFileInfo
{
FileBytes = File.ReadAllBytes(fileFullPath),
FileName = Path.GetFileName(fileFullPath)
};
}
if (taskFileList.Any(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC_NOTICE.ToString()))
{
var fileInfo = taskFileList.FirstOrDefault(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString());
var fileFullPath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
dynameNoticeFile = new DynameFileInfo
{
FileBytes = File.ReadAllBytes(fileFullPath),
FileName = Path.GetFileName(fileFullPath)
};
}
_logger.LogInformation($"提单号{mblNo} 推送舱位更新");
var pushRlt = await server.InnerApiReceive(slotModel, dynameFile, dynameNoticeFile);
_logger.LogInformation($"提单号{mblNo} 推送舱位更新,结果={JSON.Serialize(pushRlt)}");
}
result.succ = true;
result.msg = "成功";
return result;
}
#endregion
}
/// <summary>

@ -1,15 +1,26 @@
using Furion.DynamicApiController;
using Furion;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Furion.JsonSerialization;
using Furion.RemoteRequest.Extensions;
using HtmlAgilityPack;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Myshipping.Application.ConfigOption;
using Myshipping.Application.Entity;
using Myshipping.Core;
using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
namespace Myshipping.Application
{
@ -22,11 +33,37 @@ namespace Myshipping.Application
private readonly ISysCacheService _cache;
private readonly ILogger<TaskManageDRAFTService> _logger;
private readonly SqlSugarRepository<TaskBaseInfo> _taskBaseRepository;
private readonly SqlSugarRepository<TaskFileInfo> _taskFileRepository;
private readonly SqlSugarRepository<TaskDraftInfo> _taskDraftInfoRepository;
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
private readonly SqlSugarRepository<BookingOrderContact> _bookingOrderContactRepository;
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
private readonly SqlSugarRepository<SysUser> _sysUserRepository;
private readonly IDjyCustomerService _djyCustomerService;
public TaskManageDRAFTService(SqlSugarRepository<TaskBCInfo> taskBCInfoRepository,
public TaskManageDRAFTService(SqlSugarRepository<TaskBaseInfo> taskBaseRepository,
SqlSugarRepository<TaskFileInfo> taskFileRepository,
SqlSugarRepository<TaskDraftInfo> taskDraftInfoRepository,
SqlSugarRepository<DjyUserMailAccount> djyUserMailAccount,
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
SqlSugarRepository<BookingOrder> bookingOrderRepository,
SqlSugarRepository<SysUser> sysUserRepository,
IDjyCustomerService djyCustomerService,
ISysCacheService cache,
ILogger<TaskManageDRAFTService> logger)
{
_taskBaseRepository = taskBaseRepository;
_taskFileRepository = taskFileRepository;
_taskDraftInfoRepository = taskDraftInfoRepository;
_bookingOrderRepository = bookingOrderRepository;
_bookingOrderContactRepository = bookingOrderContactRepository;
_djyUserMailAccount = djyUserMailAccount;
_djyCustomerService = djyCustomerService;
_sysUserRepository = sysUserRepository;
_logger = logger;
_cache = cache;
}
#region 获取DRAFT详情
@ -35,38 +72,39 @@ namespace Myshipping.Application
/// </summary>
/// <param name="pkId">DRAFT主键</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> GetInfo(string pkId)
[HttpGet("/TaskManageDRAFT/GetInfo")]
public async Task<TaskDraftShowDto> GetInfo(string pkId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
//var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == pkId);
//if (bcOrder == null)
// throw Oops.Oh($"BC主键{pkId}无法获取业务信息");
TaskDraftShowDto dto = new TaskDraftShowDto();
//var BCCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == pkId).ToList();
var draft = _taskDraftInfoRepository.AsQueryable().First(a => a.PK_ID == pkId);
//TaskBCShowBaseDto model = bcOrder.Adapt<TaskBCShowBaseDto>();
if (draft == null)
throw Oops.Oh($"DRAFT主键{pkId}无法获取业务信息");
//if (BCCtnList.Count > 0)
// model.CtnList = BCCtnList.Adapt<List<TaskBCCTNInfoDto>>();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == draft.TASK_ID);
//var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == bcOrder.TASK_ID).ToList();
if (taskBase == null)
throw Oops.Oh($"任务主键无法获取业务信息");
//if (fileList.Count > 0)
// model.FileList = fileList.Adapt<List<TaskFileDto>>();
dto = new TaskDraftShowDto
{
PKId = draft.PK_ID,
TaskId = draft.TASK_ID,
Carrier = draft.CARRIER,
BookingId = draft.BOOKING_ID,
MBlNo = draft.MBL_NO,
NoticeDate = draft.NOTICE_DATE,
};
}
catch (Exception ex)
if (dto != null)
{
result.succ = false;
result.msg = $"获取BC详情异常原因{ex.Message}";
dto.IsComplete = taskBase.IS_COMPLETE == 1 ? true : false;
dto.CompleteTime = taskBase.COMPLETE_DATE;
}
return result;
return dto;
}
#endregion
@ -76,9 +114,38 @@ namespace Myshipping.Application
/// </summary>
/// <param name="taskPkId">DRAFT任务主键</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> GetInfoByTaskId(string taskPkId)
[HttpGet("/TaskManageDRAFT/GetInfoByTaskId")]
public async Task<TaskDraftShowDto> GetInfoByTaskId(string taskPkId)
{
return null;
TaskDraftShowDto dto = new TaskDraftShowDto();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var draft = _taskDraftInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (draft == null)
throw Oops.Oh($"DRAFT主键{taskPkId}无法获取业务信息");
dto = new TaskDraftShowDto
{
PKId = draft.PK_ID,
TaskId = draft.TASK_ID,
Carrier = draft.CARRIER,
BookingId = draft.BOOKING_ID,
MBlNo = draft.MBL_NO,
NoticeDate = draft.NOTICE_DATE,
};
if (dto != null)
{
dto.IsComplete = taskBase.IS_COMPLETE == 1 ? true : false;
dto.CompleteTime = taskBase.COMPLETE_DATE;
}
return dto;
}
#endregion
@ -89,9 +156,49 @@ namespace Myshipping.Application
/// <param name="taskPKId">DRAFT任务主键</param>
/// <param name="fileCategory">附件分类代码</param>
/// <returns>返回数据流</returns>
public Task<IActionResult> DownloadFile(string taskPKId, string fileCategory = "DRAFT")
[HttpGet("/TaskManageDRAFT/DownloadFile")]
public async Task<IActionResult> DownloadFile([FromQuery] string taskPKId, [FromQuery] string fileCategory = "DRAFT")
{
return null;
var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
if (bcTaskInfo == null)
{
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
}
TaskFileCategoryEnum fileCategoryEnum = TaskFileCategoryEnum.NONE;
System.Enum.TryParse(fileCategory, out fileCategoryEnum);
if (fileCategoryEnum == TaskFileCategoryEnum.NONE)
{
throw Oops.Oh($"附件分类代码错误,请提供正确的分类代码");
}
string name = fileCategoryEnum.ToString();
var fileInfo = await _taskFileRepository.AsQueryable().FirstAsync(u => u.TASK_PKID == taskPKId && u.FILE_CATEGORY == name);
if (fileInfo == null)
{
throw Oops.Oh($"任务主键{taskPKId}没有可下载的附件");
}
var opt = App.GetOptions<BookingAttachOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
var fileFullPath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
if (!File.Exists(fileFullPath))
{
throw Oops.Oh($"任务主键{taskPKId} 附件下载请求失败,请确认文件是否存在");
}
var fileName = HttpUtility.UrlEncode(fileInfo.FILE_NAME, Encoding.GetEncoding("UTF-8"));
var result = new FileStreamResult(new FileStream(fileFullPath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
return result;
}
#endregion
@ -101,9 +208,452 @@ namespace Myshipping.Application
/// </summary>
/// <param name="taskPKId">DRAFT任务主键</param>
/// <returns>返回回执</returns>
[HttpGet("/TaskManageDRAFT/SendEmail")]
public async Task<TaskManageOrderResultDto> SendEmail(string taskPKId)
{
return null;
if (string.IsNullOrWhiteSpace(taskPKId))
throw Oops.Oh($"DRAFT任务主键不能为空");
var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
if (bcTaskInfo == null)
{
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
}
var draft = _taskDraftInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID);
if (draft == null)
throw Oops.Oh($"任务主键{taskPKId}无法获取DRAFT业务信息");
return await GenerateSendEmail(draft);
}
#endregion
#region 生成并推送邮件
/// <summary>
/// 生成并推送邮件
/// </summary>
/// <param name="taskDraftInfo">DRAFT任务详情</param>
/// <returns>返回回执</returns>
private async Task<TaskManageOrderResultDto> GenerateSendEmail(TaskDraftInfo taskDraftInfo)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
/*
1BCNotice
2OP
3BCNotice
4
5
*/
//读取订舱数据
var bookingOrderEntity = _bookingOrderRepository.AsQueryable()
.First(a => a.Id == taskDraftInfo.BOOKING_ID);
if (bookingOrderEntity == null)
{
throw Oops.Oh($"订舱详情获取失败,请确认订舱是否存在或已删除");
}
_logger.LogInformation($"获取订舱详情完成bookid={bookingOrderEntity.Id}");
if (!bookingOrderEntity.CUSTOMERID.HasValue || (bookingOrderEntity.CUSTOMERID.HasValue && bookingOrderEntity.CUSTOMERID.Value == 0))
{
throw Oops.Oh($"订舱的委托客户不能为空");
}
var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = bookingOrderEntity.CUSTOMERID.Value })
.GetAwaiter().GetResult();
if (djyCustomerInfo == null)
{
throw Oops.Oh($"委托单位详情获取失败,请确认委托单位是否存在或已删除");
}
_logger.LogInformation($"获取委托单位详情完成djyCustomerId={djyCustomerInfo.Id}");
//DjyCustomerContactOutput djyCustomerContactMan = null;
//TO 邮件接收人
string toEmail = string.Empty;
//订舱OP的邮箱
string opEmail = string.Empty;
var bookingContactList = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == taskDraftInfo.BOOKING_ID).ToList();
if (bookingContactList == null || bookingContactList.Count == 0)
{
_logger.LogInformation($"当前订舱未指定的联系人toEmail={toEmail}");
}
toEmail = string.Join(";", bookingContactList.Select(x => x.Email.Trim()).Distinct().ToArray());
//获取操作OP的邮箱
if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID))
{
var opId = long.Parse(bookingOrderEntity.OPID);
var opUser = _sysUserRepository.AsQueryable().First(a => a.Id == opId);
if (opUser != null && !string.IsNullOrWhiteSpace(opUser.Email))
{
opEmail = opUser.Email.Trim();
_logger.LogInformation($"获取操作OP的邮箱opEmail={opEmail} id={opId} name={opUser.Name}");
}
}
//提取当前公共邮箱的配置
var publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId
&& x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != "");
if (publicMailAccount == null)
{
throw Oops.Oh($"提取公共邮箱配置失败请在用户邮箱账号管理增加配置显示名为BCNotice");
}
_logger.LogInformation($"提取当前公共邮箱的配置完成id={publicMailAccount.Id}");
string emailTitle = $"Draft : {taskDraftInfo.MBL_NO}";
string filePath = string.Empty;
SysUser opUserInfo = null;
if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID) && Regex.IsMatch(bookingOrderEntity.OPID, "[0-9]+"))
opUserInfo = _sysUserRepository.AsQueryable().First(u => u.Id == long.Parse(bookingOrderEntity.OPID));
//读取邮件模板并填充数据
string emailHtml = GenerateSendEmailHtml(taskDraftInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
_logger.LogInformation($"生成邮件BODY结果{emailHtml}");
var fileInfo = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskDraftInfo.TASK_ID && a.FILE_CATEGORY.Contains("draft_notice"))
.OrderByDescending(a => a.CreatedTime).First();
if (fileInfo == null)
{
throw Oops.Oh($"提取DRAFT的文件失败不能发送邮件");
}
_logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FILE_PATH}");
var opt = App.GetOptions<BookingAttachOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto
{
SendTo = toEmail,
CCTo = opEmail,
Title = emailTitle,
Body = emailHtml,
Account = publicMailAccount.MailAccount?.Trim(),
Password = publicMailAccount.Password?.Trim(),
Server = publicMailAccount.SmtpServer?.Trim(),
Port = publicMailAccount.SmtpPort.HasValue ? publicMailAccount.SmtpPort.Value : 465,
UseSSL = publicMailAccount.SmtpSSL.HasValue ? publicMailAccount.SmtpSSL.Value : true,
Attaches = new List<AttachesInfo>()
};
_logger.LogInformation($"生成请求邮件参数,结果:{JSON.Serialize(emailApiUserDefinedDto)}");
//推送邮件
var emailRlt = await PushEmail(emailApiUserDefinedDto, filePath);
_logger.LogInformation($"推送邮件完成,结果:{JSON.Serialize(emailRlt)}");
result.succ = true;
result.msg = "成功";
}
catch (Exception ex)
{
_logger.LogInformation($"推送邮件失败,异常:{ex.Message}");
result.succ = false;
result.msg = $"推送邮件失败,{ex.Message}";
}
return result;
}
#endregion
#region 通过邮件模板生成HTML
/// <summary>
/// 通过邮件模板生成HTML
/// </summary>
/// <param name="taskBCInfo">BC任务详情</param>
/// <param name="opUserInfo">订舱OP详情</param>
/// <param name="tenantName">当前租户全称</param>
/// <returns>返回生成的HTML</returns>
private async Task<string> GenerateSendEmailHtml(TaskDraftInfo taskDraftInfo, SysUser opUserInfo, string tenantName)
{
string result = string.Empty;
/*
1HTML
2maincontatr
3HTML
*/
try
{
string templatePath = App.Configuration["EmailTemplateFilePath"];
var opt = App.GetOptions<BookingAttachOptions>();
var dirAbs = opt.basePath;
if (string.IsNullOrEmpty(dirAbs))
{
dirAbs = App.WebHostEnvironment.WebRootPath;
}
templatePath = $"{dirAbs}{templatePath}\\DraftEmailTemplate.html";
string baseHtml = File.ReadAllText(templatePath);
if (string.IsNullOrWhiteSpace(baseHtml))
throw Oops.Oh($"读取邮件模板失败");
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Name))
{
baseHtml = baseHtml.Replace("#opname#", opUserInfo.Name);
}
else
{
baseHtml = baseHtml.Replace("#opname#", "操作");
}
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Email))
{
baseHtml = baseHtml.Replace("#opemail#", opUserInfo.Email);
}
else
{
baseHtml = baseHtml.Replace("#opemail#", "");
}
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Phone))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Phone);
}
else if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
{
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Tel);
}
else
{
baseHtml = baseHtml.Replace("#optel#", "");
}
HtmlDocument html = new HtmlDocument();
html.LoadHtml(baseHtml);
HtmlNode baseTable = html.DocumentNode.SelectNodes("//table[@class='base-table']").FirstOrDefault();
if (baseTable == null)
throw Oops.Oh($"读取邮件模板格式错误定位base-table失败");
var baseTrList = baseTable.SelectNodes(".//tr");
foreach (var baseTr in baseTrList)
{
var tdList = baseTr.SelectNodes(".//td");
foreach (var baseTd in tdList)
{
if (baseTd.Attributes["class"].Value == "billno-val")
{
baseTd.InnerHtml = taskDraftInfo.MBL_NO;
}
else if (baseTd.Attributes["class"].Value == "carrier-val")
{
baseTd.InnerHtml = taskDraftInfo.CARRIER;
}
}
}
var noreplyTr = html.DocumentNode.SelectNodes("//tr[@class='email-noreply']").FirstOrDefault();
if (noreplyTr != null)
{
var currTd = noreplyTr.SelectNodes(".//td").FirstOrDefault();
if (currTd != null)
{
var currPList = currTd.SelectNodes(".//p");
foreach (var baseP in currPList)
{
if (baseP.Attributes["class"].Value == "notice-comp-val")
{
baseP.InnerHtml = tenantName;
}
}
}
}
result = html.DocumentNode.OuterHtml;
}
catch (Exception ex)
{
_logger.LogInformation($"通过邮件模板生成HTML异常原因={ex.Message}");
throw ex;
}
return result;
}
#endregion
#region 推送邮件
/// <summary>
/// 推送邮件
/// </summary>
/// <param name="emailApiUserDefinedDto">自定义邮件详情</param>
/// <param name="filePath">文件路径</param>
/// <returns>返回回执</returns>
private async Task<CommonWebApiResult> PushEmail(EmailApiUserDefinedDto emailApiUserDefinedDto, string filePath)
{
CommonWebApiResult result = new CommonWebApiResult { succ = true };
List<EmailApiUserDefinedDto> emailList = new List<EmailApiUserDefinedDto>();
var emailUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "email_api_url")?.Value;
if (emailUrl == null)
throw Oops.Bah("字典未配置 url_set->email_api_url 请联系管理员");
System.IO.FileStream file = new System.IO.FileStream(filePath, FileMode.Open, FileAccess.Read);
int SplitSize = 5242880;//5M分片长度
int index = 1; //序号 第几片
long StartPosition = 5242880 * (index - 1);
long lastLens = file.Length - StartPosition;//真不知道怎么起命了,就这样吧
if (lastLens < 5242880)
{
SplitSize = (int)lastLens;
}
byte[] heByte = new byte[SplitSize];
file.Seek(StartPosition, SeekOrigin.Begin);
//第一个参数是 起始位置
file.Read(heByte, 0, SplitSize);
//第三个参数是 读取长度(剩余长度)
file.Close();
string base64Str = Convert.ToBase64String(heByte);
emailApiUserDefinedDto.Attaches.Add(new AttachesInfo
{
AttachName = Path.GetFileName(filePath),
AttachContent = base64Str
});
emailList.Add(emailApiUserDefinedDto);
string strJoin = System.IO.File.ReadAllText(filePath);
DateTime bDate = DateTime.Now;
HttpResponseMessage res = null;
try
{
res = await emailUrl.SetBody(emailList, "application/json").PostAsync();
}
catch (Exception ex)
{
_logger.LogInformation($"发送邮件异常:{ex.Message}");
}
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation($"邮件上传完成 上传文件大小:{heByte.Length} 用时:{timeDiff}ms.,{strJoin}");
_logger.LogInformation($"发送邮件返回:{JSON.Serialize(res)}");
if (res != null && res.StatusCode == System.Net.HttpStatusCode.OK)
{
var userResult = await res.Content.ReadAsStringAsync();
var respObj = JsonConvert.DeserializeAnonymousType(userResult, new
{
Success = false,
Message = string.Empty,
Code = -9999,
});
result.succ = respObj.Success;
result.msg = respObj.Message;
}
return result;
}
#endregion
#region 重新处理DRAFT任务
/// <summary>
/// 重新处理DRAFT任务
/// 对未匹配订舱订单的任务记录重新对应订舱订单
/// </summary>
/// <param name="taskPkId">DRAFT任务主键</param>
/// <returns></returns>
[HttpGet("/TaskManageDRAFT/SearchAndConnectBookingInfo")]
public async Task<TaskManageOrderResultDto> SearchAndConnectBookingInfo(string taskPkId)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId);
if (taskBase == null)
throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息");
var draft = _taskDraftInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID);
if (draft == null)
throw Oops.Oh($"DRAFT主键{taskPkId}无法获取业务信息");
if (draft.BOOKING_ID.HasValue)
throw Oops.Oh($"当前DRAFT已有匹配的订舱订单");
string mblNo = draft.MBL_NO.ToUpper().Trim();
var bookingInfo = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.MBLNO == mblNo && a.IsDeleted == false && (a.ParentId == null || a.ParentId == 0));
if (bookingInfo == null)
throw Oops.Oh($"提单号{mblNo}未提取有效的订舱订单");
draft.BOOKING_ID = bookingInfo.Id;
draft.UpdatedUserId = UserManager.UserId;
draft.UpdatedUserName = UserManager.Name;
//更新任务
await _taskDraftInfoRepository.AsUpdateable(draft).UpdateColumns(it => new
{
it.BOOKING_ID,
it.UpdatedTime,
it.UpdatedUserId,
it.UpdatedUserName
}).ExecuteCommandAsync();
result.succ = true;
result.msg = "成功";
return result;
}
#endregion
}

@ -476,7 +476,7 @@ namespace Myshipping.Application
{
attachFileType = "draftnoticefiles";
fileCategory = TaskFileCategoryEnum.DRAFT.ToString();
fileCategory = TaskFileCategoryEnum.DRAFT_NOTICE.ToString();
}
var noExtensionFileName = Path.GetFileNameWithoutExtension(modifyFile.FileName);

@ -12561,6 +12561,13 @@
<member name="M:Myshipping.Core.Service.DjyTenantParamService.List(System.String,System.String)">
<summary>
获取租户参数类别
准备废弃,使用/DJYTenantParam/page替代
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.DjyTenantParamService.Page(Myshipping.Core.Service.QueryDJYTenantParamInput)">
<summary>
分页获取租户参数类别
</summary>
<returns></returns>
</member>
@ -12590,7 +12597,14 @@
</member>
<member name="M:Myshipping.Core.Service.DjyTenantParamService.GetParamValue(System.Int64,System.String)">
<summary>
获取参数
获取参数
准备废弃,使用/DJYTenantParam/PageParamValue替代
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.DjyTenantParamService.PageParamValue(Myshipping.Core.Service.QueryTenantParamValueInput)">
<summary>
分页获取参数值
</summary>
<returns></returns>
</member>
@ -12713,11 +12727,6 @@
租户参数类别表查询输入参数
</summary>
</member>
<member name="P:Myshipping.Core.Service.QueryDJYTenantParamInput.Id">
<summary>
主键Id
</summary>
</member>
<member name="P:Myshipping.Core.Service.QueryDJYTenantParamInput.ParaCode">
<summary>
类别代码
@ -12733,14 +12742,19 @@
业务大类
</summary>
</member>
<member name="P:Myshipping.Core.Service.QueryDJYTenantParamInput.Remark">
<member name="T:Myshipping.Core.Service.QueryTenantParamValueInput">
<summary>
备注
租户参数值查询输入参数
</summary>
</member>
<member name="P:Myshipping.Core.Service.QueryDJYTenantParamInput.Sort">
<member name="P:Myshipping.Core.Service.QueryTenantParamValueInput.ParaCode">
<summary>
排序
类别代码
</summary>
</member>
<member name="P:Myshipping.Core.Service.QueryTenantParamValueInput.TenantId">
<summary>
租户id
</summary>
</member>
<member name="T:Myshipping.Core.Service.DJYTenantParamOutput">
@ -12768,6 +12782,11 @@
业务大类
</summary>
</member>
<member name="P:Myshipping.Core.Service.DJYTenantParamOutput.TypeName">
<summary>
业务大类名称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DJYTenantParamOutput.Remark">
<summary>
备注
@ -12778,6 +12797,51 @@
排序
</summary>
</member>
<member name="T:Myshipping.Core.Service.DjyTenantParamValueListOutput">
<summary>
列表输出
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.ParaCode">
<summary>
参数类别
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.ParaName">
<summary>
类别名称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.TenantId">
<summary>
租户id
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.ItemCode">
<summary>
参数值
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.ItemCodeName">
<summary>
参数值名称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.Remark">
<summary>
备注
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyTenantParamValueListOutput.Sort">
<summary>
排序
</summary>
</member>
<member name="T:Myshipping.Core.Service.DjyUserConfigService">
<summary>
用户自定义配置服务

@ -25,13 +25,19 @@ namespace Myshipping.Core.Service
private readonly SqlSugarRepository<DjyTenantParamValue> _valuerep;
private readonly ILogger<DjyTenantParam> _logger;
private readonly ISysCacheService _cache;
public DjyTenantParamService(SqlSugarRepository<DjyTenantParam> rep, SqlSugarRepository<DjyTenantParamItem> itemrep, SqlSugarRepository<DjyTenantParamValue> valuerep, ISysCacheService cache, ILogger<DjyTenantParam> logger)
private readonly SqlSugarRepository<SysTenant> _repTenant;
public DjyTenantParamService(SqlSugarRepository<DjyTenantParam> rep,
SqlSugarRepository<DjyTenantParamItem> itemrep,
SqlSugarRepository<DjyTenantParamValue> valuerep,
ISysCacheService cache, ILogger<DjyTenantParam> logger,
SqlSugarRepository<SysTenant> repTenant)
{
_rep = rep;
_logger = logger;
_itemrep = itemrep;
_valuerep = valuerep;
_cache = cache;
_repTenant = repTenant;
}
#region 类别
@ -119,6 +125,7 @@ namespace Myshipping.Core.Service
/// <summary>
/// 获取租户参数类别
/// 准备废弃,使用/DJYTenantParam/page替代
/// </summary>
/// <returns></returns>
[HttpGet("/DJYTenantParam/list")]
@ -126,6 +133,31 @@ namespace Myshipping.Core.Service
{
return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaName), x => x.ParaName.Contains(ParaName)).OrderBy(x => x.Sort).ToListAsync();
}
/// <summary>
/// 分页获取租户参数类别
/// </summary>
/// <returns></returns>
[HttpGet("/DJYTenantParam/page")]
public async Task<SqlSugarPagedList<DJYTenantParamOutput>> Page(QueryDJYTenantParamInput input)
{
var list = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(input.Type), x => x.Type == input.Type)
.WhereIF(!string.IsNullOrEmpty(input.ParaCode), x => x.ParaCode == input.ParaCode)
.WhereIF(!string.IsNullOrEmpty(input.ParaName), x => x.ParaName.Contains(input.ParaName))
.OrderBy(x => x.Sort)
.ToPagedListAsync(input.PageNo, input.PageSize);
var rtn = list.Adapt<SqlSugarPagedList<DJYTenantParamOutput>>();
var dict = await _cache.GetAllDictData();
foreach (var item in rtn.Items)
{
var d = dict.FirstOrDefault(x => x.TypeCode == "tenant_param_group" && x.Code == item.Type);
item.TypeName = d.Value;
}
return rtn;
}
#endregion
#region 参数
@ -231,7 +263,8 @@ namespace Myshipping.Core.Service
#region 值
/// <summary>
/// 获取参数
/// 获取参数
/// 准备废弃,使用/DJYTenantParam/PageParamValue替代
/// </summary>
/// <returns></returns>
[HttpGet("/DJYTenantParam/getParamValue")]
@ -239,6 +272,44 @@ namespace Myshipping.Core.Service
{
return await _valuerep.AsQueryable().Filter(null, true).WhereIF(paraCode != null, x => x.ParaCode == paraCode).OrderBy(x => x.Sort).ToListAsync();
}
/// <summary>
/// 分页获取参数值
/// </summary>
/// <returns></returns>
[HttpGet("/DJYTenantParam/PageParamValue")]
public async Task<SqlSugarPagedList<DjyTenantParamValueListOutput>> PageParamValue(QueryTenantParamValueInput input)
{
var list = await _valuerep.AsQueryable().Filter(null, true)
.WhereIF(!string.IsNullOrEmpty(input.ParaCode), x => x.ParaCode == input.ParaCode)
.WhereIF(input.TenantId.HasValue, x => x.TenantId == input.TenantId)
.OrderBy(x => x.Sort)
.ToPagedListAsync(input.PageNo, input.PageSize);
var rtn = list.Adapt<SqlSugarPagedList<DjyTenantParamValueListOutput>>();
var listParam = await _rep.AsQueryable().ToListAsync();
var listParamItem = await _itemrep.AsQueryable().ToListAsync();
var listTenant = await _repTenant.AsQueryable().Select(x => new { x.Id, x.Name }).ToListAsync();
foreach (var item in rtn.Items)
{
var p = listParam.FirstOrDefault(x => x.ParaCode == item.ParaCode);
item.ParaName = p.ParaName;
var t = listTenant.FirstOrDefault(x => x.Id == item.TenantId);
item.TenantName = t.Name;
var it= listParamItem.FirstOrDefault(x=>x.ParaCode == item.ParaCode&&x.ItemCode==item.ItemCode);
if (it != null)
{
item.ItemCodeName = it.ItemName;
}
}
return rtn;
}
/// <summary>
/// 增加参数
/// </summary>
@ -323,19 +394,19 @@ namespace Myshipping.Core.Service
[NonAction]
public async Task<List<DjyTenantParamValueOutput>> GetParaCodeWithValue(string[] paraCodes)
{
List<DjyTenantParamValueOutput> result = await _rep.AsQueryable()
.Filter(null, true)
.LeftJoin<DjyTenantParamValue>((t1, t2) => t1.ParaCode == t2.ParaCode)
.Where((t1, t2) => t2.TenantId == UserManager.TENANT_ID)
.WhereIF(paraCodes?.Any() == true, (t1, t2) => paraCodes.Contains(t1.ParaCode))
.Select((t1, t2) => new DjyTenantParamValueOutput()
{
ParaCode = t1.ParaCode,
ParaName = t1.ParaName,
ParaType = t1.Type,
ParaValue = t2.ItemCode
})
.ToListAsync();
List<DjyTenantParamValueOutput> result = await _rep.AsQueryable()
.Filter(null, true)
.LeftJoin<DjyTenantParamValue>((t1, t2) => t1.ParaCode == t2.ParaCode)
.Where((t1, t2) => t2.TenantId == UserManager.TENANT_ID)
.WhereIF(paraCodes?.Any() == true, (t1, t2) => paraCodes.Contains(t1.ParaCode))
.Select((t1, t2) => new DjyTenantParamValueOutput()
{
ParaCode = t1.ParaCode,
ParaName = t1.ParaName,
ParaType = t1.Type,
ParaValue = t2.ItemCode
})
.ToListAsync();
return result;
}
#endregion

@ -73,12 +73,7 @@ namespace Myshipping.Core.Service
/// 租户参数类别表查询输入参数
/// </summary>
public class QueryDJYTenantParamInput : PageInputBase
{
/// <summary>
/// 主键Id
/// </summary>
public virtual long Id { get; set; }
{
/// <summary>
/// 类别代码
/// </summary>
@ -94,15 +89,24 @@ namespace Myshipping.Core.Service
/// </summary>
public virtual string Type { get; set; }
}
/// <summary>
/// 租户参数值查询输入参数
/// </summary>
public class QueryTenantParamValueInput : PageInputBase
{
/// <summary>
/// 备注
/// 类别代码
/// </summary>
public virtual string Remark { get; set; }
public virtual string ParaCode { get; set; }
/// <summary>
/// 排序
/// 租户id
/// </summary>
public virtual int Sort { get; set; }
public long? TenantId { get; set; }
}
}

@ -26,7 +26,12 @@ namespace Myshipping.Core.Service
/// 业务大类
/// </summary>
public string Type { get; set; }
/// <summary>
/// 业务大类名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 备注
/// </summary>

@ -7,4 +7,45 @@
public string ParaType { get; set; }
public string ParaValue { get; set; }
}
/// <summary>
/// 列表输出
/// </summary>
public class DjyTenantParamValueListOutput
{
/// <summary>
/// 参数类别
/// </summary>
public string ParaCode { get; set; }
/// <summary>
/// 类别名称
/// </summary>
public string ParaName { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
/// <summary>
/// 参数值
/// </summary>
public string ItemCode { get; set; }
/// <summary>
/// 参数值名称
/// </summary>
public string ItemCodeName { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 排序
/// </summary>
public int? Sort { get; set; }
}
}

@ -0,0 +1,50 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title class="head-title">邮件模板</title>
</head>
<body style="margin: 0; padding: 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#EDF9F5" style="font-size: 12px;font-family: Arial;">
<tr>
<td height="30"></td>
</tr>
<tr>
<td>
<table class="out-table" border="0" cellpadding="8" cellspacing="0" width="800" bgcolor="#FFFFFF" align="center">
<tr>
<td>
<p>Dear Customer,</p>
</td>
</tr>
<tr>
<td>
<table class="base-table" border="1" cellpadding="8" cellspacing="0" width="100%" align="center" style="border-collapse: collapse;border-color: #ebeef5">
<tr>
<td class="billno-label" width="15%">提单号:</td>
<td class="billno-val" width="160">TEST123456</td>
</tr>
<tr>
<td class="carrier-label" width="15%">船公司:</td>
<td class="carrier-val" width="160">TEST123456</td>
</tr>
</table>
</td>
</tr>
<tr class="email-noreply">
<td>
<p class="notice1-val">请您按照更新的ETD在免箱期内用箱以免产生超期箱使费谢谢</p>
<p class="notice2-val">请不要回复此邮箱(自动发送邮箱无人处理邮件),如有疑问,请联系#opname#(邮箱#opemail#,电话#optel#),谢谢!</p>
<p class="notice3-val">货物到港后,贵司保证目的港收货人及时提取货物。因货物提取不及时/弃货产生的滞箱费、堆存费、港口费、货物处理费等概由贵司或者目的港收货人承担。如果我司对外承担了上述费用,则贵司应当无条件支付给我司,如果因此给我司造成了经济损失,则贵司还应当赔偿我司所有经济损失,包括但不限于律师费、诉讼费等等。一旦此票提箱出运就视为同意此条款,谢谢配合!</p>
<p class="notice-comp-val"></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Loading…
Cancel
Save