duheng
2024-12-24 b826e3716742abba49ab2a851b943ea8328db66e
BLL/HStation.BLL.Assets.Core/03-localclient/06-Elbow/AssetsElbowCoefficient.cs
@@ -1,27 +1,23 @@
using HStation.Dto;
using System.Collections.Generic;
using Yw.Dto;
namespace HStation.CAL.LocalClient
namespace HStation.CAL.LocalClient
{
    /// <summary>
    /// 报警等级
    /// 换热器系数
    /// </summary>
    public class AssetsElbowCoefficient : IAssetsElbowCoefficient
    public class AssetsElbowFactor : IAssetsElbowFactor
    {
        private readonly HStation.Service.AssetsElbowCoefficient _service = new();
        private readonly HStation.Service.AssetsElbowFactor _service = new();
        #region Query
        /// <summary>
        /// 获取所有
        /// </summary>
        public async Task<List<AssetsElbowCoefficientDto>> GetAll()
        public async Task<List<AssetsElbowFactorDto>> GetAll()
        {
            return await Task.Factory.StartNew(() =>
            {
                var list = _service.GetAll();
                var vm_list = list?.Select(x => new AssetsElbowCoefficientDto(x)).ToList();
                var vm_list = list?.Select(x => new AssetsElbowFactorDto(x)).ToList();
                return vm_list;
            });
        }
@@ -29,40 +25,43 @@
        /// <summary>
        /// 通过 ID 获取
        /// </summary>
        public async Task<AssetsElbowCoefficientDto> GetByID(long ID)
        public async Task<AssetsElbowFactorDto> GetByID(long ID)
        {
            return await Task.Factory.StartNew(() =>
            {
                var model = _service.GetByID(ID);
                return model == null ? null : new AssetsElbowCoefficientDto(model);
                return model == null ? null : new AssetsElbowFactorDto(model);
            });
        }
        /// <summary>
        /// 通过 Ids 获取
        /// </summary>
        public async Task<List<AssetsElbowCoefficientDto>> GetByIds(List<long> Ids)
        public async Task<List<AssetsElbowFactorDto>> GetByIds(List<long> Ids)
        {
            return await Task.Factory.StartNew(() =>
            {
                var list = _service.GetByIds(Ids);
                var vm_list = list?.Select(x => new AssetsElbowCoefficientDto(x)).ToList();
                var vm_list = list?.Select(x => new AssetsElbowFactorDto(x)).ToList();
                return vm_list;
            });
        }
        #endregion Query
        #region Insert
        /// <summary>
        /// 插入一条
        /// </summary>
        public async Task<long> Insert(AddAssetsElbowCoefficientInput input)
        public async Task<long> Insert(AddAssetsElbowFactorInput input)
        {
            return await Task.Factory.StartNew(() =>
            {
                var model = input.Adapt<AddAssetsElbowCoefficientInput, Model.AssetsElbowFactor>();
                var model = input.Adapt<AddAssetsElbowFactorInput, Model.AssetsElbowFactor>();
                model.SortCode = _service.GetMaxSortCode() + 1;
                var id = _service.Insert(model);
                return id;
            });
@@ -71,20 +70,7 @@
        /// <summary>
        /// 批量插入
        /// </summary>
        public async Task<bool> Inserts(List<AddAssetsElbowCoefficientInput> inputList)
        {
            return await Task.Factory.StartNew(() =>
            {
                var list = inputList.Select(x => x.Adapt<AddAssetsElbowCoefficientInput, Model.AssetsElbowFactor>()).ToList();
                var bol = _service.Inserts(list);
                return bol;
            });
        }
        /// <summary>
        /// 大批量插入
        /// </summary>
        public async Task<bool> BulkInserts(List<AddAssetsElbowCoefficientInput> list)
        public async Task<bool> Inserts(List<AddAssetsElbowFactorInput> inputList)
        {
            return await Task.Factory.StartNew(() =>
            {
@@ -92,22 +78,16 @@
            });
        }
        /*       /// <summary>
               /// 更新默认值状态
               /// </summary>
               public async Task<bool> UpdateDefaultStatus(long ID, bool status)
               {
                   return await Task.Factory.StartNew(() =>
                   {
                       var model = _service.GetByID(ID);
                       if (model == null)
                       {
                           throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{ID} 数据不存在");
                       }
                       var bol = _service.UpdateDefaultStatus(ID, status);
                       return bol;
                   });
               }*/
        /// <summary>
        /// 大批量插入
        /// </summary>
        public async Task<bool> BulkInserts(List<AddAssetsElbowFactorInput> list)
        {
            return await Task.Factory.StartNew(() =>
            {
                return false;
            });
        }
        #endregion Insert
@@ -116,7 +96,7 @@
        /// <summary>
        /// 更新一条
        /// </summary>
        public async Task<bool> Update(UpdateAssetsElbowCoefficientInput input)
        public async Task<bool> Update(UpdateAssetsElbowFactorInput input)
        {
            return await Task.Factory.StartNew(() =>
            {
@@ -125,7 +105,6 @@
                {
                    throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
                }
                var rhs = new Model.AssetsElbowFactor(model);
                input.Adapt(rhs);
                var bol = _service.Update(rhs);
@@ -136,24 +115,18 @@
        /// <summary>
        /// 批量更新
        /// </summary>
        public async Task<bool> Updates(List<UpdateAssetsElbowCoefficientInput> inputList)
        public async Task<bool> Updates(List<UpdateAssetsElbowFactorInput> inputList)
        {
            return await Task.Factory.StartNew(() =>
            {
                if (inputList == null || inputList.Count < 1)
                {
                    return false;
                }
                var list = inputList.Select(x => x.Adapt<UpdateAssetsElbowCoefficientInput, Model.AssetsElbowFactor>()).ToList();
                var bol = _service.Updates(list);
                return bol;
                return false;
            });
        }
        /// <summary>
        /// 大批量更新
        /// </summary>
        public async Task<bool> BulkUpdates(List<UpdateAssetsElbowCoefficientInput> list)
        public async Task<bool> BulkUpdates(List<UpdateAssetsElbowFactorInput> list)
        {
            return await Task.Factory.StartNew(() =>
            {
@@ -162,13 +135,27 @@
        }
        /// <summary>
        /// 更新编码
        /// 更新排序码
        /// </summary>
        public async Task<bool> UpdateCode(long ID, string Code)
        public async Task<bool> UpdateSortCode(long ID, int SortCode)
        {
            return await Task.Factory.StartNew(() =>
            {
                return false;
                var bol = _service.UpdateSortCode(ID, SortCode);
                return bol;
            });
        }
        /// <summary>
        /// 更新排序
        /// </summary>
        public async Task<bool> UpdateSorter(List<UpdateSortCodeInput> inputList)
        {
            return await Task.Factory.StartNew(() =>
            {
                var list = inputList.Select(x => x.Adapt<Yw.Model.Sorter>()).ToList();
                var bol = _service.UpdateSorter(list);
                return bol;
            });
        }
@@ -211,11 +198,11 @@
        {
            return await Task.Factory.StartNew(() =>
            {
                var bol = _service.DeleteAll();
                return bol;
                return false;
            });
        }
        #endregion Delete
    }
}