新增订舱合约号管理

修改马士基API订舱
usertest
jianghaiqing 4 months ago
parent c1b25073f9
commit 727a626689

@ -1158,5 +1158,17 @@ public static class MultiLanguageConst
[Description("执行舱位失败,原因:{0}")]
public const string BookingSlotApiReceiveError = "BookingSlot_ApiReceive_Error";
/// <summary>
/// 合约数据不存在或已作废
/// </summary>
[Description("合约数据不存在或已作废")]
public const string BookingContractRecordDeletedOrNoExists = "BookingContract_RecordDeleted_NoExists";
/// <summary>
/// 合约作废未提供主键ID
/// </summary>
[Description("合约作废未提供主键ID")]
public const string BookingContractDeleteIdsNull = "BookingContract_Delete_IdsNull";
#endregion
}

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
/// 合约管理
/// </summary>
public class BookingContractNoManageDto
{
/// <summary>
/// 主键
/// </summary>
/// <example>358942162968645</example>
public long Id { get; set; }
/// <summary>
/// 合约号编号
/// </summary>
public string ContractNo { get; set; }
/// <summary>
/// 合约号名称
/// </summary>
public string ContractName { get; set; }
/// <summary>
/// 合约号备注
/// </summary>
public string ContractNote { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string LaneCode { get; set; }
/// <summary>
/// 航线中文
/// </summary>
public string LaneCName { get; set; }
/// <summary>
/// 目的港代码
/// </summary>
public string PodCode { get; set; }
/// <summary>
/// 船公司主键
/// </summary>
public long CarrierId { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
public string CarrierCode { get; set; }
/// <summary>
/// 合约方公司全称
/// </summary>
public string ContractPartyName { get; set; }
/// <summary>
/// 合约方公司代码
/// </summary>
public string ContractPartyCode { get; set; }
/// <summary>
/// 合约方联系人
/// </summary>
public string ContractLinkName { get; set; }
/// <summary>
/// 合约方联系邮件
/// </summary>
public string ContractLinkEmail { get; set; }
/// <summary>
/// 是否为本公司合约价格 1-是0-否
/// </summary>
public bool IsOurOwnPrice { get; set; } = true;
}
}

@ -0,0 +1,96 @@
using DS.Module.Core.Data;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 订舱合约号管理
/// </summary>
[SqlSugar.SugarTable("booking_contract_manage", "订舱合约号管理")]
public class BookingContractNoManage : BaseModelV2<long>
{
/// <summary>
/// 合约号编号
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约号编号", Length = 50, IsNullable = true)]
public string ContractNo { get; set; }
/// <summary>
/// 合约号名称
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约号名称", Length = 100, IsNullable = true)]
public string ContractName { get; set; }
/// <summary>
/// 合约号备注
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约号备注", Length = 150, IsNullable = true)]
public string ContractNote { get; set; }
/// <summary>
/// 航线代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线代码", Length = 40, IsNullable = true)]
public string LaneCode { get; set; }
/// <summary>
/// 航线中文
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线中文", Length = 50, IsNullable = true)]
public string LaneCName { get; set; }
/// <summary>
/// 目的港代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "目的港代码", Length = 20, IsNullable = true)]
public string PodCode { get; set; }
/// <summary>
/// 船公司主键
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "船公司主键", IsNullable = true)]
public long CarrierId { get; set; }
/// <summary>
/// 船公司代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "船公司代码", Length = 20, IsNullable = true)]
public string CarrierCode { get; set; }
/// <summary>
/// 合约方公司全称
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约方公司全称", Length = 200, IsNullable = true)]
public string ContractPartyName { get; set; }
/// <summary>
/// 合约方公司代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约方公司代码", Length = 64, IsNullable = true)]
public string ContractPartyCode { get; set; }
/// <summary>
/// 合约方联系人
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约方联系人", Length = 200, IsNullable = true)]
public string ContractLinkName { get; set; }
/// <summary>
/// 合约方联系邮件
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约方联系邮件", Length = 100, IsNullable = true)]
public string ContractLinkEmail { get; set; }
/// <summary>
/// 是否为本公司合约价格 1-是0-否
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "是否为本公司合约价格 1-是0-否", IsNullable = true,DefaultValue = "0")]
public bool IsOurOwnPrice { get; set; } = true;
}
}

@ -0,0 +1,59 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Interface
{
/// <summary>
/// 合约号管理
/// </summary>
public interface IBookingContractNoManageService
{
/// <summary>
/// 保存
/// </summary>
/// <param name="model">合约号详情</param>
/// <returns>返回回执</returns>
Task<DataResult<long>> Save(BookingContractNoManageDto model);
/// <summary>
/// 主键获取合约号详情
/// </summary>
/// <param name="Id">合约号主键</param>
/// <returns>返回合约号详情</returns>
Task<DataResult<BookingContractNoManageDto>> GetInfo(long Id);
/// <summary>
/// 检索合约列表
/// </summary>
/// <param name="queryItem">检索值可(模糊查询)</param>
/// <param name="top">返回记录最大行数</param>
/// <param name="carrier">船公司代码</param>
/// <param name="lane">航线代码</param>
/// <param name="lanecname">航线中文</param>
/// <param name="pod">目的港代码</param>
/// <returns>返回合约号详情列表</returns>
Task<DataResult<List<BookingContractNoManageDto>>> QuerytContractNoInfo(string queryItem, int top = 10, string carrier = "", string lane = "", string lanecname = "", string pod = "");
/// <summary>
/// 作废(可批量删除)
/// </summary>
/// <param name="Ids">合约号主键组</param>
/// <returns>返回回执</returns>
Task<DataResult<string>> Delete (long[] Ids);
/// <summary>
/// 合约号管理台账
/// </summary>
/// <param name="QuerySearch">查询条件</param>
/// <returns>返回台账列表</returns>
Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest QuerySearch);
}
}

