合约管理:合约与航线改为一对多的关系

usertest
zhangxiaofeng 3 months ago
parent 4d2828f70a
commit bcb795fc18

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Op.Dtos
{
@ -32,20 +28,6 @@ namespace DS.WMS.Core.Op.Dtos
/// </summary>
public string ContractNote { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string LaneCode { get; set; }
/// <summary>
/// 航线中文
/// </summary>
public string LaneCName { get; set; }
/// <summary>
/// 航线主键
/// </summary>
public Nullable<long> LaneId { get; set; }
/// <summary>
/// 目的港代码
@ -101,5 +83,26 @@ namespace DS.WMS.Core.Op.Dtos
/// 是否为本公司合约价格 1-是0-否
/// </summary>
public bool IsOurOwnPrice { get; set; } = true;
/// <summary>
/// 关联的航线列表
/// </summary>
public List<BookingContractNoManageLane>? LaneList { get; set; }
}
/// <summary>
/// 合约管理台账查询Dto
/// </summary>
public class BookingContractNoManageQueryDto
{
/// <summary>
/// 航线主键
/// </summary>
public long? LaneId { get; set; }
/// <summary>
/// 航线代码
/// </summary>
public string? LaneCode { get; set; }
}
}

@ -1,11 +1,5 @@
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
{
@ -33,23 +27,6 @@ namespace DS.WMS.Core.Op.Entity
[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 = 60, IsNullable = true)]
public string LaneCName { get; set; }
/// <summary>
/// 航线主键
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线主键", IsNullable = true)]
public Nullable<long> LaneId { get; set; }
/// <summary>
/// 目的港代码
@ -114,7 +91,14 @@ namespace DS.WMS.Core.Op.Entity
/// <summary>
/// 是否为本公司合约价格 1-是0-否
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "是否为本公司合约价格 1-是0-否", IsNullable = true,DefaultValue = "0")]
[SqlSugar.SugarColumn(ColumnDescription = "是否为本公司合约价格 1-是0-否", IsNullable = true, DefaultValue = "0")]
public bool IsOurOwnPrice { get; set; } = true;
/// <summary>
/// 关联的航线列表
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(BookingContractNoManageLane.PId))]
public List<BookingContractNoManageLane>? LaneList { get; set; }
}
}

@ -0,0 +1,51 @@
using DS.Module.Core.Data;
using SqlSugar;
using System.ComponentModel;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 订舱合约号-关联航线子表
/// </summary>
[SqlSugar.SugarTable("booking_contract_manage_lane", "订舱合约号-关联航线子表")]
public class BookingContractNoManageLane
{
/// <summary>
/// 主键ID
/// </summary>
[Description("主键ID")]
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键ID")]
public long Id { get; set; }
/// <summary>
/// 合约号记录主键
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "合约号记录主键", IsNullable = false)]
public long PId { get; set; }
/// <summary>
/// 航线代码
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线代码", Length = 40, IsNullable = true)]
public string? LaneCode { get; set; }
/// <summary>
/// 航线中文
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线中文", Length = 60, IsNullable = true)]
public string? LaneCName { get; set; }
/// <summary>
/// 航线主键
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "航线主键", IsNullable = true)]
public long? LaneId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
}
}

@ -54,6 +54,6 @@ namespace DS.WMS.Core.Op.Interface
/// </summary>
/// <param name="QuerySearch">查询条件</param>
/// <returns>返回台账列表</returns>
Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest QuerySearch);
Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest<BookingContractNoManageQueryDto> QuerySearch);
}
}

