@ -78,17 +78,17 @@ namespace SettleAccount.Job.Services.Report
#region 二次对比
#region 二次对比
//二次匹配上的记录
//二次匹配上的记录
var secondMatchHaveSaHaveSes = HandleSecondCompare ( saSeEdiCompareDiffs , businessType ) ;
//var secondMatchHaveSaHaveSes = HandleSecondCompare(saSeEdiCompareDiffs, businessType);
if ( secondMatchHaveSaHaveSes . Any ( ) )
//if (secondMatchHaveSaHaveSes.Any())
{
//{
//二次匹配 匹配上的厂内零件号、PN
// //二次匹配 匹配上的厂内零件号、PN
var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes . Select ( t = > new { t . ReplaceFactoryPartCode , t . PN } ) ;
// var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
saSeEdiCompareDiffs . RemoveAll < SaSeEdiCompareDiff > ( t = > secondMatchFPartCodePNs . Contains ( new { t . ReplaceFactoryPartCode , t . PN } ) ) ;
// saSeEdiCompareDiffs.RemoveAll<SaSeEdiCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
saSeEdiCompareDiffs . AddRange ( secondMatchHaveSaHaveSes ) ;
// saSeEdiCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
//二次对比比对上的数据入库
// //二次对比比对上的数据入库
var seCDetailEntitys = _ objectMapper . Map < List < SaSeEdiCompareDiff > , List < HBPO_SEC_DETAIL > > ( secondMatchHaveSaHaveSes ) ;
// var seCDetailEntitys = _objectMapper.Map<List<SaSeEdiCompareDiff>, List<HBPO_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_ settleAccountDbContext . Set < HBPO_SEC_DETAIL > ( ) . AddRange ( seCDetailEntitys ) ;
// _settleAccountDbContext.Set<HBPO_SEC_DETAIL>().AddRange(seCDetailEntitys);
}
//}
#endregion
#endregion
#region 结算数据处理
#region 结算数据处理
@ -135,8 +135,24 @@ namespace SettleAccount.Job.Services.Report
public List < SaSeEdiCompareDiff > GetSaSeEdiCompareData ( int version , DateTime seStartDateTime , DateTime seEndDateTime )
public List < SaSeEdiCompareDiff > GetSaSeEdiCompareData ( int version , DateTime seStartDateTime , DateTime seEndDateTime )
{
{
//结算
//结算
//var saGroup = from sa in _settleAccountDbContext.Set<HBPO_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),
// Site = groupItem.Max(t => t.Site),
// Price = groupItem.Max(t => t.Price)
// };
var saGroup = from sa in _ settleAccountDbContext . Set < HBPO_SA_DETAIL > ( )
var saGroup = from sa in _ settleAccountDbContext . Set < HBPO_SA_DETAIL > ( )
where sa . BusinessType = = businessType & & sa . Version = = version
where sa . BusinessType = = businessType
group sa by new { sa . PN , sa . CustomerPartCodeNoSpace } into groupItem
group sa by new { sa . PN , sa . CustomerPartCodeNoSpace } into groupItem
select new
select new
{
{
@ -150,9 +166,26 @@ namespace SettleAccount.Job.Services.Report
Site = groupItem . Max ( t = > t . Site ) ,
Site = groupItem . Max ( t = > t . Site ) ,
Price = groupItem . Max ( t = > t . Price )
Price = groupItem . Max ( t = > t . Price )
} ;
} ;
//发运
//发运
//var seGroup = (from se in _settleAccountDbContext.Set<HBPO_SE_DETAIL>()
// where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime && se.State == 0 && se.IsDeleted == false
// 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),
// ToLoc = groupItem.Max(t => t.ToLoc),
// ErpToLoc = groupItem.Max(t => t.ErpToLoc)
// }).Where(t => t.Qty != 0M);
var seGroup = ( from se in _ settleAccountDbContext . Set < HBPO_SE_DETAIL > ( )
var seGroup = ( from se in _ settleAccountDbContext . Set < HBPO_SE_DETAIL > ( )
where se . BusinessType = = businessType & & se . BillTime > = seStartDateTime & & se . BillTime < = seEndDateTime & & se . State = = 0
where se . BusinessType = = businessType
group se by new { se . PN , se . CustomerPartCodeNoSpace } into groupItem
group se by new { se . PN , se . CustomerPartCodeNoSpace } into groupItem
select new
select new
{
{
@ -165,10 +198,21 @@ namespace SettleAccount.Job.Services.Report
FactoryPartCode = groupItem . Max ( t = > t . FactoryPartCode ) ,
FactoryPartCode = groupItem . Max ( t = > t . FactoryPartCode ) ,
ToLoc = groupItem . Max ( t = > t . ToLoc ) ,
ToLoc = groupItem . Max ( t = > t . ToLoc ) ,
ErpToLoc = groupItem . Max ( t = > t . ErpToLoc )
ErpToLoc = groupItem . Max ( t = > t . ErpToLoc )
} ) . Where ( t = > t . Qty ! = 0 M ) ;
} ) . Where ( t = > t . Qty > 0 M ) ;
//Edi
//Edi
//var ediGroup = from edi in _settleAccountDbContext.Set<HBPO_SE_EDI>()
// where edi.IsDeleted == false && edi.IsHaveSeData == true && edi.State == 0
// group edi by new { edi.PN, edi.CustomerPartCodeNoSpace } into groupItem
// select new
// {
// groupItem.Key.PN,
// groupItem.Key.CustomerPartCodeNoSpace,
// Qty = groupItem.Sum(t => t.Qty),
// LU = groupItem.Max(t => t.LU)
// };
var ediGroup = from edi in _ settleAccountDbContext . Set < HBPO_SE_EDI > ( )
var ediGroup = from edi in _ settleAccountDbContext . Set < HBPO_SE_EDI > ( )
where edi . IsDeleted = = false & & edi . IsHaveSeData = = true & & edi . State = = 0
where edi . IsDeleted = = false & & edi . IsHaveSeData = = true
group edi by new { edi . PN , edi . CustomerPartCodeNoSpace } into groupItem
group edi by new { edi . PN , edi . CustomerPartCodeNoSpace } into groupItem
select new
select new
{
{
@ -177,6 +221,7 @@ namespace SettleAccount.Job.Services.Report
Qty = groupItem . Sum ( t = > t . Qty ) ,
Qty = groupItem . Sum ( t = > t . Qty ) ,
LU = groupItem . Max ( t = > t . LU )
LU = groupItem . Max ( t = > t . LU )
} ;
} ;
var seEdiGroup = from se in seGroup
var seEdiGroup = from se in seGroup
join edi in ediGroup
join edi in ediGroup
on new { se . PN , se . CustomerPartCodeNoSpace } equals new { edi . PN , edi . CustomerPartCodeNoSpace }
on new { se . PN , se . CustomerPartCodeNoSpace } equals new { edi . PN , edi . CustomerPartCodeNoSpace }