ReCalculateNoAuditExcutor.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using JLHHJSvr.BLL;
  5. using JLHHJSvr.Com;
  6. using JLHHJSvr.Com.Model;
  7. using JLHHJSvr.Helper;
  8. using JLHHJSvr.LJException;
  9. using LJLib.DAL.SQL;
  10. using LJLib.Net.SPI.Server;
  11. using LJLib.SQLEX;
  12. using static JLHHJSvr.Helper.CacheHelper;
  13. namespace JLHHJSvr.Excutor
  14. {
  15. internal sealed class ReCalculateNoAuditExcutor : ExcutorBase<ReCalculateNoAuditRequest, ReCalculateNoAuditResponse>
  16. {
  17. protected override void ExcuteInternal(ReCalculateNoAuditRequest request, object state, ReCalculateNoAuditResponse rslt)
  18. {
  19. var tokendata = BllHelper.GetToken(request.token);
  20. if (tokendata == null)
  21. {
  22. rslt.ErrMsg = "会话已经中断,请重新登录";
  23. return;
  24. }
  25. if (request.list == null)
  26. {
  27. rslt.ErrMsg = "提交缺少列表参数,请检查!";
  28. return;
  29. }
  30. if (!request.list.Any())
  31. {
  32. rslt.ErrMsg = "至少提交一条需要重算的记录";
  33. return;
  34. }
  35. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  36. using (var cmd = con.CreateCommand())
  37. {
  38. con.Open();
  39. var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  40. foreach (var mattress in request.list)
  41. {
  42. DbSqlHelper.SelectOne(cmd, mattress, "flag,deptid");
  43. if (mattress.flag == 1) throw new LJCommonException("存在报价单已审核,不能重算!");
  44. if (mattress.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!");
  45. var dept = helper.Cache.GetData<u_dept,DeptMapping>(mattress.deptid.Value);
  46. if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
  47. }
  48. using (cmd.Transaction = con.BeginTransaction())
  49. {
  50. try
  51. {
  52. foreach (var mattress in request.list)
  53. {
  54. helper.RecalculateOne(mattress);
  55. }
  56. cmd.Transaction.Commit();
  57. }
  58. catch (Exception e)
  59. {
  60. cmd.Transaction.Rollback();
  61. rslt.ErrMsg = e.Message;
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }