AuditBedNetExcutor.cs 3.1 KB

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