Administrator 3 years ago
parent
commit
d7bcfbd9a9
  1. 101
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  2. 48
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs

101
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs

@ -85,7 +85,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" PurchaseOrderNoText,\n" + " PurchaseOrderNoText,\n" +
" AmountNoTax \n" + " AmountNoTax \n" +
" FROM\n" + " FROM\n" +
" Set_SparePart \n" + " Set_SparePart WHERE Extend != 'is90' \n" +
" GROUP BY\n" + " GROUP BY\n" +
" PurchaseOrderNo,\n" + " PurchaseOrderNo,\n" +
" MaterialCode,\n" + " MaterialCode,\n" +
@ -194,7 +194,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
/// <summary> /// <summary>
/// 有发货无结算的报表统计 /// 有结算无发货的报表统计
/// </summary> /// </summary>
/// <param name="purchaseOrderNo"></param> /// <param name="purchaseOrderNo"></param>
/// <param name="version"></param> /// <param name="version"></param>
@ -203,14 +203,14 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
/// <param name="begintime"></param> /// <param name="begintime"></param>
/// <param name="endtime"></param> /// <param name="endtime"></param>
/// <returns></returns> /// <returns></returns>
public virtual List<SettleSparePartExport> GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, public virtual List<SettleSparePartExport> GetForwardSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime) string begintime, string endtime)
{ {
string sqlString = "SELECT\n" + string sqlString = "SELECT\n" +
" temp1.交货日期,\n" + " temp1.交货日期,\n" +
" temp1.交货单号,\n" + " '' 交货单号,\n" +
" '' 订单日期,\n" + " '' 订单日期,\n" +
" temp1.采购订单号,\n" + " '' 采购订单号,\n" +
" temp1.SAP编码,\n" + " temp1.SAP编码,\n" +
" temp1.物料代码,\n" + " temp1.物料代码,\n" +
" temp1.物料描述,\n" + " temp1.物料描述,\n" +
@ -226,30 +226,91 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
"FROM\n" + "FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" a.PurchaseOrderNo AS 采购订单号,\n" + " a.Version AS 期间,\n" +
" a.WMSDeliveryNote AS 交货单号,\n" + " '' AS 采购订单文本,\n" +
" a.SpareDate AS 交货日期,\n" + " NULL AS 交货日期,\n" +
" a.MaterialCode AS 物料代码,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
" c.MaterialCode AS SAP编码,\n" + " c.MaterialCode AS SAP编码,\n" +
" a.MaterialCode AS 物料代码,\n" +
" c.MaterialDesc AS 物料描述,\n" + " c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" + " c.EstimateTypeDesc AS 物料组,\n" +
" a.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" +
" ( a.Version = '{0}' ) \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";
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<SettleSparePartExport>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
/// <summary>
/// 有发货无结算的报表统计
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="version"></param>
/// <param name="sapCode"></param>
/// <param name="matialCode"></param>
/// <param name="begintime"></param>
/// <param name="endtime"></param>
/// <returns></returns>
public virtual List<SettleSparePartExport> GetReverseSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime)
{
string sqlString = "SELECT\n" +
" temp1.交货日期,\n" +
" '' 交货单号,\n" +
" '' 订单日期,\n" +
" '' 采购订单号,\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" +
" b.Version AS 期间,\n" + " b.Version AS 期间,\n" +
" b.PurchaseOrderNoText AS 采购订单文本,\n" + " '' AS 采购订单文本,\n" +
" NULL AS 交货日期,\n" +
" c.MaterialCode AS SAP编码,\n" +
" a.MaterialCode AS 物料代码,\n" +
" c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" +
" b.PurchasePriceNoTax AS 开票单价,\n" + " b.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" + " 0 AS 数量差异,\n" +
" ISNULL( b.InvoicedQty, 0 ) AS 开票数量 ,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( b.AmountNoTax, 0 ) AS 开票金额 \n" + " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + " FROM\n" +
" Set_WMSSparePart a\n" + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS 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 JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON a.MaterialCode = b.MaterialCode\n" +
" LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" +
" WHERE\n" + " WHERE\n" +
" b.PurchaseOrderNo IS NULL \n" + " ( b.MaterialCode IS NULL ) \n" +
" ) AS temp1\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" + " 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";
"ORDER BY\n" +
" temp1.采购订单号";
string addwhere = string.Empty; string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version); string addSqlStr = string.Format(sqlString, version);

48
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs

@ -1,11 +1,15 @@
using System; using Magicodes.ExporterAndImporter.Excel;
using Shouldly;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using TaskJob.Interfaces; using TaskJob.Interfaces;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -15,12 +19,16 @@ namespace SettleAccount.Job.Services.Report
private readonly SettleSparePartDapperReportRepository _dapper; private readonly SettleSparePartDapperReportRepository _dapper;
private readonly OutputService _outputService; private readonly OutputService _outputService;
private readonly ErpPartDapperRepository _erpdapperRepository; private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
public SettleSparePartExportService(SettleSparePartDapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService)
public SettleSparePartExportService(SettleSparePartDapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService
, IBlobContainer<MyFileContainer> fileContainer)
{ {
_dapper = dapper; _dapper = dapper;
_outputService = outputService; _outputService = outputService;
_erpdapperRepository = erpdapperRepository; _erpdapperRepository = erpdapperRepository;
_fileContainer = fileContainer;
} }
@ -33,8 +41,16 @@ namespace SettleAccount.Job.Services.Report
var matialCode = p_list.Where(p => p.Name == "MatialCode").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 beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value;
var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
//汇总
var _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//正向对比,有结算无发货
var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//反向对比,有发货无结算
var _reversels = _dapper.GetReverseSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); //var diffList = _dapper.GetSettleSparePartSumQtyDiff(version);
//if (diffList != null) //if (diffList != null)
@ -68,14 +84,14 @@ namespace SettleAccount.Job.Services.Report
_ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList(); _ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList();
} }
} }
if (!string.IsNullOrEmpty(matialCode)) //if (!string.IsNullOrEmpty(matialCode))
{ //{
var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList(); // var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0) // if (_groupList.Count() > 0)
{ // {
_ls = _ls.Where(p => _groupList.Contains(p.)).ToList(); // _ls = _ls.Where(p => _groupList.Contains(p.物料代码)).ToList();
} // }
} //}
if (!string.IsNullOrEmpty(purchaseOrderNo)) if (!string.IsNullOrEmpty(purchaseOrderNo))
{ {
var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList(); var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList();
@ -89,10 +105,18 @@ namespace SettleAccount.Job.Services.Report
// _outputService.Export<SettleSparePartExport>(id, fileName, _ls);
ExcelExporter _exporter = new ExcelExporter();//导出Excel
_outputService.Export<SettleSparePartExport>(id, fileName, _ls); var result = _exporter.Append(_ls.ToList(), "大众备件数据输出")
.SeparateBySheet()
.Append(_forwardls.ToList(), "有结算无发货对比")
.SeparateBySheet()
.Append(_reversels.ToList(),"有发货无结算对比")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(fileName, result.Result, true);
return id.ToString(); return id.ToString();

Loading…
Cancel
Save