hutongqing
2024-11-27 7ff298c6834275b63b612af49651673689a39660
WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_DictionaryService.cs
@@ -40,7 +40,7 @@
            List<string> cacheDicNos = new List<string>();
            foreach (string n in dicNos)
            {
                string str = _cacheService.Get(n);
                string? str = _cacheService.Get(n);
                if (!string.IsNullOrEmpty(str))
                {
                    VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str);
@@ -54,7 +54,10 @@
            }
            if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0)
            {
                List<VueDictionaryDTO> selectDics = BaseDal.GetDictionaries(dicNos.Where(x => !cacheDicNos.Contains(x))).Select(s => new VueDictionaryDTO
                List<string> list = dicNos.Where(x => !cacheDicNos.Contains(x)).ToList();
                List<Sys_Dictionary> dictionaries = BaseDal.GetDictionaries(list).ToList();
                List<VueDictionaryDTO> selectDics = dictionaries.Select(s => new VueDictionaryDTO
                {
                    DicNo = s.DicNo,
                    Config = s.Config,
@@ -62,9 +65,26 @@
                    Data = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName })
                }).ToList();
                foreach (var v in dictionaries)
                {
                    if (!string.IsNullOrEmpty(v.DBSql))
                    {
                        VueDictionaryDTO? temp = selectDics.FirstOrDefault(x => x.DicNo == v.DicNo);
                        if (temp != null)
                            selectDics.Remove(temp);
                        selectDics.Add(new VueDictionaryDTO
                        {
                            Config = v.Config,
                            DicNo = v.DicNo,
                            Data = BaseDal.QueryDynamicDataBySql(v.DBSql),
                            SaveCache = false,
                        });
                    }
                }
                foreach (var item in selectDics)
                {
                    if (!_cacheService.Exists(item.DicNo))
                    if (!_cacheService.Exists(item.DicNo) && item.SaveCache)
                    {
                        _cacheService.Add(item.DicNo, item.Serialize());
                    }
@@ -72,25 +92,7 @@
                vueDictionaryDTOs.AddRange(selectDics);
            }
            //object GetSourceData(string dicNo, string dbSql, object data)
            //{
            //    if (string.IsNullOrEmpty(dbSql))
            //    {
            //        return data;
            //    }
            //    return BaseDal.QueryObjectDataBySql(dbSql, null);
            //}
            //List<VueDictionaryDTO> vueDictionaryDTOs = dicConfig.Select(item => new VueDictionaryDTO
            //{
            //    DicNo = item.dicNo,
            //    Config = item.config,
            //    Data = GetSourceData(item.dicNo, item.dbSql, item.list)
            //}).ToList();
            return vueDictionaryDTOs;
        }
    }
}