44673626
3 years ago
19 changed files with 16584 additions and 124 deletions
Binary file not shown.
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,46 @@ |
|||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.Wms |
||||
|
{ |
||||
|
public class WmsJitOutPutDetialDto |
||||
|
{ |
||||
|
[ImporterHeader(Name = "交货单号")] |
||||
|
public string WmsBillNum { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "KENN号")] |
||||
|
//KENN号
|
||||
|
public string KennCode { set; get; } |
||||
|
[ImporterHeader(Name = "底盘号")] |
||||
|
//底盘号
|
||||
|
public string ChassisNumber { set; get; } |
||||
|
[ImporterHeader(Name = "物料号")] |
||||
|
//物料号
|
||||
|
public string MaterialCode { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "组件组物料")] |
||||
|
//物料号
|
||||
|
public string ParentMaterialCode { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "物料描述")] |
||||
|
//物料描述
|
||||
|
public string MaterialDesc { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "物料组(车型)")] |
||||
|
//物料组(车型)
|
||||
|
public string MaterialGroup { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "结算数量")] |
||||
|
public decimal Qty { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -1,95 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
using Win.Sfs.Shared.DomainBase; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.WMS |
|
||||
{ |
|
||||
public partial class TS_UNI_API: FullAuditedAggregateRootBase<Guid> |
|
||||
{ |
|
||||
|
|
||||
|
|
||||
|
|
||||
public TS_UNI_API(string interfaceType, string version, string tableName, int? billType, int? subBillType, string sourceBillNum) |
|
||||
{ |
|
||||
InterfaceType = interfaceType; |
|
||||
Version = version; |
|
||||
TableName = tableName; |
|
||||
BillType = billType; |
|
||||
SubBillType = subBillType; |
|
||||
SourceBillNum = sourceBillNum; |
|
||||
} |
|
||||
/// <summary>
|
|
||||
/// 接口类型
|
|
||||
/// </summary>
|
|
||||
public string InterfaceType { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 版本号
|
|
||||
/// </summary>
|
|
||||
public string Version { get; set; } |
|
||||
/// <summary>
|
|
||||
/// 表明
|
|
||||
/// </summary>
|
|
||||
public string TableName { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 单据类型
|
|
||||
/// </summary>
|
|
||||
public int? BillType { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 子单据类型
|
|
||||
/// </summary>
|
|
||||
public int? SubBillType { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 原单据类型
|
|
||||
/// </summary>
|
|
||||
public string SourceBillNum { get; set; } |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 状态
|
|
||||
/// </summary>
|
|
||||
public int State { set; get; } |
|
||||
/// <summary>
|
|
||||
/// 状态
|
|
||||
/// </summary>
|
|
||||
//public int State { set; get; }
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
public class WmsOutPutDetial: FullAuditedAggregateRootBase<Guid> |
|
||||
{ |
|
||||
public WmsOutPutDetial(string wmsBillNum, string kennCode, string chassisNumber, string parentMaterialCode, string materialDesc, string materialGroup) |
|
||||
{ |
|
||||
WmsBillNum = wmsBillNum; |
|
||||
KennCode = kennCode; |
|
||||
ChassisNumber = chassisNumber; |
|
||||
ParentMaterialCode = parentMaterialCode; |
|
||||
MaterialDesc = materialDesc; |
|
||||
MaterialGroup = materialGroup; |
|
||||
} |
|
||||
|
|
||||
//交货单号
|
|
||||
public string WmsBillNum{ set; get; } |
|
||||
//KENN号
|
|
||||
public string KennCode { set; get; } |
|
||||
//底盘号
|
|
||||
public string ChassisNumber { set; get; } |
|
||||
//物料号
|
|
||||
public string ParentMaterialCode { set; get; } |
|
||||
//物料描述
|
|
||||
public string MaterialDesc { set; get; } |
|
||||
//物料组(车型)
|
|
||||
public string MaterialGroup { set; get; } |
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
} |
|
@ -0,0 +1,172 @@ |
|||||
|
using Magicodes.ExporterAndImporter.Core; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Win.Sfs.Shared.DomainBase; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.WMS |
||||
|
{ |
||||
|
public partial class TS_UNI_API: FullAuditedAggregateRootBase<Guid> |
||||
|
{ |
||||
|
public TS_UNI_API(Guid id,string interfaceType, string version, string tableName, string sourceBillNum,int state,Guid taskId) |
||||
|
{ |
||||
|
Id = id; |
||||
|
InterfaceType = interfaceType; |
||||
|
Version = version; |
||||
|
TableName = tableName; |
||||
|
SourceBillNum = sourceBillNum; |
||||
|
State = state; |
||||
|
TaskId = taskId; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 接口类型
|
||||
|
/// </summary>
|
||||
|
public string InterfaceType { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 版本号
|
||||
|
/// </summary>
|
||||
|
public string Version { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 表明
|
||||
|
/// </summary>
|
||||
|
public string TableName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 原单据号
|
||||
|
/// </summary>
|
||||
|
public string SourceBillNum { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
public int State { set; get; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
public Guid TaskId { set; get; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
public class WmsJitOutPut : FullAuditedAggregateRootBase<Guid> |
||||
|
{ |
||||
|
public WmsJitOutPut() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public WmsJitOutPut(Guid id,string version, string billNum, string creator):base(id) |
||||
|
{ |
||||
|
Id = id; |
||||
|
Version = version; |
||||
|
BillNum = billNum; |
||||
|
Creator = creator; |
||||
|
} |
||||
|
|
||||
|
public string Version { set; get; } |
||||
|
|
||||
|
public string BillNum { set; get; } |
||||
|
|
||||
|
public string Creator { set; get; } |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
public class WmsJitOutPutDetial : FullAuditedAggregateRootBase<Guid> |
||||
|
{ |
||||
|
public WmsJitOutPutDetial() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public WmsJitOutPutDetial(Guid id, string wmsBillNum, string kennCode, string chassisNumber, string materialCode, string materialDesc, string materialGroup, string outPut, string inPut, int state, string extend1, string extend2, string extend3, string parentMaterialCode,string billNum,Guid taskId) |
||||
|
{ |
||||
|
Id = id; |
||||
|
WmsBillNum = wmsBillNum; |
||||
|
KennCode = kennCode; |
||||
|
ChassisNumber = chassisNumber; |
||||
|
MaterialCode = materialCode; |
||||
|
MaterialDesc = materialDesc; |
||||
|
MaterialGroup = materialGroup; |
||||
|
OutPut = outPut; |
||||
|
InPut = inPut; |
||||
|
State = state; |
||||
|
Extend1 = extend1; |
||||
|
Extend2 = extend2; |
||||
|
Version = extend3; |
||||
|
ParentMaterialCode = parentMaterialCode; |
||||
|
BillNum = billNum; |
||||
|
TaskId = taskId; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// 交货单号 实际发货日期 KENN号 底盘号 物料号 物料描述 客户物料 组件组物料 组件组物料描述 物料组(车型) 定价 金额 结算平台未结数量 大众R3未结数量 差异金额 差异数量 漏结标识 漏结期间 说明
|
||||
|
|
||||
|
|
||||
|
//交货单号
|
||||
|
|
||||
|
[ImporterHeader(Name = "组件组物料")] |
||||
|
public string ParentMaterialCode { set; get; } |
||||
|
[ImporterHeader(Name = "交货单号")] |
||||
|
public string WmsBillNum { set; get; } |
||||
|
[ImporterHeader(Name = "KENN号")] |
||||
|
//KENN号
|
||||
|
public string KennCode { set; get; } |
||||
|
[ImporterHeader(Name = "底盘号")] |
||||
|
//底盘号
|
||||
|
public string ChassisNumber { set; get; } |
||||
|
[ImporterHeader(Name = "物料号")] |
||||
|
//物料号
|
||||
|
public string MaterialCode { set; get; } |
||||
|
[ImporterHeader(Name = "物料描述")] |
||||
|
//物料描述
|
||||
|
public string MaterialDesc { set; get; } |
||||
|
[ImporterHeader(Name = "物料组(车型)")] |
||||
|
//物料组(车型)
|
||||
|
public string MaterialGroup { set; get; } |
||||
|
[ImporterHeader(Name = "出库库位")] |
||||
|
//出库库位
|
||||
|
public string OutPut { set; get; } |
||||
|
[ImporterHeader(Name = "入库库位")] |
||||
|
//入库库位
|
||||
|
public string InPut { set; get; } |
||||
|
[ImporterHeader(Name = "状态")] |
||||
|
public int State { get; set; } |
||||
|
[ImporterHeader(Name = "扩展字段1")] |
||||
|
/// <summary>
|
||||
|
/// 扩展字段1
|
||||
|
/// </summary>
|
||||
|
public string Extend1 { set; get; } |
||||
|
/// <summary>
|
||||
|
/// 扩展字段2
|
||||
|
/// </summary>
|
||||
|
[ImporterHeader(Name = "扩展字段2")] |
||||
|
public string Extend2 { set; get; } |
||||
|
/// <summary>
|
||||
|
/// 扩展字段3
|
||||
|
/// </summary>
|
||||
|
[ImporterHeader(Name = "版本号")] |
||||
|
public string Version { set; get; } |
||||
|
[ImporterHeader(Name = "数量")] |
||||
|
public string Qty { set; get; } |
||||
|
|
||||
|
[ImporterHeader(Name = "数量",IsIgnore =true)] |
||||
|
public string BillNum { set; get; } |
||||
|
|
||||
|
|
||||
|
public Guid TaskId { set; get; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,126 @@ |
|||||
|
using Dapper; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Repositories.Dapper; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
|
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount |
||||
|
{ |
||||
|
public class WMSDapperRepository : DapperRepository<WMSDbContext>, ITransientDependency |
||||
|
{ |
||||
|
public WMSDapperRepository(IDbContextProvider<WMSDbContext> dbContextProvider) |
||||
|
: base(dbContextProvider) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public virtual async Task<List<T>> GetListBySqlAsync<T>(string sql, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
IDbTransaction trans = await GetDbTransactionAsync(); |
||||
|
return (await conn.QueryAsync<T>(sql, null, trans)) |
||||
|
.ToList(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
return (await conn.QueryAsync<T>(sql)) |
||||
|
.ToList(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<T> GetSingleBySqlAsync<T>(string sql, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
IDbTransaction trans = await GetDbTransactionAsync(); |
||||
|
return await conn.QuerySingleOrDefaultAsync<T>(sql, null, trans); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
return await conn.QuerySingleOrDefaultAsync<T>(sql); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public virtual async Task<int> ExecuteSqlAsync(string sql, object obj = null, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
//return await DbConnection.ExecuteAsync("update People set Name = @NewName", new { NewName = name }, DbTransaction);
|
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
IDbTransaction trans = await GetDbTransactionAsync(); |
||||
|
return await conn.ExecuteAsync(sql, obj, trans); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
//return await DbConnection.ExecuteAsync("update People set Name = @NewName", new { NewName = name }, DbTransaction);
|
||||
|
IDbConnection conn = await GetDbConnectionAsync(); |
||||
|
return await conn.ExecuteAsync(sql, obj); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#region 同步方法
|
||||
|
public virtual List<T> GetListBySql<T>(string sql, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
IDbConnection conn = GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
IDbTransaction trans = GetDbTransactionAsync().GetAwaiter().GetResult(); |
||||
|
return (conn.Query<T>(sql, null, trans)) |
||||
|
.ToList(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IDbConnection conn = (IDbConnection)GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
return (conn.Query<T>(sql)) |
||||
|
.ToList(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual T GetSingleBySql<T>(string sql, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
IDbConnection conn = GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
IDbTransaction trans = GetDbTransactionAsync().GetAwaiter().GetResult(); |
||||
|
return conn.QuerySingleOrDefault<T>(sql, null, trans); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IDbConnection conn = (IDbConnection)GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
return conn.QuerySingleOrDefault<T>(sql); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public virtual int ExecuteSql(string sql, object obj = null, bool isTrans = false) |
||||
|
{ |
||||
|
if (isTrans) |
||||
|
{ |
||||
|
IDbConnection conn = GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
IDbTransaction trans = GetDbTransactionAsync().GetAwaiter().GetResult(); |
||||
|
return conn.Execute(sql, obj, trans); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
IDbConnection conn = (IDbConnection)GetDbConnectionAsync().GetAwaiter().GetResult(); |
||||
|
return conn.Execute(sql, obj); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
|
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Win.Sfs.SettleAccount.Entities.WMS; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
[ConnectionStringName("WMS")] |
||||
|
public class WMSDbContext : AbpDbContext<WMSDbContext> |
||||
|
{ |
||||
|
#region DbSet
|
||||
|
//public virtual DbSet<TB_BILL> TB_BILL { get; set; }
|
||||
|
//public virtual DbSet<TS_SORT_DETAIL> TS_SORT_DETAIL { get; set; }
|
||||
|
#endregion
|
||||
|
|
||||
|
/* Add DbSet properties for your Aggregate Roots / Entities here. |
||||
|
* Also map them inside NewJitDbContextModelCreatingExtensions.ConfigureNewJit |
||||
|
*/ |
||||
|
|
||||
|
public WMSDbContext(DbContextOptions<WMSDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
//protected override void OnModelCreating(ModelBuilder builder)
|
||||
|
//{
|
||||
|
// base.OnModelCreating(builder);
|
||||
|
// builder.Entity<WmsJitOutPutDetial>(b =>
|
||||
|
// {
|
||||
|
// b.ToTable("WmsJitOutPutDetial");
|
||||
|
// b.HasKey(x => x.Id);
|
||||
|
// b.Property(x => x.WmsBillNum).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.Remark).HasMaxLength(200).IsRequired();
|
||||
|
// b.Property(x => x.ParentMaterialCode).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.MaterialCode).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.MaterialGroup).HasMaxLength(200);
|
||||
|
// b.Property(x => x.OutPut).HasMaxLength(50);
|
||||
|
// b.Property(x => x.Extend1).HasMaxLength(50);
|
||||
|
// b.Property(x => x.Extend2).HasMaxLength(50);
|
||||
|
// b.Property(x => x.Extend3).HasMaxLength(50);
|
||||
|
// b.Property(x => x.ChassisNumber).HasMaxLength(50);
|
||||
|
// b.Property(x => x.KennCode).HasMaxLength(50);
|
||||
|
// b.Property(x => x.MaterialDesc).HasMaxLength(50);
|
||||
|
// });
|
||||
|
|
||||
|
// builder.Entity<TS_UNI_API>(b =>
|
||||
|
// {
|
||||
|
// b.ToTable("TS_UNI_API");
|
||||
|
// b.HasKey(x => x.Id);
|
||||
|
// b.Property(x => x.Remark).HasMaxLength(200).IsRequired();
|
||||
|
// b.Property(x => x.SourceBillNum).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.TableName).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.Version).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.TableName).HasMaxLength(50).IsRequired();
|
||||
|
// b.Property(x => x.TableName).HasMaxLength(50).IsRequired();
|
||||
|
// });
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// //在这里配置共享表
|
||||
|
|
||||
|
// //builder.Entity<TS_SORT_DETAIL>(b =>
|
||||
|
// //{
|
||||
|
// // b.HasIndex(x => new { x.BillNum, x.VinCode, x.PartCode }).IsUnique();
|
||||
|
|
||||
|
// //});
|
||||
|
//}
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,162 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Data.Common; |
||||
|
using System.Data.SqlClient; |
||||
|
using System.Linq; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Storage; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Win.Sfs.Shared; |
||||
|
using Win.Sfs.Shared.DomainBase; |
||||
|
using Win.Sfs.Shared.Filter; |
||||
|
using Win.Sfs.Shared.RepositoryBase; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Repository |
||||
|
{ |
||||
|
public class WMSEfCoreRepository<TEntity> : |
||||
|
EfCoreRepository<WMSDbContext,TEntity>, |
||||
|
ITransientDependency |
||||
|
where TEntity : class,IEntity |
||||
|
{ |
||||
|
|
||||
|
private readonly IDbContextProvider<WMSDbContext> _dbContextProvider; |
||||
|
|
||||
|
|
||||
|
|
||||
|
public WMSEfCoreRepository(IDbContextProvider<WMSDbContext> dbContextProvider) : |
||||
|
base(dbContextProvider) |
||||
|
{ |
||||
|
|
||||
|
_dbContextProvider = dbContextProvider; |
||||
|
|
||||
|
} |
||||
|
public WMSEfCoreRepository() : base(null) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public DbCommand CreateCommand(string commandText, CommandType commandType, params DbParameter[] parameters) |
||||
|
{ |
||||
|
var command = DbContext.Database.GetDbConnection().CreateCommand(); |
||||
|
|
||||
|
command.CommandText = commandText; |
||||
|
command.CommandType = commandType; |
||||
|
command.Transaction = DbContext.Database.CurrentTransaction?.GetDbTransaction(); |
||||
|
|
||||
|
foreach (var parameter in parameters) |
||||
|
{ |
||||
|
command.Parameters.Add(parameter); |
||||
|
} |
||||
|
|
||||
|
return command; |
||||
|
} |
||||
|
|
||||
|
public async Task EnsureConnectionOpenAsync(CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var connection = DbContext.Database.GetDbConnection(); |
||||
|
|
||||
|
if (connection.State != ConnectionState.Open) |
||||
|
{ |
||||
|
await connection.OpenAsync(cancellationToken); |
||||
|
} |
||||
|
} |
||||
|
public virtual async Task<List<TEntity>> GetAllAsync( bool includeDetails = false, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var query = includeDetails ? this.WithDetails() : this.GetQueryable(); |
||||
|
|
||||
|
//query = query.Where(p => p.BranchId.Equals(branchId));
|
||||
|
|
||||
|
return await query.ToListAsync(cancellationToken: cancellationToken); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<long> GetCountAsync( CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await this.GetQueryable() |
||||
|
//.Where(p => p.BranchId.Equals(branchId))
|
||||
|
.LongCountAsync(GetCancellationToken(cancellationToken)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public virtual async Task<long> GetCountByFilterAsync( List<FilterCondition> filters, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return await this.GetQueryable() |
||||
|
//.Where(p => p.BranchId.Equals(branchId))
|
||||
|
.WhereIf(filters?.Count != 0, filters.ToLambda<TEntity>()) |
||||
|
.LongCountAsync(GetCancellationToken(cancellationToken)); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<List<TEntity>> GetListByFilterAsync(List<FilterCondition> filters, |
||||
|
string sorting = null, |
||||
|
int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, |
||||
|
CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var query = includeDetails ? this.WithDetails() : this.GetQueryable(); |
||||
|
// query = query.Where(p => p.BranchId.Equals(branchId));
|
||||
|
var entities = query.WhereIf(filters?.Count != 0, filters.ToLambda<TEntity>()); |
||||
|
//2021-07-02 设置sorting首字母大小,因设置了驼峰规则,不匹配“ var memberProp = typeof(T).GetProperty(propertyName);”反射
|
||||
|
if(!string.IsNullOrEmpty(sorting)) |
||||
|
{ |
||||
|
sorting = sorting.Substring(0, 1).ToUpper() + sorting.Substring(1); |
||||
|
} |
||||
|
entities = GetSortingQueryable(entities, sorting); |
||||
|
return await entities.PageBy(skipCount, maxResultCount) |
||||
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected static IQueryable<TEntity> GetSortingQueryable(IQueryable<TEntity> entities, string sorting) |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(sorting)) |
||||
|
{ |
||||
|
entities = entities.OrderByDescending("Id"); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
var sortParams = sorting?.Split(' '); |
||||
|
var sortName = sortParams[0]; |
||||
|
|
||||
|
|
||||
|
Type t = typeof(TEntity); |
||||
|
var _first = t.GetProperties().Where(p => p.Name.ToUpper() == sortName.ToUpper()).FirstOrDefault(); |
||||
|
if (_first != null) |
||||
|
{ |
||||
|
sortName = _first.Name; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
bool isDesc; |
||||
|
if (sortParams.Length > 1) |
||||
|
{ |
||||
|
var sortDirection = sortParams[1]; |
||||
|
isDesc = sortDirection.ToUpper().Contains("DESC") ? true : false; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
isDesc = true; |
||||
|
} |
||||
|
|
||||
|
entities = isDesc ? entities.OrderByDescending(sortName) : entities.OrderBy(sortName); |
||||
|
} |
||||
|
|
||||
|
return entities; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue