From 87faaab49ac71f0535e38e2d9527655b6e4cf922 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 29 Nov 2021 10:46:10 +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/Prices/PriceListAppService.cs | 23 --- .../ReportServices/ReportMakeService.cs | 50 ++++-- .../SettleAccount.Application.xml | 7 + .../Entities/Prices/PriceList.cs | 5 + .../Entities/Prices/PriceListManager.cs | 39 +++-- .../Entities/SettleAccountEntityBase.cs | 2 +- .../Reports/ReportDetailBase.cs | 52 +++--- .../Report/ErpPartDapperRepository.cs | 33 +++- ...nvoiceSettledDetailDiffDapperRepository.cs | 149 ++++++++++++++++-- .../InvoiceSettledDiffDapperRepository.cs | 5 +- .../SettleFisDiffDetailDapperRepository.cs | 1 + .../InvoiceSettledDetailDiffExportService.cs | 80 ++++++++++ .../Report/InvoiceSettledDiffExportService.cs | 4 +- .../SettleAccountJobModule.cs | 7 +- 14 files changed, 358 insertions(+), 99 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index b623c84d..cd8058de 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -170,29 +170,6 @@ namespace Win.Sfs.SettleAccount.Entities.Prices var entityList = ObjectMapper.Map, List>(result); var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault()); - - // List _ls = new List(); - //foreach (var itm in matialCodeList) - //{ - // var priceList= entityList.Where(p => p.MaterialCode == itm).Distinct().ToList(); - // var _list =priceList.OrderBy(p => p.BeginDate).ToList(); - // int i = 0;//查询下条记录 - // foreach (var price in _list) - // { - // i++; - // if (_list.Count == i) - // { - // price.EndDate = DateTime.MaxValue; - // break; - // } - // else - // { - // var _nextPrice = _list[i]; - // price.EndDate = _nextPrice.BeginDate.AddDays(-1); - // } - // _ls.Add(price); - // } - //} foreach (var itm in _ls) { itm.Update(GuidGenerator.Create(),version); 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 27dfbbaf..363a208b 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -267,6 +267,44 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices return _taskid; } + /// + /// 大众发票与结算核对明细表 + /// + /// 上传的文件(前端已经限制只能上传一个附件) + /// + [HttpGet] + [Route("InvoiceSettledDetailDiff-Make")] + [DisableRequestSizeLimit] + + public async Task InvoiceSettledDetailDiffMake( + string version, + string materialCode, + string begin, + string end, + string cp7begin, + string cp7end, + string kenncode, + string chassisNumber + ) + { + + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value =string.IsNullOrEmpty(version) ?string.Empty:version }); + customConditionList.Add(new CustomCondition() { Name = "MaterialCode", Value = string.IsNullOrEmpty(materialCode) ?string.Empty: materialCode }); + customConditionList.Add(new CustomCondition() { Name = "BeginTime", Value = string.IsNullOrEmpty(begin) ? string.Empty : materialCode }); + customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = string.IsNullOrEmpty(end) ? string.Empty : materialCode }); + customConditionList.Add(new CustomCondition() { Name = "Cp7BeginTime", Value = string.IsNullOrEmpty(cp7begin) ? string.Empty : cp7begin }); + customConditionList.Add(new CustomCondition() { Name = "Cp7EndTime", Value = string.IsNullOrEmpty(cp7end) ? string.Empty : cp7end }); + customConditionList.Add(new CustomCondition() { Name = "KennCode", Value = string.IsNullOrEmpty(kenncode) ? string.Empty : kenncode }); + customConditionList.Add(new CustomCondition() { Name = "ChassisNumber", Value = string.IsNullOrEmpty(chassisNumber) ? string.Empty : chassisNumber }); + var _taskid = await _service.ExportEnqueueAsync("大众发票与结算核对明细表", ExportExtentsion.Excel, CurrentUser, typeof(InvoiceSettledDetailDiffExportService), customConditionList, (rs) => + { + }); + return _taskid; + } + + /// /// 3.大众准时化结算数量差异比对表 /// @@ -312,18 +350,6 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices return _taskid; } - - - - - - - - - - - - /// /// 结算总成和ERP总成价格对比 /// diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index fff539fc..38bb8d13 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -2469,6 +2469,13 @@ 上传的文件(前端已经限制只能上传一个附件) + + + 大众发票与结算核对明细表 + + 上传的文件(前端已经限制只能上传一个附件) + + 3.大众准时化结算数量差异比对表 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs index 8c04b57a..a82e122e 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs @@ -8,6 +8,11 @@ using Win.Sfs.Shared.DomainBase; namespace Win.Sfs.SettleAccount.Entities.Prices { + public class ErpPrice + { + public string SapErpPartCode { set; get; } + public decimal SapPrice { set; get; } + } public class PriceList:FullAuditedAggregateRootBase { public PriceList() diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs index 5a34dc83..770c59b7 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs @@ -78,20 +78,37 @@ namespace Win.Sfs.SettleAccount.Entities.Prices var pricelist = GetPriceList(version); - List _list = new List(); - foreach (var itm in pricelist) - { - var entity = entities.FirstOrDefault(p => p.Type == itm.Type && p.CustomerCode == itm.CustomerCode && p.MaterialCode == p.MaterialCode); - if (entity != null) - { - itm.Price = entity.Price; - entities.Remove(entity); - } - } + + //var LeftJoin = from emp in ListOfEmployees + // join dept in ListOfDepartment + // on emp.DeptID equals dept.ID into JoinedEmpDept + // from dept in JoinedEmpDept.DefaultIfEmpty() + + + var add= from itm1 in entities join itm2 in pricelist + on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode } + into temp from itm3 in temp.DefaultIfEmpty() where itm3 == null select itm1; + + var update = from itm1 in entities + join itm2 in pricelist + on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode } + where itm1.Price != itm2.Price + select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode,itm2.Type, itm2.ParentId, itm2.Version); + + + + + + + + + + - await _repository.GetDbContext().BulkInsertAsync(entities); + await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); + await _repository.GetDbContext().BulkInsertAsync(add.ToList()); var _first = _versionRepository.FirstOrDefault(p => p.Version == version); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs index e3e108ad..7794e52e 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/SettleAccountEntityBase.cs @@ -12,7 +12,7 @@ namespace Win.Sfs.SettleAccount.Entities public class CacheManager { public static List CacheMaterials { set; get; } - public static List CachePriceList { set; get; } + public static List CachePriceList { set; get; } } public interface ISettleAccountEntityBase diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs index 038609bd..6da7581c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/ReportDetailBase.cs @@ -10,32 +10,32 @@ namespace Win.Sfs.SettleAccount.Reports public class ReportDetailBase { - [ExporterHeader(DisplayName = "交货单号 ")] - public string WmsBillNum { set; get; } - [ExporterHeader(DisplayName = "实际发货日期 ")] - public DateTime CP5Time { set; get; } - [ExporterHeader(DisplayName = "KENN号")] - public string KENNCode { set; get; } - [ExporterHeader(DisplayName = "底盘号")] - public string ChassisNumber { set; get; } - [ExporterHeader(DisplayName = "交货状态 ")] - public string WmsState { set; get; } - [ExporterHeader(DisplayName = "物料号")] - public string SapMaterialCode { set; get; } - [ExporterHeader(DisplayName = "物料描述 ")] - public string MaterialDesc { set; get; } - [ExporterHeader(DisplayName = "客户物料 ")] - public string MaterialCode { set; get; } - [ExporterHeader(DisplayName = "组件组物料 ")] - public string ParentSapMaterialCode { set; get; } - [ExporterHeader(DisplayName = "组件组物料描述 ")] - public string ParentMaterialDesc { set; get; } - [ExporterHeader(DisplayName = "物料组(车型) ")] - public string MaterialGroup { set; get; } - [ExporterHeader(DisplayName = "定价 ")] - public decimal Price { set; get; } - [ExporterHeader(DisplayName = "金额 ")] - public decimal Amt { set; get; } + + public virtual string WmsBillNum { set; get; } + + public virtual DateTime CP5Time { set; get; } + + public virtual string KENNCode { set; get; } + + public virtual string ChassisNumber { set; get; } + + public virtual string WmsState { set; get; } + + public virtual string SapMaterialCode { set; get; } + + public virtual string MaterialDesc { set; get; } + + public virtual string MaterialCode { set; get; } + + public virtual string ParentSapMaterialCode { set; get; } + + public virtual string ParentMaterialDesc { set; get; } + + public virtual string MaterialGroup { set; get; } + + public virtual decimal Price { set; get; } + + public virtual decimal Amt { set; get; } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs index 2c73e30a..191f51cf 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs @@ -15,7 +15,7 @@ using Win.Sfs.SettleAccount.Reports; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { - + /// /// 主数据Dapper表 @@ -27,10 +27,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - public virtual List GetDiffReport(List childList) where T : ReportDetailBase, new() + public virtual List GetSapList(List childList) where T : ReportDetailBase, new() { List _materialList = new List(); - List _priceList = new List(); + List _priceList = new List(); if (CacheManager.CacheMaterials != null) { _materialList = CacheManager.CacheMaterials; @@ -45,10 +45,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } else { - _priceList = DbConnection.Query("select MaterialCode,Price from Set_PriceList where version=(select max(version) from set_Set_PriceListVersion)").ToList(); + _priceList = DbConnection.Query("select Price SapPrice, MaterialCode SapErpPartCode from Set_PriceList where version=(select max(version) from Set_PriceListVersion)").ToList(); } - List _list = new List(); + + + List _list = new List(); foreach (var itm in childList) { var parentMaterial = new T(); @@ -63,11 +65,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report parentMaterial.ParentSapMaterialCode = itm.ParentSapMaterialCode; parentMaterial.ParentMaterialDesc = itm.ParentMaterialDesc; - var _price = _priceList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault(); + var _price = _priceList.Where(p => p.SapErpPartCode == itm.ParentSapMaterialCode).FirstOrDefault(); if (_price != null) { - parentMaterial.Price = _price.Price; - parentMaterial.Amt = _price.Price; + parentMaterial.Price = _price.SapPrice; + parentMaterial.Amt = _price.SapPrice; + } var _material = _materialList.Where(p => p.MaterialCode == itm.ParentSapMaterialCode).FirstOrDefault(); if (_material != null) @@ -81,5 +84,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report return _list; } + public virtual List GetErpPartCodePriceList(string version) + { + string str = "SELECT\n" + + " ErpMaterialCode SapErpPartCode,\n" + + " SUM( PRICE ) SapPrice \n" + + " FROM \n" + + " Set_MaterialRelationshipDetail A\n" + + " LEFT JOIN ( SELECT SUM( AMT )/ SUM( Qty ) PRICE, MaterialCode FROM Set_Invoice WHERE VERSION = '{0}' GROUP BY MaterialCode ) B ON A.SettleMaterialCode = B.MaterialCode \n" + + "GROUP BY\n" + + " ErpMaterialCode"; + + var _list = DbConnection.Query(string.Format(str, version)); + return _list.ToList(); + } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs index 11a6f149..1acf3d3c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs @@ -1,4 +1,6 @@ -using Magicodes.ExporterAndImporter.Core; +using Dapper; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; using System; using System.Collections.Generic; using System.Linq; @@ -11,18 +13,53 @@ using Win.Sfs.SettleAccount.Reports; namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { - public class InvoiceSettledDetilDiff : ReportDetailBase + [ExcelExporter(MaxRowNumberOnASheet = 500000)] + public class InvoiceSettledDetailDiff + : ReportDetailBase { - //结算数量 + [ExporterHeader(DisplayName = "交货单号 ")] + public override string WmsBillNum { set; get; } + [ExporterHeader(DisplayName = "实际发货日期 ")] + public override DateTime CP5Time { set; get; } + [ExporterHeader(DisplayName = "KENN号")] + public override string KENNCode { set; get; } + [ExporterHeader(DisplayName = "底盘号")] + public override string ChassisNumber { set; get; } + [ExporterHeader(DisplayName = "交货状态 ")] + public override string WmsState { set; get; } + [ExporterHeader(DisplayName = "物料号")] + public override string SapMaterialCode { set; get; } + [ExporterHeader(DisplayName = "物料描述 ")] + public override string MaterialDesc { set; get; } + [ExporterHeader(DisplayName = "客户物料 ")] + public override string MaterialCode { set; get; } + [ExporterHeader(DisplayName = "组件组物料 ")] + public override string ParentSapMaterialCode { set; get; } + [ExporterHeader(DisplayName = "组件组物料描述 ")] + public override string ParentMaterialDesc { set; get; } + [ExporterHeader(DisplayName = "物料组(车型) ")] + public override string MaterialGroup { set; get; } + [ExporterHeader(DisplayName = "定价 ")] + public override decimal Price { set; get; } + [ExporterHeader(DisplayName = "金额 ")] + public override decimal Amt { set; get; } + + + //发运数量 + [ExporterHeader(DisplayName = "M100数量")] + public decimal Qty { set; get; } + + + //结算数量 [ExporterHeader(DisplayName = "结算数量")] - public decimal SettleQty { set; get; } + public decimal SettledQty { set; get; } //结算日期 [ExporterHeader(DisplayName = "结算日期")] - public decimal CP7Time { set; get; } + public DateTime CP7Time { set; get; } //结算与发货差异 [ExporterHeader(DisplayName = "结算与发货差异")] - public decimal DiffFisQty{ set; get; } + public decimal DiffSettleFisQty{ set; get; } //结算与开票差异 [ExporterHeader(DisplayName = "结算与开票差异")] public decimal DiffSettleInvQty { set; get; } @@ -42,8 +79,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "单价差异")] public decimal DiffPrice { set; get; } //总金额差异 - [ExporterHeader(DisplayName = "交货单号 ")] - + [ExporterHeader(DisplayName = "总金额差异")] public decimal AmtDiffPrice { set; get; } @@ -51,20 +87,107 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - public class InvoiceSettledDetailDiffDapperRepository: DapperRepository, ITransientDependency + /// + /// 2.大众发票与结算核对明细表-准时化 + /// + public class InvoiceSettledDetailDiffDapperRepository : DapperRepository, ITransientDependency { public InvoiceSettledDetailDiffDapperRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { } - public virtual List GetInvoiceSettledDetailDiffReportList(string version, string year, string tablename, string materialcode) + public virtual List GetInvoiceSettledDetailDiffReportList(string version, string materialCode, string begin, string end ,string cp7begin,string cp7end,string kennCode,string chassisNumber) { - List _list = new List(); + + List _list = new List(); + + string condition = " where 1=1 "; + + + if (!string.IsNullOrEmpty(materialCode)) + { + condition += string.Format(" d.MaterialCode='{0}' ", materialCode); + } + if (!string.IsNullOrEmpty(begin)) + { + condition += string.Format(" a.BeginTime>='{0}' ", begin); + } + if (!string.IsNullOrEmpty(end)) + { + condition += string.Format(" a.BeginTime<='{0}' ", end); + } + if (!string.IsNullOrEmpty(cp7begin)) + { + condition += string.Format(" B.cp7Time>='{0}' ", cp7begin); + } + if (!string.IsNullOrEmpty(cp7end)) + { + condition += string.Format(" B.cp7Time<='{0}' ", cp7end); + } + if (!string.IsNullOrEmpty(kennCode)) + { + condition += string.Format(" B.kenncode='{0}' ", kennCode); + } + if (!string.IsNullOrEmpty(chassisNumber)) + { + condition += string.Format(" B.chassisNumber='{0}' ", chassisNumber); + } + + string str = + "SELECT\n" + +" temp1.*,\n" + +" TEMP2.Price,(\n" + +" Isnull( temp2.Price, 0 ) * isnull( temp1.Qty, 0 )) Amt \n" + +"FROM\n" + +" (\n" + +" SELECT\n" + +" b.YEAR,\n" + +" b.KENNCode,\n" + +" b.MaterialCode,\n" + +" b.Model,\n" + +" b.ChassisNumber,\n" + +" a.Qty,\n" + +" a.BeginTime CP5Time,\n" + +" a.ChassisNumber2,\n" + +" B.CP7 CP7Time,\n" + +" B.QTY SettledQty,\n" + +" a.ErpMaterialCode ParentSapMaterialCode,\n" + +" a.WMSState,\n" + +" a.WMSBillNum,\n" + +" d.MaterialCode SapMaterialCode,\n" + +" d.MaterialDesc MaterialDesc,\n" + +" d.EstimateTypeDesc MaterialGroup,\n" + +" e.MaterialDesc ParentMaterialDesc,\n" + +" c.InvoicePrice,\n" + +" ( c.InvoicePrice * a.qty ) InvoiceAmt,\n" + +" ( c.InvoicePrice * a.Qty ) SettleAmt,\n" + +" a.Qty - IsNull( B.Qty, 0 ) DiffSettleFisQty,\n" + +" 0 DiffSettleInvQty \n" + +" FROM\n" + +" ( SELECT * FROM Set_Settle b WHERE b.Version = '{0}' ) b\n" + +" INNER JOIN Set_fis a ON b.ChassisNumber = a.ChassisNumber2 \n" + +" AND b.KENNCode = a.KENNCode \n" + +" AND b.MaterialCode = a.ItemCode\n" + +" LEFT JOIN ( SELECT SUM( amt )/ SUM( Qty ) InvoicePrice, MaterialCode FROM set_invoice WHERE version = '{0}' GROUP BY materialcode ) c ON a.ItemCode = c.MaterialCode\n" + +" LEFT JOIN set_material d ON a.ItemCode = d.CustomerPartCode\n" + +" LEFT JOIN set_material e ON a.ErpMaterialCode = e.MaterialCode {1} \n" + +" ) TEMP1\n" + +" LEFT JOIN (\n" + +" SELECT\n" + +" Price,\n" + +" MaterialCode \n" + +" FROM\n" + +" Set_PriceList \n" + +"WHERE\n" + +" version = ( SELECT Max( Version ) FROM Set_PriceList )) TEMP2 ON TEMP1.SapMaterialCode = TEMP2.MaterialCode"; + var _sql = string.Format(str, version,condition); + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + _list=_query.ToList(); - string str = string.Empty; return _list; - + } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs index df1371e9..4ffc2c92 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDiffDapperRepository.cs @@ -52,10 +52,11 @@ string.Format(" '{0}' as Version ,", version)+"\n" + " (\n" + " b.InvoiceQty - ISnull(\n" + " c.Qty,\n" + -" IsNull( d.qty, 0 ))) DiffQty,\n" + +" IsNull( d.qty, 0 ))) DiffQty,\n" + " g.MaterialCode AS SapMaterialCode,\n" + -" g.MaterialDesc AS MaterialDesc \n" + +" g.MaterialDesc AS MaterialDesc, \n" + +" g.EstimateTypeDesc as SapMaterialGroup \n " + " FROM\n" + " (\n" + " SELECT\n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs index b3bfbef8..b3a2d5a0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleFisDiffDetailDapperRepository.cs @@ -37,6 +37,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report [ExporterHeader(DisplayName = "M100数量" )] public decimal Qty { set; get; } [ExporterHeader(DisplayName = "差异")] + public decimal DiffQty { set; get; } [ExporterHeader(DisplayName = "开票单价" )] public decimal Price{ set; get; } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs new file mode 100644 index 00000000..9c2de9f9 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs @@ -0,0 +1,80 @@ +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.DependencyInjection; +using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs; +using Win.Sfs.SettleAccount.Repository.SettleAccount; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; + +namespace SettleAccount.Job.Services +{ + /// + /// 2.大众发票与结算核对明细表-准时化 + /// + public class InvoiceSettledDetailDiffExportService : ITransientDependency, IExportJob + { + + private readonly InvoiceSettledDetailDiffDapperRepository _dapperRepository; + private readonly ErpPartDapperRepository _erpdapperRepository; + + private readonly OutputService _outputService; + private readonly InputService _inputService; + + public InvoiceSettledDetailDiffExportService( + + ErpPartDapperRepository erpdapperRepository, + InvoiceSettledDetailDiffDapperRepository dapperRepository, + OutputService outputService, + InputService inputService + ) + { + _inputService = inputService; + _outputService = outputService; + _erpdapperRepository= erpdapperRepository; + //_repository = repository; + //_versionRepository = versionRepository; + _dapperRepository =dapperRepository; + } + + public string ExportFile(Guid id, List exportName, List p_list) + { + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; + var begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value; + var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; + var cp7begin = p_list.Where(p => p.Name == "Cp7BeginTime").FirstOrDefault().Value; + var cp7end = p_list.Where(p => p.Name == "Cp7EndTime").FirstOrDefault().Value; + var kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value; + var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value; + var _ls = _dapperRepository.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber); + var _list = _ls.GroupBy(p => p.ParentSapMaterialCode).Select(p => p.FirstOrDefault()).ToList(); + + var rangeList = _erpdapperRepository.GetSapList(_list); + rangeList.ForEach(p => { + p.Qty = 1; + p.InvoiceQty = 1; + p.SettledQty = 1; + p.DiffSettleFisQty = 0; + p.DiffSettleInvQty = 0; + + }); + + + _ls.AddRange(rangeList); + _ls.OrderBy(p => new { p.ChassisNumber, p.KENNCode }); + _outputService.Export(id, string.Format("大众发票与结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls); + + + + //_repository.Insert(_list); + //_versionRepository.Insert(_id, version, customerCode, customerCode, string.Empty, string.Empty, projectName); + return id.ToString(); + } + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs index 099b2b5f..7e08ed8f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDiffExportService.cs @@ -66,12 +66,12 @@ namespace SettleAccount.Job.Services SettleQty =itm. SettleQty , CP7ScrapQty =itm. CP7ScrapQty , ClaimQty =itm. ClaimQty , - DiffQty =itm. DiffQty , + DiffQty = itm.InvoiceQty-itm.SettleQty-itm.CP7ScrapQty-itm.ClaimQty,//开票数量-结算数量-CP7报废数量-索赔数量 SalePrice =itm. SalePrice , DiffPrice =itm. DiffPrice , SapMaterialCode =itm.SapMaterialCode , MaterialDesc=itm.MaterialDesc, - + SapMaterialGroup=itm.SapMaterialGroup, Factory = itm.Factory, diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index 15c76cde..3bd2f36b 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -107,9 +107,14 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } - + if (key.Equals(typeof(InvoiceSettledDetailDiffExportService).FullName)) + { + return implementationFactory.GetService(); + } else { + + throw new ArgumentException($"Not Support key:{key}"); } }; return accesor;