AuditMattressBcpExcutor.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 AuditMattressBcpExcutor : ExcutorBase<AuditMattressBcpRequest, AuditMattressBcpResponse>
  13. {
  14. protected override void ExcuteInternal(AuditMattressBcpRequest request, object state, AuditMattressBcpResponse 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 power125 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 125);
  34. if (!power125)
  35. {
  36. throw new LJCommonException("你没有审核权限");
  37. }
  38. } else
  39. {
  40. var power126 = UserHelper.CheckFuncPower(cmd, tokendata.empid, 126);
  41. if (!power126)
  42. {
  43. throw new LJCommonException("你没有撤审权限");
  44. }
  45. }
  46. foreach (var bill in request.list)
  47. {
  48. if (DbSqlHelper.SelectOne(cmd, bill, "flag") != 1)
  49. {
  50. throw new LJCommonException($"查找半成品报价单据失败!({bill.billid})");
  51. }
  52. if (bill.flag == 1 && request.type == 1)
  53. {
  54. throw new LJCommonException($"查找半成品报价单据已审核,不能审核!({bill.billid})");
  55. }
  56. if(bill.flag == 0 && request.type == 0)
  57. {
  58. throw new LJCommonException($"查找半成品报价单据未审核,不能撤审!({bill.billid})");
  59. }
  60. }
  61. using (cmd.Transaction = con.BeginTransaction())
  62. {
  63. try
  64. {
  65. foreach (var bill in request.list)
  66. {
  67. bill.flag = request.type;
  68. DbSqlHelper.Update(cmd, "u_semi_finished_product", null, bill, "billid", "flag");
  69. }
  70. cmd.Transaction.Commit();
  71. }
  72. catch (Exception e)
  73. {
  74. cmd.Transaction.Rollback();
  75. rslt.ErrMsg = e.ToString();
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }