出入库任务单在金蝶没查到任务单 就作废
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user