@ -0,0 +1,261 @@
using DS.Module.Core;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DS.Module.Core.Extensions;
using Microsoft.Owin.Security.Provider;
using Microsoft.AspNetCore.Identity;
namespace DS.WMS.Core.Op.Method
{
public class BookingContractNoManageService: IBookingContractNoManageService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
public BookingContractNoManageService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
#region 保存
/// <summary>
/// 保存
/// </summary>
/// <param name="model">合约号详情</param>
/// <returns>返回回执</returns>
public async Task<DataResult<long>> Save(BookingContractNoManageDto model)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
BookingContractNoManage info = null;
try
{
if (model.Id > 0)
{
info = await tenantDb.Queryable<BookingContractNoManage>().FirstAsync(t => t.Id == model.Id);
//合约数据不存在或已作废
if (info == null)
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingContractRecordDeletedOrNoExists)));
info = model.Adapt<BookingContractNoManage>();
info.UpdateTime = DateTime.Now;
info.UpdateBy = long.Parse(user.UserId);
await tenantDb.Updateable<BookingContractNoManage>(info).IgnoreColumns(it => new
{
it.CreateTime,
it.CreateBy,
//it.CreatedUserName
}).ExecuteCommandAsync();
}
else
{
info = model.Adapt<BookingContractNoManage>();
await tenantDb.Insertable<BookingContractNoManage>(info).ExecuteReturnEntityAsync();
}
}
catch (Exception ex)
{
DataResult<long>.FailedData(info.Id, ex.Message);
}
return DataResult<long>.Success(info.Id);
}
#endregion
#region 主键获取合约号详情
/// <summary>
/// 主键获取合约号详情
/// </summary>
/// <param name="Id">合约号主键</param>
/// <returns>返回合约号详情</returns>
public async Task<DataResult<BookingContractNoManageDto>> GetInfo(long Id)
{
BookingContractNoManageDto model = null;
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
try
{
var info = await tenantDb.Queryable<BookingContractNoManage>().FirstAsync(t => t.Id == Id);
//合约数据不存在或已作废
if (info == null)
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingContractRecordDeletedOrNoExists)));
model = info.Adapt<BookingContractNoManageDto>();
}
catch (Exception ex)
{
DataResult<BookingContractNoManageDto>.FailedData(model, ex.Message);
}
return DataResult<BookingContractNoManageDto>.Success(model);
}
#endregion
#region 检索合约列表
/// <summary>
/// 检索合约列表
/// </summary>
/// <param name="queryItem">检索值可(模糊查询)</param>
/// <param name="top">返回记录最大行数</param>
/// <param name="carrier">船公司代码</param>
/// <param name="lane">航线代码</param>
/// <param name="lanecname">航线中文</param>
/// <param name="pod">目的港代码</param>
/// <returns>返回合约号详情列表</returns>
public async Task<DataResult<List<BookingContractNoManageDto>>> QuerytContractNoInfo(string queryItem, int top = 10, string carrier = "", string lane = "", string lanecname = "", string pod = "")
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var query = tenantDb.Queryable<BookingContractNoManage>();
if (!string.IsNullOrWhiteSpace(queryItem))
{
query = query.Where(t =>
t.ContractNo.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractName.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractNote.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractPartyCode.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractPartyName.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractLinkName.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) ||
t.ContractLinkEmail.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase)
);
}
if (!string.IsNullOrWhiteSpace(carrier))
{
query = query.Where(t => t.CarrierCode.Equals(carrier));
}
if (!string.IsNullOrWhiteSpace(lane))
{
query = query.Where(t => string.IsNullOrWhiteSpace(t.LaneCode) || t.LaneCode.Contains(lane));
}
if (!string.IsNullOrWhiteSpace(lanecname))
{
query = query.Where(t => string.IsNullOrWhiteSpace(t.LaneCName) || t.LaneCName.Contains(lanecname));
}
if (!string.IsNullOrWhiteSpace(pod))
{
query = query.Where(t => string.IsNullOrWhiteSpace(t.PodCode) || t.PodCode.Contains(pod));
}
var data = await query.Select<BookingContractNoManageDto>().OrderBy(a=>a.ContractNo).Take(top).ToListAsync();
if(data.Count > 0)
return DataResult<List<BookingContractNoManageDto>>.FailedData(data);
return DataResult<List<BookingContractNoManageDto>>.Success(data);
}
#endregion
#region 作废(可批量删除)
/// <summary>
/// 作废(可批量删除)
/// </summary>
/// <param name="Ids">合约号主键组</param>
/// <returns>返回回执</returns>
public async Task<DataResult<string>> Delete(long[] Ids)
{
try
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//没有提供需要作废的主键信息
if (Ids.Length == 0)
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingContractDeleteIdsNull)));
var list = tenantDb.Queryable<BookingContractNoManage>().Where(t => Ids.Contains(t.Id)).ToList();
if (list.Count != Ids.Length)
{
var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) =>
{
var currList = r.ToList();
if (r.Count() > 0)
return string.Empty;
return l.ToString();
}).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray());
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingContractRecordDeletedOrNoExists)));
}
list.ForEach(async entity =>
{
entity.Deleted = true;
entity.DeleteTime = DateTime.Now;
entity.DeleteBy = long.Parse(user.UserId);
//entity.UpdatedUserName = UserManager.Name;
await tenantDb.Updateable<BookingContractNoManage>().IgnoreColumns(it => new
{
it.CreateTime,
it.CreateBy,
//it.CreatedUserName
}).ExecuteCommandAsync();
});
}
catch (Exception ex)
{
//throw Oops.Bah($"作废约号参数异常,{ex.Message}");
DataResult<string>.FailedData(string.Empty, ex.Message);
}
return DataResult<string>.Success(string.Empty);
}
#endregion
#region 合约号管理台账
/// <summary>
/// 合约号管理台账
/// </summary>
/// <param name="QuerySearch">查询条件</param>
/// <returns>返回台账列表</returns>
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest QuerySearch)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(QuerySearch.QueryCondition);
var data = tenantDb.Queryable<BookingContractNoManage>()
.Where(whereList)
.Select<BookingContractNoManageDto>().ToQueryPage(QuerySearch.PageCondition);
return data;
}
#endregion
}
}

