|
|
#region << 版 本 注 释 >>
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2025 WenJY 保留所有权利。
|
|
|
* CLR版本:4.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}");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |