添加项目文件。

This commit is contained in:
2025-04-30 17:01:05 +08:00
commit 1eaedea85d
261 changed files with 33985 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
using BarCode.Web.Core.Dto.Erp;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Pomelo.AspNetCore.TimedJob;
using System;
using System.Collections.Generic;
using System.Text;
using BarCode.Web.Core.Dto.Erp;
using BarCode.Web.Core.Dto.Erp.Customer;
using BarCode.Web.Core.Dto.Erp.Org;
using BarCode.Web.Core.Dto.Erp.Supplier;
using BarCode.Web.Domain.IService.Public;
using BarCode.Web.Domain.Options;
using BarCode.Web.Domain.Services.Public;
namespace BarCode.Web.Domain.TimedJob
{
/// <summary>
/// erp基础数据-同步定时任务
/// </summary>
public class ErpBaseDataSyncJob : Job
{
private readonly IMemoryCache _memoryCache;
private readonly ErpOptions _erpOptions;
private ILogger<ErpBaseDataSyncJob> _logger;
private readonly IServiceProvider _serviceProvider;
public ErpBaseDataSyncJob(IServiceProvider serviceProvider,IMemoryCache memoryCache, IOptions<ErpOptions> erpOptions, ILogger<ErpBaseDataSyncJob> logger)
{
_serviceProvider = serviceProvider;
_memoryCache = memoryCache;
this._erpOptions = erpOptions?.Value;
this._logger = logger;
}
//[Invoke(Begin = "2022-03-02 01:01", Interval = 1000 * 60 * 60 * 24, SkipWhileExecuting = true)]
//30分钟执行一次
[Invoke(Begin = "2024-01-15 17:43", Interval = 1000 * 60 * 30, SkipWhileExecuting = true)]
public void Run()
{
//this.SyscErpBaseData();
}
public void SyscErpBaseData()
{
string tip = "";
_logger.LogInformation($"----------异步:定时任务拉取---------");
var sercice = _serviceProvider.GetRequiredService<IErpService>();
var materials = _memoryCache.Get<List<ErpMaterialDto>>(_erpOptions.cache_materail_key);
if (materials == null || materials.Count == 0)
ErpBaseDataSync.SyncMaterial(sercice);
else
tip = tip + "物料缓存未失效;";
var orgs = _memoryCache.Get<List<ErpOrgDto>>(_erpOptions.cache_org_key);
if (orgs == null || orgs.Count == 0)
ErpBaseDataSync.SyncOrg(sercice);
else
tip = tip + "组织缓存未失效;";
var suppliers = _memoryCache.Get<List<ErpSupplierDto>>(_erpOptions.cache_supplier_key);
if (suppliers == null || suppliers.Count == 0)
ErpBaseDataSync.SyncSupplier(sercice);
else
tip = tip + "供应商缓存未失效;";
var customers = _memoryCache.Get<List<ErpCustomerDto>>(_erpOptions.cache_customer_key);
if (customers == null || customers.Count == 0)
ErpBaseDataSync.SyncCustomer(sercice);
else
tip = tip + "客户缓存未失效;";
if (!string.IsNullOrEmpty(tip))
_logger.LogInformation($"异步:定时任务拉取-->" + tip);
}
}
}