雪花Id直接指定消息在未来的消费时间
This commit is contained in:
parent
ba118927c6
commit
93377859e0
|
@ -48,8 +48,8 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.901" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.901" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.907-beta" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
|
|
|
@ -54,33 +54,6 @@ namespace AntJob.Data.Entity
|
|||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static AppHistory FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据应用、操作查找</summary>
|
||||
/// <param name="appid">应用</param>
|
||||
/// <param name="action">操作</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<AppHistory> FindAllByAppIDAndAction(Int32 appid, String action)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.AppID == appid && e.Action == action);
|
||||
|
||||
return FindAll(_.AppID == appid & _.Action == action);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
@ -104,7 +77,8 @@ namespace AntJob.Data.Entity
|
|||
if (!action.IsNullOrEmpty()) exp &= _.Action == action;
|
||||
if (success != null) exp &= _.Success == success;
|
||||
|
||||
exp &= _.CreateTime.Between(start, end);
|
||||
exp &= _.Id.Between(start, end, Meta.Factory.FlowId);
|
||||
//exp &= _.CreateTime.Between(start, end);
|
||||
|
||||
if (!key.IsNullOrEmpty())
|
||||
{
|
||||
|
|
|
@ -15,18 +15,17 @@ namespace AntJob.Data.Entity
|
|||
[DataObject]
|
||||
[Description("应用历史。应用的操作历史")]
|
||||
[BindIndex("IX_AppHistory_AppID_Action", false, "AppID,Action")]
|
||||
[BindIndex("IX_AppHistory_CreateTime", false, "CreateTime")]
|
||||
[BindTable("AppHistory", Description = "应用历史。应用的操作历史", ConnName = "Ant", DbType = DatabaseType.None)]
|
||||
public partial class AppHistory
|
||||
{
|
||||
#region 属性
|
||||
private Int64 _ID;
|
||||
private Int64 _Id;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int64 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
[DataObjectField(true, false, false, 0)]
|
||||
[BindColumn("Id", "编号", "")]
|
||||
public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||
|
||||
private Int32 _AppID;
|
||||
/// <summary>应用</summary>
|
||||
|
@ -119,7 +118,7 @@ namespace AntJob.Data.Entity
|
|||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Id": return _Id;
|
||||
case "AppID": return _AppID;
|
||||
case "Name": return _Name;
|
||||
case "Action": return _Action;
|
||||
|
@ -137,7 +136,7 @@ namespace AntJob.Data.Entity
|
|||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToLong(); break;
|
||||
case "Id": _Id = value.ToLong(); break;
|
||||
case "AppID": _AppID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "Action": _Action = Convert.ToString(value); break;
|
||||
|
@ -159,7 +158,7 @@ namespace AntJob.Data.Entity
|
|||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
public static readonly Field Id = FindByName("Id");
|
||||
|
||||
/// <summary>应用</summary>
|
||||
public static readonly Field AppID = FindByName("AppID");
|
||||
|
@ -198,7 +197,7 @@ namespace AntJob.Data.Entity
|
|||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
public const String Id = "Id";
|
||||
|
||||
/// <summary>应用</summary>
|
||||
public const String AppID = "AppID";
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace AntJob.Data.Entity
|
|||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
return Find(_.ID == id);
|
||||
return Find(_.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -100,7 +100,9 @@ namespace AntJob.Data.Entity
|
|||
if (appid > 0) exp &= _.AppID == appid;
|
||||
if (jobid > 0) exp &= _.JobID == jobid;
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Topic.Contains(key) | _.Data.Contains(key);
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
|
||||
exp &= _.Id.Between(start, end, Meta.Factory.FlowId);
|
||||
//exp &= _.UpdateTime.Between(start, end);
|
||||
|
||||
return FindAll(exp, p);
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ namespace AntJob.Data.Entity
|
|||
/// <returns></returns>
|
||||
public static IList<AppMessage> GetTopic(Int32 appid, String topic, DateTime endTime, Int32 count)
|
||||
{
|
||||
return FindAll(_.AppID == appid & _.Topic == topic & _.UpdateTime <= endTime, _.UpdateTime.Asc(), null, 0, count);
|
||||
return FindAll(_.AppID == appid & _.Topic == topic & _.Id <= Meta.Factory.FlowId.GetId(endTime), _.Id.Asc(), null, 0, count);
|
||||
}
|
||||
|
||||
/// <summary>去重过滤</summary>
|
||||
|
|
|
@ -15,18 +15,17 @@ namespace AntJob.Data.Entity
|
|||
[DataObject]
|
||||
[Description("应用消息。消息调度,某些作业负责生产消息,供其它作业进行消费处理")]
|
||||
[BindIndex("IX_AppMessage_AppID_Topic_UpdateTime", false, "AppID,Topic,UpdateTime")]
|
||||
[BindIndex("IX_AppMessage_UpdateTime", false, "UpdateTime")]
|
||||
[BindTable("AppMessage", Description = "应用消息。消息调度,某些作业负责生产消息,供其它作业进行消费处理", ConnName = "Ant", DbType = DatabaseType.None)]
|
||||
public partial class AppMessage
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
private Int64 _Id;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
[DataObjectField(true, false, false, 0)]
|
||||
[BindColumn("Id", "编号", "")]
|
||||
public Int64 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||
|
||||
private Int32 _AppID;
|
||||
/// <summary>应用</summary>
|
||||
|
@ -87,7 +86,7 @@ namespace AntJob.Data.Entity
|
|||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Id": return _Id;
|
||||
case "AppID": return _AppID;
|
||||
case "JobID": return _JobID;
|
||||
case "Topic": return _Topic;
|
||||
|
@ -101,7 +100,7 @@ namespace AntJob.Data.Entity
|
|||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Id": _Id = value.ToLong(); break;
|
||||
case "AppID": _AppID = value.ToInt(); break;
|
||||
case "JobID": _JobID = value.ToInt(); break;
|
||||
case "Topic": _Topic = Convert.ToString(value); break;
|
||||
|
@ -119,7 +118,7 @@ namespace AntJob.Data.Entity
|
|||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
public static readonly Field Id = FindByName("Id");
|
||||
|
||||
/// <summary>应用</summary>
|
||||
public static readonly Field AppID = FindByName("AppID");
|
||||
|
@ -146,7 +145,7 @@ namespace AntJob.Data.Entity
|
|||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
public const String Id = "Id";
|
||||
|
||||
/// <summary>应用</summary>
|
||||
public const String AppID = "AppID";
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</Table>
|
||||
<Table Name="AppHistory" Description="应用历史。应用的操作历史">
|
||||
<Columns>
|
||||
<Column Name="ID" DataType="Int64" Identity="True" PrimaryKey="True" Description="编号" />
|
||||
<Column Name="Id" DataType="Int64" PrimaryKey="True" Description="编号" />
|
||||
<Column Name="AppID" DataType="Int32" Description="应用" />
|
||||
<Column Name="Name" DataType="String" Master="True" Description="名称" />
|
||||
<Column Name="Action" DataType="String" Description="操作" />
|
||||
|
@ -71,7 +71,6 @@
|
|||
</Columns>
|
||||
<Indexes>
|
||||
<Index Columns="AppID,Action" />
|
||||
<Index Columns="CreateTime" />
|
||||
</Indexes>
|
||||
</Table>
|
||||
<Table Name="AppConfig" Description="应用配置。各应用的配置数据">
|
||||
|
@ -190,7 +189,7 @@
|
|||
</Table>
|
||||
<Table Name="AppMessage" Description="应用消息。消息调度,某些作业负责生产消息,供其它作业进行消费处理">
|
||||
<Columns>
|
||||
<Column Name="ID" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
|
||||
<Column Name="Id" DataType="Int64" PrimaryKey="True" Description="编号" />
|
||||
<Column Name="AppID" DataType="Int32" Description="应用" />
|
||||
<Column Name="JobID" DataType="Int32" Description="作业。生产消息的作业" />
|
||||
<Column Name="Topic" DataType="String" Description="主题。区分作业下多种消息" />
|
||||
|
@ -200,7 +199,6 @@
|
|||
</Columns>
|
||||
<Indexes>
|
||||
<Index Columns="AppID,Topic,UpdateTime" />
|
||||
<Index Columns="UpdateTime" />
|
||||
</Indexes>
|
||||
</Table>
|
||||
</Tables>
|
|
@ -42,8 +42,8 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.901" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.901" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.907-beta" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AntJob\AntJob.csproj" />
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Agent" Version="8.7.2020.802" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.901" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.907-beta" />
|
||||
<PackageReference Include="NewLife.Stardust" Version="1.2.2020.902" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.901" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
|
||||
|
|
|
@ -358,16 +358,15 @@ namespace AntJob.Server
|
|||
var total = 0;
|
||||
var now = DateTime.Now;
|
||||
// 延迟需要基于任务开始时间,而不能用使用当前时间,防止回头跑数据时无法快速执行
|
||||
var dTime = model.DelayTime.ToDateTime();
|
||||
if (dTime.Year < 2000)
|
||||
dTime = now.AddSeconds(model.DelayTime);
|
||||
var dTime = now.AddSeconds(model.DelayTime);
|
||||
|
||||
var jb = Job.FindByAppIDAndName(app.ID, model.Job);
|
||||
|
||||
var flow = AppMessage.Meta.Factory.FlowId;
|
||||
foreach (var item in messages)
|
||||
{
|
||||
var jm = new AppMessage
|
||||
{
|
||||
Id = flow.NewId(),
|
||||
AppID = app.ID,
|
||||
JobID = jb == null ? 0 : jb.ID,
|
||||
Topic = model.Topic,
|
||||
|
@ -375,7 +374,13 @@ namespace AntJob.Server
|
|||
};
|
||||
|
||||
jm.CreateTime = jm.UpdateTime = now;
|
||||
if (model.DelayTime > 0) jm.UpdateTime = dTime;
|
||||
|
||||
// 雪花Id直接指定消息在未来的消费时间
|
||||
if (model.DelayTime > 0)
|
||||
{
|
||||
jm.Id = flow.NewId(dTime);
|
||||
jm.UpdateTime = dTime;
|
||||
}
|
||||
|
||||
ms.Add(jm);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.901" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.907-beta" />
|
||||
<PackageReference Include="NewLife.Cube.Core" Version="3.7.2020.902" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.901" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
{
|
||||
<th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="全选" /></th>
|
||||
}
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("ID"))">编号</a></th>
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("AppID"))">应用</a></th>
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Name"))">名称</a></th>
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Action"))">操作</a></th>
|
||||
|
@ -42,9 +41,8 @@
|
|||
<tr>
|
||||
@if (set.EnableSelect)
|
||||
{
|
||||
<td class="text-center"><input type="checkbox" name="keys" value="@entity.ID" /></td>
|
||||
<td class="text-center"><input type="checkbox" name="keys" value="@entity.Id" /></td>
|
||||
}
|
||||
<td class="text-center">@entity.ID</td>
|
||||
<td><a href="App?ID=@entity.AppID">@entity.AppName</a></td>
|
||||
<td>@entity.Name</td>
|
||||
<td>@entity.Action</td>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
{
|
||||
<th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="全选" /></th>
|
||||
}
|
||||
<th class="text-center hidden-md hidden-sm hidden-xs"><a href="@Html.Raw(page.GetSortUrl("ID"))">编号</a></th>
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("AppID"))">应用</a></th>
|
||||
<th class="text-center"><a href="@Html.Raw(page.GetSortUrl("JobID"))">作业</a></th>
|
||||
<th class="text-center" title="主题。区分作业下多种资源"><a href="@Html.Raw(page.GetSortUrl("Topic"))">主题</a></th>
|
||||
|
@ -44,9 +43,8 @@
|
|||
<tr>
|
||||
@if (set.EnableSelect)
|
||||
{
|
||||
<td class="text-center"><input type="checkbox" name="keys" value="@entity.ID" /></td>
|
||||
<td class="text-center"><input type="checkbox" name="keys" value="@entity.Id" /></td>
|
||||
}
|
||||
<td class="text-center hidden-md hidden-sm hidden-xs">@entity.ID</td>
|
||||
<td><a href="App?ID=@entity.AppID">@entity.AppName</a></td>
|
||||
<td><a href="Job?ID=@entity.JobID">@entity.JobName</a></td>
|
||||
<td>@entity.Topic</td>
|
||||
|
|
|
@ -46,6 +46,6 @@
|
|||
<Compile Remove="StarService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.901" />
|
||||
<PackageReference Include="NewLife.Core" Version="8.10.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -16,7 +16,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.901" />
|
||||
<PackageReference Include="NewLife.XCode" Version="9.20.2020.907-beta" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue