GetMattressSubspecsExcutor.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. using LJLib.SQLEX;
  16. namespace JLHHJSvr.Excutor
  17. {
  18. internal sealed class GetMattressSubspecsExcutor : ExcutorBase<GetMattressSubspecsRequest, GetMattressSubspecsResponse>
  19. {
  20. protected override void ExcuteInternal(GetMattressSubspecsRequest request, object state, GetMattressSubspecsResponse rslt)
  21. {
  22. var tokendata = BllHelper.GetToken(request.token);
  23. if (tokendata == null)
  24. {
  25. rslt.ErrMsg = "会话已经中断,请重新登录";
  26. return;
  27. }
  28. if (request.mattressid == 0)
  29. {
  30. rslt.ErrMsg = "床垫id不能为0";
  31. return;
  32. }
  33. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  34. using (var cmd = con.CreateCommand())
  35. {
  36. con.Open();
  37. using (cmd.Transaction = con.BeginTransaction())
  38. {
  39. var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  40. var subspecsList = new List<u_mattress>();
  41. var result = new List<u_mattress_mx_subspecs>();
  42. var fields = "mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode";
  43. if (request.type == 0)
  44. {
  45. fields += ",mattressid,mattresscode,parentid,erp_mtrlid,erp_mtrlcode,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode";
  46. }
  47. //获取副规格列表
  48. subspecsList = helper.GetMattressSubspecs(request.mattressid, fields);
  49. if (subspecsList.Count > 0)
  50. {
  51. rslt.bednetMxs = new List<u_mattress_mx_mtrl>();
  52. rslt.mtrllist = new List<u_mattress_mx_mtrl>();
  53. foreach (var mattrss in subspecsList)
  54. {
  55. //获取弹簧排列
  56. List<u_mattress_mx_mtrl> bednetmxList = helper.GetMattressSubspecsBednet(mattrss.mattressid);
  57. rslt.bednetMxs = rslt.bednetMxs.Concat(bednetmxList).ToList();
  58. //判断是否有主副规格调整物料
  59. List<u_mattress_mx_mtrl> mtrlList = helper.GetMattressMxSubspecsMtrl(mattrss.mattressid);
  60. rslt.mtrllist = rslt.mtrllist.Concat(mtrlList).ToList();
  61. }
  62. }
  63. rslt.mattresses = subspecsList;
  64. }
  65. }
  66. }
  67. }
  68. }