diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index f259923c..bf4d1d67 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -94,9 +94,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "税率")] public decimal Tax { get; set; } - - - /// ///发票分组号 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs index 9c15f384..6ad8aeef 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs @@ -20,6 +20,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Syncs; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -88,14 +89,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } var entitys = await _hbpoMng.GetDetalListAsync(invbillnum).ConfigureAwait(false); - var settleBillList= entitys.Select(p => p.SettleBillNum).Distinct(); - - - - //_saRepository.Where(p=>settleBillList.Contains(p.BillNum) && p.State==0) - - - + #region 是否核对已经完成 + List errors = new List(); + var settleBillList = entitys.Select(p => p.SettleBillNum).Distinct().ToList(); + var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum) && p.State == "0").ToList(); + foreach (var itm in checklist) + { + errors.Add(new ERR_EXP_DTO() { Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+没进行报表核对!" }); + } + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } + #endregion var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList(); //价格单 var errorList = await CheckInvoiceGenerationRules(entitys, main.Site, priceList, main.BusinessType).ConfigureAwait(false);//校验生成规则 if (errorList.Count > 0) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs index 7c22f1ac..49e4f69c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs @@ -17,6 +17,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Entities.BQ @@ -44,6 +45,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _pricebjRepository; private readonly INormalEfCoreRepository _notRepository; + private readonly INormalEfCoreRepository _saRepository; + + public PUB_CAN_SA_SERVICE (IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -56,7 +60,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ PUB_CAN_SA_MNG pubMng, BaseDomainService baseservice, INormalEfCoreRepository notRepository, - INormalEfCoreRepository priceYinDuRepository + INormalEfCoreRepository priceYinDuRepository, + INormalEfCoreRepository saRepository ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng, baseservice) { @@ -65,6 +70,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _pricebjRepository = pricebjRepository; _notRepository = notRepository; _priceYinDuRepository= priceYinDuRepository; + _saRepository= saRepository; } [HttpPost] [UnitOfWork(false)] @@ -122,6 +128,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //{ // priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单 //} + + #region 是否对比核对已经完成 + + List errors = new List(); + var settleBillList = entitys.Select(p => p.SettleBillNum).Distinct().ToList(); + var checklist = _saRepository.Where(p => settleBillList.Contains(p.BillNum) && p.State == "0").ToList(); + foreach (var itm in checklist) + { + errors.Add(new ERR_EXP_DTO(){ Remark = $"版本:{itm.Version},结算单:{itm.BillNum}+没进行报表核对!" }); + } + if (errors.Count > 0) + { + return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errors).ConfigureAwait(false) }); + } + #endregion var errorList = await CheckInvoiceGenerationRules(entitys, main.Site, priceList, main.BusinessType).ConfigureAwait(false);//校验生成规则 if (errorList.Count > 0) { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index a6b7003e..5c1dc756 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -193,18 +193,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task> BalanceSum(RequestDto input) { + var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; using var db = new SettleAccountDbContext(options); - var query = db.Set().FromSqlRaw("select * from Set_VmiBalance"); - var filters = input.Filters.ToLambda(); + var query = db.Set().FromSqlRaw("select * from Set_VmiLog"); + var filters = input.Filters.ToLambda(); if (input.Filters.Count > 0) { - query = query.Where(input.Filters.ToLambda()); + query = query.Where(input.Filters.ToLambda()); } + query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); var totalCount = query2.Count(); - query2 = string.IsNullOrEmpty(input.Sorting) ? query2 : DynamicQueryableExtensions.OrderBy(query2, input.Sorting); + + //var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); + //var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; + //using var db = new SettleAccountDbContext(options); + //var query = db.Set().FromSqlRaw("select * from Set_VmiBalance"); + //var filters = input.Filters.ToLambda(); + //if (input.Filters.Count > 0) + //{ + // query = query.Where(input.Filters.ToLambda()); + //} + //var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); + //var totalCount = query2.Count(); + //query2 = string.IsNullOrEmpty(input.Sorting) ? query2 : DynamicQueryableExtensions.OrderBy(query2, input.Sorting); var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); return new PagedResultDto(totalCount, entities); } @@ -215,14 +229,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [HttpPost] public async Task BalanceSumExport(RequestDto input) { + + + var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; using var db = new SettleAccountDbContext(options); - var query = db.Set().FromSqlRaw("select * from Set_VmiBalance"); - var filters = input.Filters.ToLambda(); + var query = db.Set().FromSqlRaw("select * from Set_VmiLog"); + var filters = input.Filters.ToLambda(); if (input.Filters.Count > 0) { - query = query.Where(input.Filters.ToLambda()); + query = query.Where(input.Filters.ToLambda()); + } + query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); + var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); + var totalCount = query2.Count(); + var entities = await query2.ToListAsync().ConfigureAwait(false); var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; + var content = this.GetContent(entities, "库存汇总"); + await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); + return fileName; + + + + + + + + + + + + + //var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); + //var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; + //using var db = new SettleAccountDbContext(options); + //var query = db.Set().FromSqlRaw("select * from Set_VmiBalance"); + //var filters = input.Filters.ToLambda(); + //if (input.Filters.Count > 0) + //{ + // query = query.Where(input.Filters.ToLambda()); + //} + //query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); + //var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); + //var totalCount = query2.Count(); + //var entities = await query2.ToListAsync().ConfigureAwait(false); var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; + //var content = this.GetContent(entities, "库存汇总"); + //await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); + //return fileName; + } + + /// + /// 1.2库存余额汇总导出 + /// + [HttpPost] + public async Task BalanceSumByLogExport(RequestDto input) + { + var connectionString = this._serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); + var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; + using var db = new SettleAccountDbContext(options); + var query = db.Set().FromSqlRaw("select * from Set_VmiLog"); + var filters = input.Filters.ToLambda(); + if (input.Filters.Count > 0) + { + query = query.Where(input.Filters.ToLambda()); } query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); @@ -233,6 +302,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ return fileName; } + + + + + + + + + /// /// 快照列表 /// @@ -1051,4 +1129,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [Display(Name = "数量", Order = 10)] public decimal Qty { get; set; } } + + + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs index abcabfc9..5e06c78a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs @@ -153,15 +153,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //本地查找 var balance = balanceList.Select(o => o.Item1).FirstOrDefault( o => - //o.DeliverBillType == log.DeliverBillType && - //o.CodeType == log.CodeType && + o.DeliverBillType == log.DeliverBillType && + o.CodeType == log.CodeType && o.RealPartCode == log.RealPartCode && o.VinCode == log.VinCode && - o.ErpToLoc == log.ErpToLoc - //&& - //o.OrderNum == log.OrderNum && - //o.factory == log.factory && - //o.Configcode == log.Configcode + o.ErpToLoc == log.ErpToLoc&& + o.OrderNum == log.OrderNum && + o.factory == log.factory && + o.Configcode == log.Configcode ); //数据库查找 if (balance == null)