完善项目架构,新增统一事件集中处理项目接口

This commit is contained in:
ChenYi 2025-05-23 14:19:57 +08:00
parent 4a609b6cf8
commit c88d934feb
58 changed files with 1566 additions and 17 deletions

View File

@ -74,6 +74,26 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBus.Migration.
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
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MainService", "MainService", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EPOService", "EPOService", "{18207368-3C39-4346-85F7-A8B499B0B458}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MigrationService", "MigrationService", "{A31EC18C-956B-4FD2-AED6-609C33B467E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBusEPO.Application.Contracts", "services\JiShe.CollectBusEPO.Application.Contracts\JiShe.CollectBusEPO.Application.Contracts.csproj", "{3B32D838-33BF-C08A-C447-3172CA62D42F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBusEPO.Application", "services\JiShe.CollectBusEPO.Application\JiShe.CollectBusEPO.Application.csproj", "{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBusEPO.HttpApi", "web\JiShe.CollectBusEPO.HttpApi\JiShe.CollectBusEPO.HttpApi.csproj", "{98FE468D-0C34-83D9-31BD-F59C44D00357}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JiShe.CollectBusEPO.HttpApi.Host", "web\JiShe.CollectBusEPO.HttpApi.Host\JiShe.CollectBusEPO.HttpApi.Host.csproj", "{A2DDA6F0-C760-0633-D576-E23A186504E4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MainHost", "MainHost", "{A38B5EB3-2F55-44A2-944B-31A73DE91402}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MigrationHost", "MigrationHost", "{C61007F8-51F5-409C-9FAF-DEF6A24DCDED}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EPOHost", "EPOHost", "{8D1FD3D9-3FF0-4581-ACF0-45AF9D595774}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -184,6 +204,22 @@ Global
{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
{3B32D838-33BF-C08A-C447-3172CA62D42F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B32D838-33BF-C08A-C447-3172CA62D42F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B32D838-33BF-C08A-C447-3172CA62D42F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B32D838-33BF-C08A-C447-3172CA62D42F}.Release|Any CPU.Build.0 = Release|Any CPU
{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA}.Release|Any CPU.Build.0 = Release|Any CPU
{98FE468D-0C34-83D9-31BD-F59C44D00357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98FE468D-0C34-83D9-31BD-F59C44D00357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98FE468D-0C34-83D9-31BD-F59C44D00357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98FE468D-0C34-83D9-31BD-F59C44D00357}.Release|Any CPU.Build.0 = Release|Any CPU
{A2DDA6F0-C760-0633-D576-E23A186504E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2DDA6F0-C760-0633-D576-E23A186504E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2DDA6F0-C760-0633-D576-E23A186504E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2DDA6F0-C760-0633-D576-E23A186504E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -191,11 +227,11 @@ Global
GlobalSection(NestedProjects) = preSolution
{D64C1577-4929-4B60-939E-96DE1534891A} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
{F2840BC7-0188-4606-9126-DADD0F5ABF7A} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{BD65D04F-08D5-40C1-8C24-77CA0BACB877} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{78040F9E-3501-4A40-82DF-00A597710F35} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{BD65D04F-08D5-40C1-8C24-77CA0BACB877} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{78040F9E-3501-4A40-82DF-00A597710F35} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{F1C58097-4C08-4D88-8976-6B3389391481} = {2E0FE301-34C3-4561-9CAE-C7A9E65AEE59}
{077AA5F8-8B61-420C-A6B5-0150A66FDB34} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
{35829A15-4127-4F69-8BDE-9405DEAACA9A} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
{077AA5F8-8B61-420C-A6B5-0150A66FDB34} = {A38B5EB3-2F55-44A2-944B-31A73DE91402}
{35829A15-4127-4F69-8BDE-9405DEAACA9A} = {A38B5EB3-2F55-44A2-944B-31A73DE91402}
{AD2F1928-4411-4511-B564-5FB996EC08B9} = {EBF7C01F-9B4F-48E6-8418-2CBFDA51EB0B}
{8BA01C3D-297D-42DF-BD63-EF07202A0A67} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{FE0457D9-4038-4A17-8808-DCAD06CFC0A0} = {2E0FE301-34C3-4561-9CAE-C7A9E65AEE59}
@ -211,10 +247,20 @@ 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}
{E01625B5-B5B7-7A4B-468F-EC12C1BDBA2A} = {A31EC18C-956B-4FD2-AED6-609C33B467E9}
{B955C5DA-3C20-35D2-0770-8FE473C41C44} = {A31EC18C-956B-4FD2-AED6-609C33B467E9}
{995D3D91-7221-D4A3-A7B2-FEC202328A18} = {C61007F8-51F5-409C-9FAF-DEF6A24DCDED}
{8A113DE5-7D50-6E6B-739F-B6EEAD5E13B4} = {C61007F8-51F5-409C-9FAF-DEF6A24DCDED}
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{18207368-3C39-4346-85F7-A8B499B0B458} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{A31EC18C-956B-4FD2-AED6-609C33B467E9} = {BA4DA3E7-9AD0-47AD-A0E6-A0BB6700DA23}
{3B32D838-33BF-C08A-C447-3172CA62D42F} = {18207368-3C39-4346-85F7-A8B499B0B458}
{C71FF348-FB47-67E6-AF0D-6A8E48C5EDEA} = {18207368-3C39-4346-85F7-A8B499B0B458}
{98FE468D-0C34-83D9-31BD-F59C44D00357} = {8D1FD3D9-3FF0-4581-ACF0-45AF9D595774}
{A2DDA6F0-C760-0633-D576-E23A186504E4} = {8D1FD3D9-3FF0-4581-ACF0-45AF9D595774}
{A38B5EB3-2F55-44A2-944B-31A73DE91402} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
{C61007F8-51F5-409C-9FAF-DEF6A24DCDED} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
{8D1FD3D9-3FF0-4581-ACF0-45AF9D595774} = {A02F7D8A-04DC-44D6-94D4-3F65712D6B94}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Concurrent;
using System.Reflection;
namespace JiShe.CollectBus.Analyzers.Shared;
public static class SourceEntityAccessorFactory3
{
private static readonly ConcurrentDictionary<Type, object> _accessors = new();
public static ISourceEntityAccessor<T> GetAccessor<T>()
{
return (ISourceEntityAccessor<T>)_accessors.GetOrAdd(typeof(T), t =>
{
// 获取泛型类型定义信息(如果是泛型类型)
var isGeneric = t.IsGenericType;
var genericTypeDef = isGeneric ? t.GetGenericTypeDefinition() : null;
var arity = isGeneric ? genericTypeDef!.GetGenericArguments().Length : 0;
// 构建访问器类名
var typeName = isGeneric
? $"{t.Namespace}.{genericTypeDef!.Name.Split('`')[0]}Accessor`{arity}"
: $"{t.Namespace}.{t.Name}Accessor";
// 尝试从当前程序集加载
var accessorType = Assembly.GetAssembly(t)!.GetType(typeName)
?? throw new InvalidOperationException($"Accessor type {typeName} not found");
// 处理泛型参数
if (isGeneric && accessorType.IsGenericTypeDefinition)
{
accessorType = accessorType.MakeGenericType(t.GetGenericArguments());
}
return Activator.CreateInstance(accessorType)!;
});
}
public static object GetAccessor(Type type)
{
MethodInfo getAccessorMethod = typeof(SourceEntityAccessorFactory)
.GetMethod(
name: nameof(GetAccessor),
bindingAttr: BindingFlags.Public | BindingFlags.Static,
types: Type.EmptyTypes
);
MethodInfo genericMethod = getAccessorMethod.MakeGenericMethod(type);
return genericMethod.Invoke(null, null);
}
}

View File

@ -19,8 +19,10 @@ using System.Threading.Channels;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application;
using Volo.Abp.AuditLogging;
using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Volo.Abp.Modularity;
@ -38,6 +40,9 @@ namespace JiShe.CollectBus;
typeof(CollectBusFreeSqlModule),
typeof(CollectBusKafkaModule),
typeof(CollectBusIoTDbModule),
typeof(CollectBusDomainSharedModule),
typeof(AbpAuditLoggingDomainModule),
typeof(AbpBackgroundJobsDomainModule),
typeof(CollectBusCassandraModule),
typeof(CollectBusProtocolModule)
)]

View File

@ -1169,19 +1169,19 @@ namespace JiShe.CollectBus.ScheduledMeterReading
item.ItemCodes = new List<string>() { T37612012PacketItemCodeConst.AFN0CHFN129H };
}
}
else if (item.MeterTypeName.Trim().Equals("西恩超声波流量计"))
else if (item.MeterTypeName.Equals("流量计") && item.BrandType.Trim().Equals("西恩超声波流量计"))
{
item.ItemCodes = new List<string>() { T37612012PacketItemCodeConst.AFN09HFN01H };
}
else if (item.MeterTypeName.Trim().Equals("江苏华海涡街流量计积算仪"))
else if (item.MeterTypeName.Equals("流量计") && item.BrandType.Trim().Equals("江苏华海涡街流量计积算仪"))
{
item.ItemCodes = new List<string>() { T37612012PacketItemCodeConst.AFN09HFN01H };
}
else if (item.MeterTypeName.Trim().Equals("V880BR涡街流量计"))
else if (item.MeterTypeName.Equals("流量计") && item.BrandType.Trim().Equals("V880BR涡街流量计"))
{
item.ItemCodes = new List<string>() { T37612012PacketItemCodeConst.AFN09HFN01H };
}
else if (item.MeterTypeName.Trim().Equals("拓思特涡街流量计H880BR"))
else if (item.MeterTypeName.Equals("流量计") && item.BrandType.Trim().Equals("拓思特涡街流量计H880BR"))
{
item.ItemCodes = new List<string>() { T37612012PacketItemCodeConst.AFN09HFN01H };
}

View File

@ -600,12 +600,14 @@ namespace JiShe.CollectBus.ScheduledMeterReading
TypeName = 1,
TimeDensity = 60,
BrandType = "云集",
MeterTypeName = "水表",
MeterType = MeterTypeEnum.WaterMeter,
ProjectID = 1,
MeteringPort = MeteringPortConst.MeteringPortTwo,
Password = "000000",
LinkType = "RS-485",
TimesRate = 1.0000m,
Protocol = 30,
});
FreeRedisProvider.Instance.Set(redisCacheDeviceInfoHashKeyTemp, deviceInfos);

View File

@ -10,10 +10,7 @@ using Volo.Abp.Emailing;
namespace JiShe.CollectBus;
[DependsOn(
typeof(CollectBusDomainSharedModule),
typeof(AbpAuditLoggingDomainModule),
typeof(AbpCachingModule),
typeof(AbpBackgroundJobsDomainModule)
typeof(AbpCachingModule)
)]
public class CollectBusDomainModule : AbpModule
{

View File

@ -0,0 +1,16 @@
using JiShe.CollectBus;
namespace JiShe.CollectBusEPO
{
[DependsOn(
typeof(CollectBusDomainSharedModule),
typeof(AbpObjectExtendingModule)
)]
public class CollectBusEPOApplicationContractsModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
CollectBusEPODtoExtensions.Configure();
}
}
}

View File

