Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
bfc5fe523f
  1. 32
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs
  2. 48
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs
  3. 163
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/UnInterfaceEfCoreRepository.cs
  4. 13
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/WmsOutputInterfaceDapperRepoisitory.cs

32
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs

@ -140,6 +140,38 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
}
[HttpGet]
[Route("WmsOutputDetailListExport")]
[UnitOfWork(false)]
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<string> ExportAsync(string taskid, string materialCode, string billnum)
{
var _ls=_dapper.GetTaskList(taskid, materialCode, billnum);
IExporter _excel = new ExcelExporter();
string _fileName = string.Empty;
//声明导出容器
_fileName = string.Format("结算接口内容导出_{0}.xlsx", Guid.NewGuid().ToString());
var result = await _excel.ExportAsByteArray(_ls);
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}

48
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs

@ -0,0 +1,48 @@

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;
using Win.Sfs.SettleAccount.Entities.WMS;
using WY.NewJit.Extends.PaiGe.WMS;
namespace Win.Sfs.SettleAccount.EntityFrameworkCore
{
[ConnectionStringName("UnInterface")]
public class UnInterfaceDbContext : AbpDbContext<UnInterfaceDbContext>
{
#region DbSet
#endregion
/* Add DbSet properties for your Aggregate Roots / Entities here.
* Also map them inside NewJitDbContextModelCreatingExtensions.ConfigureNewJit
*/
public UnInterfaceDbContext(DbContextOptions<UnInterfaceDbContext> options)
: base(options)
{
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(30));
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
}
}

163
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/UnInterfaceEfCoreRepository.cs

@ -0,0 +1,163 @@
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.SettleAccount.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 UnInterfaceEfCoreRepository<TEntity> :
EfCoreRepository<UnInterfaceDbContext,TEntity>,
ITransientDependency
where TEntity : class,IEntity
{
private readonly IDbContextProvider<UnInterfaceDbContext> _dbContextProvider;
public UnInterfaceEfCoreRepository(IDbContextProvider<UnInterfaceDbContext> dbContextProvider) :
base(dbContextProvider)
{
_dbContextProvider = dbContextProvider;
}
public UnInterfaceEfCoreRepository() : 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;
}
}
}

13
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/WmsOutputInterfaceDapperRepoisitory.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Win.Sfs.SettleAccount.Repository
{
public class WmsOutputInterfaceDapperRepoisitory
{
}
}
Loading…
Cancel
Save