ACLAuthorize.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System;
  2. using System.Data;
  3. using System.Collections.Generic;
  4. using WMS.Info;
  5. using WMS.Util;
  6. using SqlSugar;
  7. namespace WMS.Core
  8. {
  9. /// <summary>
  10. /// 描 述:权限分配
  11. /// </summary>
  12. public class ACLAuthorize
  13. {
  14. public const string ALLAuthorize = "7DC7155C4A674050BD591CF74B800958";
  15. public const string IcoAuthorize = "fa fa-align-justify";
  16. /// <summary>
  17. /// 获取按钮列表树形数据(基于WebApp)
  18. /// </summary>
  19. /// <returns></returns>
  20. public List<TreeModel> GetWebAppTree()
  21. {
  22. try
  23. {
  24. List<ACL_ACLCONST> list = SysDbCore.GetDbCtx().Queryable<ACL_ACLCONST>().Where(it => it.F_APPTYPENUM == (int)EAppType.PC).ToList();
  25. List<TreeModel> WebAppTree = new List<TreeModel>();
  26. foreach (var webitem in list)
  27. {
  28. TreeModel node = new TreeModel();
  29. node.id = webitem.F_NO;
  30. node.text = webitem.F_NAME;
  31. node.value = webitem.F_NO;
  32. node.showcheck = true;
  33. node.checkstate = 0;
  34. node.isexpand = true;
  35. node.icon = ACLAuthorize.IcoAuthorize;
  36. node.parentId = webitem.F_PNO;
  37. WebAppTree.Add(node);
  38. }
  39. return WebAppTree.ToTree();
  40. }
  41. catch (Exception ex)
  42. {
  43. throw ex;
  44. }
  45. }
  46. /// <summary>
  47. /// 获取按钮列表树形数据(基于OnLineRFApp)
  48. /// </summary>
  49. /// <returns></returns>
  50. public List<TreeModel> GetOnLineRFTree()
  51. {
  52. List<ACL_ACLCONST> list = SysDbCore.GetDbCtx().Queryable<ACL_ACLCONST>().Where(it => it.F_APPTYPENUM == (int)EAppType.OnLineRF).ToList();
  53. List<TreeModel> OnRFAppTree = new List<TreeModel>();
  54. foreach (var OnRFitem in list)
  55. {
  56. TreeModel node = new TreeModel();
  57. node.id = OnRFitem.F_NO;
  58. node.text = OnRFitem.F_NAME;
  59. node.value = OnRFitem.F_NO;
  60. node.showcheck = true;
  61. node.checkstate = 0;
  62. node.isexpand = true;
  63. node.icon = ACLAuthorize.IcoAuthorize;
  64. node.parentId = OnRFitem.F_PNO;
  65. OnRFAppTree.Add(node);
  66. }
  67. return OnRFAppTree.ToTree();
  68. }
  69. public List<string> GetItemIdList(string objectNo, EACLType eACLType, EACLObjType eACLObjType)
  70. {
  71. try
  72. {
  73. return SysDbCore.GetDbCtx().Queryable<ACL_AUTHORIZE>().Where(it => it.F_OBJNO == objectNo && it.F_ACLTYPENUM == (int)eACLType && it.F_OBJTYPENUM == (int)eACLObjType).Select(it => it.F_ITEMNO).ToList();
  74. }
  75. catch (Exception ex)
  76. {
  77. throw ex;
  78. }
  79. }
  80. public void Authorize(AuthorizeInfo authorize)
  81. {
  82. try
  83. {
  84. void action(SqlSugarClient ctx)
  85. {
  86. ctx.Deleteable<ACL_AUTHORIZE>().Where(it => it.F_OBJNO == authorize.ObjectNo && it.F_OBJTYPENUM == (int)authorize.ObjTypeNum).ExecuteCommand();
  87. if (authorize.WarehouseList != null)
  88. {
  89. foreach (var item in authorize.WarehouseList)
  90. {
  91. if (item == ACLAuthorize.ALLAuthorize)
  92. {
  93. continue;
  94. }
  95. if (item.Contains(BaseWarehouse.WarehouseHead))
  96. {
  97. continue;
  98. }
  99. ACL_AUTHORIZE insobj = new ACL_AUTHORIZE()
  100. {
  101. F_OBJTYPENUM = (int)authorize.ObjTypeNum,
  102. F_ITEMNO = item,
  103. F_NO = Guid.NewGuid().ToString(),
  104. F_OBJNO = authorize.ObjectNo,
  105. F_ACLTYPENUM = (int)EACLType.Warehouse
  106. };
  107. ctx.Insertable<ACL_AUTHORIZE>(insobj).ExecuteCommand();
  108. }
  109. }
  110. if (authorize.WebAppNoList != null)
  111. {
  112. foreach (var item in authorize.WebAppNoList)
  113. {
  114. ACL_AUTHORIZE insobj = new ACL_AUTHORIZE()
  115. {
  116. F_OBJTYPENUM = (int)authorize.ObjTypeNum,
  117. F_ITEMNO = item,
  118. F_NO = Guid.NewGuid().ToString(),
  119. F_OBJNO = authorize.ObjectNo,
  120. F_ACLTYPENUM = (int)EACLType.WebApp
  121. };
  122. ctx.Insertable<ACL_AUTHORIZE>(insobj).ExecuteCommand();
  123. }
  124. }
  125. if (authorize.OnlineRFNoList != null)
  126. {
  127. foreach (var item in authorize.OnlineRFNoList)
  128. {
  129. ACL_AUTHORIZE insobj = new ACL_AUTHORIZE()
  130. {
  131. F_OBJTYPENUM = (int)authorize.ObjTypeNum,
  132. F_ITEMNO = item,
  133. F_NO = Guid.NewGuid().ToString(),
  134. F_OBJNO = authorize.ObjectNo,
  135. F_ACLTYPENUM = (int)EACLType.OnlineRF
  136. };
  137. ctx.Insertable<ACL_AUTHORIZE>(insobj).ExecuteCommand();
  138. }
  139. }
  140. };
  141. SysDbCore.DbTranExec(action);
  142. }
  143. catch (Exception ex)
  144. {
  145. throw ex;
  146. }
  147. }
  148. public Dictionary<string, V_WMS_AUTHORIZE> GetAuthorize(LoginUserInfo loginUser)
  149. {
  150. try
  151. {
  152. Dictionary<string, V_WMS_AUTHORIZE> dics = new Dictionary<string, V_WMS_AUTHORIZE>();
  153. if (loginUser.UserType == EUserType.User)
  154. {
  155. SysDbCore.GetDbCtx().Queryable<V_WMS_AUTHORIZE>().Where(it => it.USERNO == loginUser.UserNo && it.ACLTYPENUM == (int)EACLType.WebApp).ToList().ForEach(it => dics.Add(it.ITEMNO, it));
  156. }
  157. return dics;
  158. }
  159. catch (Exception ex)
  160. {
  161. throw ex;
  162. }
  163. }
  164. public ACL_AUTHORIZE GetAuthorizeSupperNo(string queryJson)
  165. {
  166. try
  167. {
  168. var queryParam = queryJson.ToJObject();
  169. if (queryParam["F_NO"].IsEmpty() || queryParam["F_OBJTYPENUM"].IsEmpty() || queryParam["F_ACLTYPENUM"].IsEmpty())
  170. {
  171. throw SysExCore.ThrowFailException("参数不全,无法找到所属供应商");
  172. }
  173. int F_OBJTYPENUM = int.Parse(queryParam["F_OBJTYPENUM"].ToString());
  174. int F_ACLTYPENUM = int.Parse(queryParam["F_ACLTYPENUM"].ToString());
  175. var GetE = SysDbCore.GetDbCtx().Queryable<ACL_AUTHORIZE>().Where(v => v.F_OBJNO == queryParam["F_NO"].ToString() && v.F_ACLTYPENUM == F_ACLTYPENUM && v.F_OBJTYPENUM == F_OBJTYPENUM).First();
  176. if(GetE==null)
  177. throw SysExCore.ThrowFailException("所属供应商未赋值");
  178. return GetE;
  179. }
  180. catch (Exception ex)
  181. {
  182. throw SysExCore.ThrowFailException(ex.Message);
  183. }
  184. }
  185. }
  186. }