ReCalculateBedNetNoAuditExcutor.cs 3.0 KB

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