调整同步金蝶
This commit is contained in:
@@ -6,15 +6,18 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Dto.OutStock;
|
||||
using WMS.Web.Core.Dto.TakeStock;
|
||||
using WMS.Web.Core.Help;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values;
|
||||
using WMS.Web.Domain.Values.Erp;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
@@ -66,7 +69,6 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
var mIds = dto.Details.GroupBy(g => g.MaterialId).Select(s => s.Key).ToList();
|
||||
OutStock entity = new OutStock();
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
|
||||
foreach (var mid in mIds)
|
||||
{
|
||||
//任务单明细
|
||||
@@ -91,6 +93,8 @@ namespace WMS.Web.Domain.Services
|
||||
outd.SerialNumbers.AddRange(dtoDetails.SelectMany(s => s.SerialNumbers));
|
||||
entity.Details.Add(outd);
|
||||
}
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
|
||||
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -123,13 +127,42 @@ namespace WMS.Web.Domain.Services
|
||||
var list = await _outStockRepositories.GetEntityList(dto.Ids);
|
||||
foreach (var entity in list)
|
||||
{
|
||||
//下推金蝶
|
||||
var res = await _erpService.Push(new Core.Dto.Erp.ErpPushDto() { });
|
||||
entity.Sync(new List<string>(), res.IsSuccess, loginInfo.UserInfo.StaffId, res.Message);
|
||||
if (entity.SuccessSync) continue;
|
||||
List<string> failList = entity.SuccessSyncFail.Clone();//同步失败的来源单号
|
||||
//找到单据里需要同步的单据
|
||||
var sourcNos = entity.Details.SelectMany(s => s.ErpDetails).GroupBy(s => s.SourceBillNo).Select(s => s.Key);
|
||||
foreach (var s in failList)
|
||||
{
|
||||
var erp_details = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.Erp_DetailId).ToList();
|
||||
var erpDto = new ErpPushDto() {
|
||||
FormId = FormIdParam.SAL_DELIVERYNOTICE.ToString(),
|
||||
Numbers = new List<string>() { s },
|
||||
DetailsId = string.Join(",", erp_details)
|
||||
};
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto);
|
||||
if (res.IsSuccess)
|
||||
entity.SyncSuccess(s, loginInfo.UserInfo.StaffId);
|
||||
else
|
||||
entity.SyncFail(res.Message, loginInfo.UserInfo.StaffId);
|
||||
}
|
||||
entity.SuccessSync = entity.SuccessSyncFail.Count() > 0 ? false : true;
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
var isSuccess = await _outStockRepositories.Edit(entity, true);
|
||||
if (entity == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
var isSuccess = await _outStockRepositories.EditEntityList(list, true);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 下推
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> Push(ErpPushDto dto)
|
||||
{
|
||||
var res = await _erpService.Push(dto);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user