Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
bcaf240a65
  1. 102
      src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettleDiffExportService.cs

102
src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettleDiffExportService.cs

@ -45,6 +45,7 @@ namespace SettleAccount.Job.Services.Report
public class UnSettleDiffExportService : ITransientDependency, IExportJob public class UnSettleDiffExportService : ITransientDependency, IExportJob
{ {
private readonly UnSettledDetailDapperRepository _dapper2;
private readonly UnSettleDiffDapperRepository _dapper; private readonly UnSettleDiffDapperRepository _dapper;
private readonly OutputService _outputService; private readonly OutputService _outputService;
private readonly ErpPartDapperRepository _erpdapperRepository; private readonly ErpPartDapperRepository _erpdapperRepository;
@ -54,7 +55,8 @@ namespace SettleAccount.Job.Services.Report
public UnSettleDiffExportService(UnSettleDiffDapperRepository dapper, OutputService outputService, public UnSettleDiffExportService(UnSettleDiffDapperRepository dapper, OutputService outputService,
UnSettledDetailDapperRepository dapper1, UnSettledDetailDapperRepository dapper1,
ErpPartDapperRepository erpdapperRepository, ErpPartDapperRepository erpdapperRepository,
IBlobContainer<MyFileContainer> fileContainer IBlobContainer<MyFileContainer> fileContainer,
UnSettledDetailDapperRepository dapper2
) )
{ {
_erpdapperRepository = erpdapperRepository; _erpdapperRepository = erpdapperRepository;
@ -62,6 +64,7 @@ namespace SettleAccount.Job.Services.Report
_outputService = outputService; _outputService = outputService;
_dapper1 = dapper1; _dapper1 = dapper1;
_fileContainer = fileContainer; _fileContainer = fileContainer;
_dapper2 = dapper2;
} }
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list) public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> p_list)
@ -201,6 +204,23 @@ namespace SettleAccount.Job.Services.Report
DiffAmt = p.Sum(p => p.DiffAMT) DiffAmt = p.Sum(p => p.DiffAMT)
}); });
//var lst2 = LJ(id, exportName, p_list);
//_lsSum2= lst2.GroupBy(p => new { p.SapMaterialCode, p.MaterialCode, p.MaterialDesc, p.MaterialGroup })
// .Select(p =>
// new SumSettleDiffList
// {
// SapMaterialCode = p.Key.SapMaterialCode,
// MaterialCode = p.Key.MaterialCode,
// MaterialDesc = p.Key.MaterialDesc,
// MaterialGroup = p.Key.MaterialGroup,
// Qty = p.Sum(p => p.Qty),
// UnSettleQty = p.Sum(p => p.UnSettleQty),
// DiffQty = p.Sum(p => p.DiffQty),
// DiffAmt = p.Sum(p => p.DiffAMT)
// });
ExcelExporter _exporter = new ExcelExporter();//导出Excel ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(_ls, "R3大众未结对比系统未结") var result = _exporter.Append(_ls, "R3大众未结对比系统未结")
.SeparateBySheet() .SeparateBySheet()
@ -288,6 +308,86 @@ namespace SettleAccount.Job.Services.Report
} }
public List<UnSettleDetailReport> LJ(Guid id, List<string> exportName, List<CustomCondition> p_list)
{
var _first = exportName.FirstOrDefault();
var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value;
var customerCode = p_list.Where(p => p.Name == "CustomerCode").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 sapcode = p_list.Where(p => p.Name == "SapMaterialCode").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 kenncode = p_list.Where(p => p.Name == "KennCode").FirstOrDefault().Value;
var chassisNumber = p_list.Where(p => p.Name == "ChassisNumber").FirstOrDefault().Value;
var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value;
//var cp7begin = p_list.Where(p => p.Name == "CP7Begin").FirstOrDefault().Value;
//var cp7end = p_list.Where(p => p.Name == "CP7End").FirstOrDefault().Value;
var _list = _dapper2.GetDiffReport(DateTime.Now.Year.ToString(), begin, end, customerCode, version, materailCode, materialGroup, sapcode);
var _ls = _list.Where(p => p.Flag != "L").Where(p => p.ParentSapMaterialCode != p.SapMaterialCode).GroupBy(p => new { p.KENNCode, p.ChassisNumber, p.ParentSapMaterialCode }).Select(p => p.FirstOrDefault()).ToList();
var _lst = _erpdapperRepository.GetSapList(_ls, version, false);
_lst.ForEach(p =>
{
p.Qty = 1;
p.DiffAMT = Math.Round(p.Qty * p.Price, 2);
p.DiffQty = 1;
}
);
_list.AddRange(_lst);
if (!string.IsNullOrEmpty(materialGroup))
{
var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_list = _list.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
}
}
if (!string.IsNullOrEmpty(kenncode))
{
var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_list = _list.Where(p => _groupList.Contains(p.KENNCode)).ToList();
}
}
if (!string.IsNullOrEmpty(chassisNumber))
{
var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_list = _list.Where(p => _groupList.Contains(p.ChassisNumber)).ToList();
}
}
if (!string.IsNullOrEmpty(sapCode))
{
var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
}
}
if (!string.IsNullOrEmpty(materailCode))
{
var _groupList = materailCode.Split(new char[] { '\n' }).Distinct().ToList();
if (_groupList.Count() > 0)
{
_list = _list.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
}
}
_list = _list.OrderBy(p => p.ChassisNumber).ThenBy(p => p.SapMaterialCode).ThenBy(p => p.Flag).ToList();
//_outputService.Export<UnSettleDetailReport>(id, _first, _list);
//return id.ToString();
return _lst;
}

Loading…
Cancel
Save