|
|
@ -2,9 +2,12 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using EmptyFiles; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
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 Shouldly; |
|
|
|
using TaskJob.EventArgs; |
|
|
@ -104,15 +107,15 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
}); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
var haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); |
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
var haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
var notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
|
|
|
|
haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); |
|
|
|
haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && string.IsNullOrEmpty(t.SeLU)); |
|
|
|
notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); |
|
|
|
haveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); |
|
|
|
haveSaNotHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); |
|
|
|
notHaveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU); |
|
|
|
|
|
|
|
#region 二次对比
|
|
|
|
//二次对比(替换零件号)
|
|
|
@ -123,10 +126,21 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
{ |
|
|
|
notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t => |
|
|
|
{ |
|
|
|
t.RepLU = t.SeLU; |
|
|
|
t.SeLU = tbRePartsRelationship.LU; |
|
|
|
t.ReplaceLU = tbRePartsRelationship.LU; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var haveSaNotHaveSeReplaceLU = haveSaNotHaveSe.Select(t => t.ReplaceLU); |
|
|
|
var notHaveSaHaveSeReplaceLU = notHaveSaHaveSe.Select(t => t.ReplaceLU); |
|
|
|
//此次匹配上的零件号
|
|
|
|
var secondMatchReplaceLU = notHaveSaHaveSeReplaceLU.Intersect(notHaveSaHaveSeReplaceLU); |
|
|
|
//if (secondMatchReplaceLU)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(lu) == false) |
|
|
@ -138,27 +152,74 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn); |
|
|
|
} |
|
|
|
|
|
|
|
var pubSaSeCompareDiffExports = _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() |
|
|
|
{ |
|
|
|
LU = p.Key, |
|
|
|
MaterialDes = p.FirstOrDefault().MaterialDes, |
|
|
|
SAQty = p.Sum(t => t.SAQty), |
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSeExports = pubSaSeCompareDiffExports.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 =
|
|
|
|
//});
|
|
|
|
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 = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
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 = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
var result = excelExporter |
|
|
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
|
|
|
.SeparateBySheet() |
|
|
|
|
|
|
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") |
|
|
|
.SeparateBySheet() |
|
|
|
|
|
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.ExportAppendDataAsByteArray(); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
|
|
|
|
return id.ToString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var add = from item1 in pubSaSeCompareDiffs
|
|
|
@ -191,20 +252,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
//var query = BlobProviderSelectorExtensions
|
|
|
|
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
var result = excelExporter |
|
|
|
.Append(pubSaSeCompareDiffExports, $"{businessTypeDisplayName}汇总表") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发运") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发运") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(notHaveSaHaveSeExports, $"{businessTypeDisplayName}无结算有发运") |
|
|
|
.ExportAppendDataAsByteArray(); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
|
|
|
|
return id.ToString(); |
|
|
|
|
|
|
|
//结算
|
|
|
|
|
|
|
|