You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompanyController.cs 5.8 KiB

4 years ago
2 years ago
4 years ago
4 years ago
4 years ago
2 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using Learun.Application.Organization;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.Util;
  4. using Learun.Util.Operat;
  5. using System.Linq;
  6. using System.Web.Mvc;
  7. namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创建人:陈彬彬
  13. /// 日 期:2017.03.09
  14. /// 描 述:公司管理
  15. /// </summary>
  16. public class CompanyController : MvcControllerBase
  17. {
  18. private CompanyIBLL companyIBLL = new CompanyBLL();
  19. private ArrangeLessonSyncIBLL arrangeLessonSyncIBLL = new ArrangeLessonSyncBLL();
  20. #region 获取视图
  21. /// <summary>
  22. /// 主页
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult Index()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 表单
  32. /// </summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult Form()
  36. {
  37. return View();
  38. }
  39. #endregion
  40. #region 获取数据
  41. /// <summary>
  42. /// 获取公司列表信息
  43. /// </summary>
  44. /// <param name="keyword">查询关键字</param>
  45. /// <returns></returns>
  46. [HttpGet]
  47. [AjaxOnly]
  48. public ActionResult GetList(string keyword)
  49. {
  50. var data = companyIBLL.GetList(keyword);
  51. foreach (var item in data)
  52. {
  53. item.F_BriefIntroduction = WebHelper.HtmlDecode(item.F_BriefIntroduction);
  54. item.F_EnrollmentInformation = WebHelper.HtmlDecode(item.F_EnrollmentInformation);
  55. }
  56. return JsonResult(data);
  57. }
  58. /// <summary>
  59. /// 获取树形数据
  60. /// </summary>
  61. /// <param name="parentId">父级id</param>
  62. /// <returns></returns>
  63. [HttpGet]
  64. [AjaxOnly]
  65. public ActionResult GetTree(string parentId)
  66. {
  67. var data = companyIBLL.GetTree(parentId);
  68. return JsonResult(data);
  69. }
  70. /// <summary>
  71. /// 获取映射数据
  72. /// </summary>
  73. /// <returns></returns>
  74. [HttpGet]
  75. [AjaxOnly]
  76. public ActionResult GetMap(string ver)
  77. {
  78. var data = companyIBLL.GetModelMap();
  79. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  80. if (md5 == ver)
  81. {
  82. return Success("no update");
  83. }
  84. else
  85. {
  86. var jsondata = new
  87. {
  88. data = data,
  89. ver = md5
  90. };
  91. return JsonResult(jsondata);
  92. }
  93. }
  94. #endregion
  95. #region 提交数据
  96. /// <summary>
  97. /// 保存表单数据
  98. /// </summary>
  99. /// <param name="keyValue">主键</param>
  100. /// <param name="entity">实体数据</param>
  101. /// <returns></returns>
  102. [HttpPost]
  103. [ValidateAntiForgeryToken]
  104. [AjaxOnly]
  105. [ValidateInput(false)]
  106. public ActionResult SaveForm(string keyValue, string strEntity)
  107. {
  108. CompanyEntity entity = strEntity.ToObject<CompanyEntity>();
  109. entity.SyncFlag = false;
  110. entity.F_BriefIntroduction = WebHelper.HtmlEncode(entity.F_BriefIntroduction);
  111. entity.F_EnrollmentInformation = WebHelper.HtmlEncode(entity.F_EnrollmentInformation);
  112. var list = companyIBLL.GetList();
  113. if (!string.IsNullOrEmpty(keyValue))
  114. {
  115. entity.SyncFlag = true;
  116. //判断排课同步数据是否存在:若存在,清除同步数据;
  117. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  118. if (arrangeLessonSyncList.Any())
  119. {
  120. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  121. }
  122. else
  123. {
  124. entity.SyncFlag = false;
  125. }
  126. list = list.Where(m => m.F_CompanyId != keyValue).ToList();
  127. }
  128. if (keyValue == entity.F_ParentId)
  129. {
  130. return Fail("操作失败,当前项不允许");
  131. }
  132. if (list.Any(a => a.F_FullName == entity.F_FullName))
  133. {
  134. return Fail("学校名称重复");
  135. }
  136. if (list.Any(a => a.F_EnCode == entity.F_EnCode))
  137. {
  138. return Fail("学校编码重复");
  139. }
  140. if (list.Any(a => a.F_ShortName == entity.F_ShortName))
  141. {
  142. return Fail("学校简称重复");
  143. }
  144. companyIBLL.SaveEntity(keyValue, entity);
  145. return Success("保存成功!", "公司信息", string.IsNullOrEmpty(keyValue) ? OperationType.Create : OperationType.Update, entity.F_CompanyId, entity.ToJson());
  146. }
  147. /// <summary>
  148. /// 删除表单数据
  149. /// </summary>
  150. /// <param name="keyValue">主键</param>
  151. /// <returns></returns>
  152. [HttpPost]
  153. [AjaxOnly]
  154. public ActionResult DeleteForm(string keyValue)
  155. {
  156. var list = companyIBLL.GetList().Where(x => x.F_ParentId == keyValue && x.F_EnabledMark == 1 && x.F_DeleteMark == 0);
  157. if (list.Count() > 0)
  158. {
  159. return Fail("删除失败!拥有下辖项不可直接删除");
  160. }
  161. else
  162. {
  163. companyIBLL.VirtualDelete(keyValue);
  164. return Success("删除成功!", "公司信息", OperationType.Delete, keyValue, "");
  165. }
  166. }
  167. #endregion
  168. }
  169. }