@ -0,0 +1,25 @@
namespace JiShe.CollectBusEPO
{
public static class CollectBusEPODtoExtensions
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
public static void Configure()
{
OneTimeRunner.Run(() =>
{
/* You can add extension properties to DTOs
* defined in the depended modules.
*
* Example:
*
* ObjectExtensionManager.Instance
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title");
*
* See the documentation for more:
* https://docs.abp.io/en/abp/latest/Object-Extensions
*/
});
}
}
}

View File

@ -0,0 +1,7 @@
namespace JiShe.CollectBusEPO.Files;
public class FileUploadOutputDto
{
public string Name { get; set; }
public string Path { get; set; }
}

View File

@ -0,0 +1,11 @@
// Global using directives
global using System;
global using System.Threading.Tasks;
global using Volo.Abp.Application.Services;
global using Volo.Abp.Authorization.Permissions;
global using Volo.Abp.DependencyInjection;
global using Volo.Abp.Localization;
global using Volo.Abp.Modularity;
global using Volo.Abp.ObjectExtending;
global using Volo.Abp.Threading;

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>JiShe.CollectBusEPO</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="8.3.3" />
<PackageReference Include="Volo.Abp.Authorization" Version="8.3.3" />
<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" />
<ProjectReference Include="..\..\modules\JiShe.CollectBus.Kafka\JiShe.CollectBus.Kafka.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace JiShe.CollectBusEPO.Jobs
{
public interface IRecurringJob : ITransientDependency
{
/// <summary>
/// 执行任务
/// </summary>
/// <returns></returns>
Task ExecuteAsync();
}
}

View File

@ -0,0 +1,17 @@
using JiShe.CollectBus.Localization;
namespace JiShe.CollectBusEPO.Permissions
{
public class CollectBusEPOPermissionDefinitionProvider : PermissionDefinitionProvider
{
public override void Define(IPermissionDefinitionContext context)
{
var myGroup = context.AddGroup(CollectBusEPOPermissions.GroupName, L("Permission:CollectBus"));
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<CollectBusResource>(name);
}
}
}

View File

@ -0,0 +1,15 @@
using Volo.Abp.Reflection;
namespace JiShe.CollectBusEPO.Permissions
{
public static class CollectBusEPOPermissions
{
public const string GroupName = "CollectBusEPO";
public static string[] GetAll()
{
return ReflectionHelper.GetPublicConstantsRecursively(typeof(CollectBusEPOPermissions));
}
}
}

View File

@ -0,0 +1,30 @@
using JiShe.CollectBus;
using JiShe.CollectBus.FreeRedis;
using JiShe.CollectBus.FreeSql;
using JiShe.CollectBus.Localization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Threading;
namespace JiShe.CollectBusEPO
{
/* Inherit your application services from this class.
*/
[Authorize]
[ApiExplorerSettings(GroupName = CollectBusDomainSharedConsts.Business)]
public abstract class CollectBusEPOAppService : ApplicationService
{
public IFreeSqlProvider SqlProvider => LazyServiceProvider.LazyGetRequiredService<IFreeSqlProvider>();
protected IFreeRedisProvider FreeRedisProvider => LazyServiceProvider.LazyGetService<IFreeRedisProvider>()!;
private ICancellationTokenProvider CancellationTokenProvider =>
LazyServiceProvider.LazyGetService<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance);
protected CollectBusEPOAppService()
{
LocalizationResource = typeof(CollectBusResource);
ObjectMapperContext = typeof(CollectBusEPOApplicationModule);
}
}
}

View File

@ -0,0 +1,32 @@
using JiShe.CollectBus;
using JiShe.CollectBus.FreeRedis;
using JiShe.CollectBus.FreeSql;
using JiShe.CollectBus.IoTDB;
using JiShe.CollectBus.Kafka;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AuditLogging;
using Volo.Abp.BackgroundJobs;
namespace JiShe.CollectBusEPO
{
[DependsOn(
typeof(CollectBusDomainModule),
typeof(CollectBusFreeRedisModule),
typeof(CollectBusFreeSqlModule),
typeof(CollectBusKafkaModule),
typeof(CollectBusIoTDbModule)
)]
public class CollectBusEPOApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<CollectBusEPOApplicationModule>(); });
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(CollectBusEPOApplicationModule).Assembly);
});
}
}
}

View File

