From 1c907f6efb7dc2fe973c6e4ef183f9dd50e430bd Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 22 Jun 2022 13:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/WMS/WMSJitAppService.cs | 18 +-- .../ISettleAccountDbContext.cs | 7 + .../SettleAccountEntityFrameworkCoreModule.cs | 8 +- .../UnInterfaceDapperRepository.cs | 149 ++++++++++++++++++ .../UnInterfaceDbContext.cs | 2 +- .../WmsJitOutputDapperRepository.cs | 9 +- .../Services/Report/FisOutputService.cs | 14 +- 7 files changed, 188 insertions(+), 19 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDapperRepository.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs index cb887627..2044cf2a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSJitAppService.cs @@ -56,6 +56,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts /// wms出库 /// //[Authorize(SettleAccountPermissions.WMSJIT.Default)] + [AllowAnonymous] [Route("api/settleaccount/wmsjitoutput")] public class WMSJitAppService : @@ -91,7 +92,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, - ErpPartDapperRepository repository + ErpPartDapperRepository repository, + TaskJobService service ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) { @@ -102,6 +104,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts _wmsefRespository = wmsefRespository; _excelImportService = excelImportService; _repository = repository; + _service = service; } @@ -505,23 +508,16 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [HttpPost] [Route("WmsJitOutPut-Pass")] [UnitOfWork(false)] - [Authorize(SettleAccountPermissions.WMSJIT.Create)] + public async Task WmsJitOutPutPass(WmsJitRequestDto input) { List customConditionList = new List(); customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = input.BillNum ?? string.Empty }); customConditionList.Add(new CustomCondition() { Name = "Date", Value = input.AccountDate.ToString() }); - var _taskid = await _service.ExportEnqueueAsync("准时化出库服务"+input.BillNum, ExportExtentsion.Excel, input.Version, string.Empty, CurrentUser, typeof(FisOutputService), customConditionList, (rs) => { }); - - - - - - //var sql = "DECLARE @return_value int\n" + // "EXEC @return_value = [dbo].[p_wms_output]\n" + // " @billnum = N'{0}',\n" + @@ -531,6 +527,10 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts // await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( // string.Format(sql,input.BillNum,input.AccountDate.ToShortDateString()) // ); + + + + return true; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ISettleAccountDbContext.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ISettleAccountDbContext.cs index 4133f878..e006e4d2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ISettleAccountDbContext.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ISettleAccountDbContext.cs @@ -17,4 +17,11 @@ namespace Win.Sfs.SettleAccount * DbSet Questions { get; } */ } + [ConnectionStringName("UnInterface")] + public interface IUnInterfaceDbContext : IEfCoreDbContext + { + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ + } } \ No newline at end of file diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs index 086268d3..7902ad56 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs @@ -11,6 +11,7 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore; using Win.Sfs.SettleAccount.BTNotConsignReports; using Win.Sfs.SettleAccount.BTSeqKBDiffReports; using Win.Sfs.SettleAccount.BTStockUnsettledDiffReports; +using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.EstimatedStockDiffReports; using Win.Sfs.SettleAccount.JFNotConsignReports; using Win.Sfs.SettleAccount.Repository; @@ -62,13 +63,18 @@ namespace Win.Sfs.SettleAccount }); + context.Services.AddAbpDbContext(options => + { + options.AddDefaultRepositories(); + }); + // context.Services.AddTransient(typeof(IInventoryDetailRepository), //typeof(InventoryDetailRepository)); - + context.Services.AddTransient(typeof(UnInterfaceEfCoreRepository<>)); context.Services.AddTransient(typeof(WMSEfCoreRepository<>)); context.Services.AddTransient(typeof(INormalEfCoreRepository<,>), typeof(SettleAccountNormalEfCoreRepository<,>)); diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDapperRepository.cs new file mode 100644 index 00000000..e69ede81 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDapperRepository.cs @@ -0,0 +1,149 @@ +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; +using Volo.Abp.Uow; +using Win.Sfs.SettleAccount.EntityFrameworkCore; + +namespace Win.Sfs.SettleAccount +{ + public class FisOutputDapperRepository : DapperRepository, ITransientDependency + { + + + public FisOutputDapperRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + + } + + + [UnitOfWork(false)] + public virtual bool Execute(string server,string billnum, string date) + { + string sqlString = + "DECLARE\t@return_value int\n" + + "EXEC\t@return_value = [dbo].[p_wms_output_jit]\n" + + "@billnum = N'{1}',\n" + + "@type = 0,\n" + + "@date = N'{2}'\n" + + "SELECT\t'Return Value' = @return_value\n"; + + string _sql = string.Format(sqlString,server, billnum, date); + var _query = DbConnection.ExecuteScalar(_sql, null, null, 1200, System.Data.CommandType.Text); + + return true; + } + + + + + public virtual async Task> GetListBySqlAsync(string sql, bool isTrans = false) + { + if (isTrans) + { + IDbConnection conn = await GetDbConnectionAsync(); + IDbTransaction trans = await GetDbTransactionAsync(); + return (await conn.QueryAsync(sql, null, trans)) + .ToList(); + } + else + { + IDbConnection conn = await GetDbConnectionAsync(); + return (await conn.QueryAsync(sql)) + .ToList(); + } + } + + public virtual async Task GetSingleBySqlAsync(string sql, bool isTrans = false) + { + if (isTrans) + { + IDbConnection conn = await GetDbConnectionAsync(); + IDbTransaction trans = await GetDbTransactionAsync(); + return await conn.QuerySingleOrDefaultAsync(sql, null, trans); + } + else + { + IDbConnection conn = await GetDbConnectionAsync(); + return await conn.QuerySingleOrDefaultAsync(sql); + } + } + + + public virtual async Task 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 GetListBySql(string sql, bool isTrans = false) + { + if (isTrans) + { + IDbConnection conn = GetDbConnectionAsync().GetAwaiter().GetResult(); + IDbTransaction trans = GetDbTransactionAsync().GetAwaiter().GetResult(); + return (conn.Query(sql, null, trans)) + .ToList(); + } + else + { + IDbConnection conn = (IDbConnection)GetDbConnectionAsync().GetAwaiter().GetResult(); + return (conn.Query(sql)) + .ToList(); + } + } + + public virtual T GetSingleBySql(string sql, bool isTrans = false) + { + if (isTrans) + { + IDbConnection conn = GetDbConnectionAsync().GetAwaiter().GetResult(); + IDbTransaction trans = GetDbTransactionAsync().GetAwaiter().GetResult(); + return conn.QuerySingleOrDefault(sql, null, trans); + } + else + { + IDbConnection conn = (IDbConnection)GetDbConnectionAsync().GetAwaiter().GetResult(); + return conn.QuerySingleOrDefault(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 + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs index b863f4ac..f3969393 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/UnInterfaceDbContext.cs @@ -16,7 +16,7 @@ using WY.NewJit.Extends.PaiGe.WMS; namespace Win.Sfs.SettleAccount.EntityFrameworkCore { [ConnectionStringName("UnInterface")] - public class UnInterfaceDbContext : AbpDbContext + public class UnInterfaceDbContext : AbpDbContext, IUnInterfaceDbContext { #region DbSet diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/WmsJitOutput/WmsJitOutputDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/WmsJitOutput/WmsJitOutputDapperRepository.cs index 55e8b3b1..2a25c5a2 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/WmsJitOutput/WmsJitOutputDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/WmsJitOutput/WmsJitOutputDapperRepository.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories.Dapper; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Uow; using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs; @@ -23,20 +24,22 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob : base(dbContextProvider) { } + [UnitOfWork(false)] public virtual bool Execute(string billnum,string date) { string sqlString = "DECLARE\t@return_value int\n" + "EXEC\t@return_value = [dbo].[p_wms_output_jit1]\n" + "@billnum = N'{0}',\n" + - "@type = 1,\n" + + "@type = 0,\n" + "@date = N'{1}'\n" + "SELECT\t'Return Value' = @return_value\n"; - string _sql = string.Format(sqlString, billnum,date); - var _query = DbConnection.ExecuteScalar(_sql,null,null,1200,System.Data.CommandType.StoredProcedure); + var _query = DbConnection.ExecuteScalar(_sql,null,null,1200,System.Data.CommandType.Text); + + return true; diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/FisOutputService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/FisOutputService.cs index c92453c1..5995ba8a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/FisOutputService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/FisOutputService.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using TaskJob.EventArgs; using TaskJob.Interfaces; using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; +using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs; using Win.Sfs.SettleAccount.Repository.SettleAccount; using Win.Sfs.SettleAccount.Repository.SettleAccountJob; @@ -16,14 +18,14 @@ namespace SettleAccount.Job.Services { private readonly InvoiceSettledDiffRepository _repository; private readonly InvoiceSettledDiffVersionRepository _versionRepository; - private readonly WmsJitOutputDapperRepository _dapperRepository; + private readonly FisOutputDapperRepository _dapperRepository; private readonly OutputService _outputService; private readonly InputService _inputService; public FisOutputService( InvoiceSettledDiffRepository repository, InvoiceSettledDiffVersionRepository versionRepository, - WmsJitOutputDapperRepository dapperRepository, + FisOutputDapperRepository dapperRepository, OutputService outputService, InputService inputService ) @@ -34,14 +36,16 @@ namespace SettleAccount.Job.Services _versionRepository = versionRepository; _dapperRepository=dapperRepository; } - + [UnitOfWork(false)] public string ExportFile(Guid id, List exportName, List p_list) { var billnum = p_list.Where(p => p.Name == "BillNum").FirstOrDefault().Value; var date = p_list.Where(p => p.Name == "Date").FirstOrDefault().Value; - - var _ls= _dapperRepository.Execute(billnum,date); + + + + var _ls= _dapperRepository.Execute("192.168.0.63",billnum,date); return id.ToString(); }