ningshuxia
2022-08-19 153da1eef16b51d75442779a3964a1c5413132e4
Service/IStation.Service4Product/product_modify_record/ProductModifyRecord.cs
@@ -36,38 +36,34 @@
        internal void UpdateCorpCache(long CorpID, long ID)
        {
            var dal = new DAL.ProductModifyRecord();
            var entity_ds = dal.GetByID(CorpID, ID);
            var model_ds = Entity2Model(entity_ds);
            var entity = dal.GetByID(CorpID, ID);
            var model = Entity2Model(entity);
            var all = GetCorpCache(CorpID);
            var model = all.Find(x => x.ID == ID);
            if (model == null)
            all.RemoveAll(x=>x.ID==ID);
            if (model != null)
            {
                all.Add(model_ds);
            }
            else
            {
                model.Reset(model_ds);
                all.Add(model);
            }
        }
        //通过 Ids 更新缓存
        private void UpdateCorpCache(long CorpID, List<long> Ids)
        internal void UpdateCorpCache(long CorpID, List<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return;
            var dal = new DAL.ProductModifyRecord();
            var entity_list = dal.GetByIds(CorpID, Ids);
            var model_list = Entity2Models(entity_list);
            var entityList = dal.GetByIds(CorpID, Ids);
            var modelList = Entity2Models(entityList);
            var all = GetCorpCache(CorpID);
            all.RemoveAll(x => Ids.Contains(x.ID));
            if (model_list != null && model_list.Count > 0)
            if (modelList != null && modelList.Count > 0)
            {
                all.AddRange(model_list);
                all.AddRange(modelList);
            }
        }
        //通过 ID 移除缓存
        private void RemoveCorpCache(long CorpID, long ID)
        internal void RemoveCorpCache(long CorpID, long ID)
        {
            var all = GetCorpCache(CorpID);
            all.RemoveAll(x => x.ID == ID);
@@ -98,7 +94,7 @@
        /// <summary>
        /// 通过 Ids 获取
        /// </summary>
        public List<Model.ProductModifyRecord> GetByIds(long CorpID, List<long> Ids)
        public List<Model.ProductModifyRecord> GetByIds(long CorpID, IEnumerable<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return default;
@@ -159,7 +155,6 @@
            return false;
        }
        #endregion
        #region Update
@@ -198,8 +193,8 @@
            if (list.ToList().Exists(x => x.ID < 1))
                return default;
            var dal = new DAL.ProductModifyRecord();
            var entity_list = Model2Entities(list.ToList());
            var bol = dal.Updates(entity_list);
            var entityList = Model2Entities(list.ToList());
            var bol = dal.Updates(entityList);
            if (bol)
            {
                UpdateCorpCache(corpIds[0], list.Select(x => x.ID).ToList());