xml
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.Erp.Purchase;
|
||||
using WMS.Web.Core.Dto.InStockTask;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
@@ -169,5 +170,79 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步:其他入库单
|
||||
/// </summary>
|
||||
/// <param name="billNos"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SysnMiscellaneous(List<string> billNos = null, bool isTransaction = true)
|
||||
{
|
||||
//1.获取金蝶数据:其他入库订单数据
|
||||
var erp_result = await _erpService.BillQueryForMiscellaneous(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<ErpMiscellaneousDto>();
|
||||
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 ResultList<ErpPurchaseInStockResultDto>.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 => x.BillNo).Select(x => x.Key).ToList();
|
||||
foreach (var item in current_billNos)
|
||||
{
|
||||
var dto = new InStockTask();
|
||||
dto.SourceBillNo = item;
|
||||
dto.Create(InstockType.Purchase);
|
||||
|
||||
//找到当前对应来源单据编号的集合数据
|
||||
var current_erp_details = erp_list.Where(x => x.BillNo == item).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 ResultList<ErpPurchaseInStockResultDto>.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user