Browse Source

备件数据调整反向报表输出

FoShanPG
44673626 3 years ago
parent
commit
c023dda675
  1. 60
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs
  2. 22
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs

60
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs

@ -105,7 +105,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
"ORDER BY\n" +
" temp1.采购订单号";
;
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
@ -118,6 +117,65 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
public virtual List<SettleSparePart90Export> GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime)
{
string sqlString = "SELECT\n" +
" temp1.交货日期,\n" +
" temp1.交货单号,\n" +
" '' 订单日期,\n" +
" temp1.采购订单号,\n" +
" temp1.SAP编码,\n" +
" temp1.物料代码,\n" +
" temp1.物料描述,\n" +
" temp1.采购订单文本,\n" +
" temp1.发货数量,\n" +
" temp1.开票数量,\n" +
" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" +
" temp1.开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" +
" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" a.PurchaseOrderNo AS 采购订单号,\n" +
" a.WMSDeliveryNote AS 交货单号,\n" +
" a.SpareDate AS 交货日期,\n" +
" a.MaterialCode AS 物料代码,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
" c.MaterialCode AS SAP编码,\n" +
" c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" +
" b.Version AS 期间,\n" +
" b.PurchaseOrderNoText AS 采购订单文本,\n" +
" b.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" +
" ISNULL( b.InvoicedQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( b.AmountNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" +
" Set_WMSSparePart a\n" +
" LEFT JOIN ( SELECT PurchaseOrderNo, Version, PurchaseOrderNoText, PurchasePriceNoTax, InvoicedQty, AmountNoTax FROM Set_SparePart WHERE Version = '{0}' ) b ON a.PurchaseOrderNo = b.PurchaseOrderNo\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" b.PurchaseOrderNo IS NULL \n" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
"ORDER BY\n" +
" temp1.采购订单号";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
string _sql = string.Format(addSqlStr, addwhere);
//string _sql = string.Format(sqlString, version);
var _query = DbConnection.Query<SettleSparePart90Export>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
//public virtual List<SparePart90SumQtyDiff> GetSettleSparePart90SumQtyDiff(string version)
//{
// string sqlString = "SELECT\n" +

22
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.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.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report
@ -15,12 +19,15 @@ namespace SettleAccount.Job.Services.Report
private readonly SettleSparePart90DapperReportRepository _dapper;
private readonly OutputService _outputService;
private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService)
public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService,
IBlobContainer<MyFileContainer> fileContainer)
{
_dapper = dapper;
_outputService = outputService;
_erpdapperRepository = erpdapperRepository;
_fileContainer = fileContainer;
}
@ -34,6 +41,7 @@ namespace SettleAccount.Job.Services.Report
var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value;
var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
var _unls = _dapper.GetUnSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version);
//if (diffList != null)
@ -86,11 +94,17 @@ namespace SettleAccount.Job.Services.Report
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls.ToList(), "大众备件数据调整")
.SeparateBySheet()
.Append(_unls.ToList(), "有发货无结算")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(fileName, result.Result, true);
_outputService.Export<SettleSparePart90Export>(id, fileName, _ls);
//_outputService.Export<SettleSparePart90Export>(id, fileName, _ls);
return id.ToString();

Loading…
Cancel
Save