|
|
@ -176,6 +176,11 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
{ |
|
|
|
return GetSaSeCompareDataYinDu(version); |
|
|
|
} |
|
|
|
//备件对比
|
|
|
|
if (businessType == EnumBusinessType.BeiJian) |
|
|
|
{ |
|
|
|
return GetSaSeCompareDataBeiJian(version); |
|
|
|
} |
|
|
|
//结算
|
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType |
|
|
@ -412,6 +417,163 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
}).ToList(); |
|
|
|
return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取比对数据备件
|
|
|
|
/// </summary>
|
|
|
|
private List<SaSeCompareDiff> GetSaSeCompareDataBeiJian(int version) |
|
|
|
{ |
|
|
|
var businessType = EnumBusinessType.BeiJian; |
|
|
|
//结算
|
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType |
|
|
|
group sa by new { sa.PN, sa.PartCode } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
FactoryPartCode = groupItem.Key.PartCode, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate) |
|
|
|
}; |
|
|
|
|
|
|
|
var saGroupByMappingType = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType && sa.MappingType == EnumMappingType.None |
|
|
|
group sa by new { sa.PN, sa.PartCode } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
FactoryPartCode = groupItem.Key.PartCode, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate) |
|
|
|
}; |
|
|
|
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
group sa by new { sa.PN, sa.PartCode } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
FactoryPartCode = groupItem.Key.PartCode, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate) |
|
|
|
}; |
|
|
|
|
|
|
|
//发运
|
|
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
|
where se.BusinessType == businessType |
|
|
|
group se by new { se.PN, se.FactoryPartCode } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
groupItem.Key.FactoryPartCode, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
WmsBillNum = groupItem.Max(t => t.WmsBillNum), |
|
|
|
ShippingDate = groupItem.Max(t => t.ShippingDate), |
|
|
|
ToLocCode = groupItem.Max(t => t.ToLocCode), |
|
|
|
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) |
|
|
|
}; |
|
|
|
|
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSeList = (from sa in saGroupByMappingType |
|
|
|
join se in seGroup |
|
|
|
on new { sa.PN, sa.FactoryPartCode } equals new { se.PN, se.FactoryPartCode } |
|
|
|
into temp |
|
|
|
from se in temp.DefaultIfEmpty() |
|
|
|
where se.PN == null |
|
|
|
select new SaSeCompareDiff() |
|
|
|
{ |
|
|
|
Version = sa.Version, |
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
|
PN = sa.PN, |
|
|
|
SAQty = sa.Qty, |
|
|
|
SaCustomerPartCode = sa.LU, |
|
|
|
SaFactoryPartCode = sa.FactoryPartCode, |
|
|
|
CustomerPartCode = sa.LU |
|
|
|
}).ToList(); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSeList = (from se in seGroup |
|
|
|
join sa in saGroup |
|
|
|
on new { se.PN, se.FactoryPartCode } equals new { sa.PN, sa.FactoryPartCode } |
|
|
|
into temp |
|
|
|
from sa in temp.DefaultIfEmpty() |
|
|
|
where sa.PN == null |
|
|
|
select new SaSeCompareDiff() |
|
|
|
{ |
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
PN = se.PN, |
|
|
|
SEQty = se.Qty, |
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
SeCustomerPartCode = se.LU, |
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
CustomerPartCode = se.LU |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSeList = (from sa in saGroupByVersion |
|
|
|
from se in seGroup |
|
|
|
where sa.PN == se.PN && sa.FactoryPartCode == se.FactoryPartCode |
|
|
|
select new SaSeCompareDiff() |
|
|
|
{ |
|
|
|
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.LU, |
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
SaCustomerPartCode = sa.LU, |
|
|
|
SaFactoryPartCode = sa.FactoryPartCode, |
|
|
|
CustomerPartCode = sa.LU |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var saGroupByPnPartCodeLu = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
group sa by new { sa.PN, sa.PartCode, sa.LU } into groupItem |
|
|
|
select new |
|
|
|
{ |
|
|
|
groupItem.Key.PN, |
|
|
|
FactoryPartCode = groupItem.Key.PartCode, |
|
|
|
groupItem.Key.LU, |
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate) |
|
|
|
}; |
|
|
|
var replaceLus = saGroupByPnPartCodeLu.ToList().GroupBy(t => new { t.PN, t.FactoryPartCode }).Select(t => |
|
|
|
{ |
|
|
|
return new |
|
|
|
{ |
|
|
|
t.Key.PN, |
|
|
|
t.Key.FactoryPartCode, |
|
|
|
LU = t.Select(t => t.LU).Distinct() |
|
|
|
}; |
|
|
|
}).Where(t => t.LU.Count() > 1); |
|
|
|
|
|
|
|
if (replaceLus.Any()) |
|
|
|
{ |
|
|
|
haveSaHaveSeList.ForEach(haveSaHaveSe => |
|
|
|
{ |
|
|
|
var replaceLu = replaceLus.FirstOrDefault(t => t.PN == haveSaHaveSe.PN && t.FactoryPartCode == haveSaHaveSe.SaFactoryPartCode); |
|
|
|
if (replaceLu != null) |
|
|
|
{ |
|
|
|
haveSaHaveSe.SaCustomerPartCode = string.Join(",", replaceLu.LU); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
} |
|
|
|