clean:清理项目,不改变功能逻辑
This commit is contained in:
parent
e06aa10898
commit
e056585fc6
@ -41,14 +41,14 @@ public sealed class CompleteWarningRuleItemBO
|
||||
public static List<CompleteWarningRuleItemBO> From(EditCompleteWarningRuleItemInput input)
|
||||
{
|
||||
return input.Items.Select(x => new CompleteWarningRuleItemBO
|
||||
{
|
||||
Id = x.Id,
|
||||
WarningId = input.WarningId,
|
||||
OrderTypes = x.OrderTypes.Split(",").Select(int.Parse).ToHashSet(),
|
||||
CheckPointTrackStatusId = x.CheckPointTrackStatusId,
|
||||
RequireTrackStatus = x.RequireTrackStatus.Select(y => y.ToHashSet()).ToList(),
|
||||
NotifyUsers = x.NotifyUsers
|
||||
})
|
||||
{
|
||||
Id = x.Id,
|
||||
WarningId = input.WarningId,
|
||||
OrderTypes = x.OrderTypes.Split(",").Select(int.Parse).ToHashSet(),
|
||||
CheckPointTrackStatusId = x.CheckPointTrackStatusId,
|
||||
RequireTrackStatus = x.RequireTrackStatus.Select(y => y.ToHashSet()).ToList(),
|
||||
NotifyUsers = x.NotifyUsers
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ public sealed class ReturnWarningRuleItemBO
|
||||
/// </summary>
|
||||
public List<NotifyUserDto> NotifyUsers { get; set; }
|
||||
|
||||
|
||||
public static List<ReturnWarningRuleItemBO> From(EditReturnWarningRuleItemInput input)
|
||||
{
|
||||
var warningId = input.WarningId;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using SJZY.Track.Application.Contract.Dtos.Warning.Transport;
|
||||
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.WarningAggregate.Transport;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
|
||||
namespace SJZY.Track.Application.Services.Warning.Model;
|
||||
|
||||
@ -47,20 +47,23 @@ public sealed class TransportWarningSceneBO
|
||||
/// </summary>
|
||||
public int? AreaId { get; set; }
|
||||
|
||||
|
||||
public bool CanHitScene(OrderEntity order, List<RuleAreaInfoEntity>? ruleAreas)
|
||||
public bool CanHitScene(OrderEntity order, List<KpiAreaInfo>? ruleAreas)
|
||||
{
|
||||
// 是否中转
|
||||
if (IsTransit != null && IsTransit != order.IsTransit) return false;
|
||||
if (IsTransit != null && IsTransit != order.IsTransit)
|
||||
return false;
|
||||
|
||||
// 货物类型
|
||||
if (!string.IsNullOrWhiteSpace(CargoType) && order.CargoType != CargoType) return false;
|
||||
if (!string.IsNullOrWhiteSpace(CargoType) && order.CargoType != CargoType)
|
||||
return false;
|
||||
|
||||
// 启运港口
|
||||
if (!string.IsNullOrWhiteSpace(LeavePort) && order.LeavePort != LeavePort) return false;
|
||||
if (!string.IsNullOrWhiteSpace(LeavePort) && order.LeavePort != LeavePort)
|
||||
return false;
|
||||
|
||||
// 产品编码
|
||||
if (!string.IsNullOrWhiteSpace(ProductCode) && order.ProductCode != ProductCode) return false;
|
||||
if (!string.IsNullOrWhiteSpace(ProductCode) && order.ProductCode != ProductCode)
|
||||
return false;
|
||||
|
||||
// 月份
|
||||
if (!string.IsNullOrWhiteSpace(Months))
|
||||
@ -70,7 +73,8 @@ public sealed class TransportWarningSceneBO
|
||||
: Months.Split('/').Select(int.Parse).ToHashSet();
|
||||
// 订单创建时间月份
|
||||
var orderCreateTimeMonth = order.CreateTime.Month;
|
||||
if (!months.Contains(orderCreateTimeMonth)) return false;
|
||||
if (!months.Contains(orderCreateTimeMonth))
|
||||
return false;
|
||||
}
|
||||
|
||||
// 区域
|
||||
@ -90,17 +94,18 @@ public sealed class TransportWarningSceneBO
|
||||
}
|
||||
|
||||
// 城市是否匹配?
|
||||
if (!string.IsNullOrWhiteSpace(area.City) && order.ArrivalCity != area.City) return false;
|
||||
if (!string.IsNullOrWhiteSpace(area.City) && order.ArrivalCity != area.City)
|
||||
return false;
|
||||
|
||||
// 省份是否匹配?
|
||||
if (!string.IsNullOrWhiteSpace(area.Province) && order.ArrivalProvince != area.Province) return false;
|
||||
if (!string.IsNullOrWhiteSpace(area.Province) && order.ArrivalProvince != area.Province)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static TransportWarningSceneEntity ToEntity(TransportWarningSceneBO bo)
|
||||
{
|
||||
return new TransportWarningSceneEntity(
|
||||
@ -144,6 +149,11 @@ public sealed class TransportWarningSceneBO
|
||||
};
|
||||
}
|
||||
|
||||
public static List<TransportWarningSceneBO> From(List<TransportWarningSceneEntity> entities)
|
||||
{
|
||||
return entities.Select(From).ToList();
|
||||
}
|
||||
|
||||
public static TransportWarningSceneBO From(UpsertTransportWarningSceneInput input)
|
||||
{
|
||||
return new TransportWarningSceneBO
|
||||
|
||||
@ -105,7 +105,7 @@ public sealed class TransportWarningSceneRuleItemBO
|
||||
|
||||
public static List<TransportWarningSceneRuleItemEntity> ToEntities(List<TransportWarningSceneRuleItemBO> bos)
|
||||
{
|
||||
return bos.Select(x=>x.ToEntity()).ToList();
|
||||
return bos.Select(x => x.ToEntity()).ToList();
|
||||
}
|
||||
|
||||
public bool CanHitRule(int trackStatusId, HashSet<int> trackStatusIds)
|
||||
@ -115,9 +115,34 @@ public sealed class TransportWarningSceneRuleItemBO
|
||||
}
|
||||
|
||||
// 重新命中,用于规则扫描
|
||||
public bool CanReHit(HashSet<int> trackStatusIds)
|
||||
public bool CanHitRule(HashSet<int>? trackStatusIds)
|
||||
{
|
||||
if (trackStatusIds is null)
|
||||
return false;
|
||||
|
||||
return trackStatusIds.Contains(StartTrackStatusId) //存在起始
|
||||
&& !trackStatusIds.Contains(EndTrackStatusId); //不存在截止
|
||||
}
|
||||
|
||||
// 判断未命中规则
|
||||
public bool CanNotHit(HashSet<int>? trackStatusIds)
|
||||
{
|
||||
if (trackStatusIds is null) //轨迹状态为空
|
||||
return true;
|
||||
|
||||
if (!trackStatusIds.Contains(StartTrackStatusId)) //不存在起始
|
||||
return true;
|
||||
|
||||
return trackStatusIds.Contains(EndTrackStatusId); //存在起始并且存在截止,为完成态,也属于规则未命中
|
||||
}
|
||||
|
||||
// 完成态
|
||||
public bool CanCompleted(HashSet<int>? trackStatusIds)
|
||||
{
|
||||
if (trackStatusIds is null)
|
||||
return false;
|
||||
|
||||
return trackStatusIds.Contains(StartTrackStatusId) //存在起始
|
||||
&& trackStatusIds.Contains(EndTrackStatusId); //存在截止
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@ using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.Warning;
|
||||
using SJZY.Track.Application.Contract.Dtos.Warning.Return;
|
||||
using SJZY.Track.Application.Helpers;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers.Model;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers.Warning;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers;
|
||||
using SJZY.Track.Application.Services.Warning.Model;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.WarningAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Warning;
|
||||
@ -148,7 +148,7 @@ public class ReturnWarningService : ApplicationService
|
||||
result.Pagination.Total);
|
||||
|
||||
// 通知用户提取用户名称
|
||||
string ToUserNames(string notifyUsers)
|
||||
string ToUserNames(string? notifyUsers)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(notifyUsers))
|
||||
return string.Empty;
|
||||
|
||||
@ -3,8 +3,8 @@ using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.Warning;
|
||||
using SJZY.Track.Application.Contract.Dtos.Warning.Transport;
|
||||
using SJZY.Track.Application.Helpers;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers.Model;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers.Warning;
|
||||
using SJZY.Track.Application.Services.Warning.Handlers;
|
||||
using SJZY.Track.Application.Services.Warning.Model;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.WarningAggregate;
|
||||
@ -70,7 +70,7 @@ public class TransportWarningService : ApplicationService
|
||||
sb.Append($"{entity.CargoType}");
|
||||
// 月份
|
||||
if (!string.IsNullOrWhiteSpace(entity.Months))
|
||||
sb.Append($"/{entity.Months.Replace("/", string.Empty)}月份");
|
||||
sb.Append($"/{entity.Months.Replace("/", "|")}月份");
|
||||
// 中转
|
||||
if (entity.IsTransit != null)
|
||||
sb.Append($"/中转为{(entity.IsTransit.Value ? "是" : "否")}");
|
||||
@ -137,9 +137,9 @@ public class TransportWarningService : ApplicationService
|
||||
return new UnifyPageResultDto<TransportWarningDetailsDto>(new List<TransportWarningDetailsDto>(), input.PageIndex, input.PageSize, 0);
|
||||
}
|
||||
|
||||
// 查最新轨迹
|
||||
var orderIds = result.List.Select(x => x.OrderId).ToHashSet();
|
||||
var orderTracks = await _trackDetailsEsRepository.GetLatestListAsync(orderIds);
|
||||
var orderIdTrackDict = orderTracks.ToDictionary(x => x.OrderId);
|
||||
var orderIdTrackDict = await _trackDetailsEsRepository.GetLatestDictAsync(orderIds);
|
||||
|
||||
// :填充子系统名称(冗余?)
|
||||
// :填充客户简称(冗余?)
|
||||
@ -272,9 +272,12 @@ public class TransportWarningService : ApplicationService
|
||||
throw new BusinessException(message: $"预警规则场景不存在,WarningId=[{input.WarningId}]");
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
await _warningRuleRepository.DeleteTransportSceneAsync(input.WarningId, input.Id);
|
||||
// 处理删除
|
||||
|
||||
// 处理删除后
|
||||
await _transportWarningHandler.HandleSceneDeletedAsync(rule, TransportWarningSceneBO.From(scene));
|
||||
|
||||
return new UnifyResultDto(true);
|
||||
}
|
||||
|
||||
@ -300,7 +303,8 @@ public class TransportWarningService : ApplicationService
|
||||
}
|
||||
|
||||
var postRuleItems = TransportWarningSceneRuleItemBO.From(input);
|
||||
await _transportWarningHandler.HandleEditAsync(rule, ruleScene, postRuleItems);
|
||||
var sceneBo = TransportWarningSceneBO.From(ruleScene);
|
||||
await _transportWarningHandler.HandleEditAsync(rule, sceneBo, postRuleItems);
|
||||
|
||||
return new UnifyResultDto(true);
|
||||
}
|
||||
|
||||
@ -197,4 +197,11 @@ public class TrackDetailsIndex : IdBaseIndex
|
||||
/// 扩展信息字段,用与轨迹推送的附加字段
|
||||
/// </summary>
|
||||
public string? Extra { get; set; }
|
||||
|
||||
public DateTime GetUtc0TrackTime()
|
||||
{
|
||||
return Math.Abs(TrackTimeZone - GlobalConst.NoneTrackTimeZone) < 1f
|
||||
? TrackTime
|
||||
: TrackTime.AddHours(-TrackTimeZone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ public sealed class CompleteWarningDetailsIndex : IdBaseIndex
|
||||
{
|
||||
public string IndexName { get; set; }
|
||||
public int WarningId { get; set; }
|
||||
public int CompleteWarningRuleId { get; set; }
|
||||
public int CompleteWarningRuleItemId { get; set; }
|
||||
public string Version { get; set; }
|
||||
|
||||
//public string NotifyModes { get; set; } //通知方式,多个方式(,)分割 eg: 1,2
|
||||
|
||||
@ -28,7 +28,6 @@ public sealed class CompleteWarningRuleItemEntity : IFullAuditedBasicEntitys, IE
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public CompleteWarningRuleItemEntity(int id, int warningId, string orderTypes, int checkPointTrackStatusId, string requireTrackStatusIdExpression, string notifyUsers)
|
||||
{
|
||||
Id = id;
|
||||
@ -57,17 +56,32 @@ public sealed class CompleteWarningRuleItemEntity : IFullAuditedBasicEntitys, IE
|
||||
{
|
||||
var orderTypes = GetRuleOrderTypes();
|
||||
//没有命中订单类型
|
||||
if (!orderTypes.Contains(orderType)) return false;
|
||||
if (!orderTypes.Contains(orderType))
|
||||
return false;
|
||||
//没有命中状态检查点
|
||||
if (trackStatusId != CheckPointTrackStatusId) return false;
|
||||
if (trackStatusId != CheckPointTrackStatusId)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 查看是否能命中这个规则
|
||||
public bool CanHitRule(int orderType, HashSet<int> trackStatusIds)
|
||||
{
|
||||
var orderTypes = GetRuleOrderTypes();
|
||||
//没有命中订单类型
|
||||
if (!orderTypes.Contains(orderType))
|
||||
return false;
|
||||
|
||||
//缺失轨迹状态?
|
||||
return ExistsMissingTrackStatus(trackStatusIds);
|
||||
}
|
||||
|
||||
// 根据轨迹状态id集合判断是否缺失轨迹状态
|
||||
public bool ExistsMissingTrackStatus(HashSet<int> trackStatusIds)
|
||||
{
|
||||
if (trackStatusIds.Count == 0) return true;
|
||||
if (trackStatusIds.Count == 0)
|
||||
return true;
|
||||
|
||||
//组之间是并且关系,组内为或的关系
|
||||
var groups = GetRequireTrackStatusIdGroups();
|
||||
|
||||
@ -10,73 +10,80 @@ namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Return;
|
||||
public class ReturnWarningDetailsIndex : IdBaseIndex
|
||||
{
|
||||
public string IndexName { get; set; }
|
||||
//是否存在KPI考核,根据是否命中规则
|
||||
public bool IsExistsKpi => ReturnWarningRuleId != null && ReturnWarningRuleId > 0;
|
||||
public int? WarningId { get; set; }
|
||||
public int? ReturnWarningRuleId { get; set; }
|
||||
public string? Version { get; set; } //预警规则版本
|
||||
public float? ReturnTimeSpan { get; set; } //(冗余)回传时效(单位小时)
|
||||
//public string NotifyModes { get; set; } //通知方式,多个方式(,)分割 eg: 1,2
|
||||
public string NotifyUsers { get; set; } //通知人Json eg: [{"UserId":1,"UserName":"张三"},{"UserId":2,"UserName":"李四"}]
|
||||
|
||||
//订单信息
|
||||
public int SubSystemId { get; set; } //(冗余)子系统Id
|
||||
public string SubSystemName { get; set; } //(冗余)子系统名称
|
||||
public int CustomId { get; set; } //(冗余)客户Id
|
||||
public string CustomName { get; set; } //(冗余)客户名称
|
||||
public int OrderId { get; set; }
|
||||
public string OrderNo { get; set; } //订单号
|
||||
public int OrderType { get; set; } //(冗余)订单类型
|
||||
public string OrderTypeName { get; set; } //(冗余)订单类型名称
|
||||
//是否存在KPI考核,根据是否命中规则
|
||||
public bool IsExistsKpi => ReturnWarningRuleItemId != null && ReturnWarningRuleItemId > 0;
|
||||
public int? WarningId { get; set; }
|
||||
public int? ReturnWarningRuleItemId { get; set; }
|
||||
public string? Version { get; set; } //预警规则版本
|
||||
public float? ReturnTimeSpan { get; set; } //(冗余)回传时效(单位小时)
|
||||
|
||||
//轨迹信息-原始
|
||||
public int TrackStatusId { get; set; }
|
||||
public string TrackStatus { get; set; } //(冗余)轨迹状态名称
|
||||
public string? CompareFields { get; set; } //(冗余)比较字段
|
||||
public string? Extra { get; set; } //扩展字段
|
||||
public int TrackContentId { get; set; }
|
||||
public string TrackContent { get; set; }
|
||||
public string TrackCode { get; set; }
|
||||
public string TrackPlace { get; set; } //轨迹发生地
|
||||
public DateTime TrackTime { get; set; } //轨迹发生时间
|
||||
public float TrackTimeZone { get; set; } //轨迹发生时区
|
||||
public DateTime TrackCreateTime { get; set; } //轨迹创建时间
|
||||
//public string NotifyModes { get; set; } //通知方式,多个方式(,)分割 eg: 1,2
|
||||
public string? NotifyUsers { get; set; } //通知人Json eg: [{"UserId":1,"UserName":"张三"},{"UserId":2,"UserName":"李四"}]
|
||||
|
||||
//轨迹信息-映射后
|
||||
public string PushTrackStatus { get; set; } //(冗余)推送轨迹状态
|
||||
public string PushTrackCode { get; set; }
|
||||
public string PushTrackContent { get; set; }
|
||||
public string PushTrackEnContent { get; set; }
|
||||
//订单信息
|
||||
public int SubSystemId { get; set; } //(冗余)子系统Id
|
||||
public string SubSystemName { get; set; } //(冗余)子系统名称
|
||||
public int CustomId { get; set; } //(冗余)客户Id
|
||||
public string CustomName { get; set; } //(冗余)客户名称
|
||||
public int OrderId { get; set; }
|
||||
public string OrderNo { get; set; } //订单号
|
||||
public int OrderType { get; set; } //(冗余)订单类型
|
||||
public string OrderTypeName { get; set; } //(冗余)订单类型名称
|
||||
|
||||
//可变属性
|
||||
public DateTime? TrackReturnTime { get; set; } //轨迹回传时间, tips:只有回传成功了才写入
|
||||
public int RetryCount { get; set; } // 回传重试次数
|
||||
public int Status { get; set; } // 1:人工介入 2:重试中 3:推送完成 4:已关闭
|
||||
public string TrackEsId { get; set; }
|
||||
|
||||
//计算属性
|
||||
public long? ActualReturnTimeSpan { get; set; } //实际回传用时(单位毫秒)
|
||||
public long? SystemReturnTimeSpan { get; set; } //系统回传用时 (单位毫秒)
|
||||
public long TrackCreateTimeSpan { get; set; } //轨迹创建用时(单位毫秒)
|
||||
//轨迹信息-原始
|
||||
public int TrackStatusId { get; set; }
|
||||
public string TrackStatus { get; set; } //(冗余)轨迹状态名称
|
||||
public string? CompareFields { get; set; } //(冗余)比较字段
|
||||
public string? Extra { get; set; } //扩展字段
|
||||
public int TrackContentId { get; set; }
|
||||
public string TrackContent { get; set; }
|
||||
public string TrackCode { get; set; }
|
||||
public string TrackPlace { get; set; } //轨迹发生地
|
||||
public DateTime TrackTime { get; set; } //轨迹发生时间
|
||||
public float TrackTimeZone { get; set; } //轨迹发生时区
|
||||
public DateTime TrackCreateTime { get; set; } //轨迹创建时间
|
||||
|
||||
//审计属性
|
||||
public DateTime CreateTime { get; set; } // 预警创建时间
|
||||
public DateTime? UpdateTime { get; set; } // 明细更新时间
|
||||
//轨迹信息-映射后
|
||||
public string PushTrackStatus { get; set; } //(冗余)推送轨迹状态
|
||||
public string PushTrackCode { get; set; }
|
||||
public string PushTrackContent { get; set; }
|
||||
public string PushTrackEnContent { get; set; }
|
||||
|
||||
public bool MatchExtra(string? compareFields, string? extra)
|
||||
{
|
||||
// 匹配字段为空,明细明细字段为空
|
||||
if (string.IsNullOrWhiteSpace(compareFields))
|
||||
return string.IsNullOrWhiteSpace(CompareFields);
|
||||
//可变属性
|
||||
public DateTime? TrackReturnTime { get; set; } //轨迹回传时间, tips:只有回传成功了才写入
|
||||
|
||||
if (string.IsNullOrWhiteSpace(CompareFields))
|
||||
return false;
|
||||
public int RetryCount { get; set; } // 回传重试次数
|
||||
public int Status { get; set; } // 1:人工介入 2:重试中 3:推送完成 4:已关闭
|
||||
|
||||
if (!string.Equals(CompareFields, compareFields)) //todo:当比较字段存放到轨迹明细中,后面修改了比较字段后会发生什么?
|
||||
return false;
|
||||
//计算属性
|
||||
public long? ActualReturnTimeSpan { get; set; } //实际回传用时(单位毫秒)
|
||||
|
||||
if (string.IsNullOrEmpty(extra) || string.IsNullOrEmpty(Extra))
|
||||
return false;
|
||||
public long? SystemReturnTimeSpan { get; set; } //系统回传用时 (单位毫秒)
|
||||
public long TrackCreateTimeSpan { get; set; } //轨迹创建用时(单位毫秒)
|
||||
|
||||
return TextJsonHelper.EqJsonStringField(extra, Extra, compareFields);
|
||||
}
|
||||
//审计属性
|
||||
public DateTime CreateTime { get; set; } // 预警创建时间
|
||||
|
||||
public DateTime? UpdateTime { get; set; } // 明细更新时间
|
||||
|
||||
public bool MatchExtra(string? compareFields, string? extra)
|
||||
{
|
||||
// 匹配字段为空,明细明细字段为空
|
||||
if (string.IsNullOrWhiteSpace(compareFields))
|
||||
return string.IsNullOrWhiteSpace(CompareFields);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(CompareFields))
|
||||
return false;
|
||||
|
||||
if (!string.Equals(CompareFields, compareFields)) //todo:当比较字段存放到轨迹明细中,后面修改了比较字段后会发生什么?
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrEmpty(extra) || string.IsNullOrEmpty(Extra))
|
||||
return false;
|
||||
|
||||
return TextJsonHelper.EqJsonStringField(extra, Extra, compareFields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ public sealed class ReturnWarningRetryPushTaskEntity : IFullAuditedBasicEntitys,
|
||||
[SugarColumn(ColumnName = "Extra", ColumnDescription = "扩展字段")]
|
||||
public string? Extra { get; set; } //轨迹明细中的扩展字段
|
||||
|
||||
|
||||
[SugarColumn(ColumnName = "OptionType", ColumnDescription = "操作类型")]
|
||||
public string OptionType { get; set; } //操作类型,
|
||||
|
||||
@ -38,4 +37,4 @@ public sealed class ReturnWarningRetryPushTaskEntity : IFullAuditedBasicEntitys,
|
||||
|
||||
[SugarColumn(ColumnName = "IsClosed", ColumnDescription = "是否关闭")]
|
||||
public bool IsClosed { get; set; } // 已关闭的任务不会在执行
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ public sealed class ReturnWarningRuleItemEntity : IFullAuditedBasicEntitys, IEnt
|
||||
{
|
||||
}
|
||||
|
||||
public ReturnWarningRuleItemEntity(int id, int warningId,string trackStatusIds, float returnTimeSpan, string notifyUsers)
|
||||
public ReturnWarningRuleItemEntity(int id, int warningId, string trackStatusIds, float returnTimeSpan, string notifyUsers)
|
||||
{
|
||||
Id = id;
|
||||
WarningId = warningId;
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Signals;
|
||||
|
||||
public interface IWarningSignal
|
||||
public class IWarningSignal
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public WarningSignalType Type { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public virtual WarningSignalType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum WarningSignalType
|
||||
{
|
||||
轨迹新增 = 0,
|
||||
轨迹新增 = 0,
|
||||
|
||||
轨迹删除 = 1,
|
||||
轨迹删除 = 1,
|
||||
|
||||
轨迹更新 = 2,
|
||||
轨迹更新 = 2,
|
||||
}
|
||||
|
||||
public class WarningSignal
|
||||
{
|
||||
public string MessageId { get; set; } = Guid.NewGuid().ToString();
|
||||
public string OrderId { get; set; } // 分区键
|
||||
public WarningSignalType Type { get; set; } // 新增/修改/删除
|
||||
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
||||
public Dictionary<string, object> Payload { get; set; }
|
||||
}
|
||||
|
||||
@ -5,9 +5,9 @@ namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Signals;
|
||||
/// </summary>
|
||||
public sealed class TrackAddedSignal : IWarningSignal
|
||||
{
|
||||
public WarningSignalType Type { get; set; } = WarningSignalType.轨迹新增;
|
||||
public override WarningSignalType Type { get; set; } = WarningSignalType.轨迹新增;
|
||||
|
||||
public int OrderId { get; set; }
|
||||
public int TrackStatusId { get; set; }
|
||||
|
||||
public string EsId { get; set; } //新增轨迹的esId
|
||||
}
|
||||
|
||||
@ -7,9 +7,7 @@ namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Signals;
|
||||
/// </summary>
|
||||
public class TrackDeletedSignal : IWarningSignal
|
||||
{
|
||||
public WarningSignalType Type { get; set; } = WarningSignalType.轨迹删除;
|
||||
public override WarningSignalType Type { get; set; } = WarningSignalType.轨迹删除;
|
||||
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public TrackDetailsIndex DeletedTrack { get; set; } //已删除的轨迹
|
||||
}
|
||||
public TrackDetailsIndex DeletedTrack { get; set; } //已删除的轨迹
|
||||
}
|
||||
@ -2,15 +2,12 @@ using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
|
||||
namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Signals;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹更新信号
|
||||
/// </summary>
|
||||
public class TrackUpdatedSignal:IWarningSignal
|
||||
public class TrackUpdatedSignal : IWarningSignal
|
||||
{
|
||||
public WarningSignalType Type { get; set; } = WarningSignalType.轨迹更新;
|
||||
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public TrackDetailsIndex BeforeChangeTrack { get; set; } //更改前的轨迹明细
|
||||
}
|
||||
public override WarningSignalType Type { get; set; } = WarningSignalType.轨迹更新;
|
||||
|
||||
public TrackDetailsIndex BeforeChangeTrack { get; set; } //更改前的轨迹明细
|
||||
}
|
||||
@ -19,7 +19,6 @@ public sealed class TransportWarningDetailsGenerateTaskEntity : IFullAuditedBasi
|
||||
[SugarColumn(ColumnName = "WarningSceneRuleItemId", ColumnDescription = "运输时效预警规则项Id")]
|
||||
public int WarningSceneRuleItemId { get; set; } //运输时效预警规则项目Id
|
||||
|
||||
|
||||
[SugarColumn(ColumnName = "StartTrackStatusId", ColumnDescription = "起始轨迹状态Id")]
|
||||
public int StartTrackStatusId { get; set; } //起始轨迹状态Id
|
||||
|
||||
@ -38,7 +37,6 @@ public sealed class TransportWarningDetailsGenerateTaskEntity : IFullAuditedBasi
|
||||
[SugarColumn(ColumnName = "PlanExecutionTime", ColumnDescription = "计划执行时间")]
|
||||
public DateTime PlanExecutionTime { get; set; } //计划执行时间 tips:缓存【起始轨迹发生时间】+【起始轨迹生成预警时间】 结果,用于查询时过滤
|
||||
|
||||
|
||||
[SugarColumn(ColumnName = "IsClosed", ColumnDescription = "是否关闭")]
|
||||
public bool IsClosed { get; set; } //是否关闭,执行完成被关闭/手动关闭
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
namespace SJZY.Track.Domain.Aggregates.WarningAggregate.Transport;
|
||||
|
||||
// 运输时效场景
|
||||
|
||||
@ -59,4 +59,17 @@ public sealed class TransportWarningSceneRuleItemEntity : IFullAuditedBasicEntit
|
||||
return trackStatusIds.Contains(StartTrackStatusId) //存在起始
|
||||
&& !trackStatusIds.Contains(EndTrackStatusId); //不存在截止
|
||||
}
|
||||
}
|
||||
|
||||
// 判断未命中规则
|
||||
public bool CanNotHit(HashSet<int>? trackStatusIds)
|
||||
{
|
||||
if (trackStatusIds is null) //轨迹状态为空
|
||||
return true;
|
||||
|
||||
if (!trackStatusIds.Contains(StartTrackStatusId)) //不存在起始
|
||||
return true;
|
||||
|
||||
return trackStatusIds.Contains(EndTrackStatusId); //存在起始并且存在截止,为完成态,也属于规则未命中
|
||||
}
|
||||
|
||||
}
|
||||
@ -30,12 +30,10 @@ public sealed class WarningRuleEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "Version", ColumnDescription = "规则版本,用于标识规则产物(如预警信息)")]
|
||||
public string Version { get; set; } //规则版本,用于标识规则产物(如预警信息)
|
||||
|
||||
|
||||
public WarningRuleEntity()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public WarningRuleEntity(int id, string name, int subSystemId, int customId, bool isEnabled, int warningType, string version)
|
||||
{
|
||||
Id = id;
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
namespace SJZY.Track.Domain.Dtos.TrackDetails;
|
||||
|
||||
public class GetOrderTracksDictVO
|
||||
{
|
||||
public HashSet<string>? EsIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
public HashSet<int>? TrackStatusIds { get; set; }
|
||||
public HashSet<int>? TrackContentIds { get; set; }
|
||||
public HashSet<string>? TrackCodes { get; set; }
|
||||
|
||||
// 订单id 与 轨迹内容id 同时满足
|
||||
public Dictionary<int, HashSet<int>>? OrderIdTrackContentIdsDict { get; set; }
|
||||
|
||||
// 订单id 与 轨迹code 同时满足
|
||||
public Dictionary<int, HashSet<string>>? OrderIdTrackCodesDict { get; set; }
|
||||
|
||||
// 订单id 与 轨迹状态id 同时满足
|
||||
public Dictionary<int, HashSet<int>>? OrderIdTracksStatusIdsDict { get; set; }
|
||||
|
||||
public bool HasEsIds => EsIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
public bool HasTrackStatusIds => TrackStatusIds?.Count > 0;
|
||||
public bool HasTrackContentIds => TrackContentIds?.Count > 0;
|
||||
public bool HasTrackCodes => TrackCodes?.Count > 0;
|
||||
public bool HasOrderIdTrackContentIdsDict => OrderIdTrackContentIdsDict?.Count > 0;
|
||||
public bool HasOrderIdTrackCodesDict => OrderIdTrackCodesDict?.Count > 0;
|
||||
public bool HasOrderIdTracksStatusIdDict => OrderIdTracksStatusIdsDict?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class BulkCloseCompleteWarningDetailsVO
|
||||
{
|
||||
// 完整预警默认关注状态
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
CompleteWarningStatus.待处理.GetHashCode(),
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class BulkCloseReturnWarningDetailsVO
|
||||
{
|
||||
// 回传时效预警默认关注状态
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
ReturnWarningStatus.人工介入.GetHashCode(),
|
||||
ReturnWarningStatus.重试中.GetHashCode()
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class BulkCloseTransportWarningDetailsVO
|
||||
{
|
||||
// 运输时效预警默认关注状态
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
TransportWarningStatus.即将超时.GetHashCode(),
|
||||
TransportWarningStatus.已超时.GetHashCode()
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? SceneIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasSceneIds => SceneIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class GetCompleteWarningDetailsVO
|
||||
{
|
||||
// 完整预警默认关注状态
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
CompleteWarningStatus.待处理.GetHashCode()
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
|
||||
// 订单id 与 检查点轨迹状态ids 同时满足
|
||||
public Dictionary<int, HashSet<int>>? OrderIdCheckTracksStatusIdsDict { get; set; }
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
public bool HasOrderIdCheckTracksStatusIdsDict => OrderIdCheckTracksStatusIdsDict?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class GetReturnWarningDetailsVO
|
||||
{
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
ReturnWarningStatus.人工介入.GetHashCode(),
|
||||
ReturnWarningStatus.重试中.GetHashCode()
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
public Dictionary<int, HashSet<int>>? OrderIdTrackContentIdsDict { get; set; }
|
||||
public Dictionary<int, HashSet<string>>? OrderIdTrackEsIdsDict { get; set; }
|
||||
|
||||
public HashSet<(int SubSystemId, int CustomId, int TrackContentId)>? PushConfigLinks { get; set; }
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
public bool HasOrderIdTrackContentIdsDict => OrderIdTrackContentIdsDict?.Count > 0;
|
||||
public bool HasOrderIdTrackEsIdsDict => OrderIdTrackEsIdsDict?.Count > 0;
|
||||
public bool HasPushConfigLinks => PushConfigLinks?.Count > 0;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
using SJZY.Track.Domain.Enums;
|
||||
|
||||
namespace SJZY.Track.Domain.Dtos.Warning;
|
||||
|
||||
public class GetTransportWarningDetailsVO
|
||||
{
|
||||
// 运输时效预警默认关注状态
|
||||
private static readonly HashSet<int> DefaultFollowStatus = new(2)
|
||||
{
|
||||
TransportWarningStatus.即将超时.GetHashCode(),
|
||||
TransportWarningStatus.已超时.GetHashCode()
|
||||
};
|
||||
|
||||
public HashSet<string>? DetailsIds { get; set; }
|
||||
public HashSet<int>? RuleItemIds { get; set; }
|
||||
public HashSet<int>? SceneIds { get; set; }
|
||||
public HashSet<int>? WarningIds { get; set; }
|
||||
public HashSet<int>? OrderIds { get; set; }
|
||||
public HashSet<int> Status { get; set; } = DefaultFollowStatus;
|
||||
|
||||
// 订单id 与 起始轨迹状态ids 同时满足
|
||||
public Dictionary<int, HashSet<int>>? OrderIdStartTracksStatusIdsDict { get; set; }
|
||||
|
||||
public bool HasDetailsIds => DetailsIds?.Count > 0;
|
||||
public bool HasRuleItemIds => RuleItemIds?.Count > 0;
|
||||
public bool HasSceneIds => SceneIds?.Count > 0;
|
||||
public bool HasWarningIds => WarningIds?.Count > 0;
|
||||
public bool HasOrderIds => OrderIds?.Count > 0;
|
||||
public bool HasOrderIdStartTracksStatusIdDict => OrderIdStartTracksStatusIdsDict?.Count > 0;
|
||||
}
|
||||
@ -110,4 +110,24 @@ public class KpiAreaRepository : BasicRepository<RuleAreaEntity>, IKpiAreaReposi
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task<Dictionary<int, List<KpiAreaInfo>>> GetAreaInfosDictByAreaId(HashSet<int> areaIds)
|
||||
{
|
||||
var list = await Context.Queryable<RuleAreaInfoEntity>()
|
||||
.InnerJoin<RuleAreaEntity>((r, i) => r.AreaId == i.Id)
|
||||
.Where((r, i) => areaIds.Contains(i.Id))
|
||||
.Select((r, i) => new KpiAreaInfo
|
||||
{
|
||||
AreaId = r.AreaId,
|
||||
CountryCode = r.CountryCode,
|
||||
LeftPostcode = r.LeftPostcode,
|
||||
City = r.City,
|
||||
Province = r.Province,
|
||||
RightPostcode = r.RightPostcode
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return list.GroupBy(x => x.AreaId)
|
||||
.ToDictionary(x => x.Key, y => y.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,15 +5,8 @@ using SJZY.Track.Domain.Aggregates.WarningAggregate.Transport;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
public sealed class WarningTaskRepository : BasicRepository<WarningNotifyTaskEntity>, IWarningTaskRepository, ITransientDependency
|
||||
public sealed class WarningTaskRepository : BasicRepository<WarningNotifyTaskEntity>, IWarningTaskRepository
|
||||
{
|
||||
//public ISqlSugarClient Context { get; set; }
|
||||
|
||||
public WarningTaskRepository()
|
||||
{
|
||||
//Context = SqlsugarScopeBasic.GetContextSafely("default");
|
||||
}
|
||||
|
||||
#region 预警通知任务
|
||||
|
||||
public Task<List<WarningNotifyTaskEntity>> ScanMayNeedExecutedTaskAsync()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user