Browse Source

比对异常处理

master
zhouhongjun 11 months ago
parent
commit
8503c38784
  1. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  2. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

22
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -96,7 +96,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
//var ediReturnQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("SELECT a.* FROM Set_BBAC_SE_DETAIL a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace");
var ediReturnQuery = db.Set<BBAC_SE_EDI>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_EDI] a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveSeData=1) c where c.id is not null");
var ediReturnQuery = db.Set<BBAC_SE_EDI>().FromSqlRaw("select * from (SELECT distinct a.* FROM [dbo].[Set_BBAC_SE_EDI] a right join (SELECT PN,CustomerPartCodeNoSpace,sum(Qty) as Qty FROM Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having sum(Qty)=0) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveSeData=1) c where c.id is not null");
var ediReturnEntities = ediReturnQuery.ToList();
if (ediReturnEntities.Count > 0)
{
@ -104,7 +104,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
await db.BulkUpdateAsync<BBAC_SE_EDI>(ediReturnEntities).ConfigureAwait(false);
}
var seReturnQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select * from (SELECT a.* FROM [dbo].[Set_BBAC_SE_DETAIL] a right join (select PN,CustomerPartCodeNoSpace,COUNT(*) as hj,sum(Qty) as Qty,sum(CAST(IsHaveEdiData AS int)) as haveedi from Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having count(*)>sum(CAST(IsHaveEdiData AS int)) and count(*)>=3 and sum(CAST(IsHaveEdiData AS int))>=1) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveEdiData=0) c where c.id is not null ");
var seReturnQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select * from (SELECT distinct a.* FROM [dbo].[Set_BBAC_SE_DETAIL] a right join (select PN,CustomerPartCodeNoSpace,COUNT(*) as hj,sum(Qty) as Qty,sum(CAST(IsHaveEdiData AS int)) as haveedi from Set_BBAC_SE_DETAIL where BusinessType=1 group by PN,CustomerPartCodeNoSpace having count(*)>sum(CAST(IsHaveEdiData AS int)) and count(*)>=3 and sum(CAST(IsHaveEdiData AS int))>=1) b on a.PN=b.PN and a.CustomerPartCodeNoSpace=b.CustomerPartCodeNoSpace and a.IsHaveEdiData=0) c where c.id is not null ");
var seReturnEntities = seReturnQuery.ToList();
if (seReturnEntities.Count > 0)
{
@ -113,7 +113,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
}
var seFlagErrQuery = db.Set<BBAC_SE_DETAIL>().FromSqlRaw("select distinct a.* from [BQ_SA].[dbo].[Set_BBAC_SE_DETAIL] a left join [BQ_SA].[dbo].[Set_BBAC_SE_EDI] b on a.PN=b.PN and a.CustomerPartCodeNoSpace= b.CustomerPartCodeNoSpace where a.BusinessType=1 and a.IsHaveEdiData=0 and b.IsHaveSeData=1 and b.IsDeleted=0");
var seFlagErrEntities = seFlagErrQuery.ToList();
if (seFlagErrEntities.Count > 0)
{
seFlagErrEntities.ForEach(t => t.IsHaveEdiData = true);
await db.BulkUpdateAsync<BBAC_SE_DETAIL>(seFlagErrEntities).ConfigureAwait(false);
}
var ediFlagErrQuery = db.Set<BBAC_SE_EDI>().FromSqlRaw("select distinct a.* from [dbo].[Set_BBAC_SE_EDI] a left join [dbo].[Set_BBAC_SE_DETAIL] b on a.PN=b.PN and a.CustomerPartCodeNoSpace= b.CustomerPartCodeNoSpace where a.IsHaveSeData=0 and a.IsDeleted=0 and b.BusinessType=1 and b.IsHaveEdiData=1");
var ediFlagErrEntities = ediFlagErrQuery.ToList();
if (ediFlagErrEntities.Count > 0)
{
ediFlagErrEntities.ForEach(t => t.IsHaveSeData = true);
await db.BulkUpdateAsync<BBAC_SE_EDI>(ediFlagErrEntities).ConfigureAwait(false);
}
}

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -208,7 +208,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode,o.LogType }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime),Se=o.Sum(o=>o.LogType== VmiLogType.Type100 ? 1:0), ReturnGoods = o.Sum(o => o.LogType == VmiLogType.Type400 ? 1 : 0) }).Where(p => p.Qty != 0);
var totalCount = query2.Count();
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode,o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty),LastTime=o.Max(o=>o.ChangedTime) });
@ -231,14 +231,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var query = db.Set<VmiLog>().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime from Set_VmiLog");
var query = db.Set<VmiLog>().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime,LogType from Set_VmiLog");
var filters = input.Filters.ToLambda<VmiLog>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiLog>());
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode, o.LogType }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime),Se = o.Sum(o => o.LogType == VmiLogType.Type100 ? 1 : 0), ReturnGoods = o.Sum(o => o.LogType == VmiLogType.Type400 ? 1 : 0) }).Where(p => p.Qty != 0);
var entities = query2.ToList();
// var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
@ -1340,7 +1340,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Display(Name = "发运时间", Order = 5)]
public DateTime? BillTime { get; set; }
[Display(Name = "发运入库数量", Order = 4)]
public decimal Se { get; set; }
[Display(Name = "发运退货数量", Order = 4)]
public decimal ReturnGoods { get; set; }
}

Loading…
Cancel
Save