调整同步金蝶
This commit is contained in:
@@ -961,12 +961,12 @@
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.OutStock.SuccessSync">
|
||||
<summary>
|
||||
同步成功或者失败 null 就是未同步
|
||||
同步成功或者失败 默认是失败状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.OutStock.SuccessSyncFail">
|
||||
<summary>
|
||||
同步失败的源订单号
|
||||
同步失败的源订单号(默认就包含所有来源单号)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.OutStock.SyncTime">
|
||||
@@ -986,13 +986,19 @@
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.OutStock.Create(System.Int32,WMS.Web.Domain.Entitys.OutStockTask)">
|
||||
<summary>
|
||||
创建
|
||||
创建(需要在明细都生成后最后调用)
|
||||
</summary>
|
||||
<param name="creatorId"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.OutStock.Sync(System.Collections.Generic.List{System.String},System.Boolean,System.Int32,System.String)">
|
||||
<member name="M:WMS.Web.Domain.Entitys.OutStock.SyncSuccess(System.String,System.Int32)">
|
||||
<summary>
|
||||
同步金蝶
|
||||
同步金蝶(成功)
|
||||
</summary>
|
||||
<param name="operateId"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.OutStock.SyncFail(System.String,System.Int32)">
|
||||
<summary>
|
||||
同步金蝶(失败)
|
||||
</summary>
|
||||
<param name="operateId"></param>
|
||||
</member>
|
||||
@@ -3334,6 +3340,13 @@
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.OutStockService.Push(WMS.Web.Core.Dto.Erp.ErpPushDto)">
|
||||
<summary>
|
||||
下推
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Services.OutStockTaskService">
|
||||
<summary>
|
||||
出库任务
|
||||
|
||||
@@ -62,12 +62,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 同步成功或者失败 null 就是未同步
|
||||
/// 同步成功或者失败 默认是失败状态
|
||||
/// </summary>
|
||||
[Column("SuccessSync")]
|
||||
public bool? SuccessSync { get; set; }
|
||||
public bool SuccessSync { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 同步失败的源订单号
|
||||
/// 同步失败的源订单号(默认就包含所有来源单号)
|
||||
/// </summary>
|
||||
[Column("SuccessSyncFail")]
|
||||
public List<string> SuccessSyncFail { get; set; }=new List<string>();
|
||||
@@ -86,7 +86,7 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
public List<OutStockDetails> Details = new List<OutStockDetails>();
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// 创建(需要在明细都生成后最后调用)
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId, OutStockTask task)
|
||||
@@ -97,16 +97,28 @@ namespace WMS.Web.Domain.Entitys
|
||||
this.ReceiptCustomerId = task.ReceiptCustomerId;
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
this.SuccessSync = false;
|
||||
this.SuccessSyncFail = this.Details.SelectMany(s => s.ErpDetails).GroupBy(g => g.SourceBillNo).Select(s=>s.Key).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 同步金蝶
|
||||
/// 同步金蝶(成功)
|
||||
/// </summary>
|
||||
/// <param name="operateId"></param>
|
||||
public void Sync(List<string> sourcBilNos, bool isSuccess, int operateId, string remark)
|
||||
public void SyncSuccess(string sourcNos, int operateId)
|
||||
{
|
||||
SuccessSyncFail.AddRange(sourcBilNos);
|
||||
SuccessSyncFail.Distinct();
|
||||
this.SuccessSync = isSuccess;
|
||||
this.SuccessSyncFail.Remove(sourcNos);
|
||||
this.SuccessSync = true;
|
||||
this.Remark = "";
|
||||
this.OperateId = operateId;
|
||||
this.SyncTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 同步金蝶(失败)
|
||||
/// </summary>
|
||||
/// <param name="operateId"></param>
|
||||
public void SyncFail(string remark,int operateId)
|
||||
{
|
||||
this.SuccessSync = false;
|
||||
this.Remark = remark;
|
||||
this.OperateId = operateId;
|
||||
this.SyncTime = DateTime.Now;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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 _erpService.Push(new Core.Dto.Erp.ErpPushDto() { });
|
||||
entity.Sync(new List<string>(), res.IsSuccess, loginInfo.UserInfo.StaffId, res.Message);
|
||||
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