Administrator
3 years ago
11 changed files with 649 additions and 49 deletions
@ -0,0 +1,202 @@ |
|||
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 SettleSparePartExtendDapperReportRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency |
|||
{ |
|||
public SettleSparePartExtendDapperReportRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ } |
|||
|
|||
//public async Task<string> SettledSparePart(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode,
|
|||
//string state, DateTime begin, DateTime end)
|
|||
|
|||
public virtual List<SettleSparePartExport> 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" + |
|||
" FROM \n" + |
|||
" ( \n" + |
|||
" SELECT \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" + |
|||
" 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 = '{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 "; |
|||
string addwhere = string.Empty; |
|||
string addSqlStr = string.Format(sqlString, version); |
|||
//if (!string.IsNullOrEmpty(purchaseOrderNo))
|
|||
//{
|
|||
// addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(sapCode))
|
|||
//{
|
|||
// addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(matialCode))
|
|||
//{
|
|||
// addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
|
|||
//{
|
|||
// addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
|
|||
//}
|
|||
|
|||
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(); |
|||
|
|||
} |
|||
|
|||
public virtual List<SettleSparePartExport> GetSettleSparePartNoOrderList(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" + |
|||
" FROM \n" + |
|||
" ( \n" + |
|||
" SELECT \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" + |
|||
" 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 = '{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 "; |
|||
string addwhere = string.Empty; |
|||
string addSqlStr = string.Format(sqlString, version); |
|||
//if (!string.IsNullOrEmpty(purchaseOrderNo))
|
|||
//{
|
|||
// addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(sapCode))
|
|||
//{
|
|||
// addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(matialCode))
|
|||
//{
|
|||
// addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode);
|
|||
//}
|
|||
//else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime))
|
|||
//{
|
|||
// addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime);
|
|||
//}
|
|||
|
|||
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>
|
|||
////[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,86 @@ |
|||
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; |
|||
using Win.Sfs.SettleAccount.Entities; |
|||
using Win.Sfs.SettleAccount.Entities.Materials; |
|||
using Win.Sfs.SettleAccount.Entities.Prices; |
|||
using Win.Sfs.SettleAccount.Reports; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
|||
{ |
|||
|
|||
|
|||
|
|||
public class SalesStock |
|||
{ |
|||
public string SapCode { set; get; } |
|||
public decimal Qty { set; get; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 主数据Dapper表
|
|||
/// </summary>
|
|||
public class WmsDapperRepository : DapperRepository<WMSDbContext>, ITransientDependency |
|||
{ |
|||
public WmsDapperRepository(IDbContextProvider<WMSDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
public virtual List<SalesStock> GetSalesStock() |
|||
{ |
|||
string str = " select SUM(Qty) Qty,PartCode SapCode from TS_STOCK_DETAIL where AreaCode='SALE' group by PartCode "; |
|||
|
|||
var _list = DbConnection.Query<SalesStock>(str); |
|||
return _list.ToList(); |
|||
|
|||
|
|||
} |
|||
|
|||
//public virtual Dictionary<string,decimal> GetSapList<T>(List<T> childList, string version, bool isNotHistoryPart = false) where T : ReportDetailBase, new()
|
|||
//{
|
|||
|
|||
// return tmpList;
|
|||
//}
|
|||
//public virtual List<ErpPrice> GetErpPartCodePriceList(string version)
|
|||
//{
|
|||
// string str = "SELECT\n" +
|
|||
// " ErpMaterialCode SapErpPartCode,\n" +
|
|||
// " SUM( PRICE ) SapPrice \n" +
|
|||
// " FROM \n" +
|
|||
// " Set_MaterialRelationshipDetail A\n" +
|
|||
// " LEFT JOIN ( SELECT SUM( AMT )/ SUM( Qty ) PRICE, MaterialCode FROM Set_Invoice WHERE VERSION = '{0}' GROUP BY MaterialCode ) B ON A.SettleMaterialCode = B.MaterialCode \n" +
|
|||
// "GROUP BY\n" +
|
|||
// " ErpMaterialCode";
|
|||
|
|||
// var _list = DbConnection.Query<ErpPrice>(string.Format(str, version));
|
|||
// return _list.ToList();
|
|||
//}
|
|||
//public virtual List<InvoiceSettleDiff> GetSettleInvoiceDiff(string version)
|
|||
//{
|
|||
// var str = "SELECT\n" +
|
|||
// " * \n" +
|
|||
// " FROM\n" +
|
|||
// " (\n" +
|
|||
// " SELECT\n" +
|
|||
// " b.MaterialCode,\n" +
|
|||
// " InvocieQty-SettleQty DiffQty \n" +
|
|||
// " FROM\n" +
|
|||
// " ( SELECT sum( Qty ) SettleQty, MaterialCode FROM Set_Settle a WHERE version = '{0}' GROUP BY MaterialCode ) a\n" +
|
|||
// " INNER JOIN ( SELECT SUM( QTY ) InvocieQty, MaterialCode FROM Set_Invoice WHERE version = '{0}' GROUP BY MaterialCode ) b ON a.MaterialCode = b.MaterialCode \n" +
|
|||
// " ) temp \n" +
|
|||
// " WHERE\n" +
|
|||
// " temp.DiffQty <>0";
|
|||
// var _list = DbConnection.Query<InvoiceSettleDiff>(string.Format(str, version));
|
|||
// return _list.ToList();
|
|||
//}
|
|||
} |
|||
} |
Loading…
Reference in new issue