RefreshMattressInterfaceExcutor.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using JLHHJSvr.BLL;
  6. using JLHHJSvr.Com;
  7. using JLHHJSvr.Com.Model;
  8. using JLHHJSvr.Helper;
  9. using JLHHJSvr.LJException;
  10. using LJLib.DAL.SQL;
  11. using LJLib.Net.SPI.Server;
  12. namespace JLHHJSvr.Excutor
  13. {
  14. internal sealed class RefreshMattressInterfaceExcutor : ExcutorBase<RefreshMattressInterfaceRequest, RefreshMattressInterfaceResponse>
  15. {
  16. protected override void ExcuteInternal(RefreshMattressInterfaceRequest request, object state, RefreshMattressInterfaceResponse rslt)
  17. {
  18. var tokendata = BllHelper.GetToken(request.token);
  19. if (tokendata == null)
  20. {
  21. rslt.ErrMsg = "会话已经中断,请重新登录";
  22. return;
  23. }
  24. if (request.mattressid == null || request.mattressid <= 0)
  25. {
  26. rslt.ErrMsg = "床垫id有误,请检查!";
  27. return;
  28. }
  29. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  30. using (var cmd = con.CreateCommand())
  31. {
  32. con.Open();
  33. var copy_list = new List<u_mattress_interface>();
  34. var selectStr = @"SELECT mattressid
  35. ,printid
  36. ,itemname
  37. ,bj_pzname
  38. ,bj_namemx
  39. ,actual_size
  40. ,sb_craft
  41. ,actual_size_sb
  42. ,erp_pzid
  43. ,ss_rate
  44. ,ls_rate
  45. ,bj_inputtype
  46. FROM u_mattress_interface";
  47. DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", request.mattressid } }, "printid", "mattressid,printid,itemname,bj_pzname,bj_namemx,actual_size,sb_craft,actual_size_sb,erp_pzid,ss_rate,ls_rate,bj_inputtype", 0, 0, copy_list);
  48. using (var erp_con = new SqlConnection(BllHelper.GetERPConnectString(cmd)))
  49. using (var erp_cmd = erp_con.CreateCommand())
  50. {
  51. erp_con.Open();
  52. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd,erp_cmd, new HelperBase.Context() { tokendata = tokendata });
  53. var interfaceList = interfaceHelper.RefreshMattressInterfaceList(request.mattressid.Value);
  54. if(request.isPz != null && request.isPz == 1)
  55. {
  56. var copyDict = copy_list.Where(mx2 => mx2.erp_pzid > 0)
  57. .ToDictionary(mx2 => mx2.erp_pzid, mx2 => mx2);
  58. foreach (var mx in interfaceList)
  59. {
  60. if (mx.erp_pzid > 0 && copyDict.TryGetValue(mx.erp_pzid, out var mx2))
  61. {
  62. if (mx.bj_inputtype != 2 || (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1))
  63. {
  64. mx.bj_namemx = mx2.bj_namemx;
  65. mx.actual_size = mx2.actual_size;
  66. mx.sb_craft = mx2.sb_craft;
  67. mx.actual_size_sb = mx2.actual_size_sb;
  68. mx.ss_rate = mx2.ss_rate;
  69. mx.ls_rate = mx2.ls_rate;
  70. if (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1)
  71. {
  72. mx.bj_inputtype = 1;
  73. }
  74. }
  75. else
  76. {
  77. mx.actual_size = mx2.actual_size;
  78. mx.sb_craft = mx2.sb_craft;
  79. mx.actual_size_sb = mx2.actual_size_sb;
  80. mx.ss_rate = mx2.ss_rate;
  81. mx.ls_rate = mx2.ls_rate;
  82. }
  83. }
  84. }
  85. }
  86. rslt.mxList = interfaceList;
  87. }
  88. }
  89. }
  90. }
  91. }