@ -0,0 +1,21 @@
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus;
using Volo.Abp.MultiTenancy;
namespace JiShe.CollectBusEPO;
public class EntityHandler : ILocalEventHandler<EntityCreatedEventData<FullAuditedAggregateRoot<Guid>>>,
ITransientDependency
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService<ICurrentTenant>();
public Task HandleEventAsync(EntityCreatedEventData<FullAuditedAggregateRoot<Guid>> eventData)
{
// TO DO SOMETHING
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,9 @@
// Global using directives
global using Microsoft.AspNetCore.Authorization;
global using System;
global using System.Threading.Tasks;
global using Volo.Abp.Application.Services;
global using Volo.Abp.AutoMapper;
global using Volo.Abp.DependencyInjection;
global using Volo.Abp.Modularity;

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>JiShe.CollectBusEPO</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="8.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="8.3.3" />
<ProjectReference Include="..\JiShe.CollectBus.Application.Contracts\JiShe.CollectBus.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\JiShe.CollectBus.FreeRedis\JiShe.CollectBus.FreeRedis.csproj" />
<ProjectReference Include="..\..\modules\JiShe.CollectBus.Kafka\JiShe.CollectBus.Kafka.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleToAttribute("JiShe.MicroService.Application.Tests")]

View File

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.10",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@ -0,0 +1,45 @@
namespace JiShe.CollectBusEPO
{
public static class CollectBusEPOHttpApiHostConst
{
/// <summary>
/// 跨域策略名
/// </summary>
public const string DefaultCorsPolicyName = "Default";
/// <summary>
/// Cookies名称
/// </summary>
public const string DefaultCookieName = "JiShe.MicroService.Http.Api";
/// <summary>
/// SwaggerUi 端点
/// </summary>
public const string SwaggerUiEndPoint = "/swagger";
/// <summary>
/// Hangfire 端点
/// </summary>
public const string HangfireDashboardEndPoint = "/hangfire";
/// <summary>
/// CAP 端点
/// </summary>
public const string CapDashboardEndPoint = "/cap";
public const string MoreEndPoint = "https://doc.cncore.club/";
/// <summary>
/// HMiniprofiler端点
/// </summary>
public const string MiniprofilerEndPoint = "/profiler/results-index";
/// <summary>
/// HealthCheck端点
/// </summary>
public const string HealthCheckEndPoint = "/health";
}
}

View File

@ -0,0 +1,179 @@
using JiShe.CollectBusEPO.HttpApi.Host.Swaggers;
namespace JiShe.CollectBusEPO;
public partial class CollectBusEPOHttpApiHostModule
{
/// <summary>
/// 配置JWT
/// </summary>
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 (accessToken.IsNullOrWhiteSpace())
{
accessToken = currentContext.Request.Query["access_token"].FirstOrDefault();
}
if (accessToken.IsNullOrWhiteSpace())
{
accessToken = currentContext.Request.Cookies[@CollectBusEPOHttpApiHostConst.DefaultCookieName];
}
currentContext.Token = accessToken;
currentContext.Request.Headers.Remove("Authorization");
currentContext.Request.Headers.Add("Authorization", $"Bearer {accessToken}");
return Task.CompletedTask;
}
};
});
}
/// <summary>
/// Redis缓存
/// </summary>
private void ConfigureCache(ServiceConfigurationContext context)
{
Configure<AbpDistributedCacheOptions>(
options => { options.KeyPrefix = "MicroService:"; });
var configuration = context.Services.GetConfiguration();
var redis = ConnectionMultiplexer.Connect(configuration.GetValue<string>("Redis:Configuration"));
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "MicroService-Protection-Keys");
}
/// <summary>
/// 配置Identity
/// </summary>
private void ConfigureIdentity(ServiceConfigurationContext context)
{
context.Services.Configure<IdentityOptions>(options => { options.Lockout = new LockoutOptions() { AllowedForNewUsers = false }; });
}
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" && apiDes.GroupName.IsNullOrWhiteSpace()) 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.App.xml") ||
a.EndsWith("Application.Contracts.App.xml") ||
a.EndsWith("Application.xml") ||
a.EndsWith("Application.Contracts.xml") ||
a.EndsWith("HttpApi.xml") ||
a.EndsWith("HttpApi.Host.xml"))
.Distinct()
.ToList();
foreach (var xml in xmlPaths) options.IncludeXmlComments(xml, true);
});
}
/// <summary>
/// 审计日志
/// </summary>
private void ConfigureAuditLog(ServiceConfigurationContext context)
{
Configure<AbpAuditingOptions>
(
options =>
{
options.IsEnabled = true;
options.EntityHistorySelectors.AddAllEntities();
options.ApplicationName = "JiShe.MicroService";
}
);
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("/");
});
}
//private void ConfigurationMultiTenancy()
//{
// Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = MultiTenancyConsts.IsEnabled; });
//}
private void ConfigureCustom(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
//context.Services.AddStorage(configuration);
}
/// <summary>
/// 配置Serilog
/// </summary>
private void ConfigureSerilog(ServiceConfigurationContext context)
{
context.Services.AddSerilog();
}
}

View File

