From 1eddc320b8cb57f7685548cb8f1589c0bd9acb6b Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 16 Mar 2022 15:23:05 +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 --- .../ReportServices/ReportMakeService.cs | 37 +++++++++++ .../SettledPartAndErpPartPriceDiff.cs | 4 +- ...ettledPartAndErpPartPriceDiffRepository.cs | 64 ++++++++++++++++--- .../InvoiceSettledDetailDiffExportService.cs | 8 +-- ...ledPartAndErpPartPriceDiffExportService.cs | 2 +- 5 files changed, 99 insertions(+), 16 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index e20f8fe2..78edb22a 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -313,6 +313,43 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices } + /// + /// 结算总成和ERP总成价格对比 + /// + /// 上传的文件(前端已经限制只能上传一个附件) + /// + [HttpGet] + [Route("BomDiffPrice-Make")] + [DisableRequestSizeLimit] + + public async Task SettledPartAndErpPartPriceDiffMake(string version, string customerCode) + { + + if (!_relationshipRepository.Any(p => p.Version == version && p.CustomerCode == customerCode)) + { + throw new BusinessException("8989", string.Format("不存总成与结算件零件关系{0}期间", version)); + } + if (!_settlementPartVersionrepository.Any(p => p.Version == version && p.CustomerCode == customerCode)) + { + throw new BusinessException("8989", string.Format("不存结算包价格{0}期间", version)); + } + + List customConditionList = new List(); + + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "Bom定价差异明细" }); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode }); + + var _taskid = await _service.ExportEnqueueAsync("Bom定价差异明细", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettledPartAndErpPartPriceDiffExportService), customConditionList, (rs) => + { + + }); + return _taskid; + } + + + + /// /// 看板未结输出 /// 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 9567de5b..3dba01d8 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettledPartAndErpPartPriceDiffs/SettledPartAndErpPartPriceDiff.cs @@ -19,9 +19,9 @@ namespace Win.Sfs.SettleAccount.Reports.SettledPartAndErpPartPriceDiffs [ExporterHeader(DisplayName = "ERP物料编号")] public string ErpMaterialCode { set; get; } - [ExporterHeader(DisplayName = "总成价格")] + [ExporterHeader(DisplayName = "Bom总成价格")] public decimal Price { set; get; } - [ExporterHeader(DisplayName = "结算总成价格")] + [ExporterHeader(DisplayName = "总成价格")] public decimal SumPrice { get; set; } [ExporterHeader(DisplayName = "差额")] public decimal DiffPrice { get; set; } 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 39979f27..b76c64f5 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 @@ -21,16 +21,35 @@ namespace Win.Sfs.SettleAccount.Repository.Report public virtual List GetDiffReport(string year, string customcode, string version) { - string sqlString = " select " + string.Format(" {0} as Version , ", version) + " r1.ErpMaterialCode, r2.Price, r1.SumPrice , r1.MaterialDesc, (isnull(r2.Price,0)-isnull(r1.SumPrice,0)) as diffPrice from \n" + - "( select ErpMaterialCode, MaterialDesc, SUM(Price) as SumPrice from(\n" + - "select a.ErpMaterialCode, b.SettlementPartCode, a.MaterialDesc, (a.Qty * b.Price) as Price from\n" + - "(SELECT ErpMaterialCode, MaterialDesc, SettleMaterialCode, Qty, Version ,CustomerCode \n" + - "FROM [Set_MaterialRelationshipDetail] mdetail \n" + + string sqlString = "SELECT\n" + +" t1.ErpMaterialCode,\n" + +" t1.Price SumPrice,\n" + +" t2.Price,\n" + +" t3.MaterialDesc,\n" + +" t3.EstimateTypeDesc ,\n" + - " where mdetail.Version='{0}' and mdetail.CustomerCode='{1}' \n" + - ") a \n" + - "inner join Set_settlement_part b on a.Version = b.Version and a.SettleMaterialCode = b.SettlementPartCode and a.CustomerCode = b.CustomerCode) temp group by ErpMaterialCode, MaterialDesc) r1 left join set_pricelist r2 " + - " on r2.MaterialCode=r1.ErpMaterialCode and r2.Version='{0}'\n"; +" (ISNULL(t1.price,0)-ISNULL(t2.price,0)) DiffPrice\n" + + +"FROM\n" + +" (\n" + +" SELECT\n" + +" ErpMaterialCode,\n" + +" SUM( amt ) Price \n" + +" FROM\n" + +" (\n" + +" SELECT\n" + +" ErpMaterialCode,\n" + +" SettleMaterialCode,(\n" + +" Qty * isnull( b.Price, 0 )) amt \n" + +" FROM\n" + +" Set_MaterialRelationshipDetail a\n" + +" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) b ON a.SettleMaterialCode = b.MaterialCode \n" + +" ) temp1 \n" + +" GROUP BY\n" + +" ErpMaterialCode \n" + +" ) t1\n" + +" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT Max( Version ) FROM Set_PriceList ) AND type = 10 ) t2 ON t1.ErpMaterialCode = t2.MaterialCode\n" + +" LEFT JOIN ( SELECT max( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) t3 ON t1.ErpMaterialCode = t3.MaterialCode"; string _sql = string.Format(sqlString, version, customcode); @@ -38,5 +57,32 @@ namespace Win.Sfs.SettleAccount.Repository.Report //var _query = _db.Query(); return _query.ToList(); } + + 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" + +" (\n" + +" SELECT\n" + +" Price,\n" + +" MaterialCode \n" + +" FROM\n" + +" Set_PriceList \n" + +" WHERE\n" + +" version = ( SELECT Max( Version ) FROM Set_PriceList ) and type=10 )\n" + +" b on a.SettleMaterialCode=b.MaterialCode \n" + +" left join \n" + +" set_material d ON a.ShipMaterailCode = d.CustomerPartCode\n" + +" \n" + +" \n" + +" where b.MaterialCode is null"; + string _sql = string.Format(sqlString, version, customcode); + + 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/InvoiceSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs index 5446acc8..95c25bde 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs @@ -180,11 +180,11 @@ namespace SettleAccount.Job.Services _ls = _ls.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList(); } } - - - //.Select(p => p.FirstOrDefault()); - _ls = _ls.OrderBy(p => p.SapMaterialCode).ThenBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ToList(); + + + //.Select(p => p.FirstOrDefault()); + _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList(); } _outputService.Export(id, _filename, _ls); 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 59a21ca9..60ad7617 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettledPartAndErpPartPriceDiffExportService.cs @@ -31,7 +31,7 @@ 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("总成定价和结算价对比_{0}.xlsx",Guid.NewGuid().ToString()), _list); + _outputService.Export(id,string.Format("Bom定价对比_{0}.xlsx",Guid.NewGuid().ToString()), _list); return id.ToString(); }