修改被删除的意外
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Npoi.Mapper;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -955,52 +957,61 @@ namespace WMS.Web.Domain.Services
|
||||
var sourceBillNos = entity.ErpDetails.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
|
||||
var erp_InStockErpDetails = await sc_inStockRepositories.GetErpDetails(sourceBillNos);
|
||||
|
||||
|
||||
foreach (var det in erpDetails)
|
||||
if (erpDetails.Count == 0)
|
||||
{
|
||||
var erpDto = new ErpPushDto()
|
||||
for (int i = 0; i < entity.ErpDetails.Count; i++)
|
||||
{
|
||||
RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 采购订单下推采购入库单
|
||||
FormId = FormIdParam.PUR_PurchaseOrder.ToString(),
|
||||
TargetFormId = FormIdParam.STK_InStock.ToString(),
|
||||
DetailsId = det.ErpDetailId.ToString(),
|
||||
IsDraftWhenSaveFail = true//是否需要暂存fa
|
||||
//IsDraftWhenSaveFail = false//是否需要暂存
|
||||
};
|
||||
|
||||
var erp_InStockBillNos = erp_InStockErpDetails.Where(x => x.SourceBillNo == det.SourceBillNo).Select(x => x.ErpSyncBillNo).ToList();
|
||||
List<ErpPurchaseInStockDetailsDto> details = new List<ErpPurchaseInStockDetailsDto>();
|
||||
var resPurchaseInStockDetails_result = await sc_erpService.BillQueryForPurchaseInStockBy(det.ErpDetailId.ToString(), erp_InStockBillNos);
|
||||
if (resPurchaseInStockDetails_result.IsSuccess)
|
||||
details = resPurchaseInStockDetails_result.Data;
|
||||
|
||||
//金蝶已有的单;进行金蝶不同操作处理:保存,提交,审核
|
||||
ErpPurchaseInStockDetailsDto currentDet = null;
|
||||
if (det.ErpInStockDetailId.HasValue)
|
||||
currentDet = details.Where(x => x.DetailId == det.ErpInStockDetailId.Value.ToString()).FirstOrDefault();
|
||||
if (currentDet != null)
|
||||
{
|
||||
var res = await this.QueryFirst(currentDet, erpDto.TargetFormId, entity.BillNo, det, sc_erpService);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
entity.SyncFail("失败,找不到数据,请检查采购订单是否反审核或是否有被删除", entity.ErpDetails[0].ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, SyncStatus.Fail);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var det in erpDetails)
|
||||
{
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories,"pur");
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 采购订单下推采购入库单
|
||||
FormId = FormIdParam.PUR_PurchaseOrder.ToString(),
|
||||
TargetFormId = FormIdParam.STK_InStock.ToString(),
|
||||
DetailsId = det.ErpDetailId.ToString(),
|
||||
IsDraftWhenSaveFail = true//是否需要暂存fa
|
||||
//IsDraftWhenSaveFail = false//是否需要暂存
|
||||
};
|
||||
|
||||
var erp_InStockBillNos = erp_InStockErpDetails.Where(x => x.SourceBillNo == det.SourceBillNo).Select(x => x.ErpSyncBillNo).ToList();
|
||||
List<ErpPurchaseInStockDetailsDto> details = new List<ErpPurchaseInStockDetailsDto>();
|
||||
var resPurchaseInStockDetails_result = await sc_erpService.BillQueryForPurchaseInStockBy(det.ErpDetailId.ToString(), erp_InStockBillNos);
|
||||
if (resPurchaseInStockDetails_result.IsSuccess)
|
||||
details = resPurchaseInStockDetails_result.Data;
|
||||
|
||||
//金蝶已有的单;进行金蝶不同操作处理:保存,提交,审核
|
||||
ErpPurchaseInStockDetailsDto currentDet = null;
|
||||
if (det.ErpInStockDetailId.HasValue)
|
||||
currentDet = details.Where(x => x.DetailId == det.ErpInStockDetailId.Value.ToString()).FirstOrDefault();
|
||||
if (currentDet != null)
|
||||
{
|
||||
var res = await this.QueryFirst(currentDet, erpDto.TargetFormId, entity.BillNo, det, sc_erpService);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
}
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
{
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories, "pur");
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//最好一条一条执行,否则执行失败 但是金蝶那边又同步成功 就会造成数据比价乱
|
||||
var isSuccess = await sc_InStockRepositories.Update(entity, true);
|
||||
@@ -1045,50 +1056,59 @@ namespace WMS.Web.Domain.Services
|
||||
var sourceBillNos = entity.ErpDetails.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
|
||||
var erp_InStockErpDetails = await sc_inStockRepositories.GetErpDetails(sourceBillNos);
|
||||
|
||||
|
||||
foreach (var det in erpDetails)
|
||||
if (erpDetails.Count == 0)
|
||||
{
|
||||
var erpDto = new ErpPushDto()
|
||||
for (int i = 0; i < entity.ErpDetails.Count; i++)
|
||||
{
|
||||
// RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 汇报单下推汇报入库单
|
||||
RuleId = "PRD_MORPT2INSTOCK",//转换规则内码 汇报单下推汇报入库单
|
||||
FormId = FormIdParam.PRD_MORPT.ToString(),
|
||||
TargetFormId = FormIdParam.PRD_INSTOCK.ToString(),
|
||||
DetailsId = det.ErpDetailId.ToString(),
|
||||
IsDraftWhenSaveFail = true//是否需要暂存
|
||||
//IsDraftWhenSaveFail = false//是否需要暂存
|
||||
};
|
||||
|
||||
var erp_InStockBillNos = erp_InStockErpDetails.Where(x => x.SourceBillNo == det.SourceBillNo).Select(x => x.ErpSyncBillNo).ToList();
|
||||
List<ErpPurchaseInStockDetailsDto> details = new List<ErpPurchaseInStockDetailsDto>();
|
||||
var resPurchaseInStockDetails_result = await sc_erpService.BillQueryForProduceInStockBy(det.ErpDetailId.ToString(), erp_InStockBillNos);
|
||||
if (resPurchaseInStockDetails_result.IsSuccess)
|
||||
details = resPurchaseInStockDetails_result.Data;
|
||||
|
||||
//金蝶已有的单;进行金蝶不同操作处理:保存,提交,审核
|
||||
ErpPurchaseInStockDetailsDto currentDet = null;
|
||||
if (det.ErpInStockDetailId.HasValue)
|
||||
currentDet = details.Where(x => x.DetailId == det.ErpInStockDetailId.Value.ToString()).FirstOrDefault();
|
||||
if (currentDet != null)
|
||||
{
|
||||
var res = await this.QueryFirst(currentDet, erpDto.TargetFormId, entity.BillNo, det, sc_erpService);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
entity.SyncFail("失败,找不到数据,请检查生产汇报单是否反审核或是否有被删除", entity.ErpDetails[0].ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, SyncStatus.Fail);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var det in erpDetails)
|
||||
{
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories, "prd");
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
// RuleId = "PUR_PurchaseOrder-STK_InStock",//转换规则内码 汇报单下推汇报入库单
|
||||
RuleId = "PRD_MORPT2INSTOCK",//转换规则内码 汇报单下推汇报入库单
|
||||
FormId = FormIdParam.PRD_MORPT.ToString(),
|
||||
TargetFormId = FormIdParam.PRD_INSTOCK.ToString(),
|
||||
DetailsId = det.ErpDetailId.ToString(),
|
||||
IsDraftWhenSaveFail = true//是否需要暂存
|
||||
//IsDraftWhenSaveFail = false//是否需要暂存
|
||||
};
|
||||
|
||||
var erp_InStockBillNos = erp_InStockErpDetails.Where(x => x.SourceBillNo == det.SourceBillNo).Select(x => x.ErpSyncBillNo).ToList();
|
||||
List<ErpPurchaseInStockDetailsDto> details = new List<ErpPurchaseInStockDetailsDto>();
|
||||
var resPurchaseInStockDetails_result = await sc_erpService.BillQueryForProduceInStockBy(det.ErpDetailId.ToString(), erp_InStockBillNos);
|
||||
if (resPurchaseInStockDetails_result.IsSuccess)
|
||||
details = resPurchaseInStockDetails_result.Data;
|
||||
|
||||
//金蝶已有的单;进行金蝶不同操作处理:保存,提交,审核
|
||||
ErpPurchaseInStockDetailsDto currentDet = null;
|
||||
if (det.ErpInStockDetailId.HasValue)
|
||||
currentDet = details.Where(x => x.DetailId == det.ErpInStockDetailId.Value.ToString()).FirstOrDefault();
|
||||
if (currentDet != null)
|
||||
{
|
||||
var res = await this.QueryFirst(currentDet, erpDto.TargetFormId, entity.BillNo, det, sc_erpService);
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
}
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
{
|
||||
//下推金蝶
|
||||
var res = await this.Push(erpDto, det, entity.BillNo, sc_erpService, sc_inStockRepositories, "prd");
|
||||
if (res.result.IsSuccess)
|
||||
entity.SyncSuccess(det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.erpBillNo);
|
||||
else
|
||||
entity.SyncFail(res.result.Message, det.ErpDetailId, loginInfo?.UserInfo?.StaffId ?? 0, res.syncStatus);
|
||||
//记录金蝶入库单明细ID
|
||||
det.RecodErpInStockDetailId(res.instockDetailId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user