修复bug
This commit is contained in:
@@ -77,7 +77,7 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
_logger.LogInformation($"出库:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.StaffId}");
|
||||
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
|
||||
if(outStockTask==null) return Result.ReFailure(ResultCodes.OutStockTaskNoData);
|
||||
if (outStockTask == null) return Result.ReFailure(ResultCodes.OutStockTaskNoData);
|
||||
if (outStockTask.Status == OutStockStatus.Already)
|
||||
return Result.ReFailure(ResultCodes.OutStockTaskAlready);
|
||||
if (outStockTask.Status == OutStockStatus.Repeal)
|
||||
@@ -206,38 +206,47 @@ namespace WMS.Web.Domain.Services
|
||||
var list = await _outStockRepositories.GetEntityList(dto.Ids);
|
||||
foreach (var entity in list)
|
||||
{
|
||||
if (entity.SuccessSync != SyncStatus.Fail) continue;
|
||||
List<string> failList = entity.Details.SelectMany(s => s.ErpDetails)
|
||||
.Where(w => w.SuccessSync == SyncStatus.Fail).GroupBy(g => g.SourceBillNo)
|
||||
.Select(s => s.Key).ToList();//同步失败的来源单号
|
||||
//找到单据里需要同步的单据
|
||||
var sourcNos = entity.Details.SelectMany(s => s.ErpDetails).GroupBy(s => s.SourceBillNo).Select(s => s.Key);
|
||||
foreach (var s in failList)
|
||||
{
|
||||
var erp_details = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.Erp_DetailId).ToList();
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
FormId = FormIdParam.SAL_DELIVERYNOTICE.ToString(),
|
||||
Numbers = new List<string>() { s },
|
||||
Type = "",
|
||||
DetailsId = string.Join(",", erp_details)
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto);
|
||||
if (res.IsSuccess)
|
||||
entity.SyncSuccess(s, loginInfo.UserInfo.StaffId);
|
||||
else
|
||||
entity.SyncFail(res.Message, loginInfo.UserInfo.StaffId, SyncStatus.Fail);
|
||||
}
|
||||
//entity.SuccessSync = entity.SuccessSyncFail.Count() > 0 ? false : true;
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
var isSuccess = await _outStockRepositories.Edit(entity, true);
|
||||
if (entity == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
await SalOutStock(entity, loginInfo);
|
||||
}
|
||||
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 同步金蝶销售出库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> SalOutStock(OutStock entity, LoginInDto loginInfo)
|
||||
{
|
||||
if (entity.Type != OutStockType.Sal) return Result.ReSuccess();
|
||||
if (entity.SuccessSync != SyncStatus.Fail) return Result.ReSuccess();
|
||||
List<string> failList = entity.Details.SelectMany(s => s.ErpDetails)
|
||||
.Where(w => w.SuccessSync == SyncStatus.Fail).GroupBy(g => g.SourceBillNo)
|
||||
.Select(s => s.Key).ToList();//同步失败的来源单号
|
||||
//找到单据里需要同步的单据
|
||||
var sourcNos = entity.Details.SelectMany(s => s.ErpDetails).GroupBy(s => s.SourceBillNo).Select(s => s.Key);
|
||||
foreach (var s in failList)
|
||||
{
|
||||
var erp_details = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.Erp_DetailId).ToList();
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
FormId = FormIdParam.SAL_DELIVERYNOTICE.ToString(),
|
||||
Numbers = new List<string>() { s },
|
||||
TargetFormId = FormIdParam.SAL_OUTSTOCK.ToString(),
|
||||
DetailsId = string.Join(",", erp_details)
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto);
|
||||
if (res.IsSuccess)
|
||||
entity.SyncSuccess(s, loginInfo.UserInfo.StaffId);
|
||||
else
|
||||
entity.SyncFail(res.Message, loginInfo.UserInfo.StaffId, SyncStatus.Fail);
|
||||
}
|
||||
//entity.SuccessSync = entity.SuccessSyncFail.Count() > 0 ? false : true;
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
var isSuccess = await _outStockRepositories.Edit(entity, true);
|
||||
if (entity == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下推
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user