调整同步接口

This commit is contained in:
18942506660
2023-11-09 11:14:40 +08:00
parent 3687bbb7d1
commit bb77363dad
5 changed files with 130 additions and 26 deletions

View File

@@ -1823,7 +1823,7 @@
出库任务 出库任务
</summary> </summary>
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})"> <member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.BillQueryForDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary> <summary>
采购发货通知单 采购发货通知单
</summary> </summary>
@@ -1854,6 +1854,13 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.Ssyn(System.Collections.Generic.List{System.String})">
<summary>
同步金蝶数据 不传源订单号则更新所有
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.IService.Public.ISingleDataService"> <member name="T:WMS.Web.Domain.IService.Public.ISingleDataService">
<summary> <summary>
单点数据返回服务接口 单点数据返回服务接口
@@ -2438,7 +2445,7 @@
<param name="isTransaction"></param> <param name="isTransaction"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.SsynDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})"> <member name="M:WMS.Web.Domain.Services.OutStockTaskService.BillQueryForDeliveryNoticeOutStock(System.Boolean,System.Collections.Generic.List{System.String})">
<summary> <summary>
发货通知单同步数据 发货通知单同步数据
</summary> </summary>
@@ -2477,6 +2484,13 @@
<param name="sourceBillNos"></param> <param name="sourceBillNos"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.Ssyn(System.Collections.Generic.List{System.String})">
<summary>
同步金蝶数据 不传源订单号则更新所有
</summary>
<param name="sourceBillNos"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Services.Public.ErpBasicDataExtendService"> <member name="T:WMS.Web.Domain.Services.Public.ErpBasicDataExtendService">
<summary> <summary>
erp基础数据扩展服务 erp基础数据扩展服务

View File

@@ -19,7 +19,7 @@ namespace WMS.Web.Domain.IService.Public
/// </summary> /// </summary>
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction,List<string> sourceBillNos = null); Task<Result> BillQueryForDeliveryNoticeOutStock(bool isTransaction,List<string> sourceBillNos = null);
/// <summary> /// <summary>
/// erp:单据查询-直接调拨出库 /// erp:单据查询-直接调拨出库
/// </summary> /// </summary>
@@ -44,5 +44,11 @@ namespace WMS.Web.Domain.IService.Public
Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo); Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo);
//出库任务作废 //出库任务作废
Task<Result> merge(OperateRequest dto, LoginInDto loginInfo); Task<Result> merge(OperateRequest dto, LoginInDto loginInfo);
/// <summary>
/// 同步金蝶数据 不传源订单号则更新所有
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
Task<Result> Ssyn(List<string> sourceBillNos = null);
} }
} }

View File

