zhangxiaofeng 12 months ago
commit ac93552870

@ -0,0 +1,43 @@
using Myshipping.Core.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 船司订舱代理对应关系
/// </summary>
[SugarTable("booking_carrier_agent_relation")]
[Description("船司订舱代理对应关系")]
public class BookingCarrierAgentRelation : DBEntityTenant
{
/// <summary>
/// 订舱代理代码
/// </summary>
[Description("订舱代理代码")]
public string AgentCode { get; set; }
/// <summary>
/// 订舱代理
/// </summary>
[Description("订舱代理")]
public string Agent { get; set; }
/// <summary>
/// 船司代码
/// </summary>
[Description("船司代码")]
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
[Description("船司")]
public string Carrier { get; set; }
}
}

@ -0,0 +1,43 @@
using Myshipping.Core.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 船司场站对应关系
/// </summary>
[SugarTable("booking_carrier_yard_relation")]
[Description("船司场站对应关系")]
public class BookingCarrierYardRelation : DBEntityTenant
{
/// <summary>
/// 场站代码
/// </summary>
[Description("场站代码")]
public string YardCode { get; set; }
/// <summary>
/// 场站
/// </summary>
[Description("场站")]
public string Yard { get; set; }
/// <summary>
/// 船司代码
/// </summary>
[Description("船司代码")]
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
[Description("船司")]
public string Carrier { get; set; }
}
}

@ -0,0 +1,226 @@
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;
namespace Myshipping.Application
{
/// <summary>
/// 船司与场站、订舱代理等对应关系
/// </summary>
[ApiDescriptionSettings("Application", Name = "BookingCarrierRelation", Order = 1)]
public class BookingCarrierRelationService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<BookingCarrierYardRelation> _repCarrierYard;
private readonly SqlSugarRepository<BookingCarrierAgentRelation> _repCarrierAgent;
private readonly ILogger<BookingCarrierRelationService> _logger;
private readonly ISysCacheService _cache;
public BookingCarrierRelationService(SqlSugarRepository<BookingCarrierYardRelation> repCarrierYard,
SqlSugarRepository<BookingCarrierAgentRelation> repCarrierAgent,
ILogger<BookingCarrierRelationService> logger, ISysCacheService cache)
{
_repCarrierYard = repCarrierYard;
_repCarrierAgent = repCarrierAgent;
_logger = logger;
_cache = cache;
}
#region 船司场站对应关系
/// <summary>
/// 分页查询船司场站对应关系
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingCarrierRelation/pageYard")]
public async Task<SqlSugarPagedList<CarrierYardRelationSaveOutput>> PageYard([FromQuery] CarrierYardRelationQueryInput input)
{
var entities = await _repCarrierYard.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(input.CarrierCode), u => u.CarrierCode.Contains(input.CarrierCode))
.WhereIF(!string.IsNullOrEmpty(input.Carrier), u => u.Carrier.Contains(input.Carrier))
.WhereIF(!string.IsNullOrEmpty(input.YardCode), u => u.YardCode.Contains(input.YardCode))
.WhereIF(!string.IsNullOrEmpty(input.Yard), u => u.Yard.Contains(input.Yard))
.ToPagedListAsync(input.PageNo, input.PageSize);
var rtn = entities.Adapt<SqlSugarPagedList<CarrierYardRelationSaveOutput>>();
return rtn;
}
/// <summary>
/// 保存船司场站对应关系
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingCarrierRelation/saveYard")]
public async Task<long> SaveYard(CarrierYardRelationSaveInput input)
{
BookingCarrierYardRelation model = null;
if (input.Id > 0)
{
if (_repCarrierYard.Count(x => x.Carrier == input.Carrier && x.Yard == input.Yard && x.Id != input.Id) > 0)
{
throw Oops.Bah($"已存在相同代码:{input.Carrier} {input.Yard}");
}
model = _repCarrierYard.FirstOrDefault(x => x.Id == input.Id);
input.Adapt(model);
await _repCarrierYard.UpdateAsync(model);
}
else
{
if (_repCarrierYard.Count(x => x.Carrier == input.Carrier && x.Yard == input.Yard && x.Id != input.Id) > 0)
{
throw Oops.Bah($"已存在相同代码:{input.Carrier} {input.Yard}");
}
model = input.Adapt<BookingCarrierYardRelation>();
await _repCarrierYard.InsertAsync(model);
}
return model.Id;
}
/// <summary>
/// 删除船司场站对应关系
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("/BookingCarrierRelation/deleteYard")]
public async Task DeleteYard(long id)
{
var entity = await _repCarrierYard.FirstOrDefaultAsync(u => u.Id == id);
entity.IsDeleted = true;
await _repCarrierYard.UpdateAsync(entity);
}
/// <summary>
/// 根据船司代码获取可以选择的场站
/// </summary>
/// <returns></returns>
[HttpGet("/BookingCarrierRelation/ListYardByCarrier")]
public async Task<dynamic> ListYardByCarrier(string carrierCode)
{
return await _repCarrierYard.AsQueryable()
.Where(u => u.CarrierCode == carrierCode)
.Select(x => new
{
x.Yard,
x.YardCode
})
.ToListAsync();
}
#endregion
#region 船司订舱代理对应关系
/// <summary>
/// 分页查询船司订舱代理对应关系
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingCarrierRelation/pageAgent")]
public async Task<SqlSugarPagedList<CarrierAgentRelationSaveOutput>> PageAgent([FromQuery] CarrierAgentRelationQueryInput input)
{
var entities = await _repCarrierAgent.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(input.CarrierCode), u => u.CarrierCode.Contains(input.CarrierCode))
.WhereIF(!string.IsNullOrEmpty(input.Carrier), u => u.Carrier.Contains(input.Carrier))
.WhereIF(!string.IsNullOrEmpty(input.AgentCode), u => u.AgentCode.Contains(input.AgentCode))
.WhereIF(!string.IsNullOrEmpty(input.Agent), u => u.Agent.Contains(input.Agent))
.ToPagedListAsync(input.PageNo, input.PageSize);
var rtn = entities.Adapt<SqlSugarPagedList<CarrierAgentRelationSaveOutput>>();
return rtn;
}
/// <summary>
/// 保存船司订舱代理对应关系
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingCarrierRelation/saveAgent")]
public async Task<long> SaveAgent(CarrierAgentRelationSaveInput input)
{
BookingCarrierAgentRelation model = null;
if (input.Id > 0)
{
if (_repCarrierAgent.Count(x => x.Carrier == input.Carrier && x.Agent == input.Agent && x.Id != input.Id) > 0)
{
throw Oops.Bah($"已存在相同代码:{input.Carrier} {input.Agent}");
}
model = _repCarrierAgent.FirstOrDefault(x => x.Id == input.Id);
input.Adapt(model);
await _repCarrierAgent.UpdateAsync(model);
}
else
{
if (_repCarrierAgent.Count(x => x.Carrier == input.Carrier && x.Agent == input.Agent && x.Id != input.Id) > 0)
{
throw Oops.Bah($"已存在相同代码:{input.Carrier} {input.Agent}");
}
model = input.Adapt<BookingCarrierAgentRelation>();
await _repCarrierAgent.InsertAsync(model);
}
return model.Id;
}
/// <summary>
/// 删除船司订舱代理对应关系
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("/BookingCarrierRelation/deleteAgent")]
public async Task DeleteAgent(long id)
{
var entity = await _repCarrierAgent.FirstOrDefaultAsync(u => u.Id == id);
entity.IsDeleted = true;
await _repCarrierAgent.UpdateAsync(entity);
}
/// <summary>
/// 根据船司代码获取可以选择的订舱代理
/// </summary>
/// <returns></returns>
[HttpGet("/BookingCarrierRelation/ListAgentByCarrier")]
public async Task<dynamic> ListAgentByCarrier(string carrierCode)
{
return await _repCarrierAgent.AsQueryable()
.Where(u => u.CarrierCode == carrierCode)
.Select(x => new
{
x.Agent,
x.AgentCode
})
.ToListAsync();
}
#endregion
}
}

