|
|
|
@ -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<IMappingPortService>();
|
|
|
|
|
_mappingCarrierService = _serviceProvider.GetRequiredService<IMappingCarrierService>();
|
|
|
|
|
_codeCountryService = _serviceProvider.GetRequiredService<ICodeCountryService>();
|
|
|
|
|
_codeLanesService = _serviceProvider.GetRequiredService<ICodeLanesService>();
|
|
|
|
|
|
|
|
|
|
bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" });
|
|
|
|
|
}
|
|
|
|
@ -1450,7 +1453,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <param name="fileTypeName">附件类型名称</param>
|
|
|
|
|
/// <param name="moudle">附件模块代码</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
|
|
|
|
|
private async Task<DataResult<string>> 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<string>.Success(string.Empty);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -1572,7 +1577,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
|
|
|
|
|
public async Task<DataResult<string>> 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<string>.Success(string.Empty);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -2772,9 +2779,9 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <param name="bcTargetDto">新舱位详情</param>
|
|
|
|
|
/// <param name="slotId">舱位ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task MeasureDiffCautionTask(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId)
|
|
|
|
|
public async Task<DataResult<string>> MeasureDiffCautionTask(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
return DataResult<string>.Success(string.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -2789,6 +2796,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 导入舱位
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入舱位
|
|
|
|
|
/// </summary>
|
|
|
|
@ -2796,8 +2804,656 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> 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<TempFileOptions>().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<BookingSlotBase, List<BookingSlotCtn>> data = new(rowCount);
|
|
|
|
|
//List<BookingSlotBase> 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>();
|
|
|
|
|
|
|
|
|
|
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<BookingSlotBase>()
|
|
|
|
|
.Where(x => noList.Contains(x.SlotBookingNo))
|
|
|
|
|
.Select(x => x.SlotBookingNo)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
List<object> list = new List<object>();
|
|
|
|
|
result.ext = list;
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
if (existsNoList.Contains(item.Key.SlotBookingNo))
|
|
|
|
|
{
|
|
|
|
|
list.Add(new
|
|
|
|
|
{
|
|
|
|
|
IsSuccess = false,
|
|
|
|
|
FailReason = "此订舱编号已存在",
|
|
|
|
|
SlotBookingNo = item.Key.SlotBookingNo
|
|
|
|
|
});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await tenantDb.Insertable<BookingSlotBase>(item.Key).ExecuteReturnEntityAsync();
|
|
|
|
|
var id = item.Key.Id;
|
|
|
|
|
if (item.Value.Any())
|
|
|
|
|
{
|
|
|
|
|
item.Value.ForEach(x =>
|
|
|
|
|
{
|
|
|
|
|
x.SlotId = id;
|
|
|
|
|
});
|
|
|
|
|
await tenantDb.Insertable<BookingSlotCtn>(item.Value).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
list.Add(new
|
|
|
|
|
{
|
|
|
|
|
IsSuccess = true,
|
|
|
|
|
SlotBookingNo = item.Key.SlotBookingNo
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
|
|
|
|
|
var group = data.Keys.Where(x =>
|
|
|
|
|
!existsNoList.Contains(x.SlotBookingNo)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.Vessel)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.Voyno)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.ContractNo)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.BookingSlotType)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.CarrierCode)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.PortLoadCode)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.PortDischargeCode))
|
|
|
|
|
.GroupBy(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Vessel,
|
|
|
|
|
x.Voyno,
|
|
|
|
|
x.CarrierCode,
|
|
|
|
|
x.BookingSlotType,
|
|
|
|
|
x.PortDischargeCode,
|
|
|
|
|
x.PortLoadCode,
|
|
|
|
|
x.ContractNo
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in group)
|
|
|
|
|
{
|
|
|
|
|
await _bookingSlotStockService.BookingSlotStock(new BookingSlotStockUpdateModel
|
|
|
|
|
{
|
|
|
|
|
BookingSlotType = item.Key.BookingSlotType,
|
|
|
|
|
CarrierCode = item.Key.CarrierCode,
|
|
|
|
|
ContractNo = item.Key.ContractNo,
|
|
|
|
|
Vessel = item.Key.Vessel,
|
|
|
|
|
Voyno = item.Key.Voyno,
|
|
|
|
|
PortLoadId = item.Key.PortLoadCode,
|
|
|
|
|
PortDischargeId = item.Key.PortDischargeCode,
|
|
|
|
|
TenantId = long.Parse(user.TenantId)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Error, $"导入舱位异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"导入舱位异常,原因:{ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导出舱位为Excel
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出舱位为Excel
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input">请求参数</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<string>> ExportOrder(BookingSlotBasePageInput input)
|
|
|
|
|
{
|
|
|
|
|
ISugarQueryable<BookingSlotBase> select = null;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
// 箱型筛选
|
|
|
|
|
string[] ctnCodeArr = null;
|
|
|
|
|
if (!string.IsNullOrEmpty(input.CTN_STAT))
|
|
|
|
|
{
|
|
|
|
|
ctnCodeArr = input.CTN_STAT.Split(',');
|
|
|
|
|
select = tenantDb.Queryable<BookingSlotBase>().InnerJoin<BookingSlotCtn>((u, c) => u.Id == c.SlotId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
select = tenantDb.Queryable<BookingSlotBase>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
select = select.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SlotBookingNo.Contains(input.SLOT_BOOKING_NO))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SlotBookingNo.Contains(input.SLOT_BOOKING_NO))
|
|
|
|
|
.WhereIF(input.STATUS == 1, u => !u.IsCancellation)
|
|
|
|
|
.WhereIF(input.STATUS == 2, u => u.IsCancellation)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VESSEL), u => u.Vessel.Contains(input.VESSEL))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VOYNO), u => u.Voyno.Contains(input.VOYNO))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.PORTLOAD), u => u.PORTLOAD.Contains(input.PORTLOAD))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.PORTDISCHARGE), u => u.PORTDISCHARGE.Contains(input.PORTDISCHARGE))
|
|
|
|
|
|
|
|
|
|
.WhereIF(input.ETD_START.HasValue, u => u.ETD >= input.ETD_START.Value)
|
|
|
|
|
.WhereIF(input.ETD_END.HasValue, u => u.ETD < input.ETD_END.Value.AddDays(1))
|
|
|
|
|
.WhereIF(input.ETA_START.HasValue, u => u.ETA >= input.ETA_START.Value)
|
|
|
|
|
.WhereIF(input.ETA_END.HasValue, u => u.ETA < input.ETA_END.Value.AddDays(1))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CreatedUserName), u => u.CreatedUserName.Contains(input.CreatedUserName))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.UpdatedUserName), u => u.UpdatedUserName.Contains(input.UpdatedUserName))
|
|
|
|
|
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CONTRACT_NO), u => u.CONTRACT_NO.Contains(input.CONTRACT_NO))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.SI_RLT_STAT), u => u.SI_RLT_STAT == input.SI_RLT_STAT)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VGM_RLT_STAT), u => u.VGM_RLT_STAT == input.VGM_RLT_STAT)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CARRIAGE_TYPE), u => u.CARRIAGE_TYPE == input.CARRIAGE_TYPE)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.BOOKING_SLOT_TYPE), u => u.BOOKING_SLOT_TYPE == input.BOOKING_SLOT_TYPE)
|
|
|
|
|
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
|
|
|
|
|
.WhereIF(input.WEEK_AT != null, u => u.WEEK_AT == input.WEEK_AT)
|
|
|
|
|
|
|
|
|
|
//.WhereIF(isEnableCustomerAuthority, u => SqlFunc.Subqueryable<BookingSlotAllocation>()
|
|
|
|
|
// .Where(x => x.BOOKING_SLOT_ID == u.Id)
|
|
|
|
|
// .NotAny()
|
|
|
|
|
// || SqlFunc.Subqueryable<BookingSlotAllocation>()
|
|
|
|
|
// .Where(x => x.BOOKING_SLOT_ID == u.Id
|
|
|
|
|
// && userList.Contains((long)x.CreatedUserId)
|
|
|
|
|
// || userListStr.Contains(x.OPID)
|
|
|
|
|
// || userListStr.Contains(x.SALEID)
|
|
|
|
|
// || userListStr.Contains(x.DOCID)
|
|
|
|
|
// || userListStr.Contains(x.CUSTSERVICEID))
|
|
|
|
|
// .Any())
|
|
|
|
|
// 标签筛选
|
|
|
|
|
.WhereIF(input.LabelIdArray != null && input.LabelIdArray.Length > 0,
|
|
|
|
|
u => SqlFunc.Subqueryable<BookingLabelAllocation>()
|
|
|
|
|
.Where(x => x.BusinessId == u.Id && input.LabelIdArray.Contains(x.LabelId))
|
|
|
|
|
.Any());
|
|
|
|
|
|
|
|
|
|
if (ctnCodeArr != null && ctnCodeArr.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
var tempSelect = select as ISugarQueryable<BookingSlotBase, BookingSlotCtn>;
|
|
|
|
|
tempSelect.Where((u, c) => ctnCodeArr.Contains(c.CTNCODE));
|
|
|
|
|
}
|
|
|
|
|
//var sql = select.OrderByDescending(u => u.CreatedTime).ToSqlString();
|
|
|
|
|
|
|
|
|
|
var entities = await select.OrderByDescending(u => u.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var data = entities.Adapt<List<BookingSlotBaseListOutput>>();
|
|
|
|
|
|
|
|
|
|
var slotIds = entities.Select(x => x.Id);
|
|
|
|
|
|
|
|
|
|
if (slotIds.Any())
|
|
|
|
|
{
|
|
|
|
|
// 查询舱位绑定的销售信息,赋值到舱位对象中
|
|
|
|
|
List<BookingSlotSaleInfoDto> allocationInfoList = await _repAllocation.AsQueryable()
|
|
|
|
|
.Where(x => slotIds.Contains(x.BOOKING_SLOT_ID))
|
|
|
|
|
.Select(x => new BookingSlotSaleInfoDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BOOKING_ID = x.BOOKING_ID,
|
|
|
|
|
BOOKING_SLOT_ID = x.BOOKING_SLOT_ID,
|
|
|
|
|
CUSTOMERID = x.CUSTOMERID,
|
|
|
|
|
CUSTOMERNAME = x.CUSTOMERNAME,
|
|
|
|
|
CUSTSERVICEID = x.CUSTSERVICEID,
|
|
|
|
|
CUSTSERVICE = x.CUSTSERVICE,
|
|
|
|
|
SALEID = x.SALEID,
|
|
|
|
|
SALE = x.SALE,
|
|
|
|
|
OPID = x.OPID,
|
|
|
|
|
OP = x.OP,
|
|
|
|
|
DOCID = x.DOCID,
|
|
|
|
|
DOC = x.DOC,
|
|
|
|
|
BUSINESS = x.BUSINESS,
|
|
|
|
|
BUSINESSID = x.BUSINESSID,
|
|
|
|
|
SALE_TIME = x.SALE_TIME,
|
|
|
|
|
SHIPPER = x.SHIPPER,
|
|
|
|
|
GOODSNAME = x.GOODSNAME,
|
|
|
|
|
SELLING_PRICE = x.SELLING_PRICE
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
if (allocationInfoList.Any())
|
|
|
|
|
{
|
|
|
|
|
// 判断是否启用了委托单位查看控制权限
|
|
|
|
|
var tenantParamList = await _cache.GetAllTenantParam();
|
|
|
|
|
var isEnableCustomerAuthority = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID
|
|
|
|
|
&& x.ParaCode == TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY)?.ItemCode == "YES";
|
|
|
|
|
List<long> userList = null;
|
|
|
|
|
List<string> userListStr = null;
|
|
|
|
|
if (isEnableCustomerAuthority)
|
|
|
|
|
{
|
|
|
|
|
userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
|
|
|
|
|
if (userList == null || userList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
isEnableCustomerAuthority = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
userListStr = userList.Select(x => x.ToString()).ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var saleInfoGroup = allocationInfoList.GroupBy(x => x.BOOKING_SLOT_ID);
|
|
|
|
|
foreach (var item in saleInfoGroup)
|
|
|
|
|
{
|
|
|
|
|
if (isEnableCustomerAuthority)
|
|
|
|
|
{
|
|
|
|
|
// 遍历销售信息,如果销售信息中的“销售、操作、单证、客服、创建人”中不在当前登陆人的权限范围,则隐藏客户信息
|
|
|
|
|
foreach (BookingSlotSaleInfoDto saleInfoItem in item)
|
|
|
|
|
{
|
|
|
|
|
if (!userList.Contains(saleInfoItem.CreatedUserId ?? 0)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.OPID)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.DOCID)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.SALEID)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.CUSTSERVICEID))
|
|
|
|
|
{
|
|
|
|
|
saleInfoItem.CUSTOMERID = 0;
|
|
|
|
|
saleInfoItem.CUSTOMERNAME = "--";
|
|
|
|
|
saleInfoItem.OPID = "";
|
|
|
|
|
saleInfoItem.OP = "--";
|
|
|
|
|
saleInfoItem.DOCID = "";
|
|
|
|
|
saleInfoItem.DOC = "--";
|
|
|
|
|
saleInfoItem.SALEID = "";
|
|
|
|
|
saleInfoItem.SALE = "--";
|
|
|
|
|
saleInfoItem.SHIPPER = "--";
|
|
|
|
|
saleInfoItem.GOODSNAME = "--";
|
|
|
|
|
saleInfoItem.CUSTSERVICEID = "";
|
|
|
|
|
saleInfoItem.CUSTSERVICE = "--";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var slot = data.FirstOrDefault(x => x.Id == item.Key);
|
|
|
|
|
if (slot != null)
|
|
|
|
|
{
|
|
|
|
|
slot.BookingSlotSaleInfoList = item.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询舱位绑定的标签信息,赋值到舱位对象中
|
|
|
|
|
var labelCacheList = await _bookingLabelService.List(1);
|
|
|
|
|
var labelAllocationList = await _repLabelAllocation.AsQueryable()
|
|
|
|
|
.Where(x => slotIds.Contains(x.BusinessId))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
if (labelAllocationList.Any())
|
|
|
|
|
{
|
|
|
|
|
var labelInfoGroup = labelAllocationList.GroupBy(x => x.BusinessId);
|
|
|
|
|
foreach (var item in labelInfoGroup)
|
|
|
|
|
{
|
|
|
|
|
var slot = data.FirstOrDefault(x => x.Id == item.Key);
|
|
|
|
|
if (slot != null)
|
|
|
|
|
{
|
|
|
|
|
slot.LabelList = item.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
var labelCache = labelCacheList.FirstOrDefault(l => l.Id == x.LabelId);
|
|
|
|
|
if (labelCache != null)
|
|
|
|
|
{
|
|
|
|
|
return new BookingLabelBaseDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.LabelId,
|
|
|
|
|
Name = labelCache.Name,
|
|
|
|
|
Color = labelCache.Color,
|
|
|
|
|
Scope = labelCache.Scope
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}).ToList();
|
|
|
|
|
slot.LabelList.RemoveAll(x => x == null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<PrintTemplateOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, "upload/printtemplate/舱位信息导出模板.xlsx");
|
|
|
|
|
if (!File.Exists(fileAbsPath))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("舱位导出模板文件不存在");
|
|
|
|
|
}
|
|
|
|
|
var fs = new FileStream(fileAbsPath, FileMode.Open);
|
|
|
|
|
var excelwork = new XSSFWorkbook(fs);
|
|
|
|
|
var sheet = excelwork.GetSheet("导出");
|
|
|
|
|
|
|
|
|
|
var rowIndex = 1;
|
|
|
|
|
var dateStr = "yyyy-MM-dd";
|
|
|
|
|
var dateTimeStr = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
foreach (BookingSlotBaseListOutput item in data)
|
|
|
|
|
{
|
|
|
|
|
var row = sheet.GetRow(rowIndex);
|
|
|
|
|
if (row == null)
|
|
|
|
|
{
|
|
|
|
|
row = sheet.CreateRow(rowIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= 35; i++)
|
|
|
|
|
{
|
|
|
|
|
var cell = row.GetCell(i);
|
|
|
|
|
if (cell == null)
|
|
|
|
|
{
|
|
|
|
|
cell = row.CreateCell(i);
|
|
|
|
|
}
|
|
|
|
|
var value = i switch
|
|
|
|
|
{
|
|
|
|
|
0 => item.SLOT_BOOKING_NO,
|
|
|
|
|
1 => item.CARRIER,
|
|
|
|
|
2 => item.VESSEL,
|
|
|
|
|
3 => item.VOYNO,
|
|
|
|
|
4 => item.CONTRACT_NO,
|
|
|
|
|
5 => item.BOOKING_SLOT_TYPE_NAME,
|
|
|
|
|
6 => item.ETD?.ToString(dateTimeStr),
|
|
|
|
|
7 => item.ETA?.ToString(dateTimeStr),
|
|
|
|
|
8 => item.BOOKING_PARTY,
|
|
|
|
|
9 => item.IS_CANCELLATION ? "是" : "",
|
|
|
|
|
10 => item.PLACERECEIPT,
|
|
|
|
|
11 => item.PLACEDELIVERY,
|
|
|
|
|
12 => item.PORTLOAD,
|
|
|
|
|
13 => item.PORTDISCHARGE,
|
|
|
|
|
14 => item.CTN_STAT,
|
|
|
|
|
15 => item.WEEK_AT?.ToString(),
|
|
|
|
|
16 => item.SI_CUT_DATE?.ToString(dateTimeStr),
|
|
|
|
|
17 => item.VGM_SUBMISSION_CUT_DATE?.ToString(dateTimeStr),
|
|
|
|
|
18 => item.CY_CUT_DATE?.ToString(dateTimeStr),
|
|
|
|
|
19 => item.MANIFEST_CUT_DATE?.ToString(dateTimeStr),
|
|
|
|
|
20 => item.MDGF_CUT_DATE?.ToString(dateTimeStr),
|
|
|
|
|
21 => item.LANENAME,
|
|
|
|
|
22 => item.DETENSION_FREE_DAYS?.ToString(),
|
|
|
|
|
23 => item.CreatedTime?.ToString(dateTimeStr),
|
|
|
|
|
24 => item.VGM_RLT_STAT,
|
|
|
|
|
25 => item.SI_RLT_STAT,
|
|
|
|
|
26 => item.TAKE_CTN_RLT_STAT,
|
|
|
|
|
27 => item.RETURN_CTN_RLT_STAT,
|
|
|
|
|
28 => item.NOMINATION_RLT_STAT,
|
|
|
|
|
29 => item.AMENDMENT_RLT_STAT,
|
|
|
|
|
30 => item.CANCELLATION_RLT_STAT,
|
|
|
|
|
31 => item.DISCHARGE_FULL_RLT_STAT,
|
|
|
|
|
32 => item.GATE_OUTFULL_RLT_STAT,
|
|
|
|
|
33 => "",
|
|
|
|
|
34 => item.REMARK,
|
|
|
|
|
35 => item.PRICE_CALCULATION_DATE?.ToString(dateStr),
|
|
|
|
|
_ => ""
|
|
|
|
|
};
|
|
|
|
|
cell.SetCellValue(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.BookingSlotSaleInfoList != null && item.BookingSlotSaleInfoList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int m = 0; m < item.BookingSlotSaleInfoList.Count; m++)
|
|
|
|
|
{
|
|
|
|
|
BookingSlotSaleInfoDto saleItem = item.BookingSlotSaleInfoList[m];
|
|
|
|
|
var row2 = sheet.GetRow(rowIndex);
|
|
|
|
|
if (row2 == null)
|
|
|
|
|
{
|
|
|
|
|
row2 = sheet.CreateRow(rowIndex);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 36; i <= 42; i++)
|
|
|
|
|
{
|
|
|
|
|
var cell2 = row2.GetCell(i);
|
|
|
|
|
if (cell2 == null)
|
|
|
|
|
{
|
|
|
|
|
cell2 = row2.CreateCell(i);
|
|
|
|
|
}
|
|
|
|
|
var value2 = i switch
|
|
|
|
|
{
|
|
|
|
|
36 => saleItem.CUSTOMERNAME,
|
|
|
|
|
37 => saleItem.CUSTSERVICE,
|
|
|
|
|
38 => saleItem.SALE,
|
|
|
|
|
39 => saleItem.SHIPPER,
|
|
|
|
|
40 => saleItem.GOODSNAME,
|
|
|
|
|
41 => saleItem.SELLING_PRICE?.ToString(),
|
|
|
|
|
42 => saleItem.SALE_TIME?.ToString(dateTimeStr),
|
|
|
|
|
_ => ""
|
|
|
|
|
};
|
|
|
|
|
cell2.SetCellValue(value2);
|
|
|
|
|
}
|
|
|
|
|
// 如果不是最后一条数据,创建新行
|
|
|
|
|
if (m < item.BookingSlotSaleInfoList.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fileFullPath = Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions<TempFileOptions>().Path);//服务器路径
|
|
|
|
|
if (!Directory.Exists(fileFullPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
var fileName = $"舱位导出_{DateTime.Now.ToString("yyyyMMdd-HHmmss")}.xlsx";//名称
|
|
|
|
|
var filestream = new FileStream(Path.Combine(fileFullPath, fileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
|
|
|
|
excelwork.Write(filestream);
|
|
|
|
|
|
|
|
|
|
await Task.Delay(2000);
|
|
|
|
|
//return HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
return fileName;*/
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
Task<DataResult<List<BookingSlotBaseWithCtnDto>>> IBookingSlotService.GetAvailableSlots(BookingSlotBaseDto slotInput, List<long> slotIdListInput, PageWithTotal pageInfo)
|
|
|
|
|
{
|
|
|
|
|