@@ -14,7 +14,7 @@ using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob namespace WMS.Web.Domain.QuartzJob
{ {
public class OutStockOrderQuartzJob : IJob public class OutStockOrderQuartzJob : IJob
{ {
private readonly ILogger<OutStockOrderQuartzJob> _logger; private readonly ILogger<OutStockOrderQuartzJob> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IServiceScopeFactory _serviceScopeFactory;
@@ -44,28 +44,11 @@ namespace WMS.Web.Domain.QuartzJob
{ {
try try
{ {
//1.事务
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isTransaction = false;
//2.记录:开始时间 //2.记录:开始时间
var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}"); _logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}");
//3.同步数据 //3.同步数据
var result = await _outStockTaskService.SsynDeliveryNoticeOutStock(isTransaction); var result = await _outStockTaskService.Ssyn(null);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForTransferDirectOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForTransferOutOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForMisDeliveryOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForAssembledAppOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
//4.提交事务
var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
//5.记录:结束时间 //5.记录:结束时间
var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}"); _logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}");

View File

@@ -28,15 +28,17 @@ namespace WMS.Web.Domain.Services
public readonly IBasicsRepositories _transactionRepositories; public readonly IBasicsRepositories _transactionRepositories;
private readonly IOutStockRepositories _outStockRepositories; private readonly IOutStockRepositories _outStockRepositories;
private readonly IOutStockTaskRepositories _outStockTaskRepositories; private readonly IOutStockTaskRepositories _outStockTaskRepositories;
private readonly IOutStockTaskService _outStockTaskService;
public OutStockService(IMapper mapper, ILoginService loginService, public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories, IBasicsRepositories transactionRepositories,
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories) IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories, IOutStockTaskService outStockTaskService)
{ {
_mapper = mapper; _mapper = mapper;
_loginService = loginService; _loginService = loginService;
_transactionRepositories = transactionRepositories; _transactionRepositories = transactionRepositories;
_outStockRepositories = outStockRepositories; _outStockRepositories = outStockRepositories;
_outStockTaskRepositories = outStockTaskRepositories; _outStockTaskRepositories = outStockTaskRepositories;
_outStockTaskService = outStockTaskService;
} }
/// <summary> /// <summary>
/// 出库单 /// 出库单
@@ -48,6 +50,11 @@ namespace WMS.Web.Domain.Services
{ {
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId); var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
//OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId); //OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
//同步该订单最新数据到wms系统
List<string> nos = new List<string>();
nos.Add(outStockTask.SourceBillNo);
var res = await _outStockTaskService.Ssyn(nos);
if (!res.IsSuccess) return Result.ReSuccess();
OutStock entity = new OutStock(); OutStock entity = new OutStock();
entity.Create(loginInfo.UserInfo.StaffId, outStockTask); entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
@@ -56,7 +63,7 @@ namespace WMS.Web.Domain.Services
//任务单明细 //任务单明细
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId); var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
if (tDetail == null) continue; if (tDetail == null) continue;
var res = outStockTask.OutStock(d.MaterialId, d.Qty); res = outStockTask.OutStock(d.MaterialId, d.Qty);
if (!res.IsSuccess) return res; if (!res.IsSuccess) return res;
var outd = _mapper.Map<OutStockDetails>(tDetail); var outd = _mapper.Map<OutStockDetails>(tDetail);

View File

@@ -158,7 +158,7 @@ namespace WMS.Web.Domain.Services
/// </summary> /// </summary>
/// <param name="isTransaction"></param> /// <param name="isTransaction"></param>
/// <returns></returns> /// <returns></returns>
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null) public async Task<Result> BillQueryForDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
{ {
//1.获取金蝶数据:采购订单数据 //1.获取金蝶数据:采购订单数据
var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos); var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
@@ -204,7 +204,7 @@ namespace WMS.Web.Domain.Services
public async Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null) public async Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null)
{ {
List<ErpDeliveryNoticeOutStockResultDto> list = new List<ErpDeliveryNoticeOutStockResultDto>(); List<ErpDeliveryNoticeOutStockResultDto> list = new List<ErpDeliveryNoticeOutStockResultDto>();
var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos); var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos);
if (!erp_result.IsSuccess) if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status); return Result.ReFailure(erp_result.Message, erp_result.Status);
@@ -231,5 +231,99 @@ namespace WMS.Web.Domain.Services
return await this.SsynDate(erp_result.Data.ToList(), isTransaction); return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
} }
/// <summary>
/// 同步金蝶数据 不传源订单号则更新所有
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> Ssyn(List<string> sourceBillNos = null)
{
//1.事务
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
Result result;
//定时任务更新
if (sourceBillNos == null)
{
//更新时间范围内所有
result= await BillQueryForDeliveryNoticeOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForTransferDirectOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForTransferOutOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForAssembledAppOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForMisDeliveryOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
//同步成功后 更新定时开始时间
if (!isRollback)
{
}
//4.提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
//根据指定单号更新
List<string> DeliveryNotice_Nos = new List<string>();
List<string> TransferDirect_Nos = new List<string>();
List<string> TransferOut_Nos = new List<string>();
List<string> AssembledApp_Nos = new List<string>();
List<string> MisDeliveryOut_Nos = new List<string>();
var taskList = await _outStockTaskRepositories.GetListBySourceBillNo(sourceBillNos);
foreach (var entity in taskList)
{
if (entity.Type == OutStockType.Sal)
DeliveryNotice_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Stkdirecttransfers)
TransferDirect_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.StktransferInst)
TransferOut_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Assembled)
AssembledApp_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Miscellaneous)
MisDeliveryOut_Nos.Add(entity.SourceBillNo);
}
if (DeliveryNotice_Nos.Count() > 0)
{
result= await BillQueryForDeliveryNoticeOutStock(false, DeliveryNotice_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (TransferDirect_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, TransferDirect_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (TransferOut_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, TransferOut_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (AssembledApp_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, AssembledApp_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (MisDeliveryOut_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, MisDeliveryOut_Nos);
if (!result.IsSuccess) isRollback = true;
}
//4.提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
} }
} }