dev #2

Merged
admin merged 176 commits from dev into master 2025-04-18 01:31:49 +00:00
7 changed files with 85 additions and 24 deletions
Showing only changes of commit e1d4126db0 - Show all commits

View File

@ -15,6 +15,7 @@ using JiShe.CollectBus.Workers;
using Volo.Abp.BackgroundWorkers.Hangfire;
using JiShe.CollectBus.MongoDB;
using JiShe.CollectBus.ScheduledMeterReading;
using JiShe.CollectBus.IoTDBProvider;
namespace JiShe.CollectBus;
@ -25,6 +26,7 @@ namespace JiShe.CollectBus;
typeof(AbpAutoMapperModule),
typeof(AbpBackgroundWorkersHangfireModule),
typeof(CollectBusFreeRedisModule),
typeof(CollectBusIoTDBModule),
typeof(CollectBusFreeSqlModule)
)]
public class CollectBusApplicationModule : AbpModule

View File

@ -1,6 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JiShe.CollectBus.Ammeters;
using JiShe.CollectBus.FreeSql;
using JiShe.CollectBus.IoTDBProvider;
using JiShe.CollectBus.IotSystems.PrepayModel;
using Microsoft.AspNetCore.Authorization;
@ -8,6 +11,31 @@ namespace JiShe.CollectBus.Samples;
public class SampleAppService : CollectBusAppService, ISampleAppService
{
private readonly IIoTDBProvider _iotDBProvider;
public SampleAppService(IIoTDBProvider iotDBProvider)
{
_iotDBProvider = iotDBProvider;
}
public async Task AddReadingAsync()
{
ElectricityMeter meter = new ElectricityMeter()
{
SystemName = "Energy",
DeviceId = "402440506"
,
DeviceType = "Ammeter",
Current = 10,
MeterModel = "DDZY-1980",
ProjectCode = "10059",
Voltage = 10
};
await _iotDBProvider.InsertAsync(meter);
}
public Task<SampleDto> GetAsync()
{
return Task.FromResult(

View File

@ -0,0 +1,24 @@
using JiShe.CollectBus.IoTDBProvider;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiShe.CollectBus.Ammeters
{
public class ElectricityMeter : IoTEntity
{
[ATTRIBUTEColumn]
public string MeterModel { get; set; }
[FIELDColumn]
public double Voltage { get; set; }
[FIELDColumn]
public double Current { get; set; }
[FIELDColumn]
public double Power => Voltage * Current;
}
}

View File

@ -24,6 +24,7 @@
<ProjectReference Include="..\JiShe.CollectBus.Common\JiShe.CollectBus.Common.csproj" />
<ProjectReference Include="..\JiShe.CollectBus.Domain.Shared\JiShe.CollectBus.Domain.Shared.csproj" />
<ProjectReference Include="..\JiShe.CollectBus.FreeSql\JiShe.CollectBus.FreeSql.csproj" />
<ProjectReference Include="..\JiShe.CollectBus.IoTDBProvider\JiShe.CollectBus.IoTDBProvider.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -290,15 +290,15 @@ namespace JiShe.CollectBus.Host
var producerConfig = new ProducerConfig();
context.Services
.ConfigureKafkaTestOptions(options =>
{
// .ConfigureKafkaTestOptions(options =>
// {
#if DEBUG
options.CleanTopicsOnStart = true;// 测试时每次启动都删除topic,生产环境不需要
#endif
options.CreateTopicsIfNotExists = true;
options.TopicNames = ProtocolConstExtensions.GetAllTopicNames();
})
//#if DEBUG
// options.CleanTopicsOnStart = true;// 测试时每次启动都删除topic,生产环境不需要
//#endif
// options.CreateTopicsIfNotExists = true;
// options.TopicNames = ProtocolConstExtensions.GetAllTopicNames();
// })
.AddMassTransit(x =>
{
x.UsingInMemory((context, cfg) => cfg.ConfigureEndpoints(context));

View File

@ -1,4 +1,4 @@
{
{
"Serilog": {
"Using": [
"Serilog.Sinks.Console",
@ -20,7 +20,7 @@
{
"Name": "Console"
},
{
{
"Name": "File",
"Args": {
"path": "logs/logs-.txt",
@ -33,17 +33,17 @@
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "http://localhost:4200,http://localhost:3100"
},
"ConnectionStrings": {
"Default": "mongodb://admin:admin02023@118.190.144.92:37117,118.190.144.92:37119,118.190.144.92:37120/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
"Kafka": "121.42.242.91:29092,121.42.242.91:39092,121.42.242.91: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": "118.190.144.92:6379,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
"DefaultDB": "14",
"HangfireDB": "15"
},
"ConnectionStrings": {
"Default": "mongodb://admin:admin02023@118.190.144.92:37117,118.190.144.92:37119,118.190.144.92:37120/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
"Kafka": "121.42.242.91:29092,121.42.242.91:39092,121.42.242.91: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": "118.190.144.92:6379,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
"DefaultDB": "14",
"HangfireDB": "15"
},
"Jwt": {
"Audience": "JiShe.CollectBus",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
@ -80,5 +80,11 @@
"Password": "123456",
"Port": 5672
}
},
"IoTDBOptions": {
"UserName": "root",
"Password": "root",
"ClusterList": [ "192.168.56.102:6667"],
"PoolSize": 10
}
}

View File

@ -30,8 +30,8 @@
public string DeviceId { get; set; }
/// <summary>
/// 时间戳
/// 当前时间戳,单位秒
/// </summary>
public long Timestamps { get; set; }
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
}
}