RefreshMattressInterfaceExcutor.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. using LJLib.SQLEX;
  13. using NPOI.OpenXmlFormats.Spreadsheet;
  14. namespace JLHHJSvr.Excutor
  15. {
  16. internal sealed class RefreshMattressInterfaceExcutor : ExcutorBase<RefreshMattressInterfaceRequest, RefreshMattressInterfaceResponse>
  17. {
  18. protected override void ExcuteInternal(RefreshMattressInterfaceRequest request, object state, RefreshMattressInterfaceResponse rslt)
  19. {
  20. var tokendata = BllHelper.GetToken(request.token);
  21. if (tokendata == null)
  22. {
  23. rslt.ErrMsg = "会话已经中断,请重新登录";
  24. return;
  25. }
  26. if (request.mattressid == null || request.mattressid <= 0)
  27. {
  28. rslt.ErrMsg = "床垫id有误,请检查!";
  29. return;
  30. }
  31. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  32. using (var cmd = con.CreateCommand())
  33. {
  34. con.Open();
  35. var copy_list = new List<u_mattress_interface>();
  36. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  37. if (request.isPz == 1)
  38. {
  39. var selectStr = @"SELECT mattressid
  40. ,printid
  41. ,itemname
  42. ,bj_pzname
  43. ,bj_namemx
  44. ,actual_size
  45. ,sb_craft
  46. ,actual_size_sb
  47. ,erp_pzid
  48. ,ss_rate
  49. ,ls_rate
  50. ,bj_inputtype
  51. FROM u_mattress_interface";
  52. 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);
  53. // 复制配置床网单独处理
  54. var mattressHelper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  55. var mattress = mattressHelper.GetMattress(request.mattressid_fu.Value);
  56. var mxlist = mattressHelper.GetMattressMxMtrl(request.mattressid_fu.Value, new List<string>() { "u_mattress_formula.formulatype IN (1)" });
  57. var cwInterfaceList = new List<u_mattress_interface>();
  58. interfaceHelper.AutoSetFormulaTypeOnePz(mxlist, cwInterfaceList);
  59. interfaceHelper.MattressInterfaceFindERPPz(request.mattressid_fu.Value, cwInterfaceList);
  60. //
  61. var cwDict = new Dictionary<int, u_mattress_interface>();
  62. foreach(var cw in cwInterfaceList)
  63. {
  64. if (cw.erp_pzid > 0 && !cwDict.ContainsKey(cw.erp_pzid.Value)) cwDict.Add(cw.erp_pzid.Value, cw);
  65. }
  66. foreach (var copy in copy_list)
  67. {
  68. if(cwDict.TryGetValue(copy.erp_pzid.Value,out var mx) && copy.bj_pzname.Contains("床网"))
  69. {
  70. copy.bj_namemx = mx.bj_namemx;
  71. }
  72. }
  73. } else
  74. {
  75. interfaceHelper.ImportMattressInterfaceList(request.mattressid.Value, copy_list);
  76. }
  77. interfaceHelper.MattressInterfaceFindERPPz(request.mattressid.Value, copy_list, request.configcodetype);
  78. rslt.mxList = copy_list;
  79. }
  80. }
  81. }
  82. }