出入库任务单在金蝶没查到任务单 就作废

This commit is contained in:
18942506660
2024-07-29 16:00:44 +08:00
parent bb3a28bcfd
commit 0fe5c20eff
14 changed files with 378 additions and 37 deletions

View File

@@ -1093,6 +1093,11 @@
</summary>
<param name="creatorId"></param>
</member>
<member name="M:WMS.Web.Domain.Entitys.InStockTask.ErpDel">
<summary>
erp删单 作废处理
</summary>
</member>
<member name="T:WMS.Web.Domain.Entitys.InStockTaskBox">
<summary>
erp入库任务单的对应box箱信息表
@@ -1955,6 +1960,11 @@
<param name="creatorId"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Entitys.OutStockTask.ErpDel(System.String)">
<summary>
erp删单 作废处理
</summary>
</member>
<member name="T:WMS.Web.Domain.Entitys.OutStockTaskDetails">
<summary>
erp出库任务单明细
@@ -3133,6 +3143,9 @@
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetEntityList(System.DateTime)">
查询实体集合
</member>
<member name="T:WMS.Web.Domain.Infrastructure.IInventoryDetailsRepositories">
<summary>
库存相关-仓储接口
@@ -3303,6 +3316,9 @@
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.Collections.Generic.List{System.Int32})">
查询实体集合
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.DateTime)">
查询实体集合
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityListByDetailIds(System.Collections.Generic.List{System.Int32})">
查询实体集合(明细Id)
</member>
@@ -3698,6 +3714,12 @@
<param name="billNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.IInStockTaskService.ErpDel(System.DateTime)">
<summary>
金蝶删单后这边单据作废
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.IInStockTaskService.Repeal(WMS.Web.Core.Dto.OperateRequest,WMS.Web.Core.Dto.Login.LoginInDto)">
<summary>
作废
@@ -4014,84 +4036,84 @@
<param name="purchaseDetailId"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForPurchaseInStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForPurchaseInStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-采购入库单
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMiscellaneous(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMiscellaneous(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-其他入库单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferDirect(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferDirect(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-直接调拨入库单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferin(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferin(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-分步式调入单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledApp_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledApp_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单-组装(成品入库)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledApp_Disassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledApp_Disassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单-拆卸(子件入库)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForDeliveryNoticeOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForDeliveryNoticeOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-出库单
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-直接调拨出库
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-分布式调出
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单(拆卸 主出)
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单(组装 子出)
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-其他出库
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForSalOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.IService.Public.IErpService.BillQueryForSalOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-销售出库单
</summary>
@@ -4289,6 +4311,12 @@
<param name="begin"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.ErpDel(System.DateTime)">
<summary>
金蝶删单后这边单据作废
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.GetInfo(System.Int32,WMS.Web.Core.Dto.Login.LoginInDto,Microsoft.Extensions.DependencyInjection.IServiceScope)">
<summary>
查询出库任务单详情
@@ -5402,6 +5430,21 @@
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:WMS.Web.Domain.Services.InStockTaskService.ErpDel(System.DateTime)">
<summary>
金蝶删单后wms单据作废
</summary>
<param name="begin"></param>
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:WMS.Web.Domain.Services.InStockTaskService.GetData(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStockTask})">
<summary>
获取金蝶数据
</summary>
<param name="list"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Services.InventoryDetailsService">
<summary>
即时库存-服务
@@ -5597,6 +5640,20 @@
<param name="dto"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.ErpDel(System.DateTime)">
<summary>
金蝶删单后wms单据作废
</summary>
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.GetData(System.Collections.Generic.List{WMS.Web.Domain.Entitys.OutStockTask})">
<summary>
获取金蝶数据
</summary>
<param name="list"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Services.Public.ErpBaseDataSync">
<summary>
同步erp基础数据
@@ -5792,7 +5849,7 @@
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForPurchaseInStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForPurchaseInStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-采购入库单
</summary>
@@ -5800,35 +5857,35 @@
<param name="sourceBillNos">单据编号集合精确查找</param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForMiscellaneous(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForMiscellaneous(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-其他入库单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferDirect(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferDirect(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-直接调拨入库单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferin(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferin(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-分步式调入单
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledApp_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledApp_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单-组装(成品入库)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledApp_Disassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledApp_Disassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
erp:单据查询-组装拆卸单-拆卸(子件入库)
</summary>
@@ -5953,42 +6010,42 @@
<param name="dto"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferDirectOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
直接调拨出库
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForTransferOutOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
分布式调出
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Dassembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
组装拆卸单 (拆卸 主出)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForMisDeliveryOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
其他出库
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForAssembledAppOutStock_Assembly(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
组装拆卸单 (组装 子出)
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForSalOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime})">
<member name="M:WMS.Web.Domain.Services.Public.ErpService.BillQueryForSalOutStock(System.Collections.Generic.List{System.String},System.Nullable{System.DateTime},System.Boolean)">
<summary>
销售出库单
</summary>

View File

@@ -226,5 +226,17 @@ namespace WMS.Web.Domain.Entitys
this.ShelferId = creatorId;
this.ShelfTime = DateTime.Now;
}
/// <summary>
/// erp删单 作废处理
/// </summary>
public void ErpDel()
{
foreach (var d in this.Details)
{
d.AccruedQty = 0;
d.IsRepeal = true;
}
this.Status = InstockStatus.Repeal;
}
}
}

View File

@@ -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();
}
/// <summary>
/// erp删单 作废处理
/// </summary>
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;
}
}
}

View File

@@ -66,7 +66,11 @@ namespace WMS.Web.Domain.IService
/// <param name="billNos"></param>
/// <returns></returns>
Task<Result> Sysn(List<string> billNos = null);
/// <summary>
/// 金蝶删单后这边单据作废
/// </summary>
/// <returns></returns>
Task<Result> ErpDel(DateTime begin);
/// <summary>
/// 作废
/// </summary>

View File

@@ -61,6 +61,11 @@ namespace WMS.Web.Domain.IService.Public
/// <returns></returns>
Task<Result> Sync(List<string> billNos = null,DateTime? begin=null);
/// <summary>
/// 金蝶删单后这边单据作废
/// </summary>
/// <returns></returns>
Task<Result> ErpDel(DateTime begin);
/// <summary>
/// 查询出库任务单详情
/// </summary>
/// <param name="id"></param>

View File

@@ -148,5 +148,7 @@ namespace WMS.Web.Domain.Infrastructure
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<InStockTask> Update(InStockTask entity, bool isTransaction = true);
/// 查询实体集合
Task<List<InStockTask>> GetEntityList(DateTime begin);
}
}

View File

@@ -22,6 +22,8 @@ namespace WMS.Web.Domain.Infrastructure
Task<(List<OutStockTaskQueryInfoResponse> list, int total)> GetListAsync(OutStockTaskQueryRequest dto, int companyId = 0);
/// 查询实体集合
Task<List<OutStockTask>> GetEntityList(List<int> ids);
/// 查询实体集合
Task<List<OutStockTask>> GetEntityList(DateTime begin);
/// 查询实体集合(明细Id)
Task<List<OutStockTask>> GetEntityListByDetailIds(List<int> ids);
/// <summary>

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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();
}
/// <summary>
/// 金蝶删单后wms单据作废
/// </summary>
/// <param name="begin"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<Result> 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<InStockTask> update_list = new List<InStockTask>();
//处理数据 因为入库任务单和出库任务单结构不一样 没有合并的单据 所以处理不同
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();
}
/// <summary>
/// 获取金蝶数据
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<Result<List<ErpInStockResultDto>>> GetData(List<InStockTask> list)
{
List<ErpInStockResultDto> erp_list = new List<ErpInStockResultDto>();
List<string> Instock_sourceBillNos = new List<string>();
List<string> Miscellaneous_sourceBillNos = new List<string>();
List<string> TransferDirect_sourceBillNos = new List<string>();
List<string> Transferin_sourceBillNos = new List<string>();
List<string> AssembledApp_sourceBillNos = new List<string>();
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<List<ErpInStockResultDto>>.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<List<ErpInStockResultDto>>.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<List<ErpInStockResultDto>>.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<List<ErpInStockResultDto>>.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<List<ErpInStockResultDto>>.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<List<ErpInStockResultDto>>.ReFailure(erp_result_disass.Message, erp_result_disass.Status);
erp_list.AddRange(erp_result_disass.Data);
}
return Result<List<ErpInStockResultDto>>.ReSuccess(erp_list);
}
}
}

View File

@@ -641,5 +641,113 @@ namespace WMS.Web.Domain.Services
throw ex;
}
}
/// <summary>
/// 金蝶删单后wms单据作废
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<Result> 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<OutStockTask> update_list = new List<OutStockTask>();
//处理数据
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();
}
/// <summary>
/// 获取金蝶数据
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<Result<List<ErpDeliveryNoticeOutStockResultDto>>> GetData(List<OutStockTask> list)
{
List<ErpDeliveryNoticeOutStockResultDto> erp_list = new List<ErpDeliveryNoticeOutStockResultDto>();
//根据指定单号更新
List<string> SalOutStock_Nos = new List<string>();
List<string> TransferDirect_Nos = new List<string>();
List<string> TransferOut_Nos = new List<string>();
List<string> AssembledApp_Nos = new List<string>();
List<string> MisDeliveryOut_Nos = new List<string>();
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<List<ErpDeliveryNoticeOutStockResultDto>>.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<List<ErpDeliveryNoticeOutStockResultDto>>.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<List<ErpDeliveryNoticeOutStockResultDto>>.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<List<ErpDeliveryNoticeOutStockResultDto>>.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<List<ErpDeliveryNoticeOutStockResultDto>>.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<List<ErpDeliveryNoticeOutStockResultDto>>.ReFailure(erp_result.Message, erp_result.Status);
erp_list.AddRange(erp_result.Data);
}
return Result<List<ErpDeliveryNoticeOutStockResultDto>>.ReSuccess(erp_list);
}
}
}

View File

@@ -828,5 +828,15 @@ namespace WMS.Web.Repositories
return (list, total);
}
public async Task<List<InStockTask>> GetEntityList(DateTime begin)
{
var res = await _context.InStockTask
.Include(s => s.Details)
.Where(f => f.WmsUpdateTime >= begin)
.ToListAsync();
return res.Clone();
}
}
}

View File

@@ -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<List<OutStockTask>> 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();
}
}
}