|
|
|
@ -20,6 +20,7 @@ using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -54,6 +55,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingLog> _repBookingLog;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLogDetail> _repBookingLogDetail;
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingfile;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<BookingSlotService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
@ -63,7 +65,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly IDjyCustomerService _djyCustomerService;
|
|
|
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
|
private readonly IBookingLabelService _bookingLabelService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const string CONST_BC_FILE_CODE = "bc";
|
|
|
|
|
const string CONST_BC_FILE_NAME = "Booking Confirmation";
|
|
|
|
@ -93,11 +95,12 @@ namespace Myshipping.Application
|
|
|
|
|
SqlSugarRepository<BookingSlotCompare> bookingSlotCompareRepository,
|
|
|
|
|
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
|
|
|
|
|
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IBookingValueAddedService bookingValueAddedService,
|
|
|
|
|
SqlSugarRepository<BookingOrder> repBookingOrder,
|
|
|
|
|
SqlSugarRepository<BookingLabelAllocation> repLabelAllocation,
|
|
|
|
|
IBookingLabelService bookingLabelService)
|
|
|
|
|
IBookingLabelService bookingLabelService,
|
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate)
|
|
|
|
|
{
|
|
|
|
|
_repBase = repBase;
|
|
|
|
|
_repCtn = repCtn;
|
|
|
|
@ -121,8 +124,7 @@ namespace Myshipping.Application
|
|
|
|
|
_repBookingOrder = repBookingOrder;
|
|
|
|
|
_repLabelAllocation = repLabelAllocation;
|
|
|
|
|
_bookingLabelService = bookingLabelService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_repPrintTemplate = repPrintTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 舱位
|
|
|
|
@ -322,7 +324,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/SaveDataInList")]
|
|
|
|
|
public async Task<BookingSlotBaseSaveOutput> SaveDataInList(BookingSlotBaseSaveDataInListInputDto input)
|
|
|
|
|
public async Task SaveDataInList(BookingSlotBaseSaveDataInListInputDto input)
|
|
|
|
|
{
|
|
|
|
|
long slotBaseId = 0;
|
|
|
|
|
if (input.SlotBase != null)
|
|
|
|
@ -443,7 +445,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await Detail(slotBaseId);
|
|
|
|
|
//return await Detail(slotBaseId);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱舱位
|
|
|
|
@ -1836,7 +1838,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导入舱位
|
|
|
|
|
#region 导入导出
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入舱位
|
|
|
|
|
/// </summary>
|
|
|
|
@ -1866,6 +1868,267 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导出舱位为Excel
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/BookingSlot/PrintOrder")]
|
|
|
|
|
public async Task<string> PrintOrder(BookingSlotBasePageInput input)
|
|
|
|
|
{
|
|
|
|
|
ISugarQueryable<BookingSlotBase> select = null;
|
|
|
|
|
|
|
|
|
|
// 箱型筛选
|
|
|
|
|
string[] ctnCodeArr = null;
|
|
|
|
|
if (!string.IsNullOrEmpty(input.CTN_STAT))
|
|
|
|
|
{
|
|
|
|
|
ctnCodeArr = input.CTN_STAT.Split(',');
|
|
|
|
|
select = _repBase.AsQueryable().InnerJoin<BookingSlotCtn>((u, c) => u.Id == c.SLOT_ID);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
select = _repBase.AsQueryable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
select = select.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO))
|
|
|
|
|
.WhereIF(input.STATUS == 1, u => !u.IS_CANCELLATION)
|
|
|
|
|
.WhereIF(input.STATUS == 2, u => u.IS_CANCELLATION)
|
|
|
|
|
.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(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,
|
|
|
|
|
SALE_TIME = x.SALE_TIME,
|
|
|
|
|
SHIPPER = x.SHIPPER,
|
|
|
|
|
GOODSNAME = x.GOODSNAME,
|
|
|
|
|
SELLING_PRICE = x.SELLING_PRICE
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var saleInfoGroup = allocationInfoList.GroupBy(x => x.BOOKING_SLOT_ID);
|
|
|
|
|
foreach (var item in saleInfoGroup)
|
|
|
|
|
{
|
|
|
|
|
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.GetSheetAt(0);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
//return HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
|
|
|
|
return fileName;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 生成订舱订单
|
|
|
|
|