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.
 
 
 
 
 
 

180 lines
6.1 KiB

  1. using System;
  2. using Nancy;
  3. using Learun.Util;
  4. using System.Collections.Generic;
  5. using Learun.Application.TwoDevelopment.LogisticsManagement;
  6. using Learun.Application.TwoDevelopment.AssetManagementSystem;
  7. using Learun.Application.WorkFlow;
  8. namespace Learun.Application.WebApi
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 数字化智慧校园
  12. /// Copyright (c) 2013-2020 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-11-21 10:09
  15. /// 描 述:考勤记录
  16. /// </summary>
  17. public class FundsApplyApi : BaseApi
  18. {
  19. private FundsApplyIBLL fundsApplyIBLL = new FundsApplyBLL();
  20. private FundsApplyDetailIBLL fundsApplyDetailIBLL = new FundsApplyDetailBLL();
  21. private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
  22. /// <summary>
  23. /// 注册接口
  24. /// <summary>
  25. public FundsApplyApi()
  26. : base("/learun/adms/FundsApply")
  27. {
  28. Get["/pagelist"] = GetPageList;
  29. Get["/form"] = GetForm;
  30. Get["/getEnCode"] = GetEnCode;
  31. Post["/delete"] = DeleteForm;
  32. Post["/save"] = SaveForm;
  33. Post["/submit"] = Submit;
  34. Get["/shList"] = GetshList;
  35. }
  36. #region 获取数据
  37. /// <summary>
  38. /// 获取页面显示列表分页数据
  39. /// <summary>
  40. /// <param name="_"></param>
  41. /// <returns></returns>
  42. public Response GetPageList(dynamic _)
  43. {
  44. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  45. var data = fundsApplyIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  46. var jsonData = new
  47. {
  48. rows = data,
  49. total = parameter.pagination.total,
  50. page = parameter.pagination.page,
  51. records = parameter.pagination.records
  52. };
  53. return Success(jsonData);
  54. }
  55. /// <summary>
  56. /// 获取表单数据
  57. /// <summary>
  58. /// <param name="_"></param>
  59. /// <returns></returns>
  60. public Response GetForm(dynamic _)
  61. {
  62. string keyValue = this.GetReqData();
  63. var FundsApplyData = fundsApplyIBLL.GetFundsApplyEntity(keyValue);
  64. var FundsApplyDetailData = fundsApplyDetailIBLL.GetListByApplyId(keyValue);
  65. var jsonData = new
  66. {
  67. FundsApply = FundsApplyData,
  68. FundsApplyDetail = FundsApplyDetailData,
  69. };
  70. return Success(jsonData);
  71. }
  72. /// <summary>
  73. /// 获取申请单号
  74. /// <summary>
  75. /// <param name="_"></param>
  76. /// <returns></returns>
  77. public Response GetEnCode(dynamic _)
  78. {
  79. var jsonData = new
  80. {
  81. EnCode = fundsApplyIBLL.GetCode()
  82. };
  83. return Success(jsonData);
  84. }
  85. /// <summary>
  86. /// 获取页面显示列表数据
  87. /// <summary>
  88. /// <param name="_"></param>
  89. /// <returns></returns>
  90. public Response GetshList(dynamic _)
  91. {
  92. FundsApplyEntity parameter = this.GetReqData<FundsApplyEntity>();
  93. var FundsApplyData = fundsApplyIBLL.GetEntityByProcessId(parameter.ProcessId);
  94. var FundsApplyDetailData = fundsApplyDetailIBLL.GetListByApplyId(FundsApplyData.Id);
  95. var jsonData = new
  96. {
  97. FundsApply = FundsApplyData,
  98. FundsApplyDetail = FundsApplyDetailData,
  99. };
  100. return Success(jsonData);
  101. }
  102. #endregion
  103. #region 提交数据
  104. /// <summary>
  105. /// 删除实体数据
  106. /// <param name="_"></param>
  107. /// <summary>
  108. /// <returns></returns>
  109. public Response DeleteForm(dynamic _)
  110. {
  111. string keyValue = this.GetReqData();
  112. fundsApplyIBLL.DeleteEntity(keyValue);
  113. return Success("删除成功!");
  114. }
  115. /// <summary>
  116. /// 保存实体数据(新增、修改)
  117. /// <param name="_"></param>
  118. /// <summary>
  119. /// <returns></returns>
  120. public Response SaveForm(dynamic _)
  121. {
  122. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  123. FundsApplyEntity entity = parameter.strEntity.ToObject<FundsApplyEntity>();
  124. List<FundsApplyDetailEntity> detailList = parameter.fundsApplyDetailList.ToObject<List<FundsApplyDetailEntity>>();
  125. var code = entity.EnCode;
  126. var savecode = fundsApplyIBLL.SaveCode(entity.EnCode, parameter.keyValue);
  127. entity.EnCode = savecode;
  128. var encode = savecode.Substring(13).ToInt();
  129. if (encode > 99)
  130. {
  131. return Fail("保存失败,经费开支单今日数量已超上限,请您明日编辑!");
  132. }
  133. if (code != entity.EnCode)
  134. {
  135. fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList);
  136. return Success("保存成功,经费开支申报单号已重复,系统已为您自动变更!");
  137. }
  138. fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList);
  139. return Success("保存成功!");
  140. }
  141. /// <summary>
  142. /// 提交
  143. /// <param name="_"></param>
  144. /// <summary>
  145. /// <returns></returns>
  146. public Response Submit(dynamic _)
  147. {
  148. string keyValue = this.GetReqData();
  149. var processId = Guid.NewGuid().ToString();
  150. fundsApplyIBLL.ChangeStatusById(keyValue, 1, processId);
  151. UserInfo userInfo = LoginUserInfo.Get();
  152. nWFProcessIBLL.CreateFlow("LC_FundsApply", processId, "", 1, "", userInfo);
  153. return Success("提交成功!");
  154. }
  155. #endregion
  156. #region 私有类
  157. /// <summary>
  158. /// 表单实体类
  159. /// <summary>
  160. private class ReqFormEntity
  161. {
  162. public string keyValue { get; set; }
  163. public string strEntity { get; set; }
  164. public string fundsApplyDetailList { get; set; }
  165. }
  166. #endregion
  167. }
  168. }