本地密钥共享存储

This commit is contained in:
ChenYi 2025-06-09 11:21:35 +08:00
parent e9967b60fa
commit 5b7ee5d1b5
8 changed files with 50 additions and 23 deletions

View File

@ -2,7 +2,7 @@
<!-- 定义项目加载属性 --> <!-- 定义项目加载属性 -->
<PropertyGroup> <PropertyGroup>
<!--JiShe.ServicePro版本--> <!--JiShe.ServicePro版本-->
<ServiceProVersion>1.0.5.13</ServiceProVersion> <ServiceProVersion>1.0.5.16</ServiceProVersion>
<!--Volo Abp 版本--> <!--Volo Abp 版本-->
<VoloAbpVersion>9.1.1</VoloAbpVersion> <VoloAbpVersion>9.1.1</VoloAbpVersion>

View File

@ -11,6 +11,7 @@ using JiShe.CollectBus.Protocol.Models;
using JiShe.ServicePro.Core; using JiShe.ServicePro.Core;
using JiShe.ServicePro.Encrypt; using JiShe.ServicePro.Encrypt;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Diagnostics; using System.Diagnostics;
@ -21,6 +22,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
/// <summary> /// <summary>
/// 定时采集服务 /// 定时采集服务
/// </summary> /// </summary>
[AllowAnonymous]
public abstract class BasicScheduledMeterReadingService : CollectBusAppService, IScheduledMeterReadingService public abstract class BasicScheduledMeterReadingService : CollectBusAppService, IScheduledMeterReadingService
{ {
private readonly ILogger<BasicScheduledMeterReadingService> _logger; private readonly ILogger<BasicScheduledMeterReadingService> _logger;
@ -249,21 +251,21 @@ namespace JiShe.CollectBus.ScheduledMeterReading
else if (meteryType == MeterTypeEnum.WaterMeter.ToString()) else if (meteryType == MeterTypeEnum.WaterMeter.ToString())
{ {
_ = CreateMeterPublishTask<DeviceCacheInfo>( //_ = CreateMeterPublishTask<DeviceCacheInfo>(
timeDensity: timeDensity, // timeDensity: timeDensity,
nextTaskTime: currentTaskTime, // nextTaskTime: currentTaskTime,
meterType: MeterTypeEnum.WaterMeter, // meterType: MeterTypeEnum.WaterMeter,
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
{ // {
var tempTask = await WatermeterCreatePublishTaskAction(timeDensity, data, groupIndex, timestamps); // var tempTask = await WatermeterCreatePublishTaskAction(timeDensity, data, groupIndex, timestamps);
if (tempTask == null || tempTask.Count <= 0) // if (tempTask == null || tempTask.Count <= 0)
{ // {
_logger.LogWarning($"水表 {data.Name} 任务数据构建失败:{data.Serialize()}"); // _logger.LogWarning($"水表 {data.Name} 任务数据构建失败:{data.Serialize()}");
return; // return;
} // }
_ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (KafkaTopicConsts.WatermeterSubscriberWorkerAutoReadingIssuedEventName, tempTask)); // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (KafkaTopicConsts.WatermeterSubscriberWorkerAutoReadingIssuedEventName, tempTask));
}); // });
} }
else else
{ {

View File

@ -6,7 +6,8 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RootNamespace>JiShe.CollectBus</RootNamespace> <RootNamespace>JiShe.CollectBus</RootNamespace>
</PropertyGroup> <GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="PrepaymentSystems\**" /> <Compile Remove="PrepaymentSystems\**" />

View File

@ -19,6 +19,8 @@ using TouchSocket.Sockets;
using JiShe.CollectBus.Plugins; using JiShe.CollectBus.Plugins;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Diagnostics.HealthChecks;
using JiShe.CollectBus.Protocol3761;
using Microsoft.AspNetCore.Mvc;
namespace JiShe.CollectBus.Host namespace JiShe.CollectBus.Host
@ -113,6 +115,14 @@ namespace JiShe.CollectBus.Host
new OpenApiInfo { Title = group.Title, Version = group.Version }); new OpenApiInfo { Title = group.Title, Version = group.Version });
}); });
options.AddSecurityDefinition("XSRF-TOKEN", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.ApiKey,
In = ParameterLocation.Header,
Name = "X-XSRF-TOKEN",
Description = "CSRF token"
});
options.DocInclusionPredicate((docName, apiDes) => options.DocInclusionPredicate((docName, apiDes) =>
{ {
if (docName == "Basic" && string.IsNullOrWhiteSpace(apiDes.GroupName)) return true; if (docName == "Basic" && string.IsNullOrWhiteSpace(apiDes.GroupName)) return true;
@ -125,6 +135,8 @@ namespace JiShe.CollectBus.Host
var xmlPaths = Directory.GetFiles(AppContext.BaseDirectory, "*.xml") var xmlPaths = Directory.GetFiles(AppContext.BaseDirectory, "*.xml")
.Where(a => a.EndsWith("Application.xml") || .Where(a => a.EndsWith("Application.xml") ||
a.EndsWith("Application.Contracts.xml") || a.EndsWith("Application.Contracts.xml") ||
a.EndsWith("Domain.xml") ||
a.EndsWith("Domain.Shared.xml") ||
a.EndsWith("httpApi.xml") || a.EndsWith("httpApi.xml") ||
a.EndsWith("Host.xml")) a.EndsWith("Host.xml"))
.Distinct() .Distinct()
@ -133,6 +145,7 @@ namespace JiShe.CollectBus.Host
}); });
} }
/// <summary> /// <summary>
/// Configures the audit log. /// Configures the audit log.
/// </summary> /// </summary>

