RefreshMattressInterfaceExcutor.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  49. var interfaceList = interfaceHelper.RefreshMattressInterfaceList(request.mattressid.Value);
  50. if (request.isPz != null && request.isPz == 1)
  51. {
  52. var copyDict = copy_list.Where(mx2 => mx2.erp_pzid > 0)
  53. .ToDictionary(mx2 => mx2.erp_pzid, mx2 => mx2);
  54. foreach (var mx in interfaceList)
  55. {
  56. if (mx.erp_pzid > 0 && copyDict.TryGetValue(mx.erp_pzid, out var mx2))
  57. {
  58. if (mx.bj_inputtype != 2 || (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1))
  59. {
  60. mx.bj_namemx = mx2.bj_namemx;
  61. mx.actual_size = mx2.actual_size;
  62. mx.sb_craft = mx2.sb_craft;
  63. mx.actual_size_sb = mx2.actual_size_sb;
  64. mx.ss_rate = mx2.ss_rate;
  65. mx.ls_rate = mx2.ls_rate;
  66. if (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1)
  67. {
  68. mx.bj_inputtype = 1;
  69. }
  70. }
  71. else
  72. {
  73. mx.actual_size = mx2.actual_size;
  74. mx.sb_craft = mx2.sb_craft;
  75. mx.actual_size_sb = mx2.actual_size_sb;
  76. mx.ss_rate = mx2.ss_rate;
  77. mx.ls_rate = mx2.ls_rate;
  78. }
  79. }
  80. }
  81. }
  82. rslt.mxList = interfaceList;
  83. }
  84. }
  85. }
  86. }