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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2025 WenJY 保留所有权利。
* CLR版本4.0.30319.42000
* 机器名称Mr.Wen's MacBook Pro
* 命名空间Sln.Iot.Repository.service.Impl
* 唯一标识EF060FA7-6D52-478C-84FF-F26EEC206685
*
* 创建者WenJY
* 电子邮箱:
* 创建时间2025-05-20 11:26:53
* 版本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 RecordDnbInstantServiceImpl: BaseServiceImpl<RecordDnbInstant>, IRecordDnbInstantService
{
public RecordDnbInstantServiceImpl(Repository<RecordDnbInstant> 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<RecordDnbInstant> 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}");
}
}
}
}