调整监测金蝶删单

This commit is contained in:
18942506660
2024-08-07 15:20:25 +08:00
parent 1a91e4805a
commit 6239a1e54e
19 changed files with 148 additions and 33 deletions

View File

@@ -157,9 +157,7 @@ namespace WMS.Web.Api.Controllers
//2.同步金蝶 //2.同步金蝶
await _inStockTaskService.Sysn(sourcesBillNos); await _inStockTaskService.Sysn(sourcesBillNos);
////再刷新 ////再刷新
await _inStockTaskService.Sysn(null); return await _inStockTaskService.Sysn(null);
//验证金蝶是否有删单//默认拉去8个小时以内的
return await _inStockTaskService.ErpDel(DateTime.Now.AddHours(-8));
} }
/// <summary> /// <summary>

View File

@@ -269,9 +269,7 @@ namespace WMS.Web.Api.Controllers
//先刷新选中的数据 //先刷新选中的数据
await _outStockTaskService.Sync(res.Select(s => s.BillNo).ToList()); await _outStockTaskService.Sync(res.Select(s => s.BillNo).ToList());
//再刷新3天内所有的 //再刷新3天内所有的
await _outStockTaskService.Sync(null, begin); return await _outStockTaskService.Sync(null, begin);
//验证金蝶是否有删单
return await _outStockTaskService.ErpDel(DateTime.Now.AddHours(-8));
} }
/// <summary> /// <summary>
/// 出库任务单详情 /// 出库任务单详情

View File

@@ -142,6 +142,20 @@ namespace WMS.Web.Api.Controllers
return ""; return "";
} }
/// <summary>
/// 手动同步金蝶删单信息
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("RefreshErpDelete")]
public async Task<string> RefreshErpDelete()
{
if (!_env.IsDevelopment()) return "";
await _inStockTaskService.ErpDel();
await _outStockTaskService.ErpDel();
return "";
}
[HttpGet] [HttpGet]
[Route("tf")] [Route("tf")]
public async Task<string> TestTF() public async Task<string> TestTF()

View File

@@ -88,7 +88,7 @@
"JobStartExpreAmount": "0 50 23 * * ?", "JobStartExpreAmount": "0 50 23 * * ?",
"JobStartExpreSend": "0 0 12,16,20 * * ?", "JobStartExpreSend": "0 0 12,16,20 * * ?",
"JobStartExpreMaterial": "0 30 23 * * ?", "JobStartExpreMaterial": "0 30 23 * * ?",
"JobStartErpDelete": "0 5 8/12/16/20 * * ?",
//a.是否启用集群:键和值 //a.是否启用集群:键和值
"JobStoreClusteredKey": "quartz.jobStore.clustered", "JobStoreClusteredKey": "quartz.jobStore.clustered",
"JobStoreClusteredValue": true, "JobStoreClusteredValue": true,

View File

@@ -792,6 +792,12 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Api.Controllers.TestController.RefreshErpDelete">
<summary>
手动同步金蝶删单信息
</summary>
<returns></returns>
</member>
<member name="M:WMS.Web.Api.Controllers.TestController.GetMaterial(System.Collections.Generic.List{System.Int32})"> <member name="M:WMS.Web.Api.Controllers.TestController.GetMaterial(System.Collections.Generic.List{System.Int32})">
<summary> <summary>
根据物料Id获取物料编码 根据物料Id获取物料编码

View File