@ -1,6 +1,10 @@
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Map.Dtos;
using DS.WMS.Core.Map.Interface;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
@ -8,22 +12,10 @@ 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;
using DS.WMS.Core.Sys.Interface;
using DS.WMS.Core.Map.Dtos;
using DS.WMS.Core.Map.Interface;
using DS.Module.Core.Constants;
namespace DS.WMS.Core.Op.Method
{
public class BookingContractNoManageService: IBookingContractNoManageService
public class BookingContractNoManageService : IBookingContractNoManageService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
@ -63,7 +55,7 @@ namespace DS.WMS.Core.Op.Method
var cacheRlt = await _mappingCarrierService.GetAllList();
if(cacheRlt.Succeeded)
if (cacheRlt.Succeeded)
{
mapCarrierList = cacheRlt.Data;
@ -94,23 +86,23 @@ namespace DS.WMS.Core.Op.Method
info.UpdateBy = long.Parse(user.UserId);
info.UpdateUserName = user.UserName;
await tenantDb.Updateable<BookingContractNoManage>(info).RemoveDataCache($"{SqlSugarCacheConst.ContractNo}{user.TenantId}").IgnoreColumns(it => new
{
it.CreateTime,
it.CreateBy,
it.CreateUserName
}).ExecuteCommandAsync();
await tenantDb.UpdateNav(info)
.Include(it => it.LaneList)
.ExecuteCommandAsync();
}
else
{
info = model.Adapt<BookingContractNoManage>();
await tenantDb.Insertable<BookingContractNoManage>(info).RemoveDataCache($"{SqlSugarCacheConst.ContractNo}{user.TenantId}").ExecuteReturnEntityAsync();
await tenantDb.InsertNav(info)
.Include(t => t.LaneList)
.ExecuteCommandAsync();
}
}
catch (Exception ex)
{
DataResult<long>.FailedData(info.Id, ex.Message);
return DataResult<long>.FailedData(info.Id, ex.Message);
}
return DataResult<long>.Success(info.Id);
@ -130,7 +122,9 @@ namespace DS.WMS.Core.Op.Method
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
try
{
var info = await tenantDb.Queryable<BookingContractNoManage>().FirstAsync(t => t.Id == Id);
var info = await tenantDb.Queryable<BookingContractNoManage>()
.Includes(t => t.LaneList)
.FirstAsync(t => t.Id == Id);
//合约数据不存在或已作废
if (info == null)
@ -142,7 +136,7 @@ namespace DS.WMS.Core.Op.Method
}
catch (Exception ex)
{
DataResult<BookingContractNoManageDto>.FailedData(model, ex.Message);
return DataResult<BookingContractNoManageDto>.FailedData(model, ex.Message);
}
return DataResult<BookingContractNoManageDto>.Success(model);
@ -166,6 +160,8 @@ namespace DS.WMS.Core.Op.Method
var query = tenantDb.Queryable<BookingContractNoManage>();
query.Includes(t => t.LaneList);
if (!string.IsNullOrWhiteSpace(queryItem))
{
query = query.Where(t =>
@ -179,6 +175,7 @@ namespace DS.WMS.Core.Op.Method
);
}
if (!string.IsNullOrWhiteSpace(carrier))
{
query = query.Where(t => t.CarrierCode.Equals(carrier));
@ -186,12 +183,12 @@ namespace DS.WMS.Core.Op.Method
if (!string.IsNullOrWhiteSpace(lane))
{
query = query.Where(t => string.IsNullOrWhiteSpace(t.LaneCode) || t.LaneCode.Contains(lane));
query.Where(t => t.LaneList!.Any(z => string.IsNullOrWhiteSpace(z.LaneCode) || (z.LaneCode != null && z.LaneCode.Contains(lane))));
}
if (!string.IsNullOrWhiteSpace(lanecname))
{
query = query.Where(t => string.IsNullOrWhiteSpace(t.LaneCName) || t.LaneCName.Contains(lanecname));
query.Where(t => t.LaneList!.Any(z => string.IsNullOrWhiteSpace(z.LaneCName) || (z.LaneCName != null && z.LaneCName.Contains(lanecname))));
}
if (!string.IsNullOrWhiteSpace(pod))
@ -199,12 +196,13 @@ namespace DS.WMS.Core.Op.Method
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();
var data = await query.OrderBy(a => a.ContractNo).Take(top).ToListAsync();
var result = data.Adapt<List<BookingContractNoManageDto>>();
if(data.Count == 0)
return DataResult<List<BookingContractNoManageDto>>.FailedData(data);
if (result.Count == 0)
return DataResult<List<BookingContractNoManageDto>>.FailedData(result);
return DataResult<List<BookingContractNoManageDto>>.Success(data);
return DataResult<List<BookingContractNoManageDto>>.Success(result);
}
#endregion
@ -263,7 +261,7 @@ namespace DS.WMS.Core.Op.Method
{
//throw Oops.Bah($"作废约号参数异常,{ex.Message}");
DataResult<string>.FailedData(string.Empty, ex.Message);
return DataResult<string>.FailedData(string.Empty, ex.Message);
}
return DataResult<string>.Success(string.Empty);
@ -274,18 +272,23 @@ namespace DS.WMS.Core.Op.Method
/// <summary>
/// 合约号管理台账
/// </summary>
/// <param name="QuerySearch">查询条件</param>
/// <param name="querySearch">查询条件</param>
/// <returns>返回台账列表</returns>
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest QuerySearch)
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync(PageRequest<BookingContractNoManageQueryDto> querySearch)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(QuerySearch.QueryCondition);
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(querySearch.QueryCondition);
var list = tenantDb.Queryable<BookingContractNoManage>()
.Includes(x => x.LaneList)
.Where(whereList)
.WhereIF(!string.IsNullOrEmpty(querySearch.OtherQueryCondition?.LaneCode) || querySearch.OtherQueryCondition?.LaneId != null,
x => x.LaneList!.Any(z => z.LaneCode == querySearch.OtherQueryCondition!.LaneCode || z.LaneId == querySearch.OtherQueryCondition!.LaneId))
.ToQueryPage(querySearch.PageCondition);
var data = tenantDb.Queryable<BookingContractNoManage>()
.Where(whereList)
.Select<BookingContractNoManageDto>().ToQueryPage(QuerySearch.PageCondition);
return data;
var result = list.Data.Adapt<List<BookingContractNoManageDto>>();
return DataResult<List<BookingContractNoManageDto>>.PageList(list.Count, result, MultiLanguageConst.DataQuerySuccess);
}
#endregion
}

@ -88,7 +88,7 @@ namespace DS.WMS.OpApi.Controllers
/// <returns>返回台账列表</returns>
[HttpPost]
[Route("GetPage")]
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync([FromBody] PageRequest QuerySearch)
public async Task<DataResult<List<BookingContractNoManageDto>>> GetPageAsync([FromBody] PageRequest<BookingContractNoManageQueryDto> QuerySearch)
{
return await _bookingContractNoManageService.GetPageAsync(QuerySearch);
}

@ -82,7 +82,7 @@ public class SaasDBUpdateTest
var tenantDb = saasService.GetBizDbScopeById(item.TenantId).CopyNew();
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci"; //较高版本支持
//tenantDb.CodeFirst.InitTables(types); //指定表空间下的实体
tenantDb.CodeFirst.InitTables(typeof(TaskFlowModule));//指定更新特定实体
tenantDb.CodeFirst.InitTables(typeof(BookingContractNoManageLane));//指定更新特定实体
}
Assert.True(true);

Loading…
Cancel
Save