44673626
3 years ago
8 changed files with 270 additions and 90 deletions
@ -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(); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue