diff --git a/src/WMS.Web.Api/Controllers/InStockTaskController.cs b/src/WMS.Web.Api/Controllers/InStockTaskController.cs index e17d82a9..8c158e2f 100644 --- a/src/WMS.Web.Api/Controllers/InStockTaskController.cs +++ b/src/WMS.Web.Api/Controllers/InStockTaskController.cs @@ -157,9 +157,7 @@ namespace WMS.Web.Api.Controllers //2.同步金蝶 await _inStockTaskService.Sysn(sourcesBillNos); ////再刷新 - await _inStockTaskService.Sysn(null); - //验证金蝶是否有删单//默认拉去8个小时以内的 - return await _inStockTaskService.ErpDel(DateTime.Now.AddHours(-8)); + return await _inStockTaskService.Sysn(null); } /// diff --git a/src/WMS.Web.Api/Controllers/OutStockTaskController.cs b/src/WMS.Web.Api/Controllers/OutStockTaskController.cs index 3ac91f9f..edb4bc76 100644 --- a/src/WMS.Web.Api/Controllers/OutStockTaskController.cs +++ b/src/WMS.Web.Api/Controllers/OutStockTaskController.cs @@ -269,9 +269,7 @@ namespace WMS.Web.Api.Controllers //先刷新选中的数据 await _outStockTaskService.Sync(res.Select(s => s.BillNo).ToList()); //再刷新3天内所有的 - await _outStockTaskService.Sync(null, begin); - //验证金蝶是否有删单 - return await _outStockTaskService.ErpDel(DateTime.Now.AddHours(-8)); + return await _outStockTaskService.Sync(null, begin); } /// /// 出库任务单详情 diff --git a/src/WMS.Web.Api/Controllers/TestController.cs b/src/WMS.Web.Api/Controllers/TestController.cs index 5212b8c6..6182f971 100644 --- a/src/WMS.Web.Api/Controllers/TestController.cs +++ b/src/WMS.Web.Api/Controllers/TestController.cs @@ -142,6 +142,20 @@ namespace WMS.Web.Api.Controllers return ""; } + /// + /// 手动同步金蝶删单信息 + /// + /// + [HttpGet] + [Route("RefreshErpDelete")] + public async Task RefreshErpDelete() + { + if (!_env.IsDevelopment()) return ""; + await _inStockTaskService.ErpDel(); + await _outStockTaskService.ErpDel(); + return ""; + } + [HttpGet] [Route("tf")] public async Task TestTF() diff --git a/src/WMS.Web.Api/appsettings.json b/src/WMS.Web.Api/appsettings.json index 0368edc6..ec9fdc29 100644 --- a/src/WMS.Web.Api/appsettings.json +++ b/src/WMS.Web.Api/appsettings.json @@ -88,7 +88,7 @@ "JobStartExpreAmount": "0 50 23 * * ?", "JobStartExpreSend": "0 0 12,16,20 * * ?", "JobStartExpreMaterial": "0 30 23 * * ?", - + "JobStartErpDelete": "0 5 8/12/16/20 * * ?", //a.是否启用集群:键和值 "JobStoreClusteredKey": "quartz.jobStore.clustered", "JobStoreClusteredValue": true, diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index e381da6d..3dc39c57 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -792,6 +792,12 @@ + + + 手动同步金蝶删单信息 + + + 根据物料Id获取物料编码 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 96930288..18545ba5 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -3165,7 +3165,7 @@ - + 查询实体集合 @@ -3338,7 +3338,7 @@ 查询实体集合 - + 查询实体集合 @@ -3744,7 +3744,7 @@ - + 金蝶删单后这边单据作废 @@ -4341,7 +4341,7 @@ - + 金蝶删单后这边单据作废 @@ -4785,6 +4785,11 @@ 同步新物料执行cron表达式:每天23:30整点同步 + + + 监测金蝶删单 + + 是否启用集群:键 @@ -4897,6 +4902,18 @@ + + + 监测金蝶删单 + + + + + 执行方法 + + + + erp入库任务单-获取定时任务 @@ -5468,7 +5485,7 @@ - + 金蝶删单后wms单据作废 @@ -5678,7 +5695,7 @@ - + 金蝶删单后wms单据作废 diff --git a/src/WMS.Web.Domain/IService/IInStockTaskService.cs b/src/WMS.Web.Domain/IService/IInStockTaskService.cs index b46b9490..469eaa4e 100644 --- a/src/WMS.Web.Domain/IService/IInStockTaskService.cs +++ b/src/WMS.Web.Domain/IService/IInStockTaskService.cs @@ -70,7 +70,7 @@ namespace WMS.Web.Domain.IService /// 金蝶删单后这边单据作废 /// /// - Task ErpDel(DateTime begin); + Task ErpDel(); /// /// 作废 /// diff --git a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs index f83af859..8c9e10c8 100644 --- a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs +++ b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs @@ -64,7 +64,7 @@ namespace WMS.Web.Domain.IService.Public /// 金蝶删单后这边单据作废 /// /// - Task ErpDel(DateTime begin); + Task ErpDel(); /// /// 查询出库任务单详情 /// diff --git a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs index 5d6e4140..7fc6f2b9 100644 --- a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs @@ -149,6 +149,6 @@ namespace WMS.Web.Domain.Infrastructure /// Task Update(InStockTask entity, bool isTransaction = true); /// 查询实体集合 - Task> GetEntityList(DateTime begin); + Task> GetEntityListByStatus(); } } diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs index 03a293c6..a3c51c70 100644 --- a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs @@ -23,7 +23,7 @@ namespace WMS.Web.Domain.Infrastructure /// 查询实体集合 Task> GetEntityList(List ids); /// 查询实体集合 - Task> GetEntityList(DateTime begin); + Task> GetEntityListByStatus(); /// 查询实体集合(明细Id) Task> GetEntityListByDetailIds(List ids); /// diff --git a/src/WMS.Web.Domain/Options/QuartzJobOptions.cs b/src/WMS.Web.Domain/Options/QuartzJobOptions.cs index b5d826eb..cb2c89ef 100644 --- a/src/WMS.Web.Domain/Options/QuartzJobOptions.cs +++ b/src/WMS.Web.Domain/Options/QuartzJobOptions.cs @@ -99,7 +99,10 @@ namespace WMS.Web.Domain.Options /// 同步新物料执行cron表达式:每天23:30整点同步 /// public string JobStartExpreMaterial { get; set; } - + /// + /// 监测金蝶删单 + /// + public string JobStartErpDelete { get; set; } /// /// 是否启用集群:键 /// diff --git a/src/WMS.Web.Domain/QuartzJob/ErpDeleteQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/ErpDeleteQuartzJob.cs new file mode 100644 index 00000000..fc68dc06 --- /dev/null +++ b/src/WMS.Web.Domain/QuartzJob/ErpDeleteQuartzJob.cs @@ -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 +{ + /// + /// 监测金蝶删单 + /// + public class ErpDeleteQuartzJob : IJob + { + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly AppOptions _options; + private readonly IOutStockTaskService _outStockTaskService; + private readonly ITransactionRepositories _transactionRepositories; + private readonly IInStockTaskService _inStockTaskService; + + public ErpDeleteQuartzJob(ILogger logger, + IServiceScopeFactory serviceScopeFactory, + IOptions options, + IOutStockTaskService outStockTaskService, + ITransactionRepositories transactionRepositories, + IInStockTaskService inStockTaskService) + { + this._logger = logger; + _serviceScopeFactory = serviceScopeFactory; + this._options = options?.Value; + _outStockTaskService = outStockTaskService; + _transactionRepositories = transactionRepositories; + _inStockTaskService = inStockTaskService; + } + + /// + /// 执行方法 + /// + /// + /// + 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}"); + } + + } + } +} diff --git a/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs index 0e605540..3447542d 100644 --- a/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs +++ b/src/WMS.Web.Domain/QuartzJob/InStockOrderQuartzJob.cs @@ -64,9 +64,6 @@ namespace WMS.Web.Domain.QuartzJob //3.记录:结束时间 var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"同步金蝶入库单数据:执行结束时间->{begindatetime}"); - - //验证金蝶是否有删单//默认拉去8个小时以内的 - await _inStockTaskService.ErpDel(DateTime.Now.AddHours(-8)); } catch (Exception ex) { diff --git a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs index 49eabd36..493f8232 100644 --- a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs +++ b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs @@ -54,9 +54,6 @@ namespace WMS.Web.Domain.QuartzJob //5.记录:结束时间 var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"出库单-同步金蝶出库单数据:执行结束时间->{enddatetime}"); - //验证金蝶是否有删单 - await _outStockTaskService.ErpDel(begin); - } catch (Exception ex) { diff --git a/src/WMS.Web.Domain/Services/InStockTaskService.cs b/src/WMS.Web.Domain/Services/InStockTaskService.cs index 3dfd7a1b..1451a463 100644 --- a/src/WMS.Web.Domain/Services/InStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/InStockTaskService.cs @@ -706,9 +706,9 @@ namespace WMS.Web.Domain.Services /// /// /// - public async Task ErpDel(DateTime begin) + public async Task ErpDel() { - var list = await _inStockTaskRepositories.GetEntityList(begin); + var list = await _inStockTaskRepositories.GetEntityListByStatus(); var result = await GetData(list); if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); var erp_list = result.Data; diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs index a43bfbff..e4ec2fa3 100644 --- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs @@ -646,9 +646,9 @@ namespace WMS.Web.Domain.Services /// /// /// - public async Task ErpDel(DateTime begin) + public async Task ErpDel() { - var list = await _outStockTaskRepositories.GetEntityList(begin); + var list = await _outStockTaskRepositories.GetEntityListByStatus(); var result = await GetData(list); if (!result.IsSuccess) return Result.ReFailure(result.Message, result.Status); var erp_list = result.Data; diff --git a/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs b/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs index e20b581a..1e40eb03 100644 --- a/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs +++ b/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs @@ -285,6 +285,18 @@ namespace WMS.Web.Repositories.DependencyInjection //.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5])) .WithDescription("MaterialsQuartzJobTriggerDecs")); #endregion + + #region 监测金蝶删单 + var jobKey_erpdelete = new JobKey("ErpDeleteQuartzJob", options.QuartzJobValue); + q.AddJob(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服务器 Services.AddQuartzServer(options => diff --git a/src/WMS.Web.Repositories/InStockTaskRepositories.cs b/src/WMS.Web.Repositories/InStockTaskRepositories.cs index 871fdd04..ad0d1510 100644 --- a/src/WMS.Web.Repositories/InStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/InStockTaskRepositories.cs @@ -402,7 +402,7 @@ namespace WMS.Web.Repositories //非采购:可入库数量=应入库数量-收货数量; AvailableQty = s.AccruedQty - s.ReceiveQty, //v1.0.7 待上架数量显示来源单的应入库数量-实入库数量的值 - WaitShelfQty = s.AccruedQty-s.RealityQty, + WaitShelfQty = s.AccruedQty - s.RealityQty, Remark = s.Remark, ErpDetailId = s.ErpDetailId }).Where(x => x.AvailableQty > 0).ToListAsync(); @@ -829,11 +829,13 @@ namespace WMS.Web.Repositories return (list, total); } - public async Task> GetEntityList(DateTime begin) + public async Task> GetEntityListByStatus() { var res = await _context.InStockTask .Include(s => s.Details) - .Where(f => f.WmsUpdateTime >= begin) + .Where(f => f.Status == InstockStatus.Wait + || f.Status == InstockStatus.Part + || f.Status == InstockStatus.WaitInStock) .ToListAsync(); return res; diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index fe56258f..33e6ba00 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -567,11 +567,11 @@ namespace WMS.Web.Repositories return entitys.Clone(); } - public async Task> GetEntityList(DateTime begin) + public async Task> GetEntityListByStatus() { var res = await _context.OutStockTask .Include(s => s.Details).ThenInclude(s => s.ErpDetails) - .Where(f => f.WmsUpdateTime >= begin) + .Where(f => f.Status==OutStockStatus.Wait || f.Status == OutStockStatus.Part) .ToListAsync(); return res.Clone();