@ -0,0 +1,99 @@
using Myshipping.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 基础dto
/// </summary>
public class CarrierAgentRelationDto
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// 订舱代理代码
/// </summary>
public string AgentCode { get; set; }
/// <summary>
/// 订舱代理
/// </summary>
public string Agent { get; set; }
/// <summary>
/// 船司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
public string Carrier { get; set; }
}
/// <summary>
/// 查询dto
/// </summary>
public class CarrierAgentRelationQueryInput : PageInputBase
{
/// <summary>
/// 订舱代理代码
/// </summary>
public string AgentCode { get; set; }
/// <summary>
/// 订舱代理
/// </summary>
public string Agent { get; set; }
/// <summary>
/// 船司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
public string Carrier { get; set; }
}
/// <summary>
/// 保存dto
/// </summary>
public class CarrierAgentRelationSaveInput : CarrierAgentRelationDto
{
}
/// <summary>
/// 保存dto
/// </summary>
public class CarrierAgentRelationSaveOutput : CarrierAgentRelationDto
{
/// <summary>
/// 创建时间
/// </summary>
public virtual string CreatedTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public virtual string UpdatedTime { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
public virtual string CreatedUserName { get; set; }
/// <summary>
/// 修改者名称
/// </summary>
public virtual string UpdatedUserName { get; set; }
}
}

@ -0,0 +1,99 @@
using Myshipping.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 基础dto
/// </summary>
public class CarrierYardRelationDto
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// 场站代码
/// </summary>
public string YardCode { get; set; }
/// <summary>
/// 场站
/// </summary>
public string Yard { get; set; }
/// <summary>
/// 船司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
public string Carrier { get; set; }
}
/// <summary>
/// 查询dto
/// </summary>
public class CarrierYardRelationQueryInput : PageInputBase
{
/// <summary>
/// 场站代码
/// </summary>
public string YardCode { get; set; }
/// <summary>
/// 场站
/// </summary>
public string Yard { get; set; }
/// <summary>
/// 船司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 船司
/// </summary>
public string Carrier { get; set; }
}
/// <summary>
/// 保存dto
/// </summary>
public class CarrierYardRelationSaveInput : CarrierYardRelationDto
{
}
/// <summary>
/// 保存dto
/// </summary>
public class CarrierYardRelationSaveOutput : CarrierYardRelationDto
{
/// <summary>
/// 创建时间
/// </summary>
public virtual string CreatedTime { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public virtual string UpdatedTime { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
public virtual string CreatedUserName { get; set; }
/// <summary>
/// 修改者名称
/// </summary>
public virtual string UpdatedUserName { get; set; }
}
}
Loading…
Cancel
Save