调整金蝶同步
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Erp.OutStock;
|
||||
using WMS.Web.Core.Dto.Erp.Purchase;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
@@ -20,7 +21,7 @@ namespace WMS.Web.Domain.Services
|
||||
/// <summary>
|
||||
/// 出库任务
|
||||
/// </summary>
|
||||
public class OutStockTaskService: IOutStockTaskService
|
||||
public class OutStockTaskService : IOutStockTaskService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IErpService _erpService;
|
||||
@@ -85,20 +86,86 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// erp数据转化wms 执行数据库操作
|
||||
/// </summary>
|
||||
/// <param name="erp_list"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SsynDate(List<ErpDeliveryNoticeOutStockResultDto> erp_list, bool isTransaction)
|
||||
{
|
||||
//2.通过单据编号找到wms系统现有的任务单;并修改
|
||||
var erp_removeList = new List<ErpDeliveryNoticeOutStockResultDto>();
|
||||
var SourceBillNo_list = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
|
||||
var data_list = await _outStockTaskRepositories.GetListBySourceBillNo(SourceBillNo_list);
|
||||
if (data_list.Count != 0)
|
||||
{
|
||||
//2.1提取出wms任务单明细信息
|
||||
foreach (var e in erp_list)
|
||||
{
|
||||
//代表单据已经存在 那么就对单据进行修改
|
||||
var data = data_list.FirstOrDefault(f => f.SourceBillNo == e.SourceBillNo);
|
||||
var detail = data.Details.FirstOrDefault(w => w.MaterialId == e.MaterialId);
|
||||
//存在就修改,没有就添加
|
||||
if (detail != null)
|
||||
detail.AccruedQty = e.AccruedQty;
|
||||
else
|
||||
data.Details.Add(_mapper.Map<OutStockTaskDetails>(e));
|
||||
|
||||
erp_removeList.Add(e);
|
||||
}
|
||||
//2.2.提交修改
|
||||
var isSuccess = await _outStockTaskRepositories.EditEntityList(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<OutStockTask>();
|
||||
var billNos = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
|
||||
foreach (var item in billNos)
|
||||
{
|
||||
var e = erp_list.FirstOrDefault(f => f.SourceBillNo == item);
|
||||
var dto = new OutStockTask();
|
||||
dto.SourceBillNo = e.SourceBillNo;
|
||||
dto.Create((OutStockType)e.Type, e.SourceBillNo, e.DeliveryOrgId, e.ReceiptCustomerId, (DateTime)e.CreateTime);
|
||||
|
||||
//找到当前对应来源单据编号的集合数据
|
||||
var current_erp_details = erp_list.Where(x => x.SourceBillNo == item).ToList();
|
||||
//给到dto的实体明细中
|
||||
dto.Details = _mapper.Map<List<OutStockTaskDetails>>(current_erp_details);
|
||||
add_entitys.Add(dto);
|
||||
}
|
||||
//3.1提交新增
|
||||
isSuccess = await _outStockTaskRepositories.AddRange(add_entitys, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发货通知单同步数据
|
||||
/// </summary>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction)
|
||||
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
|
||||
{
|
||||
//1.获取金蝶数据:采购订单数据
|
||||
var erp_result = await _erpService.BillQueryForPurchaseInStock();
|
||||
var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
|
||||
if (!erp_result.IsSuccess)
|
||||
return Result.ReFailure(erp_result.Message, erp_result.Status);
|
||||
var erp_list = erp_result.Data;
|
||||
|
||||
return Result.ReSuccess();
|
||||
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user