RefreshMattressInterfaceExcutor.cs 4.0 KB

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