connect: 对接预警编辑
This commit is contained in:
parent
707a05f911
commit
7454827e0f
@ -0,0 +1,8 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.Common;
|
||||
|
||||
public class IdWithNameDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
@ -2,6 +2,7 @@ using System.Dynamic;
|
||||
using Nest;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Track.Application.Contract.Dtos.Common;
|
||||
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
@ -119,7 +120,7 @@ public class ForewarningHelper
|
||||
case RuleFactorType.LeavePort:
|
||||
if (value.Type is not JTokenType.String)
|
||||
{
|
||||
throw new BusinessException(message: "货物类型只接收字符串");
|
||||
throw new BusinessException(message: "起运港只接收字符串");
|
||||
}
|
||||
|
||||
rules[row].LeavePort = strValue;
|
||||
@ -127,7 +128,7 @@ public class ForewarningHelper
|
||||
case RuleFactorType.ProductCode:
|
||||
if (value.Type is not JTokenType.String)
|
||||
{
|
||||
throw new BusinessException(message: "货物类型只接收字符串");
|
||||
throw new BusinessException(message: "产品代码只接收字符串");
|
||||
}
|
||||
|
||||
rules[row].ProductCode = strValue;
|
||||
@ -161,8 +162,9 @@ public class ForewarningHelper
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public static EditWarningOutput MapWarningSummary(WarningEntity warning)
|
||||
public static EditWarningOutput MapWarningSummary(WarningEntity warning, List<IdWithNameDto> statusList)
|
||||
{
|
||||
var statusDic = statusList.ToDictionary(x => x.Id, x => x.Name);
|
||||
return new EditWarningOutput
|
||||
{
|
||||
Name = warning.Name,
|
||||
@ -174,7 +176,9 @@ public class ForewarningHelper
|
||||
{
|
||||
Id = x.Id,
|
||||
StartTrackStatusId = x.StartTrackStatusId,
|
||||
StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "",
|
||||
EndTrackStatusId = x.EndTrackStatusId,
|
||||
EndTrackStatus = statusDic.TryGetValue(x.EndTrackStatusId, out var end) ? end : "",
|
||||
NotifyUserId = x.NotifyUserId,
|
||||
}).ToList(),
|
||||
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SJZY.Track.Application.Contract.Dtos.Common;
|
||||
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||
using SJZY.Track.Application.Helpers;
|
||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
using SJZY.Track.Domain.Dtos.TrackStatus;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.ForewarningServices;
|
||||
@ -57,9 +60,11 @@ public class ForewarningService : ApplicationService
|
||||
/// 编辑预警
|
||||
/// </summary>
|
||||
/// <param name="warningId"></param>
|
||||
/// <param name="statusQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("EditWarning")]
|
||||
public async Task<EditWarningOutput> EditWarning(int warningId)
|
||||
public async Task<EditWarningOutput> EditWarning(int warningId,
|
||||
[FromServices] IBasicQuery<TrackStatusEntity> statusQuery)
|
||||
{
|
||||
var warning = await _warningRepository.GetByIdAsync(warningId);
|
||||
|
||||
@ -68,7 +73,14 @@ public class ForewarningService : ApplicationService
|
||||
throw new BusinessException(message: "预警不存在");
|
||||
}
|
||||
|
||||
return ForewarningHelper.MapWarningSummary(warning);
|
||||
var statusList = await statusQuery.GetListAsync(x => x.SubSystemId == warning.SubSystemId, x =>
|
||||
new IdWithNameDto
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.Status
|
||||
});
|
||||
|
||||
return ForewarningHelper.MapWarningSummary(warning, statusList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -86,7 +98,8 @@ public class ForewarningService : ApplicationService
|
||||
}
|
||||
|
||||
if (await _warningRepository.IsAnyAsync(x =>
|
||||
x.SubSystemId == warning.SubSystemId && x.CustomerId == warning.CustomerId && x.Id != warning.Id))
|
||||
x.SubSystemId == warning.SubSystemId && x.CustomerId == warning.CustomerId && x.Id != warning.Id &&
|
||||
x.Name == input.Name))
|
||||
{
|
||||
throw new BusinessException(message: "该子系统下的客户已经存在一个同名预警: " + warning.Name);
|
||||
}
|
||||
@ -142,7 +155,8 @@ public class ForewarningService : ApplicationService
|
||||
/// <param name="factorQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetWarningRuleList")]
|
||||
public async Task<List<dynamic>> GetWarningRuleListAsync([Required] int warningId, [FromServices] IBasicQuery<WarningFactorEntity> factorQuery)
|
||||
public async Task<List<dynamic>> GetWarningRuleListAsync([Required] int warningId,
|
||||
[FromServices] IBasicQuery<WarningFactorEntity> factorQuery)
|
||||
{
|
||||
var factors = await factorQuery.GetListAsync(x => x.WarningId == warningId, x => x.Type);
|
||||
var rules = await _warningRepository.GetWarningRuleListAsync(warningId);
|
||||
|
||||
@ -12,6 +12,16 @@ public class WarningNitifyDto
|
||||
/// </summary>
|
||||
public int EndTrackStatusId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始轨迹状态
|
||||
/// </summary>
|
||||
public string StartTrackStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 终止轨迹状态
|
||||
/// </summary>
|
||||
public string EndTrackStatus { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 通知人id
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user