Merge branch 'S07' into test
This commit is contained in:
commit
a8e7491432
@ -77,6 +77,7 @@ public class TrackChangeAfterUpdateOrderEventHandler : ITransientDependency, ICa
|
|||||||
await _orderRepository.UpdateRangeAsync(updateOrders, x => new
|
await _orderRepository.UpdateRangeAsync(updateOrders, x => new
|
||||||
{
|
{
|
||||||
x.IsCompleted,
|
x.IsCompleted,
|
||||||
|
x.LatestTrackStatus,
|
||||||
x.LatestTrackContent,
|
x.LatestTrackContent,
|
||||||
x.LatestTrackEnContent,
|
x.LatestTrackEnContent,
|
||||||
x.LatestTrackPlace,
|
x.LatestTrackPlace,
|
||||||
@ -98,9 +99,9 @@ public class TrackChangeAfterUpdateOrderEventHandler : ITransientDependency, ICa
|
|||||||
return await _orderRepository.GetListAsync(order => orderIds.Contains(order.Id), order => new OrderEntity
|
return await _orderRepository.GetListAsync(order => orderIds.Contains(order.Id), order => new OrderEntity
|
||||||
{
|
{
|
||||||
Id = order.Id,
|
Id = order.Id,
|
||||||
|
|
||||||
// 轨迹
|
// 轨迹
|
||||||
IsCompleted = order.IsCompleted,
|
IsCompleted = order.IsCompleted,
|
||||||
|
LatestTrackStatus = order.LatestTrackStatus,
|
||||||
LatestTrackContent = order.LatestTrackContent,
|
LatestTrackContent = order.LatestTrackContent,
|
||||||
LatestTrackEnContent = order.LatestTrackEnContent,
|
LatestTrackEnContent = order.LatestTrackEnContent,
|
||||||
LatestTrackPlace = order.LatestTrackPlace,
|
LatestTrackPlace = order.LatestTrackPlace,
|
||||||
|
|||||||
@ -10,42 +10,61 @@ public sealed class TransportWarningSceneBO
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 场景唯一id (传0视为新增)
|
/// 场景唯一id (传0视为新增)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预警规则主体id
|
/// 预警规则主体id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int WarningId { get; set; }
|
public int WarningId { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否中转(单一)
|
|
||||||
/// </summary>
|
|
||||||
public bool? IsTransit { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 货物类型(多个,分割)
|
/// 货物类型(多个,分割)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? CargoType { get; set; }
|
public string? CargoType { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 起运港口(多个,分割)
|
|
||||||
/// </summary>
|
|
||||||
public string? LeavePort { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 产品编码(多个,分割)
|
|
||||||
/// </summary>
|
|
||||||
public string? ProductCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 月份(多个/分割)
|
/// 月份(多个/分割)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Months { get; set; }
|
public string? Months { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 区域Id(单一)
|
/// 区域Id(单一)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? AreaId { get; set; }
|
public int? AreaId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否中转(单一)
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsTransit { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起运港口(多个,分割)
|
||||||
|
/// </summary>
|
||||||
|
public string? LeavePort { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产品编码(多个,分割)
|
||||||
|
/// </summary>
|
||||||
|
public string? ProductCode { get; }
|
||||||
|
|
||||||
|
public TransportWarningSceneBO(int id, int warningId, string? cargoType, string? months, int? areaId, bool? isTransit, string? leavePort, string? productCode)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
WarningId = warningId;
|
||||||
|
CargoType = cargoType;
|
||||||
|
|
||||||
|
// 如果有月份则排序之后在写入
|
||||||
|
if (!string.IsNullOrWhiteSpace(months))
|
||||||
|
{
|
||||||
|
var sorted = months.Split('/').Select(int.Parse).OrderBy(x => x).ToList();
|
||||||
|
Months = string.Join('/', sorted);
|
||||||
|
}
|
||||||
|
|
||||||
|
AreaId = areaId;
|
||||||
|
IsTransit = isTransit;
|
||||||
|
LeavePort = leavePort;
|
||||||
|
ProductCode = productCode;
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanHitScene(OrderEntity order, List<KpiAreaInfo>? ruleAreas)
|
public bool CanHitScene(OrderEntity order, List<KpiAreaInfo>? ruleAreas)
|
||||||
{
|
{
|
||||||
@ -136,17 +155,16 @@ public sealed class TransportWarningSceneBO
|
|||||||
|
|
||||||
public static TransportWarningSceneBO From(TransportWarningSceneEntity entity)
|
public static TransportWarningSceneBO From(TransportWarningSceneEntity entity)
|
||||||
{
|
{
|
||||||
return new TransportWarningSceneBO
|
return new TransportWarningSceneBO(
|
||||||
{
|
entity.Id,
|
||||||
Id = entity.Id,
|
entity.WarningId,
|
||||||
WarningId = entity.WarningId,
|
entity.CargoType,
|
||||||
CargoType = entity.CargoType,
|
entity.Months,
|
||||||
Months = entity.Months,
|
entity.AreaId,
|
||||||
AreaId = entity.AreaId,
|
entity.IsTransit,
|
||||||
IsTransit = entity.IsTransit,
|
entity.LeavePort,
|
||||||
LeavePort = entity.LeavePort,
|
entity.ProductCode
|
||||||
ProductCode = entity.ProductCode
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TransportWarningSceneBO> From(List<TransportWarningSceneEntity> entities)
|
public static List<TransportWarningSceneBO> From(List<TransportWarningSceneEntity> entities)
|
||||||
@ -156,16 +174,36 @@ public sealed class TransportWarningSceneBO
|
|||||||
|
|
||||||
public static TransportWarningSceneBO From(UpsertTransportWarningSceneInput input)
|
public static TransportWarningSceneBO From(UpsertTransportWarningSceneInput input)
|
||||||
{
|
{
|
||||||
return new TransportWarningSceneBO
|
return new TransportWarningSceneBO(
|
||||||
{
|
input.Id,
|
||||||
Id = input.Id,
|
input.WarningId,
|
||||||
WarningId = input.WarningId,
|
input.CargoType,
|
||||||
CargoType = input.CargoType,
|
input.Months,
|
||||||
Months = input.Months,
|
input.AreaId,
|
||||||
AreaId = input.AreaId,
|
input.IsTransit,
|
||||||
IsTransit = input.IsTransit,
|
input.LeavePort,
|
||||||
LeavePort = input.LeavePort,
|
input.ProductCode
|
||||||
ProductCode = input.ProductCode
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
private bool Equals(TransportWarningSceneBO other)
|
||||||
|
{
|
||||||
|
return WarningId == other.WarningId
|
||||||
|
&& IsTransit == other.IsTransit
|
||||||
|
&& CargoType == other.CargoType
|
||||||
|
&& LeavePort == other.LeavePort
|
||||||
|
&& ProductCode == other.ProductCode
|
||||||
|
&& Months == other.Months
|
||||||
|
&& AreaId == other.AreaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return ReferenceEquals(this, obj) || obj is TransportWarningSceneBO other && Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(WarningId, IsTransit, CargoType, LeavePort, ProductCode, Months, AreaId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,14 @@ public class TransportWarningService : ApplicationService
|
|||||||
// 月份
|
// 月份
|
||||||
if (!string.IsNullOrWhiteSpace(entity.Months))
|
if (!string.IsNullOrWhiteSpace(entity.Months))
|
||||||
list.Add($"{entity.Months.Replace("/", ",")}月份");
|
list.Add($"{entity.Months.Replace("/", ",")}月份");
|
||||||
|
// 区域名称
|
||||||
|
if (entity.AreaId != null && areaNameDict != null)
|
||||||
|
{
|
||||||
|
var areaName = areaNameDict.GetValueOrDefault(entity.AreaId.Value);
|
||||||
|
if (!string.IsNullOrWhiteSpace(areaName))
|
||||||
|
list.Add($"{areaName}");
|
||||||
|
}
|
||||||
|
|
||||||
// 中转
|
// 中转
|
||||||
if (entity.IsTransit != null)
|
if (entity.IsTransit != null)
|
||||||
list.Add($"中转为{(entity.IsTransit.Value ? "是" : "否")}");
|
list.Add($"中转为{(entity.IsTransit.Value ? "是" : "否")}");
|
||||||
@ -113,13 +121,6 @@ public class TransportWarningService : ApplicationService
|
|||||||
// 产品编码
|
// 产品编码
|
||||||
if (!string.IsNullOrWhiteSpace(entity.ProductCode))
|
if (!string.IsNullOrWhiteSpace(entity.ProductCode))
|
||||||
list.Add($"{entity.ProductCode}");
|
list.Add($"{entity.ProductCode}");
|
||||||
// 区域名称
|
|
||||||
if (entity.AreaId != null && areaNameDict != null)
|
|
||||||
{
|
|
||||||
var areaName = areaNameDict.GetValueOrDefault(entity.AreaId.Value);
|
|
||||||
if (!string.IsNullOrWhiteSpace(areaName))
|
|
||||||
list.Add($"{areaName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Join(separator, list);
|
return string.Join(separator, list);
|
||||||
}
|
}
|
||||||
@ -300,20 +301,21 @@ public class TransportWarningService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var postBo = TransportWarningSceneBO.From(input);
|
var postBo = TransportWarningSceneBO.From(input);
|
||||||
// 查出旧场景
|
|
||||||
var oldScene = await _warningRuleRepository.GetTransportSceneAsync(input.WarningId, input.Id);
|
|
||||||
var oldBo = oldScene != null ? TransportWarningSceneBO.From(oldScene) : null;
|
|
||||||
|
|
||||||
// 如果有月份则排序之后在写入
|
// 查出这个规则主体下的所有场景
|
||||||
if (!string.IsNullOrWhiteSpace(postBo.Months))
|
var oldScenes = await _warningRuleRepository.GetTransportSceneAsync(input.WarningId);
|
||||||
|
var oldBos = oldScenes.Count > 0 ? TransportWarningSceneBO.From(oldScenes) : Empty<TransportWarningSceneBO>.List;
|
||||||
|
|
||||||
|
// 验证规则场景是否重复
|
||||||
|
if (oldBos.Any(old => old.Equals(postBo) && old.Id != postBo.Id))
|
||||||
{
|
{
|
||||||
var sorted = postBo.Months.Split('/').Select(int.Parse).OrderBy(x => x).ToList();
|
throw new BusinessException(message: "同一规则主体下,不允许出现因素完全相同的场景!");
|
||||||
postBo.Months = string.Join('/', sorted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新或者新增
|
// 更新或者新增
|
||||||
var id = await _warningRuleRepository.UpsertTransportSceneReturnIdAsync(postBo.ToEntity());
|
var id = await _warningRuleRepository.UpsertTransportSceneReturnIdAsync(postBo.ToEntity());
|
||||||
|
|
||||||
|
var oldBo = oldBos.FirstOrDefault(x => x.Id == postBo.Id);
|
||||||
if (oldBo != null)
|
if (oldBo != null)
|
||||||
await _transportWarningHandler.HandleSceneChangedAsync(rule, oldBo, postBo);
|
await _transportWarningHandler.HandleSceneChangedAsync(rule, oldBo, postBo);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user