Administrator 3 years ago
parent
commit
407ec2307b
  1. 7
      src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs
  2. 3
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs
  3. 6
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs
  4. 16
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs
  5. 39
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  6. 641
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  7. 133
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs
  8. 143
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs
  9. 13
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs
  10. 5
      src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

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

@ -235,6 +235,7 @@ namespace Win.Sfs.SettleAccount.Entities
[ExporterHeader(DisplayName = "开票金额")] [ExporterHeader(DisplayName = "开票金额")]
public decimal Amt { set; get; } public decimal Amt { set; get; }
}
} }
/// <summary> /// <summary>
@ -631,9 +632,6 @@ namespace Win.Sfs.SettleAccount.Entities
} }
/// <summary>
/// 学生状态 正常、流失、休学、勤工俭学、顶岗实习、毕业、参军
/// </summary>
public enum ExporterStatus public enum ExporterStatus
{ {
/// <summary> /// <summary>
@ -671,3 +669,6 @@ namespace Win.Sfs.SettleAccount.Entities
} }

3
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs

@ -447,8 +447,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
var checkList = new List<ErrorExportDto>(); var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExtendExcelOfSheetOneImport<WmsHQHKanbanOutPutDetial>(files, _excelImportService); var result = await _exportImporter.ExtendExcelOfSheetOneImport<WmsHQHKanbanOutPutDetial>(files, _excelImportService);
//检验1:导入模板中的第一页签数据不能为空 //检验1:导入模板中的第一页签数据不能为空
if (result == null || result.Count == 0) if (result == null || result.Count() == 0)
{ {
checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty));
} }

6
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs

@ -415,9 +415,11 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
var _billNum = "BCar" + DateTime.Now.ToString("yyyyMMddhhmmss"); var _billNum = "BCar" + DateTime.Now.ToString("yyyyMMddhhmmss");
var checkList = new List<ErrorExportDto>(); var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExtendExcelOfSheetOneImport<WmsHQCarOutPutDetial>(files, _excelImportService); var result_org = await _exportImporter.ExtendExcelOfSheetOneImport<WmsHQCarOutPutDetial>(files, _excelImportService);
//过滤掉物料号为空的数据
var result = result_org.Where(p => !string.IsNullOrEmpty(p.MaterialCode));
//检验1:导入模板中的第一页签数据不能为空 //检验1:导入模板中的第一页签数据不能为空
if (result == null || result.Count == 0) if (result == null || result.Count() == 0)
{ {
checkList.Add(new ErrorExportDto(version, "轿车出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); checkList.Add(new ErrorExportDto(version, "轿车出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty));
} }

16
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs

@ -211,7 +211,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
[UnitOfWork(false)] [UnitOfWork(false)]
public async Task<string> WmsKanbanOutPut([FromForm] IFormFileCollection files, string version) public async Task<string> WmsKanbanOutPut([FromForm] IFormFileCollection files, string version)
{ {
var checkList = new List<ErrorExportDto>();
var _billNum = "OTS" + DateTime.Now.ToString("yyyyMMddhhmmss"); var _billNum = "OTS" + DateTime.Now.ToString("yyyyMMddhhmmss");
@ -219,11 +219,19 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
//只取导入模板第一个页签 //只取导入模板第一个页签
var _list = await _exportImporter.ExtendExcelOfSheetOneImport<WmsOneTimeSaleOutPutDetial>(files, _excelImportService); var _list_org = await _exportImporter.ExtendExcelOfSheetOneImport<WmsOneTimeSaleOutPutDetial>(files, _excelImportService);
// 根据物料号是否为空,过滤EXCEL自带的空行
var _list = _list_org.Where(p => !string.IsNullOrEmpty(p.SapMaterialCode));
if (_list == null || _list.Count == 0) //检验1:导入模板中的第一页签数据不能为空
if (_list == null || _list.Count() == 0)
{
checkList.Add(new ErrorExportDto(version, "一次性寄售销售导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty));
}
if (checkList.Count > 0)
{ {
throw new BusinessException("导入模板数据不能为空!"); return await ExportErrorReportAsync(checkList);
} }
////插入数据前检验 ////插入数据前检验

39
src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs

@ -252,6 +252,45 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
}); });
return _taskid; return _taskid;
} }
/// <summary>
/// 大众备件未结明细
/// </summary>
/// <param name="purchaseOrderNo"></param>
/// <param name="sapCode"></param>
/// <param name="version"></param>
/// <param name="customerCode"></param>
/// <param name="factory"></param>
/// <param name="matialCode"></param>
/// <param name="state"></param>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <returns></returns>
[HttpGet]
[Route("UnSettleSparePartExport")]
[DisableRequestSizeLimit]
public async Task<string> UnSettledSparePart(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode,
string state, DateTime begin, DateTime end)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "PurchaseOrderNo", Value = purchaseOrderNo ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" });
customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" });
customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() });
var _taskid = await _service.ExportEnqueueAsync("大众备件未结输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleUnSparePartExportService), customConditionList, (rs) =>
{
});
return _taskid;
}
#endregion #endregion
/// <summary> /// <summary>
/// 无订单备件结算输出 /// 无订单备件结算输出

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

