提交测试

This commit is contained in:
tongfei
2024-04-25 15:54:33 +08:00
parent 93d216d51f
commit 81bd764a72
5 changed files with 89 additions and 9 deletions

View File

@@ -103,7 +103,28 @@ namespace WMS.Web.Domain.Services
{
foreach (var entity in list)
{
var res = await this.PurchaseInStock(entity, loginInfo);
var res = await this.PurchaseInStock(entity, loginInfo, 0);
if (!res.IsSuccess)
_logger.LogError($"入库单同步失败:{res.Message}");
}
});
return Task.FromResult(Result.ReSuccess());
}
public Task<Result> Sync(OperateRequest dto, LoginInDto loginInfo, int errorType)
{
var list = _inStockRepositories.GetList(dto.Ids).GetAwaiter().GetResult();
var isSuccess = true;
list = list.Where(w => w.SuccessSync == SyncStatus.Fail).ToList();
list.ForEach(f => f.RepeatSync());
isSuccess = _inStockRepositories.UpdateRange(list, true).GetAwaiter().GetResult();
Task.Run(async () =>
{
foreach (var entity in list)
{
var res = await this.PurchaseInStock(entity, loginInfo, errorType);
if (!res.IsSuccess)
_logger.LogError($"入库单同步失败:{res.Message}");
}
@@ -827,7 +848,7 @@ namespace WMS.Web.Domain.Services
/// <param name="entity"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
private async Task<Result> PurchaseInStock(InStock entity, LoginInDto loginInfo)
private async Task<Result> PurchaseInStock(InStock entity, LoginInDto loginInfo, int errorType)
{
_logger.LogInformation($"采购下推-同步:{JsonConvert.SerializeObject(entity)} 操作人:{loginInfo.UserInfo.StaffId}");
var scope = _serviceScopeFactory.CreateScope();
@@ -892,7 +913,7 @@ namespace WMS.Web.Domain.Services
else
{
//下推金蝶
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories);
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories, errorType);
if (res.result.IsSuccess)
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
else
@@ -916,7 +937,7 @@ namespace WMS.Web.Domain.Services
/// <param name="erpDetail"></param>
/// <param name="billNo"></param>
/// <returns></returns>
private async Task<(Result result, SyncStatus syncStatus, string erpBillNo, string instockDetailId)> Push(ErpPushDto dto, InStockErpDetails erpDetail, string billNo, IErpService sc_erpService, IInStockRepositories sc_inStockRepositories)
private async Task<(Result result, SyncStatus syncStatus, string erpBillNo, string instockDetailId)> Push(ErpPushDto dto, InStockErpDetails erpDetail, string billNo, IErpService sc_erpService, IInStockRepositories sc_inStockRepositories, int errorType)
{
var erp_instock_detId = string.Empty;
try
@@ -935,8 +956,10 @@ namespace WMS.Web.Domain.Services
purchaseInStock.Details[0].Qty = erpDetail.Qty;
string formId = dto.TargetFormId.ToString();
erp_instock_detId = purchaseInStock.Details[0].DetailId;
//var tt = Convert.ToInt32("abc");
if (errorType == 1)
{
int tt = Convert.ToInt32("abc");
}
//批号生成和同步
if (string.IsNullOrEmpty(erpDetail.BatchBillNo))
{
@@ -972,6 +995,10 @@ namespace WMS.Web.Domain.Services
_logger.LogInformation($"入库单->保存失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{res_s.Message}");
return (Result.ReFailure(res_s.Message, res_s.Status), SyncStatus.SubmitFail, "", purchaseInStock.Details[0].DetailId);
}
if (errorType == 2)
{
int tt = Convert.ToInt32("abc");
}
//提交
_logger.LogInformation($"入库单->保存成功 开始提交 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId}");
ErpOperateDto o_dto = new ErpOperateDto(formId, res_s.Data);//res_s.Data
@@ -981,6 +1008,11 @@ namespace WMS.Web.Domain.Services
_logger.LogInformation($"入库单->提交失败 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 错误:{resSubmit.Message}");
return (resSubmit, SyncStatus.SubmitFail, o_dto.Numbers.First(), purchaseInStock.Details[0].DetailId);
}
if (errorType == 3)
{
int tt = Convert.ToInt32("abc");
}
//审核
_logger.LogInformation($"入库单->提交成功 开始审核 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId}");
resSubmit = await sc_erpService.Audit(o_dto, formId);