View File

@ -1,8 +1,11 @@
using JiShe.CollectBus.Common; using JiShe.CollectBus.Common;
using JiShe.CollectBus.Host.HealthChecks; using JiShe.CollectBus.Host.HealthChecks;
using JiShe.CollectBus.Host.Swaggers; using JiShe.CollectBus.Host.Swaggers;
using JiShe.ServicePro.FreeRedisProvider;
using JiShe.ServicePro.ServerOptions; using JiShe.ServicePro.ServerOptions;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting.Internal;
using Swashbuckle.AspNetCore.SwaggerUI; using Swashbuckle.AspNetCore.SwaggerUI;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Authentication.JwtBearer;
@ -50,6 +53,10 @@ namespace JiShe.CollectBus.Host
configuration.GetSection(nameof(ServerApplicationOptions)).Bind(options); configuration.GetSection(nameof(ServerApplicationOptions)).Bind(options);
}); });
context.Services
.AddDataProtection()
.PersistKeysToStackFreeRedis("JiSheCollectBus-Protection-Keys");
} }
@ -68,8 +75,8 @@ namespace JiShe.CollectBus.Host
app.UseCors(CollectBusHostConst.DefaultCorsPolicyName); app.UseCors(CollectBusHostConst.DefaultCorsPolicyName);
app.UseAuthentication(); app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
//if (env.IsDevelopment()) if (env.IsDevelopment())
//{ {
app.UseSwagger(); app.UseSwagger();
app.UseAbpSwaggerUI(options => app.UseAbpSwaggerUI(options =>
{ {
@ -80,7 +87,7 @@ namespace JiShe.CollectBus.Host
options.DocExpansion(DocExpansion.None); options.DocExpansion(DocExpansion.None);
options.DefaultModelsExpandDepth(-1); options.DefaultModelsExpandDepth(-1);
}); });
//} }
app.UseAuditing(); app.UseAuditing();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseUnitOfWork(); app.UseUnitOfWork();

View File

@ -36,7 +36,7 @@
"ServerApplicationOptions": { "ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus77", "ServerTagName": "JiSheCollectBus77",
"SystemType": "Energy", "SystemType": "Energy",
"FirstCollectionTime": "2025-04-28 15:07:00", "FirstCollectionTime": "2025-06-06 15:07:00",
"AutomaticVerificationTime": "16:07:00", "AutomaticVerificationTime": "16:07:00",
"AutomaticTerminalVersionTime": "17:07:00", "AutomaticTerminalVersionTime": "17:07:00",
"AutomaticTelematicsModuleTime": "17:30:00", "AutomaticTelematicsModuleTime": "17:30:00",

View File

@ -6,7 +6,7 @@
}, },
"FreeRedisOptions": { "FreeRedisOptions": {
"ConnectionString": "47.110.53.196:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14", "ConnectionString": "47.110.53.196:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14",
"UseDistributedCache": true "UseDistributedCache": false
}, },
"FreeSqlProviderOptions": { "FreeSqlProviderOptions": {
"UsePrepayDB": true, "UsePrepayDB": true,
@ -95,7 +95,7 @@
"ServerApplicationOptions": { "ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus77", "ServerTagName": "JiSheCollectBus77",
"SystemType": "Energy", "SystemType": "Energy",
"FirstCollectionTime": "2025-04-28 15:07:00", "FirstCollectionTime": "2025-06-06 15:07:00",
"AutomaticVerificationTime": "16:07:00", "AutomaticVerificationTime": "16:07:00",
"AutomaticTerminalVersionTime": "17:07:00", "AutomaticTerminalVersionTime": "17:07:00",
"AutomaticTelematicsModuleTime": "17:30:00", "AutomaticTelematicsModuleTime": "17:30:00",

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\..\services\JiShe.CollectBus.Application\JiShe.CollectBus.Application.csproj" /> <ProjectReference Include="..\..\services\JiShe.CollectBus.Application\JiShe.CollectBus.Application.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="JiShe.ServicePro.IoTDBManagement.HttpApi" />
</ItemGroup>
</Project> </Project>