dev #2
@ -15,6 +15,7 @@ using JiShe.CollectBus.Workers;
|
|||||||
using Volo.Abp.BackgroundWorkers.Hangfire;
|
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||||
using JiShe.CollectBus.MongoDB;
|
using JiShe.CollectBus.MongoDB;
|
||||||
using JiShe.CollectBus.ScheduledMeterReading;
|
using JiShe.CollectBus.ScheduledMeterReading;
|
||||||
|
using JiShe.CollectBus.IoTDBProvider;
|
||||||
|
|
||||||
namespace JiShe.CollectBus;
|
namespace JiShe.CollectBus;
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ namespace JiShe.CollectBus;
|
|||||||
typeof(AbpAutoMapperModule),
|
typeof(AbpAutoMapperModule),
|
||||||
typeof(AbpBackgroundWorkersHangfireModule),
|
typeof(AbpBackgroundWorkersHangfireModule),
|
||||||
typeof(CollectBusFreeRedisModule),
|
typeof(CollectBusFreeRedisModule),
|
||||||
|
typeof(CollectBusIoTDBModule),
|
||||||
typeof(CollectBusFreeSqlModule)
|
typeof(CollectBusFreeSqlModule)
|
||||||
)]
|
)]
|
||||||
public class CollectBusApplicationModule : AbpModule
|
public class CollectBusApplicationModule : AbpModule
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JiShe.CollectBus.Ammeters;
|
||||||
using JiShe.CollectBus.FreeSql;
|
using JiShe.CollectBus.FreeSql;
|
||||||
|
using JiShe.CollectBus.IoTDBProvider;
|
||||||
using JiShe.CollectBus.IotSystems.PrepayModel;
|
using JiShe.CollectBus.IotSystems.PrepayModel;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
||||||
@ -8,6 +11,31 @@ namespace JiShe.CollectBus.Samples;
|
|||||||
|
|
||||||
public class SampleAppService : CollectBusAppService, ISampleAppService
|
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()
|
public Task<SampleDto> GetAsync()
|
||||||
{
|
{
|
||||||
return Task.FromResult(
|
return Task.FromResult(
|
||||||
|
|||||||
24
src/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
Normal file
24
src/JiShe.CollectBus.Domain/Ammeters/ElectricityMeter.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,6 +24,7 @@
|
|||||||
<ProjectReference Include="..\JiShe.CollectBus.Common\JiShe.CollectBus.Common.csproj" />
|
<ProjectReference Include="..\JiShe.CollectBus.Common\JiShe.CollectBus.Common.csproj" />
|
||||||
<ProjectReference Include="..\JiShe.CollectBus.Domain.Shared\JiShe.CollectBus.Domain.Shared.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.FreeSql\JiShe.CollectBus.FreeSql.csproj" />
|
||||||
|
<ProjectReference Include="..\JiShe.CollectBus.IoTDBProvider\JiShe.CollectBus.IoTDBProvider.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -290,15 +290,15 @@ namespace JiShe.CollectBus.Host
|
|||||||
var producerConfig = new ProducerConfig();
|
var producerConfig = new ProducerConfig();
|
||||||
|
|
||||||
context.Services
|
context.Services
|
||||||
.ConfigureKafkaTestOptions(options =>
|
// .ConfigureKafkaTestOptions(options =>
|
||||||
{
|
// {
|
||||||
|
|
||||||
#if DEBUG
|
//#if DEBUG
|
||||||
options.CleanTopicsOnStart = true;// 测试时,每次启动都删除topic,生产环境不需要
|
// options.CleanTopicsOnStart = true;// 测试时,每次启动都删除topic,生产环境不需要
|
||||||
#endif
|
//#endif
|
||||||
options.CreateTopicsIfNotExists = true;
|
// options.CreateTopicsIfNotExists = true;
|
||||||
options.TopicNames = ProtocolConstExtensions.GetAllTopicNames();
|
// options.TopicNames = ProtocolConstExtensions.GetAllTopicNames();
|
||||||
})
|
// })
|
||||||
.AddMassTransit(x =>
|
.AddMassTransit(x =>
|
||||||
{
|
{
|
||||||
x.UsingInMemory((context, cfg) => cfg.ConfigureEndpoints(context));
|
x.UsingInMemory((context, cfg) => cfg.ConfigureEndpoints(context));
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [
|
"Using": [
|
||||||
"Serilog.Sinks.Console",
|
"Serilog.Sinks.Console",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
{
|
{
|
||||||
"Name": "Console"
|
"Name": "Console"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "File",
|
"Name": "File",
|
||||||
"Args": {
|
"Args": {
|
||||||
"path": "logs/logs-.txt",
|
"path": "logs/logs-.txt",
|
||||||
@ -33,17 +33,17 @@
|
|||||||
"SelfUrl": "http://localhost:44315",
|
"SelfUrl": "http://localhost:44315",
|
||||||
"CorsOrigins": "http://localhost:4200,http://localhost:3100"
|
"CorsOrigins": "http://localhost:4200,http://localhost:3100"
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"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",
|
"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",
|
"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",
|
"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"
|
"EnergyDB": "server=118.190.144.92;database=db_energy;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False"
|
||||||
},
|
},
|
||||||
"Redis": {
|
"Redis": {
|
||||||
"Configuration": "118.190.144.92:6379,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
|
"Configuration": "118.190.144.92:6379,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true",
|
||||||
"DefaultDB": "14",
|
"DefaultDB": "14",
|
||||||
"HangfireDB": "15"
|
"HangfireDB": "15"
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Audience": "JiShe.CollectBus",
|
"Audience": "JiShe.CollectBus",
|
||||||
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
|
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
|
||||||
@ -80,5 +80,11 @@
|
|||||||
"Password": "123456",
|
"Password": "123456",
|
||||||
"Port": 5672
|
"Port": 5672
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"IoTDBOptions": {
|
||||||
|
"UserName": "root",
|
||||||
|
"Password": "root",
|
||||||
|
"ClusterList": [ "192.168.56.102:6667"],
|
||||||
|
"PoolSize": 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -30,8 +30,8 @@
|
|||||||
public string DeviceId { get; set; }
|
public string DeviceId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 时间戳
|
/// 当前时间戳,单位秒
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long Timestamps { get; set; }
|
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user