Browse Source

大众备件无单号更改

FoShanPG
44673626 3 years ago
parent
commit
61385cac94
  1. 137
      src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs
  2. 4
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs
  3. 363
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  4. 34
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs

137
src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs

@ -1,6 +1,7 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -22,9 +23,9 @@ namespace Win.Sfs.SettleAccount.Entities
[ExporterHeader(DisplayName = "入库库位")] [ExporterHeader(DisplayName = "入库库位")]
//入库库位 //入库库位
public string InPut { set; get; } public string InPut { set; get; }
[ImporterHeader(Name = "状态")] //[ImporterHeader(Name = "状态")]
[ExporterHeader(DisplayName = "状态")] //[ExporterHeader(DisplayName = "状态")]
public int State { get; set; } //public int State { get; set; }
[ImporterHeader(Name = "开票单价")] [ImporterHeader(Name = "开票单价")]
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
@ -79,6 +80,14 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "结算数量")] [ImporterHeader(Name = "结算数量")]
public decimal Qty { set; get; } public decimal Qty { set; get; }
[ExporterHeader(DisplayName = "状态")]
[ValueMapping("未处理", 0)]
[ValueMapping("申请出库", 1)]
[ValueMapping("确认出库", 2)]
[ValueMapping("不能出库", 3)]
[ValueMapping("取消出库", 4)]
public int State { set; get; }
} }
@ -120,9 +129,15 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "入库库位", IsIgnore = true)] [ImporterHeader(Name = "入库库位", IsIgnore = true)]
//入库库位 //入库库位
public string InPut { set; get; } public string InPut { set; get; }
[ExporterHeader(DisplayName = "状态")] [ExporterHeader(DisplayName = "状态")]
[ImporterHeader(Name = "状态", IsIgnore = true)] [ValueMapping("未处理", 0)]
public int State { get; set; } [ValueMapping("申请出库", 1)]
[ValueMapping("确认出库", 2)]
[ValueMapping("不能出库", 3)]
[ValueMapping("取消出库", 4)]
public int State { set; get; }
[ExporterHeader(DisplayName = "客户物料")] [ExporterHeader(DisplayName = "客户物料")]
[ImporterHeader(Name = "客户物料")] [ImporterHeader(Name = "客户物料")]
/// <summary> /// <summary>
@ -201,8 +216,13 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "BillNum", IsIgnore = true)] [ImporterHeader(Name = "BillNum", IsIgnore = true)]
[ExporterHeader(DisplayName = "BillNum", IsIgnore = true)] [ExporterHeader(DisplayName = "BillNum", IsIgnore = true)]
public string BillNum { set; get; } public string BillNum { set; get; }
[ImporterHeader(Name = "状态", IsIgnore = true)]
[ExporterHeader(DisplayName = "状态", IsIgnore = true)] [ExporterHeader(DisplayName = "状态")]
[ValueMapping("未处理", 0)]
[ValueMapping("申请出库", 1)]
[ValueMapping("确认出库", 2)]
[ValueMapping("不能出库", 3)]
[ValueMapping("取消出库", 4)]
public int State { set; get; } public int State { set; get; }
[ImporterHeader(Name = "开票单价")] [ImporterHeader(Name = "开票单价")]
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
@ -245,8 +265,15 @@ namespace Win.Sfs.SettleAccount.Entities
[ExporterHeader(DisplayName = "入库库位", IsIgnore = true)] [ExporterHeader(DisplayName = "入库库位", IsIgnore = true)]
//入库库位 //入库库位
public string InPut { set; get; } public string InPut { set; get; }
[ExporterHeader(DisplayName = "状态", IsIgnore = true)]
public int State { get; set; } [ExporterHeader(DisplayName = "状态")]
[ValueMapping("未处理", 0)]
[ValueMapping("申请出库", 1)]
[ValueMapping("确认出库", 2)]
[ValueMapping("不能出库", 3)]
[ValueMapping("取消出库", 4)]
public int State { set; get; }
[ExporterHeader(DisplayName = "物料代码")] [ExporterHeader(DisplayName = "物料代码")]
/// <summary> /// <summary>
/// 扩展字段1 /// 扩展字段1
@ -331,9 +358,15 @@ namespace Win.Sfs.SettleAccount.Entities
[ExporterHeader(DisplayName = "入库库位", IsIgnore = true)] [ExporterHeader(DisplayName = "入库库位", IsIgnore = true)]
//入库库位 //入库库位
public string InPut { set; get; } public string InPut { set; get; }
[ImporterHeader(Name = "状态", IsIgnore = true)]
[ExporterHeader(DisplayName = "状态", IsIgnore = true)] [ExporterHeader(DisplayName = "状态")]
public int State { get; set; } [ValueMapping("未处理", 0)]
[ValueMapping("申请出库", 1)]
[ValueMapping("确认出库", 2)]
[ValueMapping("不能出库", 3)]
[ValueMapping("取消出库", 4)]
public int State { set; get; }
[ImporterHeader(Name = "物料代码")] [ImporterHeader(Name = "物料代码")]
[ExporterHeader(DisplayName = "物料代码")] [ExporterHeader(DisplayName = "物料代码")]
/// <summary> /// <summary>
@ -416,9 +449,15 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "BillNum", IsIgnore = true)] [ImporterHeader(Name = "BillNum", IsIgnore = true)]
[ExporterHeader(DisplayName = "BillNum", IsIgnore = true)] [ExporterHeader(DisplayName = "BillNum", IsIgnore = true)]
public string BillNum { set; get; } public string BillNum { set; get; }
[ImporterHeader(Name = "状态", IsIgnore = true)]
[ExporterHeader(DisplayName = "状态", IsIgnore = true)] [ValueMapping("0", "未处理")]
[ValueMapping("1", "申请出库")]
[ValueMapping("2", "确认出库")]
[ValueMapping("3", "不能出库")]
[ValueMapping("4", "取消出库")]
[ExporterHeader(DisplayName = "状态")]
public int State { set; get; } public int State { set; get; }
[ImporterHeader(Name = "开票单价")] [ImporterHeader(Name = "开票单价")]
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
@ -426,7 +465,6 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "开票金额")] [ImporterHeader(Name = "开票金额")]
[ExporterHeader(DisplayName = "开票金额")] [ExporterHeader(DisplayName = "开票金额")]
public decimal Amt { set; get; } public decimal Amt { set; get; }
} }
@ -470,8 +508,24 @@ namespace Win.Sfs.SettleAccount.Entities
[ImporterHeader(Name = "BillNum", IsIgnore = true)] [ImporterHeader(Name = "BillNum", IsIgnore = true)]
[ExporterHeader(DisplayName = "BillNum", IsIgnore = true)] [ExporterHeader(DisplayName = "BillNum", IsIgnore = true)]
public string BillNum { set; get; } public string BillNum { set; get; }
[ImporterHeader(Name = "状态", IsIgnore = true)] //[ValueMapping("未处理", "0")]
[ExporterHeader(DisplayName = "状态", IsIgnore = true)] //[ValueMapping("申请出库", "1")]
//[ValueMapping("确认出库", "2")]
//[ValueMapping("不能出库", "3")]
//[ValueMapping("取消出库", "4")]
//[ValueMapping("0","未处理")]
//[ValueMapping("1","申请出库")]
//[ValueMapping("2","确认出库")]
//[ValueMapping("3","不能出库")]
//[ValueMapping("4","取消出库")]
[ValueMapping("未处理", ExporterStatus.Normal)]
[ValueMapping("申请出库", ExporterStatus.PupilsAway)]
[ValueMapping("确认出库", ExporterStatus.Suspension)]
[ValueMapping("不能出库", ExporterStatus.WorkStudy)]
[ValueMapping("取消出库", ExporterStatus.PostPractice)]
[ExporterHeader(DisplayName = "状态")]
public int State { set; get; } public int State { set; get; }
[ImporterHeader(Name = "开票单价")] [ImporterHeader(Name = "开票单价")]
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
@ -531,9 +585,15 @@ namespace Win.Sfs.SettleAccount.Entities
[ExporterHeader(DisplayName = "入库库位", IsIgnore = true)] [ExporterHeader(DisplayName = "入库库位", IsIgnore = true)]
//入库库位 //入库库位
public string InPut { set; get; } public string InPut { set; get; }
[ImporterHeader(Name = "状态", IsIgnore = true)]
[ExporterHeader(DisplayName = "状态", IsIgnore = true)] [ExporterHeader(DisplayName = "状态")]
public int State { get; set; } //[ValueMapping("未处理", 0)]
//[ValueMapping("申请出库", 1)]
//[ValueMapping("确认出库", 2)]
//[ValueMapping("不能出库", 3)]
//[ValueMapping("取消出库", 4)]
public int State { set; get; }
[ImporterHeader(Name = "结算物料号")] [ImporterHeader(Name = "结算物料号")]
[ExporterHeader(DisplayName = "结算物料号")] [ExporterHeader(DisplayName = "结算物料号")]
/// <summary> /// <summary>
@ -575,6 +635,43 @@ namespace Win.Sfs.SettleAccount.Entities
} }
/// <summary>
/// 学生状态 正常、流失、休学、勤工俭学、顶岗实习、毕业、参军
/// </summary>
public enum ExporterStatus
{
/// <summary>
/// 未处理
/// </summary>
[Display(Name = "未处理")]
Normal = 0,
/// <summary>
/// 申请出库
/// </summary>
[Display(Name = "申请出库")]
PupilsAway = 1,
/// <summary>
/// 确认出库
/// </summary>
[Display(Name = "确认出库")]
Suspension = 2,
/// <summary>
/// 不能出库
/// </summary>
[Display(Name = "不能出库")]
WorkStudy = 3,
/// <summary>
/// 取消出库
/// </summary>
[Display(Name = "取消出库")]
PostPractice = 4,
}
} }

