分步式调入单-服务
This commit is contained in:
@@ -355,5 +355,80 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步:分步式调入单
|
||||
/// </summary>
|
||||
/// <param name="billNos"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SysnTransferin(List<string> billNos = null, bool isTransaction = true)
|
||||
{
|
||||
//1.获取金蝶数据:分步式入库订单数据
|
||||
var erp_result = await _erpService.BillQueryForTransferin(billNos);
|
||||
if (!erp_result.IsSuccess)
|
||||
return Result.ReFailure(erp_result.Message, erp_result.Status);
|
||||
var erp_list = erp_result.Data;
|
||||
|
||||
//2.通过单据编号找到wms系统现有的任务单;并修改
|
||||
var erp_removeList = new List<ErpTransferinDto>();
|
||||
var SourceBillNo_list = erp_list.GroupBy(x => x.BillNo).Select(x => x.Key).ToList();
|
||||
var data_list = await _inStockTaskRepositories.GetListBy(SourceBillNo_list);
|
||||
if (data_list.Count != 0)
|
||||
{
|
||||
//2.1提取出wms任务单明细信息
|
||||
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();
|
||||
|
||||
//2.1.1对比erp的物料信息
|
||||
var erp_data = erp_list.Where(x => x.BillNo == data.SourceBillNo && x.MaterialId == item.MaterialId).FirstOrDefault();
|
||||
if (erp_data != null)
|
||||
{
|
||||
//2.1.2修改数量
|
||||
item.AccruedQty = erp_data.Qty;
|
||||
erp_removeList.Add(erp_data);
|
||||
}
|
||||
}
|
||||
|
||||
//2.2.提交修改
|
||||
var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//2.3剔除:已修改的单据
|
||||
foreach (var item in erp_removeList)
|
||||
{
|
||||
erp_list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
//3.wms任务单的来源单据编号不存在于erp中,那么就新增
|
||||
if (erp_list.Count != 0)
|
||||
{
|
||||
var add_entitys = new List<InStockTask>();
|
||||
var current_billNos = erp_list.GroupBy(x => new { x.BillNo, x.CreateTime }).Select(x => new { x.Key.BillNo, x.Key.CreateTime }).ToList();
|
||||
foreach (var item in current_billNos)
|
||||
{
|
||||
var dto = new InStockTask();
|
||||
dto.SourceBillNo = item.BillNo;
|
||||
dto.CreateTime = item.CreateTime;
|
||||
dto.Create(InstockType.StktransferInst);
|
||||
|
||||
//找到当前对应来源单据编号的集合数据
|
||||
var current_erp_details = erp_list.Where(x => x.BillNo == item.BillNo).ToList();
|
||||
//给到dto的实体明细中
|
||||
dto.Details = _mapper.Map<List<InStockTaskDetails>>(current_erp_details);
|
||||
add_entitys.Add(dto);
|
||||
}
|
||||
//3.1提交新增
|
||||
var isSuccess = await _inStockTaskRepositories.AddRange(add_entitys, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user