AuditMattressBcpExcutor.cs 3.1 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. using LJLib.SQLEX;
  11. namespace JLHHJSvr.Excutor
  12. {
  13. internal sealed class AuditMattressBcpExcutor : ExcutorBase<AuditMattressBcpRequest, AuditMattressBcpResponse>
  14. {
  15. protected override void ExcuteInternal(AuditMattressBcpRequest request, object state, AuditMattressBcpResponse 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 power125 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 125);
  35. if (!power125)
  36. {
  37. throw new LJCommonException("你没有审核权限");
  38. }
  39. } else
  40. {
  41. var power126 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 126);
  42. if (!power126)
  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.billid})");
  52. }
  53. if (bill.flag == 1 && request.type == 1)
  54. {
  55. throw new LJCommonException($"查找半成品报价单据已审核,不能审核!({bill.billid})");
  56. }
  57. if(bill.flag == 0 && request.type == 0)
  58. {
  59. throw new LJCommonException($"查找半成品报价单据未审核,不能撤审!({bill.billid})");
  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_semi_finished_product", null, bill, "billid", "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. }