diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs index a072b259..ee2cbc4e 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOutputSumInterfaceAppService.cs +++ b/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 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; + + } + diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs new file mode 100644 index 00000000..b863f4ac --- /dev/null +++ b/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 + { + #region DbSet + + + #endregion + + /* Add DbSet properties for your Aggregate Roots / Entities here. + * Also map them inside NewJitDbContextModelCreatingExtensions.ConfigureNewJit + */ + + public UnInterfaceDbContext(DbContextOptions options) + : base(options) + { + this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(30)); + } + + + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + + } + + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/UnInterfaceEfCoreRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/UnInterfaceEfCoreRepository.cs new file mode 100644 index 00000000..17f97d8c --- /dev/null +++ b/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 : + EfCoreRepository, + ITransientDependency + where TEntity : class,IEntity + { + + private readonly IDbContextProvider _dbContextProvider; + + + + public UnInterfaceEfCoreRepository(IDbContextProvider 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> 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 GetCountAsync( CancellationToken cancellationToken = default) + { + return await this.GetQueryable() + //.Where(p => p.BranchId.Equals(branchId)) + .LongCountAsync(GetCancellationToken(cancellationToken)); + + } + + public virtual async Task GetCountByFilterAsync( List filters, + CancellationToken cancellationToken = default) + { + return await this.GetQueryable() + //.Where(p => p.BranchId.Equals(branchId)) + .WhereIf(filters?.Count != 0, filters.ToLambda()) + .LongCountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetListByFilterAsync(List 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()); + //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 GetSortingQueryable(IQueryable 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; + } + + } + + +} \ No newline at end of file diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/WmsOutputInterfaceDapperRepoisitory.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/WmsOutputInterfaceDapperRepoisitory.cs new file mode 100644 index 00000000..48e4837c --- /dev/null +++ b/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 + { + + } +}