ReCalculateBedNetNoAuditExcutor.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 = new u_dept() { deptid = bednet.deptid.Value };
  48. DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
  49. if (dept.pricelistid <= 0) throw new LJCommonException("存在报价单部门pricelistid错误,不能重算!");
  50. }
  51. using (cmd.Transaction = con.BeginTransaction())
  52. {
  53. try
  54. {
  55. foreach (var bednet in request.list)
  56. {
  57. var mxList = helper.GetBedNetMxList(bednet.bednetid.Value);
  58. var springList = helper.GetBedNetSpringList(bednet.bednetid.Value);
  59. var bednet_temp = helper.GetBedNet(bednet.bednetid.Value);
  60. helper.CalCulateFormula(bednet_temp, mxList,springList);
  61. helper.SaveBedNet(bednet_temp, mxList,springList);
  62. }
  63. cmd.Transaction.Commit();
  64. }
  65. catch (Exception e)
  66. {
  67. cmd.Transaction.Rollback();
  68. rslt.ErrMsg = e.Message;
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }