采购查询接口优化

This commit is contained in:
tongfei
2023-11-09 16:12:29 +08:00
parent db9a3d25a3
commit d386e4aa41
10 changed files with 161 additions and 86 deletions

View File

@@ -1,10 +1,12 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp.Purchase;
using WMS.Web.Core.Dto.InStockTask;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure;
@@ -37,16 +39,49 @@ namespace WMS.Web.Domain.Services
_inStockTaskRepositories = inStockTaskRepositories;
}
/// <summary>
/// 来源单-编号模糊查询-pad
/// </summary>
/// <param name="sourceBillNo"></param>
/// <returns></returns>
public async Task<ResultList<InStockTaskBillNoQueryResponse>> GetPurchaseInstockTask(string sourceBillNo)
{
//1.事务
IDbContextTransaction _transaction = _basicsRepositories.GetTransaction();
bool isRollback = false;
bool isTransaction = false;
//2.查看是否有入库任务单
var tasks= await _inStockTaskRepositories.GetListBy(sourceBillNo);
if (tasks == null || tasks.Count == 0)
return ResultList < InStockTaskBillNoQueryResponse > .ReFailure(ResultCodes.OrderNoData);
//3.有的话就同步一下金蝶的数据
var billNos = tasks.Select(x => x.SourceBillNo).ToList();
var result=await this.SsynPurchaseInStock(billNos, isTransaction);
if (!result.IsSuccess) isRollback = true;
//4.提交事务
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return ResultList < InStockTaskBillNoQueryResponse > .ReFailure(result.Message, result.Status);
//5.再一次查询新的数据:并返回最后的结果
var request = new InStockTaskBillNoQueryRequest() { SourceBillNo = sourceBillNo };
var list = await _inStockTaskRepositories.GetListBy(request);
return ResultList<InStockTaskBillNoQueryResponse>.ReSuccess(list);
}
/// <summary>
/// 同步:采购入库类型单据
/// </summary>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynPurchaseInStock(bool isTransaction)
public async Task<Result> SsynPurchaseInStock(List<string> billNos=null,bool isTransaction=true)
{
//1.获取金蝶数据:采购订单数据
var erp_result= await _erpService.BillQueryForPurchaseInStock();
var erp_result= await _erpService.BillQueryForPurchaseInStock(billNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message,erp_result.Status);
var erp_list = erp_result.Data;
@@ -69,6 +104,7 @@ namespace WMS.Web.Domain.Services
{
//2.1.2修改数量
item.AccruedQty = erp_data.FQty;
item.DeliveredQty = erp_data.FStockInQty;
erp_removeList.Add(erp_data);
}
}