44673626
3 years ago
7 changed files with 393 additions and 7 deletions
@ -0,0 +1,116 @@ |
|||
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 |
|||
{ |
|||
public class SettleSparePartDapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public SettleSparePartDapperReportRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ } |
|||
|
|||
public virtual List<SettleSparePartExport> GetSettleSparePartReportList(string state, string version, string year, string customcode, |
|||
string begintime, string endtime) |
|||
{ |
|||
string sqlString = "SELECT\n" + |
|||
" * ,\n" + |
|||
" (Price-InvoicePrice) as InvoiceDiffPrice, --单价差异\n" + |
|||
" ISNULL( Price * ReceiptQty-InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" + |
|||
"FROM\n" + |
|||
" (\n" + |
|||
" SELECT\n" + |
|||
" c.Period as WMSDeliveryDate,--交货日期\n" + |
|||
" c.DeliveryOrderNo,--交货单号\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" + |
|||
" d.Amt as InvoicedQty,--开票数量\n" + |
|||
" (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异\n" + |
|||
" d.InvoicePrice,--开票单价\n" + |
|||
" (a.ReceiptQty * d.InvoicePrice) as InvoiceMoney --开票金额\n" + |
|||
" \n" + |
|||
" FROM\n" + |
|||
" Set_SparePart 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 = '202109' 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"; |
|||
string _sql = string.Format(sqlString, version); |
|||
var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null); |
|||
return _query.ToList(); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 大众看板有条码报表
|
|||
/// </summary>
|
|||
//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
|
|||
public class SettleSparePartExport |
|||
{ |
|||
[ExporterHeader(DisplayName = "交货日期")] |
|||
public string WMSDeliveryDate { 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 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; } |
|||
|
|||
} |
|||
} |
@ -0,0 +1,43 @@ |
|||
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 SettleSparePartExportService : ITransientDependency, IExportJob |
|||
{ |
|||
private readonly SettleSparePartDapperReportRepository _dapper; |
|||
private readonly OutputService _outputService; |
|||
|
|||
public SettleSparePartExportService(SettleSparePartDapperReportRepository dapper, OutputService outputService) |
|||
{ |
|||
_dapper = dapper; |
|||
_outputService = outputService; |
|||
} |
|||
|
|||
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|||
{ |
|||
var year = p_list.Where(p => p.Name == "Year").FirstOrDefault().Value; |
|||
var state = p_list.Where(p => p.Name == "State").FirstOrDefault().Value; |
|||
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|||
var customerCode = p_list.Where(p => p.Name == "CustomerCode").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(state, version, year, customerCode, beginTime, endTime); |
|||
|
|||
_outputService.Export<SettleSparePartExport>(id, string.Format("大众备件结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _list); |
|||
|
|||
return id.ToString(); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue