mahao
1 year ago
9 changed files with 461 additions and 371 deletions
@ -0,0 +1,136 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Magicodes.ExporterAndImporter.Excel; |
||||
|
using Microsoft.AspNetCore.SignalR; |
||||
|
using SettleAccount.Job.SignalR; |
||||
|
using Win.Sfs.SettleAccount.Enums; |
||||
|
using Win.Sfs.SettleAccount.Reports; |
||||
|
|
||||
|
namespace SettleAccount.Job.Services.Report |
||||
|
{ |
||||
|
public class SaSeCompareExportBaseService |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// HubContext
|
||||
|
/// </summary>
|
||||
|
private readonly IHubContext<PageHub> _hubContext; |
||||
|
|
||||
|
public SaSeCompareExportBaseService(IHubContext<PageHub> hubContext) |
||||
|
{ |
||||
|
_hubContext = hubContext; |
||||
|
} |
||||
|
|
||||
|
public virtual void HandlePubSaSeCompareDiffList(List<PubSaSeCompareDiff> pubSaSeCompareDiffs) |
||||
|
{ |
||||
|
pubSaSeCompareDiffs.ForEach(p => |
||||
|
{ |
||||
|
p.Category = (string.IsNullOrEmpty(p.SaCustomerPartCode), string.IsNullOrEmpty(p.SeCustomerPartCode)) switch |
||||
|
{ |
||||
|
(false, false) => EnumPubSaSeCompareCategory.HaveSaHaveSe, |
||||
|
(false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe, |
||||
|
(true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe, |
||||
|
_ => EnumPubSaSeCompareCategory.None, |
||||
|
}; |
||||
|
switch (p.Category) |
||||
|
{ |
||||
|
case EnumPubSaSeCompareCategory.None: |
||||
|
break; |
||||
|
case EnumPubSaSeCompareCategory.HaveSaHaveSe: |
||||
|
{ |
||||
|
p.CustomerPartCode = p.SaCustomerPartCode; |
||||
|
p.FactoryPartCode = p.SaFactoryPartCode; |
||||
|
p.ReplaceFactoryPartCode = p.SaFactoryPartCode; |
||||
|
} |
||||
|
break; |
||||
|
case EnumPubSaSeCompareCategory.HaveSaNotHaveSe: |
||||
|
{ |
||||
|
p.CustomerPartCode = p.SaCustomerPartCode; |
||||
|
p.FactoryPartCode = p.SaFactoryPartCode; |
||||
|
p.ReplaceFactoryPartCode = p.SaFactoryPartCode; |
||||
|
} |
||||
|
break; |
||||
|
case EnumPubSaSeCompareCategory.NotHaveSaHaveSe: |
||||
|
{ |
||||
|
p.CustomerPartCode = p.SeCustomerPartCode; |
||||
|
p.FactoryPartCode = p.SeFactoryPartCode; |
||||
|
p.ReplaceFactoryPartCode = p.SeFactoryPartCode; |
||||
|
} |
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建导出文件结构
|
||||
|
/// </summary>
|
||||
|
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new() |
||||
|
{ |
||||
|
//结算核对汇总
|
||||
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
||||
|
{ |
||||
|
FactoryPartCode = p.Key, |
||||
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
||||
|
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.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
||||
|
{ |
||||
|
FactoryPartCode = p.Key, |
||||
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
||||
|
SAQty = p.Sum(t => t.SAQty), |
||||
|
SEQty = p.Sum(t => t.SEQty) |
||||
|
}).ToList(); |
||||
|
//有结算无发运
|
||||
|
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
||||
|
//有结算无发运
|
||||
|
var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
||||
|
{ |
||||
|
FactoryPartCode = p.Key, |
||||
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
||||
|
SAQty = p.Sum(t => t.SAQty), |
||||
|
SEQty = p.Sum(t => t.SEQty) |
||||
|
}).ToList(); |
||||
|
//无结算有发运
|
||||
|
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
||||
|
//无结算有发运
|
||||
|
var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
||||
|
{ |
||||
|
FactoryPartCode = p.Key, |
||||
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
||||
|
SAQty = p.Sum(t => t.SAQty), |
||||
|
SEQty = p.Sum(t => t.SEQty) |
||||
|
}).ToList(); |
||||
|
|
||||
|
ExcelExporter excelExporter = new ExcelExporter(); |
||||
|
return excelExporter |
||||
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
||||
|
.SeparateBySheet() |
||||
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
||||
|
.SeparateBySheet() |
||||
|
|
||||
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") |
||||
|
.SeparateBySheet() |
||||
|
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") |
||||
|
.SeparateBySheet() |
||||
|
|
||||
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
||||
|
.SeparateBySheet() |
||||
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 通知
|
||||
|
/// </summary>
|
||||
|
public virtual void Notify() |
||||
|
{ |
||||
|
_hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue