diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs index 961e41ca..816e4aaa 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs @@ -292,11 +292,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _list = _excelHelper.ExcelToList(); foreach (var itm in _list) { - - - - - itm.SetData(GuidGenerator.Create(),string.Empty,!string.IsNullOrEmpty(itm.WmsBillNum)? itm.WmsBillNum:string.Empty,input.Version,GuidGenerator.Create()); } _lst.AddRange(_list.ToArray()); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs index 67af3e2a..70b3f887 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -154,20 +154,12 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts public async Task WmsSharePartAudit(List ids) { - var _joblist =await _job.Where(p => ids.Contains(p.Id)).ToListAsync(); + var _joblist = await _job.Where(p => ids.Contains(p.Id)).ToListAsync(); foreach (var itm in _joblist) { itm.FileName = "已确认"; - } - foreach (var itm in _joblist) - { await _job.UpdateAsync(itm); } - var _count=await _job.BatchUpdateAsync(_joblist.ToList()); - if (_count > 0) - { - return true; - } return false; } /// @@ -193,35 +185,36 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var _list = _excelHelper.ExcelToList(); if (_list.Count() > 0) { - var _lsAry = _list.GroupBy(p => new - { - p.MaterialCode, - p.MaterialGroup, - p.OrderBillNum, - p.MaterialDesc, - p.Version, - p.WmsBillNum, - }).Select(p => new - WmsSharePartOutPutDetial( - GuidGenerator.Create(), - p.Key.WmsBillNum, - p.Key.OrderBillNum, - p.Key.MaterialCode, - p.Key.MaterialDesc, - p.Key.MaterialGroup, - string.Empty, - string.Empty, - 0, - string.Empty, - string.Empty, - string.Empty, - p.Key.MaterialCode, - _billNum, - GuidGenerator.Create(), - string.Empty, - p.Sum(itm => itm.Qty) - )); - _lst.AddRange(_lsAry.ToArray()); + + //var _lsAry = _list.GroupBy(p => new + //{ + // p.MaterialCode, + // p.MaterialGroup, + // p.OrderBillNum, + // p.MaterialDesc, + // p.Version, + // p.WmsBillNum, + //}).Select(p => new + //WmsSharePartOutPutDetial( + // GuidGenerator.Create(), + // p.Key.WmsBillNum, + // p.Key.OrderBillNum, + // p.Key.MaterialCode, + // p.Key.MaterialDesc, + // p.Key.MaterialGroup, + // string.Empty, + // string.Empty, + // 0, + // string.Empty, + // string.Empty, + // string.Empty, + // p.Key.MaterialCode, + // _billNum, + // GuidGenerator.Create(), + // string.Empty, + // p.Sum(itm => itm.Qty) + //)); + _lst.AddRange(_list.ToArray()); } } @@ -229,67 +222,34 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var error = from itm1 in outPutDetail join itm2 in _lst on - new { itm1.MaterialCode, itm1.OrderBillNum } + new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum } equals - new { itm2.MaterialCode, itm2.OrderBillNum } + new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum } select itm1; var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); if (errList.Count() == 0) { - var query = from itm1 in _lst join itm2 in outPutDetail on - new { itm1.MaterialCode, itm1.OrderBillNum } + new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } equals - new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 + new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1 from tm1 in temp1.DefaultIfEmpty() where tm1 == null select itm1; var _wmslst = query.ToList(); - _wmslst = _wmslst.GroupBy(p => new - { - p.MaterialCode, - p.MaterialGroup, - p.OrderBillNum, - p.MaterialDesc, - p.Version, - p.WmsBillNum, - }).Select(p => new - WmsSharePartOutPutDetial( - GuidGenerator.Create(), - p.Key.WmsBillNum, - p.Key.OrderBillNum, - p.Key.MaterialCode, - p.Key.MaterialDesc, - p.Key.MaterialGroup, - string.Empty, - string.Empty, - 0, - string.Empty, - string.Empty, - string.Empty, - p.Key.MaterialCode, - _billNum, - GuidGenerator.Create(), - string.Empty, - p.Sum(itm => itm.Qty) - )).ToList(); - foreach (var itm in _wmslst) { itm.BillNum = _billNum; } await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); - if (_count == 0) + if (_wmslst.Count()>0 && _count == 0) { var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); - await _wmsVersionRepository.InsertAsync(_version, true); - } - foreach (var job in _joblist) { job.FileName = _billNum; @@ -310,7 +270,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts job.FileName = _errinfo; await _job.UpdateAsync(job); } - } } else 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 d8692cef..cbfaa5ba 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -199,7 +199,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty }); customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty }); customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" }); - customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty }); customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" }); customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index 4dadc755..f7688851 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -1732,7 +1732,7 @@ wms出库 - + @@ -1852,7 +1852,7 @@ wms出库 - + @@ -3293,21 +3293,21 @@ - H平台发运核对输出 + H平台未结明细 - F平台发运核对输出 + F平台未结明细 - M平台发运核对输出 + M平台未明细 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs index ab738021..bef96f9d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs @@ -982,14 +982,14 @@ namespace Win.Sfs.SettleAccount.Entities.WMS Id = id; } - // 交货单号 实际发货日期 KENN号 底盘号 物料号 物料描述 客户物料 组件组物料 组件组物料描述 物料组(车型) 定价 金额 结算平台未结数量 大众R3未结数量 差异金额 差异数量 漏结标识 漏结期间 说明 - //交货单号 + // 期间 交货单号 发货日期 采购订单号 SAP编码 物料代码 物料描述 物料组 开票单价 数量差异 发货数量 开票数量 定价 单价差异 - [ImporterHeader(Name = "组件组物料")] + + [ImporterHeader(Name = "组件组物料",IsIgnore =true)] public string ParentMaterialCode { set; get; } [ImporterHeader(Name = "交货单号")] public string WmsBillNum { set; get; } - [ImporterHeader(Name = "看板号")] + [ImporterHeader(Name = "采购订单号")] //KENN号 public string OrderBillNum { set; get; } @@ -1032,6 +1032,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS public string BillNum { set; get; } + [ImporterHeader(Name = "任务代码", IsIgnore = true)] public Guid TaskId { 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 efb50ad0..10ecbb45 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 @@ -164,5 +164,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var _list = DbConnection.Query(string.Format(str, version)); return _list.ToList(); } + + + + } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQMSettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQMSettledDetailDapperRepository.cs index ac559d34..62b3733b 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQMSettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQMSettledDetailDapperRepository.cs @@ -197,7 +197,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " Set_HQ_M_Platform \n" + " WHERE\n" + " version = '{0}' \n" + - " AND HQHKanBan = 'BJ' { 1 } \n" + + " AND HQHKanBan = 'BJ' {1} \n" + " GROUP BY\n" + " MaterialCode,\n" + " StorageLocation,\n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 7b97f9e7..f3c26d8d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -2,6 +2,7 @@ using Magicodes.ExporterAndImporter.Core; using System; using System.Collections.Generic; + using System.Linq; using System.Text; using System.Threading.Tasks; @@ -23,59 +24,53 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, string begintime, string endtime) { - string sqlString = "SELECT\n" + - " * ,\n" + - " ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" + - " ISNULL( Price * ReceiptQty - InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" + - " \n" + - "FROM\n" + + string sqlString = + " SELECT\n" + + " temp1.期间,\n" + + " temp1.交货单号,\n" + + " temp1.发货日期,\n" + + " temp1.采购订单号,\n" + + " temp1.SAP编码,\n" + + " temp1.物料代码,\n" + + " temp1.物料描述,\n" + + " temp1.物料组,\n" + + " temp1.开票单价,\n" + + " temp1.数量差异,\n" + + " temp1.发货数量,\n" + + " temp1.开票数量,\n" + + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + + " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" + + " FROM\n" + " (\n" + " SELECT\n" + - " c.LineNumber,--行号\n" + - " c.Period AS WMSDeliveryDate,--交货日期\n" + - " c.WMSDeliveryNote,--交货单号\n" + - " c.SpareDate AS OrderDate,--订单日期\n" + - " a.PurchaseOrderNo,--采购订单号\n" + - " b.MaterialCode AS SAPCode,--SAP编码,即厂内物料号\n" + - " a.MaterialCode,--物料代码\n" + - " b.MaterialDesc,--物料描述\n" + - " a.PurchaseOrderNoText,--采购订单文本\n" + - " c.ReceiptQty,-- 发货数量\n" + - " a.InvoicedQty AS InvoicedQty,--开票数量\n" + - " ( c.ReceiptQty- d.Amt ) AS SettleInvoiceDiffQty,--发货与开票差异\n" + - " d.InvoicePrice,--开票单价\n" + - " 0 AS InvoiceMoney --开票金额\n" + - " \n" + + " a.Version AS 期间,\n" + + " b.WMSDeliveryNote AS 交货单号,\n" + + " b.SpareDate AS 发货日期,\n" + + " a.PurchaseOrderNo AS 采购订单号,\n" + + " c.MaterialCode AS SAP编码,\n" + + " a.MaterialCode AS 物料代码,\n" + + " c.MaterialDesc AS 物料描述,\n" + + " c.EstimateTypeDesc AS 物料组,\n" + + " a.PurchasePriceNoTax AS 开票单价,\n" + + " 0 AS 数量差异,\n" + + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + + " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" + + " FROM\n" + + " (SELECT SUM( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart GROUP BY PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + + " LEFT OUTER JOIN Set_WMSSparePart AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" + + " AND a.MaterialCode = b.MaterialCode\n" + + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " WHERE\n" + + " ( a.Version = '{0}' )) AS temp1\n" + + " LEFT OUTER JOIN (\n" + + " SELECT\n" + + " Price,\n" + + " MaterialCode \n" + " FROM\n" + - " (\n" + - " SELECT\n" + - " t.PurchaseOrderNoText,\n" + - " t.LineNumber,\n" + - " t.PurchaseOrderNo,\n" + - " t.MaterialCode,\n" + - " MAX ( t.SpareDate ) SpareDate,\n" + - " t.DeliveryOrderNo,\n" + - " SUM ( t.InvoicedQty ) AS InvoicedQty \n" + - " FROM\n" + - " Set_SparePart t \n" + - " WHERE\n" + - " t.Version= '{0}' \n" + - " GROUP BY\n" + - " t.PurchaseOrderNo,\n" + - " t.MaterialCode,\n" + - " t.SpareDate,\n" + - " t.DeliveryOrderNo,\n" + - " t.LineNumber,\n" + - " t.PurchaseOrderNoText \n" + - " ) AS a\n" + - " LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" + - " LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" + - " AND a.MaterialCode= c.MaterialCode\n" + - " LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode, Amt FROM set_invoice WHERE version = '{0}' GROUP BY materialcode, Amt ) d ON a.MaterialCode= d.MaterialCode \n" + - " ) TEMP1\n" + - " LEFT JOIN ( SELECT Price, --定价\n" + - " MaterialCode --厂内物料号\n" + - " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode"; + " Set_PriceList \n" + + " WHERE\n" + + " (\n" + + " Version = ( SELECT MAX(Version) AS Expr1 FROM Set_PriceList ))) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode"; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); //if (!string.IsNullOrEmpty(purchaseOrderNo)) @@ -135,7 +130,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ) TEMP1 \n" + " LEFT JOIN ( SELECT Price, --定价 \n" + " MaterialCode --厂内物料号 \n" + - " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode "; + " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList_20 ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode "; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); //if (!string.IsNullOrEmpty(purchaseOrderNo)) @@ -162,66 +157,146 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + public virtual List GetSettleSparePartSumQtyDiff(string version) + { + string sqlString = "SELECT\n" + + " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + + " a.PurchaseOrderNo 订单号,\n" + + " a.MaterialCode 物料号 \n" + + " FROM\n" + + " ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart where Version='{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" + + " LEFT JOIN ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode \n" + + " AND A.PurchaseOrderNo = B.PurchaseOrderNo"; + string addwhere = string.Empty; + string addSqlStr = string.Format(sqlString, version); + + + string _sql = string.Format(addSqlStr, addwhere); + + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + return _query.ToList(); + + } + } - /// - /// 大众看板有条码报表 - /// - //[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)] + + + + + + + + + + +public class SparePartSumQtyDiff +{ + public decimal 数量差异 { set; get; } + public string 订单号 { set; get; } + public string 物料号 { set; get; } +} + + + + + + + +/// +/// 大众看板有条码报表 +/// +//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)] public class SettleSparePartExport { - [ExporterHeader(DisplayName = "行号")] - public string LineNumber { set; get; } - [ExporterHeader(DisplayName = "交货日期")] - public string WMSDeliveryDate { set; get; } + [ExporterHeader(DisplayName = "期间 ")] + public string 期间 {set;get;} + [ExporterHeader(DisplayName = "交货单号 ")] + public string 交货单号 {set;get;} + [ExporterHeader(DisplayName = "发货日期")] + public string 发货日期 {set;get;} + [ExporterHeader(DisplayName = "采购订单号")] + public string 采购订单号 {set;get;} + [ExporterHeader(DisplayName = "SAP编码")] + public string SAP编码 {set;get;} + [ExporterHeader(DisplayName = "物料代码")] + public string 物料代码 {set;get;} + [ExporterHeader(DisplayName = "物料描述")] + public string 物料描述 {set;get;} + [ExporterHeader(DisplayName = "物料组")] + public string 物料组 {set;get;} + [ExporterHeader(DisplayName = "开票单价")] + public decimal 开票单价 {set;get;} + [ExporterHeader(DisplayName = "数量差异")] + public decimal 数量差异 {set;get;} + [ExporterHeader(DisplayName = "发货数量")] + public decimal 发货数量 {set;get;} + [ExporterHeader(DisplayName = "开票数量")] + public decimal 开票数量 {set;get;} + [ExporterHeader(DisplayName = "定价")] + public decimal 定价 {set;get;} + [ExporterHeader(DisplayName = "单价差异")] + public decimal 单价差异 { set; get;} - [ExporterHeader(DisplayName = "交货单号")] - public string DeliveryOrderNo { set; get; } - [ExporterHeader(DisplayName = "订单日期")] - public DateTime OrderDate{ set; get; } - [ExporterHeader(DisplayName = "采购订单号")] - public string PurchaseOrderNo { set; get; } - [ExporterHeader(DisplayName = "SAP编码")] - public string SAPCode { set; get; } - [ExporterHeader(DisplayName = "物料代码")] - public string MaterialCode { set; get; } - [ExporterHeader(DisplayName = "物料描述")] - public string MaterialDesc { set; get; } - [ExporterHeader(DisplayName = "采购订单文本")] - public string PurchaseOrderNoText { set; get; } + //[ExporterHeader(DisplayName = "行号")] + //public string LineNumber { set; get; } - [ExporterHeader(DisplayName = "发货数量")] - public decimal ReceiptQty { set; get; } + //[ExporterHeader(DisplayName = "交货日期")] + //public string WMSDeliveryDate { set; get; } - [ExporterHeader(DisplayName = "开票数量")] - public decimal InvoicedQty { set; get; } + //[ExporterHeader(DisplayName = "交货单号")] + //public string DeliveryOrderNo { set; get; } - [ExporterHeader(DisplayName = "发货与开票差异")] - public decimal SettleInvoiceDiffQty { set; get; } + //[ExporterHeader(DisplayName = "订单日期")] + //public DateTime OrderDate{ set; get; } - [ExporterHeader(DisplayName = "开票单价")] - public decimal InvoicePrice { set; get; } + //[ExporterHeader(DisplayName = "采购订单号")] + //public string PurchaseOrderNo { set; get; } - [ExporterHeader(DisplayName = "开票金额")] - public decimal InvoiceMoney { set; get; } - [ExporterHeader(DisplayName = "定价")] - public decimal Price { set; get; } + //[ExporterHeader(DisplayName = "SAP编码")] + //public string SAPCode { set; get; } - [ExporterHeader(DisplayName = "单价差异")] - public decimal InvoiceDiffPrice { set; get; } + //[ExporterHeader(DisplayName = "物料代码")] + //public string MaterialCode { set; get; } + + //[ExporterHeader(DisplayName = "物料描述")] + //public string MaterialDesc { set; get; } + + //[ExporterHeader(DisplayName = "采购订单文本")] + //public string PurchaseOrderNoText { set; get; } + + //[ExporterHeader(DisplayName = "发货数量")] + //public decimal ReceiptQty { set; get; } + + //[ExporterHeader(DisplayName = "开票数量")] + //public decimal InvoicedQty { set; get; } + + //[ExporterHeader(DisplayName = "发货与开票差异")] + //public decimal SettleInvoiceDiffQty { set; get; } + + //[ExporterHeader(DisplayName = "开票单价")] + //public decimal InvoicePrice { set; get; } + + //[ExporterHeader(DisplayName = "开票金额")] + //public decimal InvoiceMoney { set; get; } + //[ExporterHeader(DisplayName = "定价")] + //public decimal Price { set; get; } + + //[ExporterHeader(DisplayName = "单价差异")] + //public decimal InvoiceDiffPrice { set; get; } - [ExporterHeader(DisplayName = "总金额差异")] - public decimal SumDiffMoney { set; get; } + //[ExporterHeader(DisplayName = "总金额差异")] + //public decimal SumDiffMoney { set; get; } } } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs index 81de8f03..3c5d35ff 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -26,30 +26,70 @@ namespace SettleAccount.Job.Services.Report public string ExportFile(Guid id, List exportName, List p_list) { - + var fileName=exportName.FirstOrDefault(); var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value; var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; var matialCode = p_list.Where(p => p.Name == "MatialCode").FirstOrDefault().Value; var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; - var _list = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version); + var _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); if (diffList != null) { foreach (var itm in diffList) { - var _first = _list.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); + var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && p.物料代码==itm.物料号); if (_first != null) { - _first.InvoicedQty = _first.InvoicedQty + itm.DiffQty;//开票数量(结算数量+差异) - _first.InvoiceMoney = Math.Round(_first.InvoicedQty * _first.InvoicePrice, 2);//开票总金额(开票数量*开票单价) - _first.SumDiffMoney = (_first.ReceiptQty * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额) + _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) + _first.数量差异 = itm.数量差异; + } } } - _outputService.Export(id, string.Format("大众备件结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _list); + //if (!string.IsNullOrEmpty(materialGroup)) + //{ + // var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); + // } + //} + if (!string.IsNullOrEmpty(sapCode)) + { + var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList(); + } + } + if (!string.IsNullOrEmpty(matialCode)) + { + var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _ls = _ls.Where(p => _groupList.Contains(p.物料代码)).ToList(); + } + } + if (!string.IsNullOrEmpty(purchaseOrderNo)) + { + var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _ls = _ls.Where(p => _groupList.Contains(p.采购订单号)).ToList(); + } + } + + + + + + + + + _outputService.Export(id, fileName, _ls); return id.ToString();