Просмотр исходного кода

血压增加值基本功能

td_orm
H Vs 1 год назад
Родитель
Сommit
7f6ae327f9
18 измененных файлов: 561 добавлений и 22 удалений
  1. +2
    -2
      HealthMonitor.Core/Map/HealthMonitor/HmBloodPressReferenceValueMap.cs
  2. +49
    -0
      HealthMonitor.Model/Cache/GpsDevicePerson.cs
  3. +1
    -1
      HealthMonitor.Model/Config/RedisConfig.cs
  4. +22
    -0
      HealthMonitor.Model/Config/ServiceConfig.cs
  5. +4
    -0
      HealthMonitor.Model/Config/TDengineServiceConfig.cs
  6. +4
    -0
      HealthMonitor.Model/HealthMonitor.Model.csproj
  7. +17
    -0
      HealthMonitor.Service/Biz/db/Dto/Aggregate.cs
  8. +26
    -0
      HealthMonitor.Service/Biz/db/Dto/TDengineRestResBase.cs
  9. +86
    -4
      HealthMonitor.Service/Biz/db/TDengineService.cs
  10. +125
    -0
      HealthMonitor.Service/Cache/PersonCacheManager.cs
  11. +11
    -0
      HealthMonitor.Service/Cache/RedisHelperDb7.cs
  12. +4
    -0
      HealthMonitor.Service/HealthMonitor.Service.csproj
  13. +1
    -1
      HealthMonitor.Util/Entities/HealthMonitor/HmBloodPressReferenceValue.cs
  14. +167
    -0
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs
  15. +3
    -3
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressReferenceValueController.cs
  16. +1
    -0
      HealthMonitor.WebApi/HealthMonitor.WebApi.csproj
  17. +27
    -9
      HealthMonitor.WebApi/Program.cs
  18. +11
    -2
      HealthMonitor.WebApi/appsettings.Development.json

HealthMonitor.Core/Map/HealthMonitor/BloodPressReferenceValueMap.cs → HealthMonitor.Core/Map/HealthMonitor/HmBloodPressReferenceValueMap.cs Просмотреть файл

@@ -10,9 +10,9 @@ using System.Threading.Tasks;

