From 0fe5c20eff020a16a62fd4ab85369a4be396a1fb Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Mon, 29 Jul 2024 16:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8D=95=E5=9C=A8=E9=87=91=E8=9D=B6=E6=B2=A1=E6=9F=A5=E5=88=B0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8D=95=20=E5=B0=B1=E4=BD=9C=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 | Bin 275060 -> 275060 bytes src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 107 +++++++++++++---- src/WMS.Web.Domain/Entitys/InstockTask.cs | 30 +++-- src/WMS.Web.Domain/Entitys/OutStockTask.cs | 19 ++- .../IService/IInStockTaskService.cs | 6 +- .../IService/Public/IOutStockTaskService.cs | 5 + .../IInStockTaskRepositories.cs | 2 + .../IOutStockTaskRepositories.cs | 2 + .../QuartzJob/InStockOrderQuartzJob.cs | 7 +- .../QuartzJob/OutStockOrderQuartzJob.cs | 2 + .../Services/InStockTaskService.cs | 107 +++++++++++++++++ .../Services/OutStockTaskService.cs | 108 ++++++++++++++++++ .../InStockTaskRepositories.cs | 10 ++ .../OutStockTaskRepositories.cs | 10 ++ 14 files changed, 378 insertions(+), 37 deletions(-) diff --git a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 index 0def82f745606e5bfa16057028901f5923d95364..c6848a43361e5378aed2b365c7414d328baf9612 100644 GIT binary patch delta 3473 zcmai$33ycH6^7^Do8Iv00)sw2HR8Om(Q9Y}APPJXN&aG^-i;}kP;$>~_RCzmmMPpan()O#`_Tnz~d((J3 zd6DhiZ12(7OMM$O?p1kPd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*iWHQu)o3p!GQ{c1P3b&5ge*8Ot46ySg<65m4@9mJd(1? za1@oQp|$+M2xSemF})TeRV_v-jFy=(jWcCDGgjelnHkqOGoEMei7a1b1i};4a7<9R zSMgu|vY)6hN#Q;P7l*LFT*0m2QL(NtRX_e$H;$iuWqnthR=8Ki+GDc96pm(x{4|Kw z{jBh*QcP8-Hmu(m(^UUj%rs)HYix_K%~oUk-f!dY_`>MI)kbZ{@DeJl<(~|^vkJxk zVQaCInLidc4s0*I5;$G4(HO{V1=bG?%dZ6b6&sC#%vNCiz>uI9)SSuokiwv9@ro#nIBU#vSn;me7#8Bjsaau#RuJ1 + + + erp删单 作废处理 + + erp入库任务单的对应box箱信息表 @@ -1955,6 +1960,11 @@ + + + erp删单 作废处理 + + erp出库任务单明细 @@ -3133,6 +3143,9 @@ + + 查询实体集合 + 库存相关-仓储接口 @@ -3303,6 +3316,9 @@ 查询实体集合 + + 查询实体集合 + 查询实体集合(明细Id) @@ -3698,6 +3714,12 @@ + + + 金蝶删单后这边单据作废 + + + 作废 @@ -4014,84 +4036,84 @@ - + erp:单据查询-采购入库单 - + erp:单据查询-其他入库单 - + erp:单据查询-直接调拨入库单 - + erp:单据查询-分步式调入单 - + erp:单据查询-组装拆卸单-组装(成品入库) - + erp:单据查询-组装拆卸单-拆卸(子件入库) - + erp:单据查询-出库单 - + erp:单据查询-直接调拨出库 - + erp:单据查询-分布式调出 - + erp:单据查询-组装拆卸单(拆卸 主出) - + erp:单据查询-组装拆卸单(组装 子出) - + erp:单据查询-其他出库 - + erp:单据查询-销售出库单 @@ -4289,6 +4311,12 @@ + + + 金蝶删单后这边单据作废 + + + 查询出库任务单详情 @@ -5402,6 +5430,21 @@ + + + 金蝶删单后wms单据作废 + + + + + + + + 获取金蝶数据 + + + + 即时库存-服务 @@ -5597,6 +5640,20 @@ + + + 金蝶删单后wms单据作废 + + + + + + + 获取金蝶数据 + + + + 同步erp基础数据 @@ -5792,7 +5849,7 @@ - + erp:单据查询-采购入库单 @@ -5800,35 +5857,35 @@ 单据编号集合精确查找 - + erp:单据查询-其他入库单 - + erp:单据查询-直接调拨入库单 - + erp:单据查询-分步式调入单 - + erp:单据查询-组装拆卸单-组装(成品入库) - + erp:单据查询-组装拆卸单-拆卸(子件入库) @@ -5953,42 +6010,42 @@ - + 直接调拨出库 - + 分布式调出 - + 组装拆卸单 (拆卸 主出) - + 其他出库 - + 组装拆卸单 (组装 子出) - + 销售出库单 diff --git a/src/WMS.Web.Domain/Entitys/InstockTask.cs b/src/WMS.Web.Domain/Entitys/InstockTask.cs index 06409c78..e2d05671 100644 --- a/src/WMS.Web.Domain/Entitys/InstockTask.cs +++ b/src/WMS.Web.Domain/Entitys/InstockTask.cs @@ -12,7 +12,7 @@ namespace WMS.Web.Domain.Entitys /// erp入库任务表 /// [Serializable] - [Table("t_erp_instock_task")] + [Table("t_erp_instock_task")] public class InStockTask : EntityBase { /// @@ -91,7 +91,7 @@ namespace WMS.Web.Domain.Entitys /// /// 明细 /// - public List Details { get; set; } + public List Details { get; set; } /// /// 创建 @@ -99,7 +99,7 @@ namespace WMS.Web.Domain.Entitys /// /// /// - public void Create(InstockType type,string sourceBillNo, DateTime createTime,int supplierId,string orgCode) + public void Create(InstockType type, string sourceBillNo, DateTime createTime, int supplierId, string orgCode) { if (type == InstockType.Purchase) this.Status = InstockStatus.Wait; @@ -115,10 +115,10 @@ namespace WMS.Web.Domain.Entitys /// /// 作废 /// - public void Repeal(int repealerId,List detailsIds) + public void Repeal(int repealerId, List detailsIds) { this.RepealerId = repealerId; - this.RepealTime= DateTime.Now; + this.RepealTime = DateTime.Now; //明细行作废 this.Details.Where(x => detailsIds.Contains(x.Id)).ToList().ForEach(x => { x.IsRepeal = true; }); @@ -181,7 +181,7 @@ namespace WMS.Web.Domain.Entitys } //改变状态 - public void ChangeInstockStatus() + public void ChangeInstockStatus() { //明细中:所有的应入数量之和 var totalAccruedQty = this.Details.Where(x => x.IsRepeal != true).Sum(x => x.AccruedQty); @@ -194,9 +194,9 @@ namespace WMS.Web.Domain.Entitys if (totalAccruedQty <= totalRealityQty) this.Status = InstockStatus.Already; - else if(totalReceiveQty<= 0 && this.Type == InstockType.Purchase) + else if (totalReceiveQty <= 0 && this.Type == InstockType.Purchase) this.Status = InstockStatus.Wait; - else if(totalRealityQty<=0) + else if (totalRealityQty <= 0) this.Status = InstockStatus.WaitInStock; else this.Status = InstockStatus.Part; @@ -218,7 +218,7 @@ namespace WMS.Web.Domain.Entitys /// 非采购上架 /// /// - public void NoPurchaseShelf(int creatorId) + public void NoPurchaseShelf(int creatorId) { this.ChangeInstockStatus(); this.ReceiverId = creatorId; @@ -226,5 +226,17 @@ namespace WMS.Web.Domain.Entitys this.ShelferId = creatorId; this.ShelfTime = DateTime.Now; } + /// + /// erp删单 作废处理 + /// + public void ErpDel() + { + foreach (var d in this.Details) + { + d.AccruedQty = 0; + d.IsRepeal = true; + } + this.Status = InstockStatus.Repeal; + } } } diff --git a/src/WMS.Web.Domain/Entitys/OutStockTask.cs b/src/WMS.Web.Domain/Entitys/OutStockTask.cs index 71ac6713..e12214d9 100644 --- a/src/WMS.Web.Domain/Entitys/OutStockTask.cs +++ b/src/WMS.Web.Domain/Entitys/OutStockTask.cs @@ -1,4 +1,5 @@ -using System; +using Npoi.Mapper; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; @@ -292,5 +293,21 @@ namespace WMS.Web.Domain.Entitys return Result.ReSuccess(); } + /// + /// erp删单 作废处理 + /// + public void ErpDel(string sourceBillNo) + { + foreach (var d in this.Details) + { + d.ErpDetails.Where(w => w.SourceBillNo.Equals(sourceBillNo)).ForEach(f => f.AccruedQty = 0); + + d.AccruedQty = d.ErpDetails.Sum(s => s.AccruedQty); + if (d.AccruedQty <= 0) d.IsRepeal = true; + } + //明细都作废后 整个单据作废 + if (this.Details.Count() == this.Details.Where(w => w.IsRepeal == true).Count()) + this.Status = OutStockStatus.Repeal; + } } } diff --git a/src/WMS.Web.Domain/IService/IInStockTaskService.cs b/src/WMS.Web.Domain/IService/IInStockTaskService.cs index 4c2a8590..b46b9490 100644 --- a/src/WMS.Web.Domain/IService/IInStockTaskService.cs +++ b/src/WMS.Web.Domain/IService/IInStockTaskService.cs @@ -66,7 +66,11 @@ namespace WMS.Web.Domain.IService /// /// Task Sysn(List billNos = null); - + /// + /// 金蝶删单后这边单据作废 + /// + /// + Task ErpDel(DateTime begin); /// /// 作废 /// diff --git a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs index 755f07e2..f83af859 100644 --- a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs +++ b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs @@ -61,6 +61,11 @@ namespace WMS.Web.Domain.IService.Public /// Task Sync(List billNos = null,DateTime? begin=null); /// + /// 金蝶删单后这边单据作废 + /// + /// + Task ErpDel(DateTime begin); + /// /// 查询出库任务单详情 /// /// diff --git a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs index 8701be5f..5d6e4140 100644 --- a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs @@ -148,5 +148,7 @@ namespace WMS.Web.Domain.Infrastructure /// /// Task Update(InStockTask entity, bool isTransaction = true); + /// 查询实体集合 + Task> GetEntityList(DateTime begin); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs index 15a1ee6e..03a293c6 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs @@ -22,6 +22,8 @@ namespace WMS.Web.Domain.Infrastructure Task<(List list, int total)> GetListAsync(OutStockTaskQueryRequest dto, int companyId = 0); /// 查询实体集合 Task> GetEntityList(List ids); + /// 查询实体集合 + Task> GetEntityList(DateTime begin); /// 查询实体集合(明细Id) Task> GetEntityListByDetailIds(List ids); /// diff --git a/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs index 5c210423..513b0634 100644 --- a/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs +++ b/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Options; using Quartz; using System; using System.Collections.Generic; +using System.Drawing; using System.Text; using System.Threading.Tasks; using WMS.Web.Core.Internal.Results; @@ -12,6 +13,7 @@ using WMS.Web.Domain.Infrastructure; using WMS.Web.Domain.IService; using WMS.Web.Domain.IService.Public; using WMS.Web.Domain.Options; +using WMS.Web.Domain.Services; namespace WMS.Web.Domain.QuartzJob { @@ -63,6 +65,9 @@ namespace WMS.Web.Domain.QuartzJob var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"同步金蝶入库单数据:执行结束时间->{begindatetime}"); + DateTime begin = DateTime.Now.AddHours(-8);//默认拉去8个小时以内的 + //验证金蝶是否有删单 + await _inStockTaskService.ErpDel(begin); } catch (Exception ex) { @@ -71,6 +76,6 @@ namespace WMS.Web.Domain.QuartzJob } - + } } diff --git a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs index 131d3ef7..49eabd36 100644 --- a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs +++ b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs @@ -54,6 +54,8 @@ namespace WMS.Web.Domain.QuartzJob //5.记录:结束时间 var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"出库单-同步金蝶出库单数据:执行结束时间->{enddatetime}"); + //验证金蝶是否有删单 + await _outStockTaskService.ErpDel(begin); } catch (Exception ex) diff --git a/src/WMS.Web.Domain/Services/InStockTaskService.cs b/src/WMS.Web.Domain/Services/InStockTaskService.cs index 76b7a25b..3dfd7a1b 100644 --- a/src/WMS.Web.Domain/Services/InStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/InStockTaskService.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using WMS.Web.Core; using WMS.Web.Core.Dto; using WMS.Web.Core.Dto.Erp; +using WMS.Web.Core.Dto.Erp.OutStock; using WMS.Web.Core.Dto.InStockTask; using WMS.Web.Core.Dto.Login; using WMS.Web.Core.Internal.Results; @@ -699,5 +700,111 @@ namespace WMS.Web.Domain.Services return Result.ReSuccess(); } + /// + /// 金蝶删单后wms单据作废 + /// + /// + /// + /// + public async Task ErpDel(DateTime begin) + { + var list = await _inStockTaskRepositories.GetEntityList(begin); + var result = await GetData(list); + if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); + var erp_list = result.Data; + List update_list = new List(); + //处理数据 因为入库任务单和出库任务单结构不一样 没有合并的单据 所以处理不同 + foreach (var entity in list) + { + //判断是否在erp数据池里 + int count = erp_list.Where(w => w.BillNo.Equals(entity.SourceBillNo)).Count(); + if (count > 0) continue; + //如果不在数据池里 被删除了 那么需要把订单作废 + entity.ErpDel(); + _logger.LogInformation($"入库任务单 金蝶未找到单据:{entity.SourceBillNo} wms订单号:{entity.BillNo} 作废来源单号:{entity.SourceBillNo}"); + if (update_list.FirstOrDefault(f => f.Id == entity.Id) == null) + update_list.Add(entity); + + } + if (update_list.Count() <= 0) return Result.ReSuccess(); + + var isSuccess = await _inStockTaskRepositories.UpdateRange(update_list, true); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + + return Result.ReSuccess(); + } + /// + /// 获取金蝶数据 + /// + /// + /// + public async Task>> GetData(List list) + { + List erp_list = new List(); + List Instock_sourceBillNos = new List(); + List Miscellaneous_sourceBillNos = new List(); + List TransferDirect_sourceBillNos = new List(); + List Transferin_sourceBillNos = new List(); + List AssembledApp_sourceBillNos = new List(); + + foreach (var entity in list) + { + if (entity.Type == InstockType.Purchase) + Instock_sourceBillNos.Add(entity.SourceBillNo); + else if (entity.Type == InstockType.Stkdirecttransfers) + TransferDirect_sourceBillNos.Add(entity.SourceBillNo); + else if (entity.Type == InstockType.StktransferInst) + Transferin_sourceBillNos.Add(entity.SourceBillNo); + else if (entity.Type == InstockType.Assembled) + AssembledApp_sourceBillNos.Add(entity.SourceBillNo); + else if (entity.Type == InstockType.Miscellaneous) + Miscellaneous_sourceBillNos.Add(entity.SourceBillNo); + } + + if (Instock_sourceBillNos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForPurchaseInStock(Instock_sourceBillNos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (Miscellaneous_sourceBillNos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForMiscellaneous(Miscellaneous_sourceBillNos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (TransferDirect_sourceBillNos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForTransferDirect(TransferDirect_sourceBillNos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (Transferin_sourceBillNos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForTransferin(Transferin_sourceBillNos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (AssembledApp_sourceBillNos.Count() > 0) + { + var erp_result_ass = await _erpService.BillQueryForAssembledApp_Assembly(AssembledApp_sourceBillNos, null); + if (!erp_result_ass.IsSuccess) + return Result>.ReFailure(erp_result_ass.Message, erp_result_ass.Status); + erp_list.AddRange(erp_result_ass.Data); + + //1.1.获取金蝶数据:拆卸子件入库订单数据 + var erp_result_disass = await _erpService.BillQueryForAssembledApp_Disassembly(AssembledApp_sourceBillNos, null); + if (!erp_result_disass.IsSuccess) + return Result>.ReFailure(erp_result_disass.Message, erp_result_disass.Status); + + erp_list.AddRange(erp_result_disass.Data); + } + return Result>.ReSuccess(erp_list); + } } } diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs index 5ab4e865..a43bfbff 100644 --- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs @@ -641,5 +641,113 @@ namespace WMS.Web.Domain.Services throw ex; } } + /// + /// 金蝶删单后wms单据作废 + /// + /// + /// + public async Task ErpDel(DateTime begin) + { + var list = await _outStockTaskRepositories.GetEntityList(begin); + var result = await GetData(list); + if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); + var erp_list = result.Data; + List update_list = new List(); + //处理数据 + foreach (var entity in list) + { + //合并单有多个来源订单 + var nos = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo).ToList(); + foreach (var no in nos) + { + //判断是否在erp数据池里 + int count = erp_list.Where(w => w.SourceBillNo.Equals(no)).Count(); + if (count > 0) continue; + //如果不在数据池里 被删除了 那么需要把订单作废 + entity.ErpDel(no); + _logger.LogInformation($"出库任务单 金蝶未找到单据:{no} wms订单号:{entity.BillNo} 作废来源单号:{no}"); + if (update_list.FirstOrDefault(f => f.Id == entity.Id) == null) + update_list.Add(entity); + } + } + if (update_list.Count() <= 0) return Result.ReSuccess(); + + var isSuccess = await _outStockTaskRepositories.EditEntityList(update_list, true); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + + return Result.ReSuccess(); + } + /// + /// 获取金蝶数据 + /// + /// + /// + public async Task>> GetData(List list) + { + List erp_list = new List(); + //根据指定单号更新 + List SalOutStock_Nos = new List(); + List TransferDirect_Nos = new List(); + List TransferOut_Nos = new List(); + List AssembledApp_Nos = new List(); + List MisDeliveryOut_Nos = new List(); + foreach (var entity in list) + { + if (entity.Type == OutStockType.Sal) + SalOutStock_Nos.AddRange(entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo)); + else if (entity.Type == OutStockType.Stkdirecttransfers) + TransferDirect_Nos.AddRange(entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo)); + else if (entity.Type == OutStockType.StktransferInst) + TransferOut_Nos.AddRange(entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo)); + else if (entity.Type == OutStockType.Assembled) + AssembledApp_Nos.AddRange(entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo)); + else if (entity.Type == OutStockType.Miscellaneous) + MisDeliveryOut_Nos.AddRange(entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo)); + } + + if (SalOutStock_Nos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForSalOutStock(SalOutStock_Nos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (TransferDirect_Nos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForTransferDirectOutStock(TransferDirect_Nos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (TransferOut_Nos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForTransferOutOutStock(TransferOut_Nos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + if (AssembledApp_Nos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(AssembledApp_Nos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + + var erp_result_a = await _erpService.BillQueryForAssembledAppOutStock_Assembly(AssembledApp_Nos, null); + if (!erp_result_a.IsSuccess) + return Result>.ReFailure(erp_result_a.Message, erp_result_a.Status); + erp_list.AddRange(erp_result_a.Data); + } + if (MisDeliveryOut_Nos.Count() > 0) + { + var erp_result = await _erpService.BillQueryForMisDeliveryOutStock(MisDeliveryOut_Nos, null); + if (!erp_result.IsSuccess) + return Result>.ReFailure(erp_result.Message, erp_result.Status); + erp_list.AddRange(erp_result.Data); + } + + return Result>.ReSuccess(erp_list); + } } } diff --git a/src/WMS.Web.Repositories/InStockTaskRepositories.cs b/src/WMS.Web.Repositories/InStockTaskRepositories.cs index 431f641d..ec07b711 100644 --- a/src/WMS.Web.Repositories/InStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/InStockTaskRepositories.cs @@ -828,5 +828,15 @@ namespace WMS.Web.Repositories return (list, total); } + + public async Task> GetEntityList(DateTime begin) + { + var res = await _context.InStockTask + .Include(s => s.Details) + .Where(f => f.WmsUpdateTime >= begin) + .ToListAsync(); + + return res.Clone(); + } } } diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index d0852250..fe56258f 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Org.BouncyCastle.Crypto; using System; using System.Collections.Generic; using System.Linq; @@ -566,5 +567,14 @@ namespace WMS.Web.Repositories return entitys.Clone(); } + public async Task> GetEntityList(DateTime begin) + { + var res = await _context.OutStockTask + .Include(s => s.Details).ThenInclude(s => s.ErpDetails) + .Where(f => f.WmsUpdateTime >= begin) + .ToListAsync(); + + return res.Clone(); + } } }