Skip to content

Commit

Permalink
优化耗时时间的格式化显示
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 25, 2024
1 parent 1b1fb39 commit 81f8996
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 33 deletions.
2 changes: 1 addition & 1 deletion AntJob.Agent/AntJob.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Stardust" Version="3.0.2024.708" />
<PackageReference Include="NewLife.Stardust" Version="3.0.2024.724-beta0746" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AntJob.Data/AntJob.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<None Remove="Build.tt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.13.2024.701" />
<PackageReference Include="NewLife.XCode" Version="11.14.2024.723-beta0709" />
</ItemGroup>
<ItemGroup>
<None Update="Build.log">
Expand Down
9 changes: 6 additions & 3 deletions AntJob.Data/Entity/作业.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public partial class Job
[DisplayName("最大执行时间")]
[Description("最大执行时间。默认600秒,超过该时间则认为执行器故障,将会把该任务分配给其它执行器")]
[DataObjectField(false, false, false, 0)]
[BindColumn("MaxTime", "最大执行时间。默认600秒,超过该时间则认为执行器故障,将会把该任务分配给其它执行器", "")]
[BindColumn("MaxTime", "最大执行时间。默认600秒,超过该时间则认为执行器故障,将会把该任务分配给其它执行器", "", ItemType = "TimeSpan")]
public Int32 MaxTime { get => _MaxTime; set { if (OnPropertyChanging("MaxTime", value)) { _MaxTime = value; OnPropertyChanged("MaxTime"); } } }

private Int32 _MaxRetain;
Expand All @@ -193,7 +193,7 @@ public partial class Job
[DisplayName("最大空闲时间")]
[Description("最大空闲时间。默认3600秒,超过该时间不更新则认为应用程序故障,系统触发告警")]
[DataObjectField(false, false, false, 0)]
[BindColumn("MaxIdle", "最大空闲时间。默认3600秒,超过该时间不更新则认为应用程序故障,系统触发告警", "")]
[BindColumn("MaxIdle", "最大空闲时间。默认3600秒,超过该时间不更新则认为应用程序故障,系统触发告警", "", ItemType = "TimeSpan")]
public Int32 MaxIdle { get => _MaxIdle; set { if (OnPropertyChanging("MaxIdle", value)) { _MaxIdle = value; OnPropertyChanged("MaxIdle"); } } }

private Int32 _ErrorDelay;
Expand All @@ -202,7 +202,7 @@ public partial class Job
[DisplayName("错误延迟")]
[Description("错误延迟。默认60秒,出错延迟后重新发放")]
[DataObjectField(false, false, false, 0)]
[BindColumn("ErrorDelay", "错误延迟。默认60秒,出错延迟后重新发放", "")]
[BindColumn("ErrorDelay", "错误延迟。默认60秒,出错延迟后重新发放", "", ItemType = "TimeSpan")]
public Int32 ErrorDelay { get => _ErrorDelay; set { if (OnPropertyChanging("ErrorDelay", value)) { _ErrorDelay = value; OnPropertyChanged("ErrorDelay"); } } }

private DateTime _Deadline;
Expand Down Expand Up @@ -478,6 +478,9 @@ public override Object this[String name]

#endregion

#region 扩展查询
#endregion

#region 字段名
/// <summary>取得作业字段信息的快捷方式</summary>
public partial class _
Expand Down
41 changes: 38 additions & 3 deletions AntJob.Data/Entity/作业任务.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public partial class JobTask
[DisplayName("数据时间")]
[Description("数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用")]
[DataObjectField(false, false, true, 0)]
[BindColumn("DataTime", "数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用", "", Master = true)]
[BindColumn("DataTime", "数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用", "", DataScale = "time", Master = true)]
public DateTime DataTime { get => _DataTime; set { if (OnPropertyChanging("DataTime", value)) { _DataTime = value; OnPropertyChanged("DataTime"); } } }

private DateTime _End;
Expand Down Expand Up @@ -125,15 +125,15 @@ public partial class JobTask
[DisplayName("耗时")]
[Description("耗时。秒,执行端计算的执行时间")]
[DataObjectField(false, false, false, 0)]
[BindColumn("Cost", "耗时。秒,执行端计算的执行时间", "")]
[BindColumn("Cost", "耗时。秒,执行端计算的执行时间", "", ItemType = "TimeSpan")]
public Int32 Cost { get => _Cost; set { if (OnPropertyChanging("Cost", value)) { _Cost = value; OnPropertyChanged("Cost"); } } }

