From 5b7ee5d1b561ad052c2f8bb2ee3083fc1e60e746 Mon Sep 17 00:00:00 2001
From: ChenYi <296215406@outlook.com>
Date: Mon, 9 Jun 2025 11:21:35 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AF=86=E9=92=A5=E5=85=B1?=
=?UTF-8?q?=E4=BA=AB=E5=AD=98=E5=82=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Directory.Build.props | 2 +-
.../BasicScheduledMeterReadingService.cs | 30 ++++++++++---------
.../JiShe.CollectBus.Domain.csproj | 3 +-
.../CollectBusHostModule.Configure.cs | 15 +++++++++-
.../CollectBusHostModule.cs | 13 ++++++--
.../appsettings.Production.json | 2 +-
web/JiShe.CollectBus.Host/appsettings.json | 4 +--
.../JiShe.CollectBus.HttpApi.csproj | 4 +++
8 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index cf19e11..6b19ba6 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,7 +2,7 @@
- 1.0.5.13
+ 1.0.5.16
9.1.1
diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
index 1b17916..dad113b 100644
--- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
+++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs
@@ -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
///
/// 定时采集服务
///
+ [AllowAnonymous]
public abstract class BasicScheduledMeterReadingService : CollectBusAppService, IScheduledMeterReadingService
{
private readonly ILogger _logger;
@@ -249,21 +251,21 @@ namespace JiShe.CollectBus.ScheduledMeterReading
else if (meteryType == MeterTypeEnum.WaterMeter.ToString())
{
- _ = CreateMeterPublishTask(
- timeDensity: timeDensity,
- nextTaskTime: currentTaskTime,
- meterType: MeterTypeEnum.WaterMeter,
- taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
- {
- var tempTask = await WatermeterCreatePublishTaskAction(timeDensity, data, groupIndex, timestamps);
+ //_ = CreateMeterPublishTask(
+ // 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
{
diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
index 859f325..1ef711f 100644
--- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
+++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj
@@ -6,7 +6,8 @@
net9.0
enable
JiShe.CollectBus
-
+ True
+
diff --git a/web/JiShe.CollectBus.Host/CollectBusHostModule.Configure.cs b/web/JiShe.CollectBus.Host/CollectBusHostModule.Configure.cs
index 824a892..bdd6c5a 100644
--- a/web/JiShe.CollectBus.Host/CollectBusHostModule.Configure.cs
+++ b/web/JiShe.CollectBus.Host/CollectBusHostModule.Configure.cs
@@ -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
};
});
}
-
+
///
/// Configures the swagger services.
///
@@ -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
});
}
+
///
/// Configures the audit log.
///
diff --git a/web/JiShe.CollectBus.Host/CollectBusHostModule.cs b/web/JiShe.CollectBus.Host/CollectBusHostModule.cs
index a43aabe..707dfcb 100644
--- a/web/JiShe.CollectBus.Host/CollectBusHostModule.cs
+++ b/web/JiShe.CollectBus.Host/CollectBusHostModule.cs
@@ -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();
diff --git a/web/JiShe.CollectBus.Host/appsettings.Production.json b/web/JiShe.CollectBus.Host/appsettings.Production.json
index ea60840..4c94477 100644
--- a/web/JiShe.CollectBus.Host/appsettings.Production.json
+++ b/web/JiShe.CollectBus.Host/appsettings.Production.json
@@ -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",
diff --git a/web/JiShe.CollectBus.Host/appsettings.json b/web/JiShe.CollectBus.Host/appsettings.json
index fde49e3..bcb6128 100644
--- a/web/JiShe.CollectBus.Host/appsettings.json
+++ b/web/JiShe.CollectBus.Host/appsettings.json
@@ -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",
diff --git a/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj b/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj
index d81e1e8..b2576d6 100644
--- a/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj
+++ b/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj
@@ -20,4 +20,8 @@
+
+
+
+