|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using Furion;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订舱舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingSlot", Order = 1)]
|
|
|
|
|
public class BookingSlotService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotBase> _repBase;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotCtn> _repCtn;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotStock> _repStock;
|
|
|
|
|
private readonly ILogger<BookingSlotService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
|
|
|
|
|
public BookingSlotService(SqlSugarRepository<BookingSlotBase> repBase,
|
|
|
|
|
SqlSugarRepository<BookingSlotCtn> repCtn,
|
|
|
|
|
SqlSugarRepository<BookingSlotStock> repStock,
|
|
|
|
|
ILogger<BookingSlotService> logger,
|
|
|
|
|
ISysCacheService cache)
|
|
|
|
|
{
|
|
|
|
|
_repBase = repBase;
|
|
|
|
|
_repCtn = repCtn;
|
|
|
|
|
_repStock = repStock;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 舱位
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询订舱舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingSlot/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] BookingSlotBasePageInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _repBase.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.SLOT_BOOKING_NO), u => u.SLOT_BOOKING_NO.Contains(input.SLOT_BOOKING_NO))
|
|
|
|
|
.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.PORTLOAD.Contains(input.PORTLOAD))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
|
|
|
|
|
.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.CTN_STAT), u => u.CTN_STAT.Contains(input.CTN_STAT))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VGM_RLT_STAT), u => u.VGM_RLT_STAT == input.VGM_RLT_STAT)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.SI_RLT_STAT), u => u.SI_RLT_STAT == input.SI_RLT_STAT)
|
|
|
|
|
.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))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
|
|
|
|
|
var result = entities.Adapt<SqlSugarPagedList<BookingSlotBaseListOutput>>();
|
|
|
|
|
|
|
|
|
|
return result.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存订舱舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/save")]
|
|
|
|
|
public async Task<BookingSlotBaseSaveDto> Save(BookingSlotBaseSaveDto input)
|
|
|
|
|
{
|
|
|
|
|
BookingSlotBase model = null;
|
|
|
|
|
if (input.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
model = _repBase.FirstOrDefault(x => x.Id == input.Id);
|
|
|
|
|
|
|
|
|
|
input.Adapt(model);
|
|
|
|
|
|
|
|
|
|
await _repBase.UpdateAsync(model);
|
|
|
|
|
|
|
|
|
|
await _repCtn.DeleteAsync(x => x.SLOT_ID == model.Id);
|
|
|
|
|
foreach (var ctn in input.CtnList)
|
|
|
|
|
{
|
|
|
|
|
var newCtn = ctn.Adapt<BookingSlotCtn>();
|
|
|
|
|
newCtn.SLOT_ID = model.Id;
|
|
|
|
|
await _repCtn.InsertAsync(newCtn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
model = input.Adapt<BookingSlotBase>();
|
|
|
|
|
await _repBase.InsertAsync(model);
|
|
|
|
|
foreach (var ctn in input.CtnList)
|
|
|
|
|
{
|
|
|
|
|
var newCtn = ctn.Adapt<BookingSlotCtn>();
|
|
|
|
|
newCtn.SLOT_ID = model.Id;
|
|
|
|
|
await _repCtn.InsertAsync(newCtn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await Detail(model.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除订舱舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/delete")]
|
|
|
|
|
public async Task Delete(long id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _repBase.FirstOrDefaultAsync(u => u.Id == id);
|
|
|
|
|
entity.IsDeleted = true;
|
|
|
|
|
await _repBase.UpdateAsync(entity);
|
|
|
|
|
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync();
|
|
|
|
|
foreach (var item in ctns)
|
|
|
|
|
{
|
|
|
|
|
item.IsDeleted = true;
|
|
|
|
|
}
|
|
|
|
|
await _repCtn.UpdateAsync(ctns);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱舱位
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingSlot/detail")]
|
|
|
|
|
public async Task<BookingSlotBaseSaveDto> Detail(long id)
|
|
|
|
|
{
|
|
|
|
|
var slotBase = await _repBase.FirstOrDefaultAsync(u => u.Id == id);
|
|
|
|
|
var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var rtn = slotBase.Adapt<BookingSlotBaseSaveDto>();
|
|
|
|
|
rtn.CtnList = ctns.Adapt<List<BookingSlotCtnSaveInput>>();
|
|
|
|
|
return rtn;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 库存
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 库存查询
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="input"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//[HttpGet("/BookingSlot/pageStock")]
|
|
|
|
|
//public async Task<dynamic> PageStock([FromQuery] BookingSlotBasePageInput input)
|
|
|
|
|
//{
|
|
|
|
|
// var query = await _repStock.AsQueryable()
|
|
|
|
|
// .ToListAsync();
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|