namespace HealthMonitor.Core.Map.HealthMonitor
{
public partial class BloodPressReferenceValueMap : GenericEntityTypeConfiguration<BloodPressReferenceValue>
public partial class HmBloodPressReferenceValueMap : GenericEntityTypeConfiguration<HmBloodPressReferenceValue>
{
public override void Configure(EntityTypeBuilder<BloodPressReferenceValue> entity)
public override void Configure(EntityTypeBuilder<HmBloodPressReferenceValue> entity)
{
entity.HasKey(e => e.Id)
.HasName("PRIMARY");

+ 49
- 0
HealthMonitor.Model/Cache/GpsDevicePerson.cs Просмотреть файл

@@ -0,0 +1,49 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HealthMonitor.Model.Cache
{
public class Person
{
[JsonProperty("personId")]
public string PersonId { get; set; } = default!;

[JsonProperty("deviceId")]
public string DeviceId { get; set; } = default!;

[JsonProperty("serialno")]
public string SerialNo { get; set; } = default!;

[JsonProperty("remarks")]
public string Remarks { get; set; } = default!;

[JsonProperty("ishypertension")]
public bool Ishypertension { get; set; } = default!;

[JsonProperty("personName")]
public string PersonName { get; set; } = default!;

[JsonProperty("gender")]
public bool Gender { get; set; } = default!;

[JsonProperty("age")]
public int Age { get; set; } = default!;

[JsonProperty("bornDate")]
public string BornDate { get; set; } = default!;

}
public class GpsDevicePerson
{

[JsonProperty("person")]
public Person Person { get; set; } = default!;

[JsonProperty("time")]
public DateTime Time { get; set; } = default!;
}
}

HealthMonitor.WebApi/Configs/RedisConfig.cs → HealthMonitor.Model/Config/RedisConfig.cs Просмотреть файл

@@ -1,7 +1,7 @@
using System;
using System.Text;

namespace HealthMonitor.WebApi.Configs
namespace HealthMonitor.Model.Config
{
/// <summary>
/// Redis配置模板类

+ 22
- 0
HealthMonitor.Model/Config/ServiceConfig.cs Просмотреть файл

@@ -0,0 +1,22 @@
namespace HealthMonitor.Model.Config
{
public class ServiceConfig
{
/// <summary>
/// 数据服务Host Url
/// </summary>
public string TelpoDataUrl { get; set; } = default!;
///// <summary>
///// Kafka服务地址
///// </summary>
//public string MqServerAddress { get; set; }
///// <summary>
///// 服务守护消息kafka服务地址
///// </summary>
//public string ServiceGuardMqAddress { get; set; }
///// <summary>
///// 服务守护消息主题
///// </summary>
//public string ServiceGuardMqTopic { get; set; }
}
}

+ 4
- 0
HealthMonitor.Model/Config/TDengineServiceConfig.cs Просмотреть файл

@@ -18,6 +18,10 @@ namespace HealthMonitor.Model.Config

public string DB { get; set; } = default!;

public short RestPort { get; set; } = default!;

public string Token {get; set; } = default!;


}
}

+ 4
- 0
HealthMonitor.Model/HealthMonitor.Model.csproj Просмотреть файл

@@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>

+ 17
- 0
HealthMonitor.Service/Biz/db/Dto/Aggregate.cs Просмотреть файл

@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HealthMonitor.Service.Biz.db.Dto
{
public class Aggregate: TDengineRestResBase
{

public int Max { get; set; }

public int Min { get; set; }
}
}

+ 26
- 0
HealthMonitor.Service/Biz/db/Dto/TDengineRestResBase.cs Просмотреть файл

@@ -0,0 +1,26 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HealthMonitor.Service.Biz.db.Dto
{
public class TDengineRestResBase
{
[JsonProperty("code")]
public int Code { get; set; }


[JsonProperty("desc")]
public string? Desc { get; set; }

[JsonProperty("column_meta")]
public List<object>? ColumnMeta { get; set; }

[JsonProperty("data")]
public List<object>? Data { get; set; }

}
}

+ 86
- 4
HealthMonitor.Service/Biz/db/TDengineService.cs Просмотреть файл

@@ -1,6 +1,9 @@
using HealthMonitor.Model.Config;
using HealthMonitor.Common.helper;
using HealthMonitor.Model.Config;
using HealthMonitor.Service.Biz.db.Dto;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -15,11 +18,16 @@ namespace HealthMonitor.Service.Biz.db
{

private readonly ILogger<TDengineService> _logger;
private readonly HttpHelper _httpHelper=default!;
private readonly TDengineServiceConfig _configTDengineService;
public TDengineService(ILogger<TDengineService> logger, IOptions<TDengineServiceConfig> configTDengineService)
public TDengineService(ILogger<TDengineService> logger,
IOptions<TDengineServiceConfig> configTDengineService,
HttpHelper httpHelper
)
{
_logger = logger;
_configTDengineService = configTDengineService.Value;
_httpHelper = httpHelper;
}
public IntPtr Connection()
{
@@ -113,7 +121,6 @@ namespace HealthMonitor.Service.Biz.db
}
}


public void CheckRes(IntPtr conn, IntPtr res, String errorMsg)
{
if (TDengine.ErrorNo(res) != 0)
@@ -122,7 +129,6 @@ namespace HealthMonitor.Service.Biz.db
}
}


public void ExecuteInsertSQL(IntPtr conn, string sql)
{
try
@@ -143,6 +149,82 @@ namespace HealthMonitor.Service.Biz.db
}
}

public async Task<bool> GernalRestSql(string sql)
{

//"http://{server}:{port}/rest/sql/{db}"
var url = $"http://{_configTDengineService.Host}:{_configTDengineService.RestPort}/rest/sql/{_configTDengineService.DB}";
List<KeyValuePair<string, string>> headers = new()
{
new KeyValuePair<string, string>("Authorization", "Basic " + _configTDengineService.Token)
};
var result = await _httpHelper.HttpToPostAsync(url, sql, headers).ConfigureAwait(false);
var res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
if (result != null)
{
if (res?.Code == 0)
{
_logger.LogInformation($"{nameof(GernalRestSql)},SQL 语句执行成功|{sql}");
return true;
}
else
{
_logger.LogWarning($"{nameof(GernalRestSql)},SQL 语句执行失败||{sql}");
return false;
}
}
else
{
_logger.LogError($"{nameof(GernalRestSql)},TDengine 服务器IP:{_configTDengineService.Host} 错误,请联系运维人员");
return false;
}
//return res.Code==0;
}

