12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676 |
- 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)
- {
- 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;
- // }
- //}
- 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_pzname", interfaceList[i].bj_pzname);
- parameters.Add("queryparams", queryparams);
- var resultList = erpHelper.GetERPList<erp_configure_code>("CommonDynamicSelect", parameters);
- foreach (var result in resultList)
- {
- //var pzid = Convert.ToInt32(result["pzid"]);
- //var pzname = Convert.ToString(result["name"]);
- //var pzcode = Convert.ToString(result["pzcode"]);
- //var inputtype = Convert.ToByte(result["inputtype"]);
- 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)
- {
- 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"]);
- // }
- //}
- var erpHelper = HelperBase.GetHelper<ERPHelper>(null);
- var parameters = new JObject();
- parameters.Add("mtrlid", mx.erp_mtrlid);
- var resultList = erpHelper.GetERPList<erp_mtrldef>("GetL1Mtrldef", parameters);
- if(resultList != null && resultList.Any())
- {
- foreach(var result in resultList)
- {
- 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())
- {
- 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
- }
- }
|