| | |
| | | using System.Collections.Generic; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using CommonHelper; |
| | | using CommonHelper.Format; |
| | | using GasolineBlend.Entity; |
| | | using GasolineBlend.Entity.ViewModel; |
| | | using Pissa.Service.Extend; |
| | | using SqlSugar; |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取ipc |
| | | /// </summary> |
| | | /// <param name="param">条件</param> |
| | | /// <returns></returns> |
| | | public List<IviewTree> GetIpcClassTree(ParamIpcTree param) |
| | | { |
| | | var whereList = new List<IConditionalModel>(); |
| | | try |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(param.JsonConditional)) |
| | | whereList = Context.Utilities.JsonToConditionalModels(param.JsonConditional); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception("条件设置错误,请检查"); |
| | | } |
| | | var res = Context.Queryable<SysIpcClass>() |
| | | .Where(a => a.Year == param.Year) |
| | | .Where(whereList) |
| | | .OrderBy(a => a.Sort1).OrderBy(a => a.Sort2) |
| | | .ToList(); |
| | | |
| | | var parents = GetParents<SysIpcClass>(res); |
| | | var treedata = new List<SysIpcClass>(); |
| | | foreach (var sysIpcClass in res.Concat(parents)) |
| | | { |
| | | if(treedata.All(a=>a.Code!=sysIpcClass.Code)) |
| | | treedata.Add(sysIpcClass); |
| | | } |
| | | |
| | | var tree = TreeHelper.GenerateIviewTree(treedata, a => a.Code, |
| | | a => a.ParentCode, |
| | | a => a.Code, |
| | | a => a.Desc).ToList(); |
| | | return tree; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 递归获取当前parentCodes的祖先节点 |
| | | /// </summary> |
| | | /// <typeparam name="T"></typeparam> |
| | | /// <param name="parentCodes"></param> |
| | | /// <returns></returns> |
| | | private List<T> GetParents<T>(List<T> items,List<string> exceptCodes = null) where T:SysDictBase |
| | | { |
| | | exceptCodes = exceptCodes ?? items.Select(a => a.Code).ToList(); |
| | | var list = new List<T>(); |
| | | if (items?.Any(a => !string.IsNullOrWhiteSpace(a.ParentCode)) != true) |
| | | return list; |
| | | var items1 = Context.Queryable<T>().Where(a => items.Select(p=>p.ParentCode).Distinct().Contains(a.Code) && !exceptCodes.Contains(a.Code)).ToList(); |
| | | list.AddRange(items1); |
| | | var pc2 = items1.Where(a => !string.IsNullOrWhiteSpace(a.ParentCode)).ToList(); |
| | | if (pc2.Count() > 0) |
| | | { |
| | | var items2 = GetParents<T>(pc2, exceptCodes).ToList(); |
| | | list.AddRange(items2); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取cpc |
| | | /// </summary> |
| | | /// <param name="parentCode">父编码</param> |
| | |
| | | .ToList(); |
| | | return res; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取ipc |
| | | /// </summary> |
| | | /// <param name="param">条件</param> |
| | | /// <returns></returns> |
| | | public List<IviewTree> GetCpcClassTree(string param) |
| | | { |
| | | var whereList = new List<IConditionalModel>(); |
| | | try |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(param)) |
| | | whereList = Context.Utilities.JsonToConditionalModels(param); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception("条件设置错误,请检查"); |
| | | } |
| | | var res = Context.Queryable<SysCpcClass>() |
| | | .Where(whereList) |
| | | .OrderBy(a => a.Sort1).OrderBy(a => a.Sort2) |
| | | .ToList(); |
| | | |
| | | var parents = GetParents<SysCpcClass>(res); |
| | | var treedata = new List<SysCpcClass>(); |
| | | foreach (var item in res.Concat(parents)) |
| | | { |
| | | if (treedata.All(a => a.Code != item.Code)) |
| | | treedata.Add(item); |
| | | } |
| | | |
| | | var tree = TreeHelper.GenerateIviewTree(treedata, a => a.Code, |
| | | a => a.ParentCode, |
| | | a => a.Code, |
| | | a => a.Desc).ToList(); |
| | | return tree; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 获取产业分类 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<IviewTree> GetStraindustryTree() |
| | | public List<IviewTree> GetStraindustryTree(string param) |
| | | { |
| | | var data = Context.Queryable<SysStraindustry>().OrderBy(a => a.Code).ToList(); |
| | | var tree = TreeHelper.GenerateIviewTree(data, a => a.Code, |
| | | a => a.Code.Contains(".") ? a.Code.Substring(0, a.Code.IndexOf(".")) : null, |
| | | var whereList = new List<IConditionalModel>(); |
| | | try |
| | | { |
| | | if(!string.IsNullOrWhiteSpace(param)) |
| | | whereList = Context.Utilities.JsonToConditionalModels(param); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception("条件设置错误,请检查"); |
| | | } |
| | | var res = Context.Queryable<SysStraindustry>().Where(whereList).OrderBy(a => a.Code).ToList(); |
| | | |
| | | var parents = GetParents<SysStraindustry>(res); |
| | | var treedata = new List<SysStraindustry>(); |
| | | foreach (var item in res.Concat(parents)) |
| | | { |
| | | if (treedata.All(a => a.Code != item.Code)) |
| | | treedata.Add(item); |
| | | } |
| | | |
| | | var tree = TreeHelper.GenerateIviewTree(treedata, a => a.Code, |
| | | a => a.ParentCode, |
| | | a => a.Code, |
| | | a=>a.Name |
| | | ).ToList(); |
| | | a => a.Name).ToList(); |
| | | return tree; |
| | | } |
| | | |
| | |
| | | /// 获取国民经济行业分类 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<IviewTree> GetEcoindustryTree() |
| | | public List<IviewTree> GetEcoindustryTree(string param) |
| | | { |
| | | var data = Context.Queryable<SysEcoindustry>().OrderBy(a=>a.Code).ToList(); |
| | | var tree = TreeHelper.GenerateIviewTree(data, a => a.Code, |
| | | a =>a.Code.Length>3?a.Code.Substring(0,a.Code.Length-1):(a.Code.Length==3?a.Code.Substring(0,1): null), |
| | | |
| | | var whereList = new List<IConditionalModel>(); |
| | | try |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(param)) |
| | | whereList = Context.Utilities.JsonToConditionalModels(param); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception("条件设置错误,请检查"); |
| | | } |
| | | var res = Context.Queryable<SysEcoindustry>().Where(whereList).OrderBy(a=>a.Code).ToList(); |
| | | |
| | | var parents = GetParents<SysEcoindustry>(res); |
| | | var treedata = new List<SysEcoindustry>(); |
| | | foreach (var item in res.Concat(parents)) |
| | | { |
| | | if (treedata.All(a => a.Code != item.Code)) |
| | | treedata.Add(item); |
| | | } |
| | | |
| | | var tree = TreeHelper.GenerateIviewTree(treedata, a => a.Code, |
| | | a => a.ParentCode, |
| | | a => a.Code, |
| | | a => a.Name).ToList(); |
| | | return tree; |
| | |
| | | /// 洛迦诺分类 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<IviewTree> GetLoccn() |
| | | public List<IviewTree> GetLoccn(string param) |
| | | { |
| | | var data = Context.Queryable<SysLoccn>().OrderBy(a => a.Sort1).OrderBy(a=>a.Sort2).ToList(); |
| | | var tree = TreeHelper.GenerateIviewTree(data, a => a.Code, |
| | | var whereList = new List<IConditionalModel>(); |
| | | try |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(param)) |
| | | whereList = Context.Utilities.JsonToConditionalModels(param); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception("条件设置错误,请检查"); |
| | | } |
| | | var res = Context.Queryable<SysLoccn>().OrderBy(a => a.Sort1).OrderBy(a=>a.Sort2).ToList(); |
| | | |
| | | var parents = GetParents<SysLoccn>(res); |
| | | var treedata = new List<SysLoccn>(); |
| | | foreach (var item in res.Concat(parents)) |
| | | { |
| | | if (treedata.All(a => a.Code != item.Code)) |
| | | treedata.Add(item); |
| | | } |
| | | |
| | | var tree = TreeHelper.GenerateIviewTree(treedata, a => a.Code, |
| | | a => a.ParentCode, |
| | | a => a.Code, |
| | | a => a.Desc).ToList(); |