Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
c4c878d6f5
  1. 2
      src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs
  2. 46
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs
  3. 75
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleDoorPanelExportService.cs
  4. 164
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs

2
src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/InvoiceSettledDetailDiffDapperRepository.cs

@ -93,7 +93,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
public override decimal InvoicePrice { set; get; }
//开票金额
[ExporterHeader(DisplayName = "开票金额")]
public decimal InvocieAmt { set; get; }
public decimal InvoiceAmt { set; get; }
//结算金额
[ExporterHeader(DisplayName = "结算金额")]
public decimal SettleAmt { set; get; }

46
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs

@ -63,36 +63,21 @@ namespace SettleAccount.Job.Services
// var erpPriceList= _erpdapperRepository.GetErpPartCodePriceList(version);
//// var erpPriceList= _erpdapperRepository.GetErpPartCodePriceList(version);
var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
if (_ls.Count > 0)
{
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.InvocieAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice,2);
itm.DiffPrice = itm.Price - itm.InvoicePrice;
}
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.InvocieAmt) }).ToList();
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 }
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
@ -117,7 +102,7 @@ namespace SettleAccount.Job.Services
DiffSettleInvQty = 0,
InvoiceQty = 1,
InvoicePrice = itm1 == null ? 0 : tm1.Price,
InvocieAmt = 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
};
@ -127,6 +112,21 @@ namespace SettleAccount.Job.Services
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);
//var list1 = _ls.GroupBy(p => new { p.ChassisNumber, p.MaterialCode, p.SettleReadyQty }).Select(p => new { SettleQty = p.Key.SettleReadyQty, MaterialCode = p.Key.MaterialCode, ChassisNumber = p.Key.ChassisNumber, Qty = p.Sum(itm => itm.Qty) }).Where(p => p.Qty > 1).ToList();

75
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleDoorPanelExportService.cs

@ -56,17 +56,34 @@ namespace SettleAccount.Job.Services.Report
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 = _dapperRepository.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 _ls = _dapperRepository.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 rangeList = _erpdapperRepository.GetSapList<InvoiceSettledDetailDiff>(_list, version, true);
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;
}
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.InvoicePrice) }).ToList();
.Select(p => new { ParentSapMaterialCode = p.Key.ParentSapMaterialCode, ChassisNumber = p.Key.ChassisNumber, KENNCode = p.Key.KENNCode, Price =Math.Round( p.Sum(itm => itm.InvoiceAmt),2) }).ToList();
var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
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
@ -92,30 +109,13 @@ namespace SettleAccount.Job.Services.Report
DiffSettleFisQty = 0,
DiffSettleInvQty = 0,
InvoiceQty = 1,
InvoicePrice = tm1.Price,
InvocieAmt = tm1.Price,
SettleAmt = tm1.Price,
DiffPrice = tm1.Price - itm1.Price
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);
_first.InvoiceQty = _first.SettledQty + itm.DiffQty;
_first.DiffSettleInvQty = itm.DiffQty;
}
foreach (var itm in _ls)
{
itm.InvocieAmt =Math.Round(itm.InvoiceQty * itm.InvoicePrice,2);
}
_ls.AddRange(rangeList);
_ls = _ls.Where(p => p.DiffPrice != 0).OrderBy(p => p.SapMaterialCode).ToList();
if (!string.IsNullOrEmpty(materialGroup))
{
@ -127,7 +127,7 @@ namespace SettleAccount.Job.Services.Report
}
if (!string.IsNullOrEmpty(kenncode))
{
var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList();
var _groupList = kenncode.Split("\n").ToList();
if (_groupList.Count() > 0)
{
_ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList();
@ -135,12 +135,20 @@ namespace SettleAccount.Job.Services.Report
}
if (!string.IsNullOrEmpty(chassisNumber))
{
var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
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();
@ -149,6 +157,12 @@ namespace SettleAccount.Job.Services.Report
_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();
}
var report1List = _ls.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();
@ -170,5 +184,8 @@ namespace SettleAccount.Job.Services.Report
}
}
}

164
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs

@ -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);
}
}
}

Loading…
Cancel
Save