diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs index 3dba01d8..b8600d2f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs @@ -9,8 +9,8 @@ namespace Win.Sfs.SettleAccount.Reports.SettledPartAndErpPartPriceDiffs { public class SettledPartAndErpPartPriceDiff { - [ExporterHeader(DisplayName = "版本号")] - public string Version{ set; get; } + //[ExporterHeader(DisplayName = "版本号")] + //public string Version{ set; get; } //[ExporterHeader(DisplayName ="物料编号")] //public string MaterialCode { set; get; } @@ -19,11 +19,26 @@ namespace Win.Sfs.SettleAccount.Reports.SettledPartAndErpPartPriceDiffs [ExporterHeader(DisplayName = "ERP物料编号")] public string ErpMaterialCode { set; get; } - [ExporterHeader(DisplayName = "Bom总成价格")] + [ExporterHeader(DisplayName = "Bom组成价格")] public decimal Price { set; get; } - [ExporterHeader(DisplayName = "总成价格")] + [ExporterHeader(DisplayName = "总成定价")] public decimal SumPrice { get; set; } [ExporterHeader(DisplayName = "差额")] public decimal DiffPrice { get; set; } } + public class PartCodeDiff + { + [ExporterHeader(DisplayName = "组成组零件")] + public string ErpMaterialCode {set;get;} + [ExporterHeader(DisplayName = "Sap零件号")] + public string SettleMaterialCode {set;get;} + [ExporterHeader(DisplayName = "客户零件号")] + public string ShipMaterailCode {set;get;} + [ExporterHeader(DisplayName = "物料描述")] + public string MaterialDesc {set;get;} + [ExporterHeader(DisplayName = "物料组车型")] + public string EstimateTypeDesc { set; get; } + + + } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs index b76c64f5..63faf57b 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettledPartAndErpPartPriceDiffRepository.cs @@ -58,7 +58,7 @@ namespace Win.Sfs.SettleAccount.Repository.Report return _query.ToList(); } - public virtual List GetDiffDetailReport(string year, string customcode, string version) + public virtual List GetDiffDetailReport(string year, string customcode, string version) { string sqlString = "select a.ErpMaterialCode,SettleMaterialCode,a.ShipMaterailCode,d.MaterialDesc,d.EstimateTypeDesc from\n" + " Set_MaterialRelationshipDetail_pg a left join\n" + @@ -68,7 +68,7 @@ namespace Win.Sfs.SettleAccount.Repository.Report " MaterialCode \n" + " FROM\n" + " Set_PriceList \n" + -" WHERE\n" + +" WHERE\n" + " version = ( SELECT Max( Version ) FROM Set_PriceList ) and type=10 )\n" + " b on a.SettleMaterialCode=b.MaterialCode \n" + " left join \n" + @@ -78,7 +78,7 @@ namespace Win.Sfs.SettleAccount.Repository.Report " where b.MaterialCode is null"; string _sql = string.Format(sqlString, version, customcode); - var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); //var _query = _db.Query(); return _query.ToList(); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs index 60ad7617..b3321115 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs @@ -1,11 +1,15 @@ -using System; +using Magicodes.ExporterAndImporter.Excel; +using Shouldly; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using TaskJob.EventArgs; using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; +using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount.Reports.SettledPartAndErpPartPriceDiffs; using Win.Sfs.SettleAccount.Repository.Report; @@ -16,11 +20,16 @@ namespace SettleAccount.Job.Services.Report private readonly SettledPartAndErpPartPriceDiffRepository _dapper; private readonly OutputService _outputService; + private readonly IBlobContainer _fileContainer; - public SettledPartAndErpPartPriceDiffExportService(SettledPartAndErpPartPriceDiffRepository dapper, OutputService outputService) + public SettledPartAndErpPartPriceDiffExportService(SettledPartAndErpPartPriceDiffRepository dapper, + + IBlobContainer fileContainer, + OutputService outputService) { _dapper = dapper; _outputService = outputService; + _fileContainer = fileContainer; } @@ -31,7 +40,25 @@ namespace SettleAccount.Job.Services.Report var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; var _list= _dapper.GetDiffReport(DateTime.Now.Year.ToString(), customerCode, version); - _outputService.Export(id,string.Format("Bom定价对比_{0}.xlsx",Guid.NewGuid().ToString()), _list); + var _childList= _dapper.GetDiffDetailReport(DateTime.Now.Year.ToString(), customerCode, version); + var _filename = exportName.FirstOrDefault(); + ExcelExporter _exporter = new ExcelExporter();//导出Excel + + var result = _exporter + .Append(_list, "BOM价格对比明细") + .SeparateBySheet() + .Append(_childList, "无价格零件") + .SeparateBySheet() + + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(_filename, result.Result, true); + + + + + + //_outputService.Export(id,string.Format("Bom定价对比_{0}.xlsx",Guid.NewGuid().ToString()), _list); return id.ToString(); }