迁移服务搭建
This commit is contained in:
parent
3bb691b312
commit
17e36f5a56
@ -66,6 +66,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Analyzers", "modules\JiShe.CollectBus.Analyzers\JiShe.CollectBus.Analyzers.csproj", "{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Migration.Application.Contracts", "services\JiShe.CollectBus.Migration.Application.Contracts\JiShe.CollectBus.Migration.Application.Contracts.csproj", "{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Migration.Application", "services\JiShe.CollectBus.Migration.Application\JiShe.CollectBus.Migration.Application.csproj", "{B955C5DA-3C20-35D2-0770-8FE473C41C44}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Migration.Host", "web\JiShe.CollectBus.Migration.Host\JiShe.CollectBus.Migration.Host.csproj", "{995D3D91-7221-D4A3-A7B2-FEC202328A18}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Migration.HttpApi", "web\JiShe.CollectBus.Migration.HttpApi\JiShe.CollectBus.Migration.HttpApi.csproj", "{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -160,6 +168,22 @@ Global
|
||||
{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B955C5DA-3C20-35D2-0770-8FE473C41C44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B955C5DA-3C20-35D2-0770-8FE473C41C44}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B955C5DA-3C20-35D2-0770-8FE473C41C44}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B955C5DA-3C20-35D2-0770-8FE473C41C44}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{995D3D91-7221-D4A3-A7B2-FEC202328A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{995D3D91-7221-D4A3-A7B2-FEC202328A18}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{995D3D91-7221-D4A3-A7B2-FEC202328A18}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{995D3D91-7221-D4A3-A7B2-FEC202328A18}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -187,6 +211,10 @@ Global
|
||||
{75B7D419-C261-577D-58D6-AA3ACED9129F} = {3C3F9DB2-EC97-4464-B49F-BF1A0C2B46DC}
|
||||
{DD68F314-BC66-5601-B094-B1A7BE93F4E0} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
|
||||
{EB97C7BB-1E4A-CBA4-04C1-22DBF48A253A} = {2E0FE301-34C3-4561-9CAE-C7A9E65AEE59}
|
||||
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
|
||||
{B955C5DA-3C20-35D2-0770-8FE473C41C44} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
|
||||
{995D3D91-7221-D4A3-A7B2-FEC202328A18} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
|
||||
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
|
||||
|
||||
@ -580,7 +580,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
||||
$"new EntityMemberInfo(" +
|
||||
$"\"{prop.Name}.{elementName}\", " +
|
||||
$"typeof({elementType}), " +
|
||||
$"GetValueTupleElementName(typeof({elementType})), " +//$"\"{elementDeclaredName}\", " +
|
||||
$"GetValueTupleElementDeclaredTypeName(typeof({elementType})), " +//$"\"{elementDeclaredName}\", " +
|
||||
$"(e) => Get{prop.Name}_{elementName}(({entityType})e), " +
|
||||
$"(e, v) => Set{prop.Name}_{elementName}(({entityType})e, ({elementType})v))");
|
||||
}
|
||||
@ -596,7 +596,7 @@ namespace JiShe.CollectBus.IncrementalGenerator
|
||||
private static string GetValueTupleElementName()
|
||||
{
|
||||
return """
|
||||
public static string GetValueTupleElementName(Type declaredType)
|
||||
public static string GetValueTupleElementDeclaredTypeName(Type declaredType)
|
||||
{
|
||||
string typeName;
|
||||
// 处理可空类型
|
||||
|
||||
@ -545,7 +545,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[KafkaSubscribe(ProtocolConst.TESTSENDTOPIC), ApiExplorerSettings(IgnoreApi = true)]
|
||||
[KafkaSubscribe(ProtocolConst.TESTSENDTOPIC)/*, ApiExplorerSettings(IgnoreApi = true)*/]
|
||||
|
||||
public async Task<ISubscribeAck> KafkaSubscribeTestSendAsync(KafkaSendDto dto)
|
||||
{
|
||||
|
||||
@ -8,7 +8,6 @@ using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.Common.Models;
|
||||
using JiShe.CollectBus.DataChannels;
|
||||
using JiShe.CollectBus.DataMigration.Options;
|
||||
using JiShe.CollectBus.GatherItem;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.IoTDB.Model;
|
||||
@ -42,7 +41,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
private readonly IDataChannelManageService _dataChannelManage;
|
||||
private readonly IRedisDataCacheService _redisDataCacheService;
|
||||
private readonly IProtocolService _protocolService;
|
||||
private readonly DataMigrationOptions _dataMigrationOptions;
|
||||
private readonly KafkaOptionConfig _kafkaOptions;
|
||||
private readonly ServerApplicationOptions _applicationOptions;
|
||||
private readonly IGuidGenerator _guidGenerator;
|
||||
@ -56,7 +54,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
IIoTDbProvider dbProvider,
|
||||
IProtocolService protocolService,
|
||||
IGuidGenerator guidGenerator,
|
||||
IOptions<DataMigrationOptions> dataMigrationOptions,
|
||||
IOptions<KafkaOptionConfig> kafkaOptions,
|
||||
IOptions<ServerApplicationOptions> applicationOptions)
|
||||
{
|
||||
@ -66,7 +63,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
_redisDataCacheService = redisDataCacheService;
|
||||
_protocolService = protocolService;
|
||||
|
||||
_dataMigrationOptions = dataMigrationOptions.Value;
|
||||
_kafkaOptions = kafkaOptions.Value;
|
||||
_applicationOptions = applicationOptions.Value;
|
||||
|
||||
|
||||
@ -1,28 +1,22 @@
|
||||
using JiShe.CollectBus.Application.Contracts;
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.DeviceBalanceControl;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.DataChannels;
|
||||
using JiShe.CollectBus.DataMigration.Options;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.GatherItem;
|
||||
using JiShe.CollectBus.IoTDB.Context;
|
||||
using JiShe.CollectBus.IoTDB.Interface;
|
||||
using JiShe.CollectBus.IotSystems.Ammeters;
|
||||
using JiShe.CollectBus.IotSystems.Devices;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.IotSystems.Watermeter;
|
||||
using JiShe.CollectBus.Kafka.Internal;
|
||||
using JiShe.CollectBus.Kafka.Producer;
|
||||
using JiShe.CollectBus.Protocol.Interfaces;
|
||||
using JiShe.CollectBus.Protocol.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MongoDB.Bson.Serialization.IdGenerators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -52,7 +46,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
IIoTDbProvider dbProvider,
|
||||
IProtocolService protocolService,
|
||||
IGuidGenerator guidGenerator,
|
||||
IOptions<DataMigrationOptions> dataMigrationOptions,
|
||||
IOptions<KafkaOptionConfig> kafkaOptions,
|
||||
IOptions<ServerApplicationOptions> applicationOptions)
|
||||
: base(logger,
|
||||
@ -61,7 +54,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
dbProvider,
|
||||
protocolService,
|
||||
guidGenerator,
|
||||
dataMigrationOptions,
|
||||
kafkaOptions,
|
||||
applicationOptions)
|
||||
{
|
||||
@ -112,56 +104,98 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
// if (ammeterInfos == null || ammeterInfos.Count <= 0)
|
||||
// {
|
||||
// ammeterInfos = new List<DeviceInfo>();
|
||||
// ammeterInfos.Add(new DeviceInfo()
|
||||
// {
|
||||
// Baudrate = 2400,
|
||||
// FocusAddress = "442400040",
|
||||
// Name = "保利单箱电表1",
|
||||
// FocusId = 95780,
|
||||
// DatabaseBusiID = 1,
|
||||
// MeteringCode = 0,
|
||||
// MeterAddress = "442405000040",
|
||||
// MeterId = 127035,
|
||||
// TypeName = 1,
|
||||
// DataTypes = "581,589,592,597,601",
|
||||
// TimeDensity = 15,
|
||||
// BrandType = "DTS1980",
|
||||
// MeterType = MeterTypeEnum.Ammeter,
|
||||
// ProjectID = 1,
|
||||
// MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// Password = "000000",
|
||||
// });
|
||||
// //ammeterInfos.Add(new DeviceInfo()
|
||||
// //{
|
||||
// // Baudrate = 2400,
|
||||
// // FocusAddress = "442400040",
|
||||
// // Name = "保利单箱电表1",
|
||||
// // FocusId = 95780,
|
||||
// // DatabaseBusiID = 1,
|
||||
// // MeteringCode = 0,
|
||||
// // MeterAddress = "442405000040",
|
||||
// // MeterId = 127035,
|
||||
// // TypeName = 1,
|
||||
// // DataTypes = "581,589,592,597,601",
|
||||
// // TimeDensity = 15,
|
||||
// // BrandType = "DTS1980",
|
||||
// // MeterType = MeterTypeEnum.Ammeter,
|
||||
// // ProjectID = 1,
|
||||
// // MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// // Password = "000000",
|
||||
// //});
|
||||
|
||||
// //ammeterInfos.Add(new DeviceInfo()
|
||||
// //{
|
||||
// // Baudrate = 2400,
|
||||
// // FocusAddress = "442400039",
|
||||
// // Name = "保利单箱电表2",
|
||||
// // FocusId = 69280,
|
||||
// // DatabaseBusiID = 1,
|
||||
// // MeteringCode = 0,
|
||||
// // MeterAddress = "442405000039",
|
||||
// // MeterId = 95594,
|
||||
// // TypeName = 1,
|
||||
// // DataTypes = "581,589,592,597,601",
|
||||
// // TimeDensity = 15,
|
||||
// // BrandType = "DTS1980",
|
||||
// // MeterType = MeterTypeEnum.Ammeter,
|
||||
// // ProjectID = 1,
|
||||
// // MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// // Password = "000000",
|
||||
// //});
|
||||
|
||||
// //ammeterInfos.Add(new DeviceInfo()
|
||||
// //{
|
||||
// // Baudrate = 2400,
|
||||
// // FocusAddress = "402440506",
|
||||
// // Name = "中环半导体9#冷却泵-220KW(三相电表)",
|
||||
// // FocusId = 106857,
|
||||
// // DatabaseBusiID = 1,
|
||||
// // MeteringCode = 0,
|
||||
// // MeterAddress = "402410040506",
|
||||
// // MeterId = 139059,
|
||||
// // TypeName = 3,
|
||||
// // DataTypes = "449,503,581,582,583,584,585,586,587,588,589,590,591,592,593,594,597,598,599,600,601,602,603,604,605,606,607,608,661,663,677,679",
|
||||
// // TimeDensity = 15,
|
||||
// // BrandType = "DTS1980",
|
||||
// // Password = "000000",
|
||||
// // ProjectID = 1,
|
||||
// // MeterType = MeterTypeEnum.Ammeter,
|
||||
// // MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// //});
|
||||
|
||||
|
||||
// ammeterInfos.Add(new DeviceInfo()
|
||||
// {
|
||||
// Baudrate = 2400,
|
||||
// FocusAddress = "442400039",
|
||||
// Name = "保利单箱电表2",
|
||||
// FocusId = 69280,
|
||||
// FocusAddress = "942411321",
|
||||
// Name = "DDS1980-T4(5-60) ML307A 长稳 942408011321",
|
||||
// FocusId = 57682,
|
||||
// DatabaseBusiID = 1,
|
||||
// MeteringCode = 0,
|
||||
// MeterAddress = "442405000039",
|
||||
// MeterId = 95594,
|
||||
// TypeName = 1,
|
||||
// DataTypes = "581,589,592,597,601",
|
||||
// MeterAddress = "942408011321",
|
||||
// MeterId = 78970,
|
||||
// TypeName = 3,
|
||||
// DataTypes = "449,503,581,582,583,584,585,586,587,588,589,590,591,592,593,594,597,598,599,600,601,602,603,604,605,606,607,608,661,663,677,679",
|
||||
// TimeDensity = 15,
|
||||
// BrandType = "DTS1980",
|
||||
// MeterType = MeterTypeEnum.Ammeter,
|
||||
// ProjectID = 1,
|
||||
// MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// Password = "000000",
|
||||
// ProjectID = 1,
|
||||
// MeterType = MeterTypeEnum.Ammeter,
|
||||
// MeteringPort = MeteringPortConst.MeteringPortTwo,
|
||||
// });
|
||||
|
||||
|
||||
// ammeterInfos.Add(new DeviceInfo()
|
||||
// {
|
||||
// Baudrate = 2400,
|
||||
// FocusAddress = "402440506",
|
||||
// Name = "中环半导体9#冷却泵-220KW(三相电表)",
|
||||
// FocusId = 106857,
|
||||
// FocusAddress = "942411319",
|
||||
// Name = "DDS1980-T4(5-60) ML307A 长稳 942408011319",
|
||||
// FocusId = 57685,
|
||||
// DatabaseBusiID = 1,
|
||||
// MeteringCode = 0,
|
||||
// MeterAddress = "402410040506",
|
||||
// MeterId = 139059,
|
||||
// MeterAddress = "942408011319",
|
||||
// MeterId = 78973,
|
||||
// TypeName = 3,
|
||||
// DataTypes = "449,503,581,582,583,584,585,586,587,588,589,590,591,592,593,594,597,598,599,600,601,602,603,604,605,606,607,608,661,663,677,679",
|
||||
// TimeDensity = 15,
|
||||
@ -222,7 +256,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
|
||||
|
||||
#if DEBUG
|
||||
// sql = $@"{sql} and c.Address in('542410000504','442405000040','442405000039','402410040506')";
|
||||
//// sql = $@"{sql} and c.Address in('542410000504','442405000040','442405000039','402410040506')";
|
||||
sql = $@"{sql} and c.Address in('402410040506')";
|
||||
#endif
|
||||
|
||||
@ -339,6 +373,21 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
||||
// TimeDensity = 15,
|
||||
//});
|
||||
|
||||
//settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
//{
|
||||
// MeterType = MeterTypeEnum.Ammeter,
|
||||
// AmmerterAddress = "402410040506",
|
||||
// FocusAddress = "402440506",
|
||||
// FocusId = 57685,
|
||||
// ProjectID = 1,
|
||||
// TripType = "on",
|
||||
// TripTime = $"{DateTime.Now:HH:mm}",
|
||||
// MeterId = 78973,
|
||||
// LoopType = "EachDay",
|
||||
// EachDayWithout = "周六,周日",
|
||||
// TimeDensity = 15,
|
||||
//});
|
||||
|
||||
settingInfos.Add(new AmmeterAutoValveControlSetting()
|
||||
{
|
||||
MeterType = MeterTypeEnum.Ammeter,
|
||||
|
||||
@ -76,7 +76,7 @@ namespace JiShe.CollectBus.Subscribers
|
||||
|
||||
foreach (var item in receivedMessage)
|
||||
{
|
||||
_logger.LogError($"15分钟采集电表数据下行消息消费队列开始处理:{item.Serialize()}");
|
||||
_logger.LogError($"15分钟采集电表数据下行消息消费队列开始处理_ItemCode_{item.ItemCode}_{item.Serialize()}");
|
||||
await SendMessagesAsync(item);
|
||||
}
|
||||
return SubscribeAck.Success();
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Authorization;
|
||||
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
[DependsOn(
|
||||
typeof(CollectBusDomainSharedModule),
|
||||
typeof(AbpDddApplicationContractsModule),
|
||||
typeof(AbpAuthorizationModule)
|
||||
)]
|
||||
public class CollectBusMigrationApplicationContractsModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
public class CollectBusMigrationRemoteServiceConsts
|
||||
{
|
||||
public const string RemoteServiceName = "CollectBus";
|
||||
|
||||
public const string ModuleName = "collectBus";
|
||||
}
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.DataMigration
|
||||
namespace JiShe.CollectBus.Migration
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据迁移服务
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.DataMigration.Options
|
||||
namespace JiShe.CollectBus.Migration
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据迁移配置
|
||||
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait ContinueOnCapturedContext="false" />
|
||||
</Weavers>
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Migration
|
||||
{
|
||||
public interface ICollectWorker
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>JiShe.CollectBus.Migration</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Workers\**" />
|
||||
<EmbeddedResource Remove="Workers\**" />
|
||||
<None Remove="Workers\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="FodyWeavers.xml" />
|
||||
<None Remove="JiShe.CollectBus.Migration.Application.Contracts.abppkg" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.Authorization" Version="8.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\shared\JiShe.CollectBus.Common\JiShe.CollectBus.Common.csproj" />
|
||||
<ProjectReference Include="..\..\shared\JiShe.CollectBus.Domain.Shared\JiShe.CollectBus.Domain.Shared.csproj" />
|
||||
<ProjectReference Include="..\JiShe.CollectBus.Domain\JiShe.CollectBus.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,20 @@
|
||||
using JiShe.CollectBus.FreeRedis;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.Localization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
[ApiExplorerSettings(GroupName = CollectBusDomainSharedConsts.Business)]
|
||||
public abstract class CollectBusMigrationAppService : ApplicationService
|
||||
{
|
||||
public IFreeSqlProvider SqlProvider => LazyServiceProvider.LazyGetRequiredService<IFreeSqlProvider>();
|
||||
protected IFreeRedisProvider FreeRedisProvider => LazyServiceProvider.LazyGetService<IFreeRedisProvider>()!;
|
||||
|
||||
protected CollectBusMigrationAppService()
|
||||
{
|
||||
LocalizationResource = typeof(CollectBusResource);
|
||||
ObjectMapperContext = typeof(CollectBusMigrationApplicationModule);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
using JiShe.CollectBus.FreeRedis;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.IoTDB;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.AutoMapper;
|
||||
using Volo.Abp.BackgroundWorkers;
|
||||
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
[DependsOn(
|
||||
typeof(CollectBusDomainModule),
|
||||
typeof(CollectBusMigrationApplicationContractsModule),
|
||||
typeof(AbpDddApplicationModule),
|
||||
typeof(AbpAutoMapperModule),
|
||||
typeof(AbpBackgroundWorkersHangfireModule),
|
||||
typeof(CollectBusFreeRedisModule),
|
||||
typeof(CollectBusFreeSqlModule),
|
||||
typeof(CollectBusIoTDbModule)
|
||||
)]
|
||||
public class CollectBusMigrationApplicationModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
|
||||
context.Services.AddAutoMapperObjectMapper<CollectBusMigrationApplicationModule>();
|
||||
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<CollectBusMigrationApplicationModule>(true); });
|
||||
|
||||
}
|
||||
|
||||
public override async Task OnApplicationInitializationAsync(
|
||||
ApplicationInitializationContext context)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var types = assembly.GetTypes().Where(t => typeof(ICollectWorker).IsAssignableFrom(t) && !t.IsInterface)
|
||||
.ToList();
|
||||
foreach (var type in types) await context.AddBackgroundWorkerAsync(type);
|
||||
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// //默认初始化表计信息
|
||||
// var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
|
||||
// dbContext.InitAmmeterCacheData();
|
||||
// //await dbContext.InitWatermeterCacheData();
|
||||
//}).ConfigureAwait(false);
|
||||
|
||||
////下发任务通道构建
|
||||
//DataChannelManage.TaskDataChannel = Channel.CreateUnbounded<ValueTuple<string, List<MeterReadingTelemetryPacketInfo>>>();
|
||||
|
||||
|
||||
//// 日志存储通道构建
|
||||
//DataChannelManage.LogSaveChannel = Channel.CreateUnbounded<object>();
|
||||
|
||||
//// 日志刷新通道构建
|
||||
//DataChannelManage.LogRefreshChannel = Channel.CreateUnbounded<object>();
|
||||
|
||||
//// 启动通道任务
|
||||
//var _dataChannelManage = context.ServiceProvider.GetRequiredService<DataChannelManageService>();
|
||||
//_ = _dataChannelManage.LogSaveAsync(DataChannelManage.LogSaveChannel.Reader);
|
||||
|
||||
////默认初始化表计信息
|
||||
//var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
|
||||
//await dbContext.InitAmmeterCacheData();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using JiShe.CollectBus.DataMigration.Options;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
||||
using LiteDB;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
@ -9,12 +8,12 @@ using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace JiShe.CollectBus.DataMigration
|
||||
namespace JiShe.CollectBus.Migration.DataMigration
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据迁移服务
|
||||
/// </summary>
|
||||
public class DataMigrationService: CollectBusAppService, IDataMigrationService
|
||||
public class DataMigrationService: CollectBusMigrationAppService, IDataMigrationService
|
||||
{
|
||||
private readonly IRepository<MeterReadingRecords, Guid> _meterReadingRecordsRepository;
|
||||
private readonly DataMigrationOptions _options;
|
||||
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait ContinueOnCapturedContext="false" />
|
||||
</Weavers>
|
||||
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>JiShe.CollectBus.Migration</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="FodyWeavers.xml" />
|
||||
<None Remove="JiShe.CollectBus.Migration.Application.abppkg" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.AutoMapper" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundWorkers.Hangfire" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application" Version="8.3.3" />
|
||||
<PackageReference Include="TouchSocket" Version="3.1.2" />
|
||||
<PackageReference Include="TouchSocket.Hosting" Version="3.1.2" />
|
||||
<PackageReference Include="Volo.Abp.EventBus.Kafka" Version="8.3.3" />
|
||||
<ProjectReference Include="..\..\modules\JiShe.CollectBus.FreeRedis\JiShe.CollectBus.FreeRedis.csproj" />
|
||||
<ProjectReference Include="..\..\modules\JiShe.CollectBus.FreeSql\JiShe.CollectBus.FreeSql.csproj" />
|
||||
<ProjectReference Include="..\..\modules\JiShe.CollectBus.IoTDB\JiShe.CollectBus.IoTDB.csproj" />
|
||||
<ProjectReference Include="..\..\shared\JiShe.CollectBus.Common\JiShe.CollectBus.Common.csproj" />
|
||||
<ProjectReference Include="..\JiShe.CollectBus.Domain\JiShe.CollectBus.Domain.csproj" />
|
||||
|
||||
<ProjectReference Include="..\JiShe.CollectBus.Migration.Application.Contracts\JiShe.CollectBus.Migration.Application.Contracts.csproj" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -141,7 +141,7 @@
|
||||
}
|
||||
},
|
||||
"ServerApplicationOptions": {
|
||||
"ServerTagName": "JiSheCollectBus99",
|
||||
"ServerTagName": "JiSheCollectBus8",
|
||||
"SystemType": "Energy",
|
||||
"FirstCollectionTime": "2025-04-28 15:07:00",
|
||||
"AutomaticVerificationTime": "16:07:00",
|
||||
|
||||
@ -0,0 +1,273 @@
|
||||
using Hangfire;
|
||||
using Hangfire.Redis.StackExchange;
|
||||
using JiShe.CollectBus.Migration.Host.Hangfire;
|
||||
using JiShe.CollectBus.Migration.Host.Swaggers;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using StackExchange.Redis;
|
||||
using System.Text;
|
||||
using Volo.Abp.AspNetCore.Auditing;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host
|
||||
{
|
||||
public partial class CollectBusMigrationHostModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the hangfire.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
private void ConfigureHangfire(ServiceConfigurationContext context)
|
||||
{
|
||||
var redisStorageOptions = new RedisStorageOptions()
|
||||
{
|
||||
Db = context.Services.GetConfiguration().GetValue<int>("Redis:HangfireDB")
|
||||
};
|
||||
|
||||
Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
|
||||
|
||||
context.Services.AddHangfire(config =>
|
||||
{
|
||||
config.UseRedisStorage(
|
||||
context.Services.GetConfiguration().GetValue<string>("Redis:Configuration"), redisStorageOptions)
|
||||
.WithJobExpirationTimeout(TimeSpan.FromDays(7));
|
||||
var delaysInSeconds = new[] { 10, 60, 60 * 3 }; // 重试时间间隔
|
||||
const int Attempts = 3; // 重试次数
|
||||
config.UseFilter(new AutomaticRetryAttribute() { Attempts = Attempts, DelaysInSeconds = delaysInSeconds });
|
||||
//config.UseFilter(new AutoDeleteAfterSuccessAttribute(TimeSpan.FromDays(7)));
|
||||
config.UseFilter(new JobRetryLastFilter(Attempts));
|
||||
});
|
||||
context.Services.AddHangfireServer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the JWT authentication.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
private void ConfigureJwtAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.TokenValidationParameters =
|
||||
new TokenValidationParameters()
|
||||
{
|
||||
// 是否开启签名认证
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ClockSkew = TimeSpan.Zero,
|
||||
ValidIssuer = configuration["Jwt:Issuer"],
|
||||
ValidAudience = configuration["Jwt:Audience"],
|
||||
IssuerSigningKey =
|
||||
new SymmetricSecurityKey(
|
||||
Encoding.ASCII.GetBytes(configuration["Jwt:SecurityKey"]))
|
||||
};
|
||||
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnMessageReceived = currentContext =>
|
||||
{
|
||||
var path = currentContext.HttpContext.Request.Path;
|
||||
if (path.StartsWithSegments("/login"))
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var accessToken = string.Empty;
|
||||
if (currentContext.HttpContext.Request.Headers.ContainsKey("Authorization"))
|
||||
{
|
||||
accessToken = currentContext.HttpContext.Request.Headers["Authorization"];
|
||||
if (!string.IsNullOrWhiteSpace(accessToken))
|
||||
{
|
||||
accessToken = accessToken.Split(" ").LastOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(accessToken))
|
||||
{
|
||||
accessToken = currentContext.Request.Query["access_token"].FirstOrDefault();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(accessToken))
|
||||
{
|
||||
accessToken = currentContext.Request.Cookies[@CollectBusMigrationHostConst.DefaultCookieName];
|
||||
}
|
||||
|
||||
currentContext.Token = accessToken;
|
||||
currentContext.Request.Headers.Remove("Authorization");
|
||||
currentContext.Request.Headers.Add("Authorization", $"Bearer {accessToken}");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the cache.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
private void ConfigureCache(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpDistributedCacheOptions>(
|
||||
options => { options.KeyPrefix = "CollectBus:"; });
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var redis = ConnectionMultiplexer.Connect($"{configuration.GetValue<string>("Redis:Configuration")},defaultdatabase={configuration.GetValue<int>("Redis:DefaultDB")}");
|
||||
context.Services
|
||||
.AddDataProtection()
|
||||
.PersistKeysToStackExchangeRedis(redis, "CollectBus-Protection-Keys");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the swagger services.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
private void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddSwaggerGen(
|
||||
options =>
|
||||
{
|
||||
configuration.GetSection("SwaggerConfig").Get<List<SwaggerConfig>>()?.ForEach(group =>
|
||||
{
|
||||
options.SwaggerDoc(group.GroupName,
|
||||
new OpenApiInfo { Title = group.Title, Version = group.Version });
|
||||
});
|
||||
|
||||
options.DocInclusionPredicate((docName, apiDes) =>
|
||||
{
|
||||
if (docName == "Basic" && string.IsNullOrWhiteSpace(apiDes.GroupName)) return true;
|
||||
return docName == apiDes.GroupName;
|
||||
});
|
||||
|
||||
options.EnableAnnotations();
|
||||
options.DocumentFilter<HiddenAbpDefaultApiFilter>();
|
||||
options.SchemaFilter<EnumSchemaFilter>();
|
||||
var xmlPaths = Directory.GetFiles(AppContext.BaseDirectory, "*.xml")
|
||||
.Where(a => a.EndsWith("Application.xml") ||
|
||||
a.EndsWith("Application.Contracts.xml") ||
|
||||
a.EndsWith("httpApi.xml") ||
|
||||
a.EndsWith("Host.xml"))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
foreach (var xml in xmlPaths) options.IncludeXmlComments(xml, true);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the audit log.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
private void ConfigureAuditLog(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpAuditingOptions>
|
||||
(
|
||||
options =>
|
||||
{
|
||||
options.IsEnabled = true;
|
||||
options.EntityHistorySelectors.AddAllEntities();
|
||||
options.ApplicationName = "JiShe.CollectBus";
|
||||
}
|
||||
);
|
||||
|
||||
Configure<AbpAspNetCoreAuditingOptions>(
|
||||
options =>
|
||||
{
|
||||
options.IgnoredUrls.Add("/AuditLogs/page");
|
||||
options.IgnoredUrls.Add("/hangfire/stats");
|
||||
options.IgnoredUrls.Add("/hangfire/recurring/trigger");
|
||||
options.IgnoredUrls.Add("/cap");
|
||||
options.IgnoredUrls.Add("/");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Configures the custom.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
private void ConfigureCustom(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the network.
|
||||
/// </summary>
|
||||
/// <param name="context">The context.</param>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
public void ConfigureNetwork(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
//context.Services.AddTcpService(config =>
|
||||
//{
|
||||
// config.SetListenIPHosts(int.Parse(configuration["TCP:ClientPort"] ?? "10500"))
|
||||
// //.SetTcpDataHandlingAdapter(()=>new StandardFixedHeaderDataHandlingAdapter())
|
||||
// //.SetGetDefaultNewId(() => Guid.NewGuid().ToString())//定义ClientId的生成策略
|
||||
// .ConfigurePlugins(a =>
|
||||
// {
|
||||
// a.Add<TcpCloseMonitor>();
|
||||
// a.Add<TcpMonitor>();
|
||||
// a.Add<ServerMonitor>();
|
||||
// });
|
||||
//});
|
||||
|
||||
//context.Services.AddUdpSession(config =>
|
||||
//{
|
||||
// config.SetBindIPHost(int.Parse(configuration["UDP:ClientPort"] ?? "10500"))
|
||||
// .ConfigurePlugins(a =>
|
||||
// {
|
||||
// a.Add<UdpMonitor>();
|
||||
// a.Add<ServerMonitor>();
|
||||
// })
|
||||
// .UseBroadcast()
|
||||
// .SetUdpDataHandlingAdapter(() => new NormalUdpDataHandlingAdapter());
|
||||
//});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 健康检查
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="configuration"></param>
|
||||
private void ConfigureHealthChecks(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
//if (!configuration.GetValue<bool>("HealthChecks:IsEnable")) return;
|
||||
//var cassandraConfig = new CassandraConfig();
|
||||
//configuration.GetSection("Cassandra").Bind(cassandraConfig);
|
||||
//context.Services.AddHealthChecks()
|
||||
// .AddMongoDb(configuration.GetConnectionString("Default"), "MongoDB", HealthStatus.Unhealthy)
|
||||
// .AddRedis(configuration.GetValue<string>("Redis:Configuration") ?? string.Empty, "Redis",
|
||||
// HealthStatus.Unhealthy)
|
||||
// .AddKafka(new Confluent.Kafka.ProducerConfig
|
||||
// {
|
||||
// BootstrapServers = configuration.GetValue<string>("Kafka:BootstrapServers")
|
||||
// }, "Kafka", failureStatus: HealthStatus.Unhealthy)
|
||||
|
||||
// //.AddCheck<CassandraHealthCheck>("Cassandra")
|
||||
// .AddCheck<IoTdbHealthCheck>("IoTDB");
|
||||
|
||||
//context.Services
|
||||
// .AddHealthChecksUI(options =>
|
||||
// {
|
||||
// options.AddHealthCheckEndpoint("JiSheCollectBus", "/health"); // 映射本地端点
|
||||
// })
|
||||
// .AddInMemoryStorage();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
109
web/JiShe.CollectBus.Migration.Host/CollectBusHostModule.cs
Normal file
109
web/JiShe.CollectBus.Migration.Host/CollectBusHostModule.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using Hangfire;
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Migration.Host.HealthChecks;
|
||||
using JiShe.CollectBus.Migration.Host.Swaggers;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
||||
using Volo.Abp.AspNetCore.Serilog;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||
using Volo.Abp.Caching.StackExchangeRedis;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.Timing;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[DependsOn(typeof(CollectBusMigrationHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule),
|
||||
typeof(AbpTimingModule),
|
||||
typeof(CollectBusMigrationApplicationModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpBackgroundWorkersHangfireModule)
|
||||
)]
|
||||
public partial class CollectBusMigrationHostModule : AbpModule
|
||||
{
|
||||
/// <summary>
|
||||
/// ConfigureServices
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
ConfigureCache(context);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
ConfigureNetwork(context, configuration);
|
||||
ConfigureJwtAuthentication(context, configuration);
|
||||
ConfigureHangfire(context);
|
||||
ConfigureAuditLog(context);
|
||||
ConfigureCustom(context, configuration);
|
||||
//ConfigureHealthChecks(context, configuration);
|
||||
Configure<AbpClockOptions>(options => { options.Kind = DateTimeKind.Local; });
|
||||
|
||||
Configure<ServerApplicationOptions>(options =>
|
||||
{
|
||||
configuration.GetSection(nameof(ServerApplicationOptions)).Bind(options);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// OnApplicationInitialization
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
var app = context.GetApplicationBuilder();
|
||||
var configuration = context.GetConfiguration();
|
||||
var env = context.GetEnvironment();
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseCors(CollectBusMigrationHostConst.DefaultCorsPolicyName);
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseAbpSwaggerUI(options =>
|
||||
{
|
||||
configuration.GetSection("SwaggerConfig").Get<List<SwaggerConfig>>()?.ForEach(group =>
|
||||
{
|
||||
options.SwaggerEndpoint($"/swagger/{group.GroupName}/swagger.json", group.Title); //分组显示
|
||||
});
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
options.DefaultModelsExpandDepth(-1);
|
||||
});
|
||||
}
|
||||
app.UseAuditing();
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseUnitOfWork();
|
||||
app.UseHangfireDashboard("/hangfire", new DashboardOptions
|
||||
{
|
||||
IgnoreAntiforgeryToken = true
|
||||
});
|
||||
app.UseConfiguredEndpoints(endpoints =>
|
||||
{
|
||||
if (!configuration.GetValue<bool>("HealthChecks:IsEnable")) return;
|
||||
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
||||
{
|
||||
Predicate = _ => true,
|
||||
ResponseWriter = HealthCheckResponse.Writer
|
||||
});
|
||||
endpoints.MapHealthChecksUI(options =>
|
||||
{
|
||||
options.UIPath = "/health-ui";
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
namespace JiShe.CollectBus.Migration.Host
|
||||
{
|
||||
/// <summary>
|
||||
/// CollectBusMigrationHostConst
|
||||
/// </summary>
|
||||
public static class CollectBusMigrationHostConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 跨域策略名
|
||||
/// </summary>
|
||||
public const string DefaultCorsPolicyName = "Default";
|
||||
|
||||
/// <summary>
|
||||
/// Cookies名称
|
||||
/// </summary>
|
||||
public const string DefaultCookieName = "JiShe.CollectBus.Migration.Host";
|
||||
|
||||
/// <summary>
|
||||
/// SwaggerUi 端点
|
||||
/// </summary>
|
||||
public const string SwaggerUiEndPoint = "/swagger";
|
||||
|
||||
/// <summary>
|
||||
/// Hangfire 端点
|
||||
/// </summary>
|
||||
public const string HangfireDashboardEndPoint = "/hangfire";
|
||||
|
||||
/// <summary>
|
||||
/// 健康检查 端点
|
||||
/// </summary>
|
||||
public const string HealthEndPoint = "/health";
|
||||
|
||||
/// <summary>
|
||||
/// 健康检查 端点
|
||||
/// </summary>
|
||||
public const string HealthDashboardEndPoint = "/health-ui";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.Controllers
|
||||
{
|
||||
public class HomeController : AbpController
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Redirect("/Monitor");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
namespace JiShe.CollectBus.Migration.Host.Extensions
|
||||
{
|
||||
public static class CustomApplicationBuilderExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseProtocolPlugin(this IApplicationBuilder app)
|
||||
{
|
||||
return app;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
using System.Reflection;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static void AddPluginApplications(this IServiceCollection services, string pluginPath = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pluginPath))
|
||||
{
|
||||
pluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
|
||||
}
|
||||
var assemblies = GetAssembliesFromFolder(pluginPath);
|
||||
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
var applicationServiceType = assembly.GetTypes()
|
||||
.FirstOrDefault(a => a.IsClass && !a.IsAbstract && typeof(AbpModule).IsAssignableFrom(a));
|
||||
services.AddApplication(applicationServiceType);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Assembly> GetAssembliesFromFolder(string folderPath)
|
||||
{
|
||||
var directory = new DirectoryInfo(folderPath);
|
||||
if (!directory.Exists) return [];
|
||||
|
||||
var files = directory.GetFiles("*.dll");
|
||||
|
||||
var assemblies = new List<Assembly>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.LoadFrom(file.FullName);
|
||||
assemblies.Add(assembly);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error loading assembly from {file.FullName}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return assemblies;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using Hangfire.Common;
|
||||
using Hangfire.States;
|
||||
using Serilog;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.Hangfire
|
||||
{
|
||||
/// <summary>
|
||||
/// 重试最后一次
|
||||
/// </summary>
|
||||
public class JobRetryLastFilter : JobFilterAttribute, IElectStateFilter
|
||||
{
|
||||
private int RetryCount { get; }
|
||||
|
||||
public JobRetryLastFilter(int retryCount)
|
||||
{
|
||||
RetryCount = retryCount;
|
||||
}
|
||||
|
||||
|
||||
public void OnStateElection(ElectStateContext context)
|
||||
{
|
||||
var retryAttempt = context.GetJobParameter<int>("RetryCount");
|
||||
if (RetryCount == retryAttempt)
|
||||
{
|
||||
Log.Error("最后一次重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.HealthChecks
|
||||
{
|
||||
public class HealthCheckResponse
|
||||
{
|
||||
public static Task Writer(HttpContext context, HealthReport healthReport)
|
||||
{
|
||||
context.Response.ContentType = "application/json";
|
||||
|
||||
var result = JsonConvert.SerializeObject(new
|
||||
{
|
||||
status = healthReport.Status.ToString(),
|
||||
errors = healthReport.Entries.Select(e => new
|
||||
{
|
||||
key = e.Key,
|
||||
value = e.Value.Status.ToString()
|
||||
})
|
||||
});
|
||||
return context.Response.WriteAsync(result);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.HealthChecks
|
||||
{
|
||||
/// <summary>
|
||||
/// IoTDBHealthCheck
|
||||
/// </summary>
|
||||
/// <seealso cref="Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck" />
|
||||
public class IoTdbHealthCheck : IHealthCheck
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IoTdbHealthCheck"/> class.
|
||||
/// </summary>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
public IoTdbHealthCheck(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the health check, returning the status of the component being checked.
|
||||
/// </summary>
|
||||
/// <param name="context">A context object associated with the current execution.</param>
|
||||
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the health check.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Threading.Tasks.Task`1" /> that completes when the health check has finished, yielding the status of the component being checked.
|
||||
/// </returns>
|
||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
// todo 此处需要单独创建连接,并需要在连接打开以后立即关闭,否则会影响整个连接的使用。
|
||||
//var ioTDbOptions = new IoTDbOptions();
|
||||
//_configuration.GetSection("IoTDBOptions").Bind(ioTDbOptions);
|
||||
//var pool = new SessionPoolAdapter(ioTDbOptions);
|
||||
//await pool.OpenAsync();
|
||||
return HealthCheckResult.Healthy($"IoTDB is healthy.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new HealthCheckResult(context.Registration.FailureStatus, $"IoTDB不健康: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="logs\**" />
|
||||
<Content Remove="logs\**" />
|
||||
<EmbeddedResource Remove="logs\**" />
|
||||
<None Remove="logs\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="C:\Users\Dai Zan\.nuget\packages\volo.abp.aspnetcore.serilog\8.3.3\contentFiles\any\net8.0\Volo.Abp.AspNetCore.Serilog.abppkg.analyze.json" />
|
||||
<Content Remove="C:\Users\Dai Zan\.nuget\packages\volo.abp.aspnetcore\8.3.3\contentFiles\any\net8.0\Volo.Abp.AspNetCore.abppkg.analyze.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Kafka" Version="9.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="8.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="9.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="9.0.0" />
|
||||
|
||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundWorkers.Hangfire" Version="8.3.3" />
|
||||
|
||||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.3" />
|
||||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.3" />
|
||||
<!--<PackageReference Include="Hangfire.HttpJob" Version="3.8.5" />
|
||||
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
|
||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />-->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\services\JiShe.CollectBus.Migration.Application.Contracts\JiShe.CollectBus.Migration.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\services\JiShe.CollectBus.Migration.Application\JiShe.CollectBus.Migration.Application.csproj" />
|
||||
<ProjectReference Include="..\JiShe.CollectBus.Migration.HttpApi\JiShe.CollectBus.Migration.HttpApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
188
web/JiShe.CollectBus.Migration.Host/Pages/Monitor.cshtml
Normal file
188
web/JiShe.CollectBus.Migration.Host/Pages/Monitor.cshtml
Normal file
@ -0,0 +1,188 @@
|
||||
@page
|
||||
@using JiShe.CollectBus.Migration.Host
|
||||
@model JiShe.CollectBus.Migration.Host.Pages.Monitor
|
||||
|
||||
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<title>后端服务</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container projects">
|
||||
<div class="projects-header page-header">
|
||||
<h2>后端服务列表</h2>
|
||||
@* <p>这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的</p> *@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="thumbnail" style="height: 180px">
|
||||
<a href="@CollectBusMigrationHostConst.SwaggerUiEndPoint" target="_blank">
|
||||
<img class="lazy" src="/images/swagger.png" width="300" height="150" />
|
||||
</a>
|
||||
<div class="caption">
|
||||
<h3>
|
||||
<a href="@CollectBusMigrationHostConst.SwaggerUiEndPoint" target="_blank">SwaggerUI</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="thumbnail" style="height: 180px">
|
||||
<a href="@CollectBusMigrationHostConst.HangfireDashboardEndPoint" target="_blank">
|
||||
<img class="lazy" src="/images/hangfire.png" width="300" height="150" />
|
||||
</a>
|
||||
<div class="caption">
|
||||
<h3>
|
||||
<a href="@CollectBusMigrationHostConst.HangfireDashboardEndPoint" target="_blank">Hangfire面板</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="thumbnail" style="height: 180px">
|
||||
<a href="@CollectBusMigrationHostConst.HealthDashboardEndPoint" target="_blank">
|
||||
<img class="lazy" src="/images/hangfire.png" width="300" height="150" />
|
||||
</a>
|
||||
<div class="caption">
|
||||
<h3>
|
||||
<a href="@CollectBusMigrationHostConst.HealthEndPoint" target="_blank">健康检查API</a> |
|
||||
<a href="@CollectBusMigrationHostConst.HealthDashboardEndPoint" target="_blank">UI</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* <div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="thumbnail" style="height: 180px">
|
||||
<a href="@CollectBusMigrationHostConst.MoreEndPoint" target="_blank">
|
||||
<img class="lazy" src="/images/more.png" width="300" height="150"/>
|
||||
</a>
|
||||
<div class="caption">
|
||||
<h3>
|
||||
<a href="@CollectBusMigrationHostConst.MoreEndPoint" target="_blank">了解更多...</a>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<style>
|
||||
*:before,
|
||||
*:after {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 1170px;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.projects-header {
|
||||
width: 60%;
|
||||
text-align: center;
|
||||
font-weight: 200;
|
||||
display: block;
|
||||
margin: 60px auto 40px !important;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
padding-bottom: 9px;
|
||||
margin: 40px auto;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.projects-header h2 {
|
||||
font-size: 42px;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
color: inherit;
|
||||
/* text-align: center; */
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-right: -15px;
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
.col-lg-3 {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.projects .thumbnail {
|
||||
display: block;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
display: block;
|
||||
padding: 4px;
|
||||
line-height: 1.42857143;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
.transition(border 0.2s ease-in-out);
|
||||
}
|
||||
|
||||
a {
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.projects .thumbnail img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.thumbnail a > img,
|
||||
.thumbnail > img {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* .projects .thumbnail .caption {
|
||||
overflow-y: hidden;
|
||||
color: #555;
|
||||
} */
|
||||
|
||||
.caption {
|
||||
padding: 9px;
|
||||
overflow-y: hidden;
|
||||
color: #555;
|
||||
}
|
||||
</style>
|
||||
13
web/JiShe.CollectBus.Migration.Host/Pages/Monitor.cshtml.cs
Normal file
13
web/JiShe.CollectBus.Migration.Host/Pages/Monitor.cshtml.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.Pages
|
||||
{
|
||||
public class Monitor : PageModel
|
||||
{
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
31
web/JiShe.CollectBus.Migration.Host/Program.cs
Normal file
31
web/JiShe.CollectBus.Migration.Host/Program.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Serilog;
|
||||
using Volo.Abp.Modularity.PlugIns;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host;
|
||||
|
||||
/// <summary>
|
||||
/// Program
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Main
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseSerilog((context, loggerConfiguration) =>
|
||||
{
|
||||
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
|
||||
})
|
||||
.UseAutofac();
|
||||
var configuration = builder.Configuration;
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"JiShe.CollectBus.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:44316",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.Swaggers
|
||||
{
|
||||
/// <summary>
|
||||
/// swagger 枚举映射,
|
||||
/// 原因:前端代理生成枚举是数字
|
||||
/// </summary>
|
||||
public class EnumSchemaFilter : ISchemaFilter
|
||||
{
|
||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
||||
{
|
||||
if (!context.Type.IsEnum)
|
||||
return;
|
||||
OpenApiArray openApiArray = new OpenApiArray();
|
||||
openApiArray.AddRange((IEnumerable<IOpenApiAny>)Enum.GetNames(context.Type).Select(n => new OpenApiString(n)));
|
||||
schema.Extensions.Add("x-enumNames", openApiArray);
|
||||
schema.Extensions.Add("x-enum-varnames", openApiArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace JiShe.CollectBus.Migration.Host.Swaggers
|
||||
{
|
||||
/// <summary>
|
||||
/// 在使用nswag的时候,原生默认的api导致生产的代理类存在问题
|
||||
/// 所有隐藏原生的api,重写路由
|
||||
/// </summary>
|
||||
public class HiddenAbpDefaultApiFilter : IDocumentFilter
|
||||
{
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
foreach (ApiDescription apiDescription in context.ApiDescriptions)
|
||||
{
|
||||
if (apiDescription.TryGetMethodInfo(out MethodInfo _))
|
||||
{
|
||||
string key = "/" + apiDescription.RelativePath;
|
||||
if (IsHidden(key))
|
||||
swaggerDoc.Paths.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHidden(string key)
|
||||
{
|
||||
foreach (string hiddenAbpDefaultApi in GetHiddenAbpDefaultApiList())
|
||||
{
|
||||
if (key.Contains(hiddenAbpDefaultApi))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<string> GetHiddenAbpDefaultApiList()
|
||||
{
|
||||
return new List<string>()
|
||||
{
|
||||
"/api/abp/multi-tenancy/tenants",
|
||||
"/api/account",
|
||||
"/api/feature-management/features",
|
||||
"/api/permission-management/permissions",
|
||||
"/api/identity/my-profile",
|
||||
"/api/identity",
|
||||
"/api/multi-tenancy/tenants",
|
||||
"/api/setting-management/emailing",
|
||||
"/configuration",
|
||||
"/outputcache"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
namespace JiShe.CollectBus.Migration.Host.Swaggers
|
||||
{
|
||||
public class SwaggerConfig
|
||||
{
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"Default": "mongodb://admin:4mFmPTTB8tn6aI@47.110.62.104:27017,47.110.53.196:27017,47.110.60.222:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
|
||||
"PrepayDB": "server=118.190.144.92;database=jishe.sysdb;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False",
|
||||
"EnergyDB": "server=118.190.144.92;database=db_energy;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "47.110.60.222:6379,password=3JBGfyhTaD46nS,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
|
||||
"MaxPoolSize": "50",
|
||||
"DefaultDB": "14",
|
||||
"HangfireDB": "13"
|
||||
},
|
||||
"Kafka": {
|
||||
"BootstrapServers": "47.110.62.104:9092,47.110.53.196:9092,47.110.60.222:9092",
|
||||
"EnableFilter": true,
|
||||
"EnableAuthorization": false,
|
||||
"SecurityProtocol": "SaslPlaintext",
|
||||
"SaslMechanism": "Plain",
|
||||
"SaslUserName": "lixiao",
|
||||
"SaslPassword": "lixiao1980",
|
||||
"KafkaReplicationFactor": 3,
|
||||
"NumPartitions": 30,
|
||||
"ServerTagName": "JiSheCollectBus100",
|
||||
"FirstCollectionTime": "2025-04-22 16:07:00"
|
||||
},
|
||||
"IoTDBOptions": {
|
||||
"UserName": "root",
|
||||
"Password": "Yp2eU6MVdIjXCL",
|
||||
"ClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
|
||||
"PoolSize": 2,
|
||||
"DataBaseName": "energy",
|
||||
"OpenDebugMode": true,
|
||||
"UseTableSessionPoolByDefault": false
|
||||
},
|
||||
"Cassandra": {
|
||||
"ReplicationStrategy": {
|
||||
"Class": "NetworkTopologyStrategy", //策略为NetworkTopologyStrategy时才会有多个数据中心,SimpleStrategy用在只有一个数据中心的情况下
|
||||
"DataCenters": [
|
||||
{
|
||||
"Name": "dc1",
|
||||
"ReplicationFactor": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"Nodes": [
|
||||
{
|
||||
"Host": "121.42.175.177",
|
||||
"Port": 19042,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC1"
|
||||
},
|
||||
{
|
||||
"Host": "121.42.175.177",
|
||||
"Port": 19043,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC2"
|
||||
},
|
||||
{
|
||||
"Host": "121.42.175.177",
|
||||
"Port": 19044,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC2"
|
||||
}
|
||||
],
|
||||
"Username": "admin",
|
||||
"Password": "lixiao1980",
|
||||
"Keyspace": "jishecollectbus",
|
||||
"ConsistencyLevel": "Quorum",
|
||||
"PoolingOptions": {
|
||||
"CoreConnectionsPerHost": 4,
|
||||
"MaxConnectionsPerHost": 8,
|
||||
"MaxRequestsPerConnection": 2000
|
||||
},
|
||||
"SocketOptions": {
|
||||
"ConnectTimeoutMillis": 10000,
|
||||
"ReadTimeoutMillis": 20000
|
||||
},
|
||||
"QueryOptions": {
|
||||
"ConsistencyLevel": "Quorum",
|
||||
"SerialConsistencyLevel": "Serial",
|
||||
"DefaultIdempotence": true
|
||||
}
|
||||
}
|
||||
}
|
||||
158
web/JiShe.CollectBus.Migration.Host/appsettings.json
Normal file
158
web/JiShe.CollectBus.Migration.Host/appsettings.json
Normal file
@ -0,0 +1,158 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
"Serilog.Sinks.File"
|
||||
],
|
||||
"MinimumLevel": {
|
||||
"Default": "Warning",
|
||||
"Override": {
|
||||
"Microsoft": "Warning",
|
||||
"Volo.Abp": "Warning",
|
||||
"Hangfire": "Warning",
|
||||
"DotNetCore.CAP": "Warning",
|
||||
"Serilog.AspNetCore": "Information",
|
||||
"Microsoft.EntityFrameworkCore": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.AspNetCore.Diagnostics.HealthChecks": "Warning"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Console"
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "logs/logs-.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"App": {
|
||||
"SelfUrl": "http://localhost:44315",
|
||||
"CorsOrigins": "http://localhost:4200,http://localhost:3100"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "mongodb://mongo_PmEeF3:lixiao1980@192.168.5.9:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
|
||||
"Kafka": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092",
|
||||
"PrepayDB": "server=118.190.144.92;database=jishe.sysdb;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False",
|
||||
"EnergyDB": "server=118.190.144.92;database=db_energy;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "192.168.5.9:6380,password=1q2w3e!@#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
|
||||
"MaxPoolSize": "50",
|
||||
"DefaultDB": "14",
|
||||
"HangfireDB": "13"
|
||||
},
|
||||
"Jwt": {
|
||||
"Audience": "JiShe.CollectBus",
|
||||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
|
||||
"Issuer": "JiShe.CollectBus",
|
||||
"ExpirationTime": 2
|
||||
},
|
||||
"HealthChecks": {
|
||||
"IsEnable": true,
|
||||
"HealthCheckDatabaseName": "HealthChecks",
|
||||
"EvaluationTimeInSeconds": 10,
|
||||
"MinimumSecondsBetweenFailureNotifications": 60
|
||||
},
|
||||
"SwaggerConfig": [
|
||||
{
|
||||
"GroupName": "Basic",
|
||||
"Title": "【后台管理】基础模块",
|
||||
"Version": "V1"
|
||||
},
|
||||
{
|
||||
"GroupName": "Business",
|
||||
"Title": "【后台管理】业务模块",
|
||||
"Version": "V1"
|
||||
}
|
||||
],
|
||||
"Kafka": {
|
||||
"BootstrapServers": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092",
|
||||
"EnableFilter": true,
|
||||
"EnableAuthorization": false,
|
||||
"SecurityProtocol": "SaslPlaintext",
|
||||
"SaslMechanism": "Plain",
|
||||
"SaslUserName": "lixiao",
|
||||
"SaslPassword": "lixiao1980",
|
||||
"KafkaReplicationFactor": 3,
|
||||
"NumPartitions": 30,
|
||||
"FirstCollectionTime": "2025-04-22 16:07:00"
|
||||
},
|
||||
"IoTDBOptions": {
|
||||
"UserName": "root",
|
||||
"Password": "root",
|
||||
"ClusterList": [ "192.168.5.9:6667" ],
|
||||
"PoolSize": 32,
|
||||
"DataBaseName": "energy",
|
||||
"OpenDebugMode": false,
|
||||
"UseTableSessionPoolByDefault": false
|
||||
},
|
||||
"Cassandra": {
|
||||
"ReplicationStrategy": {
|
||||
"Class": "NetworkTopologyStrategy", //策略为NetworkTopologyStrategy时才会有多个数据中心,SimpleStrategy用在只有一个数据中心的情况下
|
||||
"DataCenters": [
|
||||
{
|
||||
"Name": "dc1",
|
||||
"ReplicationFactor": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"Nodes": [
|
||||
{
|
||||
"Host": "192.168.5.9",
|
||||
"Port": 9042,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC1"
|
||||
},
|
||||
{
|
||||
"Host": "192.168.5.9",
|
||||
"Port": 9043,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC2"
|
||||
},
|
||||
{
|
||||
"Host": "192.168.5.9",
|
||||
"Port": 9044,
|
||||
"DataCenter": "dc1",
|
||||
"Rack": "RAC2"
|
||||
}
|
||||
],
|
||||
"Username": "admin",
|
||||
"Password": "lixiao1980",
|
||||
"Keyspace": "jishecollectbus",
|
||||
"ConsistencyLevel": "Quorum",
|
||||
"PoolingOptions": {
|
||||
"CoreConnectionsPerHost": 4,
|
||||
"MaxConnectionsPerHost": 8,
|
||||
"MaxRequestsPerConnection": 2000
|
||||
},
|
||||
"SocketOptions": {
|
||||
"ConnectTimeoutMillis": 10000,
|
||||
"ReadTimeoutMillis": 20000
|
||||
},
|
||||
"QueryOptions": {
|
||||
"ConsistencyLevel": "Quorum",
|
||||
"SerialConsistencyLevel": "Serial",
|
||||
"DefaultIdempotence": true
|
||||
}
|
||||
},
|
||||
"ServerApplicationOptions": {
|
||||
"ServerTagName": "JiSheCollectBus8",
|
||||
"SystemType": "Energy",
|
||||
"FirstCollectionTime": "2025-04-28 15:07:00",
|
||||
"AutomaticVerificationTime": "16:07:00",
|
||||
"AutomaticTerminalVersionTime": "17:07:00",
|
||||
"AutomaticTelematicsModuleTime": "17:30:00",
|
||||
"AutomaticDayFreezeTime": "02:30:00",
|
||||
"AutomaticMonthFreezeTime": "03:30:00",
|
||||
"DefaultProtocolPlugin": "T37612012ProtocolPlugin"
|
||||
},
|
||||
"PlugInFolder": "",
|
||||
"TCP": {
|
||||
"ClientPort": 10500
|
||||
}
|
||||
}
|
||||
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/cap.png
Normal file
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/cap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/hangfire.png
Normal file
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/hangfire.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/more.png
Normal file
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/more.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/swagger.png
Normal file
BIN
web/JiShe.CollectBus.Migration.Host/wwwroot/images/swagger.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
6
web/JiShe.CollectBus.Migration.Host/wwwroot/libs/bootstrap/css/bootstrap.min.css
vendored
Normal file
6
web/JiShe.CollectBus.Migration.Host/wwwroot/libs/bootstrap/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,12 @@
|
||||
using JiShe.CollectBus.Localization;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
public abstract class CollectBusController : AbpControllerBase
|
||||
{
|
||||
protected CollectBusController()
|
||||
{
|
||||
LocalizationResource = typeof(CollectBusResource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
using Localization.Resources.AbpUi;
|
||||
using JiShe.CollectBus.Localization;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Migration;
|
||||
|
||||
[DependsOn(
|
||||
typeof(CollectBusMigrationApplicationModule),
|
||||
typeof(CollectBusMigrationApplicationContractsModule),
|
||||
typeof(AbpAspNetCoreMvcModule)
|
||||
)]
|
||||
public class CollectBusMigrationHttpApiModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PreConfigure<IMvcBuilder>(mvcBuilder =>
|
||||
{
|
||||
mvcBuilder.AddApplicationPartIfNotExists(typeof(CollectBusMigrationHttpApiModule).Assembly);
|
||||
});
|
||||
|
||||
Configure<AbpAspNetCoreMvcOptions>(options =>
|
||||
{
|
||||
options.ConventionalControllers
|
||||
.Create(typeof(CollectBusMigrationApplicationModule).Assembly);
|
||||
});
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpLocalizationOptions>(options =>
|
||||
{
|
||||
options.Resources
|
||||
.Get<CollectBusResource>()
|
||||
.AddBaseTypes(typeof(AbpUiResource));
|
||||
});
|
||||
}
|
||||
}
|
||||
3
web/JiShe.CollectBus.Migration.HttpApi/FodyWeavers.xml
Normal file
3
web/JiShe.CollectBus.Migration.HttpApi/FodyWeavers.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait ContinueOnCapturedContext="false" />
|
||||
</Weavers>
|
||||
@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>JiShe.CollectBus</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="FodyWeavers.xml" />
|
||||
<None Remove="JiShe.CollectBus.HttpApi.abppkg" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="8.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Samples\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\services\JiShe.CollectBus.Migration.Application.Contracts\JiShe.CollectBus.Migration.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\services\JiShe.CollectBus.Migration.Application\JiShe.CollectBus.Migration.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
x
Reference in New Issue
Block a user