非采购接口优化

This commit is contained in:
tongfei
2023-11-09 18:06:43 +08:00
parent 71efc00756
commit 6d0024fd49
8 changed files with 94 additions and 23 deletions

View File

@@ -19,7 +19,7 @@ namespace WMS.Web.Domain.Services
/// <summary>
/// 入库任务单-服务
/// </summary>
public class InStockTaskService: IInStockTaskService
public class InStockTaskService : IInStockTaskService
{
private readonly IMapper _mapper;
private readonly IErpService _erpService;
@@ -40,7 +40,7 @@ namespace WMS.Web.Domain.Services
}
/// <summary>
/// 来源单-编号模糊查询-pad
/// 来源单-与金蝶校准-第二步-pad
/// </summary>
/// <param name="sourceBillNo"></param>
/// <returns></returns>
@@ -52,19 +52,41 @@ namespace WMS.Web.Domain.Services
bool isTransaction = false;
//2.查看是否有入库任务单
var tasks= await _inStockTaskRepositories.GetListBy(sourceBillNo);
if (tasks == null || tasks.Count == 0)
return ResultList < InStockTaskBillNoQueryResponse > .ReFailure(ResultCodes.OrderNoData);
var task = await _inStockTaskRepositories.GetBy(sourceBillNo);
if (task == null)
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;
var billNos = new List<string>();
billNos.Add(sourceBillNo);
//3.1这里要对入库任务单的类型逐一判断进行去ErpService找对应的单据类型重新获取这里只有采购后面再加其它的
if (task.Type == InstockType.Purchase)
{
var result = await this.SsynPurchaseInStock(billNos, isTransaction);
if (!result.IsSuccess) isRollback = true;
}
else if (task.Type == InstockType.Miscellaneous)
{
}
else if (task.Type == InstockType.Assembled)
{
}
else if (task.Type == InstockType.Stkdirecttransfers)
{
}
else if (task.Type == InstockType.StktransferInst)
{
}
//4.提交事务
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return ResultList < InStockTaskBillNoQueryResponse > .ReFailure(result.Message, result.Status);
return ResultList<InStockTaskBillNoQueryResponse>.ReFailure(ResultCodes.AdjustError);
//5.再一次查询新的数据:并返回最后的结果
@@ -78,12 +100,12 @@ namespace WMS.Web.Domain.Services
/// </summary>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynPurchaseInStock(List<string> billNos=null,bool isTransaction=true)
public async Task<Result> SsynPurchaseInStock(List<string> billNos = null, bool isTransaction = true)
{
//1.获取金蝶数据:采购订单数据
var erp_result= await _erpService.BillQueryForPurchaseInStock(billNos);
var erp_result = await _erpService.BillQueryForPurchaseInStock(billNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message,erp_result.Status);
return Result.ReFailure(erp_result.Message, erp_result.Status);
var erp_list = erp_result.Data;
//2.通过单据编号找到wms系统现有的任务单并修改
@@ -96,12 +118,12 @@ namespace WMS.Web.Domain.Services
var data_list_details = data_list.SelectMany(x => x.Details).ToList();
foreach (var item in data_list_details)
{
var data= data_list.Where(x => x.Id == item.Fid).FirstOrDefault();
var data = data_list.Where(x => x.Id == item.Fid).FirstOrDefault();
//2.1.1对比erp的物料信息
var erp_data = erp_list.Where(x =>x.FBillNo==data.SourceBillNo && x.FMaterialId == item.MaterialId).FirstOrDefault();
var erp_data = erp_list.Where(x => x.FBillNo == data.SourceBillNo && x.FMaterialId == item.MaterialId).FirstOrDefault();
if (erp_data != null)
{
{
//2.1.2修改数量
item.AccruedQty = erp_data.FQty;
item.DeliveredQty = erp_data.FStockInQty;
@@ -133,7 +155,7 @@ namespace WMS.Web.Domain.Services
dto.Create(InstockType.Purchase);
//找到当前对应来源单据编号的集合数据
var current_erp_details= erp_list.Where(x => x.FBillNo == item).ToList();
var current_erp_details = erp_list.Where(x => x.FBillNo == item).ToList();
//给到dto的实体明细中
dto.Details = _mapper.Map<List<InStockTaskDetails>>(current_erp_details);
add_entitys.Add(dto);