FdcSystemGroup.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WebAPIBase.NetCore.BusinessCore
  8. {
  9. public class FdcSystemGroup : IComparable<FdcSystemGroup>
  10. {
  11. public static string SaHouseTypeClassCode = "670201";
  12. public static string SaMarketPlanTypeClassCode = "670203";
  13. public static string SaComplaintType = "670202";
  14. public static string BalanceMode = "670204";
  15. public static string SaComplaintFault = "670205";
  16. public string GroupCode;
  17. public string ClassCode;
  18. public string ParentCode;
  19. public string FullId;
  20. public string SortId;
  21. public string Deep;
  22. private string[] fullIdList;
  23. public string GroupName;
  24. protected string fullName = null;
  25. public List<FdcSystemGroup> Children = new List<FdcSystemGroup>();
  26. private FdcUnitStructure fus;
  27. public string FullName
  28. {
  29. get
  30. {
  31. if (fullName == null)
  32. {
  33. if (ParentCode == null || ParentCode == "")
  34. {
  35. fullName = "";
  36. }
  37. else
  38. {
  39. string text = fus.GetGroupByCode(ParentCode).FullName;
  40. if (text != "")
  41. {
  42. fullName = text + "->" + GroupName;
  43. }
  44. else
  45. {
  46. fullName = GroupName;
  47. }
  48. }
  49. }
  50. return fullName;
  51. }
  52. }
  53. internal FdcSystemGroup(FdcUnitStructure _fus, string groupcode, string classcode, string parentcode, string fullid, string groupname)
  54. {
  55. fus = _fus;
  56. GroupCode = groupcode;
  57. ClassCode = classcode;
  58. ParentCode = parentcode;
  59. FullId = fullid;
  60. GroupName = groupname;
  61. fullIdList = FullId.Split('-');
  62. }
  63. public bool isMyParent(FdcSystemGroup parentGroup)
  64. {
  65. if (FullId.IndexOf(parentGroup.GroupCode) >= 0)
  66. {
  67. return true;
  68. }
  69. return false;
  70. }
  71. public bool isMyParent(string parentGroupCode)
  72. {
  73. if (FullId.IndexOf(parentGroupCode) >= 0)
  74. {
  75. return true;
  76. }
  77. return false;
  78. }
  79. public bool isMyChild(FdcSystemGroup childGroup)
  80. {
  81. if (childGroup.isMyParent(this))
  82. {
  83. return true;
  84. }
  85. return false;
  86. }
  87. public bool isMyChild(string childGroupCode)
  88. {
  89. FdcSystemGroup groupByCode = fus.GetGroupByCode(childGroupCode);
  90. if (groupByCode == null)
  91. {
  92. return false;
  93. }
  94. return isMyChild(groupByCode);
  95. }
  96. internal void GetChild2List(List<FdcSystemGroup> children)
  97. {
  98. if (children.Contains(this))
  99. {
  100. return;
  101. }
  102. children.Add(this);
  103. foreach (FdcSystemGroup child in Children)
  104. {
  105. child.GetChild2List(children);
  106. }
  107. }
  108. public static string GetChildList(string groupCode)
  109. {
  110. FdcSystemGroup groupByCode = FdcUnitStructure.Instance.GetGroupByCode(groupCode);
  111. if (groupByCode == null)
  112. {
  113. return "";
  114. }
  115. StringBuilder stringBuilder = new StringBuilder();
  116. List<FdcSystemGroup> list = new List<FdcSystemGroup>();
  117. groupByCode.GetChild2List(list);
  118. foreach (FdcSystemGroup item in list)
  119. {
  120. if (stringBuilder.Length > 0)
  121. {
  122. stringBuilder.Append(",");
  123. }
  124. stringBuilder.Append(item.GroupCode);
  125. }
  126. return stringBuilder.ToString();
  127. }
  128. public static FdcSystemGroup GetSystemGroupRootByClass(string classCode)
  129. {
  130. foreach (DictionaryEntry item in FdcUnitStructure.Instance.GroupTree)
  131. {
  132. FdcSystemGroup fdcSystemGroup = item.Value as FdcSystemGroup;
  133. if (fdcSystemGroup.ClassCode == classCode && fdcSystemGroup.ParentCode == "")
  134. {
  135. return fdcSystemGroup;
  136. }
  137. }
  138. return null;
  139. }
  140. int IComparable<FdcSystemGroup>.CompareTo(FdcSystemGroup other)
  141. {
  142. int num = int.Parse(GroupCode);
  143. int num2 = int.Parse(other.GroupCode);
  144. if (num > num2)
  145. {
  146. return 1;
  147. }
  148. if (num == num2)
  149. {
  150. return 0;
  151. }
  152. return -1;
  153. }
  154. }
  155. }