using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using JLHHJSvr.BLL; using JLHHJSvr.Com; using JLHHJSvr.Com.Model; using JLHHJSvr.Helper; using JLHHJSvr.LJException; using LJLib.DAL.SQL; using LJLib.Net.SPI.Server; using NPOI.OpenXmlFormats.Spreadsheet; namespace JLHHJSvr.Excutor { internal sealed class RefreshMattressInterfaceExcutor : ExcutorBase { protected override void ExcuteInternal(RefreshMattressInterfaceRequest request, object state, RefreshMattressInterfaceResponse rslt) { var tokendata = BllHelper.GetToken(request.token); if (tokendata == null) { rslt.ErrMsg = "会话已经中断,请重新登录"; return; } if (request.mattressid == null || request.mattressid <= 0) { rslt.ErrMsg = "床垫id有误,请检查!"; return; } using (var con = new SqlConnection(GlobalVar.ConnectionString)) using (var cmd = con.CreateCommand()) { con.Open(); var copy_list = new List(); var interfaceHelper = HelperBase.GetHelper(cmd, new HelperBase.Context() { tokendata = tokendata }); if (request.isPz == 1) { var selectStr = @"SELECT mattressid ,printid ,itemname ,bj_pzname ,bj_namemx ,actual_size ,sb_craft ,actual_size_sb ,erp_pzid ,ss_rate ,ls_rate ,bj_inputtype FROM u_mattress_interface"; DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary() { { "@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); // 复制配置床网单独处理 var mattressHelper = HelperBase.GetHelper(cmd, new HelperBase.Context() { tokendata = tokendata }); var mattress = mattressHelper.GetMattress(request.mattressid_fu.Value); var mxlist = mattressHelper.GetMattressMxMtrl(request.mattressid_fu.Value, new List() { "u_mattress_formula.formulatype IN (1)" }); var cwInterfaceList = new List(); interfaceHelper.AutoSetFormulaTypeOnePz(mxlist, cwInterfaceList); interfaceHelper.MattressInterfaceFindERPPz(request.mattressid_fu.Value, cwInterfaceList); // var cwDict = new Dictionary(); foreach(var cw in cwInterfaceList) { if (cw.erp_pzid > 0 && !cwDict.ContainsKey(cw.erp_pzid.Value)) cwDict.Add(cw.erp_pzid.Value, cw); } foreach (var copy in copy_list) { if(cwDict.TryGetValue(copy.erp_pzid.Value,out var mx) && copy.bj_pzname.Contains("床网")) { copy.bj_namemx = mx.bj_namemx; } } } else { interfaceHelper.ImportMattressInterfaceList(request.mattressid.Value, copy_list); } interfaceHelper.MattressInterfaceFindERPPz(request.mattressid.Value, copy_list, request.configcodetype); rslt.mxList = copy_list; } } } }