123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629 |
- using JLHHJSvr.BLL;
- using JLHHJSvr.Com;
- using JLHHJSvr.Com.Model;
- using JLHHJSvr.LJException;
- using JLHHJSvr.Tools;
- using LJLib.DAL.SQL;
- using Microsoft.SqlServer.Server;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web;
- using System.Xml.Linq;
- namespace JLHHJSvr.Helper
- {
- internal class InterfaceHelper : HelperBase
- {
- /// <summary>
- /// 床垫接口-保存
- /// </summary>
- /// <param name="mattress"></param>
- /// <param name="mxlist"></param>
- /// <param name="qdlist"></param>
- /// <exception cref="LJCommonException"></exception>
- public void SaveMattressInterface(u_mattress mattress, List<u_mattress_interface> mxlist, List<u_mattress_interface_qd> qdlist)
- {
- if (mattress.mattressid <= 0)
- {
- throw new LJCommonException("错误的床垫id");
- }
- AutoSetMtrlName(mattress, mxlist);
- if (string.IsNullOrEmpty(mattress.erp_mtrlcode))
- {
- throw new LJCommonException("请输入物料名称!");
- }
- if (mattress.erp_mtrltypeid == null || mattress.erp_mtrltypeid <= 0)
- {
- throw new LJCommonException("请选择物料类别!");
- }
- if (mattress.erp_configcodetype == null || mattress.erp_configcodetype <= 0)
- {
- throw new LJCommonException("请选择配置类型!");
- }
- DbSqlHelper.Update(cmd, mattress, "erp_mtrlid,erp_mtrltypeid,erp_mtrlcode,erp_mtrlname,erp_mtrlmode,erp_mtrltype,erp_mtrlunit,erp_mtrlengname,erp_configcodetype,old_mtrlname");
- // 保存接口数据
- var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
- mattressHelper.SaveMattressInterface(mattress.mattressid, mxlist, qdlist);
- }
- public void AutoSetMtrlName(u_mattress mattress, List<u_mattress_interface> mxlist)
- {
- string mtrltypename = string.Empty, mtrltypecode = string.Empty;
- string mattresstypename = string.Empty, mattresstypecode = string.Empty;
- string packtypename = string.Empty, packtypecode = string.Empty;
- var materialCodes = new Dictionary<string, string>
- {
- { "两边单层", "21" },
- { "两边直出", "23" },
- { "三边加顶", "32" },
- { "三边直出", "33" },
- { "假三边", "34" },
- { "拉假边", "3C" },
- { "假三边加顶", "42" },
- { "上下假三边", "44" },
- { "四边双顶", "45" },
- { "四边顶上顶", "46" },
- { "四边假分体", "47" }
- };
- var mattressTypeCodes = new Dictionary<string, string>
- {
- { "袋装网", "P" },
- { "拉丝网", "C" },
- { "圆网", "B" }
- };
- var packTypeCodes = new Dictionary<string, string>
- {
- { "平压", "A" },
- { "卷包", "B" }
- };
- foreach (var mx in mxlist)
- {
- if (mx.bj_pzname.IndexOf("床垫类别") > -1)
- {
- mtrltypename = mx.bj_namemx;
- break;
- }
- }
- foreach (var mx in mxlist)
- {
- if (mx.bj_pzname.IndexOf("床网") > -1)
- {
- mattresstypename = mx.bj_namemx;
- break;
- }
- }
- foreach (var mx in mxlist)
- {
- if (mx.bj_pzname.IndexOf("包装方式") > -1)
- {
- packtypename = mx.bj_namemx;
- break;
- }
- }
- mtrltypecode = materialCodes.ContainsKey(mtrltypename) ? materialCodes[mtrltypename] : "99";
- mattresstypecode = mattressTypeCodes.ContainsKey(mtrltypename) ? mattressTypeCodes[mtrltypename] : "Z";
- packtypecode = packTypeCodes.ContainsKey(mtrltypename) ? packTypeCodes[mtrltypename] : "J";
- // 获取mxlist最后一项
- if (mattress.mattressid > 0)
- {
- mattress.erp_mtrlname = new StringBuilder().Append(mtrltypecode).Append(mattresstypecode).Append(packtypecode).ToString();
- }
- }
- public List<u_mattress_interface> GetMattressInterfaceList(int mattressid)
- {
- var interfaceList = new List<u_mattress_interface>();
- 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<string, object>() { { "@mattressid", 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, interfaceList);
- if(interfaceList.Count <= 0)
- {
- interfaceList = RefreshMattressInterfaceList(mattressid);
- }
- MattressInterfaceFindERPPz(mattressid, interfaceList);
- return interfaceList;
- }
- public List<u_mattress_interface_qd> GetMattressInterfaceQdList(int mattressid)
- {
- var qdList = new List<u_mattress_interface_qd>();
- var selectStr = @"SELECT u_mattress_interface_qd.mattressid
- ,u_mattress_interface_qd.printid
- ,u_mattress_interface_qd.itemname
- ,u_mattress_interface_qd.bj_pzname
- ,u_mattress_interface_qd.bj_pzname_mx
- ,u_mattress_interface_qd.bj_pzname_mx_mx
- ,u_mattress_interface_qd.mtrlid
- ,u_mattress_interface_qd.erp_mtrlid
- ,u_mattress_interface_qd.useqty
- ,u_mattress_interface_qd.dscrp
- ,u_mtrl_price.name AS mtrlname
- ,u_mattress_interface_qd.actual_useqty
- ,u_mattress_interface_qd.qd_actual_size
- ,u_mattress_interface_qd.qd_pfgroupqty
- ,u_mattress_interface_qd.wrkgrpid
- ,u_mattress_interface_qd.ss_rate
- ,u_mattress_interface_qd.ls_rate
- ,u_mattress_interface_qd.sh_rate
- FROM u_mattress_interface_qd
- LEFT JOIN u_mtrl_price ON u_mtrl_price.mtrlid = u_mattress_interface_qd.mtrlid";
- var outputFields = "mattressid,printid,itemname,bj_pzname,bj_pzname_mx,bj_pzname_mx_mx,mtrlid,erp_mtrlid,useqty,dscrp,mtrlname,actual_useqty,qd_actual_size,qd_pfgroupqty,wrkgrpid,ss_rate,ls_rate,sh_rate";
- DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", mattressid } }, "printid", outputFields, 0, 0, qdList);
- if (qdList.Count <= 0)
- {
- qdList = RefreshMattressInterfaceQdList(mattressid);
- }
- return qdList;
- }
- #region 导入配置方法
- /// <summary>
- /// 刷新带出配置
- /// </summary>
- /// <param name="mattressid"></param>
- /// <returns></returns>
- public List<u_mattress_interface> RefreshMattressInterfaceList(int mattressid)
- {
- var interfaceList = new List<u_mattress_interface>();
- // 导入配置
- ImportMattressInterfaceList(mattressid, interfaceList);
- MattressInterfaceFindERPPz(mattressid, interfaceList);
- return interfaceList;
- }
- /// <summary>
- /// 导入产品配置
- /// </summary>
- /// <param name="mattressid"></param>
- /// <exception cref="LJCommonException"></exception>
- public void ImportMattressInterfaceList(int mattressid, List<u_mattress_interface> interfaceList)
- {
- if (mattressid <= 0)
- {
- throw new LJCommonException("床垫id有误");
- }
- var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
- var mattress = mattressHelper.GetMattress(mattressid);
- var mattress_type = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
- DbSqlHelper.SelectOne(cmd, mattress_type, "typename");
- var mxlist = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype IN (0,1,2,3,99,104)" });
- var mxlist_103 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 103" });
- var mxlist_101 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 101" });
- // 高度
- interfaceList.Add(InserMattressInterfacePz("床垫", "高度", 2, new string[] { $"{mattress.mattress_height}" }));
- // 参考外观
- interfaceList.Add(InserMattressInterfacePz("床垫", "参考外观", 1, new string[] { "" }));
- // 尺寸
- mattress.erp_mtrlcode = $"{mattress.mattress_width}*{mattress.mattress_length}*{mattress.mattress_height}";
- interfaceList.Add(InserMattressInterfacePz("床垫", "尺寸", 2, new string[] { mattress.erp_mtrlcode }));
- // 床垫类别
- interfaceList.Add(InserMattressInterfacePz("床垫", "床垫类别", 2, new string[] { mattress_type.typename }));
- // 拆装类型
- var name_arr = new string[1];
- name_arr[0] = string.Empty;
- if (mattress.if_m_chai == 1) name_arr[0] = AppendToString(name_arr[0], "面拆");
- if (mattress.if_z_chai == 1) name_arr[0] = AppendToString(name_arr[0], "中拆");
- if (mattress.if_d_chai == 1) name_arr[0] = AppendToString(name_arr[0], "底拆");
- interfaceList.Add(InserMattressInterfacePz("床垫", "拆装类型", 1, name_arr));
- // 床垫分类
- name_arr[0] = string.Empty;
- if (mattress.if_haimian_type == 1) name_arr[0] = AppendToString(name_arr[0], "海绵床垫");
- else name_arr[0] = AppendToString(name_arr[0], "弹簧床垫");
- if (mattress.if_zhedie_type == 1) name_arr[0] = AppendToString(name_arr[0], "折叠床垫");
- interfaceList.Add(InserMattressInterfacePz("床垫", "床垫分类", 1, name_arr));
- // 外观布套做法
- name_arr[0] = string.Empty;
- if (mattress.if_m_wbutao_way == 1) name_arr[0] = AppendToString(name_arr[0], $"面层向大侧覆盖{mattress.s_m_cover_qty}CM、大侧向底层覆盖{mattress.z_m_cover_qty}CM、底层向大侧覆盖{mattress.x_m_cover_qty}CM");
- interfaceList.Add(InserMattressInterfacePz("床垫", "外观布套做法", 1, name_arr));
- // 边带
- name_arr[0] = string.Empty;
- interfaceList.Add(InserMattressInterfacePz("床垫", "边带", 0, name_arr));
- #region 面料类清单导入 AutoSetFormulaTypeZeroPz()需要优化
- AutoSetFormulaTypeZeroPz(mxlist, interfaceList);
- interfaceList.Add(InserMattressInterfacePz("车位说明", "车位说明", 1, name_arr));
- #endregion
- #region 垫层类清单导入
- AutoSetFormulaTypeOnePz(mxlist, interfaceList);
- #endregion
- #region 辅料类清单导入
- AutoSetFormulaTypeTwoPz(mxlist, interfaceList);
- #endregion
- #region 包装类清单导入
- AutoSetFormulaTypeThreePz(mattress, mxlist, interfaceList);
- #endregion
- #region 内布套类清单导入
- AutoSetFormulaType101Pz(mattress, mxlist_103, interfaceList);
- #endregion
- #region 自定义配置导入
- if(mattress.erp_configcodetype != null && mattress.erp_configcodetype > 0)
- {
- var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
- var parameters = new JObject();
- parameters.Add("dsname", "web_configure_code_list");
- var queryparams = new JObject();
- queryparams.Add("arg_configcodetype", mattress.erp_configcodetype);
- queryparams.Add("arg_ifpack", 1);
- parameters.Add("queryparams", queryparams);
- var resultList = erpHelper.GetERPList<erp_configure_code>("CommonDynamicSelect", parameters);
- foreach(var result in resultList)
- {
- var pzname = result.name;
- interfaceList.Add(InserMattressInterfacePz("自定义", pzname, 1, new string[] { "" }));
- }
- }
- #endregion
- }
- public void MattressInterfaceFindERPPz(int mattressid, List<u_mattress_interface> interfaceList)
- {
- var mattress = new u_mattress() { mattressid = mattressid };
- DbSqlHelper.SelectOne(cmd, mattress, "erp_configcodetype");
- MattressInterfaceFindERPPz(mattress, interfaceList);
- }
- public void MattressInterfaceFindERPPz(u_mattress mattress,List<u_mattress_interface> interfaceList)
- {
- var typeList = new List<erp_configure_code>();
- foreach(var item in interfaceList)
- {
- typeList.Add(new erp_configure_code() { typeid = mattress.erp_configcodetype,name = item.bj_pzname });
- }
- var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
- var parameters = new JObject();
- parameters.Add("typeList", JToken.FromObject(typeList));
- var resultList = erpHelper.GetERPList<erp_configure_code>("GetL1ConfigureCode", parameters);
- for (var i = 0; i < interfaceList.Count; i++)
- {
- interfaceList[i].printid = i + 1;
- foreach (var result in resultList)
- {
- if (result.pzid > 0)
- {
- interfaceList[i].erp_pzid = result.pzid;
- interfaceList[i].erp_pzcode = result.pzcode;
- interfaceList[i].erp_pzname = result.name;
- }
- if (interfaceList[i].bj_inputtype != 2) interfaceList[i].bj_inputtype = result.inputtype;
- }
- }
- }
- /// <summary>
- /// 初始化配置信息
- /// </summary>
- /// <param name="itemname"></param>
- /// <param name="bj_pzname"></param>
- /// <param name="inputtype"></param>
- /// <param name="names"></param>
- /// <returns></returns>
- public u_mattress_interface InserMattressInterfacePz(string itemname, string bj_pzname, byte inputtype, string[] names)
- {
- var mattress_interface = new u_mattress_interface()
- {
- itemname = itemname,
- bj_pzname = bj_pzname,
- bj_inputtype = inputtype,
- bj_namemx = names == null ? string.Empty : SetInterfacePzName(names)
- };
- return mattress_interface;
- }
- private string SetInterfacePzName(string[] names)
- {
- var result = string.Empty;
- foreach (var name in names)
- {
- if (string.IsNullOrEmpty(name)) continue;
- result = AppendToString(result, name);
- }
- return result;
- }
- private void AutoSetFormulaTypeZeroPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
- {
- var powerDict = new Dictionary<string, int[]>()
- {
- {"面裥绵",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"底裥绵",new int[] { 1, 41, 51, 61, 71, 81 } },
- {"顶布裥棉1",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"顶布裥棉2",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"顶布裥棉3",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"顶布裥棉4",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"普通大侧",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"小侧1_EMPTY",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
- {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
- };
- var chastrArrDict = new Dictionary<string, string[]>()
- {
- {"面裥绵",new string[] { "裥面", "面层裥棉", "面层裥棉图案", "面层裥面说明" } },
- {"底裥绵",new string[] { "裥底", "底层裥棉", "底层裥棉图案", "底层裥棉说明" } },
- {"顶布裥棉1",new string[] { "顶布裥棉", "", "顶布裥棉1图案", "顶布裥棉1说明" } },
- {"顶布裥棉2",new string[] { "顶布裥棉", "", "顶布裥棉2图案", "顶布裥棉2说明" } },
- {"顶布裥棉3",new string[] { "顶布裥棉", "", "顶布裥棉3图案", "顶布裥棉3说明" } },
- {"顶布裥棉4",new string[] { "顶布裥棉","", "顶布裥棉4图案", "顶布裥棉4说明" } },
- {"普通大侧",new string[] { "大侧", "大侧裥棉", "大侧裥棉图案" } },
- {"上下拼侧1",new string[] {"大侧", "大侧-上下拼侧1", "大侧-上下拼侧1", "大侧-上下拼侧1高度"} },
- {"上下拼侧2",new string[] { "大侧", "大侧-上下拼侧2", "大侧-上下拼侧2", "大侧-上下拼侧2高度" } },
- {"上下拼侧3",new string[] { "大侧", "大侧-上下拼侧3", "大侧-上下拼侧3", "大侧-上下拼侧3高度" } },
- {"左右拼侧1",new string[] { "大侧", "大侧-左右拼侧1", "大侧-左右拼侧1裥棉图案", "大侧-左右拼侧1长度" } },
- {"左右拼侧2",new string[] { "大侧", "大侧-左右拼侧2", "大侧-左右拼侧2裥棉图案", "大侧-左右拼侧2长度" } },
- {"左右拼侧3",new string[] { "大侧", "大侧-左右拼侧3", "大侧-左右拼侧3裥棉图案", "大侧-左右拼侧3长度", "大侧说明" } },
- {"小侧1_EMPTY",new string[] { "小侧", "小侧1裥棉", "小侧1裥棉图案" } },
- {"小侧1",new string[] { "小侧", "小侧1裥棉", "小侧1裥棉图案" } },
- {"小侧1-上下拼侧1",new string[] { "小侧", "小侧1-上下拼侧1裥棉", "小侧1-上下拼侧1裥棉图案" } },
- {"小侧1-上下拼侧2",new string[] { "小侧", "小侧1-上下拼侧2裥棉", "小侧1-上下拼侧2裥棉图案" } },
- {"小侧1-上下拼侧3",new string[] { "小侧", "小侧1-上下拼侧3裥棉", "小侧1-上下拼侧3裥棉图案" } },
- {"小侧2",new string[] { "小侧", "小侧2裥棉", "小侧2裥棉图案" } },
- {"小侧3",new string[] { "小侧", "小侧3裥棉", "小侧3裥棉图案", "小侧说明" } },
- {"V侧1_EMPTY",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
- {"V侧1",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
- {"V侧2",new string[] { "V侧", "V侧2裥棉", "V侧2裥棉图案" } },
- {"V侧3",new string[] { "V侧", "V侧3裥棉", "V侧3裥棉图案", "V侧说明" } }
- };
- var jianmianList = mxlist.Where(t => t.formulatype == 0).ToList();
- #region wf_import_qingdan + wf_import_qingdan_1 面料部分
- foreach (var item in powerDict)
- {
- SetFormulaTypeZeroPz(jianmianList, interfaceList, item.Value, item.Key, chastrArrDict[item.Key]);
- }
- #endregion
- #region wf_import_qingdan_next 面料部分
- // 拉手
- var lashouList = jianmianList.Where(t => t.formulakind == 5).ToList();
- for (int i = 0; i < lashouList.Count; i++)
- {
- var mx = lashouList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"拉手{i + 1}做法", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}只{mx.mtrlname}" }));
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"拉手{i + 1}刺绣", 0, new string[] { "" }));
- }
- }
- // 刺绣
- var cixiuList = jianmianList.Where(t => t.formulakind == 6).ToList();
- for (int i = 0; i < cixiuList.Count; i++)
- {
- var mx = cixiuList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"侧刺绣{i + 1}做法", 1, new string[] { "" }));
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"侧刺绣{i + 1}位置", 0, new string[] { "" }));
- }
- }
- // 大侧压压布
- var dcyybList = jianmianList.Where(t => t.formulakind == 7).ToList();
- for (int i = 0; i < dcyybList.Count; i++)
- {
- var mx = dcyybList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压压布{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- // 大侧压边带
- var dcybdList = jianmianList.Where(t => t.formulakind == 8).ToList();
- for (int i = 0; i < dcybdList.Count; i++)
- {
- var mx = dcybdList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压边带{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- // 大侧压织带
- var dcyzdList = jianmianList.Where(t => t.formulakind == 9).ToList();
- for (int i = 0; i < dcyzdList.Count; i++)
- {
- var mx = dcyzdList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压织带{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- // 大侧压上下压线
- var dcysxyxList = jianmianList.Where(t => t.formulakind == 10).ToList();
- for (int i = 0; i < dcysxyxList.Count; i++)
- {
- var mx = dcysxyxList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", $"大侧压上下压线{i + 1}", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- // 车花边
- var chbList = jianmianList.Where(t => t.formulakind == 205).ToList();
- for (int i = 0; i < chbList.Count; i++)
- {
- var mx = chbList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "车花边", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- // 防火线
- var fhxList = jianmianList.Where(t => t.formulakind == 30).ToList();
- for (int i = 0; i < fhxList.Count; i++)
- {
- var mx = fhxList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "防火线", 1, new string[] { mx.mtrlname }));
- }
- }
- // 拉链
- var llList = jianmianList.Where(t => t.formulakind == 202).ToList();
- for (int i = 0; i < llList.Count; i++)
- {
- var mx = llList[i];
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("拉手刺绣及其他工艺", "拉链", 1, new string[] { $"{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- #endregion
- }
- private void SetFormulaTypeZeroPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList, int[] powerArr, string key, string[] chastrArr)
- {
- var mianList1 = new HashSet<string> { "面裥绵", "底裥绵" };
- var mianList2 = new string[4] { "顶布裥棉1", "顶布裥棉2", "顶布裥棉3", "顶布裥棉4" };
- var mianList3 = new HashSet<string> { "普通大侧", "上下拼侧1", "上下拼侧2", "上下拼侧3", "左右拼侧1", "左右拼侧2", "左右拼侧3", "小侧1", "小侧2", "小侧3" };
- var name_arr = new string[5];
- foreach (var mx in mxlist)
- {
- SetFormulaTypeZeroPzName(mx, key, powerArr, name_arr);
- }
- if (mianList2.Contains(key))
- {
- for (int i = 0; i < mianList2.Length; i++)
- {
- DingBuLianMian.SetValue(name_arr[i], i, 0);
- }
- }
- var sb = new StringBuilder();
- foreach (var name2 in name_arr)
- {
- sb.Append(name2);
- }
- if (sb.Length > 0)
- {
- if (!string.IsNullOrEmpty(chastrArr[1])) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[1], 2, name_arr));
- interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[2], 1, new string[] { "" }));
- if (chastrArr.Length > 3) interfaceList.Add(InserMattressInterfacePz(chastrArr[0], chastrArr[3], 1, new string[] { "" }));
- }
- foreach (var name in chastrArr)
- {
- if (string.IsNullOrEmpty(name)) continue;
- if (name.Contains("说明"))
- {
- interfaceList.Add(InserMattressInterfacePz(chastrArr[0], name, 1, new string[] { "" }));
- }
- }
-
- }
- private void SetFormulaTypeZeroPzName(u_mattress_mx_mtrl mx, string key, int[] powerArr, string[] name_arr)
- {
- if (key.Contains("_EMPTY")) key = "";
- if (mx.mtrlid > 0 && key.Equals(mx.chastr) && powerArr.Contains(mx.formulakind.Value))
- {
- if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
- {
- name_arr[0] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
- }
- if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
- {
- name_arr[1] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
- }
- if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
- {
- var mtrlname_temp = mx.mtrlname;
- if (!(mx.mtrlname.IndexOf("分") > -1 && mx.thickness == 0 || mx.if_inputqty == 1))
- {
- mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
- }
- name_arr[2] = SplitNameCount(mtrlname_temp, Convert.ToInt32(mx.qty.Value));
- }
- if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
- {
- name_arr[3] = SplitNameCount(mx.mtrlname, Convert.ToInt32(mx.qty.Value));
- }
- if (mx.formulakind == 80 || mx.formulakind == 81)
- {
- name_arr[0] = AppendToString(name_arr[0], mx.mtrlname);
- }
- }
- }
- private void AutoSetFormulaTypeOnePz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
- {
- var diancengList = mxlist.Where(t => t.formulatype == 1).ToList();
- var kindDict = new Dictionary<int, string>()
- {
- { 32,"垫层" },
- { 12,"顶布" },
- { 13,"毡类" },
- { 14,"打底无纺布" },
- { 29,"网面布料" },
- { 999,"床网" },
- { 1201,"顶布裥棉" },
- };
- var chastrSet = new HashSet<string>() { "大侧", "小侧1", "小侧2", "小侧3", "V侧1", "V侧2", "V侧3" };
- var countDict = new Dictionary<string, int>();
- foreach (var cha in chastrSet)
- {
- foreach (var kind in kindDict)
- {
- countDict.Add($"{cha}-{kind.Value}", 0);
- }
- }
- foreach (var mx in diancengList)
- {
- var key = $"{mx.chastr}-{kindDict[mx.formulakind.Value]}";
- if (mx.formulakind == 999)
- {
- this.ProcessChuangWangPz(mx, interfaceList, mx.chastr, ++countDict[key]);
- }
- else if (mx.mtrlid > 0 && mx.formulakind == 1201)
- {
- this.ProcessDingbuLianMianPz(mx, interfaceList, mx.chastr, ++countDict[key]);
- }
- else if (mx.mtrlid > 0 && new int[] { 32, 12, 13, 14, 29 }.Contains(mx.formulakind.Value))
- {
- this.ProcessWangMianBLPz(mx, interfaceList, mx.chastr, kindDict[mx.formulakind.Value], ++countDict[key]);
- }
- }
- if (countDict["大侧-垫层"] > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("垫层", "大侧垫层生产说明", 1, new string[1]));
- }
- if (countDict["小侧1-垫层"] > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("垫层", "小侧垫层生产说明", 1, new string[1]));
- }
- if (countDict["V侧1-垫层"] > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("垫层", "V侧垫层生产说明", 1, new string[1]));
- }
- }
- /// <summary>
- /// 床网
- /// </summary>
- /// <param name="mx"></param>
- /// <param name="interfaceList"></param>
- /// <param name="chastr"></param>
- /// <param name="count"></param>
- private void ProcessChuangWangPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, int count)
- {
- var name_arr = new string[5];
- int bednetid = 0;
- cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid
- FROM u_bednetmx
- INNER JOIN (
- SELECT mtrlid
- FROM u_mattress_mx_mtrl
- INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
- WHERE u_mattress_formula.formulakind = 99
- AND u_mattress_mx_mtrl.mattressid = @mattressid
- AND u_mattress_mx_mtrl.mtrlid > 0
- ) v_mattress_mx_mtrl ON u_bednetmx.bednetid = v_mattress_mx_mtrl.mtrlid";
- cmd.Parameters.Clear();
- cmd.Parameters.AddWithValue("@mattressid", mx.mattressid);
- using (var reader = cmd.ExecuteReader())
- {
- while (reader.Read())
- {
- decimal height = Convert.ToDecimal(reader["bednet_height"]);
- if (height == mx.thickness) bednetid = Convert.ToInt32(reader["bednetid"]);
- }
- }
- if (bednetid > 0)
- {
- var bednetHelper = HelperBase.GetHelper<BedNetHelper>(cmd);
- var bednetQdList = bednetHelper.GetBedNetQingDan(bednetid);
- if (bednetQdList.Any())
- {
- name_arr[0] = bednetQdList[0].pznamemx;
- name_arr[0] += "丨erp编码:";
- cmd.CommandText = @"SELECT u_mattress.erp_mtrlcode
- FROM u_mattress_mx_mtrl
- INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
- INNER JOIN u_mattress ON u_mattress.mattressid = u_mattress_mx_mtrl.mattressid
- WHERE u_mattress_formula.formulakind = 99
- AND u_mattress.bcptypeid <> 0
- AND u_mattress_mx_mtrl.mtrlid = @bednetid";
- cmd.Parameters.Clear();
- cmd.Parameters.AddWithValue("@bednetid", bednetid);
- using(var reader = cmd.ExecuteReader())
- {
- if (reader.Read())
- {
- name_arr[0] += Convert.ToString(reader["erp_mtrlcode"]);
- }
- }
- }
- }
- if (FuncPowerHelper.CheckFuncPower(cmd, context.tokendata.userid, 98) && "super".Equals(context.tokendata.username.ToLower()))
- {
- interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}", 2, name_arr));
- }
- else
- {
- interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}", 1, name_arr));
- }
- interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}生产说明", 1, new string[] { "" }));
- interfaceList.Add(InserMattressInterfacePz("垫层", $"{chastr}-床网{count}包边海绵条", 1, new string[] { "" }));
- }
- /// <summary>
- /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层
- /// </summary>
- /// <param name="mx"></param>
- /// <param name="interfaceList"></param>
- /// <param name="chastr"></param>
- /// <param name="count"></param>
- private void ProcessWangMianBLPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, string typename, int count)
- {
- var name_arr = new string[5];
- var mtrlname_temp = mx.mtrlname;
- var chastr_temp = string.Empty;
- if ("顶布".Equals(typename) && count <= 1)
- {
- chastr_temp = $"{chastr}-{typename}";
- }
- else
- {
- chastr_temp = $"{chastr}-{typename}{count}";
- }
- if ((!mx.mtrlname.Contains("分") && mx.thickness > 0) || ("垫层".Equals(typename)))
- {
- mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
- }
- name_arr[0] = mtrlname_temp;
- interfaceList.Add(InserMattressInterfacePz("垫层", chastr_temp, 2, name_arr));
- }
- /// <summary>
- /// 顶布裥棉
- /// </summary>
- /// <param name="mx"></param>
- /// <param name="interfaceList"></param>
- /// <param name="count"></param>
- private void ProcessDingbuLianMianPz(u_mattress_mx_mtrl mx, List<u_mattress_interface> interfaceList, string chastr, int count)
- {
- string chastr_temp = string.Empty;
- string ls_temp = "";
- string[] name_arr = new string[5];
- if ("顶布裥棉1".Equals(mx.mtrlname))
- {
- chastr_temp = $"{chastr}-顶布裥棉";
- for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
- {
- name_arr[i] = DingBuLianMian[0, i];
- }
- }
- else if ("顶布裥棉2".Equals(mx.mtrlname))
- {
- chastr_temp = $"{chastr}-顶布裥棉2";
- for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
- {
- name_arr[i] = DingBuLianMian[1, i];
- }
- }
- else if ("顶布裥棉3".Equals(mx.mtrlname))
- {
- chastr_temp = $"{chastr}-顶布裥棉3";
- for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
- {
- name_arr[i] = DingBuLianMian[2, i];
- }
- }
- else if ("顶布裥棉4".Equals(mx.mtrlname))
- {
- chastr_temp = $"{chastr}-顶布裥棉4";
- for (int i = 0; i < DingBuLianMian.GetLength(0); i++)
- {
- name_arr[i] = DingBuLianMian[3, i];
- }
- }
- interfaceList.Add(InserMattressInterfacePz("垫层", chastr_temp, 2, name_arr));
- }
- private void AutoSetFormulaTypeTwoPz(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
- {
- var fuliaoList = mxlist.Where(t => t.formulatype == 2).ToList();
- var nameSet = new HashSet<string>(new string[] {
- "白色无字包角", "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "角网+拉链",
- "开箱刀+开箱说明", "开箱说明+开箱刀", "气钮", "吊标", "说明书", "斜标", "正标", "织唛",
- "织唛斜标", "客供标", "空白牛皮纸包角", "空白珍珠包角"
- });
- var extraSet = new HashSet<string>(new string[] { "采购小标", "打印小标", "合格证", "吊标", "斜标", "正标", "织唛", "织唛斜标", "客供标" });
- var specialSet = new HashSet<string>(new string[] { "打钮钮扣", "气钮" });
- foreach (var mx in fuliaoList)
- {
- if (mx.mtrlid > 0)
- {
- int cnt = Convert.ToInt32(Math.Abs(mx.qty.Value));
- // 处理特殊辅料
- if (specialSet.Contains(mx.mtrlname))
- {
- interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}", 1, new string[] { $"{cnt.ToString("#,##0.0#")}个" }));
- continue; // 跳过后续的处理
- }
- // 处理其他辅料
- if (nameSet.Contains(mx.mtrlname))
- {
- for (int i = 1; i <= cnt; i++)
- {
- // 添加辅料接口
- interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}", 1, new string[] { "" }));
- // 如果是额外的辅料,添加位置接口
- if (extraSet.Contains(mx.mtrlname))
- {
- interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}位置", 0, new string[] { "" }));
- }
- }
- }else if(mx.formulakind == 15 && !nameSet.Contains(mx.mtrlname))
- {
- for (int i = 1; i <= cnt; i++)
- {
- interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}", 1, new string[] { "" }));
- interfaceList.Add(InserMattressInterfacePz("辅料", $"{mx.mtrlname}{i}位置", 0, new string[] { "" }));
- }
- }
- }
- }
- }
- private void AutoSetFormulaTypeThreePz(u_mattress mattress, List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
- {
- // 筛选 formulatype 为 3 的物料
- var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
- var chastrDict = new Dictionary<int, string>
- {
- {16, "PE袋"},
- {17, "外层PE"},
- {18, "PVC"},
- {19, "卷包包装"},
- {20, "牛皮纸袋"},
- {21, "蓝色PE护角"},
- {22, "无纺布袋"},
- {23, "牛皮袋护角"},
- {24, "编织袋"},
- {27, "拉手脚轮"},
- {201, "无纺布护角"}
- };
- var countDict = new Dictionary<int, int>
- {
- {16, 0}
- };
- // 外观
- interfaceList.Add(InserMattressInterfacePz("包装", "包装方式", 1, new string[] { Enum.GetName(typeof(PackType), mattress.packtype) }));
- foreach (var mx in bzList)
- {
- if (mx.mtrlid > 0 && chastrDict.TryGetValue(mx.formulakind.GetValueOrDefault(), out var chastr))
- {
- var name_arr = new string[1];
- if (mx.qty.HasValue && mx.qty.Value > 1)
- {
- name_arr[0] = $"{mx.qty.Value.ToString("#,##0.0#")}个{mx.mtrlname}";
- }
- else
- {
- name_arr[0] = mx.mtrlname;
- }
- if (countDict.ContainsKey(mx.formulakind.Value))
- {
- chastr += countDict[mx.formulakind.Value];
- }
- // 添加包装信息
- interfaceList.Add(InserMattressInterfacePz("包装", chastr, 2, name_arr));
- }
- }
- // 压包数量
- interfaceList.Add(InserMattressInterfacePz("包装", "压包数量", 1, new string[] { $"{mattress.packqty.Value.ToString("#,##0.0#")}" }));
- // 包装说明
- interfaceList.Add(InserMattressInterfacePz("包装", "包装说明", 1, new string[] { "" }));
- // 压包说明
- if (mattress.packqty.HasValue && mattress.packqty.Value > 0) interfaceList.Add(InserMattressInterfacePz("包装", "压包说明", 1, new string[] { "" }));
- // 卷包说明
- if (mattress.diameter.HasValue && mattress.diameter.Value > 0) interfaceList.Add(InserMattressInterfacePz("包装", "卷包说明", 1, new string[] { "" }));
- }
- private void AutoSetFormulaType101Pz(u_mattress mattress, List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface> interfaceList)
- {
- var powerDict = new Dictionary<string, int[]>()
- {
- {"面裥绵",new int[] { 0, 40, 50, 60, 70 } },
- {"底裥绵",new int[] { 1, 41, 51, 61, 71 } },
- {"普通大侧",new int[] { 2, 42, 52, 62, 72 } }
- };
- var chastrDict = new Dictionary<string, string[]>()
- {
- {"面裥绵",new string[] { "内布套-面层裥棉", "内布套-面层裥棉裥棉图案" } },
- {"底裥绵",new string[] { "内布套-底层裥棉", "内布套-底层裥棉裥棉图案" } },
- {"普通大侧",new string[] { "内布套-大侧裥棉", "内布套-大侧裥棉裥棉图案" } }
- };
- foreach (var item in powerDict)
- {
- var name_arr = new string[5];
- foreach (var mx in mxlist)
- {
- SetFormulaTypeZeroPzName(mx, "内布套", item.Value, name_arr);
- }
- var sb = new StringBuilder();
- foreach (var name2 in name_arr)
- {
- sb.Append(name2);
- }
- if (sb.Length > 0)
- {
- interfaceList.Add(InserMattressInterfacePz("内布套", chastrDict[item.Key][0], 2, name_arr));
- interfaceList.Add(InserMattressInterfacePz("内布套", chastrDict[item.Key][1], 1, new string[] { "" }));
- }
- }
- // 内布套-围边边带 / 拉链
- foreach (var mx in mxlist)
- {
- if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 203)
- {
- interfaceList.Add(InserMattressInterfacePz("内布套", "内布套-围边边带", 2, new string[] { $"{mx.thickness.Value.ToString("#,##0.0#")}条共{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- else if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 202)
- {
- interfaceList.Add(InserMattressInterfacePz("内布套", "内布套-拉链", 2, new string[] { $"{mx.thickness.Value.ToString("#,##0.0#")}条共{mx.qty.Value.ToString("#,##0.0#")}米{mx.mtrlname}" }));
- }
- }
- if (mattress.if_n_butao == 1)
- {
- interfaceList.Add(InserMattressInterfacePz("内布套", "内布套做法说明", 1, new string[] { $"内布套面层向大侧覆盖{mattress.s_cover_qty.Value.ToString("#,##0.0#")}CM、内布套大侧向底层覆盖{mattress.z_cover_qty.Value.ToString("#,##0.0#")}CM、内布套底层向大侧覆盖{mattress.x_cover_qty.Value.ToString("#,##0.0#")}CM" }));
- }
- }
- #endregion
- #region 导入清单方法
- public List<u_mattress_interface_qd> RefreshMattressInterfaceQdList(int mattressid)
- {
- var qdList = new List<u_mattress_interface_qd>();
-
- ImportMattressInterfaceQdList(mattressid, qdList);
- MattressInterfaceFindERPPrdPf(qdList,null);
- return qdList;
- }
- /// <summary>
- /// wf_fine_erp_prdpf
- /// </summary>
- /// <param name="qdList"></param>
- /// <param name="interfaceList"></param>
- public void MattressInterfaceFindERPPrdPf(List<u_mattress_interface_qd> qdList,List<u_mattress_interface> interfaceList)
- {
- var mtrlidList = new List<int>();
- foreach (var mx in qdList)
- {
- // 带出有设置 的erp_mtrlid
- if (mx.erp_mtrlid == 0 && mx.mtrlid != null && mx.mtrlid > 0)
- {
- var mtrldef = new u_mtrl_price() { mtrlid = mx.mtrlid };
- if (DbSqlHelper.SelectOne(cmd, mtrldef, "erp_mtrlid") == 1)
- {
- mx.erp_mtrlid = mtrldef.erp_mtrlid;
- }
- }
- //
- if (mx.erp_mtrlid > 0)
- {
- mtrlidList.Add(mx.erp_mtrlid.Value);
- }
- }
- if (mtrlidList.Count > 0)
- {
- var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
- var parameters = new JObject();
- parameters.Add("mtrlids", JToken.FromObject(mtrlidList));
- var resultList = erpHelper.GetERPList<erp_mtrldef>("GetL1Mtrldef", parameters);
- if (resultList != null && resultList.Any())
- {
- foreach (var mx in qdList)
- {
- var result = resultList.FirstOrDefault(o => o.mtrlid == mx.erp_mtrlid);
- if (result != null)
- {
- mx.erp_mtrlcode = result.mtrlcode;
- mx.erp_mtrlname = result.mtrlname;
- mx.erp_mtrlmode = result.mtrlmode;
- mx.erp_unit = result.unit;
- mx.erp_mtrlengname = result.zxmtrlmode;
- }
- }
- }
- }
- //更新 二级明细项目 需要产品配置列表,此部分由前端完成
- if (interfaceList != null && interfaceList.Any())
- {
- // 使用 GroupBy 去重并选择第一个元素
- var distinctList = interfaceList
- .GroupBy(mb => mb.bj_pzname)
- .Select(g => g.First())
- .ToList();
- Dictionary<string, u_mattress_interface> interfaceDict = distinctList.ToDictionary(mb => mb.bj_pzname, mb => mb);
- foreach (var mx in qdList)
- {
- if (interfaceDict.TryGetValue(mx.bj_pzname, out var mb))
- {
- mx.bj_pzname_mx_mx = mb.bj_namemx;
- if (mx.ss_rate == 0) mx.ss_rate = mb.ss_rate;
- if (mx.ls_rate == 0) mx.ls_rate = mb.ls_rate;
- }
- }
- }
- }
- /// <summary>
- /// 导入产品清单
- /// </summary>
- /// <param name="mattressid"></param>
- /// <exception cref="LJCommonException"></exception>
- public void ImportMattressInterfaceQdList(int mattressid, List<u_mattress_interface_qd> qdList)
- {
- if (mattressid <= 0)
- {
- throw new LJCommonException("床垫id有误");
- }
- var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
- var mattress = mattressHelper.GetMattress(mattressid);
- var mattress_type = new u_mattress_type() { mattresstypeid = mattress.mattresstypeid };
- DbSqlHelper.SelectOne(cmd, mattress_type, "typename");
- var mxlist = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype IN (0,1,2,3,99,104)" });
- var mxlist_103 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 103" });
- var mxlist_101 = mattressHelper.GetMattressMxMtrl(mattressid, new List<string>() { "u_mattress_formula.formulatype = 101" });
- #region 面料类清单导入
- AutoSetFormulaTypeZeroPrdPf(mxlist, qdList);
- #endregion
- #region 垫层类清单导入
- AutoSetFormulaTypeOnePrdPf(mxlist, qdList);
- #endregion
- #region 辅料类清单导入
- AutoSetFormulaTypeTwoPrfPf(mxlist, qdList);
- #endregion
- #region 包装类清单导入
- AutoSetFormulaTypeThreePrdPf(mxlist, qdList);
- #endregion
- #region 内布套类清单导入
- AutoSetFormulaType101PrdPf(mxlist_103, qdList);
- #endregion
- // 最后初始化interfaceList的printid
- for (var i = 0; i < qdList.Count; i++)
- {
- qdList[i].printid = i + 1;
- }
- }
- /// <summary>
- /// 初始化清单信息
- /// </summary>
- /// <param name="itemname"></param>
- /// <param name="bj_pzname"></param>
- /// <param name="inputtype"></param>
- /// <param name="names"></param>
- /// <returns></returns>
- public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx, int mtrlid, decimal useqty)
- {
- var mattress_interface_qd = new u_mattress_interface_qd()
- {
- itemname = itemname,
- bj_pzname = bj_pzname,
- bj_pzname_mx = namemx,
- mtrlid = mtrlid,
- useqty = useqty
- };
- return mattress_interface_qd;
- }
- public u_mattress_interface_qd InserMattressInterfacePrdPf(string itemname, string bj_pzname, string namemx)
- {
- var mattress_interface_qd = new u_mattress_interface_qd()
- {
- itemname = itemname,
- bj_pzname = bj_pzname,
- bj_pzname_mx = namemx
- };
- return mattress_interface_qd;
- }
- private void AutoSetFormulaTypeZeroPrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
- {
- var powerDict = new Dictionary<string, int[]>()
- {
- {"面裥绵",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"底裥绵",new int[] { 1, 41, 51, 61, 71, 81 } },
- {"顶布裥棉1",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"顶布裥棉2",new int[] { 0, 40, 50, 60, 70, 80 } },
- {"普通大侧",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"上下拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧1",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧2",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"左右拼侧3",new int[] { 2, 42, 52, 62, 72, 82 } },
- {"小侧1_EMPTY",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧1",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧1-上下拼侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
- {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
- {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
- };
- var chastrArrDict = new Dictionary<string, string[]>()
- {
- {"面裥绵",new string[] { "裥面", "面层裥棉", "面层裥面说明" } },
- {"底裥绵",new string[] { "裥底", "底层裥棉", "底层裥棉说明" } },
- {"顶布裥棉1",new string[] { "顶布裥棉", "顶布裥棉1" } },
- {"顶布裥棉2",new string[] { "顶布裥棉", "顶布裥棉2" } },
- {"普通大侧",new string[] { "大侧", "大侧裥棉"} },
- {"上下拼侧1",new string[] {"大侧", "大侧-上下拼侧1"} },
- {"上下拼侧2",new string[] { "大侧", "大侧-上下拼侧2" } },
- {"上下拼侧3",new string[] { "大侧", "大侧-上下拼侧3" } },
- {"左右拼侧1",new string[] { "大侧", "大侧-左右拼侧1"} },
- {"左右拼侧2",new string[] { "大侧", "大侧-左右拼侧2"} },
- {"左右拼侧3",new string[] { "大侧", "大侧-左右拼侧3" ,"大侧说明" } },
- {"小侧1_EMPTY",new string[] { "小侧", "小侧1裥棉" } },
- {"小侧1",new string[] { "小侧", "小侧1裥棉"} },
- {"小侧1-上下拼侧1",new string[] { "小侧", "小侧1-上下拼侧1裥棉" } },
- {"小侧1-上下拼侧2",new string[] { "小侧", "小侧1-上下拼侧2裥棉" } },
- {"小侧1-上下拼侧3",new string[] { "小侧", "小侧1-上下拼侧3裥棉" } },
- {"小侧2",new string[] { "小侧", "小侧2裥棉", "小侧2裥棉图案" } },
- {"小侧3",new string[] { "小侧", "小侧3裥棉", "小侧3裥棉图案", "小侧说明" } },
- {"V侧1_EMPTY",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
- {"V侧1",new string[] { "V侧", "V侧1裥棉", "V侧1裥棉图案" } },
- {"V侧2",new string[] { "V侧", "V侧2裥棉", "V侧2裥棉图案" } },
- {"V侧3",new string[] { "V侧", "V侧3裥棉", "V侧3裥棉图案", "V侧说明" } }
- };
- var extreDict = new HashSet<string>() { "小侧", "V侧" };
- var jianmianList = mxlist.Where(t => t.formulatype == 0).ToList();
- var isEnter = false;
- #region wf_import_qingdan_prdpf
- foreach (var item in powerDict)
- {
- // 保证清单列表类别一致,从面裥绵 -> V侧3
- foreach (var mx in jianmianList)
- {
- if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
- {
- if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
- }
- }
- }
- if(item.Key.Contains("小侧3") || item.Key.Contains("V侧3"))
- {
- var list = qdList.FindAll(t => extreDict.Contains(t.itemname)).ToList();
- if(list.Any())
- {
- foreach (var name in chastrArrDict[item.Key])
- {
- if (name.Contains("说明"))
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
- }
- }
- }
- } else
- {
- foreach (var name in chastrArrDict[item.Key])
- {
- if (name.Contains("说明"))
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], name, ""));
- }
- }
- }
- }
- #endregion
- #region wf_import_qingdan_next 面料部分
- // 按照 formulakind 分组
- var grouped = jianmianList
- .Where(t => t.formulakind >= 5 && t.formulakind <= 10)
- .GroupBy(t => t.formulakind);
- // 需要处理的组的名称与编号映射
- var groupNames = new Dictionary<int, string>
- {
- { 5, "拉手" },
- { 6, "刺绣" },
- { 7, "大侧压压布" },
- { 8, "大侧压边带" },
- { 9, "大侧压织带" },
- { 10, "大侧压上下压线" }
- };
- // 处理每一组
- foreach (var group in grouped)
- {
- var formulakind = group.Key.Value;
- var name = groupNames.ContainsKey(formulakind) ? groupNames[formulakind] : "未知组";
- foreach (var mx in group)
- {
- if (string.IsNullOrEmpty(mx.chastr) && mx.mtrlid > 0)
- {
- qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺",$"{name}{group.ToList().IndexOf(mx) + 1}","",
- mx.mtrlid.Value,
- mx.useqty.Value
- ));
- }
- }
- }
- // 统一添加固定项
- qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手刺绣", ""));
- qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "拉手无纺布", ""));
- qdList.Add(InserMattressInterfacePrdPf("拉手刺绣及其他工艺", "侧刺绣做法", ""));
- #endregion
- }
- private void AutoSetFormulaTypeOnePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
- {
- var diancengList = mxlist.Where(t => t.formulatype == 1).ToList();
- var kindDict = new Dictionary<int, string>()
- {
- { 32,"垫层" },
- { 12,"顶布" },
- { 13,"毡类" },
- { 14,"打底无纺布" },
- { 29,"网面布料" },
- { 999,"床网" }
- };
- var chastrSet = new HashSet<string>() { "大侧", "小侧1", "小侧2", "小侧3", "V侧1", "V侧2", "V侧3" };
- var countDict = new Dictionary<string, int>();
- foreach (var cha in chastrSet)
- {
- foreach (var kind in kindDict)
- {
- countDict.Add($"{cha}-{kind.Value}", 0);
- }
- }
- foreach (var mx in diancengList)
- {
- var key = $"{mx.chastr}-{kindDict[mx.formulakind.Value]}";
- if (mx.mtrlid > 0 && new int[] { 32, 12, 13, 14, 29 }.Contains(mx.formulakind.Value))
- {
- this.ProcessWangMianBLPrdPf(mx, qdList, mx.chastr, kindDict[mx.formulakind.Value], ++countDict[key]);
- }
- if (mx.formulakind == 999)
- {
- this.ProcessChuangWangPrdPf(mx, qdList, mx.chastr, ++countDict[key]);
- }
- }
- // 顶布裥面说明
- qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明1", ""));
- qdList.Add(InserMattressInterfacePrdPf("顶布裥棉", "顶布裥面说明2", ""));
- }
- /// <summary>
- /// 床网
- /// </summary>
- /// <param name="mx"></param>
- /// <param name="interfaceList"></param>
- /// <param name="chastr"></param>
- /// <param name="count"></param>
- private void ProcessChuangWangPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, int count)
- {
- var namepz = string.Empty;
- int bednetid = 0;
- cmd.CommandText = @"SELECT u_bednetmx.bednet_height,u_bednetmx.bednetid
- FROM u_bednetmx
- INNER JOIN (
- SELECT mtrlid
- FROM u_mattress_mx_mtrl
- INNER JOIN u_mattress_formula ON u_mattress_formula.formulaid = u_mattress_mx_mtrl.formulaid
- WHERE u_mattress_formula.formulakind = 99
- AND u_mattress_mx_mtrl.mattressid = @mattressid
- AND u_mattress_mx_mtrl.mtrlid > 0
- ) v_mattress_mx_mtrl ON u_bednetmx.bednetid = v_mattress_mx_mtrl.mtrlid";
- cmd.Parameters.Clear();
- cmd.Parameters.AddWithValue("@mattressid", mx.mattressid);
- using (var reader = cmd.ExecuteReader())
- {
- while (reader.Read())
- {
- decimal height = Convert.ToDecimal(reader["bednet_height"]);
- if (height == mx.thickness) bednetid = Convert.ToInt32(reader["bednetid"]);
- }
- }
- if (bednetid > 0)
- {
- // 获取床网清单
- var bednetList = new List<u_bednetmx>();
- if (bednetList.Any())
- {
- var bednetHelper = HelperBase.GetHelper<BedNetHelper>(cmd);
- var bednetQdList = bednetHelper.GetBedNetQingDan(bednetid);
- if (bednetQdList.Any())
- {
- namepz = bednetQdList[0].pznamemx;
- }
- }
- }
- qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-床网{count}", namepz, mx.mtrlid.Value, mx.useqty.Value));
- // 海绵条*4 2
- qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条1", ""));
- qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条2", ""));
- qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条3", ""));
- qdList.Add(InserMattressInterfacePrdPf("垫层", "海绵条4", ""));
- }
- /// <summary>
- /// 网面布料 / 打底无纺布 / 毡类 / 顶布 / 垫层
- /// </summary>
- /// <param name="mx"></param>
- /// <param name="interfaceList"></param>
- /// <param name="chastr"></param>
- /// <param name="count"></param>
- private void ProcessWangMianBLPrdPf(u_mattress_mx_mtrl mx, List<u_mattress_interface_qd> qdList, string chastr, string typename, int count)
- {
- var mtrlname_temp = mx.mtrlname;
- if ((!mx.mtrlname.Contains("分") && mx.thickness > 0) || ("垫层".Equals(typename)))
- {
- mtrlname_temp = $"{mx.thickness.Value.ToString("#,##0.0#")}分{mx.mtrlname}";
- }
- qdList.Add(InserMattressInterfacePrdPf("垫层", $"{chastr}-{typename}{count}", "",mx.mtrlid.Value,mx.useqty.Value));
- }
- private void AutoSetFormulaTypeTwoPrfPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
- {
- var fuliaoList = mxlist.Where(t => t.formulatype == 2).ToList();
- var nameSet = new HashSet<string>(new string[] {
- "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
- "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标"
- });
- var extraSet = new HashSet<string>(new string[] { "保用卡", "采购小标", "打钮钮扣", "打印小标", "合格证", "画纸", "开箱说明+开箱刀", "吊标", "客供标",
- "空白牛皮纸包角", "空白珍珠包角", "气钮","说明书","斜标","正标","织唛","织唛斜标","角网+拉链","开箱刀+开箱说明" });
- var specialSet = new HashSet<string>(new string[] { "打钮钮扣", "气钮" });
- foreach (var mx in fuliaoList)
- {
- if (mx.mtrlid > 0)
- {
- int cnt = Convert.ToInt32(Math.Abs(mx.qty.Value));
- // 处理特殊辅料
- if (specialSet.Contains(mx.mtrlname))
- {
- qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}", "", mx.mtrlid.Value, mx.useqty.Value));
- continue; // 跳过后续的处理
- }
- // 处理其他辅料
- if (nameSet.Contains(mx.mtrlname))
- {
- for (int i = 1; i <= cnt; i++)
- {
- // 添加辅料接口
- qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "",mx.mtrlid.Value,mx.useqty.Value));
- }
- } else if(mx.formulakind == 15 && !extraSet.Contains(mx.mtrlname))
- {
- for (int i = 1; i <= cnt; i++)
- {
- // 添加辅料接口
- qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}", "", mx.mtrlid.Value, mx.useqty.Value));
- // 如果是额外的辅料,添加位置接口
- qdList.Add(InserMattressInterfacePrdPf("辅料", $"{mx.mtrlname}{i}位置", "", mx.mtrlid.Value, mx.useqty.Value));
- }
- }
- }
- }
- }
- private void AutoSetFormulaTypeThreePrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
- {
- // 筛选 formulatype 为 3 的物料
- var bzList = mxlist.Where(t => t.formulatype == 3).ToList();
- var chastrDict = new Dictionary<int, string>
- {
- {16, "PE袋"},
- {17, "外层PE"},
- {18, "PVC"},
- {19, "卷包包装"},
- {20, "牛皮纸袋"},
- {21, "蓝色PE护角"},
- {22, "无纺布袋"},
- {23, "牛皮袋护角"},
- {24, "编织袋"},
- {27, "拉手脚轮"},
- {201, "无纺布护角"}
- };
- var countDict = new Dictionary<int, int>
- {
- {16, 0}
- };
- foreach (var mx in bzList)
- {
- if (mx.mtrlid > 0 && chastrDict.TryGetValue(mx.formulakind.GetValueOrDefault(), out var chastr))
- {
- var name_arr = new string[1];
- if (mx.qty.HasValue && mx.qty.Value > 1)
- {
- name_arr[0] = $"{mx.qty.Value.ToString("#,##0.0#")}个{mx.mtrlname}";
- }
- else
- {
- name_arr[0] = mx.mtrlname;
- }
- if (countDict.ContainsKey(mx.formulakind.Value))
- {
- chastr += countDict[mx.formulakind.Value];
- }
- // 添加包装信息
- qdList.Add(InserMattressInterfacePrdPf("包装", chastr,"",mx.mtrlid.Value,mx.useqty.Value));
- }
- }
- // 包装说明
- qdList.Add(InserMattressInterfacePrdPf("包装", "包装说明", ""));
- // 车位说明
- qdList.Add(InserMattressInterfacePrdPf("车位说明", "车位说明", ""));
- }
- private void AutoSetFormulaType101PrdPf(List<u_mattress_mx_mtrl> mxlist, List<u_mattress_interface_qd> qdList)
- {
- var powerDict = new Dictionary<string, int[]>()
- {
- {"面裥绵",new int[] { 0, 40, 50, 60, 70,80 } },
- {"底裥绵",new int[] { 1, 41, 51, 61, 71 } },
- {"普通大侧",new int[] { 2, 42, 52, 62, 72 } }
- };
- var chastrDict = new Dictionary<string, string[]>()
- {
- {"面裥绵",new string[] { "内布套-面层裥棉", "内布套-面层裥棉裥棉图案" } },
- {"底裥绵",new string[] { "内布套-底层裥棉", "内布套-底层裥棉裥棉图案" } },
- {"普通大侧",new string[] { "内布套-大侧裥棉", "内布套-大侧裥棉裥棉图案" } }
- };
- foreach (var item in powerDict)
- {
- var name_arr = new string[5];
- foreach (var mx in mxlist)
- {
- if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
- {
- if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value));
- }
- if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
- {
- qdList.Add(InserMattressInterfacePrdPf(chastrDict[item.Key][0], chastrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value));
- }
- }
- }
- }
- // 内布套-围边边带 / 拉链
- foreach (var mx in mxlist)
- {
- if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 203)
- {
- qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-围边边带", "围边",mx.mtrlid.Value,mx.useqty.Value));
- }
- else if (mx.mtrlid > 0 && "内布套".Equals(mx.chastr) && mx.formulakind == 202)
- {
- qdList.Add(InserMattressInterfacePrdPf("内布套", "内布套-拉链", "拉链", mx.mtrlid.Value, mx.useqty.Value));
- }
- }
- }
- #endregion
- #region 通用方法
- /// <summary>
- /// 用于 字符串 + 字符串格式
- /// </summary>
- /// <param name="currentString"></param>
- /// <param name="newPart"></param>
- /// <returns></returns>
- private string AppendToString(string currentString, string newPart)
- {
- if (string.IsNullOrEmpty(currentString))
- {
- return newPart;
- }
- else
- {
- return currentString + " + " + newPart;
- }
- }
- /// <summary>
- /// 数量分割字符串
- /// </summary>
- /// <param name="name"></param>
- /// <param name="qty"></param>
- /// <returns></returns>
- private string SplitNameCount(string name, int qty)
- {
- if (qty <= 1) return name;
- var result = name;
- result = AppendToString(result, SplitNameCount(name, --qty));
- return result;
- }
- #endregion
- #region 全局变量
- // 储存顶布裥棉数据
- private string[,] DingBuLianMian = new string[4,5];
- private enum PackType
- {
- 压包 = 0,
- 卷包,
- 国内
- }
- #endregion
- }
- }
|