@ -0,0 +1,97 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Interface;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Crypto;
namespace DS.WMS.OpApi.Controllers
{
/// <summary>
/// 订舱约号管理
/// </summary>
public class BookingContractNoManageController : ApiController
{
private readonly IBookingContractNoManageService _bookingContractNoManageService;
public BookingContractNoManageController(IBookingContractNoManageService bookingContractNoManageService)
{
_bookingContractNoManageService = bookingContractNoManageService;
}
#region 保存
/// <summary>
/// 保存
/// </summary>
/// <param name="model">合约号详情</param>
/// <returns>返回回执</returns>
[HttpPost]
[Route("Save")]
public async Task<DataResult<long>> Save([FromBody] BookingContractNoManageDto model)
{
return await _bookingContractNoManageService.Save(model);
}
#endregion
#region 主键获取合约号详情
/// <summary>
/// 主键获取合约号详情
/// </summary>
/// <param name="Id">合约号主键</param>
/// <returns>返回合约号详情</returns>
[HttpGet]
[Route("GetInfo")]
public async Task<DataResult<BookingContractNoManageDto>> GetInfo([FromQuery] long Id)
{
return await _bookingContractNoManageService.GetInfo(Id);
}
#endregion
#region 检索合约列表
/// <summary>
/// 检索合约列表
/// </summary>
/// <param name="queryItem">检索值可(模糊查询)</param>
/// <param name="top">返回记录最大行数</param>
/// <param name="carrier">船公司代码</param>
/// <param name="lane">航线代码</param>
/// <param name="lanecname">航线中文</param>
/// <param name="pod">目的港代码</param>
/// <returns>返回合约号详情列表</returns>
[HttpGet]
[Route("QuerytContractNoInfo")]
public async Task<DataResult<List<BookingContractNoManageDto>>> QuerytContractNoInfo([FromQuery] string queryItem, [FromQuery] int top = 10,
[FromQuery] string carrier = "", [FromQuery] string lane = "", [FromQuery] string lanecname = "", [FromQuery] string pod = "")
{
return await _bookingContractNoManageService.QuerytContractNoInfo(queryItem, top, carrier, lane, lanecname, pod);
}
#endregion
#region 作废(可批量删除)
/// <summary>
/// 作废(可批量删除)
/// </summary>
/// <param name="Ids">合约号主键组</param>
/// <returns>返回回执</returns>
[HttpGet]
[Route("Delete")]
public async Task<DataResult<string>> Delete([FromBody] long[] Ids)
{
return await _bookingContractNoManageService.Delete(Ids);
}
#endregion
#region 合约号管理台账
/// <summary>
/// 合约号管理台账
/// </summary>
/// <param name="QuerySearch">查询条件</param>
/// <returns>返回台账列表</returns>
[HttpPost]
[Route("GetPage")]
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync([FromBody] PageRequest QuerySearch)
{
return await _bookingContractNoManageService.GetPageAsync(QuerySearch);
}
#endregion
}
}

@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.OpApi.Controllers
{
/// <summary>
/// 预订舱马士基API即期订舱
/// </summary>
public class SpaceBookingMSKAPISpotController : Controller
{
private readonly ISpaceBookingMSKSPOTAPIService _spaceBookingMSKSPOTAPIService;

@ -6,7 +6,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Code\PublishCopy\ds8-opapi</_PublishTargetUrl>
<History>True|2024-07-17T07:40:21.2550083Z||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||;</History>
<History>True|2024-07-17T08:13:32.9037697Z||;True|2024-07-17T15:40:21.2550083+08:00||;True|2024-07-17T14:03:08.1814323+08:00||;True|2024-07-15T13:43:42.6073130+08:00||;True|2024-07-15T11:53:40.6498579+08:00||;True|2024-07-15T11:53:03.1652559+08:00||;True|2024-07-15T11:42:33.0154478+08:00||;True|2024-07-15T10:20:03.3925876+08:00||;True|2024-07-15T10:13:28.1415352+08:00||;True|2024-07-08T14:33:12.6884426+08:00||;True|2024-07-08T09:56:58.4995696+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save