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 Nest;
|
||||||
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.Common;
|
||||||
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
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;
|
||||||
@ -119,7 +120,7 @@ public class ForewarningHelper
|
|||||||
case RuleFactorType.LeavePort:
|
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].LeavePort = strValue;
|
rules[row].LeavePort = strValue;
|
||||||
@ -127,7 +128,7 @@ public class ForewarningHelper
|
|||||||
case RuleFactorType.ProductCode:
|
case RuleFactorType.ProductCode:
|
||||||
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].ProductCode = strValue;
|
||||||
@ -161,8 +162,9 @@ public class ForewarningHelper
|
|||||||
}).ToList();
|
}).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
|
return new EditWarningOutput
|
||||||
{
|
{
|
||||||
Name = warning.Name,
|
Name = warning.Name,
|
||||||
@ -174,7 +176,9 @@ public class ForewarningHelper
|
|||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
StartTrackStatusId = x.StartTrackStatusId,
|
StartTrackStatusId = x.StartTrackStatusId,
|
||||||
|
StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "",
|
||||||
EndTrackStatusId = x.EndTrackStatusId,
|
EndTrackStatusId = x.EndTrackStatusId,
|
||||||
|
EndTrackStatus = statusDic.TryGetValue(x.EndTrackStatusId, out var end) ? end : "",
|
||||||
NotifyUserId = x.NotifyUserId,
|
NotifyUserId = x.NotifyUserId,
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
|
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.Common;
|
||||||
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||||
using SJZY.Track.Application.Helpers;
|
using SJZY.Track.Application.Helpers;
|
||||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||||
|
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||||
|
using SJZY.Track.Domain.Dtos.TrackStatus;
|
||||||
using SJZY.Track.Domain.Queries;
|
using SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.ForewarningServices;
|
namespace SJZY.Track.Application.Services.ForewarningServices;
|
||||||
@ -57,9 +60,11 @@ public class ForewarningService : ApplicationService
|
|||||||
/// 编辑预警
|
/// 编辑预警
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="warningId"></param>
|
/// <param name="warningId"></param>
|
||||||
|
/// <param name="statusQuery"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("EditWarning")]
|
[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);
|
var warning = await _warningRepository.GetByIdAsync(warningId);
|
||||||
|
|
||||||
@ -68,7 +73,14 @@ public class ForewarningService : ApplicationService
|
|||||||
throw new BusinessException(message: "预警不存在");
|
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>
|
/// <summary>
|
||||||
@ -86,7 +98,8 @@ public class ForewarningService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await _warningRepository.IsAnyAsync(x =>
|
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);
|
throw new BusinessException(message: "该子系统下的客户已经存在一个同名预警: " + warning.Name);
|
||||||
}
|
}
|
||||||
@ -142,7 +155,8 @@ public class ForewarningService : ApplicationService
|
|||||||
/// <param name="factorQuery"></param>
|
/// <param name="factorQuery"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("GetWarningRuleList")]
|
[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 factors = await factorQuery.GetListAsync(x => x.WarningId == warningId, x => x.Type);
|
||||||
var rules = await _warningRepository.GetWarningRuleListAsync(warningId);
|
var rules = await _warningRepository.GetWarningRuleListAsync(warningId);
|
||||||
|
|||||||
@ -12,6 +12,16 @@ public class WarningNitifyDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int EndTrackStatusId { get; set; }
|
public int EndTrackStatusId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 起始轨迹状态
|
||||||
|
/// </summary>
|
||||||
|
public string StartTrackStatus { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 终止轨迹状态
|
||||||
|
/// </summary>
|
||||||
|
public string EndTrackStatus { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通知人id
|
/// 通知人id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user