44673626
3 years ago
7 changed files with 390 additions and 3 deletions
@ -0,0 +1,178 @@ |
|||
using Dapper; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories.Dapper; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
|||
{ |
|||
/// <summary>
|
|||
/// 根据虚拟单号0-90天的是按照SAP物料号进行先进先出操作
|
|||
/// </summary>
|
|||
public class SettleSparePart90DapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public SettleSparePart90DapperReportRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ } |
|||
|
|||
|
|||
public virtual List<SettleSparePart90Export> GetSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, |
|||
string begintime, string endtime) |
|||
{ |
|||
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" + |
|||
" a.Version AS 期间,\n" + |
|||
" b.WMSDeliveryNote AS 交货单号,\n" + |
|||
" b.SpareDate AS 发货日期,\n" + |
|||
" b.PurchaseOrderNo AS 采购订单号,\n" + |
|||
" c.MaterialCode AS SAP编码,\n" + |
|||
" b.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 (\n" + |
|||
" SELECT\n" + |
|||
" WMSDeliveryNote,\n" + |
|||
" SpareDate,\n" + |
|||
" MaterialCode,\n" + |
|||
" ReceiptQty,\n" + |
|||
" PurchaseOrderNo \n" + |
|||
" FROM\n" + |
|||
" Set_WMSSparePart \n" + |
|||
" WHERE\n" + |
|||
" PurchaseOrderNo != 'BM' \n" + |
|||
" AND PurchaseOrderNo LIKE '%D30%' \n" + |
|||
" OR PurchaseOrderNo LIKE '%D60%' \n" + |
|||
" OR PurchaseOrderNo LIKE '%D90%' \n" + |
|||
" ) AS b ON a.MaterialCode = b.MaterialCode\n" + |
|||
" LEFT OUTER JOIN Set_material 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 \n" + |
|||
"WHERE\n" + |
|||
" temp1.SAP编码 IS NULL"; |
|||
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" + |
|||
" 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"; |
|||
string addwhere = string.Empty; |
|||
string addSqlStr = string.Format(sqlString, version); |
|||
|
|||
|
|||
string _sql = string.Format(addSqlStr, addwhere); |
|||
|
|||
var _query = DbConnection.Query<SparePart90SumQtyDiff>(_sql, null, null, true, 1200, null); |
|||
return _query.ToList(); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public class SparePart90SumQtyDiff |
|||
{ |
|||
public decimal 数量差异 { set; get; } |
|||
public string 订单号 { set; get; } |
|||
public string 物料号 { set; get; } |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 大众看板有条码报表
|
|||
/// </summary>
|
|||
//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
|
|||
public class SettleSparePart90Export |
|||
{ |
|||
|
|||
[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; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,100 @@ |
|||
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.Repository.SettleAccountJob.Report; |
|||
|
|||
namespace SettleAccount.Job.Services.Report |
|||
{ |
|||
public class SettleSparePart90ExportService : ITransientDependency, IExportJob |
|||
{ |
|||
private readonly SettleSparePart90DapperReportRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
private readonly ErpPartDapperRepository _erpdapperRepository; |
|||
|
|||
public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService) |
|||
{ |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
_erpdapperRepository = erpdapperRepository; |
|||
} |
|||
|
|||
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> 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 _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); |
|||
//var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version);
|
|||
//if (diffList != null)
|
|||
//{
|
|||
// foreach (var itm in diffList)
|
|||
// {
|
|||
// var _first = _ls.FirstOrDefault(p => p.物料代码 == itm.物料号);
|
|||
// if (_first != null)
|
|||
// {
|
|||
// _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异)
|
|||
// _first.数量差异 = itm.数量差异;
|
|||
|
|||
// }
|
|||
// }
|
|||
//}
|
|||
|
|||
//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<SettleSparePart90Export>(id, fileName, _ls); |
|||
|
|||
|
|||
return id.ToString(); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue