|
|
@ -45,6 +45,7 @@ namespace SettleAccount.Job.Services |
|
|
|
{ |
|
|
|
|
|
|
|
private readonly UnInvoiceSettledDetailDiffDapperRepository _dapperRepository; |
|
|
|
private readonly InvoiceSettledDetailDiffDapperRepository _dapperRepository1; |
|
|
|
private readonly ErpPartDapperRepository _erpdapperRepository; |
|
|
|
|
|
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
@ -56,6 +57,7 @@ namespace SettleAccount.Job.Services |
|
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
|
ErpPartDapperRepository erpdapperRepository, |
|
|
|
UnInvoiceSettledDetailDiffDapperRepository dapperRepository, |
|
|
|
InvoiceSettledDetailDiffDapperRepository dapperRepository1, |
|
|
|
OutputService outputService, |
|
|
|
InputService inputService |
|
|
|
) |
|
|
@ -67,6 +69,7 @@ namespace SettleAccount.Job.Services |
|
|
|
//_repository = repository;
|
|
|
|
//_versionRepository = versionRepository;
|
|
|
|
_dapperRepository =dapperRepository; |
|
|
|
_dapperRepository1 = dapperRepository1; |
|
|
|
} |
|
|
|
|
|
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|
|
@ -89,7 +92,7 @@ namespace SettleAccount.Job.Services |
|
|
|
var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version); |
|
|
|
foreach (var itm in _ls) |
|
|
|
{ |
|
|
|
itm.InvocieAmt =Math.Round( itm.InvoiceQty * itm.InvoicePrice,2); |
|
|
|
itm.InvoiceAmt =Math.Round( itm.InvoiceQty * itm.InvoicePrice,2); |
|
|
|
itm.DiffPrice = itm.Price - itm.InvoicePrice; |
|
|
|
itm.DiffSettleFisQty = itm.SettledQty; |
|
|
|
} |
|
|
@ -161,17 +164,35 @@ namespace SettleAccount.Job.Services |
|
|
|
|
|
|
|
}; |
|
|
|
_lsSum.Add(_sumTotal); |
|
|
|
ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _ls1=DiffPrice(id,exportName,p_list); |
|
|
|
|
|
|
|
var report1List = _ls1.Where(p => p.DiffPrice != 0).GroupBy(p => new { p.MaterialGroup, p.MaterialCode, p.MaterialDesc, p.Price, p.InvoicePrice, p.DiffPrice, p.SapMaterialCode }) |
|
|
|
.Select(t => new SettleDoorPanelExport { MaterialGroup = t.FirstOrDefault().MaterialGroup, MaterialCode = t.FirstOrDefault().MaterialCode, MaterialDesc = t.FirstOrDefault().MaterialDesc, Price = t.FirstOrDefault().Price, InvoicePrice = t.FirstOrDefault().InvoicePrice, InvoiceDiffPrice = t.FirstOrDefault().DiffPrice, SAPCode = t.FirstOrDefault().SapMaterialCode }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version }); ; |
|
|
|
|
|
|
|
|
|
|
|
var result = _exporter.Append(_ls, "差异明细表") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
|
|
|
|
|
|
|
var result = _exporter |
|
|
|
.Append(_ls, "差异明细表") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(_lsSum, "数量差异汇总表") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(report1List, "按物料价格差异明细表") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(report2List.ToList(), "差异汇总验证表") |
|
|
|
|
|
|
|
.ExportAppendDataAsByteArray(); |
|
|
|
|
|
|
|
result.ShouldNotBeNull(); |
|
|
|
_fileContainer.SaveAsync(_filename, result.Result, true); |
|
|
|
|
|
|
@ -179,6 +200,143 @@ namespace SettleAccount.Job.Services |
|
|
|
|
|
|
|
return id.ToString(); |
|
|
|
} |
|
|
|
public List<InvoiceSettledDetailDiff> DiffPrice(Guid id, List<string> exportName, List<CustomCondition> p_list) |
|
|
|
{ |
|
|
|
var _filename = exportName.FirstOrDefault(); |
|
|
|
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
|
var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; |
|
|
|
var begin = p_list.Where(p => p.Name == "BeginTime").FirstOrDefault().Value; |
|
|
|
var end = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; |
|
|
|
var cp7begin = p_list.Where(p => p.Name == "Cp7BeginTime").FirstOrDefault().Value; |
|
|
|
var cp7end = p_list.Where(p => p.Name == "Cp7EndTime").FirstOrDefault().Value; |
|
|
|
var kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value; |
|
|
|
var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").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 _ls = _dapperRepository1.GetInvoiceSettledDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber, materialGroup); |
|
|
|
var _list = _ls.Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.ParentSapMaterialCode, p.ChassisNumber, p.KENNCode }) |
|
|
|
.Select(p => p.FirstOrDefault()).ToList(); |
|
|
|
var rangeList = _erpdapperRepository.GetSapList<InvoiceSettledDetailDiff>(_list, version, true); |
|
|
|
var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version); |
|
|
|
if (_ls.Count > 0) |
|
|
|
{ |
|
|
|
var erpPriceList = _ls.Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.ParentSapMaterialCode, p.ChassisNumber, p.KENNCode }) |
|
|
|
.Select(p => new { ParentSapMaterialCode = p.Key.ParentSapMaterialCode, ChassisNumber = p.Key.ChassisNumber, KENNCode = p.Key.KENNCode, Price = p.Sum(itm => itm.InvoiceAmt) }).ToList(); |
|
|
|
var rangList = from itm1 in rangeList |
|
|
|
join itm2 in erpPriceList on new { itm1.ParentSapMaterialCode, itm1.KENNCode, itm1.ChassisNumber } equals new { itm2.ParentSapMaterialCode, itm2.KENNCode, itm2.ChassisNumber } |
|
|
|
into temp1 |
|
|
|
from tm1 in temp1.DefaultIfEmpty() |
|
|
|
select new InvoiceSettledDetailDiff |
|
|
|
{ |
|
|
|
WmsBillNum = itm1.WmsBillNum, |
|
|
|
CP5Time = itm1.CP5Time, |
|
|
|
KENNCode = itm1.KENNCode, |
|
|
|
ChassisNumber = itm1.ChassisNumber, |
|
|
|
WmsState = itm1.WmsState, |
|
|
|
SapMaterialCode = itm1.SapMaterialCode, |
|
|
|
MaterialDesc = itm1.MaterialDesc, |
|
|
|
MaterialCode = itm1.MaterialCode, |
|
|
|
ParentSapMaterialCode = itm1.ParentSapMaterialCode, |
|
|
|
ParentMaterialDesc = itm1.ParentMaterialDesc, |
|
|
|
MaterialGroup = itm1.MaterialGroup, |
|
|
|
Price = itm1.Price, |
|
|
|
Amt = itm1.Amt, |
|
|
|
Qty = 1, |
|
|
|
SettledQty = 1, |
|
|
|
CP7Time = itm1.CP7Time, |
|
|
|
DiffSettleFisQty = 0, |
|
|
|
DiffSettleInvQty = 0, |
|
|
|
InvoiceQty = 1, |
|
|
|
InvoicePrice = itm1 == null ? 0 : tm1.Price, |
|
|
|
InvoiceAmt = itm1 == null ? 0 : tm1.Price, |
|
|
|
SettleAmt = itm1 == null ? 0 : tm1.Price, |
|
|
|
DiffPrice = itm1 == null ? 0 - itm1.Price : tm1.Price - itm1.Price |
|
|
|
}; |
|
|
|
rangeList = rangList.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var itm in diffList) |
|
|
|
{ |
|
|
|
var _first = _ls.FirstOrDefault(p => p.MaterialCode == itm.MaterialCode); |
|
|
|
if (_first != null) |
|
|
|
{ |
|
|
|
_first.InvoiceQty = _first.SettledQty + itm.DiffQty; |
|
|
|
_first.DiffSettleInvQty = itm.DiffQty; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var itm in _ls) |
|
|
|
{ |
|
|
|
itm.InvoiceAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice, 2); |
|
|
|
itm.DiffPrice = itm.Price - itm.InvoicePrice; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_ls.AddRange(rangeList); |
|
|
|
|
|
|
|
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(kenncode)) |
|
|
|
{ |
|
|
|
var _groupList = kenncode.Split("\n").ToList(); |
|
|
|
if (_groupList.Count() > 0) |
|
|
|
{ |
|
|
|
_ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(chassisNumber)) |
|
|
|
{ |
|
|
|
var _groupList = chassisNumber.Split("\n").ToList(); |
|
|
|
if (_groupList.Count() > 0) |
|
|
|
{ |
|
|
|
_ls = _ls.Where(p => _groupList.Contains(p.ChassisNumber)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(materialCode)) |
|
|
|
{ |
|
|
|
var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList(); |
|
|
|
if (_groupList.Count() > 0) |
|
|
|
{ |
|
|
|
_ls = _ls.Where(p => _groupList.Contains(p.MaterialCode)).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.SapMaterialCode)).ToList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//.Select(p => p.FirstOrDefault());
|
|
|
|
_ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return _ls; |
|
|
|
|
|
|
|
//ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
|
|
|
//var result = _exporter.Append(report1List.ToList(), "按物料价格差异明细表")
|
|
|
|
//.SeparateBySheet()
|
|
|
|
//.Append(report2List.ToList(), "差异汇总验证表")
|
|
|
|
//.ExportAppendDataAsByteArray();
|
|
|
|
//result.ShouldNotBeNull();
|
|
|
|
//_fileContainer.SaveAsync(_filename, result.Result, true);
|
|
|
|
|
|
|
|
// _outputService.Export<SettleDoorPanelExport>(id, string.Format("大众准时化结算门板价格差异比对报表_{0}.xlsx", Guid.NewGuid().ToString()), _list);
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|