public async Task<string?> GernalRestSqlResText(string sql)
{
var url = $"http://{_configTDengineService.Host}:{_configTDengineService.RestPort}/rest/sql/{_configTDengineService.DB}";
List<KeyValuePair<string, string>> headers = new()
{
new KeyValuePair<string, string>("Authorization", "Basic " + _configTDengineService.Token)
};
var result = await _httpHelper.HttpToPostAsync(url, sql, headers).ConfigureAwait(false);
return result;
}

public async Task<Aggregate> GetAggregateValue(string field,string tbName,string? condition)
{
var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var result = await GernalRestSqlResText(sql);
var res = JsonConvert.DeserializeObject<Aggregate>(result!);
List<dynamic> data = res?.Data!;
return new Aggregate
{
Max = data[0][0],
Min = data[0][1],
};
}

public async Task<decimal> GetAvgExceptMaxMinValue(string field, string tbName, string? condition)
{

var sql = $"SELECT MAX({field}), MIN({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition}";

var result = await GernalRestSqlResText(sql);
var res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
List<dynamic> data = res?.Data!;

sql = $"SELECT AVG({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition} AND {field} < {data[0][0]} and {field} > {data[0][1]}";
result = await GernalRestSqlResText(sql);
res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
data = res?.Data!;

return data.Count.Equals(0)?0:data[0][0];
}



}
}

+ 125
- 0
HealthMonitor.Service/Cache/PersonCacheManager.cs Просмотреть файл

@@ -0,0 +1,125 @@
using CSRedis;
using HealthMonitor.Model.Cache;
using HealthMonitor.Model.Config;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using TelpoDataService.Util;
using TelpoDataService.Util.Clients;
using TelpoDataService.Util.Entities.GpsCard;
using TelpoDataService.Util.Models;
using TelpoDataService.Util.QueryObjects;

namespace HealthMonitor.Service.Cache
{
public abstract class MyHelper2 : RedisHelper<MyHelper2> { }
public class PersonCacheManager
{
private const int DEFAULT_DURATION_SECONDS = 1200; //20分钟
private const string CACHE_KEY_PERSON = "Person_";
//注意要改用 redis DB7 数据库 ,Prefix=TELPO
private const string CACHE_HASH_KEY_GPSDEVICEPERSON = "#GPSDEVICE_PERSON_HASH";
//注意要改用 redis DB7 数据库 ,Prefix=TELPO


private readonly GpsCardAccessorClient<GpsPerson> _personApiClient;
private readonly ILogger<PersonCacheManager> _logger;
private readonly IOptions<RedisConfig> _optConfigRedis;

public PersonCacheManager(GpsCardAccessorClient<GpsPerson> personApiClient,
ILogger<PersonCacheManager> logger, IOptions<RedisConfig> optConfigRedis)
{
_optConfigRedis = optConfigRedis;
_personApiClient = personApiClient;
_logger = logger;
}
public async Task<GpsPerson?> GetPersonBySerialNoAsync(string messageId, string sn)
{
if (string.IsNullOrWhiteSpace(sn)) return null;
// 切换redis DB7 数据库和前缀 "TELPO"
_optConfigRedis.Value.DefaultDatabase = 7;
_optConfigRedis.Value.Prefix = "TELPO";

// 增加容错,防止Redis宕机造成业务中断
try
{
using var csRedisDb7 = new CSRedisClient(_optConfigRedis.Value.ToString());
return await csRedisDb7.HGetAsync<GpsPerson>(CACHE_HASH_KEY_GPSDEVICEPERSON, sn);
}
catch (Exception ex)
{
_logger.LogWarning($"Redis发生异常,将直接读取MySQL数据库,构造新实例:{ex.Message}, {ex.StackTrace}");
var param = new GeneralParam
{
Filters = new List<QueryFilterCondition>
{
new QueryFilterCondition
{
Key=nameof(GpsPerson.Serialno),
Value=sn,
ValueType=QueryValueTypeEnum.String,
Operator=QueryOperatorEnum.Equal
}
}
}!;
return await _personApiClient.GetFirstAsync(param, new RequestHeader { RequestId = messageId }).ConfigureAwait(false);
}
}

/// <summary>
/// 读取个人信息(血压使用)注意要改用 redis DB7
/// </summary>
/// <param name="messageId"></param>
/// <param name="sn"></param>
/// <returns></returns>
public async Task<GpsDevicePerson?> GetDeviceGpsPersonCacheBySerialNoAsync(string messageId, string sn)
{
if (string.IsNullOrWhiteSpace(sn)) return null;
// 切换redis DB7 数据库和前缀 "TELPO"
_optConfigRedis.Value.DefaultDatabase = 7;
_optConfigRedis.Value.Prefix = "TELPO";

// 增加容错,防止Redis宕机造成业务中断
try
{
var person = await RedisHelperDb7.HGetAsync<GpsDevicePerson>(CACHE_HASH_KEY_GPSDEVICEPERSON, sn).ConfigureAwait(false);
return person;
}
catch(Exception ex)
{
_logger.LogWarning($"Redis发生异常,将直接读取MySQL数据库,构造新实例:{ex.Message}, {ex.StackTrace}");
var param = new GeneralParam
{
Filters = new List<QueryFilterCondition>
{
new QueryFilterCondition
{
Key=nameof(GpsPerson.Serialno),
Value=sn,
ValueType=QueryValueTypeEnum.String,
Operator=QueryOperatorEnum.Equal
}
}
}!;
var person = await _personApiClient.GetFirstAsync(param, new RequestHeader { RequestId = messageId }).ConfigureAwait(false);
// 读取数据库,构造新实例
return new GpsDevicePerson {
Time = DateTime.Now,
Person=new Person {
DeviceId=person.DeviceId,
PersonId=person.PersonId,
Remarks=person.Remarks,
SerialNo=person.Serialno
}
};
}

}
}
}

