diff --git a/Myshipping.Application/Helper/FileAttachHelper.cs b/Myshipping.Application/Helper/FileAttachHelper.cs
index d37f1a68..a59d711c 100644
--- a/Myshipping.Application/Helper/FileAttachHelper.cs
+++ b/Myshipping.Application/Helper/FileAttachHelper.cs
@@ -306,5 +306,83 @@ namespace Myshipping.Application
return bookFilePath;
}
#endregion
+
+
+ #region 保存文件并返回文件完整路径
+ ///
+ /// 保存文件并返回文件完整路径
+ ///
+ /// 文件目录KEY
+ /// 文件二进制流
+ /// 批次号
+ /// 文件名称
+ /// 附件类型 bcfiles-BC文件 sofile-订舱附件
+ /// 返回文件完整路径
+ public static async Task SaveFileDirect(string fileDictKey, byte[] fileBytes, string batchNo,
+ string fileName,string attachFileType = "sofiles")
+ {
+ var logger = Log.CreateLogger(nameof(FileAttachHelper));
+
+ var fileCfg = App.GetOptions();
+
+ string fileRoot = string.Empty;
+
+ if (fileCfg != null)
+ {
+ if (!string.IsNullOrWhiteSpace(fileCfg.basePath))
+ {
+ fileRoot = fileCfg.basePath;
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(fileRoot))
+ fileRoot = App.WebHostEnvironment.WebRootPath;
+
+ string relativePath = fileCfg.relativePath;
+
+ if (!string.IsNullOrWhiteSpace(attachFileType))
+ relativePath += $"\\{attachFileType}";
+
+ if (!string.IsNullOrWhiteSpace(fileDictKey))
+ relativePath += $"\\{fileDictKey}";
+
+ relativePath += $"\\{DateTime.Now.ToString("yyyyMMddHHmmssfff")}";
+
+ string filePath = $"{fileRoot}\\{relativePath}";
+
+ string fileFullName = $"{filePath}\\{fileName}";
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ relativePath = relativePath.Replace("\\", "/");
+ filePath = filePath.Replace("\\", "/");
+ fileFullName = fileFullName.Replace("\\", "/");
+ }
+
+ logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath,
+ RuntimeInformation.OSDescription);
+
+ //预先创建目录
+ if (!Directory.Exists(filePath))
+ {
+ Directory.CreateDirectory(filePath);
+ }
+
+ await File.WriteAllBytesAsync(fileFullName, fileBytes);
+
+ string bookFilePath = string.Empty;
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("/", "\\/") + ".*").Value;
+ }
+ else
+ {
+ bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("\\", "\\\\") + ".*").Value;
+ }
+
+ return bookFilePath;
+ }
+ #endregion
}
}
diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
index 8fd355a1..73a14f24 100644
--- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
@@ -1,9 +1,13 @@
using Furion.DependencyInjection;
+using Furion.DistributedIDGenerator;
using Furion.DynamicApiController;
using Furion.EventBus;
+using Furion.Extensions;
using Furion.FriendlyException;
+using Furion.JsonSerialization;
using Mapster;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Myshipping.Application.Entity;
@@ -12,14 +16,17 @@ using Myshipping.Application.Service.BookingOrder.Dto;
using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Core;
using Myshipping.Core.Service;
+using Org.BouncyCastle.Asn1.Tsp;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Drawing.Imaging;
+using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-
+using Yitter.IdGenerator;
namespace Myshipping.Application
{
@@ -34,6 +41,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository _repStock;
private readonly SqlSugarRepository _repAllocation;
private readonly SqlSugarRepository _repAllocationCtn;
+ private readonly SqlSugarRepository _bookingFileRepository;
private readonly SqlSugarRepository _repBookingLog;
private readonly SqlSugarRepository _repBookingLogDetail;
@@ -44,6 +52,12 @@ namespace Myshipping.Application
private readonly IEventPublisher _publisher;
+ const string CONST_BC_FILE_CODE = "bc";
+ const string CONST_BC_FILE_NAME = "Booking Confirmation";
+
+ const string CONST_BC_NOTICE_FILE_CODE = "bc_notice";
+ const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice";
+
public BookingSlotService(SqlSugarRepository repBase,
SqlSugarRepository repCtn,
SqlSugarRepository repStock,
@@ -54,7 +68,8 @@ namespace Myshipping.Application
ISysCacheService cache,
IEventPublisher publisher,
SqlSugarRepository repAllocation,
- SqlSugarRepository repAllocationCtn)
+ SqlSugarRepository repAllocationCtn,
+ SqlSugarRepository bookingFileRepository)
{
_repBase = repBase;
_repCtn = repCtn;
@@ -70,6 +85,7 @@ namespace Myshipping.Application
_publisher = publisher;
_bookingfile = bookingfile;
+ _bookingFileRepository = bookingFileRepository;
}
#region 舱位
@@ -180,12 +196,99 @@ namespace Myshipping.Application
///
///
[HttpPost("/BookingSlot/ApiReceive"), AllowAnonymous, ApiUser]
- public async Task ApiReceive(BookingSlotBaseApiDto dto)
+ public async Task ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ try
+ {
+ BookingSlotBaseApiDto dto = JSON.Deserialize(jsonData);
+
+ DynameFileInfo bcFile = null;
+ DynameFileInfo bcNoticeFile = null;
+
+ if (file != null)
+ {
+ bcFile = new DynameFileInfo
+ {
+ FileBytes = file.ToByteArray(),
+ FileName = file.FileName
+ };
+ }
+
+ if (modifyFile != null)
+ {
+ bcNoticeFile = new DynameFileInfo
+ {
+ FileBytes = modifyFile.ToByteArray(),
+ FileName = modifyFile.FileName
+ };
+ }
+
+ var id = InnerApiReceive(dto, bcFile, bcNoticeFile).GetAwaiter().GetResult();
+
+ result.succ = true;
+ result.msg = "成功";
+ result.ext = id;
+ }
+ catch(Exception ex)
+ {
+ result.succ = false;
+ result.msg = $"失败,原因:{ex.Message}";
+ }
+
+ return result;
+ }
+ #endregion
+
+ ///
+ /// 舱位接收保存、取消接口
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("/BookingSlot/InnerApiReceive")]
+ public async Task InnerApiReceive(BookingSlotBaseApiDto dto, DynameFileInfo file = null, DynameFileInfo modifyFile = null)
{
long id = 0;
+
//接口方法直接调用save、delete等方法会报错,可能因为非token授权登录导致,故重写一遍保存、删除代码
if (dto.OpType == "add" || dto.OpType == "update" || dto.OpType == "del")
{
+ //翻译船公司
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.CARRIERID) && string.IsNullOrWhiteSpace(dto.DataObj.CARRIER))
+ {
+ var carrierInfo = _cache.GetAllCodeCarrier().GetAwaiter().GetResult()
+ .Where(t => t.Code.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)
+ || t.EnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)
+ || t.CnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+
+ if(carrierInfo != null)
+ {
+ dto.DataObj.CARRIER = carrierInfo.CnName?.Trim();
+ }
+ }
+
+ //翻译箱型代码
+ if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0 &&
+ dto.DataObj.CtnList.Any(t => string.IsNullOrWhiteSpace(t.CTNCODE)))
+ {
+ var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
+
+ dto.DataObj.CtnList.ForEach(t =>
+ {
+ if(!string.IsNullOrWhiteSpace(t.CTNALL) && string.IsNullOrWhiteSpace(t.CTNCODE))
+ {
+ var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
+ a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
+
+ if (ctnCode != null)
+ t.CTNCODE = ctnCode?.Code;
+ }
+ });
+ }
+
BookingSlotBase model = null;
if (dto.OpType == "add")
{
@@ -208,6 +311,41 @@ namespace Myshipping.Application
}
await InsLog("Add", model.Id, "新增舱位");
+
+ string batchNo = IDGen.NextID().ToString();
+
+ //处理附件
+ if (file != null)
+ {
+ _logger.LogInformation($"请求文件名:{file.FileName}");
+
+ var fileFullPath = await FileAttachHelper.SaveFileDirect(model.Id.ToString(), file.FileBytes, batchNo, file.FileName, "bcfiles");
+
+ _logger.LogInformation($"保存文件路径:{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, file.FileName, UserManager.TENANT_ID,
+ CONST_BC_FILE_CODE, CONST_BC_FILE_NAME).GetAwaiter();
+ }
+ }
+
+ if (modifyFile != null)
+ {
+ _logger.LogInformation($"请求文件名(变更文件):{modifyFile.FileName}");
+
+ var fileFullPath = await FileAttachHelper.SaveFileDirect(model.Id.ToString(), modifyFile.FileBytes, batchNo, modifyFile.FileName, "bcnoticefiles");
+
+ _logger.LogInformation($"保存文件路径(变更文件):{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, modifyFile.FileName, UserManager.TENANT_ID,
+ CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME).GetAwaiter();
+ }
+ }
}
else if (dto.OpType == "update")
{
@@ -269,7 +407,6 @@ namespace Myshipping.Application
return id;
}
- #endregion
///
/// 插入日志(仅显示一条文本信息)
@@ -704,5 +841,54 @@ namespace Myshipping.Application
return result.XnPagedResult();
}
#endregion
+
+ #region 异步写入附件表
+ ///
+ /// 异步写入附件表
+ ///
+ /// 订舱ID
+ /// 文件路径
+ /// 文件名
+ /// 租户ID
+ /// 附件类型代码
+ /// 附件类型名称
+ /// 附件模块代码
+ ///
+ [NonAction]
+ private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
+ string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation", string moudle = "BookingSlot")
+ {
+ /*
+ 直接将附件信息写入附件表
+ */
+ //EDI文件
+ var bookFile = new BookingFile
+ {
+ Id = YitIdHelper.NextId(),
+ FileName = fileName,
+ FilePath = FilePath,
+ TypeCode = fileTypeCode,
+ TypeName = fileTypeName,
+ BookingId = boookId,
+ TenantId = tenantId,
+ Moudle = moudle
+ };
+
+ await _bookingFileRepository.InsertAsync(bookFile);
+ }
+ #endregion
+ }
+
+ public class DynameFileInfo
+ {
+ ///
+ /// 文件名称
+ ///
+ public string FileName { get; set; }
+
+ ///
+ /// 文件二进制流
+ ///
+ public byte[] FileBytes { get; set; }
}
}
diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
index 02447b42..7d24dba0 100644
--- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using Myshipping.Application.Entity;
using Myshipping.Application.Event;
using Myshipping.Application.Service.BookingSlot.Dto;
@@ -9,7 +10,15 @@ namespace Myshipping.Application
{
public interface IBookingSlotService
{
- Task ApiReceive(BookingSlotBaseApiDto dto);
+ ///
+ /// 舱位接收保存、取消接口
+ ///
+ /// 请求详情
+ /// BC附件
+ /// BC变更附件
+ ///
+ Task ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null);
+
Task Detail(long id);
Task> GetAvailableSlots(BookingSlotBaseDto input);
@@ -55,5 +64,15 @@ namespace Myshipping.Application
///
///
Task Page(BookingSlotBasePageInput input);
+
+
+ ///
+ /// 舱位接收保存、取消接口
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task InnerApiReceive(BookingSlotBaseApiDto dto, DynameFileInfo file = null, DynameFileInfo modifyFile = null);
}
}
\ No newline at end of file
diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
index 63e5a08c..b8e8d242 100644
--- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
@@ -361,5 +361,6 @@ namespace Myshipping.Application
/// 订舱确认时间
///
public Nullable BookingConfirmDate { get; set; }
+
}
}
diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs
index b5a1d4b6..bf1a40cf 100644
--- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs
@@ -331,5 +331,10 @@ namespace Myshipping.Application
/// 订舱确认时间
///
public Nullable BookingConfirmDate { get; set; }
+
+ ///
+ /// 舱位主键
+ ///
+ public Nullable BookingSlotId { get; set; }
}
}
diff --git a/Myshipping.Application/Service/TaskManagePlat/EmailTemplate/BCEmailTemplate.html b/Myshipping.Application/Service/TaskManagePlat/EmailTemplate/BCEmailTemplate.html
index cd495343..9575f220 100644
--- a/Myshipping.Application/Service/TaskManagePlat/EmailTemplate/BCEmailTemplate.html
+++ b/Myshipping.Application/Service/TaskManagePlat/EmailTemplate/BCEmailTemplate.html
@@ -48,7 +48,7 @@
2023-12-01 |
- ETD: |
+ ETA: |
2023-12-01 |
diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
index a7d7c22e..a62f02f0 100644
--- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
@@ -677,8 +677,7 @@ namespace Myshipping.Application
var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == bcTaskInfo.PK_ID).ToList();
- if ((bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value>0)
- || (bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0))
+ if (bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
{
throw Oops.Oh($"当前BC任务已生成订舱或舱位,不能重复生成");
}
@@ -687,7 +686,16 @@ namespace Myshipping.Application
{
#region 推送舱位、推送订舱
//推送舱位
- var bookingSlotId = await GenerateBookingSlot(bcOrder, bcCtnList, fileList);
+ long bookingSlotId = 0;
+
+ if(bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0)
+ {
+ bookingSlotId = bcOrder.BOOKING_SLOT_ID.Value;
+ }
+ else
+ {
+ bookingSlotId = await GenerateBookingSlot(bcOrder, bcCtnList, fileList);
+ }
if (bookingSlotId > 0)
{
@@ -696,6 +704,7 @@ namespace Myshipping.Application
if (bookingOrderId > 0)
{
+
//更新库存
//_bookingSlotService.
var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcOrder.PK_ID);
@@ -722,6 +731,10 @@ namespace Myshipping.Application
}).ExecuteCommand();
+ var currBCOrder = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcEntity.PK_ID);
+
+ if (currBCOrder != null)
+ await GenerateSendEmail(currBCOrder);
var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID);
@@ -748,6 +761,10 @@ namespace Myshipping.Application
}
}
}
+ else
+ {
+ throw Oops.Oh($"生成舱位失败,舱位已存在");
+ }
#endregion
}
else if (model.GenerateMethod == "GEN_BOOKING")
@@ -957,52 +974,42 @@ namespace Myshipping.Application
});
}
- id = await _bookingSlotService.ApiReceive(slotModel);
+ var opt = App.GetOptions();
+ var dirAbs = opt.basePath;
+ if (string.IsNullOrEmpty(dirAbs))
+ {
+ dirAbs = App.WebHostEnvironment.WebRootPath;
+ }
- string batchNo = IDGen.NextID().ToString();
+ DynameFileInfo dynameFile = null;
+ DynameFileInfo dynameNoticeFile = null;
- //成功后写入附件
- if (id > 0)
+ if (taskFileList.Any(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString()))
{
- var opt = App.GetOptions();
- var dirAbs = opt.basePath;
- if (string.IsNullOrEmpty(dirAbs))
- {
- dirAbs = App.WebHostEnvironment.WebRootPath;
- }
+ var fileInfo = taskFileList.FirstOrDefault(t => t.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString());
+ var fileFullPath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
- taskFileList.ForEach(file =>
+ dynameFile = new DynameFileInfo
{
- if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC.ToString())
- {
- var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
+ FileBytes = File.ReadAllBytes(fileFullPath),
+ FileName = Path.GetFileName(fileFullPath)
+ };
+ }
- if (File.Exists(fileFullPath))
- {
- //如果确认文件读取成功
- var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo, false, "bcfiles", true).GetAwaiter().GetResult();
+ 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);
- //将格式单附件写入订舱的附件
- SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
- CONST_BC_FILE_CODE, CONST_BC_FILE_NAME).GetAwaiter();
- }
- }
- else if (file.FILE_CATEGORY == TaskFileCategoryEnum.BC_NOTICE.ToString())
- {
- var fileFullPath = Path.Combine(dirAbs, file.FILE_PATH);
+ dynameNoticeFile = new DynameFileInfo
+ {
+ FileBytes = File.ReadAllBytes(fileFullPath),
+ FileName = Path.GetFileName(fileFullPath)
+ };
+ }
- if (File.Exists(fileFullPath))
- {
- //如果确认文件读取成功
- var bookFilePath = FileAttachHelper.MoveFile(id.ToString(), fileFullPath, batchNo,false,"bcnoticefile",true).GetAwaiter().GetResult();
+ id = await _bookingSlotService.InnerApiReceive(slotModel, dynameFile, dynameNoticeFile);
- //将格式单附件写入订舱的附件
- SaveEDIFile(id, bookFilePath, new System.IO.FileInfo(bookFilePath).Name, taskBCInfo.TenantId.Value,
- CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME).GetAwaiter();
- }
- }
- });
- }
}
catch (Exception ex)
{
@@ -1364,11 +1371,11 @@ namespace Myshipping.Application
_logger.LogInformation($"提取当前公共邮箱的配置完成,id={publicMailAccount.Id}");
- string emailTitle = string.Empty;
+ string emailTitle = $"Booking Confirmation : {taskBCInfo.MBL_NO}";
string filePath = string.Empty;
//读取邮件模板并填充数据
- string emailHtml = GenerateSendEmailHtml(taskBCInfo).GetAwaiter().GetResult();
+ string emailHtml = GenerateSendEmailHtml(taskBCInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
_logger.LogInformation($"生成邮件BODY,结果:{emailHtml}");
@@ -1401,11 +1408,13 @@ namespace Myshipping.Application
Password = publicMailAccount.Password?.Trim(),
Server = publicMailAccount.SmtpServer?.Trim(),
Port = publicMailAccount.SmtpPort.HasValue ? publicMailAccount.SmtpPort.Value : 465,
- UseSSL = publicMailAccount.SmtpSSL.HasValue ? publicMailAccount.SmtpSSL.Value : true
+ UseSSL = publicMailAccount.SmtpSSL.HasValue ? publicMailAccount.SmtpSSL.Value : true,
+ Attaches = new List()
};
_logger.LogInformation($"生成请求邮件参数,结果:{JSON.Serialize(emailApiUserDefinedDto)}");
+
//推送邮件
var emailRlt = await PushEmail(emailApiUserDefinedDto, filePath);
@@ -1431,8 +1440,9 @@ namespace Myshipping.Application
/// 通过邮件模板生成HTML
///
/// BC任务详情
+ /// 当前租户全称
/// 返回生成的HTML
- public async Task GenerateSendEmailHtml(TaskBCInfo taskBCInfo)
+ public async Task GenerateSendEmailHtml(TaskBCInfo taskBCInfo,string tenantName)
{
string result = string.Empty;
@@ -1445,6 +1455,14 @@ namespace Myshipping.Application
{
string templatePath = App.Configuration["EmailTemplateFilePath"];
+ var opt = App.GetOptions();
+ var dirAbs = opt.basePath;
+ if (string.IsNullOrEmpty(dirAbs))
+ {
+ dirAbs = App.WebHostEnvironment.WebRootPath;
+ }
+ templatePath = $"{dirAbs}{templatePath}\\BCEmailTemplate.html";
+
string baseHtml = File.ReadAllText(templatePath);
if (string.IsNullOrWhiteSpace(baseHtml))
@@ -1504,6 +1522,27 @@ namespace Myshipping.Application
}
}
+ 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)
@@ -1610,6 +1649,7 @@ namespace Myshipping.Application
///
/// BC任务主键
/// 返回回执
+ [HttpGet("/TaskManageBC/SendEmail")]
public async Task SendEmail(string taskPKId)
{
if (string.IsNullOrWhiteSpace(taskPKId))
diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
index 15b6e031..74e4d6cd 100644
--- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
@@ -302,7 +302,7 @@ namespace Myshipping.Application
if (userTendInfo != null)
{
- taskInfo.IS_PUBLIC = 0;
+ taskInfo.IS_PUBLIC = 1;
}
}
else
@@ -350,7 +350,8 @@ namespace Myshipping.Application
if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE)
attachFileType = "bcfiles";
- var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, file.FileName,
+ var noExtensionFileName = Path.GetFileNameWithoutExtension(file.FileName);
+ var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, noExtensionFileName,
GetFileType(file.FileName), attachFileType);
if (!string.IsNullOrWhiteSpace(fileFullName))
@@ -380,7 +381,8 @@ namespace Myshipping.Application
if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE)
attachFileType = "bcnoticefiles";
- var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, modifyFile.FileName,
+ var noExtensionFileName = Path.GetFileNameWithoutExtension(modifyFile.FileName);
+ var fileFullName = await FileAttachHelper.SaveFile(taskInfo.PK_ID, bytes, batchNo, noExtensionFileName,
GetFileType(modifyFile.FileName), attachFileType);
if (!string.IsNullOrWhiteSpace(fileFullName))
@@ -674,6 +676,9 @@ namespace Myshipping.Application
bcInfo.TenantId = taskInfo.TenantId;
bcInfo.TenantName = taskInfo.TenantName;
+ if (info.Main.BCInfo.BookingSlotId.HasValue && info.Main.BCInfo.BookingSlotId.Value > 0)
+ bcInfo.BOOKING_SLOT_ID = info.Main.BCInfo.BookingSlotId.Value;
+
await _taskBCInfoRepository.InsertAsync(bcInfo);
//异步写入集装箱
@@ -1184,7 +1189,7 @@ namespace Myshipping.Application
_logger.LogInformation("任务台账权限范围 {list}", userlist);
var entities = await _taskBaseInfoRepository.AsQueryable()
- .Where(t=> userlist.Contains(t.CreatedUserId))
+ .Where(t=> userlist.Contains(t.CreatedUserId) || t.IS_PUBLIC == 1)
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.MBlNo), t => mblList.Contains(t.MBL_NO))
.WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.TaskRecvName), t => t.CreatedUserName.Contains(QuerySearch.TaskRecvName.Trim()))
.WhereIF(etdBegin != DateTime.MinValue, t => t.ETD.HasValue && t.ETD.Value >= etdBegin)
diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json
index f709c330..e3a4959e 100644
--- a/Myshipping.Web.Core/applicationconfig.json
+++ b/Myshipping.Web.Core/applicationconfig.json
@@ -56,7 +56,7 @@
},
"Cache": {
"CacheType": "RedisCache", // RedisCache
- "RedisConnectionString": "192.168.0.80:6379,password=,defaultDatabase=11"
+ "RedisConnectionString": "192.168.0.180:6379,password=,defaultDatabase=11"
},
"SnowId": {
"WorkerId": "1" // 取值范围0~63,默认1
@@ -130,5 +130,6 @@
"ServiceStatusOpenAuto": "0",
"DraftCompareUrl": "http://localhost:5110/api/TaskDraftCompare/ExcuteDraftCompare",
"GetDraftCompareUrl": "http://localhost:5110/api/TaskDraftCompare/DraftCompareResult",
- "DraftReadUrl": "http://localhost:5110/api/TaskDraftCompare/ExcuteDraftFileRead"
+ "DraftReadUrl": "http://localhost:5110/api/TaskDraftCompare/ExcuteDraftFileRead",
+ "EmailTemplateFilePath": "\\EmailTemplate"
}
\ No newline at end of file
diff --git a/Myshipping.Web.Entry/appsettings.json b/Myshipping.Web.Entry/appsettings.json
index 3cc8579c..c88c7a3c 100644
--- a/Myshipping.Web.Entry/appsettings.json
+++ b/Myshipping.Web.Entry/appsettings.json
@@ -37,5 +37,5 @@
}
},
"AllowedHosts": "*",
- "Urls": "http://localhost:5000"
+ "Urls": "http://localhost:5120"
}
\ No newline at end of file