You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB
C#

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2025 WenJY
* CLR4.0.30319.42000
* Mr.Wen's MacBook Pro
* Sln.Iot.Repository.service.Impl
* 72B88660-5410-4016-9E12-B1E11841AB4B
*
* WenJY
*
* 2025-05-20 14:47:03
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
using System;
using System.Collections.Generic;
using Sln.Iot.Model.dao;
using Sln.Iot.Repository.service.@base;
namespace Sln.Iot.Repository.service.Impl
{
public class RecordFluidInstantServiceImpl: BaseServiceImpl<RecordFluidInstant>, IRecordFluidInstantService
{
public RecordFluidInstantServiceImpl(Repository<RecordFluidInstant> 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<RecordFluidInstant> 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}");
}
}
}
}