|
|
@ -1,12 +1,14 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Drawing; |
|
|
|
using System.Linq; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using ShardingCore.Extensions; |
|
|
|
using Shouldly; |
|
|
|
using TaskJob.EventArgs; |
|
|
|
using TaskJob.Interfaces; |
|
|
@ -178,7 +180,8 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
/// <summary>
|
|
|
|
/// 获取比对数据
|
|
|
|
/// </summary>
|
|
|
|
public List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
[Obsolete] |
|
|
|
private List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
{ |
|
|
|
//印度件LU对比
|
|
|
|
if (businessType == EnumBusinessType.YinDuJian) |
|
|
@ -264,7 +267,122 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
/// <summary>
|
|
|
|
/// 获取比对数据
|
|
|
|
/// </summary>
|
|
|
|
public List<PubSaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
private List<PubSaSeCompareDiff> GetSaSeCompareDataOld(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
{ |
|
|
|
//印度件LU对比
|
|
|
|
if (businessType == EnumBusinessType.YinDuJian) |
|
|
|
{ |
|
|
|
return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime); |
|
|
|
} |
|
|
|
//结算
|
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType |
|
|
|
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
Id = groupItem.Max(t => t.Id), |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
|
}; |
|
|
|
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
|
}; |
|
|
|
//发运
|
|
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
|
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
WmsBillNum = groupItem.Max(t => t.WmsBillNum), |
|
|
|
ShippingDate = groupItem.Max(t => t.ShippingDate), |
|
|
|
FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), |
|
|
|
ToLocCode = groupItem.Max(t => t.ToLocCode), |
|
|
|
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) |
|
|
|
}; |
|
|
|
|
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSeList = (from sa in saGroup |
|
|
|
join se in seGroup |
|
|
|
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } |
|
|
|
into temp |
|
|
|
from se in temp.DefaultIfEmpty() |
|
|
|
where se.PN == null |
|
|
|
select new PubSaSeCompareDiff() |
|
|
|
{ |
|
|
|
Version = sa.Version, |
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
|
PN = sa.PN, |
|
|
|
SAQty = sa.Qty, |
|
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
|
CustomerPartCode = sa.LU |
|
|
|
}).ToList(); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSeList = (from se in seGroup |
|
|
|
join sa in saGroup |
|
|
|
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } |
|
|
|
into temp |
|
|
|
from sa in temp.DefaultIfEmpty() |
|
|
|
where sa.PN == null |
|
|
|
select new PubSaSeCompareDiff() |
|
|
|
{ |
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
PN = se.PN, |
|
|
|
SEQty = se.Qty, |
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
CustomerPartCode = se.LU |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSeList = (from sa in saGroupByVersion |
|
|
|
from se in seGroup |
|
|
|
where sa.PN == se.PN && sa.CustomerPartCodeNoSpace == se.CustomerPartCodeNoSpace |
|
|
|
select new PubSaSeCompareDiff() |
|
|
|
{ |
|
|
|
Version = sa.Version, |
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
|
PN = sa.PN, |
|
|
|
SAQty = sa.Qty, |
|
|
|
SEQty = se.Qty, |
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
|
CustomerPartCode = sa.LU |
|
|
|
}).ToList(); |
|
|
|
return haveSaHaveSeList.Union(haveSaHaveSeList).Union(notHaveSaHaveSeList).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取比对数据
|
|
|
|
/// </summary>
|
|
|
|
private List<PubSaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
{ |
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version |
|
|
|