@ -21,7 +21,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
/// <summary> /// <summary>
/// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' 去掉 备件调整数据 /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' 去掉 备件调整数据,开票单价财务说会有调整,做了一个开票单价平均数据
/// </summary> /// </summary>
/// <param name="purchaseOrderNo"></param> /// <param name="purchaseOrderNo"></param>
/// <param name="version"></param> /// <param name="version"></param>
@ -34,133 +34,6 @@ 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" +
@ -178,11 +51,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" 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" + " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + " ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" +
" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" + " ( ISNULL( TEMP4.PurchasePriceNoTax, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" +
" temp1.交货数量,\n" + " temp1.交货数量,\n" +
" temp1.收货与交货差异,\n" + " temp1.收货与交货差异,\n" +
" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" + " ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" +
@ -190,7 +63,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" a.Version AS 期间,\n" +
" a.PurchaseOrderNoText AS 采购订单文本,\n" + " a.PurchaseOrderNoText AS 采购订单文本,\n" +
" '' AS 交货单号,\n" + " '' AS 交货单号,\n" +
" NULL AS 交货日期,\n" + " NULL AS 交货日期,\n" +
@ -199,14 +71,29 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" b.CustomerPartCode AS 物料代码,\n" + " b.CustomerPartCode AS 物料代码,\n" +
" b.MaterialDesc AS 物料描述,\n" + " b.MaterialDesc AS 物料描述,\n" +
" b.EstimateTypeDesc AS 物料组,\n" + " b.EstimateTypeDesc AS 物料组,\n" +
" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" +
" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" +
" ISNULL( a.InvoicedQty, 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( 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 PurchaseOrderNo!='NoOrder' ) AS a\n" + " (\n" +
" SELECT SUM\n" +
" ( ReceiptQty ) ReceiptQty,\n" +
" SUM ( InvoicedQty ) InvoicedQty,\n" +
" PurchaseOrderNo,\n" +
" MaterialCode,\n" +
" PurchaseOrderNoText \n" +
" FROM\n" +
" Set_SparePart \n" +
" WHERE\n" +
" Extend != 'is90' \n" +
" AND PurchaseOrderNo != 'NoOrder' \n" +
" AND Version = '{0}' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode,\n" +
" PurchaseOrderNoText \n" +
" ) 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" +
@ -216,18 +103,46 @@ 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' AND PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + " LEFT JOIN (\n" +
" SELECT SUM\n" +
" ( ReceiptQty ) Qty,\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_SparePart \n" +
" WHERE\n" +
" VERSION < '{0}' \n" +
" AND Extend != 'is90' \n" +
" AND PurchaseOrderNo != 'NoOrder' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" ) 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" +
" AND A.MaterialCode = C.MaterialCode \n" + " AND A.MaterialCode = C.MaterialCode \n" +
" WHERE\n" +
" ( a.Version = '{0}' ) \n" +
" ) AS temp1\n" + " ) AS temp1\n" +
" 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 \n" ; " LEFT JOIN (\n" +
" SELECT\n" +
" ROUND( SUM ( AmountNoTax ) / SUM ( ReceiptQty ), 4 ) PurchasePriceNoTax,\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_SparePart \n" +
" WHERE\n" +
" Extend != 'is90' \n" +
" AND PurchaseOrderNo != 'NoOrder' \n" +
" AND Version = '{0}' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" ) AS TEMP4 ON temp1.[物料代码] = TEMP4.MaterialCode \n" +
" AND temp1.采购订单号 = TEMP4.PurchaseOrderNo \n" +
" ) union1";
@ -240,7 +155,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var sql1 = "SELECT\n" + var sql1 = "SELECT\n" +
" A.WMSDeliveryNote WmsBillNum,\n" + " A.WMSDeliveryNote WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" + " t1.MaterialCode MaterialCode,\n" +
" A.PurchaseOrderNo,\n" + " A.PurchaseOrderNo Kanban,\n" +
" A.SpareDate WmsDate \n" + " A.SpareDate WmsDate \n" +
"FROM\n" + "FROM\n" +
" Set_WMSSparePart A\n" + " Set_WMSSparePart A\n" +
@ -285,7 +200,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var sql2 = "SELECT\n" + var sql2 = "SELECT\n" +
" A.WMSDeliveryNote WmsBillNum,\n" + " A.WMSDeliveryNote WmsBillNum,\n" +
" t1.MaterialCode MaterialCode,\n" + " t1.MaterialCode MaterialCode,\n" +
" A.PurchaseOrderNo,\n" + " A.PurchaseOrderNo Kanban,\n" +
" A.SpareDate WmsDate \n" + " A.SpareDate WmsDate \n" +
"FROM\n" + "FROM\n" +
" Set_WMSSparePart A\n" + " Set_WMSSparePart A\n" +
@ -297,6 +212,120 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//结算表中订单日期也要合并
var sql10 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT CONVERT\n" +
" ( VARCHAR ( 100 ), a.SpareDate, 23 ) AS AcceptanceDate,\n" +
" PurchaseOrderNo KanbanNumber,\n" +
" b2.MaterialCode \n" +
" FROM\n" +
" Set_SparePart a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" WHERE\n" +
" a.Extend != 'is90' \n" +
" AND a.PurchaseOrderNo != 'NoOrder' \n" +
" AND a.Version = '{0}' \n" +
" ) t1\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" PurchaseOrderNo KanbanNumber,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_SparePart a \n" +
" WHERE\n" +
" a.Extend != 'is90' \n" +
" AND a.PurchaseOrderNo != 'NoOrder' \n" +
" AND a.Version = '{0}' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.KanbanNumber = t2.KanbanNumber \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"WHERE\n" +
" t2.KanbanNumber IS NULL";
var list11 = DbConnection.Query<CompareExtend1>(string.Format(sql10, version));
var sql11 = "SELECT DISTINCT\n" +
" t1.* \n" +
"FROM\n" +
" (\n" +
" SELECT CONVERT\n" +
" ( VARCHAR ( 100 ), a.SpareDate, 23 ) AS AcceptanceDate,\n" +
" PurchaseOrderNo KanbanNumber,\n" +
" b2.MaterialCode \n" +
" FROM\n" +
" Set_SparePart a\n" +
" LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" +
" WHERE\n" +
" a.Extend != 'is90' \n" +
" AND a.PurchaseOrderNo != 'NoOrder' \n" +
" AND a.Version = '{0}' \n" +
" ) t1\n" +
" INNER JOIN (\n" +
" SELECT\n" +
" PurchaseOrderNo KanbanNumber,\n" +
" MaterialCode \n" +
" FROM\n" +
" Set_SparePart a \n" +
" WHERE\n" +
" a.Extend != 'is90' \n" +
" AND a.PurchaseOrderNo != 'NoOrder' \n" +
" AND a.Version = '{0}' \n" +
" GROUP BY\n" +
" PurchaseOrderNo,\n" +
" MaterialCode \n" +
" HAVING\n" +
" COUNT ( * ) > 1 \n" +
" ) t2 ON t1.KanbanNumber = t2.KanbanNumber \n" +
" AND t1.MaterialCode = t2.MaterialCode \n" +
"ORDER BY\n" +
" t1.KanbanNumber,\n" +
" t1.MaterialCode";
var list12 = DbConnection.Query<CompareExtend1>(string.Format(sql11, version));
List<CompareExtend1> _lscopy = new List<CompareExtend1>();
foreach (var itm in list11)
{
var first = _lscopy.FirstOrDefault(p => p.KanbanNumber == itm.KanbanNumber && p.MaterialCode == itm.MaterialCode);
if (first != null)
{
first.AcceptanceDate += "," + itm.AcceptanceDate;
}
else
{
_lscopy.Add(itm);
}
}
foreach (var itm in list12)
{
_lscopy.Add(itm);
}
List<CompareExtend> _ls = new List<CompareExtend>(); List<CompareExtend> _ls = new List<CompareExtend>();
foreach (var itm in listCompare.ToList()) foreach (var itm in listCompare.ToList())
{ {
@ -342,6 +371,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
itm1. = itm.WmsDate; itm1. = itm.WmsDate;
} }
var itmcopy = _lscopy.FirstOrDefault(p => p.KanbanNumber == itm1. && p.MaterialCode == itm1.SAP编码);
if (itmcopy != null)
{
itm1. = itmcopy.AcceptanceDate;
}
} }
@ -350,177 +385,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
/// <summary>
/// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90'
/// </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> GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
// string begintime, string endtime)
//{
// string sqlString = "SELECT\n" +
// " union1.* \n" +
// "FROM\n" +
// " (\n" +
// " SELECT\n" +
// " temp1.交货日期,\n" +
// " temp1.交货单号,\n" +
// " '' 订单日期,\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" +
// " FROM\n" +
// " (\n" +
// " SELECT\n" +
// " a.Version AS 期间,\n" +
// " a.PurchaseOrderNoText AS 采购订单文本,\n" +
// " b.WMSDeliveryNote AS 交货单号,\n" +
// " b.SpareDate AS 交货日期,\n" +
// " a.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( a.InvoicedQty, 0 ) AS 开票数量 ,\n" +
// " ISNULL( a.AmountNoTax, 0 ) AS 开票金额 \n" +
// " FROM\n" +
// " (\n" +
// " SELECT SUM\n" +
// " ( ReceiptQty ) AS ReceiptQty,\n" +
// " PurchaseOrderNo,\n" +
// " MaterialCode,\n" +
// " Version,\n" +
// " PurchasePriceNoTax,\n" +
// " InvoicedQty,\n" +
// " PurchaseOrderNoText,\n" +
// " AmountNoTax \n" +
// " FROM\n" +
// " Set_SparePart WHERE Extend != 'is90' \n" +
// " GROUP BY\n" +
// " PurchaseOrderNo,\n" +
// " MaterialCode,\n" +
// " Version,\n" +
// " PurchasePriceNoTax,\n" +
// " InvoicedQty,\n" +
// " PurchaseOrderNoText,\n" +
// " AmountNoTax \n" +
// " ) AS a\n" +
// " INNER JOIN (\n" +
// " SELECT SUM\n" +
// " ( ReceiptQty ) AS ReceiptQty,\n" +
// " PurchaseOrderNo,\n" +
// " SapCode,\n" +
// " MaterialCode,\n" +
// " WMSDeliveryNote,\n" +
// " SpareDate \n" +
// " FROM\n" +
// " Set_WMSSparePart \n" +
// " GROUP BY\n" +
// " PurchaseOrderNo,\n" +
// " SapCode,\n" +
// " MaterialCode,\n" +
// " WMSDeliveryNote,\n" +
// " SpareDate \n" +
// " ) AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" +
// " AND 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 = '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" +
// " 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" +
// " a.Version AS 期间,\n" +
// " '' AS 采购订单文本,\n" +
// " NULL AS 交货日期,\n" +
// " c.MaterialCode AS SAP编码,\n" +
// " a.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( 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' and PurchaseOrderNo is null 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 = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" +
// " ) union2";
// //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp.Sap编码 = TEMP2.MaterialCode\n" +
// 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>
/// 大众备件有单号,统计有结算无发货 /// 大众备件有单号,统计有结算无发货
@ -761,69 +625,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
/// <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" +
// " '' 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" +
// " 0 AS 数量差异,\n" +
// " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" +
// " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" +
// " ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" +
// " FROM\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 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" +
// " ( b.MaterialCode IS NULL ) \n" +
// " ) AS temp1\n" +
// " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) 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>
@ -938,91 +739,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" 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" +
" ) unint2"; " ) unint2";
//string sqlString = "SELECT\n" +
//" * \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
//" temp1.交货单号,\n" +
//" temp1.交货日期,\n" +
//" temp1.采购订单号,\n" +
//" temp1.SAP编码,\n" +
//" temp1.物料代码,\n" +
//" temp1.物料描述,\n" +
//" temp1.交货数量,\n" +
//" temp1.收货数量,\n" +
//" temp1.收货与交货差异,\n" +
//" ISNULL( temp3.Qty, 0 ) 退货数量,\n" +
//" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp1.收货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" +
//" ISNULL( TEMP2.Price, 0 ) AS 定价 \n" +
//" FROM\n" +
//" (\n" +
//" SELECT\n" +
//" '' AS 交货单号,\n" +
//" NULL AS 交货日期,\n" +
//" a.PurchaseOrderNo AS 采购订单号,\n" +
//" c.MaterialCode AS SAP编码,\n" +
//" c.CustomerPartCode AS 物料代码,\n" +
//" c.MaterialDesc AS 物料描述,\n" +
//" c.EstimateTypeDesc AS 物料组,\n" +
//" ISNULL( a.ReceiptQty, 0 ) AS 交货数量,\n" +
//" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" +
//" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" +
//" FROM\n" +
//" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) AS a\n" +
//" LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \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" +
//" WHERE\n" +
//" b.PurchaseOrderNo IS NULL \n" +
//" AND b.MaterialCode IS NULL \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" +
//" ) unint1 UNION ALL\n" +
//"SELECT\n" +
//" * \n" +
//"FROM\n" +
//" (\n" +
//" SELECT\n" +
//" temp1.交货单号,\n" +
//" temp1.交货日期,\n" +
//" temp1.采购订单号,\n" +
//" temp1.SAP编码,\n" +
//" temp1.物料代码,\n" +
//" temp1.物料描述,\n" +
//" temp1.交货数量,\n" +
//" temp1.收货数量,\n" +
//" temp1.收货与交货差异,\n" +
//" ISNULL( temp3.Qty, 0 ) 退货数量,\n" +
//" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp1.收货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" +
//" ISNULL( TEMP2.Price, 0 ) AS 定价 \n" +
//" FROM\n" +
//" (\n" +
//" SELECT\n" +
//" '' AS 交货单号,\n" +
//" NULL AS 交货日期,\n" +
//" a.PurchaseOrderNo AS 采购订单号,\n" +
//" c.MaterialCode AS SAP编码,\n" +
//" c.CustomerPartCode AS 物料代码,\n" +
//" c.MaterialDesc AS 物料描述,\n" +
//" c.EstimateTypeDesc AS 物料组,\n" +
//" ISNULL( a.ReceiptQty, 0 ) AS 交货数量,\n" +
//" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" +
//" ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" +
//" FROM\n" +
//" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) a\n" +
//" INNER JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND Version < '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \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" +
//" WHERE\n" +
//" a.ReceiptQty> b.ReceiptQty \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" +
//" ) unint2";
string _sql = string.Format(sqlString, version); string _sql = string.Format(sqlString, version);

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

@ -53,81 +53,58 @@ namespace SettleAccount.Job.Services.Report
var _forwardls_withcode = _dapper.GetWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _forwardls_withcode = _dapper.GetWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
//反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中
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 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 //var queryStockList_nocode = from itm in _forwardls_nocode
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()
select new SettleSparePartExport( // select new SettleSparePartExport(
itm.SAP编码, // itm.SAP编码,
itm., // itm.物料代码,
itm., // itm.物料描述,
itm., // itm.发货数量,
itm., // itm.收货数量,
itm., // itm.开票数量,
itm., // itm.收货与开票差异,
itm., // itm.开票单价,
itm., // itm.开票金额,
itm., // itm.定价,
itm., // itm.单价差异,
itm., // itm.差异总金额,
tm1 == null ? 0 : tm1.Qty // 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 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()
select new SettleSparePartExport( // select new SettleSparePartExport(
itm.SAP编码, // itm.SAP编码,
itm., // itm.物料代码,
itm., // itm.物料描述,
itm., // itm.发货数量,
itm., // itm.收货数量,
itm., // itm.开票数量,
itm., // itm.收货与开票差异,
itm., // itm.开票单价,
itm., // itm.开票金额,
itm., // itm.定价,
itm., // itm.单价差异,
itm., // itm.差异总金额,
tm1 == null ? 0 : tm1.Qty // tm1 == null ? 0 : tm1.Qty
); // );
//var diffList = _dapper.GetSettleSparePartSumQtyDiff(version);
//if (diffList != null)
//{
// foreach (var itm in diffList)
// {
// var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && 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)) if (!string.IsNullOrEmpty(sapCode))
{ {
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
@ -164,12 +141,12 @@ namespace SettleAccount.Job.Services.Report
var result = _exporter.Append(_ls.ToList(), "大众备件明细数据") var result = _exporter.Append(_ls.ToList(), "大众备件明细数据")
.SeparateBySheet() .SeparateBySheet()
.Append(_forwardls_withcode.ToList(), "有结算无发货对比") .Append(_forwardls_withcode.ToList(), "有结算无发货对比")
.SeparateBySheet() // .SeparateBySheet()
.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") //.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)")
.SeparateBySheet() // .SeparateBySheet()
.Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") // .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总")
.SeparateBySheet() // .SeparateBySheet()
.Append(queryStockList.ToList(), "零件汇总比对寄售库存") //.Append(queryStockList.ToList(), "零件汇总比对寄售库存")
.ExportAppendDataAsByteArray(); .ExportAppendDataAsByteArray();
result.ShouldNotBeNull(); result.ShouldNotBeNull();
_fileContainer.SaveAsync(fileName, result.Result, true); _fileContainer.SaveAsync(fileName, result.Result, true);

143
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs

@ -0,0 +1,143 @@
using Magicodes.ExporterAndImporter.Excel;
using Shouldly;
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.BlobStoring;
using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
namespace SettleAccount.Job.Services.Report
{
public class SettleUnSparePartExportService : ITransientDependency, IExportJob
{
private readonly SettleSparePartDapperReportRepository _dapper;
private readonly OutputService _outputService;
private readonly ErpPartDapperRepository _erpdapperRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly WmsDapperRepository _wmsDapper;
public SettleUnSparePartExportService(SettleSparePartDapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService
, WmsDapperRepository wmsDapper
, IBlobContainer<MyFileContainer> fileContainer)
{
_dapper = dapper;
_outputService = outputService;
_erpdapperRepository = erpdapperRepository;
_fileContainer = fileContainer;
_wmsDapper = wmsDapper;
}
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 iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value;
//反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中
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 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 queryStockList = from itm in _forwardls
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
);
if (!string.IsNullOrEmpty(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_reversels_withcode = _reversels_withcode.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)
{
_reversels_withcode = _reversels_withcode.Where(p => _groupList.Contains(p.)).ToList();
}
}
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)")
.SeparateBySheet()
.Append(queryStockList_nocode.ToList(), "大众备件无单号汇总")
.SeparateBySheet()
.Append(queryStockList.ToList(), "零件汇总比对寄售库存")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(fileName, result.Result, true);
return id.ToString();
}
}
}

13
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs

@ -174,7 +174,11 @@ namespace SettleAccount.Job.Services.Report
var materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; var materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value;
var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value;
//var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; //var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value;
var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value;
var iscontionversion = "1";//不分版本,全查
//var version = p_list.Where(p => p.Name == "Version").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 customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value;
@ -245,10 +249,11 @@ namespace SettleAccount.Job.Services.Report
var begin = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value; var begin = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value;
var end = p_list.Where(p => p.Name == "End").FirstOrDefault().Value; var end = p_list.Where(p => p.Name == "End").FirstOrDefault().Value;
var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value;
var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; //var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; //var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value;
var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value;
var iscontionversion = "1";//不分区间,全查
//有发货无结算,单独拿出去,财务要求 //有发货无结算,单独拿出去,财务要求
var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion);
if (!string.IsNullOrEmpty(sapCode)) if (!string.IsNullOrEmpty(sapCode))

5
src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -119,6 +119,11 @@ namespace Win.Sfs.SettleAccount
{ {
return implementationFactory.GetService<SettleSparePartExportService>(); return implementationFactory.GetService<SettleSparePartExportService>();
} }
//大众备件未结明细
if (key.Equals(typeof(SettleUnSparePartExportService).FullName))
{
return implementationFactory.GetService<SettleUnSparePartExportService>();
}
//大众备件90天核对明细 //大众备件90天核对明细
if (key.Equals(typeof(SettleSparePart90ExportService).FullName)) if (key.Equals(typeof(SettleSparePart90ExportService).FullName))
{ {

Loading…
Cancel
Save