diff --git a/Sln.Iot.Business/IotEnvBusiness.cs b/Sln.Iot.Business/IotEnvBusiness.cs index e778ddb..ef513cd 100644 --- a/Sln.Iot.Business/IotEnvBusiness.cs +++ b/Sln.Iot.Business/IotEnvBusiness.cs @@ -104,7 +104,7 @@ namespace Sln.Iot.Business f_tempreture = 0; } - iotEnvInstant.tempreture = (decimal) f_tempreture; + iotEnvInstant.temperature = (decimal) f_tempreture; break; case CommParams.Humidity: //湿度 @@ -202,7 +202,7 @@ namespace Sln.Iot.Business if (result.Count > 0) { - //var inRes = _service.Insert(result); + var inRes = _service.SplitInsert(result,out List insertIds); /*Task.Run(() => //保存至TD引擎 { @@ -211,7 +211,7 @@ namespace Sln.Iot.Business this.RefreshMonitorInfo(result); });*/ - //_logger.Info($"{amount}个物联网数据解析处理完成,数据保存{(inRes ? "成功" : "失败")}"); + _logger.Info($"{amount}个物联网数据解析处理完成,数据保存{(inRes ? "成功" : "失败")}"); } else { diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.dll b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.dll index 2c16aa7..473704a 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.dll and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.dll differ diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.pdb b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.pdb index 8774e8b..6d7a9c3 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.pdb and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Business.pdb differ diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.dll b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.dll index 424b132..6c0d761 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.dll and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.dll differ diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb index 813e160..b442f76 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb differ diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll index 24c630a..13958c3 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll differ diff --git a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb index 4f2cb8e..c50464a 100644 Binary files a/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb and b/Sln.Iot.Business/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb differ diff --git a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.csproj.AssemblyReference.cache b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.csproj.AssemblyReference.cache index 29fd14a..b9db106 100644 Binary files a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.csproj.AssemblyReference.cache and b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.csproj.AssemblyReference.cache differ diff --git a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.dll b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.dll index 2c16aa7..473704a 100644 Binary files a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.dll and b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.dll differ diff --git a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.pdb b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.pdb index 8774e8b..6d7a9c3 100644 Binary files a/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.pdb and b/Sln.Iot.Business/obj/Debug/netstandard2.1/Sln.Iot.Business.pdb differ diff --git a/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.dll b/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.dll index 424b132..6c0d761 100644 Binary files a/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.dll and b/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.dll differ diff --git a/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb b/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb index 813e160..b442f76 100644 Binary files a/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb and b/Sln.Iot.Model/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb differ diff --git a/Sln.Iot.Model/dao/RecordIotEnvInstant.cs b/Sln.Iot.Model/dao/RecordIotEnvInstant.cs index 1592724..8958735 100644 --- a/Sln.Iot.Model/dao/RecordIotEnvInstant.cs +++ b/Sln.Iot.Model/dao/RecordIotEnvInstant.cs @@ -28,13 +28,14 @@ using SqlSugar; namespace Sln.Iot.Model.dao { - [SugarTable("record_iotenv_instant"), TenantAttribute("tao_iot")] + [SplitTable(SplitType.Day)] + [SugarTable("record_iotenv_instant_{year}{month}{day}"), TenantAttribute("tao_iot")] public class RecordIotEnvInstant { /// - /// 编号 + /// 编号 ,IsIdentity = true /// - [SugarColumn(ColumnName="objid" ,IsPrimaryKey = true ,IsIdentity = true )] + [SugarColumn(ColumnName="objid" ,IsPrimaryKey = true )] public long objid { get; set; } /// @@ -46,8 +47,8 @@ namespace Sln.Iot.Model.dao /// /// 温度 /// - [SugarColumn(ColumnName="tempreture" )] - public decimal tempreture { get; set; } + [SugarColumn(ColumnName="temperature" )] + public decimal temperature { get; set; } /// /// 湿度 @@ -108,6 +109,7 @@ namespace Sln.Iot.Model.dao /// /// 记录时间 /// + [SplitField] [SugarColumn(ColumnName="recodeTime" )] public DateTime? recordTime { get; set; } } diff --git a/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.dll b/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.dll index 424b132..6c0d761 100644 Binary files a/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.dll and b/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.dll differ diff --git a/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.pdb b/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.pdb index 813e160..b442f76 100644 Binary files a/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.pdb and b/Sln.Iot.Model/obj/Debug/netstandard2.1/Sln.Iot.Model.pdb differ diff --git a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.dll b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.dll index 424b132..6c0d761 100644 Binary files a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.dll and b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.dll differ diff --git a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb index 813e160..b442f76 100644 Binary files a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb and b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Model.pdb differ diff --git a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll index 24c630a..13958c3 100644 Binary files a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll and b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.dll differ diff --git a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb index 4f2cb8e..c50464a 100644 Binary files a/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb and b/Sln.Iot.Repository/bin/Debug/netstandard2.1/Sln.Iot.Repository.pdb differ diff --git a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.csproj.AssemblyReference.cache b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.csproj.AssemblyReference.cache index 1c5e69e..bdb6bb8 100644 Binary files a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.csproj.AssemblyReference.cache and b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.csproj.AssemblyReference.cache differ diff --git a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.dll b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.dll index 24c630a..13958c3 100644 Binary files a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.dll and b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.dll differ diff --git a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.pdb b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.pdb index 4f2cb8e..c50464a 100644 Binary files a/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.pdb and b/Sln.Iot.Repository/obj/Debug/netstandard2.1/Sln.Iot.Repository.pdb differ diff --git a/Sln.Iot.Repository/service/IRecordIotEnvInstantService.cs b/Sln.Iot.Repository/service/IRecordIotEnvInstantService.cs index 5685c7f..f9f7cd2 100644 --- a/Sln.Iot.Repository/service/IRecordIotEnvInstantService.cs +++ b/Sln.Iot.Repository/service/IRecordIotEnvInstantService.cs @@ -23,6 +23,7 @@ #endregion << 版 本 注 释 >> +using System.Collections.Generic; using Sln.Iot.Model.dao; using Sln.Iot.Repository.service.@base; @@ -30,6 +31,12 @@ namespace Sln.Iot.Repository.service { public interface IRecordIotEnvInstantService:IBaseService { - + /// + /// 分表保存 + /// + /// + /// + /// + bool SplitInsert(List list,out List insertIds); } } \ No newline at end of file diff --git a/Sln.Iot.Repository/service/Impl/RecordIotEnvInstantServiceImpl.cs b/Sln.Iot.Repository/service/Impl/RecordIotEnvInstantServiceImpl.cs index f6c2c69..ec1a2d2 100644 --- a/Sln.Iot.Repository/service/Impl/RecordIotEnvInstantServiceImpl.cs +++ b/Sln.Iot.Repository/service/Impl/RecordIotEnvInstantServiceImpl.cs @@ -23,6 +23,8 @@ #endregion << 版 本 注 释 >> +using System; +using System.Collections.Generic; using Sln.Iot.Model.dao; using Sln.Iot.Repository.service.@base; @@ -33,5 +35,34 @@ namespace Sln.Iot.Repository.service.Impl public RecordIotEnvInstantServiceImpl(Repository rep) : base(rep) { } + + /// + /// 分表保存 + /// + /// + /// + /// + /// + /// + public bool SplitInsert(List list,out List insertIds) + { + if (list == null) + { + throw new ArgumentNullException($"参数为空"); + } + try + { + + // _rep.AsTenant().BeginTran(); + insertIds = _rep.Context.Insertable(list).SplitTable().ExecuteReturnSnowflakeIdList(); + // _rep.AsTenant().CommitTran(); + return true; + } + catch (Exception ex) + { + // _rep.AsTenant().RollbackTran(); + throw new InvalidOperationException($"物联网数据分表保存异常:{ex.Message}"); + } + } } } \ No newline at end of file diff --git a/Sln.Iot/appsettings.json b/Sln.Iot/appsettings.json index 4350b2e..c3c9792 100644 --- a/Sln.Iot/appsettings.json +++ b/Sln.Iot/appsettings.json @@ -12,9 +12,9 @@ }, { "configId": "tao_iot", //tao:青岛胶东机场简称 - "dbType": 20, //tidb + "dbType": 0, //tidb按照 mysql 去连接 "isFlag": true, - "connStr": "server=10.42.0.1;Database=tao_iot;Uid=root;Pwd=haiwei@123;" + "connStr": "server=127.0.0.1;Port=4000;Database=tao_iot;Uid=root;" //Pwd=haiwei@123; } ], "redisConfig": "175.27.215.92:6379,password=redis@2023" diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.dll b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.dll index 2c16aa7..473704a 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.dll and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.dll differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.pdb b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.pdb index 8774e8b..6d7a9c3 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.pdb and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Business.pdb differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.dll b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.dll index 424b132..6c0d761 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.dll and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.dll differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.pdb b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.pdb index 813e160..b442f76 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.pdb and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Model.pdb differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.dll b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.dll index 24c630a..13958c3 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.dll and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.dll differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.pdb b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.pdb index 4f2cb8e..c50464a 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.pdb and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.Repository.pdb differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.dll b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.dll index 7098ad9..35fcbe8 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.dll and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.dll differ diff --git a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.pdb b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.pdb index 108383b..9f4afc0 100644 Binary files a/Sln.Iot/bin/Debug/net6.0/Sln.Iot.pdb and b/Sln.Iot/bin/Debug/net6.0/Sln.Iot.pdb differ diff --git a/Sln.Iot/bin/Debug/net6.0/appsettings.json b/Sln.Iot/bin/Debug/net6.0/appsettings.json index 590362b..c3c9792 100644 --- a/Sln.Iot/bin/Debug/net6.0/appsettings.json +++ b/Sln.Iot/bin/Debug/net6.0/appsettings.json @@ -11,10 +11,10 @@ "connStr": "Host=175.27.215.92;Port=6030;Username=root;Password=taosdata;Database=db_hwmes" }, { - "configId": "tao_iot", //tao:青岛胶东机场简称 - "dbType": 1, + "configId": "tao_iot", //tao:青岛胶东机场简称 + "dbType": 0, //tidb按照 mysql 去连接 "isFlag": true, - "connStr": "server=119.45.202.115;Database=jdap_ems;Uid=sa;Pwd=haiwei@123;Encrypt=True;TrustServerCertificate=True" + "connStr": "server=127.0.0.1;Port=4000;Database=tao_iot;Uid=root;" //Pwd=haiwei@123; } ], "redisConfig": "175.27.215.92:6379,password=redis@2023" diff --git a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.csproj.AssemblyReference.cache b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.csproj.AssemblyReference.cache index 32ce79c..18f94ba 100644 Binary files a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.csproj.AssemblyReference.cache and b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.csproj.AssemblyReference.cache differ diff --git a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.dll b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.dll index 7098ad9..35fcbe8 100644 Binary files a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.dll and b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.dll differ diff --git a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.pdb b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.pdb index 108383b..9f4afc0 100644 Binary files a/Sln.Iot/obj/Debug/net6.0/Sln.Iot.pdb and b/Sln.Iot/obj/Debug/net6.0/Sln.Iot.pdb differ