Shuxia Ning
2024-11-08 0cd48df8ccca96a8a0117a508c342a90dc2eacb8
Service/HStation.Service.Assets.Core/05-service/05-Sprinkler/03-AssetsSprinklerCoefficient/AssetsSprinklerCoefficient.cs
copy from Service/HStation.Service.Assets.Core/05-service/08-FourLink/01-FourlinkMain/FourLinkManage.cs copy to Service/HStation.Service.Assets.Core/05-service/05-Sprinkler/03-AssetsSprinklerCoefficient/AssetsSprinklerCoefficient.cs
Îļþ´Ó Service/HStation.Service.Assets.Core/05-service/08-FourLink/01-FourlinkMain/FourLinkManage.cs ¸´ÖÆ
@@ -1,25 +1,23 @@
using HStation.Assets;
namespace HStation.Service
namespace HStation.Service
{
    /// <summary>
    ///
    /// </summary>
    public partial class AssetsFourlinkMain
    public partial class AssetsSprinklerCoefficient
    {
        #region Cache
        //获取缓存
        private static List<Model.AssetsFourlinkMain> GetCache()
        private static List<Model.AssetsSprinklerCoefficient> GetCache()
        {
            var all = AssetsFourlinkMainCacheHelper.GetSet(() =>
            var all = AssetsSprinklerCoefficientCacheHelper.GetSet(() =>
            {
                var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
                var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
                var entity_list = dal.GetAll();
                var model_list = Entity2Models(entity_list);
                if (model_list == null)
                {
                    model_list = new List<Model.AssetsFourlinkMain>();
                    model_list = new List<Model.AssetsSprinklerCoefficient>();
                }
                return model_list;
            }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime);
@@ -29,7 +27,7 @@
        //通过 ID æ›´æ–°ç¼“å­˜
        private static void UpdateCache(long ID)
        {
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var entity_ds = dal.GetByID(ID);
            var model_ds = Entity2Model(entity_ds);
            var all = GetCache();
@@ -42,7 +40,7 @@
            {
                model.Reset(model_ds);
            }
            AssetsPumpSeriesCacheHelper.Trigger();
            AssetsSprinklerCoefficientCacheHelper.Trigger();
        }
        //通过 Ids æ›´æ–°ç¼“å­˜
@@ -52,7 +50,7 @@
            {
                return;
            }
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var entity_list = dal.GetByIds(Ids);
            var model_list = Entity2Models(entity_list);
            var all = GetCache();
@@ -61,7 +59,7 @@
            {
                all.AddRange(model_list);
            }
            AssetsPumpSeriesCacheHelper.Trigger();
            AssetsSprinklerCoefficientCacheHelper.Trigger();
        }
        //移除缓存
@@ -69,7 +67,15 @@
        {
            var all = GetCache();
            all.RemoveAll(x => x.ID == ID);
            AssetsPumpSeriesCacheHelper.Trigger();
            AssetsSprinklerCoefficientCacheHelper.Trigger();
        }
        //移除所有缓存
        private static void RemoveAllCache()
        {
            var all = GetCache();
            all.Clear();
            AssetsSprinklerCoefficientCacheHelper.Trigger();
        }
        /// <summary>
@@ -77,7 +83,7 @@
        /// </summary>
        public static void PublishCache(string key)
        {
            AssetsPumpSeriesCacheHelper.Publish(key);
            AssetsSprinklerCoefficientCacheHelper.Publish(key);
        }
        #endregion Cache
@@ -87,7 +93,7 @@
        /// <summary>
        /// èŽ·å–æ‰€æœ‰
        /// </summary>
        public List<Model.AssetsFourlinkMain> GetAll()
        public List<Model.AssetsSprinklerCoefficient> GetAll()
        {
            var all = GetCache();
            return all;
@@ -96,7 +102,7 @@
        /// <summary>
        /// é€šè¿‡ ID èŽ·å–
        /// </summary>
        public Model.AssetsFourlinkMain GetByID(long ID)
        public Model.AssetsSprinklerCoefficient GetByID(long ID)
        {
            var all = GetAll();
            return all.Find(x => x.ID == ID);
@@ -105,7 +111,7 @@
        /// <summary>
        /// é€šè¿‡ ID èŽ·å–
        /// </summary>
        public List<Model.AssetsFourlinkMain> GetByIds(List<long> Ids)
        public List<Model.AssetsSprinklerCoefficient> GetByIds(List<long> Ids)
        {
            if (Ids == null || Ids.Count < 1)
            {
@@ -115,32 +121,6 @@
            return all.Where(x => Ids.Contains(x.ID)).ToList();
        }
        /// <summary>
        /// é€šè¿‡ ç³»åˆ—ID èŽ·å–
        /// </summary>
        public List<Model.AssetsFourlinkMain> GetBySeriesID(long id)
        {
            if (id < 1)
            {
                return default;
            }
            var all = GetAll();
            return all.Where(x => x.SeriesID == id).ToList();
        }
        /// <summary>
        /// èŽ·å–æœ€å¤§æŽ’åºç 
        /// </summary>
        public int GetMaxSortCode()
        {
            var all = GetAll();
            if (all == null || all.Count < 1)
            {
                return 0;
            }
            return all.Max(x => x.SortCode);
        }
        #endregion Query
        #region Insert
@@ -148,13 +128,13 @@
        /// <summary>
        /// æ’入一条数据
        /// </summary>
        public long Insert(Model.AssetsFourlinkMain model)
        public long Insert(Model.AssetsSprinklerCoefficient model)
        {
            if (model == null)
            {
                return default;
            }
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var entity = Model2Entity(model);
            var id = dal.Insert(entity);
            if (id > 0)
@@ -167,13 +147,13 @@
        /// <summary>
        /// æ’入多条
        /// </summary>
        public bool Inserts(List<Model.AssetsFourlinkMain> list)
        public bool Inserts(List<Model.AssetsSprinklerCoefficient> list)
        {
            if (list == null || list.Count < 1)
            {
                return false;
            }
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var entity_list = Model2Entities(list);
            var ids = dal.InsertsR(entity_list);
            if (ids != null && ids.Count > 0)
@@ -191,35 +171,14 @@
        /// <summary>
        /// æ›´æ–°ä¸€æ¡
        /// </summary>
        public bool Update(Model.AssetsFourlinkMain model)
        public bool Update(Model.AssetsSprinklerCoefficient model)
        {
            if (model == null)
            {
                return false;
            }
            var entity = Model2Entity(model);
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var bol = dal.Update(entity);
            if (bol)
            {
                UpdateCache(model.ID);
            }
            return bol;
        }
        /// <summary>
        /// æ›´æ–°é»˜è®¤å€¼çŠ¶æ€
        /// </summary>
        public bool UpdateDefaultStatus(long ID, bool Status)
        {
            if (ID < 1)
            {
                return false;
            }
            var model = GetByID(ID);
            model.IsDefault = Status;
            var entity = Model2Entity(model);
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var bol = dal.Update(entity);
            if (bol)
            {
@@ -231,7 +190,7 @@
        /// <summary>
        /// æ‰¹é‡æ›´æ–°
        /// </summary>
        public bool Updates(List<Model.AssetsFourlinkMain> list)
        public bool Updates(List<Model.AssetsSprinklerCoefficient> list)
        {
            if (list == null || list.Count < 1)
            {
@@ -242,7 +201,7 @@
                return false;
            }
            var entity_list = Model2Entities(list);
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var bol = dal.Updates(entity_list);
            if (bol)
            {
@@ -261,7 +220,7 @@
        public bool DeleteByID(long ID, out string Msg)
        {
            Msg = string.Empty;
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>();
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var bol = dal.DeleteByID(ID);
            if (bol)
            {
@@ -270,6 +229,17 @@
            return bol;
        }
        public bool DeleteAll()
        {
            var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsSprinklerCoefficient>();
            var bol = dal.DeleteAll();
            if (bol)
            {
                RemoveAllCache();
            }
            return bol;
        }
        #endregion Delete
    }
}