|
@ -2,14 +2,11 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using EmptyFiles; |
|
|
|
|
|
using Magicodes.ExporterAndImporter.Core; |
|
|
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.OpenApi.Extensions; |
|
|
using Microsoft.OpenApi.Extensions; |
|
|
using NetTopologySuite.Operation.Buffer; |
|
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
|
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
|
|
|
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
|
|
|
using SettleAccount.Job.SignalR; |
|
|
using Shouldly; |
|
|
using Shouldly; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.Interfaces; |
|
|
using TaskJob.Interfaces; |
|
@ -19,7 +16,6 @@ using Volo.Abp.ObjectMapping; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
using Win.Sfs.SettleAccount; |
|
|
using Win.Sfs.SettleAccount; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|
@ -32,6 +28,11 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public class PubSaSeCompareExportService : ITransientDependency, IExportJob |
|
|
public class PubSaSeCompareExportService : ITransientDependency, IExportJob |
|
|
{ |
|
|
{ |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// HubContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IHubContext<PageHub> _hubContext; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 替换件关系仓储
|
|
|
/// 替换件关系仓储
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -61,12 +62,14 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// 构造
|
|
|
/// 构造
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public PubSaSeCompareExportService( |
|
|
public PubSaSeCompareExportService( |
|
|
|
|
|
IHubContext<PageHub> hubContext, |
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository, |
|
|
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository, |
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
IObjectMapper objectMapper) |
|
|
IObjectMapper objectMapper) |
|
|
{ |
|
|
{ |
|
|
|
|
|
_hubContext = hubContext; |
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
_pubSeCDetailRepository = pubSeCDetailRepository; |
|
|
_pubSeCDetailRepository = pubSeCDetailRepository; |
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
@ -87,18 +90,21 @@ namespace SettleAccount.Job.Services.Report |
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
{ |
|
|
{ |
|
|
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; |
|
|
var strBusinessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; |
|
|
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; |
|
|
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; |
|
|
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; |
|
|
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; |
|
|
|
|
|
var seStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value; |
|
|
|
|
|
var seEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value; |
|
|
|
|
|
|
|
|
|
|
|
EnumBusinessType businessType = (EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), strBusinessType); |
|
|
var businessTypeDisplayName = businessType.ToString(); |
|
|
var businessTypeDisplayName = businessType.ToString(); |
|
|
DisplayAttribute attributeOfType = ((EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), businessType)).GetAttributeOfType<DisplayAttribute>(); |
|
|
DisplayAttribute attributeOfType = businessType.GetAttributeOfType<DisplayAttribute>(); |
|
|
if (attributeOfType != null) |
|
|
if (attributeOfType != null) |
|
|
{ |
|
|
{ |
|
|
businessTypeDisplayName = attributeOfType.Name; |
|
|
businessTypeDisplayName = attributeOfType.Name; |
|
|
} |
|
|
} |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(businessType); |
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime); |
|
|
|
|
|
|
|
|
pubSaSeCompareDiffs.ForEach(p => |
|
|
pubSaSeCompareDiffs.ForEach(p => |
|
|
{ |
|
|
{ |
|
@ -127,7 +133,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
#region 二次对比
|
|
|
#region 二次对比
|
|
|
//二次对比(替换零件号)
|
|
|
//二次对比(替换零件号)
|
|
|
var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList(); |
|
|
var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList(); |
|
|
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; |
|
|
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && t.BusinessType == businessType).Result; |
|
|
|
|
|
|
|
|
tbRePartsRelationships.ForEach(tbRePartsRelationship => |
|
|
tbRePartsRelationships.ForEach(tbRePartsRelationship => |
|
|
{ |
|
|
{ |
|
@ -192,7 +198,6 @@ namespace SettleAccount.Job.Services.Report |
|
|
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); |
|
|
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//结算核对明细
|
|
|
|
|
|
var pubSaSeCompareDetailExports = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExport>>(pubSaSeCompareDiffs); |
|
|
var pubSaSeCompareDetailExports = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExport>>(pubSaSeCompareDiffs); |
|
|
//结算核对汇总
|
|
|
//结算核对汇总
|
|
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
@ -234,12 +239,95 @@ namespace SettleAccount.Job.Services.Report |
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
|
|
|
|
|
#endregion
|
|
|
switch (businessType) |
|
|
|
|
|
{ |
|
|
|
|
|
case EnumBusinessType.ZhiGongJianBBAC: |
|
|
|
|
|
{ |
|
|
|
|
|
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportZhiGongJianBBAC>>(pubSaSeCompareDetailExports); |
|
|
|
|
|
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportZhiGongJianBBAC>(items, businessTypeDisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.ZhiGongJianHBPO: |
|
|
|
|
|
{ |
|
|
|
|
|
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportZhiGongJianHBPO>>(pubSaSeCompareDetailExports); |
|
|
|
|
|
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportZhiGongJianHBPO>(items, businessTypeDisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.MaiDanJianBBAC: |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.MaiDanJianHBPO: |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.BeiJian: |
|
|
|
|
|
{ |
|
|
|
|
|
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportBeiJian>>(pubSaSeCompareDetailExports); |
|
|
|
|
|
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportBeiJian>(items, businessTypeDisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case EnumBusinessType.YinDuJian: |
|
|
|
|
|
{ |
|
|
|
|
|
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportYinDuJian>>(pubSaSeCompareDetailExports); |
|
|
|
|
|
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportYinDuJian>(items, businessTypeDisplayName); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var result = excelExporter.ExportAppendDataAsByteArray(); |
|
|
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
|
|
|
|
|
|
|
|
Notify(); |
|
|
|
|
|
return id.ToString(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 私有方法
|
|
|
|
|
|
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, new() |
|
|
|
|
|
{ |
|
|
|
|
|
//结算核对汇总
|
|
|
|
|
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
|
|
|
|
{ |
|
|
|
|
|
LU = p.Key, |
|
|
|
|
|
MaterialDes = p.FirstOrDefault().MaterialDes, |
|
|
|
|
|
SAQty = p.Sum(t => t.SAQty), |
|
|
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
|
|
var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); |
|
|
|
|
|
//有结算有发运汇总
|
|
|
|
|
|
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
|
|
|
|
{ |
|
|
|
|
|
LU = p.Key, |
|
|
|
|
|
MaterialDes = p.FirstOrDefault().MaterialDes, |
|
|
|
|
|
SAQty = p.Sum(t => t.SAQty), |
|
|
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
//有结算无发运
|
|
|
|
|
|
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
|
|
//有结算无发运
|
|
|
|
|
|
var haveSaNotHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
|
|
|
|
{ |
|
|
|
|
|
LU = p.Key, |
|
|
|
|
|
MaterialDes = p.FirstOrDefault().MaterialDes, |
|
|
|
|
|
SAQty = p.Sum(t => t.SAQty), |
|
|
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
//无结算有发运
|
|
|
|
|
|
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
|
|
//无结算有发运
|
|
|
|
|
|
var notHaveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() |
|
|
|
|
|
{ |
|
|
|
|
|
LU = p.Key, |
|
|
|
|
|
MaterialDes = p.FirstOrDefault().MaterialDes, |
|
|
|
|
|
SAQty = p.Sum(t => t.SAQty), |
|
|
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
var result = excelExporter |
|
|
return excelExporter |
|
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
|
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet() |
|
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
|
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
|
@ -253,155 +341,13 @@ namespace SettleAccount.Job.Services.Report |
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet() |
|
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出") |
|
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet(); |
|
|
.ExportAppendDataAsByteArray(); |
|
|
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
|
|
|
|
|
|
|
|
return id.ToString(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
private void Notify() |
|
|
/// 导出(废弃)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string ExportFile333(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
|
|
|
{ |
|
|
{ |
|
|
return ""; |
|
|
this._hubContext.Clients.All.ServerToClient("Compare", "refresh", ""); |
|
|
// var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
|
|
|
|
|
|
|
|
|
|
|
|
// var _filename = exportName.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
// var _ls = _dapperRepository.GetDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber, materialGroup);
|
|
|
|
|
|
// var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
|
|
|
|
|
|
// foreach (var itm in _ls)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// itm.InvoiceAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice, 2);
|
|
|
|
|
|
// itm.DiffPrice = itm.Price - itm.InvoicePrice;
|
|
|
|
|
|
// itm.DiffSettleFisQty = itm.SettledQty;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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(new char[] { '\n' }).Distinct().ToList();
|
|
|
|
|
|
// if (_groupList.Count() > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(chassisNumber))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
|
|
|
|
|
|
// if (_groupList.Count() > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _ls = _ls.Where(p => _groupList.Contains(p.ChassisNumber)).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();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var _checkList = _erpdapperRepository.GetErrorBillList();
|
|
|
|
|
|
|
|
|
|
|
|
// var query = from itm in _ls
|
|
|
|
|
|
// join itm1 in _checkList on new { ChassisNumber = itm.ChassisNumber, MaterialCode = itm.MaterialCode, WmsBillNum = itm.WmsBillNum }
|
|
|
|
|
|
//equals new { ChassisNumber = itm1.BillNum, MaterialCode = itm1.MaterialCode, WmsBillNum = itm1.WmsBillNum } into temp1
|
|
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
|
|
// where tm1 == null
|
|
|
|
|
|
// select itm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _ls = query.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var _lsSum = _ls.GroupBy(p => new { p.MaterialCode, p.SapMaterialCode, p.MaterialGroup, p.InvoicePrice }).Select(p => new UnInvoiceSettledDetailSum
|
|
|
|
|
|
// {
|
|
|
|
|
|
// MaterialCode = p.Key.MaterialCode,
|
|
|
|
|
|
// SapMaterailCode = p.Key.SapMaterialCode,
|
|
|
|
|
|
// MaterialGroup = p.Key.MaterialGroup,
|
|
|
|
|
|
// SettleQty = p.Sum(itm => itm.SettledQty),
|
|
|
|
|
|
// FisQty = 0,
|
|
|
|
|
|
// DiffQty = -p.Sum(itm => itm.SettledQty),
|
|
|
|
|
|
// Price = p.Key.InvoicePrice,
|
|
|
|
|
|
// DiffAmt = p.Sum(itm => itm.SettledQty) * p.Key.InvoicePrice
|
|
|
|
|
|
// }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// var _sumTotal = new UnInvoiceSettledDetailSum()
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
// SettleQty = _lsSum.Sum(p => p.SettleQty),
|
|
|
|
|
|
// DiffQty = _lsSum.Sum(p => p.DiffQty),
|
|
|
|
|
|
// Price = _lsSum.Sum(p => p.Price),
|
|
|
|
|
|
// DiffAmt = _lsSum.Sum(p => p.DiffAmt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
// _lsSum.Add(_sumTotal);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 list1 = LSettleSum(id, exportName, p_list);
|
|
|
|
|
|
|
|
|
|
|
|
// var report1 = report2List.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (var itm in list1)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// itm.MaterialGroup = itm.MaterialGroup + "(漏结)";
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// report1.AddRange(list1);
|
|
|
|
|
|
|
|
|
|
|
|
// ExcelExporter _exporter = new ExcelExporter();//导出Excel
|
|
|
|
|
|
|
|
|
|
|
|
// var result = _exporter
|
|
|
|
|
|
// .Append(_ls, "差异明细表")
|
|
|
|
|
|
// .SeparateBySheet()
|
|
|
|
|
|
// .Append(_lsSum, "数量差异汇总表")
|
|
|
|
|
|
// .SeparateBySheet()
|
|
|
|
|
|
// .Append(report1List, "按物料价格差异明细表")
|
|
|
|
|
|
// .SeparateBySheet()
|
|
|
|
|
|
// .Append(report1, "差异汇总验证表")
|
|
|
|
|
|
// .ExportAppendDataAsByteArray();
|
|
|
|
|
|
// result.ShouldNotBeNull();
|
|
|
|
|
|
// _fileContainer.SaveAsync(_filename, result.Result, true);
|
|
|
|
|
|
|
|
|
|
|
|
// //_outputService.Export<InvoiceSettledDetailDiff>(id, string.Format("大众结算未发运核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls);
|
|
|
|
|
|
|
|
|
|
|
|
// return id.ToString();
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|