4
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs

@ -245,8 +245,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
if (_joblist.Count() > 0) if (_joblist.Count() > 0)
{ {
var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); var fileList = _joblist.Select(p => p.RealDownFileName).ToList();
List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>(); List<WmsSharePartOutPutDetial> _lst = new List<WmsSharePartOutPutDetial>();//无订单
List<WmsSharePart90OutPutDetial> _lstBill = new List<WmsSharePart90OutPutDetial>(); List<WmsSharePart90OutPutDetial> _lstBill = new List<WmsSharePart90OutPutDetial>();//有订单
foreach (var filename in fileList) foreach (var filename in fileList)
{ {
string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename;

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

@ -34,6 +34,134 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
string begintime, string endtime) string begintime, string endtime)
{ {
//string sqlString = "SELECT\n" +
//" union1.* \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
//" temp1.交货日期,\n" +
//" temp1.交货单号,\n" +
//" NULL 订单日期,\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" +
//" temp1.交货数量,\n" +
//" temp1.收货与交货差异,\n" +
//" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" +
//" ISNULL( temp3.Qty, 0 ) 退货数量 \n" +
//" FROM\n" +
//" (\n" +
//" SELECT\n" +
//" a.Version AS 期间,\n" +
//" a.PurchaseOrderNoText AS 采购订单文本,\n" +
//" '' AS 交货单号,\n" +
//" NULL AS 交货日期,\n" +
//" a.PurchaseOrderNo AS 采购订单号,\n" +
//" b.MaterialCode AS SAP编码,\n" +
//" b.CustomerPartCode AS 物料代码,\n" +
//" b.MaterialDesc AS 物料描述,\n" +
//" b.EstimateTypeDesc AS 物料组,\n" +
//" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
//" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
//" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
//" ISNULL( a.InvoicedQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额,\n" +
//" ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" +
//" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" +
//" FROM\n" +
//" ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo!='NoOrder' ) AS a\n" +
//" LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" +
//" LEFT JOIN (\n" +
//"   SELECT\n" +
//" ( ISNULL( temp1.Qty, 0 ) - ISNULL( temp2.Qty, 0 ) ) WMSDeliveryQty,\n" +
//" temp1.MaterialCode,\n" +
//" temp1.PurchaseOrderNo \n" +
//" FROM\n" +
//" (\n" +
//" ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" +
//" LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' AND PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" +
//" AND temp1.MaterialCode = temp2.MaterialCode \n" +
//" ) \n" +
//" ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" +
//" AND A.MaterialCode = C.MaterialCode \n" +
//" WHERE\n" +
//" ( a.Version = '{0}' ) \n" +
//" ) AS temp1\n" +
//" LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
//" AND temp1.SAP编码= temp3.MaterialCode\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
//" ) union1 UNION ALL\n" +
//"SELECT\n" +
//" union2.* \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
//" temp1.交货日期,\n" +
//" '' 交货单号,\n" +
//" '' 订单日期,\n" +
//" '' 采购订单号,\n" +
//" temp1.SAP编码,\n" +
//" temp1.物料代码,\n" +
//" temp1.物料描述,\n" +
//" '' 采购订单文本,\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" +
//" 0 交货数量,\n" +
//" 0 收货与交货差异,\n" +
//" 0 实际交货数量,\n" +
//" 0 退货数量 \n" +
//" FROM\n" +
//" (\n" +
//" SELECT\n" +
//" '' AS 交货单号,\n" +
//" NULL AS 交货日期,\n" +
//" c.MaterialCode AS SAP编码,\n" +
//" a.MaterialCode AS 物料代码,\n" +
//" c.MaterialDesc AS 物料描述,\n" +
//" c.EstimateTypeDesc AS 物料组,\n" +
//" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
//" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
//" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
//" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
//" FROM\n" +
//" (\n" +
//" SELECT SUM\n" +
//" ( ReceiptQty ) AS ReceiptQty,\n" +
//" SUM ( InvoicedQty ) InvoicedQty,\n" +
//" MaterialCode,\n" +
//" PurchasePriceNoTax \n" +
//" FROM\n" +
//" Set_SparePart \n" +
//" WHERE\n" +
//" Extend != 'is90' \n" +
//" AND Version = '{0}' \n" +
//" AND PurchaseOrderNo='NoOrder' \n" +
//" GROUP BY\n" +
//" MaterialCode,\n" +
//" PurchasePriceNoTax \n" +
//" ) AS a\n" +
//" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY 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" +
//" ) AS temp1\n" +
//" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
//" ) union2";
string sqlString = "SELECT\n" + string sqlString = "SELECT\n" +
" union1.* \n" + " union1.* \n" +
"FROM\n" + "FROM\n" +
@ -78,7 +206,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" + " ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" +
" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' ) AS a\n" + " ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo!='NoOrder' ) AS a\n" +
" LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" + " LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" +
" LEFT JOIN (\n" + " LEFT JOIN (\n" +
"   SELECT\n" + "   SELECT\n" +
@ -88,7 +216,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" + " ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' AND PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" +
" AND temp1.MaterialCode = temp2.MaterialCode \n" + " AND temp1.MaterialCode = temp2.MaterialCode \n" +
" ) \n" + " ) \n" +
" ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" + " ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" +
@ -99,67 +227,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" + " LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" +
" AND temp1.SAP编码= temp3.MaterialCode\n" + " AND temp1.SAP编码= temp3.MaterialCode\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
" ) union1 UNION ALL\n" + " ) union1 \n" ;
"SELECT\n" +
" union2.* \n" +
"FROM\n" +
" (\n" +
" SELECT\n" +
" temp1.交货日期,\n" +
" '' 交货单号,\n" +
" '' 订单日期,\n" +
" '' 采购订单号,\n" +
" temp1.SAP编码,\n" +
" temp1.物料代码,\n" +
" temp1.物料描述,\n" +
" '' 采购订单文本,\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" +
" 0 交货数量,\n" +
" 0 收货与交货差异,\n" +
" 0 实际交货数量,\n" +
" 0 退货数量 \n" +
" FROM\n" +
" (\n" +
" SELECT\n" +
" '' AS 交货单号,\n" +
" NULL AS 交货日期,\n" +
" c.MaterialCode AS SAP编码,\n" +
" a.MaterialCode AS 物料代码,\n" +
" c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" +
" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" +
" (\n" +
" SELECT SUM\n" +
" ( ReceiptQty ) AS ReceiptQty,\n" +
" SUM ( InvoicedQty ) InvoicedQty,\n" +
" MaterialCode,\n" +
" PurchasePriceNoTax \n" +
" FROM\n" +
" Set_SparePart \n" +
" WHERE\n" +
" Extend != 'is90' \n" +
" AND Version = '{0}' \n" +
" AND PurchaseOrderNo IS NULL \n" +
" GROUP BY\n" +
" MaterialCode,\n" +
" PurchasePriceNoTax \n" +
" ) AS a\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY 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" +
" ) AS temp1\n" +
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
" ) union2";
@ -507,7 +575,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" + " ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" +
" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS a\n" + " ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' and PurchaseOrderNo!='NoOrder' ) AS a\n" +
" LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" + " LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" +
" LEFT JOIN (\n" + " LEFT JOIN (\n" +
"   SELECT\n" + "   SELECT\n" +
@ -517,7 +585,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" + " ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' and PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" +
" AND temp1.MaterialCode = temp2.MaterialCode \n" + " AND temp1.MaterialCode = temp2.MaterialCode \n" +
" ) \n" + " ) \n" +
" ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" + " ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" +
@ -563,9 +631,10 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp1.物料代码,\n" + " temp1.物料代码,\n" +
" temp1.物料描述,\n" + " temp1.物料描述,\n" +
" '' 采购订单文本,\n" + " '' 采购订单文本,\n" +
" 0 发货数量,\n" +
" temp1.收货数量,\n" + " temp1.收货数量,\n" +
" temp1.开票数量,\n" + " temp1.开票数量,\n" +
" ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 货与开票差异,\n" + " ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 货与开票差异,\n" +
" temp1.开票单价,\n" + " temp1.开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
@ -640,8 +709,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" temp1.物料描述,\n" + " temp1.物料描述,\n" +
" temp1.采购订单文本,\n" + " temp1.采购订单文本,\n" +
" temp1.发货数量,\n" + " temp1.发货数量,\n" +
" temp1.收货数量,\n" +
" temp1.开票数量,\n" + " temp1.开票数量,\n" +
" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + " ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 收货与开票差异,\n" +
" temp1.开票单价,\n" + " temp1.开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
@ -659,10 +729,25 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" a.PurchasePriceNoTax AS 开票单价,\n" + " a.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" + " 0 AS 数量差异,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 收货数量 ,\n" +
" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' GROUP BY MaterialCode, PurchasePriceNoTax ) AS a\n" + " (\n" +
" SELECT SUM\n" +
" ( ReceiptQty ) AS ReceiptQty,\n" +
" SUM ( InvoicedQty ) InvoicedQty,\n" +
" MaterialCode,\n" +
" PurchasePriceNoTax \n" +
" FROM\n" +
" Set_SparePart \n" +
" WHERE\n" +
" Extend != 'is90' \n" +
" AND Version = '{0}' \n" +
" GROUP BY\n" +
" MaterialCode,\n" +
" PurchasePriceNoTax \n" +
" ) AS a\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY 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" + " 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" +
" ) AS temp1\n" + " ) AS temp1\n" +
@ -677,7 +762,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>
@ -686,59 +771,59 @@ 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> GetReverseSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, //public virtual List<SettleSparePartExport> GetReverseSettleSparePartReportList(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" +
" '' 交货单号,\n" + // " '' 交货单号,\n" +
" '' 订单日期,\n" + // " '' 订单日期,\n" +
" '' 采购订单号,\n" + // " '' 采购订单号,\n" +
" temp1.SAP编码,\n" + // " temp1.SAP编码,\n" +
" temp1.物料代码,\n" + // " temp1.物料代码,\n" +
" temp1.物料描述,\n" + // " temp1.物料描述,\n" +
" temp1.采购订单文本,\n" + // " temp1.采购订单文本,\n" +
" temp1.发货数量,\n" + // " temp1.发货数量,\n" +
" temp1.开票数量,\n" + // " temp1.开票数量,\n" +
" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + // " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" +
" temp1.开票单价,\n" + // " temp1.开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + // " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + // " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + // " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" +
" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + // " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" +
"FROM\n" + // "FROM\n" +
" (\n" + // " (\n" +
" SELECT\n" + // " SELECT\n" +
" b.Version AS 期间,\n" + // " b.Version AS 期间,\n" +
" '' AS 采购订单文本,\n" + // " '' AS 采购订单文本,\n" +
" NULL AS 交货日期,\n" + // " NULL AS 交货日期,\n" +
" c.MaterialCode AS SAP编码,\n" + // " c.MaterialCode AS SAP编码,\n" +
" a.MaterialCode AS 物料代码,\n" + // " a.MaterialCode AS 物料代码,\n" +
" c.MaterialDesc AS 物料描述,\n" + // " c.MaterialDesc AS 物料描述,\n" +
" c.EstimateTypeDesc AS 物料组,\n" + // " c.EstimateTypeDesc AS 物料组,\n" +
" b.PurchasePriceNoTax AS 开票单价,\n" + // " b.PurchasePriceNoTax AS 开票单价,\n" +
" 0 AS 数量差异,\n" + // " 0 AS 数量差异,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + // " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
" ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" + // " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" +
" ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + // " ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
" FROM\n" + // " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS a\n" + // " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS a\n" +
" LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON a.MaterialCode = b.MaterialCode\n" + // " LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) 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" + // " 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.MaterialCode 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 = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode"; // " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode";
string addwhere = string.Empty; // string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version); // string addSqlStr = string.Format(sqlString, version);
string _sql = string.Format(addSqlStr, addwhere); // string _sql = string.Format(addSqlStr, addwhere);
//string _sql = string.Format(sqlString, version); // //string _sql = string.Format(sqlString, version);
var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null); // var _query = DbConnection.Query<SettleSparePartExport>(_sql, null, null, true, 1200, null);
return _query.ToList(); // return _query.ToList();
} //}
/// <summary> /// <summary>
@ -798,8 +883,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" + " ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" +
" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) AS a\n" + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart WHERE PurchaseOrderNo is not null and PurchaseOrderNo!='' GROUP BY PurchaseOrderNo, MaterialCode ) AS a\n" +
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' and PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" +
" AND a.MaterialCode = b.MaterialCode\n" + " AND 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" + " 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" +
@ -841,8 +926,8 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" + " ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" +
" ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + " ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" +
" FROM\n" + " FROM\n" +
" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) a\n" + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart WHERE PurchaseOrderNo is not null and PurchaseOrderNo!='' GROUP BY PurchaseOrderNo, MaterialCode ) a\n" +
" INNER JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + " INNER JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' and PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" +
" AND a.MaterialCode = b.MaterialCode\n" + " AND 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" + " 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" +
@ -1080,12 +1165,21 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public SettleSparePartExport( string sapMaterialCode, string materialCode, string materialDesc, public SettleSparePartExport( string sapMaterialCode, string materialCode, string materialDesc,
decimal qty, decimal sockQty) decimal shouqty,decimal reqty, decimal qty, decimal diff,decimal price,decimal invocprice,
decimal dingprice,decimal diffprice,decimal diffsumprice, decimal sockQty)
{ {
SAP编码 = sapMaterialCode; SAP编码 = sapMaterialCode;
= materialDesc;
= materialCode; = materialCode;
= materialDesc;
= shouqty;
= reqty;
= qty; = qty;
= diff;
= price;
= invocprice;
= dingprice;
= diffprice;
= diffsumprice;
= sockQty; = sockQty;
} }
@ -1108,16 +1202,19 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "物料描述")]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "采购订单文本")] [ExporterHeader(DisplayName = "采购订单文本",IsIgnore =true)]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "发货数量")]
public decimal { set; get; }
[ExporterHeader(DisplayName = "收货数量")] [ExporterHeader(DisplayName = "收货数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "开票数量")] [ExporterHeader(DisplayName = "开票数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "货与开票差异")] [ExporterHeader(DisplayName = "货与开票差异")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "开票单价")] [ExporterHeader(DisplayName = "开票单价")]
public decimal { set; get; } public decimal { set; get; }
@ -1134,15 +1231,15 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
[ExporterHeader(DisplayName = "寄售库存数量")] [ExporterHeader(DisplayName = "寄售库存数量")]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "交货数量")] [ExporterHeader(DisplayName = "交货数量",IsIgnore =true)]
public decimal { set; get; } public decimal { set; get; }
[ExporterHeader(DisplayName = "退货数量")] [ExporterHeader(DisplayName = "退货数量",IsIgnore =true)]
public string 退 { set; get; } public string 退 { set; get; }
[ExporterHeader(DisplayName = "实际交货数量")] [ExporterHeader(DisplayName = "实际交货数量", IsIgnore = true)]
public string { set; get; } public string { set; get; }
[ExporterHeader(DisplayName = "收货与交货差异")] [ExporterHeader(DisplayName = "收货与交货差异", IsIgnore = true)]
public decimal { set; get; } public decimal { set; get; }
} }

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

@ -55,14 +55,34 @@ namespace SettleAccount.Job.Services.Report
//反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中
var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
var stockList = _wmsDapper.GetSalesStock();
//针对无单号备件,求和汇总显示 //针对无单号备件,求和汇总显示
var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
var queryStockList_nocode = from itm in _forwardls_nocode
join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1
from tm1 in temp1.DefaultIfEmpty()
select new SettleSparePartExport(
itm.SAP编码,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
tm1 == null ? 0 : tm1.Qty
);
//不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 //不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对
var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//按照零件号汇总数量,有一列显示寄售库数量 //按照零件号汇总数量,有一列显示寄售库数量
var stockList = _wmsDapper.GetSalesStock();
var queryStockList = from itm in _forwardls var queryStockList = from itm in _forwardls
join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1
from tm1 in temp1.DefaultIfEmpty() from tm1 in temp1.DefaultIfEmpty()
@ -70,7 +90,15 @@ namespace SettleAccount.Job.Services.Report
itm.SAP编码, itm.SAP编码,
itm., itm.,
itm., itm.,
itm.,
itm.,
itm., itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
itm.,
tm1 == null ? 0 : tm1.Qty tm1 == null ? 0 : tm1.Qty
); );
@ -139,7 +167,7 @@ namespace SettleAccount.Job.Services.Report
.SeparateBySheet() .SeparateBySheet()
.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") .Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)")
.SeparateBySheet() .SeparateBySheet()
.Append(_forwardls_nocode.ToList(), "大众备件无单号汇总") .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总")
.SeparateBySheet() .SeparateBySheet()
.Append(queryStockList.ToList(), "零件汇总比对寄售库存") .Append(queryStockList.ToList(), "零件汇总比对寄售库存")
.ExportAppendDataAsByteArray(); .ExportAppendDataAsByteArray();

Loading…
Cancel
Save