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.

150 lines
6.2 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using Entity.ViewModels;
  4. using SqlSugar;
  5. using SqlSugar.Base;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. namespace EasyBL.WEBAPP.EIP
  10. {
  11. public class CheckFlow_QryService : ServiceBase
  12. {
  13. #region 簽核流程分頁查詢
  14. /// <summary>
  15. /// 簽核流程分頁查詢
  16. /// </summary>
  17. /// <param name="i_crm"></param>
  18. /// <returns></returns>
  19. public ResponseMessage QueryPage(RequestMessage i_crm)
  20. {
  21. ResponseMessage rm = null;
  22. string sMsg = null;
  23. var db = SugarBase.GetIntance();
  24. try
  25. {
  26. do
  27. {
  28. var pml = new PageModel
  29. {
  30. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  31. PageSize = _fetchInt(i_crm, @"pageSize")
  32. };
  33. var iPageCount = 0;
  34. var sSortField = _fetchString(i_crm, @"sortField") ?? "ModifyDate";
  35. var sSortOrder = _fetchString(i_crm, @"sortOrder") ?? "desc";
  36. var sFlow_Type = _fetchString(i_crm, @"Flow_Type") ?? "";
  37. var sFlow_Name = _fetchString(i_crm, @"Flow_Name");
  38. var sFlows = _fetchString(i_crm, @"Flows") ?? "";
  39. var bExcel = _fetchBool(i_crm, @"Excel");
  40. pml.DataList = db.Queryable<OTB_EIP_CheckFlow, OTB_SYS_Members, OTB_SYS_Members, OTB_SYS_Arguments>
  41. ((t1, t2, t3, t4) =>
  42. new object[] {
  43. JoinType.Inner, t1.OrgID == t2.OrgID && t1.Handle_Person == t2.MemberID,
  44. JoinType.Inner, t1.OrgID == t3.OrgID && t1.ModifyUser == t3.MemberID,
  45. JoinType.Inner, t1.OrgID == t4.OrgID && t1.Flow_Type == t4.ArgumentID && t4.ArgumentClassID == "Flow_Type"
  46. }
  47. )
  48. .Where((t1, t2, t3, t4) => t1.OrgID == i_crm.ORIGID)
  49. .WhereIF(!string.IsNullOrEmpty(sFlows), (t1, t2, t3, t4) => t1.Flows.Contains(sFlows))
  50. .WhereIF(!string.IsNullOrEmpty(sFlow_Name), (t1, t2, t3, t4) => t1.Flow_Name.Contains(sFlow_Name))
  51. .WhereIF(!string.IsNullOrEmpty(sFlow_Type), (t1, t2, t3, t4) => t1.Flow_Type == sFlow_Type)
  52. .Select((t1, t2, t3, t4) => new View_EIP_CheckFlow
  53. {
  54. Guid = SqlFunc.GetSelfAndAutoFill(t1.Guid),
  55. Handle_PersonName = t2.MemberName,
  56. ModifyUserName = t3.MemberName,
  57. Flow_TypeName = t4.ArgumentValue
  58. })
  59. .MergeTable()
  60. .OrderBy(sSortField, sSortOrder)
  61. .ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
  62. pml.Total = iPageCount;
  63. rm = new SuccessResponseMessage(null, i_crm);
  64. if (bExcel)
  65. {
  66. }
  67. else
  68. {
  69. rm.DATA.Add(BLWording.REL, pml);
  70. }
  71. } while (false);
  72. }
  73. catch (Exception ex)
  74. {
  75. sMsg = Util.GetLastExceptionMsg(ex);
  76. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.EIP.CheckFlow_QryService", "", "QueryPage(簽核流程分頁查詢)", "", "", "");
  77. }
  78. finally
  79. {
  80. if (null != sMsg)
  81. {
  82. rm = new ErrorResponseMessage(sMsg, i_crm);
  83. }
  84. }
  85. return rm;
  86. }
  87. #endregion 簽核流程分頁查詢
  88. #region 簽核流程筆查詢
  89. /// <summary>
  90. /// 簽核流程筆查詢
  91. /// </summary>
  92. /// <param name="i_crm"></param>
  93. /// <returns></returns>
  94. public ResponseMessage QueryOne(RequestMessage i_crm)
  95. {
  96. ResponseMessage rm = null;
  97. string sMsg = null;
  98. var db = SugarBase.GetIntance();
  99. try
  100. {
  101. do
  102. {
  103. var sId = _fetchString(i_crm, @"Guid");
  104. var oInvoiceApplyInfo = db.Queryable<OTB_EIP_CheckFlow, OTB_SYS_Members, OTB_SYS_Members, OTB_SYS_Arguments>
  105. ((t1, t2, t3, t4) =>
  106. new object[] {
  107. JoinType.Inner, t1.OrgID == t2.OrgID && t1.Handle_Person == t2.MemberID,
  108. JoinType.Inner, t1.OrgID == t3.OrgID && t1.ModifyUser == t3.MemberID,
  109. JoinType.Inner, t1.OrgID == t4.OrgID && t1.Flow_Type == t4.ArgumentID && t4.ArgumentClassID == "Flow_Type"
  110. }
  111. )
  112. .Where((t1, t2, t3, t4) => t1.OrgID == i_crm.ORIGID && t1.Guid == sId)
  113. .Select((t1, t2, t3, t4) => new View_EIP_CheckFlow
  114. {
  115. Guid = SqlFunc.GetSelfAndAutoFill(t1.Guid),
  116. Handle_PersonName = t2.WenZhongAcount,
  117. ModifyUserName = t3.MemberName,
  118. Flow_TypeName = t4.ArgumentValue
  119. }).Single();
  120. rm = new SuccessResponseMessage(null, i_crm);
  121. rm.DATA.Add(BLWording.REL, oInvoiceApplyInfo);
  122. } while (false);
  123. }
  124. catch (Exception ex)
  125. {
  126. sMsg = Util.GetLastExceptionMsg(ex);
  127. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.EIP.CheckFlow_QryService", "", "QueryOne(簽核流程筆查詢)", "", "", "");
  128. }
  129. finally
  130. {
  131. if (null != sMsg)
  132. {
  133. rm = new ErrorResponseMessage(sMsg, i_crm);
  134. }
  135. }
  136. return rm;
  137. }
  138. #endregion 簽核流程筆查詢
  139. }
  140. }