@ -0,0 +1,73 @@
using JiShe.CollectBusEPO.Extensions.HealthCheck;
using JiShe.CollectBusEPO.HttpApi.Host.Swaggers;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Volo.Abp.Swashbuckle;
namespace JiShe.CollectBusEPO;
[DependsOn(
typeof(CollectBusEPOHttpApiModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule),
typeof(CollectBusEPOApplicationModule)
)]
public partial class CollectBusEPOHttpApiHostModule : AbpModule
{
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
base.OnPostApplicationInitialization(context);
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
ConfigureSerilog(context);
ConfigureCache(context);
ConfigureSwaggerServices(context, configuration);
ConfigureJwtAuthentication(context, configuration);
ConfigureIdentity(context);
ConfigureAuditLog(context);
ConfigureCustom(context, configuration);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var configuration = context.GetConfiguration();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors(CollectBusEPOHttpApiHostConst.DefaultCorsPolicyName);
app.UseAuthorization();
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.UseConfiguredEndpoints(endpoints =>
{
//endpoints.MapHealthChecks("/health", new HealthCheckOptions
//{
// Predicate = _ => true,
// ResponseWriter = HealthCheckResponse.Writer
//});
});
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Authorization;
namespace JiShe.CollectBusEPO.Controllers
{
public class HomeController : AbpController
{
private readonly ILogger<HomeController> _logger;
private readonly IConfiguration configuration;
public HomeController(ILogger<HomeController> logger, IConfiguration configuration)
{
_logger = logger;
this.configuration = configuration;
}
public ActionResult Index()
{
return Redirect("/Monitor");
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Health()
{
return Ok();
}
}
}

View File

@ -0,0 +1,47 @@
FROM docker.jisheyun.com/jisheyun/aspnetcore:8.0.10_basic_ub24 AS base
# 这里确定使用的端口
EXPOSE 8080
EXPOSE 443
COPY publish /app
WORKDIR /app
ARG BUD_ENV=Development
# 这里确定生产环境还是DEV环境等
ENV RUN_ENV=$BUD_ENV
# 根据 RUN_ENV 的值删除特定的配置文件
# 只在构建过程中执行的指令
RUN if [ "$RUN_ENV" = "Development" ]; then \
rm -f ./appsettings.Production.json; \
fi
RUN if [ "$RUN_ENV" = "Production" ]; then \
rm -f ./appsettings.Development.json; \
fi
ENTRYPOINT ["dotnet", "JiShe.MicroService.HttpApi.Host.dll"]
##See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#
#FROM mcr.microsoft.com/dotnet/aspnet:8.0.10-noble AS base
#
#WORKDIR /app
#
##USER root
#
## apt-get源 使用aliyun的源
#COPY ["sources.list", "/etc/apt/"]
#
## 转换时区
#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
#&& echo 'Asia/Shanghai' >/etc/timezone \
## 更新系统并安装网络调试工具
#&& apt-get update \
#&& apt-get install -y \
#vim \
#net-tools \
#iputils-ping

View File

@ -0,0 +1,26 @@
# 版本号
$version = "1.0.2"
$csprojFile = '..\.\*.csproj'
$files = Get-ChildItem -Path $csprojFile
$fullPath = $files[0]
$name = $fullPath.BaseName
Write-Host "准备登录到镜像仓库服务器"
docker login 192.168.111.248:10001 --username=jenkins --password GTCz3pV8kdme4rh5
$lowerName = $name.toLower()
$tagName = "$($lowerName):$($version)"
Write-Host "开始打包镜像"
Write-Host $tagName
docker build --build-arg BUD_ENV=Development --progress=plain -t $tagName .
Write-Host "镜像打包成功";
docker tag $tagName "192.168.111.248:10001/jisheyun/jishe.testservice:$($version)"
Write-Host "开始推送镜像服务";
#docker push "192.168.111.248:10001/jisheyun/jishe.testservice:$($version)"

View File

@ -0,0 +1,26 @@
# 版本号
$version = "1.0.2"
$csprojFile = '..\.\*.csproj'
$files = Get-ChildItem -Path $csprojFile
$fullPath = $files[0]
$name = $fullPath.BaseName
Write-Host "准备登录到镜像仓库服务器"
docker login 192.168.111.248:10001 --username=jenkins --password GTCz3pV8kdme4rh5
$lowerName = $name.toLower()
$tagName = "$($lowerName):$($version)"
Write-Host "开始打包镜像"
Write-Host $tagName
docker build --build-arg BUD_ENV=Production --progress=plain -t $tagName .
Write-Host "镜像打包成功";
docker tag $tagName "192.168.111.248:10001/jisheyun/jishe.testservice:$($version)"
Write-Host "开始推送镜像服务";
#docker push "192.168.111.248:10001/jisheyun/jishe.testservice:$($version)"

View File

@ -0,0 +1,10 @@
deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

View File

@ -0,0 +1,88 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace JiShe.CollectBusEPO.Extensions.HealthCheck
{
public static class Extensions
{
/// <summary>
/// 添加监控检查,支持配置文件配置
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
/// <returns></returns>
public static IServiceCollection AddHealthChecks(
this IServiceCollection services, IConfiguration configuration)
{
if (Convert.ToBoolean(configuration["HealthCheck:IsEnable"]))
{
var healthChecksService = services
.AddHealthChecks();
//添加对mysql的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:MySql:IsEnable"]))
//{
// var connectionString = configuration["HealthCheck:MySql:Connection"];
// if (connectionString.IsNullOrWhiteSpace())
// connectionString = configuration.GetConnectionString("Default");
// healthChecksService.AddMySql(
// connectionString,
// "Mysql",
// HealthStatus.Degraded,
// new string[] { "db", "sql", "mysql" }
// );
//}
//添加对Pings的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:Pings:IsEnable"]))
// healthChecksService.AddPingHealthCheck(setup =>
// {
// setup.AddHost(configuration["HealthCheck:Pings:Host"], Convert.ToInt32(configuration["HealthCheck:Pings:TimeOut"]));
// }, tags: new string[] { "ping" });
////添加对postgresql的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:PostgreSql:IsEnable"]))
// healthChecksService.AddNpgSql(
// configuration["ConnectionStrings:Default"],
// name: configuration["HealthCheck:PostgreSql:Name"],
// failureStatus: HealthStatus.Degraded,
// tags: new string[] { "db", "sql", "postgresql" }
// );
////添加对Redis的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:Redis:IsEnable"]))
// healthChecksService.AddRedis(
// configuration["HealthCheck:Redis:ConnectionString"],
// tags: new string[] { "redis" }
// );
////添加对RabbitMq的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:RabbitMq:IsEnable"]))
// healthChecksService.AddRabbitMQ(
// rabbitConnectionString: configuration["HealthCheck:RabbitMq:ConnectionString"],
// tags: new string[] { "redis" }
// );
////添加对sql server的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:SqlServer:IsEnable"]))
// healthChecksService.AddSqlServer(
// configuration["ConnectionStrings:Default"],
// "SELECT 1;",
// configuration["HealthCheck:SqlServer:Name"],
// HealthStatus.Degraded,
// new string[] { "db", "sql", "sqlserver" }
////添加对Hangfire的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:Hangfire:IsEnable"]))
// healthChecksService.AddHangfire(options =>
// {
// options.MaximumJobsFailed = Convert.ToInt32(configuration["HealthCheck:Hangfire:MaximumJobsFailed"]);
// options.MinimumAvailableServers = Convert.ToInt32(configuration["HealthCheck:Hangfire:MinimumAvailableServers"]);
// }, tags: new string[] { "hangfire" });
////添加对SignalR的监控检查
//if (Convert.ToBoolean(configuration["HealthCheck:SignalR:IsEnable"]))
// healthChecksService.AddSignalRHub(configuration["HealthCheck:SignalR:Url"], tags: new string[] { "signalr" });
}
return services;
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Newtonsoft.Json;
namespace JiShe.CollectBusEPO.Extensions.HealthCheck
{
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);
}
}
}

View File

@ -0,0 +1,32 @@
// Global using directives
global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.DataProtection;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Identity;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using Microsoft.IdentityModel.Tokens;
global using Microsoft.OpenApi.Models;
global using Serilog;
global using StackExchange.Redis;
global using Swashbuckle.AspNetCore.SwaggerUI;
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using Volo.Abp;
global using Volo.Abp.AspNetCore.Auditing;
global using Volo.Abp.AspNetCore.Authentication.JwtBearer;
global using Volo.Abp.AspNetCore.Mvc;
global using Volo.Abp.AspNetCore.Serilog;
global using Volo.Abp.Auditing;
global using Volo.Abp.Caching;
global using Volo.Abp.Modularity;

View File

@ -0,0 +1,62 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>JiShe.CollectBusEPO</RootNamespace>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<UserSecretsId>JiShe.MicroService-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<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.Swashbuckle" Version="8.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\services\JiShe.CollectBusEPO.Application\JiShe.CollectBusEPO.Application.csproj" />
<ProjectReference Include="..\JiShe.CollectBusEPO.HttpApi\JiShe.CollectBusEPO.HttpApi.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Docker\publish\**" />
<Compile Remove="Logs\**" />
<Compile Remove="nacos\**" />
<Content Remove="Docker\publish\**" />
<Content Remove="Logs\**" />
<Content Remove="nacos\**" />
<EmbeddedResource Remove="Docker\publish\**" />
<EmbeddedResource Remove="Logs\**" />
<EmbeddedResource Remove="nacos\**" />
<None Remove="Docker\publish\**" />
<None Remove="Logs\**" />
<None Remove="nacos\**" />
</ItemGroup>
<ItemGroup>
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\files\a.txt" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\TemporaryFiles\.gitkeep" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,193 @@
@page "/Monitor"
@using JiShe.CollectBusEPO
@model JiShe.CollectBusEPO.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="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet" />
<title>后端服务</title>
</head>
<body>
<div class="container projects">
<div class="projects-header page-header">
<h2>后端服务列表</h2>
</div>
<div class="row">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="thumbnail" style="height: 180px">
<a href="@@CollectBusEPOHttpApiHostConst.SwaggerUiEndPoint" target="_blank">
<img class="lazy" src="/images/swagger.png" width="300" height="150" />
</a>
<div class="caption">
<h3>
<a href="@@CollectBusEPOHttpApiHostConst.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="@@CollectBusEPOHttpApiHostConst.CapDashboardEndPoint" target="_blank">
<img class="lazy" src="/images/cap.png" width="300" height="150" />
</a>
<div class="caption">
<h3>
<a href="@@CollectBusEPOHttpApiHostConst.CapDashboardEndPoint" target="_blank">CAP面板</a>
</h3>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="thumbnail" style="height: 180px">
<a href="@@CollectBusEPOHttpApiHostConst.HangfireDashboardEndPoint" target="_blank">
<img class="lazy" src="/images/hangfire.png" width="300" height="150" />
</a>
<div class="caption">
<h3>
<a href="@@CollectBusEPOHttpApiHostConst.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="@@CollectBusEPOHttpApiHostConst.MiniprofilerEndPoint" target="_blank">
<img class="lazy" src="/images/miniprofiler.png" width="300" height="150" />
</a>
<div class="caption">
<h3>
<a href="@@CollectBusEPOHttpApiHostConst.MiniprofilerEndPoint" target="_blank">Miniprofiler</a>
</h3>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="thumbnail" style="height: 180px">
<a href="@@CollectBusEPOHttpApiHostConst.HealthCheckEndPoint" target="_blank">
<img class="lazy" src="/images/healthchecks.png" width="300" height="150" />
</a>
<div class="caption">
<h3>
<a href="@@CollectBusEPOHttpApiHostConst.HealthCheckEndPoint" target="_blank">HealthCheck</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: px 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;
}
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;
}
.caption {
padding: 9px;
overflow-y: hidden;
color: #555;
}
</style>

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace JiShe.CollectBusEPO.Pages
{
public class Monitor : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,39 @@
namespace JiShe.CollectBusEPO
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
private static IHostBuilder CreateHostBuilder(string[] args)
{
var env = Environment.GetEnvironmentVariable("RUN_ENV") ?? "Development";
return Host.CreateDefaultBuilder(args)
.UseEnvironment(env)
.ConfigureAppConfiguration((context, builder) =>
{
var c = builder.Build();
builder.AddJsonFile($"appsettings.json", false, true);
builder.AddJsonFile($"appsettings.{env}.json", false, true);
//builder.AddNacosV2Configuration(c.GetSection("NacosConfig"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
var runPort = Environment.GetEnvironmentVariable("RUN_PORT") ?? "8088";
webBuilder.ConfigureKestrel((context, options) => { options.Limits.MaxRequestBodySize = 1024 * 50; });
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls($"http://*:{runPort}");
})
.UseSerilog((context, loggerConfiguration) =>
{
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
}).UseAutofac();
}
}
}

