ReCalculateBedNetNoAuditExcutor.cs 3.1 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. namespace JLHHJSvr.Excutor
  15. {
  16. internal sealed class ReCalculateBedNetNoAuditExcutor : ExcutorBase<ReCalculateBedNetNoAuditRequest, ReCalculateBedNetNoAuditResponse>
  17. {
  18. protected override void ExcuteInternal(ReCalculateBedNetNoAuditRequest request, object state, ReCalculateBedNetNoAuditResponse rslt)
  19. {
  20. var tokendata = BllHelper.GetToken(request.token);
  21. if (tokendata == null)
  22. {
  23. rslt.ErrMsg = "会话已经中断,请重新登录";
  24. return;
  25. }
  26. if (request.list == null)
  27. {
  28. rslt.ErrMsg = "提交缺少列表参数,请检查!";
  29. return;
  30. }
  31. if (!request.list.Any())
  32. {
  33. rslt.ErrMsg = "至少提交一条需要重算的记录";
  34. return;
  35. }
  36. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  37. using (var cmd = con.CreateCommand())
  38. {
  39. con.Open();
  40. var helper = HelperBase.GetHelper<BedNetHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  41. foreach (var bednet in request.list)
  42. {
  43. DbSqlHelper.SelectOne(cmd, bednet, "flag,deptid");
  44. if (bednet.flag == 1) throw new LJCommonException("存在报价单已审核,不能重算!");
  45. if (bednet.deptid <= 0) throw new LJCommonException("存在报价单部门id错误,不能重算!");
  46. var dept = new u_dept() { deptid = bednet.deptid.Value };
  47. DbSqlHelper.SelectOne(cmd, dept, "pricelistid");
  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. }