From e26f067afd7be55ef7809ae174faf265d5a79e02 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 10 Mar 2022 15:21:21 +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/WmsDetailUnInterface.cs | 188 ++++++++++++++++++ .../Entities/WMS/WmsUnInterface.cs | 37 ++-- .../Entities/WmsDetailReport.cs | 72 +++++++ 3 files changed, 278 insertions(+), 19 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs new file mode 100644 index 00000000..fb992dcd --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsDetailUnInterface.cs @@ -0,0 +1,188 @@ + +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Mvc; +using Shouldly; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.Wms; +using Win.Sfs.SettleAccount.Entities.Wms.WmsSumOutput; +using Win.Sfs.SettleAccount.Reports; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; +using Win.Sfs.Shared.DomainBase; +using Win.Sfs.Shared.Filter; + +namespace Win.Sfs.SettleAccount.Entities.WMS +{ + [Route("api/settleaccount/WMSOutputDetailDiffReport")] + public class WMSOutputDetailDiffReportAppService : + SettleAccountApplicationBase + { + private readonly ISettleAccountBranchEfCoreRepository _wmsRepository; + private readonly WmsOutputSumDapperRepository _dapper; + private readonly IExcelImportAppService _excelImportService; + + private readonly ErpSumOutputDapperRepository _erpDapper; + /// + /// + /// + /// + /// + + public WMSOutputDetailDiffReportAppService( + WmsOutputSumDapperRepository dapper, + ISettleAccountBranchEfCoreRepository wmsRepository, + ISettleAccountBranchEfCoreRepository job, + IExcelImportAppService excelImportService, + IDistributedCache cache, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager, + ErpSumOutputDapperRepository erpDapper + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _erpDapper = erpDapper; + _wmsRepository = wmsRepository; + _dapper = dapper; + + } + + [HttpGet] + [Route("Make")] + [UnitOfWork(false)] + public async Task ReportMake(string version,DateTime accountDate) + { + var _ls= _dapper.GetWmsSumReportList(version,"0");//报表 + + var _count= _wmsRepository.Count(p => p.Version == version && p.State>0); + if (_count > 0) + { + throw new BusinessException("8899", "不能重新生成此版本!"); + } + else + { + var query = _wmsRepository.Where(p => p.Version == version); + await query.BatchDeleteAsync(); + } + List _lst = new List(); + if (_ls != null && _ls.Count() > 0) + { + foreach (var itm in _ls) + { + _lst.Add(new WmsDetailDiffReport( + Guid.NewGuid(), + itm.客户, + itm.出库类型, + version, + itm.结算单, + itm.通用代码号, + itm.物料号, + itm.结算数量, + itm.实际出库数量, + itm.差异数量, + itm.物料组编码, + itm.物料组车型, + itm.物料描述, + itm.备注, + 0)); + } + } + await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); + return ApplicationConsts.SuccessStr; + } + /// + /// Wms汇总合计明细 + /// + /// + /// + [HttpPost] + [Route("WmsDetailReport")] + + virtual public async Task> GetListAsync(WmsRequestDetailReportDto input) + { + var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, + input.SkipCount, true); + var totalCount = await GetCountAsync(input); + return new PagedResultDto(totalCount, entities); + } + + + private async Task GetCountAsync(WmsRequestDetailReportDto input) + { + // input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "BillNum", Logic = EnumFilterLogic.And, Value = input.BillNum }); + return await _wmsRepository.GetCountByFilterAsync(GuidGenerator.Create(), input.Filters); + } + + + //[HttpPost] + //[Route("Output")] + + //virtual public async Task OutputAsync(WmsRequestDetailReportDto input) + //{ + // var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, + // 0, true); + // List _ls = new List(); + // if (entities.Count() > 0) + // { + // var _entity = entities.FirstOrDefault(); + // if (_entity != null) + // { + // var _version = _entity.Version; + // var _accountDate = _entity.AccountDate; + // _erpDapper.InsertWmsSum(_ls, _version, _accountDate); + // } + // } + // return true; + //} + [HttpPost] + [Route("Export")] + virtual public async Task ExportAsync(WmsRequestDetailReportDto input) + { + var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, + 0, true); + IExporter _excel = new ExcelExporter(); + byte[] result = null; + var _fileName = string.Format("汇总合计报表_{0}.xlsx", Guid.NewGuid().ToString()); + result = await _excel.ExportAsByteArray(entities); + result.ShouldNotBeNull(); + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + + + } + + + + + + + + + + + + + + +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs index 8ca3dd46..0959944f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsUnInterface.cs @@ -14,6 +14,7 @@ using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; using Win.Abp.Snowflakes; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.CommonManagers; @@ -61,6 +62,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS [HttpGet] [Route("Make")] + [UnitOfWork(false)] public async Task ReportMake(string version,DateTime accountDate) { var _ls= _dapper.GetWmsSumExtendList(version);//报表 @@ -104,16 +106,12 @@ namespace Win.Sfs.SettleAccount.Entities.WMS 0, version, accountDate - - )); } } await _wmsRepository.GetDbContext().BulkInsertAsync(_lst); return ApplicationConsts.SuccessStr; } - - /// /// Wms汇总合计明细 /// @@ -131,8 +129,23 @@ namespace Win.Sfs.SettleAccount.Entities.WMS } + /// + /// Wms汇总合计明细 + /// + /// + /// + [HttpPost] + [Route("version")] + + virtual public async Task> GetVersionListAsync() + { + var entities = _wmsRepository.Select(p => p.Version).Distinct().ToList(); + + return entities; + } + + - @@ -143,8 +156,6 @@ namespace Win.Sfs.SettleAccount.Entities.WMS } - - [HttpPost] [Route("Output")] @@ -152,9 +163,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS { var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, 0, true); - List _ls = new List(); - if (entities.Count() > 0) { var _entity = entities.FirstOrDefault(); @@ -164,21 +173,11 @@ namespace Win.Sfs.SettleAccount.Entities.WMS var _accountDate = _entity.AccountDate; _erpDapper.InsertWmsSum(_ls, _version, _accountDate); } - - } - - return true; - - - - - } [HttpPost] [Route("Export")] - virtual public async Task ExportAsync(WmsRequestDetailReportDto input) { var entities = await _wmsRepository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WmsDetailReport.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WmsDetailReport.cs index 9902a72d..d4edeeac 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WmsDetailReport.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WmsDetailReport.cs @@ -92,4 +92,76 @@ namespace Win.Sfs.SettleAccount.Entities public DateTime AccountDate { set; get; } } + public class WmsDetailDiffReport : FullAuditedAggregateRootBase + { + public WmsDetailDiffReport() + { + } + + public WmsDetailDiffReport(Guid id,string client, string type,string version, string billNum, string switchCode, string materialCode, decimal qty, decimal outputQty, decimal diffQty, string materialGroupCode, string materialGroup, string materialDesc, string remark1,int state):base(id) + { + Version = version; + Type = type; + Client = client; + BillNum = billNum; + SwitchCode = switchCode; + MaterialCode = materialCode; + Qty = qty; + OutputQty = outputQty; + DiffQty = diffQty; + MaterialGroupCode = materialGroupCode; + MaterialGroup = materialGroup; + MaterialDesc = materialDesc; + Remark1 = remark1; + State = state; + } + + [Display(Name = "版本号")] + public string Version { set; get; } + + [Display(Name = "客户")] + public string Client { set; get; } + [Display(Name = "出库类型")] + public string Type { set; get; } + //[Display(Name = "结算编码")] + //public string SettleCode { set; get; } + //[Display(Name = "销售渠道")] + //public string SaleCode { set; get; } + //[Display(Name = "客户代码")] + //public string ClientCode { set; get; } + [Display(Name = "结算单")] + public string BillNum { set; get; } + [Display(Name = "交货编码")] + public string SwitchCode { set; get; } + + [Display(Name = "物料号")] + public string MaterialCode { set; get; } + //[Display(Name = "寄售类别")] + //public string SaleType { set; get; } + [Display(Name = "结算数量")] + public decimal Qty { set; get; } + [Display(Name = "实际出库数量")] + public decimal OutputQty { set; get; } + [Display(Name = "差异数量")] + public decimal DiffQty { set; get; } + //[Display(Name = "开票单价")] + //public decimal Price { set; get; } + //[Display(Name = "结算金额")] + //public decimal Amt { set; get; } + //[Display(Name = "已出库金额")] + //public decimal OutPutAmt { set; get; } + //[Display(Name = "WMS待出库金额")] + //public decimal DiffAmt { set; get; } + [Display(Name = "物料组编码")] + public string MaterialGroupCode { set; get; } + [Display(Name = "物料组(车型)")] + public string MaterialGroup { set; get; } + [Display(Name = "物料组描述")] + public string MaterialDesc { set; get; } + [Display(Name = "备注")] + public string Remark1 { set; get; } + + public int State { set; get; } + + } }