GetMattressSubspecsExcutor.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using DirectService.Tools;
  7. using JLHHJSvr.BLL;
  8. using JLHHJSvr.Com;
  9. using JLHHJSvr.Com.Model;
  10. using JLHHJSvr.Helper;
  11. using JLHHJSvr.LJException;
  12. using JLHHJSvr.Tools;
  13. using LJLib.DAL.SQL;
  14. using LJLib.Net.SPI.Server;
  15. namespace JLHHJSvr.Excutor
  16. {
  17. internal sealed class GetMattressSubspecsExcutor : ExcutorBase<GetMattressSubspecsRequest, GetMattressSubspecsResponse>
  18. {
  19. protected override void ExcuteInternal(GetMattressSubspecsRequest request, object state, GetMattressSubspecsResponse rslt)
  20. {
  21. var tokendata = BllHelper.GetToken(request.token);
  22. if (tokendata == null)
  23. {
  24. rslt.ErrMsg = "会话已经中断,请重新登录";
  25. return;
  26. }
  27. if (request.mattressid == 0)
  28. {
  29. rslt.ErrMsg = "床垫id不能为0";
  30. return;
  31. }
  32. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  33. using (var cmd = con.CreateCommand())
  34. {
  35. con.Open();
  36. using (cmd.Transaction = con.BeginTransaction())
  37. {
  38. var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  39. var subspecsList = new List<u_mattress>();
  40. var result = new List<u_mattress_mx_subspecs>();
  41. //获取副规格列表
  42. subspecsList = helper.GetMattressSubspecs(request.mattressid);
  43. if (subspecsList.Count > 0)
  44. {
  45. rslt.bednetMxs = new List<u_mattress_mx_mtrl>();
  46. rslt.mtrllist = new List<u_mattress_mx_mtrl>();
  47. foreach (var mattrss in subspecsList)
  48. {
  49. //获取弹簧排列
  50. List<u_mattress_mx_mtrl> bednetmxList = helper.GetMattressSubspecsBednet(mattrss.mattressid);
  51. rslt.bednetMxs = rslt.bednetMxs.Concat(bednetmxList).ToList();
  52. //判断是否有主副规格调整物料
  53. List<u_mattress_mx_mtrl> mtrlList = helper.GetMattressMxSubspecsMtrl(mattrss.mattressid);
  54. rslt.mtrllist = rslt.mtrllist.Concat(mtrlList).ToList();
  55. }
  56. }
  57. rslt.mattresses = subspecsList;
  58. }
  59. }
  60. }
  61. }
  62. }