25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

197 satır
7.1 KiB

  1. using Learun.Application.Base.AuthorizeModule;
  2. using Learun.Application.Base.SystemModule;
  3. using Learun.Application.Organization;
  4. using Learun.Application.TwoDevelopment.LogisticsManagement;
  5. using Learun.Application.TwoDevelopment.LR_Desktop;
  6. using Learun.Util;
  7. using Nancy;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Web;
  12. namespace Learun.Application.WebApi
  13. {
  14. /// <summary>
  15. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  16. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  17. /// 创 建:超级管理员
  18. /// 日 期:2020-06-03 14:29
  19. /// 描 述:系部数据
  20. /// </summary>
  21. public class RepairReportStudentApi : BaseApi
  22. {
  23. private RepairReportStudentIBLL repairreportStudentIBLL = new RepairReportStudentBLL();
  24. private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
  25. private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
  26. private DataItemIBLL dataItemIBLL = new DataItemBLL();
  27. private UserIBLL userIbll = new UserBLL();
  28. private RoleIBLL roleIBLL = new RoleBLL();
  29. /// <summary>
  30. /// 注册接口
  31. /// <summary>
  32. public RepairReportStudentApi()
  33. : base("/learun/adms/repairreportStudent")
  34. {
  35. Get["/pagelist"] = GetPageList;
  36. Get["/form"] = GetForm;
  37. Post["/delete"] = DeleteForm;
  38. Post["/save"] = SaveForm;
  39. Post["/submit"] = Submit;
  40. }
  41. #region 获取数据
  42. /// <summary>
  43. /// 获取页面显示列表分页数据
  44. /// <summary>
  45. /// <param name="_"></param>
  46. /// <returns></returns>
  47. public Response GetPageList(dynamic _)
  48. {
  49. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  50. var data = repairreportStudentIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  51. var jsonData = new
  52. {
  53. rows = data,
  54. total = parameter.pagination.total,
  55. page = parameter.pagination.page,
  56. records = parameter.pagination.records
  57. };
  58. return Success(jsonData);
  59. }
  60. /// <summary>
  61. /// 获取表单数据
  62. /// <summary>
  63. /// <param name="_"></param>
  64. /// <returns></returns>
  65. public Response GetForm(dynamic _)
  66. {
  67. string keyValue = this.GetReqData();
  68. var RepairReport_StudentData = repairreportStudentIBLL.GetRepairReport_StudentEntity(keyValue);
  69. var jsonData = new
  70. {
  71. RepairReport_Student = RepairReport_StudentData,
  72. };
  73. return Success(jsonData);
  74. }
  75. #endregion
  76. #region 提交数据
  77. /// <summary>
  78. /// 删除实体数据
  79. /// <param name="_"></param>
  80. /// <summary>
  81. /// <returns></returns>
  82. public Response DeleteForm(dynamic _)
  83. {
  84. string keyValue = this.GetReqData();
  85. repairreportStudentIBLL.DeleteEntity(keyValue);
  86. return Success("删除成功!");
  87. }
  88. /// <summary>
  89. /// 保存实体数据(新增、修改)
  90. /// <param name="_"></param>
  91. /// <summary>
  92. /// <returns></returns>
  93. public Response SaveForm(dynamic _)
  94. {
  95. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  96. RepairReport_StudentEntity entity = parameter.strEntity.ToObject<RepairReport_StudentEntity>();
  97. repairreportStudentIBLL.SaveEntity(parameter.keyValue, entity);
  98. //entity.Status = 2;
  99. if (entity.Status == 2)
  100. {
  101. var model = repairreportStudentIBLL.GetRepairReport_StudentEntity(parameter.keyValue);
  102. //获取所有的维修员账号并添加
  103. var userList = userIbll.GetListByUserIds(model.Creator);
  104. List<DataItemDetailEntity> datalist = dataItemIBLL.GetDetailList("repairtype", "");
  105. string servicevalue = datalist.Where(c => c.F_ItemValue == model.ServiceType).FirstOrDefault().F_ItemName;
  106. string content = "您发起" + model.Address + "-" + servicevalue + "维修请求已处理,请评价。";
  107. addmessagerind(userList, model, content, "评价通知");
  108. }
  109. return Success("保存成功!");
  110. }
  111. /// <summary>
  112. /// 提交
  113. /// <param name="_"></param>
  114. /// <summary>
  115. /// <returns></returns>
  116. public Response Submit(dynamic _)
  117. {
  118. string keyValue = this.GetReqData();
  119. //repairreportStudentIBLL.ModifyStatus(keyValue, 1,"");
  120. //修改状态
  121. repairreportStudentIBLL.ModifyStatus(keyValue, 1, "");
  122. var model = repairreportStudentIBLL.GetRepairReport_StudentEntity(keyValue);
  123. //向所有维修员发消息
  124. string roleid = roleIBLL.GetIdByRoleName("维修角色");
  125. var data = userRelationIBLL.GetUserIdList(roleid);
  126. string userIds = "";
  127. foreach (var item in data)
  128. {
  129. if (userIds != "")
  130. {
  131. userIds += ",";
  132. }
  133. userIds += item.F_UserId;
  134. }
  135. //获取所有的维修员账号并添加
  136. var userList = userIbll.GetListByUserIds(userIds);
  137. List<DataItemDetailEntity> datalist = dataItemIBLL.GetDetailList("repairtype", "");
  138. string servicevalue = datalist.Where(c => c.F_ItemValue == model.ServiceType).FirstOrDefault().F_ItemName;
  139. string content = model.DeptName + model.CreatorName + "发起" + model.Address + "-" + servicevalue + "维修请求。";
  140. addmessagerind(userList, model, content);
  141. return Success("提交成功!");
  142. }
  143. #endregion
  144. #region 私有类
  145. /// <summary>
  146. /// 表单实体类
  147. /// <summary>
  148. private class ReqFormEntity
  149. {
  150. public string keyValue { get; set; }
  151. public string strEntity { get; set; }
  152. public string DetailList { get; set; }
  153. }
  154. #endregion
  155. #region 插入提醒公告
  156. private void addmessagerind(List<UserEntity> userList, RepairReport_StudentEntity model, string content, string title = "维修通知")
  157. {
  158. foreach (var userinfo in userList)
  159. {
  160. //站内通知逻辑
  161. MessageRemindEntity entity = new MessageRemindEntity();
  162. entity.ReceiptId = userinfo.F_UserId;
  163. entity.ReceiptName = userinfo.F_RealName;
  164. entity.SenderId = model.Creator;
  165. entity.SenderName = model.CreatorName;
  166. entity.TheTitle = title;
  167. entity.TheContent = content;
  168. entity.InstanceId = model.ID;
  169. entity.ConnectionUrl = "/LogisticsManagement/RepairReportStudent/FormView?keyValue=";
  170. entity.SendTime = DateTime.Now;
  171. entity.ReadSigns = false;
  172. messageRindIBLL.SaveEntity("", entity);
  173. }
  174. }
  175. #endregion
  176. }
  177. }