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.

134 lines
5.5 KiB

2 years ago
  1. using Entity.Sugar;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using SqlSugar;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace EasyBL
  11. {
  12. public class SuperAuditor
  13. {
  14. public static bool CheckAuditable()
  15. {
  16. return false;
  17. }
  18. public static OTB_EIP_InvoiceApplyInfo AgreeAll(string strCheckFlows, string SuperAuditor, string Opinion, out List<string> Notification)
  19. {
  20. Notification = new List<string>();
  21. var CheckFlows = (JArray)JsonConvert.DeserializeObject(strCheckFlows);
  22. foreach (var flowInfo in CheckFlows)
  23. {
  24. var SignedDecision = flowInfo["SignedDecision"].ObjToString();
  25. var SignedOpinion = flowInfo["SignedOpinion"].ObjToString();
  26. var SignedDate = flowInfo["SignedDate"].ObjToString();
  27. bool NotSigned = string.IsNullOrWhiteSpace(SignedDecision) || string.IsNullOrWhiteSpace(SignedOpinion) && string.IsNullOrWhiteSpace(SignedDate);
  28. if (NotSigned)
  29. {
  30. flowInfo["SignedOpinion"] = SuperAuditor + "(簽核全部)。意見:" + Opinion;
  31. flowInfo["SignedDate"] = DateTime.Now.ToString("s");
  32. var SignedWay = flowInfo["SignedWay"].ObjToString();
  33. switch (SignedWay)
  34. {
  35. case "flow1":
  36. case "flow2":
  37. case "flow3":
  38. {
  39. flowInfo["SignedDecision"] = "Y";
  40. }
  41. break;
  42. case "flow4":
  43. {
  44. var SignedId = flowInfo["SignedId"].ObjToString();
  45. if(!string.IsNullOrWhiteSpace(SignedId))
  46. {
  47. Notification.Add(SignedId);
  48. }
  49. flowInfo["SignedDecision"] = "R";
  50. }
  51. break;
  52. default:
  53. break;
  54. }
  55. }
  56. }
  57. var ModifiedCheckFlows = JsonConvert.SerializeObject(CheckFlows);
  58. return new OTB_EIP_InvoiceApplyInfo() { Status = "E", CheckFlows = ModifiedCheckFlows, ModifyDate = DateTime.Now, ModifyUser = SuperAuditor };
  59. }
  60. public static OTB_EIP_InvoiceApplyInfo Disagree(string strCheckFlows, string SuperAuditor, string Opinion)
  61. {
  62. var CheckFlows = (JArray)JsonConvert.DeserializeObject(strCheckFlows);
  63. foreach (var flowInfo in CheckFlows)
  64. {
  65. var SignedDecision = flowInfo["SignedDecision"].ObjToString();
  66. var SignedOpinion = flowInfo["SignedOpinion"].ObjToString();
  67. var SignedDate = flowInfo["SignedDate"].ObjToString();
  68. bool NotSigned = string.IsNullOrWhiteSpace(SignedDecision) || string.IsNullOrWhiteSpace(SignedOpinion) && string.IsNullOrWhiteSpace(SignedDate);
  69. if (NotSigned)
  70. {
  71. flowInfo["SignedOpinion"] = SuperAuditor + "(簽核全部)。意見:" + Opinion;
  72. flowInfo["SignedDate"] = DateTime.Now.ToString("s");
  73. var SignedWay = flowInfo["SignedWay"].ObjToString();
  74. switch (SignedWay)
  75. {
  76. case "flow1":
  77. case "flow2":
  78. case "flow3":
  79. {
  80. flowInfo["SignedDecision"] = "N";
  81. }
  82. break;
  83. case "flow4":
  84. {
  85. //flowInfo.SignedDecision = "R";
  86. }
  87. break;
  88. default:
  89. break;
  90. }
  91. }
  92. }
  93. var ModifiedCheckFlows = JsonConvert.SerializeObject(CheckFlows);
  94. return new OTB_EIP_InvoiceApplyInfo() { Status = "D-O", CheckFlows = ModifiedCheckFlows, ModifyDate = DateTime.Now, ModifyUser = SuperAuditor };
  95. }
  96. public static Tuple<string,string> GetNotification(OTB_EIP_InvoiceApplyInfo oEip, OTB_SYS_Members Auditor, OTB_SYS_Members Applicant, bool Decision = true)
  97. {
  98. var PayeeType = GetPayeeName(oEip.PayeeType);
  99. var AuditorNotification = Auditor.MemberName + @"審批了" + Applicant.MemberName + "的"+ PayeeType + "「" + oEip.KeyNote + @"」簽呈編號:" + oEip.SignedNumber;
  100. var AuditorDecision = "審批結果:同意";
  101. if (!Decision)
  102. AuditorDecision = "審批結果:不同意";
  103. return new Tuple<string, string>(AuditorNotification, AuditorDecision);
  104. }
  105. private static string GetPayeeName(string PayeeType)
  106. {
  107. var Result = "";
  108. switch (PayeeType)
  109. {
  110. case "P":
  111. Result = "請款單(客戶)";
  112. break;
  113. case "C":
  114. Result = "請款單(廠商)";
  115. break;
  116. case "B":
  117. Result = "帳單更改申請單";
  118. break;
  119. default:
  120. break;
  121. }
  122. return Result;
  123. }
  124. }
  125. }