+ 11
- 0
HealthMonitor.Service/Cache/RedisHelperDb7.cs Просмотреть файл

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HealthMonitor.Service.Cache
{
public abstract class RedisHelperDb7 : RedisHelper<RedisHelperDb7> { }
}

+ 4
- 0
HealthMonitor.Service/HealthMonitor.Service.csproj Просмотреть файл

@@ -7,13 +7,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.8.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="TDengine.Connector" Version="3.0.2" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.16-beta1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HealthMonitor.Common\HealthMonitor.Common.csproj" />
<ProjectReference Include="..\HealthMonitor.Model\HealthMonitor.Model.csproj" />
<ProjectReference Include="..\HealthMonitor.Util\HealthMonitor.Util.csproj" />
</ItemGroup>

</Project>

HealthMonitor.Util/Entities/HealthMonitor/BloodPressReferenceValue.cs → HealthMonitor.Util/Entities/HealthMonitor/HmBloodPressReferenceValue.cs Просмотреть файл

@@ -10,7 +10,7 @@ using HealthMonitor.Util.Entities.Interfaces;

namespace HealthMonitor.Util.Entities.HealthMonitor
{
public partial class BloodPressReferenceValue : HealthMonitorEntityBase, IKeyIntType
public partial class HmBloodPressReferenceValue : HealthMonitorEntityBase, IKeyIntType
{
[Key]


+ 167
- 0
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs Просмотреть файл

@@ -0,0 +1,167 @@
using HealthMonitor.Core.Dal;
using HealthMonitor.Model.Cache;
using HealthMonitor.Service.Biz.db;
using HealthMonitor.Service.Cache;
using HealthMonitor.Util.Entities.HealthMonitor;
using HealthMonitor.WebApi.Configs;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TelpoDataService.Util.Entities.GpsLocationHistory;

namespace HealthMonitor.WebApi.Controllers.HealthMonitor
{
[ApiExplorerSettings(GroupName = AppConsts.SWAGGER_DOC_HealthMonitor)]
[Produces("application/json")]
[Route("api/HealthMonitor/[controller]/[action]")]
[ApiController]
public class HmBloodPressController:ControllerBase
{
protected readonly ILogger _logger;
private readonly TDengineService _serviceTDengine;
private readonly PersonCacheManager _personCacheMgr;
protected readonly IHealthMonitorDataAccessor _dataAccessor;

public HmBloodPressController
(
ILogger<HmBloodPressController> logger,
TDengineService serviceDengine,
PersonCacheManager personCacheMgr,
IHealthMonitorDataAccessor dataAccessor
)
{
_logger = logger;
_serviceTDengine = serviceDengine;
_personCacheMgr = personCacheMgr;
_dataAccessor = dataAccessor;
}

[HttpPost]
public async Task<IActionResult> AddAsync([FromHeader] string requestId, HisGpsBloodPress bp1)
{
HisGpsBloodPress bp = new()
{
BloodPressId = "261850cb-ce91-4003-8c63-a1f8f50d6495",
MessageId = "1670682284342246914",
Serialno = "861281060083627",
SystolicValue = 114,
DiastolicValue = 79,
CreateTime = DateTime.Parse("2023-06-19 14:37:53"),
LastUpdate = DateTime.Parse("2023-06-19 14:26:52"),
Method = 1,
IsDisplay = 1

};
//var aggregate = await _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{DateTime.Now.AddDays(-7):yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{DateTime.Now:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='861281060083627' and systolic_value < {120} and diastolic_value >{80}");

//+++++++++++++++++++++++++++++++

#region 插入当次BP数据
// 保存到TDengine
/**
var sql = $"INSERT INTO health_monitor.hm_bloodpress VALUES(" +
$"'{bp.LastUpdate:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{bp.BloodPressId}'," +
$"'{bp.MessageId}'," +
$"'{bp.Serialno}'," +
$"{bp.SystolicValue}," +
$"{bp.DiastolicValue}," +
$"'{bp.CreateTime:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{bp.LastUpdate:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"{bp.Method}," +
$"{bp.IsDisplay == 1})";

// var sql = "select * from health_monitor.hm_bloodpress order by last_update desc";


var res=await _serviceTDengine.GernalRestSql(sql);
*/
#endregion

#region 获取个人信息
var person = await _personCacheMgr.GetDeviceGpsPersonCacheBySerialNoAsync(bp.MessageId, bp.Serialno).ConfigureAwait(false);

//var person = new GpsDevicePerson()
//{
// Time = DateTime.Now,
// Person = new Person()
// {
// Age = 43,
// DeviceId = "111111",
// Gender = true,
// Ishypertension = false,
// SerialNo = bp.Serialno
// }
//};
#endregion

#region 计算增量值
// 获取个人资料 redis
var age = person?.Person.Age;
var gender = person?.Person.Gender == true ? 1 : 2;
var isHypertension = person?.Person.Ishypertension;
var height = 0f;
var weight = 0f;
// 获取标定值 mysql
var bpRef = _dataAccessor
.GetFirstOrDefault<HmBloodPressReferenceValue>(
i =>
i.Age.Equals(age) &&
i.Gender.Equals(gender) &&
i.Hypertension.Equals(isHypertension)
);
var systolicRefValue = bpRef.Systolic;//?
var diastolicRefValue = bpRef.Diastolic;//?

// 获取历史数据
DateTime now = DateTime.Now;
DateTime startTime = now.AddDays(-2);
DateTime endTime = now;

// 计算去除最大值和最小值和异常值的平均值
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} and diastolic_value >{diastolicRefValue}");

// 偏移参数
var avgOffset = 0.25M;

// 增量值
var systolicInc = (int)(systolicRefValue - systolicAvg * avgOffset);
var diastolicInc = (int)(diastolicRefValue - systolicAvg * avgOffset);

#endregion

#region 插入BP增量值
var sql = $"INSERT INTO health_monitor.hm_bloodpress_stats_inc VALUES(" +
$"'{bp.LastUpdate:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{bp.BloodPressId}'," +
$"'{bp.MessageId}'," +
$"'{bp.Serialno}'," +
$"{bp.SystolicValue}," +
$"{bp.DiastolicValue}," +
$"'{bp.LastUpdate:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"{systolicInc}," +
$"{diastolicInc}," +
$"{avgOffset}," +
$"{gender}," +
$"{age}," +
$"{height}," +
$"{weight}," +
$"'{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}'," +
$"'{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}')";
var res = await _serviceTDengine.GernalRestSql(sql);
#endregion


return Ok(true);
}



}
}

HealthMonitor.WebApi/Controllers/HealthMonitor/BloodPressReferenceValueController.cs → HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressReferenceValueController.cs Просмотреть файл

@@ -9,14 +9,14 @@ using Microsoft.AspNetCore.Mvc;
namespace HealthMonitor.WebApi.Controllers.HealthMonitor
{
[ApiExplorerSettings(GroupName = AppConsts.SWAGGER_DOC_HealthMonitor)]
public class BloodPressReferenceValueController : HealthMonitorControllerBase<BloodPressReferenceValue>
public class HmBloodPressReferenceValueController : HealthMonitorControllerBase<HmBloodPressReferenceValue>
{
public BloodPressReferenceValueController(
public HmBloodPressReferenceValueController(
// IHealthMonitorDataAccessor dataAccessor,
IHealthMonitorDataAccessor dataAccessor,
IHealthMonitorOperatorManager operatorManager,
IDurableEntityManager durableManager,
ILogger<BloodPressReferenceValueController> logger)
ILogger<HmBloodPressReferenceValueController> logger)
: base(dataAccessor, operatorManager, durableManager, logger)
{


+ 1
- 0
HealthMonitor.WebApi/HealthMonitor.WebApi.csproj Просмотреть файл

@@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.16-beta1" />
</ItemGroup>

<ItemGroup>


+ 27
- 9
HealthMonitor.WebApi/Program.cs Просмотреть файл

@@ -20,6 +20,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using HealthMonitor.WebApi.Swagger;
using HealthMonitor.Service.Cache;
using TelpoDataService.Util.Clients;

namespace HealthMonitor.WebApi
{
@@ -44,13 +46,6 @@ namespace HealthMonitor.WebApi
builder.Services.AddSingleton<HttpHelper>();
builder.Services.AddSingleton<TDengineService>();





builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
@@ -110,7 +105,8 @@ namespace HealthMonitor.WebApi
options.SuppressModelStateInvalidFilter = true;
})
.Configure<RedisConfig>(builder.Configuration.GetSection("Redis"))
.Configure<TDengineServiceConfig>(builder.Configuration.GetSection("TDengineServiceConfig")); ;
.Configure<TDengineServiceConfig>(builder.Configuration.GetSection("TDengineServiceConfig"))
.Configure<ServiceConfig>(builder.Configuration.GetSection("ServiceConfig"));


builder.Services
@@ -144,6 +140,21 @@ namespace HealthMonitor.WebApi
builder.Host.UseServiceProviderFactory(new DynamicProxyServiceProviderFactory());
#endregion

#region Cache
builder.Services
.AddSingleton<PersonCacheManager>();

#endregion

#region

builder.Services.AddTelpoDataServices(opt =>
{
opt.TelpoDataUrl = builder.Configuration.GetSection("ServiceConfig:TelpoDataUrl").Value;
});

#endregion

// Register the Swagger generator, defining 1 or more Swagger documents
builder.Services.AddSwaggerGen(c =>
{
@@ -203,10 +214,17 @@ namespace HealthMonitor.WebApi



// redis
// redis default
var csredis = new CSRedis.CSRedisClient(app.Services.GetService<IOptions<RedisConfig>>()!.Value.ToString());
RedisHelper.Initialization(csredis);

// redis db7
var csredisDb7Con = app.Services.GetService<IOptions<RedisConfig>>()!.Value;
csredisDb7Con.DefaultDatabase = 7;
csredisDb7Con.Prefix = "TELPO";
var csredisDb7 = new CSRedis.CSRedisClient(csredisDb7Con.ToString());
RedisHelperDb7.Initialization(csredisDb7);

app.UseHttpsRedirection();

app.UseAuthorization();


+ 11
- 2
HealthMonitor.WebApi/appsettings.Development.json Просмотреть файл

@@ -9,20 +9,29 @@
"Host": "47.116.142.20",
"UserName": "root",
"Password": "taosdata",
"Token": "cm9vdDp0YW9zZGF0YQ==",
"Port": 6030,
"RestPort": 6041,
"DB": "health_monitor"
},
"Redis": {
//"Server": "172.16.192.26:8090",
"Server": "47.116.142.20:8090",
//"Server": "47.116.142.20:8090", // 测试环境
"Server": "139.224.254.18:8090", // 正式环境
"Password": "telpo#1234",
//"Server": "127.0.0.1:6379",
"DefaultDatabase": 2,
"Prefix": "_HM_",
//"DefaultDatabase": 7,
// "Prefix": "TELPO",
"Poolsize": 50,
"Prefix": "_HW_",
"ConnectTimeout": 5000,
"IdleTimeout": 20000
},
"ServiceConfig": {
"TelpoDataUrl": "https://id.ssjlai.com/data/"
},
"ConnectionStrings": {
//"GpsCard_Connection_String": "server=172.16.192.26;port=3304;database=user_operation_platform;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none",
"GpsCard_Connection_String": "server=139.224.254.18;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none",


Загрузка…
Отмена
Сохранить