定时任务时间从配置文件中读取

dev
嵇文龙 4 weeks ago
parent 79c078e9ec
commit ab6bfe19ca

@ -1,5 +1,6 @@
using DS.WMS.Core.Jobs;
using DS.WMS.Core.QuarztJobs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
@ -7,7 +8,7 @@ namespace DS.Module.QuartzModuleInstall
{
public static class QuartzModuleInstall
{
public static void AddFeeQuartzModuleInstall(this IServiceCollection services)
public static void AddFeeQuartzModuleInstall(this IServiceCollection services, IConfiguration configuration)
{
//获取进项发票
var jobKey = new JobKey("InInvoice");
@ -52,7 +53,7 @@ namespace DS.Module.QuartzModuleInstall
q.AddTrigger(opts => opts
.ForJob(jobKey3)
.WithIdentity(nameof(FeeCustTemplateJob) + "-trigger")
.WithCronSchedule("1 59 23 * * ?")
.WithCronSchedule(configuration["JobConfig:" + jobKey3.Name])
);
});
@ -60,7 +61,7 @@ namespace DS.Module.QuartzModuleInstall
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
}
public static void AddOpQuartzModuleInstall(this IServiceCollection services)
public static void AddOpQuartzModuleInstall(this IServiceCollection services, IConfiguration configuration)
{
var jobKey1 = new JobKey(nameof(WSLReportJob));
services.AddQuartz(q =>
@ -70,7 +71,7 @@ namespace DS.Module.QuartzModuleInstall
q.AddTrigger(opts => opts
.ForJob(jobKey1)
.WithIdentity(nameof(WSLReportJob) + "-trigger")
.WithCronSchedule("0 0 1 * * ?")
.WithCronSchedule(configuration["JobConfig:" + jobKey1.Name])
//.WithSimpleSchedule(s => s.WithIntervalInMinutes(1).WithRepeatCount(1)) //测试用
);
});

@ -0,0 +1,191 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using Masuit.Tools.Systems;
namespace DS.WMS.Core.Fee.Dtos
{
/// <summary>
/// 客户费用模板视图
/// </summary>
public class FeeCustTemplateView
{
/// <summary>
/// 主键ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 模板ID
/// </summary>
public long TemplateId { get; set; }
/// <summary>
/// 结算对象Id
/// </summary>
public long CustomerId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
public string? CustomerName { get; set; }
/// <summary>
/// 结算对象类型
/// </summary>
public string? CustomerType { get; set; }
/// <summary>
/// 费用Id
/// </summary>
public long FeeId { get; set; }
/// <summary>
/// 费用名称
/// </summary>
public string? FeeName { get; set; }
/// <summary>
/// 20GP
/// </summary>
public string? Unit20GP { get; set; }
/// <summary>
/// 40GP
/// </summary>
public string? Unit40GP { get; set; }
/// <summary>
/// 40HC
/// </summary>
public string? Unit40HC { get; set; }
/// <summary>
/// 45G0
/// </summary>
public string? Unit45G0 { get; set; }
/// <summary>
/// TEU
/// </summary>
public string? UnitTEU { get; set; }
/// <summary>
/// 单票
/// </summary>
public string? UnitP { get; set; }
/// <summary>
/// 是否箱型
/// </summary>
public bool IsCtn { get; set; }
/// <summary>
/// 币别
/// </summary>
public string? Currency { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal? UnitPrice { get; set; }
/// <summary>
/// 汇率,为空时取默认汇率
/// </summary>
public decimal? ExchangeRate { get; set; }
/// <summary>
/// 费用默认税率
/// </summary>
public decimal? TaxRate { get; set; }
/// <summary>
/// 财务税率
/// </summary>
public decimal? AccTaxRate { get; set; }
/// <summary>
/// 税额
/// </summary>
public decimal? Tax { get; set; }
/// <summary>
/// 含税单价
/// </summary>
public decimal? TaxUnitPrice { get; set; }
/// <summary>
/// 是否开票
/// </summary>
public bool IsInvoice { get; set; }
/// <summary>
/// 是否垫付费用
/// </summary>
public bool IsAdvancedPay { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string? CreateBy { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; }
/// <summary>
/// 业务类型文本
/// </summary>
public string BusinessTypeText => BusinessType.GetDescription();
/// <summary>
/// 费用类型
/// </summary>
public FeeType FeeType { get; set; }
/// <summary>
/// 费用类型文本
/// </summary>
public string FeeTypeText => FeeType.GetDescription();
/// <summary>
/// 开始时间
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// 是否禁用
/// </summary>
public bool IsDisabled { get; set; }
///// <summary>
///// 费用类别ID
///// </summary>
//public string? FeeCategoryId { get; set; }
/// <summary>
/// 费用类别名称
/// </summary>
public string? FeeCategoryName { get; set; }
/// <summary>
/// 优先级
/// </summary>
public int Priority { get; set; }
/// <summary>
/// 起运港代码
/// </summary>
public string? POLCode { get; set; }
/// <summary>
/// 卸货港代码
/// </summary>
public string? PODCode { get; set; }
/// <summary>
/// 航线名称
/// </summary>
public string? LaneName { get; set; }
/// <summary>
/// 承运商名称
/// </summary>
public string? CarrierName { get; set; }
/// <summary>
/// 付费方式代码
/// </summary>
public string? MBLFrtCode { get; set; }
/// <summary>
/// 业务来源名称
/// </summary>
public string? SourceName { get; set; }
/// <summary>
/// 业务来源明细名称
/// </summary>
public string? SourceDetailName { get; set; }
/// <summary>
/// 订舱口名称
/// </summary>
public string? ForwarderName { get; set; }
/// <summary>
/// 分公司名称
/// </summary>
public string? DeptOrgName { get; set; }
}
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using AngleSharp.Css;
using DS.Module.Core;
using DS.Module.Core.Condition;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Entity;
@ -497,6 +498,79 @@ namespace DS.WMS.Core.Fee.Method
return await TenantDb.Queryable<FeeCustTemplate>().Where(whereList).ToQueryPageAsync(request.PageCondition);
}
///// <summary>
///// 视图列表
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public async Task<DataResult<List<FeeCustTemplateView>>> GetListViewAsync(PageRequest request)
//{
// var list = TenantDb.Queryable<FeeCustTemplateDetail>()
// .InnerJoin<FeeCustTemplate>((d, t) => d.TemplateId == t.Id)
// .LeftJoin<CodeCarrier>((d, t, cc) => t.CarrierId == cc.Id)
// .LeftJoin<CodeLanes>((d, t, cc, cl) => t.LaneId == cl.Id)
// .LeftJoin<CodeSource>((d, t, cc, cl, cs) => t.SourceId == cs.Id)
// .LeftJoin<CodeSourceDetail>((d, t, cc, cl, cs, csd) => t.SourceDetailId == csd.Id)
// .LeftJoin<InfoClient>((d, t, cc, cl, cs, csd, c) => t.ForwarderId == c.Id)
// .LeftJoin<SysOrg>((d, t, cc, cl, cs, csd, c, so) => t.DeptOrgId == so.Id, "shippingweb8_dev.sys_org")
// .GroupBy((d, t, cc, cl, cs, csd, c, so) => new
// {
// d.TemplateId,
// d.FeeId,
// d.FeeName,
// d.CustomerType,
// d.CustomerId,
// d.CustomerName,
// t.BusinessType,
// t.FeeType,
// t.StartTime,
// t.EndTime,
// t.IsDisabled,
// t.FeeCategoryName,
// t.Priority,
// t.POLCode,
// t.PODCode,
// t.MBLFrtCode,
// cl.LaneName,
// CarrierName = cc.CnName,
// cs.SourceName,
// SourceDetailName = csd.DetailName,
// ForwarderName = c.ShortName,
// DeptOrgName = so.OrgName
// }).Select((d, t, cc, cl, cs, csd, c, so) => new FeeCustTemplateView
// {
// Id = d.Id,
// TemplateId = d.TemplateId,
// CustomerType = d.CustomerType,
// CustomerId = d.CustomerId,
// CustomerName = d.CustomerName,
// FeeId = d.FeeId,
// FeeName = d.FeeName,
// BusinessType = t.BusinessType,
// FeeType = t.FeeType,
// StartTime = t.StartTime,
// EndTime = t.EndTime,
// IsDisabled = t.IsDisabled,
// FeeCategoryName = t.FeeCategoryName,
// Priority = t.Priority,
// POLCode = t.POLCode,
// PODCode = t.PODCode,
// MBLFrtCode = t.MBLFrtCode,
// LaneName = cl.LaneName,
// CarrierName = cc.CnName,
// SourceName = cs.SourceName,
// SourceDetailName = csd.DetailName,
// ForwarderName = c.ShortName,
// DeptOrgName = so.OrgName
// });
//}
/// <summary>
/// 详情
/// </summary>
@ -686,7 +760,7 @@ namespace DS.WMS.Core.Fee.Method
var list = await TenantDb.Queryable<FeeCustTemplate>().Where(x => ids.Contains(x.Id))
.Includes(x => x.Details).ToListAsync();
foreach (var item in list)
foreach (var item in list)
{
item.Id = 0;
item.CreateTime = dt;

@ -47,7 +47,7 @@ builder.Services.AddRuleEngineModuleInstall();//Djy
//builder.Services.AddHangfireFeeInstall();//Hangfire服务
// 使用自定义的 Quartz 配置// 添加 Quartz 服务
builder.Services.AddFeeQuartzModuleInstall();
builder.Services.AddFeeQuartzModuleInstall(builder.Configuration);
// builder.Services.AddEndpointsApiExplorer();
// builder.Services.AddSwaggerGen();

@ -73,5 +73,8 @@
"WorkerCount": 10,
"ServerName": "FeeApi",
"Queues": "fee"
},
"JobConfig": {
"FeeCustTemplateJob": "1 59 23 * * ?"
}
}

@ -56,8 +56,8 @@ builder.Services.AddMQModuleInstall();//MQ
//builder.Services.AddCrawlerModuleInstall();//ÔË×Ù·þÎñ
// 使用自定义的 Quartz 配置// 添加 Quartz 服务
builder.Services.AddOpQuartzModuleInstall();
//Ìí¼Ó Quartz ·þÎñ
builder.Services.AddOpQuartzModuleInstall(builder.Configuration);
var app = builder.Build();

@ -146,5 +146,8 @@
"BasePath": "", //使
"RelativePath": "ExportTemplate",
"FileType": [ ".xls", ".xlsx" ]
},
"JobConfig": {
"WSLReportJob": "0 0 1 * * ?"
}
}

Loading…
Cancel
Save