|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
|
* 版权所有 (c) 2025 WenJY 保留所有权利。
|
|
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
|
|
* 机器名称:Mr.Wen's MacBook Pro
|
|
|
|
|
* 命名空间:Sln.Iot.Repository.service.Impl
|
|
|
|
|
* 唯一标识:C914F6F6-C7CC-4DDC-B061-C89A15419EF0
|
|
|
|
|
*
|
|
|
|
|
* 创建者:WenJY
|
|
|
|
|
* 电子邮箱:
|
|
|
|
|
* 创建时间:2025-04-11 15:44:49
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
* 描述:
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
|
* 修改人:
|
|
|
|
|
* 时间:
|
|
|
|
|
* 修改说明:
|
|
|
|
|
*
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Sln.Iot.Model.dao;
|
|
|
|
|
using Sln.Iot.Repository.service.@base;
|
|
|
|
|
using Sln.Iot.Repository.service.split;
|
|
|
|
|
|
|
|
|
|
namespace Sln.Iot.Repository.service.Impl
|
|
|
|
|
{
|
|
|
|
|
public class RecordIotEnvInstantServiceImpl: BaseServiceImpl<RecordIotEnvInstant>, IRecordIotEnvInstantService
|
|
|
|
|
{
|
|
|
|
|
public RecordIotEnvInstantServiceImpl(Repository<RecordIotEnvInstant> rep) : base(rep)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分表保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
/// <param name="insertIds"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="ArgumentNullException"></exception>
|
|
|
|
|
/// <exception cref="InvalidOperationException"></exception>
|
|
|
|
|
public bool SplitInsert(List<RecordIotEnvInstant> list,out List<long> insertIds)
|
|
|
|
|
{
|
|
|
|
|
if (list == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException($"参数为空");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// _rep.AsTenant().BeginTran();
|
|
|
|
|
|
|
|
|
|
var sqlSugarClient = _rep.Context;
|
|
|
|
|
//加载指定分表策略
|
|
|
|
|
//sqlSugarClient.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService = new MonitorIdToSplitService();
|
|
|
|
|
insertIds = sqlSugarClient.Insertable(list).SplitTable().ExecuteReturnSnowflakeIdList();
|
|
|
|
|
|
|
|
|
|
// _rep.AsTenant().CommitTran();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
// _rep.AsTenant().RollbackTran();
|
|
|
|
|
throw new InvalidOperationException($"物联网数据分表保存异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|