From 3800aee4acd26133384a92f3ba1fd9e3bce7512e Mon Sep 17 00:00:00 2001 From: zhaoxinyu Date: Tue, 19 Dec 2023 14:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/Syncs/EdiWmsDiffSerice.cs | 98 +++++++++++++++++ .../ReportServices/ReportMakeService.cs | 55 ++++++++++ .../SettleAccountApplicationModule.cs | 13 +++ .../BalanceSum/BalanceSumDapperRepository.cs | 100 ++++++++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/EdiWmsDiffSerice.cs diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/EdiWmsDiffSerice.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/EdiWmsDiffSerice.cs new file mode 100644 index 00000000..bbac2d8a --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/EdiWmsDiffSerice.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Magicodes.ExporterAndImporter.Excel; +using Shouldly; +using TaskJob.EventArgs; +using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Bases; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; + +namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs +{ + public class EdiWmsDiffService :BASE_SERVICE, ITransientDependency, IExportJob + { + + protected readonly EdiWmsDapperRepository _dapper; + + private readonly IBlobContainer _fileContainer; + + + public EdiWmsDiffService(IBlobContainer fileContainer, EdiWmsDapperRepository dapper, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager) : base(excelImportService, snowflakeIdGenerator, commonManager) + { + _dapper = dapper; + _fileContainer = fileContainer; + } + + [UnitOfWork(false)] + public string ExportFile(Guid id, List exportName, List property) + { + var _filename = exportName.FirstOrDefault(); + var year = property.Where(p => p.Name == "Year").FirstOrDefault().Value; + var list = _dapper.GetEdiWms(); + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(list.ToList(), "BBAC业务EDI发运对比表") + //.SeparateBySheet() + //.Append(_reversels.ToList(), "有发货无结算对比") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(_filename, result.Result, true); + return id.ToString(); + + } + + + + + + + } + + public class HBPOEdiWmsDiffService : BASE_SERVICE, ITransientDependency, IExportJob + { + + protected readonly EdiWmsDapperRepository _dapper; + + private readonly IBlobContainer _fileContainer; + + + public HBPOEdiWmsDiffService(IBlobContainer fileContainer, EdiWmsDapperRepository dapper, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager) : base(excelImportService, snowflakeIdGenerator, commonManager) + { + _dapper = dapper; + _fileContainer = fileContainer; + } + + [UnitOfWork(false)] + public string ExportFile(Guid id, List exportName, List property) + { + var _filename = exportName.FirstOrDefault(); + var year = property.Where(p => p.Name == "Year").FirstOrDefault().Value; + var list = _dapper.GetHBPOEdiWms(); + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(list.ToList(), "HBPO业务EDI发运对比表") + //.SeparateBySheet() + //.Append(_reversels.ToList(), "有发货无结算对比") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(_filename, result.Result, true); + return id.ToString(); + + } + + + + + + + } + + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index ba43361a..d8e26d9a 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -74,6 +74,61 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices } + [HttpPost] + [DisableRequestSizeLimit] + /// + /// 差异对比EDI和WMS + /// + /// + /// + + public async Task GetBBACWmsEdiDiff() + { + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Year", Value = DateTime.Now.Year.ToString() }); + + var _taskid = await _service.ExportEnqueueAsync("EDI发运对比", ExportExtentsion.Excel, DateTime.Now.Year.ToString(), string.Empty, CurrentUser, typeof(EdiWmsDiffService), customConditionList, (rs) => + { + + }).ConfigureAwait(false); + + return _taskid; + } + + + [HttpPost] + [DisableRequestSizeLimit] + /// + /// 差异对比EDI和WMS + /// + /// + /// + + public async Task GetHBPOWmsEdiDiff() + { + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Year", Value = DateTime.Now.Year.ToString() }); + + var _taskid = await _service.ExportEnqueueAsync("EDI发运对比", ExportExtentsion.Excel, DateTime.Now.Year.ToString(), string.Empty, CurrentUser, typeof(HBPOEdiWmsDiffService), customConditionList, (rs) => + { + + }).ConfigureAwait(false); + + return _taskid; + } + + + + + + + + + + + + + } public class BalanceSumVersionDto diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs index 5930063d..db0a0a16 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs @@ -97,6 +97,19 @@ namespace Win.Sfs.SettleAccount return implementationFactory.GetService(); } + if (key.Equals(typeof(EdiWmsDiffService).FullName)) + { + return implementationFactory.GetService(); + } + if (key.Equals(typeof(HBPOEdiWmsDiffService).FullName)) + { + return implementationFactory.GetService(); + } + + + + + else { throw new ArgumentException($"Not Support key:{key}"); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs index a53559f4..6e0579f2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; using System.Linq; using Dapper; using Magicodes.ExporterAndImporter.Core; +using NPOI.HPSF; using SettleAccount.Domain.BQ; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Repositories.Dapper; @@ -12,6 +14,31 @@ using Win.Sfs.SettleAccount.Entities.BQ.Temp; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { + + + + + public class EdiWms + { + [ExporterHeader(DisplayName = "生产码", IsBold = true)] + public string PN { set; get; } + [ExporterHeader(DisplayName = "客户零件号", IsBold = true)] + public string LU { set; get; } + [ExporterHeader(DisplayName = "发运时间", IsBold = true, Format = "yyyy-MM-dd")] + public DateTime? BillTime { set; get; } + [ExporterHeader(DisplayName = "订单日期", IsBold = true, Format = "yyyy-MM-dd")] + public DateTime? EDITime { set; get; } + [ExporterHeader(DisplayName = "发运数量", IsBold = true)] + public decimal ShippingQty { set; get; } + [ExporterHeader(DisplayName = "EDI数量", IsBold = true)] + public decimal EdiQty { set; get; } + [ExporterHeader(DisplayName = "差异数量", IsBold = true)] + public decimal DiffQty { set; get; } + [ExporterHeader(DisplayName = "状态", IsBold = true)] + public string State { set; get; } + + + } public class BalanceSum { @@ -463,5 +490,78 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + + + public class EdiWmsDapperRepository : DapperRepository, ITransientDependency + { + public EdiWmsDapperRepository(IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + /// + /// 获取库存余额汇总 + /// + /// + /// + public virtual List GetEdiWms() + { + var sql = + "select * from (\n" + + "select\n" + + "ISNULL(a.PN,b.PN) PN,\n" + + "ISNULL(a.LU,a.LU) LU,A.BillTime,\n" + + "B.EDITime,\n" + + "ISNULL(A.qty,0) ShippingQty,\n" + + "ISNULL(b.qty,0) EdiQty ,\n" + + "case when ISNULL(A.qty,0) >ISNULL(b.qty,0) then '发运比EDI多'\n" + + "when ISNULL(A.qty,0) B.qty ) temp order by EDITime,BillTime\n"; + var entities = DbConnection.Query(sql, null, null, false, 1200, null).ToList(); + foreach(var itm in entities) + { + itm.DiffQty = itm.ShippingQty - itm.EdiQty; + } + return entities.ToList(); + } + + /// + /// 获取库存余额汇总 + /// + /// + /// + public virtual List GetHBPOEdiWms() + { + var sql = + "select * from (\n" + + "select\n" + + "ISNULL(a.PN,b.PN) PN,\n" + + "ISNULL(a.LU,a.LU) LU,A.BillTime,\n" + + "B.EDITime,\n" + + "ISNULL(A.qty,0) ShippingQty,\n" + + "ISNULL(b.qty,0) EdiQty ,\n" + + "case when ISNULL(A.qty,0) >ISNULL(b.qty,0) then '发运比EDI多'\n" + + "when ISNULL(A.qty,0) B.qty ) temp order by EDITime,BillTime\n"; + var entities = DbConnection.Query(sql, null, null, false, 1200, null).ToList(); + foreach (var itm in entities) + { + itm.DiffQty = itm.ShippingQty - itm.EdiQty; + } + return entities.ToList(); + } + + + + } + + }