@@ -3165,7 +3165,7 @@
<param name="isTransaction"></param> <param name="isTransaction"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetEntityList(System.DateTime)"> <member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetEntityListByStatus">
查询实体集合 查询实体集合
</member> </member>
<member name="T:WMS.Web.Domain.Infrastructure.IInventoryDetailsRepositories"> <member name="T:WMS.Web.Domain.Infrastructure.IInventoryDetailsRepositories">
@@ -3338,7 +3338,7 @@
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.Collections.Generic.List{System.Int32})"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.Collections.Generic.List{System.Int32})">
查询实体集合 查询实体集合
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityList(System.DateTime)"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityListByStatus">
查询实体集合 查询实体集合
</member> </member>
<member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityListByDetailIds(System.Collections.Generic.List{System.Int32})"> <member name="M:WMS.Web.Domain.Infrastructure.IOutStockTaskRepositories.GetEntityListByDetailIds(System.Collections.Generic.List{System.Int32})">
@@ -3744,7 +3744,7 @@
<param name="billNos"></param> <param name="billNos"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.IService.IInStockTaskService.ErpDel(System.DateTime)"> <member name="M:WMS.Web.Domain.IService.IInStockTaskService.ErpDel">
<summary> <summary>
金蝶删单后这边单据作废 金蝶删单后这边单据作废
</summary> </summary>
@@ -4341,7 +4341,7 @@
<param name="begin"></param> <param name="begin"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.ErpDel(System.DateTime)"> <member name="M:WMS.Web.Domain.IService.Public.IOutStockTaskService.ErpDel">
<summary> <summary>
金蝶删单后这边单据作废 金蝶删单后这边单据作废
</summary> </summary>
@@ -4785,6 +4785,11 @@
同步新物料执行cron表达式每天2330整点同步 同步新物料执行cron表达式每天2330整点同步
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Domain.Options.QuartzJobOptions.JobStartErpDelete">
<summary>
监测金蝶删单
</summary>
</member>
<member name="P:WMS.Web.Domain.Options.QuartzJobOptions.JobStoreClusteredKey"> <member name="P:WMS.Web.Domain.Options.QuartzJobOptions.JobStoreClusteredKey">
<summary> <summary>
是否启用集群:键 是否启用集群:键
@@ -4897,6 +4902,18 @@
<param name="context"></param> <param name="context"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:WMS.Web.Domain.QuartzJob.ErpDeleteQuartzJob">
<summary>
监测金蝶删单
</summary>
</member>
<member name="M:WMS.Web.Domain.QuartzJob.ErpDeleteQuartzJob.Execute(Quartz.IJobExecutionContext)">
<summary>
执行方法
</summary>
<param name="context"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.QuartzJob.InStockOrderQuartzJob"> <member name="T:WMS.Web.Domain.QuartzJob.InStockOrderQuartzJob">
<summary> <summary>
erp入库任务单-获取定时任务 erp入库任务单-获取定时任务
@@ -5468,7 +5485,7 @@
<returns></returns> <returns></returns>
<exception cref="T:System.NotImplementedException"></exception> <exception cref="T:System.NotImplementedException"></exception>
</member> </member>
<member name="M:WMS.Web.Domain.Services.InStockTaskService.ErpDel(System.DateTime)"> <member name="M:WMS.Web.Domain.Services.InStockTaskService.ErpDel">
<summary> <summary>
金蝶删单后wms单据作废 金蝶删单后wms单据作废
</summary> </summary>
@@ -5678,7 +5695,7 @@
<param name="dto"></param> <param name="dto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:WMS.Web.Domain.Services.OutStockTaskService.ErpDel(System.DateTime)"> <member name="M:WMS.Web.Domain.Services.OutStockTaskService.ErpDel">
<summary> <summary>
金蝶删单后wms单据作废 金蝶删单后wms单据作废
</summary> </summary>

View File

@@ -70,7 +70,7 @@ namespace WMS.Web.Domain.IService
/// 金蝶删单后这边单据作废 /// 金蝶删单后这边单据作废
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<Result> ErpDel(DateTime begin); Task<Result> ErpDel();
/// <summary> /// <summary>
/// 作废 /// 作废
/// </summary> /// </summary>

View File

@@ -64,7 +64,7 @@ namespace WMS.Web.Domain.IService.Public
/// 金蝶删单后这边单据作废 /// 金蝶删单后这边单据作废
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<Result> ErpDel(DateTime begin); Task<Result> ErpDel();
/// <summary> /// <summary>
/// 查询出库任务单详情 /// 查询出库任务单详情
/// </summary> /// </summary>

View File

@@ -149,6 +149,6 @@ namespace WMS.Web.Domain.Infrastructure
/// <returns></returns> /// <returns></returns>
Task<InStockTask> Update(InStockTask entity, bool isTransaction = true); Task<InStockTask> Update(InStockTask entity, bool isTransaction = true);
/// 查询实体集合 /// 查询实体集合
Task<List<InStockTask>> GetEntityList(DateTime begin); Task<List<InStockTask>> GetEntityListByStatus();
} }
} }

View File

@@ -23,7 +23,7 @@ namespace WMS.Web.Domain.Infrastructure
/// 查询实体集合 /// 查询实体集合
Task<List<OutStockTask>> GetEntityList(List<int> ids); Task<List<OutStockTask>> GetEntityList(List<int> ids);
/// 查询实体集合 /// 查询实体集合
Task<List<OutStockTask>> GetEntityList(DateTime begin); Task<List<OutStockTask>> GetEntityListByStatus();
/// 查询实体集合(明细Id) /// 查询实体集合(明细Id)
Task<List<OutStockTask>> GetEntityListByDetailIds(List<int> ids); Task<List<OutStockTask>> GetEntityListByDetailIds(List<int> ids);
/// <summary> /// <summary>

View File

@@ -99,7 +99,10 @@ namespace WMS.Web.Domain.Options
/// 同步新物料执行cron表达式每天2330整点同步 /// 同步新物料执行cron表达式每天2330整点同步
/// </summary> /// </summary>
public string JobStartExpreMaterial { get; set; } public string JobStartExpreMaterial { get; set; }
/// <summary>
/// 监测金蝶删单
/// </summary>
public string JobStartErpDelete { get; set; }
/// <summary> /// <summary>
/// 是否启用集群:键 /// 是否启用集群:键
/// </summary> /// </summary>

View File

