fix:修复验证描述,修复预警通知消息体标题加在头部
This commit is contained in:
parent
3ca5e538de
commit
bf3afe9480
@ -49,7 +49,7 @@ public class EditTransportWarningSceneRuleItemDto
|
|||||||
/// 时效 (单位h)
|
/// 时效 (单位h)
|
||||||
/// 注意:需要大于起始轨迹生成预警时间
|
/// 注意:需要大于起始轨迹生成预警时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Range(0.1f, 9999.9f, ErrorMessage = "时效必须范围0.1-9999.9")]
|
[Range(0.1f, 9999.9f, ErrorMessage = "时效范围0.1-9999.9")]
|
||||||
public float TransportTimeSpan { get; set; }
|
public float TransportTimeSpan { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using SJZY.Track.Application.Contract.Dtos.Warning;
|
using SJZY.Track.Application.Contract.Dtos.Warning;
|
||||||
|
using SJZY.Track.Application.Helpers;
|
||||||
using SJZY.Track.Application.Options;
|
using SJZY.Track.Application.Options;
|
||||||
using SJZY.Track.Application.Services.Warning.Model;
|
using SJZY.Track.Application.Services.Warning.Model;
|
||||||
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||||
@ -315,7 +316,6 @@ public sealed class WarningNotifyAggregator : ITransientDependency
|
|||||||
{
|
{
|
||||||
var options = _optionsMonitor.CurrentValue;
|
var options = _optionsMonitor.CurrentValue;
|
||||||
var hours = options.ScanWarningNotifyTaskHourInterval;
|
var hours = options.ScanWarningNotifyTaskHourInterval;
|
||||||
const float timeZone = 8.00f;
|
|
||||||
var transportCount = 0;
|
var transportCount = 0;
|
||||||
var transportLastNHoursCount = 0;
|
var transportLastNHoursCount = 0;
|
||||||
var returnCount = 0;
|
var returnCount = 0;
|
||||||
@ -344,7 +344,6 @@ public sealed class WarningNotifyAggregator : ITransientDependency
|
|||||||
|
|
||||||
return NotifyMessageBuilder.Build(
|
return NotifyMessageBuilder.Build(
|
||||||
hours,
|
hours,
|
||||||
timeZone,
|
|
||||||
transportCount,
|
transportCount,
|
||||||
transportLastNHoursCount,
|
transportLastNHoursCount,
|
||||||
returnCount,
|
returnCount,
|
||||||
@ -364,7 +363,7 @@ public static class NotifyMessageBuilder
|
|||||||
{
|
{
|
||||||
public const string Title = "预警通知";
|
public const string Title = "预警通知";
|
||||||
|
|
||||||
public static string Build(int hours, float timeZone,
|
public static string Build(int hours,
|
||||||
int transportCount, int transportLastNHoursCount,
|
int transportCount, int transportLastNHoursCount,
|
||||||
int returnCount, int returnLastNHoursCount,
|
int returnCount, int returnLastNHoursCount,
|
||||||
int completeCount, int completeLastNHoursCount)
|
int completeCount, int completeLastNHoursCount)
|
||||||
@ -375,15 +374,25 @@ public static class NotifyMessageBuilder
|
|||||||
var url1 = "";
|
var url1 = "";
|
||||||
var url2 = "";
|
var url2 = "";
|
||||||
var url3 = "";
|
var url3 = "";
|
||||||
var message = $"尊敬的用户,截止到{dateTime}(UTC {timeZone:+0:00:F2}),轨迹中心监测到与您相关的预警风险信息共计{totalCount} 条,请及时处理,详情如下:";
|
|
||||||
|
var message = $"{Title}\n尊敬的用户,截止到{dateTime}(UTC {BuildLocalTimezoneStr()}),轨迹中心监测到与您相关的预警风险信息共计{totalCount} 条,请及时处理,详情如下:";
|
||||||
|
|
||||||
if (transportCount > 0)
|
if (transportCount > 0)
|
||||||
message += $"\n运输时效预警共计{transportCount}条,其中过去{hours}小时内新增的预警{transportLastNHoursCount}条,查看详情{url1}";
|
message += $"\n运输时效预警共计{transportCount}条,其中过去{hours}小时内新增的预警{transportLastNHoursCount}条";
|
||||||
if (returnCount > 0)
|
if (returnCount > 0)
|
||||||
message += $"\n回传时效预警共计{returnCount}条,其中过去{hours}小时内新增的预警{returnLastNHoursCount}条,查看详情{url2}";
|
message += $"\n回传时效预警共计{returnCount}条,其中过去{hours}小时内新增的预警{returnLastNHoursCount}条";
|
||||||
if (completeCount > 0)
|
if (completeCount > 0)
|
||||||
message += $"\n轨迹完整预警共计{completeCount}条,其中过去{hours}小时内新增的预警{completeLastNHoursCount}条,查看详情{url3}";
|
message += $"\n轨迹完整预警共计{completeCount}条,其中过去{hours}小时内新增的预警{completeLastNHoursCount}条";
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 构建本地时区字符串标识 e.g UTC +8:00
|
||||||
|
private static string BuildLocalTimezoneStr()
|
||||||
|
{
|
||||||
|
var offset = TimeZoneInfo.Local.BaseUtcOffset;
|
||||||
|
var flag = offset.Hours > 0 ? "+" : "";
|
||||||
|
var offsetStr = offset.ToString().RemovePostFix(":00");
|
||||||
|
return $"UTC {flag}{offsetStr}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,9 @@ public static class DateTimeHelper
|
|||||||
{
|
{
|
||||||
if (timezone == null) return "--";
|
if (timezone == null) return "--";
|
||||||
|
|
||||||
if (Math.Abs(timezone.Value - GlobalConst.NoneTrackTimeZone) < 1) return "--";
|
if (Math.Abs(timezone.Value - GlobalConst.NoneTrackTimeZone) < 0.01f) return "--";
|
||||||
|
|
||||||
|
if (Math.Abs(timezone.Value) < 0.01f) return "GMT +00:00";
|
||||||
|
|
||||||
// 将小数形式的小时转换为时区偏移量
|
// 将小数形式的小时转换为时区偏移量
|
||||||
var hours = (int) timezone.Value; // 提取整数部分作为小时
|
var hours = (int) timezone.Value; // 提取整数部分作为小时
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user