优化对比接口

This commit is contained in:
tongfei
2023-11-07 11:34:37 +08:00
parent c0610b18c4
commit d4d4b37e66
5 changed files with 118 additions and 9 deletions

View File

@@ -22,9 +22,9 @@ namespace WMS.Web.Api.Controllers
{
private readonly IErpService _erpService;
private IInStockTaskService _inStockTaskService;
private ITransactionRepositories _transactionRepositories;
public TestController(IErpService erpService, IInStockTaskService inStockTaskService, ITransactionRepositories transactionRepositories)
private IBasicsRepositories _transactionRepositories;
public TestController(IErpService erpService, IInStockTaskService inStockTaskService, IBasicsRepositories transactionRepositories)
{
this._erpService = erpService;
this._inStockTaskService = inStockTaskService;
@@ -35,7 +35,7 @@ namespace WMS.Web.Api.Controllers
[Route("hj")]
public async Task<string> TestHJ()
{
var res = await this._erpService.BillQueryForTransferDirectOutStock();
var res = await this._erpService.BillQueryForTransferDirectOutStock();
//var result= await this._erpService.BillQueryForPurchaseInStock();
//var result = await this._erpService.BillQueryForOrg();
var result = await this._erpService.BillQueryForMaterial();
@@ -44,6 +44,47 @@ namespace WMS.Web.Api.Controllers
return JsonConvert.SerializeObject(result.Data);
}
[HttpGet]
[Route("tf")]
public async Task<bool> TestTF()
{
var list1 = new List<TT1>();
var t1 = new TT1();
t1.Id = 1;
t1.Qty = 5;
var t2 = new TT1();
t2.Id = 2;
t2.Qty = 9;
var t3 = new TT1();
t3.Id = 3;
t3.Qty = 9;
list1.Add(t1);
list1.Add(t2);
list1.Add(t3);
var list2 = new List<TT2>();
var a1 = new TT2();
a1.Id = 1;
a1.Qty = 5;
var a2 = new TT2();
a2.Id = 2;
a2.Qty = 9;
var a3 = new TT2();
a3.Id = 4;
a3.Qty = 9;
list2.Add(a1);
list2.Add(a2);
list2.Add(a3);
//3.比对
bool isRight = list2.All(x => list1.Any(t => t.Id == x.Id && t.Qty == x.Qty)) && list2.Count == list1.Count;
return isRight;
}
/// <summary>
/// 测试:同步采购单的入库
/// </summary>
@@ -56,7 +97,7 @@ namespace WMS.Web.Api.Controllers
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isTransaction = false;
//3.同步数据
var result = await _inStockTaskService.SsynPurchaseInStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
@@ -64,9 +105,23 @@ namespace WMS.Web.Api.Controllers
//4.提交事务
var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(result.Message,result.Status);
return Result.ReFailure(result.Message, result.Status);
return result;
}
}
public class TT1
{
public int Id { get; set; }
public decimal Qty { get; set; }
}
public class TT2
{
public int Id { get; set; }
public decimal Qty { get; set; }
}
}