|
|
|
|
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.Core.Entity;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 船期手工维护模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings(Name = "DjyVesselInfo", Order = 1)]
|
|
|
|
|
public class DjyVesselInfoService : IDjyVesselInfoService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<DjyVesselInfo> _rep;
|
|
|
|
|
private readonly ISysCacheService _sysCacheService;
|
|
|
|
|
public DjyVesselInfoService(SqlSugarRepository<DjyVesselInfo> rep, ISysCacheService sysCacheService)
|
|
|
|
|
{
|
|
|
|
|
_sysCacheService = sysCacheService;
|
|
|
|
|
_rep = rep;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="KeyWord"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DjyVesselInfoService/GetListPage")]
|
|
|
|
|
public async Task<dynamic> GetListPage([FromQuery] string KeyWord)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return await _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).
|
|
|
|
|
WhereIF(!string.IsNullOrWhiteSpace(KeyWord), x => x.Vessel.Contains(KeyWord)
|
|
|
|
|
|| x.CARRIER.Contains(KeyWord) || x.Voyno.Contains(KeyWord) || x.PortLoading.Contains(KeyWord) || x.PortTransit.Contains(KeyWord) ||
|
|
|
|
|
x.PortDischarge.Contains(KeyWord) || x.VoynoInside.Contains(KeyWord)
|
|
|
|
|
).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DjyVesselInfoService/Delete")]
|
|
|
|
|
public async Task Delete([FromQuery] long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var entity = await _rep.FirstOrDefaultAsync(u => Ids.Contains(u.Id));
|
|
|
|
|
await _rep.DeleteAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/DjyVesselInfoService/AddOrUpdate")]
|
|
|
|
|
public async Task<long> AddOrUpdate(DjyVesselInfoDto dto)
|
|
|
|
|
{
|
|
|
|
|
if (dto == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("请传入数据!");
|
|
|
|
|
}
|
|
|
|
|
if (dto.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<DjyVesselInfo>();
|
|
|
|
|
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<DjyVesselInfo>();
|
|
|
|
|
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
return dto.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/DjyVesselInfoService/GetList")]
|
|
|
|
|
public async Task<dynamic> GetList([FromQuery] string CarrierID, string KeyWord = "")
|
|
|
|
|
{
|
|
|
|
|
//获取船名
|
|
|
|
|
List<CodeVessel> list = await _sysCacheService.GetAllCodeVessel();
|
|
|
|
|
|
|
|
|
|
var tlist = await _rep.AsQueryable().Filter(null, true).WhereIF(!string.IsNullOrWhiteSpace(KeyWord), x => x.Vessel.StartsWith(KeyWord.ToUpper())).
|
|
|
|
|
Where(x => x.CARRIERID == CarrierID && x.ETD > DateTime.Now.AddDays(-7) && x.TenantId == UserManager.TENANT_ID).
|
|
|
|
|
Select(x => new
|
|
|
|
|
{
|
|
|
|
|
Voyno = x.Voyno,
|
|
|
|
|
VoynoInside = x.VoynoInside,
|
|
|
|
|
Vessel = x.Vessel,
|
|
|
|
|
ETD = x.ETD==null?"":Convert.ToDateTime(x.ETD).ToString("yyyy-MM-dd"),
|
|
|
|
|
ATD = x.ATD == null ? "" : Convert.ToDateTime(x.ATD).ToString("yyyy-MM-dd"),
|
|
|
|
|
}).Take(20).
|
|
|
|
|
ToListAsync();
|
|
|
|
|
|
|
|
|
|
var ves = tlist.Select(x => x.Vessel).ToList();
|
|
|
|
|
var all = list.WhereIF(!string.IsNullOrWhiteSpace(KeyWord), x => x.Name.StartsWith(KeyWord.ToUpper())).
|
|
|
|
|
Select(x => new
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Voyno = "",
|
|
|
|
|
VoynoInside = "",
|
|
|
|
|
Vessel = x.Name,
|
|
|
|
|
ETD = "",
|
|
|
|
|
ATD = "",
|
|
|
|
|
}).Take(20).ToList();
|
|
|
|
|
foreach (var item in ves)
|
|
|
|
|
{
|
|
|
|
|
all.RemoveAll(x => x.Vessel.StartsWith(item));
|
|
|
|
|
}
|
|
|
|
|
return tlist.Union<dynamic>(all);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|