diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs index c20759b5..b3b310d2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs +++ b/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().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().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().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(ediReturnEntities).ConfigureAwait(false); } - var seReturnQuery = db.Set().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().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().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(seFlagErrEntities).ConfigureAwait(false); + } + + var ediFlagErrQuery = db.Set().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(ediFlagErrEntities).ConfigureAwait(false); + } + } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 6419897a..eead5ad5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/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().GetConnectionString("SettleAccountService"); var options = new DbContextOptionsBuilder().UseSqlServer(connectionString).Options; using var db = new SettleAccountDbContext(options); - var query = db.Set().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime from Set_VmiLog"); + var query = db.Set().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime,LogType from Set_VmiLog"); var filters = input.Filters.ToLambda(); if (input.Filters.Count > 0) { query = query.Where(input.Filters.ToLambda()); } 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; } }