private Int32 _FullCost;
/// <summary>全部耗时。秒,从任务发放到执行完成的时间</summary>
[DisplayName("全部耗时")]
[Description("全部耗时。秒,从任务发放到执行完成的时间")]
[DataObjectField(false, false, false, 0)]
[BindColumn("FullCost", "全部耗时。秒,从任务发放到执行完成的时间", "")]
[BindColumn("FullCost", "全部耗时。秒,从任务发放到执行完成的时间", "", ItemType = "TimeSpan")]
public Int32 FullCost { get => _FullCost; set { if (OnPropertyChanging("FullCost", value)) { _FullCost = value; OnPropertyChanged("FullCost"); } } }

private JobStatus _Status;
Expand Down Expand Up @@ -329,6 +329,41 @@ public override Object this[String name]

#endregion

#region 扩展查询
/// <summary>根据编号查找</summary>
/// <param name="id">编号</param>
/// <returns>实体对象</returns>
public static JobTask FindByID(Int32 id)
{
if (id < 0) return null;

return Find(_.ID == id);
}

/// <summary>根据作业查找</summary>
/// <param name="jobId">作业</param>
/// <returns>实体列表</returns>
public static IList<JobTask> FindAllByJobID(Int32 jobId)
{
if (jobId < 0) return [];

return FindAll(_.JobID == jobId);
}
#endregion

#region 数据清理
/// <summary>清理指定时间段内的数据</summary>
/// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
/// <param name="end">结束时间</param>
/// <returns>清理行数</returns>
public static Int32 DeleteWith(DateTime start, DateTime end)
{
if (start == end) return Delete(_.DataTime == start);

return Delete(_.DataTime.Between(start, end));
}
#endregion

#region 字段名
/// <summary>取得作业任务字段信息的快捷方式</summary>
public partial class _
Expand Down
3 changes: 3 additions & 0 deletions AntJob.Data/Entity/作业错误.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public override Object this[String name]

#endregion

#region 扩展查询
#endregion

#region 字段名
/// <summary>取得作业错误字段信息的快捷方式</summary>
public partial class _
Expand Down
16 changes: 15 additions & 1 deletion AntJob.Data/Entity/应用历史.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class AppHistory
[DisplayName("编号")]
[Description("编号")]
[DataObjectField(true, false, false, 0)]
[BindColumn("Id", "编号", "")]
[BindColumn("Id", "编号", "", DataScale = "time")]
public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

private Int32 _AppID;
Expand Down Expand Up @@ -178,6 +178,20 @@ public override Object this[String name]

#endregion

#region 扩展查询
#endregion

#region 数据清理
/// <summary>清理指定时间段内的数据</summary>
/// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
/// <param name="end">结束时间</param>
/// <returns>清理行数</returns>
public static Int32 DeleteWith(DateTime start, DateTime end)
{
return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
}
#endregion

#region 字段名
/// <summary>取得应用历史字段信息的快捷方式</summary>
public partial class _
Expand Down
5 changes: 4 additions & 1 deletion AntJob.Data/Entity/应用在线.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public partial class AppOnline
[DisplayName("耗时")]
[Description("耗时。执行任务总耗时,秒")]
[DataObjectField(false, false, false, 0)]
[BindColumn("Cost", "耗时。执行任务总耗时,秒", "")]
[BindColumn("Cost", "耗时。执行任务总耗时,秒", "", ItemType = "TimeSpan")]
public Int64 Cost { get => _Cost; set { if (OnPropertyChanging("Cost", value)) { _Cost = value; OnPropertyChanged("Cost"); } } }

private Int64 _Speed;
Expand Down Expand Up @@ -271,6 +271,9 @@ public override Object this[String name]

#endregion

#region 扩展查询
#endregion

#region 字段名
/// <summary>取得应用在线字段信息的快捷方式</summary>
public partial class _
Expand Down
25 changes: 24 additions & 1 deletion AntJob.Data/Entity/应用消息.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class AppMessage
[DisplayName("编号")]
[Description("编号")]
[DataObjectField(true, false, false, 0)]
[BindColumn("Id", "编号", "")]
[BindColumn("Id", "编号", "", DataScale = "time")]
public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

private Int32 _AppID;
Expand Down Expand Up @@ -167,6 +167,29 @@ public override Object this[String name]

#endregion

#region 扩展查询
/// <summary>根据编号查找</summary>
/// <param name="id">编号</param>
/// <returns>实体对象</returns>
public static AppMessage FindById(Int64 id)
{
if (id < 0) return null;

return Find(_.Id == id);
}
#endregion

#region 数据清理
/// <summary>清理指定时间段内的数据</summary>
/// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
/// <param name="end">结束时间</param>
/// <returns>清理行数</returns>
public static Int32 DeleteWith(DateTime start, DateTime end)
{
return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
}
#endregion

#region 字段名
/// <summary>取得应用消息字段信息的快捷方式</summary>
public partial class _
Expand Down
3 changes: 3 additions & 0 deletions AntJob.Data/Entity/应用系统.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ public override Object this[String name]

#endregion

#region 扩展查询
#endregion

#region 字段名
/// <summary>取得应用系统字段信息的快捷方式</summary>
public partial class _
Expand Down
18 changes: 9 additions & 9 deletions AntJob.Data/Model.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<EntityModel xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="https://newlifex.com https://newlifex.com/Model202309.xsd" Document="https://newlifex.com/xcode/model" xmlns="https://newlifex.com/Model202309.xsd">
<EntityModel xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="https://newlifex.com https://newlifex.com/Model202407.xsd" Document="https://newlifex.com/xcode/model" xmlns="https://newlifex.com/Model202407.xsd">
<Option>
<!--类名模板。其中{name}替换为Table.Name,如{name}Model/I{name}Dto等-->
<ClassNameTemplate />
Expand Down Expand Up @@ -82,7 +82,7 @@
<Column Name="Total" DataType="Int64" Description="总数" />
<Column Name="Success" DataType="Int64" Description="成功" />
<Column Name="Error" DataType="Int64" Description="错误" />
<Column Name="Cost" DataType="Int64" Description="耗时。执行任务总耗时,秒" />
<Column Name="Cost" DataType="Int64" ItemType="TimeSpan" Description="耗时。执行任务总耗时,秒" />
<Column Name="Speed" DataType="Int64" Description="速度。每秒处理数" />
<Column Name="LastKey" DataType="String" Description="最后键" />
<Column Name="TraceId" DataType="String" Length="200" Description="追踪。链路追踪,用于APM性能追踪定位,还原该事件的调用链" Category="扩展" />
Expand All @@ -99,7 +99,7 @@
</Table>
<Table Name="AppHistory" Description="应用历史。数据计算应用的操作历史">
<Columns>
<Column Name="Id" DataType="Int64" PrimaryKey="True" Description="编号" />
<Column Name="Id" DataType="Int64" PrimaryKey="True" DataScale="time" Description="编号" />
<Column Name="AppID" DataType="Int32" Map="App@ID@$" Description="应用" />
<Column Name="Name" DataType="String" Master="True" Description="名称" />
<Column Name="Action" DataType="String" Description="操作" />
Expand Down Expand Up @@ -136,10 +136,10 @@
<Column Name="MaxTask" DataType="Int32" Description="并行度。一共允许多少个任务并行处理,多执行端时平均分配,确保该作业整体并行度" Category="控制参数" />
<Column Name="MaxError" DataType="Int32" Description="最大错误。连续错误达到最大错误数时停止" Category="控制参数" />
<Column Name="MaxRetry" DataType="Int32" Description="最大重试。默认10次,超过该次数后将不再重试" Category="控制参数" />
<Column Name="MaxTime" DataType="Int32" Description="最大执行时间。默认600秒,超过该时间则认为执行器故障,将会把该任务分配给其它执行器" Category="控制参数" />
<Column Name="MaxTime" DataType="Int32" ItemType="TimeSpan" Description="最大执行时间。默认600秒,超过该时间则认为执行器故障,将会把该任务分配给其它执行器" Category="控制参数" />
<Column Name="MaxRetain" DataType="Int32" Description="保留。任务项保留天数,超过天数的任务项将被删除,默认30天" Category="控制参数" />
<Column Name="MaxIdle" DataType="Int32" Description="最大空闲时间。默认3600秒,超过该时间不更新则认为应用程序故障,系统触发告警" Category="控制参数" />
<Column Name="ErrorDelay" DataType="Int32" Description="错误延迟。默认60秒,出错延迟后重新发放" Category="控制参数" />
<Column Name="MaxIdle" DataType="Int32" ItemType="TimeSpan" Description="最大空闲时间。默认3600秒,超过该时间不更新则认为应用程序故障,系统触发告警" Category="控制参数" />
<Column Name="ErrorDelay" DataType="Int32" ItemType="TimeSpan" Description="错误延迟。默认60秒,出错延迟后重新发放" Category="控制参数" />
<Column Name="Deadline" DataType="DateTime" Description="最后期限。超过该时间后,任务将不再执行" Category="控制参数" />
<Column Name="Total" DataType="Int64" Description="总数。任务处理的总数据,例如数据调度抽取得到的总行数,定时调度默认1" Category="统计" />
<Column Name="Success" DataType="Int64" Description="成功。成功处理的数据,取自于Handler.Execute返回值,或者ProcessItem返回true的个数" Category="统计" />
Expand Down Expand Up @@ -169,7 +169,7 @@
<Column Name="AppID" DataType="Int32" Map="App@ID@$" Description="应用" />
<Column Name="JobID" DataType="Int32" Map="Job@ID@$" Description="作业" />
<Column Name="Client" DataType="String" Description="客户端。IP加进程" />
<Column Name="DataTime" DataType="DateTime" DataScale="time" Master="True" Description="数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
<Column Name="DataTime" DataType="DateTime" Master="True" DataScale="time" Description="数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
<Column Name="End" DataType="DateTime" Description="结束。小于不等于,数据调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
<Column Name="BatchSize" DataType="Int32" Description="批大小。数据调度每次抽取数据的分页大小,或消息调度每次处理的消息数,定时调度不适用" />
<Column Name="Total" DataType="Int32" Description="总数。任务处理的总数据,例如数据调度抽取得到的总行数,定时调度默认1" />
Expand All @@ -178,7 +178,7 @@
<Column Name="Times" DataType="Int32" Description="次数" />
<Column Name="Speed" DataType="Int32" Description="速度。每秒处理数,执行端计算" />
<Column Name="Cost" DataType="Int32" ItemType="TimeSpan" Description="耗时。秒,执行端计算的执行时间" />
<Column Name="FullCost" DataType="Int32" ItemType="TimeSpan" Description="全部耗时。秒,从任务发放到执行完成的时间" />
<Column Name="FullCost" DataType="Int32" ItemType="TimeSpan" Description="全部耗时。秒,从任务发放到执行完成的时间" />
<Column Name="Status" DataType="Int32" Description="状态" Type="JobStatus" />
<Column Name="MsgCount" DataType="Int32" Description="消息。消费消息数" />
<Column Name="Server" DataType="String" Description="服务器" />
Expand Down Expand Up @@ -224,7 +224,7 @@
</Table>
<Table Name="AppMessage" Description="应用消息。消息调度,某些作业负责生产消息,供其它作业进行消费处理">
<Columns>
<Column Name="Id" DataType="Int64" PrimaryKey="True" Description="编号" />
<Column Name="Id" DataType="Int64" PrimaryKey="True" DataScale="time" Description="编号" />
<Column Name="AppID" DataType="Int32" Map="App@ID@$" Description="应用" />
<Column Name="JobID" DataType="Int32" Map="Job@ID@$" Description="作业。生产消息的作业" />
<Column Name="Topic" DataType="String" Description="主题。区分作业下多种消息" />
Expand Down
5 changes: 5 additions & 0 deletions AntJob.Data/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
xcode
IF ERRORLEVEL 1 (
echo xcode 命令执行失败,正在安装 .NET 工具...
dotnet tool install xcodetool -g --prerelease
)
2 changes: 1 addition & 1 deletion AntJob.Extensions/AntJob.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.13.2024.701" />
<PackageReference Include="NewLife.XCode" Version="11.14.2024.723-beta0709" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AntJob\AntJob.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions AntJob.Web/AntJob.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<Content Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.710" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.0.2024.708" />
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.723-beta2117" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.0.2024.724-beta0746" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
Expand Down
6 changes: 1 addition & 5 deletions AntJob.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ public static void Main(string[] args)
{
XTrace.UseConsole();

var app = ApplicationManager.Load();
do
{
app.Start(CreateHostBuilder(args).Build());
} while (app.Restarting);
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(String[] args)
Expand Down
6 changes: 3 additions & 3 deletions AntJob/AntJob.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.10.2024.701" />
<PackageReference Include="NewLife.Remoting" Version="3.0.2024.708" />
<PackageReference Include="NewLife.Stardust" Version="3.0.2024.708" />
<PackageReference Include="NewLife.Core" Version="10.10.2024.723-beta1414" />
<PackageReference Include="NewLife.Remoting" Version="3.0.2024.719-beta0806" />
<PackageReference Include="NewLife.Stardust" Version="3.0.2024.724-beta0746" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/HisData/HisData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.13.2024.701" />
<PackageReference Include="NewLife.XCode" Version="11.14.2024.723-beta0709" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/HisWeb/HisWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.710" />
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.723-beta2117" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 81f8996

Please sign in to comment.