Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
690f5e8c21
  1. 5
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs
  2. 111
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs
  3. 2
      src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs
  4. 10
      src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml
  5. 9
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs
  6. 4
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs
  7. 237
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs
  8. 56
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs

5
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs

@ -292,11 +292,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
var _list = _excelHelper.ExcelToList<WmsKanbanOutPutDetial>(); var _list = _excelHelper.ExcelToList<WmsKanbanOutPutDetial>();
foreach (var itm in _list) foreach (var itm in _list)
{ {
itm.SetData(GuidGenerator.Create(),string.Empty,!string.IsNullOrEmpty(itm.WmsBillNum)? itm.WmsBillNum:string.Empty,input.Version,GuidGenerator.Create()); itm.SetData(GuidGenerator.Create(),string.Empty,!string.IsNullOrEmpty(itm.WmsBillNum)? itm.WmsBillNum:string.Empty,input.Version,GuidGenerator.Create());
} }
_lst.AddRange(_list.ToArray()); _lst.AddRange(_list.ToArray());

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

@ -158,16 +158,8 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
foreach (var itm in _joblist) foreach (var itm in _joblist)
{ {
itm.FileName = "已确认"; itm.FileName = "已确认";
}
foreach (var itm in _joblist)
{
await _job.UpdateAsync(itm); await _job.UpdateAsync(itm);
} }
var _count=await _job.BatchUpdateAsync(_joblist.ToList());
if (_count > 0)
{
return true;
}
return false; return false;
} }
/// <summary> /// <summary>
@ -193,35 +185,36 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>(); var _list = _excelHelper.ExcelToList<WmsSharePartOutPutDetial>();
if (_list.Count() > 0) if (_list.Count() > 0)
{ {
var _lsAry = _list.GroupBy(p => new
{ //var _lsAry = _list.GroupBy(p => new
p.MaterialCode, //{
p.MaterialGroup, // p.MaterialCode,
p.OrderBillNum, // p.MaterialGroup,
p.MaterialDesc, // p.OrderBillNum,
p.Version, // p.MaterialDesc,
p.WmsBillNum, // p.Version,
}).Select(p => new // p.WmsBillNum,
WmsSharePartOutPutDetial( //}).Select(p => new
GuidGenerator.Create(), //WmsSharePartOutPutDetial(
p.Key.WmsBillNum, // GuidGenerator.Create(),
p.Key.OrderBillNum, // p.Key.WmsBillNum,
p.Key.MaterialCode, // p.Key.OrderBillNum,
p.Key.MaterialDesc, // p.Key.MaterialCode,
p.Key.MaterialGroup, // p.Key.MaterialDesc,
string.Empty, // p.Key.MaterialGroup,
string.Empty, // string.Empty,
0, // string.Empty,
string.Empty, // 0,
string.Empty, // string.Empty,
string.Empty, // string.Empty,
p.Key.MaterialCode, // string.Empty,
_billNum, // p.Key.MaterialCode,
GuidGenerator.Create(), // _billNum,
string.Empty, // GuidGenerator.Create(),
p.Sum(itm => itm.Qty) // string.Empty,
)); // p.Sum(itm => itm.Qty)
_lst.AddRange(_lsAry.ToArray()); //));
_lst.AddRange(_list.ToArray());
} }
} }
@ -229,67 +222,34 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
var error = from itm1 in outPutDetail var error = from itm1 in outPutDetail
join itm2 in _lst on join itm2 in _lst on
new { itm1.MaterialCode, itm1.OrderBillNum } new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum }
equals equals
new { itm2.MaterialCode, itm2.OrderBillNum } new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum }
select itm1; select itm1;
var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) });
if (errList.Count() == 0) if (errList.Count() == 0)
{ {
var query = from itm1 in _lst var query = from itm1 in _lst
join itm2 in outPutDetail on join itm2 in outPutDetail on
new { itm1.MaterialCode, itm1.OrderBillNum } new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum }
equals equals
new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1
from tm1 in temp1.DefaultIfEmpty() from tm1 in temp1.DefaultIfEmpty()
where tm1 == null where tm1 == null
select itm1; select itm1;
var _wmslst = query.ToList(); var _wmslst = query.ToList();
_wmslst = _wmslst.GroupBy(p => new
{
p.MaterialCode,
p.MaterialGroup,
p.OrderBillNum,
p.MaterialDesc,
p.Version,
p.WmsBillNum,
}).Select(p => new
WmsSharePartOutPutDetial(
GuidGenerator.Create(),
p.Key.WmsBillNum,
p.Key.OrderBillNum,
p.Key.MaterialCode,
p.Key.MaterialDesc,
p.Key.MaterialGroup,
string.Empty,
string.Empty,
0,
string.Empty,
string.Empty,
string.Empty,
p.Key.MaterialCode,
_billNum,
GuidGenerator.Create(),
string.Empty,
p.Sum(itm => itm.Qty)
)).ToList();
foreach (var itm in _wmslst) foreach (var itm in _wmslst)
{ {
itm.BillNum = _billNum; itm.BillNum = _billNum;
} }
await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 });
int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum);
if (_count == 0) if (_wmslst.Count()>0 && _count == 0)
{ {
var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email);
await _wmsVersionRepository.InsertAsync(_version, true); await _wmsVersionRepository.InsertAsync(_version, true);
} }
foreach (var job in _joblist) foreach (var job in _joblist)
{ {
job.FileName = _billNum; job.FileName = _billNum;
@ -310,7 +270,6 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
job.FileName = _errinfo; job.FileName = _errinfo;
await _job.UpdateAsync(job); await _job.UpdateAsync(job);
} }
} }
} }
else else

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

@ -199,7 +199,7 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices
customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? 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 = "CustomerCode", Value = customerCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" }); customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" });
customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? "0" }); customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" }); customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" });
customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() });
customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() });

10
src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml

@ -1732,7 +1732,7 @@
wms出库 wms出库
</summary> </summary>
</member> </member>
<member name="M:Win.Sfs.SettleAccount.Entities.SettleAccounts.WMSHQFSharePartAppService.#ctor(Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.TaskJob,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPut,System.Guid},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{WY.NewJit.Extends.PaiGe.WMS.TB_BILL},Win.Sfs.BaseData.ImportExcelCommon.IExcelImportAppService,Volo.Abp.Caching.IDistributedCache{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial},Win.Abp.Snowflakes.ISnowflakeIdGenerator,Win.Sfs.SettleAccount.CommonManagers.ICommonManager)"> <member name="M:Win.Sfs.SettleAccount.Entities.SettleAccounts.WMSHQFSharePartAppService.#ctor(Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report.WmsDapperRepository,Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.TaskJob,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPut,System.Guid},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{WY.NewJit.Extends.PaiGe.WMS.TB_BILL},Win.Sfs.BaseData.ImportExcelCommon.IExcelImportAppService,Volo.Abp.Caching.IDistributedCache{Win.Sfs.SettleAccount.Entities.WMS.WmsHQFSharePartOutPutDetial},Win.Abp.Snowflakes.ISnowflakeIdGenerator,Win.Sfs.SettleAccount.CommonManagers.ICommonManager)">
<summary> <summary>
</summary> </summary>
@ -1852,7 +1852,7 @@
wms出库 wms出库
</summary> </summary>
</member> </member>
<member name="M:Win.Sfs.SettleAccount.Entities.SettleAccounts.WmsHQHSharePartAppService.#ctor(Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.TaskJob,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPut,System.Guid},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{WY.NewJit.Extends.PaiGe.WMS.TB_BILL},Win.Sfs.BaseData.ImportExcelCommon.IExcelImportAppService,Volo.Abp.Caching.IDistributedCache{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial},Win.Abp.Snowflakes.ISnowflakeIdGenerator,Win.Sfs.SettleAccount.CommonManagers.ICommonManager)"> <member name="M:Win.Sfs.SettleAccount.Entities.SettleAccounts.WmsHQHSharePartAppService.#ctor(Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.TaskJob,System.Guid},Win.Sfs.SettleAccount.ISettleAccountBranchEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPut,System.Guid},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial},Win.Sfs.SettleAccount.Repository.WMSEfCoreRepository{WY.NewJit.Extends.PaiGe.WMS.TB_BILL},Win.Sfs.BaseData.ImportExcelCommon.IExcelImportAppService,Volo.Abp.Caching.IDistributedCache{Win.Sfs.SettleAccount.Entities.WMS.WmsHQHSharePartOutPutDetial},Win.Abp.Snowflakes.ISnowflakeIdGenerator,Win.Sfs.SettleAccount.CommonManagers.ICommonManager,Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report.WmsDapperRepository)">
<summary> <summary>
</summary> </summary>
@ -3293,21 +3293,21 @@
</member> </member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQHShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)"> <member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQHShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)">
<summary> <summary>
H平台发运核对输出 H平台未结明细
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQFShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)"> <member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQFShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)">
<summary> <summary>
F平台发运核对输出 F平台未结明细
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQMShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)"> <member name="M:Win.Sfs.SettleAccount.Reports.ReportServices.ReportService.HQMShippingExportServiceMake(Win.Sfs.SettleAccount.Reports.ReportRequestDto.HQKanbanRequestDto)">
<summary> <summary>
M平台发运核对输出 M平台未明细
</summary> </summary>
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>

9
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/WMS/TaskList.cs

@ -982,14 +982,14 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
Id = id; Id = id;
} }
// 交货单号 实际发货日期 KENN号 底盘号 物料号 物料描述 客户物料 组件组物料 组件组物料描述 物料组(车型) 定价 金额 结算平台未结数量 大众R3未结数量 差异金额 差异数量 漏结标识 漏结期间 说明 // 期间 交货单号 发货日期 采购订单号 SAP编码 物料代码 物料描述 物料组 开票单价 数量差异 发货数量 开票数量 定价 单价差异
//交货单号
[ImporterHeader(Name = "组件组物料")]
[ImporterHeader(Name = "组件组物料",IsIgnore =true)]
public string ParentMaterialCode { set; get; } public string ParentMaterialCode { set; get; }
[ImporterHeader(Name = "交货单号")] [ImporterHeader(Name = "交货单号")]
public string WmsBillNum { set; get; } public string WmsBillNum { set; get; }
[ImporterHeader(Name = "看板号")] [ImporterHeader(Name = "采购订单号")]
//KENN号 //KENN号
public string OrderBillNum { set; get; } public string OrderBillNum { set; get; }
@ -1032,6 +1032,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS
public string BillNum { set; get; } public string BillNum { set; get; }
[ImporterHeader(Name = "任务代码", IsIgnore = true)]
public Guid TaskId { set; get; } public Guid TaskId { set; get; }

4
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/ErpPartDapperRepository.cs

@ -164,5 +164,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
var _list = DbConnection.Query<InvoiceSettleDiff>(string.Format(str, version)); var _list = DbConnection.Query<InvoiceSettleDiff>(string.Format(str, version));
return _list.ToList(); return _list.ToList();
} }
} }
} }

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

@ -2,6 +2,7 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -23,59 +24,53 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public virtual List<SettleSparePartExport> GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, public virtual List<SettleSparePartExport> GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode,
string begintime, string endtime) string begintime, string endtime)
{ {
string sqlString = "SELECT\n" + string sqlString =
" * ,\n" + " SELECT\n" +
" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" + " temp1.期间,\n" +
" ISNULL( Price * ReceiptQty - InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" + " temp1.交货单号,\n" +
" \n" + " temp1.发货日期,\n" +
" temp1.采购订单号,\n" +
" temp1.SAP编码,\n" +
" temp1.物料代码,\n" +
" temp1.物料描述,\n" +
" temp1.物料组,\n" +
" temp1.开票单价,\n" +
" temp1.数量差异,\n" +
" temp1.发货数量,\n" +
" temp1.开票数量,\n" +
" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" +
" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 \n" +
" FROM\n" + " FROM\n" +
" (\n" + " (\n" +
" SELECT\n" + " SELECT\n" +
" c.LineNumber,--行号\n" + " a.Version AS 期间,\n" +
" c.Period AS WMSDeliveryDate,--交货日期\n" + " b.WMSDeliveryNote AS 交货单号,\n" +
" c.WMSDeliveryNote,--交货单号\n" + " b.SpareDate AS 发货日期,\n" +
" c.SpareDate AS OrderDate,--订单日期\n" + " a.PurchaseOrderNo AS 采购订单号,\n" +
" a.PurchaseOrderNo,--采购订单号\n" + " c.MaterialCode AS SAP编码,\n" +
" b.MaterialCode AS SAPCode,--SAP编码,即厂内物料号\n" + " a.MaterialCode AS 物料代码,\n" +
" a.MaterialCode,--物料代码\n" + " c.MaterialDesc AS 物料描述,\n" +
" b.MaterialDesc,--物料描述\n" + " c.EstimateTypeDesc AS 物料组,\n" +
" a.PurchaseOrderNoText,--采购订单文本\n" + " a.PurchasePriceNoTax AS 开票单价,\n" +
" c.ReceiptQty,-- 发货数量\n" + " 0 AS 数量差异,\n" +
" a.InvoicedQty AS InvoicedQty,--开票数量\n" + " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" +
" ( c.ReceiptQty- d.Amt ) AS SettleInvoiceDiffQty,--发货与开票差异\n" + " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 \n" +
" d.InvoicePrice,--开票单价\n" +
" 0 AS InvoiceMoney --开票金额\n" +
" \n" +
" FROM\n" + " FROM\n" +
" (\n" + " (SELECT SUM( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart GROUP BY PurchaseOrderNo, MaterialCode, Version, PurchasePriceNoTax ) AS a\n" +
" LEFT OUTER JOIN Set_WMSSparePart 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}' )) AS temp1\n" +
" LEFT OUTER JOIN (\n" +
" SELECT\n" + " SELECT\n" +
" t.PurchaseOrderNoText,\n" + " Price,\n" +
" t.LineNumber,\n" + " MaterialCode \n" +
" t.PurchaseOrderNo,\n" +
" t.MaterialCode,\n" +
" MAX ( t.SpareDate ) SpareDate,\n" +
" t.DeliveryOrderNo,\n" +
" SUM ( t.InvoicedQty ) AS InvoicedQty \n" +
" FROM\n" + " FROM\n" +
" Set_SparePart t \n" + " Set_PriceList \n" +
" WHERE\n" + " WHERE\n" +
" t.Version= '{0}' \n" + " (\n" +
" GROUP BY\n" + " Version = ( SELECT MAX(Version) AS Expr1 FROM Set_PriceList ))) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode";
" t.PurchaseOrderNo,\n" +
" t.MaterialCode,\n" +
" t.SpareDate,\n" +
" t.DeliveryOrderNo,\n" +
" t.LineNumber,\n" +
" t.PurchaseOrderNoText \n" +
" ) 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 addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version); string addSqlStr = string.Format(sqlString, version);
//if (!string.IsNullOrEmpty(purchaseOrderNo)) //if (!string.IsNullOrEmpty(purchaseOrderNo))
@ -135,7 +130,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
" ) TEMP1 \n" + " ) TEMP1 \n" +
" LEFT JOIN ( SELECT Price, --定价 \n" + " LEFT JOIN ( SELECT Price, --定价 \n" +
" MaterialCode --厂内物料号 \n" + " MaterialCode --厂内物料号 \n" +
" FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode "; " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList_20 ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode ";
string addwhere = string.Empty; string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version); string addSqlStr = string.Format(sqlString, version);
//if (!string.IsNullOrEmpty(purchaseOrderNo)) //if (!string.IsNullOrEmpty(purchaseOrderNo))
@ -162,66 +157,146 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
} }
public virtual List<SparePartSumQtyDiff> GetSettleSparePartSumQtyDiff(string version)
{
string sqlString = "SELECT\n" +
" ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" +
" a.PurchaseOrderNo 订单号,\n" +
" a.MaterialCode 物料号 \n" +
" FROM\n" +
" ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart where Version='{0}' GROUP BY PurchaseOrderNo, MaterialCode ) A\n" +
" LEFT JOIN ( SELECT sum( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) B ON A.MaterialCode = B.MaterialCode \n" +
" AND A.PurchaseOrderNo = B.PurchaseOrderNo";
string addwhere = string.Empty;
string addSqlStr = string.Format(sqlString, version);
string _sql = string.Format(addSqlStr, addwhere);
var _query = DbConnection.Query<SparePartSumQtyDiff>(_sql, null, null, true, 1200, null);
return _query.ToList();
}
}
public class SparePartSumQtyDiff
{
public decimal { set; get; }
public string { set; get; }
public string { set; get; }
} }
/// <summary> /// <summary>
/// 大众看板有条码报表 /// 大众看板有条码报表
/// </summary> /// </summary>
//[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)] //[ExcelExporter(Name = "未结明细", AutoFitAllColumn = true, MaxRowNumberOnASheet = 500000)]
public class SettleSparePartExport public class SettleSparePartExport
{ {
[ExporterHeader(DisplayName = "行号")]
public string LineNumber { set; get; }
[ExporterHeader(DisplayName = "交货日期")]
public string WMSDeliveryDate { set; get; }
[ExporterHeader(DisplayName = "期间 ")]
public string {set;get;}
[ExporterHeader(DisplayName = "交货单号 ")] [ExporterHeader(DisplayName = "交货单号 ")]
public string DeliveryOrderNo { set; get; } public string {set;get;}
[ExporterHeader(DisplayName = "发货日期")]
public string {set;get;}
[ExporterHeader(DisplayName = "采购订单号")]
public string {set;get;}
[ExporterHeader(DisplayName = "SAP编码")]
public string SAP编码 {set;get;}
[ExporterHeader(DisplayName = "物料代码")]
public string {set;get;}
[ExporterHeader(DisplayName = "物料描述")]
public string {set;get;}
[ExporterHeader(DisplayName = "物料组")]
public string {set;get;}
[ExporterHeader(DisplayName = "开票单价")]
public decimal {set;get;}
[ExporterHeader(DisplayName = "数量差异")]
public decimal {set;get;}
[ExporterHeader(DisplayName = "发货数量")]
public decimal {set;get;}
[ExporterHeader(DisplayName = "开票数量")]
public decimal {set;get;}
[ExporterHeader(DisplayName = "定价")]
public decimal {set;get;}
[ExporterHeader(DisplayName = "单价差异")]
public decimal { set; get;}
[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 = "发货数量")] //[ExporterHeader(DisplayName = "行号")]
public decimal ReceiptQty { set; get; } //public string LineNumber { set; get; }
[ExporterHeader(DisplayName = "开票数量")] //[ExporterHeader(DisplayName = "交货日期")]
public decimal InvoicedQty { set; get; } //public string WMSDeliveryDate { set; get; }
[ExporterHeader(DisplayName = "发货与开票差异")] //[ExporterHeader(DisplayName = "交货单号")]
public decimal SettleInvoiceDiffQty { set; get; } //public string DeliveryOrderNo { set; get; }
[ExporterHeader(DisplayName = "开票单价")] //[ExporterHeader(DisplayName = "订单日期")]
public decimal InvoicePrice { set; get; } //public DateTime OrderDate{ set; get; }
[ExporterHeader(DisplayName = "开票金额")] //[ExporterHeader(DisplayName = "采购订单号")]
public decimal InvoiceMoney { set; get; } //public string PurchaseOrderNo { set; get; }
[ExporterHeader(DisplayName = "定价")]
public decimal Price { set; get; }
[ExporterHeader(DisplayName = "单价差异")] //[ExporterHeader(DisplayName = "SAP编码")]
public decimal InvoiceDiffPrice { set; get; } //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 = "总金额差异")] //[ExporterHeader(DisplayName = "总金额差异")]
public decimal SumDiffMoney { set; get; } //public decimal SumDiffMoney { set; get; }
} }
} }

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

@ -26,30 +26,70 @@ namespace SettleAccount.Job.Services.Report
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) 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 purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value;
var version = p_list.Where(p => p.Name == "Version").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 sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value;
var matialCode = p_list.Where(p => p.Name == "MatialCode").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 beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value;
var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value;
var _list = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); var _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);
var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version); var diffList = _dapper.GetSettleSparePartSumQtyDiff(version);
if (diffList != null) if (diffList != null)
{ {
foreach (var itm in diffList) foreach (var itm in diffList)
{ {
var _first = _list.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); var _first = _ls.FirstOrDefault(p => p. == itm. && p.==itm.);
if (_first != null) if (_first != null)
{ {
_first.InvoicedQty = _first.InvoicedQty + itm.DiffQty;//开票数量(结算数量+差异) _first. = _first. + itm.;//开票数量(结算数量+差异)
_first.InvoiceMoney = Math.Round(_first.InvoicedQty * _first.InvoicePrice, 2);//开票总金额(开票数量*开票单价) _first. = itm.;
_first.SumDiffMoney = (_first.ReceiptQty * _first.Price) - _first.InvoiceMoney;//总金额差异(结算金额-开票金额)
}
}
}
//if (!string.IsNullOrEmpty(materialGroup))
//{
// var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
// }
//}
if (!string.IsNullOrEmpty(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.SAP编码)).ToList();
}
}
if (!string.IsNullOrEmpty(matialCode))
{
var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.)).ToList();
}
} }
if (!string.IsNullOrEmpty(purchaseOrderNo))
{
var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.)).ToList();
} }
} }
_outputService.Export<SettleSparePartExport>(id, string.Format("大众备件结算核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _list);
_outputService.Export<SettleSparePartExport>(id, fileName, _ls);
return id.ToString(); return id.ToString();

Loading…
Cancel
Save