Merge remote-tracking branch 'origin/S04轨迹预警' into S04轨迹预警
This commit is contained in:
commit
02edff1580
@ -0,0 +1,42 @@
|
|||||||
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
|
|
||||||
|
public class CreateWarningInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模板名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子系统id
|
||||||
|
/// </summary>
|
||||||
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户id
|
||||||
|
/// </summary>
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知方式
|
||||||
|
/// </summary>
|
||||||
|
public NotifyMode NotifyMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知模板
|
||||||
|
/// </summary>
|
||||||
|
public string NotifyTemplate { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态跨度列表
|
||||||
|
/// </summary>
|
||||||
|
public List<WarningNitifyDto> TrackStatusSpans { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警因素列表。
|
||||||
|
/// </summary>
|
||||||
|
public List<WarningFactorDto> WarningFactors { get; set; } = new();
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
|
|
||||||
|
public class EditWarningOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模板名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 子系统id
|
||||||
|
/// </summary>
|
||||||
|
public int SubSystemId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户id
|
||||||
|
/// </summary>
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知方式
|
||||||
|
/// </summary>
|
||||||
|
public NotifyMode NotifyMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知模板
|
||||||
|
/// </summary>
|
||||||
|
public string NotifyTemplate { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知列表
|
||||||
|
/// </summary>
|
||||||
|
public List<WarningNotifyWithIdDto> TrackStatusSpans { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警因素列表。
|
||||||
|
/// </summary>
|
||||||
|
public List<WarningFactorWithIdDto> WarningFactors { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WarningNotifyWithIdDto: WarningNitifyDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 通知id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WarningFactorWithIdDto : WarningFactorDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 因素id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
|
|
||||||
|
public class UpdateWarningInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 预警id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模板名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知方式
|
||||||
|
/// </summary>
|
||||||
|
public NotifyMode NotifyMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知模板
|
||||||
|
/// </summary>
|
||||||
|
public string NotifyTemplate { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知列表
|
||||||
|
/// </summary>
|
||||||
|
public List<NotifyDto> Notifies { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NotifyDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 通知id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知人id
|
||||||
|
/// </summary>
|
||||||
|
public int NotifyUserId { get; set; }
|
||||||
|
}
|
||||||
@ -1,8 +1,10 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
using SJZY.Track.Domain.Enums;
|
using SJZY.Track.Domain.Enums;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Helpers;
|
namespace SJZY.Track.Application.Helpers;
|
||||||
|
|
||||||
@ -14,9 +16,14 @@ public class ForewarningHelper
|
|||||||
/// <param name="statusSpans"></param>
|
/// <param name="statusSpans"></param>
|
||||||
/// <param name="factors"></param>
|
/// <param name="factors"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static List<WarningRuleEntity> CalcRuleList(List<TrackStatusSpanDto> statusSpans,
|
public static List<WarningRuleEntity> CalcRuleList(List<WarningNitifyDto> statusSpans,
|
||||||
List<WarningFactorDto> factors)
|
List<WarningFactorDto> factors)
|
||||||
{
|
{
|
||||||
|
if (statusSpans.Count == 0 || factors.Count == 0)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "轨迹状态区间或因素列表为空");
|
||||||
|
}
|
||||||
|
|
||||||
var len = statusSpans.Count * factors.Select(f => f.FactorValue.Count).Aggregate((pre, cur) => pre * cur);
|
var len = statusSpans.Count * factors.Select(f => f.FactorValue.Count).Aggregate((pre, cur) => pre * cur);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
@ -32,19 +39,18 @@ public class ForewarningHelper
|
|||||||
foreach (var factor in factors)
|
foreach (var factor in factors)
|
||||||
{
|
{
|
||||||
var factorValueCount = factor.FactorValue.Count;
|
var factorValueCount = factor.FactorValue.Count;
|
||||||
repeat /= factor.FactorValue.Count; // repeat梯度下降,与times成反比关系
|
|
||||||
|
|
||||||
for (int time = 0; time < len / repeat / factorValueCount; time++)
|
// repeat梯度下降,与times成反比关系
|
||||||
{
|
repeat /= factor.FactorValue.Count;
|
||||||
FillFactor(factor, rules, repeat, time);
|
var times = len / repeat / factorValueCount;
|
||||||
}
|
FillFactor(factor, rules, repeat, times);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FillStatus(List<TrackStatusSpanDto> statusSpans, List<WarningRuleEntity> rules, int repeat)
|
private static void FillStatus(List<WarningNitifyDto> statusSpans, List<WarningRuleEntity> rules, int repeat)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < statusSpans.Count; i++)
|
for (var i = 0; i < statusSpans.Count; i++)
|
||||||
{
|
{
|
||||||
@ -59,70 +65,77 @@ public class ForewarningHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FillFactor(WarningFactorDto factor, List<WarningRuleEntity> rules, int repeat, int time)
|
private static void FillFactor(WarningFactorDto factor, List<WarningRuleEntity> rules, int repeat, int times)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < factor.FactorValue.Count * time; i++)
|
var row = 0;
|
||||||
|
for (var i = 0; i < times; i++)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < repeat; j++)
|
foreach (var value in factor.FactorValue)
|
||||||
{
|
{
|
||||||
var row = i * repeat + j;
|
|
||||||
var value = factor.FactorValue[row];
|
|
||||||
var strValue = value.ToString();
|
var strValue = value.ToString();
|
||||||
switch (factor.FactorType)
|
if (strValue.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
case RuleFactorType.CargoType:
|
throw new BusinessException(message: "因素值不能为空");
|
||||||
if (value.Type is not JTokenType.String)
|
}
|
||||||
{
|
|
||||||
throw new BusinessException(message: "货物类型只接收字符串");
|
|
||||||
}
|
|
||||||
|
|
||||||
rules[row].CargoType = strValue;
|
for (var j = 0; j < repeat; j++, row++)
|
||||||
break;
|
{
|
||||||
case RuleFactorType.Months:
|
switch (factor.FactorType)
|
||||||
foreach (var item in strValue.Split("/"))
|
{
|
||||||
{
|
case RuleFactorType.CargoType:
|
||||||
if (!int.TryParse(item, out var month) || month < 1 || month > 12)
|
if (value.Type is not JTokenType.String)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "请输入合法的月份,多个月份请以'/'连接");
|
throw new BusinessException(message: "货物类型只接收字符串");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rules[row].Months = strValue;
|
rules[row].CargoType = strValue;
|
||||||
break;
|
break;
|
||||||
case RuleFactorType.Areas:
|
case RuleFactorType.Months:
|
||||||
if (value.Type is not JTokenType.Integer)
|
foreach (var item in strValue.Split("/"))
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "分区请传id");
|
if (!int.TryParse(item, out var month) || month < 1 || month > 12)
|
||||||
}
|
{
|
||||||
|
throw new BusinessException(message: "请输入合法的月份,多个月份请以'/'连接");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rules[row].AreaId = int.Parse(strValue);
|
rules[row].Months = strValue;
|
||||||
break;
|
break;
|
||||||
case RuleFactorType.IsTransit:
|
case RuleFactorType.Areas:
|
||||||
if (value.Type is not JTokenType.Boolean)
|
if (value.Type is not JTokenType.Integer)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "是否中转只接收bool类型");
|
throw new BusinessException(message: "分区请传id");
|
||||||
}
|
}
|
||||||
|
|
||||||
rules[row].IsTransit = bool.Parse(strValue);
|
rules[row].AreaId = int.Parse(strValue);
|
||||||
break;
|
break;
|
||||||
case RuleFactorType.LeavePort:
|
case RuleFactorType.IsTransit:
|
||||||
if (value.Type is not JTokenType.String)
|
if (value.Type is not JTokenType.Boolean)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "货物类型只接收字符串");
|
throw new BusinessException(message: "是否中转只接收bool类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
rules[row].LeavePort = strValue;
|
rules[row].IsTransit = bool.Parse(strValue);
|
||||||
break;
|
break;
|
||||||
case RuleFactorType.ProductCode:
|
case RuleFactorType.LeavePort:
|
||||||
if (value.Type is not JTokenType.String)
|
if (value.Type is not JTokenType.String)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: "货物类型只接收字符串");
|
throw new BusinessException(message: "货物类型只接收字符串");
|
||||||
}
|
}
|
||||||
|
|
||||||
rules[row].ProductCode = strValue;
|
rules[row].LeavePort = strValue;
|
||||||
break;
|
break;
|
||||||
default:
|
case RuleFactorType.ProductCode:
|
||||||
throw new BusinessException(message: $"不支持的因素:{factor.FactorType}");
|
if (value.Type is not JTokenType.String)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "货物类型只接收字符串");
|
||||||
|
}
|
||||||
|
|
||||||
|
rules[row].ProductCode = strValue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BusinessException(message: $"不支持的因素:{factor.FactorType}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,4 +149,41 @@ public class ForewarningHelper
|
|||||||
Value = x.FactorValue.ToJson()
|
Value = x.FactorValue.ToJson()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<WarningNotifyEntity> MapNotifyEntities(CreateWarningInput input)
|
||||||
|
{
|
||||||
|
return input.TrackStatusSpans.Select(x => new WarningNotifyEntity
|
||||||
|
{
|
||||||
|
StartTrackStatusId = x.StartTrackStatusId,
|
||||||
|
EndTrackStatusId = x.EndTrackStatusId,
|
||||||
|
NotifyMode = input.NotifyMode,
|
||||||
|
NotifyTemplate = input.NotifyTemplate,
|
||||||
|
NotifyUserId = x.NotifyUserId
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EditWarningOutput MapWarningSummary(WarningEntity warning)
|
||||||
|
{
|
||||||
|
return new EditWarningOutput
|
||||||
|
{
|
||||||
|
Name = warning.Name,
|
||||||
|
SubSystemId = warning.SubSystemId,
|
||||||
|
CustomerId = warning.CustomerId,
|
||||||
|
NotifyMode = warning.WarningNotifies.First().NotifyMode,
|
||||||
|
NotifyTemplate = warning.WarningNotifies.First().NotifyTemplate,
|
||||||
|
TrackStatusSpans = warning.WarningNotifies.Select(x => new WarningNotifyWithIdDto
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
StartTrackStatusId = x.StartTrackStatusId,
|
||||||
|
EndTrackStatusId = x.EndTrackStatusId,
|
||||||
|
NotifyUserId = x.NotifyUserId,
|
||||||
|
}).ToList(),
|
||||||
|
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
FactorType = x.Type,
|
||||||
|
FactorValue = JArray.Parse(x.Value),
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -17,6 +17,18 @@ public class ForewarningService : ApplicationService
|
|||||||
_warningRepository = warningRepository;
|
_warningRepository = warningRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取预警分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputVo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("GetWarningPageList")]
|
||||||
|
public async Task<UnifyPageResultDto<WarningPageOutput>> GetWarningPageList(GetWarningPageInputVo inputVo)
|
||||||
|
{
|
||||||
|
if (!inputVo.KeyWord.IsNullOrEmpty()) inputVo.KeyWord = inputVo.KeyWord!.Trim();
|
||||||
|
return await _warningRepository.GetWarningPageListAsync(inputVo);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建预警
|
/// 创建预警
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -28,10 +40,106 @@ public class ForewarningService : ApplicationService
|
|||||||
var warning = ObjectMapper.Map<CreateWarningInput, WarningEntity>(input);
|
var warning = ObjectMapper.Map<CreateWarningInput, WarningEntity>(input);
|
||||||
warning.WarningRules = ForewarningHelper.CalcRuleList(input.TrackStatusSpans, input.WarningFactors);
|
warning.WarningRules = ForewarningHelper.CalcRuleList(input.TrackStatusSpans, input.WarningFactors);
|
||||||
warning.WarningFactors = ForewarningHelper.MapFactorEntities(input.WarningFactors);
|
warning.WarningFactors = ForewarningHelper.MapFactorEntities(input.WarningFactors);
|
||||||
|
warning.WarningNotifies = ForewarningHelper.MapNotifyEntities(input);
|
||||||
await _warningRepository.CreateForewarningAsync(warning);
|
await _warningRepository.CreateForewarningAsync(warning);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑预警
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warningId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("EditWarning")]
|
||||||
|
public async Task<EditWarningOutput> EditWarning(int warningId)
|
||||||
|
{
|
||||||
|
var warning = await _warningRepository.GetByIdAsync(warningId);
|
||||||
|
|
||||||
|
if (warning == null)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "预警不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ForewarningHelper.MapWarningSummary(warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新预警
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("UpdateWarning")]
|
||||||
|
public async Task<bool> UpdateWarning(UpdateWarningInput input)
|
||||||
|
{
|
||||||
|
var warning = await _warningRepository.GetFirstAsync(x => x.Id == input.Id);
|
||||||
|
if (warning == null)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "预警不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _warningRepository.IsAnyAsync(x =>
|
||||||
|
x.SubSystemId == warning.SubSystemId && x.CustomerId == warning.CustomerId && x.Id != warning.Id))
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "该子系统下的客户已经存在一个同名预警: " + warning.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
warning.SetName(input.Name);
|
||||||
|
|
||||||
|
warning.WarningNotifies = input.Notifies.Select(x => new WarningNotifyEntity
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
NotifyMode = input.NotifyMode,
|
||||||
|
NotifyTemplate = input.NotifyTemplate,
|
||||||
|
NotifyUserId = x.NotifyUserId
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
await _warningRepository.UpdateForewarningAsync(warning);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用or禁用预警
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warningId">预警id</param>
|
||||||
|
/// <param name="isEnable">是否启用</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("TurnWarning")]
|
||||||
|
public async Task<bool> TurnWarning(int warningId, bool isEnable)
|
||||||
|
{
|
||||||
|
var warning = await _warningRepository.GetFirstAsync(x => x.Id == warningId);
|
||||||
|
if (warning == null)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "预警不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEnable)
|
||||||
|
{
|
||||||
|
if (await _warningRepository.IsAnyAsync(x =>
|
||||||
|
x.SubSystemId == warning.SubSystemId && x.CustomerId == warning.CustomerId && x.IsEnable))
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: "该子系统下的客户已经存在一个启用的预警,请先禁用");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
warning.SetEnable(isEnable);
|
||||||
|
|
||||||
|
return await _warningRepository.TurnWarningAsync(warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询预警规则列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warningId">预警规则id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("GetWarningRuleList")]
|
||||||
|
public async Task<List<WarningRuleVo>> GetWarningRuleListAsync([Required] int warningId)
|
||||||
|
{
|
||||||
|
var rules = await _warningRepository.GetWarningRuleListAsync(warningId);
|
||||||
|
|
||||||
|
return rules;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改预警规则时效
|
/// 修改预警规则时效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -54,36 +162,4 @@ public class ForewarningService : ApplicationService
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取预警分页列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inputVo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("GetWarningPageList")]
|
|
||||||
public async Task<UnifyPageResultDto<WarningPageOutput>> GetWarningPageList(GetWarningPageInputVo inputVo)
|
|
||||||
{
|
|
||||||
if (!inputVo.KeyWord.IsNullOrEmpty()) inputVo.KeyWord = inputVo.KeyWord!.Trim();
|
|
||||||
return await _warningRepository.GetWarningPageListAsync(inputVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询预警规则列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="warningId">预警规则id</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("GetWarningRuleList")]
|
|
||||||
public async Task<List<WarningRuleOutput>> GetWarningRuleListAsync([Required] int warningId)
|
|
||||||
{
|
|
||||||
return await _warningRepository.GetWarningRuleListAsync(warningId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 发送预警通知
|
|
||||||
/// </summary>
|
|
||||||
[HttpPost("SendForewarningNotification")]
|
|
||||||
public void SendForewarningNotification()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Validations.Forewarning;
|
namespace SJZY.Track.Application.Validations.Forewarning;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using SJZY.Track.Domain.Dtos.Forewarning;
|
|||||||
|
|
||||||
namespace SJZY.Track.Application.Validations.Forewarning;
|
namespace SJZY.Track.Application.Validations.Forewarning;
|
||||||
|
|
||||||
public class RuleTrackStateDtoValidator : AbstractValidator<TrackStatusSpanDto>
|
public class RuleTrackStateDtoValidator : AbstractValidator<WarningNitifyDto>
|
||||||
{
|
{
|
||||||
public RuleTrackStateDtoValidator()
|
public RuleTrackStateDtoValidator()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,19 +5,12 @@ namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
|||||||
public interface IWarningRepository : IBasicRepository<WarningEntity>
|
public interface IWarningRepository : IBasicRepository<WarningEntity>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建预警
|
/// 创建预警,include factors, notifies, rules
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="warning"></param>
|
/// <param name="warning"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> CreateForewarningAsync(WarningEntity warning);
|
Task<int> CreateForewarningAsync(WarningEntity warning);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 修改预警
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="warning"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<int> UpdateForewarningAsync(WarningEntity warning);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 复制预警
|
/// 复制预警
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -37,7 +30,14 @@ public interface IWarningRepository : IBasicRepository<WarningEntity>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="warningId">预警id</param>
|
/// <param name="warningId">预警id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<WarningRuleOutput>> GetWarningRuleListAsync(int warningId);
|
Task<List<WarningRuleVo>> GetWarningRuleListAsync(int warningId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改预警
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warning"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateForewarningAsync(WarningEntity warning);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改预警时效
|
/// 修改预警时效
|
||||||
@ -45,4 +45,18 @@ public interface IWarningRepository : IBasicRepository<WarningEntity>
|
|||||||
/// <param name="inputItems"></param>
|
/// <param name="inputItems"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> ModifyTimeSpansAsync(List<WarningRuleEntity> inputItems);
|
Task<int> ModifyTimeSpansAsync(List<WarningRuleEntity> inputItems);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用预警
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warning"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> TurnWarningAsync(WarningEntity warning);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取预警,include factors, notifies
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="warningId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<WarningEntity?> GetByIdAsync(int warningId);
|
||||||
}
|
}
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
using Volo.Abp;
|
||||||
|
|
||||||
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
|
||||||
[SugarTable("t_warning")]
|
[SugarTable("t_warning")]
|
||||||
@ -21,12 +24,6 @@ public class WarningEntity: IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
[SugarColumn(ColumnName = "CustomerId")]
|
[SugarColumn(ColumnName = "CustomerId")]
|
||||||
public int CustomerId { get; set; }
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 客户
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnName = "CustomerName", Length = 255)]
|
|
||||||
public string CustomerName { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 规则模板名称,KPI名称
|
/// 规则模板名称,KPI名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -50,4 +47,25 @@ public class WarningEntity: IFullAuditedBasicEntitys, IAggregateRoot
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public List<WarningFactorEntity> WarningFactors { get; set; } = new();
|
public List<WarningFactorEntity> WarningFactors { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警通知
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public List<WarningNotifyEntity> WarningNotifies { get; set; } = new();
|
||||||
|
|
||||||
|
public void SetName(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEnable(bool isEnable)
|
||||||
|
{
|
||||||
|
if (IsEnable == isEnable)
|
||||||
|
{
|
||||||
|
throw new BusinessException(message: $"预警已经是{(isEnable ? "启用" : "禁用")}状态");
|
||||||
|
}
|
||||||
|
|
||||||
|
IsEnable = isEnable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@ using SJZY.Track.Domain.Enums;
|
|||||||
|
|
||||||
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
|
||||||
public class WarningFactorEntity : IFullAuditedBasicEntitys
|
public class WarningFactorEntity : IFullAuditedBasicEntitys, IEntity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自增主键
|
/// 自增主键
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
using SJZY.Track.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
|
||||||
|
public class WarningNotifyEntity : IFullAuditedBasicEntitys, IEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自增主键
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预警id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "WarningId")]
|
||||||
|
public int WarningId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起始轨迹状态id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "StartTrackStatusId", IsNullable = false)]
|
||||||
|
public int StartTrackStatusId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 终止轨迹状态id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "EndTrackStatusId", IsNullable = false)]
|
||||||
|
public int EndTrackStatusId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知方式
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "NotifyMode")]
|
||||||
|
public NotifyMode NotifyMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知模板
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "NotifyTemplate", Length = 256)]
|
||||||
|
public string NotifyTemplate { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通知人
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "NotifyUserId")]
|
||||||
|
public int NotifyUserId { get; set; }
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
|
||||||
[SugarTable("t_warning_rule")]
|
[SugarTable("t_warning_rule")]
|
||||||
public class WarningRuleEntity : IFullAuditedBasicEntitys
|
public class WarningRuleEntity : IFullAuditedBasicEntitys, IEntity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自增主键
|
/// 自增主键
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using SJZY.Track.Domain.Enums;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Domain.Dtos.Forewarning
|
|
||||||
{
|
|
||||||
public class CreateWarningInput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 模板名称
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子系统id
|
|
||||||
/// </summary>
|
|
||||||
public int SubSystemId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 客户id
|
|
||||||
/// </summary>
|
|
||||||
public int CustomerId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 客户名称
|
|
||||||
/// </summary>
|
|
||||||
public string CustomerName { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 通知方式
|
|
||||||
/// </summary>
|
|
||||||
public NotifyMode NotifyMode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 通知模板
|
|
||||||
/// </summary>
|
|
||||||
public string NotifyTemplate { get; set; } = null!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 轨迹状态跨度列表
|
|
||||||
/// </summary>
|
|
||||||
public List<TrackStatusSpanDto> TrackStatusSpans { get; set; } = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 预警因素列表。
|
|
||||||
/// </summary>
|
|
||||||
public List<WarningFactorDto> WarningFactors { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace SJZY.Track.Domain.Dtos.Forewarning;
|
namespace SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
|
||||||
public class TrackStatusSpanDto
|
public class WarningNitifyDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 起始轨迹状态id
|
/// 起始轨迹状态id
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace SJZY.Track.Domain.Dtos.Forewarning;
|
namespace SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
|
||||||
public class WarningRuleOutput
|
public class WarningRuleVo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自增主键
|
/// 自增主键
|
||||||
@ -45,7 +45,7 @@ public class WarningRuleOutput
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 区域
|
/// 区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? AreaId { get; set; }
|
public string? Area { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否中转
|
/// 是否中转
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace SJZY.Track.Repository.VData.Entitys;
|
namespace SJZY.Track.Domain.VEntities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 外部主体
|
/// 外部主体
|
||||||
|
|||||||
@ -20,21 +20,20 @@ public class DataBaseContext
|
|||||||
//新增
|
//新增
|
||||||
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
||||||
{
|
{
|
||||||
|
var time = DateTime.Now;
|
||||||
|
var userId = CurrentUserRequest.CurrentUser.UserId;
|
||||||
|
|
||||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime))
|
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateTime))
|
||||||
entityInfo.SetValue(DateTime.Now);
|
entityInfo.SetValue(time);
|
||||||
if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId))
|
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateTime))
|
||||||
|
entityInfo.SetValue(time);
|
||||||
|
else if (entityInfo.PropertyName == nameof(ICreateBaicEntity.CreateUserId))
|
||||||
{
|
{
|
||||||
if (oldValue == null || (int)oldValue == 0)
|
entityInfo.SetValue(userId);
|
||||||
{
|
}
|
||||||
try
|
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId))
|
||||||
{
|
{
|
||||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser?.UserId);
|
entityInfo.SetValue(userId);
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//修改
|
//修改
|
||||||
@ -44,17 +43,7 @@ public class DataBaseContext
|
|||||||
entityInfo.SetValue(DateTime.Now);
|
entityInfo.SetValue(DateTime.Now);
|
||||||
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId))
|
else if (entityInfo.PropertyName == nameof(IUpdateBasicEntity.UpdateUserId))
|
||||||
{
|
{
|
||||||
if (oldValue == null || (int)oldValue == 1)
|
entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//entityInfo.SetValue(CurrentUserRequest.CurrentUser.UserId);
|
|
||||||
}
|
}
|
||||||
//删除
|
//删除
|
||||||
else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted))
|
else if (entityInfo.PropertyName == nameof(IDeleteBasicEntity.IsDeleted))
|
||||||
|
|||||||
@ -4,7 +4,6 @@ using SJZY.Track.Domain.Dtos.Order;
|
|||||||
using SJZY.Track.Domain.Enums;
|
using SJZY.Track.Domain.Enums;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
using SJZY.Track.Domain.VEntities;
|
using SJZY.Track.Domain.VEntities;
|
||||||
using SJZY.Track.Repository.VData.Entitys;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Queries;
|
namespace SJZY.Track.Repository.Queries;
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ using SJZY.Track.Domain.Dtos.Common;
|
|||||||
using SJZY.Track.Domain.Dtos.TrackPush;
|
using SJZY.Track.Domain.Dtos.TrackPush;
|
||||||
using SJZY.Track.Domain.Enums;
|
using SJZY.Track.Domain.Enums;
|
||||||
using SJZY.Track.Domain.VEntities;
|
using SJZY.Track.Domain.VEntities;
|
||||||
using SJZY.Track.Repository.VData.Entitys;
|
|
||||||
|
|
||||||
namespace SJZY.Track.Repository.Repositories;
|
namespace SJZY.Track.Repository.Repositories;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using SJZY.Track.Domain;
|
using SJZY.Track.Domain;
|
||||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
using SJZY.Track.Domain.VEntities;
|
using SJZY.Track.Domain.VEntities;
|
||||||
@ -13,20 +14,17 @@ public class WarningRepository : BasicRepository<WarningEntity>, IWarningReposit
|
|||||||
using var tran = TransactionHelper.GetReadCommitted();
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
|
|
||||||
var ruleId = await InsertReturnIdentityAsync(warning);
|
var ruleId = await InsertReturnIdentityAsync(warning);
|
||||||
warning.WarningRules.ForEach(x => x.WarningId = ruleId);
|
warning.WarningNotifies.ForEach(x => x.WarningId = ruleId);
|
||||||
warning.WarningFactors.ForEach(x => x.WarningId = ruleId);
|
warning.WarningFactors.ForEach(x => x.WarningId = ruleId);
|
||||||
|
warning.WarningRules.ForEach(x => x.WarningId = ruleId);
|
||||||
|
|
||||||
await Context.Insertable(warning.WarningRules).ExecuteCommandAsync();
|
|
||||||
await Context.Insertable(warning.WarningFactors).ExecuteCommandAsync();
|
await Context.Insertable(warning.WarningFactors).ExecuteCommandAsync();
|
||||||
|
await Context.Insertable(warning.WarningNotifies).ExecuteCommandAsync();
|
||||||
|
await Context.Insertable(warning.WarningRules).ExecuteCommandAsync();
|
||||||
tran.Complete();
|
tran.Complete();
|
||||||
return ruleId;
|
return ruleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> UpdateForewarningAsync(WarningEntity warning)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task CopyForewarning(int warningId)
|
public Task CopyForewarning(int warningId)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@ -36,40 +34,79 @@ public class WarningRepository : BasicRepository<WarningEntity>, IWarningReposit
|
|||||||
{
|
{
|
||||||
var query = Context.Queryable<WarningEntity>()
|
var query = Context.Queryable<WarningEntity>()
|
||||||
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id)
|
||||||
|
.LeftJoin<VExternalSubjectEntity>((a, b, c) => a.CustomerId == c.Id)
|
||||||
.WhereIF(input.SystemId.HasValue, (a, b) => a.SubSystemId == input.SystemId)
|
.WhereIF(input.SystemId.HasValue, (a, b) => a.SubSystemId == input.SystemId)
|
||||||
.WhereIF(!string.IsNullOrEmpty(input.KeyWord), a => a.CustomerName.Contains(input.KeyWord!) || a.Name.Contains(input.KeyWord!))
|
.WhereIF(!string.IsNullOrEmpty(input.KeyWord),
|
||||||
|
(a, b, c) => a.Name.Contains(input.KeyWord!) || c.Name.Contains(input.KeyWord!))
|
||||||
.OrderBy(a => a.UpdateTime, OrderByType.Desc);
|
.OrderBy(a => a.UpdateTime, OrderByType.Desc);
|
||||||
|
|
||||||
return query
|
return query
|
||||||
.Select((a, b) => new WarningPageOutput
|
.Select((a, b, c) => new WarningPageOutput
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
SubSystem = b.CnName,
|
SubSystem = b.CnName,
|
||||||
Custom = a.CustomerName,
|
Custom = c.Name,
|
||||||
Name = a.Name,
|
Name = a.Name,
|
||||||
UpdateTime = a.UpdateTime
|
UpdateTime = a.UpdateTime
|
||||||
})
|
})
|
||||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<WarningRuleOutput>> GetWarningRuleListAsync(int warningId)
|
public async Task<List<WarningRuleVo>> GetWarningRuleListAsync(int warningId)
|
||||||
{
|
{
|
||||||
return await Context.Queryable<WarningRuleEntity>()
|
return await Context.Queryable<WarningRuleEntity>()
|
||||||
.LeftJoin<TrackStatusEntity>((a, b) => a.StartTrackStatusId == b.Id)
|
.LeftJoin<TrackStatusEntity>((a, b) => a.StartTrackStatusId == b.Id)
|
||||||
.LeftJoin<TrackStatusEntity>((a, b, c) => a.EndTrackStatusId == c.Id)
|
.LeftJoin<TrackStatusEntity>((a, b, c) => a.EndTrackStatusId == c.Id)
|
||||||
|
.LeftJoin<RuleAreaEntity>((a, b, c, d) => a.AreaId == d.Id)
|
||||||
.Where(a => a.WarningId == warningId)
|
.Where(a => a.WarningId == warningId)
|
||||||
.Select((a, b, c) => new WarningRuleOutput
|
.Select((a, b, c, d) => new WarningRuleVo
|
||||||
{
|
{
|
||||||
StartTrackStatus = b.Status,
|
StartTrackStatus = b.Status,
|
||||||
EndTrackStatus = c.Status,
|
EndTrackStatus = c.Status,
|
||||||
|
Area = d.Name
|
||||||
}, true)
|
}, true)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateForewarningAsync(WarningEntity warning)
|
||||||
|
{
|
||||||
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
|
|
||||||
|
await Context.Updateable(warning).ExecuteCommandAsync();
|
||||||
|
await Context.Updateable(warning.WarningNotifies)
|
||||||
|
.UpdateColumns(x => new { x.NotifyMode, x.NotifyTemplate, x.NotifyUserId, x.UpdateTime, x.UpdateUserId })
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
tran.Complete();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<int> ModifyTimeSpansAsync(List<WarningRuleEntity> rules)
|
public async Task<int> ModifyTimeSpansAsync(List<WarningRuleEntity> rules)
|
||||||
{
|
{
|
||||||
return await Context.Updateable(rules)
|
return await Context.Updateable(rules)
|
||||||
.UpdateColumns(x => new { x.TotalTimeSpan, x.WarnTimeSpan, x.WarnCount })
|
.UpdateColumns(x => new { x.TotalTimeSpan, x.WarnTimeSpan, x.WarnCount, x.UpdateTime, x.UpdateUserId })
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> TurnWarningAsync(WarningEntity warning)
|
||||||
|
{
|
||||||
|
return await Context.Updateable(warning)
|
||||||
|
.UpdateColumns(x => new { x.IsEnable, x.UpdateTime, x.UpdateUserId })
|
||||||
|
.ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<WarningEntity?> GetByIdAsync(int warningId)
|
||||||
|
{
|
||||||
|
var warning = await GetFirstAsync(x => x.Id == warningId);
|
||||||
|
|
||||||
|
if (warning == null) return null;
|
||||||
|
|
||||||
|
warning.WarningFactors = await Context.Queryable<WarningFactorEntity>()
|
||||||
|
.Where(x => x.WarningId == warningId)
|
||||||
|
.ToListAsync();
|
||||||
|
warning.WarningNotifies = await Context.Queryable<WarningNotifyEntity>()
|
||||||
|
.Where(x => x.WarningId == warningId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return warning;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user