From 1198e01805c4f9d0e3ea5f9dc31dea6ab3f252c0 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Mon, 27 Nov 2023 11:28:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Domain/Entitys/OutStock.cs | 18 ++++++++++-------- src/WMS.Web.Domain/Services/OutStockService.cs | 6 ++++-- .../Configuration/RepositoryDbContext.cs | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/WMS.Web.Domain/Entitys/OutStock.cs b/src/WMS.Web.Domain/Entitys/OutStock.cs index be44627d..0e0c7c18 100644 --- a/src/WMS.Web.Domain/Entitys/OutStock.cs +++ b/src/WMS.Web.Domain/Entitys/OutStock.cs @@ -85,7 +85,7 @@ namespace WMS.Web.Domain.Entitys /// 同步失败的源订单号(默认就包含所有来源单号) /// [Column("SuccessSyncFail")] - public List SuccessSyncFail { get; set; }=new List(); + public List SuccessSyncFail { get; set; } = new List(); /// /// 同步时间 /// @@ -104,7 +104,7 @@ namespace WMS.Web.Domain.Entitys /// 创建(需要在明细都生成后最后调用) /// /// - public void Create(int creatorId, OutStockTask task,int method) + public void Create(int creatorId, OutStockTask task, int method) { this.TaskId = task.Id; this.Type = task.Type; @@ -119,20 +119,22 @@ namespace WMS.Web.Domain.Entitys { //只有销售出库才需要同步金蝶 this.SuccessSync = false; - this.SuccessSyncFail = this.Details.SelectMany(s => s.ErpDetails).GroupBy(g => g.SourceBillNo).Select(s => s.Key).ToList(); - }else + this.SuccessSyncFail = this.Details.SelectMany(s => s.ErpDetails).GroupBy(g => g.Erp_DetailId).Select(s => s.Key).ToList(); + } + else { this.SuccessSync = true; - this.SuccessSyncFail = new List(); + this.SuccessSyncFail = new List(); } } /// /// 同步金蝶(成功) /// /// - public void SyncSuccess(string sourcNos, int operateId) + public void SyncSuccess(List erpDetailIds, int operateId) { - this.SuccessSyncFail.Remove(sourcNos); + foreach (var e in erpDetailIds) + this.SuccessSyncFail.Remove(e); this.SuccessSync = true; this.Remark = ""; this.OperateId = operateId; @@ -142,7 +144,7 @@ namespace WMS.Web.Domain.Entitys /// 同步金蝶(失败) /// /// - public void SyncFail(string remark,int operateId) + public void SyncFail(string remark, int operateId) { this.SuccessSync = false; this.Remark = remark; diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs index 5ed40bdd..66d926ef 100644 --- a/src/WMS.Web.Domain/Services/OutStockService.cs +++ b/src/WMS.Web.Domain/Services/OutStockService.cs @@ -179,7 +179,9 @@ namespace WMS.Web.Domain.Services foreach (var entity in list) { if (entity.SuccessSync) continue; - List failList = entity.SuccessSyncFail.Clone();//同步失败的来源单号 + List failList =entity.Details.SelectMany(s=>s.ErpDetails) + .Where(w=> entity.SuccessSyncFail.Contains(w.Erp_DetailId)) + .Select(s=>s.SourceBillNo).ToList();//同步失败的来源单号 //找到单据里需要同步的单据 var sourcNos = entity.Details.SelectMany(s => s.ErpDetails).GroupBy(s => s.SourceBillNo).Select(s => s.Key); foreach (var s in failList) @@ -195,7 +197,7 @@ namespace WMS.Web.Domain.Services //下推金蝶 var res = await this.Push(erpDto); if (res.IsSuccess) - entity.SyncSuccess(s, loginInfo.UserInfo.StaffId); + entity.SyncSuccess(erp_details, loginInfo.UserInfo.StaffId); else entity.SyncFail(res.Message, loginInfo.UserInfo.StaffId); } diff --git a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs index 3522c59a..fd1000db 100644 --- a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs +++ b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -83,7 +83,7 @@ namespace WMS.Web.Repositories.Configuration ent.Property(f => f.SuccessSyncFail).HasConversion( v => JsonConvert.SerializeObject(v), - v => JsonConvert.DeserializeObject>(v)); + v => JsonConvert.DeserializeObject>(v)); ent.HasMany(p => p.Details) .WithOne()