diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeLanesService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeLanesService.cs
index 5d04c90e..d987c385 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeLanesService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeLanesService.cs
@@ -74,4 +74,16 @@ public interface ICodeLanesService
///
public DataResult BatchDelCodeLanes(IdModel req);
+ ///
+ /// 获取航线基础数据
+ ///
+ /// 是否从缓存提取 true-从缓存读取 false-从数据库读取
+ /// 返回箱型基础数据列表
+ Task>> GetAllList(bool isFromCache = true);
+
+ ///
+ /// 加载到缓存
+ ///
+ ///
+ Task LoadCache();
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeLanesService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeLanesService.cs
index d182e247..6fbd6f8a 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeLanesService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeLanesService.cs
@@ -6,8 +6,10 @@ using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
+using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.Code.Method;
@@ -18,6 +20,8 @@ public class CodeLanesService:ICodeLanesService
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
+ private readonly ISysCacheService _sysCacheService;
+
///
///
///
@@ -28,6 +32,7 @@ public class CodeLanesService:ICodeLanesService
db = _serviceProvider.GetRequiredService();
user = _serviceProvider.GetRequiredService();
saasService = _serviceProvider.GetRequiredService();
+ _sysCacheService = _serviceProvider.GetRequiredService();
}
public DataResult> GetListByPage(PageRequest request)
@@ -53,7 +58,7 @@ public class CodeLanesService:ICodeLanesService
var data = req.Adapt();
var entity = db.Insertable(data).ExecuteReturnEntity();
-
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
@@ -63,6 +68,7 @@ public class CodeLanesService:ICodeLanesService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@@ -101,7 +107,7 @@ public class CodeLanesService:ICodeLanesService
var data = req.Adapt();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
-
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
@@ -111,6 +117,7 @@ public class CodeLanesService:ICodeLanesService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@@ -150,6 +157,7 @@ public class CodeLanesService:ICodeLanesService
}
tenantDb.Insertable(list).ExecuteCommand();
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
@@ -173,6 +181,65 @@ public class CodeLanesService:ICodeLanesService
{
tenantDb.Deleteable(list).ExecuteCommand();
}
+ _sysCacheService.RemoveCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8").GetAwaiter().GetResult();
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
+
+ ///
+ /// 获取航线基础数据
+ ///
+ /// 是否从缓存提取 true-从缓存读取 false-从数据库读取
+ /// 返回箱型基础数据列表
+ public async Task>> GetAllList(bool isFromCache = true)
+ {
+ List list = new List();
+
+ bool isLoad = false;
+
+ if (isFromCache)
+ {
+ var rlt = await _sysCacheService.GetAllCommonCodeFromCache(Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8");
+
+ if (rlt.Succeeded)
+ return rlt;
+
+ isLoad = true;
+ }
+
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ list = tenantDb.Queryable()
+ .Select()
+ .Where(a => a.Status == StatusEnum.Enable).ToList();
+
+ if (list.Count > 0)
+ {
+ if (isLoad)
+ {
+ await _sysCacheService.SetCommonCode(JsonConvert.SerializeObject(list), Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8");
+ }
+
+ return DataResult>.Success(list);
+ }
+
+ return DataResult>.FailedData(list);
+ }
+
+ ///
+ /// 加载到缓存
+ ///
+ ///
+ public async Task LoadCache()
+ {
+ var rlt = await GetAllList(false);
+
+ if (rlt.Succeeded)
+ {
+ await _sysCacheService.SetCommonCode(JsonConvert.SerializeObject(rlt.Data), Sys.Method.SysCacheCategoryEnum.CommonCodeLanes, "DS8");
+
+ return DataResult.Successed(MultiLanguageConst.LoadCacheSucc);
+ }
+
+ return DataResult.Failed(MultiLanguageConst.LoadCacheFailDataNull);
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs
index 948d11d4..aed5a3c1 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotService.cs
@@ -162,7 +162,7 @@ namespace DS.WMS.Core.Op.Interface
/// 舱位主键
/// 请求批次号用来区分对应的哪个批次任务
///
- Task PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo);
+ Task> PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo);
///
/// 估算差异重要提醒
@@ -201,5 +201,12 @@ namespace DS.WMS.Core.Op.Interface
/// 生成订舱订单请求
/// 返回回执
Task MergeCreateBookingOrder(BookingGenerateDto model);
+
+ ///
+ /// 导出舱位为Excel
+ ///
+ /// 请求参数
+ ///
+ Task> ExportOrder(BookingSlotBasePageInput input);
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
index ef8965ca..a589150b 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
@@ -50,6 +50,7 @@ using DS.Module.Core.Extensions;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.WMS.Core.TaskPlat.Dtos;
+using NPOI.XSSF.UserModel;
namespace DS.WMS.Core.Op.Method
{
@@ -76,7 +77,8 @@ namespace DS.WMS.Core.Op.Method
private readonly ICodePortService _codePortService;
private readonly IMappingPortService _mappingPortService;
private readonly ICodeCountryService _codeCountryService;
-
+ private readonly ICodeLanesService _codeLanesService;
+
private readonly string bcCompareUrl;
@@ -129,6 +131,7 @@ namespace DS.WMS.Core.Op.Method
_mappingPortService = _serviceProvider.GetRequiredService();
_mappingCarrierService = _serviceProvider.GetRequiredService();
_codeCountryService = _serviceProvider.GetRequiredService();
+ _codeLanesService = _serviceProvider.GetRequiredService();
bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" });
}
@@ -1450,7 +1453,7 @@ namespace DS.WMS.Core.Op.Method
/// 附件类型名称
/// 附件模块代码
///
- private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
+ private async Task> SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation", string moudle = "BookingSlot")
{
/*
@@ -1469,6 +1472,8 @@ namespace DS.WMS.Core.Op.Method
};
await tenantDb.Insertable(newFile).ExecuteCommandAsync();
+
+ return DataResult.Success(string.Empty);
}
#endregion
@@ -1572,7 +1577,7 @@ namespace DS.WMS.Core.Op.Method
/// 请求批次号用来区分对应的哪个批次任务
///
[NonAction]
- public async Task PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
+ public async Task> PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
@@ -1651,6 +1656,8 @@ namespace DS.WMS.Core.Op.Method
{
//new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,未获取到比对结果", $"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,未获取到比对结果", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
+
+ return DataResult.Success(string.Empty);
}
#endregion
@@ -2772,9 +2779,9 @@ namespace DS.WMS.Core.Op.Method
/// 新舱位详情
/// 舱位ID
///
- public async Task MeasureDiffCautionTask(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId)
+ public async Task> MeasureDiffCautionTask(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId)
{
- return;
+ return DataResult.Success(string.Empty);
}
///
@@ -2789,6 +2796,7 @@ namespace DS.WMS.Core.Op.Method
return null;
}
+ #region 导入舱位
///
/// 导入舱位
///
@@ -2796,8 +2804,656 @@ namespace DS.WMS.Core.Op.Method
/// 返回回执
public async Task ImportSlotFromFile(IFormFile file)
{
- return null;
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ try
+ {
+ result.succ = false;
+ if (file == null)
+ {
+ result.msg = "附件不能为空";
+ return result;
+ }
+
+ FileInfo fileInfo = new FileInfo(file.FileName);
+ if (fileInfo.Extension != ".xlsx")
+ {
+ result.msg = "请上传指定模板文件";
+ return result;
+ }
+ var tempDic = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions().Path, DateTime.Now.Ticks.ToString());
+ Directory.CreateDirectory(tempDic);
+ var filePath = Path.Combine(tempDic, file.FileName);
+
+ using (var stream = File.Create(filePath))
+ {
+ await file.CopyToAsync(stream);
+ }
+ using FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
+ var readbook = new XSSFWorkbook(fs);
+ var sheet = readbook.GetSheet("导入");
+ if (sheet == null)
+ {
+ result.msg = "内容为空";
+ return result;
+ }
+
+ var rowCount = sheet.LastRowNum;
+ if (rowCount <= 1)
+ {
+ result.msg = "内容为空";
+ return result;
+ }
+
+ Dictionary> data = new(rowCount);
+ //List data = new(rowCount);
+
+ var cacheMappCarrier = _mappingCarrierService.GetAllList().GetAwaiter().GetResult().Data;
+ var cachePort = _codePortService.GetAllList().GetAwaiter().GetResult().Data;
+ var cacheLane = _codeLanesService.GetAllList().GetAwaiter().GetResult().Data;
+ var cacheCtnCode = _codeCtnService.GetAllList().GetAwaiter().GetResult().Data;
+
+ BookingSlotBase lastSlot = null;
+ for (int i = 1; i < rowCount; i++)
+ {
+ var row = sheet.GetRow(i);
+ if (row == null)
+ {
+ continue;
+ }
+ if (string.IsNullOrWhiteSpace(row.GetCell(0)?.StringCellValue))
+ {
+ if (string.IsNullOrWhiteSpace(row.GetCell(23)?.ToString()))
+ {
+ continue;
+ }
+
+ BookingSlotCtn ctnExt = new();
+ // 解析箱信息
+ for (int n = 23; n <= 24; n++)
+ {
+ var cell = row.GetCell(n);
+ if (cell == null) continue;
+
+ var value = cell.ToString();
+
+ if (string.IsNullOrWhiteSpace(value)) continue;
+
+ switch (n)
+ {
+ case 23:
+ {
+ ctnExt.CtnAll = value;
+ ctnExt.CtnCode = cacheCtnCode.FirstOrDefault(x => x.Name == value)?.Code;
+ break;
+ }
+ case 24:
+ {
+ if (int.TryParse(value, out int temp)) ctnExt.CtnNum = temp; break;
+ }
+ }
+ }
+ if (!string.IsNullOrEmpty(ctnExt.CtnCode) && data.TryGetValue(lastSlot, out var ctnList))
+ {
+ ctnList.Add(ctnExt);
+ }
+ continue;
+ }
+ var slot = new BookingSlotBase();
+
+ // 解析舱位信息
+ for (int n = 0; n <= 22; n++)
+ {
+ var cell = row.GetCell(n);
+ if (cell == null) continue;
+
+ //var value = cell.StringCellValue;
+ var value = cell.ToString().Trim();
+
+ if (string.IsNullOrWhiteSpace(value)) continue;
+
+ switch (n)
+ {
+ case 0: slot.SlotBookingNo = value; break;
+ case 1: slot.CarrierCode = value; break;
+ case 2: slot.Vessel = value; break;
+ case 3: slot.Voyno = value; break;
+ case 4: slot.ContractNo = value; break;
+ case 5: slot.BookingSlotTypeName = value; break;
+ case 6:
+ slot.ETD = cell.DateCellValue; break;
+ //{
+ // if (DateTime.TryParse(value, out DateTime temp)) slot.ETD = temp; break;
+ //}
+ case 7:
+ slot.ETA = cell.DateCellValue; break;
+ //{
+ // if (DateTime.TryParse(value, out DateTime temp)) slot.ETA = temp; break;
+ //}
+ case 8: slot.BookingParty = value; break;
+ case 9: slot.PlaceReceipt = value; break;
+ case 10: slot.PlaceDelivery = value; break;
+ case 11: slot.PortLoadCode = value; break;
+ case 12: slot.PortDischargeCode = value; break;
+ case 13:
+ {
+ if (int.TryParse(value, out int temp)) slot.WeekAt = temp; break;
+ }
+ case 14:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.SI_CUT_DATE = temp; break;
+ slot.SICutDate = cell.DateCellValue; break;
+ }
+ case 15:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.VGM_SUBMISSION_CUT_DATE = temp; break;
+ slot.VGMSubmissionCutDate = cell.DateCellValue; break;
+ }
+ case 16:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.CY_CUT_DATE = temp; break;
+ slot.CYCutDate = cell.DateCellValue; break;
+ }
+ case 17:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.MANIFEST_CUT_DATE = temp; break;
+ slot.ManifestCutDate = cell.DateCellValue; break;
+ }
+ case 18:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.MDGF_CUT_DATE = temp; break;
+ slot.MDGFCutDate = cell.DateCellValue; break;
+ }
+ case 19: slot.LaneName = value; break; //
+ case 20:
+ {
+ if (int.TryParse(value, out int temp)) slot.DetensionFreeDays = temp; break;
+ }
+ case 21:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.CreatedTime = temp; break;
+ slot.CreateTime = cell.DateCellValue.Value; break;
+ }
+ case 22:
+ {
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.PRICE_CALCULATION_DATE = temp; break;
+ slot.PriceCalculationDate = cell.DateCellValue; break;
+ }
+ default: break;
+ }
+ }
+ // 特殊处理
+ if (!string.IsNullOrWhiteSpace(slot.CarrierCode)) slot.Carrier = cacheCarrier.FirstOrDefault(x => x.EnName == slot.CarrierCode)?.CnName;
+ if (!string.IsNullOrWhiteSpace(slot.PortLoadCode)) slot.PortLoad = cachePort.FirstOrDefault(x => x.EdiCode == slot.PortLoadCode)?.PortName;
+ if (!string.IsNullOrWhiteSpace(slot.PortDischargeCode)) slot.PortDischarge = cachePort.FirstOrDefault(x => x.EdiCode == slot.PortDischargeCode)?.PortName;
+ if (!string.IsNullOrWhiteSpace(slot.LaneName)) slot.LaneCode = cacheLane.FirstOrDefault(x => x.LaneName == slot.LaneName)?.Code;
+ if (!string.IsNullOrWhiteSpace(slot.BookingSlotTypeName))
+ slot.BookingSlotType = slot.BookingSlotTypeName switch
+ {
+ "合约订舱" => "CONTRACT_ORDER",
+ "SPOT订舱" => "SPOT_ORDER",
+ _ => null
+ };
+
+ var ctns = new List();
+
+ BookingSlotCtn ctn = new();
+ // 解析箱信息
+ for (int n = 23; n <= 24; n++)
+ {
+ var cell = row.GetCell(n);
+ if (cell == null) continue;
+
+ var value = cell.ToString();
+
+ if (string.IsNullOrWhiteSpace(value)) continue;
+
+ switch (n)
+ {
+ case 23:
+ {
+ ctn.CtnAll = value;
+ ctn.CtnCode = cacheCtnCode.FirstOrDefault(x => x.Name == value)?.Code;
+ break;
+ }
+ case 24:
+ {
+ if (int.TryParse(value, out int temp)) ctn.CtnNum = temp; break;
+ }
+ }
+ }
+ if (!string.IsNullOrEmpty(ctn.CtnCode))
+ {
+ ctns.Add(ctn);
+ }
+
+ data.Add(slot, ctns);
+ lastSlot = slot;
+ }
+
+ // 判断是否已经存在
+ var noList = data.Select(x => x.Key).Select(x => x.SlotBookingNo).ToList();
+ var existsNoList = await tenantDb.Queryable()
+ .Where(x => noList.Contains(x.SlotBookingNo))
+ .Select(x => x.SlotBookingNo)
+ .ToListAsync();
+
+ List