采购入库同步金蝶-一直同步中的问题解决

This commit is contained in:
tongfei
2024-04-10 14:28:12 +08:00
parent a03fff91a9
commit e24ce0a3ef
3 changed files with 53 additions and 25 deletions

View File

@@ -788,6 +788,13 @@
<param name="operateId"></param> <param name="operateId"></param>
<param name="syncStatus"></param> <param name="syncStatus"></param>
</member> </member>
<member name="M:WMS.Web.Domain.Entitys.InStock.SyncFailAll(System.String,System.Int32)">
<summary>
全部失败
</summary>
<param name="remark"></param>
<param name="operateId"></param>
</member>
<member name="M:WMS.Web.Domain.Entitys.InStock.RepeatSync"> <member name="M:WMS.Web.Domain.Entitys.InStock.RepeatSync">
<summary> <summary>
重传 重传

View File

@@ -190,6 +190,19 @@ namespace WMS.Web.Domain.Entitys
this.SyncTime = DateTime.Now; this.SyncTime = DateTime.Now;
} }
/// <summary>
/// 全部失败
/// </summary>
/// <param name="remark"></param>
/// <param name="operateId"></param>
public void SyncFailAll(string remark, int operateId)
{
this.SuccessSync = SyncStatus.Fail;
this.Remark = remark;
this.OperateId = operateId;
this.SyncTime = DateTime.Now;
}
/// <summary> /// <summary>
/// 重传 /// 重传
/// </summary> /// </summary>

View File

@@ -200,7 +200,7 @@ namespace WMS.Web.Domain.Services
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_No_Task_Data); return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_No_Task_Data);
//1.先判断:箱号已经绑定了入库任务单中;备注:其它单据收的提示 //1.先判断:箱号已经绑定了入库任务单中;备注:其它单据收的提示
var tast_box = await _inStockTaskBoxRepositories.GetBy(dto.BoxBillNo,dto.TaskId); var tast_box = await _inStockTaskBoxRepositories.GetBy(dto.BoxBillNo, dto.TaskId);
if (tast_box == null) if (tast_box == null)
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data); return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data);
@@ -316,17 +316,17 @@ namespace WMS.Web.Domain.Services
//1.获取最新的erp明细信息 //1.获取最新的erp明细信息
var billNo_new = await _inStockRepositories.GetLastBillNo(); var billNo_new = await _inStockRepositories.GetLastBillNo();
//erp明细生成批号 //erp明细生成批号
int new_firstBillNo = billNo_new == null ? 0 : (billNo_new.FirstBillNo.HasValue? billNo_new.FirstBillNo.Value:0); int new_firstBillNo = billNo_new == null ? 0 : (billNo_new.FirstBillNo.HasValue ? billNo_new.FirstBillNo.Value : 0);
int new_lastBillNo = billNo_new == null ? 0 : (billNo_new.LastBillNo.HasValue? billNo_new.LastBillNo.Value:0); int new_lastBillNo = billNo_new == null ? 0 : (billNo_new.LastBillNo.HasValue ? billNo_new.LastBillNo.Value : 0);
entity.ErpDetails.ForEach(x => entity.ErpDetails.ForEach(x =>
{ {
//物料必须是启动了批号管理才生成批号 //物料必须是启动了批号管理才生成批号
var mat= materials.Where(m => m.MaterialNumber == x.MaterialNumber && m.OrgCode == entity.OrgCode && m.IsBatchManage==true).FirstOrDefault(); var mat = materials.Where(m => m.MaterialNumber == x.MaterialNumber && m.OrgCode == entity.OrgCode && m.IsBatchManage == true).FirstOrDefault();
if (mat != null) if (mat != null)
{ {
x.GenerateBatchBillNo(new_firstBillNo, new_lastBillNo, mat.IsBatchManage); x.GenerateBatchBillNo(new_firstBillNo, new_lastBillNo, mat.IsBatchManage);
new_firstBillNo = x.FirstBillNo??0; new_firstBillNo = x.FirstBillNo ?? 0;
new_lastBillNo = x.LastBillNo??0; new_lastBillNo = x.LastBillNo ?? 0;
} }
}); });
@@ -584,7 +584,7 @@ namespace WMS.Web.Domain.Services
foreach (var item in dto.Boxs) foreach (var item in dto.Boxs)
{ {
var taskBox = _mapper.Map<InStockTaskBox>(item); var taskBox = _mapper.Map<InStockTaskBox>(item);
taskBox.TaskId = entity.Id; taskBox.TaskId = entity.Id;
taskBox.Receiver(staffId); taskBox.Receiver(staffId);
var current_dto_box_dets = boxEntitys.Where(x => x.Id == item.BoxId).SelectMany(x => x.Details).ToList(); var current_dto_box_dets = boxEntitys.Where(x => x.Id == item.BoxId).SelectMany(x => x.Details).ToList();
taskBox.Details = _mapper.Map<List<InStockTaskBoxDetails>>(current_dto_box_dets); taskBox.Details = _mapper.Map<List<InStockTaskBoxDetails>>(current_dto_box_dets);
@@ -748,24 +748,32 @@ namespace WMS.Web.Domain.Services
erpDetails.Add(item); erpDetails.Add(item);
} }
foreach (var s in erpDetails) if (erpDetails.Count != 0)
{ {
var erp_details = entity.ErpDetails foreach (var s in erpDetails)
.Where(w => w.SourceBillNo.Equals(s)).Select(s => s.ErpDetailId).ToList();
var erpDto = new ErpPushDto()
{ {
RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 采购订单下推采购入库单 var erp_details = entity.ErpDetails
FormId = FormIdParam.PUR_PurchaseOrder.ToString(), .Where(w => w.SourceBillNo.Equals(s)).Select(s => s.ErpDetailId).ToList();
TargetFormId = FormIdParam.STK_InStock.ToString(), var erpDto = new ErpPushDto()
DetailsId = s.ErpDetailId.ToString(), {
IsDraftWhenSaveFail = true//是否需要暂存 RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 采购订单下推采购入库单
}; FormId = FormIdParam.PUR_PurchaseOrder.ToString(),
//下推金蝶 TargetFormId = FormIdParam.STK_InStock.ToString(),
var res = await this.Push(erpDto, s, entity.BillNo, sc_erpService, sc_inStockRepositories); DetailsId = s.ErpDetailId.ToString(),
if (res.result.IsSuccess) IsDraftWhenSaveFail = true//是否需要暂存
entity.SyncSuccess(s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo); };
else //下推金蝶
entity.SyncFail(res.result.Message, s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus); var res = await this.Push(erpDto, s, entity.BillNo, sc_erpService, sc_inStockRepositories);
if (res.result.IsSuccess)
entity.SyncSuccess(s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
else
entity.SyncFail(res.result.Message, s.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
}
}
else
{
erpDetails_tags.ForEach(x => { x.SuccessSync = SyncStatus.Fail; });
entity.SyncFailAll("同步金蝶失败,金蝶存在已审核的采购入库单", loginInfo?.UserInfo?.StaffId ?? 0);
} }
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱 //最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
var isSuccess = await sc_InStockRepositories.Update(entity, true); var isSuccess = await sc_InStockRepositories.Update(entity, true);
@@ -824,7 +832,7 @@ namespace WMS.Web.Domain.Services
purchaseInStock.Details[0].Lot = new ErpLotSaveDto(); purchaseInStock.Details[0].Lot = new ErpLotSaveDto();
purchaseInStock.Details[0].Lot.Number = erpDetail.BatchBillNo; purchaseInStock.Details[0].Lot.Number = erpDetail.BatchBillNo;
} }
_logger.LogInformation($"入库单->下推成功 开始保存 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 数据: {JsonConvert.SerializeObject(purchaseInStock)}"); _logger.LogInformation($"入库单->下推成功 开始保存 单号:{billNo} erp明细Id:{erpDetail.ErpDetailId} 数据: {JsonConvert.SerializeObject(purchaseInStock)}");
var res_s = await sc_erpService.Save<ErpPurchaseInStockSaveDto>(purchaseInStock, formId); var res_s = await sc_erpService.Save<ErpPurchaseInStockSaveDto>(purchaseInStock, formId);
if (!res_s.IsSuccess) if (!res_s.IsSuccess)