1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630 |
- 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)
- {
- erp_cmd.CommandText = @"SELECT u_configure_code.pzid
- ,u_configure_code.pzcode
- ,u_configure_code.name
- ,u_configure_code.inputtype
- FROM u_configure_code
- WHERE u_configure_code.typeid = @configcodetype
- AND u_configure_code.ifpack = 1";
- erp_cmd.Parameters.Clear();
- erp_cmd.Parameters.AddWithValue("@configcodetype", mattress.erp_configcodetype);
- using (var reader = erp_cmd.ExecuteReader())
- {
- while (reader.Read())
- {
- var pzname = Convert.ToString(reader["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)
- {
- for (var i = 0; i < interfaceList.Count; i++)
- {
- interfaceList[i].printid = i + 1;
- erp_cmd.CommandText = @"SELECT u_configure_code.pzid
- ,u_configure_code.pzcode
- ,u_configure_code.name
- ,u_configure_code.inputtype
- FROM u_configure_code
- WHERE u_configure_code.typeid = @configcodetype
- AND u_configure_code.name = @pzname";
- erp_cmd.Parameters.Clear();
- erp_cmd.Parameters.AddWithValue("@configcodetype", mattress.erp_configcodetype);
- erp_cmd.Parameters.AddWithValue("@pzname", interfaceList[i].bj_pzname);
- using (var reader = erp_cmd.ExecuteReader())
- {
- if (reader.Read())
- {
- var pzid = Convert.ToInt32(reader["pzid"]);
- var pzname = Convert.ToString(reader["name"]);
- var pzcode = Convert.ToString(reader["pzcode"]);
- var inputtype = Convert.ToByte(reader["inputtype"]);
- if (pzid > 0)
- {
- interfaceList[i].erp_pzid = pzid;
- interfaceList[i].erp_pzcode = pzcode;
- interfaceList[i].erp_pzname = pzname;
- }
- if (interfaceList[i].bj_inputtype != 2) interfaceList[i].bj_inputtype = 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)
- {
- 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;
- }
- }
- }
- foreach(var mx in qdList)
- {
- if(mx.erp_mtrlid > 0)
- {
- erp_cmd.CommandText = @"SELECT mtrlid
- ,mtrlcode
- ,mtrlname
- ,mtrlmode
- ,unit
- ,dftwrkgrpid
- ,mtrlengname
- ,zxmtrlmode
- FROM u_mtrldef
- WHERE mtrlid = @mtrlid";
- erp_cmd.Parameters.Clear();
- erp_cmd.Parameters.AddWithValue("@mtrlid", mx.erp_mtrlid);
- using (var reader = erp_cmd.ExecuteReader())
- {
- if (reader.Read())
- {
- mx.erp_mtrlcode = Convert.ToString(reader["mtrlcode"]);
- mx.erp_mtrlname = Convert.ToString(reader["mtrlname"]);
- mx.erp_mtrlmode = Convert.ToString(reader["mtrlmode"]);
- mx.erp_unit = Convert.ToString(reader["unit"]);
- mx.erp_mtrlengname = Convert.ToString(reader["zxmtrlmode"]);
- }
- }
- }
- }
- //更新 二级明细项目 需要产品配置列表,此部分由前端完成
- if(interfaceList != null && interfaceList.Any())
- {
- Dictionary<string, u_mattress_interface> interfaceDict = interfaceList.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
- }
- }
|