@@ -0,0 +1,71 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Quartz;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService;
using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob
{
/// <summary>
/// 监测金蝶删单
/// </summary>
public class ErpDeleteQuartzJob : IJob
{
private readonly ILogger<OutStockOrderQuartzJob> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly AppOptions _options;
private readonly IOutStockTaskService _outStockTaskService;
private readonly ITransactionRepositories _transactionRepositories;
private readonly IInStockTaskService _inStockTaskService;
public ErpDeleteQuartzJob(ILogger<OutStockOrderQuartzJob> logger,
IServiceScopeFactory serviceScopeFactory,
IOptions<AppOptions> options,
IOutStockTaskService outStockTaskService,
ITransactionRepositories transactionRepositories,
IInStockTaskService inStockTaskService)
{
this._logger = logger;
_serviceScopeFactory = serviceScopeFactory;
this._options = options?.Value;
_outStockTaskService = outStockTaskService;
_transactionRepositories = transactionRepositories;
_inStockTaskService = inStockTaskService;
}
/// <summary>
/// 执行方法
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task Execute(IJobExecutionContext context)
{
try
{
_logger.LogInformation($"出库单-监测金蝶删单:执行开始时间->{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
//验证金蝶是否有删单
await _outStockTaskService.ErpDel();
_logger.LogInformation($"出库单-监测金蝶删单:执行结束时间->{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
//验证金蝶是否有删单
await _inStockTaskService.ErpDel();
_logger.LogInformation($"入库单-监测金蝶删单:执行结束时间->{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
}
catch (Exception ex)
{
_logger.LogInformation($"监测金蝶删单:定时任务执行失败->{ex.Message}");
}
}
}
}

View File

@@ -64,9 +64,6 @@ namespace WMS.Web.Domain.QuartzJob
//3.记录:结束时间 //3.记录:结束时间
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}");
//验证金蝶是否有删单//默认拉去8个小时以内的
await _inStockTaskService.ErpDel(DateTime.Now.AddHours(-8));
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -54,9 +54,6 @@ namespace WMS.Web.Domain.QuartzJob
//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($"出库单-同步金蝶出库单数据:执行结束时间->{enddatetime}"); _logger.LogInformation($"出库单-同步金蝶出库单数据:执行结束时间->{enddatetime}");
//验证金蝶是否有删单
await _outStockTaskService.ErpDel(begin);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -706,9 +706,9 @@ namespace WMS.Web.Domain.Services
/// <param name="begin"></param> /// <param name="begin"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<Result> ErpDel(DateTime begin) public async Task<Result> ErpDel()
{ {
var list = await _inStockTaskRepositories.GetEntityList(begin); var list = await _inStockTaskRepositories.GetEntityListByStatus();
var result = await GetData(list); var result = await GetData(list);
if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status);
var erp_list = result.Data; var erp_list = result.Data;

View File

@@ -646,9 +646,9 @@ namespace WMS.Web.Domain.Services
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
public async Task<Result> ErpDel(DateTime begin) public async Task<Result> ErpDel()
{ {
var list = await _outStockTaskRepositories.GetEntityList(begin); var list = await _outStockTaskRepositories.GetEntityListByStatus();
var result = await GetData(list); var result = await GetData(list);
if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status);
var erp_list = result.Data; var erp_list = result.Data;

View File

@@ -285,6 +285,18 @@ namespace WMS.Web.Repositories.DependencyInjection
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5])) //.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
.WithDescription("MaterialsQuartzJobTriggerDecs")); .WithDescription("MaterialsQuartzJobTriggerDecs"));
#endregion #endregion
#region
var jobKey_erpdelete = new JobKey("ErpDeleteQuartzJob", options.QuartzJobValue);
q.AddJob<ErpDeleteQuartzJob>(jobKey_erpdelete, j => j.WithDescription("ErpDeleteQuartzJob"));
q.AddTrigger(t => t
.WithIdentity("ErpDeleteQuartzJobTrigger")
.ForJob(jobKey_erpdelete)
.StartNow()
.WithCronSchedule(options.JobStartErpDelete)
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
.WithDescription("ErpDeleteQuartzJobTriggerDecs"));
#endregion
}); });
//.net core核心托管-添加Quartz服务器 //.net core核心托管-添加Quartz服务器
Services.AddQuartzServer(options => Services.AddQuartzServer(options =>

View File

@@ -829,11 +829,13 @@ namespace WMS.Web.Repositories
return (list, total); return (list, total);
} }
public async Task<List<InStockTask>> GetEntityList(DateTime begin) public async Task<List<InStockTask>> GetEntityListByStatus()
{ {
var res = await _context.InStockTask var res = await _context.InStockTask
.Include(s => s.Details) .Include(s => s.Details)
.Where(f => f.WmsUpdateTime >= begin) .Where(f => f.Status == InstockStatus.Wait
|| f.Status == InstockStatus.Part
|| f.Status == InstockStatus.WaitInStock)
.ToListAsync(); .ToListAsync();
return res; return res;

View File

@@ -567,11 +567,11 @@ namespace WMS.Web.Repositories
return entitys.Clone(); return entitys.Clone();
} }
public async Task<List<OutStockTask>> GetEntityList(DateTime begin) public async Task<List<OutStockTask>> GetEntityListByStatus()
{ {
var res = await _context.OutStockTask var res = await _context.OutStockTask
.Include(s => s.Details).ThenInclude(s => s.ErpDetails) .Include(s => s.Details).ThenInclude(s => s.ErpDetails)
.Where(f => f.WmsUpdateTime >= begin) .Where(f => f.Status==OutStockStatus.Wait || f.Status == OutStockStatus.Part)
.ToListAsync(); .ToListAsync();
return res.Clone(); return res.Clone();