本地密钥共享存储

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>
<!--JiShe.ServicePro版本-->
<ServiceProVersion>1.0.5.13</ServiceProVersion>
<ServiceProVersion>1.0.5.16</ServiceProVersion>
<!--Volo Abp 版本-->
<VoloAbpVersion>9.1.1</VoloAbpVersion>

View File

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

View File

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

View File

@ -19,6 +19,8 @@ using TouchSocket.Sockets;
using JiShe.CollectBus.Plugins;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using JiShe.CollectBus.Protocol3761;
using Microsoft.AspNetCore.Mvc;
namespace JiShe.CollectBus.Host
@ -96,7 +98,7 @@ namespace JiShe.CollectBus.Host
};
});
}
/// <summary>
/// Configures the swagger services.
/// </summary>
@ -113,6 +115,14 @@ namespace JiShe.CollectBus.Host
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) =>
{
if (docName == "Basic" && string.IsNullOrWhiteSpace(apiDes.GroupName)) return true;
@ -125,6 +135,8 @@ namespace JiShe.CollectBus.Host
var xmlPaths = Directory.GetFiles(AppContext.BaseDirectory, "*.xml")
.Where(a => a.EndsWith("Application.xml") ||
a.EndsWith("Application.Contracts.xml") ||
a.EndsWith("Domain.xml") ||
a.EndsWith("Domain.Shared.xml") ||
a.EndsWith("httpApi.xml") ||
a.EndsWith("Host.xml"))
.Distinct()
@ -133,6 +145,7 @@ namespace JiShe.CollectBus.Host
});
}
/// <summary>
/// Configures the audit log.
/// </summary>

View File

@ -1,8 +1,11 @@
using JiShe.CollectBus.Common;
using JiShe.CollectBus.Host.HealthChecks;
using JiShe.CollectBus.Host.Swaggers;
using JiShe.ServicePro.FreeRedisProvider;
using JiShe.ServicePro.ServerOptions;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting.Internal;
using Swashbuckle.AspNetCore.SwaggerUI;
using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
@ -50,6 +53,10 @@ namespace JiShe.CollectBus.Host
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.UseAuthentication();
app.UseAuthorization();
//if (env.IsDevelopment())
//{
if (env.IsDevelopment())
{
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
@ -80,7 +87,7 @@ namespace JiShe.CollectBus.Host
options.DocExpansion(DocExpansion.None);
options.DefaultModelsExpandDepth(-1);
});
//}
}
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();

View File

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

View File

@ -6,7 +6,7 @@
},
"FreeRedisOptions": {
"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": {
"UsePrepayDB": true,
@ -95,7 +95,7 @@
"ServerApplicationOptions": {
"ServerTagName": "JiSheCollectBus77",
"SystemType": "Energy",
"FirstCollectionTime": "2025-04-28 15:07:00",
"FirstCollectionTime": "2025-06-06 15:07:00",
"AutomaticVerificationTime": "16:07:00",
"AutomaticTerminalVersionTime": "17:07:00",
"AutomaticTelematicsModuleTime": "17:30:00",

View File

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