View File

@ -0,0 +1,13 @@
{
"profiles": {
"JiShe.MicroService.HttpApi.Host": {
"commandName": "Project",
"commandLineArgs": "serviceip=192.168.111.174 serviceport=8088",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:8088"
}
}
}

View File

@ -0,0 +1,23 @@
namespace JiShe.CollectBusEPO
{
public class Startup
{
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<CollectBusEPOHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app,IHostApplicationLifetime lifetime)
{
app.InitializeApplication();
}
}
}

View File

@ -0,0 +1,24 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace JiShe.CollectBusEPO.HttpApi.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);
}
}
}

View File

@ -0,0 +1,54 @@
using System.Reflection;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace JiShe.CollectBusEPO.HttpApi.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"
};
}
}
}

View File

@ -0,0 +1,11 @@
namespace JiShe.CollectBusEPO.HttpApi.Host.Swaggers
{
public class SwaggerConfig
{
public string GroupName { get; set; }
public string Title { get; set; }
public string Version { get; set; }
}
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,104 @@
{
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.File"
],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"Volo.Abp": "Information",
"Hangfire": "Information",
"DotNetCore.CAP": "Information",
"Serilog.AspNetCore": "Information",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.AspNetCore": "Information"
}
},
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": "logs/logs-.txt",
"rollingInterval": "Day"
}
}
]
},
"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"
},
"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": [ "121.42.175.177:16667" ],
"PoolSize": 32,
"DataBaseName": "energy",
"OpenDebugMode": true,
"UseTableSessionPoolByDefault": false
},
"App": {
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "http://localhost:4200,http://localhost:3100"
},
"Jwt": {
"Audience": "JiShe.CollectBus",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
"Issuer": "JiShe.CollectBus",
"ExpirationTime": 2
},
"HealthChecks": {
"IsEnable": false,
"HealthCheckDatabaseName": "HealthChecks",
"EvaluationTimeInSeconds": 10,
"MinimumSecondsBetweenFailureNotifications": 60
},
"SwaggerConfig": [
{
"GroupName": "Basic",
"Title": "【后台管理】基础模块",
"Version": "V1"
},
{
"GroupName": "Business",
"Title": "【后台管理】业务模块",
"Version": "V1"
}
],
"ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus99",
"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"
}
}

View File

@ -0,0 +1 @@
{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"eH-Ld45J684VguyI2jACQEEVGtTx79Nt7ElT20JeUi-pbVnhJxxAJwnAe68d9Q8skpv6BxZs5QuyIORwfGpJK-lKVuo8EtyUQTuUuPmP4o1YK4cv2FIi5xN18tddTltg2JmJi1sN2AD5z-zwm45YNvoFxdQYlnUlA9lJL8QfG0HQLMQX1sv2_lgND8RfRGQBCpVXC2kcap4GvkFVQpKaQ5xaUqvNdH6ftwkGMdFfMRlHGhyYyabIjs4T16HslofvXiHbOCAzk37HtBNNsBpeoQuZul1-G7tAndHe1XtuGvuE-k1fyqdm3YiCU8wK7FpvQU3x6JqvfqmWgMAPnWKOtQ","DP":"hd3I9Nc3LlaZDoPg20JZu48kpv9rMMQ0rLtcZ0UPB_HpZWBC_No-3t3t1HFRbD4iz0MCpCR6gb5q4UsL2N2xh3Q8OhQ1Zrl76UKDZrVKs3oE0VVr9K2VUU3s1sytE4OWSv7PAHYURygcx_MrunMn8Ryd4ZJBQ_g5M2GvpBj1o5M","DQ":"T3ibciK4KxGGHqau9dnWxE6l3fGtcNw1GcjV93Lxe0NKTbfrwPEIFVVAyPsFS8QdmRXEgyunkDFKLHyq2hXBi2fZCwXGoWkUqVUKAKMaNYZaDDd_XeJKOu7mwNY8rgxNETHCyMSnnNNPNabBf2iiXmrBnMwesle2L1kwky42yns","E":"AQAB","K":null,"KeyId":"0D94529E740F5FD50EC6B8A19FF460D6","Kid":"0D94529E740F5FD50EC6B8A19FF460D6","Kty":"RSA","N":"w2jhtWb6a3kH4VqAPfuuvdF5hBh7U6gwMRnddHAH7zaVL6aYwjpCzNW56RQy4W4Zabv1My4Yw9GZpjrOcyr3Bm669eZjn_JC0O00eRTNStNgmg2kB_6AB6ROkEW7br1JC0jKr_dXhOYPBMmR-KHvpwaZXA9R1xOqY02S3JD0KB-TGMSC9q1RlVydt81aMOHFzWVyruLsYGdmcKhRPKDtL6GXpU_DG1gzzOYbk795x_D_UUTOJYuhIDEj7aYi3o32yXLEBvh4Q7HPLjLcWzV-EzCn6Ossl-EVJ2TrR53Eln03R93Vmo63DzQbLIOi3yTcZD2a3O6mpGLiqyZjUducIQ","Oth":null,"P":"y84cEtE6IRBeU2sDJxjDYb50HB4nAF7-bfvbEq0haQL2sFBz-Q-uOUAeXhaS74Gh_IagmW1TzOKblVilijMHCsfOFTWlCljaDoNfdl31enh50HMFvUu8IFjcWiQ9fjR5no8n5-jDeRO5zVfgcWoRHfVTOq4Di7WlVHJRr8FB-R8","Q":"9XRZvvMIvoumlDAVxWZHkb7_an0_dFwBLqc8v74XBZhiK5SLuBqmsJICB5kwNTKzORH7yedx-RXOJWkchJLlEtmH_cQO_6WKQQAyc1PMnLPa0tYkhjotWo8VRE9bAdVmrR0cnJeudfSJ-6gDpUBQYy9g1m8cAfWbTAk3at2_gr8","QI":"xRLXLwhTdNbevlEzANlDDnU9lDeKZWV9-YrvUxHMJBBygBNVqkNFWiee7LNUi82YgTHRn46rpHY9TZf6oQbgk6xa86MyDYXGU2uGO8DHm5oh20Spp7A-RlzZ4JRXAJ3eAYMZHQIP45JApVvKbgHh_pUGjNaiqZKZ9IN6H_L9k1s","Use":null,"X":null,"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true}}

View File

@ -0,0 +1 @@
{"KeyId":"600caa200caf5d805eba9f06ace9e236","Parameters":{"D":"KCNDHA96eimN+UqchSKocgYITGflaAIwxzCS5KqSTkYAFliPthQx7LySuLor4F1+uLvwnh3ZocyI3y43GZu+eVHD256sxdV8/UsQz1HC23RRFqcUiAZjze8K5VMVStrBOxaa/Ds1U9/bpuNE7jZdcgFIEHsdZtCACqwtlE4nlIs1/GLiokqjBOESgxJMy9WUeDbWcvoo+YdwgKf5jt6AZHOYSS+TokLL+Y7TEfGMXe3jZD9VtSMkBSM8wGB89zNGR0FZB9maCG/BCoRJqxdYRyeb4FFXJclQtK3DexyDVqlNZQaNKVHu0tVAnVNKKcd7Iex8gA+5DNqqucUA7C/F6Q==","DP":"fr9iaNb1W4YZ/NJ56+N3SCeDQYuKobq1qeaQWmHlQsOHKoHhNZJQZ5x0M9PQilou16AwVlNGCJncMwxsSUxXn6itG0LcBnvfMeo2v3xKcij1BtFR9qfXecwEn2nnhI3mpXtZxyCdP3NIYUp9qViLJUjGJqrbQk+OIAGRQd2rRe0=","DQ":"o1umLkDodtwvpCsDguQYSjd3iob+WHNmfe/9HyjADmUehP8b9SpUgcrb+QF301J8YmQMnYZKWW5rEwKOtwsWNswgXfMnXeWerlZmz0tj9y38YczS70liU0vETsRefhrRCaXHraMvneqYNNedhsrCNalWK+DNwcixi4L59vA8ofs=","Exponent":"AQAB","InverseQ":"btd1nwwxl/E3ryfDi2bN12TuVDvv7yoPvryIlLgu+FiLpe4vaA1omDLliQBcl7oeyA563HBUop4D5oE7si+jD64N8XgFz37dD3KqUokeQ4lrTSSOePT1K+nWIl30sqDd7YE4auz4CvSjm2wXmN31+CXW1hp3YWN2972yrUt+R5U=","Modulus":"uwMB6reAVtm/Cq0BRPZ0ozBq6g3wDh2kzqFKBf8I7u8d9p7i5ExLSrOWPupHwPr/IW1VUn2TKHrJ8OnyYhznKIRxqlxj0U3D2GXijz5kfFOoHK+mlfKaDMqweRoS0UzEz58kMlgwUoDraUj6dTHTPCVPo3TqA2ImRw50j6D+jobFrY5321EFvlirZViMPDAgB8Ca7wGCqNBcCxvIPYw1O6WZmcVmjG7umelD3XjcUIQlEbIyAmi/3gXAo7NdPmgOamla6bnSWsy429HfsNpXyCfPBzV3QS3ubpTekWPoPcOVZbWwVPYtFQbhRh8PmWATRx0cV6oePZNZGxGeJl8WYQ==","P":"wplelBfVmiOPmr6iUxtOgIzuvwSqvP6Rqmh8dhaGDiJjU8OqZ0tZhuh0G+xnMLPIHb2fMeg0dqZMJZ5iXaIi1QycYn/JKz1i4cUonJ6IIQeKKf67tvzn/BY0V0N8rJw8hVfzou+/5sRBCbiHtJ2KIN1YJQuWGFFfrZJOJzc95ss=","Q":"9gTGKoDiOdrY8kqIXJ2nMhoeNryAH4q3EUrROJ7simqc28oYlGx24Sco/wOoeB2xxrdcF5JYOlyJ7H2YY/huLvJISaw/wHLPskiKiYQ78tuNwW0ip+5ceB1dSToHcEe3sR30+OeTh0Z4ZKoqthKziFGIt3EhEgiGq1gjZuWB5gM="}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,39 @@

using JiShe.CollectBus;
using JiShe.CollectBus.Localization;
using Microsoft.Extensions.DependencyInjection;
namespace JiShe.CollectBusEPO
{
[DependsOn(
typeof(CollectBusEPOApplicationContractsModule),
typeof(CollectBusEPOApplicationModule),
typeof(AbpAspNetCoreMvcModule)
)]
public class CollectBusEPOHttpApiModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(CollectBusEPOHttpApiModule).Assembly);
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers
.Create(typeof(CollectBusEPOHttpApiModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<CollectBusResource>()
.AddBaseTypes(typeof(AbpUiResource));
});
}
}
}

View File

@ -0,0 +1,14 @@
using JiShe.CollectBus.Localization;
namespace JiShe.CollectBusEPO.Controllers
{
/* Inherit your controllers from this class.
*/
public abstract class CollectBusEPOController : AbpController
{
protected CollectBusEPOController()
{
LocalizationResource = typeof(CollectBusResource);
}
}
}

View File

@ -0,0 +1,6 @@
// Global using directives
global using Localization.Resources.AbpUi;
global using Volo.Abp.AspNetCore.Mvc;
global using Volo.Abp.Localization;
global using Volo.Abp.Modularity;

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>JiShe.CollectBusEPO</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="8.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\services\JiShe.CollectBusEPO.Application.Contracts\JiShe.CollectBusEPO.Application.Contracts.csproj" />
<ProjectReference Include="..\..\services\JiShe.CollectBusEPO.Application\JiShe.CollectBusEPO.Application.csproj" />
</ItemGroup>
</Project>