change:支持otel
con:对接前端,返回预警编辑页面数据区域给name
This commit is contained in:
parent
39e2dab9cc
commit
29624edec3
3
src/SJZY.Track.Application/FodyWeavers.xml
Normal file
3
src/SJZY.Track.Application/FodyWeavers.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Rougamo/>
|
||||
</Weavers>
|
||||
26
src/SJZY.Track.Application/FodyWeavers.xsd
Normal file
26
src/SJZY.Track.Application/FodyWeavers.xsd
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Rougamo" minOccurs="0" maxOccurs="1" type="xs:anyType" />
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@ -164,9 +164,11 @@ public class ForewarningHelper
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public static EditWarningOutput MapWarningSummary(WarningEntity warning, List<IdWithNameDto> statusList)
|
||||
public static EditWarningOutput MapWarningSummary(WarningEntity warning, List<IdWithNameDto> statusList,
|
||||
List<IdWithNameDto> areaList)
|
||||
{
|
||||
var statusDic = statusList.ToDictionary(x => x.Id, x => x.Name);
|
||||
var areaDic = areaList.ToDictionary(x => x.Id, x => x.Name);
|
||||
return new EditWarningOutput
|
||||
{
|
||||
Name = warning.Name,
|
||||
@ -184,11 +186,27 @@ public class ForewarningHelper
|
||||
? new List<int>()
|
||||
: x.NotifyMode.Split(',').Select(int.Parse).ToList(),
|
||||
}).ToList(),
|
||||
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
|
||||
WarningFactors = warning.WarningFactors.Select(x =>
|
||||
{
|
||||
Id = x.Id,
|
||||
FactorType = (int) x.Type,
|
||||
FactorValue = JsonConvert.DeserializeObject<List<object>>(x.Value)!,
|
||||
if (x.Type == RuleFactorType.Area)
|
||||
{
|
||||
var areaIds = JsonConvert.DeserializeObject<List<int>>(x.Value);
|
||||
return new WarningFactorWithIdDto
|
||||
{
|
||||
Id = x.Id,
|
||||
FactorType = (int) x.Type,
|
||||
FactorValue = areaIds?
|
||||
.Select(area => areaDic.TryGetValue(area, out var name) ? name : area.ToString())
|
||||
.Cast<object>().ToList() ?? new List<object>(),
|
||||
};
|
||||
}
|
||||
|
||||
return new WarningFactorWithIdDto
|
||||
{
|
||||
Id = x.Id,
|
||||
FactorType = (int) x.Type,
|
||||
FactorValue = JsonConvert.DeserializeObject<List<object>>(x.Value)!,
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="8.2.0"/>
|
||||
<PackageReference Include="DotNetCore.CAP.MySql" Version="8.2.0"/>
|
||||
<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.2.0"/>
|
||||
<PackageReference Include="SJZY.OTel" Version="1.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
51
src/SJZY.Track.Application/Services/DebugApis/OTelService.cs
Normal file
51
src/SJZY.Track.Application/Services/DebugApis/OTelService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using SJZY.OTel;
|
||||
using SJZY.Track.Domain.Aggregates.OrderAggregate;
|
||||
|
||||
namespace SJZY.Track.Application.Services.DebugApis;
|
||||
|
||||
[AllowAnonymous]
|
||||
[ApiExplorerSettings(GroupName = "调试专用")]
|
||||
public class OTelService : ApplicationService
|
||||
{
|
||||
private readonly IBasicRepository<OrderEntity> _orderRepository;
|
||||
|
||||
public OTelService(IBasicRepository<OrderEntity> orderRepository)
|
||||
{
|
||||
_orderRepository = orderRepository;
|
||||
}
|
||||
|
||||
[OTel]
|
||||
public async Task<string> Hello(string name)
|
||||
{
|
||||
var order = await _orderRepository.GetFirstAsync(x => true);
|
||||
if (order == null)
|
||||
{
|
||||
throw new BusinessException(message: "订单不存在");
|
||||
}
|
||||
|
||||
await DoSomethingAsync(order);
|
||||
|
||||
return $"hello {name}";
|
||||
}
|
||||
|
||||
[OTel]
|
||||
private async Task DoSomethingAsync(OrderEntity order)
|
||||
{
|
||||
var order2 = await _orderRepository.GetFirstAsync(x => true);
|
||||
|
||||
if (order.Id == order2?.Id)
|
||||
{
|
||||
await Task.Delay(3000);
|
||||
}
|
||||
|
||||
|
||||
await DoWorkAsync();
|
||||
}
|
||||
|
||||
[OTel]
|
||||
private async Task DoWorkAsync()
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
||||
|
||||
tran.Exec();
|
||||
|
||||
LogHelper.Info($"本次共计产生{addCounter}条预警,移除{delCounter}条预警,触发缘由是");
|
||||
LogHelper.Info($"本次共计产生{addCounter}条预警,移除{delCounter}条预警,触发缘由是{dto}");
|
||||
|
||||
await _warningRecordEsRepository.BulkUpdateAsync(dels); // 标记处理完成
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using SJZY.Track.Application.Contract.Dtos.Forewarning;
|
||||
using SJZY.Track.Application.Contract.Services;
|
||||
using SJZY.Track.Application.Helpers;
|
||||
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Dtos.Common;
|
||||
using SJZY.Track.Domain.Dtos.Forewarning;
|
||||
@ -69,7 +70,8 @@ public class ForewarningService : ApplicationService
|
||||
/// <returns></returns>
|
||||
[HttpGet("EditWarning")]
|
||||
public async Task<EditWarningOutput> EditWarning(int warningId,
|
||||
[FromServices] IBasicQuery<TrackStatusEntity> statusQuery)
|
||||
[FromServices] IBasicQuery<TrackStatusEntity> statusQuery,
|
||||
[FromServices] IKpiAreaRepository kpiAreaRepository)
|
||||
{
|
||||
var warning = await _warningRepository.GetByIdAsync(warningId);
|
||||
|
||||
@ -85,7 +87,14 @@ public class ForewarningService : ApplicationService
|
||||
Name = x.Status
|
||||
});
|
||||
|
||||
return ForewarningHelper.MapWarningSummary(warning, statusList);
|
||||
var areaList = await kpiAreaRepository.GetListAsync(x => x.SubSystemId == warning.SubSystemId, x =>
|
||||
new IdWithNameDto
|
||||
{
|
||||
Id = x.Id,
|
||||
Name = x.Name
|
||||
});
|
||||
|
||||
return ForewarningHelper.MapWarningSummary(warning, statusList, areaList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
|
||||
|
||||
public class RuleAreaEntity
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace SJZY.Track.Domain.Aggregates;
|
||||
|
||||
public class KPIAreaAggregate
|
||||
{
|
||||
|
||||
}
|
||||
3
src/SJZY.Track.Domain/FodyWeavers.xml
Normal file
3
src/SJZY.Track.Domain/FodyWeavers.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Rougamo/>
|
||||
</Weavers>
|
||||
31
src/SJZY.Track.Domain/FodyWeavers.xsd
Normal file
31
src/SJZY.Track.Domain/FodyWeavers.xsd
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Rougamo" minOccurs="0" maxOccurs="1" type="xs:anyType"/>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all
|
||||
weavers have been executed.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly
|
||||
verification.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@ -6,15 +6,10 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SJZY.Expand.ABP.Core" Version="7.8.6"/>
|
||||
<PackageReference Include="SJZY.Expand.ElasticSearch" Version="7.0.17" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Aggregates\KPIAreaAggregate.cs" />
|
||||
<Compile Remove="Aggregates\ForewarningAggregate\RuleAreaEntity.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user