AuditBedNetExcutor.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Data.SqlClient;
  3. using System.Linq;
  4. using JLHHJSvr.BLL;
  5. using JLHHJSvr.Com;
  6. using JLHHJSvr.Com.Model;
  7. using JLHHJSvr.LJException;
  8. using LJLib.DAL.SQL;
  9. using LJLib.Net.SPI.Server;
  10. namespace JLHHJSvr.Excutor
  11. {
  12. internal sealed class AuditBedNetExcutor : ExcutorBase<AuditBedNetRequest, AuditBedNetResponse>
  13. {
  14. protected override void ExcuteInternal(AuditBedNetRequest request, object state, AuditBedNetResponse rslt)
  15. {
  16. var tokendata = BllHelper.GetToken(request.token);
  17. if (tokendata == null)
  18. {
  19. rslt.ErrMsg = "会话已经中断,请重新登录";
  20. return;
  21. }
  22. if (!request.list.Any())
  23. {
  24. rslt.ErrMsg = "至少提交一条需要审核的记录";
  25. return;
  26. }
  27. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  28. using (var cmd = con.CreateCommand())
  29. {
  30. con.Open();
  31. if (request.type == 1)
  32. {
  33. var power63 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 63);
  34. if (!power63)
  35. {
  36. throw new LJCommonException("你没有审核权限");
  37. }
  38. }
  39. else
  40. {
  41. var power64 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 64);
  42. if (!power64)
  43. {
  44. throw new LJCommonException("你没有撤审权限");
  45. }
  46. }
  47. foreach (var bill in request.list)
  48. {
  49. if (DbSqlHelper.SelectOne(cmd, bill, "flag") != 1)
  50. {
  51. throw new LJCommonException($"查找床网报价单据失败!({bill.bednetid})");
  52. }
  53. if (bill.flag == 1 && request.type == 1)
  54. {
  55. throw new LJCommonException($"查找床网报价单据已审核,不能审核!({bill.bednetid})");
  56. }
  57. if (bill.flag == 0 && request.type == 0)
  58. {
  59. throw new LJCommonException($"查找床网报价单据未审核,不能撤审!({bill.bednetid})");
  60. }
  61. }
  62. using (cmd.Transaction = con.BeginTransaction())
  63. {
  64. try
  65. {
  66. foreach (var bill in request.list)
  67. {
  68. bill.flag = request.type;
  69. DbSqlHelper.Update(cmd, "u_bednet", null, bill, "bednetid", "flag");
  70. }
  71. cmd.Transaction.Commit();
  72. }
  73. catch (Exception e)
  74. {
  75. cmd.Transaction.Rollback();
  76. rslt.ErrMsg = e.ToString();
  77. }
  78. }
  79. }
  80. }
  81. }
  82. }